diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/mathml | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/mathml')
-rw-r--r-- | WebCore/mathml/MathMLElement.cpp | 11 | ||||
-rw-r--r-- | WebCore/mathml/MathMLElement.h | 13 | ||||
-rw-r--r-- | WebCore/mathml/MathMLInlineContainerElement.cpp | 14 | ||||
-rw-r--r-- | WebCore/mathml/MathMLInlineContainerElement.h | 5 | ||||
-rw-r--r-- | WebCore/mathml/MathMLMathElement.cpp | 17 | ||||
-rw-r--r-- | WebCore/mathml/MathMLMathElement.h | 10 | ||||
-rw-r--r-- | WebCore/mathml/MathMLTextElement.cpp | 9 | ||||
-rw-r--r-- | WebCore/mathml/MathMLTextElement.h | 8 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLBlock.cpp | 6 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLFraction.cpp | 24 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLFraction.h | 1 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLOperator.cpp | 36 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLOperator.h | 1 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLRoot.cpp | 14 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLRow.cpp | 21 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLRow.h | 1 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLSquareRoot.cpp | 5 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLSubSup.cpp | 42 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLUnderOver.cpp | 10 |
19 files changed, 146 insertions, 102 deletions
diff --git a/WebCore/mathml/MathMLElement.cpp b/WebCore/mathml/MathMLElement.cpp index b84616f..b93ff9f 100644 --- a/WebCore/mathml/MathMLElement.cpp +++ b/WebCore/mathml/MathMLElement.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,20 +38,14 @@ namespace WebCore { using namespace MathMLNames; MathMLElement::MathMLElement(const QualifiedName& tagName, Document* document) - : StyledElement(tagName, document, CreateStyledElementZeroRefCount) + : StyledElement(tagName, document, CreateStyledElement) { } PassRefPtr<MathMLElement> MathMLElement::create(const QualifiedName& tagName, Document* document) { - return new MathMLElement(tagName, document); + return adoptRef(new MathMLElement(tagName, document)); } - -RenderObject* MathMLElement::createRenderer(RenderArena*, RenderStyle* style) -{ - return RenderObject::createObject(this, style); -} - } diff --git a/WebCore/mathml/MathMLElement.h b/WebCore/mathml/MathMLElement.h index 2fa322f..46cd7fd 100644 --- a/WebCore/mathml/MathMLElement.h +++ b/WebCore/mathml/MathMLElement.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,18 +31,16 @@ #include "StyledElement.h" namespace WebCore { - + class MathMLElement : public StyledElement { public: static PassRefPtr<MathMLElement> create(const QualifiedName& tagName, Document*); - - virtual bool isMathMLElement() const { return true; } - - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - + protected: MathMLElement(const QualifiedName& tagName, Document*); - + +private: + virtual bool isMathMLElement() const { return true; } }; } diff --git a/WebCore/mathml/MathMLInlineContainerElement.cpp b/WebCore/mathml/MathMLInlineContainerElement.cpp index c5fcac9..efc9f8c 100644 --- a/WebCore/mathml/MathMLInlineContainerElement.cpp +++ b/WebCore/mathml/MathMLInlineContainerElement.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,7 +33,6 @@ #include "MathMLNames.h" #include "RenderMathMLBlock.h" #include "RenderMathMLFraction.h" -#include "RenderMathMLMath.h" #include "RenderMathMLRoot.h" #include "RenderMathMLRow.h" #include "RenderMathMLSquareRoot.h" @@ -50,16 +50,14 @@ MathMLInlineContainerElement::MathMLInlineContainerElement(const QualifiedName& PassRefPtr<MathMLInlineContainerElement> MathMLInlineContainerElement::create(const QualifiedName& tagName, Document* document) { - return new MathMLInlineContainerElement(tagName, document); + return adoptRef(new MathMLInlineContainerElement(tagName, document)); } -RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena *arena, RenderStyle* style) +RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena* arena, RenderStyle* style) { - RenderObject* object = 0; + RenderObject* object; if (hasLocalName(MathMLNames::mrowTag)) object = new (arena) RenderMathMLRow(this); - else if (hasLocalName(MathMLNames::mathTag)) - object = new (arena) RenderMathMLMath(this); else if (hasLocalName(MathMLNames::msubTag)) object = new (arena) RenderMathMLSubSup(this); else if (hasLocalName(MathMLNames::msupTag)) @@ -83,9 +81,7 @@ RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena *arena, R object->setStyle(style); return object; } - - + } #endif // ENABLE(MATHML) - diff --git a/WebCore/mathml/MathMLInlineContainerElement.h b/WebCore/mathml/MathMLInlineContainerElement.h index dc78dc4..4e80e36 100644 --- a/WebCore/mathml/MathMLInlineContainerElement.h +++ b/WebCore/mathml/MathMLInlineContainerElement.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,11 +36,11 @@ class MathMLInlineContainerElement : public MathMLElement { public: static PassRefPtr<MathMLInlineContainerElement> create(const QualifiedName& tagName, Document*); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - protected: MathMLInlineContainerElement(const QualifiedName& tagName, Document*); +private: + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); }; } diff --git a/WebCore/mathml/MathMLMathElement.cpp b/WebCore/mathml/MathMLMathElement.cpp index bd3b797..1b6b18d 100644 --- a/WebCore/mathml/MathMLMathElement.cpp +++ b/WebCore/mathml/MathMLMathElement.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,21 +30,25 @@ #include "MathMLMathElement.h" -#include "MathMLNames.h" -#include "RenderObject.h" +#include "RenderMathMLMath.h" namespace WebCore { - -using namespace MathMLNames; -MathMLMathElement::MathMLMathElement(const QualifiedName& tagName, Document* document) +inline MathMLMathElement::MathMLMathElement(const QualifiedName& tagName, Document* document) : MathMLInlineContainerElement(tagName, document) { } PassRefPtr<MathMLMathElement> MathMLMathElement::create(const QualifiedName& tagName, Document* document) { - return new MathMLMathElement(tagName, document); + return adoptRef(new MathMLMathElement(tagName, document)); +} + +RenderObject* MathMLMathElement::createRenderer(RenderArena* arena, RenderStyle* style) +{ + RenderMathMLMath* renderer = new (arena) RenderMathMLMath(this); + renderer->setStyle(style); + return renderer; } } diff --git a/WebCore/mathml/MathMLMathElement.h b/WebCore/mathml/MathMLMathElement.h index e784524..d31d548 100644 --- a/WebCore/mathml/MathMLMathElement.h +++ b/WebCore/mathml/MathMLMathElement.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,14 +31,15 @@ #include "MathMLInlineContainerElement.h" namespace WebCore { - + class MathMLMathElement : public MathMLInlineContainerElement { public: static PassRefPtr<MathMLMathElement> create(const QualifiedName& tagName, Document*); - -protected: + +private: MathMLMathElement(const QualifiedName& tagName, Document*); - + + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); }; } diff --git a/WebCore/mathml/MathMLTextElement.cpp b/WebCore/mathml/MathMLTextElement.cpp index 6f6bcbc..4135d6c 100644 --- a/WebCore/mathml/MathMLTextElement.cpp +++ b/WebCore/mathml/MathMLTextElement.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,14 +37,14 @@ namespace WebCore { using namespace MathMLNames; -MathMLTextElement::MathMLTextElement(const QualifiedName& tagName, Document* document) +inline MathMLTextElement::MathMLTextElement(const QualifiedName& tagName, Document* document) : MathMLElement(tagName, document) { } PassRefPtr<MathMLTextElement> MathMLTextElement::create(const QualifiedName& tagName, Document* document) { - return new MathMLTextElement(tagName, document); + return adoptRef(new MathMLTextElement(tagName, document)); } RenderObject* MathMLTextElement::createRenderer(RenderArena* arena, RenderStyle* style) @@ -54,11 +55,9 @@ RenderObject* MathMLTextElement::createRenderer(RenderArena* arena, RenderStyle* return object; } - return RenderObject::createObject(this, style); + return MathMLElement::createRenderer(arena, style); } - } #endif // ENABLE(MATHML) - diff --git a/WebCore/mathml/MathMLTextElement.h b/WebCore/mathml/MathMLTextElement.h index e647bfa..3af93d5 100644 --- a/WebCore/mathml/MathMLTextElement.h +++ b/WebCore/mathml/MathMLTextElement.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,11 +36,10 @@ class MathMLTextElement : public MathMLElement { public: static PassRefPtr<MathMLTextElement> create(const QualifiedName& tagName, Document*); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - -protected: +private: MathMLTextElement(const QualifiedName& tagName, Document*); - + + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); }; } diff --git a/WebCore/mathml/RenderMathMLBlock.cpp b/WebCore/mathml/RenderMathMLBlock.cpp index a897ff5..ef94893 100644 --- a/WebCore/mathml/RenderMathMLBlock.cpp +++ b/WebCore/mathml/RenderMathMLBlock.cpp @@ -96,6 +96,12 @@ void RenderMathMLBlock::paint(PaintInfo& info, int tx, int ty) info.context->drawLine(IntPoint(tx, ty + offsetHeight()), IntPoint(tx + offsetWidth(), ty + offsetHeight())); info.context->drawLine(IntPoint(tx, ty), IntPoint(tx, ty + offsetHeight())); + int topStart = paddingTop(); + + info.context->setStrokeColor(Color(0, 255, 0), sRGBColorSpace); + + info.context->drawLine(IntPoint(tx, ty + topStart), IntPoint(tx + offsetWidth(), ty + topStart)); + int baseline = baselinePosition(true); info.context->setStrokeColor(Color(255, 0, 0), sRGBColorSpace); diff --git a/WebCore/mathml/RenderMathMLFraction.cpp b/WebCore/mathml/RenderMathMLFraction.cpp index 3399e55..811c230 100644 --- a/WebCore/mathml/RenderMathMLFraction.cpp +++ b/WebCore/mathml/RenderMathMLFraction.cpp @@ -127,14 +127,6 @@ void RenderMathMLFraction::layout() if (lastChild() && lastChild()->isRenderBlock()) m_lineThickness = m_lineThickness * ceil(gFractionBarWidth * style()->fontSize()); - if (previousSibling() && previousSibling()->isRenderBlock()) { - RenderBlock* sibling = toRenderBlock(previousSibling()); - verticalAlignCompute(sibling); - } else if (nextSibling() && nextSibling()->isRenderBlock()) { - RenderBlock* sibling = toRenderBlock(nextSibling()); - verticalAlignCompute(sibling); - } - RenderBlock::layout(); // The row layout can affect the numerator/denominator width. @@ -183,21 +175,15 @@ void RenderMathMLFraction::paint(PaintInfo& info, int tx, int ty) info.context->restore(); } -void RenderMathMLFraction::verticalAlignCompute(RenderBlock* sibling) -{ - if (sibling->isRenderMathMLBlock()) { - RenderMathMLBlock* op = toRenderMathMLBlock(sibling); - style()->setVerticalAlign(LENGTH); - int verticalShift = static_cast<int>(ceil(gFractionAlignment * op->offsetHeight() + 0.5 * lastChild()->style()->borderTopWidth())); - style()->setVerticalAlignLength(Length(verticalShift, Fixed)); - } -} - int RenderMathMLFraction::baselinePosition(bool firstLine, bool isRootLineBox) const { if (firstChild()->isRenderMathMLBlock()) { RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild()); - return numerator->offsetHeight(); + // FIXME: the baseline should adjust so the fraction line aligns + // relative certain operators (e.g. aligns with the horizontal + // stroke of the plus). 1/3 of the current font size is just + // a good guess. + return numerator->offsetHeight() + style()->fontSize() / 3; } return RenderBlock::baselinePosition(firstLine, isRootLineBox); } diff --git a/WebCore/mathml/RenderMathMLFraction.h b/WebCore/mathml/RenderMathMLFraction.h index 30162ac..c8c1cb8 100644 --- a/WebCore/mathml/RenderMathMLFraction.h +++ b/WebCore/mathml/RenderMathMLFraction.h @@ -43,7 +43,6 @@ public: protected: virtual void layout(); private: - void verticalAlignCompute(RenderBlock*); int m_lineThickness; }; diff --git a/WebCore/mathml/RenderMathMLOperator.cpp b/WebCore/mathml/RenderMathMLOperator.cpp index 1ab3409..911c5d2 100644 --- a/WebCore/mathml/RenderMathMLOperator.cpp +++ b/WebCore/mathml/RenderMathMLOperator.cpp @@ -56,11 +56,14 @@ bool RenderMathMLOperator::isChildAllowed(RenderObject*, RenderStyle*) const return false; } +static const float gOperatorSpacer = 0.1; +static const float gOperatorExpansion = 1.2; + void RenderMathMLOperator::stretchToHeight(int height) { if (height == m_stretchHeight) return; - m_stretchHeight = height; + m_stretchHeight = static_cast<int>(height * gOperatorExpansion); updateBoxModelInfoFromStyle(); setNeedsLayoutAndPrefWidthsRecalc(); @@ -110,6 +113,7 @@ static const int gMinimumStretchHeight = 24; static const int gGlyphHeight = 10; static const int gMiddleGlyphTopAdjust = -2; static const int gBottomGlyphTopAdjust = -4; +static const float gMinimumRatioForStretch = 0.10; void RenderMathMLOperator::updateFromElement() { @@ -161,15 +165,16 @@ void RenderMathMLOperator::updateFromElement() // We only stretch character if the stretch height is larger than a minimum size (e.g. 24px). bool shouldStretch = isStretchy && m_stretchHeight>gMinimumStretchHeight; + m_isCentered = true; // Either stretch is disabled or we don't have a stretchable character over the minimum height if (stretchDisabled || !shouldStretch) { m_isStacked = false; - RenderBlock* container = new (renderArena()) RenderBlock(node()); + RenderBlock* container = new (renderArena()) RenderMathMLBlock(node()); RefPtr<RenderStyle> newStyle = RenderStyle::create(); newStyle->inheritFrom(style()); - newStyle->setDisplay(BLOCK); + newStyle->setDisplay(INLINE_BLOCK); // Check for a stretchable character that is under the minimum height and use the // font size to adjust the glyph size. @@ -181,9 +186,20 @@ void RenderMathMLOperator::updateFromElement() desc->setComputedSize(m_stretchHeight); newStyle->setFontDescription(*desc); newStyle->font().update(newStyle->font().fontSelector()); + newStyle->setVerticalAlign(BASELINE); + m_isCentered = false; + } else { + int topPad = (m_stretchHeight - currentFontSize) / 2; + + if (topPad / static_cast<float>(m_stretchHeight) > gMinimumRatioForStretch) { + newStyle->setVerticalAlign(TOP); + newStyle->setPaddingTop(Length(topPad, Fixed)); + } else { + m_isCentered = false; + newStyle->setVerticalAlign(BASELINE); + } } - newStyle->setVerticalAlign(BASELINE); container->setStyle(newStyle.release()); addChild(container); @@ -196,7 +212,9 @@ void RenderMathMLOperator::updateFromElement() text = new (renderArena()) RenderText(node(), StringImpl::create(mo->textContent().characters(), mo->textContent().length())); // If we can't figure out the text, leave it blank. if (text) { - text->setStyle(container->style()); + RefPtr<RenderStyle> textStyle = RenderStyle::create(); + textStyle->inheritFrom(container->style()); + text->setStyle(textStyle.release()); container->addChild(text); } } else { @@ -296,7 +314,7 @@ RefPtr<RenderStyle> RenderMathMLOperator::createStackableStyle(int size, int top RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int size, int charRelative, int topRelative) { - RenderBlock* container = new (renderArena()) RenderBlock(node()); + RenderBlock* container = new (renderArena()) RenderMathMLBlock(node()); container->setStyle(createStackableStyle(size, topRelative).release()); addChild(container); RenderBlock* parent = container; @@ -320,7 +338,11 @@ RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int size, int charRe int RenderMathMLOperator::baselinePosition(bool firstLine, bool isRootLineBox) const { - return !m_isStacked && firstChild() ? firstChild()->baselinePosition(firstLine, isRootLineBox) : offsetHeight(); + if (m_isStacked) + return m_stretchHeight * 2 / 3 - (m_stretchHeight - static_cast<int>(m_stretchHeight / gOperatorExpansion)) / 2; + if (m_isCentered && firstChild()) + return firstChild()->baselinePosition(firstLine, isRootLineBox); + return RenderBlock::baselinePosition(firstLine, isRootLineBox); } } diff --git a/WebCore/mathml/RenderMathMLOperator.h b/WebCore/mathml/RenderMathMLOperator.h index 6566dd7..cc183c3 100644 --- a/WebCore/mathml/RenderMathMLOperator.h +++ b/WebCore/mathml/RenderMathMLOperator.h @@ -50,6 +50,7 @@ protected: private: int m_stretchHeight; bool m_isStacked; + bool m_isCentered; UChar m_operator; }; diff --git a/WebCore/mathml/RenderMathMLRoot.cpp b/WebCore/mathml/RenderMathMLRoot.cpp index 23e3519..c624539 100644 --- a/WebCore/mathml/RenderMathMLRoot.cpp +++ b/WebCore/mathml/RenderMathMLRoot.cpp @@ -97,6 +97,9 @@ void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty) { RenderMathMLBlock::paint(info , tx , ty); + if (info.context->paintingDisabled()) + return; + tx += x(); ty += y(); @@ -145,7 +148,7 @@ void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty) info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize()); info.context->setStrokeStyle(SolidStroke); - info.context->setStrokeColor(style()->color(), sRGBColorSpace); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), sRGBColorSpace); info.context->setLineJoin(MiterJoin); info.context->setMiterLimit(style()->fontSize()); @@ -204,8 +207,7 @@ void RenderMathMLRoot::layout() int maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight(); RenderObject* current = lastChild()->firstChild(); - - toRenderMathMLBlock(current)->style()->setVerticalAlign(BASELINE); + current->style()->setVerticalAlign(BASELINE); if (!maxHeight) maxHeight = style()->fontSize(); @@ -238,9 +240,11 @@ void RenderMathMLRoot::layout() setNeedsLayoutAndPrefWidthsRecalc(); markContainingBlocksForLayout(); RenderBlock::layout(); - + indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed)); - + + // Now that we've potentially changed its position, we need layout the index again. + indexBox->setNeedsLayoutAndPrefWidthsRecalc(); indexBox->layout(); } diff --git a/WebCore/mathml/RenderMathMLRow.cpp b/WebCore/mathml/RenderMathMLRow.cpp index 1bb656f..acbfb9d 100644 --- a/WebCore/mathml/RenderMathMLRow.cpp +++ b/WebCore/mathml/RenderMathMLRow.cpp @@ -69,9 +69,6 @@ void RenderMathMLRow::layout() // Calculate the maximum height of the row without the operators. int maxHeight = nonOperatorHeight(); - // Set the maximum height of the row for intermediate layouts. - style()->setHeight(Length(maxHeight, Fixed)); - // Notify contained operators they may need to re-layout their stretched operators. // We need to keep track of the number of children and operators because a row of // operators needs some special handling. @@ -141,16 +138,24 @@ void RenderMathMLRow::layout() maxHeight = box->offsetHeight(); } } - - // Set the maximum height of the row based on the calculations. - style()->setHeight(Length(maxHeight, Fixed)); - // Do the final layout by calling our parent's layout again. + // Mark outself as needing layout and do the final layout of the row. setNeedsLayoutAndPrefWidthsRecalc(); markContainingBlocksForLayout(); RenderBlock::layout(); -} +} +int RenderMathMLRow::baselinePosition(bool firstLine, bool isRootLineBox) const +{ + if (firstChild() && firstChild()->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(firstChild()); + if (block->isRenderMathMLOperator()) + return block->baselinePosition(firstLine, isRootLineBox); + } + + return RenderBlock::baselinePosition(firstLine, isRootLineBox); +} + } #endif // ENABLE(MATHML) diff --git a/WebCore/mathml/RenderMathMLRow.h b/WebCore/mathml/RenderMathMLRow.h index a88b212..83c6832 100644 --- a/WebCore/mathml/RenderMathMLRow.h +++ b/WebCore/mathml/RenderMathMLRow.h @@ -37,6 +37,7 @@ public: RenderMathMLRow(Node* container); virtual bool isRenderMathMLRow() const { return true; } virtual int nonOperatorHeight() const; + virtual int baselinePosition(bool , bool) const; protected: virtual void layout(); }; diff --git a/WebCore/mathml/RenderMathMLSquareRoot.cpp b/WebCore/mathml/RenderMathMLSquareRoot.cpp index fc0a16d..6802176 100644 --- a/WebCore/mathml/RenderMathMLSquareRoot.cpp +++ b/WebCore/mathml/RenderMathMLSquareRoot.cpp @@ -69,6 +69,9 @@ void RenderMathMLSquareRoot::paint(PaintInfo& info, int tx, int ty) { RenderMathMLBlock::paint(info, tx, ty); + if (info.context->paintingDisabled()) + return; + tx += x(); ty += y(); @@ -114,7 +117,7 @@ void RenderMathMLSquareRoot::paint(PaintInfo& info, int tx, int ty) info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize()); info.context->setStrokeStyle(SolidStroke); - info.context->setStrokeColor(style()->color(), sRGBColorSpace); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), sRGBColorSpace); info.context->setLineJoin(MiterJoin); info.context->setMiterLimit(style()->fontSize()); diff --git a/WebCore/mathml/RenderMathMLSubSup.cpp b/WebCore/mathml/RenderMathMLSubSup.cpp index 3124ac9..af25980 100644 --- a/WebCore/mathml/RenderMathMLSubSup.cpp +++ b/WebCore/mathml/RenderMathMLSubSup.cpp @@ -72,7 +72,7 @@ void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild RefPtr<RenderStyle> scriptsStyle = RenderStyle::create(); scriptsStyle->inheritFrom(style()); scriptsStyle->setDisplay(INLINE_BLOCK); - scriptsStyle->setVerticalAlign(MIDDLE); + scriptsStyle->setVerticalAlign(TOP); scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed)); scriptsStyle->setTextAlign(LEFT); m_scripts->setStyle(scriptsStyle.release()); @@ -95,7 +95,7 @@ void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild RefPtr<RenderStyle> wrapperStyle = RenderStyle::create(); wrapperStyle->inheritFrom(style()); wrapperStyle->setDisplay(INLINE_BLOCK); - wrapperStyle->setVerticalAlign(MIDDLE); + wrapperStyle->setVerticalAlign(TOP); wrapper->setStyle(wrapperStyle.release()); RenderMathMLBlock::addChild(wrapper, beforeChild); wrapper->addChild(child); @@ -141,21 +141,32 @@ int RenderMathMLSubSup::nonOperatorHeight() const void RenderMathMLSubSup::layout() { + if (firstChild()) { + firstChild()->setNeedsLayoutAndPrefWidthsRecalc(); + firstChild()->markContainingBlocksForLayout(); + } + if (m_scripts) { + m_scripts->setNeedsLayoutAndPrefWidthsRecalc(); + m_scripts->markContainingBlocksForLayout(); + } RenderBlock::layout(); if (m_kind == SubSup) { - int width = 0; - RenderObject* current = firstChild(); - while (current) { - width += getBoxModelObjectWidth(current); - current = current->nextSibling(); + RenderObject* base = firstChild(); + if (base) { + int maxHeight = 0; + RenderObject* current = base->firstChild(); + while (current) { + int height = getBoxModelObjectHeight(current); + if (height > maxHeight) + maxHeight = height; + current = current->nextSibling(); + } + int heightDiff = (m_scripts->offsetHeight() - maxHeight) / 2; + if (heightDiff < 0) + heightDiff = 0; + base->style()->setMarginTop(Length(heightDiff, Fixed)); } - width++; - // 1 + margin of scripts - if (m_scripts) - width += gSubsupScriptMargin; - style()->setWidth(Length(width, Fixed)); - setNeedsLayoutAndPrefWidthsRecalc(); markContainingBlocksForLayout(); RenderBlock::layout(); @@ -181,7 +192,10 @@ int RenderMathMLSubSup::baselinePosition(bool firstLine, bool isRootLineBox) con RenderBoxModelObject* box = toRenderBoxModelObject(base); topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2; } - return topAdjust + (base ? base->baselinePosition(firstLine, isRootLineBox) : 0) + 4; + // FIXME: The last bit of this calculation should be more exact. Why is the 2-3px scaled for zoom necessary? + // The baseline is top spacing of the base + the baseline of the base + adjusted space for zoom + float zoomFactor = style()->effectiveZoom(); + return topAdjust + base->baselinePosition(firstLine, isRootLineBox) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); } break; case Sup: diff --git a/WebCore/mathml/RenderMathMLUnderOver.cpp b/WebCore/mathml/RenderMathMLUnderOver.cpp index 514b872..ad32d59 100644 --- a/WebCore/mathml/RenderMathMLUnderOver.cpp +++ b/WebCore/mathml/RenderMathMLUnderOver.cpp @@ -234,7 +234,7 @@ void RenderMathMLUnderOver::layout() RenderBlock::layout(); } -int RenderMathMLUnderOver::baselinePosition(bool, bool) const +int RenderMathMLUnderOver::baselinePosition(bool firstLine, bool isRootLineBox) const { int baseline = 0; RenderObject* current = 0; @@ -247,9 +247,12 @@ int RenderMathMLUnderOver::baselinePosition(bool, bool) const if (current) { // actual base RenderObject* base = current->firstChild(); - baseline += base->baselinePosition(true); + baseline += base->baselinePosition(firstLine, isRootLineBox); // added the negative top margin baseline += current->style()->marginTop().value(); + // FIXME: Where is the extra 2-3px adjusted for zoom coming from? + float zoomFactor = style()->effectiveZoom(); + baseline += static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); } break; case Under: @@ -257,6 +260,9 @@ int RenderMathMLUnderOver::baselinePosition(bool, bool) const if (current) { RenderObject* base = current->firstChild(); baseline += base->baselinePosition(true); + // FIXME: Where is the extra 2-3px adjusted for zoom coming from? + float zoomFactor = style()->effectiveZoom(); + baseline += static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); } } return baseline; |