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 const_cast<Frame&>(m_frame.get()); }
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; }
116 WEBCORE_EXPORT bool inPaintableState() { return m_layoutPhase != InLayout && m_layoutPhase != InViewSizeAdjust && m_layoutPhase != InPostLayout; }
118 RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
119 void clearLayoutRoot() { m_layoutRoot = nullptr; }
120 int layoutCount() const { return m_layoutCount; }
122 WEBCORE_EXPORT bool needsLayout() const;
123 WEBCORE_EXPORT void setNeedsLayout();
124 void setViewportConstrainedObjectsNeedLayout();
126 bool needsStyleRecalcOrLayout(bool includeSubframes = true) const;
128 bool needsFullRepaint() const { return m_needsFullRepaint; }
130 WEBCORE_EXPORT bool renderedCharactersExceed(unsigned threshold);
133 bool useCustomFixedPositionLayoutRect() const { return m_useCustomFixedPositionLayoutRect; }
134 IntRect customFixedPositionLayoutRect() const { return m_customFixedPositionLayoutRect; }
135 WEBCORE_EXPORT void setCustomFixedPositionLayoutRect(const IntRect&);
136 bool updateFixedPositionLayoutRect();
138 IntSize customSizeForResizeEvent() const { return m_customSizeForResizeEvent; }
139 WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize);
141 WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, double timestamp);
143 bool useCustomFixedPositionLayoutRect() const { return false; }
146 #if ENABLE(REQUEST_ANIMATION_FRAME)
147 WEBCORE_EXPORT void serviceScriptedAnimations(double monotonicAnimationStartTime);
150 void willRecalcStyle();
151 void updateCompositingLayersAfterStyleChange();
152 void updateCompositingLayersAfterLayout();
153 bool flushCompositingStateForThisFrame(Frame* rootFrameForFlush);
155 void clearBackingStores();
156 void restoreBackingStores();
158 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
159 // content rendered via the normal painting path.
160 void setNeedsOneShotDrawingSynchronization();
162 WEBCORE_EXPORT GraphicsLayer* graphicsLayerForPlatformWidget(PlatformWidget);
163 WEBCORE_EXPORT void scheduleLayerFlushAllowingThrottling();
165 WEBCORE_EXPORT virtual TiledBacking* tiledBacking() const override;
167 // In the future when any ScrollableArea can have a node in th ScrollingTree, this should
168 // become a virtual function on ScrollableArea.
169 uint64_t scrollLayerID() const;
170 ScrollableArea* scrollableAreaForScrollLayerID(uint64_t) const;
172 bool hasCompositedContent() const;
173 WEBCORE_EXPORT void enterCompositingMode();
174 WEBCORE_EXPORT bool isEnclosedInCompositingLayer() const;
176 // Only used with accelerated compositing, but outside the #ifdef to make linkage easier.
177 // Returns true if the flush was completed.
178 WEBCORE_EXPORT bool flushCompositingStateIncludingSubframes();
180 // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
181 // a faithful representation of the content.
182 WEBCORE_EXPORT bool isSoftwareRenderable() const;
184 void setIsInWindow(bool);
186 void resetScrollbars();
187 void resetScrollbarsAndClearContentsSize();
188 void prepareForDetach();
189 void detachCustomScrollbars();
190 void recalculateScrollbarOverlayStyle();
194 WEBCORE_EXPORT bool isTransparent() const;
195 WEBCORE_EXPORT void setTransparent(bool isTransparent);
197 // True if the FrameView is not transparent, and the base background color is opaque.
198 bool hasOpaqueBackground() const;
200 WEBCORE_EXPORT Color baseBackgroundColor() const;
201 WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
202 void updateBackgroundRecursively(const Color&, bool);
204 enum ExtendedBackgroundModeFlags {
205 ExtendedBackgroundModeNone = 0,
206 ExtendedBackgroundModeVertical = 1 << 0,
207 ExtendedBackgroundModeHorizontal = 1 << 1,
208 ExtendedBackgroundModeAll = ExtendedBackgroundModeVertical | ExtendedBackgroundModeHorizontal,
210 typedef unsigned ExtendedBackgroundMode;
212 void updateExtendBackgroundIfNecessary();
213 void updateTilesForExtendedBackgroundMode(ExtendedBackgroundMode);
214 ExtendedBackgroundMode calculateExtendedBackgroundMode() const;
216 bool hasExtendedBackgroundRectForPainting() const;
217 IntRect extendedBackgroundRectForPainting() const;
219 bool shouldUpdateWhileOffscreen() const;
220 WEBCORE_EXPORT void setShouldUpdateWhileOffscreen(bool);
221 bool shouldUpdate() const;
223 WEBCORE_EXPORT void adjustViewSize();
225 WEBCORE_EXPORT void setViewportSizeForCSSViewportUnits(IntSize);
226 IntSize viewportSizeForCSSViewportUnits() const;
228 virtual IntRect windowClipRect() const override;
229 WEBCORE_EXPORT IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
231 virtual IntRect windowResizerRect() const override;
233 virtual float visibleContentScaleFactor() const override;
235 #if USE(COORDINATED_GRAPHICS)
236 virtual void setFixedVisibleContentRect(const IntRect&) override;
238 WEBCORE_EXPORT virtual void setScrollPosition(const IntPoint&) override;
239 virtual void updateLayerPositionsAfterScrolling() override;
240 virtual void updateCompositingLayersAfterScrolling() override;
241 virtual bool requestScrollPositionUpdate(const IntPoint&) override;
242 virtual bool isRubberBandInProgress() const override;
243 WEBCORE_EXPORT virtual IntPoint minimumScrollPosition() const override;
244 WEBCORE_EXPORT virtual IntPoint maximumScrollPosition() const override;
245 void delayedScrollEventTimerFired();
247 void viewportContentsChanged();
248 WEBCORE_EXPORT void resumeVisibleImageAnimationsIncludingSubframes();
250 // This is different than visibleContentRect() in that it ignores negative (or overly positive)
251 // offsets from rubber-banding, and it takes zooming into account.
252 LayoutRect viewportConstrainedVisibleContentRect() const;
254 String mediaType() const;
255 WEBCORE_EXPORT void setMediaType(const String&);
256 void adjustMediaTypeForPrinting(bool printing);
258 void setCannotBlitToWindow();
259 void setIsOverlapped(bool);
260 bool isOverlapped() const { return m_isOverlapped; }
261 bool isOverlappedIncludingAncestors() const;
262 void setContentIsOpaque(bool);
264 void addSlowRepaintObject(RenderElement*);
265 void removeSlowRepaintObject(RenderElement*);
266 bool hasSlowRepaintObject(RenderElement* o) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(o); }
267 bool hasSlowRepaintObjects() const { return m_slowRepaintObjects && m_slowRepaintObjects->size(); }
269 // Includes fixed- and sticky-position objects.
270 typedef HashSet<RenderElement*> ViewportConstrainedObjectSet;
271 void addViewportConstrainedObject(RenderElement*);
272 void removeViewportConstrainedObject(RenderElement*);
273 const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
274 bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
276 float frameScaleFactor() const;
278 // Functions for querying the current scrolled position, negating the effects of overhang
279 // and adjusting for page scale.
280 LayoutSize scrollOffsetForFixedPosition() const
282 return scrollOffsetForFixedPosition(visibleContentRect(), totalContentsSize(), scrollPosition(), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), scrollBehaviorForFixedElements(), headerHeight(), footerHeight());
285 // Static function can be called from another thread.
286 static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
288 // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed
289 // on both the main thread and the scrolling thread.
290 static float yPositionForInsetClipLayer(const FloatPoint& scrollPosition, float topContentInset);
291 WEBCORE_EXPORT static float yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset, float headerHeight);
292 WEBCORE_EXPORT float yPositionForRootContentLayer() const;
294 static float yPositionForHeaderLayer(const FloatPoint& scrollPosition, float topContentInset);
295 static float yPositionForFooterLayer(const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float footerHeight);
298 WEBCORE_EXPORT LayoutRect viewportConstrainedObjectsRect() const;
299 // Static function can be called from another thread.
300 WEBCORE_EXPORT static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements);
303 bool fixedElementsLayoutRelativeToFrame() const;
305 WEBCORE_EXPORT void disableLayerFlushThrottlingTemporarilyForInteraction();
306 bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; }
307 void loadProgressingStatusChanged();
309 #if ENABLE(DASHBOARD_SUPPORT)
310 void updateAnnotatedRegions();
312 WEBCORE_EXPORT void updateControlTints();
314 void restoreScrollbar();
316 void postLayoutTimerFired();
318 void registerThrottledDOMTimer(DOMTimer*);
319 void unregisterThrottledDOMTimer(DOMTimer*);
321 WEBCORE_EXPORT bool wasScrolledByUser() const;
322 WEBCORE_EXPORT void setWasScrolledByUser(bool);
324 bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
325 void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
327 void addEmbeddedObjectToUpdate(RenderEmbeddedObject&);
328 void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&);
330 WEBCORE_EXPORT virtual void paintContents(GraphicsContext*, const IntRect& dirtyRect) override;
332 struct PaintingState {
333 PaintBehavior paintBehavior;
334 bool isTopLevelPainter;
335 bool isFlatteningPaintOfRootFrame;
338 , isTopLevelPainter(false)
339 , isFlatteningPaintOfRootFrame(false)
344 void willPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
345 void didPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
347 WEBCORE_EXPORT void setPaintBehavior(PaintBehavior);
348 WEBCORE_EXPORT PaintBehavior paintBehavior() const;
349 bool isPainting() const;
350 bool hasEverPainted() const { return m_lastPaintTime; }
351 void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
352 WEBCORE_EXPORT void setNodeToDraw(Node*);
354 enum SelectionInSnapshot { IncludeSelection, ExcludeSelection };
355 enum CoordinateSpaceForSnapshot { DocumentCoordinates, ViewCoordinates };
356 WEBCORE_EXPORT void paintContentsForSnapshot(GraphicsContext*, const IntRect& imageRect, SelectionInSnapshot shouldPaintSelection, CoordinateSpaceForSnapshot);
358 virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) override;
359 virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect) override;
360 virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) override;
362 WEBCORE_EXPORT Color documentBackgroundColor() const;
364 bool isInChildFrameWithFrameFlattening() const;
366 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
368 WEBCORE_EXPORT void updateLayoutAndStyleIfNeededRecursive();
370 void incrementVisuallyNonEmptyCharacterCount(unsigned);
371 void incrementVisuallyNonEmptyPixelCount(const IntSize&);
372 void updateIsVisuallyNonEmpty();
373 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
374 WEBCORE_EXPORT void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
375 WEBCORE_EXPORT void setAutoSizeFixedMinimumHeight(int);
376 IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; }
378 WEBCORE_EXPORT void forceLayout(bool allowSubtree = false);
379 WEBCORE_EXPORT void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
381 // FIXME: This method is retained because of embedded WebViews in AppKit. When a WebView is embedded inside
382 // some enclosing view with auto-pagination, no call happens to resize the view. The new pagination model
383 // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
384 // resize around that view. Auto-pagination uses the bounds of the actual view that's being printed to determine
385 // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
386 // web document's bounds.
388 // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
389 // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
390 // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
391 // page size, it can't actually paginate correctly during _layoutForPrinting.
393 // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
394 // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
396 // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
397 WEBCORE_EXPORT void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
399 bool scrollToFragment(const URL&);
400 bool scrollToAnchor(const String&);
401 void maintainScrollPositionAtAnchor(ContainerNode*);
402 WEBCORE_EXPORT void scrollElementToRect(Element*, const IntRect&);
404 // Methods to convert points and rects between the coordinate space of the renderer, and this view.
405 WEBCORE_EXPORT IntRect convertFromRendererToContainingView(const RenderElement*, const IntRect&) const;
406 WEBCORE_EXPORT IntRect convertFromContainingViewToRenderer(const RenderElement*, const IntRect&) const;
407 WEBCORE_EXPORT IntPoint convertFromRendererToContainingView(const RenderElement*, const IntPoint&) const;
408 WEBCORE_EXPORT IntPoint convertFromContainingViewToRenderer(const RenderElement*, const IntPoint&) const;
410 // Override ScrollView methods to do point conversion via renderers, in order to take transforms into account.
411 virtual IntRect convertToContainingView(const IntRect&) const override;
412 virtual IntRect convertFromContainingView(const IntRect&) const override;
413 virtual IntPoint convertToContainingView(const IntPoint&) const override;
414 virtual IntPoint convertFromContainingView(const IntPoint&) const override;
416 bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
418 // isScrollable() takes an optional Scrollability parameter that allows the caller to define what they mean by 'scrollable.'
419 // Most callers are interested in the default value, Scrollability::Scrollable, which means that there is actually content
420 // 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
421 // to rubber-band, which the main frame might be allowed to do even if there is no content to scroll to. In that case,
422 // callers use Scrollability::ScrollableOrRubberbandable.
423 enum class Scrollability { Scrollable, ScrollableOrRubberbandable };
424 bool isScrollable(Scrollability definitionOfScrollable = Scrollability::Scrollable);
426 virtual bool isScrollableOrRubberbandable() override;
427 virtual bool hasScrollableOrRubberbandableAncestor() override;
429 enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
430 void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
432 virtual IntPoint lastKnownMousePosition() const override;
433 virtual bool isHandlingWheelEvent() const override;
434 bool shouldSetCursor() const;
436 // FIXME: Remove this method once plugin loading is decoupled from layout.
437 void flushAnyPendingPostLayoutTasks();
439 virtual bool shouldSuspendScrollAnimations() const override;
440 virtual void scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate) override;
442 RenderBox* embeddedContentBox() const;
444 WEBCORE_EXPORT void setTracksRepaints(bool);
445 bool isTrackingRepaints() const { return m_isTrackingRepaints; }
446 WEBCORE_EXPORT void resetTrackedRepaints();
447 const Vector<FloatRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
448 String trackedRepaintRectsAsText() const;
450 typedef HashSet<ScrollableArea*> ScrollableAreaSet;
451 // Returns whether the scrollable area has just been newly added.
452 WEBCORE_EXPORT bool addScrollableArea(ScrollableArea*);
453 // Returns whether the scrollable area has just been removed.
454 WEBCORE_EXPORT bool removeScrollableArea(ScrollableArea*);
455 bool containsScrollableArea(ScrollableArea*) const;
456 const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
458 virtual void removeChild(Widget&) override;
460 // This function exists for ports that need to handle wheel events manually.
461 // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
462 // we need this function in order to do the scroll ourselves.
463 bool wheelEvent(const PlatformWheelEvent&);
465 WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool);
467 // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
468 // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
469 // FrameViews in the page cache, but FrameView::pagination() only affects the current
470 // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
471 // it will return Page::pagination() since currently there are no callers that need to
472 // distinguish between the two.
473 const Pagination& pagination() const;
474 void setPagination(const Pagination&);
476 bool inProgrammaticScroll() const override { return m_inProgrammaticScroll; }
477 void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
479 #if ENABLE(CSS_DEVICE_ADAPTATION)
480 IntSize initialViewportSize() const { return m_initialViewportSize; }
481 void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
484 virtual bool isActive() const override;
485 virtual bool updatesScrollLayerPositionOnMainThread() const override;
486 virtual bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
488 #if ENABLE(RUBBER_BANDING)
489 WEBCORE_EXPORT GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
490 WEBCORE_EXPORT GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
493 virtual int headerHeight() const override { return m_headerHeight; }
494 WEBCORE_EXPORT void setHeaderHeight(int);
495 virtual int footerHeight() const override { return m_footerHeight; }
496 WEBCORE_EXPORT void setFooterHeight(int);
498 WEBCORE_EXPORT virtual float topContentInset(TopContentInsetType = TopContentInsetType::WebCoreContentInset) const override;
499 void topContentInsetDidChange(float newTopContentInset);
501 WEBCORE_EXPORT virtual void willStartLiveResize() override;
502 WEBCORE_EXPORT virtual void willEndLiveResize() override;
504 WEBCORE_EXPORT virtual void availableContentSizeChanged(AvailableSizeChangeReason) override;
506 void addPaintPendingMilestones(LayoutMilestones);
507 void firePaintRelatedMilestonesIfNeeded();
508 void fireLayoutRelatedMilestonesIfNeeded();
509 LayoutMilestones milestonesPendingPaint() const { return m_milestonesPendingPaint; }
511 bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; }
512 WEBCORE_EXPORT void setVisualUpdatesAllowedByClient(bool);
514 WEBCORE_EXPORT void setScrollPinningBehavior(ScrollPinningBehavior);
516 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const;
518 bool hasFlippedBlockRenderers() const { return m_hasFlippedBlockRenderers; }
519 void setHasFlippedBlockRenderers(bool b) { m_hasFlippedBlockRenderers = b; }
521 void updateWidgetPositions();
522 void didAddWidgetToRenderTree(Widget&);
523 void willRemoveWidgetFromRenderTree(Widget&);
525 const HashSet<Widget*>& widgetsInRenderTree() const { return m_widgetsInRenderTree; }
527 typedef Vector<Ref<FrameView>, 16> FrameViewList;
528 FrameViewList renderedChildFrameViews() const;
530 void addTrackedRepaintRect(const FloatRect&);
532 // exposedRect represents WebKit's understanding of what part
533 // of the view is actually exposed on screen (taking into account
534 // clipping by other UI elements), whereas visibleContentRect is
535 // internal to WebCore and doesn't respect those things.
536 WEBCORE_EXPORT void setExposedRect(FloatRect);
537 FloatRect exposedRect() const { return m_exposedRect; }
539 #if ENABLE(CSS_SCROLL_SNAP)
540 virtual void updateSnapOffsets() override;
543 virtual float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity) override;
545 void didChangeScrollOffset();
548 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
549 virtual void scrollContentsSlowPath(const IntRect& updateRect) override;
551 void repaintSlowRepaintObjects();
553 virtual bool isVerticalDocument() const override;
554 virtual bool isFlippedDocument() const override;
557 explicit FrameView(Frame&);
565 InPreLayoutStyleUpdate,
569 InPostLayerPositionsUpdatedAfterLayout,
571 LayoutPhase layoutPhase() const { return m_layoutPhase; }
573 bool inPreLayoutStyleUpdate() const { return m_layoutPhase == InPreLayoutStyleUpdate; }
575 virtual bool isFrameView() const override { return true; }
577 friend class RenderWidget;
578 bool useSlowRepaints(bool considerOverlap = true) const;
579 bool useSlowRepaintsIfNotOverlapped() const;
580 void updateCanBlitOnScrollRecursively();
581 bool shouldLayoutAfterContentsResized() const;
583 bool shouldUpdateCompositingLayersAfterScrolling() const;
585 virtual bool shouldDeferScrollUpdateAfterContentSizeChange() override;
587 virtual void scrollPositionChangedViaPlatformWidgetImpl(const IntPoint& oldPosition, const IntPoint& newPosition) override;
589 void applyOverflowToViewport(RenderElement*, ScrollbarMode& hMode, ScrollbarMode& vMode);
590 void applyPaginationToViewport();
592 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
594 WEBCORE_EXPORT void paintControlTints();
596 void forceLayoutParentViewIfNeeded();
597 void performPostLayoutTasks();
598 void autoSizeIfEnabled();
599 void updateThrottledDOMTimersState();
601 void updateLayerFlushThrottling();
602 WEBCORE_EXPORT void adjustTiledBackingCoverage();
604 virtual void repaintContentRectangle(const IntRect&) override;
605 virtual void updateContentsSize() override;
606 virtual void addedOrRemovedScrollbar() override;
608 virtual void delegatesScrollingDidChange() override;
610 // ScrollableArea interface
611 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
612 virtual void scrollTo(const IntSize&) override;
613 virtual void setVisibleScrollerThumbRect(const IntRect&) override;
614 virtual ScrollableArea* enclosingScrollableArea() const override;
615 virtual IntRect scrollableAreaBoundingBox() const override;
616 virtual bool scrollAnimatorEnabled() const override;
617 virtual GraphicsLayer* layerForScrolling() const override;
618 virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
619 virtual GraphicsLayer* layerForVerticalScrollbar() const override;
620 virtual GraphicsLayer* layerForScrollCorner() const override;
621 #if ENABLE(RUBBER_BANDING)
622 virtual GraphicsLayer* layerForOverhangAreas() const override;
625 virtual bool usesCompositedScrolling() const override;
626 virtual bool usesAsyncScrolling() const override;
628 // Override scrollbar notifications to update the AXObject cache.
629 virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) override;
630 virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) override;
632 IntSize sizeForResizeEvent() const;
633 void sendResizeEventIfNeeded();
635 void updateScrollableAreaSet();
637 virtual void notifyPageThatContentAreaWillPaint() const override;
639 void enableSpeculativeTilingIfNeeded();
640 void speculativeTilingEnableTimerFired();
642 void updateEmbeddedObjectsTimerFired();
643 bool updateEmbeddedObjects();
644 void updateEmbeddedObject(RenderEmbeddedObject&);
645 void scrollToAnchor();
646 void scrollPositionChanged(const IntPoint& oldPosition, const IntPoint& newPosition);
647 void scrollableAreaSetChanged();
648 void sendScrollEvent();
650 bool hasCustomScrollbars() const;
652 virtual void updateScrollCorner() override;
654 FrameView* parentFrameView() const;
656 void startLayoutAtMainFrameViewIfNeeded(bool allowSubtree);
657 bool frameFlatteningEnabled() const;
658 bool isFrameFlatteningValidForThisFrame() const;
660 bool qualifiesAsVisuallyNonEmpty() const;
661 bool isViewForDocumentInFrame() const;
663 AXObjectCache* axObjectCache() const;
664 void notifyWidgetsInAllFrames(WidgetNotification);
665 void removeFromAXObjectCache();
666 void notifyWidgets(WidgetNotification);
668 HashSet<Widget*> m_widgetsInRenderTree;
670 static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
673 LayoutSize m_margins;
675 std::unique_ptr<ListHashSet<RenderEmbeddedObject*>> m_embeddedObjectsToUpdate;
676 const Ref<Frame> m_frame;
678 std::unique_ptr<HashSet<RenderElement*>> m_slowRepaintObjects;
680 bool m_needsFullRepaint;
682 bool m_canHaveScrollbars;
683 bool m_cannotBlitToWindow;
685 bool m_contentIsOpaque;
688 bool m_delayedLayout;
689 RenderElement* m_layoutRoot;
691 LayoutPhase m_layoutPhase;
692 bool m_layoutSchedulingEnabled;
693 bool m_inSynchronousPostLayout;
695 unsigned m_nestedLayoutCount;
696 Timer m_postLayoutTasksTimer;
697 Timer m_updateEmbeddedObjectsTimer;
698 bool m_firstLayoutCallbackPending;
701 bool m_isTransparent;
702 Color m_baseBackgroundColor;
703 IntSize m_lastViewportSize;
704 float m_lastZoomFactor;
707 String m_mediaTypeWhenNotPrinting;
709 bool m_overflowStatusDirty;
710 bool m_horizontalOverflow;
711 bool m_verticalOverflow;
712 RenderElement* m_viewportRenderer;
714 Pagination m_pagination;
716 bool m_wasScrolledByUser;
717 bool m_inProgrammaticScroll;
718 bool m_safeToPropagateScrollToParent;
719 Timer m_delayedScrollEventTimer;
721 double m_lastPaintTime;
723 bool m_isTrackingRepaints; // Used for testing.
724 Vector<FloatRect> m_trackedRepaintRects;
726 bool m_shouldUpdateWhileOffscreen;
728 FloatRect m_exposedRect;
730 unsigned m_deferSetNeedsLayoutCount;
731 bool m_setNeedsLayoutWasDeferred;
733 RefPtr<Node> m_nodeToDraw;
734 PaintBehavior m_paintBehavior;
737 unsigned m_visuallyNonEmptyCharacterCount;
738 unsigned m_visuallyNonEmptyPixelCount;
739 bool m_isVisuallyNonEmpty;
740 bool m_firstVisuallyNonEmptyLayoutCallbackPending;
742 RefPtr<ContainerNode> m_maintainScrollPositionAnchor;
744 // Renderer to hold our custom scroll corner.
745 RenderPtr<RenderScrollbarPart> m_scrollCorner;
747 bool m_speculativeTilingEnabled;
748 Timer m_speculativeTilingEnableTimer;
751 bool m_useCustomFixedPositionLayoutRect;
752 IntRect m_customFixedPositionLayoutRect;
754 bool m_useCustomSizeForResizeEvent;
755 IntSize m_customSizeForResizeEvent;
757 double m_horizontalVelocity;
758 double m_verticalVelocity;
759 double m_scaleChangeRate;
760 double m_lastVelocityUpdateTime;
763 IntSize m_overrideViewportSize;
764 bool m_hasOverrideViewportSize;
766 // If true, automatically resize the frame view around its content.
767 bool m_shouldAutoSize;
769 // True if autosize has been run since m_shouldAutoSize was set.
770 bool m_didRunAutosize;
771 // The lower bound on the size when autosizing.
772 IntSize m_minAutoSize;
773 // The upper bound on the size when autosizing.
774 IntSize m_maxAutoSize;
775 // The fixed height to resize the view to after autosizing is complete.
776 int m_autoSizeFixedMinimumHeight;
777 // The intrinsic content size decided by autosizing.
778 IntSize m_autoSizeContentSize;
780 std::unique_ptr<ScrollableAreaSet> m_scrollableAreas;
781 std::unique_ptr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
783 HashSet<DOMTimer*> m_throttledTimers;
788 LayoutMilestones m_milestonesPendingPaint;
790 static const unsigned visualCharacterThreshold = 200;
791 static const unsigned visualPixelThreshold = 32 * 32;
793 #if ENABLE(CSS_DEVICE_ADAPTATION)
794 // Size of viewport before any UA or author styles have overridden
795 // the viewport given by the window or viewing area of the UA.
796 IntSize m_initialViewportSize;
799 bool m_visualUpdatesAllowedByClient;
800 bool m_hasFlippedBlockRenderers;
802 ScrollPinningBehavior m_scrollPinningBehavior;
804 IntRect* m_cachedWindowClipRect { nullptr };
807 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
809 if (m_isVisuallyNonEmpty)
811 m_visuallyNonEmptyCharacterCount += count;
812 if (m_visuallyNonEmptyCharacterCount <= visualCharacterThreshold)
814 updateIsVisuallyNonEmpty();
817 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
819 if (m_isVisuallyNonEmpty)
821 m_visuallyNonEmptyPixelCount += size.width() * size.height();
822 if (m_visuallyNonEmptyPixelCount <= visualPixelThreshold)
824 updateIsVisuallyNonEmpty();
827 } // namespace WebCore
829 SPECIALIZE_TYPE_TRAITS_WIDGET(FrameView, isFrameView())
831 #endif // FrameView_h