Fix Bug 14498: RenderContainer::positionForCoordinates contains an order of operation...
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2007 23:54:22 +0000 (23:54 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2007 23:54:22 +0000 (23:54 +0000)
WebCore:

        Fix Bug 14498: RenderContainer::positionForCoordinates contains an order of operations error
        http://bugs.webkit.org/show_bug.cgi?id=14498

        There were two bugs:
        1) xPos/yPos were flipped
        2) + binds tighter than ?:, so the order of operations was incorrect

        Reviewed by Darin.

        Test: fast/inline-block/14498-positionForCoordinates.html

        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::positionForCoordinates):

LayoutTests:

        Test for Bug 14498: RenderContainer::positionForCoordinates contains an order of operations error
        http://bugs.webkit.org/show_bug.cgi?id=14498

        Reviewed by Darin.

        * fast/inline-block/14498-positionForCoordinates-expected.txt: Added.
        * fast/inline-block/14498-positionForCoordinates.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23938 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/inline-block/14498-positionForCoordinates-expected.txt [new file with mode: 0644]
LayoutTests/fast/inline-block/14498-positionForCoordinates.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderContainer.cpp

index df3e7712db08e608532ededa38665636f39e1261..f4b2e0e21a146a355545f57e6993300418402103 100644 (file)
@@ -1,3 +1,13 @@
+2007-07-02  Adam Roben  <aroben@apple.com>
+
+        Test for Bug 14498: RenderContainer::positionForCoordinates contains an order of operations error
+        http://bugs.webkit.org/show_bug.cgi?id=14498
+
+        Reviewed by Darin.
+
+        * fast/inline-block/14498-positionForCoordinates-expected.txt: Added.
+        * fast/inline-block/14498-positionForCoordinates.html: Added.
+
 2007-07-01  Darin Adler  <darin@apple.com>
 
         Fixed a no-SVG test failure by removing a node that was affecting the test results differently
diff --git a/LayoutTests/fast/inline-block/14498-positionForCoordinates-expected.txt b/LayoutTests/fast/inline-block/14498-positionForCoordinates-expected.txt
new file mode 100644 (file)
index 0000000..894e38b
--- /dev/null
@@ -0,0 +1,32 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 93x18
+          text run at (0,0) width 93: "This test is for "
+        RenderInline {A} at (0,0) size 299x18 [color=#0000EE]
+          RenderText {#text} at (93,0) size 299x18
+            text run at (93,0) width 299: "http://bugs.webkit.org/show_bug.cgi?id=14498"
+        RenderText {#text} at (392,0) size 4x18
+          text run at (392,0) width 4: "."
+      RenderBlock {P} at (0,34) size 784x18
+        RenderText {#text} at (0,0) size 402x18
+          text run at (0,0) width 402: "Click inside the right border. The caret should move after \x{201C}bar\x{201D}."
+      RenderBlock (anonymous) at (0,68) size 784x18
+        RenderInline {SPAN} at (0,0) size 65x38 [border: (10px solid #0000FF)]
+          RenderText {#text} at (0,0) size 0x0
+          RenderBlock {DIV} at (10,0) size 21x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+          RenderText {#text} at (31,0) size 4x18
+            text run at (31,0) width 4: " "
+          RenderBlock {DIV} at (35,0) size 20x18
+            RenderText {#text} at (0,0) size 20x18
+              text run at (0,0) width 20: "bar"
+          RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+caret: position 3 of child 0 {#text} of child 1 {DIV} of child 5 {SPAN} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/inline-block/14498-positionForCoordinates.html b/LayoutTests/fast/inline-block/14498-positionForCoordinates.html
new file mode 100644 (file)
index 0000000..5ad668f
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<head>
+    <style>
+        span { border: 10px solid blue; }
+        div { display:inline-block; }
+    </style>
+    <script>
+        function test()
+        {
+            var span = document.getElementById("span");
+            var x = span.offsetLeft + span.offsetWidth - 5;
+            var y = span.offsetTop + (span.offsetHeight / 2);
+            if (window.eventSender) {
+                eventSender.mouseMoveTo(x, y);
+                eventSender.mouseDown();
+                eventSender.mouseUp();
+            }
+        }
+    </script>
+</head>
+<body onload="test()" contenteditable="true">
+    <p>This test is for <a href="http://bugs.webkit.org/show_bug.cgi?id=14498">http://bugs.webkit.org/show_bug.cgi?id=14498</a>.</p>
+    <p>Click inside the right border. The caret should move after &ldquo;bar&rdquo;.</p>
+    <span id="span" style="">
+        <div>foo</div>
+        <div>bar</div>
+    </span>
+</body>
+</html>
index db90a880a0c13d92e4dfe267321c34b2798e609e..e950cf43a410a7388af6b53ae6dfb5cc1e35a303 100644 (file)
@@ -1,3 +1,19 @@
+2007-07-02  Adam Roben  <aroben@apple.com>
+
+        Fix Bug 14498: RenderContainer::positionForCoordinates contains an order of operations error
+        http://bugs.webkit.org/show_bug.cgi?id=14498
+
+        There were two bugs:
+        1) xPos/yPos were flipped
+        2) + binds tighter than ?:, so the order of operations was incorrect
+
+        Reviewed by Darin.
+
+        Test: fast/inline-block/14498-positionForCoordinates.html
+
+        * rendering/RenderContainer.cpp:
+        (WebCore::RenderContainer::positionForCoordinates):
+
 2007-07-02  Darin Adler  <darin@apple.com>
 
         Reviewed by Kevin Decker and Tim Hatcher.
index 5042681e27b6be6ad47e3747f82ba46c48ff38f1..093183ab838aaf9a3c6b54b1dee0d7a6076d7bac 100644 (file)
@@ -583,9 +583,9 @@ VisiblePosition RenderContainer::positionForCoordinates(int x, int y)
             || renderer->style()->visibility() != VISIBLE)
             continue;
         
-        int top = borderTop() + paddingTop() + isTableRow() ? 0 : renderer->xPos();
+        int top = borderTop() + paddingTop() + (isTableRow() ? 0 : renderer->yPos());
         int bottom = top + renderer->contentHeight();
-        int left = borderLeft() + paddingLeft() + isTableRow() ? 0 : renderer->yPos();
+        int left = borderLeft() + paddingLeft() + (isTableRow() ? 0 : renderer->xPos());
         int right = left + renderer->contentWidth();
         
         if (x <= right && x >= left && y <= top && y >= bottom) {