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 IntPoint&, ScrollBehavior = ScrollBehav iorInstant) override; | 163 void setScrollPosition(const IntPoint&, ScrollBehavior = ScrollBehaviorInsta nt); |
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 IntSize scrollOffset() const { return toIntSize(visibleContentRect().locatio n()); } // Gets the scrolled position as an IntSize. Convenient for adding to ot her sizes. | |
428 DoubleSize pendingScrollDelta() const { return m_pendingScrollDelta; } | |
429 virtual IntPoint minimumScrollPosition() const override; // The minimum posi tion we can be scrolled to. | |
430 // Adjust the passed in scroll position to keep it between the minimum and m aximum positions. | |
431 IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; | |
432 DoublePoint adjustScrollPositionWithinRange(const DoublePoint&) const; | |
433 double scrollX() const { return scrollPositionDouble().x(); } | |
434 double scrollY() const { return scrollPositionDouble().y(); } | |
435 | |
436 virtual IntSize overhangAmount() const override; | |
437 | |
438 void cacheCurrentScrollPosition() { m_cachedScrollPosition = scrollPositionD ouble(); } | |
439 DoublePoint cachedScrollPosition() const { return m_cachedScrollPosition; } | |
440 | |
441 // Functions for scrolling the view. | |
442 void setScrollPositionInternal(const IntPoint&, ScrollBehavior = ScrollBehav iorInstant); | |
443 void scrollBy(const IntSize& s, ScrollBehavior behavior = ScrollBehaviorInst ant) | |
444 { | |
445 return setScrollPosition(scrollPosition() + s, behavior); | |
446 } | |
447 | |
448 bool scroll(ScrollDirection, ScrollGranularity); | |
449 | |
450 // Scroll the actual contents of the view (either blitting or invalidating a s needed). | |
451 void scrollContents(const IntSize& scrollDelta); | |
452 | |
453 // This gives us a means of blocking painting on our scrollbars until the fi rst layout has occurred. | |
454 void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = fal se); | |
455 bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; } | |
456 | |
457 IntPoint rootViewToContents(const IntPoint&) const; | |
458 IntPoint contentsToRootView(const IntPoint&) const; | |
459 IntRect rootViewToContents(const IntRect&) const; | |
460 IntRect contentsToRootView(const IntRect&) const; | |
461 | |
462 // Event coordinates are assumed to be in the coordinate space of a window t hat contains | |
463 // the entire widget hierarchy. It is up to the platform to decide what the precise definition | |
464 // of containing window is. (For example on Mac it is the containing NSWindo w.) | |
465 IntPoint windowToContents(const IntPoint&) const; | |
466 FloatPoint windowToContents(const FloatPoint&) const; | |
467 IntPoint contentsToWindow(const IntPoint&) const; | |
468 IntRect windowToContents(const IntRect&) const; | |
469 IntRect contentsToWindow(const IntRect&) const; | |
470 | |
471 // Functions for converting to screen coordinates. | |
472 IntRect contentsToScreen(const IntRect&) const; | |
473 | |
474 // These functions are used to enable scrollbars to avoid window resizer con trols that overlap the scroll view. This happens on Mac | |
475 // for example. | |
476 IntRect windowResizerRectInternal() const { return IntRect(); } | |
477 bool containsScrollbarsAvoidingResizer() const; | |
478 void adjustScrollbarsAvoidingResizerCount(int overlapDelta); | |
479 void windowResizerRectChanged(); | |
480 | |
481 void setParentInternal(Widget*); // Overridden to update the overlapping scr ollbar count. | |
Ian Vollick
2014/10/10 17:43:24
No longer virtual. Looks like comment needs updati
skobes
2014/10/10 17:54:27
Done.
| |
482 | |
483 // Called when our frame rect changes (or the rect/scroll position of an anc estor changes). | |
484 void frameRectsChangedInternal(); | |
485 | |
486 // Widget override to update our scrollbars and notify our contents of the r esize. | |
487 void setFrameRectInternal(const IntRect&); | |
Ian Vollick
2014/10/10 17:43:24
Ditto.
skobes
2014/10/10 17:54:27
Done.
| |
488 | |
489 // For platforms that need to hit test scrollbars from within the engine's e vent handlers (like Win32). | |
490 Scrollbar* scrollbarAtWindowPoint(const IntPoint& windowPoint); | |
491 Scrollbar* scrollbarAtViewPoint(const IntPoint& viewPoint); | |
492 | |
493 virtual IntPoint convertChildToSelf(const Widget* child, const IntPoint& poi nt) const override | |
494 { | |
495 IntPoint newPoint = point; | |
496 if (!isScrollViewScrollbar(child)) | |
497 newPoint = point - scrollOffset(); | |
498 newPoint.moveBy(child->location()); | |
499 return newPoint; | |
500 } | |
501 | |
502 virtual IntPoint convertSelfToChild(const Widget* child, const IntPoint& poi nt) const override | |
503 { | |
504 IntPoint newPoint = point; | |
505 if (!isScrollViewScrollbar(child)) | |
506 newPoint = point + scrollOffset(); | |
507 newPoint.moveBy(-child->location()); | |
508 return newPoint; | |
509 } | |
510 | |
511 // Widget override. Handles painting of the contents of the view as well as the scrollbars. | |
512 virtual void paint(GraphicsContext*, const IntRect&) override; | |
513 void paintScrollbars(GraphicsContext*, const IntRect&); | |
514 | |
515 // Widget overrides to ensure that our children's visibility status is kept up to date when we get shown and hidden. | |
516 virtual void show() override; | |
517 virtual void hide() override; | |
518 virtual void setParentVisible(bool) override; | |
519 | |
520 // Pan scrolling. | |
521 static const int noPanScrollRadius = 15; | |
522 void addPanScrollIcon(const IntPoint&); | |
523 void removePanScrollIcon(); | |
524 void paintPanScrollIcon(GraphicsContext*); | |
525 | |
526 bool isPointInScrollbarCorner(const IntPoint&); | |
527 bool scrollbarCornerPresent() const; | |
528 virtual IntRect scrollCornerRect() const override; | |
529 void paintScrollCornerInternal(GraphicsContext*, const IntRect& cornerRect); | |
530 void paintScrollbarInternal(GraphicsContext*, Scrollbar*, const IntRect&); | |
531 | |
532 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const override; | |
533 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const override; | |
534 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, cons t IntPoint&) const override; | |
535 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, cons t IntPoint&) const override; | |
536 | |
537 void calculateAndPaintOverhangAreas(GraphicsContext*, const IntRect& dirtyRe ct); | |
538 void calculateAndPaintOverhangBackground(GraphicsContext*, const IntRect& di rtyRect); | |
539 | |
540 virtual bool isScrollView() const override FINAL { return true; } | |
541 virtual bool isFrameView() const override { return true; } | |
542 | |
335 protected: | 543 protected: |
336 virtual bool scrollContentsFastPath(const IntSize& scrollDelta) override; | 544 bool scrollContentsFastPath(const IntSize& scrollDelta); |
337 virtual void scrollContentsSlowPath(const IntRect& updateRect) override; | 545 void scrollContentsSlowPath(const IntRect& updateRect); |
338 | 546 |
339 virtual bool isVerticalDocument() const override; | 547 bool isVerticalDocument() const; |
340 virtual bool isFlippedDocument() const override; | 548 bool isFlippedDocument() const; |
341 | 549 |
342 // Prevents creation of scrollbars. Used to prevent drawing two sets of | 550 // Prevents creation of scrollbars. Used to prevent drawing two sets of |
343 // overlay scrollbars in the case of the pinch viewport. | 551 // overlay scrollbars in the case of the pinch viewport. |
344 virtual bool scrollbarsDisabled() const override; | 552 bool scrollbarsDisabled() const; |
553 | |
554 // --- ScrollView --- | |
555 // NOTE: This should only be called by the overriden setScrollOffset from Sc rollableArea. | |
556 void scrollToInternal(const DoublePoint& newPosition); | |
557 | |
558 void contentRectangleForPaintInvalidationInternal(const IntRect&); | |
559 | |
560 void paintOverhangAreasInternal(GraphicsContext*, const IntRect& horizontalO verhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect); | |
561 | |
562 // These functions are used to create/destroy scrollbars. | |
563 void setHasHorizontalScrollbar(bool); | |
564 void setHasVerticalScrollbar(bool); | |
565 | |
566 void updateScrollCornerInternal(); | |
567 virtual void invalidateScrollCornerRect(const IntRect&) override; | |
568 | |
569 void scrollContentsIfNeeded(); | |
570 // Scroll the content by via the compositor. | |
571 bool scrollContentsFastPathInternal(const IntSize& scrollDelta) { return tru e; } | |
572 // Scroll the content by invalidating everything. | |
573 void scrollContentsSlowPathInternal(const IntRect& updateRect); | |
574 | |
575 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updateP ositionSynchronously); | |
576 | |
577 // Subclassed by FrameView to check the writing-mode of the document. | |
578 bool isVerticalDocumentInternal() const { return true; } | |
579 bool isFlippedDocumentInternal() const { return false; } | |
580 | |
581 enum ComputeScrollbarExistenceOption { | |
582 FirstPass, | |
583 Incremental | |
584 }; | |
585 void computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHas VerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOption = Fir stPass) const; | |
586 void updateScrollbarGeometry(); | |
587 IntRect adjustScrollbarRectForResizer(const IntRect&, Scrollbar*); | |
588 | |
589 // Called to update the scrollbars to accurately reflect the state of the vi ew. | |
590 void updateScrollbars(const IntSize& desiredOffset); | |
591 | |
592 IntSize excludeScrollbars(const IntSize&) const; | |
593 | |
594 class InUpdateScrollbarsScope { | |
595 public: | |
596 explicit InUpdateScrollbarsScope(FrameView* view) | |
597 : m_scope(view->m_inUpdateScrollbars, true) | |
598 { } | |
599 private: | |
600 TemporaryChange<bool> m_scope; | |
601 }; | |
602 | |
603 bool scrollbarsDisabledInternal() const { return false; } | |
345 | 604 |
346 private: | 605 private: |
347 explicit FrameView(LocalFrame*); | 606 explicit FrameView(LocalFrame*); |
348 | 607 |
349 void reset(); | 608 void reset(); |
350 void init(); | 609 void init(); |
351 | 610 |
352 virtual void frameRectsChanged() override; | 611 virtual void frameRectsChanged() override; |
353 virtual bool isFrameView() const override { return true; } | |
354 | 612 |
355 friend class RenderWidget; | 613 friend class RenderWidget; |
356 | 614 |
357 bool contentsInCompositedLayer() const; | 615 bool contentsInCompositedLayer() const; |
358 | 616 |
359 void applyOverflowToViewportAndSetRenderer(RenderObject*, ScrollbarMode& hMo de, ScrollbarMode& vMode); | 617 void applyOverflowToViewportAndSetRenderer(RenderObject*, ScrollbarMode& hMo de, ScrollbarMode& vMode); |
360 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); | 618 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); |
361 | 619 |
362 void updateCounters(); | 620 void updateCounters(); |
363 void forceLayoutParentViewIfNeeded(); | 621 void forceLayoutParentViewIfNeeded(); |
364 void performPreLayoutTasks(); | 622 void performPreLayoutTasks(); |
365 void performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout); | 623 void performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout); |
366 void scheduleOrPerformPostLayoutTasks(); | 624 void scheduleOrPerformPostLayoutTasks(); |
367 void performPostLayoutTasks(); | 625 void performPostLayoutTasks(); |
368 | 626 |
369 void invalidateTreeIfNeeded(); | 627 void invalidateTreeIfNeeded(); |
370 | 628 |
371 void gatherDebugLayoutRects(RenderObject* layoutRoot); | 629 void gatherDebugLayoutRects(RenderObject* layoutRoot); |
372 | 630 |
373 DocumentLifecycle& lifecycle() const; | 631 DocumentLifecycle& lifecycle() const; |
374 | 632 |
375 virtual void contentRectangleForPaintInvalidation(const IntRect&) override; | 633 void contentRectangleForPaintInvalidation(const IntRect&); |
376 virtual void contentsResized() override; | 634 virtual void contentsResized() override; |
377 virtual void scrollbarExistenceDidChange() override; | 635 void scrollbarExistenceDidChange(); |
378 | 636 |
379 // Override ScrollView methods to do point conversion via renderers, in orde r to | 637 // Override ScrollView methods to do point conversion via renderers, in orde r to |
Ian Vollick
2014/10/10 17:43:24
Stale comment?
skobes
2014/10/10 17:54:27
Done.
| |
380 // take transforms into account. | 638 // take transforms into account. |
381 virtual IntRect convertToContainingView(const IntRect&) const override; | 639 virtual IntRect convertToContainingView(const IntRect&) const override; |
382 virtual IntRect convertFromContainingView(const IntRect&) const override; | 640 virtual IntRect convertFromContainingView(const IntRect&) const override; |
383 virtual IntPoint convertToContainingView(const IntPoint&) const override; | 641 virtual IntPoint convertToContainingView(const IntPoint&) const override; |
384 virtual IntPoint convertFromContainingView(const IntPoint&) const override; | 642 virtual IntPoint convertFromContainingView(const IntPoint&) const override; |
385 | 643 |
386 void updateWidgetPositionsIfNeeded(); | 644 void updateWidgetPositionsIfNeeded(); |
387 | 645 |
388 bool wasViewportResized(); | 646 bool wasViewportResized(); |
389 void sendResizeEventIfNeeded(); | 647 void sendResizeEventIfNeeded(); |
390 | 648 |
391 void updateScrollableAreaSet(); | 649 void updateScrollableAreaSet(); |
392 | 650 |
393 virtual void notifyPageThatContentAreaWillPaint() const override; | 651 void notifyPageThatContentAreaWillPaint() const; |
394 | 652 |
395 void scheduleUpdateWidgetsIfNecessary(); | 653 void scheduleUpdateWidgetsIfNecessary(); |
396 void updateWidgetsTimerFired(Timer<FrameView>*); | 654 void updateWidgetsTimerFired(Timer<FrameView>*); |
397 bool updateWidgets(); | 655 bool updateWidgets(); |
398 | 656 |
399 void scrollToAnchor(); | 657 void scrollToAnchor(); |
400 void scrollPositionChanged(); | 658 void scrollPositionChanged(); |
401 void didScrollTimerFired(Timer<FrameView>*); | 659 void didScrollTimerFired(Timer<FrameView>*); |
402 | 660 |
403 void updateLayersAndCompositingAfterScrollIfNeeded(); | 661 void updateLayersAndCompositingAfterScrollIfNeeded(); |
404 | 662 |
405 static bool computeCompositedSelectionBounds(LocalFrame&, CompositedSelectio nBound& start, CompositedSelectionBound& end); | 663 static bool computeCompositedSelectionBounds(LocalFrame&, CompositedSelectio nBound& start, CompositedSelectionBound& end); |
406 void updateCompositedSelectionBoundsIfNeeded(); | 664 void updateCompositedSelectionBoundsIfNeeded(); |
407 | 665 |
408 bool hasCustomScrollbars() const; | 666 bool hasCustomScrollbars() const; |
409 bool shouldUseCustomScrollbars(Element*& customScrollbarElement, LocalFrame* & customScrollbarFrame); | 667 bool shouldUseCustomScrollbars(Element*& customScrollbarElement, LocalFrame* & customScrollbarFrame); |
410 | 668 |
411 virtual void updateScrollCorner() override; | 669 void updateScrollCorner(); |
412 | 670 |
413 FrameView* parentFrameView() const; | 671 FrameView* parentFrameView() const; |
414 | 672 |
415 AXObjectCache* axObjectCache() const; | 673 AXObjectCache* axObjectCache() const; |
416 void removeFromAXObjectCache(); | 674 void removeFromAXObjectCache(); |
417 | 675 |
418 void setLayoutSizeInternal(const IntSize&); | 676 void setLayoutSizeInternal(const IntSize&); |
419 | 677 |
420 bool paintInvalidationIsAllowed() const | 678 bool paintInvalidationIsAllowed() const |
421 { | 679 { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 | 765 |
508 IntSize m_layoutSize; | 766 IntSize m_layoutSize; |
509 bool m_layoutSizeFixedToFrameSize; | 767 bool m_layoutSizeFixedToFrameSize; |
510 | 768 |
511 Timer<FrameView> m_didScrollTimer; | 769 Timer<FrameView> m_didScrollTimer; |
512 | 770 |
513 Vector<IntRect> m_tickmarks; | 771 Vector<IntRect> m_tickmarks; |
514 | 772 |
515 bool m_needsUpdateWidgetPositions; | 773 bool m_needsUpdateWidgetPositions; |
516 float m_topControlsViewportAdjustment; | 774 float m_topControlsViewportAdjustment; |
775 | |
776 // --- ScrollView --- | |
777 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); | |
778 void adjustScrollbarOpacity(); | |
779 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse tWithoutAnimation, | |
780 // notifyScrollPositionChanged...there's too many ways to scroll this class. This needs | |
781 // some cleanup. | |
782 void setScrollOffsetFromUpdateScrollbars(const IntSize&); | |
783 | |
784 RefPtr<Scrollbar> m_horizontalScrollbar; | |
785 RefPtr<Scrollbar> m_verticalScrollbar; | |
786 ScrollbarMode m_horizontalScrollbarMode; | |
787 ScrollbarMode m_verticalScrollbarMode; | |
788 | |
789 bool m_horizontalScrollbarLock; | |
790 bool m_verticalScrollbarLock; | |
791 | |
792 HashSet<RefPtr<Widget> > m_children; | |
793 | |
794 DoubleSize m_pendingScrollDelta; | |
795 DoublePoint m_scrollPosition; | |
796 DoublePoint m_cachedScrollPosition; | |
797 IntSize m_contentsSize; | |
798 | |
799 int m_scrollbarsAvoidingResizer; | |
800 bool m_scrollbarsSuppressed; | |
801 | |
802 bool m_inUpdateScrollbars; | |
803 | |
804 IntPoint m_panScrollIconPoint; | |
805 bool m_drawPanScrollIcon; | |
806 | |
807 bool m_clipsRepaints; | |
808 | |
809 IntRect rectToCopyOnScroll() const; | |
810 | |
811 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect); | |
812 void updateOverhangAreas(); | |
517 }; | 813 }; |
518 | 814 |
519 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 815 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
520 { | 816 { |
521 if (m_isVisuallyNonEmpty) | 817 if (m_isVisuallyNonEmpty) |
522 return; | 818 return; |
523 m_visuallyNonEmptyCharacterCount += count; | 819 m_visuallyNonEmptyCharacterCount += count; |
524 // Use a threshold value to prevent very small amounts of visible content fr om triggering didFirstVisuallyNonEmptyLayout. | 820 // 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. | 821 // The first few hundred characters rarely contain the interesting content o f the page. |
526 static const unsigned visualCharacterThreshold = 200; | 822 static const unsigned visualCharacterThreshold = 200; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 m_view->setCanInvalidatePaintDuringPerformLayout(m_originalValue); | 857 m_view->setCanInvalidatePaintDuringPerformLayout(m_originalValue); |
562 } | 858 } |
563 private: | 859 private: |
564 FrameView* m_view; | 860 FrameView* m_view; |
565 bool m_originalValue; | 861 bool m_originalValue; |
566 }; | 862 }; |
567 | 863 |
568 } // namespace blink | 864 } // namespace blink |
569 | 865 |
570 #endif // FrameView_h | 866 #endif // FrameView_h |
OLD | NEW |