By default, disable MozAfterPaint for content. (Bug 608030) r=roc a=blocking2.0:betaN+

This commit is contained in:
L. David Baron 2011-01-23 20:21:40 -08:00
Родитель a762925658
Коммит fcb90264ce
7 изменённых файлов: 155 добавлений и 5 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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<nsIDOMEventTarget> dispatchTarget = do_QueryInterface(ourWindow);
nsCOMPtr<nsIDOMEventTarget> eventTarget = dispatchTarget;
if (!IsChrome()) {
PRBool isCrossDocOnly = PR_TRUE;
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)) {
isCrossDocOnly = PR_FALSE;
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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 \

Просмотреть файл

@ -0,0 +1,126 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=608030
-->
<head>
<title>Test for MozAfterPaint pref Bug 608030</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=608030">Mozilla Bug 608030</a>
<div id="display" style="width: 10em; height: 5em; background-color: red"></div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 608030 **/
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var prefService = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
var domBranch = prefService.getBranch("dom.");
function get_pref()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
return domBranch.getBoolPref("send_after_paint_to_content");
}
function set_pref(val)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
domBranch.setBoolPref("send_after_paint_to_content", val);
}
SimpleTest.waitForExplicitFinish();
window.addEventListener("load", step0, false);
is(get_pref(), true, "pref defaults to true in mochitest harness");
function print_rect(rect) {
return "(top=" + rect.top + ",left=" + rect.left + ",width=" + rect.width + ",height=" + rect.height + ")";
}
function print_event(event) {
var res = "boundingClientRect=" + print_rect(event.boundingClientRect);
var rects = event.clientRects;
for (var i = 0; i < rects.length; ++i) {
res += " clientRects[" + i + "]=" + print_rect(rects[i]);
}
return res;
}
function step0(event) {
// Wait until we get the MozAfterPaint following the load event
// before starting.
window.addEventListener("MozAfterPaint", step1, false);
}
var start;
var div = document.getElementById("display");
function step1(event)
{
//ok(true, "step1 event: " + print_event(event));
window.removeEventListener("MozAfterPaint", step1, false);
start = Date.now();
window.addEventListener("MozAfterPaint", step2, false);
div.style.backgroundColor = "blue";
}
function step2(event)
{
//ok(true, "step2 event: " + print_event(event));
window.removeEventListener("MozAfterPaint", step2, false);
var end = Date.now();
var timeout = 3 * Math.max(end - start, 300);
ok(true, "got MozAfterPaint (timeout for next step is " + timeout + "ms)");
// Set the pref for our second test
set_pref(false);
// When there was previously another page in our window, we seem to
// get duplicate events, simultaneously, so we need to register our
// next listener after a zero timeout.
setTimeout(step3, 0, timeout);
}
function step3(timeout) {
window.addEventListener("MozAfterPaint", failstep, false);
div.style.backgroundColor = "fuchsia";
setTimeout(step4, timeout);
}
function failstep(event)
{
//ok(true, "failstep event: " + print_event(event));
ok(false, "got MozAfterPaint when we should not have");
}
function step4()
{
window.removeEventListener("MozAfterPaint", failstep, false);
ok(true, "got final step"); // If we didn't get the failure in failstep,
// then we passed.
// Set the pref back in its initial state.
set_pref(true);
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);