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

Side by Side Diff: Source/core/layout/LayoutPart.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) 2000 Simon Hausmann <hausmann@kde.org> 3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return false; 128 return false;
129 } 129 }
130 130
131 bool LayoutPart::needsPreferredWidthsRecalculation() const 131 bool LayoutPart::needsPreferredWidthsRecalculation() const
132 { 132 {
133 if (LayoutReplaced::needsPreferredWidthsRecalculation()) 133 if (LayoutReplaced::needsPreferredWidthsRecalculation())
134 return true; 134 return true;
135 return embeddedContentBox(); 135 return embeddedContentBox();
136 } 136 }
137 137
138 bool LayoutPart::nodeAtPointOverWidget(const HitTestRequest& request, HitTestRes ult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accu mulatedOffset, HitTestAction action) 138 bool LayoutPart::nodeAtPointOverWidget(HitTestResult& result, const HitTestLocat ion& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction ac tion)
139 { 139 {
140 bool hadResult = result.innerNode(); 140 bool hadResult = result.innerNode();
141 bool inside = LayoutReplaced::nodeAtPoint(request, result, locationInContain er, accumulatedOffset, action); 141 bool inside = LayoutReplaced::nodeAtPoint(result, locationInContainer, accum ulatedOffset, action);
142 142
143 // Check to see if we are really over the widget itself (and not just in the border/padding area). 143 // Check to see if we are really over the widget itself (and not just in the border/padding area).
144 if ((inside || result.isRectBasedTest()) && !hadResult && result.innerNode() == node()) 144 if ((inside || result.isRectBasedTest()) && !hadResult && result.innerNode() == node())
145 result.setIsOverWidget(contentBoxRect().contains(result.localPoint())); 145 result.setIsOverWidget(contentBoxRect().contains(result.localPoint()));
146 return inside; 146 return inside;
147 } 147 }
148 148
149 bool LayoutPart::nodeAtPoint(const HitTestRequest& request, HitTestResult& resul t, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOff set, HitTestAction action) 149 bool LayoutPart::nodeAtPoint(HitTestResult& result, const HitTestLocation& locat ionInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
150 { 150 {
151 if (!widget() || !widget()->isFrameView() || !request.allowsChildFrameConten t()) 151 if (!widget() || !widget()->isFrameView() || !result.hitTestRequest().allows ChildFrameContent())
152 return nodeAtPointOverWidget(request, result, locationInContainer, accum ulatedOffset, action); 152 return nodeAtPointOverWidget(result, locationInContainer, accumulatedOff set, action);
153 153
154 FrameView* childFrameView = toFrameView(widget()); 154 FrameView* childFrameView = toFrameView(widget());
155 LayoutView* childRoot = childFrameView->layoutView(); 155 LayoutView* childRoot = childFrameView->layoutView();
156 156
157 if (visibleToHitTestRequest(request) && childRoot) { 157 if (visibleToHitTestRequest(result.hitTestRequest()) && childRoot) {
158 LayoutPoint adjustedLocation = accumulatedOffset + location(); 158 LayoutPoint adjustedLocation = accumulatedOffset + location();
159 LayoutPoint contentOffset = LayoutPoint(borderLeft() + paddingLeft(), bo rderTop() + paddingTop()) - LayoutSize(childFrameView->scrollOffset()); 159 LayoutPoint contentOffset = LayoutPoint(borderLeft() + paddingLeft(), bo rderTop() + paddingTop()) - LayoutSize(childFrameView->scrollOffset());
160 HitTestLocation newHitTestLocation(locationInContainer, -adjustedLocatio n - contentOffset); 160 HitTestLocation newHitTestLocation(locationInContainer, -adjustedLocatio n - contentOffset);
161 HitTestRequest newHitTestRequest(request.type() | HitTestRequest::ChildF rameHitTest); 161 HitTestRequest newHitTestRequest(result.hitTestRequest().type() | HitTes tRequest::ChildFrameHitTest);
162 HitTestResult childFrameResult(newHitTestLocation); 162 HitTestResult childFrameResult(newHitTestRequest, newHitTestLocation);
163 163
164 bool isInsideChildFrame = childRoot->hitTest(newHitTestRequest, newHitTe stLocation, childFrameResult); 164 bool isInsideChildFrame = childRoot->hitTest(newHitTestRequest, newHitTe stLocation, childFrameResult);
165 165
166 if (request.listBased()) 166 if (result.hitTestRequest().listBased())
167 result.append(childFrameResult, request); 167 result.append(childFrameResult);
168 else if (isInsideChildFrame) 168 else if (isInsideChildFrame)
169 result = childFrameResult; 169 result = childFrameResult;
170 170
171 if (isInsideChildFrame) 171 if (isInsideChildFrame)
172 return true; 172 return true;
173 } 173 }
174 174
175 return nodeAtPointOverWidget(request, result, locationInContainer, accumulat edOffset, action); 175 return nodeAtPointOverWidget(result, locationInContainer, accumulatedOffset, action);
176 } 176 }
177 177
178 CompositingReasons LayoutPart::additionalCompositingReasons() const 178 CompositingReasons LayoutPart::additionalCompositingReasons() const
179 { 179 {
180 if (requiresAcceleratedCompositing()) 180 if (requiresAcceleratedCompositing())
181 return CompositingReasonIFrame; 181 return CompositingReasonIFrame;
182 return CompositingReasonNone; 182 return CompositingReasonNone;
183 } 183 }
184 184
185 void LayoutPart::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyl e) 185 void LayoutPart::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyl e)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (widget->frameRect() == newFrame) 310 if (widget->frameRect() == newFrame)
311 return false; 311 return false;
312 312
313 RefPtrWillBeRawPtr<LayoutPart> protector(this); 313 RefPtrWillBeRawPtr<LayoutPart> protector(this);
314 RefPtrWillBeRawPtr<Node> protectedNode(node()); 314 RefPtrWillBeRawPtr<Node> protectedNode(node());
315 widget->setFrameRect(newFrame); 315 widget->setFrameRect(newFrame);
316 return widget->frameRect().size() != newFrame.size(); 316 return widget->frameRect().size() != newFrame.size();
317 } 317 }
318 318
319 } 319 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698