Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      4  *           (C) 2007 David Smith (catfish.man (at) gmail.com)
      5  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  */
     22 
     23 #ifndef RenderBlock_h
     24 #define RenderBlock_h
     25 
     26 #include "core/rendering/ColumnInfo.h"
     27 #include "core/rendering/FloatingObjects.h"
     28 #include "core/rendering/GapRects.h"
     29 #include "core/rendering/RenderBox.h"
     30 #include "core/rendering/RenderLineBoxList.h"
     31 #include "core/rendering/RootInlineBox.h"
     32 #include "core/rendering/style/ShapeValue.h"
     33 #include "platform/text/TextBreakIterator.h"
     34 #include "platform/text/TextRun.h"
     35 #include "wtf/ListHashSet.h"
     36 #include "wtf/OwnPtr.h"
     37 
     38 namespace blink {
     39 
     40 class LineInfo;
     41 class LineLayoutState;
     42 struct PaintInfo;
     43 class RenderInline;
     44 class RenderRubyRun;
     45 class RenderText;
     46 class WordMeasurement;
     47 
     48 template <class Run> class BidiRunList;
     49 typedef WTF::ListHashSet<RenderBox*, 16> TrackedRendererListHashSet;
     50 typedef WTF::HashMap<const RenderBlock*, OwnPtr<TrackedRendererListHashSet> > TrackedDescendantsMap;
     51 typedef WTF::HashMap<const RenderBox*, OwnPtr<HashSet<RenderBlock*> > > TrackedContainerMap;
     52 typedef Vector<WordMeasurement, 64> WordMeasurements;
     53 
     54 enum ContainingBlockState { NewContainingBlock, SameContainingBlock };
     55 
     56 typedef WTF::HashMap<RenderBlock*, OwnPtr<ListHashSet<RenderInline*> > > ContinuationOutlineTableMap;
     57 
     58 ContinuationOutlineTableMap* continuationOutlineTable();
     59 
     60 class RenderBlock : public RenderBox {
     61 public:
     62     virtual void destroy() OVERRIDE;
     63     virtual void trace(Visitor*) OVERRIDE;
     64     friend class LineLayoutState;
     65 
     66 protected:
     67     explicit RenderBlock(ContainerNode*);
     68     virtual ~RenderBlock();
     69 
     70 public:
     71     RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     72     RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
     73 
     74     // If you have a RenderBlock, use firstChild or lastChild instead.
     75     void slowFirstChild() const WTF_DELETED_FUNCTION;
     76     void slowLastChild() const WTF_DELETED_FUNCTION;
     77 
     78     const RenderObjectChildList* children() const { return &m_children; }
     79     RenderObjectChildList* children() { return &m_children; }
     80 
     81     bool beingDestroyed() const { return m_beingDestroyed; }
     82 
     83     // These two functions are overridden for inline-block.
     84     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE FINAL;
     85     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
     86 
     87     LayoutUnit minLineHeightForReplacedRenderer(bool isFirstLine, LayoutUnit replacedHeight) const;
     88 
     89     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
     90 
     91 protected:
     92     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
     93     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
     94 
     95     RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
     96     RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); }
     97 
     98 public:
     99     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
    100     virtual void deleteLineBoxTree();
    101 
    102     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
    103     virtual void removeChild(RenderObject*) OVERRIDE;
    104 
    105     virtual void layoutBlock(bool relayoutChildren);
    106 
    107     void insertPositionedObject(RenderBox*);
    108     static void removePositionedObject(RenderBox*);
    109     void removePositionedObjects(RenderBlock*, ContainingBlockState = SameContainingBlock);
    110 
    111     TrackedRendererListHashSet* positionedObjects() const;
    112     bool hasPositionedObjects() const
    113     {
    114         TrackedRendererListHashSet* objects = positionedObjects();
    115         return objects && !objects->isEmpty();
    116     }
    117 
    118     void addPercentHeightDescendant(RenderBox*);
    119     static void removePercentHeightDescendant(RenderBox*);
    120     static bool hasPercentHeightContainerMap();
    121     static bool hasPercentHeightDescendant(RenderBox*);
    122     static void clearPercentHeightDescendantsFrom(RenderBox*);
    123     static void removePercentHeightDescendantIfNeeded(RenderBox*);
    124 
    125     TrackedRendererListHashSet* percentHeightDescendants() const;
    126     bool hasPercentHeightDescendants() const
    127     {
    128         TrackedRendererListHashSet* descendants = percentHeightDescendants();
    129         return descendants && !descendants->isEmpty();
    130     }
    131 
    132     void setHasMarkupTruncation(bool b) { m_hasMarkupTruncation = b; }
    133     bool hasMarkupTruncation() const { return m_hasMarkupTruncation; }
    134 
    135     void setHasMarginBeforeQuirk(bool b) { m_hasMarginBeforeQuirk = b; }
    136     void setHasMarginAfterQuirk(bool b) { m_hasMarginAfterQuirk = b; }
    137 
    138     bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; }
    139     bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; }
    140 
    141     bool hasMarginBeforeQuirk(const RenderBox* child) const;
    142     bool hasMarginAfterQuirk(const RenderBox* child) const;
    143 
    144     void markPositionedObjectsForLayout();
    145     // FIXME: Do we really need this to be virtual? It's just so we can call this on
    146     // RenderBoxes without needed to check whether they're RenderBlocks first.
    147     virtual void markForPaginationRelayoutIfNeeded(SubtreeLayoutScope&) OVERRIDE FINAL;
    148 
    149     LayoutUnit textIndentOffset() const;
    150 
    151     virtual PositionWithAffinity positionForPoint(const LayoutPoint&) OVERRIDE;
    152 
    153     // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
    154     virtual LayoutUnit availableLogicalWidth() const OVERRIDE FINAL;
    155 
    156     LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
    157     void adjustStartEdgeForWritingModeIncludingColumns(LayoutRect&) const;
    158 
    159     LayoutUnit blockDirectionOffset(const LayoutSize& offsetFromBlock) const;
    160     LayoutUnit inlineDirectionOffset(const LayoutSize& offsetFromBlock) const;
    161 
    162     virtual bool shouldPaintSelectionGaps() const OVERRIDE FINAL;
    163     GapRects selectionGapRectsForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer) const;
    164     LayoutRect logicalLeftSelectionGap(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
    165                                        const RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo*) const;
    166     LayoutRect logicalRightSelectionGap(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
    167                                         const RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo*) const;
    168     void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap) const;
    169     RenderBlock* blockBeforeWithinSelectionRoot(LayoutSize& offset) const;
    170 
    171     virtual void setSelectionState(SelectionState) OVERRIDE;
    172 
    173     LayoutRect logicalRectToPhysicalRect(const LayoutPoint& physicalPosition, const LayoutRect& logicalRect) const;
    174 
    175     // Helper methods for computing line counts and heights for line counts.
    176     RootInlineBox* lineAtIndex(int) const;
    177     int lineCount(const RootInlineBox* = 0, bool* = 0) const;
    178     int heightForLineCount(int);
    179     void clearTruncation();
    180 
    181     void adjustRectForColumns(LayoutRect&) const;
    182     virtual LayoutSize columnOffset(const LayoutPoint&) const OVERRIDE;
    183     void adjustForColumnRect(LayoutSize& offset, const LayoutPoint& locationInContainer) const;
    184 
    185     void addContinuationWithOutline(RenderInline*);
    186 
    187     virtual RenderBoxModelObject* virtualContinuation() const OVERRIDE FINAL { return continuation(); }
    188     bool isAnonymousBlockContinuation() const { return continuation() && isAnonymousBlock(); }
    189     RenderInline* inlineElementContinuation() const;
    190     RenderBlock* blockElementContinuation() const;
    191 
    192     using RenderBoxModelObject::continuation;
    193     using RenderBoxModelObject::setContinuation;
    194 
    195     static RenderBlock* createAnonymousWithParentRendererAndDisplay(const RenderObject*, EDisplay = BLOCK);
    196     static RenderBlockFlow* createAnonymousColumnsWithParentRenderer(const RenderObject*);
    197     static RenderBlockFlow* createAnonymousColumnSpanWithParentRenderer(const RenderObject*);
    198     RenderBlock* createAnonymousBlock(EDisplay display = BLOCK) const { return createAnonymousWithParentRendererAndDisplay(this, display); }
    199     RenderBlockFlow* createAnonymousColumnsBlock() const { return createAnonymousColumnsWithParentRenderer(this); }
    200     RenderBlockFlow* createAnonymousColumnSpanBlock() const { return createAnonymousColumnSpanWithParentRenderer(this); }
    201 
    202     virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE;
    203 
    204     ColumnInfo* columnInfo() const;
    205     int columnGap() const;
    206 
    207     // These two functions take the ColumnInfo* to avoid repeated lookups of the info in the global HashMap.
    208     unsigned columnCount(ColumnInfo*) const;
    209     LayoutRect columnRectAt(ColumnInfo*, unsigned) const;
    210 
    211     // The page logical offset is the object's offset from the top of the page in the page progression
    212     // direction (so an x-offset in vertical text and a y-offset for horizontal text).
    213     LayoutUnit pageLogicalOffset() const { return m_pageLogicalOffset; }
    214     void setPageLogicalOffset(LayoutUnit offset) { m_pageLogicalOffset = offset; }
    215 
    216     // Accessors for logical width/height and margins in the containing block's block-flow direction.
    217     LayoutUnit logicalWidthForChild(const RenderBox* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); }
    218     LayoutUnit logicalHeightForChild(const RenderBox* child) const { return isHorizontalWritingMode() ? child->height() : child->width(); }
    219     LayoutSize logicalSizeForChild(const RenderBox* child) const { return isHorizontalWritingMode() ? child->size() : child->size().transposedSize(); }
    220     LayoutUnit logicalTopForChild(const RenderBox* child) const { return isHorizontalWritingMode() ? child->y() : child->x(); }
    221     LayoutUnit marginBeforeForChild(const RenderBoxModelObject* child) const { return child->marginBefore(style()); }
    222     LayoutUnit marginAfterForChild(const RenderBoxModelObject* child) const { return child->marginAfter(style()); }
    223     LayoutUnit marginStartForChild(const RenderBoxModelObject* child) const { return child->marginStart(style()); }
    224     LayoutUnit marginEndForChild(const RenderBoxModelObject* child) const { return child->marginEnd(style()); }
    225     void setMarginStartForChild(RenderBox* child, LayoutUnit value) const { child->setMarginStart(value, style()); }
    226     void setMarginEndForChild(RenderBox* child, LayoutUnit value) const { child->setMarginEnd(value, style()); }
    227     void setMarginBeforeForChild(RenderBox* child, LayoutUnit value) const { child->setMarginBefore(value, style()); }
    228     void setMarginAfterForChild(RenderBox* child, LayoutUnit value) const { child->setMarginAfter(value, style()); }
    229     LayoutUnit collapsedMarginBeforeForChild(const RenderBox* child) const;
    230     LayoutUnit collapsedMarginAfterForChild(const RenderBox* child) const;
    231 
    232     virtual void updateFirstLetter();
    233     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
    234 
    235     virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/) { }
    236 
    237     LayoutUnit availableLogicalWidthForContent() const { return max<LayoutUnit>(0, logicalRightOffsetForContent() - logicalLeftOffsetForContent()); }
    238     LayoutUnit logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
    239     LayoutUnit logicalRightOffsetForContent() const { return logicalLeftOffsetForContent() + availableLogicalWidth(); }
    240     LayoutUnit startOffsetForContent() const { return style()->isLeftToRightDirection() ? logicalLeftOffsetForContent() : logicalWidth() - logicalRightOffsetForContent(); }
    241     LayoutUnit endOffsetForContent() const { return !style()->isLeftToRightDirection() ? logicalLeftOffsetForContent() : logicalWidth() - logicalRightOffsetForContent(); }
    242 
    243     virtual LayoutUnit logicalLeftSelectionOffset(const RenderBlock* rootBlock, LayoutUnit position) const;
    244     virtual LayoutUnit logicalRightSelectionOffset(const RenderBlock* rootBlock, LayoutUnit position) const;
    245 
    246     GapRects selectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
    247         LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* = 0) const;
    248 
    249 #if ENABLE(ASSERT)
    250     void checkPositionedObjectsNeedLayout();
    251     bool paintsContinuationOutline(RenderInline* flow);
    252 #endif
    253 #ifndef NDEBUG
    254     void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const;
    255 #endif
    256 
    257     bool recalcChildOverflowAfterStyleChange();
    258     bool recalcOverflowAfterStyleChange();
    259 
    260 protected:
    261     virtual void willBeDestroyed() OVERRIDE;
    262 
    263     void dirtyForLayoutFromPercentageHeightDescendants(SubtreeLayoutScope&);
    264 
    265     virtual void layout() OVERRIDE;
    266     virtual bool updateImageLoadingPriorities() OVERRIDE FINAL;
    267 
    268     enum PositionedLayoutBehavior {
    269         DefaultLayout,
    270         LayoutOnlyFixedPositionedObjects,
    271         ForcedLayoutAfterContainingBlockMoved
    272     };
    273 
    274     void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior = DefaultLayout);
    275     void markFixedPositionObjectForLayoutIfNeeded(RenderObject* child, SubtreeLayoutScope&);
    276 
    277     LayoutUnit marginIntrinsicLogicalWidthForChild(RenderBox* child) const;
    278 
    279     int beforeMarginInLineDirection(LineDirectionMode) const;
    280 
    281     virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
    282 public:
    283     virtual void paintObject(PaintInfo&, const LayoutPoint&) OVERRIDE;
    284     virtual void paintChildren(PaintInfo&, const LayoutPoint&);
    285 
    286     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
    287     virtual void paintFloats(PaintInfo&, const LayoutPoint&, bool) { }
    288 
    289 protected:
    290     virtual void adjustInlineDirectionLineBounds(unsigned /* expansionOpportunityCount */, float& /* logicalLeft */, float& /* logicalWidth */) const { }
    291 
    292     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
    293     virtual void computePreferredLogicalWidths() OVERRIDE;
    294     void adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
    295 
    296     virtual int firstLineBoxBaseline() const OVERRIDE;
    297     virtual int inlineBlockBaseline(LineDirectionMode) const OVERRIDE;
    298     int lastLineBoxBaseline(LineDirectionMode) const;
    299 
    300     virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) OVERRIDE;
    301 
    302     // Delay update scrollbar until finishDelayUpdateScrollInfo() will be
    303     // called. This function is used when a flexbox is laying out its
    304     // descendant. If multiple calls are made to startDelayUpdateScrollInfo(),
    305     // finishDelayUpdateScrollInfo() will do nothing until finishDelayUpdateScrollInfo()
    306     // is called the same number of times.
    307     static void startDelayUpdateScrollInfo();
    308     static void finishDelayUpdateScrollInfo();
    309 
    310     void updateScrollInfoAfterLayout();
    311 
    312     virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle) OVERRIDE;
    313     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
    314 
    315     virtual bool hasLineIfEmpty() const;
    316 
    317     bool simplifiedLayout();
    318     virtual void simplifiedNormalFlowLayout();
    319 
    320     void setDesiredColumnCountAndWidth(int, LayoutUnit);
    321 
    322 public:
    323     virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool = false);
    324 protected:
    325     virtual void addOverflowFromChildren();
    326     void addOverflowFromPositionedObjects();
    327     void addOverflowFromBlockChildren();
    328     void addVisualOverflowFromTheme();
    329 
    330     virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const OVERRIDE;
    331 
    332     virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const OVERRIDE;
    333 
    334     void updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, RenderBox*);
    335 
    336     virtual bool isInlineBlockOrInlineTable() const OVERRIDE FINAL { return isInline() && isReplaced(); }
    337 
    338     virtual void invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& childPaintInvalidationState) OVERRIDE;
    339 
    340 private:
    341     virtual RenderObjectChildList* virtualChildren() OVERRIDE FINAL { return children(); }
    342     virtual const RenderObjectChildList* virtualChildren() const OVERRIDE FINAL { return children(); }
    343 
    344     virtual const char* renderName() const OVERRIDE;
    345 
    346     virtual bool isRenderBlock() const OVERRIDE FINAL { return true; }
    347 
    348     void makeChildrenNonInline(RenderObject* insertionPoint = 0);
    349     virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
    350 
    351     static void collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child);
    352 
    353     virtual void dirtyLinesFromChangedChild(RenderObject* child) OVERRIDE FINAL { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
    354 
    355     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
    356     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild) OVERRIDE;
    357     void addChildToAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild);
    358 
    359     void addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild = 0);
    360 
    361     virtual bool isSelfCollapsingBlock() const OVERRIDE;
    362 
    363     void insertIntoTrackedRendererMaps(RenderBox* descendant, TrackedDescendantsMap*&, TrackedContainerMap*&);
    364     static void removeFromTrackedRendererMaps(RenderBox* descendant, TrackedDescendantsMap*&, TrackedContainerMap*&);
    365 
    366     void createFirstLetterRenderer(RenderObject* firstLetterBlock, RenderText& currentChild, unsigned length);
    367     void updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderObject* firstLetterContainer);
    368 
    369     Node* nodeForHitTest() const;
    370 
    371 private:
    372     virtual bool avoidsFloats() const OVERRIDE { return true; }
    373 
    374     bool hitTestColumns(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
    375     bool hitTestContents(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
    376     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
    377     virtual bool hitTestFloats(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&) { return false; }
    378 
    379     virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& locationInContainer, const LayoutPoint& accumulatedOffset);
    380 
    381     void computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
    382 
    383     // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
    384     // children.
    385     virtual RenderBlock* firstLineBlock() const OVERRIDE;
    386 
    387     virtual LayoutRect rectWithOutlineForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalidationState* = 0) const OVERRIDE FINAL;
    388 
    389     virtual RenderObject* hoverAncestor() const OVERRIDE FINAL;
    390     virtual void updateDragState(bool dragOn) OVERRIDE FINAL;
    391     virtual void childBecameNonInline(RenderObject* child) OVERRIDE FINAL;
    392 
    393     virtual LayoutRect selectionRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer) const OVERRIDE FINAL
    394     {
    395         return selectionGapRectsForPaintInvalidation(paintInvalidationContainer);
    396     }
    397     bool isSelectionRoot() const;
    398     GapRects blockSelectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
    399                                 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo*) const;
    400     LayoutRect blockSelectionGap(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
    401                                  LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const PaintInfo*) const;
    402 
    403     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
    404     virtual void clipOutFloatingObjects(const RenderBlock*, const PaintInfo*, const LayoutPoint&, const LayoutSize&) const { };
    405 
    406     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const OVERRIDE;
    407     virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const OVERRIDE;
    408 
    409     LayoutUnit desiredColumnWidth() const;
    410 
    411 private:
    412     virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) OVERRIDE FINAL;
    413 
    414     void adjustPointToColumnContents(LayoutPoint&) const;
    415 
    416     void markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit logicalBottom, RootInlineBox* highest = 0);
    417 
    418     Position positionForBox(InlineBox*, bool start = true) const;
    419     PositionWithAffinity positionForPointWithInlineChildren(const LayoutPoint&);
    420 
    421     void calcColumnWidth();
    422     void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlockFlow* newBlockBox, RenderObject* newChild);
    423 
    424     void splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
    425                      RenderObject* beforeChild, RenderBoxModelObject* oldCont);
    426     void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
    427                    RenderObject* newChild, RenderBoxModelObject* oldCont);
    428     RenderBlock* clone() const;
    429     RenderBlock* continuationBefore(RenderObject* beforeChild);
    430     RenderBlockFlow* containingColumnsBlock(bool allowAnonymousColumnBlock = true);
    431     RenderBlockFlow* columnsBlockForSpanningElement(RenderObject* newChild);
    432 
    433     // End helper functions and structs used by layoutBlockChildren.
    434 
    435     void removeFromGlobalMaps();
    436     bool widthAvailableToChildrenHasChanged();
    437 
    438 protected:
    439     // Returns the logicalOffset at the top of the next page. If the offset passed in is already at the top of the current page,
    440     // then nextPageLogicalTop with ExcludePageBoundary will still move to the top of the next page. nextPageLogicalTop with
    441     // IncludePageBoundary set will not.
    442     //
    443     // For a page height of 800px, the first rule will return 800 if the value passed in is 0. The second rule will simply return 0.
    444     enum PageBoundaryRule { ExcludePageBoundary, IncludePageBoundary };
    445     LayoutUnit nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundaryRule = ExcludePageBoundary) const;
    446 
    447     bool createsBlockFormattingContext() const;
    448 
    449 public:
    450     LayoutUnit pageLogicalHeightForOffset(LayoutUnit offset) const;
    451     LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit offset, PageBoundaryRule = IncludePageBoundary) const;
    452 
    453 protected:
    454     // A page break is required at some offset due to space shortage in the current fragmentainer.
    455     void setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage);
    456 
    457     // Update minimum page height required to avoid fragmentation where it shouldn't occur (inside
    458     // unbreakable content, between orphans and widows, etc.). This will be used as a hint to the
    459     // column balancer to help set a good minimum column height.
    460     void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight);
    461 
    462     // Adjust from painting offsets to the local coords of this renderer
    463     void offsetForContents(LayoutPoint&) const;
    464 
    465     bool requiresColumns(int desiredColumnCount) const;
    466 
    467     virtual bool updateLogicalWidthAndColumnWidth();
    468 
    469     virtual bool canCollapseAnonymousBlockChild() const { return true; }
    470 
    471 public:
    472     virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const OVERRIDE FINAL;
    473 
    474 protected:
    475     RenderObjectChildList m_children;
    476     RenderLineBoxList m_lineBoxes;   // All of the root line boxes created for this block flow.  For example, <div>Hello<br>world.</div> will have two total lines for the <div>.
    477 
    478     LayoutUnit m_pageLogicalOffset;
    479 
    480     unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in RenderBlockRareData since they are set too frequently.
    481     unsigned m_hasMarginAfterQuirk : 1;
    482     unsigned m_beingDestroyed : 1;
    483     unsigned m_hasMarkupTruncation : 1;
    484     unsigned m_hasBorderOrPaddingLogicalWidthChanged : 1;
    485     mutable unsigned m_hasOnlySelfCollapsingChildren : 1;
    486     mutable unsigned m_descendantsWithFloatsMarkedForLayout : 1;
    487 
    488     // RenderRubyBase objects need to be able to split and merge, moving their children around
    489     // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
    490     friend class RenderRubyBase;
    491     // FIXME-BLOCKFLOW: Remove this when the line layout stuff has all moved out of RenderBlock
    492     friend class LineBreaker;
    493 
    494     // FIXME: This is temporary as we move code that accesses block flow
    495     // member variables out of RenderBlock and into RenderBlockFlow.
    496     friend class RenderBlockFlow;
    497 };
    498 
    499 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlock, isRenderBlock());
    500 
    501 } // namespace blink
    502 
    503 #endif // RenderBlock_h
    504