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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h

Issue 2383113003: Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: nits and rebase 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) 2003, 2009, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void scrollbarVisibilityChanged() override; 303 void scrollbarVisibilityChanged() override;
304 IntRect scrollableAreaBoundingBox() const override; 304 IntRect scrollableAreaBoundingBox() const override;
305 void registerForAnimation() override; 305 void registerForAnimation() override;
306 void deregisterForAnimation() override; 306 void deregisterForAnimation() override;
307 bool userInputScrollable(ScrollbarOrientation) const override; 307 bool userInputScrollable(ScrollbarOrientation) const override;
308 bool shouldPlaceVerticalScrollbarOnLeft() const override; 308 bool shouldPlaceVerticalScrollbarOnLeft() const override;
309 int pageStep(ScrollbarOrientation) const override; 309 int pageStep(ScrollbarOrientation) const override;
310 ScrollBehavior scrollBehaviorStyle() const override; 310 ScrollBehavior scrollBehaviorStyle() const override;
311 CompositorAnimationTimeline* compositorAnimationTimeline() const override; 311 CompositorAnimationTimeline* compositorAnimationTimeline() const override;
312 312
313 double scrollXOffset() const {
314 return m_scrollOffset.width() + scrollOrigin().x();
315 }
316 double scrollYOffset() const {
317 return m_scrollOffset.height() + scrollOrigin().y();
318 }
319
320 DoubleSize scrollOffset() const { return m_scrollOffset; } 313 DoubleSize scrollOffset() const { return m_scrollOffset; }
321 314
322 // FIXME: We shouldn't allow access to m_overflowRect outside this class. 315 // FIXME: We shouldn't allow access to m_overflowRect outside this class.
323 LayoutRect overflowRect() const { return m_overflowRect; } 316 LayoutRect overflowRect() const { return m_overflowRect; }
324 317
325 void scrollToPosition(const DoublePoint& scrollPosition,
326 ScrollOffsetClamping = ScrollOffsetUnclamped,
327 ScrollBehavior = ScrollBehaviorInstant,
328 ScrollType = ProgrammaticScroll);
329
330 void scrollToOffset(const DoubleSize& scrollOffset, 318 void scrollToOffset(const DoubleSize& scrollOffset,
331 ScrollOffsetClamping clamp = ScrollOffsetUnclamped,
332 ScrollBehavior scrollBehavior = ScrollBehaviorInstant, 319 ScrollBehavior scrollBehavior = ScrollBehaviorInstant,
333 ScrollType scrollType = ProgrammaticScroll) { 320 ScrollType scrollType = ProgrammaticScroll) {
334 scrollToPosition(-scrollOrigin() + scrollOffset, clamp, scrollBehavior, 321 ScrollableArea::setScrollPosition(-scrollOrigin() + scrollOffset,
335 scrollType); 322 scrollType, scrollBehavior);
336 }
337
338 void scrollToXOffset(double x,
339 ScrollOffsetClamping clamp = ScrollOffsetUnclamped,
340 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) {
341 scrollToOffset(DoubleSize(x, scrollYOffset()), clamp, scrollBehavior);
342 }
343
344 void scrollToYOffset(double y,
345 ScrollOffsetClamping clamp = ScrollOffsetUnclamped,
346 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) {
347 scrollToOffset(DoubleSize(scrollXOffset(), y), clamp, scrollBehavior);
348 } 323 }
349 324
350 void setScrollPosition( 325 void setScrollPosition(
351 const DoublePoint& position, 326 const DoublePoint& position,
352 ScrollType scrollType, 327 ScrollType scrollType,
353 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override { 328 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override {
354 scrollToOffset(toDoubleSize(position), ScrollOffsetClamped, scrollBehavior, 329 scrollToOffset(toDoubleSize(position), scrollBehavior, scrollType);
355 scrollType);
356 } 330 }
357 331
332 // This will set the scroll position without clamping, and it will do all
333 // post-update work even if the scroll position didn't change.
334 void setScrollPositionUnconditionally(const DoublePoint&,
335 ScrollType = ProgrammaticScroll);
336
358 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they 337 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they
359 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while 338 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while
360 // document layout is still happening. 339 // document layout is still happening.
361 void updateAfterLayout(); 340 void updateAfterLayout();
362 void clampScrollPositionsAfterLayout(); 341 void clampScrollPositionsAfterLayout();
363 342
364 void updateAfterStyleChange(const ComputedStyle*); 343 void updateAfterStyleChange(const ComputedStyle*);
365 void updateAfterOverflowRecalc(); 344 void updateAfterOverflowRecalc();
366 345
367 bool updateAfterCompositingChange() override; 346 bool updateAfterCompositingChange() override;
(...skipping 21 matching lines...) Expand all
389 LayoutUnit scrollHeight() const; 368 LayoutUnit scrollHeight() const;
390 int pixelSnappedScrollWidth() const; 369 int pixelSnappedScrollWidth() const;
391 int pixelSnappedScrollHeight() const; 370 int pixelSnappedScrollHeight() const;
392 371
393 int verticalScrollbarWidth( 372 int verticalScrollbarWidth(
394 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const; 373 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const;
395 int horizontalScrollbarHeight( 374 int horizontalScrollbarHeight(
396 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const; 375 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const;
397 376
398 DoubleSize adjustedScrollOffset() const { 377 DoubleSize adjustedScrollOffset() const {
399 return DoubleSize(scrollXOffset(), scrollYOffset()); 378 return toDoubleSize(DoublePoint(scrollOrigin()) + m_scrollOffset);
400 } 379 }
401 380
402 void positionOverflowControls(); 381 void positionOverflowControls();
403 382
404 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control 383 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control
405 // area. 384 // area.
406 bool isPointInResizeControl(const IntPoint& absolutePoint, 385 bool isPointInResizeControl(const IntPoint& absolutePoint,
407 ResizerHitTestType) const; 386 ResizerHitTestType) const;
408 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); 387 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
409 388
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 589
611 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, 590 DEFINE_TYPE_CASTS(PaintLayerScrollableArea,
612 ScrollableArea, 591 ScrollableArea,
613 scrollableArea, 592 scrollableArea,
614 scrollableArea->isPaintLayerScrollableArea(), 593 scrollableArea->isPaintLayerScrollableArea(),
615 scrollableArea.isPaintLayerScrollableArea()); 594 scrollableArea.isPaintLayerScrollableArea());
616 595
617 } // namespace blink 596 } // namespace blink
618 597
619 #endif // LayerScrollableArea_h 598 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698