summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderBlock.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderBlock.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderBlock.h')
-rw-r--r--Source/WebCore/rendering/RenderBlock.h395
1 files changed, 151 insertions, 244 deletions
diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h
index c29b078ab..af0fc3407 100644
--- a/Source/WebCore/rendering/RenderBlock.h
+++ b/Source/WebCore/rendering/RenderBlock.h
@@ -20,33 +20,27 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef RenderBlock_h
-#define RenderBlock_h
+#pragma once
-#include "ColumnInfo.h"
#include "GapRects.h"
+#include "LineWidth.h"
#include "RenderBox.h"
#include "TextRun.h"
-#include <wtf/OwnPtr.h>
+#include <memory>
#include <wtf/ListHashSet.h>
namespace WebCore {
+class LayoutState;
class LineLayoutState;
class LogicalSelectionOffsetCaches;
class RenderInline;
class RenderText;
-#if ENABLE(CSS_SHAPES)
-class ShapeInsideInfo;
-class ShapeValue;
-#endif
struct BidiRun;
struct PaintInfo;
-typedef WTF::ListHashSet<RenderBox*, 16> TrackedRendererListHashSet;
-typedef WTF::HashMap<const RenderBlock*, OwnPtr<TrackedRendererListHashSet>> TrackedDescendantsMap;
-typedef WTF::HashMap<const RenderBox*, OwnPtr<HashSet<RenderBlock*>>> TrackedContainerMap;
+typedef WTF::ListHashSet<RenderBox*> TrackedRendererListHashSet;
enum CaretType { CursorCaret, DragCaret };
enum ContainingBlockState { NewContainingBlock, SameContainingBlock };
@@ -62,34 +56,32 @@ typedef unsigned TextRunFlags;
class RenderBlock : public RenderBox {
public:
friend class LineLayoutState;
+ virtual ~RenderBlock();
protected:
- RenderBlock(Element&, PassRef<RenderStyle>, unsigned baseTypeFlags);
- RenderBlock(Document&, PassRef<RenderStyle>, unsigned baseTypeFlags);
- virtual ~RenderBlock();
+ RenderBlock(Element&, RenderStyle&&, BaseTypeFlags);
+ RenderBlock(Document&, RenderStyle&&, BaseTypeFlags);
public:
- bool beingDestroyed() const { return m_beingDestroyed; }
-
// These two functions are overridden for inline-block.
- virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
- virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
+ LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const final;
+ int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
LayoutUnit minLineHeightForReplacedRenderer(bool isFirstLine, LayoutUnit replacedHeight) const;
// FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
virtual void deleteLines();
- virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override;
- virtual void removeChild(RenderObject&) override;
+ void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override;
+ void removeChild(RenderObject&) override;
virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
- void invalidateLineLayoutPath();
+ virtual void invalidateLineLayoutPath() { }
void insertPositionedObject(RenderBox&);
- static void removePositionedObject(RenderBox&);
- void removePositionedObjects(RenderBlock*, ContainingBlockState = SameContainingBlock);
+ static void removePositionedObject(const RenderBox&);
+ void removePositionedObjects(const RenderBlock*, ContainingBlockState = SameContainingBlock);
TrackedRendererListHashSet* positionedObjects() const;
bool hasPositionedObjects() const
@@ -106,11 +98,13 @@ public:
static void clearPercentHeightDescendantsFrom(RenderBox&);
static void removePercentHeightDescendantIfNeeded(RenderBox&);
- void setHasMarginBeforeQuirk(bool b) { m_hasMarginBeforeQuirk = b; }
- void setHasMarginAfterQuirk(bool b) { m_hasMarginAfterQuirk = b; }
+ void setHasMarginBeforeQuirk(bool b) { setRenderBlockHasMarginBeforeQuirk(b); }
+ void setHasMarginAfterQuirk(bool b) { setRenderBlockHasMarginAfterQuirk(b); }
+ void setShouldForceRelayoutChildren(bool b) { setRenderBlockShouldForceRelayoutChildren(b); }
- bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; }
- bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; }
+ bool hasMarginBeforeQuirk() const { return renderBlockHasMarginBeforeQuirk(); }
+ bool hasMarginAfterQuirk() const { return renderBlockHasMarginAfterQuirk(); }
+ bool hasBorderOrPaddingLogicalWidthChanged() const { return renderBlockShouldForceRelayoutChildren(); }
bool hasMarginBeforeQuirk(const RenderBox& child) const;
bool hasMarginAfterQuirk(const RenderBox& child) const;
@@ -118,67 +112,55 @@ public:
bool generatesLineBoxesForInlineChild(RenderObject*);
void markPositionedObjectsForLayout();
- virtual void markForPaginationRelayoutIfNeeded() override final;
+ void markForPaginationRelayoutIfNeeded() override;
// FIXME-BLOCKFLOW: Remove virtualizaion when all of the line layout code has been moved out of RenderBlock
virtual bool containsFloats() const { return false; }
// Versions that can compute line offsets with the region and page offset passed in. Used for speed to avoid having to
// compute the region all over again when you already know it.
- LayoutUnit availableLogicalWidthForLineInRegion(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
+ LayoutUnit availableLogicalWidthForLineInRegion(LayoutUnit position, IndentTextOrNot shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
{
return std::max<LayoutUnit>(0, logicalRightOffsetForLineInRegion(position, shouldIndentText, region, logicalHeight)
- logicalLeftOffsetForLineInRegion(position, shouldIndentText, region, logicalHeight));
}
- LayoutUnit logicalRightOffsetForLineInRegion(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
+ LayoutUnit logicalRightOffsetForLineInRegion(LayoutUnit position, IndentTextOrNot shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
{
return logicalRightOffsetForLine(position, logicalRightOffsetForContent(region), shouldIndentText, logicalHeight);
}
- LayoutUnit logicalLeftOffsetForLineInRegion(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
+ LayoutUnit logicalLeftOffsetForLineInRegion(LayoutUnit position, IndentTextOrNot shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
{
return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(region), shouldIndentText, logicalHeight);
}
- LayoutUnit startOffsetForLineInRegion(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
+ LayoutUnit startOffsetForLineInRegion(LayoutUnit position, IndentTextOrNot shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
{
return style().isLeftToRightDirection() ? logicalLeftOffsetForLineInRegion(position, shouldIndentText, region, logicalHeight)
: logicalWidth() - logicalRightOffsetForLineInRegion(position, shouldIndentText, region, logicalHeight);
}
- LayoutUnit endOffsetForLineInRegion(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
+ LayoutUnit endOffsetForLineInRegion(LayoutUnit position, IndentTextOrNot shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
{
return !style().isLeftToRightDirection() ? logicalLeftOffsetForLineInRegion(position, shouldIndentText, region, logicalHeight)
: logicalWidth() - logicalRightOffsetForLineInRegion(position, shouldIndentText, region, logicalHeight);
}
- LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
+ LayoutUnit availableLogicalWidthForLine(LayoutUnit position, IndentTextOrNot shouldIndentText, LayoutUnit logicalHeight = 0) const
{
return availableLogicalWidthForLineInRegion(position, shouldIndentText, regionAtBlockOffset(position), logicalHeight);
}
- LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
+ LayoutUnit logicalRightOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText, LayoutUnit logicalHeight = 0) const
{
return logicalRightOffsetForLine(position, logicalRightOffsetForContent(position), shouldIndentText, logicalHeight);
}
- LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
+ LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText, LayoutUnit logicalHeight = 0) const
{
return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(position), shouldIndentText, logicalHeight);
}
- LayoutUnit pixelSnappedLogicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
- {
- return roundToInt(logicalLeftOffsetForLine(position, shouldIndentText, logicalHeight));
- }
- LayoutUnit pixelSnappedLogicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
- {
- // FIXME: Multicolumn layouts break carrying over subpixel values to the logical right offset because the lines may be shifted
- // by a subpixel value for all but the first column. This can lead to the actual pixel snapped width of the column being off
- // by one pixel when rendered versus layed out, which can result in the line being clipped. For now, we have to floor.
- // https://bugs.webkit.org/show_bug.cgi?id=105461
- return floorToInt(logicalRightOffsetForLine(position, shouldIndentText, logicalHeight));
- }
- LayoutUnit startOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
+ LayoutUnit startOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText, LayoutUnit logicalHeight = 0) const
{
return style().isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, logicalHeight)
: logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, logicalHeight);
}
- LayoutUnit endOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
+ LayoutUnit endOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText, LayoutUnit logicalHeight = 0) const
{
return !style().isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, logicalHeight)
: logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, logicalHeight);
@@ -186,87 +168,55 @@ public:
LayoutUnit textIndentOffset() const;
- virtual VisiblePosition positionForPoint(const LayoutPoint&) override;
-
- // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
- virtual LayoutUnit availableLogicalWidth() const override final;
-
- LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
- void adjustStartEdgeForWritingModeIncludingColumns(LayoutRect&) const;
+ VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) override;
GapRects selectionGapRectsForRepaint(const RenderLayerModelObject* repaintContainer);
LayoutRect logicalLeftSelectionGap(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
- RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&, const PaintInfo*);
+ RenderBoxModelObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&, const PaintInfo*);
LayoutRect logicalRightSelectionGap(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
- RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&, const PaintInfo*);
+ RenderBoxModelObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&, const PaintInfo*);
void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap);
- RenderBlock* blockBeforeWithinSelectionRoot(LayoutSize& offset) const;
+ bool isSelectionRoot() const;
LayoutRect logicalRectToPhysicalRect(const LayoutPoint& physicalPosition, const LayoutRect& logicalRect);
- void adjustRectForColumns(LayoutRect&) const;
- virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const override final;
- void adjustForColumnRect(LayoutSize& offset, const LayoutPoint& locationInContainer) const;
-
void addContinuationWithOutline(RenderInline*);
bool paintsContinuationOutline(RenderInline*);
- virtual RenderBoxModelObject* virtualContinuation() const override final { return continuation(); }
+ RenderBoxModelObject* virtualContinuation() const final { return continuation(); }
bool isAnonymousBlockContinuation() const { return isAnonymousBlock() && continuation(); }
- RenderInline* inlineElementContinuation() const;
+ WEBCORE_EXPORT RenderInline* inlineElementContinuation() const;
RenderBlock* blockElementContinuation() const;
using RenderBoxModelObject::continuation;
using RenderBoxModelObject::setContinuation;
- static RenderBlock* createAnonymousWithParentRendererAndDisplay(const RenderObject*, EDisplay = BLOCK);
- static RenderBlock* createAnonymousColumnsWithParentRenderer(const RenderObject*);
- static RenderBlock* createAnonymousColumnSpanWithParentRenderer(const RenderObject*);
- RenderBlock* createAnonymousBlock(EDisplay display = BLOCK) const { return createAnonymousWithParentRendererAndDisplay(this, display); }
- RenderBlock* createAnonymousColumnsBlock() const { return createAnonymousColumnsWithParentRenderer(this); }
- RenderBlock* createAnonymousColumnSpanBlock() const { return createAnonymousColumnSpanWithParentRenderer(this); }
- static void collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* child);
+ static std::unique_ptr<RenderBlock> createAnonymousWithParentRendererAndDisplay(const RenderBox& parent, EDisplay = BLOCK);
+ RenderBlock* createAnonymousBlock(EDisplay = BLOCK) const;
+ static void dropAnonymousBoxChild(RenderBlock& parent, RenderBlock& child);
- virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const override;
+ std::unique_ptr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox&) const override;
- static bool shouldSkipCreatingRunsForObject(RenderObject* obj)
+ static bool shouldSkipCreatingRunsForObject(RenderObject& obj)
{
- return obj->isFloating() || (obj->isOutOfFlowPositioned() && !obj->style().isOriginalDisplayInlineType() && !obj->container()->isRenderInline());
+ return obj.isFloating() || (obj.isOutOfFlowPositioned() && !obj.style().isOriginalDisplayInlineType() && !obj.container()->isRenderInline());
}
- static TextRun constructTextRun(RenderObject* context, const Font&, const String&, const RenderStyle&,
- TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);
-
- static TextRun constructTextRun(RenderObject* context, const Font&, const RenderText*, const RenderStyle&,
- TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion);
-
- static TextRun constructTextRun(RenderObject* context, const Font&, const RenderText*, unsigned offset, unsigned length, const RenderStyle&,
- TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion);
-
- static TextRun constructTextRun(RenderObject* context, const Font&, const RenderText*, unsigned offset, const RenderStyle&,
- TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion);
-
-#if ENABLE(8BIT_TEXTRUN)
- static TextRun constructTextRun(RenderObject* context, const Font&, const LChar* characters, int length, const RenderStyle&,
- TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion);
-#endif
-
- static TextRun constructTextRun(RenderObject* context, const Font&, const UChar* characters, int length, const RenderStyle&,
- TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion);
-
- ColumnInfo* columnInfo() const;
- int columnGap() const;
-
- // FIXME: Can devirtualize this and only have the RenderBlockFlow version once the old multi-column code is gone.
- virtual void updateColumnProgressionFromStyle(RenderStyle*);
+ static TextRun constructTextRun(StringView, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ static TextRun constructTextRun(const String&, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ static TextRun constructTextRun(const AtomicString&, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ static TextRun constructTextRun(const RenderText&, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
+ static TextRun constructTextRun(const RenderText&, unsigned offset, unsigned length, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
+ static TextRun constructTextRun(const LChar* characters, unsigned length, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
+ static TextRun constructTextRun(const UChar* characters, unsigned length, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
- LayoutUnit initialBlockOffsetForPainting() const;
- LayoutUnit blockDeltaForPaintingNextColumn() const;
-
- // These two functions take the ColumnInfo* to avoid repeated lookups of the info in the global HashMap.
- unsigned columnCount(ColumnInfo*) const;
- LayoutRect columnRectAt(ColumnInfo*, unsigned) const;
-
LayoutUnit paginationStrut() const;
void setPaginationStrut(LayoutUnit);
@@ -279,6 +229,7 @@ public:
enum ApplyLayoutDeltaMode { ApplyLayoutDelta, DoNotApplyLayoutDelta };
LayoutUnit logicalWidthForChild(const RenderBox& child) const { return isHorizontalWritingMode() ? child.width() : child.height(); }
LayoutUnit logicalHeightForChild(const RenderBox& child) const { return isHorizontalWritingMode() ? child.height() : child.width(); }
+ LayoutSize logicalSizeForChild(const RenderBox& child) const { return isHorizontalWritingMode() ? child.size() : child.size().transposedSize(); }
LayoutUnit logicalTopForChild(const RenderBox& child) const { return isHorizontalWritingMode() ? child.y() : child.x(); }
void setLogicalLeftForChild(RenderBox& child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
void setLogicalTopForChild(RenderBox& child, LayoutUnit logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
@@ -293,7 +244,9 @@ public:
LayoutUnit collapsedMarginBeforeForChild(const RenderBox& child) const;
LayoutUnit collapsedMarginAfterForChild(const RenderBox& child) const;
- virtual void updateFirstLetter();
+ enum class RenderTreeMutationIsAllowed { Yes, No };
+ virtual void updateFirstLetter(RenderTreeMutationIsAllowed = RenderTreeMutationIsAllowed::Yes);
+ void getFirstLetter(RenderObject*& firstLetter, RenderElement*& firstLetterContainer, RenderObject* skipObject = nullptr);
virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/) { }
@@ -341,45 +294,38 @@ public:
LayoutUnit computeStartPositionDeltaForChildAvoidingFloats(const RenderBox& child, LayoutUnit childMarginStart, RenderRegion* = 0);
- void placeRunInIfNeeded(RenderObject& newChild);
- bool runInIsPlacedIntoSiblingBlock(RenderObject& runIn);
-
#ifndef NDEBUG
void checkPositionedObjectsNeedLayout();
- virtual void showLineTreeAndMark(const InlineBox* = nullptr, const char* = nullptr, const InlineBox* = nullptr, const char* = nullptr, const RenderObject* = nullptr) const;
#endif
-#if ENABLE(CSS_SHAPES)
- ShapeInsideInfo& ensureShapeInsideInfo();
- ShapeInsideInfo* shapeInsideInfo() const;
- void setShapeInsideInfo(std::unique_ptr<ShapeInsideInfo>);
-
- void markShapeInsideDescendantsForLayout();
- ShapeInsideInfo* layoutShapeInsideInfo() const;
- bool allowsShapeInsideInfoSharing() const { return !isInline() && !isFloating(); }
- LayoutSize logicalOffsetFromShapeAncestorContainer(const RenderBlock* container) const;
- virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) override;
-#endif
+ void updateHitTestResult(HitTestResult&, const LayoutPoint&) override;
- virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) override;
+ bool canHaveChildren() const override { return true; }
+ virtual bool canDropAnonymousBlockChild() const { return true; }
- virtual bool canHaveChildren() const override { return true; }
- virtual bool canCollapseAnonymousBlockChild() const { return true; }
+ RenderFlowThread* cachedFlowThreadContainingBlock() const;
+ void setCachedFlowThreadContainingBlockNeedsUpdate();
+ virtual bool cachedFlowThreadContainingBlockNeedsUpdate() const;
+ void resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
protected:
- virtual void willBeDestroyed() override;
+ RenderFlowThread* locateFlowThreadContainingBlock() const override;
+ void willBeDestroyed() override;
- virtual void layout() override;
+ void layout() override;
void layoutPositionedObjects(bool relayoutChildren, bool fixedPositionObjectsOnly = false);
- void markFixedPositionObjectForLayoutIfNeeded(RenderObject& child);
+ virtual void layoutPositionedObject(RenderBox&, bool relayoutChildren, bool fixedPositionObjectsOnly);
+
+ void markFixedPositionObjectForLayoutIfNeeded(RenderBox& child);
LayoutUnit marginIntrinsicLogicalWidthForChild(RenderBox&) const;
- virtual void paint(PaintInfo&, const LayoutPoint&) override;
- virtual void paintObject(PaintInfo&, const LayoutPoint&) override;
+ void paint(PaintInfo&, const LayoutPoint&) override;
+ void paintObject(PaintInfo&, const LayoutPoint&) override;
virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect);
- bool paintChild(RenderBox&, PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect);
+ enum PaintBlockType { PaintAsBlock, PaintAsInlineBlock };
+ bool paintChild(RenderBox&, PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect, PaintBlockType paintType = PaintAsBlock);
LayoutUnit logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const
{
@@ -390,43 +336,44 @@ protected:
return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logicalTop, fixedOffset, logicalHeight), applyTextIndent);
}
- 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;
- virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
- virtual void computePreferredLogicalWidths() override;
- void adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
+ void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
+ void computePreferredLogicalWidths() override;
+
+ std::optional<int> firstLineBaseline() const override;
+ std::optional<int> inlineBlockBaseline(LineDirectionMode) const override;
- virtual int firstLineBaseline() const override;
- virtual int inlineBlockBaseline(LineDirectionMode) const override;
+ // Delay updating scrollbars until endAndCommitUpdateScrollInfoAfterLayoutTransaction() is called. These functions are used
+ // when a flexbox is laying out its descendants. If multiple calls are made to beginUpdateScrollInfoAfterLayoutTransaction()
+ // then endAndCommitUpdateScrollInfoAfterLayoutTransaction() will do nothing until it is called the same number of times.
+ void beginUpdateScrollInfoAfterLayoutTransaction();
+ void endAndCommitUpdateScrollInfoAfterLayoutTransaction();
- // Delay update scrollbar until finishDelayRepaint() will be
- // called. This function is used when a flexbox is laying out its
- // descendant. If multiple calls are made to startDelayRepaint(),
- // finishDelayRepaint() will do nothing until finishDelayRepaint()
- // is called the same number of times.
- static void startDelayUpdateScrollInfo();
- static void finishDelayUpdateScrollInfo();
+ void removeFromUpdateScrollInfoAfterLayoutTransaction();
void updateScrollInfoAfterLayout();
- void removeFromDelayedUpdateScrollInfoSet();
- virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle) override;
- virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
+ void styleWillChange(StyleDifference, const RenderStyle& newStyle) override;
+ void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
virtual bool hasLineIfEmpty() const;
+ virtual bool canPerformSimplifiedLayout() const;
bool simplifiedLayout();
virtual void simplifiedNormalFlowLayout();
- // FIXME: Can de-virtualize this once old columns go away.
- virtual void setComputedColumnCountAndWidth(int, LayoutUnit);
+ bool childBoxIsUnsplittableForFragmentation(const RenderBox& child) const;
public:
virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false);
void clearLayoutOverflow();
- bool isTopLayoutOverflowAllowed() const override;
- bool isLeftLayoutOverflowAllowed() const override;
+ // Adjust from painting offsets to the local coords of this renderer
+ void offsetForContents(LayoutPoint&) const;
+ // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
+ // children.
+ RenderBlock* firstLineBlock() const override;
protected:
virtual void addOverflowFromChildren();
@@ -436,11 +383,9 @@ protected:
void addOverflowFromPositionedObjects();
void addVisualOverflowFromTheme();
- virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) override;
- virtual void addFocusRingRectsForInlineChildren(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer);
+ void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) override;
+ virtual void addFocusRingRectsForInlineChildren(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer);
- bool updateShapesBeforeBlockLayout();
- void updateShapesAfterBlockLayout(bool heightChanged = false);
void computeRegionRangeForBoxChild(const RenderBox&) const;
void estimateRegionRangeForBoxChild(const RenderBox&) const;
@@ -448,9 +393,13 @@ protected:
void updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, RenderBox&);
- void prepareShapesAndPaginationBeforeBlockLayout(bool&);
+ void preparePaginationBeforeBlockLayout(bool&);
+
+ void blockWillBeDestroyed();
private:
+ static std::unique_ptr<RenderBlock> createAnonymousBlockWithStyleAndDisplay(Document&, const RenderStyle&, EDisplay);
+
// FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
virtual LayoutUnit logicalRightFloatOffsetForLine(LayoutUnit, LayoutUnit fixedOffset, LayoutUnit) const { return fixedOffset; };
// FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
@@ -458,37 +407,24 @@ private:
LayoutUnit adjustLogicalRightOffsetForLine(LayoutUnit offsetFromFloats, bool applyTextIndent) const;
LayoutUnit adjustLogicalLeftOffsetForLine(LayoutUnit offsetFromFloats, bool applyTextIndent) const;
-#if ENABLE(CSS_SHAPES)
- void computeShapeSize();
- void updateShapeInsideInfoAfterStyleChange(const ShapeValue*, const ShapeValue* oldShape);
- void relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset);
-#endif
-
- virtual const char* renderName() const override;
+ const char* renderName() const override;
- virtual bool isInlineBlockOrInlineTable() const override final { return isInline() && isReplaced(); }
+ bool isInlineBlockOrInlineTable() const final { return isInline() && isReplaced(); }
void makeChildrenNonInline(RenderObject* insertionPoint = nullptr);
virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
// FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
- virtual void moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveInsert) { moveAllChildrenTo(toBlock, fullRemoveInsert); }
+ virtual void moveAllChildrenIncludingFloatsTo(RenderBlock& toBlock, bool fullRemoveInsert) { moveAllChildrenTo(&toBlock, fullRemoveInsert); }
void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
- virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild) override;
- void addChildToAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild);
+ void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild) override;
- void addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild = 0);
+ bool isSelfCollapsingBlock() const override;
+ virtual bool childrenPreventSelfCollapsing() const;
- virtual bool isSelfCollapsingBlock() const override final;
- // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
- virtual bool hasLines() const { return false; }
-
- void insertIntoTrackedRendererMaps(RenderBox& descendant, TrackedDescendantsMap*&, TrackedContainerMap*&);
- static void removeFromTrackedRendererMaps(RenderBox& descendant, TrackedDescendantsMap*&, TrackedContainerMap*&);
-
- void createFirstLetterRenderer(RenderObject* firstLetterBlock, RenderText* currentTextChild);
- void updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderObject* firstLetterContainer);
+ void createFirstLetterRenderer(RenderElement* firstLetterBlock, RenderText* currentTextChild);
+ void updateFirstLetterStyle(RenderElement* firstLetterBlock, RenderObject* firstLetterContainer);
Node* nodeForHitTest() const;
@@ -496,42 +432,33 @@ private:
virtual void paintFloats(PaintInfo&, const LayoutPoint&, bool) { }
virtual void paintInlineChildren(PaintInfo&, const LayoutPoint&) { }
void paintContents(PaintInfo&, const LayoutPoint&);
- void paintColumnContents(PaintInfo&, const LayoutPoint&, bool paintFloats = false);
- void paintColumnRules(PaintInfo&, const LayoutPoint&);
+ virtual void paintColumnRules(PaintInfo&, const LayoutPoint&) { };
void paintSelection(PaintInfo&, const LayoutPoint&);
void paintCaret(PaintInfo&, const LayoutPoint&, CaretType);
- virtual bool avoidsFloats() const override;
+ bool avoidsFloats() const override;
- bool hitTestColumns(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
- // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
+ // FIXME-BLOCKFLOW: Remove virtualization when all callers have moved to RenderBlockFlow
virtual bool hitTestFloats(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&) { return false; }
virtual bool hitTestInlineChildren(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction) { return false; }
virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& locationInContainer, const LayoutPoint& accumulatedOffset);
- // FIXME: Make this method const so we can remove the const_cast in computeIntrinsicLogicalWidths.
- void computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth);
void computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
- // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
- // children.
- virtual RenderBlock* firstLineBlock() const override;
+ LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const final;
+ const RenderStyle& outlineStyleForRepaint() const final;
- virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const override final;
- virtual const RenderStyle& outlineStyleForRepaint() const override final;
-
- virtual RenderElement* hoverAncestor() const override final;
- virtual void updateDragState(bool dragOn) override final;
- virtual void childBecameNonInline(RenderObject* child) override final;
+ RenderElement* hoverAncestor() const final;
+ void updateDragState(bool dragOn) final;
+ void childBecameNonInline(RenderElement&) final;
- virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool /*clipToVisibleContent*/) override final
+ LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool /*clipToVisibleContent*/) final
{
return selectionGapRectsForRepaint(repaintContainer);
}
- virtual bool shouldPaintSelectionGaps() const override final;
- bool isSelectionRoot() const;
+ bool shouldPaintSelectionGaps() const final;
GapRects selectionGaps(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const LogicalSelectionOffsetCaches&, const PaintInfo* = 0);
// FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
@@ -546,57 +473,34 @@ private:
virtual void clipOutFloatingObjects(RenderBlock&, const PaintInfo*, const LayoutPoint&, const LayoutSize&) { };
friend class LogicalSelectionOffsetCaches;
- virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const override;
- virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
-
- // FIXME: Can de-virtualize once old columns go away.
- virtual LayoutUnit computedColumnWidth() const;
- virtual unsigned computedColumnCount() const;
+ void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const override;
+ void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
void paintContinuationOutlines(PaintInfo&, const LayoutPoint&);
- virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override final;
-
- void adjustPointToColumnContents(LayoutPoint&) const;
+ LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) final;
// FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
- virtual VisiblePosition positionForPointWithInlineChildren(const LayoutPoint&);
-
- virtual void computeColumnCountAndWidth();
- void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlock* newBlockBox, RenderObject* newChild);
+ virtual VisiblePosition positionForPointWithInlineChildren(const LayoutPoint&, const RenderRegion*);
- bool expandsToEncloseOverhangingFloats() const;
-
- void splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
- RenderObject* beforeChild, RenderBoxModelObject* oldCont);
- void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
- RenderObject* newChild, RenderBoxModelObject* oldCont);
RenderPtr<RenderBlock> clone() const;
RenderBlock* continuationBefore(RenderObject* beforeChild);
- RenderBlock* containingColumnsBlock(bool allowAnonymousColumnBlock = true);
- RenderBlock* columnsBlockForSpanningElement(RenderObject* newChild);
- RenderBoxModelObject& createReplacementRunIn(RenderBoxModelObject& runIn);
- void moveRunInUnderSiblingBlockIfNeeded(RenderObject& runIn);
- void moveRunInToOriginalPosition(RenderObject& runIn);
+ RenderFlowThread* updateCachedFlowThreadContainingBlock(RenderFlowThread*) const;
+
+ void removePositionedObjectsIfNeeded(const RenderStyle& oldStyle, const RenderStyle& newStyle);
private:
bool hasRareData() const;
protected:
void dirtyForLayoutFromPercentageHeightDescendants();
-
- virtual ColumnInfo::PaginationUnit paginationUnit() const;
protected:
- // Adjust from painting offsets to the local coords of this renderer
- void offsetForContents(LayoutPoint&) const;
-
- virtual bool requiresColumns(int computedColumnCount) const;
-
- bool updateLogicalWidthAndColumnWidth();
+ bool recomputeLogicalWidth();
+
public:
- virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const override;
+ LayoutUnit offsetFromLogicalTopOfFirstPage() const override;
RenderRegion* regionAtBlockOffset(LayoutUnit) const;
// FIXME: This is temporary to allow us to move code from RenderBlock into RenderBlockFlow that accesses member variables that we haven't moved out of
@@ -605,15 +509,6 @@ public:
// FIXME-BLOCKFLOW: Remove this when the line layout stuff has all moved out of RenderBlock
friend class LineBreaker;
- mutable signed m_lineHeight : 25;
- unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in RenderBlockRareData since they are set too frequently.
- unsigned m_hasMarginAfterQuirk : 1;
- unsigned m_beingDestroyed : 1;
- unsigned m_hasMarkupTruncation : 1;
- unsigned m_hasBorderOrPaddingLogicalWidthChanged : 1;
- unsigned m_lineLayoutPath : 2;
- enum LineLayoutPath { UndeterminedPath, SimpleLinesPath, LineBoxesPath, ForceLineBoxesPath };
-
// RenderRubyBase objects need to be able to split and merge, moving their children around
// (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
friend class RenderRubyBase;
@@ -623,13 +518,25 @@ private:
static bool s_canPropagateFloatIntoSibling;
};
-template<> inline bool isRendererOfType<const RenderBlock>(const RenderObject& renderer) { return renderer.isRenderBlock(); }
-RENDER_OBJECT_TYPE_CASTS(RenderBlock, isRenderBlock())
-
LayoutUnit blockDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
LayoutUnit inlineDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
VisiblePosition positionForPointRespectingEditingBoundaries(RenderBlock&, RenderBox&, const LayoutPoint&);
+inline std::unique_ptr<RenderBlock> RenderBlock::createAnonymousWithParentRendererAndDisplay(const RenderBox& parent, EDisplay display)
+{
+ return createAnonymousBlockWithStyleAndDisplay(parent.document(), parent.style(), display);
+}
+
+inline std::unique_ptr<RenderBox> RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderBox& renderer) const
+{
+ return createAnonymousBlockWithStyleAndDisplay(document(), renderer.style(), style().display());
+}
+
+inline RenderBlock* RenderBlock::createAnonymousBlock(EDisplay display) const
+{
+ return createAnonymousBlockWithStyleAndDisplay(document(), style(), display).release();
+}
+
} // namespace WebCore
-#endif // RenderBlock_h
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBlock, isRenderBlock())