Bug 613433 - Invalid caret position on facebook's status textbox (styled with min-height and overflow-x or overflow-y); r=roc a=blocking-final+
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 22 Nov 2010 03:13:37 -0500
changeset 58184 b5aa5e3dc568443dc18e35f62af77e68d2d90bc1
parent 58183 35f5ea0863906841ead9d4b0b3e1676200903251
child 58185 f17e290f4e4f97cad3ddbbceeef6482541dbe9ae
child 58295 9123f97f059c4aba1af51ea6b657be1d21d45ea1
push id17189
push usereakhgari@mozilla.com
push dateWed, 24 Nov 2010 19:58:50 +0000
treeherdermozilla-central@b5aa5e3dc568 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking-final
bugs613433
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 613433 - Invalid caret position on facebook's status textbox (styled with min-height and overflow-x or overflow-y); r=roc a=blocking-final+
layout/base/nsCaret.cpp
layout/base/tests/Makefile.in
layout/base/tests/bug613433-1.html
layout/base/tests/bug613433-2.html
layout/base/tests/bug613433-3.html
layout/base/tests/bug613433-ref.html
layout/base/tests/test_reftests_with_caret.html
layout/reftests/bugs/613433-1-ref.html
layout/reftests/bugs/613433-1.html
layout/reftests/bugs/613433-2-ref.html
layout/reftests/bugs/613433-2.html
layout/reftests/bugs/613433-3-ref.html
layout/reftests/bugs/613433-3.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -360,17 +360,19 @@ void nsCaret::SetCaretReadOnly(PRBool in
 void
 nsCaret::GetGeometryForFrame(nsIFrame* aFrame,
                              PRInt32   aFrameOffset,
                              nsRect*   aRect,
                              nscoord*  aBidiIndicatorSize)
 {
   nsPoint framePos(0, 0);
   aFrame->GetPointFromOffset(aFrameOffset, &framePos);
-  nscoord baseline = aFrame->GetCaretBaseline();
+  nsIFrame *frame = aFrame->GetContentInsertionFrame();
+  NS_ASSERTION(frame, "We should not be in the middle of reflow");
+  nscoord baseline = frame->GetCaretBaseline();
   nscoord ascent = 0, descent = 0;
   nsCOMPtr<nsIFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
   NS_ASSERTION(fm, "We should be able to get the font metrics");
   if (fm) {
     fm->GetMaxAscent(ascent);
     fm->GetMaxDescent(descent);
   }
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -117,16 +117,20 @@ DEFINES += -D_IMPL_NS_LAYOUT
 		     bug602141-1.html \
 		     bug602141-1-ref.html \
 		     bug602141-2.html \
 		     bug602141-2-ref.html \
 		     bug602141-3.html \
 		     bug602141-3-ref.html \
 		     bug602141-4.html \
 		     bug602141-4-ref.html \
+		     bug613433-1.html \
+		     bug613433-2.html \
+		     bug613433-3.html \
+		     bug613433-ref.html \
 		test_bug514127.html \
 		test_bug518777.html \
 		test_bug548545.xhtml \
 		test_bug558663.html \
 		test_bug559499.html \
 		test_flush_on_paint.html \
 		test_mozPaintCount.html \
 		test_scroll_selection_into_view.html \
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug613433-1.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+        overflow-x: auto;
+      }
+    </style>
+    <script type="text/javascript" src="/MochiKit/packed.js"></script>
+    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+        // type a character, then press backspace to delete it
+        sendKey("X", window);
+        sendKey("BACK_SPACE", window);
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug613433-2.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+        overflow-y: auto;
+      }
+    </style>
+    <script type="text/javascript" src="/MochiKit/packed.js"></script>
+    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+        // type a character, then press backspace to delete it
+        sendKey("X", window);
+        sendKey("BACK_SPACE", window);
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug613433-3.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+        overflow: auto;
+      }
+    </style>
+    <script type="text/javascript" src="/MochiKit/packed.js"></script>
+    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+        // type a character, then press backspace to delete it
+        sendKey("X", window);
+        sendKey("BACK_SPACE", window);
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug613433-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+      }
+    </style>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"></div>
+  </body>
+</html>
--- a/layout/base/tests/test_reftests_with_caret.html
+++ b/layout/base/tests/test_reftests_with_caret.html
@@ -96,17 +96,20 @@ var tests = [
     [ 'bug482484.html'   , 'bug482484-ref.html'   ] ,
     [ 'bug512295-1.html' , 'bug512295-1-ref.html' ] ,
     [ 'bug512295-2.html' , 'bug512295-2-ref.html' ] ,
     [ 'bug585922.html'   , 'bug585922-ref.html'   ] ,
     [ 'bug597519-1.html' , 'bug597519-1-ref.html' ] ,
     [ 'bug602141-1.html' , 'bug602141-1-ref.html' ] ,
     [ 'bug602141-2.html' , 'bug602141-2-ref.html' ] ,
     [ 'bug602141-3.html' , 'bug602141-3-ref.html' ] ,
-    [ 'bug602141-4.html' , 'bug602141-4-ref.html' ]
+    [ 'bug602141-4.html' , 'bug602141-4-ref.html' ] ,
+    [ 'bug613433-1.html' , 'bug613433-ref.html' ] ,
+    [ 'bug613433-2.html' , 'bug613433-ref.html' ] ,
+    [ 'bug613433-3.html' , 'bug613433-ref.html' ]
 ];
 var testIndex = 0;
 
 function nextTest() {
   if (testIndex < tests.length) {
     refTest(tests[testIndex][0],tests[testIndex][1]);
     ++testIndex;
   } else {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/613433-1-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+      }
+    </style>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/613433-1.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+        overflow-x: auto;
+      }
+    </style>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/613433-2-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+      }
+    </style>
+    <script>
+      function test() {
+        var d = document.querySelector("div");
+        d.appendChild(document.createTextNode(""));
+        d.focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/613433-2.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+        overflow-y: auto;
+      }
+    </style>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/613433-3-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+      }
+    </style>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"><br></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/613433-3.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <style>
+      div {
+        min-height: 36px;
+        overflow: auto;
+      }
+    </style>
+    <script>
+      function test() {
+        document.querySelector("div").focus();
+      }
+      function onfocus() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <div contenteditable onfocus="onfocus()"></div>
+  </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1536,8 +1536,17 @@ fails-if(!haveTestPlugin) == 599476.html
 == 602200-1.html 602200-1-ref.html
 == 602200-2.html 602200-2-ref.html
 == 602200-3.html 602200-3-ref.html
 == 602200-4.html 602200-4-ref.html
 == 604737.html 604737-ref.html
 == 605138-1.html 605138-1-ref.html
 == 605157-1.xhtml 605157-1-ref.xhtml
 == 608636-1.html 608636-1-ref.html
+== 613433-1.html 613433-1-ref.html
+== 613433-1.html 613433-2-ref.html
+== 613433-1.html 613433-3-ref.html
+== 613433-2.html 613433-1-ref.html
+== 613433-2.html 613433-2-ref.html
+== 613433-2.html 613433-3-ref.html
+== 613433-3.html 613433-1-ref.html
+== 613433-3.html 613433-2-ref.html
+== 613433-3.html 613433-3-ref.html