Copied: branches/chromium/1132/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt (from rev 119733, trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt) (0 => 120006)
--- branches/chromium/1132/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt (rev 0)
+++ branches/chromium/1132/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt 2012-06-11 21:01:22 UTC (rev 120006)
@@ -0,0 +1,10 @@
+ PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS All correct nodes found for rect
+PASS All correct nodes found for rect
+PASS All correct nodes found for rect
+PASS All correct nodes found for rect
+FAIL Different number of nodes for rect[0,98], [0,1,2,0]: '2' vs '3'
+PASS All correct nodes found for rect
+
Copied: branches/chromium/1132/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html (from rev 119733, trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html) (0 => 120006)
--- branches/chromium/1132/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html (rev 0)
+++ branches/chromium/1132/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html 2012-06-11 21:01:22 UTC (rev 120006)
@@ -0,0 +1,56 @@
+<html>
+<head>
+ <title>Document::nodesFromRect test - bug 85849</title>
+ <script src=""
+ <script src=""
+ <script type="application/_javascript_">
+ function runTest()
+ {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ var e = {};
+
+ // Set up shortcut access to elements
+ e['html'] = document.getElementsByTagName("html")[0];
+ ['body', 'span', 'img'].forEach(function(a) {
+ e[a] = document.getElementById(a);
+ });
+
+ window.scrollTo(0, 0);
+
+ /* Point based test over the img only. */
+ check(20, 20, 0, 0, 0, 0, [e.img]);
+ /* Rect based test over the img only. */
+ check(20, 20, 5, 5, 5, 5, [e.img]);
+
+ /* Note that for the tests below, the img bounds are considered to be (99, 99). */
+ /* Point based test over the img and the span. */
+ check(0, 99, 0, 0, 0, 0, [e.img]);
+ /* Rect based test over the img and the span with the img fully covering the hit region. */
+ check(0, 98, 0, 1, 1, 0, [e.img]);
+ /* Rect based test over the img and the span with the img not fully covering the hit region. */
+ /* FIXME: This fails due to: https://bugs.webkit.org/show_bug.cgi?id=88376 */
+ check(0, 98, 0, 1, 2, 0, [e.img, e.span]);
+ /* Rect based test over the entire img. */
+ check(0, 0, 0, 99, 99, 0, [e.img]);
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+
+ window._onload_ = runTest;
+ </script>
+</head>
+<body id="body" style="padding: 0; margin: 0;">
+ <span id="span" style="margin: 0; padding: 0; font-size:36px">
+ <img id="img" width="100" height="100" style="background-color: black; margin: 0; padding: 0;" />
+ </span>
+
+ <span id="console" style="position: absolute; top: 150px;"></span>
+ <script src=""
+</body>
+</html>
+
Modified: branches/chromium/1132/Source/WebCore/rendering/HitTestResult.cpp (120005 => 120006)
--- branches/chromium/1132/Source/WebCore/rendering/HitTestResult.cpp 2012-06-11 20:52:14 UTC (rev 120005)
+++ branches/chromium/1132/Source/WebCore/rendering/HitTestResult.cpp 2012-06-11 21:01:22 UTC (rev 120006)
@@ -582,21 +582,23 @@
mutableRectBasedTestResult().add(node);
- if (node->renderer()->isInline()) {
+ bool regionFilled = rect.contains(rectForPoint(pointInContainer));
+ // FIXME: This code (incorrectly) attempts to correct for culled inline nodes. See https://bugs.webkit.org/show_bug.cgi?id=85849.
+ if (node->renderer()->isInline() && !regionFilled) {
for (RenderObject* curr = node->renderer()->parent(); curr; curr = curr->parent()) {
if (!curr->isRenderInline())
break;
-
+
// We need to make sure the nodes for culled inlines get included.
RenderInline* currInline = toRenderInline(curr);
if (currInline->alwaysCreateLineBoxes())
break;
-
+
if (currInline->visibleToHitTesting() && currInline->node())
mutableRectBasedTestResult().add(currInline->node()->shadowAncestorNode());
}
}
- return !rect.contains(rectForPoint(pointInContainer));
+ return !regionFilled;
}
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const LayoutPoint& pointInContainer, const FloatRect& rect)
@@ -615,21 +617,23 @@
mutableRectBasedTestResult().add(node);
- if (node->renderer()->isInline()) {
+ bool regionFilled = rect.contains(rectForPoint(pointInContainer));
+ // FIXME: This code (incorrectly) attempts to correct for culled inline nodes. See https://bugs.webkit.org/show_bug.cgi?id=85849.
+ if (node->renderer()->isInline() && !regionFilled) {
for (RenderObject* curr = node->renderer()->parent(); curr; curr = curr->parent()) {
if (!curr->isRenderInline())
break;
-
+
// We need to make sure the nodes for culled inlines get included.
RenderInline* currInline = toRenderInline(curr);
if (currInline->alwaysCreateLineBoxes())
break;
-
+
if (currInline->visibleToHitTesting() && currInline->node())
mutableRectBasedTestResult().add(currInline->node()->shadowAncestorNode());
}
}
- return !rect.contains(rectForPoint(pointInContainer));
+ return !regionFilled;
}
void HitTestResult::append(const HitTestResult& other)