diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
commit | 881da28418d380042aa95a97f0cbd42560a64f7c (patch) | |
tree | a794dff3274695e99c651902dde93d934ea7a5af /Source/WebCore/rendering/RenderView.h | |
parent | 7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff) | |
parent | 0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff) | |
download | qtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz |
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebCore/rendering/RenderView.h')
-rw-r--r-- | Source/WebCore/rendering/RenderView.h | 399 |
1 files changed, 198 insertions, 201 deletions
diff --git a/Source/WebCore/rendering/RenderView.h b/Source/WebCore/rendering/RenderView.h index 09466dec7..40aa58229 100644 --- a/Source/WebCore/rendering/RenderView.h +++ b/Source/WebCore/rendering/RenderView.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2015 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,96 +24,81 @@ #include "FrameView.h" #include "LayoutState.h" -#include "PODFreeListArena.h" -#include "RenderBlock.h" -#include <wtf/OwnPtr.h> +#include "Region.h" +#include "RenderBlockFlow.h" +#include "RenderWidget.h" +#include "SelectionSubtreeRoot.h" +#include <memory> +#include <wtf/HashSet.h> + +#if ENABLE(SERVICE_CONTROLS) +#include "SelectionRectGatherer.h" +#endif namespace WebCore { class FlowThreadController; -class RenderQuote; -class RenderWidget; - -#if USE(ACCELERATED_COMPOSITING) +class ImageQualityController; class RenderLayerCompositor; -#endif - -#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS) -class CustomFilterGlobalContext; -#endif +class RenderQuote; -class RenderView : public RenderBlock { +class RenderView final : public RenderBlockFlow, public SelectionSubtreeRoot { public: - explicit RenderView(Document*); + RenderView(Document&, Ref<RenderStyle>&&); virtual ~RenderView(); - bool hitTest(const HitTestRequest&, HitTestResult&); + WEBCORE_EXPORT bool hitTest(const HitTestRequest&, HitTestResult&); bool hitTest(const HitTestRequest&, const HitTestLocation&, HitTestResult&); - virtual const char* renderName() const OVERRIDE { return "RenderView"; } - - virtual bool isRenderView() const OVERRIDE { return true; } + virtual const char* renderName() const override { return "RenderView"; } - virtual bool requiresLayer() const OVERRIDE { return true; } + virtual bool requiresLayer() const override { return true; } - virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE; + virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const override; - virtual void layout() OVERRIDE; - virtual void updateLogicalWidth() OVERRIDE; - virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE; + virtual void layout() override; + virtual void updateLogicalWidth() override; + virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const override; - virtual LayoutUnit availableLogicalHeight(AvailableLogicalHeightType) const OVERRIDE; + virtual LayoutUnit availableLogicalHeight(AvailableLogicalHeightType) const override; // The same as the FrameView's layoutHeight/layoutWidth but with null check guards. int viewHeight() const; int viewWidth() const; - int viewLogicalWidth() const { return style()->isHorizontalWritingMode() ? viewWidth() : viewHeight(); } + int viewLogicalWidth() const { return style().isHorizontalWritingMode() ? viewWidth() : viewHeight(); } int viewLogicalHeight() const; + LayoutUnit clientLogicalWidthForFixedPosition() const; + LayoutUnit clientLogicalHeightForFixedPosition() const; + float zoomFactor() const; - FrameView* frameView() const { return m_frameView; } + FrameView& frameView() const { return m_frameView; } - virtual LayoutRect visualOverflowRect() const OVERRIDE; - virtual void computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect&, bool fixed = false) const OVERRIDE; - void repaintViewRectangle(const LayoutRect&, bool immediate = false) const; - // Repaint the view, and all composited layers that intersect the given absolute rectangle. - // FIXME: ideally we'd never have to do this, if all repaints are container-relative. - void repaintRectangleInViewAndCompositedLayers(const LayoutRect&, bool immediate = false); + virtual LayoutRect visualOverflowRect() const override; + virtual LayoutRect computeRectForRepaint(const LayoutRect&, const RenderLayerModelObject* repaintContainer, bool fixed = false) const override; + void repaintRootContents(); + void repaintViewRectangle(const LayoutRect&) const; void repaintViewAndCompositedLayers(); - virtual void paint(PaintInfo&, const LayoutPoint&); - virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&) OVERRIDE; + virtual void paint(PaintInfo&, const LayoutPoint&) override; + virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&) override; enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld, RepaintNothing }; void setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode = RepaintNewXOROld); void getSelection(RenderObject*& startRenderer, int& startOffset, RenderObject*& endRenderer, int& endOffset) const; void clearSelection(); - RenderObject* selectionStart() const { return m_selectionStart; } - RenderObject* selectionEnd() const { return m_selectionEnd; } + RenderObject* selectionUnsplitStart() const { return m_selectionUnsplitStart; } + RenderObject* selectionUnsplitEnd() const { return m_selectionUnsplitEnd; } IntRect selectionBounds(bool clipToVisibleContent = true) const; - void selectionStartEnd(int& startPos, int& endPos) const; void repaintSelection() const; bool printing() const; - virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const; - virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const; - -#if USE(ACCELERATED_COMPOSITING) - void setMaximalOutlineSize(int o); -#else - void setMaximalOutlineSize(int o) { m_maximalOutlineSize = o; } -#endif - int maximalOutlineSize() const { return m_maximalOutlineSize; } + virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const override; + virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override; - virtual LayoutRect viewRect() const OVERRIDE; - - void updateWidgetPositions(); - void addWidget(RenderWidget*); - void removeWidget(RenderWidget*); - - void notifyWidgets(WidgetNotification); + LayoutRect viewRect() const; // layoutDelta is used transiently during layout to store how far an object has moved from its // last layout location, in order to repaint correctly. @@ -126,39 +111,35 @@ public: { if (m_layoutState) { m_layoutState->m_layoutDelta += delta; -#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) +#if !ASSERT_DISABLED m_layoutState->m_layoutDeltaXSaturated |= m_layoutState->m_layoutDelta.width() == LayoutUnit::max() || m_layoutState->m_layoutDelta.width() == LayoutUnit::min(); m_layoutState->m_layoutDeltaYSaturated |= m_layoutState->m_layoutDelta.height() == LayoutUnit::max() || m_layoutState->m_layoutDelta.height() == LayoutUnit::min(); #endif } } - + #if !ASSERT_DISABLED bool layoutDeltaMatches(const LayoutSize& delta) { if (!m_layoutState) return false; -#if ENABLE(SATURATED_LAYOUT_ARITHMETIC) return (delta.width() == m_layoutState->m_layoutDelta.width() || m_layoutState->m_layoutDeltaXSaturated) && (delta.height() == m_layoutState->m_layoutDelta.height() || m_layoutState->m_layoutDeltaYSaturated); -#else - return delta == m_layoutState->m_layoutDelta; -#endif } #endif - bool doingFullRepaint() const { return m_frameView->needsFullRepaint(); } + bool doingFullRepaint() const { return frameView().needsFullRepaint(); } // Subtree push/pop - void pushLayoutState(RenderObject*); - void popLayoutState(RenderObject*) { return popLayoutState(); } // Just doing this to keep popLayoutState() private and to make the subtree calls symmetrical. + void pushLayoutState(RenderObject&); + void popLayoutState(RenderObject&) { return popLayoutState(); } // Just doing this to keep popLayoutState() private and to make the subtree calls symmetrical. bool shouldDisableLayoutStateForSubtree(RenderObject*) const; // Returns true if layoutState should be used for its cached offset and clip. bool layoutStateEnabled() const { return m_layoutStateDisableCount == 0 && m_layoutState; } - LayoutState* layoutState() const { return m_layoutState; } + LayoutState* layoutState() const { return m_layoutState.get(); } - virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&); + virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; } void setPageLogicalHeight(LayoutUnit height) @@ -170,6 +151,14 @@ public: } LayoutUnit pageOrViewLogicalHeight() const; + // This method is used to assign a page number only when pagination modes have + // a block progression. This happens with vertical-rl books for example, but it + // doesn't happen for normal horizontal-tb books. This is a very specialized + // function and should not be mistaken for a general page number API. + unsigned pageNumberForBlockProgressionOffset(int offset) const; + + unsigned pageCount() const; + // FIXME: These functions are deprecated. No code should be added that uses these. int bestTruncatedAt() const { return m_legacyPrinting.m_bestTruncatedAt; } void setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak = false); @@ -188,32 +177,30 @@ public: // Notification that this view moved into or out of a native window. void setIsInWindow(bool); -#if USE(ACCELERATED_COMPOSITING) - RenderLayerCompositor* compositor(); - bool usesCompositing() const; -#endif + WEBCORE_EXPORT RenderLayerCompositor& compositor(); + WEBCORE_EXPORT bool usesCompositing() const; -#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS) - CustomFilterGlobalContext* customFilterGlobalContext(); -#endif + bool usesFirstLineRules() const { return m_usesFirstLineRules; } + bool usesFirstLetterRules() const { return m_usesFirstLetterRules; } + void setUsesFirstLineRules(bool value) { m_usesFirstLineRules = value; } + void setUsesFirstLetterRules(bool value) { m_usesFirstLetterRules = value; } - IntRect unscaledDocumentRect() const; - LayoutRect backgroundRect(RenderBox* backgroundRenderer) const; + WEBCORE_EXPORT IntRect unscaledDocumentRect() const; + LayoutRect unextendedBackgroundRect() const; + LayoutRect backgroundRect() const; - IntRect documentRect() const; + WEBCORE_EXPORT IntRect documentRect() const; // Renderer that paints the root background has background-images which all have background-attachment: fixed. bool rootBackgroundIsEntirelyFixed() const; bool hasRenderNamedFlowThreads() const; bool checkTwoPassLayoutForAutoHeightRegions() const; - FlowThreadController* flowThreadController(); - - void styleDidChange(StyleDifference, const RenderStyle* oldStyle); + FlowThreadController& flowThreadController(); - IntervalArena* intervalArena(); + virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; - IntSize viewportSize() const { return document()->viewportSize(); } + IntSize viewportSizeForCSSViewportUnits() const; void setRenderQuoteHead(RenderQuote* head) { m_renderQuoteHead = head; } RenderQuote* renderQuoteHead() const { return m_renderQuoteHead; } @@ -226,37 +213,67 @@ public: void removeRenderCounter() { ASSERT(m_renderCounterCount > 0); m_renderCounterCount--; } bool hasRenderCounters() { return m_renderCounterCount; } - virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE; + ImageQualityController& imageQualityController(); + + void setHasSoftwareFilters(bool hasSoftwareFilters) { m_hasSoftwareFilters = hasSoftwareFilters; } + bool hasSoftwareFilters() const { return m_hasSoftwareFilters; } + + uint64_t rendererCount() const { return m_rendererCount; } + void didCreateRenderer() { ++m_rendererCount; } + void didDestroyRenderer() { --m_rendererCount; } + + void updateVisibleViewportRect(const IntRect&); + void registerForVisibleInViewportCallback(RenderElement&); + void unregisterForVisibleInViewportCallback(RenderElement&); + void resumePausedImageAnimationsIfNeeded(IntRect visibleRect); + void addRendererWithPausedImageAnimations(RenderElement&); + void removeRendererWithPausedImageAnimations(RenderElement&); + + class RepaintRegionAccumulator { + WTF_MAKE_NONCOPYABLE(RepaintRegionAccumulator); + public: + RepaintRegionAccumulator(RenderView*); + ~RepaintRegionAccumulator(); + + private: + RenderView* m_rootView; + bool m_wasAccumulatingRepaintRegion; + }; + + void scheduleLazyRepaint(RenderBox&); + void unscheduleLazyRepaint(RenderBox&); - IntRect pixelSnappedLayoutOverflowRect() const { return pixelSnappedIntRect(layoutOverflowRect()); } + void protectRenderWidgetUntilLayoutIsDone(RenderWidget& widget) { m_protectedRenderWidgets.append(&widget); } + void releaseProtectedRenderWidgets() { m_protectedRenderWidgets.clear(); } + +#if ENABLE(CSS_SCROLL_SNAP) + void registerBoxWithScrollSnapCoordinates(const RenderBox&); + void unregisterBoxWithScrollSnapCoordinates(const RenderBox&); + const HashSet<const RenderBox*>& boxesWithScrollSnapCoordinates() { return m_boxesWithScrollSnapCoordinates; } +#endif protected: - virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const OVERRIDE; - virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE; - virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const; - virtual bool requiresColumns(int desiredColumnCount) const OVERRIDE; - + virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override; + virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override; + virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const override; + virtual bool requiresColumns(int desiredColumnCount) const override; + private: - bool initializeLayoutState(LayoutState&); + void initializeLayoutState(LayoutState&); - virtual void calcColumnWidth() OVERRIDE; - virtual ColumnInfo::PaginationUnit paginationUnit() const OVERRIDE; + virtual void computeColumnCountAndWidth() override; bool shouldRepaint(const LayoutRect&) const; + void flushAccumulatedRepaintRegion() const; // These functions may only be accessed by LayoutStateMaintainer. - bool pushLayoutState(RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) + bool pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false) { // We push LayoutState even if layoutState is disabled because it stores layoutDelta too. - if (!doingFullRepaint() || m_layoutState->isPaginated() || renderer->hasColumns() || renderer->flowThreadContainingBlock() - || m_layoutState->lineGrid() || (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow()) -#if ENABLE(CSS_SHAPES) - || (renderer->isRenderBlock() && toRenderBlock(renderer)->shapeInsideInfo()) - || (m_layoutState->shapeInsideInfo() && renderer->isRenderBlock() && !toRenderBlock(renderer)->allowsShapeInsideInfoSharing()) -#endif - ) { + if (!doingFullRepaint() || m_layoutState->isPaginated() || renderer.flowThreadContainingBlock() + || m_layoutState->lineGrid() || (renderer.style().lineGrid() != RenderStyle::initialLineGrid() && renderer.isRenderBlockFlow())) { + m_layoutState = std::make_unique<LayoutState>(WTFMove(m_layoutState), &renderer, offset, pageHeight, pageHeightChanged); pushLayoutStateForCurrentFlowThread(renderer); - m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, pageHeightChanged, colInfo); return true; } return false; @@ -264,10 +281,8 @@ private: void popLayoutState() { - LayoutState* state = m_layoutState; - m_layoutState = state->m_next; - state->destroy(renderArena()); popLayoutStateForCurrentFlowThread(); + m_layoutState = WTFMove(m_layoutState->m_next); } // Suspends the LayoutState optimization. Used under transforms that cannot be represented by @@ -280,26 +295,39 @@ private: void layoutContent(const LayoutState&); void layoutContentInAutoLogicalHeightRegions(const LayoutState&); + void layoutContentToComputeOverflowInRegions(const LayoutState&); #ifndef NDEBUG void checkLayoutState(const LayoutState&); #endif - size_t getRetainedWidgets(Vector<RenderWidget*>&); - void releaseWidgets(Vector<RenderWidget*>&); - - void pushLayoutStateForCurrentFlowThread(const RenderObject*); + void pushLayoutStateForCurrentFlowThread(const RenderObject&); void popLayoutStateForCurrentFlowThread(); - + friend class LayoutStateMaintainer; friend class LayoutStateDisabler; + friend class SubtreeLayoutStateMaintainer; -protected: - FrameView* m_frameView; + virtual bool isScrollableOrRubberbandableBox() const override; + + void splitSelectionBetweenSubtrees(const RenderObject* startRenderer, int startPos, const RenderObject* endRenderer, int endPos, SelectionRepaintMode blockRepaintMode); + void clearSubtreeSelection(const SelectionSubtreeRoot&, SelectionRepaintMode, OldSelectionData&) const; + void updateSelectionForSubtrees(RenderSubtreesMap&, SelectionRepaintMode); + void applySubtreeSelection(const SelectionSubtreeRoot&, SelectionRepaintMode, const OldSelectionData&); + LayoutRect subtreeSelectionBounds(const SelectionSubtreeRoot&, bool clipToVisibleContent = true) const; + void repaintSubtreeSelection(const SelectionSubtreeRoot&) const; + +private: + FrameView& m_frameView; + + RenderObject* m_selectionUnsplitStart; + RenderObject* m_selectionUnsplitEnd; + int m_selectionUnsplitStartPos; + int m_selectionUnsplitEndPos; - RenderObject* m_selectionStart; - RenderObject* m_selectionEnd; - int m_selectionStartPos; - int m_selectionEndPos; + // Include this RenderView. + uint64_t m_rendererCount { 1 }; + + mutable std::unique_ptr<Region> m_accumulatedRepaintRegion; // FIXME: Only used by embedded WebViews inside AppKit NSViews. Find a way to remove. struct LegacyPrinting { @@ -319,150 +347,119 @@ protected: LegacyPrinting m_legacyPrinting; // End deprecated members. - int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect checks on blocks/tables. + bool shouldUsePrintingLayout() const; - typedef HashSet<RenderWidget*> RenderWidgetSet; - RenderWidgetSet m_widgets; + void lazyRepaintTimerFired(); -private: - bool shouldUsePrintingLayout() const; + Timer m_lazyRepaintTimer; + HashSet<RenderBox*> m_renderersNeedingLazyRepaint; + std::unique_ptr<ImageQualityController> m_imageQualityController; LayoutUnit m_pageLogicalHeight; bool m_pageLogicalHeightChanged; - LayoutState* m_layoutState; + std::unique_ptr<LayoutState> m_layoutState; unsigned m_layoutStateDisableCount; -#if USE(ACCELERATED_COMPOSITING) - OwnPtr<RenderLayerCompositor> m_compositor; -#endif -#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS) - OwnPtr<CustomFilterGlobalContext> m_customFilterGlobalContext; -#endif - OwnPtr<FlowThreadController> m_flowThreadController; - RefPtr<IntervalArena> m_intervalArena; + std::unique_ptr<RenderLayerCompositor> m_compositor; + std::unique_ptr<FlowThreadController> m_flowThreadController; RenderQuote* m_renderQuoteHead; unsigned m_renderCounterCount; bool m_selectionWasCaret; -}; + bool m_hasSoftwareFilters; + bool m_usesFirstLineRules { false }; + bool m_usesFirstLetterRules { false }; -inline RenderView* toRenderView(RenderObject* object) -{ - ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderView()); - return static_cast<RenderView*>(object); -} + HashSet<RenderElement*> m_renderersWithPausedImageAnimation; + HashSet<RenderElement*> m_visibleInViewportRenderers; + Vector<RefPtr<RenderWidget>> m_protectedRenderWidgets; -inline const RenderView* toRenderView(const RenderObject* object) -{ - ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderView()); - return static_cast<const RenderView*>(object); -} - -// This will catch anyone doing an unnecessary cast. -void toRenderView(const RenderView*); - -ALWAYS_INLINE RenderView* Document::renderView() const -{ - return toRenderView(renderer()); -} +#if ENABLE(SERVICE_CONTROLS) + SelectionRectGatherer m_selectionRectGatherer; +#endif +#if ENABLE(CSS_SCROLL_SNAP) + HashSet<const RenderBox*> m_boxesWithScrollSnapCoordinates; +#endif +}; // Stack-based class to assist with LayoutState push/pop class LayoutStateMaintainer { WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer); public: - // ctor to push now - LayoutStateMaintainer(RenderView* view, RenderBox* root, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) + // Constructor to push now. + explicit LayoutStateMaintainer(RenderView& view, RenderBox& root, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false) : m_view(view) , m_disabled(disableState) - , m_didStart(false) - , m_didEnd(false) - , m_didCreateLayoutState(false) { - push(root, offset, pageHeight, pageHeightChanged, colInfo); + push(root, offset, pageHeight, pageHeightChanged); } - - // ctor to maybe push later - LayoutStateMaintainer(RenderView* view) + + // Constructor to maybe push later. + explicit LayoutStateMaintainer(RenderView& view) : m_view(view) - , m_disabled(false) - , m_didStart(false) - , m_didEnd(false) - , m_didCreateLayoutState(false) { } ~LayoutStateMaintainer() { - ASSERT(m_didStart == m_didEnd); // if this fires, it means that someone did a push(), but forgot to pop(). + ASSERT(!m_didCallPush || m_didCallPush == m_didCallPop); } - void push(RenderBox* root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) + void push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false) { - ASSERT(!m_didStart); + ASSERT(!m_didCallPush); + m_didCallPush = true; // We push state even if disabled, because we still need to store layoutDelta - m_didCreateLayoutState = m_view->pushLayoutState(root, offset, pageHeight, pageHeightChanged, colInfo); - if (m_disabled && m_didCreateLayoutState) - m_view->disableLayoutState(); - m_didStart = true; + m_didPushLayoutState = m_view.pushLayoutState(root, offset, pageHeight, pageHeightChanged); + if (!m_didPushLayoutState) + return; + if (m_disabled) + m_view.disableLayoutState(); } void pop() { - if (m_didStart) { - ASSERT(!m_didEnd); - if (m_didCreateLayoutState) { - m_view->popLayoutState(); - if (m_disabled) - m_view->enableLayoutState(); - } - - m_didEnd = true; - } + ASSERT(!m_didCallPop); + m_didCallPop = true; + if (!m_didCallPush) + return; + if (!m_didPushLayoutState) + return; + m_view.popLayoutState(); + if (m_disabled) + m_view.enableLayoutState(); } - bool didPush() const { return m_didStart; } + bool didPush() const { return m_didCallPush; } private: - RenderView* m_view; - bool m_disabled : 1; // true if the offset and clip part of layoutState is disabled - bool m_didStart : 1; // true if we did a push or disable - bool m_didEnd : 1; // true if we popped or re-enabled - bool m_didCreateLayoutState : 1; // true if we actually made a layout state. + RenderView& m_view; + bool m_disabled { false }; + bool m_didCallPush { false }; + bool m_didCallPop { false }; + bool m_didPushLayoutState { false }; }; class LayoutStateDisabler { WTF_MAKE_NONCOPYABLE(LayoutStateDisabler); public: - LayoutStateDisabler(RenderView* view) + LayoutStateDisabler(RenderView& view) : m_view(view) { - if (m_view) - m_view->disableLayoutState(); + m_view.disableLayoutState(); } ~LayoutStateDisabler() { - if (m_view) - m_view->enableLayoutState(); + m_view.enableLayoutState(); } -private: - RenderView* m_view; -}; -class FragmentationDisabler { - WTF_MAKE_NONCOPYABLE(FragmentationDisabler); -public: - FragmentationDisabler(RenderObject* root); - ~FragmentationDisabler(); private: - RenderObject* m_root; - RenderObject::FlowThreadState m_flowThreadState; - bool m_fragmenting; -#ifndef NDEBUG - LayoutState* m_layoutState; -#endif + RenderView& m_view; }; } // namespace WebCore +SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderView, isRenderView()) + #endif // RenderView_h |