Source/WebCore/ChangeLog

 12012-03-21 David Barton <dbarton@mathscribe.com>
 2
 3 MathML internals - improve naming in RenderMathMLSquareRoot.cpp and RenderMathMLRoot.cpp
 4 https://bugs.webkit.org/show_bug.cgi?id=81850
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This prepares these files for bug fixes, and eventually combining their common code. To
 9 understand this patch, I suggest you start with RenderMathMLSquareRoot.cpp, as it's
 10 simpler than RenderMathMLRoot.cpp.
 11
 12 No new tests. LayoutTests/mathml/presentation/roots.xhtml is thorough enough for this.
 13
 14 * rendering/mathml/RenderMathMLRoot.cpp:
 15 (WebCore):
 16 (WebCore::RenderMathMLRoot::addChild):
 17 (WebCore::RenderMathMLRoot::paint):
 18 (WebCore::RenderMathMLRoot::layout):
 19 * rendering/mathml/RenderMathMLRoot.h:
 20 (WebCore):
 21 (RenderMathMLRoot):
 22 * rendering/mathml/RenderMathMLSquareRoot.cpp:
 23 (WebCore):
 24 (WebCore::RenderMathMLSquareRoot::paint):
 25 (WebCore::RenderMathMLSquareRoot::layout):
 26 * rendering/mathml/RenderMathMLSquareRoot.h:
 27 (WebCore):
 28 (RenderMathMLSquareRoot):
 29 * rendering/mathml/RenderMathMLSubSup.h:
 30 (WebCore):
 31
1322012-03-21 Patrick Gansterer <paroga@webkit.org>
233
334 Build fix for !ENABLE(INSPECTOR) after r104831.
111625

Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp

@@namespace WebCore {
3838
3939using namespace MathMLNames;
4040
41 // Left margin of the radical (px)
42 const int gRadicalLeftMargin = 3;
43 // Bottom padding of the radical (px)
44 const int gRadicalBasePad = 3;
45 // Threshold above which the radical shape is modified to look nice with big bases (%)
46 const float gThresholdBaseHeight = 1.5f;
47 // Radical width (%)
48 const float gRadicalWidth = 0.75f;
49 // Horizontal position of the bottom point of the radical (%)
50 const float gRadicalBottomPointXPos= 0.5f;
51 // Horizontal position of the top left point of the radical (%)
52 const float gRadicalTopLeftPointXPos = 0.8f;
53 // Vertical position of the top left point of the radical (%)
54 const float gRadicalTopLeftPointYPos = 0.625f;
55 // Vertical shift of the left end point of the radical (%)
56 const float gRadicalLeftEndYShift = 0.05f;
57 // Root padding around the base (%)
58 const float gRootPadding = 0.2f;
59 // Additional bottom root padding (%)
60 const float gRootBottomPadding = 0.2f;
61 
62 // Radical line thickness (%)
63 const float gRadicalLineThickness = 0.02f;
64 // Radical thick line thickness (%)
65 const float gRadicalThickLineThickness = 0.1f;
 41// Extra space on the left for the radical sign (px)
 42const int gRadicalLeftExtra = 3;
 43// Lower the radical sign's bottom point (px)
 44const int gRadicalBottomPointLower = 3;
 45// Threshold above which the radical shape is modified to look nice with big bases (em)
 46const float gThresholdBaseHeightEms = 1.5f;
 47// Front width (em)
 48const float gFrontWidthEms = 0.75f;
 49// Horizontal position of the bottom point of the radical (* frontWidth)
 50const float gRadicalBottomPointXFront = 0.5f;
 51// Horizontal position of the top left point of the radical "dip" (* frontWidth)
 52const float gRadicalDipLeftPointXFront = 0.8f;
 53// Vertical position of the top left point of the radical "dip" (* baseHeight)
 54const float gRadicalDipLeftPointYPos = 0.625f;
 55// Vertical shift of the left end point of the radical (em)
 56const float gRadicalLeftEndYShiftEms = 0.05f;
 57// Root padding around the base (em) (mroot padding-top/left from mathml.css)
 58const float gRootPaddingEms = 0.2f;
 59// Additional bottom root padding if baseHeight > threshold (em)
 60const float gBigRootBottomPaddingEms = 0.2f;
 61
 62// Radical line thickness (em)
 63const float gRadicalLineThicknessEms = 0.02f;
 64// Radical thick line thickness (em)
 65const float gRadicalThickLineThicknessEms = 0.1f;
6666
6767RenderMathMLRoot::RenderMathMLRoot(Element* element)
6868 : RenderMathMLBlock(element)

@@void RenderMathMLRoot::addChild(RenderOb
7979 // FIXME: the wrapping does not seem to be needed anymore.
8080 // this is the base, so wrap it so we can pad it
8181 RenderBlock* baseWrapper = createAlmostAnonymousBlock(INLINE_BLOCK);
82  baseWrapper->style()->setPaddingLeft(Length(5 * gRadicalWidth, Percent));
 82 baseWrapper->style()->setPaddingLeft(Length(5 * gFrontWidthEms, Percent));
8383 RenderBlock::addChild(baseWrapper);
8484 baseWrapper->addChild(child);
8585 } else {

@@void RenderMathMLRoot::paint(PaintInfo&
9494
9595 if (info.context->paintingDisabled())
9696 return;
97 
 97
9898 if (!firstChild() || !lastChild())
9999 return;
100 
 100
101101 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
102102
103  RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild());
 103 RenderBoxModelObject* baseWrapper = toRenderBoxModelObject(lastChild());
104104
105  int maxHeight = indexBox->pixelSnappedOffsetHeight();
 105 int baseHeight = baseWrapper->pixelSnappedOffsetHeight();
106106 // default to the font size in pixels if we're empty
107  if (!maxHeight)
108  maxHeight = style()->fontSize();
109  int width = indexBox->pixelSnappedOffsetWidth();
 107 if (!baseHeight)
 108 baseHeight = style()->fontSize();
 109 int overbarWidth = baseWrapper->pixelSnappedOffsetWidth();
110110
111111 int indexWidth = 0;
112112 RenderObject* current = firstChild();

@@void RenderMathMLRoot::paint(PaintInfo&
118118 current = current->nextSibling();
119119 }
120120
121  int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
122  int topStartShift = 0;
 121 int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
 122 int overbarLeftPointShift = 0;
123123 // Base height above which the shape of the root changes
124  int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
 124 int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
125125
126  if (maxHeight > thresholdHeight && thresholdHeight) {
127  float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
 126 if (baseHeight > thresholdHeight && thresholdHeight) {
 127 float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
128128 if (shift > 1.)
129129 shift = 1.0f;
130  topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
 130 overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
131131 }
132132
133  width += topStartShift;
 133 overbarWidth += overbarLeftPointShift;
134134
135  int rootPad = static_cast<int>(gRootPadding * style()->fontSize());
136  int start = adjustedPaintOffset.x() + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad;
 135 int rootPad = static_cast<int>(gRootPaddingEms * style()->fontSize());
 136 int startX = adjustedPaintOffset.x() + indexWidth + gRadicalLeftExtra + style()->paddingLeft().value() - rootPad;
137137 adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad);
138138
139  FloatPoint topStart(start - topStartShift, adjustedPaintOffset.y());
140  FloatPoint bottomLeft(start - gRadicalBottomPointXPos * frontWidth , adjustedPaintOffset.y() + maxHeight + gRadicalBasePad);
141  FloatPoint topLeft(start - gRadicalTopLeftPointXPos * frontWidth , adjustedPaintOffset.y() + gRadicalTopLeftPointYPos * maxHeight);
142  FloatPoint leftEnd(start - frontWidth , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize());
 139 FloatPoint overbarLeftPoint(startX - overbarLeftPointShift, adjustedPaintOffset.y());
 140 FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
 141 FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
 142 FloatPoint leftEnd(startX - frontWidth, dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
143143
144144 GraphicsContextStateSaver stateSaver(*info.context);
145145
146  info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize());
 146 info.context->setStrokeThickness(gRadicalLineThicknessEms * style()->fontSize());
147147 info.context->setStrokeStyle(SolidStroke);
148148 info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB);
149149 info.context->setLineJoin(MiterJoin);

@@void RenderMathMLRoot::paint(PaintInfo&
151151
152152 Path root;
153153
154  root.moveTo(FloatPoint(topStart.x() + width, adjustedPaintOffset.y()));
 154 root.moveTo(FloatPoint(overbarLeftPoint.x() + overbarWidth, adjustedPaintOffset.y()));
155155 // draw top
156  root.addLineTo(topStart);
 156 root.addLineTo(overbarLeftPoint);
157157 // draw from top left corner to bottom point of radical
158  root.addLineTo(bottomLeft);
159  // draw from bottom point to top of left part of radical base "pocket"
160  root.addLineTo(topLeft);
 158 root.addLineTo(bottomPoint);
 159 // draw from bottom point to top of left part of radical base "dip"
 160 root.addLineTo(dipLeftPoint);
161161 // draw to end
162162 root.addLineTo(leftEnd);
163163

@@void RenderMathMLRoot::paint(PaintInfo&
168168 // Build a mask to draw the thick part of the root.
169169 Path mask;
170170
171  mask.moveTo(topStart);
172  mask.addLineTo(bottomLeft);
173  mask.addLineTo(topLeft);
174  mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
 171 mask.moveTo(overbarLeftPoint);
 172 mask.addLineTo(bottomPoint);
 173 mask.addLineTo(dipLeftPoint);
 174 mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
175175
176176 info.context->clip(mask);
177177
178178 // Draw the thick part of the root.
179  info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize());
 179 info.context->setStrokeThickness(gRadicalThickLineThicknessEms * style()->fontSize());
180180 info.context->setLineCap(SquareCap);
181181
182182 Path line;
183  line.moveTo(bottomLeft);
184  line.addLineTo(topLeft);
185 
 183 line.moveTo(bottomPoint);
 184 line.addLineTo(dipLeftPoint);
 185
186186 info.context->strokePath(line);
187187}
188188

@@void RenderMathMLRoot::layout()
193193 if (!firstChild() || !lastChild())
194194 return;
195195
196  int maxHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
197 
198  RenderObject* current = lastChild()->firstChild();
199  if (current)
200  current->style()->setVerticalAlign(BASELINE);
201 
202  if (!maxHeight)
203  maxHeight = style()->fontSize();
 196 int baseHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
 197 if (!baseHeight)
 198 baseHeight = style()->fontSize();
 199
 200 RenderObject* base = lastChild()->firstChild();
 201 if (base)
 202 base->style()->setVerticalAlign(BASELINE); // FIXME: Can this style be modified?
204203
205204 // Base height above which the shape of the root changes
206  int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
207  int topStartShift = 0;
 205 int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
 206 int overbarLeftPointShift = 0;
208207
209  if (maxHeight > thresholdHeight && thresholdHeight) {
210  float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
 208 // FIXME: Can style() and indexBox->style() be modified (4 times below)?
 209 if (baseHeight > thresholdHeight && thresholdHeight) {
 210 float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
211211 if (shift > 1.)
212212 shift = 1.0f;
213  int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
214  topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
 213 int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
 214 overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
215215
216  style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
 216 style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
217217 }
218218
219219 // Positioning of the index

@@void RenderMathMLRoot::layout()
224224 if (!indexBox)
225225 return;
226226
227  int indexShift = indexBox->pixelSnappedOffsetWidth() + topStartShift;
228  int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight);
229  int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
230  - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize()));
231 
232  style()->setPaddingLeft(Length(indexShift, Fixed));
233  if (rootMarginTop > 0)
234  style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
 227 int shiftForIndex = indexBox->pixelSnappedOffsetWidth() + overbarLeftPointShift;
 228 int partDipHeight = static_cast<int>((1 - gRadicalDipLeftPointYPos) * baseHeight);
 229 int rootExtraTop = partDipHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
 230 - (baseHeight + static_cast<int>(gRootPaddingEms * style()->fontSize()));
 231
 232 style()->setPaddingLeft(Length(shiftForIndex, Fixed));
 233 if (rootExtraTop > 0)
 234 style()->setPaddingTop(Length(rootExtraTop + static_cast<int>(gRootPaddingEms * style()->fontSize()), Fixed));
235235
236236 setNeedsLayout(true);
237  setPreferredLogicalWidthsDirty(true, false);
 237 setPreferredLogicalWidthsDirty(true, false); // FIXME: Can this really be right?
238238 RenderBlock::layout();
239239
240  indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed));
 240 indexBox->style()->setBottom(Length(partDipHeight + style()->paddingBottom().value(), Fixed));
241241
242242 // Now that we've potentially changed its position, we need layout the index again.
243243 indexBox->setNeedsLayout(true);
111083

Source/WebCore/rendering/mathml/RenderMathMLRoot.h

3232
3333namespace WebCore {
3434
 35// Render base^(1/index), using radical notation.
3536class RenderMathMLRoot : public RenderMathMLBlock {
3637public:
3738 RenderMathMLRoot(Element*);
3839 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
 40
3941 virtual void paint(PaintInfo&, const LayoutPoint&);
 42
4043protected:
4144 virtual void layout();
4245
111083

Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp

3333#include "GraphicsContext.h"
3434#include "MathMLNames.h"
3535#include "PaintInfo.h"
36 #include "Path.h"
3736
3837namespace WebCore {
3938
4039using namespace MathMLNames;
4140
42 // Bottom padding of the radical (px)
43 const int gRadicalBasePad = 3;
44 // Threshold above which the radical shape is modified to look nice with big bases (%)
45 const float gThresholdBaseHeight = 1.5f;
46 // Radical width (%)
47 const float gRadicalWidth = 0.75f;
48 // Horizontal position of the bottom point of the radical (%)
49 const float gRadicalBottomPointXPos= 0.5f;
50 // Horizontal position of the top left point of the radical (%)
51 const float gRadicalTopLeftPointXPos = 0.2f;
52 // Vertical position of the top left point of the radical (%)
53 const float gRadicalTopLeftPointYPos = 0.5f;
54 // Vertical shift of the left end point of the radical (%)
55 const float gRadicalLeftEndYShift = 0.05f;
56 // Additional bottom root padding (%)
57 const float gRootBottomPadding = 0.2f;
58 
59 // Radical line thickness (%)
60 const float gRadicalLineThickness = 0.02f;
61 // Radical thick line thickness (%)
62 const float gRadicalThickLineThickness = 0.1f;
 41// Lower the radical sign's bottom point (px)
 42const int gRadicalBottomPointLower = 3;
 43// Threshold above which the radical shape is modified to look nice with big bases (em)
 44const float gThresholdBaseHeightEms = 1.5f;
 45// Front width (em)
 46const float gFrontWidthEms = 0.75f;
 47// Horizontal position of the bottom point of the radical (* frontWidth)
 48const float gRadicalBottomPointXFront = 0.5f;
 49// Horizontal position of the top left point of the radical "dip" (* frontWidth)
 50const float gRadicalDipLeftPointXFront = 0.2f;
 51// Vertical position of the top left point of the radical "dip" (* baseHeight)
 52const float gRadicalDipLeftPointYPos = 0.5f;
 53// Vertical shift of the left end point of the radical (em)
 54const float gRadicalLeftEndYShiftEms = 0.05f;
 55// Additional bottom root padding if baseHeight > threshold (em)
 56const float gBigRootBottomPaddingEms = 0.2f;
 57
 58// Radical line thickness (em)
 59const float gRadicalLineThicknessEms = 0.02f;
 60// Radical thick line thickness (em)
 61const float gRadicalThickLineThicknessEms = 0.1f;
6362
6463RenderMathMLSquareRoot::RenderMathMLSquareRoot(Element* element)
6564 : RenderMathMLBlock(element)

@@RenderMathMLSquareRoot::RenderMathMLSqua
6968void RenderMathMLSquareRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
7069{
7170 RenderMathMLBlock::paint(info, paintOffset);
72 
 71
7372 if (info.context->paintingDisabled())
7473 return;
7574
7675 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
77 
78  int maxHeight = 0;
79  int width = 0;
 76
 77 int baseHeight = 0;
 78 int overbarWidth = 0;
8079 RenderObject* current = firstChild();
8180 while (current) {
8281 if (current->isBoxModelObject()) {
83 
8482 RenderBoxModelObject* box = toRenderBoxModelObject(current);
8583
8684 // Check to see if this box has a larger height
87  if (box->pixelSnappedOffsetHeight() > maxHeight)
88  maxHeight = box->pixelSnappedOffsetHeight();
89  width += box->pixelSnappedOffsetWidth();
 85 // FIXME: We should consider the height above & below the baseline separately. This will be
 86 // fixed by an <mrow> base wrapper, which is required anyway by the MathML spec.
 87 if (box->pixelSnappedOffsetHeight() > baseHeight)
 88 baseHeight = box->pixelSnappedOffsetHeight();
 89 overbarWidth += box->pixelSnappedOffsetWidth();
9090 }
9191 current = current->nextSibling();
9292 }
9393 // default to the font size in pixels if we're empty
94  if (!maxHeight)
95  maxHeight = style()->fontSize();
 94 if (!baseHeight)
 95 baseHeight = style()->fontSize();
9696
97  int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
98  int topStartShift = 0;
 97 int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
 98 int overbarLeftPointShift = 0;
9999 // Base height above which the shape of the root changes
100  int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
 100 int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
101101
102  if (maxHeight > thresholdHeight && thresholdHeight) {
103  float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
 102 if (baseHeight > thresholdHeight && thresholdHeight) {
 103 float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
104104 if (shift > 1.)
105105 shift = 1.0f;
106  topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
 106 overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
107107 }
108108
109  width += topStartShift;
 109 overbarWidth += overbarLeftPointShift;
110110
111  FloatPoint topStart(adjustedPaintOffset.x() + frontWidth - topStartShift, adjustedPaintOffset.y());
112  FloatPoint bottomLeft(adjustedPaintOffset.x() + frontWidth * gRadicalBottomPointXPos , adjustedPaintOffset.y() + maxHeight + gRadicalBasePad);
113  FloatPoint topLeft(adjustedPaintOffset.x() + frontWidth * gRadicalTopLeftPointXPos , adjustedPaintOffset.y() + gRadicalTopLeftPointYPos * maxHeight);
114  FloatPoint leftEnd(adjustedPaintOffset.x() , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize());
 111 FloatPoint overbarLeftPoint(adjustedPaintOffset.x() + frontWidth - overbarLeftPointShift, adjustedPaintOffset.y());
 112 FloatPoint bottomPoint(adjustedPaintOffset.x() + frontWidth * gRadicalBottomPointXFront, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
 113 FloatPoint dipLeftPoint(adjustedPaintOffset.x() + frontWidth * gRadicalDipLeftPointXFront, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
 114 FloatPoint leftEnd(adjustedPaintOffset.x(), dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
115115
116116 GraphicsContextStateSaver stateSaver(*info.context);
117117
118  info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize());
 118 info.context->setStrokeThickness(gRadicalLineThicknessEms * style()->fontSize());
119119 info.context->setStrokeStyle(SolidStroke);
120120 info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB);
121121 info.context->setLineJoin(MiterJoin);

@@void RenderMathMLSquareRoot::paint(Paint
123123
124124 Path root;
125125
126  root.moveTo(FloatPoint(topStart.x() + width , adjustedPaintOffset.y()));
 126 root.moveTo(FloatPoint(overbarLeftPoint.x() + overbarWidth, adjustedPaintOffset.y()));
127127 // draw top
128  root.addLineTo(topStart);
 128 root.addLineTo(overbarLeftPoint);
129129 // draw from top left corner to bottom point of radical
130  root.addLineTo(bottomLeft);
131  // draw from bottom point to top of left part of radical base "pocket"
132  root.addLineTo(topLeft);
 130 root.addLineTo(bottomPoint);
 131 // draw from bottom point to top of left part of radical base "dip"
 132 root.addLineTo(dipLeftPoint);
133133 // draw to end
134134 root.addLineTo(leftEnd);
135 
 135
136136 info.context->strokePath(root);
137137
138138 GraphicsContextStateSaver maskStateSaver(*info.context);

@@void RenderMathMLSquareRoot::paint(Paint
140140 // Build a mask to draw the thick part of the root.
141141 Path mask;
142142
143  mask.moveTo(topStart);
144  mask.addLineTo(bottomLeft);
145  mask.addLineTo(topLeft);
146  mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
 143 mask.moveTo(overbarLeftPoint);
 144 mask.addLineTo(bottomPoint);
 145 mask.addLineTo(dipLeftPoint);
 146 mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
147147
148148 info.context->clip(mask);
149149
150150 // Draw the thick part of the root.
151  info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize());
 151 info.context->setStrokeThickness(gRadicalThickLineThicknessEms * style()->fontSize());
152152 info.context->setLineCap(SquareCap);
153153
154154 Path line;
155  line.moveTo(bottomLeft);
156  line.addLineTo(topLeft);
 155 line.moveTo(bottomPoint);
 156 line.addLineTo(dipLeftPoint);
157157
158158 info.context->strokePath(line);
159159}
160160
161161void RenderMathMLSquareRoot::layout()
162162{
163  int maxHeight = 0;
 163 int baseHeight = 0;
164164
165165 RenderObject* current = firstChild();
166166 while (current) {
167167 if (current->isBoxModelObject()) {
168168 RenderBoxModelObject* box = toRenderBoxModelObject(current);
169169
170  if (box->pixelSnappedOffsetHeight() > maxHeight)
171  maxHeight = box->pixelSnappedOffsetHeight();
 170 if (box->pixelSnappedOffsetHeight() > baseHeight)
 171 baseHeight = box->pixelSnappedOffsetHeight();
172172
 173 // FIXME: Can box->style() be modified?
173174 box->style()->setVerticalAlign(BASELINE);
174175 }
175176 current = current->nextSibling();
176177 }
177178
178  if (!maxHeight)
179  maxHeight = style()->fontSize();
180 
 179 if (!baseHeight)
 180 baseHeight = style()->fontSize();
181181
182  if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize()))
183  style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
184 
 182 // FIXME: Can style() be modified? And don't we need styleDidChange()?
 183 if (baseHeight > static_cast<int>(gThresholdBaseHeightEms * style()->fontSize()))
 184 style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
185185
186186 RenderBlock::layout();
187187}
111083

Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h

3232
3333namespace WebCore {
3434
 35// Render sqrt(base), using radical notation.
3536class RenderMathMLSquareRoot : public RenderMathMLBlock {
3637public:
3738 RenderMathMLSquareRoot(Element*);
 39
3840 virtual void paint(PaintInfo&, const LayoutPoint&);
 41
3942protected:
4043 virtual void layout();
4144
111083

Source/WebCore/rendering/mathml/RenderMathMLSubSup.h

3232
3333namespace WebCore {
3434
 35// Render a base with a subscript and/or a superscript.
3536class RenderMathMLSubSup : public RenderMathMLBlock {
3637public:
3738 RenderMathMLSubSup(Element*);
111083