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 "AdjustViewSizeOrNot.h"
29#include "Color.h"
30#include "Frame.h"
31#include "LayoutRect.h"
32#include "Pagination.h"
33#include "PaintPhase.h"
34#include "ScrollView.h"
35#include <wtf/Forward.h>
36#include <wtf/OwnPtr.h>
37#include <wtf/text/WTFString.h>
38
39namespace WebCore {
40
41class AXObjectCache;
42class Element;
43class FloatSize;
44class KURL;
45class Node;
46class Page;
47class RenderBox;
48class RenderEmbeddedObject;
49class RenderLayer;
50class RenderObject;
51class RenderScrollbarPart;
52class RenderStyle;
53
54Pagination::Mode paginationModeForRenderStyle(RenderStyle*);
55
56typedef unsigned long long DOMTimeStamp;
57
58class FrameView : public ScrollView {
59public:
60    friend class RenderView;
61    friend class Internals;
62
63    static PassRefPtr<FrameView> create(Frame*);
64    static PassRefPtr<FrameView> create(Frame*, const IntSize& initialSize);
65
66    virtual ~FrameView();
67
68    virtual HostWindow* hostWindow() const;
69
70    virtual void invalidateRect(const IntRect&);
71    virtual void setFrameRect(const IntRect&);
72
73#if ENABLE(REQUEST_ANIMATION_FRAME)
74    virtual bool scheduleAnimation();
75#endif
76
77    Frame* frame() const { return m_frame.get(); }
78    void clearFrame();
79
80    RenderView* renderView() const { return m_frame ? m_frame->contentRenderer() : 0; }
81
82    int mapFromLayoutToCSSUnits(LayoutUnit);
83    LayoutUnit mapFromCSSToLayoutUnits(int);
84
85    LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default
86    LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default
87    void setMarginWidth(LayoutUnit);
88    void setMarginHeight(LayoutUnit);
89
90    virtual void setCanHaveScrollbars(bool);
91    void updateCanHaveScrollbars();
92
93    virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
94
95    virtual bool avoidScrollbarCreation() const;
96
97    virtual void setContentsSize(const IntSize&);
98
99    void layout(bool allowSubtree = true);
100    bool didFirstLayout() const;
101    void layoutTimerFired(Timer<FrameView>*);
102    void scheduleRelayout();
103    void scheduleRelayoutOfSubtree(RenderObject*);
104    void unscheduleRelayout();
105    bool layoutPending() const;
106    bool isInLayout() const { return m_inLayout; }
107
108    RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
109    void clearLayoutRoot() { m_layoutRoot = 0; }
110    int layoutCount() const { return m_layoutCount; }
111
112    bool needsLayout() const;
113    void setNeedsLayout();
114    void setViewportConstrainedObjectsNeedLayout();
115
116    bool needsFullRepaint() const { return m_doFullRepaint; }
117
118#if ENABLE(REQUEST_ANIMATION_FRAME)
119    void serviceScriptedAnimations(double monotonicAnimationStartTime);
120#endif
121
122#if USE(ACCELERATED_COMPOSITING)
123    void updateCompositingLayersAfterStyleChange();
124    void updateCompositingLayersAfterLayout();
125    bool flushCompositingStateForThisFrame(Frame* rootFrameForFlush);
126
127    void clearBackingStores();
128    void restoreBackingStores();
129
130    // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
131    // content rendered via the normal painting path.
132    void setNeedsOneShotDrawingSynchronization();
133
134    virtual TiledBacking* tiledBacking() OVERRIDE;
135
136    // In the future when any ScrollableArea can have a node in th ScrollingTree, this should
137    // become a virtual function on ScrollableArea.
138    uint64_t scrollLayerID() const;
139#endif
140
141    bool hasCompositedContent() const;
142    bool hasCompositedContentIncludingDescendants() const;
143    bool hasCompositingAncestor() const;
144    void enterCompositingMode();
145    bool isEnclosedInCompositingLayer() const;
146
147    // Only used with accelerated compositing, but outside the #ifdef to make linkage easier.
148    // Returns true if the flush was completed.
149    bool flushCompositingStateIncludingSubframes();
150
151    // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
152    // a faithful representation of the content.
153    bool isSoftwareRenderable() const;
154
155    void didMoveOnscreen();
156    void willMoveOffscreen();
157    void setIsInWindow(bool);
158
159    void resetScrollbars();
160    void resetScrollbarsAndClearContentsSize();
161    void prepareForDetach();
162    void detachCustomScrollbars();
163    virtual void recalculateScrollbarOverlayStyle();
164
165    void clear();
166
167    bool isTransparent() const;
168    void setTransparent(bool isTransparent);
169
170    // True if the FrameView is not transparent, and the base background color is opaque.
171    bool hasOpaqueBackground() const;
172
173    Color baseBackgroundColor() const;
174    void setBaseBackgroundColor(const Color&);
175    void updateBackgroundRecursively(const Color&, bool);
176
177    bool shouldUpdateWhileOffscreen() const;
178    void setShouldUpdateWhileOffscreen(bool);
179    bool shouldUpdate(bool = false) const;
180
181    void adjustViewSize();
182
183    virtual IntRect windowClipRect(bool clipToContents = true) const;
184    IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
185
186    virtual IntRect windowResizerRect() const;
187
188    virtual float visibleContentScaleFactor() const OVERRIDE;
189
190    virtual void setFixedVisibleContentRect(const IntRect&) OVERRIDE;
191    virtual void setScrollPosition(const IntPoint&) OVERRIDE;
192    void scrollPositionChangedViaPlatformWidget();
193    virtual void repaintFixedElementsAfterScrolling();
194    virtual void updateFixedElementsAfterScrolling();
195    virtual bool shouldRubberBandInDirection(ScrollDirection) const;
196    virtual bool requestScrollPositionUpdate(const IntPoint&) OVERRIDE;
197    virtual bool isRubberBandInProgress() const OVERRIDE;
198    virtual IntPoint minimumScrollPosition() const OVERRIDE;
199    virtual IntPoint maximumScrollPosition() const OVERRIDE;
200
201    // This is different than visibleContentRect() in that it ignores negative (or overly positive)
202    // offsets from rubber-banding, and it takes zooming into account.
203    LayoutRect viewportConstrainedVisibleContentRect() const;
204
205    String mediaType() const;
206    void setMediaType(const String&);
207    void adjustMediaTypeForPrinting(bool printing);
208
209    void setCannotBlitToWindow();
210    void setIsOverlapped(bool);
211    bool isOverlapped() const { return m_isOverlapped; }
212    bool isOverlappedIncludingAncestors() const;
213    void setContentIsOpaque(bool);
214
215    void addSlowRepaintObject(RenderObject*);
216    void removeSlowRepaintObject(RenderObject*);
217    bool hasSlowRepaintObject(RenderObject* o) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(o); }
218    bool hasSlowRepaintObjects() const { return m_slowRepaintObjects && m_slowRepaintObjects->size(); }
219
220    // Includes fixed- and sticky-position objects.
221    typedef HashSet<RenderObject*> ViewportConstrainedObjectSet;
222    void addViewportConstrainedObject(RenderObject*);
223    void removeViewportConstrainedObject(RenderObject*);
224    const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
225    bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
226
227    // Functions for querying the current scrolled position, negating the effects of overhang
228    // and adjusting for page scale.
229    IntSize scrollOffsetForFixedPosition() const;
230    // Static function can be called from another thread.
231    static IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, int headerHeight, int footerHeight);
232
233    bool fixedElementsLayoutRelativeToFrame() const;
234
235    void beginDeferredRepaints();
236    void endDeferredRepaints();
237    void handleLoadCompleted();
238    void flushDeferredRepaints();
239    void startDeferredRepaintTimer(double delay);
240    void resetDeferredRepaintDelay();
241
242    void updateLayerFlushThrottlingInAllFrames();
243    void adjustTiledBackingCoverage();
244
245    void beginDisableRepaints();
246    void endDisableRepaints();
247    bool repaintsDisabled() { return m_disableRepaints > 0; }
248
249#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
250    void updateAnnotatedRegions();
251#endif
252    void updateControlTints();
253
254    void restoreScrollbar();
255
256    void postLayoutTimerFired(Timer<FrameView>*);
257
258    bool wasScrolledByUser() const;
259    void setWasScrolledByUser(bool);
260
261    bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
262    void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
263
264    void addWidgetToUpdate(RenderObject*);
265    void removeWidgetToUpdate(RenderObject*);
266
267    virtual void paintContents(GraphicsContext*, const IntRect& damageRect);
268    void setPaintBehavior(PaintBehavior);
269    PaintBehavior paintBehavior() const;
270    bool isPainting() const;
271    bool hasEverPainted() const { return m_lastPaintTime; }
272    void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
273    void setNodeToDraw(Node*);
274
275    enum SelectionInSnaphot { IncludeSelection, ExcludeSelection };
276    enum CoordinateSpaceForSnapshot { DocumentCoordinates, ViewCoordinates };
277    void paintContentsForSnapshot(GraphicsContext*, const IntRect& imageRect, SelectionInSnaphot shouldPaintSelection, CoordinateSpaceForSnapshot);
278
279    virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
280    virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
281    virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) OVERRIDE;
282
283    Color documentBackgroundColor() const;
284
285    bool isInChildFrameWithFrameFlattening() const;
286
287    static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
288
289    void updateLayoutAndStyleIfNeededRecursive();
290
291    void incrementVisuallyNonEmptyCharacterCount(unsigned);
292    void incrementVisuallyNonEmptyPixelCount(const IntSize&);
293    void setIsVisuallyNonEmpty();
294    bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
295    void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
296    void setAutoSizeFixedMinimumHeight(int fixedMinimumHeight);
297    IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; }
298
299    void forceLayout(bool allowSubtree = false);
300    void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
301
302    // FIXME: This method is retained because of embedded WebViews in AppKit.  When a WebView is embedded inside
303    // some enclosing view with auto-pagination, no call happens to resize the view.  The new pagination model
304    // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
305    // resize around that view.  Auto-pagination uses the bounds of the actual view that's being printed to determine
306    // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
307    // web document's bounds.
308    //
309    // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
310    // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
311    // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
312    // page size, it can't actually paginate correctly during _layoutForPrinting.
313    //
314    // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
315    // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
316    //
317    // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
318    void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
319
320    bool scrollToFragment(const KURL&);
321    bool scrollToAnchor(const String&);
322    void maintainScrollPositionAtAnchor(Node*);
323    void scrollElementToRect(Element*, const IntRect&);
324
325    // Methods to convert points and rects between the coordinate space of the renderer, and this view.
326    virtual IntRect convertFromRenderer(const RenderObject*, const IntRect&) const;
327    virtual IntRect convertToRenderer(const RenderObject*, const IntRect&) const;
328    virtual IntPoint convertFromRenderer(const RenderObject*, const IntPoint&) const;
329    virtual IntPoint convertToRenderer(const RenderObject*, const IntPoint&) const;
330
331    bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
332
333    bool isScrollable();
334
335    enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
336    void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
337
338    // Normal delay
339    static void setRepaintThrottlingDeferredRepaintDelay(double p);
340    // Negative value would mean that first few repaints happen without a delay
341    static void setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(double p);
342    // The delay grows on each repaint to this maximum value
343    static void setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(double p);
344    // On each repaint the delay increses by this amount
345    static void setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(double p);
346
347    virtual IntPoint lastKnownMousePosition() const;
348    virtual bool isHandlingWheelEvent() const OVERRIDE;
349    bool shouldSetCursor() const;
350
351    virtual bool scrollbarsCanBeActive() const OVERRIDE;
352
353    // FIXME: Remove this method once plugin loading is decoupled from layout.
354    void flushAnyPendingPostLayoutTasks();
355
356    virtual bool shouldSuspendScrollAnimations() const;
357    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
358
359    void setAnimatorsAreActive();
360
361    RenderBox* embeddedContentBox() const;
362
363    void setTracksRepaints(bool);
364    bool isTrackingRepaints() const { return m_isTrackingRepaints; }
365    void resetTrackedRepaints();
366    const Vector<IntRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
367    String trackedRepaintRectsAsText() const;
368
369    typedef HashSet<ScrollableArea*> ScrollableAreaSet;
370    // Returns whether the scrollable area has just been newly added.
371    bool addScrollableArea(ScrollableArea*);
372    // Returns whether the scrollable area has just been removed.
373    bool removeScrollableArea(ScrollableArea*);
374    bool containsScrollableArea(ScrollableArea*) const;
375    const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
376
377    virtual void removeChild(Widget*) OVERRIDE;
378
379    // This function exists for ports that need to handle wheel events manually.
380    // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
381    // we need this function in order to do the scroll ourselves.
382    bool wheelEvent(const PlatformWheelEvent&);
383
384    void setScrollingPerformanceLoggingEnabled(bool);
385
386    // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
387    // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
388    // FrameViews in the page cache, but FrameView::pagination() only affects the current
389    // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
390    // it will return Page::pagination() since currently there are no callers that need to
391    // distinguish between the two.
392    const Pagination& pagination() const;
393    void setPagination(const Pagination&);
394
395    bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
396    void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
397
398#if ENABLE(CSS_FILTERS)
399    void setHasSoftwareFilters(bool hasSoftwareFilters) { m_hasSoftwareFilters = hasSoftwareFilters; }
400    bool hasSoftwareFilters() const { return m_hasSoftwareFilters; }
401#endif
402#if ENABLE(CSS_DEVICE_ADAPTATION)
403    IntSize initialViewportSize() const { return m_initialViewportSize; }
404    void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
405#endif
406
407    virtual bool isActive() const OVERRIDE;
408
409#if ENABLE(RUBBER_BANDING)
410    GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
411    GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
412#endif
413
414    virtual int headerHeight() const OVERRIDE { return m_headerHeight; }
415    void setHeaderHeight(int);
416    virtual int footerHeight() const OVERRIDE { return m_footerHeight; }
417    void setFooterHeight(int);
418
419    virtual void willStartLiveResize() OVERRIDE;
420    virtual void willEndLiveResize() OVERRIDE;
421
422#if USE(ACCELERATED_COMPOSITING)
423    virtual bool scrollbarAnimationsAreSuppressed() const OVERRIDE;
424#endif
425
426    void addPaintPendingMilestones(LayoutMilestones);
427    void firePaintRelatedMilestones();
428    LayoutMilestones milestonesPendingPaint() const { return m_milestonesPendingPaint; }
429
430    bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; }
431    void setVisualUpdatesAllowedByClient(bool);
432
433    void setScrollPinningBehavior(ScrollPinningBehavior);
434
435protected:
436    virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
437    virtual void scrollContentsSlowPath(const IntRect& updateRect);
438
439    void repaintSlowRepaintObjects();
440
441    virtual bool isVerticalDocument() const;
442    virtual bool isFlippedDocument() const;
443
444private:
445    explicit FrameView(Frame*);
446
447    void reset();
448    void init();
449
450    virtual bool isFrameView() const OVERRIDE { return true; }
451
452    friend class RenderWidget;
453    bool useSlowRepaints(bool considerOverlap = true) const;
454    bool useSlowRepaintsIfNotOverlapped() const;
455    void updateCanBlitOnScrollRecursively();
456    bool contentsInCompositedLayer() const;
457
458    bool shouldUpdateFixedElementsAfterScrolling();
459
460    void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode);
461    void applyPaginationToViewport();
462
463    void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
464
465    void paintControlTints();
466
467    void forceLayoutParentViewIfNeeded();
468    void performPostLayoutTasks();
469    void autoSizeIfEnabled();
470
471    virtual void repaintContentRectangle(const IntRect&, bool immediate);
472    virtual void contentsResized() OVERRIDE;
473    virtual void visibleContentsResized();
474
475    virtual void delegatesScrollingDidChange();
476
477    // Override ScrollView methods to do point conversion via renderers, in order to
478    // take transforms into account.
479    virtual IntRect convertToContainingView(const IntRect&) const OVERRIDE;
480    virtual IntRect convertFromContainingView(const IntRect&) const OVERRIDE;
481    virtual IntPoint convertToContainingView(const IntPoint&) const OVERRIDE;
482    virtual IntPoint convertFromContainingView(const IntPoint&) const OVERRIDE;
483
484    virtual PlatformDisplayID windowDisplayID() const OVERRIDE;
485
486    // ScrollableArea interface
487    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
488    virtual void getTickmarks(Vector<IntRect>&) const OVERRIDE;
489    virtual void scrollTo(const IntSize&) OVERRIDE;
490    virtual void setVisibleScrollerThumbRect(const IntRect&) OVERRIDE;
491    virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE;
492    virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
493    virtual bool scrollAnimatorEnabled() const OVERRIDE;
494#if USE(ACCELERATED_COMPOSITING)
495    virtual bool usesCompositedScrolling() const OVERRIDE;
496    virtual GraphicsLayer* layerForScrolling() const OVERRIDE;
497    virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
498    virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
499    virtual GraphicsLayer* layerForScrollCorner() const OVERRIDE;
500#if ENABLE(RUBBER_BANDING)
501    virtual GraphicsLayer* layerForOverhangAreas() const OVERRIDE;
502#endif
503#endif
504
505    // Override scrollbar notifications to update the AXObject cache.
506    virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) OVERRIDE;
507    virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) OVERRIDE;
508
509    void sendResizeEventIfNeeded();
510
511    void updateScrollableAreaSet();
512
513    virtual void notifyPageThatContentAreaWillPaint() const;
514
515    bool shouldUseLoadTimeDeferredRepaintDelay() const;
516    void deferredRepaintTimerFired(Timer<FrameView>*);
517    void doDeferredRepaints();
518    void updateDeferredRepaintDelayAfterRepaint();
519    double adjustedDeferredRepaintDelay() const;
520
521    bool updateWidgets();
522    void updateWidget(RenderObject*);
523    void updateEmbeddedObjectsTimerFired(Timer<FrameView>*);
524    void scrollToAnchor();
525    void scrollPositionChanged();
526
527    bool hasCustomScrollbars() const;
528
529    virtual void updateScrollCorner();
530
531    FrameView* parentFrameView() const;
532
533    bool doLayoutWithFrameFlattening(bool allowSubtree);
534
535    virtual AXObjectCache* axObjectCache() const;
536    void notifyWidgetsInAllFrames(WidgetNotification);
537    void removeFromAXObjectCache();
538
539    static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
540
541    LayoutSize m_size;
542    LayoutSize m_margins;
543
544    typedef HashSet<RenderObject*> RenderObjectSet;
545    OwnPtr<RenderObjectSet> m_widgetUpdateSet;
546    RefPtr<Frame> m_frame;
547
548    OwnPtr<RenderObjectSet> m_slowRepaintObjects;
549
550    bool m_doFullRepaint;
551
552    bool m_canHaveScrollbars;
553    bool m_cannotBlitToWindow;
554    bool m_isOverlapped;
555    bool m_contentIsOpaque;
556
557    int m_borderX;
558    int m_borderY;
559
560    Timer<FrameView> m_layoutTimer;
561    bool m_delayedLayout;
562    RenderObject* m_layoutRoot;
563
564    bool m_layoutSchedulingEnabled;
565    bool m_inLayout;
566    bool m_doingPreLayoutStyleUpdate;
567    bool m_inSynchronousPostLayout;
568    int m_layoutCount;
569    unsigned m_nestedLayoutCount;
570    Timer<FrameView> m_postLayoutTasksTimer;
571    Timer<FrameView> m_updateEmbeddedObjectsTimer;
572    bool m_firstLayoutCallbackPending;
573
574    bool m_firstLayout;
575    bool m_isTransparent;
576    Color m_baseBackgroundColor;
577    IntSize m_lastViewportSize;
578    float m_lastZoomFactor;
579
580    String m_mediaType;
581    String m_mediaTypeWhenNotPrinting;
582
583    bool m_overflowStatusDirty;
584    bool m_horizontalOverflow;
585    bool m_verticalOverflow;
586    RenderObject* m_viewportRenderer;
587
588    Pagination m_pagination;
589
590    bool m_wasScrolledByUser;
591    bool m_inProgrammaticScroll;
592    bool m_safeToPropagateScrollToParent;
593
594    unsigned m_deferringRepaints;
595    unsigned m_repaintCount;
596    Vector<LayoutRect> m_repaintRects;
597    Timer<FrameView> m_deferredRepaintTimer;
598    double m_deferredRepaintDelay;
599    double m_lastPaintTime;
600
601    unsigned m_disableRepaints;
602
603    bool m_isTrackingRepaints; // Used for testing.
604    Vector<IntRect> m_trackedRepaintRects;
605
606    bool m_shouldUpdateWhileOffscreen;
607
608    unsigned m_deferSetNeedsLayouts;
609    bool m_setNeedsLayoutWasDeferred;
610
611    RefPtr<Node> m_nodeToDraw;
612    PaintBehavior m_paintBehavior;
613    bool m_isPainting;
614
615    unsigned m_visuallyNonEmptyCharacterCount;
616    unsigned m_visuallyNonEmptyPixelCount;
617    bool m_isVisuallyNonEmpty;
618    bool m_firstVisuallyNonEmptyLayoutCallbackPending;
619
620    RefPtr<Node> m_maintainScrollPositionAnchor;
621
622    // Renderer to hold our custom scroll corner.
623    RenderScrollbarPart* m_scrollCorner;
624
625    // If true, automatically resize the frame view around its content.
626    bool m_shouldAutoSize;
627    bool m_inAutoSize;
628    // True if autosize has been run since m_shouldAutoSize was set.
629    bool m_didRunAutosize;
630    // The lower bound on the size when autosizing.
631    IntSize m_minAutoSize;
632    // The upper bound on the size when autosizing.
633    IntSize m_maxAutoSize;
634    // The fixed height to resize the view to after autosizing is complete.
635    int m_autoSizeFixedMinimumHeight;
636    // The intrinsic content size decided by autosizing.
637    IntSize m_autoSizeContentSize;
638
639    OwnPtr<ScrollableAreaSet> m_scrollableAreas;
640    OwnPtr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
641
642    int m_headerHeight;
643    int m_footerHeight;
644
645    LayoutMilestones m_milestonesPendingPaint;
646
647    static double s_normalDeferredRepaintDelay;
648    static double s_initialDeferredRepaintDelayDuringLoading;
649    static double s_maxDeferredRepaintDelayDuringLoading;
650    static double s_deferredRepaintDelayIncrementDuringLoading;
651
652#if ENABLE(CSS_FILTERS)
653    bool m_hasSoftwareFilters;
654#endif
655#if ENABLE(CSS_DEVICE_ADAPTATION)
656    // Size of viewport before any UA or author styles have overridden
657    // the viewport given by the window or viewing area of the UA.
658    IntSize m_initialViewportSize;
659#endif
660
661    bool m_visualUpdatesAllowedByClient;
662
663    ScrollPinningBehavior m_scrollPinningBehavior;
664};
665
666inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
667{
668    if (m_isVisuallyNonEmpty)
669        return;
670    m_visuallyNonEmptyCharacterCount += count;
671    // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout.
672    // The first few hundred characters rarely contain the interesting content of the page.
673    static const unsigned visualCharacterThreshold = 200;
674    if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
675        setIsVisuallyNonEmpty();
676}
677
678inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
679{
680    if (m_isVisuallyNonEmpty)
681        return;
682    m_visuallyNonEmptyPixelCount += size.width() * size.height();
683    // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout
684    static const unsigned visualPixelThreshold = 32 * 32;
685    if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
686        setIsVisuallyNonEmpty();
687}
688
689inline int FrameView::mapFromLayoutToCSSUnits(LayoutUnit value)
690{
691    return value / (m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
692}
693
694inline LayoutUnit FrameView::mapFromCSSToLayoutUnits(int value)
695{
696    return value * m_frame->pageZoomFactor() * m_frame->frameScaleFactor();
697}
698
699inline FrameView* toFrameView(Widget* widget)
700{
701    ASSERT(!widget || widget->isFrameView());
702    return static_cast<FrameView*>(widget);
703}
704
705inline const FrameView* toFrameView(const Widget* widget)
706{
707    ASSERT(!widget || widget->isFrameView());
708    return static_cast<const FrameView*>(widget);
709}
710
711// This will catch anyone doing an unnecessary cast.
712void toFrameView(const FrameView*);
713
714} // namespace WebCore
715
716#endif // FrameView_h
717