bug 629838 - After incrementing mozPaintCount during an empty transaction, also dispatch MozAfterPaint; r=roc a=blocking-final+
authorKevin Gadd <kgadd@mozilla.com>
Mon, 31 Jan 2011 18:41:58 -0800
changeset 61796 f4c949162937888ad4574266f3c2c3515784c147
parent 61795 8df0d4bd765f2e5b601341a30f2158d97c867440
child 61797 e5ce46fd72037b04f98a0988e75886858fcf65c2
push idunknown
push userunknown
push dateunknown
reviewersroc, blocking-final
bugs629838
milestone2.0b12pre
bug 629838 - After incrementing mozPaintCount during an empty transaction, also dispatch MozAfterPaint; r=roc a=blocking-final+
layout/base/nsPresShell.cpp
layout/base/tests/Makefile.in
layout/base/tests/test_bug629838.html
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6141,16 +6141,17 @@ PresShell::Paint(nsIView*           aDis
   LayerManager* layerManager = aWidgetToPaint->GetLayerManager();
   NS_ASSERTION(layerManager, "Must be in paint event");
   layerManager->BeginTransaction();
 
   if (frame) {
     if (!(frame->GetStateBits() & NS_FRAME_UPDATE_LAYER_TREE)) {
       if (layerManager->EndEmptyTransaction()) {
         frame->UpdatePaintCountForPaintedPresShells();
+        presContext->NotifyDidPaintForSubtree();
         
         return NS_OK;
       }
     }
     
     frame->ClearPresShellsFromLastPaint();
     frame->RemoveStateBits(NS_FRAME_UPDATE_LAYER_TREE);
   }
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -138,16 +138,17 @@ DEFINES += -D_IMPL_NS_LAYOUT
 		test_bug548545.xhtml \
 		test_bug558663.html \
 		test_bug559499.html \
 		test_flush_on_paint.html \
 		test_mozPaintCount.html \
 		test_scroll_selection_into_view.html \
 		test_bug582771.html \
 		test_bug603550.html \
+		test_bug629838.html \
 		$(NULL)
 
 # Tests for bugs 441782, 467672 and 570378 don't pass reliably on Windows, because of bug 469208
 ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
 _TEST_FILES += \
 		bidi_numeral_test.js \
 		test_bug332655-1.html \
 		test_bug332655-2.html \
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/test_bug629838.html
@@ -0,0 +1,91 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Tests for MozAfterPaint</title>
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display">
+<embed type="application/x-test" width="100" height="100" id="p"
+       drawmode="solid" color="FF00FF00"></embed>
+</p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+var initialPaintCount, afterPaintCount;
+var color = 0;
+
+function onAfterPaint () {
+  ok(true, "OnAfterPaint");
+  afterPaintCount += 1;
+}
+
+function startTest() {
+  setTimeout(function () {
+    afterPaintCount = 0;
+    initialPaintCount = window.mozPaintCount;
+    window.addEventListener("MozAfterPaint", onAfterPaint, true);
+    doBackgroundFlicker();
+  }, 1000);
+}
+
+document.addEventListener("DOMContentLoaded", startTest, true);
+
+function doPluginFlicker() {
+  ok(true, "Plugin color iteration " + color + 
+     ", afterpaint count: " + afterPaintCount +
+     ", mozpaint count: " + window.mozPaintCount);
+  if ((afterPaintCount >= window.mozPaintCount - initialPaintCount) && 
+      (afterPaintCount > 20)) {
+    ok(true, "Got enough paints from plugin color changes");
+    SimpleTest.finish();
+    return;
+  }
+
+  color = (color + 1) % 256;
+  var str = color.toString(16);
+  if (str.length < 2) {
+    str = "0" + str;
+  }
+  str = "FF" + str + str + str;
+  document.getElementById("p").setColor(str);
+  setTimeout(doPluginFlicker, 0);
+}
+
+function doBackgroundFlicker() {
+  ok(true, "Background color iteration " + color + 
+     ", afterpaint count: " + afterPaintCount +
+     ", mozpaint count: " + window.mozPaintCount);
+  if ((afterPaintCount >= window.mozPaintCount - initialPaintCount) && 
+      (afterPaintCount > 20)) {
+    ok(true, "Got enough paints from background color changes");
+    afterPaintCount = 0;
+    initialPaintCount = window.mozPaintCount;
+    doPluginFlicker();
+    return;
+  }
+
+  color = (color + 1) % 256;
+  document.body.style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
+  setTimeout(doBackgroundFlicker, 0);
+}
+
+</script>
+</pre>
+
+<div style="height:4000px"></div>
+<a id="first"  href="http://www.mozilla.org/">first<br>link</a>
+<a id="second" href="http://www.mozilla.org/">second link</a>
+<a id="third"  href="http://www.mozilla.org/">third<br>link</a>
+<div style="height:4000px"></div>
+
+</body>
+</html>
+