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, 2005, 2006, 2007, 2008, 2009 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 "LayoutMilestones.h"
31 #include "LayoutRect.h"
32 #include "Pagination.h"
33 #include "PaintPhase.h"
34 #include "RenderPtr.h"
35 #include "ScrollView.h"
37 #include <wtf/Forward.h>
38 #include <wtf/ListHashSet.h>
39 #include <wtf/text/WTFString.h>
47 class HTMLFrameOwnerElement;
53 class RenderEmbeddedObject;
56 class RenderScrollbarPart;
61 Pagination::Mode paginationModeForRenderStyle(const RenderStyle&);
63 typedef unsigned long long DOMTimeStamp;
65 class FrameView final : public ScrollView {
67 friend class RenderView;
68 friend class Internals;
70 static PassRefPtr<FrameView> create(Frame&);
71 static PassRefPtr<FrameView> create(Frame&, const IntSize& initialSize);
75 virtual HostWindow* hostWindow() const override;
77 virtual void invalidateRect(const IntRect&) override;
78 virtual void setFrameRect(const IntRect&) override;
80 #if ENABLE(REQUEST_ANIMATION_FRAME)
81 virtual bool scheduleAnimation() override;
84 Frame& frame() const { return *m_frame; }
86 RenderView* renderView() const;
88 int mapFromLayoutToCSSUnits(LayoutUnit) const;
89 LayoutUnit mapFromCSSToLayoutUnits(int) const;
91 LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default
92 LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default
93 void setMarginWidth(LayoutUnit);
94 void setMarginHeight(LayoutUnit);
96 virtual void setCanHaveScrollbars(bool) override;
97 void updateCanHaveScrollbars();
99 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation) override;
101 virtual bool avoidScrollbarCreation() const override;
103 virtual void setContentsSize(const IntSize&) override;
105 void layout(bool allowSubtree = true);
106 bool didFirstLayout() const;
107 void layoutTimerFired(Timer<FrameView>&);
108 void scheduleRelayout();
109 void scheduleRelayoutOfSubtree(RenderElement&);
110 void unscheduleRelayout();
111 bool layoutPending() const;
112 bool isInLayout() const { return m_layoutPhase == InLayout; }
114 RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
115 void clearLayoutRoot() { m_layoutRoot = nullptr; }
116 int layoutCount() const { return m_layoutCount; }
118 bool needsLayout() const;
119 void setNeedsLayout();
120 void setViewportConstrainedObjectsNeedLayout();
122 bool needsFullRepaint() const { return m_needsFullRepaint; }
124 bool renderedCharactersExceed(unsigned threshold);
127 bool useCustomFixedPositionLayoutRect() const { return m_useCustomFixedPositionLayoutRect; }
128 IntRect customFixedPositionLayoutRect() const { return m_customFixedPositionLayoutRect; }
129 void setCustomFixedPositionLayoutRect(const IntRect&);
130 bool updateFixedPositionLayoutRect();
132 void setCustomSizeForResizeEvent(IntSize);
134 void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, double timestamp);
135 FloatRect computeCoverageRect(double horizontalMargin, double verticalMargin) const;
137 bool useCustomFixedPositionLayoutRect() const { return false; }
140 #if ENABLE(REQUEST_ANIMATION_FRAME)
141 void serviceScriptedAnimations(double monotonicAnimationStartTime);
144 void updateCompositingLayersAfterStyleChange();
145 void updateCompositingLayersAfterLayout();
146 bool flushCompositingStateForThisFrame(Frame* rootFrameForFlush);
148 void clearBackingStores();
149 void restoreBackingStores();
151 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
152 // content rendered via the normal painting path.
153 void setNeedsOneShotDrawingSynchronization();
155 GraphicsLayer* graphicsLayerForPlatformWidget(PlatformWidget);
156 void scheduleLayerFlushAllowingThrottling();
158 virtual TiledBacking* tiledBacking() const override;
160 // In the future when any ScrollableArea can have a node in th ScrollingTree, this should
161 // become a virtual function on ScrollableArea.
162 uint64_t scrollLayerID() const;
163 ScrollableArea* scrollableAreaForScrollLayerID(uint64_t) const;
165 bool hasCompositedContent() const;
166 bool hasCompositedContentIncludingDescendants() const;
167 bool hasCompositingAncestor() const;
168 void enterCompositingMode();
169 bool isEnclosedInCompositingLayer() const;
171 // Only used with accelerated compositing, but outside the #ifdef to make linkage easier.
172 // Returns true if the flush was completed.
173 bool flushCompositingStateIncludingSubframes();
175 // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
176 // a faithful representation of the content.
177 bool isSoftwareRenderable() const;
179 void didMoveOnscreen();
180 void willMoveOffscreen();
181 void setIsInWindow(bool);
183 void resetScrollbars();
184 void resetScrollbarsAndClearContentsSize();
185 void prepareForDetach();
186 void detachCustomScrollbars();
187 void recalculateScrollbarOverlayStyle();
191 bool isTransparent() const;
192 void setTransparent(bool isTransparent);
194 // True if the FrameView is not transparent, and the base background color is opaque.
195 bool hasOpaqueBackground() const;
197 Color baseBackgroundColor() const;
198 void setBaseBackgroundColor(const Color&);
199 void updateBackgroundRecursively(const Color&, bool);
201 enum ExtendedBackgroundModeFlags {
202 ExtendedBackgroundModeNone = 0,
203 ExtendedBackgroundModeVertical = 1 << 0,
204 ExtendedBackgroundModeHorizontal = 1 << 1,
205 ExtendedBackgroundModeAll = ExtendedBackgroundModeVertical | ExtendedBackgroundModeHorizontal,
207 typedef unsigned ExtendedBackgroundMode;
209 void updateExtendBackgroundIfNecessary();
210 void updateTilesForExtendedBackgroundMode(ExtendedBackgroundMode);
211 ExtendedBackgroundMode calculateExtendedBackgroundMode() const;
213 bool hasExtendedBackgroundRectForPainting() const;
214 IntRect extendedBackgroundRectForPainting() const;
216 bool shouldUpdateWhileOffscreen() const;
217 void setShouldUpdateWhileOffscreen(bool);
218 bool shouldUpdate() const;
220 void adjustViewSize();
222 void setViewportSizeForCSSViewportUnits(IntSize);
223 IntSize viewportSizeForCSSViewportUnits() const;
225 virtual IntRect windowClipRect(bool clipToContents = true) const override;
226 IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
228 virtual IntRect windowResizerRect() const override;
230 virtual float visibleContentScaleFactor() const override;
232 #if USE(TILED_BACKING_STORE)
233 virtual void setFixedVisibleContentRect(const IntRect&) override;
235 virtual void setScrollPosition(const IntPoint&) override;
236 void scrollPositionChangedViaPlatformWidget(const IntPoint& oldPosition, const IntPoint& newPosition);
237 virtual void updateLayerPositionsAfterScrolling() override;
238 virtual void updateCompositingLayersAfterScrolling() override;
239 virtual bool requestScrollPositionUpdate(const IntPoint&) override;
240 virtual bool isRubberBandInProgress() const override;
241 virtual IntPoint minimumScrollPosition() const override;
242 virtual IntPoint maximumScrollPosition() const override;
244 // This is different than visibleContentRect() in that it ignores negative (or overly positive)
245 // offsets from rubber-banding, and it takes zooming into account.
246 LayoutRect viewportConstrainedVisibleContentRect() const;
248 String mediaType() const;
249 void setMediaType(const String&);
250 void adjustMediaTypeForPrinting(bool printing);
252 void setCannotBlitToWindow();
253 void setIsOverlapped(bool);
254 bool isOverlapped() const { return m_isOverlapped; }
255 bool isOverlappedIncludingAncestors() const;
256 void setContentIsOpaque(bool);
258 void addSlowRepaintObject(RenderElement*);
259 void removeSlowRepaintObject(RenderElement*);
260 bool hasSlowRepaintObject(RenderElement* o) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(o); }
261 bool hasSlowRepaintObjects() const { return m_slowRepaintObjects && m_slowRepaintObjects->size(); }
263 // Includes fixed- and sticky-position objects.
264 typedef HashSet<RenderElement*> ViewportConstrainedObjectSet;
265 void addViewportConstrainedObject(RenderElement*);
266 void removeViewportConstrainedObject(RenderElement*);
267 const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
268 bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
270 // Functions for querying the current scrolled position, negating the effects of overhang
271 // and adjusting for page scale.
272 LayoutSize scrollOffsetForFixedPosition() const;
273 // Static function can be called from another thread.
274 static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
276 // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed
277 // on both the main thread and the scrolling thread.
278 static float yPositionForInsetClipLayer(const FloatPoint& scrollPosition, float topContentInset);
279 static float yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset, float headerHeight);
280 static float yPositionForHeaderLayer(const FloatPoint& scrollPosition, float topContentInset);
281 static float yPositionForFooterLayer(const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float footerHeight);
284 LayoutRect viewportConstrainedObjectsRect() const;
285 // Static function can be called from another thread.
286 static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements);
289 bool fixedElementsLayoutRelativeToFrame() const;
291 void disableLayerFlushThrottlingTemporarilyForInteraction();
292 void updateLayerFlushThrottlingInAllFrames();
293 void adjustTiledBackingCoverage();
294 bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; }
296 #if ENABLE(DASHBOARD_SUPPORT)
297 void updateAnnotatedRegions();
299 void updateControlTints();
301 void restoreScrollbar();
303 void postLayoutTimerFired(Timer<FrameView>&);
305 bool wasScrolledByUser() const;
306 void setWasScrolledByUser(bool);
308 bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
309 void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
311 void addEmbeddedObjectToUpdate(RenderEmbeddedObject&);
312 void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&);
314 virtual void paintContents(GraphicsContext*, const IntRect& dirtyRect) override;
316 struct PaintingState {
317 PaintBehavior paintBehavior;
318 bool isTopLevelPainter;
319 bool isFlatteningPaintOfRootFrame;
322 , isTopLevelPainter(false)
323 , isFlatteningPaintOfRootFrame(false)
328 void willPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
329 void didPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
331 void setPaintBehavior(PaintBehavior);
332 PaintBehavior paintBehavior() const;
333 bool isPainting() const;
334 bool hasEverPainted() const { return m_lastPaintTime; }
335 void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
336 void setNodeToDraw(Node*);
338 enum SelectionInSnapshot { IncludeSelection, ExcludeSelection };
339 enum CoordinateSpaceForSnapshot { DocumentCoordinates, ViewCoordinates };
340 void paintContentsForSnapshot(GraphicsContext*, const IntRect& imageRect, SelectionInSnapshot shouldPaintSelection, CoordinateSpaceForSnapshot);
342 virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) override;
343 virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect) override;
344 virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) override;
346 Color documentBackgroundColor() const;
348 bool isInChildFrameWithFrameFlattening() const;
350 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
352 void updateLayoutAndStyleIfNeededRecursive();
354 void incrementVisuallyNonEmptyCharacterCount(unsigned);
355 void incrementVisuallyNonEmptyPixelCount(const IntSize&);
356 void updateIsVisuallyNonEmpty();
357 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
358 void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
359 void setAutoSizeFixedMinimumHeight(int fixedMinimumHeight);
360 IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; }
362 void forceLayout(bool allowSubtree = false);
363 void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
365 // FIXME: This method is retained because of embedded WebViews in AppKit. When a WebView is embedded inside
366 // some enclosing view with auto-pagination, no call happens to resize the view. The new pagination model
367 // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
368 // resize around that view. Auto-pagination uses the bounds of the actual view that's being printed to determine
369 // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
370 // web document's bounds.
372 // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
373 // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
374 // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
375 // page size, it can't actually paginate correctly during _layoutForPrinting.
377 // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
378 // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
380 // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
381 void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
383 bool scrollToFragment(const URL&);
384 bool scrollToAnchor(const String&);
385 void maintainScrollPositionAtAnchor(Node*);
386 void scrollElementToRect(Element*, const IntRect&);
388 // Methods to convert points and rects between the coordinate space of the renderer, and this view.
389 IntRect convertFromRenderer(const RenderElement*, const IntRect&) const;
390 IntRect convertToRenderer(const RenderElement*, const IntRect&) const;
391 IntPoint convertFromRenderer(const RenderElement*, const IntPoint&) const;
392 IntPoint convertToRenderer(const RenderElement*, const IntPoint&) const;
394 bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
398 enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
399 void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
401 virtual IntPoint lastKnownMousePosition() const override;
402 virtual bool isHandlingWheelEvent() const override;
403 bool shouldSetCursor() const;
405 // FIXME: Remove this method once plugin loading is decoupled from layout.
406 void flushAnyPendingPostLayoutTasks();
408 virtual bool shouldSuspendScrollAnimations() const override;
409 virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
411 RenderBox* embeddedContentBox() const;
413 void setTracksRepaints(bool);
414 bool isTrackingRepaints() const { return m_isTrackingRepaints; }
415 void resetTrackedRepaints();
416 const Vector<FloatRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
417 String trackedRepaintRectsAsText() const;
419 typedef HashSet<ScrollableArea*> ScrollableAreaSet;
420 // Returns whether the scrollable area has just been newly added.
421 bool addScrollableArea(ScrollableArea*);
422 // Returns whether the scrollable area has just been removed.
423 bool removeScrollableArea(ScrollableArea*);
424 bool containsScrollableArea(ScrollableArea*) const;
425 const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
427 virtual void removeChild(Widget*) override;
429 // This function exists for ports that need to handle wheel events manually.
430 // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
431 // we need this function in order to do the scroll ourselves.
432 bool wheelEvent(const PlatformWheelEvent&);
434 void setScrollingPerformanceLoggingEnabled(bool);
436 // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
437 // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
438 // FrameViews in the page cache, but FrameView::pagination() only affects the current
439 // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
440 // it will return Page::pagination() since currently there are no callers that need to
441 // distinguish between the two.
442 const Pagination& pagination() const;
443 void setPagination(const Pagination&);
445 bool inProgrammaticScroll() const override { return m_inProgrammaticScroll; }
446 void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
448 #if ENABLE(CSS_DEVICE_ADAPTATION)
449 IntSize initialViewportSize() const { return m_initialViewportSize; }
450 void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
453 virtual bool isActive() const override;
454 virtual bool updatesScrollLayerPositionOnMainThread() const override;
456 #if ENABLE(RUBBER_BANDING)
457 GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
458 GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
461 virtual int headerHeight() const override { return m_headerHeight; }
462 void setHeaderHeight(int);
463 virtual int footerHeight() const override { return m_footerHeight; }
464 void setFooterHeight(int);
466 virtual float topContentInset() const override;
467 void topContentInsetDidChange();
469 virtual void willStartLiveResize() override;
470 virtual void willEndLiveResize() override;
472 void addPaintPendingMilestones(LayoutMilestones);
473 void firePaintRelatedMilestonesIfNeeded();
474 void fireLayoutRelatedMilestonesIfNeeded();
475 LayoutMilestones milestonesPendingPaint() const { return m_milestonesPendingPaint; }
477 bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; }
478 void setVisualUpdatesAllowedByClient(bool);
480 void setScrollPinningBehavior(ScrollPinningBehavior);
482 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const;
484 void updateWidgetPositions();
485 void didAddWidgetToRenderTree(Widget&);
486 void willRemoveWidgetFromRenderTree(Widget&);
488 void addTrackedRepaintRect(const FloatRect&);
490 // exposedRect represents WebKit's understanding of what part
491 // of the view is actually exposed on screen (taking into account
492 // clipping by other UI elements), whereas visibleContentRect is
493 // internal to WebCore and doesn't respect those things.
494 void setExposedRect(FloatRect);
495 FloatRect exposedRect() const { return m_exposedRect; }
498 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
499 virtual void scrollContentsSlowPath(const IntRect& updateRect) override;
501 void repaintSlowRepaintObjects();
503 virtual bool isVerticalDocument() const override;
504 virtual bool isFlippedDocument() const override;
507 explicit FrameView(Frame&);
515 InPreLayoutStyleUpdate,
520 LayoutPhase layoutPhase() const { return m_layoutPhase; }
522 bool inPreLayoutStyleUpdate() const { return m_layoutPhase == InPreLayoutStyleUpdate; }
524 virtual bool isFrameView() const override { return true; }
526 friend class RenderWidget;
527 bool useSlowRepaints(bool considerOverlap = true) const;
528 bool useSlowRepaintsIfNotOverlapped() const;
529 void updateCanBlitOnScrollRecursively();
530 bool contentsInCompositedLayer() const;
531 bool shouldLayoutAfterContentsResized() const;
533 bool shouldUpdateCompositingLayersAfterScrolling() const;
535 void applyOverflowToViewport(RenderElement*, ScrollbarMode& hMode, ScrollbarMode& vMode);
536 void applyPaginationToViewport();
538 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
540 void paintControlTints();
542 void forceLayoutParentViewIfNeeded();
543 void performPostLayoutTasks();
544 void autoSizeIfEnabled();
546 virtual void repaintContentRectangle(const IntRect&) override;
547 virtual void contentsResized() override;
548 virtual void visibleContentsResized() override;
549 virtual void addedOrRemovedScrollbar() override;
550 virtual void fixedLayoutSizeChanged() override;
552 virtual void delegatesScrollingDidChange() override;
554 // Override ScrollView methods to do point conversion via renderers, in order to
555 // take transforms into account.
556 virtual IntRect convertToContainingView(const IntRect&) const override;
557 virtual IntRect convertFromContainingView(const IntRect&) const override;
558 virtual IntPoint convertToContainingView(const IntPoint&) const override;
559 virtual IntPoint convertFromContainingView(const IntPoint&) const override;
561 // ScrollableArea interface
562 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
563 virtual void scrollTo(const IntSize&) override;
564 virtual void setVisibleScrollerThumbRect(const IntRect&) override;
565 virtual ScrollableArea* enclosingScrollableArea() const override;
566 virtual IntRect scrollableAreaBoundingBox() const override;
567 virtual bool scrollAnimatorEnabled() const override;
568 virtual GraphicsLayer* layerForScrolling() const override;
569 virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
570 virtual GraphicsLayer* layerForVerticalScrollbar() const override;
571 virtual GraphicsLayer* layerForScrollCorner() const override;
572 #if ENABLE(RUBBER_BANDING)
573 virtual GraphicsLayer* layerForOverhangAreas() const override;
576 // Override scrollbar notifications to update the AXObject cache.
577 virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) override;
578 virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) override;
580 IntSize sizeForResizeEvent() const;
581 void sendResizeEventIfNeeded();
583 void updateScrollableAreaSet();
585 virtual void notifyPageThatContentAreaWillPaint() const override;
587 void enableSpeculativeTilingIfNeeded();
588 void speculativeTilingEnableTimerFired(Timer<FrameView>&);
590 void updateEmbeddedObjectsTimerFired(Timer<FrameView>*);
591 bool updateEmbeddedObjects();
592 void updateEmbeddedObject(RenderEmbeddedObject&);
593 void scrollToAnchor();
594 void scrollPositionChanged(const IntPoint& oldPosition, const IntPoint& newPosition);
595 void scrollableAreaSetChanged();
597 bool hasCustomScrollbars() const;
599 virtual void updateScrollCorner() override;
601 FrameView* parentFrameView() const;
603 void startLayoutAtMainFrameViewIfNeeded(bool allowSubtree);
604 bool frameFlatteningEnabled() const;
605 bool isFrameFlatteningValidForThisFrame() const;
607 bool qualifiesAsVisuallyNonEmpty() const;
609 AXObjectCache* axObjectCache() const;
610 void notifyWidgetsInAllFrames(WidgetNotification);
611 void removeFromAXObjectCache();
612 void notifyWidgets(WidgetNotification);
614 HashSet<Widget*> m_widgetsInRenderTree;
616 static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
619 LayoutSize m_margins;
621 std::unique_ptr<ListHashSet<RenderEmbeddedObject*>> m_embeddedObjectsToUpdate;
622 const RefPtr<Frame> m_frame;
624 std::unique_ptr<HashSet<RenderElement*>> m_slowRepaintObjects;
626 bool m_needsFullRepaint;
628 bool m_canHaveScrollbars;
629 bool m_cannotBlitToWindow;
631 bool m_contentIsOpaque;
633 Timer<FrameView> m_layoutTimer;
634 bool m_delayedLayout;
635 RenderElement* m_layoutRoot;
637 LayoutPhase m_layoutPhase;
638 bool m_layoutSchedulingEnabled;
639 bool m_inSynchronousPostLayout;
641 unsigned m_nestedLayoutCount;
642 Timer<FrameView> m_postLayoutTasksTimer;
643 Timer<FrameView> m_updateEmbeddedObjectsTimer;
644 bool m_firstLayoutCallbackPending;
647 bool m_isTransparent;
648 Color m_baseBackgroundColor;
649 IntSize m_lastViewportSize;
650 float m_lastZoomFactor;
653 String m_mediaTypeWhenNotPrinting;
655 bool m_overflowStatusDirty;
656 bool m_horizontalOverflow;
657 bool m_verticalOverflow;
658 RenderElement* m_viewportRenderer;
660 Pagination m_pagination;
662 bool m_wasScrolledByUser;
663 bool m_inProgrammaticScroll;
664 bool m_safeToPropagateScrollToParent;
666 double m_lastPaintTime;
668 bool m_isTrackingRepaints; // Used for testing.
669 Vector<FloatRect> m_trackedRepaintRects;
671 bool m_shouldUpdateWhileOffscreen;
673 FloatRect m_exposedRect;
675 unsigned m_deferSetNeedsLayouts;
676 bool m_setNeedsLayoutWasDeferred;
678 RefPtr<Node> m_nodeToDraw;
679 PaintBehavior m_paintBehavior;
682 unsigned m_visuallyNonEmptyCharacterCount;
683 unsigned m_visuallyNonEmptyPixelCount;
684 bool m_isVisuallyNonEmpty;
685 bool m_firstVisuallyNonEmptyLayoutCallbackPending;
687 RefPtr<Node> m_maintainScrollPositionAnchor;
689 // Renderer to hold our custom scroll corner.
690 RenderPtr<RenderScrollbarPart> m_scrollCorner;
692 bool m_speculativeTilingEnabled;
693 Timer<FrameView> m_speculativeTilingEnableTimer;
696 bool m_useCustomFixedPositionLayoutRect;
697 IntRect m_customFixedPositionLayoutRect;
699 bool m_useCustomSizeForResizeEvent;
700 IntSize m_customSizeForResizeEvent;
702 double m_horizontalVelocity;
703 double m_verticalVelocity;
704 double m_scaleChangeRate;
705 double m_lastVelocityUpdateTime;
708 IntSize m_overrideViewportSize;
709 bool m_hasOverrideViewportSize;
711 // If true, automatically resize the frame view around its content.
712 bool m_shouldAutoSize;
714 // True if autosize has been run since m_shouldAutoSize was set.
715 bool m_didRunAutosize;
716 // The lower bound on the size when autosizing.
717 IntSize m_minAutoSize;
718 // The upper bound on the size when autosizing.
719 IntSize m_maxAutoSize;
720 // The fixed height to resize the view to after autosizing is complete.
721 int m_autoSizeFixedMinimumHeight;
722 // The intrinsic content size decided by autosizing.
723 IntSize m_autoSizeContentSize;
725 std::unique_ptr<ScrollableAreaSet> m_scrollableAreas;
726 std::unique_ptr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
731 LayoutMilestones m_milestonesPendingPaint;
733 static const unsigned visualCharacterThreshold = 200;
734 static const unsigned visualPixelThreshold = 32 * 32;
736 #if ENABLE(CSS_DEVICE_ADAPTATION)
737 // Size of viewport before any UA or author styles have overridden
738 // the viewport given by the window or viewing area of the UA.
739 IntSize m_initialViewportSize;
742 bool m_visualUpdatesAllowedByClient;
744 ScrollPinningBehavior m_scrollPinningBehavior;
747 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
749 if (m_isVisuallyNonEmpty)
751 m_visuallyNonEmptyCharacterCount += count;
752 if (m_visuallyNonEmptyCharacterCount <= visualCharacterThreshold)
754 updateIsVisuallyNonEmpty();
757 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
759 if (m_isVisuallyNonEmpty)
761 m_visuallyNonEmptyPixelCount += size.width() * size.height();
762 if (m_visuallyNonEmptyPixelCount <= visualPixelThreshold)
764 updateIsVisuallyNonEmpty();
767 WIDGET_TYPE_CASTS(FrameView, isFrameView());
769 } // namespace WebCore
771 #endif // FrameView_h