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-2015 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>
49 class HTMLFrameOwnerElement;
55 class RenderEmbeddedObject;
58 class RenderScrollbarPart;
63 Pagination::Mode paginationModeForRenderStyle(const RenderStyle&);
65 typedef unsigned long long DOMTimeStamp;
67 class FrameView final : public ScrollView {
69 friend class RenderView;
70 friend class Internals;
72 WEBCORE_EXPORT static Ref<FrameView> create(Frame&);
73 static Ref<FrameView> create(Frame&, const IntSize& initialSize);
77 HostWindow* hostWindow() const override;
79 WEBCORE_EXPORT void invalidateRect(const IntRect&) override;
80 void setFrameRect(const IntRect&) override;
82 #if ENABLE(REQUEST_ANIMATION_FRAME)
83 bool scheduleAnimation() override;
86 Frame& frame() const { return const_cast<Frame&>(m_frame.get()); }
88 WEBCORE_EXPORT RenderView* renderView() const;
90 int mapFromLayoutToCSSUnits(LayoutUnit) const;
91 LayoutUnit mapFromCSSToLayoutUnits(int) const;
93 LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default
94 LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default
95 void setMarginWidth(LayoutUnit);
96 void setMarginHeight(LayoutUnit);
98 WEBCORE_EXPORT void setCanHaveScrollbars(bool) override;
99 WEBCORE_EXPORT void updateCanHaveScrollbars();
101 PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation) override;
103 bool avoidScrollbarCreation() const override;
105 void setContentsSize(const IntSize&) override;
106 void updateContentsSize() 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 void queuePostLayoutCallback(std::function<void()>);
115 bool layoutPending() const;
116 bool isInLayout() const { return m_layoutPhase != OutsideLayout; }
117 bool isInRenderTreeLayout() const { return m_layoutPhase == InRenderTreeLayout; }
118 WEBCORE_EXPORT bool inPaintableState() { return m_layoutPhase != InRenderTreeLayout && m_layoutPhase != InViewSizeAdjust && m_layoutPhase != InPostLayout; }
120 RenderElement* layoutRoot() const { return m_layoutRoot; }
121 void clearLayoutRoot() { m_layoutRoot = nullptr; }
122 int layoutCount() const { return m_layoutCount; }
124 WEBCORE_EXPORT bool needsLayout() const;
125 WEBCORE_EXPORT void setNeedsLayout();
126 void setViewportConstrainedObjectsNeedLayout();
128 bool needsStyleRecalcOrLayout(bool includeSubframes = true) const;
130 bool needsFullRepaint() const { return m_needsFullRepaint; }
132 WEBCORE_EXPORT bool renderedCharactersExceed(unsigned threshold);
134 WEBCORE_EXPORT void setViewportIsStable(bool stable) { m_viewportIsStable = stable; }
135 bool viewportIsStable() const { return m_viewportIsStable; }
138 bool useCustomFixedPositionLayoutRect() const { return m_useCustomFixedPositionLayoutRect; }
139 IntRect customFixedPositionLayoutRect() const { return m_customFixedPositionLayoutRect; }
140 WEBCORE_EXPORT void setCustomFixedPositionLayoutRect(const IntRect&);
141 bool updateFixedPositionLayoutRect();
143 IntSize customSizeForResizeEvent() const { return m_customSizeForResizeEvent; }
144 WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize);
146 WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, double timestamp);
148 bool useCustomFixedPositionLayoutRect() const { return false; }
151 #if ENABLE(REQUEST_ANIMATION_FRAME)
152 WEBCORE_EXPORT void serviceScriptedAnimations(double monotonicAnimationStartTime);
155 void willRecalcStyle();
156 bool updateCompositingLayersAfterStyleChange();
157 void updateCompositingLayersAfterLayout();
159 void clearBackingStores();
160 void restoreBackingStores();
162 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
163 // content rendered via the normal painting path.
164 void setNeedsOneShotDrawingSynchronization();
166 WEBCORE_EXPORT GraphicsLayer* graphicsLayerForPlatformWidget(PlatformWidget);
167 WEBCORE_EXPORT void scheduleLayerFlushAllowingThrottling();
169 WEBCORE_EXPORT TiledBacking* tiledBacking() const override;
171 // In the future when any ScrollableArea can have a node in th ScrollingTree, this should
172 // become a virtual function on ScrollableArea.
173 uint64_t scrollLayerID() const;
174 ScrollableArea* scrollableAreaForScrollLayerID(uint64_t) const;
176 bool hasCompositedContent() const;
177 WEBCORE_EXPORT void enterCompositingMode();
178 WEBCORE_EXPORT bool isEnclosedInCompositingLayer() const;
180 // Only used with accelerated compositing, but outside the #ifdef to make linkage easier.
181 // Returns true if the flush was completed.
182 WEBCORE_EXPORT bool flushCompositingStateIncludingSubframes();
184 // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
185 // a faithful representation of the content.
186 WEBCORE_EXPORT bool isSoftwareRenderable() const;
188 void setIsInWindow(bool);
190 void resetScrollbars();
191 void resetScrollbarsAndClearContentsSize();
192 void prepareForDetach();
193 void detachCustomScrollbars();
194 WEBCORE_EXPORT void recalculateScrollbarOverlayStyle();
198 WEBCORE_EXPORT bool isTransparent() const;
199 WEBCORE_EXPORT void setTransparent(bool isTransparent);
201 // True if the FrameView is not transparent, and the base background color is opaque.
202 bool hasOpaqueBackground() const;
204 WEBCORE_EXPORT Color baseBackgroundColor() const;
205 WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
206 void updateBackgroundRecursively(const Color&, bool);
208 enum ExtendedBackgroundModeFlags {
209 ExtendedBackgroundModeNone = 0,
210 ExtendedBackgroundModeVertical = 1 << 0,
211 ExtendedBackgroundModeHorizontal = 1 << 1,
212 ExtendedBackgroundModeAll = ExtendedBackgroundModeVertical | ExtendedBackgroundModeHorizontal,
214 typedef unsigned ExtendedBackgroundMode;
216 void updateExtendBackgroundIfNecessary();
217 void updateTilesForExtendedBackgroundMode(ExtendedBackgroundMode);
218 ExtendedBackgroundMode calculateExtendedBackgroundMode() const;
220 bool hasExtendedBackgroundRectForPainting() const;
221 IntRect extendedBackgroundRectForPainting() const;
223 bool shouldUpdateWhileOffscreen() const;
224 WEBCORE_EXPORT void setShouldUpdateWhileOffscreen(bool);
225 bool shouldUpdate() const;
227 WEBCORE_EXPORT void adjustViewSize();
229 WEBCORE_EXPORT void setViewportSizeForCSSViewportUnits(IntSize);
230 IntSize viewportSizeForCSSViewportUnits() const;
232 IntRect windowClipRect() const override;
233 WEBCORE_EXPORT IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
235 float visibleContentScaleFactor() const override;
237 #if USE(COORDINATED_GRAPHICS)
238 void setFixedVisibleContentRect(const IntRect&) override;
240 WEBCORE_EXPORT void setScrollPosition(const ScrollPosition&) override;
241 void updateLayerPositionsAfterScrolling() override;
242 void updateCompositingLayersAfterScrolling() override;
243 bool requestScrollPositionUpdate(const ScrollPosition&) override;
244 bool isRubberBandInProgress() const override;
245 WEBCORE_EXPORT ScrollPosition minimumScrollPosition() const override;
246 WEBCORE_EXPORT ScrollPosition maximumScrollPosition() const override;
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(const RenderElement& renderer) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(&renderer); }
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 float frameScaleFactor() const;
279 // Functions for querying the current scrolled position, negating the effects of overhang
280 // and adjusting for page scale.
281 LayoutPoint scrollPositionForFixedPosition() const
283 return scrollPositionForFixedPosition(visibleContentRect(), totalContentsSize(), scrollPosition(), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), scrollBehaviorForFixedElements(), headerHeight(), footerHeight());
286 // Static function can be called from another thread.
287 static LayoutPoint scrollPositionForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
289 // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed
290 // on both the main thread and the scrolling thread.
291 static float yPositionForInsetClipLayer(const FloatPoint& scrollPosition, float topContentInset);
292 WEBCORE_EXPORT static FloatPoint positionForRootContentLayer(const FloatPoint& scrollPosition, const FloatPoint& scrollOrigin, float topContentInset, float headerHeight);
293 WEBCORE_EXPORT FloatPoint positionForRootContentLayer() const;
295 static float yPositionForHeaderLayer(const FloatPoint& scrollPosition, float topContentInset);
296 static float yPositionForFooterLayer(const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float footerHeight);
299 WEBCORE_EXPORT LayoutRect viewportConstrainedObjectsRect() const;
300 // Static function can be called from another thread.
301 WEBCORE_EXPORT static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements);
304 bool fixedElementsLayoutRelativeToFrame() const;
306 WEBCORE_EXPORT void disableLayerFlushThrottlingTemporarilyForInteraction();
307 bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; }
308 void loadProgressingStatusChanged();
310 #if ENABLE(DASHBOARD_SUPPORT)
311 void updateAnnotatedRegions();
313 WEBCORE_EXPORT void updateControlTints();
315 void restoreScrollbar();
317 WEBCORE_EXPORT bool wasScrolledByUser() const;
318 WEBCORE_EXPORT void setWasScrolledByUser(bool);
320 bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
321 void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
323 void addEmbeddedObjectToUpdate(RenderEmbeddedObject&);
324 void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&);
326 WEBCORE_EXPORT void paintContents(GraphicsContext&, const IntRect& dirtyRect) override;
328 struct PaintingState {
329 PaintBehavior paintBehavior;
330 bool isTopLevelPainter;
331 bool isFlatteningPaintOfRootFrame;
334 , isTopLevelPainter(false)
335 , isFlatteningPaintOfRootFrame(false)
340 void willPaintContents(GraphicsContext&, const IntRect& dirtyRect, PaintingState&);
341 void didPaintContents(GraphicsContext&, const IntRect& dirtyRect, PaintingState&);
344 WEBCORE_EXPORT void didReplaceMultipartContent();
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 void paintOverhangAreas(GraphicsContext&, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) override;
359 void paintScrollCorner(GraphicsContext&, const IntRect& cornerRect) override;
360 void paintScrollbar(GraphicsContext&, Scrollbar&, const IntRect&) override;
362 WEBCORE_EXPORT Color documentBackgroundColor() const;
364 bool isInChildFrameWithFrameFlattening() const;
366 void startDisallowingLayout() { ++m_layoutDisallowed; }
367 void endDisallowingLayout() { ASSERT(m_layoutDisallowed > 0); --m_layoutDisallowed; }
368 bool layoutDisallowed() const { return m_layoutDisallowed; }
370 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
372 WEBCORE_EXPORT void updateLayoutAndStyleIfNeededRecursive();
374 void incrementVisuallyNonEmptyCharacterCount(unsigned);
375 void incrementVisuallyNonEmptyPixelCount(const IntSize&);
376 void updateIsVisuallyNonEmpty();
377 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
378 WEBCORE_EXPORT void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
379 WEBCORE_EXPORT void setAutoSizeFixedMinimumHeight(int);
380 IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; }
382 WEBCORE_EXPORT void forceLayout(bool allowSubtree = false);
383 WEBCORE_EXPORT void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
385 // FIXME: This method is retained because of embedded WebViews in AppKit. When a WebView is embedded inside
386 // some enclosing view with auto-pagination, no call happens to resize the view. The new pagination model
387 // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
388 // resize around that view. Auto-pagination uses the bounds of the actual view that's being printed to determine
389 // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
390 // web document's bounds.
392 // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
393 // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
394 // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
395 // page size, it can't actually paginate correctly during _layoutForPrinting.
397 // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
398 // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
400 // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
401 WEBCORE_EXPORT void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
403 bool scrollToFragment(const URL&);
404 bool scrollToAnchor(const String&);
405 void maintainScrollPositionAtAnchor(ContainerNode*);
406 WEBCORE_EXPORT void scrollElementToRect(const Element&, const IntRect&);
408 // Methods to convert points and rects between the coordinate space of the renderer, and this view.
409 WEBCORE_EXPORT IntRect convertFromRendererToContainingView(const RenderElement*, const IntRect&) const;
410 WEBCORE_EXPORT IntRect convertFromContainingViewToRenderer(const RenderElement*, const IntRect&) const;
411 WEBCORE_EXPORT IntPoint convertFromRendererToContainingView(const RenderElement*, const IntPoint&) const;
412 WEBCORE_EXPORT IntPoint convertFromContainingViewToRenderer(const RenderElement*, const IntPoint&) const;
414 // Override ScrollView methods to do point conversion via renderers, in order to take transforms into account.
415 IntRect convertToContainingView(const IntRect&) const override;
416 IntRect convertFromContainingView(const IntRect&) const override;
417 IntPoint convertToContainingView(const IntPoint&) const override;
418 IntPoint convertFromContainingView(const IntPoint&) const override;
420 bool isFrameViewScrollCorner(const RenderScrollbarPart& scrollCorner) const { return m_scrollCorner == &scrollCorner; }
422 // isScrollable() takes an optional Scrollability parameter that allows the caller to define what they mean by 'scrollable.'
423 // Most callers are interested in the default value, Scrollability::Scrollable, which means that there is actually content
424 // 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
425 // to rubber-band, which the main frame might be allowed to do even if there is no content to scroll to. In that case,
426 // callers use Scrollability::ScrollableOrRubberbandable.
427 enum class Scrollability { Scrollable, ScrollableOrRubberbandable };
428 WEBCORE_EXPORT bool isScrollable(Scrollability definitionOfScrollable = Scrollability::Scrollable);
430 bool isScrollableOrRubberbandable() override;
431 bool hasScrollableOrRubberbandableAncestor() override;
433 enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
434 void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
436 IntPoint lastKnownMousePosition() const override;
437 bool isHandlingWheelEvent() const override;
438 bool shouldSetCursor() const;
440 // FIXME: Remove this method once plugin loading is decoupled from layout.
441 void flushAnyPendingPostLayoutTasks();
443 bool shouldSuspendScrollAnimations() const override;
444 void scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate) override;
446 RenderBox* embeddedContentBox() const;
448 WEBCORE_EXPORT void setTracksRepaints(bool);
449 bool isTrackingRepaints() const { return m_isTrackingRepaints; }
450 WEBCORE_EXPORT void resetTrackedRepaints();
451 const Vector<FloatRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
452 String trackedRepaintRectsAsText() const;
454 typedef HashSet<ScrollableArea*> ScrollableAreaSet;
455 // Returns whether the scrollable area has just been newly added.
456 WEBCORE_EXPORT bool addScrollableArea(ScrollableArea*);
457 // Returns whether the scrollable area has just been removed.
458 WEBCORE_EXPORT bool removeScrollableArea(ScrollableArea*);
459 bool containsScrollableArea(ScrollableArea*) const;
460 const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
462 void removeChild(Widget&) override;
464 // This function exists for ports that need to handle wheel events manually.
465 // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
466 // we need this function in order to do the scroll ourselves.
467 bool wheelEvent(const PlatformWheelEvent&);
469 WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool);
471 // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
472 // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
473 // FrameViews in the page cache, but FrameView::pagination() only affects the current
474 // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
475 // it will return Page::pagination() since currently there are no callers that need to
476 // distinguish between the two.
477 const Pagination& pagination() const;
478 void setPagination(const Pagination&);
480 bool inProgrammaticScroll() const override { return m_inProgrammaticScroll; }
481 void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
483 #if ENABLE(CSS_DEVICE_ADAPTATION)
484 IntSize initialViewportSize() const { return m_initialViewportSize; }
485 void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
488 bool isActive() const override;
489 bool updatesScrollLayerPositionOnMainThread() const override;
490 bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
492 #if ENABLE(RUBBER_BANDING)
493 WEBCORE_EXPORT GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
494 WEBCORE_EXPORT GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
497 LayoutRect fixedScrollableAreaBoundsInflatedForScrolling(const LayoutRect& uninflatedBounds) const;
498 LayoutPoint scrollPositionRespectingCustomFixedPosition() const;
500 int headerHeight() const override { return m_headerHeight; }
501 WEBCORE_EXPORT void setHeaderHeight(int);
502 int footerHeight() const override { return m_footerHeight; }
503 WEBCORE_EXPORT void setFooterHeight(int);
505 WEBCORE_EXPORT float topContentInset(TopContentInsetType = TopContentInsetType::WebCoreContentInset) const override;
506 void topContentInsetDidChange(float newTopContentInset);
508 WEBCORE_EXPORT void willStartLiveResize() override;
509 WEBCORE_EXPORT void willEndLiveResize() override;
511 WEBCORE_EXPORT void availableContentSizeChanged(AvailableSizeChangeReason) override;
513 void adjustTiledBackingScrollability();
515 void addPaintPendingMilestones(LayoutMilestones);
516 void firePaintRelatedMilestonesIfNeeded();
517 void fireLayoutRelatedMilestonesIfNeeded();
518 LayoutMilestones milestonesPendingPaint() const { return m_milestonesPendingPaint; }
520 bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; }
521 WEBCORE_EXPORT void setVisualUpdatesAllowedByClient(bool);
523 WEBCORE_EXPORT void setScrollPinningBehavior(ScrollPinningBehavior);
525 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const;
527 bool hasFlippedBlockRenderers() const { return m_hasFlippedBlockRenderers; }
528 void setHasFlippedBlockRenderers(bool b) { m_hasFlippedBlockRenderers = b; }
530 void updateWidgetPositions();
531 void didAddWidgetToRenderTree(Widget&);
532 void willRemoveWidgetFromRenderTree(Widget&);
534 const HashSet<Widget*>& widgetsInRenderTree() const { return m_widgetsInRenderTree; }
536 typedef Vector<Ref<FrameView>, 16> FrameViewList;
537 FrameViewList renderedChildFrameViews() const;
539 void addTrackedRepaintRect(const FloatRect&);
541 // exposedRect represents WebKit's understanding of what part
542 // of the view is actually exposed on screen (taking into account
543 // clipping by other UI elements), whereas visibleContentRect is
544 // internal to WebCore and doesn't respect those things.
545 WEBCORE_EXPORT void setExposedRect(FloatRect);
546 FloatRect exposedRect() const { return m_exposedRect; }
548 #if ENABLE(CSS_SCROLL_SNAP)
549 void updateSnapOffsets() override;
550 bool isScrollSnapInProgress() const override;
551 void updateScrollingCoordinatorScrollSnapProperties() const;
554 float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity) override;
556 void didChangeScrollOffset();
558 void show() override;
561 bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
562 void scrollContentsSlowPath(const IntRect& updateRect) override;
564 void repaintSlowRepaintObjects();
566 bool isVerticalDocument() const override;
567 bool isFlippedDocument() const override;
570 explicit FrameView(Frame&);
578 InPreLayoutStyleUpdate,
582 InPostLayerPositionsUpdatedAfterLayout,
584 LayoutPhase layoutPhase() const { return m_layoutPhase; }
586 bool inPreLayoutStyleUpdate() const { return m_layoutPhase == InPreLayoutStyleUpdate; }
588 bool isFrameView() const override { return true; }
590 friend class RenderWidget;
591 bool useSlowRepaints(bool considerOverlap = true) const;
592 bool useSlowRepaintsIfNotOverlapped() const;
593 void updateCanBlitOnScrollRecursively();
594 bool shouldLayoutAfterContentsResized() const;
596 bool shouldUpdateCompositingLayersAfterScrolling() const;
597 bool flushCompositingStateForThisFrame(const Frame& rootFrameForFlush);
599 bool shouldDeferScrollUpdateAfterContentSizeChange() override;
601 void scrollOffsetChangedViaPlatformWidgetImpl(const ScrollOffset& oldOffset, const ScrollOffset& newOffset) override;
603 void applyOverflowToViewport(const RenderElement&, ScrollbarMode& hMode, ScrollbarMode& vMode);
604 void applyPaginationToViewport();
606 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
608 WEBCORE_EXPORT void paintControlTints();
610 void forceLayoutParentViewIfNeeded();
611 void flushPostLayoutTasksQueue();
612 void performPostLayoutTasks();
613 void autoSizeIfEnabled();
615 void applyRecursivelyWithVisibleRect(const std::function<void (FrameView& frameView, const IntRect& visibleRect)>&);
616 void resumeVisibleImageAnimations(const IntRect& visibleRect);
617 void updateScriptedAnimationsAndTimersThrottlingState(const IntRect& visibleRect);
619 void updateLayerFlushThrottling();
620 WEBCORE_EXPORT void adjustTiledBackingCoverage();
622 void repaintContentRectangle(const IntRect&) override;
623 void addedOrRemovedScrollbar() override;
625 void delegatesScrollingDidChange() override;
627 // ScrollableArea interface
628 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
629 void scrollTo(const ScrollPosition&) override;
630 void setVisibleScrollerThumbRect(const IntRect&) override;
631 ScrollableArea* enclosingScrollableArea() const override;
632 IntRect scrollableAreaBoundingBox(bool* = nullptr) const override;
633 bool scrollAnimatorEnabled() const override;
634 GraphicsLayer* layerForScrolling() const override;
635 GraphicsLayer* layerForHorizontalScrollbar() const override;
636 GraphicsLayer* layerForVerticalScrollbar() const override;
637 GraphicsLayer* layerForScrollCorner() const override;
638 #if ENABLE(RUBBER_BANDING)
639 GraphicsLayer* layerForOverhangAreas() const override;
641 void contentsResized() override;
644 void unobscuredContentSizeChanged() override;
647 bool usesCompositedScrolling() const override;
648 bool usesAsyncScrolling() const override;
649 bool usesMockScrollAnimator() const override;
650 void logMockScrollAnimatorMessage(const String&) const override;
652 // Override scrollbar notifications to update the AXObject cache.
653 void didAddScrollbar(Scrollbar*, ScrollbarOrientation) override;
654 void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) override;
656 IntSize sizeForResizeEvent() const;
657 void sendResizeEventIfNeeded();
659 void updateScrollableAreaSet();
661 void notifyPageThatContentAreaWillPaint() const override;
663 void enableSpeculativeTilingIfNeeded();
664 void speculativeTilingEnableTimerFired();
666 void updateEmbeddedObjectsTimerFired();
667 bool updateEmbeddedObjects();
668 void updateEmbeddedObject(RenderEmbeddedObject&);
669 void scrollToAnchor();
670 void scrollPositionChanged(const ScrollPosition& oldPosition, const ScrollPosition& newPosition);
671 void scrollableAreaSetChanged();
672 void sendScrollEvent();
674 bool hasCustomScrollbars() const;
676 void updateScrollCorner() override;
678 FrameView* parentFrameView() const;
680 void startLayoutAtMainFrameViewIfNeeded(bool allowSubtree);
681 bool frameFlatteningEnabled() const;
682 bool isFrameFlatteningValidForThisFrame() const;
684 bool qualifiesAsVisuallyNonEmpty() const;
685 bool isViewForDocumentInFrame() const;
687 AXObjectCache* axObjectCache() const;
688 void notifyWidgetsInAllFrames(WidgetNotification);
689 void removeFromAXObjectCache();
690 void notifyWidgets(WidgetNotification);
692 void convertSubtreeLayoutToFullLayout();
694 RenderElement* viewportRenderer() const;
696 HashSet<Widget*> m_widgetsInRenderTree;
698 static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
701 LayoutSize m_margins;
703 std::unique_ptr<ListHashSet<RenderEmbeddedObject*>> m_embeddedObjectsToUpdate;
704 const Ref<Frame> m_frame;
706 std::unique_ptr<HashSet<const RenderElement*>> m_slowRepaintObjects;
708 bool m_needsFullRepaint;
710 bool m_canHaveScrollbars;
711 bool m_cannotBlitToWindow;
713 bool m_contentIsOpaque;
716 bool m_delayedLayout;
717 RenderElement* m_layoutRoot { nullptr };
719 LayoutPhase m_layoutPhase;
720 bool m_layoutSchedulingEnabled;
721 bool m_inSynchronousPostLayout;
723 unsigned m_nestedLayoutCount;
724 Timer m_postLayoutTasksTimer;
725 Timer m_updateEmbeddedObjectsTimer;
726 bool m_firstLayoutCallbackPending;
729 bool m_isTransparent;
730 Color m_baseBackgroundColor;
731 IntSize m_lastViewportSize;
732 float m_lastZoomFactor;
735 String m_mediaTypeWhenNotPrinting;
737 bool m_overflowStatusDirty;
738 bool m_horizontalOverflow;
739 bool m_verticalOverflow;
740 enum class ViewportRendererType { None, Document, Body };
741 ViewportRendererType m_viewportRendererType { ViewportRendererType::None };
743 Pagination m_pagination;
745 bool m_wasScrolledByUser;
746 bool m_inProgrammaticScroll;
747 bool m_safeToPropagateScrollToParent;
748 Timer m_delayedScrollEventTimer;
750 double m_lastPaintTime;
752 bool m_isTrackingRepaints; // Used for testing.
753 Vector<FloatRect> m_trackedRepaintRects;
755 bool m_shouldUpdateWhileOffscreen;
757 FloatRect m_exposedRect;
759 unsigned m_deferSetNeedsLayoutCount;
760 bool m_setNeedsLayoutWasDeferred;
761 int m_layoutDisallowed { 0 };
763 RefPtr<Node> m_nodeToDraw;
764 PaintBehavior m_paintBehavior;
767 unsigned m_visuallyNonEmptyCharacterCount;
768 unsigned m_visuallyNonEmptyPixelCount;
769 bool m_isVisuallyNonEmpty;
770 bool m_firstVisuallyNonEmptyLayoutCallbackPending;
772 bool m_viewportIsStable { true };
774 RefPtr<ContainerNode> m_maintainScrollPositionAnchor;
776 // Renderer to hold our custom scroll corner.
777 RenderPtr<RenderScrollbarPart> m_scrollCorner;
779 bool m_speculativeTilingEnabled;
780 Timer m_speculativeTilingEnableTimer;
783 bool m_useCustomFixedPositionLayoutRect;
784 IntRect m_customFixedPositionLayoutRect;
786 bool m_useCustomSizeForResizeEvent;
787 IntSize m_customSizeForResizeEvent;
790 IntSize m_overrideViewportSize;
791 bool m_hasOverrideViewportSize;
793 // If true, automatically resize the frame view around its content.
794 bool m_shouldAutoSize;
796 // True if autosize has been run since m_shouldAutoSize was set.
797 bool m_didRunAutosize;
798 // The lower bound on the size when autosizing.
799 IntSize m_minAutoSize;
800 // The upper bound on the size when autosizing.
801 IntSize m_maxAutoSize;
802 // The fixed height to resize the view to after autosizing is complete.
803 int m_autoSizeFixedMinimumHeight;
804 // The intrinsic content size decided by autosizing.
805 IntSize m_autoSizeContentSize;
807 std::unique_ptr<ScrollableAreaSet> m_scrollableAreas;
808 std::unique_ptr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
813 LayoutMilestones m_milestonesPendingPaint;
815 static const unsigned visualCharacterThreshold = 200;
816 static const unsigned visualPixelThreshold = 32 * 32;
818 #if ENABLE(CSS_DEVICE_ADAPTATION)
819 // Size of viewport before any UA or author styles have overridden
820 // the viewport given by the window or viewing area of the UA.
821 IntSize m_initialViewportSize;
824 bool m_visualUpdatesAllowedByClient;
825 bool m_hasFlippedBlockRenderers;
827 ScrollPinningBehavior m_scrollPinningBehavior;
829 IntRect* m_cachedWindowClipRect { nullptr };
830 Vector<std::function<void()>> m_postLayoutCallbackQueue;
833 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
835 if (m_isVisuallyNonEmpty)
837 m_visuallyNonEmptyCharacterCount += count;
838 if (m_visuallyNonEmptyCharacterCount <= visualCharacterThreshold)
840 updateIsVisuallyNonEmpty();
843 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
845 if (m_isVisuallyNonEmpty)
847 m_visuallyNonEmptyPixelCount += size.width() * size.height();
848 if (m_visuallyNonEmptyPixelCount <= visualPixelThreshold)
850 updateIsVisuallyNonEmpty();
853 } // namespace WebCore
855 SPECIALIZE_TYPE_TRAITS_WIDGET(FrameView, isFrameView())
857 #endif // FrameView_h