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

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

Powered by Google App Engine
This is Rietveld 408576698