Bug 579767 - Frame borders are sometimes not redrawn correctly after dragging them or resizing the window; r,a=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 26 Jan 2011 00:41:52 -0500
changeset 61323 6e590b267675d578082281e70059901ee26e8952
parent 61322 8149e1a06476462075134a338170c0f8ca3ba9a4
child 61324 410390378caaf6d2b55ff704012cac7f50b267b0
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs579767
milestone2.0b11pre
Bug 579767 - Frame borders are sometimes not redrawn correctly after dragging them or resizing the window; r,a=roc
layout/generic/nsFrameSetFrame.cpp
layout/generic/nsFrameSetFrame.h
layout/generic/test/Makefile.in
layout/generic/test/file_bug579767_1.html
layout/generic/test/file_bug579767_2.html
layout/generic/test/test_bug579767.html
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -96,26 +96,24 @@ void nsFramesetDrag::Reset(PRBool       
                            PRInt32              aIndex, 
                            PRInt32              aChange, 
                            nsHTMLFramesetFrame* aSource) 
 {
   mVertical = aVertical;
   mIndex    = aIndex;
   mChange   = aChange;
   mSource   = aSource;
-  mActive   = PR_TRUE;
 }
 
 void nsFramesetDrag::UnSet()
 {
   mVertical = PR_TRUE;
   mIndex    = -1;
   mChange   = 0;
   mSource   = nsnull;
-  mActive   = PR_FALSE;
 }
 
 /*******************************************************************************
  * nsHTMLFramesetBorderFrame
  ******************************************************************************/
 class nsHTMLFramesetBorderFrame : public nsLeafFrame
 {
 public:
@@ -994,20 +992,18 @@ nsHTMLFramesetFrame::Reflow(nsPresContex
   // will be re-created.
   if (mNumRows != rows || mNumCols != cols) {
     aStatus = NS_FRAME_COMPLETE;
     mDrag.UnSet();
     NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
     return NS_OK;
   }
 
-  if (!mDrag.mActive) {
-    CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes);
-    CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes);
-  }
+  CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes);
+  CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes);
 
   nsAutoArrayPtr<PRBool>  verBordersVis; // vertical borders visibility
   nsAutoArrayPtr<nscolor> verBorderColors;
   nsAutoArrayPtr<PRBool>  horBordersVis; // horizontal borders visibility
   nsAutoArrayPtr<nscolor> horBorderColors;
   nscolor                 borderColor = GetBorderColor();
   nsFrameborder           frameborder = GetFrameBorder();
 
--- a/layout/generic/nsFrameSetFrame.h
+++ b/layout/generic/nsFrameSetFrame.h
@@ -79,17 +79,16 @@ enum nsFrameborder {
   eFrameborder_Notset
 };
 
 struct nsFramesetDrag {
   nsHTMLFramesetFrame* mSource;    // frameset whose border was dragged to cause the resize
   PRInt32              mIndex;     // index of left col or top row of effected area
   PRInt32              mChange;    // pos for left to right or top to bottom, neg otherwise
   PRPackedBool         mVertical;  // vertical if true, otherwise horizontal
-  PRPackedBool         mActive;
 
   nsFramesetDrag();
   void Reset(PRBool               aVertical, 
              PRInt32              aIndex, 
              PRInt32              aChange, 
              nsHTMLFramesetFrame* aSource); 
   void UnSet();
 };
--- a/layout/generic/test/Makefile.in
+++ b/layout/generic/test/Makefile.in
@@ -92,16 +92,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug470212.html \
 		$(warning test_bug488417.html temporarily disabled - see bug 489560) \
 		test_bug496275.html \
 		test_bug503813.html \
 		test_bug508115.xul \
 		$(warning test_bug507902.html temporarily disabled - see bug 510001) \
 		test_bug514732.html \
 		test_bug527306.html \
+		test_bug579767.html \
 		test_bug597333.html \
 		test_image_selection.html \
 		test_invalidate_during_plugin_paint.html \
 		test_movement_by_characters.html \
 		test_movement_by_words.html \
 		test_plugin_clipping.xhtml \
 		test_plugin_clipping2.xhtml \
 		test_plugin_clipping_transformed.xhtml \
@@ -113,16 +114,18 @@ include $(topsrcdir)/config/rules.mk
 		selection_expanding_xbl.xml \
 		test_selection_underline.html \
 		file_BrokenImageReference.png \
 		file_Dolske.png \
 		file_IconTestServer.sjs \
 		file_LoadingImageReference.png \
 		file_bug514732_1.html \
 		file_bug514732_helper.html \
+		file_bug579767_1.html \
+		file_bug579767_2.html \
 		test_bug522632.html \
 		test_bug589621.html \
 		test_bug589623.html \
 		$(srcdir)/../../reftests/backgrounds/blue-32x32.png \
 		$(srcdir)/../../reftests/backgrounds/fuchsia-32x32.png \
 		$(NULL)
 
 _CHROME_FILES = \
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/file_bug579767_1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<HTML style="background-color: yellow">
+  <FRAMESET cols="10%,90%" border="6">
+    <FRAMESET rows="90,210" border="6">
+      <FRAME src="data:text/html,<body bgcolor=blue>">
+      <FRAME src="data:text/html,<body bgcolor=green>">
+    </FRAMESET>
+    <FRAME src="data:text/html,<body bgcolor=red>">
+  </FRAMESET>
+</HTML>
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/file_bug579767_2.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<HTML style="background-color: yellow">
+  <FRAMESET cols="11%,89%" border="6">
+    <FRAMESET rows="100,200" border="6">
+      <FRAME src="data:text/html,<body bgcolor=blue>">
+      <FRAME src="data:text/html,<body bgcolor=green>">
+    </FRAMESET>
+    <FRAME src="data:text/html,<body bgcolor=red>">
+  </FRAMESET>
+</HTML>
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/test_bug579767.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=579767
+-->
+<head>
+  <title>Test for Bug 579767</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <style>
+    iframe {
+      width: 1006px;
+      height: 306px;
+    }
+  </style>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=579767">Mozilla Bug 579767</a>
+<p id="display"></p>
+<div id="content">
+<iframe src="file_bug579767_1.html" id="f1"></iframe>
+<iframe src="file_bug579767_2.html" id="f2"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 579767 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+  var f1 = document.getElementById("f1");
+  var f2 = document.getElementById("f2");
+  var t1 = f1.contentDocument.documentElement;
+  var t2 = f2.contentDocument.documentElement;
+
+  setTimeout(function() {
+    // drag the vertical handle 10px to the right
+    synthesizeMouse(t1, 100, 6, {type: "mousedown"}, f1.contentWindow);
+    synthesizeMouse(t1, 101, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 102, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 103, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 104, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 105, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 106, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 107, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 108, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 109, 6, {type: "mousemove"}, f1.contentWindow);
+    synthesizeMouse(t1, 200, 6, {type: "mouseup"  }, f1.contentWindow);
+
+    setTimeout(function() {
+      // drag the horizontal handle 10px to down and 5px to right
+      synthesizeMouse(t1, 2, 92, {type: "mousedown"}, f1.contentWindow);
+      synthesizeMouse(t1, 3, 93, {type: "mousemove"}, f1.contentWindow);
+      synthesizeMouse(t1, 4, 94, {type: "mousemove"}, f1.contentWindow);
+      synthesizeMouse(t1, 5, 95, {type: "mousemove"}, f1.contentWindow);
+      synthesizeMouse(t1, 7, 102,{type: "mousemove"}, f1.contentWindow);
+      synthesizeMouse(t1, 7, 102,{type: "mouseup"  }, f1.contentWindow);
+
+      setTimeout(function() {
+        // now compare the two windows
+        ok(compareSnapshots(snapshotWindow(f1.contentWindow),
+                            snapshotWindow(f2.contentWindow), true)[0],
+           "The borders should be painted correctly after resizing");
+        is(t1.querySelectorAll("frameset")[0].getAttribute("cols"), "11%,89%",
+           "The cols attribute should be correctly updated");
+        is(t1.querySelectorAll("frameset")[1].getAttribute("rows"), "100,200",
+           "The rows attribute should be correctly updated");
+        SimpleTest.finish();
+      }, 0);
+    }, 0);
+  }, 0);
+});
+
+</script>
+</pre>
+</body>
+</html>