https://bugs.webkit.org/show_bug.cgi?id=45164
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Mar 2011 20:56:18 +0000 (20:56 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Mar 2011 20:56:18 +0000 (20:56 +0000)
Reviewed by Dan Bernstein.

REGRESSION: <a><img align=top></a> Clickable area too large

Make sure to clamp hit testing of quirky inline flow boxes the same way we already clamped
painting.

Source/WebCore:

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::nodeAtPoint):

LayoutTests:

* fast/inline/inline-position-top-align-expected.txt: Added.
* fast/inline/inline-position-top-align.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/inline/inline-position-top-align-expected.txt [new file with mode: 0644]
LayoutTests/fast/inline/inline-position-top-align.html [new file with mode: 0755]
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineFlowBox.cpp

index e7a4709..b92c366 100644 (file)
@@ -1,3 +1,17 @@
+2011-03-14  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=45164
+
+        REGRESSION: <a><img align=top></a> Clickable area too large
+        
+        Make sure to clamp hit testing of quirky inline flow boxes the same way we already clamped
+        painting.
+
+        * fast/inline/inline-position-top-align-expected.txt: Added.
+        * fast/inline/inline-position-top-align.html: Added.
+
 2011-03-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Reviewed by Tony Chang.
diff --git a/LayoutTests/fast/inline/inline-position-top-align-expected.txt b/LayoutTests/fast/inline/inline-position-top-align-expected.txt
new file mode 100644 (file)
index 0000000..7200cb8
--- /dev/null
@@ -0,0 +1,12 @@
+pre-text after-text    Something
+Tests for hitTest of element 
+bug 45164: REGRESSION:  Clickable area too large
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS hitResult is false
+
diff --git a/LayoutTests/fast/inline/inline-position-top-align.html b/LayoutTests/fast/inline/inline-position-top-align.html
new file mode 100755 (executable)
index 0000000..9452903
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<style>
+       body{
+        font-size: 16px;
+        line-height: 26px;
+        margin: 0px;
+        padding: 0px;
+       }
+       table, td {
+        margin: 0px;
+        padding: 0px;
+       }
+</style>
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+
+<body onload="runTests();">
+<table>
+    <tbody><tr>
+        <td width="200">
+            pre-text<a href="https://bug-45164-attachments.webkit.org/" style="background-color:red;">
+                <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL0AAABBCAIAAAAL5TIFAAAABGdBTUEAALGPC/xhBQAAAY5JREFUeF7t07ENA0EMBLFz/0XbbmEnFPj4UAqOGH3e+z4fgV3g342fwCogGgJFoOysbZq/J6AbAkWg7Ny7Hi9aBXRDoAiUnbVN8/cEdEOgCJSde9fjRauAbggUgbKztmn+noBuCBSBsnPverxoFdANgSJQdtY2zd8T0A2BIlB27l2PF60CuiFQBMrO2qb5ewK6IVAEys696/GiVUA3BIpA2VnbNH9PQDcEikDZuXc9XrQK6IZAESg7a5vm7wnohkARKDv3rseLVgHdECgCZWdt0/w9Ad0QKAJl5971eNEqoBsCRaDsrG2avyegGwJFoOzcux4vWgV0Q6AIlJ21TfP3BHRDoAiUnXvX40WrgG4IFIGys7Zp/p6AbggUgbJz73q8aBXQDYEiUHbWNs3fE9ANgSJQdu5djxetArohUATKztqm+XsCuiFQBMrOvevxolVANwSKQNlZ2zR/T0A3BIpA2bl3PV60CuiGQBEoO2ub5u8J6IZAESg7967Hi1YB3RAoAmVnbdP8PQHdENgFftJRFIIJq05RAAAAAElFTkSuQmCC" align="top">
+            </a> after-text
+        </td>
+        <td>Something</td>
+    </tr></tbody>
+</table>
+<br>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Tests for hitTest of <a> element <br/> <a href="https://bugs.webkit.org/show_bug.cgi?id=45164">bug 45164</a>: REGRESSION: <a><img align=top></a> Clickable area too large');
+
+var hitResult;
+function runTests() {
+    var obj = document.elementFromPoint(15, 15);
+    hitResult = (obj.nodeName.toLowerCase() == "a");
+    shouldBeFalse('hitResult');
+}
+var successfullyParsed = true;
+</script>  
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 61917a5..aa2ca2f 100644 (file)
@@ -1,3 +1,17 @@
+2011-03-14  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=45164
+
+        REGRESSION: <a><img align=top></a> Clickable area too large
+        
+        Make sure to clamp hit testing of quirky inline flow boxes the same way we already clamped
+        painting.
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::nodeAtPoint):
+
 2011-03-14  Chris Marrin  <cmarrin@apple.com>
 
         Reviewed by Adam Roben.
index 557013b..a5f6ba6 100644 (file)
@@ -920,10 +920,29 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
         }
     }
 
-    // Now check ourselves.
-    FloatPoint boxOrigin = locationIncludingFlipping();
-    boxOrigin.move(tx, ty);
-    FloatRect rect(boxOrigin, IntSize(width(), height()));
+    // Now check ourselves. Pixel snap hit testing.
+    IntRect frameRect = roundedFrameRect();
+    int minX = frameRect.x();
+    int minY = frameRect.y();
+    int width = frameRect.width();
+    int height = frameRect.height();
+
+    // Constrain our hit testing to the line top and bottom if necessary.
+    bool noQuirksMode = renderer()->document()->inNoQuirksMode();
+    if (!hasTextChildren() && !noQuirksMode) {
+        RootInlineBox* rootBox = root();
+        int& top = isHorizontal() ? minY : minX;
+        int& logicalHeight = isHorizontal() ? height : width;
+        int bottom = min(rootBox->lineBottom(), top + logicalHeight);
+        top = max(rootBox->lineTop(), top);
+        logicalHeight = bottom - top;
+    }
+    
+    // Move x/y to our coordinates.
+    IntRect rect(minX, minY, width, height);
+    flipForWritingMode(rect);
+    rect.move(tx, ty);
+
     if (visibleToHitTesting() && rect.intersects(result.rectForPoint(x, y))) {
         renderer()->updateHitTestResult(result, flipForWritingMode(IntPoint(x - tx, y - ty))); // Don't add in m_x or m_y here, we want coords in the containing block's space.
         if (!result.addNodeToRectBasedTestResult(renderer()->node(), x, y, rect))