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 2071598a2f
commit af67a93015
9 changed files with 38 additions and 32 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

@@ -63,7 +63,7 @@ function nextTest() {
function runNextTest() {
if (gTestIndex < gTestWindows.length) {
info("Run test " + gTestWindows[gTestIndex]);
testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500");
testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500,scrollbars=yes");
// We'll wait for the window to load, then make sure our window is refocused
// before starting the test, which will get kicked off on "focus".
// This ensures that we're essentially back on the primary "desktop" on

View File

@@ -842,6 +842,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

@@ -48,7 +48,8 @@ function testWindow(w)
}
else {
// w.location.search == '?true' if we expect the bars to be on, and
// '?false' otherwise.
// '?false' otherwise. By default, no bars are enabled, so '?default'
// can be handled the same way as '?false'.
var enabled = w.location.search == '?true';
is(w[feature].visible, enabled, feature + ' should follow window.open settings.');
}
@@ -64,7 +65,7 @@ function testWindow(w)
w.close();
numWindows++;
if (numWindows == 2) {
if (numWindows == 3) {
// We're done!
SimpleTest.finish();
}
@@ -87,6 +88,10 @@ var noBarsWindow =
'personalbar=no,status=no,scrollbars=no',
false);
var defaultWindow =
window.open('file_window_bar.html?default', 'default-bars',
'width=500,height=500', false);
</script>
</pre>
</body>

View File

@@ -2100,16 +2100,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()