• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, 2005, 2006, 2007, 2008, 2009 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 #ifndef FrameView_h
26 #define FrameView_h
27 
28 #include "core/rendering/PaintPhase.h"
29 #include "platform/RuntimeEnabledFeatures.h"
30 #include "platform/geometry/LayoutRect.h"
31 #include "platform/graphics/Color.h"
32 #include "platform/scroll/ScrollView.h"
33 #include "wtf/Forward.h"
34 #include "wtf/OwnPtr.h"
35 #include "wtf/text/WTFString.h"
36 
37 namespace WebCore {
38 
39 class AXObjectCache;
40 class DocumentLifecycle;
41 class Cursor;
42 class Element;
43 class FloatSize;
44 class HTMLFrameOwnerElement;
45 class LocalFrame;
46 class KURL;
47 class Node;
48 class Page;
49 class RenderBox;
50 class RenderEmbeddedObject;
51 class RenderObject;
52 class RenderScrollbarPart;
53 class RenderStyle;
54 class RenderView;
55 class RenderWidget;
56 
57 typedef unsigned long long DOMTimeStamp;
58 
59 class FrameView FINAL : public ScrollView {
60 public:
61     friend class RenderView;
62     friend class Internals;
63 
64     static PassRefPtr<FrameView> create(LocalFrame*);
65     static PassRefPtr<FrameView> create(LocalFrame*, const IntSize& initialSize);
66 
67     virtual ~FrameView();
68 
69     virtual HostWindow* hostWindow() const OVERRIDE;
70 
71     virtual void invalidateRect(const IntRect&) OVERRIDE;
72     virtual void setFrameRect(const IntRect&) OVERRIDE;
73 
74     virtual bool scheduleAnimation() OVERRIDE;
75 
frame()76     LocalFrame& frame() const { return *m_frame; }
77     Page* page() const;
78 
79     RenderView* renderView() const;
80 
81     virtual void setCanHaveScrollbars(bool) OVERRIDE;
82 
83     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation) OVERRIDE;
84 
85     virtual void setContentsSize(const IntSize&) OVERRIDE;
86     IntPoint clampOffsetAtScale(const IntPoint& offset, float scale) const;
87 
88     void layout(bool allowSubtree = true);
89     bool didFirstLayout() const;
90     void scheduleRelayout();
91     void scheduleRelayoutOfSubtree(RenderObject*);
92     bool layoutPending() const;
93     bool isInPerformLayout() const;
94 
setCanInvalidatePaintDuringPerformLayout(bool b)95     void setCanInvalidatePaintDuringPerformLayout(bool b) { m_canInvalidatePaintDuringPerformLayout = b; }
canInvalidatePaintDuringPerformLayout()96     bool canInvalidatePaintDuringPerformLayout() const { return m_canInvalidatePaintDuringPerformLayout; }
97 
98     RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
clearLayoutSubtreeRoot()99     void clearLayoutSubtreeRoot() { m_layoutSubtreeRoot = 0; }
layoutCount()100     int layoutCount() const { return m_layoutCount; }
101 
102     bool needsLayout() const;
103     void setNeedsLayout();
104 
105     // Methods for getting/setting the size Blink should use to layout the contents.
106     IntSize layoutSize(IncludeScrollbarsInRect = ExcludeScrollbars) const;
107     void setLayoutSize(const IntSize&);
108 
109     // If this is set to false, the layout size will need to be explicitly set by the owner.
110     // E.g. WebViewImpl sets its mainFrame's layout size manually
setLayoutSizeFixedToFrameSize(bool isFixed)111     void setLayoutSizeFixedToFrameSize(bool isFixed) { m_layoutSizeFixedToFrameSize = isFixed; }
layoutSizeFixedToFrameSize()112     bool layoutSizeFixedToFrameSize() { return m_layoutSizeFixedToFrameSize; }
113 
needsFullPaintInvalidation()114     bool needsFullPaintInvalidation() const { return m_doFullPaintInvalidation; }
115 
116     void updateAcceleratedCompositingSettings();
117 
118     void recalcOverflowAfterStyleChange();
119 
120     bool hasCompositedContent() const;
121     bool isEnclosedInCompositingLayer() const;
122 
123     void resetScrollbars();
124     void prepareForDetach();
125     void detachCustomScrollbars();
126     virtual void recalculateScrollbarOverlayStyle();
127 
128     void clear();
129 
130     bool isTransparent() const;
131     void setTransparent(bool isTransparent);
132 
133     // True if the FrameView is not transparent, and the base background color is opaque.
134     bool hasOpaqueBackground() const;
135 
136     Color baseBackgroundColor() const;
137     void setBaseBackgroundColor(const Color&);
138     void updateBackgroundRecursively(const Color&, bool);
139 
140     void adjustViewSize();
141 
142     virtual IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars) const OVERRIDE;
143     IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*) const;
144 
145     virtual IntRect windowResizerRect() const OVERRIDE;
146 
visibleContentScaleFactor()147     virtual float visibleContentScaleFactor() const OVERRIDE { return m_visibleContentScaleFactor; }
148     void setVisibleContentScaleFactor(float);
149 
150     virtual float inputEventsScaleFactor() const OVERRIDE;
151     virtual IntSize inputEventsOffsetForEmulation() const OVERRIDE;
152     void setInputEventsTransformForEmulation(const IntSize&, float);
153 
154     virtual void setScrollPosition(const IntPoint&) OVERRIDE;
155     virtual bool isRubberBandInProgress() const OVERRIDE;
156     void setScrollPositionNonProgrammatically(const IntPoint&);
157 
158     // This is different than visibleContentRect() in that it ignores negative (or overly positive)
159     // offsets from rubber-banding, and it takes zooming into account.
160     LayoutRect viewportConstrainedVisibleContentRect() const;
161     void viewportConstrainedVisibleContentSizeChanged(bool widthChanged, bool heightChanged);
162 
163     AtomicString mediaType() const;
164     void setMediaType(const AtomicString&);
165     void adjustMediaTypeForPrinting(bool printing);
166 
167     void setCannotBlitToWindow();
168     void setIsOverlapped(bool);
isOverlapped()169     bool isOverlapped() const { return m_isOverlapped; }
170     void setContentIsOpaque(bool);
171 
172     void addSlowRepaintObject();
173     void removeSlowRepaintObject();
hasSlowRepaintObjects()174     bool hasSlowRepaintObjects() const { return m_slowRepaintObjectCount; }
175 
176     // Includes fixed- and sticky-position objects.
177     typedef HashSet<RenderObject*> ViewportConstrainedObjectSet;
178     void addViewportConstrainedObject(RenderObject*);
179     void removeViewportConstrainedObject(RenderObject*);
viewportConstrainedObjects()180     const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
hasViewportConstrainedObjects()181     bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
182 
183     void handleLoadCompleted();
184 
185     void updateAnnotatedRegions();
186     void updateControlTints();
187 
188     void restoreScrollbar();
189 
190     void postLayoutTimerFired(Timer<FrameView>*);
191 
192     bool wasScrolledByUser() const;
193     void setWasScrolledByUser(bool);
194 
safeToPropagateScrollToParent()195     bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
setSafeToPropagateScrollToParent(bool isSafe)196     void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
197 
198     void addWidget(RenderWidget*);
199     void removeWidget(RenderWidget*);
200     void updateWidgetPositions();
201 
202     void addWidgetToUpdate(RenderEmbeddedObject&);
203 
204     virtual void paintContents(GraphicsContext*, const IntRect& damageRect) OVERRIDE;
205     void setPaintBehavior(PaintBehavior);
206     PaintBehavior paintBehavior() const;
207     bool isPainting() const;
hasEverPainted()208     bool hasEverPainted() const { return m_lastPaintTime; }
209     void setNodeToDraw(Node*);
210 
211     virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) OVERRIDE;
212     virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect) OVERRIDE;
213     virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) OVERRIDE;
214 
215     Color documentBackgroundColor() const;
216 
currentFrameTimeStamp()217     static double currentFrameTimeStamp() { return s_currentFrameTimeStamp; }
218 
219     void updateLayoutAndStyleForPainting();
220     void updateLayoutAndStyleIfNeededRecursive();
221 
222     void incrementVisuallyNonEmptyCharacterCount(unsigned);
223     void incrementVisuallyNonEmptyPixelCount(const IntSize&);
setIsVisuallyNonEmpty()224     void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; }
225     void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
226 
227     void forceLayout(bool allowSubtree = false);
228     void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor);
229 
230     bool scrollToFragment(const KURL&);
231     bool scrollToAnchor(const String&);
232     void maintainScrollPositionAtAnchor(Node*);
233     void scrollElementToRect(Element*, const IntRect&);
234     void scrollContentsIfNeededRecursive();
235 
236     // Methods to convert points and rects between the coordinate space of the renderer, and this view.
237     IntRect convertFromRenderer(const RenderObject&, const IntRect&) const;
238     IntRect convertToRenderer(const RenderObject&, const IntRect&) const;
239     IntPoint convertFromRenderer(const RenderObject&, const IntPoint&) const;
240     IntPoint convertToRenderer(const RenderObject&, const IntPoint&) const;
241 
isFrameViewScrollCorner(RenderScrollbarPart * scrollCorner)242     bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
243 
244     bool isScrollable();
245 
246     enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
247     void calculateScrollbarModesForLayoutAndSetViewportRenderer(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
248 
249     virtual IntPoint lastKnownMousePosition() const OVERRIDE;
250     bool shouldSetCursor() const;
251 
252     void setCursor(const Cursor&);
253 
254     virtual bool scrollbarsCanBeActive() const OVERRIDE;
255 
256     // FIXME: Remove this method once plugin loading is decoupled from layout.
257     void flushAnyPendingPostLayoutTasks();
258 
259     virtual bool shouldSuspendScrollAnimations() const OVERRIDE;
260     virtual void scrollbarStyleChanged() OVERRIDE;
261 
262     RenderBox* embeddedContentBox() const;
263 
264     void setTracksPaintInvalidations(bool);
isTrackingPaintInvalidations()265     bool isTrackingPaintInvalidations() const { return m_isTrackingPaintInvalidations; }
266     void resetTrackedPaintInvalidations();
267     String trackedPaintInvalidationRectsAsText() const;
268 
269     typedef HashSet<ScrollableArea*> ScrollableAreaSet;
270     void addScrollableArea(ScrollableArea*);
271     void removeScrollableArea(ScrollableArea*);
scrollableAreas()272     const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
273 
274     // With CSS style "resize:" enabled, a little resizer handle will appear at the bottom
275     // right of the object. We keep track of these resizer areas for checking if touches
276     // (implemented using Scroll gesture) are targeting the resizer.
277     typedef HashSet<RenderBox*> ResizerAreaSet;
278     void addResizerArea(RenderBox&);
279     void removeResizerArea(RenderBox&);
resizerAreas()280     const ResizerAreaSet* resizerAreas() const { return m_resizerAreas.get(); }
281 
282     virtual void removeChild(Widget*) OVERRIDE;
283 
284     // This function exists for ports that need to handle wheel events manually.
285     // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
286     // we need this function in order to do the scroll ourselves.
287     bool wheelEvent(const PlatformWheelEvent&);
288 
inProgrammaticScroll()289     bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
setInProgrammaticScroll(bool programmaticScroll)290     void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
291 
setHasSoftwareFilters(bool hasSoftwareFilters)292     void setHasSoftwareFilters(bool hasSoftwareFilters) { m_hasSoftwareFilters = hasSoftwareFilters; }
hasSoftwareFilters()293     bool hasSoftwareFilters() const { return m_hasSoftwareFilters; }
294 
295     virtual bool isActive() const OVERRIDE;
296 
297     // DEPRECATED: Use viewportConstrainedVisibleContentRect() instead.
298     IntSize scrollOffsetForFixedPosition() const;
299 
300     // Override scrollbar notifications to update the AXObject cache.
301     virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) OVERRIDE;
302     virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) OVERRIDE;
303 
304     virtual bool shouldAttemptToScrollUsingFastPath() const OVERRIDE;
305     // FIXME: This should probably be renamed as the 'inSubtreeLayout' parameter
306     // passed around the FrameView layout methods can be true while this returns
307     // false.
isSubtreeLayout()308     bool isSubtreeLayout() const { return !!m_layoutSubtreeRoot; }
309 
310     // Sets the tickmarks for the FrameView, overriding the default behavior
311     // which is to display the tickmarks corresponding to find results.
312     // If |m_tickmarks| is empty, the default behavior is restored.
setTickmarks(const Vector<IntRect> & tickmarks)313     void setTickmarks(const Vector<IntRect>& tickmarks) { m_tickmarks = tickmarks; }
314 
315     // ScrollableArea interface
316     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
317     virtual void getTickmarks(Vector<IntRect>&) const OVERRIDE;
318     virtual void scrollTo(const IntSize&) OVERRIDE;
319     virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
320     virtual bool scrollAnimatorEnabled() const OVERRIDE;
321     virtual bool usesCompositedScrolling() const OVERRIDE;
322     virtual GraphicsLayer* layerForScrolling() const OVERRIDE;
323     virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
324     virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
325     virtual GraphicsLayer* layerForScrollCorner() const OVERRIDE;
326 
327 protected:
328     virtual void scrollContentsIfNeeded();
329     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) OVERRIDE;
330     virtual void scrollContentsSlowPath(const IntRect& updateRect) OVERRIDE;
331 
332     virtual bool isVerticalDocument() const OVERRIDE;
333     virtual bool isFlippedDocument() const OVERRIDE;
334 
335 private:
336     explicit FrameView(LocalFrame*);
337 
338     void reset();
339     void init();
340 
341     virtual void frameRectsChanged() OVERRIDE;
isFrameView()342     virtual bool isFrameView() const OVERRIDE { return true; }
343 
344     friend class RenderWidget;
345     bool useSlowRepaints(bool considerOverlap = true) const;
346     bool useSlowRepaintsIfNotOverlapped() const;
347 
348     bool contentsInCompositedLayer() const;
349 
350     void applyOverflowToViewportAndSetRenderer(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode);
351     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
352 
353     void updateCounters();
354     void autoSizeIfEnabled();
355     void forceLayoutParentViewIfNeeded();
356     void performPreLayoutTasks();
357     void performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout);
358     void scheduleOrPerformPostLayoutTasks();
359     void performPostLayoutTasks();
360 
361     void invalidateTree(RenderObject* root);
362 
363     void gatherDebugLayoutRects(RenderObject* layoutRoot);
364 
365     DocumentLifecycle& lifecycle() const;
366 
367     virtual void contentRectangleForPaintInvalidation(const IntRect&) OVERRIDE;
368     virtual void contentsResized() OVERRIDE;
369     virtual void scrollbarExistenceDidChange() OVERRIDE;
370 
371     // Override ScrollView methods to do point conversion via renderers, in order to
372     // take transforms into account.
373     virtual IntRect convertToContainingView(const IntRect&) const OVERRIDE;
374     virtual IntRect convertFromContainingView(const IntRect&) const OVERRIDE;
375     virtual IntPoint convertToContainingView(const IntPoint&) const OVERRIDE;
376     virtual IntPoint convertFromContainingView(const IntPoint&) const OVERRIDE;
377 
378     void sendResizeEventIfNeeded();
379 
380     void updateScrollableAreaSet();
381 
382     virtual void notifyPageThatContentAreaWillPaint() const OVERRIDE;
383 
384     void scheduleUpdateWidgetsIfNecessary();
385     void updateWidgetsTimerFired(Timer<FrameView>*);
386     bool updateWidgets();
387 
388     void scrollToAnchor();
389     void scrollPositionChanged();
390     void didScrollTimerFired(Timer<FrameView>*);
391 
392     void updateLayersAndCompositingAfterScrollIfNeeded();
393     void updateFixedElementPaintInvalidationRectsAfterScroll();
394 
395     bool hasCustomScrollbars() const;
396     bool shouldUseCustomScrollbars(Element*& customScrollbarElement, LocalFrame*& customScrollbarFrame);
397 
398     virtual void updateScrollCorner() OVERRIDE;
399 
400     FrameView* parentFrameView() const;
401 
402     AXObjectCache* axObjectCache() const;
403     void removeFromAXObjectCache();
404 
405     void setLayoutSizeInternal(const IntSize&);
406 
paintInvalidationIsAllowed()407     bool paintInvalidationIsAllowed() const
408     {
409         if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
410             return true;
411 
412         return !isInPerformLayout() || canInvalidatePaintDuringPerformLayout();
413     }
414 
415     static double s_currentFrameTimeStamp; // used for detecting decoded resource thrash in the cache
416     static bool s_inPaintContents;
417 
418     LayoutSize m_size;
419 
420     typedef HashSet<RefPtr<RenderEmbeddedObject> > EmbeddedObjectSet;
421     EmbeddedObjectSet m_widgetUpdateSet;
422 
423     // FIXME: These are just "children" of the FrameView and should be RefPtr<Widget> instead.
424     HashSet<RefPtr<RenderWidget> > m_widgets;
425 
426     RefPtr<LocalFrame> m_frame;
427 
428     bool m_doFullPaintInvalidation;
429 
430     bool m_canHaveScrollbars;
431     bool m_cannotBlitToWindow;
432     bool m_isOverlapped;
433     bool m_contentIsOpaque;
434     unsigned m_slowRepaintObjectCount;
435 
436     bool m_hasPendingLayout;
437     RenderObject* m_layoutSubtreeRoot;
438 
439     bool m_layoutSchedulingEnabled;
440     bool m_inPerformLayout;
441     bool m_canInvalidatePaintDuringPerformLayout;
442     bool m_inSynchronousPostLayout;
443     int m_layoutCount;
444     unsigned m_nestedLayoutCount;
445     Timer<FrameView> m_postLayoutTasksTimer;
446     Timer<FrameView> m_updateWidgetsTimer;
447     bool m_firstLayoutCallbackPending;
448 
449     bool m_firstLayout;
450     bool m_isTransparent;
451     Color m_baseBackgroundColor;
452     IntSize m_lastViewportSize;
453     float m_lastZoomFactor;
454 
455     AtomicString m_mediaType;
456     AtomicString m_mediaTypeWhenNotPrinting;
457 
458     bool m_overflowStatusDirty;
459     bool m_horizontalOverflow;
460     bool m_verticalOverflow;
461     RenderObject* m_viewportRenderer;
462 
463     bool m_wasScrolledByUser;
464     bool m_inProgrammaticScroll;
465     bool m_safeToPropagateScrollToParent;
466 
467     double m_lastPaintTime;
468 
469     bool m_isTrackingPaintInvalidations; // Used for testing.
470     Vector<IntRect> m_trackedPaintInvalidationRects;
471 
472     RefPtrWillBePersistent<Node> m_nodeToDraw;
473     PaintBehavior m_paintBehavior;
474     bool m_isPainting;
475 
476     unsigned m_visuallyNonEmptyCharacterCount;
477     unsigned m_visuallyNonEmptyPixelCount;
478     bool m_isVisuallyNonEmpty;
479     bool m_firstVisuallyNonEmptyLayoutCallbackPending;
480 
481     RefPtrWillBePersistent<Node> m_maintainScrollPositionAnchor;
482 
483     // Renderer to hold our custom scroll corner.
484     RenderScrollbarPart* m_scrollCorner;
485 
486     // If true, automatically resize the frame view around its content.
487     bool m_shouldAutoSize;
488     bool m_inAutoSize;
489     // True if autosize has been run since m_shouldAutoSize was set.
490     bool m_didRunAutosize;
491     // The lower bound on the size when autosizing.
492     IntSize m_minAutoSize;
493     // The upper bound on the size when autosizing.
494     IntSize m_maxAutoSize;
495 
496     OwnPtr<ScrollableAreaSet> m_scrollableAreas;
497     OwnPtr<ResizerAreaSet> m_resizerAreas;
498     OwnPtr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
499 
500     bool m_hasSoftwareFilters;
501 
502     float m_visibleContentScaleFactor;
503     IntSize m_inputEventsOffsetForEmulation;
504     float m_inputEventsScaleFactorForEmulation;
505 
506     IntSize m_layoutSize;
507     bool m_layoutSizeFixedToFrameSize;
508 
509     Timer<FrameView> m_didScrollTimer;
510 
511     Vector<IntRect> m_tickmarks;
512 };
513 
incrementVisuallyNonEmptyCharacterCount(unsigned count)514 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
515 {
516     if (m_isVisuallyNonEmpty)
517         return;
518     m_visuallyNonEmptyCharacterCount += count;
519     // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout.
520     // The first few hundred characters rarely contain the interesting content of the page.
521     static const unsigned visualCharacterThreshold = 200;
522     if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
523         setIsVisuallyNonEmpty();
524 }
525 
incrementVisuallyNonEmptyPixelCount(const IntSize & size)526 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
527 {
528     if (m_isVisuallyNonEmpty)
529         return;
530     m_visuallyNonEmptyPixelCount += size.width() * size.height();
531     // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout
532     static const unsigned visualPixelThreshold = 32 * 32;
533     if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
534         setIsVisuallyNonEmpty();
535 }
536 
537 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFrameView());
538 
539 class AllowPaintInvalidationScope {
540 public:
AllowPaintInvalidationScope(FrameView * view)541     explicit AllowPaintInvalidationScope(FrameView* view)
542         : m_view(view)
543         , m_originalValue(view ? view->canInvalidatePaintDuringPerformLayout() : false)
544     {
545         if (!m_view)
546             return;
547 
548         m_view->setCanInvalidatePaintDuringPerformLayout(true);
549     }
550 
~AllowPaintInvalidationScope()551     ~AllowPaintInvalidationScope()
552     {
553         if (!m_view)
554             return;
555 
556         m_view->setCanInvalidatePaintDuringPerformLayout(m_originalValue);
557     }
558 private:
559     FrameView* m_view;
560     bool m_originalValue;
561 };
562 
563 } // namespace WebCore
564 
565 #endif // FrameView_h
566