| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 box().document().rootScrollerController()) | 163 box().document().rootScrollerController()) |
| 164 controller->didDisposePaintLayerScrollableArea(*this); | 164 controller->didDisposePaintLayerScrollableArea(*this); |
| 165 | 165 |
| 166 m_scrollbarManager.dispose(); | 166 m_scrollbarManager.dispose(); |
| 167 | 167 |
| 168 if (m_scrollCorner) | 168 if (m_scrollCorner) |
| 169 m_scrollCorner->destroy(); | 169 m_scrollCorner->destroy(); |
| 170 if (m_resizer) | 170 if (m_resizer) |
| 171 m_resizer->destroy(); | 171 m_resizer->destroy(); |
| 172 | 172 |
| 173 clearScrollableArea(); | 173 clearScrollAnimators(); |
| 174 | 174 |
| 175 // Note: it is not safe to call ScrollAnchor::clear if the document is being | 175 // Note: it is not safe to call ScrollAnchor::clear if the document is being |
| 176 // destroyed, because LayoutObjectChildList::removeChildNode skips the call to | 176 // destroyed, because LayoutObjectChildList::removeChildNode skips the call to |
| 177 // willBeRemovedFromTree, | 177 // willBeRemovedFromTree, |
| 178 // leaving the ScrollAnchor with a stale LayoutObject pointer. | 178 // leaving the ScrollAnchor with a stale LayoutObject pointer. |
| 179 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 179 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
| 180 !box().documentBeingDestroyed()) | 180 !box().documentBeingDestroyed()) |
| 181 m_scrollAnchor.clearSelf(); | 181 m_scrollAnchor.clearSelf(); |
| 182 | 182 |
| 183 #if ENABLE(ASSERT) | 183 #if ENABLE(ASSERT) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 maximumScrollOffsetInt() - minimumScrollOffsetInt(); | 359 maximumScrollOffsetInt() - minimumScrollOffsetInt(); |
| 360 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() | 360 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() |
| 361 : scrollDimensions.height(); | 361 : scrollDimensions.height(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset, | 364 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset, |
| 365 ScrollType scrollType) { | 365 ScrollType scrollType) { |
| 366 if (scrollOffset() == newOffset) | 366 if (scrollOffset() == newOffset) |
| 367 return; | 367 return; |
| 368 | 368 |
| 369 showOverlayScrollbars(); | |
| 370 ScrollOffset scrollDelta = scrollOffset() - newOffset; | 369 ScrollOffset scrollDelta = scrollOffset() - newOffset; |
| 371 m_scrollOffset = newOffset; | 370 m_scrollOffset = newOffset; |
| 372 | 371 |
| 373 LocalFrame* frame = box().frame(); | 372 LocalFrame* frame = box().frame(); |
| 374 ASSERT(frame); | 373 ASSERT(frame); |
| 375 | 374 |
| 376 FrameView* frameView = box().frameView(); | 375 FrameView* frameView = box().frameView(); |
| 377 | 376 |
| 378 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", | 377 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", |
| 379 InspectorScrollLayerEvent::data(&box())); | 378 InspectorScrollLayerEvent::data(&box())); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 : 0; | 508 : 0; |
| 510 } | 509 } |
| 511 | 510 |
| 512 // TODO(szager): Handle fractional scroll offsets correctly. | 511 // TODO(szager): Handle fractional scroll offsets correctly. |
| 513 return IntRect( | 512 return IntRect( |
| 514 flooredIntPoint(scrollPosition()), | 513 flooredIntPoint(scrollPosition()), |
| 515 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), | 514 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), |
| 516 max(0, layer()->size().height() - horizontalScrollbarHeight))); | 515 max(0, layer()->size().height() - horizontalScrollbarHeight))); |
| 517 } | 516 } |
| 518 | 517 |
| 519 void PaintLayerScrollableArea::visibleSizeChanged() { | |
| 520 showOverlayScrollbars(); | |
| 521 } | |
| 522 | |
| 523 int PaintLayerScrollableArea::visibleHeight() const { | 518 int PaintLayerScrollableArea::visibleHeight() const { |
| 524 return layer()->size().height(); | 519 return layer()->size().height(); |
| 525 } | 520 } |
| 526 | 521 |
| 527 int PaintLayerScrollableArea::visibleWidth() const { | 522 int PaintLayerScrollableArea::visibleWidth() const { |
| 528 return layer()->size().width(); | 523 return layer()->size().width(); |
| 529 } | 524 } |
| 530 | 525 |
| 531 IntSize PaintLayerScrollableArea::contentsSize() const { | 526 IntSize PaintLayerScrollableArea::contentsSize() const { |
| 532 return IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight()); | 527 return IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 544 } | 539 } |
| 545 | 540 |
| 546 bool PaintLayerScrollableArea::shouldSuspendScrollAnimations() const { | 541 bool PaintLayerScrollableArea::shouldSuspendScrollAnimations() const { |
| 547 LayoutView* view = box().view(); | 542 LayoutView* view = box().view(); |
| 548 if (!view) | 543 if (!view) |
| 549 return true; | 544 return true; |
| 550 return view->frameView()->shouldSuspendScrollAnimations(); | 545 return view->frameView()->shouldSuspendScrollAnimations(); |
| 551 } | 546 } |
| 552 | 547 |
| 553 void PaintLayerScrollableArea::scrollbarVisibilityChanged() { | 548 void PaintLayerScrollableArea::scrollbarVisibilityChanged() { |
| 554 updateScrollbarsEnabledState(); | |
| 555 if (LayoutView* view = box().view()) | 549 if (LayoutView* view = box().view()) |
| 556 return view->clearHitTestCache(); | 550 return view->clearHitTestCache(); |
| 557 } | 551 } |
| 558 | 552 |
| 559 bool PaintLayerScrollableArea::scrollbarsCanBeActive() const { | 553 bool PaintLayerScrollableArea::scrollbarsCanBeActive() const { |
| 560 LayoutView* view = box().view(); | 554 LayoutView* view = box().view(); |
| 561 if (!view) | 555 if (!view) |
| 562 return false; | 556 return false; |
| 563 return view->frameView()->scrollbarsCanBeActive(); | 557 return view->frameView()->scrollbarsCanBeActive(); |
| 564 } | 558 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (overflowRect().isEmpty()) | 635 if (overflowRect().isEmpty()) |
| 642 return; | 636 return; |
| 643 LayoutPoint scrollableOverflow = | 637 LayoutPoint scrollableOverflow = |
| 644 m_overflowRect.location() - | 638 m_overflowRect.location() - |
| 645 LayoutSize(box().borderLeft(), box().borderTop()); | 639 LayoutSize(box().borderLeft(), box().borderTop()); |
| 646 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + | 640 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + |
| 647 box().originAdjustmentForScrollbars()); | 641 box().originAdjustmentForScrollbars()); |
| 648 } | 642 } |
| 649 | 643 |
| 650 void PaintLayerScrollableArea::updateScrollDimensions() { | 644 void PaintLayerScrollableArea::updateScrollDimensions() { |
| 651 if (m_overflowRect.size() != box().layoutOverflowRect().size()) | |
| 652 contentsResized(); | |
| 653 m_overflowRect = box().layoutOverflowRect(); | 645 m_overflowRect = box().layoutOverflowRect(); |
| 654 box().flipForWritingMode(m_overflowRect); | 646 box().flipForWritingMode(m_overflowRect); |
| 655 updateScrollOrigin(); | 647 updateScrollOrigin(); |
| 656 } | 648 } |
| 657 | 649 |
| 658 void PaintLayerScrollableArea::setScrollOffsetUnconditionally( | 650 void PaintLayerScrollableArea::setScrollOffsetUnconditionally( |
| 659 const ScrollOffset& offset, | 651 const ScrollOffset& offset, |
| 660 ScrollType scrollType) { | 652 ScrollType scrollType) { |
| 661 cancelScrollAnimation(); | 653 cancelScrollAnimation(); |
| 662 scrollOffsetChanged(offset, scrollType); | 654 scrollOffsetChanged(offset, scrollType); |
| 663 } | 655 } |
| 664 | 656 |
| 657 void PaintLayerScrollableArea::didChangeScrollbarsHidden() { |
| 658 updateScrollbarsEnabledState(); |
| 659 } |
| 660 |
| 665 void PaintLayerScrollableArea::updateScrollbarsEnabledState() { | 661 void PaintLayerScrollableArea::updateScrollbarsEnabledState() { |
| 666 // overflow:scroll should just enable/disable. | 662 // overflow:scroll should just enable/disable. |
| 667 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) { | 663 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) { |
| 668 horizontalScrollbar()->setEnabled(hasHorizontalOverflow() && | 664 horizontalScrollbar()->setEnabled(hasHorizontalOverflow() && |
| 669 !scrollbarsHidden()); | 665 !scrollbarsHidden()); |
| 670 } | 666 } |
| 671 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) { | 667 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) { |
| 672 verticalScrollbar()->setEnabled(hasVerticalOverflow() && | 668 verticalScrollbar()->setEnabled(hasVerticalOverflow() && |
| 673 !scrollbarsHidden()); | 669 !scrollbarsHidden()); |
| 674 } | 670 } |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 | 1963 |
| 1968 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 1964 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 1969 clampScrollableAreas() { | 1965 clampScrollableAreas() { |
| 1970 for (auto& scrollableArea : *s_needsClamp) | 1966 for (auto& scrollableArea : *s_needsClamp) |
| 1971 scrollableArea->clampScrollOffsetsAfterLayout(); | 1967 scrollableArea->clampScrollOffsetsAfterLayout(); |
| 1972 delete s_needsClamp; | 1968 delete s_needsClamp; |
| 1973 s_needsClamp = nullptr; | 1969 s_needsClamp = nullptr; |
| 1974 } | 1970 } |
| 1975 | 1971 |
| 1976 } // namespace blink | 1972 } // namespace blink |
| OLD | NEW |