| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 return DoublePoint(m_scrollOffset); | 482 return DoublePoint(m_scrollOffset); |
| 483 } | 483 } |
| 484 | 484 |
| 485 IntPoint DeprecatedPaintLayerScrollableArea::minimumScrollPosition() const | 485 IntPoint DeprecatedPaintLayerScrollableArea::minimumScrollPosition() const |
| 486 { | 486 { |
| 487 return -scrollOrigin(); | 487 return -scrollOrigin(); |
| 488 } | 488 } |
| 489 | 489 |
| 490 IntPoint DeprecatedPaintLayerScrollableArea::maximumScrollPosition() const | 490 IntPoint DeprecatedPaintLayerScrollableArea::maximumScrollPosition() const |
| 491 { | 491 { |
| 492 if (!box().hasOverflowClip()) | 492 IntSize contentSize; |
| 493 return -scrollOrigin(); | 493 IntSize visibleSize; |
| 494 return -scrollOrigin() + IntPoint(pixelSnappedScrollWidth(), pixelSnappedScr
ollHeight()) - enclosingIntRect(box().clientBoxRect()).size(); | 494 if (layer()->isRootLayer()) { |
| 495 FrameView* frameView = box().frameView(); |
| 496 contentSize = frameView->contentsSize(); |
| 497 visibleSize = frameView->visibleContentSize(ExcludeScrollbars) + frameVi
ew->topControlsSize(); |
| 498 } else if (box().hasOverflowClip()) { |
| 499 contentSize = IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeigh
t()); |
| 500 visibleSize = enclosingIntRect(box().clientBoxRect()).size(); |
| 501 } |
| 502 return -scrollOrigin() + (contentSize - visibleSize); |
| 495 } | 503 } |
| 496 | 504 |
| 497 IntRect DeprecatedPaintLayerScrollableArea::visibleContentRect(IncludeScrollbars
InRect scrollbarInclusion) const | 505 IntRect DeprecatedPaintLayerScrollableArea::visibleContentRect(IncludeScrollbars
InRect scrollbarInclusion) const |
| 498 { | 506 { |
| 499 int verticalScrollbarWidth = 0; | 507 int verticalScrollbarWidth = 0; |
| 500 int horizontalScrollbarHeight = 0; | 508 int horizontalScrollbarHeight = 0; |
| 501 if (scrollbarInclusion == IncludeScrollbars) { | 509 if (scrollbarInclusion == IncludeScrollbars) { |
| 502 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; | 510 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; |
| 503 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; | 511 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; |
| 504 } | 512 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 void DeprecatedPaintLayerScrollableArea::computeScrollDimensions() | 643 void DeprecatedPaintLayerScrollableArea::computeScrollDimensions() |
| 636 { | 644 { |
| 637 m_overflowRect = box().layoutOverflowRect(); | 645 m_overflowRect = box().layoutOverflowRect(); |
| 638 box().flipForWritingMode(m_overflowRect); | 646 box().flipForWritingMode(m_overflowRect); |
| 639 | 647 |
| 640 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box(
).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr
ollbarWidth() : 0); | 648 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box(
).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr
ollbarWidth() : 0); |
| 641 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); | 649 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); |
| 642 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 650 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
| 643 } | 651 } |
| 644 | 652 |
| 645 void DeprecatedPaintLayerScrollableArea::scrollToOffset(const DoubleSize& scroll
Offset, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior) | 653 void DeprecatedPaintLayerScrollableArea::scrollToPosition(const DoublePoint& scr
ollPosition, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior) |
| 646 { | 654 { |
| 647 cancelProgrammaticScrollAnimation(); | 655 cancelProgrammaticScrollAnimation(); |
| 648 DoubleSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffse
t(scrollOffset) : scrollOffset; | 656 |
| 649 if (newScrollOffset != adjustedScrollOffset()) { | 657 DoublePoint newScrollPosition = clamp == ScrollOffsetClamped ? clampScrollPo
sition(scrollPosition) : scrollPosition; |
| 650 DoublePoint origin(scrollOrigin()); | 658 if (newScrollPosition != scrollPositionDouble()) |
| 651 ScrollableArea::setScrollPosition(-origin + newScrollOffset, Programmati
cScroll, scrollBehavior); | 659 ScrollableArea::setScrollPosition(newScrollPosition, ProgrammaticScroll,
scrollBehavior); |
| 652 } | |
| 653 } | 660 } |
| 654 | 661 |
| 655 void DeprecatedPaintLayerScrollableArea::updateScrollDimensions(DoubleSize& scro
llOffset, bool& autoHorizontalScrollBarChanged, bool& autoVerticalScrollBarChang
ed) | 662 void DeprecatedPaintLayerScrollableArea::updateScrollDimensions(DoubleSize& scro
llOffset, bool& autoHorizontalScrollBarChanged, bool& autoVerticalScrollBarChang
ed) |
| 656 { | 663 { |
| 657 ASSERT(box().hasOverflowClip()); | 664 ASSERT(box().hasOverflowClip()); |
| 658 | 665 |
| 659 if (needsScrollbarReconstruction()) { | 666 if (needsScrollbarReconstruction()) { |
| 660 if (m_hBar) | 667 if (m_hBar) |
| 661 destroyScrollbar(HorizontalScrollbar); | 668 destroyScrollbar(HorizontalScrollbar); |
| 662 if (m_vBar) | 669 if (m_vBar) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 684 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true
: hasVerticalOverflow); | 691 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true
: hasVerticalOverflow); |
| 685 } | 692 } |
| 686 } | 693 } |
| 687 | 694 |
| 688 void DeprecatedPaintLayerScrollableArea::finalizeScrollDimensions(const DoubleSi
ze& originalScrollOffset, bool autoHorizontalScrollBarChanged, bool autoVertical
ScrollBarChanged) | 695 void DeprecatedPaintLayerScrollableArea::finalizeScrollDimensions(const DoubleSi
ze& originalScrollOffset, bool autoHorizontalScrollBarChanged, bool autoVertical
ScrollBarChanged) |
| 689 { | 696 { |
| 690 ASSERT(box().hasOverflowClip()); | 697 ASSERT(box().hasOverflowClip()); |
| 691 | 698 |
| 692 // Layout may cause us to be at an invalid scroll position. In this case we
need | 699 // Layout may cause us to be at an invalid scroll position. In this case we
need |
| 693 // to pull our scroll offsets back to the max (or push them up to the min). | 700 // to pull our scroll offsets back to the max (or push them up to the min). |
| 694 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); | 701 DoublePoint clampedScrollPosition = clampScrollPosition(scrollPositionDouble
()); |
| 695 if (clampedScrollOffset != adjustedScrollOffset()) | 702 if (clampedScrollPosition != scrollPositionDouble()) |
| 696 scrollToOffset(clampedScrollOffset); | 703 scrollToPosition(clampedScrollPosition); |
| 697 | 704 |
| 698 if (originalScrollOffset != adjustedScrollOffset()) { | 705 if (originalScrollOffset != adjustedScrollOffset()) { |
| 699 DoublePoint origin(scrollOrigin()); | 706 DoublePoint origin(scrollOrigin()); |
| 700 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro
ll); | 707 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro
ll); |
| 701 } | 708 } |
| 702 | 709 |
| 703 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 710 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 704 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 711 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 705 | 712 |
| 706 { | 713 { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 } | 903 } |
| 897 | 904 |
| 898 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 905 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 899 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 906 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 900 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); | 907 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); |
| 901 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); | 908 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); |
| 902 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) | 909 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) |
| 903 box().setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::U
nknown); | 910 box().setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::U
nknown); |
| 904 } | 911 } |
| 905 | 912 |
| 906 DoubleSize DeprecatedPaintLayerScrollableArea::clampScrollOffset(const DoubleSiz
e& scrollOffset) const | |
| 907 { | |
| 908 int maxX = scrollWidth() - box().pixelSnappedClientWidth(); | |
| 909 int maxY = scrollHeight() - box().pixelSnappedClientHeight(); | |
| 910 | |
| 911 double x = std::max(std::min(scrollOffset.width(), static_cast<double>(maxX)
), 0.0); | |
| 912 double y = std::max(std::min(scrollOffset.height(), static_cast<double>(maxY
)), 0.0); | |
| 913 return DoubleSize(x, y); | |
| 914 } | |
| 915 | |
| 916 IntRect DeprecatedPaintLayerScrollableArea::rectForHorizontalScrollbar(const Int
Rect& borderBoxRect) const | 913 IntRect DeprecatedPaintLayerScrollableArea::rectForHorizontalScrollbar(const Int
Rect& borderBoxRect) const |
| 917 { | 914 { |
| 918 if (!m_hBar) | 915 if (!m_hBar) |
| 919 return IntRect(); | 916 return IntRect(); |
| 920 | 917 |
| 921 const IntRect& scrollCorner = scrollCornerRect(); | 918 const IntRect& scrollCorner = scrollCornerRect(); |
| 922 | 919 |
| 923 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), | 920 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), |
| 924 borderBoxRect.maxY() - box().borderBottom() - m_hBar->height(), | 921 borderBoxRect.maxY() - box().borderBottom() - m_hBar->height(), |
| 925 borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scr
ollCorner.width(), | 922 borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scr
ollCorner.width(), |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. | 1392 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. |
| 1396 } | 1393 } |
| 1397 | 1394 |
| 1398 LayoutRect DeprecatedPaintLayerScrollableArea::scrollIntoView(const LayoutRect&
rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY) | 1395 LayoutRect DeprecatedPaintLayerScrollableArea::scrollIntoView(const LayoutRect&
rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY) |
| 1399 { | 1396 { |
| 1400 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec
t)), UseTransforms).boundingBox()); | 1397 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec
t)), UseTransforms).boundingBox()); |
| 1401 localExposeRect.move(-box().borderLeft(), -box().borderTop()); | 1398 localExposeRect.move(-box().borderLeft(), -box().borderTop()); |
| 1402 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); | 1399 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); |
| 1403 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect
, alignX, alignY); | 1400 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect
, alignX, alignY); |
| 1404 | 1401 |
| 1405 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() +
roundedIntSize(r.location())); | 1402 DoublePoint clampedScrollPosition = clampScrollPosition(scrollPositionDouble
() + roundedIntSize(r.location())); |
| 1406 if (clampedScrollOffset == adjustedScrollOffset()) | 1403 if (clampedScrollPosition == scrollPositionDouble()) |
| 1407 return rect; | 1404 return rect; |
| 1408 | 1405 |
| 1409 DoubleSize oldScrollOffset = adjustedScrollOffset(); | 1406 DoubleSize oldScrollOffset = adjustedScrollOffset(); |
| 1410 scrollToOffset(clampedScrollOffset); | 1407 scrollToPosition(clampedScrollPosition); |
| 1411 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset
; | 1408 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset
; |
| 1412 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); | 1409 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); |
| 1413 return LayoutRect(box().localToAbsoluteQuad(FloatQuad(FloatRect(localExposeR
ect)), UseTransforms).boundingBox()); | 1410 return LayoutRect(box().localToAbsoluteQuad(FloatQuad(FloatRect(localExposeR
ect)), UseTransforms).boundingBox()); |
| 1414 } | 1411 } |
| 1415 | 1412 |
| 1416 void DeprecatedPaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflo
w) | 1413 void DeprecatedPaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflo
w) |
| 1417 { | 1414 { |
| 1418 LocalFrame* frame = box().frame(); | 1415 LocalFrame* frame = box().frame(); |
| 1419 if (!frame) | 1416 if (!frame) |
| 1420 return; | 1417 return; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 return false; | 1499 return false; |
| 1503 | 1500 |
| 1504 LocalFrame* frame = box().frame(); | 1501 LocalFrame* frame = box().frame(); |
| 1505 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1502 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1506 return false; | 1503 return false; |
| 1507 | 1504 |
| 1508 return frame->settings()->viewportMetaEnabled(); | 1505 return frame->settings()->viewportMetaEnabled(); |
| 1509 } | 1506 } |
| 1510 | 1507 |
| 1511 } // namespace blink | 1508 } // namespace blink |
| OLD | NEW |