From fcb90264ce3dd36ff36671d9b446f8190ca7070a Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Sun, 23 Jan 2011 20:21:40 -0800 Subject: [PATCH] By default, disable MozAfterPaint for content. (Bug 608030) r=roc a=blocking2.0:betaN+ --- build/automation.py.in | 1 + layout/base/nsPresContext.cpp | 28 ++++- layout/base/nsPresContext.h | 1 + layout/base/tests/Makefile.in | 1 + layout/base/tests/test_after_paint_pref.html | 126 +++++++++++++++++++ layout/tools/reftest/reftest-cmdline.js | 1 + modules/libpref/src/init/all.js | 2 + 7 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 layout/base/tests/test_after_paint_pref.html diff --git a/build/automation.py.in b/build/automation.py.in index 2bd5844f76f..b292a67f63b 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -339,6 +339,7 @@ user_pref("dom.disable_open_during_load", false); user_pref("dom.max_script_run_time", 0); // no slow script dialogs user_pref("dom.max_chrome_script_run_time", 0); user_pref("dom.popup_maximum", -1); +user_pref("dom.send_after_paint_to_content", true); user_pref("dom.successive_dialog_time_limit", 0); user_pref("signed.applets.codebase_principal_support", true); user_pref("security.warn_submit_insecure", false); diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index b48f0b3afa2..875222413d5 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -229,6 +229,7 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType) mActiveLinkColor = NS_RGB(0xEE, 0x00, 0x00); mVisitedLinkColor = NS_RGB(0x55, 0x1A, 0x8B); mUnderlineLinks = PR_TRUE; + mSendAfterPaintToContent = PR_FALSE; mFocusTextColor = mDefaultColor; mFocusBackgroundColor = mBackgroundColor; @@ -303,6 +304,9 @@ nsPresContext::~nsPresContext() #ifdef IBMBIDI nsContentUtils::UnregisterPrefCallback("bidi.", PrefChangedCallback, this); #endif // IBMBIDI + nsContentUtils::UnregisterPrefCallback("dom.send_after_paint_to_content", + nsPresContext::PrefChangedCallback, + this); nsContentUtils::UnregisterPrefCallback("gfx.font_rendering.", nsPresContext::PrefChangedCallback, this); @@ -649,6 +653,10 @@ nsPresContext::GetUserPreferences() // * document colors GetDocumentColorPreferences(); + mSendAfterPaintToContent = + nsContentUtils::GetBoolPref("dom.send_after_paint_to_content", + mSendAfterPaintToContent); + // * link colors mUnderlineLinks = nsContentUtils::GetBoolPref("browser.underline_anchors", mUnderlineLinks); @@ -956,6 +964,9 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext) nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback, this); #endif + nsContentUtils::RegisterPrefCallback("dom.send_after_paint_to_content", + nsPresContext::PrefChangedCallback, + this); nsContentUtils::RegisterPrefCallback("gfx.font_rendering.", PrefChangedCallback, this); nsContentUtils::RegisterPrefCallback("layout.css.dpi", @@ -2092,13 +2103,20 @@ nsPresContext::FireDOMPaintEvent() nsCOMPtr dispatchTarget = do_QueryInterface(ourWindow); nsCOMPtr eventTarget = dispatchTarget; if (!IsChrome()) { - PRBool isCrossDocOnly = PR_TRUE; - for (PRUint32 i = 0; i < mInvalidateRequests.mRequests.Length(); ++i) { - if (!(mInvalidateRequests.mRequests[i].mFlags & nsIFrame::INVALIDATE_CROSS_DOC)) { - isCrossDocOnly = PR_FALSE; + PRBool notifyContent = mSendAfterPaintToContent; + + if (notifyContent) { + // If the pref is set, we still don't post events when they're + // entirely cross-doc. + notifyContent = PR_FALSE; + for (PRUint32 i = 0; i < mInvalidateRequests.mRequests.Length(); ++i) { + if (!(mInvalidateRequests.mRequests[i].mFlags & + nsIFrame::INVALIDATE_CROSS_DOC)) { + notifyContent = PR_TRUE; + } } } - if (isCrossDocOnly) { + if (!notifyContent) { // Don't tell the window about this event, it should not know that // something happened in a subdocument. Tell only the chrome event handler. // (Events sent to the window get propagated to the chrome event handler diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index c07fa83b8c9..9e674516aef 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -1121,6 +1121,7 @@ protected: unsigned mUseDocumentFonts : 1; unsigned mUseDocumentColors : 1; unsigned mUnderlineLinks : 1; + unsigned mSendAfterPaintToContent : 1; unsigned mUseFocusColors : 1; unsigned mFocusRingOnAnything : 1; unsigned mFocusRingStyle : 1; diff --git a/layout/base/tests/Makefile.in b/layout/base/tests/Makefile.in index 06c442b17dd..e9d1232be92 100644 --- a/layout/base/tests/Makefile.in +++ b/layout/base/tests/Makefile.in @@ -66,6 +66,7 @@ _TEST_FILES = \ bug369950-subframe.xml \ bug495648.rdf \ decoration_line_rendering.js \ + test_after_paint_pref.html \ test_border_radius_hit_testing.html \ test_bug66619.html \ test_bug114649.html \ diff --git a/layout/base/tests/test_after_paint_pref.html b/layout/base/tests/test_after_paint_pref.html new file mode 100644 index 00000000000..0ff22d3d861 --- /dev/null +++ b/layout/base/tests/test_after_paint_pref.html @@ -0,0 +1,126 @@ + + + + + Test for MozAfterPaint pref Bug 608030 + + + + + +Mozilla Bug 608030 +
+
+
+
+ + diff --git a/layout/tools/reftest/reftest-cmdline.js b/layout/tools/reftest/reftest-cmdline.js index 41b99771caf..ec4bc2bfa36 100644 --- a/layout/tools/reftest/reftest-cmdline.js +++ b/layout/tools/reftest/reftest-cmdline.js @@ -107,6 +107,7 @@ RefTestCmdLineHandler.prototype = branch.setBoolPref("gfx.color_management.force_srgb", true); branch.setBoolPref("browser.dom.window.dump.enabled", true); branch.setIntPref("ui.caretBlinkTime", -1); + branch.setBoolPref("dom.send_after_paint_to_content", true); // no slow script dialogs branch.setIntPref("dom.max_script_run_time", 0); branch.setIntPref("dom.max_chrome_script_run_time", 0); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index cceac5849c6..a06a109c90a 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -570,6 +570,8 @@ pref("dom.disable_open_click_delay", 1000); pref("dom.storage.enabled", true); pref("dom.storage.default_quota", 5120); +pref("dom.send_after_paint_to_content", false); + // Timeout clamp in ms for timeouts we clamp pref("dom.min_timeout_value", 10);