Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: sky/engine/core/rendering/RenderLayerScrollableArea.cpp

Issue 721473002: Removed ScrollingCoordinator and a bunch of composited scrolling' (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cr comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/dom/Node.h" 47 #include "core/dom/Node.h"
48 #include "core/dom/shadow/ShadowRoot.h" 48 #include "core/dom/shadow/ShadowRoot.h"
49 #include "core/editing/FrameSelection.h" 49 #include "core/editing/FrameSelection.h"
50 #include "core/frame/FrameView.h" 50 #include "core/frame/FrameView.h"
51 #include "core/frame/LocalFrame.h" 51 #include "core/frame/LocalFrame.h"
52 #include "core/inspector/InspectorTraceEvents.h" 52 #include "core/inspector/InspectorTraceEvents.h"
53 #include "core/page/Chrome.h" 53 #include "core/page/Chrome.h"
54 #include "core/page/EventHandler.h" 54 #include "core/page/EventHandler.h"
55 #include "core/page/FocusController.h" 55 #include "core/page/FocusController.h"
56 #include "core/page/Page.h" 56 #include "core/page/Page.h"
57 #include "core/page/scrolling/ScrollingCoordinator.h"
58 #include "core/rendering/HitTestResult.h" 57 #include "core/rendering/HitTestResult.h"
59 #include "core/rendering/RenderGeometryMap.h" 58 #include "core/rendering/RenderGeometryMap.h"
60 #include "core/rendering/RenderView.h" 59 #include "core/rendering/RenderView.h"
61 #include "core/rendering/compositing/CompositedLayerMapping.h" 60 #include "core/rendering/compositing/CompositedLayerMapping.h"
62 #include "core/rendering/compositing/RenderLayerCompositor.h" 61 #include "core/rendering/compositing/RenderLayerCompositor.h"
63 #include "platform/PlatformGestureEvent.h" 62 #include "platform/PlatformGestureEvent.h"
64 #include "platform/PlatformMouseEvent.h" 63 #include "platform/PlatformMouseEvent.h"
65 #include "platform/graphics/GraphicsContextStateSaver.h" 64 #include "platform/graphics/GraphicsContextStateSaver.h"
66 #include "platform/graphics/GraphicsLayer.h" 65 #include "platform/graphics/GraphicsLayer.h"
67 #include "platform/scroll/ScrollAnimator.h" 66 #include "platform/scroll/ScrollAnimator.h"
(...skipping 19 matching lines...) Expand all
87 Element* element = toElement(node); 86 Element* element = toElement(node);
88 m_scrollOffset = element->savedLayerScrollOffset(); 87 m_scrollOffset = element->savedLayerScrollOffset();
89 if (!m_scrollOffset.isZero()) 88 if (!m_scrollOffset.isZero())
90 scrollAnimator()->setCurrentPosition(FloatPoint(m_scrollOffset.width (), m_scrollOffset.height())); 89 scrollAnimator()->setCurrentPosition(FloatPoint(m_scrollOffset.width (), m_scrollOffset.height()));
91 element->setSavedLayerScrollOffset(IntSize()); 90 element->setSavedLayerScrollOffset(IntSize());
92 } 91 }
93 } 92 }
94 93
95 RenderLayerScrollableArea::~RenderLayerScrollableArea() 94 RenderLayerScrollableArea::~RenderLayerScrollableArea()
96 { 95 {
97 if (box().frame() && box().frame()->page()) {
98 if (ScrollingCoordinator* scrollingCoordinator = box().frame()->page()-> scrollingCoordinator())
99 scrollingCoordinator->willDestroyScrollableArea(this);
100 }
101
102 if (!box().documentBeingDestroyed()) { 96 if (!box().documentBeingDestroyed()) {
103 Node* node = box().node(); 97 Node* node = box().node();
104 if (node && node->isElementNode()) 98 if (node && node->isElementNode())
105 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset); 99 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset);
106 } 100 }
107 101
108 destroyScrollbar(HorizontalScrollbar); 102 destroyScrollbar(HorizontalScrollbar);
109 destroyScrollbar(VerticalScrollbar); 103 destroyScrollbar(VerticalScrollbar);
110 } 104 }
111 105
112 HostWindow* RenderLayerScrollableArea::hostWindow() const 106 HostWindow* RenderLayerScrollableArea::hostWindow() const
113 { 107 {
114 if (Page* page = box().frame()->page()) 108 if (Page* page = box().frame()->page())
115 return &page->chrome(); 109 return &page->chrome();
116 return nullptr; 110 return nullptr;
117 } 111 }
118 112
119 GraphicsLayer* RenderLayerScrollableArea::layerForScrolling() const
120 {
121 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin g()->scrollingContentsLayer() : 0;
122 }
123
124 GraphicsLayer* RenderLayerScrollableArea::layerForHorizontalScrollbar() const
125 {
126 // See crbug.com/343132.
127 DisableCompositingQueryAsserts disabler;
128
129 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin g()->layerForHorizontalScrollbar() : 0;
130 }
131
132 GraphicsLayer* RenderLayerScrollableArea::layerForVerticalScrollbar() const
133 {
134 // See crbug.com/343132.
135 DisableCompositingQueryAsserts disabler;
136
137 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin g()->layerForVerticalScrollbar() : 0;
138 }
139
140 void RenderLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, co nst IntRect& rect) 113 void RenderLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, co nst IntRect& rect)
141 { 114 {
142 // See crbug.com/343132. 115 // See crbug.com/343132.
143 DisableCompositingQueryAsserts disabler; 116 DisableCompositingQueryAsserts disabler;
144 117
145 if (scrollbar == m_vBar.get()) {
146 if (GraphicsLayer* layer = layerForVerticalScrollbar()) {
147 layer->setNeedsDisplayInRect(rect);
148 return;
149 }
150 } else {
151 if (GraphicsLayer* layer = layerForHorizontalScrollbar()) {
152 layer->setNeedsDisplayInRect(rect);
153 return;
154 }
155 }
156
157 IntRect scrollRect = rect; 118 IntRect scrollRect = rect;
158 // If we are not yet inserted into the tree, there is no need to issue paint invaldiations. 119 // If we are not yet inserted into the tree, there is no need to issue paint invaldiations.
159 if (!box().parent()) 120 if (!box().parent())
160 return; 121 return;
161 122
162 if (scrollbar == m_vBar.get()) 123 if (scrollbar == m_vBar.get())
163 scrollRect.move(verticalScrollbarStart(0, box().width()), box().borderTo p()); 124 scrollRect.move(verticalScrollbarStart(0, box().width()), box().borderTo p());
164 else 125 else
165 scrollRect.move(horizontalScrollbarStart(0), box().height() - box().bord erBottom() - scrollbar->height()); 126 scrollRect.move(horizontalScrollbarStart(0), box().height() - box().bord erBottom() - scrollbar->height());
166 127
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 IntRect vBarRect = rectForVerticalScrollbar(borderBox); 703 IntRect vBarRect = rectForVerticalScrollbar(borderBox);
743 vBarRect.move(offsetFromRoot); 704 vBarRect.move(offsetFromRoot);
744 verticalScrollbar->setFrameRect(vBarRect); 705 verticalScrollbar->setFrameRect(vBarRect);
745 } 706 }
746 707
747 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { 708 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
748 IntRect hBarRect = rectForHorizontalScrollbar(borderBox); 709 IntRect hBarRect = rectForHorizontalScrollbar(borderBox);
749 hBarRect.move(offsetFromRoot); 710 hBarRect.move(offsetFromRoot);
750 horizontalScrollbar->setFrameRect(hBarRect); 711 horizontalScrollbar->setFrameRect(hBarRect);
751 } 712 }
752
753 // FIXME, this should eventually be removed, once we are certain that compos ited
754 // controls get correctly positioned on a compositor update. For now, conser vatively
755 // leaving this unchanged.
756 if (layer()->hasCompositedLayerMapping())
757 layer()->compositedLayerMapping()->positionOverflowControlsLayers(offset FromRoot);
758 } 713 }
759 714
760 void RenderLayerScrollableArea::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayCont rols) 715 void RenderLayerScrollableArea::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayCont rols)
761 { 716 {
762 // Don't do anything if we have no overflow. 717 // Don't do anything if we have no overflow.
763 if (!box().hasOverflowClip()) 718 if (!box().hasOverflowClip())
764 return; 719 return;
765 720
766 IntPoint adjustedPaintOffset = paintOffset; 721 IntPoint adjustedPaintOffset = paintOffset;
767 if (paintingOverlayControls) 722 if (paintingOverlayControls)
768 adjustedPaintOffset = m_cachedOverlayScrollbarOffset; 723 adjustedPaintOffset = m_cachedOverlayScrollbarOffset;
769 724
770 // Move the scrollbar widgets if necessary. We normally move and resize widg ets during layout, 725 // Move the scrollbar widgets if necessary. We normally move and resize widg ets during layout,
771 // but sometimes widgets can move without layout occurring (most notably whe n you scroll a 726 // but sometimes widgets can move without layout occurring (most notably whe n you scroll a
772 // document that contains fixed positioned elements). 727 // document that contains fixed positioned elements).
773 positionOverflowControls(toIntSize(adjustedPaintOffset)); 728 positionOverflowControls(toIntSize(adjustedPaintOffset));
774 729
775 // Overlay scrollbars paint in a second pass through the layer tree so that they will paint 730 // Overlay scrollbars paint in a second pass through the layer tree so that they will paint
776 // on top of everything else. If this is the normal painting pass, paintingO verlayControls 731 // on top of everything else. If this is the normal painting pass, paintingO verlayControls
777 // will be false, and we should just tell the root layer that there are over lay scrollbars 732 // will be false, and we should just tell the root layer that there are over lay scrollbars
778 // that need to be painted. That will cause the second pass through the laye r tree to run, 733 // that need to be painted. That will cause the second pass through the laye r tree to run,
779 // and we'll paint the scrollbars then. In the meantime, cache tx and ty so that the 734 // and we'll paint the scrollbars then. In the meantime, cache tx and ty so that the
780 // second pass doesn't need to re-enter the RenderTree to get it right. 735 // second pass doesn't need to re-enter the RenderTree to get it right.
781 if (hasOverlayScrollbars() && !paintingOverlayControls) { 736 if (hasOverlayScrollbars() && !paintingOverlayControls) {
782 m_cachedOverlayScrollbarOffset = paintOffset; 737 m_cachedOverlayScrollbarOffset = paintOffset;
783 // It's not necessary to do the second pass if the scrollbars paint into layers.
784 if ((m_hBar && layerForHorizontalScrollbar()) || (m_vBar && layerForVert icalScrollbar()))
785 return;
786 IntRect localDamgeRect = damageRect; 738 IntRect localDamgeRect = damageRect;
787 localDamgeRect.moveBy(-paintOffset); 739 localDamgeRect.moveBy(-paintOffset);
788 if (!overflowControlsIntersectRect(localDamgeRect)) 740 if (!overflowControlsIntersectRect(localDamgeRect))
789 return; 741 return;
790 742
791 RenderView* renderView = box().view(); 743 RenderView* renderView = box().view();
792 744
793 RenderLayer* paintingRoot = layer()->enclosingLayerWithCompositedLayerMa pping(IncludeSelf); 745 RenderLayer* paintingRoot = layer()->enclosingLayerWithCompositedLayerMa pping(IncludeSelf);
794 if (!paintingRoot) 746 if (!paintingRoot)
795 paintingRoot = renderView->layer(); 747 paintingRoot = renderView->layer();
796 748
797 paintingRoot->setContainsDirtyOverlayScrollbars(true); 749 paintingRoot->setContainsDirtyOverlayScrollbars(true);
798 return; 750 return;
799 } 751 }
800 752
801 // This check is required to avoid painting custom CSS scrollbars twice. 753 // This check is required to avoid painting custom CSS scrollbars twice.
802 if (paintingOverlayControls && !hasOverlayScrollbars()) 754 if (paintingOverlayControls && !hasOverlayScrollbars())
803 return; 755 return;
804 756
805 // Now that we're sure the scrollbars are in the right place, paint them. 757 // Now that we're sure the scrollbars are in the right place, paint them.
806 if (m_hBar && !layerForHorizontalScrollbar()) 758 if (m_hBar)
807 m_hBar->paint(context, damageRect); 759 m_hBar->paint(context, damageRect);
808 if (m_vBar && !layerForVerticalScrollbar()) 760 if (m_vBar)
809 m_vBar->paint(context, damageRect); 761 m_vBar->paint(context, damageRect);
810 } 762 }
811 763
812 bool RenderLayerScrollableArea::overflowControlsIntersectRect(const IntRect& loc alRect) const 764 bool RenderLayerScrollableArea::overflowControlsIntersectRect(const IntRect& loc alRect) const
813 { 765 {
814 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); 766 const IntRect borderBox = box().pixelSnappedBorderBoxRect();
815 767
816 if (rectForHorizontalScrollbar(borderBox).intersects(localRect)) 768 if (rectForHorizontalScrollbar(borderBox).intersects(localRect))
817 return true; 769 return true;
818 770
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild) 843 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild)
892 { 844 {
893 // We only want to track the topmost scroll child for scrollable areas with 845 // We only want to track the topmost scroll child for scrollable areas with
894 // overlay scrollbars. 846 // overlay scrollbars.
895 if (!hasOverlayScrollbars()) 847 if (!hasOverlayScrollbars())
896 return; 848 return;
897 m_nextTopmostScrollChild = scrollChild; 849 m_nextTopmostScrollChild = scrollChild;
898 } 850 }
899 851
900 } // namespace blink 852 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayerScrollableArea.h ('k') | sky/engine/core/rendering/compositing/CompositedLayerMapping.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698