Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 */ | 34 */ |
| 35 | 35 |
| 36 #ifndef RenderBlockFlow_h | 36 #ifndef RenderBlockFlow_h |
| 37 #define RenderBlockFlow_h | 37 #define RenderBlockFlow_h |
| 38 | 38 |
| 39 #include "core/rendering/FloatingObjects.h" | 39 #include "core/rendering/FloatingObjects.h" |
| 40 #include "core/rendering/RenderBlock.h" | 40 #include "core/rendering/RenderBlock.h" |
| 41 #include "core/rendering/line/TrailingObjects.h" | 41 #include "core/rendering/line/TrailingObjects.h" |
| 42 #include "core/rendering/style/RenderStyleConstants.h" | 42 #include "core/rendering/style/RenderStyleConstants.h" |
| 43 | 43 |
| 44 // This define globally controls whether we use recursion or not for layout. The | |
| 45 // default is recursion and all layout tests pass with this patch and this defau lt. | |
| 46 // Right now, if you switch to non-recursion I still have ~500 failures, but the | |
| 47 // vast majority of tests that exercise this code are passing. | |
| 48 #define NON_RECURSIVE 0 | |
| 49 | |
| 44 namespace WebCore { | 50 namespace WebCore { |
| 45 | 51 |
| 46 class MarginInfo; | 52 class MarginInfo; |
| 53 class LayoutStateMaintainer; | |
| 47 class LineBreaker; | 54 class LineBreaker; |
| 48 class LineWidth; | 55 class LineWidth; |
| 49 class RenderNamedFlowFragment; | 56 class RenderNamedFlowFragment; |
| 57 class SubtreeLayoutScope; | |
| 50 | 58 |
| 51 class RenderBlockFlow : public RenderBlock { | 59 class RenderBlockFlow : public RenderBlock { |
| 52 public: | 60 public: |
| 53 explicit RenderBlockFlow(ContainerNode*); | 61 explicit RenderBlockFlow(ContainerNode*); |
| 54 virtual ~RenderBlockFlow(); | 62 virtual ~RenderBlockFlow(); |
| 55 | 63 |
| 56 static RenderBlockFlow* createAnonymous(Document*); | 64 static RenderBlockFlow* createAnonymous(Document*); |
| 57 RenderBlockFlow* createAnonymousBlockFlow() const; | 65 RenderBlockFlow* createAnonymousBlockFlow() const; |
| 58 | 66 |
| 59 virtual bool isRenderBlockFlow() const OVERRIDE FINAL { return true; } | 67 virtual bool isRenderBlockFlow() const OVERRIDE FINAL { return true; } |
| 60 | 68 |
| 69 #if NON_RECURSIVE | |
| 70 virtual bool isNonRecursiveLayout() const OVERRIDE { return true; } | |
| 71 #else | |
| 72 virtual bool isNonRecursiveLayout() const OVERRIDE { return false; } | |
| 73 #endif | |
| 61 virtual void layoutBlock(bool relayoutChildren) OVERRIDE; | 74 virtual void layoutBlock(bool relayoutChildren) OVERRIDE; |
| 75 virtual void preLayoutBlock(bool relayoutChildren, bool traverseChildren) OV ERRIDE; | |
| 76 virtual bool postLayoutBlock() OVERRIDE; | |
| 62 | 77 |
| 63 virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFl oats = false) OVERRIDE; | 78 virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFl oats = false) OVERRIDE; |
| 64 virtual void deleteLineBoxTree() OVERRIDE FINAL; | 79 virtual void deleteLineBoxTree() OVERRIDE FINAL; |
| 65 | 80 |
| 66 // Versions that can compute line offsets with the region and page offset pa ssed in. Used for speed to avoid having to | 81 // Versions that can compute line offsets with the region and page offset pa ssed in. Used for speed to avoid having to |
| 67 // compute the region all over again when you already know it. | 82 // compute the region all over again when you already know it. |
| 68 LayoutUnit availableLogicalWidthForLineInRegion(LayoutUnit position, bool sh ouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const | 83 LayoutUnit availableLogicalWidthForLineInRegion(LayoutUnit position, bool sh ouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const |
| 69 { | 84 { |
| 70 return max<LayoutUnit>(0, logicalRightOffsetForLineInRegion(position, sh ouldIndentText, region, logicalHeight) | 85 return max<LayoutUnit>(0, logicalRightOffsetForLineInRegion(position, sh ouldIndentText, region, logicalHeight) |
| 71 - logicalLeftOffsetForLineInRegion(position, shouldIndentText, regio n, logicalHeight)); | 86 - logicalLeftOffsetForLineInRegion(position, shouldIndentText, regio n, logicalHeight)); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 return adjustLogicalRightOffsetForLine(logicalRightFloatOffsetForLine(lo gicalTop, fixedOffset, logicalHeight), applyTextIndent); | 263 return adjustLogicalRightOffsetForLine(logicalRightFloatOffsetForLine(lo gicalTop, fixedOffset, logicalHeight), applyTextIndent); |
| 249 } | 264 } |
| 250 LayoutUnit logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedO ffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const | 265 LayoutUnit logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedO ffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const |
| 251 { | 266 { |
| 252 return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logi calTop, fixedOffset, logicalHeight), applyTextIndent); | 267 return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logi calTop, fixedOffset, logicalHeight), applyTextIndent); |
| 253 } | 268 } |
| 254 | 269 |
| 255 virtual void insertedIntoTree() OVERRIDE; | 270 virtual void insertedIntoTree() OVERRIDE; |
| 256 virtual void willBeDestroyed() OVERRIDE; | 271 virtual void willBeDestroyed() OVERRIDE; |
| 257 private: | 272 private: |
| 258 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&); | 273 void preLayoutBlockFlow(bool traverseChildren); |
| 259 void layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalB ottom, SubtreeLayoutScope&, LayoutUnit beforeEdge, LayoutUnit afterEdge); | 274 bool postLayoutBlockFlow(); |
| 275 bool preLayoutBlockChild(RenderBox* child, bool& skipChildren); | |
| 276 void postLayoutBlockChild(RenderBox* child); | |
| 260 | 277 |
| 261 void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom, LayoutUnit& maxFloatLogicalBottom); | 278 void layoutBlockChildren(LayoutUnit beforeEdge, LayoutUnit afterEdge, bool t raverseChildren); |
| 279 | |
| 262 void adjustPositionedBlock(RenderBox* child, const MarginInfo&); | 280 void adjustPositionedBlock(RenderBox* child, const MarginInfo&); |
| 263 void adjustFloatingBlock(const MarginInfo&); | 281 void adjustFloatingBlock(const MarginInfo&); |
| 264 | 282 |
| 265 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const; | 283 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const; |
| 266 | 284 |
| 267 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) con st | 285 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) con st |
| 268 { | 286 { |
| 269 if (isHorizontalWritingMode()) | 287 if (isHorizontalWritingMode()) |
| 270 return child->x() + child->renderer()->marginLeft(); | 288 return child->x() + child->renderer()->marginLeft(); |
| 271 | 289 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); | 532 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); |
| 515 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const Inlin eIterator& endLineStart, const BidiStatus& endLineStatus); | 533 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const Inlin eIterator& endLineStart, const BidiStatus& endLineStatus); |
| 516 void deleteEllipsisLineBoxes(); | 534 void deleteEllipsisLineBoxes(); |
| 517 void checkLinesForTextOverflow(); | 535 void checkLinesForTextOverflow(); |
| 518 // Positions new floats and also adjust all floats encountered on the line i f any of them | 536 // Positions new floats and also adjust all floats encountered on the line i f any of them |
| 519 // have to move to the next page/column. | 537 // have to move to the next page/column. |
| 520 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFl oatFromPreviousLine, LineInfo&, LineWidth&); | 538 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFl oatFromPreviousLine, LineInfo&, LineWidth&); |
| 521 | 539 |
| 522 | 540 |
| 523 // END METHODS DEFINED IN RenderBlockLineLayout | 541 // END METHODS DEFINED IN RenderBlockLineLayout |
| 542 private: | |
| 543 // Here we have the state that was previously held on the stack and now need s | |
| 544 // to be held somewhere else. I've put the state as member variables of thi s | |
| 545 // class, but most likely we'd need to put them in LayoutState or something | |
| 546 // very similar. Each subclass will have its own needs so perhaps we'll nee d | |
| 547 // LayoutState inner class that each RenderObject can subclass and override | |
| 548 // or something. | |
| 549 // FIXME: Figure out the best way to manage this state for this class and th e | |
| 550 // other various subclasses that switch to non-recursive layout. | |
| 524 | 551 |
| 552 // Used by (pre/post)layoutBlockFlow and friends | |
| 553 SubtreeLayoutScope* m_layoutScope; | |
| 554 LayoutStateMaintainer* m_statePusher; | |
| 555 bool m_hasSpecifiedPageLogicalHeight; | |
| 556 bool m_checkForRepaint; | |
| 557 bool m_relayoutChildren; | |
| 558 LayoutRect m_oldBounds; | |
| 559 LayoutRect m_oldOutlineBox; | |
| 560 LayoutUnit m_pageLogicalHeight; | |
| 561 LayoutUnit m_heightBeforeLayout; | |
| 562 LayoutUnit m_previousFloatLogicalBottom; | |
| 563 LayoutUnit m_maxFloatLogicalBottom; | |
| 564 RenderBox* m_lastNormalFlowChild; | |
| 565 MarginInfo* m_marginInfo; | |
| 566 | |
| 567 // Used by (pre/post) layoutBlockChild and friends | |
| 568 RenderObject* m_childToExclude; | |
| 569 SubtreeLayoutScope* m_childLayoutScope; | |
| 570 LayoutUnit m_oldPosMarginBefore; | |
| 571 LayoutUnit m_oldNegMarginBefore; | |
| 572 LayoutUnit m_estimateWithoutPagination; | |
| 573 LayoutUnit m_logicalTopEstimate; | |
| 574 LayoutRect m_oldRect; | |
| 575 LayoutSize m_oldLayoutDelta; | |
| 576 bool m_childHadLayout; | |
| 577 bool m_childNeededLayout; | |
|
esprehn
2014/02/15 00:35:43
This is huge, I don't think you can make RenderBlo
atreat
2014/02/18 16:03:57
No, of course not. That is why I said in the comm
| |
| 525 }; | 578 }; |
| 526 | 579 |
| 527 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow()); | 580 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow()); |
| 528 | 581 |
| 529 } // namespace WebCore | 582 } // namespace WebCore |
| 530 | 583 |
| 531 #endif // RenderBlockFlow_h | 584 #endif // RenderBlockFlow_h |
| OLD | NEW |