diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 748413a5c8fa..27d8d7e00814 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -728,6 +728,7 @@ pref("font.size.inflation.disabledInMasterProcess", true); pref("memory.free_dirty_pages", true); pref("layout.imagevisibility.enabled", false); +pref("layout.imagevisibility.enabled_for_browser_elements_only", true); pref("layout.imagevisibility.numscrollportwidths", 1); pref("layout.imagevisibility.numscrollportheights", 1); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index e7174433985f..7476f5ca108b 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -5383,16 +5383,22 @@ bool PresShell::AssumeAllImagesVisible() { static bool sImageVisibilityEnabled = true; + static bool sImageVisibilityEnabledForBrowserElementsOnly = false; static bool sImageVisibilityPrefCached = false; if (!sImageVisibilityPrefCached) { Preferences::AddBoolVarCache(&sImageVisibilityEnabled, - "layout.imagevisibility.enabled", true); + "layout.imagevisibility.enabled", true); + Preferences::AddBoolVarCache(&sImageVisibilityEnabledForBrowserElementsOnly, + "layout.imagevisibility.enabled_for_browser_elements_only", false); sImageVisibilityPrefCached = true; } - if (!sImageVisibilityEnabled || !mPresContext || !mDocument) + if ((!sImageVisibilityEnabled && + !sImageVisibilityEnabledForBrowserElementsOnly) || + !mPresContext || !mDocument) { return true; + } // We assume all images are visible in print, print preview, chrome, xul, and // resource docs and don't keep track of them. @@ -5404,6 +5410,15 @@ PresShell::AssumeAllImagesVisible() return true; } + if (!sImageVisibilityEnabled && + sImageVisibilityEnabledForBrowserElementsOnly) { + nsCOMPtr container = mPresContext->GetContainer(); + nsCOMPtr docshell(do_QueryInterface(container)); + if (!docshell || !docshell->GetIsInBrowserElement()) { + return true; + } + } + return false; } diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 9685d521d076..ab9d5e96435c 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -550,7 +550,13 @@ pref("nglayout.debug.paint_flashing_chrome", false); // BasicLayers (other layer managers always update the entire widget area) pref("nglayout.debug.widget_update_flashing", false); +// Whether image visibility is enabled globally (ie we will try to unlock images +// that are not visible). pref("layout.imagevisibility.enabled", true); +// Whether image visibility is enabled in documents that are within a browser +// element as defined by nsDocShell::FrameType and GetInheritedFrameType. This +// pref only has an effect if layout.imagevisibility.enabled is false. +pref("layout.imagevisibility.enabled_for_browser_elements_only", false); pref("layout.imagevisibility.numscrollportwidths", 0); pref("layout.imagevisibility.numscrollportheights", 1);