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. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 frameElementBase->scrollingMode() == ScrollbarAlwaysOff; | 632 frameElementBase->scrollingMode() == ScrollbarAlwaysOff; |
633 } | 633 } |
634 } | 634 } |
635 return false; | 635 return false; |
636 } | 636 } |
637 | 637 |
638 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, | 638 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, |
639 const ScrollAlignment& alignX, | 639 const ScrollAlignment& alignX, |
640 const ScrollAlignment& alignY, | 640 const ScrollAlignment& alignY, |
641 ScrollType scrollType, | 641 ScrollType scrollType, |
642 bool makeVisibleInVisualViewport) { | 642 bool makeVisibleInVisualViewport, |
| 643 ScrollBehavior scrollBehavior) { |
643 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll); | 644 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll); |
644 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 645 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
645 DisableCompositingQueryAsserts disabler; | 646 DisableCompositingQueryAsserts disabler; |
646 | 647 |
647 LayoutRect rectToScroll = rect; | 648 LayoutRect rectToScroll = rect; |
648 if (rectToScroll.width() <= 0) | 649 if (rectToScroll.width() <= 0) |
649 rectToScroll.setWidth(LayoutUnit(1)); | 650 rectToScroll.setWidth(LayoutUnit(1)); |
650 if (rectToScroll.height() <= 0) | 651 if (rectToScroll.height() <= 0) |
651 rectToScroll.setHeight(LayoutUnit(1)); | 652 rectToScroll.setHeight(LayoutUnit(1)); |
652 | 653 |
653 LayoutBox* parentBox = nullptr; | 654 LayoutBox* parentBox = nullptr; |
654 LayoutRect newRect = rectToScroll; | 655 LayoutRect newRect = rectToScroll; |
655 | 656 |
656 bool restrictedByLineClamp = false; | 657 bool restrictedByLineClamp = false; |
657 if (containingBlock()) { | 658 if (containingBlock()) { |
658 parentBox = containingBlock(); | 659 parentBox = containingBlock(); |
659 restrictedByLineClamp = !containingBlock()->style()->lineClamp().isNone(); | 660 restrictedByLineClamp = !containingBlock()->style()->lineClamp().isNone(); |
660 } | 661 } |
661 | 662 |
| 663 bool isSmooth = false; |
| 664 if (scrollBehavior == ScrollBehaviorSmooth || |
| 665 (scrollBehavior == ScrollBehaviorAuto && |
| 666 style()->getScrollBehavior() == ScrollBehaviorSmooth)) { |
| 667 isSmooth = true; |
| 668 } |
| 669 |
662 if (hasOverflowClip() && !restrictedByLineClamp) { | 670 if (hasOverflowClip() && !restrictedByLineClamp) { |
663 // Don't scroll to reveal an overflow layer that is restricted by the | 671 // Don't scroll to reveal an overflow layer that is restricted by the |
664 // -webkit-line-clamp property. This will prevent us from revealing text | 672 // -webkit-line-clamp property. This will prevent us from revealing text |
665 // hidden by the slider in Safari RSS. | 673 // hidden by the slider in Safari RSS. |
666 // TODO(eae): We probably don't need this any more as we don't share any | 674 // TODO(eae): We probably don't need this any more as we don't share any |
667 // code with the Safari RSS reeder. | 675 // code with the Safari RSS reeder. |
668 newRect = getScrollableArea()->scrollIntoView(rectToScroll, alignX, alignY, | 676 newRect = getScrollableArea()->scrollIntoView(rectToScroll, alignX, alignY, |
669 scrollType); | 677 scrollType, isSmooth); |
670 if (newRect.isEmpty()) | 678 if (newRect.isEmpty()) |
671 return; | 679 return; |
672 } else if (!parentBox && canBeProgramaticallyScrolled()) { | 680 } else if (!parentBox && canBeProgramaticallyScrolled()) { |
673 if (FrameView* frameView = this->frameView()) { | 681 if (FrameView* frameView = this->frameView()) { |
674 HTMLFrameOwnerElement* ownerElement = document().localOwner(); | 682 HTMLFrameOwnerElement* ownerElement = document().localOwner(); |
675 if (!isDisallowedAutoscroll(ownerElement, frameView)) { | 683 if (!isDisallowedAutoscroll(ownerElement, frameView)) { |
676 if (makeVisibleInVisualViewport) { | 684 if (makeVisibleInVisualViewport) { |
677 frameView->getScrollableArea()->scrollIntoView(rectToScroll, alignX, | 685 frameView->getScrollableArea()->scrollIntoView( |
678 alignY, scrollType); | 686 rectToScroll, alignX, alignY, scrollType, isSmooth); |
679 } else { | 687 } else { |
680 frameView->layoutViewportScrollableArea()->scrollIntoView( | 688 frameView->layoutViewportScrollableArea()->scrollIntoView( |
681 rectToScroll, alignX, alignY, scrollType); | 689 rectToScroll, alignX, alignY, scrollType, isSmooth); |
682 } | 690 } |
683 if (ownerElement && ownerElement->layoutObject()) { | 691 if (ownerElement && ownerElement->layoutObject()) { |
684 if (frameView->safeToPropagateScrollToParent()) { | 692 if (frameView->safeToPropagateScrollToParent()) { |
685 parentBox = ownerElement->layoutObject()->enclosingBox(); | 693 parentBox = ownerElement->layoutObject()->enclosingBox(); |
686 LayoutView* parentView = ownerElement->layoutObject()->view(); | 694 LayoutView* parentView = ownerElement->layoutObject()->view(); |
687 newRect = enclosingLayoutRect( | 695 newRect = enclosingLayoutRect( |
688 view() | 696 view() |
689 ->localToAncestorQuad( | 697 ->localToAncestorQuad( |
690 FloatRect(rectToScroll), parentView, | 698 FloatRect(rectToScroll), parentView, |
691 UseTransforms | TraverseDocumentBoundaries) | 699 UseTransforms | TraverseDocumentBoundaries) |
692 .boundingBox()); | 700 .boundingBox()); |
693 } else { | 701 } else { |
694 parentBox = nullptr; | 702 parentBox = nullptr; |
695 } | 703 } |
696 } | 704 } |
697 } | 705 } |
698 } | 706 } |
699 } | 707 } |
700 | 708 |
701 // If we are fixed-position and stick to the viewport, it is useless to | 709 // If we are fixed-position and stick to the viewport, it is useless to |
702 // scroll the parent. | 710 // scroll the parent. |
703 if (style()->position() == EPosition::kFixed && | 711 if (style()->position() == EPosition::kFixed && |
704 containerForFixedPosition() == view()) { | 712 containerForFixedPosition() == view()) { |
705 return; | 713 return; |
706 } | 714 } |
707 | 715 |
708 if (frame()->page()->autoscrollController().autoscrollInProgress()) | 716 if (frame()->page()->autoscrollController().autoscrollInProgress()) |
709 parentBox = enclosingScrollableBox(); | 717 parentBox = enclosingScrollableBox(); |
710 | 718 |
711 if (parentBox) | 719 if (parentBox) { |
712 parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType, | 720 parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType, |
713 makeVisibleInVisualViewport); | 721 makeVisibleInVisualViewport, scrollBehavior); |
| 722 } |
714 } | 723 } |
715 | 724 |
716 void LayoutBox::absoluteRects(Vector<IntRect>& rects, | 725 void LayoutBox::absoluteRects(Vector<IntRect>& rects, |
717 const LayoutPoint& accumulatedOffset) const { | 726 const LayoutPoint& accumulatedOffset) const { |
718 rects.push_back(pixelSnappedIntRect(accumulatedOffset, size())); | 727 rects.push_back(pixelSnappedIntRect(accumulatedOffset, size())); |
719 } | 728 } |
720 | 729 |
721 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, | 730 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, |
722 MapCoordinatesFlags mode) const { | 731 MapCoordinatesFlags mode) const { |
723 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) { | 732 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) { |
(...skipping 4991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5715 block->adjustChildDebugRect(rect); | 5724 block->adjustChildDebugRect(rect); |
5716 | 5725 |
5717 return rect; | 5726 return rect; |
5718 } | 5727 } |
5719 | 5728 |
5720 bool LayoutBox::shouldClipOverflow() const { | 5729 bool LayoutBox::shouldClipOverflow() const { |
5721 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); | 5730 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); |
5722 } | 5731 } |
5723 | 5732 |
5724 } // namespace blink | 5733 } // namespace blink |
OLD | NEW |