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

Unified Diff: third_party/WebKit/Source/core/page/SpatialNavigation.cpp

Issue 1651703002: More explicit LayoutUnit conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@evenMoarConstructors
Patch Set: Traits vs Properties vs Pandas Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/SpatialNavigation.cpp
diff --git a/third_party/WebKit/Source/core/page/SpatialNavigation.cpp b/third_party/WebKit/Source/core/page/SpatialNavigation.cpp
index 6cc510d9af8d2c8c20f728dad25b667f4030259b..e670e13ebf5313a384010f9964f41bafd6c53d93 100644
--- a/third_party/WebKit/Source/core/page/SpatialNavigation.cpp
+++ b/third_party/WebKit/Source/core/page/SpatialNavigation.cpp
@@ -194,8 +194,8 @@ bool scrollInDirection(LocalFrame* frame, WebFocusType type)
ASSERT(frame);
if (frame && canScrollInDirection(frame->document(), type)) {
- LayoutUnit dx;
- LayoutUnit dy;
+ int dx = 0;
+ int dy = 0;
switch (type) {
case WebFocusTypeLeft:
dx = - ScrollableArea::pixelsPerLineStep();
@@ -230,22 +230,25 @@ bool scrollInDirection(Node* container, WebFocusType type)
return false;
if (canScrollInDirection(container, type)) {
- LayoutUnit dx;
- LayoutUnit dy;
+ int dx = 0;
+ int dy = 0;
+ // TODO(leviw): Why are these values truncated (toInt) instead of rounding?
switch (type) {
case WebFocusTypeLeft:
- dx = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), container->layoutBox()->scrollLeft());
+ dx = - std::min(ScrollableArea::pixelsPerLineStep(), container->layoutBox()->scrollLeft().toInt());
break;
case WebFocusTypeRight:
ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox()->scrollLeft() + container->layoutBox()->clientWidth()));
- dx = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), container->layoutBox()->scrollWidth() - (container->layoutBox()->scrollLeft() + container->layoutBox()->clientWidth()));
+ dx = std::min(ScrollableArea::pixelsPerLineStep(),
+ (container->layoutBox()->scrollWidth() - (container->layoutBox()->scrollLeft() + container->layoutBox()->clientWidth())).toInt());
break;
case WebFocusTypeUp:
- dy = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), container->layoutBox()->scrollTop());
+ dy = - std::min(ScrollableArea::pixelsPerLineStep(), container->layoutBox()->scrollTop().toInt());
break;
case WebFocusTypeDown:
ASSERT(container->layoutBox()->scrollHeight() - (container->layoutBox()->scrollTop() + container->layoutBox()->clientHeight()));
- dy = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), container->layoutBox()->scrollHeight() - (container->layoutBox()->scrollTop() + container->layoutBox()->clientHeight()));
+ dy = std::min(ScrollableArea::pixelsPerLineStep(),
+ (container->layoutBox()->scrollHeight() - (container->layoutBox()->scrollTop() + container->layoutBox()->clientHeight())).toInt());
break;
default:
ASSERT_NOT_REACHED();
@@ -264,7 +267,7 @@ static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b)
if (!a.intersects(b) || a.contains(b) || b.contains(a))
return;
- LayoutUnit deflateFactor = -fudgeFactor();
+ LayoutUnit deflateFactor = LayoutUnit(-fudgeFactor());
// Avoid negative width or height values.
if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor > 0))

Powered by Google App Engine
This is Rietveld 408576698