| 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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, LayoutUnit lineTop, LayoutUnit lineBottom) | 1004 bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 1005 { | 1005 { |
| 1006 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); | 1006 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); |
| 1007 flipForWritingMode(overflowRect); | 1007 flipForWritingMode(overflowRect); |
| 1008 overflowRect.moveBy(accumulatedOffset); | 1008 overflowRect.moveBy(accumulatedOffset); |
| 1009 if (!locationInContainer.intersects(overflowRect)) | 1009 if (!locationInContainer.intersects(overflowRect)) |
| 1010 return false; | 1010 return false; |
| 1011 | 1011 |
| 1012 // We need to hit test both our inline children (InlineBoxes) and culled inl
ines | 1012 // Check children first. |
| 1013 // (LayoutObjects). We check our inlines in the same order as line layout bu
t | 1013 // 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. |
| 1014 // for each inline we additionally need to hit test its culled inline parent
s. | 1014 LayoutObject* culledParent = 0; |
| 1015 // While hit testing culled inline parents, we can stop once we reach | 1015 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { |
| 1016 // a non-inline parent or a culled inline associated with a different inline
box. | 1016 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin
gLayer()) { |
| 1017 InlineBox* prev; | 1017 LayoutObject* newParent = 0; |
| 1018 for (InlineBox* curr = lastChild(); curr; curr = prev) { | 1018 // Culled parents are only relevant for area-based hit-tests, so ign
ore it in point-based ones. |
| 1019 prev = curr->prevOnLine(); | 1019 if (locationInContainer.isRectBasedTest()) { |
| 1020 | 1020 newParent = curr->renderer().parent(); |
| 1021 // Layers will handle hit testing themselves. | 1021 if (newParent == renderer()) |
| 1022 if (curr->boxModelObject() && curr->boxModelObject()->hasSelfPaintingLay
er()) | 1022 newParent = 0; |
| 1023 continue; | 1023 } |
| 1024 | 1024 // Check the culled parent after all its children have been checked,
to do this we wait until |
| 1025 if (curr->nodeAtPoint(request, result, locationInContainer, accumulatedO
ffset, lineTop, lineBottom)) { | 1025 // we are about to test an element with a different parent. |
| 1026 renderer().updateHitTestResult(result, locationInContainer.point() -
toLayoutSize(accumulatedOffset)); | 1026 if (newParent != culledParent) { |
| 1027 if (!newParent || !newParent->isDescendantOf(culledParent)) { |
| 1028 while (culledParent && culledParent != renderer() && culledP
arent != newParent) { |
| 1029 if (culledParent->isRenderInline() && toRenderInline(cul
ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate
dOffset)) |
| 1030 return true; |
| 1031 culledParent = culledParent->parent(); |
| 1032 } |
| 1033 } |
| 1034 culledParent = newParent; |
| 1035 } |
| 1036 if (curr->nodeAtPoint(request, result, locationInContainer, accumula
tedOffset, lineTop, lineBottom)) { |
| 1037 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
| 1038 return true; |
| 1039 } |
| 1040 } |
| 1041 } |
| 1042 // Check any culled ancestor of the final children tested. |
| 1043 while (culledParent && culledParent != renderer()) { |
| 1044 if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitT
estCulledInline(request, result, locationInContainer, accumulatedOffset)) |
| 1027 return true; | 1045 return true; |
| 1028 } | 1046 culledParent = culledParent->parent(); |
| 1029 | |
| 1030 // If the current inlinebox's renderer and the previous inlinebox's rend
erer are same, | |
| 1031 // we should yield the hit-test to the previous inlinebox. | |
| 1032 if (prev && curr->renderer() == prev->renderer()) | |
| 1033 continue; | |
| 1034 | |
| 1035 LayoutObject* culledParent = &curr->renderer(); | |
| 1036 while (true) { | |
| 1037 LayoutObject* sibling = culledParent->style()->isLeftToRightDirectio
n() ? culledParent->previousSibling() : culledParent->nextSibling(); | |
| 1038 culledParent = culledParent->parent(); | |
| 1039 ASSERT(culledParent); | |
| 1040 | |
| 1041 if (culledParent == renderer() || (sibling && prev && prev->renderer
().isDescendantOf(culledParent))) | |
| 1042 break; | |
| 1043 | |
| 1044 if (culledParent->isRenderInline() && toRenderInline(culledParent)->
hitTestCulledInline(request, result, locationInContainer, accumulatedOffset)) | |
| 1045 return true; | |
| 1046 } | |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 // Now check ourselves. Pixel snap hit testing. | 1049 // Now check ourselves. Pixel snap hit testing. |
| 1050 LayoutRect frameRect = roundedFrameRect(); | 1050 LayoutRect frameRect = roundedFrameRect(); |
| 1051 LayoutUnit minX = frameRect.x(); | 1051 LayoutUnit minX = frameRect.x(); |
| 1052 LayoutUnit minY = frameRect.y(); | 1052 LayoutUnit minY = frameRect.y(); |
| 1053 LayoutUnit width = frameRect.width(); | 1053 LayoutUnit width = frameRect.width(); |
| 1054 LayoutUnit height = frameRect.height(); | 1054 LayoutUnit height = frameRect.height(); |
| 1055 | 1055 |
| 1056 // Constrain our hit testing to the line top and bottom if necessary. | 1056 // 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... |
| 1333 ASSERT(child->prevOnLine() == prev); | 1333 ASSERT(child->prevOnLine() == prev); |
| 1334 prev = child; | 1334 prev = child; |
| 1335 } | 1335 } |
| 1336 ASSERT(prev == m_lastChild); | 1336 ASSERT(prev == m_lastChild); |
| 1337 #endif | 1337 #endif |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 #endif | 1340 #endif |
| 1341 | 1341 |
| 1342 } // namespace blink | 1342 } // namespace blink |
| OLD | NEW |