diff options
Diffstat (limited to 'Source/WebCore/rendering/RenderFlowThread.h')
-rw-r--r-- | Source/WebCore/rendering/RenderFlowThread.h | 204 |
1 files changed, 101 insertions, 103 deletions
diff --git a/Source/WebCore/rendering/RenderFlowThread.h b/Source/WebCore/rendering/RenderFlowThread.h index f396b9a3f..a69f73579 100644 --- a/Source/WebCore/rendering/RenderFlowThread.h +++ b/Source/WebCore/rendering/RenderFlowThread.h @@ -27,30 +27,27 @@ * SUCH DAMAGE. */ -#ifndef RenderFlowThread_h -#define RenderFlowThread_h - +#pragma once +#include "LayerFragment.h" #include "RenderBlockFlow.h" #include <wtf/HashCountedSet.h> #include <wtf/ListHashSet.h> -#include <wtf/PassRefPtr.h> namespace WebCore { -struct LayerFragment; -typedef Vector<LayerFragment, 1> LayerFragments; +class CurrentRenderRegionMaintainer; class RenderFlowThread; class RenderNamedFlowFragment; class RenderStyle; class RenderRegion; +class RootInlineBox; typedef ListHashSet<RenderRegion*> RenderRegionList; typedef Vector<RenderLayer*> RenderLayerList; -#if USE(ACCELERATED_COMPOSITING) typedef HashMap<RenderNamedFlowFragment*, RenderLayerList> RegionToLayerListMap; typedef HashMap<RenderLayer*, RenderNamedFlowFragment*> LayerToRegionMap; -#endif +typedef HashMap<const RootInlineBox*, RenderRegion*> ContainingRegionMap; // RenderFlowThread is used to collect all the render objects that participate in a // flow thread. It will also help in doing the layout. However, it will not render @@ -60,69 +57,69 @@ typedef HashMap<RenderLayer*, RenderNamedFlowFragment*> LayerToRegionMap; class RenderFlowThread: public RenderBlockFlow { public: - RenderFlowThread(Document&, PassRef<RenderStyle>); - virtual ~RenderFlowThread() { }; - - virtual bool isRenderFlowThread() const override final { return true; } + virtual ~RenderFlowThread() { } - virtual void layout() override final; - - // Always create a RenderLayer for the RenderFlowThread so that we - // can easily avoid drawing the children directly. - virtual bool requiresLayer() const override final { return true; } - - virtual void removeFlowChildInfo(RenderObject*); + virtual void removeFlowChildInfo(RenderElement&); #ifndef NDEBUG - bool hasChildInfo(RenderObject* child) const { return child && child->isBox() && m_regionRangeMap.contains(toRenderBox(child)); } + bool hasChildInfo(RenderObject* child) const { return is<RenderBox>(child) && m_regionRangeMap.contains(downcast<RenderBox>(child)); } #endif - virtual void addRegionToThread(RenderRegion*); +#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED + bool checkLinesConsistency(const RenderBlockFlow&) const; +#endif + + void deleteLines() override; + + virtual void addRegionToThread(RenderRegion*) = 0; virtual void removeRegionFromThread(RenderRegion*); const RenderRegionList& renderRegionList() const { return m_regionList; } - virtual void updateLogicalWidth() override final; - virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const override; + void updateLogicalWidth() final; + LogicalExtentComputedValues computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const override; - virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; + bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; bool hasRegions() const { return m_regionList.size(); } virtual void regionChangedWritingMode(RenderRegion*) { } void validateRegions(); - void invalidateRegions(); + void invalidateRegions(MarkingBehavior = MarkContainingBlockChain); bool hasValidRegionInfo() const { return !m_regionsInvalidated && !m_regionList.isEmpty(); } - static PassRef<RenderStyle> createFlowThreadStyle(RenderStyle* parentStyle); + // Some renderers (column spanners) are moved out of the flow thread to live among column + // sets. If |child| is such a renderer, resolve it to the placeholder that lives at the original + // location in the tree. + virtual RenderObject* resolveMovedChild(RenderObject* child) const { return child; } + // Called when a descendant of the flow thread has been inserted. + virtual void flowThreadDescendantInserted(RenderObject&) { } + // Called when a sibling or descendant of the flow thread is about to be removed. + virtual void flowThreadRelativeWillBeRemoved(RenderObject&) { } + // Called when a descendant box's layout is finished and it has been positioned within its container. + virtual void flowThreadDescendantBoxLaidOut(RenderBox*) { } - virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; + static RenderStyle createFlowThreadStyle(const RenderStyle* parentStyle); - void repaintRectangleInRegions(const LayoutRect&, bool immediate) const; + void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; + + void repaintRectangleInRegions(const LayoutRect&) const; - LayoutPoint adjustedPositionRelativeToOffsetParent(const RenderBoxModelObject&, const LayoutPoint&); + LayoutPoint adjustedPositionRelativeToOffsetParent(const RenderBoxModelObject&, const LayoutPoint&) const; - LayoutUnit pageLogicalTopForOffset(LayoutUnit); - LayoutUnit pageLogicalWidthForOffset(LayoutUnit); - LayoutUnit pageLogicalHeightForOffset(LayoutUnit); - LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit, PageBoundaryRule = IncludePageBoundary); + LayoutUnit pageLogicalTopForOffset(LayoutUnit) const; + LayoutUnit pageLogicalWidthForOffset(LayoutUnit) const; + LayoutUnit pageLogicalHeightForOffset(LayoutUnit) const; + LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit, PageBoundaryRule = IncludePageBoundary) const; virtual void setPageBreak(const RenderBlock*, LayoutUnit /*offset*/, LayoutUnit /*spaceShortage*/) { } virtual void updateMinimumPageHeight(const RenderBlock*, LayoutUnit /*offset*/, LayoutUnit /*minHeight*/) { } - enum RegionAutoGenerationPolicy { - AllowRegionAutoGeneration, - DisallowRegionAutoGeneration, - }; - - RenderRegion* regionAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastRegion = false, RegionAutoGenerationPolicy = AllowRegionAutoGeneration); - - RenderRegion* regionFromAbsolutePointAndBox(const IntPoint&, const RenderBox& flowedBox); + virtual RenderRegion* regionAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastRegion = false) const; bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; } bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLogicalHeight; } - RenderRegion* mapFromFlowToRegion(TransformState&) const; + virtual RenderRegion* mapFromFlowToRegion(TransformState&) const; - void removeRenderBoxRegionInfo(RenderBox*); void logicalWidthChangedInRegionsForBlock(const RenderBlock*, bool&); LayoutUnit contentLogicalWidthOfFirstRegion() const; @@ -135,21 +132,24 @@ public: bool previousRegionCountChanged() const { return m_previousRegionCount != m_regionList.size(); }; void updatePreviousRegionCount() { m_previousRegionCount = m_regionList.size(); }; - void setRegionRangeForBox(const RenderBox*, RenderRegion*, RenderRegion*); - void getRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const; + virtual void setRegionRangeForBox(const RenderBox&, RenderRegion*, RenderRegion*); + bool getRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const; + bool computedRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const; + bool hasCachedRegionRangeForBox(const RenderBox&) const; // Check if the object is in region and the region is part of this flow thread. bool objectInFlowRegion(const RenderObject*, const RenderRegion*) const; // Check if the object should be painted in this region and if the region is part of this flow thread. - bool objectShouldPaintInFlowRegion(const RenderObject*, const RenderRegion*) const; + bool objectShouldFragmentInFlowRegion(const RenderObject*, const RenderRegion*) const; void markAutoLogicalHeightRegionsForLayout(); void markRegionsForOverflowLayoutIfNeeded(); virtual bool addForcedRegionBreak(const RenderBlock*, LayoutUnit, RenderBox* breakChild, bool isBefore, LayoutUnit* offsetBreakAdjustment = 0); - void applyBreakAfterContent(LayoutUnit); + virtual void applyBreakAfterContent(LayoutUnit) { } + virtual bool isPageLogicalHeightKnown() const { return true; } bool pageLogicalSizeChanged() const { return m_pageLogicalSizeChanged; } bool hasAutoLogicalHeightRegions() const { ASSERT(isAutoLogicalHeightRegionsCountConsistent()); return m_autoLogicalHeightRegionsCount; } @@ -179,7 +179,6 @@ public: bool needsTwoPhasesLayout() const { return m_needsTwoPhasesLayout; } void clearNeedsTwoPhasesLayout() { m_needsTwoPhasesLayout = false; } -#if USE(ACCELERATED_COMPOSITING) // Whether any of the regions has a compositing descendant. bool hasCompositingRegionDescendant() const; @@ -190,18 +189,17 @@ public: updateAllLayerToRegionMappings(); } - const RenderLayerList* getLayerListForRegion(RenderNamedFlowFragment*); + const RenderLayerList* getLayerListForRegion(RenderNamedFlowFragment*) const; - RenderNamedFlowFragment* regionForCompositedLayer(RenderLayer&); // By means of getRegionRangeForBox or regionAtBlockOffset. - RenderNamedFlowFragment* cachedRegionForCompositedLayer(RenderLayer&); + RenderNamedFlowFragment* regionForCompositedLayer(RenderLayer&) const; // By means of getRegionRangeForBox or regionAtBlockOffset. + RenderNamedFlowFragment* cachedRegionForCompositedLayer(RenderLayer&) const; -#endif virtual bool collectsGraphicsLayersUnderRegions() const; void pushFlowThreadLayoutState(const RenderObject&); void popFlowThreadLayoutState(); LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const; - void clearRenderBoxRegionInfoAndCustomStyle(const RenderBox*, const RenderRegion*, const RenderRegion*, const RenderRegion*, const RenderRegion*); + void clearRenderBoxRegionInfoAndCustomStyle(const RenderBox&, const RenderRegion*, const RenderRegion*, const RenderRegion*, const RenderRegion*); void addRegionsVisualEffectOverflow(const RenderBox*); void addRegionsVisualOverflowFromTheme(const RenderBlock*); @@ -212,53 +210,59 @@ public: LayoutRect mapFromFlowThreadToLocal(const RenderBox*, const LayoutRect&) const; LayoutRect mapFromLocalToFlowThread(const RenderBox*, const LayoutRect&) const; - - LayoutRect decorationsClipRectForBoxInRegion(const RenderBox&, RenderRegion&) const; - + void flipForWritingModeLocalCoordinates(LayoutRect&) const; // Used to estimate the maximum height of the flow thread. static LayoutUnit maxLogicalHeight() { return LayoutUnit::max() / 2; } - + bool regionInRange(const RenderRegion* targetRegion, const RenderRegion* startRegion, const RenderRegion* endRegion) const; + virtual bool absoluteQuadsForBox(Vector<FloatQuad>&, bool*, const RenderBox*, float, float) const { return false; } + + void layout() override; + + void setCurrentRegionMaintainer(CurrentRenderRegionMaintainer* currentRegionMaintainer) { m_currentRegionMaintainer = currentRegionMaintainer; } + RenderRegion* currentRegion() const; + + ContainingRegionMap& containingRegionMap(); + + bool cachedFlowThreadContainingBlockNeedsUpdate() const override { return false; } + + // FIXME: Eventually as column and region flow threads start nesting, this may end up changing. + virtual bool shouldCheckColumnBreaks() const { return false; } + +private: + // Always create a RenderLayer for the RenderFlowThread so that we + // can easily avoid drawing the children directly. + bool requiresLayer() const final { return true; } + protected: - virtual const char* renderName() const = 0; + RenderFlowThread(Document&, RenderStyle&&); + + RenderFlowThread* locateFlowThreadContainingBlock() const override { return const_cast<RenderFlowThread*>(this); } + + const char* renderName() const override = 0; // Overridden by columns/pages to set up an initial logical width of the page width even when // no regions have been generated yet. virtual LayoutUnit initialLogicalWidth() const { return 0; }; + + void clearLinesToRegionMap(); + void willBeDestroyed() override; - virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const override; + void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override; - void updateRegionsFlowThreadPortionRect(const RenderRegion* = 0); + void updateRegionsFlowThreadPortionRect(const RenderRegion* = nullptr); bool shouldRepaint(const LayoutRect&) const; - LayoutRect computeRegionClippingRect(const LayoutPoint&, const LayoutRect&, const LayoutRect&) const; - -#if USE(ACCELERATED_COMPOSITING) bool updateAllLayerToRegionMappings(); // Triggers a layers' update if a layer has moved from a region to another since the last update. void updateLayerToRegionMappings(RenderLayer&, LayerToRegionMap&, RegionToLayerListMap&, bool& needsLayerUpdate); - RenderNamedFlowFragment* regionForCompositedLayer(RenderLayer*); - bool updateLayerToRegionMappings(); void updateRegionForRenderLayer(RenderLayer*, LayerToRegionMap&, RegionToLayerListMap&, bool& needsLayerUpdate); -#endif - - void setDispatchRegionLayoutUpdateEvent(bool value) { m_dispatchRegionLayoutUpdateEvent = value; } - bool shouldDispatchRegionLayoutUpdateEvent() { return m_dispatchRegionLayoutUpdateEvent; } - - void setDispatchRegionOversetChangeEvent(bool value) { m_dispatchRegionOversetChangeEvent = value; } - bool shouldDispatchRegionOversetChangeEvent() const { return m_dispatchRegionOversetChangeEvent; } - - // Override if the flow thread implementation supports dispatching events when the flow layout is updated (e.g. for named flows) - virtual void dispatchRegionLayoutUpdateEvent() { m_dispatchRegionLayoutUpdateEvent = false; } - virtual void dispatchRegionOversetChangeEvent() { m_dispatchRegionOversetChangeEvent = false; } - void initializeRegionsComputedAutoHeight(RenderRegion* = 0); - - virtual void autoGenerateRegionsToBlockOffset(LayoutUnit) { }; + void initializeRegionsComputedAutoHeight(RenderRegion* = nullptr); inline bool hasCachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*) const; inline LayoutUnit cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*) const; @@ -267,6 +271,11 @@ protected: inline const RenderBox* currentActiveRenderBox() const; + bool getRegionRangeForBoxFromCachedInfo(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const; + + void removeRenderBoxRegionInfo(RenderBox&); + void removeLineRegionInfo(const RenderBlockFlow&); + RenderRegionList m_regionList; unsigned short m_previousRegionCount; @@ -274,7 +283,7 @@ protected: public: RenderRegionRange() { - setRange(0, 0); + setRange(nullptr, nullptr); } RenderRegionRange(RenderRegion* start, RenderRegion* end) @@ -307,7 +316,7 @@ protected: public: RegionSearchAdapter(LayoutUnit offset) : m_offset(offset) - , m_result(0) + , m_result(nullptr) { } @@ -322,13 +331,14 @@ protected: RenderRegion* m_result; }; -#if USE(ACCELERATED_COMPOSITING) - // To easily find the region where a layer should be painted. - OwnPtr<LayerToRegionMap> m_layerToRegionMap; + // Map a layer to the region in which the layer is painted. + std::unique_ptr<LayerToRegionMap> m_layerToRegionMap; - // To easily find the list of layers that paint in a region. - OwnPtr<RegionToLayerListMap> m_regionToLayerListMap; -#endif + // Map a region to the list of layers that paint in that region. + std::unique_ptr<RegionToLayerListMap> m_regionToLayerListMap; + + // Map a line to its containing region. + std::unique_ptr<ContainingRegionMap> m_lineToRegionMap; // Map a box to the list of regions in which the box is rendered. typedef HashMap<const RenderBox*, RenderRegionRange> RenderRegionRangeMap; @@ -339,7 +349,7 @@ protected: RenderBoxToRegionMap m_breakBeforeToRegionMap; RenderBoxToRegionMap m_breakAfterToRegionMap; - typedef ListHashSet<const RenderObject*> RenderObjectStack; + typedef Vector<const RenderObject*> RenderObjectStack; RenderObjectStack m_activeObjectsStack; typedef HashMap<const RenderBox*, LayoutUnit> RenderBoxToOffsetMap; @@ -349,29 +359,17 @@ protected: RegionIntervalTree m_regionIntervalTree; + CurrentRenderRegionMaintainer* m_currentRegionMaintainer; + bool m_regionsInvalidated : 1; bool m_regionsHaveUniformLogicalWidth : 1; bool m_regionsHaveUniformLogicalHeight : 1; - bool m_dispatchRegionLayoutUpdateEvent : 1; - bool m_dispatchRegionOversetChangeEvent : 1; bool m_pageLogicalSizeChanged : 1; unsigned m_layoutPhase : 2; bool m_needsTwoPhasesLayout : 1; bool m_layersToRegionMappingsDirty : 1; }; -RENDER_OBJECT_TYPE_CASTS(RenderFlowThread, isRenderFlowThread()) - -class CurrentRenderFlowThreadMaintainer { - WTF_MAKE_NONCOPYABLE(CurrentRenderFlowThreadMaintainer); -public: - CurrentRenderFlowThreadMaintainer(RenderFlowThread*); - ~CurrentRenderFlowThreadMaintainer(); -private: - RenderFlowThread* m_renderFlowThread; - RenderFlowThread* m_previousRenderFlowThread; -}; - // This structure is used by PODIntervalTree for debugging. #ifndef NDEBUG template <> struct ValueToString<RenderRegion*> { @@ -381,4 +379,4 @@ template <> struct ValueToString<RenderRegion*> { } // namespace WebCore -#endif // RenderFlowThread_h +SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFlowThread, isRenderFlowThread()) |