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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 frameElementBase->scrollingMode() == ScrollbarAlwaysOff; | 623 frameElementBase->scrollingMode() == ScrollbarAlwaysOff; |
624 } | 624 } |
625 } | 625 } |
626 return false; | 626 return false; |
627 } | 627 } |
628 | 628 |
629 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, | 629 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, |
630 const ScrollAlignment& alignX, | 630 const ScrollAlignment& alignX, |
631 const ScrollAlignment& alignY, | 631 const ScrollAlignment& alignY, |
632 ScrollType scrollType, | 632 ScrollType scrollType, |
633 bool makeVisibleInVisualViewport) { | 633 bool makeVisibleInVisualViewport, |
634 ScrollBehavior scrollBehavior) { | |
634 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll); | 635 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll); |
635 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 636 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
636 DisableCompositingQueryAsserts disabler; | 637 DisableCompositingQueryAsserts disabler; |
637 | 638 |
638 LayoutRect rectToScroll = rect; | 639 LayoutRect rectToScroll = rect; |
639 if (rectToScroll.width() <= 0) | 640 if (rectToScroll.width() <= 0) |
640 rectToScroll.setWidth(LayoutUnit(1)); | 641 rectToScroll.setWidth(LayoutUnit(1)); |
641 if (rectToScroll.height() <= 0) | 642 if (rectToScroll.height() <= 0) |
642 rectToScroll.setHeight(LayoutUnit(1)); | 643 rectToScroll.setHeight(LayoutUnit(1)); |
643 | 644 |
644 LayoutBox* parentBox = nullptr; | 645 LayoutBox* parentBox = nullptr; |
645 LayoutRect newRect = rectToScroll; | 646 LayoutRect newRect = rectToScroll; |
646 | 647 |
647 bool restrictedByLineClamp = false; | 648 bool restrictedByLineClamp = false; |
648 if (containingBlock()) { | 649 if (containingBlock()) { |
649 parentBox = containingBlock(); | 650 parentBox = containingBlock(); |
650 restrictedByLineClamp = !containingBlock()->style()->lineClamp().isNone(); | 651 restrictedByLineClamp = !containingBlock()->style()->lineClamp().isNone(); |
651 } | 652 } |
652 | 653 |
654 ScrollBehavior behavior = ScrollBehaviorAuto; | |
655 if (style()->getScrollBehavior() == ScrollBehaviorSmooth || | |
bokan
2017/02/02 22:51:50
Does the spec mention what should happen when the
sunyunjia
2017/02/10 23:25:20
Thanks and yes. Updated according to the spec http
| |
656 scrollBehavior == ScrollBehaviorSmooth) { | |
657 behavior = ScrollBehaviorSmooth; | |
658 } | |
659 | |
653 if (hasOverflowClip() && !restrictedByLineClamp) { | 660 if (hasOverflowClip() && !restrictedByLineClamp) { |
654 // Don't scroll to reveal an overflow layer that is restricted by the | 661 // Don't scroll to reveal an overflow layer that is restricted by the |
655 // -webkit-line-clamp property. This will prevent us from revealing text | 662 // -webkit-line-clamp property. This will prevent us from revealing text |
656 // hidden by the slider in Safari RSS. | 663 // hidden by the slider in Safari RSS. |
657 // TODO(eae): We probably don't need this any more as we don't share any | 664 // TODO(eae): We probably don't need this any more as we don't share any |
658 // code with the Safari RSS reeder. | 665 // code with the Safari RSS reeder. |
659 newRect = getScrollableArea()->scrollIntoView(rectToScroll, alignX, alignY, | 666 newRect = getScrollableArea()->scrollIntoView(rectToScroll, alignX, alignY, |
660 scrollType); | 667 scrollType, behavior); |
661 if (newRect.isEmpty()) | 668 if (newRect.isEmpty()) |
662 return; | 669 return; |
663 } else if (!parentBox && canBeProgramaticallyScrolled()) { | 670 } else if (!parentBox && canBeProgramaticallyScrolled()) { |
664 if (FrameView* frameView = this->frameView()) { | 671 if (FrameView* frameView = this->frameView()) { |
665 HTMLFrameOwnerElement* ownerElement = document().localOwner(); | 672 HTMLFrameOwnerElement* ownerElement = document().localOwner(); |
666 if (!isDisallowedAutoscroll(ownerElement, frameView)) { | 673 if (!isDisallowedAutoscroll(ownerElement, frameView)) { |
667 if (makeVisibleInVisualViewport) { | 674 if (makeVisibleInVisualViewport) { |
668 frameView->getScrollableArea()->scrollIntoView(rectToScroll, alignX, | 675 frameView->getScrollableArea()->scrollIntoView( |
669 alignY, scrollType); | 676 rectToScroll, alignX, alignY, scrollType, behavior); |
670 } else { | 677 } else { |
671 frameView->layoutViewportScrollableArea()->scrollIntoView( | 678 frameView->layoutViewportScrollableArea()->scrollIntoView( |
672 rectToScroll, alignX, alignY, scrollType); | 679 rectToScroll, alignX, alignY, scrollType, behavior); |
673 } | 680 } |
674 if (ownerElement && ownerElement->layoutObject()) { | 681 if (ownerElement && ownerElement->layoutObject()) { |
675 if (frameView->safeToPropagateScrollToParent()) { | 682 if (frameView->safeToPropagateScrollToParent()) { |
676 parentBox = ownerElement->layoutObject()->enclosingBox(); | 683 parentBox = ownerElement->layoutObject()->enclosingBox(); |
677 LayoutView* parentView = ownerElement->layoutObject()->view(); | 684 LayoutView* parentView = ownerElement->layoutObject()->view(); |
678 newRect = enclosingLayoutRect( | 685 newRect = enclosingLayoutRect( |
679 view() | 686 view() |
680 ->localToAncestorQuad( | 687 ->localToAncestorQuad( |
681 FloatRect(rectToScroll), parentView, | 688 FloatRect(rectToScroll), parentView, |
682 UseTransforms | TraverseDocumentBoundaries) | 689 UseTransforms | TraverseDocumentBoundaries) |
683 .boundingBox()); | 690 .boundingBox()); |
684 } else { | 691 } else { |
685 parentBox = nullptr; | 692 parentBox = nullptr; |
686 } | 693 } |
687 } | 694 } |
688 } | 695 } |
689 } | 696 } |
690 } | 697 } |
691 | 698 |
692 // If we are fixed-position and stick to the viewport, it is useless to | 699 // If we are fixed-position and stick to the viewport, it is useless to |
693 // scroll the parent. | 700 // scroll the parent. |
694 if (style()->position() == FixedPosition && | 701 if (style()->position() == FixedPosition && |
695 containerForFixedPosition() == view()) { | 702 containerForFixedPosition() == view()) { |
696 return; | 703 return; |
697 } | 704 } |
698 | 705 |
699 if (frame()->page()->autoscrollController().autoscrollInProgress()) | 706 if (frame()->page()->autoscrollController().autoscrollInProgress()) |
700 parentBox = enclosingScrollableBox(); | 707 parentBox = enclosingScrollableBox(); |
701 | 708 |
702 if (parentBox) | 709 if (parentBox) { |
703 parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType, | 710 parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType, |
704 makeVisibleInVisualViewport); | 711 makeVisibleInVisualViewport, scrollBehavior); |
712 } | |
705 } | 713 } |
706 | 714 |
707 void LayoutBox::absoluteRects(Vector<IntRect>& rects, | 715 void LayoutBox::absoluteRects(Vector<IntRect>& rects, |
708 const LayoutPoint& accumulatedOffset) const { | 716 const LayoutPoint& accumulatedOffset) const { |
709 rects.push_back(pixelSnappedIntRect(accumulatedOffset, size())); | 717 rects.push_back(pixelSnappedIntRect(accumulatedOffset, size())); |
710 } | 718 } |
711 | 719 |
712 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, | 720 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, |
713 MapCoordinatesFlags mode) const { | 721 MapCoordinatesFlags mode) const { |
714 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) { | 722 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) { |
(...skipping 4979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5694 block->adjustChildDebugRect(rect); | 5702 block->adjustChildDebugRect(rect); |
5695 | 5703 |
5696 return rect; | 5704 return rect; |
5697 } | 5705 } |
5698 | 5706 |
5699 bool LayoutBox::shouldClipOverflow() const { | 5707 bool LayoutBox::shouldClipOverflow() const { |
5700 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); | 5708 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); |
5701 } | 5709 } |
5702 | 5710 |
5703 } // namespace blink | 5711 } // namespace blink |
OLD | NEW |