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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 frame_element_base->ScrollingMode() == kScrollbarAlwaysOff; | 638 frame_element_base->ScrollingMode() == kScrollbarAlwaysOff; |
639 } | 639 } |
640 } | 640 } |
641 return false; | 641 return false; |
642 } | 642 } |
643 | 643 |
644 void LayoutBox::ScrollRectToVisible(const LayoutRect& rect, | 644 void LayoutBox::ScrollRectToVisible(const LayoutRect& rect, |
645 const ScrollAlignment& align_x, | 645 const ScrollAlignment& align_x, |
646 const ScrollAlignment& align_y, | 646 const ScrollAlignment& align_y, |
647 ScrollType scroll_type, | 647 ScrollType scroll_type, |
648 bool make_visible_in_visual_viewport) { | 648 bool make_visible_in_visual_viewport, |
| 649 ScrollBehavior scroll_behavior) { |
649 DCHECK(scroll_type == kProgrammaticScroll || scroll_type == kUserScroll); | 650 DCHECK(scroll_type == kProgrammaticScroll || scroll_type == kUserScroll); |
650 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 651 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
651 DisableCompositingQueryAsserts disabler; | 652 DisableCompositingQueryAsserts disabler; |
652 | 653 |
653 LayoutRect rect_to_scroll = rect; | 654 LayoutRect rect_to_scroll = rect; |
654 if (rect_to_scroll.Width() <= 0) | 655 if (rect_to_scroll.Width() <= 0) |
655 rect_to_scroll.SetWidth(LayoutUnit(1)); | 656 rect_to_scroll.SetWidth(LayoutUnit(1)); |
656 if (rect_to_scroll.Height() <= 0) | 657 if (rect_to_scroll.Height() <= 0) |
657 rect_to_scroll.SetHeight(LayoutUnit(1)); | 658 rect_to_scroll.SetHeight(LayoutUnit(1)); |
658 | 659 |
659 LayoutBox* parent_box = nullptr; | 660 LayoutBox* parent_box = nullptr; |
660 LayoutRect new_rect = rect_to_scroll; | 661 LayoutRect new_rect = rect_to_scroll; |
661 | 662 |
662 bool restricted_by_line_clamp = false; | 663 bool restricted_by_line_clamp = false; |
663 if (ContainingBlock()) { | 664 if (ContainingBlock()) { |
664 parent_box = ContainingBlock(); | 665 parent_box = ContainingBlock(); |
665 restricted_by_line_clamp = | 666 restricted_by_line_clamp = |
666 !ContainingBlock()->Style()->LineClamp().IsNone(); | 667 !ContainingBlock()->Style()->LineClamp().IsNone(); |
667 } | 668 } |
668 | 669 |
| 670 bool is_smooth = false; |
| 671 if (scroll_behavior == kScrollBehaviorSmooth || |
| 672 (scroll_behavior == kScrollBehaviorAuto && |
| 673 Style()->GetScrollBehavior() == kScrollBehaviorSmooth)) { |
| 674 is_smooth = true; |
| 675 } |
| 676 |
669 if (HasOverflowClip() && !restricted_by_line_clamp) { | 677 if (HasOverflowClip() && !restricted_by_line_clamp) { |
670 // Don't scroll to reveal an overflow layer that is restricted by the | 678 // Don't scroll to reveal an overflow layer that is restricted by the |
671 // -webkit-line-clamp property. This will prevent us from revealing text | 679 // -webkit-line-clamp property. This will prevent us from revealing text |
672 // hidden by the slider in Safari RSS. | 680 // hidden by the slider in Safari RSS. |
673 // TODO(eae): We probably don't need this any more as we don't share any | 681 // TODO(eae): We probably don't need this any more as we don't share any |
674 // code with the Safari RSS reeder. | 682 // code with the Safari RSS reeder. |
675 new_rect = GetScrollableArea()->ScrollIntoView(rect_to_scroll, align_x, | 683 new_rect = GetScrollableArea()->ScrollIntoView( |
676 align_y, scroll_type); | 684 rect_to_scroll, align_x, align_y, scroll_type, is_smooth); |
677 if (new_rect.IsEmpty()) | 685 if (new_rect.IsEmpty()) |
678 return; | 686 return; |
679 } else if (!parent_box && CanBeProgramaticallyScrolled()) { | 687 } else if (!parent_box && CanBeProgramaticallyScrolled()) { |
680 if (FrameView* frame_view = this->GetFrameView()) { | 688 if (FrameView* frame_view = this->GetFrameView()) { |
681 HTMLFrameOwnerElement* owner_element = GetDocument().LocalOwner(); | 689 HTMLFrameOwnerElement* owner_element = GetDocument().LocalOwner(); |
682 if (!IsDisallowedAutoscroll(owner_element, frame_view)) { | 690 if (!IsDisallowedAutoscroll(owner_element, frame_view)) { |
683 if (make_visible_in_visual_viewport) { | 691 if (make_visible_in_visual_viewport) { |
684 frame_view->GetScrollableArea()->ScrollIntoView( | 692 frame_view->GetScrollableArea()->ScrollIntoView( |
685 rect_to_scroll, align_x, align_y, scroll_type); | 693 rect_to_scroll, align_x, align_y, scroll_type, is_smooth); |
686 } else { | 694 } else { |
687 frame_view->LayoutViewportScrollableArea()->ScrollIntoView( | 695 frame_view->LayoutViewportScrollableArea()->ScrollIntoView( |
688 rect_to_scroll, align_x, align_y, scroll_type); | 696 rect_to_scroll, align_x, align_y, scroll_type, is_smooth); |
689 } | 697 } |
690 if (owner_element && owner_element->GetLayoutObject()) { | 698 if (owner_element && owner_element->GetLayoutObject()) { |
691 if (frame_view->SafeToPropagateScrollToParent()) { | 699 if (frame_view->SafeToPropagateScrollToParent()) { |
692 parent_box = owner_element->GetLayoutObject()->EnclosingBox(); | 700 parent_box = owner_element->GetLayoutObject()->EnclosingBox(); |
693 LayoutView* parent_view = owner_element->GetLayoutObject()->View(); | 701 LayoutView* parent_view = owner_element->GetLayoutObject()->View(); |
694 new_rect = EnclosingLayoutRect( | 702 new_rect = EnclosingLayoutRect( |
695 View() | 703 View() |
696 ->LocalToAncestorQuad( | 704 ->LocalToAncestorQuad( |
697 FloatRect(rect_to_scroll), parent_view, | 705 FloatRect(rect_to_scroll), parent_view, |
698 kUseTransforms | kTraverseDocumentBoundaries) | 706 kUseTransforms | kTraverseDocumentBoundaries) |
699 .BoundingBox()); | 707 .BoundingBox()); |
700 } else { | 708 } else { |
701 parent_box = nullptr; | 709 parent_box = nullptr; |
702 } | 710 } |
703 } | 711 } |
704 } | 712 } |
705 } | 713 } |
706 } | 714 } |
707 | 715 |
708 // If we are fixed-position and stick to the viewport, it is useless to | 716 // If we are fixed-position and stick to the viewport, it is useless to |
709 // scroll the parent. | 717 // scroll the parent. |
710 if (Style()->GetPosition() == EPosition::kFixed && | 718 if (Style()->GetPosition() == EPosition::kFixed && |
711 ContainerForFixedPosition() == View()) { | 719 ContainerForFixedPosition() == View()) { |
712 return; | 720 return; |
713 } | 721 } |
714 | 722 |
715 if (GetFrame()->GetPage()->GetAutoscrollController().AutoscrollInProgress()) | 723 if (GetFrame()->GetPage()->GetAutoscrollController().AutoscrollInProgress()) |
716 parent_box = EnclosingScrollableBox(); | 724 parent_box = EnclosingScrollableBox(); |
717 | 725 |
718 if (parent_box) | 726 if (parent_box) { |
719 parent_box->ScrollRectToVisible(new_rect, align_x, align_y, scroll_type, | 727 parent_box->ScrollRectToVisible(new_rect, align_x, align_y, scroll_type, |
720 make_visible_in_visual_viewport); | 728 make_visible_in_visual_viewport, |
| 729 scroll_behavior); |
| 730 } |
721 } | 731 } |
722 | 732 |
723 void LayoutBox::AbsoluteRects(Vector<IntRect>& rects, | 733 void LayoutBox::AbsoluteRects(Vector<IntRect>& rects, |
724 const LayoutPoint& accumulated_offset) const { | 734 const LayoutPoint& accumulated_offset) const { |
725 rects.push_back(PixelSnappedIntRect(accumulated_offset, Size())); | 735 rects.push_back(PixelSnappedIntRect(accumulated_offset, Size())); |
726 } | 736 } |
727 | 737 |
728 void LayoutBox::AbsoluteQuads(Vector<FloatQuad>& quads, | 738 void LayoutBox::AbsoluteQuads(Vector<FloatQuad>& quads, |
729 MapCoordinatesFlags mode) const { | 739 MapCoordinatesFlags mode) const { |
730 if (LayoutFlowThread* flow_thread = FlowThreadContainingBlock()) { | 740 if (LayoutFlowThread* flow_thread = FlowThreadContainingBlock()) { |
(...skipping 5130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5861 void LayoutBox::MutableForPainting:: | 5871 void LayoutBox::MutableForPainting:: |
5862 SavePreviousContentBoxSizeAndLayoutOverflowRect() { | 5872 SavePreviousContentBoxSizeAndLayoutOverflowRect() { |
5863 auto& rare_data = GetLayoutBox().EnsureRareData(); | 5873 auto& rare_data = GetLayoutBox().EnsureRareData(); |
5864 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; | 5874 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; |
5865 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); | 5875 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); |
5866 rare_data.previous_layout_overflow_rect_ = | 5876 rare_data.previous_layout_overflow_rect_ = |
5867 GetLayoutBox().LayoutOverflowRect(); | 5877 GetLayoutBox().LayoutOverflowRect(); |
5868 } | 5878 } |
5869 | 5879 |
5870 } // namespace blink | 5880 } // namespace blink |
OLD | NEW |