2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 (C) 1998 Waldo Bastian (bastian@kde.org)
4 (C) 1998, 1999 Torben Weis (weis@kde.org)
5 (C) 1999 Lars Knoll (knoll@kde.org)
6 (C) 1999 Antti Koivisto (koivisto@kde.org)
7 Copyright (C) 2004-2009, 2014 Apple Inc. All rights reserved.
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA.
28 #include "AdjustViewSizeOrNot.h"
30 #include "ContainerNode.h"
31 #include "LayoutMilestones.h"
32 #include "LayoutRect.h"
33 #include "Pagination.h"
34 #include "PaintPhase.h"
35 #include "RenderPtr.h"
36 #include "ScrollView.h"
38 #include <wtf/Forward.h>
39 #include <wtf/HashSet.h>
40 #include <wtf/ListHashSet.h>
41 #include <wtf/text/WTFString.h>
50 class HTMLFrameOwnerElement;
56 class RenderEmbeddedObject;
59 class RenderScrollbarPart;
64 Pagination::Mode paginationModeForRenderStyle(const RenderStyle&);
66 typedef unsigned long long DOMTimeStamp;
68 class FrameView final : public ScrollView {
70 friend class RenderView;
71 friend class Internals;
73 WEBCORE_EXPORT static Ref<FrameView> create(Frame&);
74 static Ref<FrameView> create(Frame&, const IntSize& initialSize);
78 virtual HostWindow* hostWindow() const override;
80 WEBCORE_EXPORT virtual void invalidateRect(const IntRect&) override;
81 virtual void setFrameRect(const IntRect&) override;
83 #if ENABLE(REQUEST_ANIMATION_FRAME)
84 virtual bool scheduleAnimation() override;
87 Frame& frame() const { return *m_frame; }
89 WEBCORE_EXPORT RenderView* renderView() const;
91 int mapFromLayoutToCSSUnits(LayoutUnit) const;
92 LayoutUnit mapFromCSSToLayoutUnits(int) const;
94 LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default
95 LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default
96 void setMarginWidth(LayoutUnit);
97 void setMarginHeight(LayoutUnit);
99 WEBCORE_EXPORT virtual void setCanHaveScrollbars(bool) override;
100 WEBCORE_EXPORT void updateCanHaveScrollbars();
102 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation) override;
104 virtual bool avoidScrollbarCreation() const override;
106 virtual void setContentsSize(const IntSize&) override;
108 void layout(bool allowSubtree = true);
109 WEBCORE_EXPORT bool didFirstLayout() const;
110 void layoutTimerFired();
111 void scheduleRelayout();
112 void scheduleRelayoutOfSubtree(RenderElement&);
113 void unscheduleRelayout();
114 bool layoutPending() const;
115 bool isInLayout() const { return m_layoutPhase == InLayout; }
117 RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
118 void clearLayoutRoot() { m_layoutRoot = nullptr; }
119 int layoutCount() const { return m_layoutCount; }
121 WEBCORE_EXPORT bool needsLayout() const;
122 WEBCORE_EXPORT void setNeedsLayout();
123 void setViewportConstrainedObjectsNeedLayout();
125 bool needsStyleRecalcOrLayout(bool includeSubframes = true) const;
127 bool needsFullRepaint() const { return m_needsFullRepaint; }
129 WEBCORE_EXPORT bool renderedCharactersExceed(unsigned threshold);
132 bool useCustomFixedPositionLayoutRect() const { return m_useCustomFixedPositionLayoutRect; }
133 IntRect customFixedPositionLayoutRect() const { return m_customFixedPositionLayoutRect; }
134 WEBCORE_EXPORT void setCustomFixedPositionLayoutRect(const IntRect&);
135 bool updateFixedPositionLayoutRect();
137 IntSize customSizeForResizeEvent() const { return m_customSizeForResizeEvent; }
138 WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize);
140 WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, double timestamp);
141 FloatRect computeCoverageRect(double horizontalMargin, double verticalMargin) const;
143 bool useCustomFixedPositionLayoutRect() const { return false; }
146 #if ENABLE(REQUEST_ANIMATION_FRAME)
147 WEBCORE_EXPORT void serviceScriptedAnimations(double monotonicAnimationStartTime);
150 void updateCompositingLayersAfterStyleChange();
151 void updateCompositingLayersAfterLayout();
152 bool flushCompositingStateForThisFrame(Frame* rootFrameForFlush);
154 void clearBackingStores();
155 void restoreBackingStores();
157 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
158 // content rendered via the normal painting path.
159 void setNeedsOneShotDrawingSynchronization();
161 WEBCORE_EXPORT GraphicsLayer* graphicsLayerForPlatformWidget(PlatformWidget);
162 WEBCORE_EXPORT void scheduleLayerFlushAllowingThrottling();
164 WEBCORE_EXPORT virtual TiledBacking* tiledBacking() const override;
166 // In the future when any ScrollableArea can have a node in th ScrollingTree, this should
167 // become a virtual function on ScrollableArea.
168 uint64_t scrollLayerID() const;
169 ScrollableArea* scrollableAreaForScrollLayerID(uint64_t) const;
171 bool hasCompositedContent() const;
172 bool hasCompositedContentIncludingDescendants() const;
173 bool hasCompositingAncestor() const;
174 WEBCORE_EXPORT void enterCompositingMode();
175 WEBCORE_EXPORT bool isEnclosedInCompositingLayer() const;
177 // Only used with accelerated compositing, but outside the #ifdef to make linkage easier.
178 // Returns true if the flush was completed.
179 WEBCORE_EXPORT bool flushCompositingStateIncludingSubframes();
181 // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
182 // a faithful representation of the content.
183 WEBCORE_EXPORT bool isSoftwareRenderable() const;
185 void setIsInWindow(bool);
187 void resetScrollbars();
188 void resetScrollbarsAndClearContentsSize();
189 void prepareForDetach();
190 void detachCustomScrollbars();
191 void recalculateScrollbarOverlayStyle();
195 WEBCORE_EXPORT bool isTransparent() const;
196 WEBCORE_EXPORT void setTransparent(bool isTransparent);
198 // True if the FrameView is not transparent, and the base background color is opaque.
199 bool hasOpaqueBackground() const;
201 WEBCORE_EXPORT Color baseBackgroundColor() const;
202 WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
203 void updateBackgroundRecursively(const Color&, bool);
205 enum ExtendedBackgroundModeFlags {
206 ExtendedBackgroundModeNone = 0,
207 ExtendedBackgroundModeVertical = 1 << 0,
208 ExtendedBackgroundModeHorizontal = 1 << 1,
209 ExtendedBackgroundModeAll = ExtendedBackgroundModeVertical | ExtendedBackgroundModeHorizontal,
211 typedef unsigned ExtendedBackgroundMode;
213 void updateExtendBackgroundIfNecessary();
214 void updateTilesForExtendedBackgroundMode(ExtendedBackgroundMode);
215 ExtendedBackgroundMode calculateExtendedBackgroundMode() const;
217 bool hasExtendedBackgroundRectForPainting() const;
218 IntRect extendedBackgroundRectForPainting() const;
220 bool shouldUpdateWhileOffscreen() const;
221 WEBCORE_EXPORT void setShouldUpdateWhileOffscreen(bool);
222 bool shouldUpdate() const;
224 WEBCORE_EXPORT void adjustViewSize();
226 WEBCORE_EXPORT void setViewportSizeForCSSViewportUnits(IntSize);
227 IntSize viewportSizeForCSSViewportUnits() const;
229 virtual IntRect windowClipRect() const override;
230 WEBCORE_EXPORT IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
232 virtual IntRect windowResizerRect() const override;
234 virtual float visibleContentScaleFactor() const override;
236 #if USE(TILED_BACKING_STORE)
237 virtual void setFixedVisibleContentRect(const IntRect&) override;
239 WEBCORE_EXPORT virtual void setScrollPosition(const IntPoint&) override;
240 virtual void updateLayerPositionsAfterScrolling() override;
241 virtual void updateCompositingLayersAfterScrolling() override;
242 virtual bool requestScrollPositionUpdate(const IntPoint&) override;
243 virtual bool isRubberBandInProgress() const override;
244 WEBCORE_EXPORT virtual IntPoint minimumScrollPosition() const override;
245 WEBCORE_EXPORT virtual IntPoint maximumScrollPosition() const override;
246 void delayedScrollEventTimerFired();
248 void viewportContentsChanged();
249 WEBCORE_EXPORT void resumeVisibleImageAnimationsIncludingSubframes();
251 // This is different than visibleContentRect() in that it ignores negative (or overly positive)
252 // offsets from rubber-banding, and it takes zooming into account.
253 LayoutRect viewportConstrainedVisibleContentRect() const;
255 String mediaType() const;
256 WEBCORE_EXPORT void setMediaType(const String&);
257 void adjustMediaTypeForPrinting(bool printing);
259 void setCannotBlitToWindow();
260 void setIsOverlapped(bool);
261 bool isOverlapped() const { return m_isOverlapped; }
262 bool isOverlappedIncludingAncestors() const;
263 void setContentIsOpaque(bool);
265 void addSlowRepaintObject(RenderElement*);
266 void removeSlowRepaintObject(RenderElement*);
267 bool hasSlowRepaintObject(RenderElement* o) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(o); }
268 bool hasSlowRepaintObjects() const { return m_slowRepaintObjects && m_slowRepaintObjects->size(); }
270 // Includes fixed- and sticky-position objects.
271 typedef HashSet<RenderElement*> ViewportConstrainedObjectSet;
272 void addViewportConstrainedObject(RenderElement*);
273 void removeViewportConstrainedObject(RenderElement*);
274 const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
275 bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
277 // Functions for querying the current scrolled position, negating the effects of overhang
278 // and adjusting for page scale.
279 LayoutSize scrollOffsetForFixedPosition() const;
280 // Static function can be called from another thread.
281 static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
283 // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed
284 // on both the main thread and the scrolling thread.
285 static float yPositionForInsetClipLayer(const FloatPoint& scrollPosition, float topContentInset);
286 WEBCORE_EXPORT static float yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset, float headerHeight);
287 static float yPositionForHeaderLayer(const FloatPoint& scrollPosition, float topContentInset);
288 static float yPositionForFooterLayer(const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float footerHeight);
291 WEBCORE_EXPORT LayoutRect viewportConstrainedObjectsRect() const;
292 // Static function can be called from another thread.
293 WEBCORE_EXPORT static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements);
296 bool fixedElementsLayoutRelativeToFrame() const;
298 WEBCORE_EXPORT void disableLayerFlushThrottlingTemporarilyForInteraction();
299 bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; }
300 void loadProgressingStatusChanged();
302 #if ENABLE(DASHBOARD_SUPPORT)
303 void updateAnnotatedRegions();
305 WEBCORE_EXPORT void updateControlTints();
307 void restoreScrollbar();
309 void postLayoutTimerFired();
311 void registerThrottledDOMTimer(DOMTimer*);
312 void unregisterThrottledDOMTimer(DOMTimer*);
314 WEBCORE_EXPORT bool wasScrolledByUser() const;
315 WEBCORE_EXPORT void setWasScrolledByUser(bool);
317 bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
318 void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
320 void addEmbeddedObjectToUpdate(RenderEmbeddedObject&);
321 void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&);
323 WEBCORE_EXPORT virtual void paintContents(GraphicsContext*, const IntRect& dirtyRect) override;
325 struct PaintingState {
326 PaintBehavior paintBehavior;
327 bool isTopLevelPainter;
328 bool isFlatteningPaintOfRootFrame;
331 , isTopLevelPainter(false)
332 , isFlatteningPaintOfRootFrame(false)
337 void willPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
338 void didPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
340 WEBCORE_EXPORT void setPaintBehavior(PaintBehavior);
341 WEBCORE_EXPORT PaintBehavior paintBehavior() const;
342 bool isPainting() const;
343 bool hasEverPainted() const { return m_lastPaintTime; }
344 void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
345 WEBCORE_EXPORT void setNodeToDraw(Node*);
347 enum SelectionInSnapshot { IncludeSelection, ExcludeSelection };
348 enum CoordinateSpaceForSnapshot { DocumentCoordinates, ViewCoordinates };
349 WEBCORE_EXPORT void paintContentsForSnapshot(GraphicsContext*, const IntRect& imageRect, SelectionInSnapshot shouldPaintSelection, CoordinateSpaceForSnapshot);
351 virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) override;
352 virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect) override;
353 virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) override;
355 WEBCORE_EXPORT Color documentBackgroundColor() const;
357 bool isInChildFrameWithFrameFlattening() const;
359 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
361 WEBCORE_EXPORT void updateLayoutAndStyleIfNeededRecursive();
363 void incrementVisuallyNonEmptyCharacterCount(unsigned);
364 void incrementVisuallyNonEmptyPixelCount(const IntSize&);
365 void updateIsVisuallyNonEmpty();
366 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
367 WEBCORE_EXPORT void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
368 WEBCORE_EXPORT void setAutoSizeFixedMinimumHeight(int);
369 IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; }
371 WEBCORE_EXPORT void forceLayout(bool allowSubtree = false);
372 WEBCORE_EXPORT void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
374 // FIXME: This method is retained because of embedded WebViews in AppKit. When a WebView is embedded inside
375 // some enclosing view with auto-pagination, no call happens to resize the view. The new pagination model
376 // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
377 // resize around that view. Auto-pagination uses the bounds of the actual view that's being printed to determine
378 // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
379 // web document's bounds.
381 // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
382 // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
383 // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
384 // page size, it can't actually paginate correctly during _layoutForPrinting.
386 // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
387 // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
389 // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
390 WEBCORE_EXPORT void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
392 bool scrollToFragment(const URL&);
393 bool scrollToAnchor(const String&);
394 void maintainScrollPositionAtAnchor(ContainerNode*);
395 WEBCORE_EXPORT void scrollElementToRect(Element*, const IntRect&);
397 // Methods to convert points and rects between the coordinate space of the renderer, and this view.
398 WEBCORE_EXPORT IntRect convertFromRendererToContainingView(const RenderElement*, const IntRect&) const;
399 WEBCORE_EXPORT IntRect convertFromContainingViewToRenderer(const RenderElement*, const IntRect&) const;
400 WEBCORE_EXPORT IntPoint convertFromRendererToContainingView(const RenderElement*, const IntPoint&) const;
401 WEBCORE_EXPORT IntPoint convertFromContainingViewToRenderer(const RenderElement*, const IntPoint&) const;
403 bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
405 // isScrollable() takes an optional Scrollability parameter that allows the caller to define what they mean by 'scrollable.'
406 // Most callers are interested in the default value, Scrollability::Scrollable, which means that there is actually content
407 // to scroll to, and a scrollbar that will allow you to access it. In some cases, callers want to know if the FrameView is allowed
408 // to rubber-band, which the main frame might be allowed to do even if there is no content to scroll to. In that case,
409 // callers use Scrollability::ScrollableOrRubberbandable.
410 enum class Scrollability { Scrollable, ScrollableOrRubberbandable };
411 bool isScrollable(Scrollability definitionOfScrollable = Scrollability::Scrollable);
413 virtual bool isScrollableOrRubberbandable() override;
414 virtual bool hasScrollableOrRubberbandableAncestor() override;
416 enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
417 void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
419 virtual IntPoint lastKnownMousePosition() const override;
420 virtual bool isHandlingWheelEvent() const override;
421 bool shouldSetCursor() const;
423 // FIXME: Remove this method once plugin loading is decoupled from layout.
424 void flushAnyPendingPostLayoutTasks();
426 virtual bool shouldSuspendScrollAnimations() const override;
427 virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
429 RenderBox* embeddedContentBox() const;
431 WEBCORE_EXPORT void setTracksRepaints(bool);
432 bool isTrackingRepaints() const { return m_isTrackingRepaints; }
433 WEBCORE_EXPORT void resetTrackedRepaints();
434 const Vector<FloatRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
435 String trackedRepaintRectsAsText() const;
437 typedef HashSet<ScrollableArea*> ScrollableAreaSet;
438 // Returns whether the scrollable area has just been newly added.
439 WEBCORE_EXPORT bool addScrollableArea(ScrollableArea*);
440 // Returns whether the scrollable area has just been removed.
441 WEBCORE_EXPORT bool removeScrollableArea(ScrollableArea*);
442 bool containsScrollableArea(ScrollableArea*) const;
443 const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
445 virtual void removeChild(Widget&) override;
447 // This function exists for ports that need to handle wheel events manually.
448 // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
449 // we need this function in order to do the scroll ourselves.
450 bool wheelEvent(const PlatformWheelEvent&);
452 WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool);
454 // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
455 // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
456 // FrameViews in the page cache, but FrameView::pagination() only affects the current
457 // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
458 // it will return Page::pagination() since currently there are no callers that need to
459 // distinguish between the two.
460 const Pagination& pagination() const;
461 void setPagination(const Pagination&);
463 bool inProgrammaticScroll() const override { return m_inProgrammaticScroll; }
464 void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
466 #if ENABLE(CSS_DEVICE_ADAPTATION)
467 IntSize initialViewportSize() const { return m_initialViewportSize; }
468 void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
471 virtual bool isActive() const override;
472 virtual bool updatesScrollLayerPositionOnMainThread() const override;
473 virtual bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
475 #if ENABLE(RUBBER_BANDING)
476 WEBCORE_EXPORT GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
477 WEBCORE_EXPORT GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
480 virtual int headerHeight() const override { return m_headerHeight; }
481 WEBCORE_EXPORT void setHeaderHeight(int);
482 virtual int footerHeight() const override { return m_footerHeight; }
483 WEBCORE_EXPORT void setFooterHeight(int);
485 WEBCORE_EXPORT virtual float topContentInset(TopContentInsetType = TopContentInsetType::WebCoreContentInset) const override;
486 void topContentInsetDidChange(float newTopContentInset);
488 WEBCORE_EXPORT virtual void willStartLiveResize() override;
489 WEBCORE_EXPORT virtual void willEndLiveResize() override;
491 void addPaintPendingMilestones(LayoutMilestones);
492 void firePaintRelatedMilestonesIfNeeded();
493 void fireLayoutRelatedMilestonesIfNeeded();
494 LayoutMilestones milestonesPendingPaint() const { return m_milestonesPendingPaint; }
496 bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; }
497 WEBCORE_EXPORT void setVisualUpdatesAllowedByClient(bool);
499 WEBCORE_EXPORT void setScrollPinningBehavior(ScrollPinningBehavior);
501 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const;
503 void updateWidgetPositions();
504 void didAddWidgetToRenderTree(Widget&);
505 void willRemoveWidgetFromRenderTree(Widget&);
507 void addTrackedRepaintRect(const FloatRect&);
509 // exposedRect represents WebKit's understanding of what part
510 // of the view is actually exposed on screen (taking into account
511 // clipping by other UI elements), whereas visibleContentRect is
512 // internal to WebCore and doesn't respect those things.
513 WEBCORE_EXPORT void setExposedRect(FloatRect);
514 FloatRect exposedRect() const { return m_exposedRect; }
516 #if ENABLE(CSS_SCROLL_SNAP)
517 virtual void updateSnapOffsets() override;
520 virtual float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity) override;
522 void didChangeScrollOffset();
525 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
526 virtual void scrollContentsSlowPath(const IntRect& updateRect) override;
528 void repaintSlowRepaintObjects();
530 virtual bool isVerticalDocument() const override;
531 virtual bool isFlippedDocument() const override;
534 explicit FrameView(Frame&);
542 InPreLayoutStyleUpdate,
546 InPostLayerPositionsUpdatedAfterLayout,
548 LayoutPhase layoutPhase() const { return m_layoutPhase; }
550 bool inPreLayoutStyleUpdate() const { return m_layoutPhase == InPreLayoutStyleUpdate; }
552 virtual bool isFrameView() const override { return true; }
554 friend class RenderWidget;
555 bool useSlowRepaints(bool considerOverlap = true) const;
556 bool useSlowRepaintsIfNotOverlapped() const;
557 void updateCanBlitOnScrollRecursively();
558 bool contentsInCompositedLayer() const;
559 bool shouldLayoutAfterContentsResized() const;
561 bool shouldUpdateCompositingLayersAfterScrolling() const;
563 virtual bool shouldDeferScrollUpdateAfterContentSizeChange() override;
565 virtual void scrollPositionChangedViaPlatformWidgetImpl(const IntPoint& oldPosition, const IntPoint& newPosition) override;
567 void applyOverflowToViewport(RenderElement*, ScrollbarMode& hMode, ScrollbarMode& vMode);
568 void applyPaginationToViewport();
570 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
572 WEBCORE_EXPORT void paintControlTints();
574 void forceLayoutParentViewIfNeeded();
575 void performPostLayoutTasks();
576 void autoSizeIfEnabled();
577 void updateThrottledDOMTimersState();
579 void updateLayerFlushThrottling();
580 WEBCORE_EXPORT void adjustTiledBackingCoverage();
582 virtual void repaintContentRectangle(const IntRect&) override;
583 virtual void contentsResized() override;
584 virtual void visibleContentsResized() override;
585 virtual void addedOrRemovedScrollbar() override;
586 virtual void fixedLayoutSizeChanged() override;
588 virtual void delegatesScrollingDidChange() override;
590 // Override ScrollView methods to do point conversion via renderers, in order to
591 // take transforms into account.
592 virtual IntRect convertToContainingView(const IntRect&) const override;
593 virtual IntRect convertFromContainingView(const IntRect&) const override;
594 virtual IntPoint convertToContainingView(const IntPoint&) const override;
595 virtual IntPoint convertFromContainingView(const IntPoint&) const override;
597 // ScrollableArea interface
598 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
599 virtual void scrollTo(const IntSize&) override;
600 virtual void setVisibleScrollerThumbRect(const IntRect&) override;
601 virtual ScrollableArea* enclosingScrollableArea() const override;
602 virtual IntRect scrollableAreaBoundingBox() const override;
603 virtual bool scrollAnimatorEnabled() const override;
604 virtual GraphicsLayer* layerForScrolling() const override;
605 virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
606 virtual GraphicsLayer* layerForVerticalScrollbar() const override;
607 virtual GraphicsLayer* layerForScrollCorner() const override;
608 #if ENABLE(RUBBER_BANDING)
609 virtual GraphicsLayer* layerForOverhangAreas() const override;
612 // Override scrollbar notifications to update the AXObject cache.
613 virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) override;
614 virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) override;
616 IntSize sizeForResizeEvent() const;
617 void sendResizeEventIfNeeded();
619 void updateScrollableAreaSet();
621 virtual void notifyPageThatContentAreaWillPaint() const override;
623 void enableSpeculativeTilingIfNeeded();
624 void speculativeTilingEnableTimerFired();
626 void updateEmbeddedObjectsTimerFired();
627 bool updateEmbeddedObjects();
628 void updateEmbeddedObject(RenderEmbeddedObject&);
629 void scrollToAnchor();
630 void scrollPositionChanged(const IntPoint& oldPosition, const IntPoint& newPosition);
631 void scrollableAreaSetChanged();
632 void sendScrollEvent();
634 bool hasCustomScrollbars() const;
636 virtual void updateScrollCorner() override;
638 FrameView* parentFrameView() const;
640 void startLayoutAtMainFrameViewIfNeeded(bool allowSubtree);
641 bool frameFlatteningEnabled() const;
642 bool isFrameFlatteningValidForThisFrame() const;
644 bool qualifiesAsVisuallyNonEmpty() const;
646 AXObjectCache* axObjectCache() const;
647 void notifyWidgetsInAllFrames(WidgetNotification);
648 void removeFromAXObjectCache();
649 void notifyWidgets(WidgetNotification);
651 HashSet<Widget*> m_widgetsInRenderTree;
653 static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
656 LayoutSize m_margins;
658 std::unique_ptr<ListHashSet<RenderEmbeddedObject*>> m_embeddedObjectsToUpdate;
659 const RefPtr<Frame> m_frame;
661 std::unique_ptr<HashSet<RenderElement*>> m_slowRepaintObjects;
663 bool m_needsFullRepaint;
665 bool m_canHaveScrollbars;
666 bool m_cannotBlitToWindow;
668 bool m_contentIsOpaque;
671 bool m_delayedLayout;
672 RenderElement* m_layoutRoot;
674 LayoutPhase m_layoutPhase;
675 bool m_layoutSchedulingEnabled;
676 bool m_inSynchronousPostLayout;
678 unsigned m_nestedLayoutCount;
679 Timer m_postLayoutTasksTimer;
680 Timer m_updateEmbeddedObjectsTimer;
681 bool m_firstLayoutCallbackPending;
684 bool m_isTransparent;
685 Color m_baseBackgroundColor;
686 IntSize m_lastViewportSize;
687 float m_lastZoomFactor;
690 String m_mediaTypeWhenNotPrinting;
692 bool m_overflowStatusDirty;
693 bool m_horizontalOverflow;
694 bool m_verticalOverflow;
695 RenderElement* m_viewportRenderer;
697 Pagination m_pagination;
699 bool m_wasScrolledByUser;
700 bool m_inProgrammaticScroll;
701 bool m_safeToPropagateScrollToParent;
702 Timer m_delayedScrollEventTimer;
704 double m_lastPaintTime;
706 bool m_isTrackingRepaints; // Used for testing.
707 Vector<FloatRect> m_trackedRepaintRects;
709 bool m_shouldUpdateWhileOffscreen;
711 FloatRect m_exposedRect;
713 unsigned m_deferSetNeedsLayoutCount;
714 bool m_setNeedsLayoutWasDeferred;
716 RefPtr<Node> m_nodeToDraw;
717 PaintBehavior m_paintBehavior;
720 unsigned m_visuallyNonEmptyCharacterCount;
721 unsigned m_visuallyNonEmptyPixelCount;
722 bool m_isVisuallyNonEmpty;
723 bool m_firstVisuallyNonEmptyLayoutCallbackPending;
725 RefPtr<ContainerNode> m_maintainScrollPositionAnchor;
727 // Renderer to hold our custom scroll corner.
728 RenderPtr<RenderScrollbarPart> m_scrollCorner;
730 bool m_speculativeTilingEnabled;
731 Timer m_speculativeTilingEnableTimer;
734 bool m_useCustomFixedPositionLayoutRect;
735 IntRect m_customFixedPositionLayoutRect;
737 bool m_useCustomSizeForResizeEvent;
738 IntSize m_customSizeForResizeEvent;
740 double m_horizontalVelocity;
741 double m_verticalVelocity;
742 double m_scaleChangeRate;
743 double m_lastVelocityUpdateTime;
746 IntSize m_overrideViewportSize;
747 bool m_hasOverrideViewportSize;
749 // If true, automatically resize the frame view around its content.
750 bool m_shouldAutoSize;
752 // True if autosize has been run since m_shouldAutoSize was set.
753 bool m_didRunAutosize;
754 // The lower bound on the size when autosizing.
755 IntSize m_minAutoSize;
756 // The upper bound on the size when autosizing.
757 IntSize m_maxAutoSize;
758 // The fixed height to resize the view to after autosizing is complete.
759 int m_autoSizeFixedMinimumHeight;
760 // The intrinsic content size decided by autosizing.
761 IntSize m_autoSizeContentSize;
763 std::unique_ptr<ScrollableAreaSet> m_scrollableAreas;
764 std::unique_ptr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
766 HashSet<DOMTimer*> m_throttledTimers;
771 LayoutMilestones m_milestonesPendingPaint;
773 static const unsigned visualCharacterThreshold = 200;
774 static const unsigned visualPixelThreshold = 32 * 32;
776 #if ENABLE(CSS_DEVICE_ADAPTATION)
777 // Size of viewport before any UA or author styles have overridden
778 // the viewport given by the window or viewing area of the UA.
779 IntSize m_initialViewportSize;
782 bool m_visualUpdatesAllowedByClient;
784 ScrollPinningBehavior m_scrollPinningBehavior;
787 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
789 if (m_isVisuallyNonEmpty)
791 m_visuallyNonEmptyCharacterCount += count;
792 if (m_visuallyNonEmptyCharacterCount <= visualCharacterThreshold)
794 updateIsVisuallyNonEmpty();
797 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
799 if (m_isVisuallyNonEmpty)
801 m_visuallyNonEmptyPixelCount += size.width() * size.height();
802 if (m_visuallyNonEmptyPixelCount <= visualPixelThreshold)
804 updateIsVisuallyNonEmpty();
807 } // namespace WebCore
809 SPECIALIZE_TYPE_TRAITS_WIDGET(FrameView, isFrameView())
811 #endif // FrameView_h