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

Side by Side Diff: third_party/WebKit/Source/web/RotationViewportAnchor.cpp

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 4 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "web/RotationViewportAnchor.h" 5 #include "web/RotationViewportAnchor.h"
6 6
7 #include "core/dom/ContainerNode.h" 7 #include "core/dom/ContainerNode.h"
8 #include "core/dom/Node.h" 8 #include "core/dom/Node.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
11 #include "core/frame/PageScaleConstraintsSet.h" 11 #include "core/frame/PageScaleConstraintsSet.h"
12 #include "core/frame/VisualViewport.h" 12 #include "core/frame/VisualViewport.h"
13 #include "core/input/EventHandler.h" 13 #include "core/input/EventHandler.h"
14 #include "core/layout/HitTestResult.h" 14 #include "core/layout/HitTestResult.h"
15 #include "platform/geometry/DoubleRect.h" 15 #include "platform/geometry/DoubleRect.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 namespace { 19 namespace {
20 20
21 static const float viewportAnchorRelativeEpsilon = 0.1f; 21 static const float viewportAnchorRelativeEpsilon = 0.1f;
22 static const int viewportToNodeMaxRelativeArea = 2; 22 static const int viewportToNodeMaxRelativeArea = 2;
23 23
24 template <typename RectType>
25 int area(const RectType& rect)
26 {
27 return rect.width() * rect.height();
28 }
29
30 Node* findNonEmptyAnchorNode(const IntPoint& point, const IntRect& viewRect, Eve ntHandler& eventHandler) 24 Node* findNonEmptyAnchorNode(const IntPoint& point, const IntRect& viewRect, Eve ntHandler& eventHandler)
31 { 25 {
32 Node* node = eventHandler.hitTestResultAtPoint(point, HitTestRequest::ReadOn ly | HitTestRequest::Active).innerNode(); 26 Node* node = eventHandler.hitTestResultAtPoint(point, HitTestRequest::ReadOn ly | HitTestRequest::Active).innerNode();
33 27
34 // If the node bounding box is sufficiently large, make a single attempt to 28 // If the node bounding box is sufficiently large, make a single attempt to
35 // find a smaller node; the larger the node bounds, the greater the 29 // find a smaller node; the larger the node bounds, the greater the
36 // variability under resize. 30 // variability under resize.
37 const int maxNodeArea = area(viewRect) * viewportToNodeMaxRelativeArea; 31 const int maxNodeArea = viewRect.width() * viewRect.height() * viewportToNod eMaxRelativeArea;
38 if (node && area(node->boundingBox()) > maxNodeArea) { 32 if (node && node->boundingBox().width() * node->boundingBox().height() > max NodeArea) {
39 IntSize pointOffset = viewRect.size(); 33 IntSize pointOffset = viewRect.size();
40 pointOffset.scale(viewportAnchorRelativeEpsilon); 34 pointOffset.scale(viewportAnchorRelativeEpsilon);
41 node = eventHandler.hitTestResultAtPoint(point + pointOffset, HitTestReq uest::ReadOnly | HitTestRequest::Active).innerNode(); 35 node = eventHandler.hitTestResultAtPoint(point + pointOffset, HitTestReq uest::ReadOnly | HitTestRequest::Active).innerNode();
42 } 36 }
43 37
44 while (node && node->boundingBox().isEmpty()) 38 while (node && node->boundingBox().isEmpty())
45 node = node->parentNode(); 39 node = node->parentNode();
46 40
47 return node; 41 return node;
48 } 42 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoord s.height()); 199 anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoord s.height());
206 FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOf fsetFromNode; 200 FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOf fsetFromNode;
207 201
208 // Compute the new origin point relative to the new anchor point 202 // Compute the new origin point relative to the new anchor point
209 FloatSize anchorOffsetFromOrigin = innerSize; 203 FloatSize anchorOffsetFromOrigin = innerSize;
210 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInIn nerViewCoords.height()); 204 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInIn nerViewCoords.height());
211 return anchorPoint - anchorOffsetFromOrigin; 205 return anchorPoint - anchorOffsetFromOrigin;
212 } 206 }
213 207
214 } // namespace blink 208 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/geometry/IntRect.cpp ('k') | third_party/WebKit/Source/web/WebInputEventConversion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698