📄 renderblock.h
字号:
/* * This file is part of the render object implementation for KHTML. * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2007 David Smith (catfish.man@gmail.com) * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */#ifndef RenderBlock_h#define RenderBlock_h#include "DeprecatedPtrList.h"#include "GapRects.h"#include "RenderBox.h"#include "RenderLineBoxList.h"#include "RootInlineBox.h"#include <wtf/ListHashSet.h>namespace WebCore {class InlineIterator;class BidiRun;class Position;class RenderInline;class RootInlineBox;template <class Iterator, class Run> class BidiResolver;typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;enum CaretType { CursorCaret, DragCaret };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. virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const; virtual int baselinePosition(bool firstLine, bool isRootLineBox = false) const; virtual bool isRenderBlock() const { return true; } virtual bool isBlockFlow() const { return (!isInline() || isReplaced()) && !isTable(); } virtual bool isInlineBlockOrInlineTable() const { return isInline() && isReplaced(); } 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 // it would have an overflow height of borderTop() + paddingTop() + 100px. virtual int overflowHeight(bool includeInterior = true) const; virtual int overflowWidth(bool includeInterior = true) const; virtual int overflowLeft(bool includeInterior = true) const; virtual int overflowTop(bool includeInterior = true) const; virtual IntRect overflowRect(bool includeInterior = true) const; virtual void setOverflowHeight(int h) { m_overflowHeight = h; } virtual void setOverflowWidth(int w) { m_overflowWidth = w; } void addVisualOverflow(const IntRect&); virtual bool isSelfCollapsingBlock() const; virtual int maxTopMargin(bool positive) const { return positive ? maxTopPosMargin() : maxTopNegMargin(); } virtual int maxBottomMargin(bool positive) const { return positive ? maxBottomPosMargin() : maxBottomNegMargin(); } int maxTopPosMargin() const { return m_maxMargin ? m_maxMargin->m_topPos : MaxMargin::topPosDefault(this); } int maxTopNegMargin() const { return m_maxMargin ? m_maxMargin->m_topNeg : MaxMargin::topNegDefault(this); } int maxBottomPosMargin() const { return m_maxMargin ? m_maxMargin->m_bottomPos : MaxMargin::bottomPosDefault(this); } int maxBottomNegMargin() const { return m_maxMargin ? m_maxMargin->m_bottomNeg : MaxMargin::bottomNegDefault(this); } void setMaxTopMargins(int pos, int neg); void setMaxBottomMargins(int pos, int neg); void initMaxMarginValues() { if (m_maxMargin) { m_maxMargin->m_topPos = MaxMargin::topPosDefault(this); m_maxMargin->m_topNeg = MaxMargin::topNegDefault(this); m_maxMargin->m_bottomPos = MaxMargin::bottomPosDefault(this); m_maxMargin->m_bottomNeg = MaxMargin::bottomNegDefault(this); } } virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0); virtual void removeChild(RenderObject*); virtual void repaintOverhangingFloats(bool paintAllDescendants); virtual void layout(); virtual void layoutBlock(bool relayoutChildren); void layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom); void layoutInlineChildren(bool relayoutChildren, int& repaintTop, int& repaintBottom); void layoutPositionedObjects(bool relayoutChildren); void insertPositionedObject(RenderBox*); void removePositionedObject(RenderBox*); void removePositionedObjects(RenderBlock*); void addPercentHeightDescendant(RenderBox*); static void removePercentHeightDescendant(RenderBox*); 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; } // the implementation of the following functions is in bidi.cpp struct FloatWithRect { FloatWithRect(RenderBox* f) : object(f) , rect(IntRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom())) { } RenderBox* object; IntRect rect; }; void bidiReorderLine(InlineBidiResolver&, const InlineIterator& end); RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats); RootInlineBox* determineEndPosition(RootInlineBox* startBox, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus, int& yPos); bool matchedEndLine(const InlineBidiResolver&, const InlineIterator& endLineStart, const BidiStatus& endLineStatus, RootInlineBox*& endLine, int& endYPos, int& repaintBottom, int& repaintTop); bool generatesLineBoxesForInlineChild(RenderObject*); void skipTrailingWhitespace(InlineIterator&); 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(); void checkLinesForTextOverflow(); // end bidi.cpp functions virtual void paint(PaintInfo&, int tx, int ty); 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 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); void paintCaret(PaintInfo&, int tx, int ty, CaretType); void insertFloatingObject(RenderBox*); void removeFloatingObject(RenderBox*); // Called from lineWidth, to position the floats added in the last line. // Returns ture if and only if it has positioned any floats. bool positionNewFloats(); void clearFloats(); int getClearDelta(RenderBox* child, int yPos); void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true); void markPositionedObjectsForLayout(); bool containsFloats() { return m_floatingObjects && !m_floatingObjects->isEmpty(); } bool containsFloat(RenderObject*); virtual bool avoidsFloats() const; 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); int nextFloatBottomBelow(int) const; int floatBottom() const; inline int leftBottom(); inline int rightBottom(); IntRect floatRect() 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, 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, 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); virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty); 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; virtual void calcPrefWidths(); void calcInlinePrefWidths(); void calcBlockPrefWidths(); virtual int firstLineBoxBaseline() const; virtual int lastLineBoxBaseline() const; RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); } RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); } bool containsNonZeroBidiLevel() const; // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline // children. virtual RenderBlock* firstLineBlock() const; virtual void updateFirstLetter(); bool inRootBlockContext() const; 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&);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -