OLD | NEW |
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 public: | 209 public: |
210 FreezeScrollbarsScope() { s_count++; } | 210 FreezeScrollbarsScope() { s_count++; } |
211 ~FreezeScrollbarsScope() { s_count--; } | 211 ~FreezeScrollbarsScope() { s_count--; } |
212 | 212 |
213 static bool scrollbarsAreFrozen() { return s_count; } | 213 static bool scrollbarsAreFrozen() { return s_count; } |
214 | 214 |
215 private: | 215 private: |
216 static int s_count; | 216 static int s_count; |
217 }; | 217 }; |
218 | 218 |
219 // If a DelayScrollPositionClampScope object is alive, updateAfterLayout() | 219 // If a DelayScrollOffsetClampScope object is alive, updateAfterLayout() will |
220 // will not clamp scroll positions to ensure they are in the valid range. | 220 // not clamp scroll offsets to ensure they are in the valid range. When the |
221 // When the last DelayScrollPositionClampScope object is destructed, all | 221 // last DelayScrollOffsetClampScope object is destructed, all |
222 // PaintLayerScrollableArea's that delayed clamping their positions will | 222 // PaintLayerScrollableArea's that delayed clamping their offsets will |
223 // immediately clamp them. | 223 // immediately clamp them. |
224 class DelayScrollPositionClampScope { | 224 class DelayScrollOffsetClampScope { |
225 STACK_ALLOCATED(); | 225 STACK_ALLOCATED(); |
226 | 226 |
227 public: | 227 public: |
228 DelayScrollPositionClampScope(); | 228 DelayScrollOffsetClampScope(); |
229 ~DelayScrollPositionClampScope(); | 229 ~DelayScrollOffsetClampScope(); |
230 | 230 |
231 static bool clampingIsDelayed() { return s_count; } | 231 static bool clampingIsDelayed() { return s_count; } |
232 static void setNeedsClamp(PaintLayerScrollableArea*); | 232 static void setNeedsClamp(PaintLayerScrollableArea*); |
233 | 233 |
234 private: | 234 private: |
235 static void clampScrollableAreas(); | 235 static void clampScrollableAreas(); |
236 | 236 |
237 static int s_count; | 237 static int s_count; |
238 static PersistentHeapVector<Member<PaintLayerScrollableArea>>* s_needsClamp; | 238 static PersistentHeapVector<Member<PaintLayerScrollableArea>>* s_needsClamp; |
239 }; | 239 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 const IntRect&) const override; | 283 const IntRect&) const override; |
284 IntRect convertFromContainingWidgetToScrollbar(const Scrollbar&, | 284 IntRect convertFromContainingWidgetToScrollbar(const Scrollbar&, |
285 const IntRect&) const override; | 285 const IntRect&) const override; |
286 IntPoint convertFromScrollbarToContainingWidget( | 286 IntPoint convertFromScrollbarToContainingWidget( |
287 const Scrollbar&, | 287 const Scrollbar&, |
288 const IntPoint&) const override; | 288 const IntPoint&) const override; |
289 IntPoint convertFromContainingWidgetToScrollbar( | 289 IntPoint convertFromContainingWidgetToScrollbar( |
290 const Scrollbar&, | 290 const Scrollbar&, |
291 const IntPoint&) const override; | 291 const IntPoint&) const override; |
292 int scrollSize(ScrollbarOrientation) const override; | 292 int scrollSize(ScrollbarOrientation) const override; |
293 IntPoint scrollPosition() const override; | 293 IntSize scrollOffsetInt() const override; |
294 DoublePoint scrollPositionDouble() const override; | 294 ScrollOffset scrollOffset() const override; |
295 IntPoint minimumScrollPosition() const override; | 295 IntSize minimumScrollOffsetInt() const override; |
296 IntPoint maximumScrollPosition() const override; | 296 IntSize maximumScrollOffsetInt() const override; |
297 IntRect visibleContentRect( | 297 IntRect visibleContentRect( |
298 IncludeScrollbarsInRect = ExcludeScrollbars) const override; | 298 IncludeScrollbarsInRect = ExcludeScrollbars) const override; |
299 int visibleHeight() const override; | 299 int visibleHeight() const override; |
300 int visibleWidth() const override; | 300 int visibleWidth() const override; |
301 IntSize contentsSize() const override; | 301 IntSize contentsSize() const override; |
302 IntPoint lastKnownMousePosition() const override; | 302 IntPoint lastKnownMousePosition() const override; |
303 bool scrollAnimatorEnabled() const override; | 303 bool scrollAnimatorEnabled() const override; |
304 bool shouldSuspendScrollAnimations() const override; | 304 bool shouldSuspendScrollAnimations() const override; |
305 bool scrollbarsCanBeActive() const override; | 305 bool scrollbarsCanBeActive() const override; |
306 void scrollbarVisibilityChanged() override; | 306 void scrollbarVisibilityChanged() override; |
307 IntRect scrollableAreaBoundingBox() const override; | 307 IntRect scrollableAreaBoundingBox() const override; |
308 void registerForAnimation() override; | 308 void registerForAnimation() override; |
309 void deregisterForAnimation() override; | 309 void deregisterForAnimation() override; |
310 bool userInputScrollable(ScrollbarOrientation) const override; | 310 bool userInputScrollable(ScrollbarOrientation) const override; |
311 bool shouldPlaceVerticalScrollbarOnLeft() const override; | 311 bool shouldPlaceVerticalScrollbarOnLeft() const override; |
312 int pageStep(ScrollbarOrientation) const override; | 312 int pageStep(ScrollbarOrientation) const override; |
313 ScrollBehavior scrollBehaviorStyle() const override; | 313 ScrollBehavior scrollBehaviorStyle() const override; |
314 CompositorAnimationTimeline* compositorAnimationTimeline() const override; | 314 CompositorAnimationTimeline* compositorAnimationTimeline() const override; |
315 | 315 |
316 DoubleSize scrollOffset() const { return m_scrollOffset; } | |
317 | |
318 // FIXME: We shouldn't allow access to m_overflowRect outside this class. | 316 // FIXME: We shouldn't allow access to m_overflowRect outside this class. |
319 LayoutRect overflowRect() const { return m_overflowRect; } | 317 LayoutRect overflowRect() const { return m_overflowRect; } |
320 | 318 |
321 void scrollToOffset(const DoubleSize& scrollOffset, | 319 void scrollToAbsolutePosition( |
322 ScrollBehavior scrollBehavior = ScrollBehaviorInstant, | 320 const FloatPoint& position, |
323 ScrollType scrollType = ProgrammaticScroll) { | 321 ScrollBehavior scrollBehavior = ScrollBehaviorInstant, |
324 ScrollableArea::setScrollPosition(-scrollOrigin() + scrollOffset, | 322 ScrollType scrollType = ProgrammaticScroll) { |
325 scrollType, scrollBehavior); | 323 setScrollOffset(position - scrollOrigin(), scrollType, scrollBehavior); |
326 } | |
327 | |
328 void setScrollPosition( | |
329 const DoublePoint& position, | |
330 ScrollType scrollType, | |
331 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override { | |
332 scrollToOffset(toDoubleSize(position), scrollBehavior, scrollType); | |
333 } | 324 } |
334 | 325 |
335 // This will set the scroll position without clamping, and it will do all | 326 // This will set the scroll position without clamping, and it will do all |
336 // post-update work even if the scroll position didn't change. | 327 // post-update work even if the scroll position didn't change. |
| 328 void setScrollOffsetUnconditionally(const ScrollOffset&, |
| 329 ScrollType = ProgrammaticScroll); |
| 330 |
| 331 // This will set the scroll position without clamping, and it will do all |
| 332 // post-update work even if the scroll position didn't change. |
337 void setScrollPositionUnconditionally(const DoublePoint&, | 333 void setScrollPositionUnconditionally(const DoublePoint&, |
338 ScrollType = ProgrammaticScroll); | 334 ScrollType = ProgrammaticScroll); |
339 | 335 |
340 // TODO(szager): Actually run these after all of layout is finished. | 336 // TODO(szager): Actually run these after all of layout is finished. |
341 // Currently, they run at the end of box()'es layout (or after all flexbox | 337 // Currently, they run at the end of box()'es layout (or after all flexbox |
342 // layout has finished) but while document layout is still happening. | 338 // layout has finished) but while document layout is still happening. |
343 void updateAfterLayout(); | 339 void updateAfterLayout(); |
344 void clampScrollPositionsAfterLayout(); | 340 void clampScrollOffsetsAfterLayout(); |
345 | 341 |
346 void updateAfterStyleChange(const ComputedStyle*); | 342 void updateAfterStyleChange(const ComputedStyle*); |
347 void updateAfterOverflowRecalc(); | 343 void updateAfterOverflowRecalc(); |
348 | 344 |
349 bool updateAfterCompositingChange() override; | 345 bool updateAfterCompositingChange() override; |
350 | 346 |
351 bool hasScrollbar() const { | 347 bool hasScrollbar() const { |
352 return hasHorizontalScrollbar() || hasVerticalScrollbar(); | 348 return hasHorizontalScrollbar() || hasVerticalScrollbar(); |
353 } | 349 } |
354 bool hasOverflowControls() const { | 350 bool hasOverflowControls() const { |
(...skipping 30 matching lines...) Expand all Loading... |
385 | 381 |
386 // isPointInResizeControl() is used for testing if a pointer/touch position is | 382 // isPointInResizeControl() is used for testing if a pointer/touch position is |
387 // in the resize control area. | 383 // in the resize control area. |
388 bool isPointInResizeControl(const IntPoint& absolutePoint, | 384 bool isPointInResizeControl(const IntPoint& absolutePoint, |
389 ResizerHitTestType) const; | 385 ResizerHitTestType) const; |
390 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); | 386 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); |
391 | 387 |
392 bool hitTestResizerInFragments(const PaintLayerFragments&, | 388 bool hitTestResizerInFragments(const PaintLayerFragments&, |
393 const HitTestLocation&) const; | 389 const HitTestLocation&) const; |
394 | 390 |
395 // Returns the new position, after scrolling, of the given rect in absolute | 391 // Returns the new offset, after scrolling, of the given rect in absolute |
396 // coordinates, clipped by the parent's client rect. | 392 // coordinates, clipped by the parent's client rect. |
397 LayoutRect scrollIntoView(const LayoutRect&, | 393 LayoutRect scrollIntoView(const LayoutRect&, |
398 const ScrollAlignment& alignX, | 394 const ScrollAlignment& alignX, |
399 const ScrollAlignment& alignY, | 395 const ScrollAlignment& alignY, |
400 ScrollType = ProgrammaticScroll) override; | 396 ScrollType = ProgrammaticScroll) override; |
401 | 397 |
402 // Returns true if scrollable area is in the FrameView's collection of | 398 // Returns true if scrollable area is in the FrameView's collection of |
403 // scrollable areas. This can only happen if we're scrollable, visible to hit | 399 // scrollable areas. This can only happen if we're scrollable, visible to hit |
404 // test, and do in fact overflow. This means that 'overflow: hidden' or | 400 // test, and do in fact overflow. This means that 'overflow: hidden' or |
405 // 'pointer-events: none' layers never get added to the FrameView's | 401 // 'pointer-events: none' layers never get added to the FrameView's |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 LayoutBox* layoutBox() const override { return &box(); } | 444 LayoutBox* layoutBox() const override { return &box(); } |
449 | 445 |
450 bool shouldRebuildHorizontalScrollbarLayer() const { | 446 bool shouldRebuildHorizontalScrollbarLayer() const { |
451 return m_rebuildHorizontalScrollbarLayer; | 447 return m_rebuildHorizontalScrollbarLayer; |
452 } | 448 } |
453 bool shouldRebuildVerticalScrollbarLayer() const { | 449 bool shouldRebuildVerticalScrollbarLayer() const { |
454 return m_rebuildVerticalScrollbarLayer; | 450 return m_rebuildVerticalScrollbarLayer; |
455 } | 451 } |
456 void resetRebuildScrollbarLayerFlags(); | 452 void resetRebuildScrollbarLayerFlags(); |
457 | 453 |
458 // Did DelayScrollPositionClampScope prevent us from running | 454 // Did DelayScrollOffsetClampScope prevent us from running |
459 // clampScrollPositionsAfterLayout() | 455 // clampScrollOffsetsAfterLayout() in updateAfterLayout()? |
460 // in updateAfterLayout()? | 456 bool needsScrollOffsetClamp() const { return m_needsScrollOffsetClamp; } |
461 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; } | 457 void setNeedsScrollOffsetClamp(bool val) { m_needsScrollOffsetClamp = val; } |
462 void setNeedsScrollPositionClamp(bool val) { | |
463 m_needsScrollPositionClamp = val; | |
464 } | |
465 | 458 |
466 // Did PreventRelayoutScope prevent us from running re-layout due to | 459 // Did PreventRelayoutScope prevent us from running re-layout due to |
467 // adding/subtracting scrollbars in updateAfterLayout()? | 460 // adding/subtracting scrollbars in updateAfterLayout()? |
468 bool needsRelayout() const { return m_needsRelayout; } | 461 bool needsRelayout() const { return m_needsRelayout; } |
469 void setNeedsRelayout(bool val) { m_needsRelayout = val; } | 462 void setNeedsRelayout(bool val) { m_needsRelayout = val; } |
470 | 463 |
471 // Were we laid out with a horizontal scrollbar at the time we were marked as | 464 // Were we laid out with a horizontal scrollbar at the time we were marked as |
472 // needing relayout by PreventRelayoutScope? | 465 // needing relayout by PreventRelayoutScope? |
473 bool hadHorizontalScrollbarBeforeRelayout() const { | 466 bool hadHorizontalScrollbarBeforeRelayout() const { |
474 return m_hadHorizontalScrollbarBeforeRelayout; | 467 return m_hadHorizontalScrollbarBeforeRelayout; |
(...skipping 29 matching lines...) Expand all Loading... |
504 bool hasVerticalOverflow() const; | 497 bool hasVerticalOverflow() const; |
505 bool hasScrollableHorizontalOverflow() const; | 498 bool hasScrollableHorizontalOverflow() const; |
506 bool hasScrollableVerticalOverflow() const; | 499 bool hasScrollableVerticalOverflow() const; |
507 bool visualViewportSuppliesScrollbars() const; | 500 bool visualViewportSuppliesScrollbars() const; |
508 | 501 |
509 bool needsScrollbarReconstruction() const; | 502 bool needsScrollbarReconstruction() const; |
510 | 503 |
511 void updateScrollOrigin(); | 504 void updateScrollOrigin(); |
512 void updateScrollDimensions(); | 505 void updateScrollDimensions(); |
513 | 506 |
514 void setScrollOffset(const DoublePoint&, ScrollType) override; | 507 void updateScrollOffset(const ScrollOffset&, ScrollType) override; |
515 | 508 |
516 int verticalScrollbarStart(int minX, int maxX) const; | 509 int verticalScrollbarStart(int minX, int maxX) const; |
517 int horizontalScrollbarStart(int minX) const; | 510 int horizontalScrollbarStart(int minX) const; |
518 IntSize scrollbarOffset(const Scrollbar&) const; | 511 IntSize scrollbarOffset(const Scrollbar&) const; |
519 | 512 |
520 void setHasHorizontalScrollbar(bool hasScrollbar); | 513 void setHasHorizontalScrollbar(bool hasScrollbar); |
521 void setHasVerticalScrollbar(bool hasScrollbar); | 514 void setHasVerticalScrollbar(bool hasScrollbar); |
522 | 515 |
523 void updateScrollCornerStyle(); | 516 void updateScrollCornerStyle(); |
524 | 517 |
(...skipping 28 matching lines...) Expand all Loading... |
553 // FIXME: once cc can handle composited scrolling with clip paths, we will | 546 // FIXME: once cc can handle composited scrolling with clip paths, we will |
554 // no longer need this bit. | 547 // no longer need this bit. |
555 unsigned m_needsCompositedScrolling : 1; | 548 unsigned m_needsCompositedScrolling : 1; |
556 | 549 |
557 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt | 550 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt |
558 // in the next compositing update because the underlying blink::Scrollbar | 551 // in the next compositing update because the underlying blink::Scrollbar |
559 // instance has been reconstructed. | 552 // instance has been reconstructed. |
560 unsigned m_rebuildHorizontalScrollbarLayer : 1; | 553 unsigned m_rebuildHorizontalScrollbarLayer : 1; |
561 unsigned m_rebuildVerticalScrollbarLayer : 1; | 554 unsigned m_rebuildVerticalScrollbarLayer : 1; |
562 | 555 |
563 unsigned m_needsScrollPositionClamp : 1; | 556 unsigned m_needsScrollOffsetClamp : 1; |
564 unsigned m_needsRelayout : 1; | 557 unsigned m_needsRelayout : 1; |
565 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1; | 558 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1; |
566 unsigned m_hadVerticalScrollbarBeforeRelayout : 1; | 559 unsigned m_hadVerticalScrollbarBeforeRelayout : 1; |
567 | 560 |
568 // The width/height of our scrolled area. | 561 // The width/height of our scrolled area. |
569 // This is OverflowModel's layout overflow translated to physical | 562 // This is OverflowModel's layout overflow translated to physical |
570 // coordinates. See OverflowModel for the different overflow and | 563 // coordinates. See OverflowModel for the different overflow and |
571 // LayoutBoxModelObject for the coordinate systems. | 564 // LayoutBoxModelObject for the coordinate systems. |
572 LayoutRect m_overflowRect; | 565 LayoutRect m_overflowRect; |
573 | 566 |
574 // ScrollbarManager holds the Scrollbar instances. | 567 // ScrollbarManager holds the Scrollbar instances. |
575 ScrollbarManager m_scrollbarManager; | 568 ScrollbarManager m_scrollbarManager; |
576 | 569 |
577 // This is the (scroll) offset from scrollOrigin(). | 570 // This is the offset from the beginning of content flow. |
578 DoubleSize m_scrollOffset; | 571 ScrollOffset m_scrollOffset; |
579 | 572 |
580 IntPoint m_cachedOverlayScrollbarOffset; | 573 IntPoint m_cachedOverlayScrollbarOffset; |
581 | 574 |
582 // LayoutObject to hold our custom scroll corner. | 575 // LayoutObject to hold our custom scroll corner. |
583 LayoutScrollbarPart* m_scrollCorner; | 576 LayoutScrollbarPart* m_scrollCorner; |
584 | 577 |
585 // LayoutObject to hold our custom resizer. | 578 // LayoutObject to hold our custom resizer. |
586 LayoutScrollbarPart* m_resizer; | 579 LayoutScrollbarPart* m_resizer; |
587 | 580 |
588 ScrollAnchor m_scrollAnchor; | 581 ScrollAnchor m_scrollAnchor; |
589 | 582 |
590 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData; | 583 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData; |
591 | 584 |
592 #if ENABLE(ASSERT) | 585 #if ENABLE(ASSERT) |
593 bool m_hasBeenDisposed; | 586 bool m_hasBeenDisposed; |
594 #endif | 587 #endif |
595 }; | 588 }; |
596 | 589 |
597 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, | 590 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, |
598 ScrollableArea, | 591 ScrollableArea, |
599 scrollableArea, | 592 scrollableArea, |
600 scrollableArea->isPaintLayerScrollableArea(), | 593 scrollableArea->isPaintLayerScrollableArea(), |
601 scrollableArea.isPaintLayerScrollableArea()); | 594 scrollableArea.isPaintLayerScrollableArea()); |
602 | 595 |
603 } // namespace blink | 596 } // namespace blink |
604 | 597 |
605 #endif // LayerScrollableArea_h | 598 #endif // LayerScrollableArea_h |
OLD | NEW |