diff options
author | myid.shin <myid.shin@chromium.org> | 2015-10-03 19:35:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-04 02:36:20 +0000 |
commit | 253e64f8e0999a165b0b1c6377b15e0bf9c40fbf (patch) | |
tree | faaa702ad338dc3ce912fbf7e393f745a4623d80 | |
parent | 5a3d2b6cd5bad05c14c4f724b6fd3cced3b5e31b (diff) | |
download | chromium_src-253e64f8e0999a165b0b1c6377b15e0bf9c40fbf.zip chromium_src-253e64f8e0999a165b0b1c6377b15e0bf9c40fbf.tar.gz chromium_src-253e64f8e0999a165b0b1c6377b15e0bf9c40fbf.tar.bz2 |
Fix hitTest bug with checking the direction of culled inline
When the document only has the RTL direction with dir
attribute, even if text such as English is LTR, culled inlines
will be the directionality of their document.
So we should check only the sibling regardless of the direction.
BUG=513010
R=leviw@chromium.org, pdr@chromium.org
TEST=fast/events/event-on-culled-inline-with-pseudo.html
Review URL: https://codereview.chromium.org/1378633002
Cr-Commit-Position: refs/heads/master@{#352269}
-rw-r--r-- | third_party/WebKit/LayoutTests/fast/events/event-on-culled-inline-with-pseudo.html | 31 | ||||
-rw-r--r-- | third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp | 22 |
2 files changed, 46 insertions, 7 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/events/event-on-culled-inline-with-pseudo.html b/third_party/WebKit/LayoutTests/fast/events/event-on-culled-inline-with-pseudo.html new file mode 100644 index 0000000..a348372 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/events/event-on-culled-inline-with-pseudo.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<style> +li { display: inline; } +li:after { content: " •"; } +</style> +<ul dir="rtl"> +<li><a href="#" id="clickme1">Click Me 1</a></li> +<li dir="ltr"><a href="#" id="clickme2">Click Me 2</a></li> +</ul> +<div id="log"></div> +<script> +test(function(t) +{ + if (!window.eventSender) + return; + + ['clickme1', 'clickme2'].forEach(function(id) { + var gotClick = false; + var element = document.getElementById(id); + element.addEventListener('click', function() { gotClick = true; }); + + eventSender.mouseMoveTo(element.offsetLeft + element.offsetWidth / 2, element.offsetTop + element.offsetHeight / 2); + eventSender.mouseDown(); + eventSender.mouseUp(); + + assert_true(gotClick); + }); +}, "Test if the click event is fired when hitting the culled inline element having the pseudo element :after as a child"); +</script>
\ No newline at end of file diff --git a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp index b182aaf..2729668 100644 --- a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp +++ b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp @@ -971,7 +971,7 @@ bool InlineFlowBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo if (!locationInContainer.intersects(overflowRect)) return false; - // We need to hit test both our inline children (InlineBoxes) and culled inlines + // We need to hit test both our inline children (Inline Boxes) and culled inlines // (LayoutObjects). We check our inlines in the same order as line layout but // for each inline we additionally need to hit test its culled inline parents. // While hit testing culled inline parents, we can stop once we reach @@ -989,22 +989,30 @@ bool InlineFlowBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo return true; } - // If the current inlinebox's layout object and the previous inlinebox's layout object are same, - // we should yield the hit-test to the previous inlinebox. + // If the current inline box's layout object and the previous inline box's layout object are same, + // we should yield the hit-test to the previous inline box. if (prev && curr->layoutObject() == prev->layoutObject()) continue; - LayoutObject* culledParent = &curr->layoutObject(); + // If a parent of the current inline box is a culled inline, + // we hit test it before we move the previous inline box. + LayoutObject* currLayoutObject = &curr->layoutObject(); while (true) { - LayoutObject* sibling = culledParent->style()->isLeftToRightDirection() ? culledParent->previousSibling() : culledParent->nextSibling(); - culledParent = culledParent->parent(); + // If the previous inline box is not a descendant of a current inline's parent, + // the parent is a culled inline and we hit test it. + // Otherwise, move to the previous inline box because we hit test first all + // candidate inline boxes under the parent to take a pre-order tree traversal in reverse. + bool hasSibling = currLayoutObject->previousSibling() || currLayoutObject->nextSibling(); + LayoutObject* culledParent = currLayoutObject->parent(); ASSERT(culledParent); - if (culledParent == layoutObject() || (sibling && prev && prev->layoutObject().isDescendantOf(culledParent))) + if (culledParent == layoutObject() || (hasSibling && prev && prev->layoutObject().isDescendantOf(culledParent))) break; if (culledParent->isLayoutInline() && toLayoutInline(culledParent)->hitTestCulledInline(result, locationInContainer, accumulatedOffset)) return true; + + currLayoutObject = culledParent; } } |