Title: [108302] trunk/Source/WebCore
- Revision
- 108302
- Author
- [email protected]
- Date
- 2012-02-20 22:00:51 -0800 (Mon, 20 Feb 2012)
Log Message
MathML internals - code clean-up for RenderMathMLSubSup
https://bugs.webkit.org/show_bug.cgi?id=79063
Patch by David Barton <[email protected]> on 2012-02-20
Reviewed by Eric Seidel.
In the next patch, I will shrink and revise the <msubsup> formatting code. To make this
easier to follow, I am first doing some simple code clean-up.
No new tests.
* rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::layout):
* rendering/mathml/RenderMathMLRow.h:
(WebCore::RenderMathMLRow::isRenderMathMLRow):
* rendering/mathml/RenderMathMLSubSup.cpp:
(WebCore::RenderMathMLSubSup::stretchToHeight):
(WebCore::RenderMathMLSubSup::layout):
- There is no need to iterate over baseWrapper's children since it should have only
one child, the base of the <msubsup>.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (108301 => 108302)
--- trunk/Source/WebCore/ChangeLog 2012-02-21 05:52:43 UTC (rev 108301)
+++ trunk/Source/WebCore/ChangeLog 2012-02-21 06:00:51 UTC (rev 108302)
@@ -1,3 +1,25 @@
+2012-02-20 David Barton <[email protected]>
+
+ MathML internals - code clean-up for RenderMathMLSubSup
+ https://bugs.webkit.org/show_bug.cgi?id=79063
+
+ Reviewed by Eric Seidel.
+
+ In the next patch, I will shrink and revise the <msubsup> formatting code. To make this
+ easier to follow, I am first doing some simple code clean-up.
+
+ No new tests.
+
+ * rendering/mathml/RenderMathMLRow.cpp:
+ (WebCore::RenderMathMLRow::layout):
+ * rendering/mathml/RenderMathMLRow.h:
+ (WebCore::RenderMathMLRow::isRenderMathMLRow):
+ * rendering/mathml/RenderMathMLSubSup.cpp:
+ (WebCore::RenderMathMLSubSup::stretchToHeight):
+ (WebCore::RenderMathMLSubSup::layout):
+ - There is no need to iterate over baseWrapper's children since it should have only
+ one child, the base of the <msubsup>.
+
2012-02-20 Kentaro Hara <[email protected]>
Replace [V8Custom=DOMWindowNOP] with [V8Custom]
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp (108301 => 108302)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp 2012-02-21 05:52:43 UTC (rev 108301)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp 2012-02-21 06:00:51 UTC (rev 108302)
@@ -82,18 +82,7 @@
}
}
-
-LayoutUnit RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
-{
- if (firstChild() && firstChild()->isRenderMathMLBlock() && linePositionMode == PositionOnContainingLine) {
- RenderMathMLBlock* block = toRenderMathMLBlock(firstChild());
- if (block->isRenderMathMLOperator())
- return block->y() + block->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode);
- }
- return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode);
}
-
-}
#endif // ENABLE(MATHML)
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h (108301 => 108302)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h 2012-02-21 05:52:43 UTC (rev 108301)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h 2012-02-21 06:00:51 UTC (rev 108302)
@@ -36,7 +36,6 @@
public:
RenderMathMLRow(Element*);
virtual bool isRenderMathMLRow() const { return true; }
- virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
virtual void stretchToHeight(int) {}
protected:
virtual void layout();
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp (108301 => 108302)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp 2012-02-21 05:52:43 UTC (rev 108301)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp 2012-02-21 06:00:51 UTC (rev 108302)
@@ -125,63 +125,39 @@
void RenderMathMLSubSup::stretchToHeight(int height)
{
- RenderObject* baseWrapper = firstChild();
- if (!baseWrapper || !baseWrapper->firstChild())
- return;
-
- if (baseWrapper->firstChild() && baseWrapper->firstChild()->isRenderMathMLBlock()) {
- RenderMathMLBlock* block = toRenderMathMLBlock(baseWrapper->firstChild());
- block->stretchToHeight(static_cast<int>(gSubSupStretch * height));
+ RenderBoxModelObject* base = this->base();
+ if (base && base->isRenderMathMLBlock()) {
+ toRenderMathMLBlock(base)->stretchToHeight(static_cast<int>(gSubSupStretch * height));
// Adjust the script placement after we stretch
if (height > 0 && m_kind == SubSup && m_scripts) {
- RenderObject* script = m_scripts->firstChild();
- if (script) {
+ RenderObject* supWrapper = m_scripts->firstChild();
+ if (supWrapper) {
// Calculate the script height without the container margins.
- RenderObject* top = script;
- int topHeight = getBoxModelObjectHeight(top->firstChild());
- int topAdjust = topHeight / gTopAdjustDivisor;
- top->style()->setMarginTop(Length(-topAdjust, Fixed));
- top->style()->setMarginBottom(Length(height - topHeight + topAdjust, Fixed));
- if (top->isBoxModelObject()) {
- RenderBoxModelObject* topBox = toRenderBoxModelObject(top);
- topBox->updateBoxModelInfoFromStyle();
- }
- m_scripts->setNeedsLayout(true);
- setNeedsLayout(true);
+ int supHeight = getBoxModelObjectHeight(supWrapper->firstChild());
+ int supTopAdjust = supHeight / gTopAdjustDivisor;
+ supWrapper->style()->setMarginTop(Length(-supTopAdjust, Fixed));
+ supWrapper->style()->setMarginBottom(Length(height - supHeight + supTopAdjust, Fixed));
+ supWrapper->setNeedsLayout(true);
}
}
-
}
}
-void RenderMathMLSubSup::layout()
+void RenderMathMLSubSup::layout()
{
- if (firstChild())
- firstChild()->setNeedsLayout(true);
- if (m_scripts)
- m_scripts->setNeedsLayout(true);
-
RenderBlock::layout();
- if (m_kind == SubSup) {
- if (RenderObject* baseWrapper = firstChild()) {
- LayoutUnit maxHeight = 0;
- RenderObject* current = baseWrapper->firstChild();
- while (current) {
- LayoutUnit height = getBoxModelObjectHeight(current);
- if (height > maxHeight)
- maxHeight = height;
- current = current->nextSibling();
- }
- LayoutUnit heightDiff = m_scripts ? (m_scripts->offsetHeight() - maxHeight) / 2 : zeroLayoutUnit;
+ if (m_kind == SubSup && m_scripts) {
+ if (RenderBoxModelObject* base = this->base()) {
+ LayoutUnit heightDiff = (m_scripts->offsetHeight() - base->offsetHeight()) / 2;
if (heightDiff < 0)
heightDiff = 0;
+ RenderObject* baseWrapper = firstChild();
baseWrapper->style()->setPaddingTop(Length(heightDiff, Fixed));
baseWrapper->setNeedsLayout(true);
+ RenderBlock::layout();
}
- setNeedsLayout(true);
- RenderBlock::layout();
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes