OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 } | 1021 } |
1022 | 1022 |
1023 bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, LayoutUnit lineTop, LayoutUnit lineBottom) | 1023 bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, LayoutUnit lineTop, LayoutUnit lineBottom) |
1024 { | 1024 { |
1025 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); | 1025 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); |
1026 flipForWritingMode(overflowRect); | 1026 flipForWritingMode(overflowRect); |
1027 overflowRect.moveBy(accumulatedOffset); | 1027 overflowRect.moveBy(accumulatedOffset); |
1028 if (!locationInContainer.intersects(overflowRect)) | 1028 if (!locationInContainer.intersects(overflowRect)) |
1029 return false; | 1029 return false; |
1030 | 1030 |
1031 // Check children first. | 1031 // Check all of children including culled inlines. |
pdr.
2014/12/05 21:21:01
This may be fantastic code but I was unable to und
Miyoung Shin(g)
2014/12/06 07:22:11
I agree with your opinion. I will add the comment
| |
1032 // 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. | 1032 // We need to account for culled inline parents of the hit-tested nodes, |
1033 RenderObject* culledParent = 0; | 1033 // so that they may also get included in not only area-based hit-tests but a lso point-based ones. |
1034 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { | 1034 // And we should consider of running the minimal loops for hit-test |
1035 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer()) { | 1035 InlineBox* currentBox = lastChild(); |
pdr.
2014/12/05 21:21:01
Why do we need to track the current box and curren
Miyoung Shin(g)
2014/12/06 07:22:11
current box is for hit-testing inline boxes in inl
| |
1036 RenderObject* newParent = 0; | 1036 RenderObject* currentRenderer = currentBox ? ¤tBox->renderer() : 0; |
1037 // Culled parents are only relevant for area-based hit-tests, so ign ore it in point-based ones. | 1037 while (currentRenderer && currentRenderer != renderer()) { |
1038 if (locationInContainer.isRectBasedTest()) { | 1038 if (currentBox && currentBox->renderer() == currentRenderer) { |
1039 newParent = curr->renderer().parent(); | 1039 // We should check the previous line in current renderer until the n ext renderer comes |
1040 if (newParent == renderer()) | 1040 bool escapedRenderer = true; |
1041 newParent = 0; | 1041 while (escapedRenderer) { |
pdr.
2014/12/05 21:21:01
What is this inner loop really doing?
Would a for
Miyoung Shin(g)
2014/12/06 07:22:11
I will re-factor this and remove it.
If I remain t
| |
1042 } | 1042 if (currentBox->renderer().isText() || !currentBox->boxModelObje ct()->hasSelfPaintingLayer()) { |
pdr.
2014/12/05 21:21:01
isText() and !hasSelfPaintingLayer() seem complete
Miyoung Shin(g)
2014/12/06 07:22:11
It was from origin code and I tried to keep them.
| |
1043 // Check the culled parent after all its children have been checked, to do this we wait until | 1043 if (currentBox->nodeAtPoint(request, result, locationInConta iner, accumulatedOffset, lineTop, lineBottom)) { |
1044 // we are about to test an element with a different parent. | 1044 renderer().updateHitTestResult(result, locationInContain er.point() - toLayoutSize(accumulatedOffset)); |
1045 if (newParent != culledParent) { | 1045 return true; |
1046 if (!newParent || !newParent->isDescendantOf(culledParent)) { | |
1047 while (culledParent && culledParent != renderer() && culledP arent != newParent) { | |
1048 if (culledParent->isRenderInline() && toRenderInline(cul ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate dOffset)) | |
1049 return true; | |
1050 culledParent = culledParent->parent(); | |
1051 } | 1046 } |
1052 } | 1047 } |
1053 culledParent = newParent; | 1048 |
1049 InlineBox* previousBox = currentBox; | |
1050 currentBox = currentBox->prevOnLine(); | |
1051 if (!currentBox || currentBox->renderer() != previousBox->render er()) | |
1052 escapedRenderer = false; | |
1054 } | 1053 } |
1055 if (curr->nodeAtPoint(request, result, locationInContainer, accumula tedOffset, lineTop, lineBottom)) { | 1054 } else if (!currentBox || !currentRenderer->isDescendantOf(¤tBox-> renderer())) { |
1056 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset)); | 1055 if (currentRenderer->isRenderInline() && !toRenderInline(currentRend erer)->alwaysCreateLineBoxes() && toRenderInline(currentRenderer)->hitTestCulled Inline(request, result, locationInContainer, accumulatedOffset)) |
1057 return true; | 1056 return true; |
1058 } | |
1059 } | 1057 } |
1060 } | 1058 currentRenderer = currentRenderer->previousInPreOrder(); |
pdr.
2014/12/05 21:21:01
previousInPreOrder could be rather expensive in th
Miyoung Shin(g)
2014/12/06 07:22:11
I will re-factor this and remove it. the next patc
| |
1061 // Check any culled ancestor of the final children tested. | |
1062 while (culledParent && culledParent != renderer()) { | |
1063 if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitT estCulledInline(request, result, locationInContainer, accumulatedOffset)) | |
1064 return true; | |
1065 culledParent = culledParent->parent(); | |
1066 } | 1059 } |
1067 | 1060 |
1068 // Now check ourselves. Pixel snap hit testing. | 1061 // Now check ourselves. Pixel snap hit testing. |
1069 LayoutRect frameRect = roundedFrameRect(); | 1062 LayoutRect frameRect = roundedFrameRect(); |
1070 LayoutUnit minX = frameRect.x(); | 1063 LayoutUnit minX = frameRect.x(); |
1071 LayoutUnit minY = frameRect.y(); | 1064 LayoutUnit minY = frameRect.y(); |
1072 LayoutUnit width = frameRect.width(); | 1065 LayoutUnit width = frameRect.width(); |
1073 LayoutUnit height = frameRect.height(); | 1066 LayoutUnit height = frameRect.height(); |
1074 | 1067 |
1075 // Constrain our hit testing to the line top and bottom if necessary. | 1068 // Constrain our hit testing to the line top and bottom if necessary. |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1352 ASSERT(child->prevOnLine() == prev); | 1345 ASSERT(child->prevOnLine() == prev); |
1353 prev = child; | 1346 prev = child; |
1354 } | 1347 } |
1355 ASSERT(prev == m_lastChild); | 1348 ASSERT(prev == m_lastChild); |
1356 #endif | 1349 #endif |
1357 } | 1350 } |
1358 | 1351 |
1359 #endif | 1352 #endif |
1360 | 1353 |
1361 } // namespace blink | 1354 } // namespace blink |
OLD | NEW |