OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
6 * | 6 * |
7 * Other contributors: | 7 * Other contributors: |
8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
10 * Christian Biesinger <cbiesinger@gmail.com> | 10 * Christian Biesinger <cbiesinger@gmail.com> |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 box().document().rootScrollerController()) | 165 box().document().rootScrollerController()) |
166 controller->didDisposePaintLayerScrollableArea(*this); | 166 controller->didDisposePaintLayerScrollableArea(*this); |
167 | 167 |
168 m_scrollbarManager.dispose(); | 168 m_scrollbarManager.dispose(); |
169 | 169 |
170 if (m_scrollCorner) | 170 if (m_scrollCorner) |
171 m_scrollCorner->destroy(); | 171 m_scrollCorner->destroy(); |
172 if (m_resizer) | 172 if (m_resizer) |
173 m_resizer->destroy(); | 173 m_resizer->destroy(); |
174 | 174 |
175 clearScrollAnimators(); | 175 clearScrollableArea(); |
176 | 176 |
177 // Note: it is not safe to call ScrollAnchor::clear if the document is being | 177 // Note: it is not safe to call ScrollAnchor::clear if the document is being |
178 // destroyed, because LayoutObjectChildList::removeChildNode skips the call to | 178 // destroyed, because LayoutObjectChildList::removeChildNode skips the call to |
179 // willBeRemovedFromTree, | 179 // willBeRemovedFromTree, |
180 // leaving the ScrollAnchor with a stale LayoutObject pointer. | 180 // leaving the ScrollAnchor with a stale LayoutObject pointer. |
181 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 181 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
182 !box().documentBeingDestroyed()) | 182 !box().documentBeingDestroyed()) |
183 m_scrollAnchor.clearSelf(); | 183 m_scrollAnchor.clearSelf(); |
184 | 184 |
185 #if DCHECK_IS_ON() | 185 #if DCHECK_IS_ON() |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 maximumScrollOffsetInt() - minimumScrollOffsetInt(); | 361 maximumScrollOffsetInt() - minimumScrollOffsetInt(); |
362 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() | 362 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() |
363 : scrollDimensions.height(); | 363 : scrollDimensions.height(); |
364 } | 364 } |
365 | 365 |
366 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset, | 366 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset, |
367 ScrollType scrollType) { | 367 ScrollType scrollType) { |
368 if (scrollOffset() == newOffset) | 368 if (scrollOffset() == newOffset) |
369 return; | 369 return; |
370 | 370 |
| 371 showOverlayScrollbars(); |
371 ScrollOffset scrollDelta = scrollOffset() - newOffset; | 372 ScrollOffset scrollDelta = scrollOffset() - newOffset; |
372 m_scrollOffset = newOffset; | 373 m_scrollOffset = newOffset; |
373 | 374 |
374 LocalFrame* frame = box().frame(); | 375 LocalFrame* frame = box().frame(); |
375 DCHECK(frame); | 376 DCHECK(frame); |
376 | 377 |
377 FrameView* frameView = box().frameView(); | 378 FrameView* frameView = box().frameView(); |
378 | 379 |
379 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", | 380 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", |
380 InspectorScrollLayerEvent::data(&box())); | 381 InspectorScrollLayerEvent::data(&box())); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 : 0; | 509 : 0; |
509 } | 510 } |
510 | 511 |
511 // TODO(szager): Handle fractional scroll offsets correctly. | 512 // TODO(szager): Handle fractional scroll offsets correctly. |
512 return IntRect( | 513 return IntRect( |
513 flooredIntPoint(scrollPosition()), | 514 flooredIntPoint(scrollPosition()), |
514 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), | 515 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), |
515 max(0, layer()->size().height() - horizontalScrollbarHeight))); | 516 max(0, layer()->size().height() - horizontalScrollbarHeight))); |
516 } | 517 } |
517 | 518 |
| 519 void PaintLayerScrollableArea::visibleSizeChanged() { |
| 520 showOverlayScrollbars(); |
| 521 } |
| 522 |
518 int PaintLayerScrollableArea::visibleHeight() const { | 523 int PaintLayerScrollableArea::visibleHeight() const { |
519 return layer()->size().height(); | 524 return layer()->size().height(); |
520 } | 525 } |
521 | 526 |
522 int PaintLayerScrollableArea::visibleWidth() const { | 527 int PaintLayerScrollableArea::visibleWidth() const { |
523 return layer()->size().width(); | 528 return layer()->size().width(); |
524 } | 529 } |
525 | 530 |
526 IntSize PaintLayerScrollableArea::contentsSize() const { | 531 IntSize PaintLayerScrollableArea::contentsSize() const { |
527 return IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight()); | 532 return IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 if (overflowRect().isEmpty()) | 640 if (overflowRect().isEmpty()) |
636 return; | 641 return; |
637 LayoutPoint scrollableOverflow = | 642 LayoutPoint scrollableOverflow = |
638 m_overflowRect.location() - | 643 m_overflowRect.location() - |
639 LayoutSize(box().borderLeft(), box().borderTop()); | 644 LayoutSize(box().borderLeft(), box().borderTop()); |
640 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + | 645 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + |
641 box().originAdjustmentForScrollbars()); | 646 box().originAdjustmentForScrollbars()); |
642 } | 647 } |
643 | 648 |
644 void PaintLayerScrollableArea::updateScrollDimensions() { | 649 void PaintLayerScrollableArea::updateScrollDimensions() { |
| 650 if (m_overflowRect.size() != box().layoutOverflowRect().size()) |
| 651 contentsResized(); |
645 m_overflowRect = box().layoutOverflowRect(); | 652 m_overflowRect = box().layoutOverflowRect(); |
646 box().flipForWritingMode(m_overflowRect); | 653 box().flipForWritingMode(m_overflowRect); |
647 updateScrollOrigin(); | 654 updateScrollOrigin(); |
648 } | 655 } |
649 | 656 |
650 void PaintLayerScrollableArea::setScrollOffsetUnconditionally( | 657 void PaintLayerScrollableArea::setScrollOffsetUnconditionally( |
651 const ScrollOffset& offset, | 658 const ScrollOffset& offset, |
652 ScrollType scrollType) { | 659 ScrollType scrollType) { |
653 cancelScrollAnimation(); | 660 cancelScrollAnimation(); |
654 scrollOffsetChanged(offset, scrollType); | 661 scrollOffsetChanged(offset, scrollType); |
655 } | 662 } |
656 | 663 |
657 void PaintLayerScrollableArea::didChangeScrollbarsHidden() { | |
658 updateScrollbarsEnabledState(); | |
659 } | |
660 | |
661 void PaintLayerScrollableArea::updateScrollbarsEnabledState() { | |
662 // overflow:scroll should just enable/disable. | |
663 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) { | |
664 horizontalScrollbar()->setEnabled(hasHorizontalOverflow() && | |
665 !scrollbarsHidden()); | |
666 } | |
667 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) { | |
668 verticalScrollbar()->setEnabled(hasVerticalOverflow() && | |
669 !scrollbarsHidden()); | |
670 } | |
671 } | |
672 | |
673 void PaintLayerScrollableArea::updateAfterLayout() { | 664 void PaintLayerScrollableArea::updateAfterLayout() { |
674 DCHECK(box().hasOverflowClip()); | 665 DCHECK(box().hasOverflowClip()); |
675 | 666 |
676 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented(); | 667 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented(); |
677 bool scrollbarsAreFrozen = | 668 bool scrollbarsAreFrozen = |
678 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); | 669 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); |
679 | 670 |
680 if (needsScrollbarReconstruction()) { | 671 if (needsScrollbarReconstruction()) { |
681 setHasHorizontalScrollbar(false); | 672 setHasHorizontalScrollbar(false); |
682 setHasVerticalScrollbar(false); | 673 setHasVerticalScrollbar(false); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 if (parent && parent->isFlexibleBox()) | 740 if (parent && parent->isFlexibleBox()) |
750 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box()); | 741 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box()); |
751 } | 742 } |
752 } | 743 } |
753 | 744 |
754 { | 745 { |
755 // Hits in | 746 // Hits in |
756 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st
yle-change.html. | 747 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st
yle-change.html. |
757 DisableCompositingQueryAsserts disabler; | 748 DisableCompositingQueryAsserts disabler; |
758 | 749 |
759 updateScrollbarsEnabledState(); | 750 // overflow:scroll should just enable/disable. |
| 751 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) |
| 752 horizontalScrollbar()->setEnabled(hasHorizontalOverflow()); |
| 753 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) |
| 754 verticalScrollbar()->setEnabled(hasVerticalOverflow()); |
760 | 755 |
761 // Set up the range (and page step/line step). | 756 // Set up the range (and page step/line step). |
762 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 757 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
763 int clientWidth = box().pixelSnappedClientWidth(); | 758 int clientWidth = box().pixelSnappedClientWidth(); |
764 horizontalScrollbar->setProportion(clientWidth, | 759 horizontalScrollbar->setProportion(clientWidth, |
765 overflowRect().width().toInt()); | 760 overflowRect().width().toInt()); |
766 } | 761 } |
767 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { | 762 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { |
768 int clientHeight = box().pixelSnappedClientHeight(); | 763 int clientHeight = box().pixelSnappedClientHeight(); |
769 verticalScrollbar->setProportion(clientHeight, | 764 verticalScrollbar->setProportion(clientHeight, |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 | 1967 |
1973 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 1968 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
1974 clampScrollableAreas() { | 1969 clampScrollableAreas() { |
1975 for (auto& scrollableArea : *s_needsClamp) | 1970 for (auto& scrollableArea : *s_needsClamp) |
1976 scrollableArea->clampScrollOffsetsAfterLayout(); | 1971 scrollableArea->clampScrollOffsetsAfterLayout(); |
1977 delete s_needsClamp; | 1972 delete s_needsClamp; |
1978 s_needsClamp = nullptr; | 1973 s_needsClamp = nullptr; |
1979 } | 1974 } |
1980 | 1975 |
1981 } // namespace blink | 1976 } // namespace blink |
OLD | NEW |