| 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 clearScrollAnimators(); | 173 clearScrollableArea(); |
| 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(); |
| 369 ScrollOffset scrollDelta = scrollOffset() - newOffset; | 370 ScrollOffset scrollDelta = scrollOffset() - newOffset; |
| 370 m_scrollOffset = newOffset; | 371 m_scrollOffset = newOffset; |
| 371 | 372 |
| 372 LocalFrame* frame = box().frame(); | 373 LocalFrame* frame = box().frame(); |
| 373 ASSERT(frame); | 374 ASSERT(frame); |
| 374 | 375 |
| 375 FrameView* frameView = box().frameView(); | 376 FrameView* frameView = box().frameView(); |
| 376 | 377 |
| 377 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", | 378 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", |
| 378 InspectorScrollLayerEvent::data(&box())); | 379 InspectorScrollLayerEvent::data(&box())); |
| (...skipping 129 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::visibleContentResized() { |
| 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 11 matching lines...) Expand all Loading... |
| 539 } | 544 } |
| 540 | 545 |
| 541 bool PaintLayerScrollableArea::shouldSuspendScrollAnimations() const { | 546 bool PaintLayerScrollableArea::shouldSuspendScrollAnimations() const { |
| 542 LayoutView* view = box().view(); | 547 LayoutView* view = box().view(); |
| 543 if (!view) | 548 if (!view) |
| 544 return true; | 549 return true; |
| 545 return view->frameView()->shouldSuspendScrollAnimations(); | 550 return view->frameView()->shouldSuspendScrollAnimations(); |
| 546 } | 551 } |
| 547 | 552 |
| 548 void PaintLayerScrollableArea::scrollbarVisibilityChanged() { | 553 void PaintLayerScrollableArea::scrollbarVisibilityChanged() { |
| 554 updateScrollbarsEnabledState(); |
| 549 if (LayoutView* view = box().view()) | 555 if (LayoutView* view = box().view()) |
| 550 return view->clearHitTestCache(); | 556 return view->clearHitTestCache(); |
| 551 } | 557 } |
| 552 | 558 |
| 553 bool PaintLayerScrollableArea::scrollbarsCanBeActive() const { | 559 bool PaintLayerScrollableArea::scrollbarsCanBeActive() const { |
| 554 LayoutView* view = box().view(); | 560 LayoutView* view = box().view(); |
| 555 if (!view) | 561 if (!view) |
| 556 return false; | 562 return false; |
| 557 return view->frameView()->scrollbarsCanBeActive(); | 563 return view->frameView()->scrollbarsCanBeActive(); |
| 558 } | 564 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 if (overflowRect().isEmpty()) | 641 if (overflowRect().isEmpty()) |
| 636 return; | 642 return; |
| 637 LayoutPoint scrollableOverflow = | 643 LayoutPoint scrollableOverflow = |
| 638 m_overflowRect.location() - | 644 m_overflowRect.location() - |
| 639 LayoutSize(box().borderLeft(), box().borderTop()); | 645 LayoutSize(box().borderLeft(), box().borderTop()); |
| 640 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + | 646 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + |
| 641 box().originAdjustmentForScrollbars()); | 647 box().originAdjustmentForScrollbars()); |
| 642 } | 648 } |
| 643 | 649 |
| 644 void PaintLayerScrollableArea::updateScrollDimensions() { | 650 void PaintLayerScrollableArea::updateScrollDimensions() { |
| 651 if (m_overflowRect.size() != box().layoutOverflowRect().size()) |
| 652 contentsResized(); |
| 645 m_overflowRect = box().layoutOverflowRect(); | 653 m_overflowRect = box().layoutOverflowRect(); |
| 646 box().flipForWritingMode(m_overflowRect); | 654 box().flipForWritingMode(m_overflowRect); |
| 647 updateScrollOrigin(); | 655 updateScrollOrigin(); |
| 648 } | 656 } |
| 649 | 657 |
| 650 void PaintLayerScrollableArea::setScrollOffsetUnconditionally( | 658 void PaintLayerScrollableArea::setScrollOffsetUnconditionally( |
| 651 const ScrollOffset& offset, | 659 const ScrollOffset& offset, |
| 652 ScrollType scrollType) { | 660 ScrollType scrollType) { |
| 653 cancelScrollAnimation(); | 661 cancelScrollAnimation(); |
| 654 scrollOffsetChanged(offset, scrollType); | 662 scrollOffsetChanged(offset, scrollType); |
| 655 } | 663 } |
| 656 | 664 |
| 657 void PaintLayerScrollableArea::didChangeScrollbarsHidden() { | |
| 658 updateScrollbarsEnabledState(); | |
| 659 } | |
| 660 | |
| 661 void PaintLayerScrollableArea::updateScrollbarsEnabledState() { | 665 void PaintLayerScrollableArea::updateScrollbarsEnabledState() { |
| 662 // overflow:scroll should just enable/disable. | 666 // overflow:scroll should just enable/disable. |
| 663 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) { | 667 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) { |
| 664 horizontalScrollbar()->setEnabled(hasHorizontalOverflow() && | 668 horizontalScrollbar()->setEnabled(hasHorizontalOverflow() && |
| 665 !scrollbarsHidden()); | 669 !scrollbarsHidden()); |
| 666 } | 670 } |
| 667 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) { | 671 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) { |
| 668 verticalScrollbar()->setEnabled(hasVerticalOverflow() && | 672 verticalScrollbar()->setEnabled(hasVerticalOverflow() && |
| 669 !scrollbarsHidden()); | 673 !scrollbarsHidden()); |
| 670 } | 674 } |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 | 1967 |
| 1964 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 1968 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 1965 clampScrollableAreas() { | 1969 clampScrollableAreas() { |
| 1966 for (auto& scrollableArea : *s_needsClamp) | 1970 for (auto& scrollableArea : *s_needsClamp) |
| 1967 scrollableArea->clampScrollOffsetsAfterLayout(); | 1971 scrollableArea->clampScrollOffsetsAfterLayout(); |
| 1968 delete s_needsClamp; | 1972 delete s_needsClamp; |
| 1969 s_needsClamp = nullptr; | 1973 s_needsClamp = nullptr; |
| 1970 } | 1974 } |
| 1971 | 1975 |
| 1972 } // namespace blink | 1976 } // namespace blink |
| OLD | NEW |