diff options
Diffstat (limited to 'WebCore/rendering/RenderBlock.h')
-rw-r--r-- | WebCore/rendering/RenderBlock.h | 176 |
1 files changed, 107 insertions, 69 deletions
diff --git a/WebCore/rendering/RenderBlock.h b/WebCore/rendering/RenderBlock.h index 2e74e41..d7a26ef 100644 --- a/WebCore/rendering/RenderBlock.h +++ b/WebCore/rendering/RenderBlock.h @@ -27,7 +27,8 @@ #include "DeprecatedPtrList.h" #include "GapRects.h" -#include "RenderFlow.h" +#include "RenderBox.h" +#include "RenderLineBoxList.h" #include "RootInlineBox.h" #include <wtf/ListHashSet.h> @@ -36,6 +37,7 @@ namespace WebCore { class InlineIterator; class BidiRun; class Position; +class RenderInline; class RootInlineBox; template <class Iterator, class Run> class BidiResolver; @@ -43,11 +45,18 @@ typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver; enum CaretType { CursorCaret, DragCaret }; -class RenderBlock : public RenderFlow { +class RenderBlock : public RenderBox { public: RenderBlock(Node*); virtual ~RenderBlock(); + virtual RenderObjectChildList* virtualChildren() { return children(); } + virtual const RenderObjectChildList* virtualChildren() const { return children(); } + const RenderObjectChildList* children() const { return &m_children; } + RenderObjectChildList* children() { return &m_children; } + + virtual void destroy(); + virtual const char* renderName() const; // These two functions are overridden for inline-block. @@ -58,10 +67,17 @@ public: virtual bool isBlockFlow() const { return (!isInline() || isReplaced()) && !isTable(); } virtual bool isInlineBlockOrInlineTable() const { return isInline() && isReplaced(); } - virtual bool childrenInline() const { return m_childrenInline; } - virtual void setChildrenInline(bool b) { m_childrenInline = b; } void makeChildrenNonInline(RenderObject* insertionPoint = 0); + virtual void removeLeftoverAnonymousBlock(RenderBlock* child); + + RenderLineBoxList* lineBoxes() { return &m_lineBoxes; } + const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; } + + InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); } + InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); } + void deleteLineBoxTree(); + virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); } // The height (and width) of a block when you include overflow spillage out of the bottom // of the block (e.g., a <div style="height:25px"> that has a 100px tall image inside @@ -77,8 +93,6 @@ public: void addVisualOverflow(const IntRect&); virtual bool isSelfCollapsingBlock() const; - virtual bool isTopMarginQuirk() const { return m_topMarginQuirk; } - virtual bool isBottomMarginQuirk() const { return m_bottomMarginQuirk; } virtual int maxTopMargin(bool positive) const { return positive ? maxTopPosMargin() : maxTopNegMargin(); } virtual int maxBottomMargin(bool positive) const { return positive ? maxBottomPosMargin() : maxBottomNegMargin(); } @@ -100,7 +114,7 @@ public: } } - virtual void addChildToFlow(RenderObject* newChild, RenderObject* beforeChild); + virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0); virtual void removeChild(RenderObject*); virtual void repaintOverhangingFloats(bool paintAllDescendants); @@ -117,11 +131,16 @@ public: void addPercentHeightDescendant(RenderBox*); static void removePercentHeightDescendant(RenderBox*); + HashSet<RenderBox*>* percentHeightDescendants() const; virtual void positionListMarker() { } virtual void borderFitAdjust(int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set. + virtual void updateBeforeAfterContent(PseudoId); + + RootInlineBox* createRootInlineBox(); + // Called to lay out the legend for a fieldset. virtual RenderObject* layoutLegend(bool /*relayoutChildren*/) { return 0; } @@ -138,7 +157,7 @@ public: }; void bidiReorderLine(InlineBidiResolver&, const InlineIterator& end); - RootInlineBox* determineStartPosition(bool& fullLayout, InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats); + RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats); RootInlineBox* determineEndPosition(RootInlineBox* startBox, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus, int& yPos); @@ -146,12 +165,12 @@ public: RootInlineBox*& endLine, int& endYPos, int& repaintBottom, int& repaintTop); bool generatesLineBoxesForInlineChild(RenderObject*); void skipTrailingWhitespace(InlineIterator&); - int skipLeadingWhitespace(InlineBidiResolver&); - void fitBelowFloats(int widthToFit, int& availableWidth); - InlineIterator findNextLineBreak(InlineBidiResolver&, EClear* clear = 0); - RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool lastLine, RenderObject* endObject); - InlineFlowBox* createLineBoxes(RenderObject*); - void computeHorizontalPositionsForLine(RootInlineBox*, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd); + int skipLeadingWhitespace(InlineBidiResolver&, bool firstLine); + void fitBelowFloats(int widthToFit, bool firstLine, int& availableWidth); + InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, EClear* clear = 0); + RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool firstLine, bool lastLine, RenderObject* endObject); + InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine); + void computeHorizontalPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd); void computeVerticalPositionsForLine(RootInlineBox*, BidiRun*); void checkLinesForOverflow(); void deleteEllipsisLineBoxes(); @@ -162,7 +181,8 @@ public: virtual void paintObject(PaintInfo&, int tx, int ty); void paintFloats(PaintInfo&, int tx, int ty, bool preservePhase = false); void paintContents(PaintInfo&, int tx, int ty); - void paintColumns(PaintInfo&, int tx, int ty, bool paintFloats = false); + void paintColumnContents(PaintInfo&, int tx, int ty, bool paintFloats = false); + void paintColumnRules(PaintInfo&, int tx, int ty); void paintChildren(PaintInfo&, int tx, int ty); void paintEllipsisBoxes(PaintInfo&, int tx, int ty); void paintSelection(PaintInfo&, int tx, int ty); @@ -175,16 +195,16 @@ public: // Returns ture if and only if it has positioned any floats. bool positionNewFloats(); void clearFloats(); - int getClearDelta(RenderBox* child); + int getClearDelta(RenderBox* child, int yPos); void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true); void markPositionedObjectsForLayout(); - virtual bool containsFloats() { return m_floatingObjects && !m_floatingObjects->isEmpty(); } - virtual bool containsFloat(RenderObject*); + bool containsFloats() { return m_floatingObjects && !m_floatingObjects->isEmpty(); } + bool containsFloat(RenderObject*); virtual bool avoidsFloats() const; - virtual bool hasOverhangingFloats() { return !hasColumns() && floatBottom() > height(); } + bool hasOverhangingFloats() { return parent() && !hasColumns() && floatBottom() > height(); } void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset); int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats); @@ -194,18 +214,18 @@ public: inline int rightBottom(); IntRect floatRect() const; - virtual int lineWidth(int) const; + int lineWidth(int y, bool firstLine) const; virtual int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const; virtual int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const; virtual int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const; int rightOffset() const; int rightRelOffset(int y, int fixedOffset, bool applyTextIndent = true, int* heightRemaining = 0) const; - int rightOffset(int y) const { return rightRelOffset(y, rightOffset(), true); } + int rightOffset(int y, bool firstLine) const { return rightRelOffset(y, rightOffset(), firstLine); } int leftOffset() const; int leftRelOffset(int y, int fixedOffset, bool applyTextIndent = true, int* heightRemaining = 0) const; - int leftOffset(int y) const { return leftRelOffset(y, leftOffset(), true); } + int leftOffset(int y, bool firstLine) const { return leftRelOffset(y, leftOffset(), firstLine); } virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); @@ -213,7 +233,7 @@ public: virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty); - virtual VisiblePosition positionForCoordinates(int x, int y); + virtual VisiblePosition positionForPoint(const IntPoint&); // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.) virtual int availableWidth() const; @@ -222,8 +242,8 @@ public: void calcInlinePrefWidths(); void calcBlockPrefWidths(); - virtual int getBaselineOfFirstLineBox() const; - virtual int getBaselineOfLastLineBox() const; + virtual int firstLineBoxBaseline() const; + virtual int lastLineBoxBaseline() const; RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); } RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); } @@ -237,38 +257,22 @@ public: bool inRootBlockContext() const; - void setHasMarkupTruncation(bool b = true) { m_hasMarkupTruncation = b; } - bool hasMarkupTruncation() const { return m_hasMarkupTruncation; } + virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth); + virtual RenderStyle* outlineStyleForRepaint() const; + + virtual RenderObject* hoverAncestor() const; + virtual void updateDragState(bool dragOn); + virtual void updateHitTestResult(HitTestResult&, const IntPoint&); + + virtual void childBecameNonInline(RenderObject* child); - virtual bool hasSelectedChildren() const { return m_selectionState != SelectionNone; } - virtual SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); } virtual void setSelectionState(SelectionState s); - struct BlockSelectionInfo { - RenderBlock* m_block; - GapRects m_rects; - SelectionState m_state; - - BlockSelectionInfo() - : m_block(0) - , m_state(SelectionNone) - { - } - - BlockSelectionInfo(RenderBlock* b) - : m_block(b) - , m_rects(b->needsLayout() ? GapRects() : b->selectionGapRects()) - , m_state(b->selectionState()) - { - } - - RenderBlock* block() const { return m_block; } - GapRects rects() const { return m_rects; } - SelectionState state() const { return m_state; } - }; - - virtual IntRect selectionRect(bool) { return selectionGapRects(); } - GapRects selectionGapRects(); + virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool /*clipToVisibleContent*/) + { + return selectionGapRectsForRepaint(repaintContainer); + } + GapRects selectionGapRectsForRepaint(RenderBoxModelObject* repaintContainer); virtual bool shouldPaintSelectionGaps() const; bool isSelectionRoot() const; GapRects fillSelectionGaps(RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty, @@ -289,6 +293,9 @@ public: int leftSelectionOffset(RenderBlock* rootBlock, int y); int rightSelectionOffset(RenderBlock* rootBlock, int y); + virtual void absoluteRects(Vector<IntRect>&, int tx, int ty, bool topLevel = true); + virtual void absoluteQuads(Vector<FloatQuad>&, bool topLevel = true); + // Helper methods for computing line counts and heights for line counts. RootInlineBox* lineAtIndex(int); int lineCount(); @@ -299,12 +306,24 @@ public: unsigned desiredColumnCount() const; Vector<IntRect>* columnRects() const; void setDesiredColumnCountAndWidth(int count, int width); + int columnGap() const; void adjustRectForColumns(IntRect&) const; - void addContinuationWithOutline(RenderFlow*); + void addContinuationWithOutline(RenderInline*); void paintContinuationOutlines(PaintInfo&, int tx, int ty); + RenderInline* inlineContinuation() const { return m_inlineContinuation; } + void setInlineContinuation(RenderInline* c) { m_inlineContinuation = c; } + + virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0); + + virtual void addFocusRingRects(GraphicsContext*, int tx, int ty); + + // This function is a convenience helper for creating an anonymous block that inherits its + // style from this RenderBlock. + RenderBlock* createAnonymousBlock() const; + private: void adjustPointToColumnContents(IntPoint&) const; void adjustForBorderFit(int x, int& left, int& right) const; // Helper function for borderFitAdjust @@ -312,13 +331,15 @@ private: void markLinesDirtyInVerticalRange(int top, int bottom); protected: - virtual void styleWillChange(RenderStyle::Diff, const RenderStyle* newStyle); - virtual void styleDidChange(RenderStyle::Diff, const RenderStyle* oldStyle); + virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle); + virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); void newLine(EClear); virtual bool hasLineIfEmpty() const; bool layoutOnlyPositionedObjects(); + virtual RootInlineBox* createRootBox(); // Subclassed by SVG. + private: Position positionForBox(InlineBox*, bool start = true) const; Position positionForRenderer(RenderObject*, bool start = true) const; @@ -326,15 +347,6 @@ private: // Adjust tx and ty from painting offsets to the local coords of this renderer void offsetForContents(int& tx, int& ty) const; - // columGap() is used by WebKit when hit-testing columns. It's called by - // CacheBuilder when it duplicates the hit-testing logic. -#ifdef ANDROID_EXPOSE_COLUMN_GAP - public: -#endif - int columnGap() const; -#ifdef ANDROID_EXPOSE_COLUMN_GAP -private: -#endif void calcColumnWidth(); int layoutColumns(int endOfContent = -1); @@ -443,8 +455,8 @@ protected: RenderBox* handleFloatingChild(RenderBox* child, const MarginInfo&, bool& handled); RenderBox* handlePositionedChild(RenderBox* child, const MarginInfo&, bool& handled); RenderBox* handleRunInChild(RenderBox* child, bool& handled); - void collapseMargins(RenderBox* child, MarginInfo&, int yPosEstimate); - void clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin); + int collapseMargins(RenderBox* child, MarginInfo&); + int clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos); int estimateVerticalPosition(RenderBox* child, const MarginInfo&); void determineHorizontalPosition(RenderBox* child); void handleBottomOfBlock(int top, int bottom, MarginInfo&); @@ -455,7 +467,13 @@ private: typedef ListHashSet<RenderBox*>::const_iterator Iterator; DeprecatedPtrList<FloatingObject>* m_floatingObjects; ListHashSet<RenderBox*>* m_positionedObjects; - + + // An inline can be split with blocks occurring in between the inline content. + // When this occurs we need a pointer to our next object. We can basically be + // split into a sequence of inlines and blocks. The continuation will either be + // an anonymous block (that houses other blocks) or it will be an inline flow. + RenderInline* m_inlineContinuation; + // Allocated only when some of these fields have non-default values struct MaxMargin { MaxMargin(const RenderBlock* o) @@ -480,13 +498,33 @@ private: MaxMargin* m_maxMargin; protected: + RenderObjectChildList m_children; + 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>. + // How much content overflows out of our block vertically or horizontally. int m_overflowHeight; int m_overflowWidth; int m_overflowLeft; int m_overflowTop; + + mutable int m_lineHeight; }; +inline RenderBlock* toRenderBlock(RenderObject* o) +{ + ASSERT(!o || o->isRenderBlock()); + return static_cast<RenderBlock*>(o); +} + +inline const RenderBlock* toRenderBlock(const RenderObject* o) +{ + ASSERT(!o || o->isRenderBlock()); + return static_cast<const RenderBlock*>(o); +} + +// This will catch anyone doing an unnecessary cast. +void toRenderBlock(const RenderBlock* o); + } // namespace WebCore #endif // RenderBlock_h |