Bug 1229220 - Update the scrollbar visibility prefs when initializing a TabChild; r=smaug

This will make sure that window.scrollbars correctly reflects the respective
chrome flags in e10s mode.

We also update nsXULWindow::SetContentScrollbarVisibility() to the new
nsContentUtils helper.  That code is responsible for doing this work in the
single process case.
This commit is contained in:
Ehsan Akhgari 2016-03-11 18:10:13 -05:00
parent f6d36d05d1
commit ce1ef38b75
7 changed files with 30 additions and 29 deletions

View File

@ -287,23 +287,7 @@ ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv)
and because embedding apps have no interface for implementing this
themselves, and therefore the implementation must be internal. */
nsCOMPtr<nsIScrollable> scroller =
do_QueryInterface(mDOMWindow->GetDocShell());
if (scroller) {
int32_t prefValue;
if (aVisible) {
prefValue = nsIScrollable::Scrollbar_Auto;
} else {
prefValue = nsIScrollable::Scrollbar_Never;
}
scroller->SetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_Y, prefValue);
scroller->SetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_X, prefValue);
}
nsContentUtils::SetScrollbarsVisibility(mDOMWindow->GetDocShell(), aVisible);
/* Notably absent is the part where we notify the chrome window using
GetBrowserChrome()->SetChromeFlags(). Given the possibility of multiple

View File

@ -156,6 +156,7 @@
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsIScrollable.h"
#include "nsIStreamConverterService.h"
#include "nsIStringBundle.h"
#include "nsIURI.h"
@ -8996,3 +8997,24 @@ nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri)
uri->GetSpec(spec);
return spec.EqualsASCII(aUri);
}
/* static */ void
nsContentUtils::SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible)
{
nsCOMPtr<nsIScrollable> scroller = do_QueryInterface(aDocShell);
if (scroller) {
int32_t prefValue;
if (aVisible) {
prefValue = nsIScrollable::Scrollbar_Auto;
} else {
prefValue = nsIScrollable::Scrollbar_Never;
}
scroller->SetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_Y, prefValue);
scroller->SetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_X, prefValue);
}
}

View File

@ -2582,6 +2582,8 @@ public:
*/
static bool IsSpecificAboutPage(JSObject* aGlobal, const char* aUri);
static void SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible);
private:
static bool InitializeEventTable();

View File

@ -841,6 +841,9 @@ TabChild::Init()
do_QueryInterface(window->GetChromeEventHandler());
docShell->SetChromeEventHandler(chromeHandler);
nsContentUtils::SetScrollbarsVisibility(window->GetDocShell(),
!!(mChromeFlags & nsIWebBrowserChrome::CHROME_SCROLLBARS));
nsWeakPtr weakPtrThis = do_GetWeakReference(static_cast<nsITabChild*>(this)); // for capture by the lambda
ContentReceivedInputBlockCallback callback(
[weakPtrThis](const ScrollableLayerGuid& aGuid,

View File

@ -9,7 +9,6 @@ support-files =
geo_leak_test.html
[browser_test_toolbars_visibility.js]
skip-if = e10s
support-files =
test_new_window_from_content_child.html
[browser_bug1008941_dismissGeolocationHanger.js]

View File

@ -165,7 +165,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #Windows can't change size on Android # b2g(Windows can't change size on B2G) b2g-debug(Windows can't change size on B2G) b2g-desktop(Windows can't change size on B2G)
[test_toJSON.html]
[test_window_bar.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
[test_bug1022869.html]
[test_bug1112040.html]
[test_bug1160342_marquee.html]

View File

@ -2091,16 +2091,7 @@ void nsXULWindow::SetContentScrollbarVisibility(bool aVisible)
return;
}
MOZ_ASSERT(contentWin->IsOuterWindow());
if (nsPIDOMWindowInner* innerWindow = contentWin->GetCurrentInnerWindow()) {
mozilla::ErrorResult rv;
RefPtr<nsGlobalWindow> window = static_cast<nsGlobalWindow*>(reinterpret_cast<nsPIDOMWindow<nsISupports>*>(innerWindow));
RefPtr<mozilla::dom::BarProp> scrollbars = window->GetScrollbars(rv);
if (scrollbars) {
scrollbars->SetVisible(aVisible, rv);
}
}
nsContentUtils::SetScrollbarsVisibility(contentWin->GetDocShell(), aVisible);
}
bool nsXULWindow::GetContentScrollbarVisibility()