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

Side by Side Diff: third_party/WebKit/Source/core/page/SpatialNavigation.cpp

Issue 2387393003: Revert of Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: Created 4 years, 2 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) 2009 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org> 3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org>
4 * 4 *
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 if (canScrollInDirection(container, type)) { 238 if (canScrollInDirection(container, type)) {
239 int dx = 0; 239 int dx = 0;
240 int dy = 0; 240 int dy = 0;
241 // TODO(leviw): Why are these values truncated (toInt) instead of rounding? 241 // TODO(leviw): Why are these values truncated (toInt) instead of rounding?
242 FrameView* frameView = container->document().view(); 242 FrameView* frameView = container->document().view();
243 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep( 243 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(
244 frameView ? frameView->getHostWindow() : nullptr); 244 frameView ? frameView->getHostWindow() : nullptr);
245 switch (type) { 245 switch (type) {
246 case WebFocusTypeLeft: 246 case WebFocusTypeLeft:
247 dx = -pixelsPerLineStep; 247 dx = -std::min(pixelsPerLineStep,
248 container->layoutBox()->scrollLeft().toInt());
248 break; 249 break;
249 case WebFocusTypeRight: 250 case WebFocusTypeRight:
250 ASSERT(container->layoutBox()->scrollWidth() > 251 ASSERT(container->layoutBox()->scrollWidth() >
251 (container->layoutBox()->scrollLeft() + 252 (container->layoutBox()->scrollLeft() +
252 container->layoutBox()->clientWidth())); 253 container->layoutBox()->clientWidth()));
253 dx = pixelsPerLineStep; 254 dx = std::min(pixelsPerLineStep,
255 (container->layoutBox()->scrollWidth() -
256 (container->layoutBox()->scrollLeft() +
257 container->layoutBox()->clientWidth()))
258 .toInt());
254 break; 259 break;
255 case WebFocusTypeUp: 260 case WebFocusTypeUp:
256 dy = -pixelsPerLineStep; 261 dy = -std::min(pixelsPerLineStep,
262 container->layoutBox()->scrollTop().toInt());
257 break; 263 break;
258 case WebFocusTypeDown: 264 case WebFocusTypeDown:
259 ASSERT(container->layoutBox()->scrollHeight() - 265 ASSERT(container->layoutBox()->scrollHeight() -
260 (container->layoutBox()->scrollTop() + 266 (container->layoutBox()->scrollTop() +
261 container->layoutBox()->clientHeight())); 267 container->layoutBox()->clientHeight()));
262 dy = pixelsPerLineStep; 268 dy = std::min(pixelsPerLineStep,
269 (container->layoutBox()->scrollHeight() -
270 (container->layoutBox()->scrollTop() +
271 container->layoutBox()->clientHeight()))
272 .toInt());
263 break; 273 break;
264 default: 274 default:
265 ASSERT_NOT_REACHED(); 275 ASSERT_NOT_REACHED();
266 return false; 276 return false;
267 } 277 }
268 278
269 container->layoutBox()->scrollByRecursively(IntSize(dx, dy)); 279 container->layoutBox()->scrollByRecursively(IntSize(dx, dy));
270 return true; 280 return true;
271 } 281 }
272 282
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 return rect; 690 return rect;
681 } 691 }
682 692
683 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) { 693 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) {
684 return candidate.isFrameOwnerElement() 694 return candidate.isFrameOwnerElement()
685 ? toHTMLFrameOwnerElement(candidate.visibleNode) 695 ? toHTMLFrameOwnerElement(candidate.visibleNode)
686 : nullptr; 696 : nullptr;
687 }; 697 };
688 698
689 } // namespace blink 699 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollEnums.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698