| OLD | NEW |
| (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 SKY_ENGINE_CORE_RENDERING_RENDERLAYERSCROLLABLEAREA_H_ | |
| 45 #define SKY_ENGINE_CORE_RENDERING_RENDERLAYERSCROLLABLEAREA_H_ | |
| 46 | |
| 47 #include "sky/engine/platform/scroll/ScrollableArea.h" | |
| 48 | |
| 49 namespace blink { | |
| 50 | |
| 51 class RenderBox; | |
| 52 class RenderLayer; | |
| 53 | |
| 54 class RenderLayerScrollableArea final : public ScrollableArea { | |
| 55 public: | |
| 56 // FIXME: We should pass in the RenderBox but this opens a window | |
| 57 // for crashers during RenderLayer setup (see crbug.com/368062). | |
| 58 RenderLayerScrollableArea(RenderLayer&); | |
| 59 virtual ~RenderLayerScrollableArea(); | |
| 60 | |
| 61 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } | |
| 62 bool hasVerticalScrollbar() const { return verticalScrollbar(); } | |
| 63 | |
| 64 Scrollbar* horizontalScrollbar() const override { return m_hBar.get(); } | |
| 65 Scrollbar* verticalScrollbar() const override { return m_vBar.get(); } | |
| 66 | |
| 67 HostWindow* hostWindow() const override; | |
| 68 | |
| 69 bool isActive() const override; | |
| 70 IntRect scrollCornerRect() const; | |
| 71 IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect
&) const override; | |
| 72 IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect
&) const override; | |
| 73 IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoi
nt&) const override; | |
| 74 IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoi
nt&) const override; | |
| 75 int scrollSize(ScrollbarOrientation) const override; | |
| 76 void setScrollOffset(const IntPoint&) override; | |
| 77 IntPoint scrollPosition() const override; | |
| 78 IntPoint minimumScrollPosition() const override; | |
| 79 IntPoint maximumScrollPosition() const override; | |
| 80 IntRect visibleContentRect(IncludeScrollbarsInRect) const; | |
| 81 int visibleHeight() const; | |
| 82 int visibleWidth() const; | |
| 83 IntSize contentsSize() const override; | |
| 84 IntSize overhangAmount() const; | |
| 85 IntRect scrollableAreaBoundingBox() const; | |
| 86 bool userInputScrollable(ScrollbarOrientation) const override; | |
| 87 bool shouldPlaceVerticalScrollbarOnLeft() const override; | |
| 88 int pageStep(ScrollbarOrientation) const override; | |
| 89 | |
| 90 int scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin().x
(); } | |
| 91 int scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin().
y(); } | |
| 92 | |
| 93 IntSize scrollOffset() const { return m_scrollOffset; } | |
| 94 | |
| 95 // FIXME: We shouldn't allow access to m_overflowRect outside this class. | |
| 96 LayoutRect overflowRect() const { return m_overflowRect; } | |
| 97 | |
| 98 void scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClamping = Scro
llOffsetUnclamped); | |
| 99 void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamp
ed) { scrollToOffset(IntSize(x, scrollYOffset()), clamp); } | |
| 100 void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamp
ed) { scrollToOffset(IntSize(scrollXOffset(), y), clamp); } | |
| 101 | |
| 102 void updateAfterLayout(); | |
| 103 void updateAfterStyleChange(const RenderStyle*); | |
| 104 void updateAfterOverflowRecalc(); | |
| 105 | |
| 106 bool updateAfterCompositingChange() override; | |
| 107 | |
| 108 bool hasScrollbar() const { return m_hBar || m_vBar; } | |
| 109 | |
| 110 LayoutUnit scrollWidth() const; | |
| 111 LayoutUnit scrollHeight() const; | |
| 112 int pixelSnappedScrollWidth() const; | |
| 113 int pixelSnappedScrollHeight() const; | |
| 114 | |
| 115 IntSize adjustedScrollOffset() const { return IntSize(scrollXOffset(), scrol
lYOffset()); } | |
| 116 | |
| 117 void paintOverflowControls(GraphicsContext*, const IntPoint& paintOffset, co
nst IntRect& damageRect, bool paintingOverlayControls); | |
| 118 void positionOverflowControls(const IntSize& offsetFromRoot); | |
| 119 | |
| 120 LayoutRect exposeRect(const LayoutRect&, const ScrollAlignment& alignX, cons
t ScrollAlignment& alignY); | |
| 121 | |
| 122 // Returns true our scrollable area is in the FrameView's collection of scro
llable areas. This can | |
| 123 // only happen if we're both scrollable, and we do in fact overflow. This me
ans that overflow: hidden | |
| 124 // layers never get added to the FrameView's collection. | |
| 125 bool scrollsOverflow() const { return m_scrollsOverflow; } | |
| 126 | |
| 127 // FIXME(sky): Remove | |
| 128 bool needsCompositedScrolling() const { return m_needsCompositedScrolling; } | |
| 129 | |
| 130 // These are used during compositing updates to determine if the overflow | |
| 131 // controls need to be repositioned in the GraphicsLayer tree. | |
| 132 void setTopmostScrollChild(RenderLayer*); | |
| 133 RenderLayer* topmostScrollChild() const { ASSERT(!m_nextTopmostScrollChild);
return m_topmostScrollChild; } | |
| 134 | |
| 135 private: | |
| 136 bool hasHorizontalOverflow() const; | |
| 137 bool hasVerticalOverflow() const; | |
| 138 bool hasScrollableHorizontalOverflow() const; | |
| 139 bool hasScrollableVerticalOverflow() const; | |
| 140 | |
| 141 void computeScrollDimensions(); | |
| 142 | |
| 143 IntSize clampScrollOffset(const IntSize&) const; | |
| 144 | |
| 145 void setScrollOffset(const IntSize& scrollOffset) { m_scrollOffset = scrollO
ffset; } | |
| 146 | |
| 147 IntRect rectForHorizontalScrollbar(const IntRect& borderBoxRect) const; | |
| 148 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const; | |
| 149 LayoutUnit verticalScrollbarStart(int minX, int maxX) const; | |
| 150 LayoutUnit horizontalScrollbarStart(int minX) const; | |
| 151 IntSize scrollbarOffset(const Scrollbar*) const; | |
| 152 | |
| 153 PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); | |
| 154 void destroyScrollbar(ScrollbarOrientation); | |
| 155 | |
| 156 void setHasHorizontalScrollbar(bool hasScrollbar); | |
| 157 void setHasVerticalScrollbar(bool hasScrollbar); | |
| 158 | |
| 159 bool overflowControlsIntersectRect(const IntRect& localRect) const; | |
| 160 | |
| 161 RenderBox& box() const; | |
| 162 RenderLayer* layer() const; | |
| 163 | |
| 164 void updateScrollableAreaSet(bool hasOverflow); | |
| 165 | |
| 166 RenderLayer& m_layer; | |
| 167 | |
| 168 unsigned m_scrollsOverflow : 1; | |
| 169 | |
| 170 unsigned m_scrollDimensionsDirty : 1; | |
| 171 | |
| 172 RenderLayer* m_nextTopmostScrollChild; | |
| 173 RenderLayer* m_topmostScrollChild; | |
| 174 | |
| 175 // FIXME: once cc can handle composited scrolling with clip paths, we will | |
| 176 // no longer need this bit. | |
| 177 unsigned m_needsCompositedScrolling : 1; | |
| 178 | |
| 179 // The width/height of our scrolled area. | |
| 180 LayoutRect m_overflowRect; | |
| 181 | |
| 182 // This is the (scroll) offset from scrollOrigin(). | |
| 183 IntSize m_scrollOffset; | |
| 184 | |
| 185 IntPoint m_cachedOverlayScrollbarOffset; | |
| 186 | |
| 187 // For areas with overflow, we have a pair of scrollbars. | |
| 188 RefPtr<Scrollbar> m_hBar; | |
| 189 RefPtr<Scrollbar> m_vBar; | |
| 190 }; | |
| 191 | |
| 192 } // namespace blink | |
| 193 | |
| 194 #endif // SKY_ENGINE_CORE_RENDERING_RENDERLAYERSCROLLABLEAREA_H_ | |
| OLD | NEW |