| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 void RenderBox::setScrollTop(LayoutUnit newTop) | 403 void RenderBox::setScrollTop(LayoutUnit newTop) |
| 404 { | 404 { |
| 405 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers
.html | 405 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers
.html |
| 406 DisableCompositingQueryAsserts disabler; | 406 DisableCompositingQueryAsserts disabler; |
| 407 | 407 |
| 408 if (hasOverflowClip()) | 408 if (hasOverflowClip()) |
| 409 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped); | 409 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void RenderBox::scrollToOffset(const IntSize& offset) | 412 void RenderBox::scrollToOffset(const DoubleSize& offset) |
| 413 { | 413 { |
| 414 ASSERT(hasOverflowClip()); | 414 ASSERT(hasOverflowClip()); |
| 415 | 415 |
| 416 // This doesn't hit in any tests, but since the equivalent code in setScroll
Top | 416 // This doesn't hit in any tests, but since the equivalent code in setScroll
Top |
| 417 // does, presumably this code does as well. | 417 // does, presumably this code does as well. |
| 418 DisableCompositingQueryAsserts disabler; | 418 DisableCompositingQueryAsserts disabler; |
| 419 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped); | 419 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped); |
| 420 } | 420 } |
| 421 | 421 |
| 422 static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
ementBase, FrameView* frameView) | 422 static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
ementBase, FrameView* frameView) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } else if (!parentBox && canBeProgramaticallyScrolled()) { | 458 } else if (!parentBox && canBeProgramaticallyScrolled()) { |
| 459 if (FrameView* frameView = this->frameView()) { | 459 if (FrameView* frameView = this->frameView()) { |
| 460 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); | 460 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); |
| 461 | 461 |
| 462 if (ownerElement && ownerElement->renderer()) { | 462 if (ownerElement && ownerElement->renderer()) { |
| 463 HTMLFrameElementBase* frameElementBase = isHTMLFrameElementBase(
*ownerElement) ? toHTMLFrameElementBase(ownerElement) : 0; | 463 HTMLFrameElementBase* frameElementBase = isHTMLFrameElementBase(
*ownerElement) ? toHTMLFrameElementBase(ownerElement) : 0; |
| 464 if (frameElementAndViewPermitScroll(frameElementBase, frameView)
) { | 464 if (frameElementAndViewPermitScroll(frameElementBase, frameView)
) { |
| 465 LayoutRect viewRect = frameView->visibleContentRect(); | 465 LayoutRect viewRect = frameView->visibleContentRect(); |
| 466 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(vie
wRect, rect, alignX, alignY); | 466 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(vie
wRect, rect, alignX, alignY); |
| 467 | 467 |
| 468 int xOffset = roundToInt(exposeRect.x()); | 468 double xOffset = exposeRect.x(); |
| 469 int yOffset = roundToInt(exposeRect.y()); | 469 double yOffset = exposeRect.y(); |
| 470 // Adjust offsets if they're outside of the allowable range. | 470 // Adjust offsets if they're outside of the allowable range. |
| 471 xOffset = std::max(0, std::min(frameView->contentsWidth(), x
Offset)); | 471 xOffset = std::max(0.0, std::min<double>(frameView->contents
Width(), xOffset)); |
| 472 yOffset = std::max(0, std::min(frameView->contentsHeight(),
yOffset)); | 472 yOffset = std::max(0.0, std::min<double>(frameView->contents
Height(), yOffset)); |
| 473 | 473 |
| 474 frameView->setScrollPosition(IntPoint(xOffset, yOffset)); | 474 frameView->setScrollPosition(DoublePoint(xOffset, yOffset)); |
| 475 if (frameView->safeToPropagateScrollToParent()) { | 475 if (frameView->safeToPropagateScrollToParent()) { |
| 476 parentBox = ownerElement->renderer()->enclosingBox(); | 476 parentBox = ownerElement->renderer()->enclosingBox(); |
| 477 // FIXME: This doesn't correctly convert the rect to | 477 // FIXME: This doesn't correctly convert the rect to |
| 478 // absolute coordinates in the parent. | 478 // absolute coordinates in the parent. |
| 479 newRect.setX(rect.x() - frameView->scrollX() + frameView
->x()); | 479 newRect.setX(rect.x() - frameView->scrollX() + frameView
->x()); |
| 480 newRect.setY(rect.y() - frameView->scrollY() + frameView
->y()); | 480 newRect.setY(rect.y() - frameView->scrollY() + frameView
->y()); |
| 481 } else { | 481 } else { |
| 482 parentBox = 0; | 482 parentBox = 0; |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 } else { | 485 } else { |
| 486 if (frame()->settings()->pinchVirtualViewportEnabled()) { | 486 if (frame()->settings()->pinchVirtualViewportEnabled()) { |
| 487 PinchViewport& pinchViewport = frame()->page()->frameHost().
pinchViewport(); | 487 PinchViewport& pinchViewport = frame()->page()->frameHost().
pinchViewport(); |
| 488 LayoutRect r = ScrollAlignment::getRectToExpose(LayoutRect(p
inchViewport.visibleRectInDocument()), rect, alignX, alignY); | 488 LayoutRect r = ScrollAlignment::getRectToExpose(LayoutRect(p
inchViewport.visibleRectInDocument()), rect, alignX, alignY); |
| 489 pinchViewport.scrollIntoView(r); | 489 pinchViewport.scrollIntoView(r); |
| 490 } else { | 490 } else { |
| 491 LayoutRect viewRect = frameView->visibleContentRect(); | 491 LayoutRect viewRect = frameView->visibleContentRect(); |
| 492 LayoutRect r = ScrollAlignment::getRectToExpose(viewRect, re
ct, alignX, alignY); | 492 LayoutRect r = ScrollAlignment::getRectToExpose(viewRect, re
ct, alignX, alignY); |
| 493 frameView->setScrollPosition(roundedIntPoint(r.location())); | 493 frameView->setScrollPosition(DoublePoint(r.location())); |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 | 498 |
| 499 if (frame()->page()->autoscrollController().autoscrollInProgress()) | 499 if (frame()->page()->autoscrollController().autoscrollInProgress()) |
| 500 parentBox = enclosingScrollableBox(); | 500 parentBox = enclosingScrollableBox(); |
| 501 | 501 |
| 502 if (parentBox) | 502 if (parentBox) |
| 503 parentBox->scrollRectToVisible(newRect, alignX, alignY); | 503 parentBox->scrollRectToVisible(newRect, alignX, alignY); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 lastKnownMousePosition = previousMousePosition; | 798 lastKnownMousePosition = previousMousePosition; |
| 799 else | 799 else |
| 800 previousMousePosition = lastKnownMousePosition; | 800 previousMousePosition = lastKnownMousePosition; |
| 801 | 801 |
| 802 IntSize delta = lastKnownMousePosition - sourcePoint; | 802 IntSize delta = lastKnownMousePosition - sourcePoint; |
| 803 | 803 |
| 804 if (abs(delta.width()) <= ScrollView::noPanScrollRadius) // at the center we
let the space for the icon | 804 if (abs(delta.width()) <= ScrollView::noPanScrollRadius) // at the center we
let the space for the icon |
| 805 delta.setWidth(0); | 805 delta.setWidth(0); |
| 806 if (abs(delta.height()) <= ScrollView::noPanScrollRadius) | 806 if (abs(delta.height()) <= ScrollView::noPanScrollRadius) |
| 807 delta.setHeight(0); | 807 delta.setHeight(0); |
| 808 | |
| 809 scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped); | 808 scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped); |
| 810 } | 809 } |
| 811 | 810 |
| 812 void RenderBox::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping c
lamp) | 811 void RenderBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin
g clamp) |
| 813 { | 812 { |
| 814 if (delta.isZero()) | 813 if (delta.isZero()) |
| 815 return; | 814 return; |
| 816 | 815 |
| 817 bool restrictedByLineClamp = false; | 816 bool restrictedByLineClamp = false; |
| 818 if (parent()) | 817 if (parent()) |
| 819 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 818 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
| 820 | 819 |
| 821 if (hasOverflowClip() && !restrictedByLineClamp) { | 820 if (hasOverflowClip() && !restrictedByLineClamp) { |
| 822 IntSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOffse
t() + delta; | 821 DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOf
fset() + delta; |
| 823 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); | 822 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); |
| 824 | 823 |
| 825 // If this layer can't do the scroll we ask the next layer up that can s
croll to try | 824 // If this layer can't do the scroll we ask the next layer up that can s
croll to try |
| 826 IntSize remainingScrollOffset = newScrollOffset - layer()->scrollableAre
a()->adjustedScrollOffset(); | 825 DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollable
Area()->adjustedScrollOffset(); |
| 827 if (!remainingScrollOffset.isZero() && parent()) { | 826 if (!remainingScrollOffset.isZero() && parent()) { |
| 828 if (RenderBox* scrollableBox = enclosingScrollableBox()) | 827 if (RenderBox* scrollableBox = enclosingScrollableBox()) |
| 829 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp)
; | 828 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp)
; |
| 830 | 829 |
| 831 LocalFrame* frame = this->frame(); | 830 LocalFrame* frame = this->frame(); |
| 832 if (frame && frame->page()) | 831 if (frame && frame->page()) |
| 833 frame->page()->autoscrollController().updateAutoscrollRenderer()
; | 832 frame->page()->autoscrollController().updateAutoscrollRenderer()
; |
| 834 } | 833 } |
| 835 } else if (view()->frameView()) { | 834 } else if (view()->frameView()) { |
| 836 // If we are here, we were called on a renderer that can be programmatic
ally scrolled, but doesn't | 835 // If we are here, we were called on a renderer that can be programmatic
ally scrolled, but doesn't |
| 837 // have an overflow clip. Which means that it is a document node that ca
n be scrolled. | 836 // have an overflow clip. Which means that it is a document node that ca
n be scrolled. |
| 838 view()->frameView()->scrollBy(delta); | 837 // FIXME: Pass in DoubleSize. crbug.com/414283. |
| 838 view()->frameView()->scrollBy(flooredIntSize(delta)); |
| 839 | 839 |
| 840 // FIXME: If we didn't scroll the whole way, do we want to try looking a
t the frames ownerElement? | 840 // FIXME: If we didn't scroll the whole way, do we want to try looking a
t the frames ownerElement? |
| 841 // https://bugs.webkit.org/show_bug.cgi?id=28237 | 841 // https://bugs.webkit.org/show_bug.cgi?id=28237 |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 | 844 |
| 845 bool RenderBox::needsPreferredWidthsRecalculation() const | 845 bool RenderBox::needsPreferredWidthsRecalculation() const |
| 846 { | 846 { |
| 847 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen
t(); | 847 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen
t(); |
| 848 } | 848 } |
| 849 | 849 |
| 850 IntSize RenderBox::scrolledContentOffset() const | 850 IntSize RenderBox::scrolledContentOffset() const |
| 851 { | 851 { |
| 852 ASSERT(hasOverflowClip()); | 852 ASSERT(hasOverflowClip()); |
| 853 ASSERT(hasLayer()); | 853 ASSERT(hasLayer()); |
| 854 return layer()->scrollableArea()->scrollOffset(); | 854 // FIXME: Return DoubleSize here. crbug.com/414283. |
| 855 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); |
| 855 } | 856 } |
| 856 | 857 |
| 857 void RenderBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p
aintRect) const | 858 void RenderBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p
aintRect) const |
| 858 { | 859 { |
| 859 ASSERT(hasLayer()); | 860 ASSERT(hasLayer()); |
| 860 ASSERT(hasOverflowClip()); | 861 ASSERT(hasOverflowClip()); |
| 861 | 862 |
| 862 flipForWritingMode(paintRect); | 863 flipForWritingMode(paintRect); |
| 863 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden
. | 864 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden
. |
| 864 | 865 |
| (...skipping 3644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4509 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); | 4510 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); |
| 4510 | 4511 |
| 4511 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) | 4512 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) |
| 4512 return m_rareData->m_previousBorderBoxSize; | 4513 return m_rareData->m_previousBorderBoxSize; |
| 4513 | 4514 |
| 4514 // We didn't save the old border box size because it was the same as the siz
e of oldBounds. | 4515 // We didn't save the old border box size because it was the same as the siz
e of oldBounds. |
| 4515 return previousBoundsSize; | 4516 return previousBoundsSize; |
| 4516 } | 4517 } |
| 4517 | 4518 |
| 4518 } // namespace blink | 4519 } // namespace blink |
| OLD | NEW |