| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 (C) 1998 Waldo Bastian (bastian@kde.org) | 3 (C) 1998 Waldo Bastian (bastian@kde.org) |
| 4 (C) 1998, 1999 Torben Weis (weis@kde.org) | 4 (C) 1998, 1999 Torben Weis (weis@kde.org) |
| 5 (C) 1999 Lars Knoll (knoll@kde.org) | 5 (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 7 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 7 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 Boston, MA 02110-1301, USA. | 22 Boston, MA 02110-1301, USA. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef FrameView_h | 25 #ifndef FrameView_h |
| 26 #define FrameView_h | 26 #define FrameView_h |
| 27 | 27 |
| 28 #include "core/frame/FrameViewAutoSizeInfo.h" | 28 #include "core/frame/FrameViewAutoSizeInfo.h" |
| 29 #include "core/rendering/PaintPhase.h" | 29 #include "core/rendering/PaintPhase.h" |
| 30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
| 31 #include "platform/Widget.h" |
| 32 #include "platform/geometry/IntRect.h" |
| 31 #include "platform/geometry/LayoutRect.h" | 33 #include "platform/geometry/LayoutRect.h" |
| 32 #include "platform/graphics/Color.h" | 34 #include "platform/graphics/Color.h" |
| 33 #include "platform/scroll/ScrollView.h" | 35 #include "platform/scroll/ScrollTypes.h" |
| 36 #include "platform/scroll/ScrollableArea.h" |
| 37 #include "platform/scroll/Scrollbar.h" |
| 34 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 39 #include "wtf/HashSet.h" |
| 35 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/TemporaryChange.h" |
| 36 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 37 | 43 |
| 38 namespace blink { | 44 namespace blink { |
| 39 | 45 |
| 40 class AXObjectCache; | 46 class AXObjectCache; |
| 41 class DocumentLifecycle; | 47 class DocumentLifecycle; |
| 42 class Cursor; | 48 class Cursor; |
| 43 class Element; | 49 class Element; |
| 44 class FloatSize; | 50 class FloatSize; |
| 45 class HTMLFrameOwnerElement; | 51 class HTMLFrameOwnerElement; |
| 46 class LocalFrame; | 52 class LocalFrame; |
| 47 class KURL; | 53 class KURL; |
| 48 class Node; | 54 class Node; |
| 49 class Page; | 55 class Page; |
| 50 class RenderBox; | 56 class RenderBox; |
| 51 class RenderEmbeddedObject; | 57 class RenderEmbeddedObject; |
| 52 class RenderObject; | 58 class RenderObject; |
| 53 class RenderScrollbarPart; | 59 class RenderScrollbarPart; |
| 54 class RenderView; | 60 class RenderView; |
| 55 class RenderWidget; | 61 class RenderWidget; |
| 56 struct CompositedSelectionBound; | 62 struct CompositedSelectionBound; |
| 57 | 63 |
| 58 typedef unsigned long long DOMTimeStamp; | 64 typedef unsigned long long DOMTimeStamp; |
| 59 | 65 |
| 60 // FIXME: Oilpan: move Widget (and thereby FrameView) to the heap. | 66 // FIXME: Oilpan: move Widget (and thereby FrameView) to the heap. |
| 61 class FrameView final : public ScrollView { | 67 class FrameView final : public Widget, public ScrollableArea { |
| 62 public: | 68 public: |
| 63 friend class RenderView; | 69 friend class RenderView; |
| 64 friend class Internals; | 70 friend class Internals; |
| 65 | 71 |
| 66 static PassRefPtr<FrameView> create(LocalFrame*); | 72 static PassRefPtr<FrameView> create(LocalFrame*); |
| 67 static PassRefPtr<FrameView> create(LocalFrame*, const IntSize& initialSize)
; | 73 static PassRefPtr<FrameView> create(LocalFrame*, const IntSize& initialSize)
; |
| 68 | 74 |
| 69 virtual ~FrameView(); | 75 virtual ~FrameView(); |
| 70 | 76 |
| 71 virtual HostWindow* hostWindow() const override; | |
| 72 | |
| 73 virtual void invalidateRect(const IntRect&) override; | 77 virtual void invalidateRect(const IntRect&) override; |
| 74 virtual void setFrameRect(const IntRect&) override; | 78 virtual void setFrameRect(const IntRect&) override; |
| 75 | 79 |
| 76 LocalFrame& frame() const | 80 LocalFrame& frame() const |
| 77 { | 81 { |
| 78 ASSERT(m_frame); | 82 ASSERT(m_frame); |
| 79 return *m_frame; | 83 return *m_frame; |
| 80 } | 84 } |
| 81 | 85 |
| 82 Page* page() const; | 86 Page* page() const; |
| 83 | 87 |
| 84 RenderView* renderView() const; | 88 RenderView* renderView() const; |
| 85 | 89 |
| 86 virtual void setCanHaveScrollbars(bool) override; | 90 void setCanHaveScrollbars(bool); |
| 87 | 91 |
| 88 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation) override
; | 92 PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); |
| 89 | 93 |
| 90 virtual void setContentsSize(const IntSize&) override; | 94 void setContentsSize(const IntSize&); |
| 91 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale) const; | 95 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale) const; |
| 92 | 96 |
| 93 void layout(bool allowSubtree = true); | 97 void layout(bool allowSubtree = true); |
| 94 bool didFirstLayout() const; | 98 bool didFirstLayout() const; |
| 95 void scheduleRelayout(); | 99 void scheduleRelayout(); |
| 96 void scheduleRelayoutOfSubtree(RenderObject*); | 100 void scheduleRelayoutOfSubtree(RenderObject*); |
| 97 bool layoutPending() const; | 101 bool layoutPending() const; |
| 98 bool isInPerformLayout() const; | 102 bool isInPerformLayout() const; |
| 99 | 103 |
| 100 void setCanInvalidatePaintDuringPerformLayout(bool b) { m_canInvalidatePaint
DuringPerformLayout = b; } | 104 void setCanInvalidatePaintDuringPerformLayout(bool b) { m_canInvalidatePaint
DuringPerformLayout = b; } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 142 |
| 139 // True if the FrameView is not transparent, and the base background color i
s opaque. | 143 // True if the FrameView is not transparent, and the base background color i
s opaque. |
| 140 bool hasOpaqueBackground() const; | 144 bool hasOpaqueBackground() const; |
| 141 | 145 |
| 142 Color baseBackgroundColor() const; | 146 Color baseBackgroundColor() const; |
| 143 void setBaseBackgroundColor(const Color&); | 147 void setBaseBackgroundColor(const Color&); |
| 144 void updateBackgroundRecursively(const Color&, bool); | 148 void updateBackgroundRecursively(const Color&, bool); |
| 145 | 149 |
| 146 void adjustViewSize(); | 150 void adjustViewSize(); |
| 147 | 151 |
| 148 virtual IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars)
const override; | |
| 149 IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*) const; | 152 IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*) const; |
| 150 | 153 |
| 151 virtual IntRect windowResizerRect() const override; | 154 IntRect windowResizerRect() const; |
| 152 | 155 |
| 153 virtual float visibleContentScaleFactor() const override { return m_visibleC
ontentScaleFactor; } | 156 float visibleContentScaleFactor() const { return m_visibleContentScaleFactor
; } |
| 154 void setVisibleContentScaleFactor(float); | 157 void setVisibleContentScaleFactor(float); |
| 155 | 158 |
| 156 virtual float inputEventsScaleFactor() const override; | 159 float inputEventsScaleFactor() const; |
| 157 virtual IntSize inputEventsOffsetForEmulation() const override; | 160 IntSize inputEventsOffsetForEmulation() const; |
| 158 void setInputEventsTransformForEmulation(const IntSize&, float); | 161 void setInputEventsTransformForEmulation(const IntSize&, float); |
| 159 | 162 |
| 160 virtual void setScrollPosition(const DoublePoint&, ScrollBehavior = ScrollBe
haviorInstant) override; | 163 void setScrollPosition(const DoublePoint&, ScrollBehavior = ScrollBehaviorIn
stant); |
| 161 virtual bool isRubberBandInProgress() const override; | 164 virtual bool isRubberBandInProgress() const override; |
| 162 void setScrollPositionNonProgrammatically(const IntPoint&); | 165 void setScrollPositionNonProgrammatically(const IntPoint&); |
| 163 | 166 |
| 164 // This is different than visibleContentRect() in that it ignores negative (
or overly positive) | 167 // This is different than visibleContentRect() in that it ignores negative (
or overly positive) |
| 165 // offsets from rubber-banding, and it takes zooming into account. | 168 // offsets from rubber-banding, and it takes zooming into account. |
| 166 LayoutRect viewportConstrainedVisibleContentRect() const; | 169 LayoutRect viewportConstrainedVisibleContentRect() const; |
| 167 void viewportConstrainedVisibleContentSizeChanged(bool widthChanged, bool he
ightChanged); | 170 void viewportConstrainedVisibleContentSizeChanged(bool widthChanged, bool he
ightChanged); |
| 168 | 171 |
| 169 AtomicString mediaType() const; | 172 AtomicString mediaType() const; |
| 170 void setMediaType(const AtomicString&); | 173 void setMediaType(const AtomicString&); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 194 | 197 |
| 195 bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollT
oParent; } | 198 bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollT
oParent; } |
| 196 void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScroll
ToParent = isSafe; } | 199 void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScroll
ToParent = isSafe; } |
| 197 | 200 |
| 198 void addWidget(RenderWidget*); | 201 void addWidget(RenderWidget*); |
| 199 void removeWidget(RenderWidget*); | 202 void removeWidget(RenderWidget*); |
| 200 void updateWidgetPositions(); | 203 void updateWidgetPositions(); |
| 201 | 204 |
| 202 void addWidgetToUpdate(RenderEmbeddedObject&); | 205 void addWidgetToUpdate(RenderEmbeddedObject&); |
| 203 | 206 |
| 204 virtual void paintContents(GraphicsContext*, const IntRect& damageRect) over
ride; | 207 void paintContents(GraphicsContext*, const IntRect& damageRect); |
| 205 void setPaintBehavior(PaintBehavior); | 208 void setPaintBehavior(PaintBehavior); |
| 206 PaintBehavior paintBehavior() const; | 209 PaintBehavior paintBehavior() const; |
| 207 bool isPainting() const; | 210 bool isPainting() const; |
| 208 bool hasEverPainted() const { return m_lastPaintTime; } | 211 bool hasEverPainted() const { return m_lastPaintTime; } |
| 209 void setNodeToDraw(Node*); | 212 void setNodeToDraw(Node*); |
| 210 | 213 |
| 211 virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalO
verhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) over
ride; | 214 void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangA
rea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect); |
| 212 virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect)
override; | 215 void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect); |
| 213 virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) ov
erride; | 216 void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&); |
| 214 | 217 |
| 215 Color documentBackgroundColor() const; | 218 Color documentBackgroundColor() const; |
| 216 | 219 |
| 217 static double currentFrameTimeStamp() { return s_currentFrameTimeStamp; } | 220 static double currentFrameTimeStamp() { return s_currentFrameTimeStamp; } |
| 218 | 221 |
| 219 void updateLayoutAndStyleForPainting(); | 222 void updateLayoutAndStyleForPainting(); |
| 220 void updateLayoutAndStyleIfNeededRecursive(); | 223 void updateLayoutAndStyleIfNeededRecursive(); |
| 221 | 224 |
| 222 void invalidateTreeIfNeededRecursive(); | 225 void invalidateTreeIfNeededRecursive(); |
| 223 | 226 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 280 |
| 278 // With CSS style "resize:" enabled, a little resizer handle will appear at
the bottom | 281 // With CSS style "resize:" enabled, a little resizer handle will appear at
the bottom |
| 279 // right of the object. We keep track of these resizer areas for checking if
touches | 282 // right of the object. We keep track of these resizer areas for checking if
touches |
| 280 // (implemented using Scroll gesture) are targeting the resizer. | 283 // (implemented using Scroll gesture) are targeting the resizer. |
| 281 typedef HashSet<RenderBox*> ResizerAreaSet; | 284 typedef HashSet<RenderBox*> ResizerAreaSet; |
| 282 void addResizerArea(RenderBox&); | 285 void addResizerArea(RenderBox&); |
| 283 void removeResizerArea(RenderBox&); | 286 void removeResizerArea(RenderBox&); |
| 284 const ResizerAreaSet* resizerAreas() const { return m_resizerAreas.get(); } | 287 const ResizerAreaSet* resizerAreas() const { return m_resizerAreas.get(); } |
| 285 | 288 |
| 286 virtual void setParent(Widget*) override; | 289 virtual void setParent(Widget*) override; |
| 287 virtual void removeChild(Widget*) override; | 290 void removeChild(Widget*); |
| 288 | 291 |
| 289 // This function exists for ports that need to handle wheel events manually. | 292 // This function exists for ports that need to handle wheel events manually. |
| 290 // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but o
n most other platforms | 293 // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but o
n most other platforms |
| 291 // we need this function in order to do the scroll ourselves. | 294 // we need this function in order to do the scroll ourselves. |
| 292 bool wheelEvent(const PlatformWheelEvent&); | 295 bool wheelEvent(const PlatformWheelEvent&); |
| 293 | 296 |
| 294 bool inProgrammaticScroll() const { return m_inProgrammaticScroll; } | 297 bool inProgrammaticScroll() const { return m_inProgrammaticScroll; } |
| 295 void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScro
ll = programmaticScroll; } | 298 void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScro
ll = programmaticScroll; } |
| 296 | 299 |
| 297 virtual bool isActive() const override; | 300 virtual bool isActive() const override; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 316 // Since the compositor can resize the viewport due to top controls and | 319 // Since the compositor can resize the viewport due to top controls and |
| 317 // commit scroll offsets before a WebView::resize occurs, we need to adjust | 320 // commit scroll offsets before a WebView::resize occurs, we need to adjust |
| 318 // our scroll extents to prevent clamping the scroll offsets. | 321 // our scroll extents to prevent clamping the scroll offsets. |
| 319 void setTopControlsViewportAdjustment(float); | 322 void setTopControlsViewportAdjustment(float); |
| 320 | 323 |
| 321 virtual IntPoint maximumScrollPosition() const override; | 324 virtual IntPoint maximumScrollPosition() const override; |
| 322 | 325 |
| 323 // ScrollableArea interface | 326 // ScrollableArea interface |
| 324 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; | 327 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; |
| 325 virtual void getTickmarks(Vector<IntRect>&) const override; | 328 virtual void getTickmarks(Vector<IntRect>&) const override; |
| 326 virtual void scrollTo(const DoublePoint&) override; | 329 void scrollTo(const DoublePoint&); |
| 327 virtual IntRect scrollableAreaBoundingBox() const override; | 330 virtual IntRect scrollableAreaBoundingBox() const override; |
| 328 virtual bool scrollAnimatorEnabled() const override; | 331 virtual bool scrollAnimatorEnabled() const override; |
| 329 virtual bool usesCompositedScrolling() const override; | 332 virtual bool usesCompositedScrolling() const override; |
| 330 virtual GraphicsLayer* layerForScrolling() const override; | 333 virtual GraphicsLayer* layerForScrolling() const override; |
| 331 virtual GraphicsLayer* layerForHorizontalScrollbar() const override; | 334 virtual GraphicsLayer* layerForHorizontalScrollbar() const override; |
| 332 virtual GraphicsLayer* layerForVerticalScrollbar() const override; | 335 virtual GraphicsLayer* layerForVerticalScrollbar() const override; |
| 333 virtual GraphicsLayer* layerForScrollCorner() const override; | 336 virtual GraphicsLayer* layerForScrollCorner() const override; |
| 334 | 337 |
| 338 // --- ScrollView --- |
| 339 virtual int scrollSize(ScrollbarOrientation) const override; |
| 340 virtual void setScrollOffset(const IntPoint&) override; |
| 341 virtual void setScrollOffset(const DoublePoint&) override; |
| 342 virtual bool isScrollCornerVisible() const override; |
| 343 void scrollbarStyleChangedInternal(); |
| 344 virtual bool userInputScrollable(ScrollbarOrientation) const override; |
| 345 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override; |
| 346 |
| 347 void notifyPageThatContentAreaWillPaintInternal() const; |
| 348 |
| 349 // The window that hosts the ScrollView. The ScrollView will communicate scr
olls and repaints to the |
| 350 // host window in the window's coordinate space. |
| 351 HostWindow* hostWindow() const; |
| 352 |
| 353 // Returns a clip rect in host window coordinates. Used to clip the blit on
a scroll. |
| 354 IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars) const; |
| 355 |
| 356 // Functions for child manipulation and inspection. |
| 357 const HashSet<RefPtr<Widget> >* children() const { return &m_children; } |
| 358 void addChild(PassRefPtr<Widget>); |
| 359 void removeChildInternal(Widget*); |
| 360 |
| 361 // If the scroll view does not use a native widget, then it will have cross-
platform Scrollbars. These functions |
| 362 // can be used to obtain those scrollbars. |
| 363 virtual Scrollbar* horizontalScrollbar() const override { return m_horizonta
lScrollbar.get(); } |
| 364 virtual Scrollbar* verticalScrollbar() const override { return m_verticalScr
ollbar.get(); } |
| 365 virtual bool isScrollViewScrollbar(const Widget* child) const override { ret
urn horizontalScrollbar() == child || verticalScrollbar() == child; } |
| 366 |
| 367 void positionScrollbarLayers(); |
| 368 |
| 369 // Functions for setting and retrieving the scrolling mode in each axis (hor
izontal/vertical). The mode has values of |
| 370 // AlwaysOff, AlwaysOn, and Auto. AlwaysOff means never show a scrollbar, Al
waysOn means always show a scrollbar. |
| 371 // Auto means show a scrollbar only when one is needed. |
| 372 // Note that for platforms with native widgets, these modes are considered a
dvisory. In other words the underlying native |
| 373 // widget may choose not to honor the requested modes. |
| 374 void setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalM
ode, bool horizontalLock = false, bool verticalLock = false); |
| 375 void setHorizontalScrollbarMode(ScrollbarMode mode, bool lock = false) { set
ScrollbarModes(mode, verticalScrollbarMode(), lock, verticalScrollbarLock()); } |
| 376 void setVerticalScrollbarMode(ScrollbarMode mode, bool lock = false) { setSc
rollbarModes(horizontalScrollbarMode(), mode, horizontalScrollbarLock(), lock);
}; |
| 377 void scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& verticalMo
de) const; |
| 378 ScrollbarMode horizontalScrollbarMode() const { ScrollbarMode horizontal, ve
rtical; scrollbarModes(horizontal, vertical); return horizontal; } |
| 379 ScrollbarMode verticalScrollbarMode() const { ScrollbarMode horizontal, vert
ical; scrollbarModes(horizontal, vertical); return vertical; } |
| 380 |
| 381 void setHorizontalScrollbarLock(bool lock = true) { m_horizontalScrollbarLoc
k = lock; } |
| 382 bool horizontalScrollbarLock() const { return m_horizontalScrollbarLock; } |
| 383 void setVerticalScrollbarLock(bool lock = true) { m_verticalScrollbarLock =
lock; } |
| 384 bool verticalScrollbarLock() const { return m_verticalScrollbarLock; } |
| 385 |
| 386 void setScrollingModesLock(bool lock = true) { m_horizontalScrollbarLock = m
_verticalScrollbarLock = lock; } |
| 387 |
| 388 void setCanHaveScrollbarsInternal(bool); |
| 389 bool canHaveScrollbars() const { return horizontalScrollbarMode() != Scrollb
arAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; } |
| 390 |
| 391 // By default, paint events are clipped to the visible area. If set to |
| 392 // false, paint events are no longer clipped. |
| 393 bool clipsPaintInvalidations() const { return m_clipsRepaints; } |
| 394 void setClipsRepaints(bool); |
| 395 |
| 396 // Overridden by FrameView to create custom CSS scrollbars if applicable. |
| 397 PassRefPtr<Scrollbar> createScrollbarInternal(ScrollbarOrientation); |
| 398 |
| 399 // The visible content rect has a location that is the scrolled offset of th
e document. The width and height are the viewport width |
| 400 // and height. By default the scrollbars themselves are excluded from this r
ectangle, but an optional boolean argument allows them to be |
| 401 // included. |
| 402 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba
rs) const override; |
| 403 IntSize visibleSize() const { return visibleContentRect().size(); } |
| 404 |
| 405 // visibleContentRect().size() is computed from unscaledVisibleContentSize()
divided by the value of visibleContentScaleFactor. |
| 406 // For the main frame, visibleContentScaleFactor is equal to the page's page
ScaleFactor; it's 1 otherwise. |
| 407 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba
rs) const; |
| 408 float visibleContentScaleFactorInternal() const { return 1; } |
| 409 |
| 410 // Offset used to convert incoming input events while emulating device metic
s. |
| 411 IntSize inputEventsOffsetForEmulationInternal() const { return IntSize(); } |
| 412 |
| 413 // Scale used to convert incoming input events. Usually the same as visibleC
ontentScaleFactor(), unless specifically changed. |
| 414 float inputEventsScaleFactorInternal() const { return visibleContentScaleFac
tor(); } |
| 415 |
| 416 // Functions for getting/setting the size of the document contained inside t
he ScrollView (as an IntSize or as individual width and height |
| 417 // values). |
| 418 virtual IntSize contentsSize() const override; // Always at least as big as
the visibleWidth()/visibleHeight(). |
| 419 int contentsWidth() const { return contentsSize().width(); } |
| 420 int contentsHeight() const { return contentsSize().height(); } |
| 421 void setContentsSizeInternal(const IntSize&); |
| 422 |
| 423 // Functions for querying the current scrolled position (both as a point, a
size, or as individual X and Y values). |
| 424 // FIXME: Remove the IntPoint version. crbug.com/414283. |
| 425 virtual IntPoint scrollPosition() const override { return visibleContentRect
().location(); } |
| 426 virtual DoublePoint scrollPositionDouble() const override { return m_scrollP
osition; } |
| 427 // FIXME: Remove scrollOffset(). crbug.com/414283. |
| 428 IntSize scrollOffset() const { return toIntSize(visibleContentRect().locatio
n()); } // Gets the scrolled position as an IntSize. Convenient for adding to ot
her sizes. |
| 429 DoubleSize scrollOffsetDouble() const { return DoubleSize(m_scrollPosition.x
(), m_scrollPosition.y()); } |
| 430 DoubleSize pendingScrollDelta() const { return m_pendingScrollDelta; } |
| 431 virtual IntPoint minimumScrollPosition() const override; // The minimum posi
tion we can be scrolled to. |
| 432 // Adjust the passed in scroll position to keep it between the minimum and m
aximum positions. |
| 433 IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; |
| 434 DoublePoint adjustScrollPositionWithinRange(const DoublePoint&) const; |
| 435 double scrollX() const { return scrollPositionDouble().x(); } |
| 436 double scrollY() const { return scrollPositionDouble().y(); } |
| 437 |
| 438 virtual IntSize overhangAmount() const override; |
| 439 |
| 440 void cacheCurrentScrollPosition() { m_cachedScrollPosition = scrollPositionD
ouble(); } |
| 441 DoublePoint cachedScrollPosition() const { return m_cachedScrollPosition; } |
| 442 |
| 443 // Functions for scrolling the view. |
| 444 void setScrollPositionInternal(const DoublePoint&, ScrollBehavior = ScrollBe
haviorInstant); |
| 445 void scrollBy(const DoubleSize& s, ScrollBehavior behavior = ScrollBehaviorI
nstant) |
| 446 { |
| 447 return setScrollPosition(scrollPositionDouble() + s, behavior); |
| 448 } |
| 449 |
| 450 bool scroll(ScrollDirection, ScrollGranularity); |
| 451 |
| 452 // Scroll the actual contents of the view (either blitting or invalidating a
s needed). |
| 453 void scrollContents(const IntSize& scrollDelta); |
| 454 |
| 455 // This gives us a means of blocking painting on our scrollbars until the fi
rst layout has occurred. |
| 456 void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = fal
se); |
| 457 bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; } |
| 458 |
| 459 IntPoint rootViewToContents(const IntPoint&) const; |
| 460 IntPoint contentsToRootView(const IntPoint&) const; |
| 461 IntRect rootViewToContents(const IntRect&) const; |
| 462 IntRect contentsToRootView(const IntRect&) const; |
| 463 |
| 464 // Event coordinates are assumed to be in the coordinate space of a window t
hat contains |
| 465 // the entire widget hierarchy. It is up to the platform to decide what the
precise definition |
| 466 // of containing window is. (For example on Mac it is the containing NSWindo
w.) |
| 467 IntPoint windowToContents(const IntPoint&) const; |
| 468 FloatPoint windowToContents(const FloatPoint&) const; |
| 469 IntPoint contentsToWindow(const IntPoint&) const; |
| 470 IntRect windowToContents(const IntRect&) const; |
| 471 IntRect contentsToWindow(const IntRect&) const; |
| 472 |
| 473 // Functions for converting to screen coordinates. |
| 474 IntRect contentsToScreen(const IntRect&) const; |
| 475 |
| 476 // These functions are used to enable scrollbars to avoid window resizer con
trols that overlap the scroll view. This happens on Mac |
| 477 // for example. |
| 478 IntRect windowResizerRectInternal() const { return IntRect(); } |
| 479 bool containsScrollbarsAvoidingResizer() const; |
| 480 void adjustScrollbarsAvoidingResizerCount(int overlapDelta); |
| 481 void windowResizerRectChanged(); |
| 482 |
| 483 void setParentInternal(Widget*); // Updates the overlapping scrollbar count. |
| 484 |
| 485 // Called when our frame rect changes (or the rect/scroll position of an anc
estor changes). |
| 486 void frameRectsChangedInternal(); |
| 487 |
| 488 // Updates our scrollbars and notifies our contents of the resize. |
| 489 void setFrameRectInternal(const IntRect&); |
| 490 |
| 491 // For platforms that need to hit test scrollbars from within the engine's e
vent handlers (like Win32). |
| 492 Scrollbar* scrollbarAtWindowPoint(const IntPoint& windowPoint); |
| 493 Scrollbar* scrollbarAtViewPoint(const IntPoint& viewPoint); |
| 494 |
| 495 virtual IntPoint convertChildToSelf(const Widget* child, const IntPoint& poi
nt) const override |
| 496 { |
| 497 IntPoint newPoint = point; |
| 498 if (!isScrollViewScrollbar(child)) |
| 499 newPoint = point - scrollOffset(); |
| 500 newPoint.moveBy(child->location()); |
| 501 return newPoint; |
| 502 } |
| 503 |
| 504 virtual IntPoint convertSelfToChild(const Widget* child, const IntPoint& poi
nt) const override |
| 505 { |
| 506 IntPoint newPoint = point; |
| 507 if (!isScrollViewScrollbar(child)) |
| 508 newPoint = point + scrollOffset(); |
| 509 newPoint.moveBy(-child->location()); |
| 510 return newPoint; |
| 511 } |
| 512 |
| 513 // Widget override. Handles painting of the contents of the view as well as
the scrollbars. |
| 514 virtual void paint(GraphicsContext*, const IntRect&) override; |
| 515 void paintScrollbars(GraphicsContext*, const IntRect&); |
| 516 |
| 517 // Widget overrides to ensure that our children's visibility status is kept
up to date when we get shown and hidden. |
| 518 virtual void show() override; |
| 519 virtual void hide() override; |
| 520 virtual void setParentVisible(bool) override; |
| 521 |
| 522 // Pan scrolling. |
| 523 static const int noPanScrollRadius = 15; |
| 524 void addPanScrollIcon(const IntPoint&); |
| 525 void removePanScrollIcon(); |
| 526 void paintPanScrollIcon(GraphicsContext*); |
| 527 |
| 528 bool isPointInScrollbarCorner(const IntPoint&); |
| 529 bool scrollbarCornerPresent() const; |
| 530 virtual IntRect scrollCornerRect() const override; |
| 531 void paintScrollCornerInternal(GraphicsContext*, const IntRect& cornerRect); |
| 532 void paintScrollbarInternal(GraphicsContext*, Scrollbar*, const IntRect&); |
| 533 |
| 534 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const
IntRect&) const override; |
| 535 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const
IntRect&) const override; |
| 536 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, cons
t IntPoint&) const override; |
| 537 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, cons
t IntPoint&) const override; |
| 538 |
| 539 void calculateAndPaintOverhangAreas(GraphicsContext*, const IntRect& dirtyRe
ct); |
| 540 void calculateAndPaintOverhangBackground(GraphicsContext*, const IntRect& di
rtyRect); |
| 541 |
| 542 virtual bool isScrollView() const override final { return true; } |
| 543 virtual bool isFrameView() const override { return true; } |
| 544 |
| 335 protected: | 545 protected: |
| 336 virtual bool scrollContentsFastPath(const IntSize& scrollDelta) override; | 546 bool scrollContentsFastPath(const IntSize& scrollDelta); |
| 337 virtual void scrollContentsSlowPath(const IntRect& updateRect) override; | 547 void scrollContentsSlowPath(const IntRect& updateRect); |
| 338 | 548 |
| 339 virtual bool isVerticalDocument() const override; | 549 bool isVerticalDocument() const; |
| 340 virtual bool isFlippedDocument() const override; | 550 bool isFlippedDocument() const; |
| 341 | 551 |
| 342 // Prevents creation of scrollbars. Used to prevent drawing two sets of | 552 // Prevents creation of scrollbars. Used to prevent drawing two sets of |
| 343 // overlay scrollbars in the case of the pinch viewport. | 553 // overlay scrollbars in the case of the pinch viewport. |
| 344 virtual bool scrollbarsDisabled() const override; | 554 bool scrollbarsDisabled() const; |
| 555 |
| 556 // --- ScrollView --- |
| 557 // NOTE: This should only be called by the overriden setScrollOffset from Sc
rollableArea. |
| 558 void scrollToInternal(const DoublePoint& newPosition); |
| 559 |
| 560 void contentRectangleForPaintInvalidationInternal(const IntRect&); |
| 561 |
| 562 void paintOverhangAreasInternal(GraphicsContext*, const IntRect& horizontalO
verhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect); |
| 563 |
| 564 // These functions are used to create/destroy scrollbars. |
| 565 void setHasHorizontalScrollbar(bool); |
| 566 void setHasVerticalScrollbar(bool); |
| 567 |
| 568 void updateScrollCornerInternal(); |
| 569 virtual void invalidateScrollCornerRect(const IntRect&) override; |
| 570 |
| 571 void scrollContentsIfNeeded(); |
| 572 // Scroll the content by via the compositor. |
| 573 bool scrollContentsFastPathInternal(const IntSize& scrollDelta) { return tru
e; } |
| 574 // Scroll the content by invalidating everything. |
| 575 void scrollContentsSlowPathInternal(const IntRect& updateRect); |
| 576 |
| 577 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updateP
ositionSynchronously); |
| 578 |
| 579 // Subclassed by FrameView to check the writing-mode of the document. |
| 580 bool isVerticalDocumentInternal() const { return true; } |
| 581 bool isFlippedDocumentInternal() const { return false; } |
| 582 |
| 583 enum ComputeScrollbarExistenceOption { |
| 584 FirstPass, |
| 585 Incremental |
| 586 }; |
| 587 void computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHas
VerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOption = Fir
stPass) const; |
| 588 void updateScrollbarGeometry(); |
| 589 IntRect adjustScrollbarRectForResizer(const IntRect&, Scrollbar*); |
| 590 |
| 591 // Called to update the scrollbars to accurately reflect the state of the vi
ew. |
| 592 void updateScrollbars(const DoubleSize& desiredOffset); |
| 593 |
| 594 IntSize excludeScrollbars(const IntSize&) const; |
| 595 |
| 596 class InUpdateScrollbarsScope { |
| 597 public: |
| 598 explicit InUpdateScrollbarsScope(FrameView* view) |
| 599 : m_scope(view->m_inUpdateScrollbars, true) |
| 600 { } |
| 601 private: |
| 602 TemporaryChange<bool> m_scope; |
| 603 }; |
| 604 |
| 605 bool scrollbarsDisabledInternal() const { return false; } |
| 345 | 606 |
| 346 private: | 607 private: |
| 347 explicit FrameView(LocalFrame*); | 608 explicit FrameView(LocalFrame*); |
| 348 | 609 |
| 349 void reset(); | 610 void reset(); |
| 350 void init(); | 611 void init(); |
| 351 | 612 |
| 352 virtual void frameRectsChanged() override; | 613 virtual void frameRectsChanged() override; |
| 353 virtual bool isFrameView() const override { return true; } | |
| 354 | 614 |
| 355 friend class RenderWidget; | 615 friend class RenderWidget; |
| 356 | 616 |
| 357 bool contentsInCompositedLayer() const; | 617 bool contentsInCompositedLayer() const; |
| 358 | 618 |
| 359 void applyOverflowToViewportAndSetRenderer(RenderObject*, ScrollbarMode& hMo
de, ScrollbarMode& vMode); | 619 void applyOverflowToViewportAndSetRenderer(RenderObject*, ScrollbarMode& hMo
de, ScrollbarMode& vMode); |
| 360 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); | 620 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); |
| 361 | 621 |
| 362 void updateCounters(); | 622 void updateCounters(); |
| 363 void forceLayoutParentViewIfNeeded(); | 623 void forceLayoutParentViewIfNeeded(); |
| 364 void performPreLayoutTasks(); | 624 void performPreLayoutTasks(); |
| 365 void performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout); | 625 void performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout); |
| 366 void scheduleOrPerformPostLayoutTasks(); | 626 void scheduleOrPerformPostLayoutTasks(); |
| 367 void performPostLayoutTasks(); | 627 void performPostLayoutTasks(); |
| 368 | 628 |
| 369 void invalidateTreeIfNeeded(); | 629 void invalidateTreeIfNeeded(); |
| 370 | 630 |
| 371 void gatherDebugLayoutRects(RenderObject* layoutRoot); | 631 void gatherDebugLayoutRects(RenderObject* layoutRoot); |
| 372 | 632 |
| 373 DocumentLifecycle& lifecycle() const; | 633 DocumentLifecycle& lifecycle() const; |
| 374 | 634 |
| 375 virtual void contentRectangleForPaintInvalidation(const IntRect&) override; | 635 void contentRectangleForPaintInvalidation(const IntRect&); |
| 376 virtual void contentsResized() override; | 636 virtual void contentsResized() override; |
| 377 virtual void scrollbarExistenceDidChange() override; | 637 void scrollbarExistenceDidChange(); |
| 378 | 638 |
| 379 // Override ScrollView methods to do point conversion via renderers, in orde
r to | 639 // Override Widget methods to do point conversion via renderers, in order to |
| 380 // take transforms into account. | 640 // take transforms into account. |
| 381 virtual IntRect convertToContainingView(const IntRect&) const override; | 641 virtual IntRect convertToContainingView(const IntRect&) const override; |
| 382 virtual IntRect convertFromContainingView(const IntRect&) const override; | 642 virtual IntRect convertFromContainingView(const IntRect&) const override; |
| 383 virtual IntPoint convertToContainingView(const IntPoint&) const override; | 643 virtual IntPoint convertToContainingView(const IntPoint&) const override; |
| 384 virtual IntPoint convertFromContainingView(const IntPoint&) const override; | 644 virtual IntPoint convertFromContainingView(const IntPoint&) const override; |
| 385 | 645 |
| 386 void updateWidgetPositionsIfNeeded(); | 646 void updateWidgetPositionsIfNeeded(); |
| 387 | 647 |
| 388 bool wasViewportResized(); | 648 bool wasViewportResized(); |
| 389 void sendResizeEventIfNeeded(); | 649 void sendResizeEventIfNeeded(); |
| 390 | 650 |
| 391 void updateScrollableAreaSet(); | 651 void updateScrollableAreaSet(); |
| 392 | 652 |
| 393 virtual void notifyPageThatContentAreaWillPaint() const override; | 653 void notifyPageThatContentAreaWillPaint() const; |
| 394 | 654 |
| 395 void scheduleUpdateWidgetsIfNecessary(); | 655 void scheduleUpdateWidgetsIfNecessary(); |
| 396 void updateWidgetsTimerFired(Timer<FrameView>*); | 656 void updateWidgetsTimerFired(Timer<FrameView>*); |
| 397 bool updateWidgets(); | 657 bool updateWidgets(); |
| 398 | 658 |
| 399 void scrollToAnchor(); | 659 void scrollToAnchor(); |
| 400 void scrollPositionChanged(); | 660 void scrollPositionChanged(); |
| 401 void didScrollTimerFired(Timer<FrameView>*); | 661 void didScrollTimerFired(Timer<FrameView>*); |
| 402 | 662 |
| 403 void updateLayersAndCompositingAfterScrollIfNeeded(); | 663 void updateLayersAndCompositingAfterScrollIfNeeded(); |
| 404 | 664 |
| 405 static bool computeCompositedSelectionBounds(LocalFrame&, CompositedSelectio
nBound& start, CompositedSelectionBound& end); | 665 static bool computeCompositedSelectionBounds(LocalFrame&, CompositedSelectio
nBound& start, CompositedSelectionBound& end); |
| 406 void updateCompositedSelectionBoundsIfNeeded(); | 666 void updateCompositedSelectionBoundsIfNeeded(); |
| 407 | 667 |
| 408 bool hasCustomScrollbars() const; | 668 bool hasCustomScrollbars() const; |
| 409 bool shouldUseCustomScrollbars(Element*& customScrollbarElement, LocalFrame*
& customScrollbarFrame); | 669 bool shouldUseCustomScrollbars(Element*& customScrollbarElement, LocalFrame*
& customScrollbarFrame); |
| 410 | 670 |
| 411 virtual void updateScrollCorner() override; | 671 void updateScrollCorner(); |
| 412 | 672 |
| 413 FrameView* parentFrameView() const; | 673 FrameView* parentFrameView() const; |
| 414 | 674 |
| 415 AXObjectCache* axObjectCache() const; | 675 AXObjectCache* axObjectCache() const; |
| 416 void removeFromAXObjectCache(); | 676 void removeFromAXObjectCache(); |
| 417 | 677 |
| 418 void setLayoutSizeInternal(const IntSize&); | 678 void setLayoutSizeInternal(const IntSize&); |
| 419 | 679 |
| 420 bool paintInvalidationIsAllowed() const | 680 bool paintInvalidationIsAllowed() const |
| 421 { | 681 { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 767 |
| 508 IntSize m_layoutSize; | 768 IntSize m_layoutSize; |
| 509 bool m_layoutSizeFixedToFrameSize; | 769 bool m_layoutSizeFixedToFrameSize; |
| 510 | 770 |
| 511 Timer<FrameView> m_didScrollTimer; | 771 Timer<FrameView> m_didScrollTimer; |
| 512 | 772 |
| 513 Vector<IntRect> m_tickmarks; | 773 Vector<IntRect> m_tickmarks; |
| 514 | 774 |
| 515 bool m_needsUpdateWidgetPositions; | 775 bool m_needsUpdateWidgetPositions; |
| 516 float m_topControlsViewportAdjustment; | 776 float m_topControlsViewportAdjustment; |
| 777 |
| 778 // --- ScrollView --- |
| 779 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); |
| 780 void adjustScrollbarOpacity(); |
| 781 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse
tWithoutAnimation, |
| 782 // notifyScrollPositionChanged...there's too many ways to scroll this class.
This needs |
| 783 // some cleanup. |
| 784 void setScrollOffsetFromUpdateScrollbars(const DoubleSize&); |
| 785 |
| 786 RefPtr<Scrollbar> m_horizontalScrollbar; |
| 787 RefPtr<Scrollbar> m_verticalScrollbar; |
| 788 ScrollbarMode m_horizontalScrollbarMode; |
| 789 ScrollbarMode m_verticalScrollbarMode; |
| 790 |
| 791 bool m_horizontalScrollbarLock; |
| 792 bool m_verticalScrollbarLock; |
| 793 |
| 794 HashSet<RefPtr<Widget> > m_children; |
| 795 |
| 796 DoubleSize m_pendingScrollDelta; |
| 797 DoublePoint m_scrollPosition; |
| 798 DoublePoint m_cachedScrollPosition; |
| 799 IntSize m_contentsSize; |
| 800 |
| 801 int m_scrollbarsAvoidingResizer; |
| 802 bool m_scrollbarsSuppressed; |
| 803 |
| 804 bool m_inUpdateScrollbars; |
| 805 |
| 806 IntPoint m_panScrollIconPoint; |
| 807 bool m_drawPanScrollIcon; |
| 808 |
| 809 bool m_clipsRepaints; |
| 810 |
| 811 IntRect rectToCopyOnScroll() const; |
| 812 |
| 813 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR
ect& verticalOverhangRect); |
| 814 void updateOverhangAreas(); |
| 517 }; | 815 }; |
| 518 | 816 |
| 519 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 817 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
| 520 { | 818 { |
| 521 if (m_isVisuallyNonEmpty) | 819 if (m_isVisuallyNonEmpty) |
| 522 return; | 820 return; |
| 523 m_visuallyNonEmptyCharacterCount += count; | 821 m_visuallyNonEmptyCharacterCount += count; |
| 524 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didFirstVisuallyNonEmptyLayout. | 822 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didFirstVisuallyNonEmptyLayout. |
| 525 // The first few hundred characters rarely contain the interesting content o
f the page. | 823 // The first few hundred characters rarely contain the interesting content o
f the page. |
| 526 static const unsigned visualCharacterThreshold = 200; | 824 static const unsigned visualCharacterThreshold = 200; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 m_view->setCanInvalidatePaintDuringPerformLayout(m_originalValue); | 859 m_view->setCanInvalidatePaintDuringPerformLayout(m_originalValue); |
| 562 } | 860 } |
| 563 private: | 861 private: |
| 564 FrameView* m_view; | 862 FrameView* m_view; |
| 565 bool m_originalValue; | 863 bool m_originalValue; |
| 566 }; | 864 }; |
| 567 | 865 |
| 568 } // namespace blink | 866 } // namespace blink |
| 569 | 867 |
| 570 #endif // FrameView_h | 868 #endif // FrameView_h |
| OLD | NEW |