diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/InlineFlowBox.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/InlineFlowBox.h')
-rw-r--r-- | Source/WebCore/rendering/InlineFlowBox.h | 125 |
1 files changed, 65 insertions, 60 deletions
diff --git a/Source/WebCore/rendering/InlineFlowBox.h b/Source/WebCore/rendering/InlineFlowBox.h index b64993492..572b02561 100644 --- a/Source/WebCore/rendering/InlineFlowBox.h +++ b/Source/WebCore/rendering/InlineFlowBox.h @@ -18,8 +18,7 @@ * */ -#ifndef InlineFlowBox_h -#define InlineFlowBox_h +#pragma once #include "InlineBox.h" #include "RenderOverflow.h" @@ -31,21 +30,21 @@ class HitTestRequest; class HitTestResult; class InlineTextBox; class RenderLineBoxList; -class SimpleFontData; +class Font; class VerticalPositionCache; struct GlyphOverflow; -typedef HashMap<const InlineTextBox*, std::pair<Vector<const SimpleFontData*>, GlyphOverflow>> GlyphOverflowAndFallbackFontsMap; +typedef HashMap<const InlineTextBox*, std::pair<Vector<const Font*>, GlyphOverflow>> GlyphOverflowAndFallbackFontsMap; class InlineFlowBox : public InlineBox { public: explicit InlineFlowBox(RenderBoxModelObject& renderer) : InlineBox(renderer) - , m_firstChild(0) - , m_lastChild(0) - , m_prevLineBox(0) - , m_nextLineBox(0) + , m_firstChild(nullptr) + , m_lastChild(nullptr) + , m_prevLineBox(nullptr) + , m_nextLineBox(nullptr) , m_includeLogicalLeftEdge(false) , m_includeLogicalRightEdge(false) , m_descendantsHaveSameLineHeightAndBaseline(true) @@ -53,7 +52,7 @@ public: , m_hasAnnotationsBefore(false) , m_hasAnnotationsAfter(false) , m_isFirstAfterPageBreak(false) - , m_hasContainingRegion(false) + , m_hasAnonymousInlineBlock(false) #if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED , m_hasBadChildList(false) #endif @@ -71,12 +70,12 @@ public: virtual ~InlineFlowBox(); #endif -#ifndef NDEBUG - virtual void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0, int = 0) const override; - virtual const char* boxName() const override; +#if ENABLE(TREE_DEBUGGING) + void showLineTreeAndMark(const InlineBox* markedBox, int depth) const override; + const char* boxName() const override; #endif - RenderBoxModelObject& renderer() const { return toRenderBoxModelObject(InlineBox::renderer()); } + RenderBoxModelObject& renderer() const { return downcast<RenderBoxModelObject>(InlineBox::renderer()); } const RenderStyle& lineStyle() const { return isFirstLine() ? renderer().firstLineStyle() : renderer().style(); } InlineFlowBox* prevLineBox() const { return m_prevLineBox; } @@ -87,15 +86,15 @@ public: InlineBox* firstChild() const { checkConsistency(); return m_firstChild; } InlineBox* lastChild() const { checkConsistency(); return m_lastChild; } - virtual bool isLeaf() const override final { return false; } + bool isLeaf() const final { return false; } InlineBox* firstLeafChild() const; InlineBox* lastLeafChild() const; typedef void (*CustomInlineBoxRangeReverse)(void* userData, Vector<InlineBox*>::iterator first, Vector<InlineBox*>::iterator last); - void collectLeafBoxesInLogicalOrder(Vector<InlineBox*>&, CustomInlineBoxRangeReverse customReverseImplementation = 0, void* userData = 0) const; + void collectLeafBoxesInLogicalOrder(Vector<InlineBox*>&, CustomInlineBoxRangeReverse customReverseImplementation = nullptr, void* userData = nullptr) const; - virtual void setConstructed() override final + void setConstructed() final { InlineBox::setConstructed(); for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) @@ -103,26 +102,24 @@ public: } void addToLine(InlineBox* child); - virtual void deleteLine() override final; - virtual void extractLine() override final; - virtual void attachLine() override final; - virtual void adjustPosition(float dx, float dy) override; + void deleteLine() final; + void extractLine() final; + void attachLine() final; + void adjustPosition(float dx, float dy) override; virtual void extractLineBoxFromRenderObject(); virtual void attachLineBoxToRenderObject(); virtual void removeLineBoxFromRenderObject(); - virtual void clearTruncation() override; + void clearTruncation() override; - IntRect roundedFrameRect() const; - void paintBoxDecorations(PaintInfo&, const LayoutPoint&); void paintMask(PaintInfo&, const LayoutPoint&); - void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver); - void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver); + void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, CompositeOperator = CompositeSourceOver); + void paintFillLayer(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, CompositeOperator = CompositeSourceOver); void paintBoxShadow(const PaintInfo&, const RenderStyle&, ShadowStyle, const LayoutRect&); - virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override; - virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) override; + void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override; + bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override; bool boxShadowCanBeAppliedToBackground(const FillLayer&) const; @@ -141,25 +138,25 @@ public: return 0; return isHorizontal() ? renderer().marginRight() : renderer().marginBottom(); } - int borderLogicalLeft() const + float borderLogicalLeft() const { if (!includeLogicalLeftEdge()) return 0; return isHorizontal() ? lineStyle().borderLeftWidth() : lineStyle().borderTopWidth(); } - int borderLogicalRight() const + float borderLogicalRight() const { if (!includeLogicalRightEdge()) return 0; return isHorizontal() ? lineStyle().borderRightWidth() : lineStyle().borderBottomWidth(); } - int paddingLogicalLeft() const + float paddingLogicalLeft() const { if (!includeLogicalLeftEdge()) return 0; return isHorizontal() ? renderer().paddingLeft() : renderer().paddingTop(); } - int paddingLogicalRight() const + float paddingLogicalRight() const { if (!includeLogicalRightEdge()) return 0; @@ -177,8 +174,8 @@ public: // Helper functions used during line construction and placement. void determineSpacingForFlowBoxes(bool lastLine, bool isLogicallyLastRunWrapped, RenderObject* logicallyLastRunRenderer); LayoutUnit getFlowSpacingLogicalWidth(); - float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&); - float placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&); + float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing); + float placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing); void beginPlacingBoxRangesInInlineDirection(float logicalLeft) { setLogicalLeft(logicalLeft); } void endPlacingBoxRangesInInlineDirection(float logicalLeft, float logicalRight, float minLogicalLeft, float maxLogicalRight) { @@ -187,13 +184,13 @@ public: clearKnownToHaveNoOverflow(); } - void computeLogicalBoxHeights(RootInlineBox*, LayoutUnit& maxPositionTop, LayoutUnit& maxPositionBottom, - int& maxAscent, int& maxDescent, bool& setMaxAscent, bool& setMaxDescent, - bool strictMode, GlyphOverflowAndFallbackFontsMap&, FontBaseline, VerticalPositionCache&); + void computeLogicalBoxHeights(RootInlineBox&, LayoutUnit& maxPositionTop, LayoutUnit& maxPositionBottom, + int& maxAscent, int& maxDescent, bool& setMaxAscent, bool& setMaxDescent, + bool strictMode, GlyphOverflowAndFallbackFontsMap&, FontBaseline, VerticalPositionCache&); void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, - int maxPositionTop, int maxPositionBottom); + int maxPositionTop, int maxPositionBottom); void placeBoxesInBlockDirection(LayoutUnit logicalTop, LayoutUnit maxHeight, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, bool& setLineTop, - LayoutUnit& lineTopIncludingMargins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline); + LayoutUnit& lineTopIncludingMargins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline); void flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lineBottom); bool requiresIdeographicBaseline(const GlyphOverflowAndFallbackFontsMap&) const; @@ -204,16 +201,20 @@ public: void removeChild(InlineBox* child); - virtual RenderObject::SelectionState selectionState() override; + RenderObject::SelectionState selectionState() override; - virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const override final; - virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool&) override; + bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const final; + float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool&) override; bool hasTextChildren() const { return m_hasTextChildren; } bool hasTextDescendants() const { return m_hasTextDescendants; } void setHasTextChildren() { m_hasTextChildren = true; setHasTextDescendants(); } void setHasTextDescendants() { m_hasTextDescendants = true; } + bool hasAnonymousInlineBlock() const { return m_hasAnonymousInlineBlock; } + void setHasAnonymousInlineBlock(bool b) { m_hasAnonymousInlineBlock = b; } + RenderBlockFlow* anonymousInlineBlock() const; + void checkConsistency() const; void setHasBadChildList(); @@ -221,7 +222,7 @@ public: // For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right // respectively are flipped when compared to their physical counterparts. For example minX is on the left in vertical-lr, but it is on the right in vertical-rl. LayoutRect layoutOverflowRect(LayoutUnit lineTop, LayoutUnit lineBottom) const - { + { return m_overflow ? m_overflow->layoutOverflowRect() : enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom)); } LayoutUnit logicalTopLayoutOverflow(LayoutUnit lineTop) const @@ -248,8 +249,8 @@ public: { return m_overflow ? m_overflow->visualOverflowRect() : enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom)); } - LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->visualOverflowRect().x() : m_overflow->visualOverflowRect().y()) : static_cast<LayoutUnit>(logicalLeft()); } - LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->visualOverflowRect().maxX() : m_overflow->visualOverflowRect().maxY()) : static_cast<LayoutUnit>(ceilf(logicalRight())); } + LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->visualOverflowRect().x() : m_overflow->visualOverflowRect().y()) : LayoutUnit(logicalLeft()); } + LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->visualOverflowRect().maxX() : m_overflow->visualOverflowRect().maxY()) : LayoutUnit(ceilf(logicalRight())); } LayoutUnit logicalTopVisualOverflow(LayoutUnit lineTop) const { if (m_overflow) @@ -294,13 +295,20 @@ public: parent()->clearDescendantsHaveSameLineHeightAndBaseline(); } + void computeReplacedAndTextLineTopAndBottom(LayoutUnit& lineTop, LayoutUnit& lineBottom) const; + + // Used to calculate the underline offset for TextUnderlinePositionUnder. + void maxLogicalBottomForTextDecorationLine(float& maxLogicalBottom, const RenderElement* decorationRenderer, TextDecoration) const; + void minLogicalTopForTextDecorationLine(float& minLogicalTop, const RenderElement* decorationRenderer, TextDecoration) const; + private: - virtual bool isInlineFlowBox() const override final { return true; } + bool isInlineFlowBox() const final { return true; } void boxModelObject() const = delete; void addBoxShadowVisualOverflow(LayoutRect& logicalVisualOverflow); void addBorderOutsetVisualOverflow(LayoutRect& logicalVisualOverflow); - void addTextBoxVisualOverflow(InlineTextBox*, GlyphOverflowAndFallbackFontsMap&, LayoutRect& logicalVisualOverflow); + void addTextBoxVisualOverflow(InlineTextBox&, GlyphOverflowAndFallbackFontsMap&, LayoutRect& logicalVisualOverflow); + void addOutlineVisualOverflow(LayoutRect& logicalVisualOverflow); void addReplacedChildOverflow(const InlineBox*, LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow); void constrainToLineTopAndBottomIfNeeded(LayoutRect&) const; @@ -313,9 +321,6 @@ protected: InlineFlowBox* m_prevLineBox; // The previous box that also uses our RenderObject InlineFlowBox* m_nextLineBox; // The next box that also uses our RenderObject - // Maximum logicalTop among all children of an InlineFlowBox. Used to - // calculate the offset for TextUnderlinePositionUnder. - void computeMaxLogicalTop(float& maxLogicalTop) const; private: unsigned m_includeLogicalLeftEdge : 1; unsigned m_includeLogicalRightEdge : 1; @@ -338,8 +343,7 @@ protected: unsigned m_lineBreakBidiStatusLast : 5; // UCharDirection unsigned m_isFirstAfterPageBreak : 1; - - unsigned m_hasContainingRegion : 1; + unsigned m_hasAnonymousInlineBlock : 1; // End of RootInlineBox-specific members. @@ -349,26 +353,27 @@ private: #endif }; -INLINE_BOX_OBJECT_TYPE_CASTS(InlineFlowBox, isInlineFlowBox()) - #ifdef NDEBUG + inline void InlineFlowBox::checkConsistency() const { } + #endif +#if ASSERT_WITH_SECURITY_IMPLICATION_DISABLED + inline void InlineFlowBox::setHasBadChildList() { -#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED - m_hasBadChildList = true; -#endif } +#endif + } // namespace WebCore -#ifndef NDEBUG -// Outside the WebCore namespace for ease of invocation from gdb. +SPECIALIZE_TYPE_TRAITS_INLINE_BOX(InlineFlowBox, isInlineFlowBox()) + +#if ENABLE(TREE_DEBUGGING) +// Outside the WebCore namespace for ease of invocation from the debugger. void showTree(const WebCore::InlineFlowBox*); #endif - -#endif // InlineFlowBox_h |