| 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, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r
ights reserved. |
| 6 * All rights reserved. | |
| 7 * | 6 * |
| 8 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 12 * | 11 * |
| 13 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // certain tree walks (e.g. layout()). The rule is that anything that | 81 // certain tree walks (e.g. layout()). The rule is that anything that |
| 83 // cares about containing blocks should skip the out-of-flow elements | 82 // cares about containing blocks should skip the out-of-flow elements |
| 84 // in the normal tree walk and do an optional follow-up pass for them | 83 // in the normal tree walk and do an optional follow-up pass for them |
| 85 // using LayoutBlock::positionedObjects(). | 84 // using LayoutBlock::positionedObjects(). |
| 86 // Not doing so will result in passing the wrong containing | 85 // Not doing so will result in passing the wrong containing |
| 87 // block as tree walks will always pass the parent as the | 86 // block as tree walks will always pass the parent as the |
| 88 // containing block. | 87 // containing block. |
| 89 // | 88 // |
| 90 // Sample code of how to handle positioned objects in LayoutBlock: | 89 // Sample code of how to handle positioned objects in LayoutBlock: |
| 91 // | 90 // |
| 92 // for (LayoutObject* child = firstChild(); child; child = child->nextSibling()) | 91 // for (LayoutObject* child = firstChild(); child; child = child->nextSibling())
{ |
| 93 // { | |
| 94 // if (child->isOutOfFlowPositioned()) | 92 // if (child->isOutOfFlowPositioned()) |
| 95 // continue; | 93 // continue; |
| 96 // | 94 // |
| 97 // // Handle normal flow children. | 95 // // Handle normal flow children. |
| 98 // ... | 96 // ... |
| 99 // } | 97 // } |
| 100 // for (LayoutBox* positionedObject : positionedObjects()) { | 98 // for (LayoutBox* positionedObject : positionedObjects()) { |
| 101 // // Handle out-of-flow positioned objects. | 99 // // Handle out-of-flow positioned objects. |
| 102 // ... | 100 // ... |
| 103 // } | 101 // } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 LinePositionMode = PositionOnContainingLine) const override; | 133 LinePositionMode = PositionOnContainingLine) const override; |
| 136 | 134 |
| 137 LayoutUnit minLineHeightForReplacedObject(bool isFirstLine, | 135 LayoutUnit minLineHeightForReplacedObject(bool isFirstLine, |
| 138 LayoutUnit replacedHeight) const; | 136 LayoutUnit replacedHeight) const; |
| 139 | 137 |
| 140 bool createsNewFormattingContext() const; | 138 bool createsNewFormattingContext() const; |
| 141 | 139 |
| 142 const char* name() const override; | 140 const char* name() const override; |
| 143 | 141 |
| 144 protected: | 142 protected: |
| 145 // Insert a child correctly into the tree when |beforeDescendant| isn't a | 143 // Insert a child correctly into the tree when |beforeDescendant| isn't a dire
ct child of |
| 146 // direct child of |this|. This happens e.g. when there's an anonymous block | 144 // |this|. This happens e.g. when there's an anonymous block child of |this| a
nd |
| 147 // child of |this| and |beforeDescendant| has been reparented into that one. | 145 // |beforeDescendant| has been reparented into that one. Such things are invis
ible to the DOM, |
| 148 // Such things are invisible to the DOM, and addChild() is typically called | 146 // and addChild() is typically called with the DOM tree (and not the layout tr
ee) in mind. |
| 149 // with the DOM tree (and not the layout tree) in mind. | |
| 150 void addChildBeforeDescendant(LayoutObject* newChild, | 147 void addChildBeforeDescendant(LayoutObject* newChild, |
| 151 LayoutObject* beforeDescendant); | 148 LayoutObject* beforeDescendant); |
| 152 | 149 |
| 153 public: | 150 public: |
| 154 void addChild(LayoutObject* newChild, | 151 void addChild(LayoutObject* newChild, |
| 155 LayoutObject* beforeChild = nullptr) override; | 152 LayoutObject* beforeChild = nullptr) override; |
| 156 | 153 |
| 157 virtual void layoutBlock(bool relayoutChildren); | 154 virtual void layoutBlock(bool relayoutChildren); |
| 158 | 155 |
| 159 void insertPositionedObject(LayoutBox*); | 156 void insertPositionedObject(LayoutBox*); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 EDisplay = EDisplay::Block); | 221 EDisplay = EDisplay::Block); |
| 225 LayoutBlock* createAnonymousBlock(EDisplay display = EDisplay::Block) const { | 222 LayoutBlock* createAnonymousBlock(EDisplay display = EDisplay::Block) const { |
| 226 return createAnonymousWithParentAndDisplay(this, display); | 223 return createAnonymousWithParentAndDisplay(this, display); |
| 227 } | 224 } |
| 228 | 225 |
| 229 LayoutBox* createAnonymousBoxWithSameTypeAs( | 226 LayoutBox* createAnonymousBoxWithSameTypeAs( |
| 230 const LayoutObject* parent) const override; | 227 const LayoutObject* parent) const override; |
| 231 | 228 |
| 232 int columnGap() const; | 229 int columnGap() const; |
| 233 | 230 |
| 234 // Accessors for logical width/height and margins in the containing block's | 231 // Accessors for logical width/height and margins in the containing block's bl
ock-flow direction. |
| 235 // block-flow direction. | |
| 236 LayoutUnit logicalWidthForChild(const LayoutBox& child) const { | 232 LayoutUnit logicalWidthForChild(const LayoutBox& child) const { |
| 237 return logicalWidthForChildSize(child.size()); | 233 return logicalWidthForChildSize(child.size()); |
| 238 } | 234 } |
| 239 LayoutUnit logicalWidthForChildSize(LayoutSize childSize) const { | 235 LayoutUnit logicalWidthForChildSize(LayoutSize childSize) const { |
| 240 return isHorizontalWritingMode() ? childSize.width() : childSize.height(); | 236 return isHorizontalWritingMode() ? childSize.width() : childSize.height(); |
| 241 } | 237 } |
| 242 LayoutUnit logicalHeightForChild(const LayoutBox& child) const { | 238 LayoutUnit logicalHeightForChild(const LayoutBox& child) const { |
| 243 return isHorizontalWritingMode() ? child.size().height() | 239 return isHorizontalWritingMode() ? child.size().height() |
| 244 : child.size().width(); | 240 : child.size().width(); |
| 245 } | 241 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // #enclosingFirstLineStyleBlock::first-line { ... } | 327 // #enclosingFirstLineStyleBlock::first-line { ... } |
| 332 // </style> | 328 // </style> |
| 333 // <div id="enclosingFirstLineStyleBlock"> | 329 // <div id="enclosingFirstLineStyleBlock"> |
| 334 // <div> | 330 // <div> |
| 335 // <div id="nearestInnerBlockWithFirstLine"> | 331 // <div id="nearestInnerBlockWithFirstLine"> |
| 336 // [<span>]first line text[</span>] | 332 // [<span>]first line text[</span>] |
| 337 // </div> | 333 // </div> |
| 338 // </div> | 334 // </div> |
| 339 // </div> | 335 // </div> |
| 340 | 336 |
| 341 // Returns the nearest enclosing block (including this block) that contributes | 337 // Returns the nearest enclosing block (including this block) that contributes
a first-line style to our first line. |
| 342 // a first-line style to our first line. | |
| 343 const LayoutBlock* enclosingFirstLineStyleBlock() const; | 338 const LayoutBlock* enclosingFirstLineStyleBlock() const; |
| 344 // Returns this block or the nearest inner block containing the actual first | 339 // Returns this block or the nearest inner block containing the actual first l
ine. |
| 345 // line. | |
| 346 LayoutBlockFlow* nearestInnerBlockWithFirstLine(); | 340 LayoutBlockFlow* nearestInnerBlockWithFirstLine(); |
| 347 | 341 |
| 348 protected: | 342 protected: |
| 349 void willBeDestroyed() override; | 343 void willBeDestroyed() override; |
| 350 | 344 |
| 351 void dirtyForLayoutFromPercentageHeightDescendants(SubtreeLayoutScope&); | 345 void dirtyForLayoutFromPercentageHeightDescendants(SubtreeLayoutScope&); |
| 352 | 346 |
| 353 void layout() override; | 347 void layout() override; |
| 354 | 348 |
| 355 enum PositionedLayoutBehavior { | 349 enum PositionedLayoutBehavior { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 const LayoutPoint& accumulatedOffset, | 401 const LayoutPoint& accumulatedOffset, |
| 408 HitTestAction) override; | 402 HitTestAction) override; |
| 409 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; | 403 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; |
| 410 | 404 |
| 411 void updateAfterLayout(); | 405 void updateAfterLayout(); |
| 412 | 406 |
| 413 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) override; | 407 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) override; |
| 414 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override; | 408 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override; |
| 415 void updateFromStyle() override; | 409 void updateFromStyle() override; |
| 416 | 410 |
| 417 // Returns true if non-visible overflow should be respected. Otherwise | 411 // Returns true if non-visible overflow should be respected. Otherwise hasOver
flowClip() will be |
| 418 // hasOverflowClip() will be false and we won't create scrollable area for | 412 // false and we won't create scrollable area for this object even if overflow
is non-visible. |
| 419 // this object even if overflow is non-visible. | |
| 420 virtual bool allowsOverflowClip() const; | 413 virtual bool allowsOverflowClip() const; |
| 421 | 414 |
| 422 virtual bool hasLineIfEmpty() const; | 415 virtual bool hasLineIfEmpty() const; |
| 423 | 416 |
| 424 bool simplifiedLayout(); | 417 bool simplifiedLayout(); |
| 425 virtual void simplifiedNormalFlowLayout(); | 418 virtual void simplifiedNormalFlowLayout(); |
| 426 | 419 |
| 427 public: | 420 public: |
| 428 virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool = false); | 421 virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool = false); |
| 429 | 422 |
| 430 protected: | 423 protected: |
| 431 virtual void addOverflowFromChildren(); | 424 virtual void addOverflowFromChildren(); |
| 432 void addOverflowFromPositionedObjects(); | 425 void addOverflowFromPositionedObjects(); |
| 433 void addOverflowFromBlockChildren(); | 426 void addOverflowFromBlockChildren(); |
| 434 void addVisualOverflowFromTheme(); | 427 void addVisualOverflowFromTheme(); |
| 435 | 428 |
| 436 void addOutlineRects(Vector<LayoutRect>&, | 429 void addOutlineRects(Vector<LayoutRect>&, |
| 437 const LayoutPoint& additionalOffset, | 430 const LayoutPoint& additionalOffset, |
| 438 IncludeBlockVisualOverflowOrNot) const override; | 431 IncludeBlockVisualOverflowOrNot) const override; |
| 439 | 432 |
| 440 void updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, LayoutBox&); | 433 void updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, LayoutBox&); |
| 441 | 434 |
| 442 // TODO(jchaffraix): We should rename this function as inline-flex and | 435 // TODO(jchaffraix): We should rename this function as inline-flex and inline-
grid as also covered. |
| 443 // inline-grid as also covered. | 436 // Alternatively it should be removed as we clarify the meaning of isAtomicInl
ineLevel to imply |
| 444 // Alternatively it should be removed as we clarify the meaning of | 437 // isInline. |
| 445 // isAtomicInlineLevel to imply isInline. | |
| 446 bool isInlineBlockOrInlineTable() const final { | 438 bool isInlineBlockOrInlineTable() const final { |
| 447 return isInline() && isAtomicInlineLevel(); | 439 return isInline() && isAtomicInlineLevel(); |
| 448 } | 440 } |
| 449 | 441 |
| 450 private: | 442 private: |
| 451 LayoutObjectChildList* virtualChildren() final { return children(); } | 443 LayoutObjectChildList* virtualChildren() final { return children(); } |
| 452 const LayoutObjectChildList* virtualChildren() const final { | 444 const LayoutObjectChildList* virtualChildren() const final { |
| 453 return children(); | 445 return children(); |
| 454 } | 446 } |
| 455 | 447 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 497 |
| 506 protected: | 498 protected: |
| 507 bool isPageLogicalHeightKnown(LayoutUnit logicalOffset) const { | 499 bool isPageLogicalHeightKnown(LayoutUnit logicalOffset) const { |
| 508 return pageLogicalHeightForOffset(logicalOffset); | 500 return pageLogicalHeightForOffset(logicalOffset); |
| 509 } | 501 } |
| 510 | 502 |
| 511 // Returns the logical offset at the top of the next page, for a given offset. | 503 // Returns the logical offset at the top of the next page, for a given offset. |
| 512 LayoutUnit nextPageLogicalTop(LayoutUnit logicalOffset) const; | 504 LayoutUnit nextPageLogicalTop(LayoutUnit logicalOffset) const; |
| 513 | 505 |
| 514 // Paginated content inside this block was laid out. | 506 // Paginated content inside this block was laid out. |
| 515 // |logicalBottomOffsetAfterPagination| is the logical bottom offset of the | 507 // |logicalBottomOffsetAfterPagination| is the logical bottom offset of the ch
ild content after |
| 516 // child content after applying any forced or unforced breaks as needed. | 508 // applying any forced or unforced breaks as needed. |
| 517 void paginatedContentWasLaidOut( | 509 void paginatedContentWasLaidOut( |
| 518 LayoutUnit logicalBottomOffsetAfterPagination); | 510 LayoutUnit logicalBottomOffsetAfterPagination); |
| 519 | 511 |
| 520 // Adjust from painting offsets to the local coords of this layoutObject | 512 // Adjust from painting offsets to the local coords of this layoutObject |
| 521 void offsetForContents(LayoutPoint&) const; | 513 void offsetForContents(LayoutPoint&) const; |
| 522 | 514 |
| 523 PositionWithAffinity positionForPointRespectingEditingBoundaries( | 515 PositionWithAffinity positionForPointRespectingEditingBoundaries( |
| 524 LineLayoutBox child, | 516 LineLayoutBox child, |
| 525 const LayoutPoint& pointInParentCoordinates); | 517 const LayoutPoint& pointInParentCoordinates); |
| 526 PositionWithAffinity positionForPointIfOutsideAtomicInlineLevel( | 518 PositionWithAffinity positionForPointIfOutsideAtomicInlineLevel( |
| 527 const LayoutPoint&); | 519 const LayoutPoint&); |
| 528 | 520 |
| 529 virtual bool updateLogicalWidthAndColumnWidth(); | 521 virtual bool updateLogicalWidthAndColumnWidth(); |
| 530 | 522 |
| 531 LayoutObjectChildList m_children; | 523 LayoutObjectChildList m_children; |
| 532 | 524 |
| 533 unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put | 525 unsigned |
| 534 // in LayoutBlockRareData since they are | 526 m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in La
youtBlockRareData since they are set too frequently. |
| 535 // set too frequently. | |
| 536 unsigned m_hasMarginAfterQuirk : 1; | 527 unsigned m_hasMarginAfterQuirk : 1; |
| 537 unsigned m_beingDestroyed : 1; | 528 unsigned m_beingDestroyed : 1; |
| 538 unsigned m_hasMarkupTruncation : 1; | 529 unsigned m_hasMarkupTruncation : 1; |
| 539 unsigned m_widthAvailableToChildrenChanged : 1; | 530 unsigned m_widthAvailableToChildrenChanged : 1; |
| 540 unsigned m_heightAvailableToChildrenChanged : 1; | 531 unsigned m_heightAvailableToChildrenChanged : 1; |
| 541 unsigned m_isSelfCollapsing : 1; // True if margin-before and margin-after | 532 unsigned |
| 542 // are adjoining. | 533 m_isSelfCollapsing : 1; // True if margin-before and margin-after are adj
oining. |
| 543 unsigned m_descendantsWithFloatsMarkedForLayout : 1; | 534 unsigned m_descendantsWithFloatsMarkedForLayout : 1; |
| 544 | 535 |
| 545 unsigned m_hasPositionedObjects : 1; | 536 unsigned m_hasPositionedObjects : 1; |
| 546 unsigned m_hasPercentHeightDescendants : 1; | 537 unsigned m_hasPercentHeightDescendants : 1; |
| 547 | 538 |
| 548 // FIXME: This is temporary as we move code that accesses block flow | 539 // FIXME: This is temporary as we move code that accesses block flow |
| 549 // member variables out of LayoutBlock and into LayoutBlockFlow. | 540 // member variables out of LayoutBlock and into LayoutBlockFlow. |
| 550 friend class LayoutBlockFlow; | 541 friend class LayoutBlockFlow; |
| 551 | 542 |
| 552 // This is necessary for now for interoperability between the old and new | 543 // This is necessary for now for interoperability between the old and new |
| 553 // layout code. Primarily for calling layoutPositionedObjects at the moment. | 544 // layout code. Primarily for calling layoutPositionedObjects at the moment. |
| 554 friend class NGBox; | 545 friend class NGBox; |
| 555 | 546 |
| 556 public: | 547 public: |
| 557 // TODO(lunalu): Temporary in order to ensure compatibility with existing | 548 // TODO(lunalu): Temporary in order to ensure compatibility with existing layo
ut test |
| 558 // layout test results. | 549 // results. |
| 559 virtual void adjustChildDebugRect(LayoutRect&) const {} | 550 virtual void adjustChildDebugRect(LayoutRect&) const {} |
| 560 }; | 551 }; |
| 561 | 552 |
| 562 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); | 553 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); |
| 563 | 554 |
| 564 } // namespace blink | 555 } // namespace blink |
| 565 | 556 |
| 566 #endif // LayoutBlock_h | 557 #endif // LayoutBlock_h |
| OLD | NEW |