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

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 // 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.
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
1036 // Behaviour of hit-test is as follows:
1037 // - the main loop is the first loop and the sub loop is the second loop.
1038 // the main loop is for inline boxes and the sub loop is for render object of culled inline.
1039 // - the main loop tries to hit-test all of inline box, if one of them is hi t, then return.
1040 // although one of them is not hit, culled parent of inline box can be hit . so we enter the sub loop.
1041 // - the sub loop tries to hit-test the culled parent of inline box.
1042 // However, if there is a sibling, we yield own parent to sibling becase w e should check first the children before parent.
1043 // the direction of sibling depends on BIDI direction.
1044 InlineBox* prev;
1045 for (InlineBox* curr = lastChild(); curr; curr = prev) {
1046 prev = curr->prevOnLine();
1035 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer()) { 1047 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer()) {
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.
1036 RenderObject* newParent = 0;
1037 // Culled parents are only relevant for area-based hit-tests, so ign ore it in point-based ones.
1038 if (locationInContainer.isRectBasedTest()) {
1039 newParent = curr->renderer().parent();
1040 if (newParent == renderer())
1041 newParent = 0;
1042 }
1043 // Check the culled parent after all its children have been checked, to do this we wait until
1044 // we are about to test an element with a different parent.
1045 if (newParent != culledParent) {
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 }
1052 }
1053 culledParent = newParent;
1054 }
1055 if (curr->nodeAtPoint(request, result, locationInContainer, accumula tedOffset, lineTop, lineBottom)) { 1048 if (curr->nodeAtPoint(request, result, locationInContainer, accumula tedOffset, lineTop, lineBottom)) {
1056 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset)); 1049 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset));
1057 return true; 1050 return true;
1058 } 1051 }
1052
1053 RenderObject* culledParent = &curr->renderer();
1054 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
1055 while (culledParent) {
1056 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
1057 if (culledParent->previousSibling())
1058 break;
1059 } else if (culledParent->nextSibling()) {
1060 break;
1061 }
1062 culledParent = culledParent->parent();
1063 if (culledParent == renderer())
1064 break;
1065
1066 if (culledParent && culledParent->isRenderInline() && toRend erInline(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
1067 return true;
1068 }
1069 }
1070 }
1059 } 1071 }
1060 } 1072 }
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 1073
1068 // Now check ourselves. Pixel snap hit testing. 1074 // Now check ourselves. Pixel snap hit testing.
1069 LayoutRect frameRect = roundedFrameRect(); 1075 LayoutRect frameRect = roundedFrameRect();
1070 LayoutUnit minX = frameRect.x(); 1076 LayoutUnit minX = frameRect.x();
1071 LayoutUnit minY = frameRect.y(); 1077 LayoutUnit minY = frameRect.y();
1072 LayoutUnit width = frameRect.width(); 1078 LayoutUnit width = frameRect.width();
1073 LayoutUnit height = frameRect.height(); 1079 LayoutUnit height = frameRect.height();
1074 1080
1075 // Constrain our hit testing to the line top and bottom if necessary. 1081 // Constrain our hit testing to the line top and bottom if necessary.
1076 bool noQuirksMode = renderer().document().inNoQuirksMode(); 1082 bool noQuirksMode = renderer().document().inNoQuirksMode();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 ASSERT(child->prevOnLine() == prev); 1358 ASSERT(child->prevOnLine() == prev);
1353 prev = child; 1359 prev = child;
1354 } 1360 }
1355 ASSERT(prev == m_lastChild); 1361 ASSERT(prev == m_lastChild);
1356 #endif 1362 #endif
1357 } 1363 }
1358 1364
1359 #endif 1365 #endif
1360 1366
1361 } // namespace blink 1367 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698