FrameView.h 28 KB
Newer Older
darin's avatar
darin committed
1
/*
kocienda's avatar
kocienda committed
2 3 4 5 6
   Copyright (C) 1997 Martin Jones (mjones@kde.org)
             (C) 1998 Waldo Bastian (bastian@kde.org)
             (C) 1998, 1999 Torben Weis (weis@kde.org)
             (C) 1999 Lars Knoll (knoll@kde.org)
             (C) 1999 Antti Koivisto (koivisto@kde.org)
7
   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
kocienda's avatar
kocienda committed
8 9 10 11 12 13 14 15 16 17 18 19 20

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
ddkilzer's avatar
ddkilzer committed
21 22
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
kocienda's avatar
kocienda committed
23 24
*/

25 26
#ifndef FrameView_h
#define FrameView_h
kocienda's avatar
kocienda committed
27

28 29
#include "AdjustViewSizeOrNot.h"
#include "Color.h"
30
#include "LayoutMilestones.h"
31
#include "LayoutRect.h"
32
#include "Pagination.h"
33
#include "PaintPhase.h"
34
#include "RenderPtr.h"
35
#include "ScrollView.h"
darin's avatar
darin committed
36
#include <wtf/Forward.h>
37
#include <wtf/ListHashSet.h>
bdakin's avatar
bdakin committed
38
#include <wtf/OwnPtr.h>
39
#include <wtf/text/WTFString.h>
darin's avatar
darin committed
40

darin's avatar
darin committed
41
namespace WebCore {
kocienda's avatar
kocienda committed
42

43
class AXObjectCache;
44
class Element;
45
class FloatSize;
46 47
class Frame;
class HTMLFrameOwnerElement;
darin@apple.com's avatar
darin@apple.com committed
48
class URL;
darin's avatar
darin committed
49
class Node;
50
class Page;
51
class RenderBox;
52
class RenderElement;
53
class RenderEmbeddedObject;
54
class RenderLayer;
darin's avatar
darin committed
55
class RenderObject;
56
class RenderScrollbarPart;
57
class RenderStyle;
58
class RenderView;
59
class RenderWidget;
60

61
Pagination::Mode paginationModeForRenderStyle(const RenderStyle&);
62

63 64
typedef unsigned long long DOMTimeStamp;

65
class FrameView final : public ScrollView {
kocienda's avatar
kocienda committed
66
public:
67
    friend class RenderView;
68
    friend class Internals;
69

70 71
    static PassRefPtr<FrameView> create(Frame&);
    static PassRefPtr<FrameView> create(Frame&, const IntSize& initialSize);
72

73
    virtual ~FrameView();
kocienda's avatar
kocienda committed
74

75
    virtual HostWindow* hostWindow() const override;
hyatt@apple.com's avatar
hyatt@apple.com committed
76
    
77 78
    virtual void invalidateRect(const IntRect&) override;
    virtual void setFrameRect(const IntRect&) override;
79

80
#if ENABLE(REQUEST_ANIMATION_FRAME)
81
    virtual bool scheduleAnimation() override;
82
#endif
83

84
    Frame& frame() const { return *m_frame; }
kocienda's avatar
kocienda committed
85

86
    RenderView* renderView() const;
87

88 89
    int mapFromLayoutToCSSUnits(LayoutUnit) const;
    LayoutUnit mapFromCSSToLayoutUnits(int) const;
90

91 92 93 94
    LayoutUnit marginWidth() const { return m_margins.width(); } // -1 means default
    LayoutUnit marginHeight() const { return m_margins.height(); } // -1 means default
    void setMarginWidth(LayoutUnit);
    void setMarginHeight(LayoutUnit);
kocienda's avatar
kocienda committed
95

96
    virtual void setCanHaveScrollbars(bool) override;
97 98
    void updateCanHaveScrollbars();

99
    virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation) override;
100

101
    virtual bool avoidScrollbarCreation() const override;
102

103
    virtual void setContentsSize(const IntSize&) override;
104

adele's avatar
adele committed
105
    void layout(bool allowSubtree = true);
darin's avatar
darin committed
106
    bool didFirstLayout() const;
107
    void layoutTimerFired(Timer<FrameView>&);
darin's avatar
darin committed
108
    void scheduleRelayout();
109
    void scheduleRelayoutOfSubtree(RenderElement&);
darin's avatar
darin committed
110 111
    void unscheduleRelayout();
    bool layoutPending() const;
112
    bool isInLayout() const { return m_layoutPhase == InLayout; }
kocienda's avatar
kocienda committed
113

mitz@apple.com's avatar
mitz@apple.com committed
114
    RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
115
    void clearLayoutRoot() { m_layoutRoot = nullptr; }
116
    int layoutCount() const { return m_layoutCount; }
117

118 119
    bool needsLayout() const;
    void setNeedsLayout();
120
    void setViewportConstrainedObjectsNeedLayout();
121

122
    bool needsFullRepaint() const { return m_needsFullRepaint; }
123

124 125 126 127 128 129 130 131 132 133
    bool renderedCharactersExceed(unsigned threshold);

#if PLATFORM(IOS)
    bool useCustomFixedPositionLayoutRect() const { return m_useCustomFixedPositionLayoutRect; }
    void setUseCustomFixedPositionLayoutRect(bool);
    IntRect customFixedPositionLayoutRect() const { return m_customFixedPositionLayoutRect; }
    void setCustomFixedPositionLayoutRect(const IntRect&);
    bool updateFixedPositionLayoutRect();
#endif

134
#if ENABLE(REQUEST_ANIMATION_FRAME)
135
    void serviceScriptedAnimations(double monotonicAnimationStartTime);
136 137
#endif

138
#if USE(ACCELERATED_COMPOSITING)
139 140
    void updateCompositingLayersAfterStyleChange();
    void updateCompositingLayersAfterLayout();
141
    bool flushCompositingStateForThisFrame(Frame* rootFrameForFlush);
142

143 144 145
    void clearBackingStores();
    void restoreBackingStores();

146 147 148
    // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
    // content rendered via the normal painting path.
    void setNeedsOneShotDrawingSynchronization();
149

150 151 152
    GraphicsLayer* graphicsLayerForPlatformWidget(PlatformWidget);
    void scheduleLayerFlushAllowingThrottling();

153
    virtual TiledBacking* tiledBacking() const override;
154 155 156 157

    // In the future when any ScrollableArea can have a node in th ScrollingTree, this should
    // become a virtual function on ScrollableArea.
    uint64_t scrollLayerID() const;
158
#endif
159

160
    bool hasCompositedContent() const;
161 162
    bool hasCompositedContentIncludingDescendants() const;
    bool hasCompositingAncestor() const;
163
    void enterCompositingMode();
164
    bool isEnclosedInCompositingLayer() const;
165

166
    // Only used with accelerated compositing, but outside the #ifdef to make linkage easier.
167 168
    // Returns true if the flush was completed.
    bool flushCompositingStateIncludingSubframes();
169

170 171 172 173
    // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives
    // a faithful representation of the content.
    bool isSoftwareRenderable() const;

174 175
    void didMoveOnscreen();
    void willMoveOffscreen();
176
    void setIsInWindow(bool);
177

ggaren's avatar
ggaren committed
178
    void resetScrollbars();
179
    void resetScrollbarsAndClearContentsSize();
180
    void prepareForDetach();
levin@chromium.org's avatar
levin@chromium.org committed
181
    void detachCustomScrollbars();
182
    void recalculateScrollbarOverlayStyle();
183

184
    void clear();
185

darin's avatar
darin committed
186 187
    bool isTransparent() const;
    void setTransparent(bool isTransparent);
188 189 190
    
    // True if the FrameView is not transparent, and the base background color is opaque.
    bool hasOpaqueBackground() const;
191

darin's avatar
darin committed
192
    Color baseBackgroundColor() const;
193
    void setBaseBackgroundColor(const Color&);
194
    void updateBackgroundRecursively(const Color&, bool);
darin's avatar
darin committed
195

196 197 198
    // extendedBackgroundRect() is in the viewport's coordinate space. 
    bool hasExtendedBackground() const;
    IntRect extendedBackgroundRect() const;
199 200 201 202
    
#if USE(ACCELERATED_COMPOSITING)
    void setBackgroundExtendsBeyondPage(bool);
#endif
203

204
    bool shouldUpdateWhileOffscreen() const;
mitz@apple.com's avatar
mitz@apple.com committed
205
    void setShouldUpdateWhileOffscreen(bool);
206
    bool shouldUpdate(bool = false) const;
mitz@apple.com's avatar
mitz@apple.com committed
207

darin's avatar
darin committed
208 209
    void adjustViewSize();
    
210
    virtual IntRect windowClipRect(bool clipToContents = true) const override;
211
    IntRect windowClipRectForFrameOwner(const HTMLFrameOwnerElement*, bool clipToLayerContents) const;
darin's avatar
darin committed
212

213
    virtual IntRect windowResizerRect() const override;
214

215
    virtual float visibleContentScaleFactor() const override;
216

217
#if USE(TILED_BACKING_STORE)
218
    virtual void setFixedVisibleContentRect(const IntRect&) override;
219
#endif
220
    virtual void setScrollPosition(const IntPoint&) override;
221
    void scrollPositionChangedViaPlatformWidget();
222 223 224 225 226 227
    virtual void updateLayerPositionsAfterScrolling() override;
    virtual void updateCompositingLayersAfterScrolling() override;
    virtual bool requestScrollPositionUpdate(const IntPoint&) override;
    virtual bool isRubberBandInProgress() const override;
    virtual IntPoint minimumScrollPosition() const override;
    virtual IntPoint maximumScrollPosition() const override;
darin's avatar
darin committed
228

229 230 231 232
    // This is different than visibleContentRect() in that it ignores negative (or overly positive)
    // offsets from rubber-banding, and it takes zooming into account. 
    LayoutRect viewportConstrainedVisibleContentRect() const;

darin's avatar
darin committed
233
    String mediaType() const;
darin's avatar
darin committed
234
    void setMediaType(const String&);
235
    void adjustMediaTypeForPrinting(bool printing);
darin's avatar
darin committed
236

237
    void setCannotBlitToWindow();
mitz@apple.com's avatar
mitz@apple.com committed
238
    void setIsOverlapped(bool);
239
    bool isOverlapped() const { return m_isOverlapped; }
240
    bool isOverlappedIncludingAncestors() const;
mitz@apple.com's avatar
mitz@apple.com committed
241
    void setContentIsOpaque(bool);
darin's avatar
darin committed
242

243 244 245
    void addSlowRepaintObject(RenderElement*);
    void removeSlowRepaintObject(RenderElement*);
    bool hasSlowRepaintObject(RenderElement* o) const { return m_slowRepaintObjects && m_slowRepaintObjects->contains(o); }
246
    bool hasSlowRepaintObjects() const { return m_slowRepaintObjects && m_slowRepaintObjects->size(); }
darin's avatar
darin committed
247

248
    // Includes fixed- and sticky-position objects.
249 250 251
    typedef HashSet<RenderElement*> ViewportConstrainedObjectSet;
    void addViewportConstrainedObject(RenderElement*);
    void removeViewportConstrainedObject(RenderElement*);
252 253
    const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
    bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
254

255 256
    // Functions for querying the current scrolled position, negating the effects of overhang
    // and adjusting for page scale.
257
    IntSize scrollOffsetForFixedPosition() const;
258
    // Static function can be called from another thread.
259
    static IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
260

261
    bool fixedElementsLayoutRelativeToFrame() const;
262

263 264
    void beginDeferredRepaints();
    void endDeferredRepaints();
265
    void handleLoadCompleted();
266
    void flushDeferredRepaints();
267
    void startDeferredRepaintTimer(double delay);
antti@apple.com's avatar
antti@apple.com committed
268
    void resetDeferredRepaintDelay();
269

270
    void updateLayerFlushThrottlingInAllFrames();
271
    void adjustTiledBackingCoverage();
272

273
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
274
    void updateAnnotatedRegions();
ddkilzer@apple.com's avatar
ddkilzer@apple.com committed
275
#endif
darin's avatar
darin committed
276
    void updateControlTints();
darin's avatar
darin committed
277

darin's avatar
darin committed
278 279
    void restoreScrollbar();

280
    void postLayoutTimerFired(Timer<FrameView>&);
darin's avatar
darin committed
281

darin's avatar
darin committed
282 283 284
    bool wasScrolledByUser() const;
    void setWasScrolledByUser(bool);

285 286 287
    bool safeToPropagateScrollToParent() const { return m_safeToPropagateScrollToParent; }
    void setSafeToPropagateScrollToParent(bool isSafe) { m_safeToPropagateScrollToParent = isSafe; }

288 289
    void addEmbeddedObjectToUpdate(RenderEmbeddedObject&);
    void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&);
bdakin's avatar
bdakin committed
290

291
    virtual void paintContents(GraphicsContext*, const IntRect& damageRect) override;
292
    void setPaintBehavior(PaintBehavior);
293
    PaintBehavior paintBehavior() const;
294
    bool isPainting() const;
295
    bool hasEverPainted() const { return m_lastPaintTime; }
296
    void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
297 298
    void setNodeToDraw(Node*);

299
    enum SelectionInSnapshot { IncludeSelection, ExcludeSelection };
300
    enum CoordinateSpaceForSnapshot { DocumentCoordinates, ViewCoordinates };
301
    void paintContentsForSnapshot(GraphicsContext*, const IntRect& imageRect, SelectionInSnapshot shouldPaintSelection, CoordinateSpaceForSnapshot);
302

303 304 305
    virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) override;
    virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect) override;
    virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) override;
306

307 308
    Color documentBackgroundColor() const;

309 310
    bool isInChildFrameWithFrameFlattening() const;

311 312
    static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
    
313
    void updateLayoutAndStyleIfNeededRecursive();
zecke's avatar
zecke committed
314

315 316
    void incrementVisuallyNonEmptyCharacterCount(unsigned);
    void incrementVisuallyNonEmptyPixelCount(const IntSize&);
317
    void updateIsVisuallyNonEmpty();
318
    bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
319
    void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
320 321
    void setAutoSizeFixedMinimumHeight(int fixedMinimumHeight);
    IntSize autoSizingIntrinsicContentSize() const { return m_autoSizeContentSize; }
weinig@apple.com's avatar
weinig@apple.com committed
322

323
    void forceLayout(bool allowSubtree = false);
324
    void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
325

326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
    // FIXME: This method is retained because of embedded WebViews in AppKit.  When a WebView is embedded inside
    // some enclosing view with auto-pagination, no call happens to resize the view.  The new pagination model
    // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially
    // resize around that view.  Auto-pagination uses the bounds of the actual view that's being printed to determine
    // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the
    // web document's bounds.
    // 
    // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets.
    // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI
    // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or
    // page size, it can't actually paginate correctly during _layoutForPrinting.
    //
    // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model,
    // but that doesn't solve the general problem of how other AppKit views could opt in to the better model.
    //
    // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD.
    void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
343

darin@apple.com's avatar
darin@apple.com committed
344
    bool scrollToFragment(const URL&);
345
    bool scrollToAnchor(const String&);
mitz@apple.com's avatar
mitz@apple.com committed
346
    void maintainScrollPositionAtAnchor(Node*);
347
    void scrollElementToRect(Element*, const IntRect&);
abarth@webkit.org's avatar
abarth@webkit.org committed
348

hyatt@apple.com's avatar
hyatt@apple.com committed
349
    // Methods to convert points and rects between the coordinate space of the renderer, and this view.
350 351 352 353
    IntRect convertFromRenderer(const RenderElement*, const IntRect&) const;
    IntRect convertToRenderer(const RenderElement*, const IntRect&) const;
    IntPoint convertFromRenderer(const RenderElement*, const IntPoint&) const;
    IntPoint convertToRenderer(const RenderElement*, const IntPoint&) const;
354

355 356
    bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }

357 358
    bool isScrollable();

359 360
    enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };
    void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy = AnyRule);
361

362 363 364 365 366 367 368 369
    // Normal delay
    static void setRepaintThrottlingDeferredRepaintDelay(double p);
    // Negative value would mean that first few repaints happen without a delay
    static void setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(double p);
    // The delay grows on each repaint to this maximum value
    static void setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(double p);
    // On each repaint the delay increses by this amount
    static void setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(double p);
370

371 372
    virtual IntPoint lastKnownMousePosition() const override;
    virtual bool isHandlingWheelEvent() const override;
373
    bool shouldSetCursor() const;
374

375 376 377
    // FIXME: Remove this method once plugin loading is decoupled from layout.
    void flushAnyPendingPostLayoutTasks();

378 379
    virtual bool shouldSuspendScrollAnimations() const override;
    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
380

381
    RenderBox* embeddedContentBox() const;
382 383 384
    
    void setTracksRepaints(bool);
    bool isTrackingRepaints() const { return m_isTrackingRepaints; }
385
    void resetTrackedRepaints();
386
    const Vector<IntRect>& trackedRepaintRects() const { return m_trackedRepaintRects; }
387
    String trackedRepaintRectsAsText() const;
388

389
    typedef HashSet<ScrollableArea*> ScrollableAreaSet;
390 391 392 393
    // Returns whether the scrollable area has just been newly added.
    bool addScrollableArea(ScrollableArea*);
    // Returns whether the scrollable area has just been removed.
    bool removeScrollableArea(ScrollableArea*);
394 395 396
    bool containsScrollableArea(ScrollableArea*) const;
    const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }

397
    virtual void removeChild(Widget*) override;
398

399 400 401 402 403
    // This function exists for ports that need to handle wheel events manually.
    // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
    // we need this function in order to do the scroll ourselves.
    bool wheelEvent(const PlatformWheelEvent&);

404 405
    void setScrollingPerformanceLoggingEnabled(bool);

406 407 408 409 410 411 412 413
    // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
    // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
    // FrameViews in the page cache, but FrameView::pagination() only affects the current
    // FrameView. FrameView::pagination() will return m_pagination if it has been set. Otherwise,
    // it will return Page::pagination() since currently there are no callers that need to
    // distinguish between the two.
    const Pagination& pagination() const;
    void setPagination(const Pagination&);
414 415 416
    
    bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
    void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
417

418 419 420 421
#if ENABLE(CSS_DEVICE_ADAPTATION)
    IntSize initialViewportSize() const { return m_initialViewportSize; }
    void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
#endif
422

423 424
    virtual bool isActive() const override;
    virtual bool updatesScrollLayerPositionOnMainThread() const override;
425

426 427 428 429 430
#if ENABLE(RUBBER_BANDING)
    GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
    GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
#endif

431
    virtual int headerHeight() const override { return m_headerHeight; }
432
    void setHeaderHeight(int);
433
    virtual int footerHeight() const override { return m_footerHeight; }
434 435
    void setFooterHeight(int);

436 437
    virtual void willStartLiveResize() override;
    virtual void willEndLiveResize() override;
438

439 440 441 442
    void addPaintPendingMilestones(LayoutMilestones);
    void firePaintRelatedMilestones();
    LayoutMilestones milestonesPendingPaint() const { return m_milestonesPendingPaint; }

443 444 445
    bool visualUpdatesAllowedByClient() const { return m_visualUpdatesAllowedByClient; }
    void setVisualUpdatesAllowedByClient(bool);

446
    void setScrollPinningBehavior(ScrollPinningBehavior);
447

448 449
    ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const;

450 451 452 453
    void updateWidgetPositions();
    void didAddWidgetToRenderTree(Widget&);
    void willRemoveWidgetFromRenderTree(Widget&);

454 455
    void addTrackedRepaintRect(const IntRect&);

456 457 458 459 460 461 462
    // exposedRect represents WebKit's understanding of what part
    // of the view is actually exposed on screen (taking into account
    // clipping by other UI elements), whereas visibleContentRect is
    // internal to WebCore and doesn't respect those things.
    void setExposedRect(FloatRect);
    FloatRect exposedRect() const { return m_exposedRect; }

463
protected:
464 465
    virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
    virtual void scrollContentsSlowPath(const IntRect& updateRect) override;
466 467
    
    void repaintSlowRepaintObjects();
468

469 470
    virtual bool isVerticalDocument() const override;
    virtual bool isFlippedDocument() const override;
471

darin's avatar
darin committed
472
private:
473
    explicit FrameView(Frame&);
darin@apple.com's avatar
darin@apple.com committed
474

475
    void reset();
darin's avatar
darin committed
476 477
    void init();

478 479 480 481 482 483 484 485 486 487 488 489
    enum LayoutPhase {
        OutsideLayout,
        InPreLayout,
        InPreLayoutStyleUpdate,
        InLayout,
        InViewSizeAdjust,
        InPostLayout,
    };
    LayoutPhase layoutPhase() const { return m_layoutPhase; }

    bool inPreLayoutStyleUpdate() const { return m_layoutPhase == InPreLayoutStyleUpdate; }

490
    virtual bool isFrameView() const override { return true; }
darin's avatar
darin committed
491

mitz@apple.com's avatar
mitz@apple.com committed
492
    friend class RenderWidget;
493
    bool useSlowRepaints(bool considerOverlap = true) const;
494
    bool useSlowRepaintsIfNotOverlapped() const;
495
    void updateCanBlitOnScrollRecursively();
496
    bool contentsInCompositedLayer() const;
darin's avatar
darin committed
497

498
    bool shouldUpdateCompositingLayersAfterScrolling() const;
499

500
    void applyOverflowToViewport(RenderElement*, ScrollbarMode& hMode, ScrollbarMode& vMode);
501
    void applyPaginationToViewport();
darin's avatar
darin committed
502 503 504

    void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);

505 506
    void paintControlTints();

507
    void forceLayoutParentViewIfNeeded();
mitz@apple.com's avatar
mitz@apple.com committed
508
    void performPostLayoutTasks();
509
    void autoSizeIfEnabled();
darin's avatar
darin committed
510

511 512 513 514 515
    virtual void repaintContentRectangle(const IntRect&, bool immediate) override;
    virtual void contentsResized() override;
    virtual void visibleContentsResized() override;
    virtual void addedOrRemovedScrollbar() override;
    virtual void fixedLayoutSizeChanged() override;
hyatt@apple.com's avatar
hyatt@apple.com committed
516

517
    virtual void delegatesScrollingDidChange() override;
518

hyatt@apple.com's avatar
hyatt@apple.com committed
519 520
    // Override ScrollView methods to do point conversion via renderers, in order to
    // take transforms into account.
521 522 523 524
    virtual IntRect convertToContainingView(const IntRect&) const override;
    virtual IntRect convertFromContainingView(const IntRect&) const override;
    virtual IntPoint convertToContainingView(const IntPoint&) const override;
    virtual IntPoint convertFromContainingView(const IntPoint&) const override;
hyatt@apple.com's avatar
hyatt@apple.com committed
525

526
    // ScrollableArea interface
527 528 529 530 531 532
    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
    virtual void scrollTo(const IntSize&) override;
    virtual void setVisibleScrollerThumbRect(const IntRect&) override;
    virtual ScrollableArea* enclosingScrollableArea() const override;
    virtual IntRect scrollableAreaBoundingBox() const override;
    virtual bool scrollAnimatorEnabled() const override;
533
#if USE(ACCELERATED_COMPOSITING)
534 535 536 537 538
    virtual bool usesCompositedScrolling() const override;
    virtual GraphicsLayer* layerForScrolling() const override;
    virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
    virtual GraphicsLayer* layerForVerticalScrollbar() const override;
    virtual GraphicsLayer* layerForScrollCorner() const override;
539
#if ENABLE(RUBBER_BANDING)
540
    virtual GraphicsLayer* layerForOverhangAreas() const override;
541
#endif
542
#endif
543

544
    // Override scrollbar notifications to update the AXObject cache.
545 546
    virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) override;
    virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) override;
547

548
    void sendResizeEventIfNeeded();
549

550
    void updateScrollableAreaSet();
551

552
    virtual void notifyPageThatContentAreaWillPaint() const override;
553

554
    bool shouldUseLoadTimeDeferredRepaintDelay() const;
555
    void deferredRepaintTimerFired(Timer<FrameView>&);
antti@apple.com's avatar
antti@apple.com committed
556
    void doDeferredRepaints();
557
    void updateDeferredRepaintDelayAfterRepaint();
antti@apple.com's avatar
antti@apple.com committed
558
    double adjustedDeferredRepaintDelay() const;
559

560
    bool updateEmbeddedObjects();
561
    void updateEmbeddedObject(RenderEmbeddedObject&);
mitz@apple.com's avatar
mitz@apple.com committed
562
    void scrollToAnchor();
563
    void scrollPositionChanged();
564

565 566
    bool hasCustomScrollbars() const;

567
    virtual void updateScrollCorner() override;
568

569 570
    FrameView* parentFrameView() const;

571
    void startLayoutAtMainFrameViewIfNeeded(bool allowSubtree);
572 573
    bool frameFlatteningEnabled() const;
    bool isFrameFlatteningValidForThisFrame() const;
574

575 576
    bool qualifiesAsVisuallyNonEmpty() const;

577
    AXObjectCache* axObjectCache() const;
578
    void notifyWidgetsInAllFrames(WidgetNotification);
579
    void removeFromAXObjectCache();
580 581 582 583
    void notifyWidgets(WidgetNotification);

    HashSet<Widget*> m_widgetsInRenderTree;

584 585
    static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache

586 587
    LayoutSize m_size;
    LayoutSize m_margins;
588

589
    OwnPtr<ListHashSet<RenderEmbeddedObject*>> m_embeddedObjectsToUpdate;
590
    const RefPtr<Frame> m_frame;
591

592
    OwnPtr<HashSet<RenderElement*>> m_slowRepaintObjects;
593

594
    bool m_needsFullRepaint;
595
    
596
    bool m_canHaveScrollbars;
597
    bool m_cannotBlitToWindow;
mitz@apple.com's avatar
mitz@apple.com committed
598
    bool m_isOverlapped;
mitz@apple.com's avatar
mitz@apple.com committed
599
    bool m_contentIsOpaque;
600

601 602
    int m_borderX;
    int m_borderY;
603 604 605

    Timer<FrameView> m_layoutTimer;
    bool m_delayedLayout;
606
    RenderElement* m_layoutRoot;
607 608

    LayoutPhase m_layoutPhase;
609
    bool m_layoutSchedulingEnabled;
610
    bool m_inSynchronousPostLayout;
611 612 613 614 615 616 617 618
    int m_layoutCount;
    unsigned m_nestedLayoutCount;
    Timer<FrameView> m_postLayoutTasksTimer;
    bool m_firstLayoutCallbackPending;

    bool m_firstLayout;
    bool m_isTransparent;
    Color m_baseBackgroundColor;
619
    IntSize m_lastViewportSize;
620 621 622
    float m_lastZoomFactor;

    String m_mediaType;
623 624
    String m_mediaTypeWhenNotPrinting;

625 626 627
    bool m_overflowStatusDirty;
    bool m_horizontalOverflow;
    bool m_verticalOverflow;    
628
    RenderElement* m_viewportRenderer;
629

630 631
    Pagination m_pagination;

632 633
    bool m_wasScrolledByUser;
    bool m_inProgrammaticScroll;
634 635
    bool m_safeToPropagateScrollToParent;

636 637
    unsigned m_deferringRepaints;
    unsigned m_repaintCount;
638
    Vector<LayoutRect> m_repaintRects;
antti@apple.com's avatar
antti@apple.com committed
639 640 641
    Timer<FrameView> m_deferredRepaintTimer;
    double m_deferredRepaintDelay;
    double m_lastPaintTime;
642

643
    bool m_isTrackingRepaints; // Used for testing.
644
    Vector<IntRect> m_trackedRepaintRects;
645 646 647

    bool m_shouldUpdateWhileOffscreen;

648 649
    FloatRect m_exposedRect;

650 651 652
    unsigned m_deferSetNeedsLayouts;
    bool m_setNeedsLayoutWasDeferred;

653
    RefPtr<Node> m_nodeToDraw;
654
    PaintBehavior m_paintBehavior;
655 656
    bool m_isPainting;

657 658
    unsigned m_visuallyNonEmptyCharacterCount;
    unsigned m_visuallyNonEmptyPixelCount;
659 660
    bool m_isVisuallyNonEmpty;
    bool m_firstVisuallyNonEmptyLayoutCallbackPending;
abarth@webkit.org's avatar
abarth@webkit.org committed
661

mitz@apple.com's avatar
mitz@apple.com committed
662
    RefPtr<Node> m_maintainScrollPositionAnchor;
663 664

    // Renderer to hold our custom scroll corner.
665
    RenderPtr<RenderScrollbarPart> m_scrollCorner;
666

667 668 669 670 671
#if PLATFORM(IOS)
    bool m_useCustomFixedPositionLayoutRect;
    IntRect m_customFixedPositionLayoutRect;
#endif

672 673 674
    // If true, automatically resize the frame view around its content.
    bool m_shouldAutoSize;
    bool m_inAutoSize;
675 676
    // True if autosize has been run since m_shouldAutoSize was set.
    bool m_didRunAutosize;
677 678 679 680
    // The lower bound on the size when autosizing.
    IntSize m_minAutoSize;
    // The upper bound on the size when autosizing.
    IntSize m_maxAutoSize;
681 682 683 684
    // The fixed height to resize the view to after autosizing is complete.
    int m_autoSizeFixedMinimumHeight;
    // The intrinsic content size decided by autosizing.
    IntSize m_autoSizeContentSize;
685

686
    OwnPtr<ScrollableAreaSet> m_scrollableAreas;
687
    OwnPtr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
688

689 690 691
    int m_headerHeight;
    int m_footerHeight;

692 693
    LayoutMilestones m_milestonesPendingPaint;

694
    static double s_normalDeferredRepaintDelay;
695 696 697
    static double s_initialDeferredRepaintDelayDuringLoading;
    static double s_maxDeferredRepaintDelayDuringLoading;
    static double s_deferredRepaintDelayIncrementDuringLoading;
698

699 700 701
    static const unsigned visualCharacterThreshold = 200;
    static const unsigned visualPixelThreshold = 32 * 32;

702 703 704 705 706
#if ENABLE(CSS_DEVICE_ADAPTATION)
    // Size of viewport before any UA or author styles have overridden
    // the viewport given by the window or viewing area of the UA.
    IntSize m_initialViewportSize;
#endif
707 708

    bool m_visualUpdatesAllowedByClient;
709 710
    
    ScrollPinningBehavior m_scrollPinningBehavior;
kocienda's avatar
kocienda committed
711 712
};

713 714 715 716 717
inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
{
    if (m_isVisuallyNonEmpty)
        return;
    m_visuallyNonEmptyCharacterCount += count;
718 719 720
    if (m_visuallyNonEmptyCharacterCount <= visualCharacterThreshold)
        return;
    updateIsVisuallyNonEmpty();
721 722 723 724 725 726 727
}

inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
{
    if (m_isVisuallyNonEmpty)
        return;
    m_visuallyNonEmptyPixelCount += size.width() * size.height();
728 729 730
    if (m_visuallyNonEmptyPixelCount <= visualPixelThreshold)
        return;
    updateIsVisuallyNonEmpty();
731 732
}

733
WIDGET_TYPE_CASTS(FrameView, isFrameView());
734

735
} // namespace WebCore
darin's avatar
darin committed
736

737
#endif // FrameView_h