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