Changeset 110496 in webkit
- Timestamp:
- Mar 12, 2012 3:59:44 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r110495 r110496 1 2012-03-12 Levi Weintraub <leviw@chromium.org> 2 3 Update LayoutUnit usage in RenderMathML* classes 4 https://bugs.webkit.org/show_bug.cgi?id=77916 5 6 Reviewed by Eric Seidel. 7 8 The purpose of this patch is to ensure MathML rendering does not regress when 9 we switch to sub-pixel layout. A subsequent patch can likely improve MathML's 10 rendering when zoom is applied. 11 12 To accomplish this without changing the current heuristics for positioning, 13 we continue to use integers for sizes and locations, using pixel snapping 14 when communicating with other Rendering classes. 15 16 No new tests. No change in behavior. 17 18 * rendering/mathml/RenderMathMLBlock.cpp: 19 (WebCore::RenderMathMLBlock::paint): Cleaning up debug painting to be on 20 pixel boundaries instead of subpixel. 21 * rendering/mathml/RenderMathMLFraction.cpp: 22 (WebCore::RenderMathMLFraction::paint): Reverting to integers for determining 23 the vertical offset. 24 (WebCore::RenderMathMLFraction::baselinePosition): 25 * rendering/mathml/RenderMathMLRoot.cpp: 26 (WebCore::RenderMathMLRoot::paint): Using integers for height and width 27 and only accumulating pixel snapped values. 28 (WebCore::RenderMathMLRoot::layout): Setting padding with integers to 29 avoid inconsistent rounding based on the root's location. 30 * rendering/mathml/RenderMathMLRow.cpp: 31 (WebCore::RenderMathMLRow::layout): 32 * rendering/mathml/RenderMathMLSquareRoot.cpp: 33 (WebCore::RenderMathMLSquareRoot::paint): See RenderMathMLRoot. 34 (WebCore::RenderMathMLSquareRoot::layout): Ditto. 35 * rendering/mathml/RenderMathMLUnderOver.cpp: 36 (WebCore::getOffsetHeight): 37 (WebCore::RenderMathMLUnderOver::layout): 38 1 39 2012-03-12 Anders Carlsson <andersca@apple.com> 2 40 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
r108249 r110496 83 83 info.context->setStrokeColor(Color(0, 0, 255), ColorSpaceSRGB); 84 84 85 info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));86 info.context->drawLine( LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));87 info.context->drawLine( LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));88 info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()));85 info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y())); 86 info.context->drawLine(IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight())); 87 info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight())); 88 info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight())); 89 89 90 90 int topStart = paddingTop(); … … 92 92 info.context->setStrokeColor(Color(0, 255, 0), ColorSpaceSRGB); 93 93 94 info.context->drawLine( LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + topStart));94 info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + topStart)); 95 95 96 int baseline = baselinePosition(AlphabeticBaseline, true, HorizontalLine);96 int baseline = roundToInt(baselinePosition(AlphabeticBaseline, true, HorizontalLine)); 97 97 98 98 info.context->setStrokeColor(Color(255, 0, 0), ColorSpaceSRGB); 99 99 100 info.context->drawLine( LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + baseline));100 info.context->drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + baseline)); 101 101 } 102 102 #endif // ENABLE(DEBUG_MATH_LAYOUT) -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
r108136 r110496 152 152 return; 153 153 154 LayoutUnit verticalOffset = 0;154 int verticalOffset = 0; 155 155 // The children are always RenderMathMLBlock instances 156 156 if (firstChild()->isRenderMathMLBlock()) { … … 160 160 RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild()); 161 161 if (numerator->isRenderMathMLRow()) 162 verticalOffset = numerator-> offsetHeight() + adjustForThickness;162 verticalOffset = numerator->pixelSnappedOffsetHeight() + adjustForThickness; 163 163 else 164 verticalOffset = numerator-> offsetHeight();164 verticalOffset = numerator->pixelSnappedOffsetHeight(); 165 165 } 166 166 … … 174 174 info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB); 175 175 176 info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));176 info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y())); 177 177 } 178 178 … … 187 187 refStyle = nextSibling()->style(); 188 188 int shift = int(ceil((refStyle->fontMetrics().xHeight() + 1) / 2)); 189 return numerator-> offsetHeight() + shift;189 return numerator->pixelSnappedOffsetHeight() + shift; 190 190 } 191 191 return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
r107473 r110496 109 109 RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild()); 110 110 111 LayoutUnit maxHeight = indexBox->offsetHeight();111 int maxHeight = indexBox->pixelSnappedOffsetHeight(); 112 112 // default to the font size in pixels if we're empty 113 113 if (!maxHeight) 114 114 maxHeight = style()->fontSize(); 115 LayoutUnit width = indexBox->offsetWidth();116 117 LayoutUnit indexWidth = 0;115 int width = indexBox->pixelSnappedOffsetWidth(); 116 117 int indexWidth = 0; 118 118 RenderObject* current = firstChild(); 119 119 while (current != lastChild()) { 120 120 if (current->isBoxModelObject()) { 121 121 RenderBoxModelObject* box = toRenderBoxModelObject(current); 122 indexWidth += box-> offsetWidth();122 indexWidth += box->pixelSnappedOffsetWidth(); 123 123 } 124 124 current = current->nextSibling(); … … 140 140 141 141 int rootPad = static_cast<int>(gRootPadding * style()->fontSize()); 142 LayoutUnit start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;142 int start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad; 143 143 adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad); 144 144 … … 200 200 return; 201 201 202 LayoutUnit maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight();202 int maxHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight(); 203 203 204 204 RenderObject* current = lastChild()->firstChild(); … … 210 210 211 211 // Base height above which the shape of the root changes 212 LayoutUnit thresholdHeight = static_cast<LayoutUnit>(gThresholdBaseHeight * style()->fontSize());213 LayoutUnit topStartShift = 0;212 int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize()); 213 int topStartShift = 0; 214 214 215 215 if (maxHeight > thresholdHeight && thresholdHeight) { … … 217 217 if (shift > 1.) 218 218 shift = 1.0f; 219 LayoutUnit frontWidth = static_cast<LayoutUnit>(style()->fontSize() * gRadicalWidth);220 topStartShift = static_cast< LayoutUnit>(gRadicalBottomPointXPos * frontWidth * shift);219 int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth); 220 topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift); 221 221 222 style()->setPaddingBottom(Length(static_cast< LayoutUnit>(gRootBottomPadding * style()->fontSize()), Fixed));222 style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed)); 223 223 } 224 224 … … 231 231 return; 232 232 233 LayoutUnit indexShift = indexBox->offsetWidth() + topStartShift;234 LayoutUnit radicalHeight = static_cast<LayoutUnit>((1 - gRadicalTopLeftPointYPos) * maxHeight);235 LayoutUnit rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight()236 - (maxHeight + static_cast< LayoutUnit>(gRootPadding * style()->fontSize()));233 int indexShift = indexBox->pixelSnappedOffsetWidth() + topStartShift; 234 int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight); 235 int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight() 236 - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize())); 237 237 238 238 style()->setPaddingLeft(Length(indexShift, Fixed)); 239 239 if (rootMarginTop > 0) 240 style()->setPaddingTop(Length(rootMarginTop + static_cast< LayoutUnit>(gRootPadding * style()->fontSize()), Fixed));240 style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed)); 241 241 242 242 setNeedsLayout(true); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp
r108302 r110496 46 46 RenderBlock::layout(); 47 47 48 LayoutUnit maxHeight = 0;48 int maxHeight = 0; 49 49 50 50 // Calculate the non-operator max height of the row. … … 57 57 RenderBoxModelObject* box = toRenderBoxModelObject(current); 58 58 // Check to see if this box has a larger height. 59 if (box-> offsetHeight() > maxHeight)60 maxHeight = box-> offsetHeight();59 if (box->pixelSnappedOffsetHeight() > maxHeight) 60 maxHeight = box->pixelSnappedOffsetHeight(); 61 61 } 62 62 } -
trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp
r107296 r110496 76 76 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location()); 77 77 78 LayoutUnit maxHeight = 0;79 LayoutUnit width = 0;78 int maxHeight = 0; 79 int width = 0; 80 80 RenderObject* current = firstChild(); 81 81 while (current) { … … 85 85 86 86 // Check to see if this box has a larger height 87 if (box-> offsetHeight() > maxHeight)88 maxHeight = box-> offsetHeight();89 width += box-> offsetWidth();87 if (box->pixelSnappedOffsetHeight() > maxHeight) 88 maxHeight = box->pixelSnappedOffsetHeight(); 89 width += box->pixelSnappedOffsetWidth(); 90 90 } 91 91 current = current->nextSibling(); … … 161 161 void RenderMathMLSquareRoot::layout() 162 162 { 163 LayoutUnit maxHeight = 0;163 int maxHeight = 0; 164 164 165 165 RenderObject* current = firstChild(); … … 168 168 RenderBoxModelObject* box = toRenderBoxModelObject(current); 169 169 170 if (box-> offsetHeight() > maxHeight)171 maxHeight = box-> offsetHeight();170 if (box->pixelSnappedOffsetHeight() > maxHeight) 171 maxHeight = box->pixelSnappedOffsetHeight(); 172 172 173 173 box->style()->setVerticalAlign(BASELINE); … … 180 180 181 181 182 if (maxHeight > static_cast< LayoutUnit>(gThresholdBaseHeight * style()->fontSize()))183 style()->setPaddingBottom(Length(static_cast< LayoutUnit>(gRootBottomPadding * style()->fontSize()), Fixed));182 if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize())) 183 style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed)); 184 184 185 185 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
r108249 r110496 132 132 if (obj->isBoxModelObject()) { 133 133 RenderBoxModelObject* box = toRenderBoxModelObject(obj); 134 return box-> offsetHeight();134 return box->pixelSnappedOffsetHeight(); 135 135 } 136 136 … … 186 186 base = firstChild(); 187 187 if (base) { 188 LayoutUnit baseHeight = getOffsetHeight(base);188 int baseHeight = getOffsetHeight(base); 189 189 // actual base 190 190 base = base->firstChild(); … … 227 227 // adjust the placement of the under block. 228 228 229 LayoutUnit baseHeight = getOffsetHeight(base);229 int baseHeight = getOffsetHeight(base); 230 230 // actual base 231 231 base = base->firstChild();
Note: See TracChangeset
for help on using the changeset viewer.