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