| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SKY_ENGINE_CORE_RENDERING_RENDERPARAGRAPH_H_ | 5 #ifndef SKY_ENGINE_CORE_RENDERING_RENDERPARAGRAPH_H_ |
| 6 #define SKY_ENGINE_CORE_RENDERING_RENDERPARAGRAPH_H_ | 6 #define SKY_ENGINE_CORE_RENDERING_RENDERPARAGRAPH_H_ |
| 7 | 7 |
| 8 #include "sky/engine/core/dom/ContainerNode.h" | 8 #include "sky/engine/core/dom/ContainerNode.h" |
| 9 #include "sky/engine/core/rendering/RenderBlockFlow.h" | 9 #include "sky/engine/core/rendering/RenderBlock.h" |
| 10 #include "sky/engine/core/rendering/line/TrailingObjects.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 14 struct BidiRun; |
| 13 class ContainerNode; | 15 class ContainerNode; |
| 16 // class InlineBidiResolver; |
| 17 class InlineIterator; |
| 14 | 18 |
| 15 class RenderParagraph final : public RenderBlockFlow { | 19 class RenderParagraph final : public RenderBlock { |
| 16 public: | 20 public: |
| 17 explicit RenderParagraph(ContainerNode*); | 21 explicit RenderParagraph(ContainerNode*); |
| 18 virtual ~RenderParagraph(); | 22 virtual ~RenderParagraph(); |
| 19 | 23 |
| 20 static RenderParagraph* createAnonymous(Document&); | 24 static RenderParagraph* createAnonymous(Document&); |
| 21 | 25 |
| 22 bool isRenderParagraph() const override { return true; } | 26 bool isRenderParagraph() const final { return true; } |
| 27 |
| 28 void layout() final; |
| 29 |
| 30 LayoutUnit logicalRightOffsetForLine(bool shouldIndentText) const |
| 31 { |
| 32 LayoutUnit right = logicalRightOffsetForContent(); |
| 33 if (shouldIndentText && !style()->isLeftToRightDirection()) |
| 34 right -= textIndentOffset(); |
| 35 return right; |
| 36 } |
| 37 LayoutUnit logicalLeftOffsetForLine(bool shouldIndentText) const |
| 38 { |
| 39 LayoutUnit left = logicalLeftOffsetForContent(); |
| 40 if (shouldIndentText && style()->isLeftToRightDirection()) |
| 41 left += textIndentOffset(); |
| 42 return left; |
| 43 } |
| 44 |
| 45 LayoutUnit logicalLeftSelectionOffset(RenderBlock* rootBlock, LayoutUnit pos
ition) final; |
| 46 LayoutUnit logicalRightSelectionOffset(RenderBlock* rootBlock, LayoutUnit po
sition) final; |
| 23 | 47 |
| 24 virtual RootInlineBox* lineAtIndex(int) const; | 48 virtual RootInlineBox* lineAtIndex(int) const; |
| 25 virtual int lineCount(const RootInlineBox* = 0, bool* = 0) const; | 49 virtual int lineCount(const RootInlineBox* = 0, bool* = 0) const; |
| 26 | 50 |
| 51 void deleteLineBoxTree() final; |
| 52 |
| 27 GapRects inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& root
BlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 53 GapRects inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& root
BlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 28 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& las
tLogicalRight, const PaintInfo*); | 54 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& las
tLogicalRight, const PaintInfo*); |
| 29 | 55 |
| 56 static bool shouldSkipCreatingRunsForObject(RenderObject* obj) |
| 57 { |
| 58 return obj->isOutOfFlowPositioned() && !obj->style()->isOriginalDisplayI
nlineType() && !obj->container()->isRenderInline(); |
| 59 } |
| 60 |
| 61 // TODO(ojan): Remove the need for these. |
| 62 using RenderBlock::lineBoxes; |
| 63 using RenderBlock::firstLineBox; |
| 64 using RenderBlock::lastRootBox; |
| 65 |
| 66 struct FloatWithRect { |
| 67 FloatWithRect(RenderBox* f) |
| 68 : object(f) |
| 69 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(),
f->width() + f->marginWidth(), f->height() + f->marginHeight())) |
| 70 , everHadLayout(f->everHadLayout()) |
| 71 { |
| 72 } |
| 73 |
| 74 RenderBox* object; |
| 75 LayoutRect rect; |
| 76 bool everHadLayout; |
| 77 }; |
| 78 |
| 30 protected: | 79 protected: |
| 31 void layoutChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutUnit b
eforeEdge, LayoutUnit afterEdge) final; | |
| 32 | |
| 33 void addOverflowFromChildren() final; | 80 void addOverflowFromChildren() final; |
| 34 | 81 |
| 35 void simplifiedNormalFlowLayout() final; | 82 void simplifiedNormalFlowLayout() final; |
| 36 | 83 |
| 37 void paintChildren(PaintInfo&, const LayoutPoint&, Vector<RenderBox*>& layer
s) final; | 84 void paintChildren(PaintInfo&, const LayoutPoint&, Vector<RenderBox*>& layer
s) final; |
| 38 | 85 |
| 39 bool hitTestContents(const HitTestRequest&, HitTestResult&, const HitTestLoc
ation& locationInContainer, const LayoutPoint& accumulatedOffset) final; | 86 bool hitTestContents(const HitTestRequest&, HitTestResult&, const HitTestLoc
ation& locationInContainer, const LayoutPoint& accumulatedOffset) final; |
| 40 | 87 |
| 41 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const; | 88 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const; |
| 42 | 89 |
| 43 void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit&
maxLogicalWidth) const final; | 90 void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit&
maxLogicalWidth) const final; |
| 44 | 91 |
| 45 int firstLineBoxBaseline() const final; | 92 int firstLineBoxBaseline() const final; |
| 46 int lastLineBoxBaseline(LineDirectionMode) const final; | 93 int lastLineBoxBaseline(LineDirectionMode) const final; |
| 47 | 94 |
| 48 private: | 95 private: |
| 49 virtual const char* renderName() const override; | 96 virtual const char* renderName() const override; |
| 50 | 97 |
| 98 void layoutChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutUnit b
eforeEdge, LayoutUnit afterEdge); |
| 99 |
| 51 void markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit logicalBot
tom, RootInlineBox* highest = 0); | 100 void markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit logicalBot
tom, RootInlineBox* highest = 0); |
| 52 | 101 |
| 102 void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*,
BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float&
availableLogicalWidth, unsigned expansionOpportunityCount); |
| 103 |
| 104 RootInlineBox* createAndAppendRootInlineBox(); |
| 105 RootInlineBox* createRootInlineBox(); |
| 53 InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox* ch
ildBox); | 106 InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox* ch
ildBox); |
| 107 InlineBox* createInlineBoxForRenderer(RenderObject*, bool isRootLineBox, boo
l isOnlyRun = false); |
| 54 RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&); | 108 RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&); |
| 55 void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&,
BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAnd
FallbackFontsMap&, VerticalPositionCache&, WordMeasurements&); | 109 void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&,
BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAnd
FallbackFontsMap&, VerticalPositionCache&, WordMeasurements&); |
| 56 BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const Lin
eInfo&, ETextAlign, float& logicalLeft, | 110 BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const Lin
eInfo&, ETextAlign, float& logicalLeft, |
| 57 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceR
un, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache&, Wo
rdMeasurements&); | 111 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceR
un, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache&, Wo
rdMeasurements&); |
| 58 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOv
erflowAndFallbackFontsMap&, VerticalPositionCache&); | 112 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOv
erflowAndFallbackFontsMap&, VerticalPositionCache&); |
| 59 // Helper function for layoutChildren() | 113 // Helper function for layoutChildren() |
| 60 RootInlineBox* createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<B
idiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun*
trailingSpaceRun, WordMeasurements&); | 114 RootInlineBox* createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<B
idiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun*
trailingSpaceRun, WordMeasurements&); |
| 61 void layoutRunsAndFloats(LineLayoutState&); | 115 void layoutRunsAndFloats(LineLayoutState&); |
| 62 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, | 116 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, |
| 63 const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiSta
tus); | 117 const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiSta
tus); |
| 64 void linkToEndLineIfNeeded(LineLayoutState&); | 118 void linkToEndLineIfNeeded(LineLayoutState&); |
| 65 void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t&
floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat); | 119 void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t&
floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat); |
| 66 RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&)
; | 120 RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&)
; |
| 67 void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineI
terator& cleanLineStart, BidiStatus& cleanLineBidiStatus); | 121 void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineI
terator& cleanLineStart, BidiStatus& cleanLineBidiStatus); |
| 68 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); | 122 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); |
| 69 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const Inlin
eIterator& endLineStart, const BidiStatus& endLineStatus); | 123 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const Inlin
eIterator& endLineStart, const BidiStatus& endLineStatus); |
| 70 void deleteEllipsisLineBoxes(); | 124 void deleteEllipsisLineBoxes(); |
| 71 void checkLinesForTextOverflow(); | 125 void checkLinesForTextOverflow(); |
| 72 }; | 126 }; |
| 73 | 127 |
| 74 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderParagraph, isRenderParagraph()); | 128 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderParagraph, isRenderParagraph()); |
| 75 | 129 |
| 76 } // namespace blink | 130 } // namespace blink |
| 77 | 131 |
| 78 #endif // SKY_ENGINE_CORE_RENDERING_RENDERPARAGRAPH_H_ | 132 #endif // SKY_ENGINE_CORE_RENDERING_RENDERPARAGRAPH_H_ |
| OLD | NEW |