Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: Source/core/rendering/InlineFlowBox.cpp

Issue 685963002: We need to account for culled inline parents of the hit-tested nodes.(Reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // We need to hit test both our inline children (InlineBoxes) and culled inl ines
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 // (RenderObjects). We check our inlines in the same order as line layout bu t
1033 RenderObject* culledParent = 0; 1033 // for each inline we additionally need to hit test its culled inline parent s.
1034 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { 1034 // While hit testing culled inline parents, we can stop once we reach
1035 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer()) { 1035 // a non-inline parent or a culled inline associated with a different inline box.
1036 RenderObject* newParent = 0; 1036 InlineBox* prev;
1037 // Culled parents are only relevant for area-based hit-tests, so ign ore it in point-based ones. 1037 for (InlineBox* curr = lastChild(); curr; curr = prev) {
1038 if (locationInContainer.isRectBasedTest()) { 1038 prev = curr->prevOnLine();
1039 newParent = curr->renderer().parent(); 1039
1040 if (newParent == renderer()) 1040 // Layers will handle hit testing themselves.
1041 newParent = 0; 1041 if (curr->boxModelObject() && curr->boxModelObject()->hasSelfPaintingLay er())
1042 } 1042 continue;
1043 // Check the culled parent after all its children have been checked, to do this we wait until 1043
1044 // we are about to test an element with a different parent. 1044 if (curr->nodeAtPoint(request, result, locationInContainer, accumulatedO ffset, lineTop, lineBottom)) {
1045 if (newParent != culledParent) { 1045 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
1046 if (!newParent || !newParent->isDescendantOf(culledParent)) { 1046 return true;
1047 while (culledParent && culledParent != renderer() && culledP arent != newParent) { 1047 }
1048 if (culledParent->isRenderInline() && toRenderInline(cul ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate dOffset)) 1048
1049 return true; 1049 RenderObject* culledParent = &curr->renderer();
pdr. 2014/12/20 06:55:31 Can you move this down above the while (true) line
1050 culledParent = culledParent->parent(); 1050 // If the current inlinebox's renderer and the previous inlinebox's rend erer are same,
1051 } 1051 // we should yield the hit-test to the previous inlinebox.
1052 } 1052 if (prev && curr->renderer() == prev->renderer())
1053 culledParent = newParent; 1053 continue;
1054 } 1054
1055 if (curr->nodeAtPoint(request, result, locationInContainer, accumula tedOffset, lineTop, lineBottom)) { 1055 while (true) {
1056 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset)); 1056 RenderObject* sibling = culledParent->style()->isLeftToRightDirectio n() ? culledParent->previousSibling() : culledParent->nextSibling();
1057 culledParent = culledParent->parent();
1058 ASSERT(culledParent);
1059
1060 if (culledParent == renderer() || (sibling && prev && prev->renderer ().isDescendantOf(culledParent)))
1061 break;
1062
1063 if (culledParent->isRenderInline() && toRenderInline(culledParent)-> hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
1057 return true; 1064 return true;
1058 }
1059 } 1065 }
1060 } 1066 }
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 }
1067 1067
1068 // Now check ourselves. Pixel snap hit testing. 1068 // Now check ourselves. Pixel snap hit testing.
1069 LayoutRect frameRect = roundedFrameRect(); 1069 LayoutRect frameRect = roundedFrameRect();
1070 LayoutUnit minX = frameRect.x(); 1070 LayoutUnit minX = frameRect.x();
1071 LayoutUnit minY = frameRect.y(); 1071 LayoutUnit minY = frameRect.y();
1072 LayoutUnit width = frameRect.width(); 1072 LayoutUnit width = frameRect.width();
1073 LayoutUnit height = frameRect.height(); 1073 LayoutUnit height = frameRect.height();
1074 1074
1075 // Constrain our hit testing to the line top and bottom if necessary. 1075 // Constrain our hit testing to the line top and bottom if necessary.
1076 bool noQuirksMode = renderer().document().inNoQuirksMode(); 1076 bool noQuirksMode = renderer().document().inNoQuirksMode();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 ASSERT(child->prevOnLine() == prev); 1352 ASSERT(child->prevOnLine() == prev);
1353 prev = child; 1353 prev = child;
1354 } 1354 }
1355 ASSERT(prev == m_lastChild); 1355 ASSERT(prev == m_lastChild);
1356 #endif 1356 #endif
1357 } 1357 }
1358 1358
1359 #endif 1359 #endif
1360 1360
1361 } // namespace blink 1361 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/event-on-culled_inline-expected.txt ('k') | Source/core/rendering/RenderInline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698