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