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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1957673002: Less duplicated code between nodeAtPoint() in LayoutBox and LayoutBlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 if (style()->boxSizing() == BoxSizingBorderBox) 1184 if (style()->boxSizing() == BoxSizingBorderBox)
1185 result -= borderAndPaddingLogicalHeight(); 1185 result -= borderAndPaddingLogicalHeight();
1186 return std::max(LayoutUnit(), result); 1186 return std::max(LayoutUnit(), result);
1187 } 1187 }
1188 1188
1189 // Hit Testing 1189 // Hit Testing
1190 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) 1190 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
1191 { 1191 {
1192 LayoutPoint adjustedLocation = accumulatedOffset + location(); 1192 LayoutPoint adjustedLocation = accumulatedOffset + location();
1193 1193
1194 // Exit early if no children can be hit. 1194 if (!isLayoutView()) {
1195 LayoutRect overflowRect = visualOverflowRect(); 1195 // Check if we need to do anything at all.
1196 overflowRect.moveBy(adjustedLocation); 1196 // If we have clipping, then we can't have any spillout.
1197 if (!locationInContainer.intersects(overflowRect)) 1197 LayoutRect overflowBox = hasOverflowClip() ? borderBoxRect() : visualOve rflowRect();
1198 return false; 1198 flipForWritingMode(overflowBox);
1199 overflowBox.moveBy(adjustedLocation);
1200 if (!locationInContainer.intersects(overflowBox))
1201 return false;
1202 }
1199 1203
1200 // TODO(pdr): We should also check for css clip in the !isSelfPaintingLayer 1204 // TODO(pdr): We should also check for css clip in the !isSelfPaintingLayer
1201 // case, similar to overflow clip in LayoutBlock::nodeAtPoint. 1205 // case, similar to overflow clip in LayoutBlock::nodeAtPoint.
1202 1206
1207 // TODO(pdr): We should also include checks for hit testing border radius at
1208 // the layer level (see: crbug.com/568904).
1209
1203 if (hitTestChildren(result, locationInContainer, adjustedLocation, action)) 1210 if (hitTestChildren(result, locationInContainer, adjustedLocation, action))
1204 return true; 1211 return true;
1205 1212
1206 if (hitTestClippedOutByRoundedBorder(locationInContainer, adjustedLocation)) 1213 if (hitTestClippedOutByRoundedBorder(locationInContainer, adjustedLocation))
1207 return false; 1214 return false;
1208 1215
1209 // Check our bounds next. For this purpose always assume that we can only be hit in the 1216 // Now hit test ourselves.
1210 // foreground phase (which is true for replaced elements like images). 1217 if (isInSelfHitTestingPhase(action) && visibleToHitTestRequest(result.hitTes tRequest())) {
1211 LayoutRect boundsRect = borderBoxRect(); 1218 LayoutRect boundsRect(adjustedLocation, size());
1212 boundsRect.moveBy(adjustedLocation); 1219 if (locationInContainer.intersects(boundsRect)) {
1213 if (visibleToHitTestRequest(result.hitTestRequest()) && action == HitTestFor eground && locationInContainer.intersects(boundsRect)) { 1220 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - toLayoutSize(adjustedLocation)));
1214 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation)); 1221 if (result.addNodeToListBasedTestResult(nodeForHitTest(), locationIn Container, boundsRect) == StopHitTesting)
1215 if (result.addNodeToListBasedTestResult(node(), locationInContainer, bou ndsRect) == StopHitTesting) 1222 return true;
1216 return true; 1223 }
1217 } 1224 }
1218 1225
1219 return false; 1226 return false;
1220 } 1227 }
1221 1228
1222 bool LayoutBox::hitTestChildren(HitTestResult& result, const HitTestLocation& lo cationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) 1229 bool LayoutBox::hitTestChildren(HitTestResult& result, const HitTestLocation& lo cationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
1223 { 1230 {
1224 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi bling()) { 1231 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi bling()) {
1225 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe lfPaintingLayer()) && child->nodeAtPoint(result, locationInContainer, accumulate dOffset, action)) 1232 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe lfPaintingLayer()) && child->nodeAtPoint(result, locationInContainer, accumulate dOffset, action))
1226 return true; 1233 return true;
(...skipping 3545 matching lines...) Expand 10 before | Expand all | Expand 10 after
4772 4779
4773 void LayoutBox::clearPercentHeightDescendants() 4780 void LayoutBox::clearPercentHeightDescendants()
4774 { 4781 {
4775 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) { 4782 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) {
4776 if (curr->isBox()) 4783 if (curr->isBox())
4777 toLayoutBox(curr)->removeFromPercentHeightContainer(); 4784 toLayoutBox(curr)->removeFromPercentHeightContainer();
4778 } 4785 }
4779 } 4786 }
4780 4787
4781 } // namespace blink 4788 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698