OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * Copyright (C) 2013 Google Inc. All rights reserved. | 7 * Copyright (C) 2013 Google Inc. All rights reserved. |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions are | 10 * modification, are permitted provided that the following conditions are |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 bool containsFloat(LayoutBox*) const; | 112 bool containsFloat(LayoutBox*) const; |
113 | 113 |
114 void removeFloatingObjects(); | 114 void removeFloatingObjects(); |
115 | 115 |
116 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0) override; | 116 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0) override; |
117 | 117 |
118 void moveAllChildrenIncludingFloatsTo(LayoutBlock* toBlock, bool fullRemoveI nsert); | 118 void moveAllChildrenIncludingFloatsTo(LayoutBlock* toBlock, bool fullRemoveI nsert); |
119 | 119 |
120 bool generatesLineBoxesForInlineChild(LayoutObject*); | 120 bool generatesLineBoxesForInlineChild(LayoutObject*); |
121 | 121 |
122 LayoutUnit logicalTopForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->y() : floatingObject->x(); } | 122 LayoutUnit logicalTopForFloat(const FloatingObject& floatingObject) const { return isHorizontalWritingMode() ? floatingObject.y() : floatingObject.x(); } |
123 LayoutUnit logicalBottomForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->maxY() : floatingObject->m axX(); } | 123 LayoutUnit logicalBottomForFloat(const FloatingObject& floatingObject) const { return isHorizontalWritingMode() ? floatingObject.maxY() : floatingObject.max X(); } |
124 LayoutUnit logicalLeftForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->x() : floatingObject->y(); } | 124 LayoutUnit logicalLeftForFloat(const FloatingObject& floatingObject) const { return isHorizontalWritingMode() ? floatingObject.x() : floatingObject.y(); } |
125 LayoutUnit logicalRightForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->maxX() : floatingObject->ma xY(); } | 125 LayoutUnit logicalRightForFloat(const FloatingObject& floatingObject) const { return isHorizontalWritingMode() ? floatingObject.maxX() : floatingObject.maxY (); } |
126 LayoutUnit logicalWidthForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->width() : floatingObject->h eight(); } | 126 LayoutUnit logicalWidthForFloat(const FloatingObject& floatingObject) const { return isHorizontalWritingMode() ? floatingObject.width() : floatingObject.hei ght(); } |
127 | 127 |
128 int pixelSnappedLogicalTopForFloat(const FloatingObject* floatingObject) con st { return isHorizontalWritingMode() ? floatingObject->frameRect().pixelSnapped Y() : floatingObject->frameRect().pixelSnappedX(); } | 128 int pixelSnappedLogicalTopForFloat(const FloatingObject& floatingObject) con st { return isHorizontalWritingMode() ? floatingObject.frameRect().pixelSnappedY () : floatingObject.frameRect().pixelSnappedX(); } |
129 int pixelSnappedLogicalBottomForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->frameRect().pixelSnap pedMaxY() : floatingObject->frameRect().pixelSnappedMaxX(); } | 129 int pixelSnappedLogicalBottomForFloat(const FloatingObject& floatingObject) const { return isHorizontalWritingMode() ? floatingObject.frameRect().pixelSnapp edMaxY() : floatingObject.frameRect().pixelSnappedMaxX(); } |
130 | 130 |
131 void setLogicalTopForFloat(FloatingObject* floatingObject, LayoutUnit logica lTop) | 131 void setLogicalTopForFloat(FloatingObject& floatingObject, LayoutUnit logica lTop) |
132 { | 132 { |
133 if (isHorizontalWritingMode()) | 133 if (isHorizontalWritingMode()) |
134 floatingObject->setY(logicalTop); | 134 floatingObject.setY(logicalTop); |
135 else | 135 else |
136 floatingObject->setX(logicalTop); | 136 floatingObject.setX(logicalTop); |
137 } | 137 } |
138 void setLogicalLeftForFloat(FloatingObject* floatingObject, LayoutUnit logic alLeft) | 138 void setLogicalLeftForFloat(FloatingObject& floatingObject, LayoutUnit logic alLeft) |
139 { | 139 { |
140 if (isHorizontalWritingMode()) | 140 if (isHorizontalWritingMode()) |
141 floatingObject->setX(logicalLeft); | 141 floatingObject.setX(logicalLeft); |
142 else | 142 else |
143 floatingObject->setY(logicalLeft); | 143 floatingObject.setY(logicalLeft); |
144 } | 144 } |
145 void setLogicalHeightForFloat(FloatingObject* floatingObject, LayoutUnit log icalHeight) | 145 void setLogicalHeightForFloat(FloatingObject& floatingObject, LayoutUnit log icalHeight) |
146 { | 146 { |
147 if (isHorizontalWritingMode()) | 147 if (isHorizontalWritingMode()) |
148 floatingObject->setHeight(logicalHeight); | 148 floatingObject.setHeight(logicalHeight); |
149 else | 149 else |
150 floatingObject->setWidth(logicalHeight); | 150 floatingObject.setWidth(logicalHeight); |
151 } | 151 } |
152 void setLogicalWidthForFloat(FloatingObject* floatingObject, LayoutUnit logi calWidth) | 152 void setLogicalWidthForFloat(FloatingObject& floatingObject, LayoutUnit logi calWidth) |
153 { | 153 { |
154 if (isHorizontalWritingMode()) | 154 if (isHorizontalWritingMode()) |
155 floatingObject->setWidth(logicalWidth); | 155 floatingObject.setWidth(logicalWidth); |
156 else | 156 else |
157 floatingObject->setHeight(logicalWidth); | 157 floatingObject.setHeight(logicalWidth); |
158 } | 158 } |
159 | 159 |
160 LayoutUnit startAlignedOffsetForLine(LayoutUnit position, bool shouldIndentT ext); | 160 LayoutUnit startAlignedOffsetForLine(LayoutUnit position, bool shouldIndentT ext); |
161 | 161 |
162 void setStaticInlinePositionForChild(LayoutBox&, LayoutUnit inlinePosition); | 162 void setStaticInlinePositionForChild(LayoutBox&, LayoutUnit inlinePosition); |
163 void updateStaticInlinePositionForChild(LayoutBox&, LayoutUnit logicalTop); | 163 void updateStaticInlinePositionForChild(LayoutBox&, LayoutUnit logicalTop); |
164 | 164 |
165 static bool shouldSkipCreatingRunsForObject(LayoutObject* obj) | 165 static bool shouldSkipCreatingRunsForObject(LayoutObject* obj) |
166 { | 166 { |
167 return obj->isFloating() || (obj->isOutOfFlowPositioned() && !obj->style ()->isOriginalDisplayInlineType() && !obj->container()->isLayoutInline()); | 167 return obj->isFloating() || (obj->isOutOfFlowPositioned() && !obj->style ()->isOriginalDisplayInlineType() && !obj->container()->isLayoutInline()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 LayoutUnit paginationStrut() const { return m_rareData ? m_rareData->m_pagin ationStrut : LayoutUnit(); } | 201 LayoutUnit paginationStrut() const { return m_rareData ? m_rareData->m_pagin ationStrut : LayoutUnit(); } |
202 void setPaginationStrut(LayoutUnit); | 202 void setPaginationStrut(LayoutUnit); |
203 | 203 |
204 void positionSpannerDescendant(LayoutMultiColumnSpannerPlaceholder& child); | 204 void positionSpannerDescendant(LayoutMultiColumnSpannerPlaceholder& child); |
205 | 205 |
206 virtual bool avoidsFloats() const override; | 206 virtual bool avoidsFloats() const override; |
207 | 207 |
208 using LayoutBoxModelObject::moveChildrenTo; | 208 using LayoutBoxModelObject::moveChildrenTo; |
209 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe moveInsert = false) override; | 209 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe moveInsert = false) override; |
210 | 210 |
211 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) con st | 211 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject& child) con st |
212 { | 212 { |
213 if (isHorizontalWritingMode()) | 213 if (isHorizontalWritingMode()) |
214 return child->x() + child->layoutObject()->marginLeft(); | 214 return child.x() + child.layoutObject()->marginLeft(); |
215 | 215 |
216 return child->x() + marginBeforeForChild(*(child->layoutObject())); | 216 return child.x() + marginBeforeForChild(*(child.layoutObject())); |
217 } | 217 } |
218 | 218 |
219 LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject* child) con st | 219 LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject& child) con st |
220 { | 220 { |
221 if (isHorizontalWritingMode()) | 221 if (isHorizontalWritingMode()) |
222 return child->y() + marginBeforeForChild(*(child->layoutObject())); | 222 return child.y() + marginBeforeForChild(*(child.layoutObject())); |
223 | 223 |
224 return child->y() + child->layoutObject()->marginTop(); | 224 return child.y() + child.layoutObject()->marginTop(); |
225 } | 225 } |
226 | 226 |
227 LayoutSize positionForFloatIncludingMargin(const FloatingObject* child) cons t | 227 LayoutSize positionForFloatIncludingMargin(const FloatingObject& child) cons t |
228 { | 228 { |
229 if (isHorizontalWritingMode()) { | 229 if (isHorizontalWritingMode()) { |
230 return LayoutSize(child->x() + child->layoutObject()->marginLeft(), | 230 return LayoutSize(child.x() + child.layoutObject()->marginLeft(), |
231 child->y() + marginBeforeForChild(*(child->layoutObject()))); | 231 child.y() + marginBeforeForChild(*(child.layoutObject()))); |
Julien - ping for review
2015/06/10 15:15:44
Same comment about parentheses.
Sunil Ratnu
2015/06/11 05:49:43
Done.
| |
232 } | 232 } |
233 | 233 |
234 return LayoutSize(child->x() + marginBeforeForChild(*(child->layoutObjec t())), | 234 return LayoutSize(child.x() + marginBeforeForChild(*(child.layoutObject( ))), |
Julien - ping for review
2015/06/10 15:15:44
Ditto.
Sunil Ratnu
2015/06/11 05:49:43
Done.
| |
235 child->y() + child->layoutObject()->marginTop()); | 235 child.y() + child.layoutObject()->marginTop()); |
236 } | 236 } |
237 | 237 |
238 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const; | 238 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject&, const Lay outPoint&) const; |
239 | 239 |
240 virtual const char* name() const override { return "LayoutBlockFlow"; } | 240 virtual const char* name() const override { return "LayoutBlockFlow"; } |
241 | 241 |
242 protected: | 242 protected: |
243 void rebuildFloatsFromIntruding(); | 243 void rebuildFloatsFromIntruding(); |
244 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& paintInvalidati onLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUnit afterEdge); | 244 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& paintInvalidati onLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUnit afterEdge); |
245 | 245 |
246 void createFloatingObjects(); | 246 void createFloatingObjects(); |
247 | 247 |
248 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) override; | 248 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) override; |
(...skipping 20 matching lines...) Expand all Loading... | |
269 void determineLogicalLeftPositionForChild(LayoutBox& child); | 269 void determineLogicalLeftPositionForChild(LayoutBox& child); |
270 | 270 |
271 private: | 271 private: |
272 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&); | 272 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&); |
273 void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutU nit beforeEdge, LayoutUnit afterEdge); | 273 void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutU nit beforeEdge, LayoutUnit afterEdge); |
274 | 274 |
275 void layoutBlockChild(LayoutBox& child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom); | 275 void layoutBlockChild(LayoutBox& child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom); |
276 void adjustPositionedBlock(LayoutBox& child, const MarginInfo&); | 276 void adjustPositionedBlock(LayoutBox& child, const MarginInfo&); |
277 void adjustFloatingBlock(const MarginInfo&); | 277 void adjustFloatingBlock(const MarginInfo&); |
278 | 278 |
279 LayoutPoint computeLogicalLocationForFloat(const FloatingObject*, LayoutUnit logicalTopOffset) const; | 279 LayoutPoint computeLogicalLocationForFloat(const FloatingObject&, LayoutUnit logicalTopOffset) const; |
280 | 280 |
281 FloatingObject* insertFloatingObject(LayoutBox&); | 281 FloatingObject* insertFloatingObject(LayoutBox&); |
282 void removeFloatingObject(LayoutBox*); | 282 void removeFloatingObject(LayoutBox*); |
283 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset); | 283 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset); |
284 | 284 |
285 // Called from lineWidth, to position the floats added in the last line. | 285 // Called from lineWidth, to position the floats added in the last line. |
286 // Returns true if and only if it has positioned any floats. | 286 // Returns true if and only if it has positioned any floats. |
287 bool positionNewFloats(LineWidth* = 0); | 287 bool positionNewFloats(LineWidth* = 0); |
288 | 288 |
289 LayoutUnit getClearDelta(LayoutBox* child, LayoutUnit yPos); | 289 LayoutUnit getClearDelta(LayoutBox* child, LayoutUnit yPos); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 // line layout code is separated from LayoutBlock and LayoutBlockFlow. | 508 // line layout code is separated from LayoutBlock and LayoutBlockFlow. |
509 // START METHODS DEFINED IN LayoutBlockFlowLine | 509 // START METHODS DEFINED IN LayoutBlockFlowLine |
510 private: | 510 private: |
511 InlineFlowBox* createLineBoxes(LayoutObject*, const LineInfo&, InlineBox* ch ildBox); | 511 InlineFlowBox* createLineBoxes(LayoutObject*, const LineInfo&, InlineBox* ch ildBox); |
512 RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&); | 512 RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&); |
513 void setMarginsForRubyRun(BidiRun*, LayoutRubyRun*, LayoutObject*, const Lin eInfo&); | 513 void setMarginsForRubyRun(BidiRun*, LayoutRubyRun*, LayoutObject*, const Lin eInfo&); |
514 void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAnd FallbackFontsMap&, VerticalPositionCache&, WordMeasurements&); | 514 void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAnd FallbackFontsMap&, VerticalPositionCache&, WordMeasurements&); |
515 BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const Lin eInfo&, ETextAlign, LayoutUnit& logicalLeft, | 515 BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const Lin eInfo&, ETextAlign, LayoutUnit& logicalLeft, |
516 LayoutUnit& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingS paceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache &, WordMeasurements&); | 516 LayoutUnit& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingS paceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache &, WordMeasurements&); |
517 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOv erflowAndFallbackFontsMap&, VerticalPositionCache&); | 517 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOv erflowAndFallbackFontsMap&, VerticalPositionCache&); |
518 void appendFloatingObjectToLastLine(FloatingObject*); | 518 void appendFloatingObjectToLastLine(FloatingObject&); |
519 // Helper function for layoutInlineChildren() | 519 // Helper function for layoutInlineChildren() |
520 RootInlineBox* createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<B idiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun, WordMeasurements&); | 520 RootInlineBox* createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<B idiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun, WordMeasurements&); |
521 void layoutRunsAndFloats(LineLayoutState&); | 521 void layoutRunsAndFloats(LineLayoutState&); |
522 const InlineIterator& restartLayoutRunsAndFloatsInRange(LayoutUnit oldLogica lHeight, LayoutUnit newLogicalHeight, FloatingObject* lastFloatFromPreviousLine , InlineBidiResolver&, const InlineIterator&); | 522 const InlineIterator& restartLayoutRunsAndFloatsInRange(LayoutUnit oldLogica lHeight, LayoutUnit newLogicalHeight, FloatingObject* lastFloatFromPreviousLine , InlineBidiResolver&, const InlineIterator&); |
523 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, | 523 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, |
524 const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiSta tus); | 524 const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiSta tus); |
525 void linkToEndLineIfNeeded(LineLayoutState&); | 525 void linkToEndLineIfNeeded(LineLayoutState&); |
526 bool appendFloatsToEndOfLine(LineLayoutState&, bool updateFloatIndex); | 526 bool appendFloatsToEndOfLine(LineLayoutState&, bool updateFloatIndex); |
527 static void markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& float s); | 527 static void markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& float s); |
528 void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat); | 528 void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat); |
529 RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&) ; | 529 RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&) ; |
530 void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineI terator& cleanLineStart, BidiStatus& cleanLineBidiStatus); | 530 void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineI terator& cleanLineStart, BidiStatus& cleanLineBidiStatus); |
531 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); | 531 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); |
532 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const Inlin eIterator& endLineStart, const BidiStatus& endLineStatus); | 532 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const Inlin eIterator& endLineStart, const BidiStatus& endLineStatus); |
533 void deleteEllipsisLineBoxes(); | 533 void deleteEllipsisLineBoxes(); |
534 void checkLinesForTextOverflow(); | 534 void checkLinesForTextOverflow(); |
535 // Positions new floats and also adjust all floats encountered on the line i f any of them | 535 // Positions new floats and also adjust all floats encountered on the line i f any of them |
536 // have to move to the next page/column. | 536 // have to move to the next page/column. |
537 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFl oatFromPreviousLine, LineInfo&, LineWidth&); | 537 bool positionNewFloatOnLine(FloatingObject& newFloat, FloatingObject* lastFl oatFromPreviousLine, LineInfo&, LineWidth&); |
538 void positionDialog(); | 538 void positionDialog(); |
539 | 539 |
540 // END METHODS DEFINED IN LayoutBlockFlowLine | 540 // END METHODS DEFINED IN LayoutBlockFlowLine |
541 | 541 |
542 }; | 542 }; |
543 | 543 |
544 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlockFlow, isLayoutBlockFlow()); | 544 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlockFlow, isLayoutBlockFlow()); |
545 | 545 |
546 } // namespace blink | 546 } // namespace blink |
547 | 547 |
548 #endif // LayoutBlockFlow_h | 548 #endif // LayoutBlockFlow_h |
OLD | NEW |