Permalink
Browse files

Backout 61fd66629c4f, 7c8121f8d3af & 2a2e9cf8fd41 (bug 539356), e31a5…

…e6545d3 (bug 761884), 85fa80bd9792, a284ccb25b83, 2865904db9fc, 34e07b09c426, e9b3d41e0360, cef00ebcd6c8, f943b729ac14 & 783f298401b6 (bug 539356), 330a086f1570 (bug 741682), d80219c8842c (bug 739671), e8c96b4fd4da, 313af486e68d, 0adc41ff56dc, 0cd288a38085, f1d43208825c, 4859876972f3, eec8ef3ebe48, f7f29fcd1845, 6079b229d306, f23c3a7e7ce0, 9824458a41e2 & 6748b5496059 (bug 539356) for mochitest-4 orange & talos regressions on multiple platforms
  • Loading branch information...
1 parent 7509026 commit 8ec71a25a66d7eb13807db50b9c6adb5aee8ffbc @edmorley edmorley committed Jun 11, 2012
Showing with 3,285 additions and 4,304 deletions.
  1. +1 −3 browser/components/tabview/content.js
  2. +1 −3 browser/devtools/layoutview/LayoutView.jsm
  3. +21 −1 content/base/src/nsFrameLoader.cpp
  4. +3 −3 content/base/src/nsObjectLoadingContent.cpp
  5. +16 −12 content/events/src/nsDOMNotifyPaintEvent.cpp
  6. +11 −1 content/events/src/nsPaintRequest.cpp
  7. +0 −2 content/events/test/Makefile.in
  8. +0 −182 content/events/test/bug426082.html
  9. +0 −208 content/events/test/bug656379-1.html
  10. +153 −5 content/events/test/test_bug426082.html
  11. +174 −6 content/events/test/test_bug656379-1.html
  12. +16 −6 content/html/content/src/nsHTMLCanvasElement.cpp
  13. +3 −2 content/media/VideoFrameContainer.cpp
  14. +11 −2 dom/base/nsDOMWindowUtils.cpp
  15. +19 −7 dom/plugins/base/nsPluginInstanceOwner.cpp
  16. +1 −2 dom/plugins/test/mochitest/test_painting.html
  17. +1 −1 editor/libeditor/html/crashtests/crashtests.list
  18. +1 −1 editor/reftests/reftest.list
  19. +19 −19 editor/reftests/spellcheck-textarea-focused-notreadonly.html
  20. +0 −11 editor/reftests/spellcheck-textarea-ref2.html
  21. +4 −21 gfx/2d/UserData.h
  22. +1 −2 gfx/layers/ImageLayers.h
  23. +0 −331 gfx/layers/LayerTreeInvalidation.cpp
  24. +0 −64 gfx/layers/LayerTreeInvalidation.h
  25. +67 −76 gfx/layers/Layers.h
  26. +0 −2 gfx/layers/Makefile.in
  27. +17 −9 gfx/layers/basic/BasicImplData.h
  28. +24 −47 gfx/layers/basic/BasicLayers.cpp
  29. +5 −9 gfx/layers/basic/BasicLayers.h
  30. +5 −4 gfx/layers/basic/BasicTiledThebesLayer.h
  31. +4 −8 gfx/layers/d3d10/LayerManagerD3D10.cpp
  32. +1 −1 gfx/layers/d3d10/LayerManagerD3D10.h
  33. +1 −3 gfx/layers/d3d10/ThebesLayerD3D10.cpp
  34. +1 −4 gfx/layers/d3d9/CanvasLayerD3D9.cpp
  35. +0 −3 gfx/layers/d3d9/ColorLayerD3D9.cpp
  36. +17 −22 gfx/layers/d3d9/ContainerLayerD3D9.cpp
  37. +1 −5 gfx/layers/d3d9/ImageLayerD3D9.cpp
  38. +0 −7 gfx/layers/d3d9/LayerManagerD3D9.cpp
  39. +0 −9 gfx/layers/d3d9/LayerManagerD3D9.h
  40. +2 −8 gfx/layers/d3d9/ThebesLayerD3D9.cpp
  41. +0 −6 gfx/layers/opengl/CanvasLayerOGL.cpp
  42. +0 −4 gfx/layers/opengl/ColorLayerOGL.cpp
  43. +38 −42 gfx/layers/opengl/ContainerLayerOGL.cpp
  44. +1 −4 gfx/layers/opengl/ImageLayerOGL.cpp
  45. +0 −8 gfx/layers/opengl/LayerManagerOGL.cpp
  46. +0 −4 gfx/layers/opengl/LayerManagerOGL.h
  47. +9 −23 gfx/layers/opengl/ThebesLayerOGL.cpp
  48. +0 −7 gfx/thebes/gfx3DMatrix.cpp
  49. +0 −1 gfx/thebes/gfx3DMatrix.h
  50. +0 −7 gfx/thebes/gfxASurface.cpp
  51. +0 −2 image/test/mochitest/test_animSVGImage.html
  52. +473 −785 layout/base/FrameLayerBuilder.cpp
  53. +56 −196 layout/base/FrameLayerBuilder.h
  54. +0 −1 layout/base/Makefile.in
  55. +23 −4 layout/base/nsCSSFrameConstructor.cpp
  56. +37 −4 layout/base/nsCaret.cpp
  57. +6 −0 layout/base/nsCaret.h
  58. +23 −203 layout/base/nsDisplayList.cpp
  59. +11 −180 layout/base/nsDisplayList.h
  60. +0 −118 layout/base/nsDisplayListInvalidation.h
  61. +2 −1 layout/base/nsDocumentViewer.cpp
  62. +12 −1 layout/base/nsFrameManager.cpp
  63. +2 −1 layout/base/nsFrameManager.h
  64. +4 −16 layout/base/nsIPresShell.h
  65. +33 −1 layout/base/nsImageLoader.cpp
  66. +1 −1 layout/base/nsLayoutDebugger.cpp
  67. +1 −12 layout/base/nsLayoutUtils.cpp
  68. +1 −2 layout/base/nsLayoutUtils.h
  69. +36 −111 layout/base/nsPresContext.cpp
  70. +5 −30 layout/base/nsPresContext.h
  71. +33 −77 layout/base/nsPresShell.cpp
  72. +4 −9 layout/base/nsPresShell.h
  73. +1 −8 layout/base/nsRefreshDriver.cpp
  74. +0 −3 layout/base/nsRefreshDriver.h
  75. +1 −2 layout/base/tests/Makefile.in
  76. +0 −192 layout/base/tests/bug450930.xhtml
  77. +0 −3 layout/base/tests/chrome/Makefile.in
  78. +47 −47 layout/base/tests/chrome/test_transformed_scrolling_repaints.html
  79. +51 −47 layout/base/tests/chrome/test_transformed_scrolling_repaints_2.html
  80. +0 −1 layout/base/tests/test_after_paint_pref.html
  81. +194 −4 layout/base/tests/test_bug450930.xhtml
  82. +0 −7 layout/forms/nsButtonFrameRenderer.cpp
  83. +1 −1 layout/forms/nsComboboxControlFrame.cpp
  84. +1 −1 layout/forms/nsFieldSetFrame.cpp
  85. +21 −3 layout/forms/nsListControlFrame.cpp
  86. +4 −0 layout/forms/nsListControlFrame.h
  87. +1 −1 layout/forms/nsMeterFrame.cpp
  88. +1 −1 layout/forms/nsProgressFrame.cpp
  89. +4 −4 layout/generic/crashtests/crashtests.list
  90. +17 −0 layout/generic/nsAbsoluteContainingBlock.cpp
  91. +145 −1 layout/generic/nsBlockFrame.cpp
  92. +3 −0 layout/generic/nsBlockFrame.h
  93. +1 −0 layout/generic/nsBlockReflowState.cpp
  94. +2 −2 layout/generic/nsBulletFrame.cpp
  95. +16 −2 layout/generic/nsCanvasFrame.cpp
  96. +0 −55 layout/generic/nsCanvasFrame.h
  97. +8 −0 layout/generic/nsColumnSetFrame.cpp
  98. +30 −0 layout/generic/nsContainerFrame.cpp
  99. +346 −172 layout/generic/nsFrame.cpp
  100. +10 −0 layout/generic/nsFrame.h
  101. +224 −10 layout/generic/nsGfxScrollFrame.cpp
  102. +8 −0 layout/generic/nsGfxScrollFrame.h
  103. +5 −1 layout/generic/nsHTMLCanvasFrame.cpp
  104. +147 −91 layout/generic/nsIFrame.h
  105. +30 −7 layout/generic/nsImageFrame.cpp
  106. +3 −1 layout/generic/nsImageMap.cpp
  107. +2 −2 layout/generic/nsObjectFrame.cpp
  108. +2 −1 layout/generic/nsPlaceholderFrame.cpp
  109. +5 −8 layout/generic/nsSubDocumentFrame.cpp
  110. +0 −20 layout/generic/nsTextFrame.h
  111. +6 −56 layout/generic/nsTextFrameThebes.cpp
  112. +5 −1 layout/generic/nsVideoFrame.cpp
  113. +37 −11 layout/generic/nsViewportFrame.cpp
  114. +4 −0 layout/generic/nsViewportFrame.h
  115. +1 −1 layout/inspector/src/inFlasher.cpp
  116. +12 −0 layout/ipc/RenderFrameParent.cpp
  117. +1 −1 layout/ipc/RenderFrameParent.h
  118. +3 −6 layout/mathml/nsMathMLChar.cpp
  119. +3 −3 layout/reftests/bidi/reftest.list
  120. +2 −2 layout/reftests/bugs/reftest.list
  121. +2 −2 layout/reftests/font-inflation/reftest.list
  122. +1 −1 layout/reftests/forms/placeholder/reftest.list
  123. +1 −1 layout/reftests/layers/reftest.list
  124. +1 −1 layout/reftests/reftest-sanity/invalidation.html
  125. +1 −1 layout/reftests/scrolling/fixed-text-1.html
  126. +4 −4 layout/reftests/svg/reftest.list
  127. +1 −1 layout/reftests/svg/smil/sort/reftest.list
  128. +3 −3 layout/reftests/svg/smil/transform/reftest.list
  129. +1 −1 layout/reftests/text/reftest.list
  130. +1 −1 layout/svg/base/src/nsSVGEffects.cpp
  131. +87 −24 layout/svg/base/src/nsSVGForeignObjectFrame.cpp
  132. +13 −3 layout/svg/base/src/nsSVGForeignObjectFrame.h
  133. +18 −23 layout/svg/base/src/nsSVGIntegrationUtils.cpp
  134. +4 −6 layout/svg/base/src/nsSVGIntegrationUtils.h
  135. +9 −68 layout/svg/base/src/nsSVGOuterSVGFrame.cpp
  136. +0 −49 layout/svg/base/src/nsSVGOuterSVGFrame.h
  137. +1 −1 layout/svg/base/src/nsSVGUtils.cpp
  138. +25 −0 layout/tables/nsTableCellFrame.cpp
  139. +0 −7 layout/tables/nsTableCellFrame.h
  140. +0 −8 layout/tables/nsTableColFrame.cpp
  141. +0 −2 layout/tables/nsTableColFrame.h
  142. +0 −10 layout/tables/nsTableColGroupFrame.cpp
  143. +0 −3 layout/tables/nsTableColGroupFrame.h
  144. +96 −2 layout/tables/nsTableFrame.cpp
  145. +17 −7 layout/tables/nsTableFrame.h
  146. +23 −0 layout/tables/nsTableOuterFrame.cpp
  147. +31 −9 layout/tables/nsTableRowFrame.cpp
  148. +0 −2 layout/tables/nsTableRowFrame.h
  149. +43 −10 layout/tables/nsTableRowGroupFrame.cpp
  150. +0 −2 layout/tables/nsTableRowGroupFrame.h
  151. +0 −2 layout/tables/test/Makefile.in
  152. +0 −121 layout/tables/test/invalidation.html
  153. +0 −23 layout/tables/test/test_invalidation.html
  154. +0 −2 layout/tools/reftest/reftest-content.js
  155. +1 −5 layout/tools/reftest/reftest.js
  156. +10 −2 layout/xul/base/src/nsBox.cpp
  157. +1 −1 layout/xul/base/src/nsDeckFrame.cpp
  158. +0 −4 layout/xul/base/src/nsImageBoxFrame.cpp
  159. +3 −1 layout/xul/base/src/nsListBoxLayout.cpp
  160. +8 −2 layout/xul/base/src/nsMenuPopupFrame.cpp
  161. +4 −0 layout/xul/base/src/nsMenuPopupFrame.h
  162. +1 −1 layout/xul/base/src/nsSliderFrame.cpp
  163. +8 −1 layout/xul/base/src/nsStackLayout.cpp
  164. +15 −6 layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
  165. +0 −4 modules/libpref/src/init/all.js
  166. +3 −7 toolkit/content/tests/chrome/window_panel.xul
  167. +1 −4 view/public/nsIViewManager.h
  168. +0 −2 view/src/Makefile.in
  169. +0 −2 view/src/nsView.cpp
  170. +0 −15 view/src/nsView.h
  171. +22 −46 view/src/nsViewManager.cpp
  172. +5 −6 view/src/nsViewManager.h
  173. +1 −1 widget/android/nsLookAndFeel.cpp
  174. +0 −19 widget/android/nsWindow.cpp
  175. +1 −1 widget/android/nsWindow.h
  176. +0 −3 widget/cocoa/nsChildView.mm
  177. +0 −6 widget/gtk2/nsNativeThemeGTK.cpp
  178. +0 −12 widget/nsIWidget.h
  179. +1 −1 widget/xpwidgets/nsNativeTheme.cpp
@@ -41,9 +41,7 @@ let WindowEventHandler = {
// Sends an asynchronous message when the "onMozAfterPaint" event
// is fired.
onMozAfterPaint: function WEH_onMozAfterPaint(event) {
- if (event.clientRects.length > 0) {
- sendAsyncMessage("Panorama:MozAfterPaint");
- }
+ sendAsyncMessage("Panorama:MozAfterPaint");
}
};
@@ -294,9 +294,7 @@ LayoutView.prototype = {
let clientRect = node.getBoundingClientRect();
let width = Math.round(clientRect.width);
let height = Math.round(clientRect.height);
- if (this.doc.querySelector("#element-size").textContent != width + "x" + height) {
- this.doc.querySelector("#element-size").textContent = width + "x" + height;
- }
+ this.doc.querySelector("#element-size").textContent = width + "x" + height;
// If the view is closed, no need to do anything more.
if (!this.isOpen) return;
@@ -107,6 +107,14 @@ class nsAsyncDocShellDestroyer : public nsRunnable
nsRefPtr<nsIDocShell> mDocShell;
};
+static void InvalidateFrame(nsIFrame* aFrame, PRUint32 aFlags)
+{
+ if (!aFrame)
+ return;
+ nsRect rect = nsRect(nsPoint(0, 0), aFrame->GetRect().Size());
+ aFrame->InvalidateWithFlags(rect, aFlags);
+}
+
NS_IMPL_ISUPPORTS1(nsContentView, nsIContentView)
bool
@@ -141,6 +149,13 @@ nsContentView::Update(const ViewConfig& aConfig)
rfp->ContentViewScaleChanged(this);
}
+ // XXX could be clever here and compute a smaller invalidation
+ // rect
+ // NB: we pass INVALIDATE_NO_THEBES_LAYERS here to keep view
+ // semantics the same for both in-process and out-of-process
+ // <browser>. This is just a transform of the layer subtree in
+ // both.
+ InvalidateFrame(mFrameLoader->GetPrimaryFrameOfOwningContent(), nsIFrame::INVALIDATE_NO_THEBES_LAYERS);
return NS_OK;
}
@@ -1708,6 +1723,11 @@ nsFrameLoader::SetRenderMode(PRUint32 aRenderMode)
}
mRenderMode = aRenderMode;
+ // NB: we pass INVALIDATE_NO_THEBES_LAYERS here to keep view
+ // semantics the same for both in-process and out-of-process
+ // <browser>. This is just a transform of the layer subtree in
+ // both.
+ InvalidateFrame(GetPrimaryFrameOfOwningContent(), nsIFrame::INVALIDATE_NO_THEBES_LAYERS);
return NS_OK;
}
@@ -1738,7 +1758,7 @@ nsFrameLoader::SetClipSubdocument(bool aClip)
mClipSubdocument = aClip;
nsIFrame* frame = GetPrimaryFrameOfOwningContent();
if (frame) {
- frame->InvalidateFrame();
+ InvalidateFrame(frame, 0);
frame->PresContext()->PresShell()->
FrameNeedsReflow(frame, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
nsSubDocumentFrame* subdocFrame = do_QueryFrame(frame);
@@ -505,8 +505,8 @@ nsresult nsObjectLoadingContent::IsPluginEnabledForType(const nsCString& aMIMETy
nsCOMPtr<nsIPermissionManager> permissionManager = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 permission;
- rv = permissionManager->TestPermission(topUri,
- "plugins",
+ rv = permissionManager->TestPermission(topUri,
+ "plugins",
&permission);
NS_ENSURE_SUCCESS(rv, rv);
if (permission == nsIPermissionManager::ALLOW_ACTION) {
@@ -1100,7 +1100,7 @@ nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
// Set up new frame to draw.
objFrame->FixupWindow(objFrame->GetContentRectRelativeToSelf().Size());
- objFrame->InvalidateFrame();
+ objFrame->Invalidate(objFrame->GetContentRectRelativeToSelf());
return NS_OK;
}
@@ -39,10 +39,12 @@ nsRegion
nsDOMNotifyPaintEvent::GetRegion()
{
nsRegion r;
- if (!nsContentUtils::IsCallerTrustedForRead()) {
- return r;
- }
+ bool isTrusted = nsContentUtils::IsCallerTrustedForRead();
for (PRUint32 i = 0; i < mInvalidateRequests.Length(); ++i) {
+ if (!isTrusted &&
+ (mInvalidateRequests[i].mFlags & nsIFrame::INVALIDATE_CROSS_DOC))
+ continue;
+
r.Or(r, mInvalidateRequests[i].mRect);
r.SimplifyOutward(10);
}
@@ -96,15 +98,17 @@ nsDOMNotifyPaintEvent::GetPaintRequests(nsIDOMPaintRequestList** aResult)
if (!requests)
return NS_ERROR_OUT_OF_MEMORY;
- if (nsContentUtils::IsCallerTrustedForRead()) {
- for (PRUint32 i = 0; i < mInvalidateRequests.Length(); ++i) {
- nsRefPtr<nsPaintRequest> r = new nsPaintRequest();
- if (!r)
- return NS_ERROR_OUT_OF_MEMORY;
-
- r->SetRequest(mInvalidateRequests[i]);
- requests->Append(r);
- }
+ bool isTrusted = nsContentUtils::IsCallerTrustedForRead();
+ for (PRUint32 i = 0; i < mInvalidateRequests.Length(); ++i) {
+ if (!isTrusted &&
+ (mInvalidateRequests[i].mFlags & nsIFrame::INVALIDATE_CROSS_DOC))
+ continue;
+
+ nsRefPtr<nsPaintRequest> r = new nsPaintRequest();
+ if (!r)
+ return NS_ERROR_OUT_OF_MEMORY;
+ r->SetRequest(mInvalidateRequests[i]);
+ requests->Append(r);
}
requests.forget(aResult);
@@ -35,7 +35,17 @@ nsPaintRequest::GetClientRect(nsIDOMClientRect** aResult)
NS_IMETHODIMP
nsPaintRequest::GetReason(nsAString& aResult)
{
- aResult.AssignLiteral("repaint");
+ switch (mRequest.mFlags & nsIFrame::INVALIDATE_REASON_MASK) {
+ case nsIFrame::INVALIDATE_REASON_SCROLL_BLIT:
+ aResult.AssignLiteral("scroll copy");
+ break;
+ case nsIFrame::INVALIDATE_REASON_SCROLL_REPAINT:
+ aResult.AssignLiteral("scroll repaint");
+ break;
+ default:
+ aResult.Truncate();
+ break;
+ }
return NS_OK;
}
@@ -36,7 +36,6 @@ _TEST_FILES = \
test_bug409604.html \
test_bug412567.html \
test_bug426082.html \
- bug426082.html \
test_bug427537.html \
test_bug432698.html \
test_bug443985.html \
@@ -71,7 +70,6 @@ _TEST_FILES = \
test_bug648573.html \
test_bug615597.html \
test_bug656379-1.html \
- bug656379-1.html \
test_bug656379-2.html \
test_bug656954.html \
test_bug659350.html \
@@ -1,182 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=426082
--->
-<head>
- <title>Test for Bug 426082</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- <style>
- canvas {
- display: none;
- }
- </style>
-</head>
-<body onload="runTests()">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=426082">Mozilla Bug 426082</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<p><input type="button" value="Button" id="button"></p>
-<p><label for="button" id="label">Label</label></p>
-<p id="outside">Something under the label</p>
-<pre id="test">
-<script type="application/javascript;version=1.8">
-
-/** Test for Bug 426082 **/
-
-var normalButtonCanvas, pressedButtonCanvas, normalFocusedButtonCanvas,
- pressedFocusedButtonCanvas, currentSnapshot, button, label, outside;
-
-function runTests() {
- normalButtonCanvas = document.getElementById("normalButtonCanvas");
- pressedButtonCanvas = document.getElementById("pressedButtonCanvas");
- normalFocusedButtonCanvas = document.getElementById("normalFocusedButtonCanvas");
- pressedFocusedButtonCanvas = document.getElementById("pressedFocusedButtonCanvas");
- currentSnapshot = document.getElementById("currentSnapshot");
- button = document.getElementById("button");
- label = document.getElementById("label");
- outside = document.getElementById("outside");
- SimpleTest.executeSoon(executeTests);
-}
-
-function isRectContainedInRectFromRegion(rect, region) {
- console.log("Button rect: " + rect.left + " " + rect.top + " " + rect.right + " " + rect.bottom);
- return Array.some(region, function (r) {
- console.log("Region rect: " + r.left + " " + r.top + " " + r.right + " " + r.bottom);
- return rect.left >= r.left &&
- rect.top >= r.top &&
- rect.right <= r.right &&
- rect.bottom <= r.bottom;
- });
-}
-
-function paintListener(e) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- console.log("paint");
- if (isRectContainedInRectFromRegion(buttonRect(), e.clientRects)) {
- console.log("painted");
- gNeedsPaint = false;
- takeSnapshot(currentSnapshot);
- }
-}
-
-var gNeedsPaint = false;
-function executeTests() {
- var testYielder = tests();
- function execNext() {
- try {
- console.log("check painted");
- if (!gNeedsPaint) {
- testYielder.next();
- button.getBoundingClientRect(); // Flush.
- gNeedsPaint = true;
- }
- SimpleTest.executeSoon(execNext);
- } catch (e) {}
- }
- execNext();
-}
-
-function tests() {
- window.addEventListener("MozAfterPaint", paintListener, false);
- takeSnapshot(normalButtonCanvas);
- // Press the button.
- sendMouseEvent("mousemove", button);
- sendMouseEvent("mousedown", button);
- yield;
- takeSnapshot(pressedFocusedButtonCanvas);
- compareSnapshots_(normalButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal buttons.");
- // Release.
- sendMouseEvent("mouseup", button);
- yield;
- // make sure the button is focused as this doesn't happen on click on Mac
- button.focus();
- takeSnapshot(normalFocusedButtonCanvas);
- compareSnapshots_(normalFocusedButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal focused buttons.");
- // Unfocus the button.
- sendMouseEvent("mousedown", outside);
- sendMouseEvent("mouseup", outside);
- yield;
-
- // Press the label.
- sendMouseEvent("mousemove", label);
- sendMouseEvent("mousedown", label);
- yield;
- compareSnapshots_(normalButtonCanvas, currentSnapshot, false, "Pressing the label should have pressed the button.");
- takeSnapshot(pressedButtonCanvas);
- // Move the mouse down from the label.
- sendMouseEvent("mousemove", outside);
- yield;
- compareSnapshots_(normalButtonCanvas, currentSnapshot, true, "Moving the mouse down from the label should have unpressed the button.");
- // ... and up again.
- sendMouseEvent("mousemove", label);
- yield;
- compareSnapshots_(pressedButtonCanvas, currentSnapshot, true, "Moving the mouse back on top of the label should have pressed the button.");
- // Release.
- sendMouseEvent("mouseup", label);
- yield;
- compareSnapshots_(normalFocusedButtonCanvas, currentSnapshot, true, "Releasing the mouse over the label should have unpressed (and focused) the button.");
- // Press the label and remove it.
- sendMouseEvent("mousemove", label);
- sendMouseEvent("mousedown", label);
- yield;
- label.parentNode.removeChild(label);
- yield;
- compareSnapshots_(normalButtonCanvas, currentSnapshot, true, "Removing the label should have unpressed the button.");
- sendMouseEvent("mouseup", label);
- window.removeEventListener("MozAfterPaint", paintListener, false);
- window.opener.finishTests();
-}
-
-function sendMouseEvent(t, elem) {
- var r = elem.getBoundingClientRect();
- synthesizeMouse(elem, r.width / 2, r.height / 2, {type: t});
-}
-
-function compareSnapshots_(c1, c2, shouldBeIdentical, msg) {
- var [correct, c1url, c2url] = compareSnapshots(c1, c2, shouldBeIdentical);
- if (correct) {
- if (shouldBeIdentical) {
- window.opener.ok(true, msg + " - expected " + c1url);
- } else {
- window.opener.ok(true, msg + " - got " + c1url + " and " + c2url);
- }
- } else {
- if (shouldBeIdentical) {
- window.opener.ok(false, msg + " - expected " + c1url + " but got " + c2url);
- } else {
- window.opener.ok(false, msg + " - expected something other than " + c1url);
- }
- }
-}
-
-function takeSnapshot(canvas) {
- var r = buttonRect();
- var ctx = canvas.getContext("2d");
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- canvas.width = r.width + 4;
- canvas.height = r.height + 4;
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- ctx.drawWindow(window, r.left - 2, r.top - 2, r.width + 4, r.height + 4, "#FFF");
-}
-
-function buttonRect() {
- return button.getBoundingClientRect();
-}
-
-
-</script>
-</pre>
-
-<canvas id="normalButtonCanvas"></canvas>
-<canvas id="pressedButtonCanvas"></canvas>
-<canvas id="normalFocusedButtonCanvas"></canvas>
-<canvas id="pressedFocusedButtonCanvas"></canvas>
-<canvas id="currentSnapshot"></canvas>
-</body>
-</html>
Oops, something went wrong.

0 comments on commit 8ec71a2

Please sign in to comment.