Changeset 93333 in webkit
- Timestamp:
- Aug 18, 2011 12:23:22 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93332 r93333 1 2011-08-18 Levi Weintraub <leviw@chromium.org> 2 3 Switch Inline rendering classes to new layout types 4 https://bugs.webkit.org/show_bug.cgi?id=66239 5 6 Reviewed by Eric Seidel. 7 8 Converting inline rendering classes to use the LayoutUnit abstraction from ints. 9 10 No new tests as no change in functionality. 11 12 * rendering/InlineBox.h: 13 (WebCore::InlineBox::logicalFrameRect): 14 (WebCore::InlineBox::baselinePosition): 15 (WebCore::InlineBox::lineHeight): 16 * rendering/InlineFlowBox.h: 17 * rendering/InlineTextBox.cpp: 18 (WebCore::InlineTextBox::logicalOverflowRect): 19 (WebCore::InlineTextBox::setLogicalOverflowRect): 20 (WebCore::InlineTextBox::baselinePosition): 21 (WebCore::InlineTextBox::lineHeight): 22 * rendering/InlineTextBox.h: 23 (WebCore::InlineTextBox::logicalTopVisualOverflow): 24 (WebCore::InlineTextBox::logicalBottomVisualOverflow): 25 (WebCore::InlineTextBox::logicalLeftVisualOverflow): 26 (WebCore::InlineTextBox::logicalRightVisualOverflow): 27 * rendering/RenderInline.cpp: 28 (WebCore::RenderInline::culledInlineAbsoluteRects): 29 (WebCore::computeMargin): 30 (WebCore::RenderInline::culledInlineBoundingBox): 31 (WebCore::RenderInline::culledInlineVisualOverflowBoundingBox): 32 (WebCore::RenderInline::linesVisualOverflowBoundingBox): 33 (WebCore::RenderInline::clippedOverflowRectForRepaint): 34 (WebCore::RenderInline::rectWithOutlineForRepaint): 35 (WebCore::RenderInline::computeRectForRepaint): 36 (WebCore::RenderInline::mapLocalToContainer): 37 (WebCore::RenderInline::lineHeight): 38 (WebCore::RenderInline::baselinePosition): 39 (WebCore::RenderInline::addDashboardRegions): 40 * rendering/RenderInline.h: 41 1 42 2011-08-18 Jeffrey Pfau <jpfau@apple.com> 2 43 -
trunk/Source/WebCore/rendering/InlineBox.h
r90869 r93333 272 272 LayoutUnit logicalHeight() const; 273 273 274 FloatRect logicalFrameRect() const { return isHorizontal() ? IntRect(m_topLeft.x(), m_topLeft.y(), m_logicalWidth, logicalHeight()) : IntRect(m_topLeft.y(), m_topLeft.x(), m_logicalWidth, logicalHeight()); }275 276 virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); }277 virtual int lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); }274 FloatRect logicalFrameRect() const { return isHorizontal() ? FloatRect(m_topLeft.x(), m_topLeft.y(), m_logicalWidth, logicalHeight()) : FloatRect(m_topLeft.y(), m_topLeft.x(), m_logicalWidth, logicalHeight()); } 275 276 virtual LayoutUnit baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); } 277 virtual LayoutUnit lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); } 278 278 279 279 virtual int caretMinOffset() const; -
trunk/Source/WebCore/rendering/InlineFlowBox.h
r92340 r93333 249 249 } 250 250 251 void setOverflowFromLogicalRects(const LayoutRect& logicalLayoutOverflow, const IntRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom);251 void setOverflowFromLogicalRects(const LayoutRect& logicalLayoutOverflow, const LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom); 252 252 void setLayoutOverflow(const LayoutRect&, LayoutUnit lineTop, LayoutUnit lineBottom); 253 253 void setVisualOverflow(const LayoutRect&, LayoutUnit lineTop, LayoutUnit lineBottom); -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r92625 r93333 54 54 namespace WebCore { 55 55 56 typedef WTF::HashMap<const InlineTextBox*, IntRect> InlineTextBoxOverflowMap;56 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap; 57 57 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow; 58 58 … … 64 64 } 65 65 66 IntRect InlineTextBox::logicalOverflowRect() const66 LayoutRect InlineTextBox::logicalOverflowRect() const 67 67 { 68 68 if (m_knownToHaveNoOverflow || !gTextBoxesWithOverflow) … … 71 71 } 72 72 73 void InlineTextBox::setLogicalOverflowRect(const IntRect& rect)73 void InlineTextBox::setLogicalOverflowRect(const LayoutRect& rect) 74 74 { 75 75 ASSERT(!m_knownToHaveNoOverflow); … … 79 79 } 80 80 81 int InlineTextBox::baselinePosition(FontBaseline baselineType) const81 LayoutUnit InlineTextBox::baselinePosition(FontBaseline baselineType) const 82 82 { 83 83 if (!isText() || !parent()) … … 87 87 return toRenderBoxModelObject(renderer()->parent())->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); 88 88 } 89 90 int InlineTextBox::lineHeight() const89 90 LayoutUnit InlineTextBox::lineHeight() const 91 91 { 92 92 if (!isText() || !renderer()->parent()) -
trunk/Source/WebCore/rendering/InlineTextBox.h
r92625 r93333 79 79 static inline bool compareByStart(const InlineTextBox* first, const InlineTextBox* second) { return first->start() < second->start(); } 80 80 81 virtual int baselinePosition(FontBaseline) const;82 virtual int lineHeight() const;81 virtual LayoutUnit baselinePosition(FontBaseline) const; 82 virtual LayoutUnit lineHeight() const; 83 83 84 84 bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const; 85 85 86 IntRect logicalOverflowRect() const;87 void setLogicalOverflowRect(const IntRect&);88 int logicalTopVisualOverflow() const { return logicalOverflowRect().y(); }89 int logicalBottomVisualOverflow() const { return logicalOverflowRect().maxY(); }90 int logicalLeftVisualOverflow() const { return logicalOverflowRect().x(); }91 int logicalRightVisualOverflow() const { return logicalOverflowRect().maxX(); }86 LayoutRect logicalOverflowRect() const; 87 void setLogicalOverflowRect(const LayoutRect&); 88 LayoutUnit logicalTopVisualOverflow() const { return logicalOverflowRect().y(); } 89 LayoutUnit logicalBottomVisualOverflow() const { return logicalOverflowRect().maxY(); } 90 LayoutUnit logicalLeftVisualOverflow() const { return logicalOverflowRect().x(); } 91 LayoutUnit logicalRightVisualOverflow() const { return logicalOverflowRect().maxX(); } 92 92 93 93 #ifndef NDEBUG -
trunk/Source/WebCore/rendering/RenderInline.cpp
r93303 r93333 486 486 } 487 487 488 void RenderInline::culledInlineAbsoluteRects(const RenderInline* container, Vector< IntRect>& rects, const IntSize& offset)488 void RenderInline::culledInlineAbsoluteRects(const RenderInline* container, Vector<LayoutRect>& rects, const LayoutSize& offset) 489 489 { 490 490 if (!culledInlineFirstLineBox()) { … … 661 661 return margin.value(); 662 662 if (margin.isPercent()) 663 return margin.calcMinValue(max (0, renderer->containingBlock()->availableLogicalWidth()));663 return margin.calcMinValue(max<LayoutUnit>(0, renderer->containingBlock()->availableLogicalWidth())); 664 664 return 0; 665 665 } … … 838 838 } 839 839 } 840 return enclosing IntRect(result);840 return enclosingLayoutRect(result); 841 841 } 842 842 … … 889 889 } 890 890 891 IntRect RenderInline::culledInlineVisualOverflowBoundingBox() const892 { 893 IntRect result(culledInlineBoundingBox(this));891 LayoutRect RenderInline::culledInlineVisualOverflowBoundingBox() const 892 { 893 LayoutRect result(culledInlineBoundingBox(this)); 894 894 bool isHorizontal = style()->isHorizontalWritingMode(); 895 895 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { … … 901 901 RenderBox* currBox = toRenderBox(curr); 902 902 if (!currBox->hasSelfPaintingLayer() && currBox->inlineBoxWrapper()) { 903 IntRect logicalRect = currBox->logicalVisualOverflowRectForPropagation(style());903 LayoutRect logicalRect = currBox->logicalVisualOverflowRectForPropagation(style()); 904 904 if (isHorizontal) { 905 905 logicalRect.moveBy(currBox->location()); … … 927 927 } 928 928 929 IntRect RenderInline::linesVisualOverflowBoundingBox() const929 LayoutRect RenderInline::linesVisualOverflowBoundingBox() const 930 930 { 931 931 if (!alwaysCreateLineBoxes()) … … 933 933 934 934 if (!firstLineBox() || !lastLineBox()) 935 return IntRect();935 return LayoutRect(); 936 936 937 937 // Return the width of the minimal left side and the maximal right side. 938 int logicalLeftSide = numeric_limits<int>::max();939 int logicalRightSide = numeric_limits<int>::min();938 LayoutUnit logicalLeftSide = numeric_limits<LayoutUnit>::max(); 939 LayoutUnit logicalRightSide = numeric_limits<LayoutUnit>::min(); 940 940 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { 941 941 logicalLeftSide = min(logicalLeftSide, curr->logicalLeftVisualOverflow()); … … 946 946 RootInlineBox* lastRootBox = lastLineBox()->root(); 947 947 948 int logicalTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox->lineTop());949 int logicalWidth = logicalRightSide - logicalLeftSide;950 int logicalHeight = lastLineBox()->logicalBottomVisualOverflow(lastRootBox->lineBottom()) - logicalTop;951 952 IntRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight);948 LayoutUnit logicalTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox->lineTop()); 949 LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide; 950 LayoutUnit logicalHeight = lastLineBox()->logicalBottomVisualOverflow(lastRootBox->lineBottom()) - logicalTop; 951 952 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); 953 953 if (!style()->isHorizontalWritingMode()) 954 954 rect = rect.transposedRect(); … … 956 956 } 957 957 958 IntRect RenderInline::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const958 LayoutRect RenderInline::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const 959 959 { 960 960 // Only run-ins are allowed in here during layout. … … 962 962 963 963 if (!firstLineBoxIncludingCulling() && !continuation()) 964 return IntRect();964 return LayoutRect(); 965 965 966 966 // Find our leftmost position. 967 IntRect boundingBox(linesVisualOverflowBoundingBox());968 int left = boundingBox.x();969 int top = boundingBox.y();967 LayoutRect boundingBox(linesVisualOverflowBoundingBox()); 968 LayoutUnit left = boundingBox.x(); 969 LayoutUnit top = boundingBox.y(); 970 970 971 971 // Now invalidate a rectangle. 972 int ow = style() ? style()->outlineSize() : 0;972 LayoutUnit ow = style() ? style()->outlineSize() : 0; 973 973 974 974 // We need to add in the relative position offsets of any inlines (including us) up to our … … 981 981 } 982 982 983 IntRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2);983 LayoutRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2); 984 984 985 985 if (cb->hasColumns()) … … 990 990 // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint 991 991 // anyway if its size does change. 992 IntRect repaintRect(r);992 LayoutRect repaintRect(r); 993 993 repaintRect.move(-cb->layer()->scrolledContentOffset()); // For overflow:auto/scroll/hidden. 994 994 995 IntRect boxRect(IntPoint(), cb->layer()->size());995 LayoutRect boxRect(LayoutPoint(), cb->layer()->size()); 996 996 r = intersection(repaintRect, boxRect); 997 997 } … … 1005 1005 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { 1006 1006 if (!curr->isText()) { 1007 IntRect childRect = curr->rectWithOutlineForRepaint(repaintContainer, ow);1007 LayoutRect childRect = curr->rectWithOutlineForRepaint(repaintContainer, ow); 1008 1008 r.unite(childRect); 1009 1009 } … … 1011 1011 1012 1012 if (continuation() && !continuation()->isInline()) { 1013 IntRect contRect = continuation()->rectWithOutlineForRepaint(repaintContainer, ow);1013 LayoutRect contRect = continuation()->rectWithOutlineForRepaint(repaintContainer, ow); 1014 1014 r.unite(contRect); 1015 1015 } … … 1019 1019 } 1020 1020 1021 IntRect RenderInline::rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth) const1022 { 1023 IntRect r(RenderBoxModelObject::rectWithOutlineForRepaint(repaintContainer, outlineWidth));1021 LayoutRect RenderInline::rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const 1022 { 1023 LayoutRect r(RenderBoxModelObject::rectWithOutlineForRepaint(repaintContainer, outlineWidth)); 1024 1024 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { 1025 1025 if (!curr->isText()) … … 1029 1029 } 1030 1030 1031 void RenderInline::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed) const1031 void RenderInline::computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect& rect, bool fixed) const 1032 1032 { 1033 1033 if (RenderView* v = view()) { … … 1052 1052 return; 1053 1053 1054 IntPoint topLeft = rect.location();1054 LayoutPoint topLeft = rect.location(); 1055 1055 1056 1056 if (o->isBlockFlow() && style()->position() != AbsolutePosition && style()->position() != FixedPosition) { 1057 1057 RenderBlock* cb = toRenderBlock(o); 1058 1058 if (cb->hasColumns()) { 1059 IntRect repaintRect(topLeft, rect.size());1059 LayoutRect repaintRect(topLeft, rect.size()); 1060 1060 cb->adjustRectForColumns(repaintRect); 1061 1061 topLeft = repaintRect.location(); … … 1082 1082 topLeft -= containerBox->layer()->scrolledContentOffset(); // For overflow:auto/scroll/hidden. 1083 1083 1084 IntRect repaintRect(topLeft, rect.size());1085 IntRect boxRect(IntPoint(), containerBox->layer()->size());1084 LayoutRect repaintRect(topLeft, rect.size()); 1085 LayoutRect boxRect(LayoutPoint(), containerBox->layer()->size()); 1086 1086 rect = intersection(repaintRect, boxRect); 1087 1087 if (rect.isEmpty()) … … 1092 1092 if (containerSkipped) { 1093 1093 // If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates. 1094 IntSize containerOffset = repaintContainer->offsetFromAncestorContainer(o);1094 LayoutSize containerOffset = repaintContainer->offsetFromAncestorContainer(o); 1095 1095 rect.move(-containerOffset); 1096 1096 return; … … 1154 1154 // There can't be a transform between repaintContainer and o, because transforms create containers, so it should be safe 1155 1155 // to just subtract the delta between the repaintContainer and o. 1156 IntSize containerOffset = repaintContainer->offsetFromAncestorContainer(o);1156 LayoutSize containerOffset = repaintContainer->offsetFromAncestorContainer(o); 1157 1157 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); 1158 1158 return; … … 1272 1272 } 1273 1273 1274 int RenderInline::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const1274 LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const 1275 1275 { 1276 1276 if (firstLine && document()->usesFirstLineRules()) { … … 1286 1286 } 1287 1287 1288 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const1288 LayoutUnit RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 1289 1289 { 1290 1290 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); … … 1512 1512 StyleDashboardRegion styleRegion = styleRegions[i]; 1513 1513 1514 IntRect linesBoundingBox = this->linesBoundingBox();1515 int w = linesBoundingBox.width();1516 int h = linesBoundingBox.height();1514 LayoutRect linesBoundingBox = this->linesBoundingBox(); 1515 LayoutUnit w = linesBoundingBox.width(); 1516 LayoutUnit h = linesBoundingBox.height(); 1517 1517 1518 1518 DashboardRegionValue region; 1519 1519 region.label = styleRegion.label; 1520 region.bounds = IntRect(linesBoundingBox.x() + styleRegion.offset.left().value(),1520 region.bounds = LayoutRect(linesBoundingBox.x() + styleRegion.offset.left().value(), 1521 1521 linesBoundingBox.y() + styleRegion.offset.top().value(), 1522 1522 w - styleRegion.offset.left().value() - styleRegion.offset.right().value(), -
trunk/Source/WebCore/rendering/RenderInline.h
r92692 r93333 53 53 54 54 LayoutRect linesBoundingBox() const; 55 IntRect linesVisualOverflowBoundingBox() const;55 LayoutRect linesVisualOverflowBoundingBox() const; 56 56 57 57 InlineFlowBox* createAndAppendInlineFlowBox(); … … 100 100 101 101 FloatRect culledInlineBoundingBox(const RenderInline* container) const; 102 IntRect culledInlineVisualOverflowBoundingBox() const;102 LayoutRect culledInlineVisualOverflowBoundingBox() const; 103 103 InlineBox* culledInlineFirstLineBox() const; 104 104 InlineBox* culledInlineLastLineBox() const; 105 void culledInlineAbsoluteRects(const RenderInline* container, Vector< IntRect>&, const IntSize&);105 void culledInlineAbsoluteRects(const RenderInline* container, Vector<LayoutRect>&, const LayoutSize&); 106 106 void culledInlineAbsoluteQuads(const RenderInline* container, Vector<FloatQuad>&); 107 107 … … 127 127 virtual LayoutUnit offsetHeight() const { return linesBoundingBox().height(); } 128 128 129 virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;130 virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth) const;131 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed) const;129 virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const; 130 virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const; 131 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed) const; 132 132 133 133 virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&, bool* wasFixed = 0) const; … … 146 146 virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); } 147 147 148 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;149 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;148 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 149 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 150 150 151 151 virtual void childBecameNonInline(RenderObject* child); … … 170 170 RenderLineBoxList m_lineBoxes; // All of the line boxes created for this inline flow. For example, <i>Hello<br>world.</i> will have two <i> line boxes. 171 171 172 mutable int m_lineHeight : 31;172 mutable LayoutUnit m_lineHeight; 173 173 bool m_alwaysCreateLineBoxes : 1; 174 174 };
Note: See TracChangeset
for help on using the changeset viewer.