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

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

Issue 1032823003: Refactor HitTestResult to store the HitTestRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating as per review comments Created 5 years, 8 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
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 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 } 1142 }
1143 1143
1144 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit heigh t) const 1144 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit heigh t) const
1145 { 1145 {
1146 if (style()->boxSizing() == BORDER_BOX) 1146 if (style()->boxSizing() == BORDER_BOX)
1147 height -= borderAndPaddingLogicalHeight(); 1147 height -= borderAndPaddingLogicalHeight();
1148 return std::max(LayoutUnit(), height); 1148 return std::max(LayoutUnit(), height);
1149 } 1149 }
1150 1150
1151 // Hit Testing 1151 // Hit Testing
1152 bool LayoutBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result , const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs et, HitTestAction action) 1152 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
1153 { 1153 {
1154 LayoutPoint adjustedLocation = accumulatedOffset + location(); 1154 LayoutPoint adjustedLocation = accumulatedOffset + location();
1155 1155
1156 // Check kids first. 1156 // Check kids first.
1157 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi bling()) { 1157 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi bling()) {
1158 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe lfPaintingLayer()) && child->nodeAtPoint(request, result, locationInContainer, a djustedLocation, action)) { 1158 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe lfPaintingLayer()) && child->nodeAtPoint(result, locationInContainer, adjustedLo cation, action)) {
1159 updateHitTestResult(result, locationInContainer.point() - toLayoutSi ze(adjustedLocation)); 1159 updateHitTestResult(result, locationInContainer.point() - toLayoutSi ze(adjustedLocation));
1160 return true; 1160 return true;
1161 } 1161 }
1162 } 1162 }
1163 1163
1164 // Check our bounds next. For this purpose always assume that we can only be hit in the 1164 // Check our bounds next. For this purpose always assume that we can only be hit in the
1165 // foreground phase (which is true for replaced elements like images). 1165 // foreground phase (which is true for replaced elements like images).
1166 LayoutRect boundsRect = borderBoxRect(); 1166 LayoutRect boundsRect = borderBoxRect();
1167 boundsRect.moveBy(adjustedLocation); 1167 boundsRect.moveBy(adjustedLocation);
1168 if (visibleToHitTestRequest(request) && action == HitTestForeground && locat ionInContainer.intersects(boundsRect)) { 1168 if (visibleToHitTestRequest(result.hitTestRequest()) && action == HitTestFor eground && locationInContainer.intersects(boundsRect)) {
1169 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation)); 1169 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation));
1170 if (!result.addNodeToListBasedTestResult(node(), request, locationInCont ainer, boundsRect)) 1170 if (!result.addNodeToListBasedTestResult(node(), locationInContainer, bo undsRect))
1171 return true; 1171 return true;
1172 } 1172 }
1173 1173
1174 return false; 1174 return false;
1175 } 1175 }
1176 1176
1177 void LayoutBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset ) 1177 void LayoutBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset )
1178 { 1178 {
1179 BoxPainter(*this).paint(paintInfo, paintOffset); 1179 BoxPainter(*this).paint(paintInfo, paintOffset);
1180 } 1180 }
(...skipping 3464 matching lines...) Expand 10 before | Expand all | Expand 10 after
4645 computedValues.m_margins.m_end = marginEnd(); 4645 computedValues.m_margins.m_end = marginEnd();
4646 4646
4647 setLogicalTop(oldLogicalTop); 4647 setLogicalTop(oldLogicalTop);
4648 setLogicalWidth(oldLogicalWidth); 4648 setLogicalWidth(oldLogicalWidth);
4649 setLogicalLeft(oldLogicalLeft); 4649 setLogicalLeft(oldLogicalLeft);
4650 setMarginLeft(oldMarginLeft); 4650 setMarginLeft(oldMarginLeft);
4651 setMarginRight(oldMarginRight); 4651 setMarginRight(oldMarginRight);
4652 } 4652 }
4653 4653
4654 } // namespace blink 4654 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698