Chromium Code Reviews| 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(static_cast<double>(frameVi ew->contentsWidth()), xOffset)); |
|
Rick Byers
2014/10/02 21:44:06
Do you really need this static_cast here? I would
Yufeng Shen (Slow to review)
2014/10/02 23:34:34
min<double>(a,b) works but not implicit conversion
| |
| 472 yOffset = std::max(0, std::min(frameView->contentsHeight(), yOffset)); | 472 yOffset = std::max(0.0, std::min(static_cast<double>(frameVi ew->contentsHeight()), 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 lastKnownMousePosition = previousMousePosition; | 803 lastKnownMousePosition = previousMousePosition; |
| 804 else | 804 else |
| 805 previousMousePosition = lastKnownMousePosition; | 805 previousMousePosition = lastKnownMousePosition; |
| 806 | 806 |
| 807 IntSize delta = lastKnownMousePosition - sourcePoint; | 807 IntSize delta = lastKnownMousePosition - sourcePoint; |
| 808 | 808 |
| 809 if (abs(delta.width()) <= ScrollView::noPanScrollRadius) // at the center we let the space for the icon | 809 if (abs(delta.width()) <= ScrollView::noPanScrollRadius) // at the center we let the space for the icon |
| 810 delta.setWidth(0); | 810 delta.setWidth(0); |
| 811 if (abs(delta.height()) <= ScrollView::noPanScrollRadius) | 811 if (abs(delta.height()) <= ScrollView::noPanScrollRadius) |
| 812 delta.setHeight(0); | 812 delta.setHeight(0); |
| 813 | 813 DoubleSize adjustedDelta = adjustedScrollDelta(delta); |
| 814 scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped); | 814 scrollByRecursively(adjustedDelta, ScrollOffsetClamped); |
| 815 } | 815 } |
| 816 | 816 |
| 817 void RenderBox::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping c lamp) | 817 void RenderBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin g clamp) |
| 818 { | 818 { |
| 819 if (delta.isZero()) | 819 if (delta.isZero()) |
| 820 return; | 820 return; |
| 821 | 821 |
| 822 bool restrictedByLineClamp = false; | 822 bool restrictedByLineClamp = false; |
| 823 if (parent()) | 823 if (parent()) |
| 824 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 824 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
| 825 | 825 |
| 826 if (hasOverflowClip() && !restrictedByLineClamp) { | 826 if (hasOverflowClip() && !restrictedByLineClamp) { |
| 827 IntSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOffse t() + delta; | 827 DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOf fset() + delta; |
| 828 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); | 828 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); |
| 829 | 829 |
| 830 // If this layer can't do the scroll we ask the next layer up that can s croll to try | 830 // If this layer can't do the scroll we ask the next layer up that can s croll to try |
| 831 IntSize remainingScrollOffset = newScrollOffset - layer()->scrollableAre a()->adjustedScrollOffset(); | 831 DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollable Area()->adjustedScrollOffset(); |
| 832 if (!remainingScrollOffset.isZero() && parent()) { | 832 if (!remainingScrollOffset.isZero() && parent()) { |
| 833 if (RenderBox* scrollableBox = enclosingScrollableBox()) | 833 if (RenderBox* scrollableBox = enclosingScrollableBox()) |
| 834 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; | 834 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; |
| 835 | 835 |
| 836 LocalFrame* frame = this->frame(); | 836 LocalFrame* frame = this->frame(); |
| 837 if (frame && frame->page()) | 837 if (frame && frame->page()) |
| 838 frame->page()->autoscrollController().updateAutoscrollRenderer() ; | 838 frame->page()->autoscrollController().updateAutoscrollRenderer() ; |
| 839 } | 839 } |
| 840 } else if (view()->frameView()) { | 840 } else if (view()->frameView()) { |
| 841 // If we are here, we were called on a renderer that can be programmatic ally scrolled, but doesn't | 841 // If we are here, we were called on a renderer that can be programmatic ally scrolled, but doesn't |
| 842 // have an overflow clip. Which means that it is a document node that ca n be scrolled. | 842 // have an overflow clip. Which means that it is a document node that ca n be scrolled. |
| 843 view()->frameView()->scrollBy(delta); | 843 // FIXME: Pass in DoubleSize. crbug.com/414283. |
| 844 view()->frameView()->scrollBy(flooredIntSize(delta)); | |
| 844 | 845 |
| 845 // FIXME: If we didn't scroll the whole way, do we want to try looking a t the frames ownerElement? | 846 // FIXME: If we didn't scroll the whole way, do we want to try looking a t the frames ownerElement? |
| 846 // https://bugs.webkit.org/show_bug.cgi?id=28237 | 847 // https://bugs.webkit.org/show_bug.cgi?id=28237 |
| 847 } | 848 } |
| 848 } | 849 } |
| 849 | 850 |
| 850 bool RenderBox::needsPreferredWidthsRecalculation() const | 851 bool RenderBox::needsPreferredWidthsRecalculation() const |
| 851 { | 852 { |
| 852 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen t(); | 853 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen t(); |
| 853 } | 854 } |
| 854 | 855 |
| 855 IntSize RenderBox::scrolledContentOffset() const | 856 IntSize RenderBox::scrolledContentOffset() const |
| 856 { | 857 { |
| 857 ASSERT(hasOverflowClip()); | 858 ASSERT(hasOverflowClip()); |
| 858 ASSERT(hasLayer()); | 859 ASSERT(hasLayer()); |
| 859 return layer()->scrollableArea()->scrollOffset(); | 860 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); |
|
Rick Byers
2014/10/02 21:44:05
We need a FIXME here, right?
Yufeng Shen (Slow to review)
2014/10/02 23:34:34
Done.
| |
| 860 } | 861 } |
| 861 | 862 |
| 862 void RenderBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p aintRect) const | 863 void RenderBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p aintRect) const |
| 863 { | 864 { |
| 864 ASSERT(hasLayer()); | 865 ASSERT(hasLayer()); |
| 865 ASSERT(hasOverflowClip()); | 866 ASSERT(hasOverflowClip()); |
| 866 | 867 |
| 867 flipForWritingMode(paintRect); | 868 flipForWritingMode(paintRect); |
| 868 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden . | 869 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden . |
| 869 | 870 |
| (...skipping 3653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4523 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); | 4524 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); |
| 4524 | 4525 |
| 4525 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) | 4526 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) |
| 4526 return m_rareData->m_previousBorderBoxSize; | 4527 return m_rareData->m_previousBorderBoxSize; |
| 4527 | 4528 |
| 4528 // We didn't save the old border box size because it was the same as the siz e of oldBounds. | 4529 // We didn't save the old border box size because it was the same as the siz e of oldBounds. |
| 4529 return previousBoundsSize; | 4530 return previousBoundsSize; |
| 4530 } | 4531 } |
| 4531 | 4532 |
| 4532 } // namespace blink | 4533 } // namespace blink |
| OLD | NEW |