| 1 | /* |
| 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-2017 Apple Inc. All rights reserved. |
| 8 | |
| 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. |
| 13 | |
| 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. |
| 18 | |
| 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. |
| 23 | */ |
| 24 | |
| 25 | #pragma once |
| 26 | |
| 27 | #include "AdjustViewSizeOrNot.h" |
| 28 | #include "Color.h" |
| 29 | #include "ContainerNode.h" |
| 30 | #include "FrameViewLayoutContext.h" |
| 31 | #include "GraphicsContext.h" |
| 32 | #include "LayoutMilestone.h" |
| 33 | #include "LayoutRect.h" |
| 34 | #include "Pagination.h" |
| 35 | #include "PaintPhase.h" |
| 36 | #include "RenderPtr.h" |
| 37 | #include "ScrollView.h" |
| 38 | #include "StyleColor.h" |
| 39 | #include "TiledBacking.h" |
| 40 | #include <memory> |
| 41 | #include <wtf/Forward.h> |
| 42 | #include <wtf/Function.h> |
| 43 | #include <wtf/HashSet.h> |
| 44 | #include <wtf/IsoMalloc.h> |
| 45 | #include <wtf/ListHashSet.h> |
| 46 | #include <wtf/OptionSet.h> |
| 47 | #include <wtf/text/WTFString.h> |
| 48 | |
| 49 | namespace WebCore { |
| 50 | |
| 51 | class AXObjectCache; |
| 52 | class Element; |
| 53 | class FloatSize; |
| 54 | class Frame; |
| 55 | class HTMLFrameOwnerElement; |
| 56 | class Page; |
| 57 | class RenderBox; |
| 58 | class RenderElement; |
| 59 | class RenderEmbeddedObject; |
| 60 | class RenderLayer; |
| 61 | class RenderLayerModelObject; |
| 62 | class RenderObject; |
| 63 | class RenderScrollbarPart; |
| 64 | class RenderStyle; |
| 65 | class RenderView; |
| 66 | class RenderWidget; |
| 67 | |
| 68 | enum class FrameFlattening; |
| 69 | |
| 70 | Pagination::Mode (const RenderStyle&); |
| 71 | |
| 72 | class FrameView final : public ScrollView { |
| 73 | WTF_MAKE_ISO_ALLOCATED(FrameView); |
| 74 | public: |
| 75 | friend class RenderView; |
| 76 | friend class Internals; |
| 77 | friend class FrameViewLayoutContext; |
| 78 | |
| 79 | WEBCORE_EXPORT static Ref<FrameView> create(Frame&); |
| 80 | static Ref<FrameView> create(Frame&, const IntSize& initialSize); |
| 81 | |
| 82 | virtual ~FrameView(); |
| 83 | |
| 84 | HostWindow* hostWindow() const final; |
| 85 | |
| 86 | WEBCORE_EXPORT void invalidateRect(const IntRect&) final; |
| 87 | void setFrameRect(const IntRect&) final; |
| 88 | |
| 89 | bool scheduleAnimation() final; |
| 90 | |
| 91 | Frame& frame() const { return m_frame; } |
| 92 | |
| 93 | WEBCORE_EXPORT RenderView* renderView() const; |
| 94 | |
| 95 | int mapFromLayoutToCSSUnits(LayoutUnit) const; |
| 96 | LayoutUnit mapFromCSSToLayoutUnits(int) const; |
| 97 | |
| 98 | LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default |
| 99 | LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default |
| 100 | void setMarginWidth(LayoutUnit); |
| 101 | void setMarginHeight(LayoutUnit); |
| 102 | |
| 103 | WEBCORE_EXPORT void setCanHaveScrollbars(bool) final; |
| 104 | WEBCORE_EXPORT void updateCanHaveScrollbars(); |
| 105 | |
| 106 | Ref<Scrollbar> createScrollbar(ScrollbarOrientation) final; |
| 107 | |
| 108 | bool avoidScrollbarCreation() const final; |
| 109 | |
| 110 | void setContentsSize(const IntSize&) final; |
| 111 | void updateContentsSize() final; |
| 112 | |
| 113 | const FrameViewLayoutContext& layoutContext() const { return m_layoutContext; } |
| 114 | FrameViewLayoutContext& layoutContext() { return m_layoutContext; } |
| 115 | |
| 116 | WEBCORE_EXPORT bool didFirstLayout() const; |
| 117 | void queuePostLayoutCallback(WTF::Function<void ()>&&); |
| 118 | |
| 119 | WEBCORE_EXPORT bool needsLayout() const; |
| 120 | WEBCORE_EXPORT void setNeedsLayoutAfterViewConfigurationChange(); |
| 121 | |
| 122 | void setNeedsCompositingConfigurationUpdate(); |
| 123 | void setNeedsCompositingGeometryUpdate(); |
| 124 | |
| 125 | void setViewportConstrainedObjectsNeedLayout(); |
| 126 | |
| 127 | WEBCORE_EXPORT bool renderedCharactersExceed(unsigned threshold); |
| 128 | |
| 129 | void scheduleSelectionUpdate(); |
| 130 | |
| 131 | #if PLATFORM(IOS_FAMILY) |
| 132 | bool useCustomFixedPositionLayoutRect() const; |
| 133 | IntRect customFixedPositionLayoutRect() const { return m_customFixedPositionLayoutRect; } |
| 134 | WEBCORE_EXPORT void setCustomFixedPositionLayoutRect(const IntRect&); |
| 135 | bool updateFixedPositionLayoutRect(); |
| 136 | |
| 137 | IntSize customSizeForResizeEvent() const { return m_customSizeForResizeEvent; } |
| 138 | WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize); |
| 139 | |
| 140 | WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, MonotonicTime timestamp); |
| 141 | #else |
| 142 | bool useCustomFixedPositionLayoutRect() const { return false; } |
| 143 | #endif |
| 144 | |
| 145 | void willRecalcStyle(); |
| 146 | bool updateCompositingLayersAfterStyleChange(); |
| 147 | void updateCompositingLayersAfterLayout(); |
| 148 | |
| 149 | // Called when changes to the GraphicsLayer hierarchy have to be synchronized with |
| 150 | // content rendered via the normal painting path. |
| 151 | void setNeedsOneShotDrawingSynchronization(); |
| 152 | |
| 153 | WEBCORE_EXPORT GraphicsLayer* graphicsLayerForPlatformWidget(PlatformWidget); |
| 154 | WEBCORE_EXPORT void scheduleLayerFlushAllowingThrottling(); |
| 155 | |
| 156 | WEBCORE_EXPORT TiledBacking* tiledBacking() const final; |
| 157 | |
| 158 | ScrollingNodeID scrollingNodeID() const override; |
| 159 | ScrollableArea* scrollableAreaForScrollLayerID(uint64_t) const; |
| 160 | bool usesAsyncScrolling() const final; |
| 161 | |
| 162 | WEBCORE_EXPORT void enterCompositingMode(); |
| 163 | WEBCORE_EXPORT bool isEnclosedInCompositingLayer() const; |
| 164 | |
| 165 | // Only used with accelerated compositing, but outside the #ifdef to make linkage easier. |
| 166 | // Returns true if the flush was completed. |
| 167 | WEBCORE_EXPORT bool flushCompositingStateIncludingSubframes(); |
| 168 | |
| 169 | // Returns true when a paint with the PaintBehavior::FlattenCompositingLayers flag set gives |
| 170 | // a faithful representation of the content. |
| 171 | WEBCORE_EXPORT bool isSoftwareRenderable() const; |
| 172 | |
| 173 | void setIsInWindow(bool); |
| 174 | |
| 175 | void resetScrollbars(); |
| 176 | void resetScrollbarsAndClearContentsSize(); |
| 177 | void prepareForDetach(); |
| 178 | void detachCustomScrollbars(); |
| 179 | WEBCORE_EXPORT void recalculateScrollbarOverlayStyle(); |
| 180 | #if ENABLE(DARK_MODE_CSS) |
| 181 | void recalculateBaseBackgroundColor(); |
| 182 | #endif |
| 183 | |
| 184 | void clear(); |
| 185 | void resetLayoutMilestones(); |
| 186 | |
| 187 | WEBCORE_EXPORT bool isTransparent() const; |
| 188 | WEBCORE_EXPORT void setTransparent(bool isTransparent); |
| 189 | |
| 190 | // True if the FrameView is not transparent, and the base background color is opaque. |
| 191 | bool hasOpaqueBackground() const; |
| 192 | |
| 193 | WEBCORE_EXPORT Color baseBackgroundColor() const; |
| 194 | WEBCORE_EXPORT void setBaseBackgroundColor(const Color&); |
| 195 | WEBCORE_EXPORT void updateBackgroundRecursively(const Optional<Color>& backgroundColor); |
| 196 | |
| 197 | enum ExtendedBackgroundModeFlags { |
| 198 | ExtendedBackgroundModeNone = 0, |
| 199 | ExtendedBackgroundModeVertical = 1 << 0, |
| 200 | ExtendedBackgroundModeHorizontal = 1 << 1, |
| 201 | ExtendedBackgroundModeAll = ExtendedBackgroundModeVertical | ExtendedBackgroundModeHorizontal, |
| 202 | }; |
| 203 | typedef unsigned ExtendedBackgroundMode; |
| 204 | |
| 205 | void updateExtendBackgroundIfNecessary(); |
| 206 | void updateTilesForExtendedBackgroundMode(ExtendedBackgroundMode); |
| 207 | ExtendedBackgroundMode calculateExtendedBackgroundMode() const; |
| 208 | |
| 209 | bool hasExtendedBackgroundRectForPainting() const; |
| 210 | IntRect extendedBackgroundRectForPainting() const; |
| 211 | |
| 212 | bool shouldUpdateWhileOffscreen() const; |
| 213 | WEBCORE_EXPORT void setShouldUpdateWhileOffscreen(bool); |
| 214 | bool shouldUpdate() const; |
| 215 | |
| 216 | WEBCORE_EXPORT void adjustViewSize(); |
| 217 | |
| 218 | WEBCORE_EXPORT void setViewportSizeForCSSViewportUnits(IntSize); |
| 219 | void clearViewportSizeOverrideForCSSViewportUnits(); |
| 220 | IntSize viewportSizeForCSSViewportUnits() const; |
| 221 | |
| 222 | IntRect windowClipRect() const final; |
| 223 | WEBCORE_EXPORT IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const; |
| 224 | |
| 225 | float visibleContentScaleFactor() const final; |
| 226 | |
| 227 | #if USE(COORDINATED_GRAPHICS) |
| 228 | WEBCORE_EXPORT void setFixedVisibleContentRect(const IntRect&) final; |
| 229 | #endif |
| 230 | WEBCORE_EXPORT void setScrollPosition(const ScrollPosition&) final; |
| 231 | void restoreScrollbar(); |
| 232 | void scheduleScrollToFocusedElement(SelectionRevealMode); |
| 233 | void scrollToFocusedElementImmediatelyIfNeeded(); |
| 234 | void updateLayerPositionsAfterScrolling() final; |
| 235 | void updateCompositingLayersAfterScrolling() final; |
| 236 | bool requestScrollPositionUpdate(const ScrollPosition&) final; |
| 237 | bool isRubberBandInProgress() const final; |
| 238 | WEBCORE_EXPORT ScrollPosition minimumScrollPosition() const final; |
| 239 | WEBCORE_EXPORT ScrollPosition maximumScrollPosition() const final; |
| 240 | |
| 241 | // The scrollOrigin, scrollPosition, minimumScrollPosition and maximumScrollPosition are all affected by frame scale, |
| 242 | // but layoutViewport computations require unscaled scroll positions. |
| 243 | ScrollPosition unscaledMinimumScrollPosition() const; |
| 244 | ScrollPosition unscaledMaximumScrollPosition() const; |
| 245 | |
| 246 | IntPoint unscaledScrollOrigin() const; |
| 247 | |
| 248 | WEBCORE_EXPORT LayoutPoint minStableLayoutViewportOrigin() const; |
| 249 | WEBCORE_EXPORT LayoutPoint maxStableLayoutViewportOrigin() const; |
| 250 | |
| 251 | enum class TriggerLayoutOrNot { |
| 252 | No, |
| 253 | Yes |
| 254 | }; |
| 255 | // This origin can be overridden by setLayoutViewportOverrideRect. |
| 256 | void setBaseLayoutViewportOrigin(LayoutPoint, TriggerLayoutOrNot = TriggerLayoutOrNot::Yes); |
| 257 | // This size can be overridden by setLayoutViewportOverrideRect. |
| 258 | WEBCORE_EXPORT LayoutSize baseLayoutViewportSize() const; |
| 259 | |
| 260 | // If set, overrides the default "m_layoutViewportOrigin, size of initial containing block" rect. |
| 261 | // Used with delegated scrolling (i.e. iOS). |
| 262 | WEBCORE_EXPORT void setLayoutViewportOverrideRect(Optional<LayoutRect>, TriggerLayoutOrNot = TriggerLayoutOrNot::Yes); |
| 263 | |
| 264 | WEBCORE_EXPORT void setVisualViewportOverrideRect(Optional<LayoutRect>); |
| 265 | |
| 266 | // These are in document coordinates, unaffected by page scale (but affected by zooming). |
| 267 | WEBCORE_EXPORT LayoutRect layoutViewportRect() const; |
| 268 | WEBCORE_EXPORT LayoutRect visualViewportRect() const; |
| 269 | |
| 270 | static LayoutRect visibleDocumentRect(const FloatRect& visibleContentRect, float , float , const FloatSize& totalContentsSize, float pageScaleFactor); |
| 271 | |
| 272 | // This is different than visibleContentRect() in that it ignores negative (or overly positive) |
| 273 | // offsets from rubber-banding, and it takes zooming into account. |
| 274 | LayoutRect viewportConstrainedVisibleContentRect() const; |
| 275 | |
| 276 | LayoutRect rectForFixedPositionLayout() const; |
| 277 | |
| 278 | void viewportContentsChanged(); |
| 279 | WEBCORE_EXPORT void resumeVisibleImageAnimationsIncludingSubframes(); |
| 280 | |
| 281 | String mediaType() const; |
| 282 | WEBCORE_EXPORT void setMediaType(const String&); |
| 283 | void adjustMediaTypeForPrinting(bool printing); |
| 284 | |
| 285 | void setCannotBlitToWindow(); |
| 286 | void setIsOverlapped(bool); |
| 287 | void setContentIsOpaque(bool); |
| 288 | |
| 289 | void addSlowRepaintObject(RenderElement&); |
| 290 | void removeSlowRepaintObject(RenderElement&); |
| 291 | bool hasSlowRepaintObject(const RenderElement& renderer) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(&renderer); } |
| 292 | bool hasSlowRepaintObjects() const { return m_slowRepaintObjects && m_slowRepaintObjects->size(); } |
| 293 | |
| 294 | // Includes fixed- and sticky-position objects. |
| 295 | typedef HashSet<RenderLayerModelObject*> ViewportConstrainedObjectSet; |
| 296 | void addViewportConstrainedObject(RenderLayerModelObject*); |
| 297 | void removeViewportConstrainedObject(RenderLayerModelObject*); |
| 298 | const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); } |
| 299 | bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; } |
| 300 | |
| 301 | float frameScaleFactor() const; |
| 302 | |
| 303 | // Functions for querying the current scrolled position, negating the effects of overhang |
| 304 | // and adjusting for page scale. |
| 305 | LayoutPoint scrollPositionForFixedPosition() const; |
| 306 | |
| 307 | // Static function can be called from another thread. |
| 308 | WEBCORE_EXPORT static LayoutPoint scrollPositionForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int , int ); |
| 309 | |
| 310 | WEBCORE_EXPORT static LayoutSize expandedLayoutViewportSize(const LayoutSize& baseLayoutViewportSize, const LayoutSize& documentSize, double heightExpansionFactor); |
| 311 | |
| 312 | enum class LayoutViewportConstraint { ConstrainedToDocumentRect, Unconstrained }; |
| 313 | WEBCORE_EXPORT static LayoutRect computeUpdatedLayoutViewportRect(const LayoutRect& layoutViewport, const LayoutRect& documentRect, const LayoutSize& unobscuredContentSize, const LayoutRect& unobscuredContentRect, const LayoutSize& baseLayoutViewportSize, const LayoutPoint& stableLayoutViewportOriginMin, const LayoutPoint& stableLayoutViewportOriginMax, LayoutViewportConstraint); |
| 314 | |
| 315 | WEBCORE_EXPORT static LayoutPoint computeLayoutViewportOrigin(const LayoutRect& visualViewport, const LayoutPoint& stableLayoutViewportOriginMin, const LayoutPoint& stableLayoutViewportOriginMax, const LayoutRect& layoutViewport, ScrollBehaviorForFixedElements); |
| 316 | |
| 317 | // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed |
| 318 | // on both the main thread and the scrolling thread. |
| 319 | static float yPositionForInsetClipLayer(const FloatPoint& scrollPosition, float topContentInset); |
| 320 | WEBCORE_EXPORT static FloatPoint positionForRootContentLayer(const FloatPoint& scrollPosition, const FloatPoint& scrollOrigin, float topContentInset, float ); |
| 321 | WEBCORE_EXPORT FloatPoint positionForRootContentLayer() const; |
| 322 | |
| 323 | static float (const FloatPoint& scrollPosition, float topContentInset); |
| 324 | static float (const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float ); |
| 325 | |
| 326 | #if PLATFORM(IOS_FAMILY) |
| 327 | WEBCORE_EXPORT LayoutRect viewportConstrainedObjectsRect() const; |
| 328 | // Static function can be called from another thread. |
| 329 | WEBCORE_EXPORT static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements); |
| 330 | #endif |
| 331 | |
| 332 | IntRect visualViewportRectExpandedByContentInsets() const; |
| 333 | |
| 334 | bool fixedElementsLayoutRelativeToFrame() const; |
| 335 | |
| 336 | WEBCORE_EXPORT void disableLayerFlushThrottlingTemporarilyForInteraction(); |
| 337 | bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; } |
| 338 | void loadProgressingStatusChanged(); |
| 339 | |
| 340 | WEBCORE_EXPORT void updateControlTints(); |
| 341 | |
| 342 | WEBCORE_EXPORT bool wasScrolledByUser() const; |
| 343 | WEBCORE_EXPORT void setWasScrolledByUser(bool); |
| 344 | |
| 345 | bool safeToPropagateScrollToParent() const; |
| 346 | |
| 347 | void addEmbeddedObjectToUpdate(RenderEmbeddedObject&); |
| 348 | void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&); |
| 349 | |
| 350 | WEBCORE_EXPORT void paintContents(GraphicsContext&, const IntRect& dirtyRect, SecurityOriginPaintPolicy = SecurityOriginPaintPolicy::AnyOrigin) final; |
| 351 | |
| 352 | struct PaintingState { |
| 353 | OptionSet<PaintBehavior> paintBehavior; |
| 354 | bool isTopLevelPainter; |
| 355 | bool isFlatteningPaintOfRootFrame; |
| 356 | PaintingState() |
| 357 | : paintBehavior() |
| 358 | , isTopLevelPainter(false) |
| 359 | , isFlatteningPaintOfRootFrame(false) |
| 360 | { |
| 361 | } |
| 362 | }; |
| 363 | |
| 364 | void willPaintContents(GraphicsContext&, const IntRect& dirtyRect, PaintingState&); |
| 365 | void didPaintContents(GraphicsContext&, const IntRect& dirtyRect, PaintingState&); |
| 366 | |
| 367 | #if PLATFORM(IOS_FAMILY) |
| 368 | WEBCORE_EXPORT void didReplaceMultipartContent(); |
| 369 | #endif |
| 370 | |
| 371 | WEBCORE_EXPORT void setPaintBehavior(OptionSet<PaintBehavior>); |
| 372 | WEBCORE_EXPORT OptionSet<PaintBehavior> paintBehavior() const; |
| 373 | bool isPainting() const; |
| 374 | bool hasEverPainted() const { return !!m_lastPaintTime; } |
| 375 | void setLastPaintTime(MonotonicTime lastPaintTime) { m_lastPaintTime = lastPaintTime; } |
| 376 | WEBCORE_EXPORT void setNodeToDraw(Node*); |
| 377 | |
| 378 | enum SelectionInSnapshot { IncludeSelection, ExcludeSelection }; |
| 379 | enum CoordinateSpaceForSnapshot { DocumentCoordinates, ViewCoordinates }; |
| 380 | WEBCORE_EXPORT void paintContentsForSnapshot(GraphicsContext&, const IntRect& imageRect, SelectionInSnapshot shouldPaintSelection, CoordinateSpaceForSnapshot); |
| 381 | |
| 382 | void paintOverhangAreas(GraphicsContext&, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) final; |
| 383 | void paintScrollCorner(GraphicsContext&, const IntRect& cornerRect) final; |
| 384 | void paintScrollbar(GraphicsContext&, Scrollbar&, const IntRect&) final; |
| 385 | |
| 386 | WEBCORE_EXPORT Color documentBackgroundColor() const; |
| 387 | |
| 388 | bool isInChildFrameWithFrameFlattening() const; |
| 389 | |
| 390 | void startDisallowingLayout() { layoutContext().startDisallowingLayout(); } |
| 391 | void endDisallowingLayout() { layoutContext().endDisallowingLayout(); } |
| 392 | |
| 393 | static MonotonicTime currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting |
| 394 | |
| 395 | WEBCORE_EXPORT void updateLayoutAndStyleIfNeededRecursive(); |
| 396 | |
| 397 | void incrementVisuallyNonEmptyCharacterCount(const String&); |
| 398 | void incrementVisuallyNonEmptyPixelCount(const IntSize&); |
| 399 | void updateIsVisuallyNonEmpty(); |
| 400 | void updateSignificantRenderedTextMilestoneIfNeeded(); |
| 401 | bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; } |
| 402 | WEBCORE_EXPORT void enableAutoSizeMode(bool enable, const IntSize& minSize); |
| 403 | WEBCORE_EXPORT void setAutoSizeFixedMinimumHeight(int); |
| 404 | bool isAutoSizeEnabled() const { return m_shouldAutoSize; } |
| 405 | IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; } |
| 406 | |
| 407 | WEBCORE_EXPORT void forceLayout(bool allowSubtreeLayout = false); |
| 408 | WEBCORE_EXPORT void (const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot); |
| 409 | |
| 410 | // FIXME: This method is retained because of embedded WebViews in AppKit. When a WebView is embedded inside |
| 411 | // some enclosing view with auto-pagination, no call happens to resize the view. The new pagination model |
| 412 | // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially |
| 413 | // resize around that view. Auto-pagination uses the bounds of the actual view that's being printed to determine |
| 414 | // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the |
| 415 | // web document's bounds. |
| 416 | // |
| 417 | // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets. |
| 418 | // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI |
| 419 | // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or |
| 420 | // page size, it can't actually paginate correctly during _layoutForPrinting. |
| 421 | // |
| 422 | // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model, |
| 423 | // but that doesn't solve the general problem of how other AppKit views could opt in to the better model. |
| 424 | // |
| 425 | // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD. |
| 426 | WEBCORE_EXPORT void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit); |
| 427 | |
| 428 | bool scrollToFragment(const URL&); |
| 429 | bool scrollToAnchor(const String&); |
| 430 | void maintainScrollPositionAtAnchor(ContainerNode*); |
| 431 | WEBCORE_EXPORT void scrollElementToRect(const Element&, const IntRect&); |
| 432 | |
| 433 | // Coordinate systems: |
| 434 | // |
| 435 | // "View" |
| 436 | // Top left is top left of the FrameView/ScrollView/Widget. Size is Widget::boundsRect().size(). |
| 437 | // |
| 438 | // "TotalContents" |
| 439 | // Relative to ScrollView's scrolled contents, including headers and footers. Size is totalContentsSize(). |
| 440 | // |
| 441 | // "Contents" |
| 442 | // Relative to ScrollView's scrolled contents, excluding headers and footers, so top left is top left of the scroll view's |
| 443 | // document, and size is contentsSize(). |
| 444 | // |
| 445 | // "Absolute" |
| 446 | // Relative to the document's scroll origin (non-zero for RTL documents), but affected by page zoom and page scale. Mostly used |
| 447 | // in rendering code. |
| 448 | // |
| 449 | // "Document" |
| 450 | // Relative to the document's scroll origin, but not affected by page zoom or page scale. Size is equivalent to CSS pixel dimensions. |
| 451 | // FIXME: some uses are affected by page zoom (e.g. layout and visual viewports). |
| 452 | // |
| 453 | // "Client" |
| 454 | // Relative to the visible part of the document (or, more strictly, the layout viewport rect), and with the same scaling |
| 455 | // as Document coordinates, i.e. matching CSS pixels. Affected by scroll origin. |
| 456 | // |
| 457 | // "LayoutViewport" |
| 458 | // Similar to client coordinates, but affected by page zoom (but not page scale). |
| 459 | // |
| 460 | |
| 461 | // Methods to convert points and rects between the coordinate space of the renderer, and this view. |
| 462 | WEBCORE_EXPORT IntRect convertFromRendererToContainingView(const RenderElement*, const IntRect&) const; |
| 463 | WEBCORE_EXPORT IntRect convertFromContainingViewToRenderer(const RenderElement*, const IntRect&) const; |
| 464 | WEBCORE_EXPORT FloatRect convertFromContainingViewToRenderer(const RenderElement*, const FloatRect&) const; |
| 465 | WEBCORE_EXPORT IntPoint convertFromRendererToContainingView(const RenderElement*, const IntPoint&) const; |
| 466 | WEBCORE_EXPORT IntPoint convertFromContainingViewToRenderer(const RenderElement*, const IntPoint&) const; |
| 467 | |
| 468 | // Override ScrollView methods to do point conversion via renderers, in order to take transforms into account. |
| 469 | IntRect convertToContainingView(const IntRect&) const final; |
| 470 | IntRect convertFromContainingView(const IntRect&) const final; |
| 471 | FloatRect convertFromContainingView(const FloatRect&) const final; |
| 472 | IntPoint convertToContainingView(const IntPoint&) const final; |
| 473 | IntPoint convertFromContainingView(const IntPoint&) const final; |
| 474 | |
| 475 | float documentToAbsoluteScaleFactor(Optional<float> effectiveZoom = WTF::nullopt) const; |
| 476 | float absoluteToDocumentScaleFactor(Optional<float> effectiveZoom = WTF::nullopt) const; |
| 477 | |
| 478 | WEBCORE_EXPORT FloatRect absoluteToDocumentRect(FloatRect, Optional<float> effectiveZoom = WTF::nullopt) const; |
| 479 | WEBCORE_EXPORT FloatPoint absoluteToDocumentPoint(FloatPoint, Optional<float> effectiveZoom = WTF::nullopt) const; |
| 480 | |
| 481 | FloatRect absoluteToClientRect(FloatRect, Optional<float> effectiveZoom = WTF::nullopt) const; |
| 482 | |
| 483 | FloatSize documentToClientOffset() const; |
| 484 | WEBCORE_EXPORT FloatRect documentToClientRect(FloatRect) const; |
| 485 | FloatPoint documentToClientPoint(FloatPoint) const; |
| 486 | WEBCORE_EXPORT FloatRect clientToDocumentRect(FloatRect) const; |
| 487 | WEBCORE_EXPORT FloatPoint clientToDocumentPoint(FloatPoint) const; |
| 488 | |
| 489 | WEBCORE_EXPORT FloatPoint absoluteToLayoutViewportPoint(FloatPoint) const; |
| 490 | FloatPoint layoutViewportToAbsolutePoint(FloatPoint) const; |
| 491 | |
| 492 | WEBCORE_EXPORT FloatRect absoluteToLayoutViewportRect(FloatRect) const; |
| 493 | FloatRect layoutViewportToAbsoluteRect(FloatRect) const; |
| 494 | |
| 495 | // Unlike client coordinates, layout viewport coordinates are affected by page zoom. |
| 496 | WEBCORE_EXPORT FloatRect clientToLayoutViewportRect(FloatRect) const; |
| 497 | WEBCORE_EXPORT FloatPoint clientToLayoutViewportPoint(FloatPoint) const; |
| 498 | |
| 499 | bool isFrameViewScrollCorner(const RenderScrollbarPart& scrollCorner) const { return m_scrollCorner.get() == &scrollCorner; } |
| 500 | |
| 501 | // isScrollable() takes an optional Scrollability parameter that allows the caller to define what they mean by 'scrollable.' |
| 502 | // Most callers are interested in the default value, Scrollability::Scrollable, which means that there is actually content |
| 503 | // 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 |
| 504 | // to rubber-band, which the main frame might be allowed to do even if there is no content to scroll to. In that case, |
| 505 | // callers use Scrollability::ScrollableOrRubberbandable. |
| 506 | enum class Scrollability { Scrollable, ScrollableOrRubberbandable }; |
| 507 | WEBCORE_EXPORT bool isScrollable(Scrollability definitionOfScrollable = Scrollability::Scrollable); |
| 508 | |
| 509 | bool isScrollableOrRubberbandable() final; |
| 510 | bool hasScrollableOrRubberbandableAncestor() final; |
| 511 | |
| 512 | enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule }; |
| 513 | void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule); |
| 514 | |
| 515 | IntPoint lastKnownMousePosition() const final; |
| 516 | bool isHandlingWheelEvent() const final; |
| 517 | bool shouldSetCursor() const; |
| 518 | |
| 519 | WEBCORE_EXPORT bool useDarkAppearance() const final; |
| 520 | OptionSet<StyleColor::Options> styleColorOptions() const; |
| 521 | |
| 522 | // FIXME: Remove this method once plugin loading is decoupled from layout. |
| 523 | void flushAnyPendingPostLayoutTasks(); |
| 524 | |
| 525 | bool shouldSuspendScrollAnimations() const final; |
| 526 | void scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate) override; |
| 527 | |
| 528 | RenderBox* embeddedContentBox() const; |
| 529 | |
| 530 | WEBCORE_EXPORT void setTracksRepaints(bool); |
| 531 | bool isTrackingRepaints() const { return m_isTrackingRepaints; } |
| 532 | WEBCORE_EXPORT void resetTrackedRepaints(); |
| 533 | const Vector<FloatRect>& trackedRepaintRects() const { return m_trackedRepaintRects; } |
| 534 | String trackedRepaintRectsAsText() const; |
| 535 | |
| 536 | typedef HashSet<ScrollableArea*> ScrollableAreaSet; |
| 537 | // Returns whether the scrollable area has just been newly added. |
| 538 | WEBCORE_EXPORT bool addScrollableArea(ScrollableArea*); |
| 539 | // Returns whether the scrollable area has just been removed. |
| 540 | WEBCORE_EXPORT bool removeScrollableArea(ScrollableArea*); |
| 541 | bool containsScrollableArea(ScrollableArea*) const; |
| 542 | const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); } |
| 543 | |
| 544 | WEBCORE_EXPORT void addChild(Widget&) final; |
| 545 | WEBCORE_EXPORT void removeChild(Widget&) final; |
| 546 | |
| 547 | // This function exists for ports that need to handle wheel events manually. |
| 548 | // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms |
| 549 | // we need this function in order to do the scroll ourselves. |
| 550 | bool wheelEvent(const PlatformWheelEvent&); |
| 551 | |
| 552 | WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool); |
| 553 | |
| 554 | // Page and FrameView both store a Pagination value. Page::pagination() is set only by API, |
| 555 | // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all |
| 556 | // FrameViews in the page cache, but FrameView::pagination() only affects the current |
| 557 | // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise, |
| 558 | // it will return Page::pagination() since currently there are no callers that need to |
| 559 | // distinguish between the two. |
| 560 | const Pagination& () const; |
| 561 | void (const Pagination&); |
| 562 | |
| 563 | #if ENABLE(CSS_DEVICE_ADAPTATION) |
| 564 | IntSize initialViewportSize() const { return m_initialViewportSize; } |
| 565 | void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; } |
| 566 | #endif |
| 567 | |
| 568 | bool isActive() const final; |
| 569 | bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const final; |
| 570 | |
| 571 | #if ENABLE(RUBBER_BANDING) |
| 572 | WEBCORE_EXPORT GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const; |
| 573 | WEBCORE_EXPORT GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const; |
| 574 | #endif |
| 575 | |
| 576 | // This function "smears" the "position:fixed" uninflatedBounds for scrolling, returning a rect that is the union of |
| 577 | // all possible locations of the given rect under page scrolling. |
| 578 | LayoutRect fixedScrollableAreaBoundsInflatedForScrolling(const LayoutRect& uninflatedBounds) const; |
| 579 | |
| 580 | LayoutPoint scrollPositionRespectingCustomFixedPosition() const; |
| 581 | |
| 582 | WEBCORE_EXPORT int () const final; |
| 583 | WEBCORE_EXPORT int () const final; |
| 584 | |
| 585 | WEBCORE_EXPORT float topContentInset(TopContentInsetType = TopContentInsetType::WebCoreContentInset) const final; |
| 586 | void topContentInsetDidChange(float newTopContentInset); |
| 587 | |
| 588 | void topContentDirectionDidChange(); |
| 589 | |
| 590 | WEBCORE_EXPORT void willStartLiveResize() final; |
| 591 | WEBCORE_EXPORT void willEndLiveResize() final; |
| 592 | |
| 593 | WEBCORE_EXPORT void availableContentSizeChanged(AvailableSizeChangeReason) final; |
| 594 | |
| 595 | void updateTiledBackingAdaptiveSizing(); |
| 596 | TiledBacking::Scrollability computeScrollability() const; |
| 597 | |
| 598 | #if PLATFORM(IOS_FAMILY) |
| 599 | WEBCORE_EXPORT void didUpdateViewportOverrideRects(); |
| 600 | #endif |
| 601 | |
| 602 | void addPaintPendingMilestones(OptionSet<LayoutMilestone>); |
| 603 | void firePaintRelatedMilestonesIfNeeded(); |
| 604 | void fireLayoutRelatedMilestonesIfNeeded(); |
| 605 | OptionSet<LayoutMilestone> milestonesPendingPaint() const { return m_milestonesPendingPaint; } |
| 606 | |
| 607 | bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; } |
| 608 | WEBCORE_EXPORT void setVisualUpdatesAllowedByClient(bool); |
| 609 | |
| 610 | WEBCORE_EXPORT void setScrollPinningBehavior(ScrollPinningBehavior); |
| 611 | |
| 612 | ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const; |
| 613 | |
| 614 | bool hasFlippedBlockRenderers() const { return m_hasFlippedBlockRenderers; } |
| 615 | void setHasFlippedBlockRenderers(bool b) { m_hasFlippedBlockRenderers = b; } |
| 616 | |
| 617 | void updateWidgetPositions(); |
| 618 | void scheduleUpdateWidgetPositions(); |
| 619 | |
| 620 | void didAddWidgetToRenderTree(Widget&); |
| 621 | void willRemoveWidgetFromRenderTree(Widget&); |
| 622 | |
| 623 | const HashSet<Widget*>& widgetsInRenderTree() const { return m_widgetsInRenderTree; } |
| 624 | |
| 625 | void addTrackedRepaintRect(const FloatRect&); |
| 626 | |
| 627 | // exposedRect represents WebKit's understanding of what part |
| 628 | // of the view is actually exposed on screen (taking into account |
| 629 | // clipping by other UI elements), whereas visibleContentRect is |
| 630 | // internal to WebCore and doesn't respect those things. |
| 631 | WEBCORE_EXPORT void setViewExposedRect(Optional<FloatRect>); |
| 632 | Optional<FloatRect> viewExposedRect() const { return m_viewExposedRect; } |
| 633 | |
| 634 | #if ENABLE(CSS_SCROLL_SNAP) |
| 635 | void updateSnapOffsets() final; |
| 636 | bool isScrollSnapInProgress() const final; |
| 637 | void updateScrollingCoordinatorScrollSnapProperties() const; |
| 638 | #endif |
| 639 | |
| 640 | float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity) final; |
| 641 | |
| 642 | void didChangeScrollOffset(); |
| 643 | |
| 644 | void show() final; |
| 645 | void hide() final; |
| 646 | |
| 647 | bool shouldPlaceBlockDirectionScrollbarOnLeft() const final; |
| 648 | |
| 649 | void didRestoreFromPageCache(); |
| 650 | |
| 651 | void willDestroyRenderTree(); |
| 652 | void didDestroyRenderTree(); |
| 653 | |
| 654 | void setSpeculativeTilingDelayDisabledForTesting(bool disabled) { m_speculativeTilingDelayDisabledForTesting = disabled; } |
| 655 | |
| 656 | WEBCORE_EXPORT FrameFlattening effectiveFrameFlattening() const; |
| 657 | |
| 658 | WEBCORE_EXPORT void traverseForPaintInvalidation(GraphicsContext::PaintInvalidationReasons); |
| 659 | void invalidateControlTints() { traverseForPaintInvalidation(GraphicsContext::PaintInvalidationReasons::InvalidatingControlTints); } |
| 660 | void invalidateImagesWithAsyncDecodes() { traverseForPaintInvalidation(GraphicsContext::PaintInvalidationReasons::InvalidatingImagesWithAsyncDecodes); } |
| 661 | |
| 662 | GraphicsLayer* layerForHorizontalScrollbar() const final; |
| 663 | GraphicsLayer* layerForVerticalScrollbar() const final; |
| 664 | |
| 665 | protected: |
| 666 | bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) final; |
| 667 | void scrollContentsSlowPath(const IntRect& updateRect) final; |
| 668 | |
| 669 | void repaintSlowRepaintObjects(); |
| 670 | |
| 671 | bool isVerticalDocument() const final; |
| 672 | bool isFlippedDocument() const final; |
| 673 | |
| 674 | private: |
| 675 | explicit FrameView(Frame&); |
| 676 | |
| 677 | void reset(); |
| 678 | void init(); |
| 679 | |
| 680 | enum LayoutPhase { |
| 681 | OutsideLayout, |
| 682 | InPreLayout, |
| 683 | InRenderTreeLayout, |
| 684 | InViewSizeAdjust, |
| 685 | InPostLayout |
| 686 | }; |
| 687 | |
| 688 | bool isFrameView() const final { return true; } |
| 689 | |
| 690 | friend class RenderWidget; |
| 691 | bool useSlowRepaints(bool considerOverlap = true) const; |
| 692 | bool useSlowRepaintsIfNotOverlapped() const; |
| 693 | void updateCanBlitOnScrollRecursively(); |
| 694 | bool shouldLayoutAfterContentsResized() const; |
| 695 | |
| 696 | bool shouldUpdateCompositingLayersAfterScrolling() const; |
| 697 | bool flushCompositingStateForThisFrame(const Frame& rootFrameForFlush); |
| 698 | |
| 699 | bool shouldDeferScrollUpdateAfterContentSizeChange() final; |
| 700 | |
| 701 | void scrollOffsetChangedViaPlatformWidgetImpl(const ScrollOffset& oldOffset, const ScrollOffset& newOffset) final; |
| 702 | |
| 703 | void applyOverflowToViewport(const RenderElement&, ScrollbarMode& hMode, ScrollbarMode& vMode); |
| 704 | void (); |
| 705 | |
| 706 | void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); |
| 707 | |
| 708 | void forceLayoutParentViewIfNeeded(); |
| 709 | void flushPostLayoutTasksQueue(); |
| 710 | void performPostLayoutTasks(); |
| 711 | void autoSizeIfEnabled(); |
| 712 | |
| 713 | void applyRecursivelyWithVisibleRect(const WTF::Function<void (FrameView& frameView, const IntRect& visibleRect)>&); |
| 714 | void resumeVisibleImageAnimations(const IntRect& visibleRect); |
| 715 | void updateScriptedAnimationsAndTimersThrottlingState(const IntRect& visibleRect); |
| 716 | |
| 717 | void updateLayerFlushThrottling(); |
| 718 | WEBCORE_EXPORT void adjustTiledBackingCoverage(); |
| 719 | |
| 720 | void repaintContentRectangle(const IntRect&) final; |
| 721 | void addedOrRemovedScrollbar() final; |
| 722 | |
| 723 | void scrollToFocusedElementTimerFired(); |
| 724 | void scrollToFocusedElementInternal(); |
| 725 | |
| 726 | void delegatesScrollingDidChange() final; |
| 727 | |
| 728 | // ScrollableArea interface |
| 729 | void invalidateScrollbarRect(Scrollbar&, const IntRect&) final; |
| 730 | void scrollTo(const ScrollPosition&) final; |
| 731 | void setVisibleScrollerThumbRect(const IntRect&) final; |
| 732 | ScrollableArea* enclosingScrollableArea() const final; |
| 733 | IntRect scrollableAreaBoundingBox(bool* = nullptr) const final; |
| 734 | bool scrollAnimatorEnabled() const final; |
| 735 | GraphicsLayer* layerForScrollCorner() const final; |
| 736 | #if ENABLE(RUBBER_BANDING) |
| 737 | GraphicsLayer* layerForOverhangAreas() const final; |
| 738 | #endif |
| 739 | void contentsResized() final; |
| 740 | |
| 741 | #if PLATFORM(IOS_FAMILY) |
| 742 | void unobscuredContentSizeChanged() final; |
| 743 | #endif |
| 744 | |
| 745 | #if ENABLE(DARK_MODE_CSS) |
| 746 | RenderObject* rendererForColorScheme() const; |
| 747 | #endif |
| 748 | |
| 749 | bool usesCompositedScrolling() const final; |
| 750 | bool usesMockScrollAnimator() const final; |
| 751 | void logMockScrollAnimatorMessage(const String&) const final; |
| 752 | |
| 753 | // Override scrollbar notifications to update the AXObject cache. |
| 754 | void didAddScrollbar(Scrollbar*, ScrollbarOrientation) final; |
| 755 | void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) final; |
| 756 | |
| 757 | IntSize sizeForResizeEvent() const; |
| 758 | void sendResizeEventIfNeeded(); |
| 759 | |
| 760 | void adjustScrollbarsForLayout(bool firstLayout); |
| 761 | |
| 762 | void handleDeferredScrollbarsUpdateAfterDirectionChange(); |
| 763 | |
| 764 | void updateScrollableAreaSet(); |
| 765 | void updateLayoutViewport(); |
| 766 | |
| 767 | void notifyPageThatContentAreaWillPaint() const final; |
| 768 | |
| 769 | void enableSpeculativeTilingIfNeeded(); |
| 770 | void speculativeTilingEnableTimerFired(); |
| 771 | |
| 772 | void updateEmbeddedObjectsTimerFired(); |
| 773 | bool updateEmbeddedObjects(); |
| 774 | void updateEmbeddedObject(RenderEmbeddedObject&); |
| 775 | |
| 776 | void updateWidgetPositionsTimerFired(); |
| 777 | |
| 778 | void scrollToAnchor(); |
| 779 | void scrollPositionChanged(const ScrollPosition& oldPosition, const ScrollPosition& newPosition); |
| 780 | void scrollableAreaSetChanged(); |
| 781 | void sendScrollEvent(); |
| 782 | void resetScrollAnchor(); |
| 783 | |
| 784 | bool hasCustomScrollbars() const; |
| 785 | |
| 786 | void updateScrollCorner() final; |
| 787 | |
| 788 | FrameView* parentFrameView() const; |
| 789 | |
| 790 | bool frameFlatteningEnabled() const; |
| 791 | bool isFrameFlatteningValidForThisFrame() const; |
| 792 | |
| 793 | void markRootOrBodyRendererDirty() const; |
| 794 | |
| 795 | bool qualifiesAsVisuallyNonEmpty() const; |
| 796 | bool qualifiesAsSignificantRenderedText() const; |
| 797 | void updateHasReachedSignificantRenderedTextThreshold(); |
| 798 | |
| 799 | bool isViewForDocumentInFrame() const; |
| 800 | |
| 801 | AXObjectCache* axObjectCache() const; |
| 802 | void notifyWidgetsInAllFrames(WidgetNotification); |
| 803 | void removeFromAXObjectCache(); |
| 804 | void notifyWidgets(WidgetNotification); |
| 805 | |
| 806 | RenderElement* viewportRenderer() const; |
| 807 | |
| 808 | void willDoLayout(WeakPtr<RenderElement> layoutRoot); |
| 809 | void didLayout(WeakPtr<RenderElement> layoutRoot); |
| 810 | |
| 811 | struct OverrideViewportSize { |
| 812 | Optional<int> width; |
| 813 | Optional<int> height; |
| 814 | |
| 815 | bool operator==(const OverrideViewportSize& rhs) const { return rhs.width == width && rhs.height == height; } |
| 816 | }; |
| 817 | void overrideViewportSizeForCSSViewportUnits(OverrideViewportSize); |
| 818 | |
| 819 | static MonotonicTime sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache |
| 820 | |
| 821 | const Ref<Frame> m_frame; |
| 822 | FrameViewLayoutContext m_layoutContext; |
| 823 | |
| 824 | HashSet<Widget*> m_widgetsInRenderTree; |
| 825 | std::unique_ptr<ListHashSet<RenderEmbeddedObject*>> m_embeddedObjectsToUpdate; |
| 826 | std::unique_ptr<HashSet<const RenderElement*>> m_slowRepaintObjects; |
| 827 | |
| 828 | RefPtr<ContainerNode> m_maintainScrollPositionAnchor; |
| 829 | RefPtr<Node> m_nodeToDraw; |
| 830 | |
| 831 | // Renderer to hold our custom scroll corner. |
| 832 | RenderPtr<RenderScrollbarPart> m_scrollCorner; |
| 833 | |
| 834 | Timer m_updateEmbeddedObjectsTimer; |
| 835 | Timer m_updateWidgetPositionsTimer; |
| 836 | Timer m_delayedScrollEventTimer; |
| 837 | Timer m_delayedScrollToFocusedElementTimer; |
| 838 | Timer m_speculativeTilingEnableTimer; |
| 839 | |
| 840 | MonotonicTime m_lastPaintTime; |
| 841 | |
| 842 | LayoutSize m_size; |
| 843 | LayoutSize m_margins; |
| 844 | |
| 845 | Color m_baseBackgroundColor { Color::white }; |
| 846 | IntSize m_lastViewportSize; |
| 847 | |
| 848 | String m_mediaType { "screen"_s }; |
| 849 | String m_mediaTypeWhenNotPrinting; |
| 850 | |
| 851 | Vector<FloatRect> m_trackedRepaintRects; |
| 852 | |
| 853 | IntRect* m_cachedWindowClipRect { nullptr }; |
| 854 | Vector<WTF::Function<void ()>> m_postLayoutCallbackQueue; |
| 855 | |
| 856 | LayoutPoint m_layoutViewportOrigin; |
| 857 | Optional<LayoutRect> m_layoutViewportOverrideRect; |
| 858 | Optional<LayoutRect> m_visualViewportOverrideRect; // Used when the iOS keyboard is showing. |
| 859 | |
| 860 | Optional<FloatRect> m_viewExposedRect; |
| 861 | |
| 862 | OptionSet<PaintBehavior> m_paintBehavior; |
| 863 | |
| 864 | float m_lastZoomFactor { 1 }; |
| 865 | unsigned m_visuallyNonEmptyCharacterCount { 0 }; |
| 866 | unsigned m_visuallyNonEmptyPixelCount { 0 }; |
| 867 | unsigned m_textRendererCountForVisuallyNonEmptyCharacters { 0 }; |
| 868 | int { 0 }; |
| 869 | int { 0 }; |
| 870 | |
| 871 | #if PLATFORM(IOS_FAMILY) |
| 872 | bool m_useCustomFixedPositionLayoutRect { false }; |
| 873 | bool m_useCustomSizeForResizeEvent { false }; |
| 874 | |
| 875 | IntRect m_customFixedPositionLayoutRect; |
| 876 | IntSize m_customSizeForResizeEvent; |
| 877 | #endif |
| 878 | |
| 879 | Optional<OverrideViewportSize> m_overrideViewportSize; |
| 880 | |
| 881 | // The view size when autosizing. |
| 882 | IntSize m_autoSizeConstraint; |
| 883 | // The fixed height to resize the view to after autosizing is complete. |
| 884 | int m_autoSizeFixedMinimumHeight { 0 }; |
| 885 | // The intrinsic content size decided by autosizing. |
| 886 | IntSize m_autoSizeContentSize; |
| 887 | |
| 888 | std::unique_ptr<ScrollableAreaSet> m_scrollableAreas; |
| 889 | std::unique_ptr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects; |
| 890 | |
| 891 | OptionSet<LayoutMilestone> m_milestonesPendingPaint; |
| 892 | |
| 893 | static const unsigned visualCharacterThreshold = 200; |
| 894 | static const unsigned visualPixelThreshold = 32 * 32; |
| 895 | |
| 896 | #if ENABLE(CSS_DEVICE_ADAPTATION) |
| 897 | // Size of viewport before any UA or author styles have overridden |
| 898 | // the viewport given by the window or viewing area of the UA. |
| 899 | IntSize m_initialViewportSize; |
| 900 | #endif |
| 901 | |
| 902 | Pagination ; |
| 903 | |
| 904 | enum class ViewportRendererType : uint8_t { None, Document, Body }; |
| 905 | ViewportRendererType m_viewportRendererType { ViewportRendererType::None }; |
| 906 | ScrollPinningBehavior m_scrollPinningBehavior { DoNotPin }; |
| 907 | SelectionRevealMode m_selectionRevealModeForFocusedElement { SelectionRevealMode::DoNotReveal }; |
| 908 | |
| 909 | bool m_shouldUpdateWhileOffscreen { true }; |
| 910 | bool m_overflowStatusDirty { true }; |
| 911 | bool m_horizontalOverflow { false }; |
| 912 | bool m_verticalOverflow { false }; |
| 913 | bool m_canHaveScrollbars { true }; |
| 914 | bool m_cannotBlitToWindow { false }; |
| 915 | bool m_isOverlapped { false }; |
| 916 | bool m_contentIsOpaque { false }; |
| 917 | bool m_firstLayoutCallbackPending { false }; |
| 918 | |
| 919 | bool m_isTransparent { false }; |
| 920 | #if ENABLE(DARK_MODE_CSS) |
| 921 | bool m_usesDarkAppearance { false }; |
| 922 | #endif |
| 923 | |
| 924 | bool m_isTrackingRepaints { false }; // Used for testing. |
| 925 | bool m_wasScrolledByUser { false }; |
| 926 | bool m_shouldScrollToFocusedElement { false }; |
| 927 | |
| 928 | bool m_isPainting { false }; |
| 929 | |
| 930 | bool m_isVisuallyNonEmpty { false }; |
| 931 | |
| 932 | bool m_renderedSignificantAmountOfText { false }; |
| 933 | bool m_hasReachedSignificantRenderedTextThreshold { false }; |
| 934 | |
| 935 | bool m_needsDeferredScrollbarsUpdate { false }; |
| 936 | bool m_speculativeTilingEnabled { false }; |
| 937 | bool m_visualUpdatesAllowedByClient { true }; |
| 938 | bool m_hasFlippedBlockRenderers { false }; |
| 939 | bool m_speculativeTilingDelayDisabledForTesting { false }; |
| 940 | |
| 941 | // If true, automatically resize the frame view around its content. |
| 942 | bool m_shouldAutoSize { false }; |
| 943 | bool m_inAutoSize { false }; |
| 944 | // True if autosize has been run since m_shouldAutoSize was set. |
| 945 | bool m_didRunAutosize { false }; |
| 946 | }; |
| 947 | |
| 948 | inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size) |
| 949 | { |
| 950 | if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) |
| 951 | return; |
| 952 | m_visuallyNonEmptyPixelCount += size.width() * size.height(); |
| 953 | } |
| 954 | |
| 955 | } // namespace WebCore |
| 956 | |
| 957 | SPECIALIZE_TYPE_TRAITS_WIDGET(FrameView, isFrameView()) |
| 958 | |