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

Side by Side Diff: Source/core/rendering/RenderLayerScrollableArea.h

Issue 898783003: Move rendering/RenderLayer* to layout/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 *
6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com>
11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
12 * Josh Soref <timeless@mac.com>
13 * Boris Zbarsky <bzbarsky@mit.edu>
14 *
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
19 *
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US A
28 *
29 * Alternatively, the contents of this file may be used under the terms
30 * of either the Mozilla Public License Version 1.1, found at
31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
33 * (the "GPL"), in which case the provisions of the MPL or the GPL are
34 * applicable instead of those above. If you wish to allow use of your
35 * version of this file only under the terms of one of those two
36 * licenses (the MPL or the GPL) and not to allow others to use your
37 * version of this file under the LGPL, indicate your decision by
38 * deletingthe provisions above and replace them with the notice and
39 * other provisions required by the MPL or the GPL, as the case may be.
40 * If you do not delete the provisions above, a recipient may use your
41 * version of this file under any of the LGPL, the MPL or the GPL.
42 */
43
44 #ifndef RenderLayerScrollableArea_h
45 #define RenderLayerScrollableArea_h
46
47
48 #include "core/rendering/LayerFragment.h"
49 #include "core/rendering/RenderBox.h"
50
51 #include "platform/scroll/ScrollableArea.h"
52
53 namespace blink {
54
55 enum ResizerHitTestType {
56 ResizerForPointer,
57 ResizerForTouch
58 };
59
60 class PlatformEvent;
61 class RenderBox;
62 class RenderLayer;
63 class RenderScrollbarPart;
64
65 class RenderLayerScrollableArea final : public ScrollableArea {
66 friend class Internals;
67
68 public:
69 // FIXME: We should pass in the RenderBox but this opens a window
70 // for crashers during RenderLayer setup (see crbug.com/368062).
71 RenderLayerScrollableArea(RenderLayer&);
72 virtual ~RenderLayerScrollableArea();
73
74 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); }
75 bool hasVerticalScrollbar() const { return verticalScrollbar(); }
76
77 virtual Scrollbar* horizontalScrollbar() const override { return m_hBar.get( ); }
78 virtual Scrollbar* verticalScrollbar() const override { return m_vBar.get(); }
79
80 virtual HostWindow* hostWindow() const override;
81
82 virtual GraphicsLayer* layerForScrolling() const override;
83 virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
84 virtual GraphicsLayer* layerForVerticalScrollbar() const override;
85 virtual GraphicsLayer* layerForScrollCorner() const override;
86 virtual bool usesCompositedScrolling() const override;
87 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
88 virtual void invalidateScrollCornerRect(const IntRect&) override;
89 virtual bool shouldUseIntegerScrollOffset() const override;
90 virtual bool isActive() const override;
91 virtual bool isScrollCornerVisible() const override;
92 virtual IntRect scrollCornerRect() const override;
93 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const override;
94 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const override;
95 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, cons t IntPoint&) const override;
96 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, cons t IntPoint&) const override;
97 virtual int scrollSize(ScrollbarOrientation) const override;
98 virtual void setScrollOffset(const IntPoint&) override;
99 virtual void setScrollOffset(const DoublePoint&) override;
100 virtual IntPoint scrollPosition() const override;
101 virtual DoublePoint scrollPositionDouble() const override;
102 virtual IntPoint minimumScrollPosition() const override;
103 virtual IntPoint maximumScrollPosition() const override;
104 virtual IntRect visibleContentRect(IncludeScrollbarsInRect) const override;
105 virtual int visibleHeight() const override;
106 virtual int visibleWidth() const override;
107 virtual IntSize contentsSize() const override;
108 virtual IntSize overhangAmount() const override;
109 virtual IntPoint lastKnownMousePosition() const override;
110 virtual bool shouldSuspendScrollAnimations() const override;
111 virtual bool scrollbarsCanBeActive() const override;
112 virtual IntRect scrollableAreaBoundingBox() const override;
113 virtual void registerForAnimation() override;
114 virtual void deregisterForAnimation() override;
115 virtual bool userInputScrollable(ScrollbarOrientation) const override;
116 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override;
117 virtual int pageStep(ScrollbarOrientation) const override;
118
119 double scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin( ).x(); }
120 double scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin ().y(); }
121
122 DoubleSize scrollOffset() const { return m_scrollOffset; }
123
124 // FIXME: We shouldn't allow access to m_overflowRect outside this class.
125 LayoutRect overflowRect() const { return m_overflowRect; }
126
127 void scrollToOffset(const DoubleSize& scrollOffset, ScrollOffsetClamping = S crollOffsetUnclamped, ScrollBehavior = ScrollBehaviorInstant);
128
129 void scrollToXOffset(double x, ScrollOffsetClamping clamp = ScrollOffsetUncl amped, ScrollBehavior scrollBehavior = ScrollBehaviorInstant)
130 {
131 scrollToOffset(DoubleSize(x, scrollYOffset()), clamp, scrollBehavior);
132 }
133
134 void scrollToYOffset(double y, ScrollOffsetClamping clamp = ScrollOffsetUncl amped, ScrollBehavior scrollBehavior = ScrollBehaviorInstant)
135 {
136 scrollToOffset(DoubleSize(scrollXOffset(), y), clamp, scrollBehavior);
137 }
138
139 virtual void setScrollPosition(const DoublePoint& position, ScrollBehavior s crollBehavior = ScrollBehaviorInstant) override
140 {
141 scrollToOffset(toDoubleSize(position), ScrollOffsetClamped, scrollBehavi or);
142 }
143
144 void updateAfterLayout();
145 void updateAfterStyleChange(const RenderStyle*);
146 void updateAfterOverflowRecalc();
147
148 virtual bool updateAfterCompositingChange() override;
149
150 bool hasScrollbar() const { return m_hBar || m_vBar; }
151
152 RenderScrollbarPart* scrollCorner() const { return m_scrollCorner; }
153
154 void resize(const PlatformEvent&, const LayoutSize&);
155 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const;
156
157 bool inResizeMode() const { return m_inResizeMode; }
158 void setInResizeMode(bool inResizeMode) { m_inResizeMode = inResizeMode; }
159
160 IntRect touchResizerCornerRect(const IntRect& bounds) const
161 {
162 return resizerCornerRect(bounds, ResizerForTouch);
163 }
164
165 LayoutUnit scrollWidth() const;
166 LayoutUnit scrollHeight() const;
167 int pixelSnappedScrollWidth() const;
168 int pixelSnappedScrollHeight() const;
169
170 int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScro llbarSize) const;
171 int horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy = IgnoreOverlayS crollbarSize) const;
172
173 DoubleSize adjustedScrollOffset() const { return DoubleSize(scrollXOffset(), scrollYOffset()); }
174
175 void positionOverflowControls(const IntSize& offsetFromRoot);
176
177 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control
178 // area.
179 bool isPointInResizeControl(const IntPoint& absolutePoint, ResizerHitTestTyp e) const;
180 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
181
182 bool hitTestResizerInFragments(const LayerFragments&, const HitTestLocation& ) const;
183
184 LayoutRect exposeRect(const LayoutRect&, const ScrollAlignment& alignX, cons t ScrollAlignment& alignY);
185
186 // Returns true our scrollable area is in the FrameView's collection of scro llable areas. This can
187 // only happen if we're both scrollable, and we do in fact overflow. This me ans that overflow: hidden
188 // layers never get added to the FrameView's collection.
189 bool scrollsOverflow() const { return m_scrollsOverflow; }
190
191 // Rectangle encompassing the scroll corner and resizer rect.
192 IntRect scrollCornerAndResizerRect() const;
193
194 enum LCDTextMode {
195 ConsiderLCDText,
196 IgnoreLCDText
197 };
198
199 void updateNeedsCompositedScrolling(LCDTextMode = ConsiderLCDText);
200 bool needsCompositedScrolling() const { return m_needsCompositedScrolling; }
201
202 // These are used during compositing updates to determine if the overflow
203 // controls need to be repositioned in the GraphicsLayer tree.
204 void setTopmostScrollChild(RenderLayer*);
205 RenderLayer* topmostScrollChild() const { ASSERT(!m_nextTopmostScrollChild); return m_topmostScrollChild; }
206
207 IntRect resizerCornerRect(const IntRect&, ResizerHitTestType) const;
208
209 RenderBox& box() const;
210 RenderLayer* layer() const;
211
212 RenderScrollbarPart* resizer() { return m_resizer; }
213
214 const IntPoint& cachedOverlayScrollbarOffset() { return m_cachedOverlayScrol lbarOffset; }
215 void setCachedOverlayScrollbarOffset(const IntPoint& offset) { m_cachedOverl ayScrollbarOffset = offset; }
216
217 IntRect rectForHorizontalScrollbar(const IntRect& borderBoxRect) const;
218 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const;
219
220 private:
221 bool hasHorizontalOverflow() const;
222 bool hasVerticalOverflow() const;
223 bool hasScrollableHorizontalOverflow() const;
224 bool hasScrollableVerticalOverflow() const;
225
226 void computeScrollDimensions();
227
228 DoubleSize clampScrollOffset(const DoubleSize&) const;
229
230
231 LayoutUnit verticalScrollbarStart(int minX, int maxX) const;
232 LayoutUnit horizontalScrollbarStart(int minX) const;
233 IntSize scrollbarOffset(const Scrollbar*) const;
234
235 PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
236 void destroyScrollbar(ScrollbarOrientation);
237
238 void setHasHorizontalScrollbar(bool hasScrollbar);
239 void setHasVerticalScrollbar(bool hasScrollbar);
240
241 void updateScrollCornerStyle();
242
243 // See comments on isPointInResizeControl.
244 void updateResizerAreaSet();
245 void updateResizerStyle();
246
247
248 void updateScrollableAreaSet(bool hasOverflow);
249
250 void updateCompositingLayersAfterScroll();
251
252 RenderLayer& m_layer;
253
254 // Keeps track of whether the layer is currently resizing, so events can cau se resizing to start and stop.
255 unsigned m_inResizeMode : 1;
256 unsigned m_scrollsOverflow : 1;
257
258 unsigned m_scrollDimensionsDirty : 1;
259 unsigned m_inOverflowRelayout : 1;
260
261 RenderLayer* m_nextTopmostScrollChild;
262 RenderLayer* m_topmostScrollChild;
263
264 // FIXME: once cc can handle composited scrolling with clip paths, we will
265 // no longer need this bit.
266 unsigned m_needsCompositedScrolling : 1;
267
268 // The width/height of our scrolled area.
269 LayoutRect m_overflowRect;
270
271 // This is the (scroll) offset from scrollOrigin().
272 DoubleSize m_scrollOffset;
273
274 IntPoint m_cachedOverlayScrollbarOffset;
275
276 // For areas with overflow, we have a pair of scrollbars.
277 RefPtrWillBePersistent<Scrollbar> m_hBar;
278 RefPtrWillBePersistent<Scrollbar> m_vBar;
279
280 // Renderers to hold our custom scroll corner.
281 RenderScrollbarPart* m_scrollCorner;
282
283 // Renderers to hold our custom resizer.
284 RenderScrollbarPart* m_resizer;
285 };
286
287 } // namespace blink
288
289 #endif // RenderLayerScrollableArea_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerReflectionInfo.cpp ('k') | Source/core/rendering/RenderLayerScrollableArea.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698