Chromium Code Reviews| Index: Source/core/rendering/InlineFlowBox.cpp |
| diff --git a/Source/core/rendering/InlineFlowBox.cpp b/Source/core/rendering/InlineFlowBox.cpp |
| index 10918f9e4886f4037c2b3e46bb0a46be044f9f21..8b7e768944965c3952a5ae3cc50b03327fc8eaa6 100644 |
| --- a/Source/core/rendering/InlineFlowBox.cpp |
| +++ b/Source/core/rendering/InlineFlowBox.cpp |
| @@ -1028,42 +1028,48 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re |
| if (!locationInContainer.intersects(overflowRect)) |
| return false; |
| - // Check children first. |
| - // We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests. |
| - RenderObject* culledParent = 0; |
| - for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { |
| + // Check all of children including culled inlines. |
|
pdr.
2014/12/10 07:16:19
These comments helped me a lot, thank you :)
I tr
Miyoung Shin(g)
2014/12/12 14:46:57
thank you. it's perfect.
Should I replace all of c
pdr.
2014/12/12 21:21:08
Lets replace the entire comment.
|
| + // We need to account for culled inline parents of the hit-tested nodes, |
| + // so that they may also get included in not only area-based hit-tests but also point-based ones. |
| + // And we should consider of running the minimal loops for hit-test |
| + |
| + // Behaviour of hit-test is as follows: |
| + // - the main loop is the first loop and the sub loop is the second loop. |
| + // the main loop is for inline boxes and the sub loop is for render object of culled inline. |
| + // - the main loop tries to hit-test all of inline box, if one of them is hit, then return. |
| + // although one of them is not hit, culled parent of inline box can be hit. so we enter the sub loop. |
| + // - the sub loop tries to hit-test the culled parent of inline box. |
| + // However, if there is a sibling, we yield own parent to sibling becase we should check first the children before parent. |
| + // the direction of sibling depends on BIDI direction. |
| + InlineBox* prev; |
| + for (InlineBox* curr = lastChild(); curr; curr = prev) { |
| + prev = curr->prevOnLine(); |
| if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintingLayer()) { |
|
pdr.
2014/12/10 07:16:19
I think I understand what this is doing now. If yo
Miyoung Shin(g)
2014/12/12 14:46:57
Ok, I will try.
|
| - RenderObject* newParent = 0; |
| - // Culled parents are only relevant for area-based hit-tests, so ignore it in point-based ones. |
| - if (locationInContainer.isRectBasedTest()) { |
| - newParent = curr->renderer().parent(); |
| - if (newParent == renderer()) |
| - newParent = 0; |
| - } |
| - // Check the culled parent after all its children have been checked, to do this we wait until |
| - // we are about to test an element with a different parent. |
| - if (newParent != culledParent) { |
| - if (!newParent || !newParent->isDescendantOf(culledParent)) { |
| - while (culledParent && culledParent != renderer() && culledParent != newParent) { |
| - if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitTestCulledInline(request, result, locationInContainer, accumulatedOffset)) |
| - return true; |
| - culledParent = culledParent->parent(); |
| - } |
| - } |
| - culledParent = newParent; |
| - } |
| if (curr->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom)) { |
| renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset)); |
| return true; |
| } |
| + |
| + RenderObject* culledParent = &curr->renderer(); |
| + if (!prev || curr->renderer() != prev->renderer()) { |
|
pdr.
2014/12/10 07:16:19
Can you help me understand the "curr->renderer() !
Miyoung Shin(g)
2014/12/12 14:46:57
current inlinebox and next inlinbox in the main lo
pdr.
2014/12/12 21:21:08
Ah, I see. Should this check be moved up then, so
Miyoung Shin(g)
2014/12/14 06:54:56
No, we should call inlinebox::nodeAtPoint for each
|
| + while (culledParent) { |
| + if (culledParent->style()->isLeftToRightDirection()) { |
|
pdr.
2014/12/10 07:16:19
Imagine a case where you have three culled inline
Miyoung Shin(g)
2014/12/12 14:46:57
Ah... you're right. I was back on track.
I should
pdr.
2014/12/12 21:21:08
I still don't really understand why the order matt
Miyoung Shin(g)
2014/12/14 06:54:56
I realized we don't need to care three culled inli
|
| + if (culledParent->previousSibling()) |
| + break; |
| + } else if (culledParent->nextSibling()) { |
| + break; |
| + } |
| + culledParent = culledParent->parent(); |
| + if (culledParent == renderer()) |
| + break; |
| + |
| + if (culledParent && culledParent->isRenderInline() && toRenderInline(culledParent)->hitTestCulledInline(request, result, locationInContainer, accumulatedOffset)) { |
|
pdr.
2014/12/10 07:16:19
In the worst case, we'll iterate up the culled inl
Miyoung Shin(g)
2014/12/12 14:46:57
I think, it's impossible to be null. I will add AS
|
| + return true; |
| + } |
| + } |
| + } |
| } |
| } |
| - // Check any culled ancestor of the final children tested. |
| - while (culledParent && culledParent != renderer()) { |
| - if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitTestCulledInline(request, result, locationInContainer, accumulatedOffset)) |
| - return true; |
| - culledParent = culledParent->parent(); |
| - } |
| // Now check ourselves. Pixel snap hit testing. |
| LayoutRect frameRect = roundedFrameRect(); |