Home | History | Annotate | Download | only in page
      1 /*
      2    Copyright (C) 1997 Martin Jones (mjones (at) kde.org)
      3              (C) 1998 Waldo Bastian (bastian (at) kde.org)
      4              (C) 1998, 1999 Torben Weis (weis (at) kde.org)
      5              (C) 1999 Lars Knoll (knoll (at) kde.org)
      6              (C) 1999 Antti Koivisto (koivisto (at) 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/page/AdjustViewSizeOrNot.h"
     29 #include "core/page/Frame.h"
     30 #include "core/platform/ScrollView.h"
     31 #include "core/platform/graphics/Color.h"
     32 #include "core/platform/graphics/LayoutRect.h"
     33 #include "core/rendering/Pagination.h"
     34 #include "core/rendering/PaintPhase.h"
     35 #include "wtf/Forward.h"
     36 #include "wtf/OwnPtr.h"
     37 #include "wtf/text/WTFString.h"
     38 
     39 namespace WebCore {
     40 
     41 class Element;
     42 class Event;
     43 class FloatSize;
     44 class FrameActionScheduler;
     45 class KURL;
     46 class Node;
     47 class Page;
     48 class RenderBox;
     49 class RenderEmbeddedObject;
     50 class RenderLayer;
     51 class RenderObject;
     52 class RenderScrollbarPart;
     53 class RenderStyle;
     54 
     55 Pagination::Mode paginationModeForRenderStyle(RenderStyle*);
     56 
     57 typedef unsigned long long DOMTimeStamp;
     58 
     59 class FrameView : public ScrollView {
     60 public:
     61     friend class RenderView;
     62     friend class Internals;
     63 
     64     static PassRefPtr<FrameView> create(Frame*);
     65     static PassRefPtr<FrameView> create(Frame*, const IntSize& initialSize);
     66 
     67     virtual ~FrameView();
     68 
     69     virtual HostWindow* hostWindow() const;
     70 
     71     virtual void invalidateRect(const IntRect&);
     72     virtual void setFrameRect(const IntRect&);
     73 
     74     virtual bool scheduleAnimation();
     75 
     76     Frame* frame() const { return m_frame.get(); }
     77     void clearFrame();
     78 
     79     RenderView* renderView() const { return m_frame ? m_frame->contentRenderer() : 0; }
     80 
     81     int mapFromLayoutToCSSUnits(LayoutUnit);
     82     LayoutUnit mapFromCSSToLayoutUnits(int);
     83 
     84     LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default
     85     LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default
     86     void setMarginWidth(LayoutUnit);
     87     void setMarginHeight(LayoutUnit);
     88 
     89     virtual void setCanHaveScrollbars(bool);
     90     void updateCanHaveScrollbars();
     91 
     92     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
     93 
     94     virtual void setContentsSize(const IntSize&);
     95 
     96     void layout(bool allowSubtree = true);
     97     bool didFirstLayout() const;
     98     void layoutTimerFired(Timer<FrameView>*);
     99     void scheduleRelayout();
    100     void scheduleRelayoutOfSubtree(RenderObject*);
    101     void unscheduleRelayout();
    102     bool layoutPending() const;
    103     bool isInLayout() const { return m_inLayout; }
    104 
    105     void layoutLazyBlocks();
    106 
    107     RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
    108     void clearLayoutRoot() { m_layoutRoot = 0; }
    109     int layoutCount() const { return m_layoutCount; }
    110 
    111     bool needsLayout() const;
    112     void setNeedsLayout();
    113     void setViewportConstrainedObjectsNeedLayout();
    114 
    115     bool needsFullRepaint() const { return m_doFullRepaint; }
    116 
    117     void serviceScriptedAnimations(double monotonicAnimationStartTime);
    118 
    119     void updateCompositingLayersAfterStyleChange();
    120     void updateCompositingLayersAfterLayout();
    121 
    122     bool hasCompositedContent() const;
    123     bool isEnclosedInCompositingLayer() const;
    124 
    125     // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
    126     // a faithful representation of the content.
    127     bool isSoftwareRenderable() const;
    128 
    129     void resetScrollbars();
    130     void prepareForDetach();
    131     void detachCustomScrollbars();
    132     virtual void recalculateScrollbarOverlayStyle();
    133 
    134     void clear();
    135 
    136     bool isTransparent() const;
    137     void setTransparent(bool isTransparent);
    138 
    139     // True if the FrameView is not transparent, and the base background color is opaque.
    140     bool hasOpaqueBackground() const;
    141 
    142     Color baseBackgroundColor() const;
    143     void setBaseBackgroundColor(const StyleColor&);
    144     void updateBackgroundRecursively(const StyleColor&, bool);
    145 
    146     bool shouldUpdateWhileOffscreen() const;
    147     void setShouldUpdateWhileOffscreen(bool);
    148     bool shouldUpdate() const;
    149 
    150     void adjustViewSize();
    151 
    152     virtual IntRect windowClipRect(bool clipToContents = true) const;
    153     IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
    154 
    155     virtual IntRect windowResizerRect() const;
    156 
    157     virtual float visibleContentScaleFactor() const OVERRIDE { return m_visibleContentScaleFactor; }
    158     void setVisibleContentScaleFactor(float);
    159 
    160     virtual void setScrollPosition(const IntPoint&) OVERRIDE;
    161     virtual void repaintFixedElementsAfterScrolling();
    162     virtual void updateFixedElementsAfterScrolling();
    163     virtual bool shouldRubberBandInDirection(ScrollDirection) const;
    164     virtual bool requestScrollPositionUpdate(const IntPoint&) OVERRIDE;
    165     virtual bool isRubberBandInProgress() const OVERRIDE;
    166     void setScrollPositionNonProgrammatically(const IntPoint&);
    167 
    168     // This is different than visibleContentRect() in that it ignores negative (or overly positive)
    169     // offsets from rubber-banding, and it takes zooming into account.
    170     LayoutRect viewportConstrainedVisibleContentRect() const;
    171 
    172     AtomicString mediaType() const;
    173     void setMediaType(const AtomicString&);
    174     void adjustMediaTypeForPrinting(bool printing);
    175 
    176     void setCannotBlitToWindow();
    177     void setIsOverlapped(bool);
    178     bool isOverlapped() const { return m_isOverlapped; }
    179     bool isOverlappedIncludingAncestors() const;
    180     void setContentIsOpaque(bool);
    181 
    182     void addSlowRepaintObject();
    183     void removeSlowRepaintObject();
    184     bool hasSlowRepaintObjects() const { return m_slowRepaintObjectCount; }
    185 
    186     // Includes fixed- and sticky-position objects.
    187     typedef HashSet<RenderObject*> ViewportConstrainedObjectSet;
    188     void addViewportConstrainedObject(RenderObject*);
    189     void removeViewportConstrainedObject(RenderObject*);
    190     const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
    191     bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
    192 
    193     void beginDeferredRepaints();
    194     void endDeferredRepaints();
    195     void handleLoadCompleted();
    196     void flushDeferredRepaints();
    197     void startDeferredRepaintTimer(double delay);
    198     void resetDeferredRepaintDelay();
    199 
    200     void beginDisableRepaints();
    201     void endDisableRepaints();
    202     bool repaintsDisabled() { return m_disableRepaints > 0; }
    203 
    204     void updateAnnotatedRegions();
    205     void updateControlTints();
    206 
    207     void restoreScrollbar();
    208 
    209     void scheduleEvent(PassRefPtr<Event>, PassRefPtr<Node>);
    210     void pauseScheduledEvents();
    211     void resumeScheduledEvents();
    212     void postLayoutTimerFired(Timer<FrameView>*);
    213 
    214     bool wasScrolledByUser() const;
    215     void setWasScrolledByUser(bool);
    216 
    217     bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
    218     void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }
    219 
    220     void addWidgetToUpdate(RenderObject*);
    221     void removeWidgetToUpdate(RenderObject*);
    222 
    223     virtual void paintContents(GraphicsContext*, const IntRect& damageRect);
    224     void setPaintBehavior(PaintBehavior);
    225     PaintBehavior paintBehavior() const;
    226     bool isPainting() const;
    227     bool hasEverPainted() const { return m_lastPaintTime; }
    228     void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
    229     void setNodeToDraw(Node*);
    230 
    231     virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
    232     virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
    233     virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) OVERRIDE;
    234 
    235     StyleColor documentBackgroundColor() const;
    236 
    237     static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
    238 
    239     void updateLayoutAndStyleIfNeededRecursive();
    240 
    241     void incrementVisuallyNonEmptyCharacterCount(unsigned);
    242     void incrementVisuallyNonEmptyPixelCount(const IntSize&);
    243     void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; }
    244     bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
    245     void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
    246 
    247     void forceLayout(bool allowSubtree = false);
    248     void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
    249 
    250     bool scrollToFragment(const KURL&);
    251     bool scrollToAnchor(const String&);
    252     void maintainScrollPositionAtAnchor(Node*);
    253     void scrollElementToRect(Element*, const IntRect&);
    254 
    255     // Methods to convert points and rects between the coordinate space of the renderer, and this view.
    256     virtual IntRect convertFromRenderer(const RenderObject*, const IntRect&) const;
    257     virtual IntRect convertToRenderer(const RenderObject*, const IntRect&) const;
    258     virtual IntPoint convertFromRenderer(const RenderObject*, const IntPoint&) const;
    259     virtual IntPoint convertToRenderer(const RenderObject*, const IntPoint&) const;
    260 
    261     bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
    262 
    263     bool isScrollable();
    264 
    265     enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
    266     void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
    267 
    268     // Normal delay
    269     static void setRepaintThrottlingDeferredRepaintDelay(double p);
    270     // Negative value would mean that first few repaints happen without a delay
    271     static void setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(double p);
    272     // The delay grows on each repaint to this maximum value
    273     static void setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(double p);
    274     // On each repaint the delay increses by this amount
    275     static void setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(double p);
    276 
    277     virtual IntPoint lastKnownMousePosition() const;
    278 
    279     virtual bool scrollbarsCanBeActive() const OVERRIDE;
    280 
    281     // FIXME: Remove this method once plugin loading is decoupled from layout.
    282     void flushAnyPendingPostLayoutTasks();
    283 
    284     virtual bool shouldSuspendScrollAnimations() const;
    285     virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
    286 
    287     void setAnimatorsAreActive();
    288 
    289     RenderBox* embeddedContentBox() const;
    290 
    291     void setTracksRepaints(bool);
    292     bool isTrackingRepaints() const { return m_isTrackingRepaints; }
    293     void resetTrackedRepaints();
    294     const Vector<IntRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
    295     String trackedRepaintRectsAsText() const;
    296 
    297     typedef HashSet<ScrollableArea*> ScrollableAreaSet;
    298     // Returns whether the scrollable area has just been newly added.
    299     bool addScrollableArea(ScrollableArea*);
    300     // Returns whether the scrollable area has just been removed.
    301     bool removeScrollableArea(ScrollableArea*);
    302     bool containsScrollableArea(ScrollableArea*) const;
    303     const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
    304 
    305     // With CSS style "resize:" enabled, a little resizer handle will appear at the bottom
    306     // right of the object. We keep track of these resizer areas for checking if touches
    307     // (implemented using Scroll gesture) are targeting the resizer.
    308     typedef HashSet<RenderLayer*> ResizerAreaSet;
    309     void addResizerArea(RenderLayer*);
    310     void removeResizerArea(RenderLayer*);
    311     const ResizerAreaSet* resizerAreas() const { return m_resizerAreas.get(); }
    312 
    313     virtual void removeChild(Widget*) OVERRIDE;
    314 
    315     // This function exists for ports that need to handle wheel events manually.
    316     // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
    317     // we need this function in order to do the scroll ourselves.
    318     bool wheelEvent(const PlatformWheelEvent&);
    319 
    320     // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
    321     // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
    322     // FrameViews in the page cache, but FrameView::pagination() only affects the current
    323     // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
    324     // it will return Page::pagination() since currently there are no callers that need to
    325     // distinguish between the two.
    326     const Pagination& pagination() const;
    327     void setPagination(const Pagination&);
    328 
    329     bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
    330     void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
    331 
    332     void setHasSoftwareFilters(bool hasSoftwareFilters) { m_hasSoftwareFilters = hasSoftwareFilters; }
    333     bool hasSoftwareFilters() const { return m_hasSoftwareFilters; }
    334 
    335     virtual bool isActive() const OVERRIDE;
    336 
    337     // DEPRECATED: Use viewportConstrainedVisibleContentRect() instead.
    338     IntSize scrollOffsetForFixedPosition() const;
    339 
    340 protected:
    341     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
    342     virtual void scrollContentsSlowPath(const IntRect& updateRect);
    343 
    344     virtual bool isVerticalDocument() const;
    345     virtual bool isFlippedDocument() const;
    346 
    347 private:
    348     explicit FrameView(Frame*);
    349 
    350     void reset();
    351     void init();
    352 
    353     virtual bool isFrameView() const OVERRIDE { return true; }
    354 
    355     friend class RenderWidget;
    356     bool useSlowRepaints(bool considerOverlap = true) const;
    357     bool useSlowRepaintsIfNotOverlapped() const;
    358     void updateCanBlitOnScrollRecursively();
    359     bool contentsInCompositedLayer() const;
    360 
    361     void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode);
    362     void applyPaginationToViewport();
    363 
    364     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
    365 
    366     void paintControlTints();
    367 
    368     void forceLayoutParentViewIfNeeded();
    369     void performPostLayoutTasks();
    370     void autoSizeIfEnabled();
    371 
    372     virtual void repaintContentRectangle(const IntRect&);
    373     virtual void contentsResized() OVERRIDE;
    374     virtual void visibleContentsResized();
    375 
    376     // Override ScrollView methods to do point conversion via renderers, in order to
    377     // take transforms into account.
    378     virtual IntRect convertToContainingView(const IntRect&) const OVERRIDE;
    379     virtual IntRect convertFromContainingView(const IntRect&) const OVERRIDE;
    380     virtual IntPoint convertToContainingView(const IntPoint&) const OVERRIDE;
    381     virtual IntPoint convertFromContainingView(const IntPoint&) const OVERRIDE;
    382 
    383     // ScrollableArea interface
    384     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
    385     virtual void getTickmarks(Vector<IntRect>&) const OVERRIDE;
    386     virtual void scrollTo(const IntSize&) OVERRIDE;
    387     virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE;
    388     virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
    389     virtual bool scrollAnimatorEnabled() const OVERRIDE;
    390     virtual bool usesCompositedScrolling() const OVERRIDE;
    391     virtual GraphicsLayer* layerForScrolling() const OVERRIDE;
    392     virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
    393     virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
    394     virtual GraphicsLayer* layerForScrollCorner() const OVERRIDE;
    395 #if ENABLE(RUBBER_BANDING)
    396     virtual GraphicsLayer* layerForOverhangAreas() const OVERRIDE;
    397 #endif
    398 
    399     void updateScrollableAreaSet();
    400 
    401     virtual void notifyPageThatContentAreaWillPaint() const;
    402 
    403     bool shouldUseLoadTimeDeferredRepaintDelay() const;
    404     void deferredRepaintTimerFired(Timer<FrameView>*);
    405     void doDeferredRepaints();
    406     void updateDeferredRepaintDelayAfterRepaint();
    407     double adjustedDeferredRepaintDelay() const;
    408 
    409     bool updateWidgets();
    410     void updateWidget(RenderObject*);
    411     void scrollToAnchor();
    412     void scrollPositionChanged();
    413 
    414     bool hasCustomScrollbars() const;
    415 
    416     virtual void updateScrollCorner();
    417 
    418     FrameView* parentFrameView() const;
    419 
    420     virtual AXObjectCache* axObjectCache() const;
    421     void removeFromAXObjectCache();
    422 
    423     static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
    424 
    425     LayoutSize m_size;
    426     LayoutSize m_margins;
    427 
    428     typedef HashSet<RenderObject*> RenderObjectSet;
    429     OwnPtr<RenderObjectSet> m_widgetUpdateSet;
    430     RefPtr<Frame> m_frame;
    431 
    432     bool m_doFullRepaint;
    433 
    434     bool m_canHaveScrollbars;
    435     bool m_cannotBlitToWindow;
    436     bool m_isOverlapped;
    437     bool m_contentIsOpaque;
    438     unsigned m_slowRepaintObjectCount;
    439     int m_borderX;
    440     int m_borderY;
    441 
    442     Timer<FrameView> m_layoutTimer;
    443     bool m_delayedLayout;
    444     RenderObject* m_layoutRoot;
    445 
    446     bool m_layoutSchedulingEnabled;
    447     bool m_inLayout;
    448     bool m_doingPreLayoutStyleUpdate;
    449     bool m_inSynchronousPostLayout;
    450     int m_layoutCount;
    451     unsigned m_nestedLayoutCount;
    452     Timer<FrameView> m_postLayoutTasksTimer;
    453     bool m_firstLayoutCallbackPending;
    454 
    455     bool m_firstLayout;
    456     bool m_isTransparent;
    457     Color m_baseBackgroundColor;
    458     IntSize m_lastViewportSize;
    459     float m_lastZoomFactor;
    460 
    461     AtomicString m_mediaType;
    462     AtomicString m_mediaTypeWhenNotPrinting;
    463 
    464     OwnPtr<FrameActionScheduler> m_actionScheduler;
    465 
    466     bool m_overflowStatusDirty;
    467     bool m_horizontalOverflow;
    468     bool m_verticalOverflow;
    469     RenderObject* m_viewportRenderer;
    470 
    471     Pagination m_pagination;
    472 
    473     bool m_wasScrolledByUser;
    474     bool m_inProgrammaticScroll;
    475     bool m_safeToPropagateScrollToParent;
    476 
    477     unsigned m_deferringRepaints;
    478     unsigned m_repaintCount;
    479     Vector<LayoutRect> m_repaintRects;
    480     Timer<FrameView> m_deferredRepaintTimer;
    481     double m_deferredRepaintDelay;
    482     double m_lastPaintTime;
    483 
    484     unsigned m_disableRepaints;
    485 
    486     bool m_isTrackingRepaints; // Used for testing.
    487     Vector<IntRect> m_trackedRepaintRects;
    488 
    489     bool m_shouldUpdateWhileOffscreen;
    490 
    491     unsigned m_deferSetNeedsLayouts;
    492     bool m_setNeedsLayoutWasDeferred;
    493 
    494     RefPtr<Node> m_nodeToDraw;
    495     PaintBehavior m_paintBehavior;
    496     bool m_isPainting;
    497 
    498     unsigned m_visuallyNonEmptyCharacterCount;
    499     unsigned m_visuallyNonEmptyPixelCount;
    500     bool m_isVisuallyNonEmpty;
    501     bool m_firstVisuallyNonEmptyLayoutCallbackPending;
    502 
    503     RefPtr<Node> m_maintainScrollPositionAnchor;
    504 
    505     // Renderer to hold our custom scroll corner.
    506     RenderScrollbarPart* m_scrollCorner;
    507 
    508     // If true, automatically resize the frame view around its content.
    509     bool m_shouldAutoSize;
    510     bool m_inAutoSize;
    511     // True if autosize has been run since m_shouldAutoSize was set.
    512     bool m_didRunAutosize;
    513     // The lower bound on the size when autosizing.
    514     IntSize m_minAutoSize;
    515     // The upper bound on the size when autosizing.
    516     IntSize m_maxAutoSize;
    517 
    518     OwnPtr<ScrollableAreaSet> m_scrollableAreas;
    519     OwnPtr<ResizerAreaSet> m_resizerAreas;
    520     OwnPtr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
    521 
    522     static double s_normalDeferredRepaintDelay;
    523     static double s_initialDeferredRepaintDelayDuringLoading;
    524     static double s_maxDeferredRepaintDelayDuringLoading;
    525     static double s_deferredRepaintDelayIncrementDuringLoading;
    526 
    527     bool m_hasSoftwareFilters;
    528 
    529     float m_visibleContentScaleFactor;
    530 };
    531 
    532 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
    533 {
    534     if (m_isVisuallyNonEmpty)
    535         return;
    536     m_visuallyNonEmptyCharacterCount += count;
    537     // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout.
    538     // The first few hundred characters rarely contain the interesting content of the page.
    539     static const unsigned visualCharacterThreshold = 200;
    540     if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
    541         setIsVisuallyNonEmpty();
    542 }
    543 
    544 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
    545 {
    546     if (m_isVisuallyNonEmpty)
    547         return;
    548     m_visuallyNonEmptyPixelCount += size.width() * size.height();
    549     // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout
    550     static const unsigned visualPixelThreshold = 32 * 32;
    551     if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
    552         setIsVisuallyNonEmpty();
    553 }
    554 
    555 inline int FrameView::mapFromLayoutToCSSUnits(LayoutUnit value)
    556 {
    557     return value / m_frame->pageZoomFactor();
    558 }
    559 
    560 inline LayoutUnit FrameView::mapFromCSSToLayoutUnits(int value)
    561 {
    562     return value * m_frame->pageZoomFactor();
    563 }
    564 
    565 inline FrameView* toFrameView(Widget* widget)
    566 {
    567     ASSERT(!widget || widget->isFrameView());
    568     return static_cast<FrameView*>(widget);
    569 }
    570 
    571 inline const FrameView* toFrameView(const Widget* widget)
    572 {
    573     ASSERT(!widget || widget->isFrameView());
    574     return static_cast<const FrameView*>(widget);
    575 }
    576 
    577 // This will catch anyone doing an unnecessary cast.
    578 void toFrameView(const FrameView*);
    579 
    580 } // namespace WebCore
    581 
    582 #endif // FrameView_h
    583