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