summaryrefslogtreecommitdiffstats
path: root/WebCore/mathml
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/mathml')
-rw-r--r--WebCore/mathml/MathMLElement.cpp27
-rw-r--r--WebCore/mathml/MathMLInlineContainerElement.cpp30
-rw-r--r--WebCore/mathml/MathMLMathElement.cpp6
-rw-r--r--WebCore/mathml/MathMLTextElement.cpp7
-rw-r--r--WebCore/mathml/RenderMathMLFenced.cpp164
-rw-r--r--WebCore/mathml/RenderMathMLFenced.h56
-rw-r--r--WebCore/mathml/RenderMathMLFraction.cpp13
-rw-r--r--WebCore/mathml/RenderMathMLOperator.cpp116
-rw-r--r--WebCore/mathml/RenderMathMLRoot.cpp26
-rw-r--r--WebCore/mathml/RenderMathMLSquareRoot.cpp20
-rw-r--r--WebCore/mathml/RenderMathMLSubSup.cpp2
-rw-r--r--WebCore/mathml/mathattrs.in7
12 files changed, 359 insertions, 115 deletions
diff --git a/WebCore/mathml/MathMLElement.cpp b/WebCore/mathml/MathMLElement.cpp
index 30d02da..6088810 100644
--- a/WebCore/mathml/MathMLElement.cpp
+++ b/WebCore/mathml/MathMLElement.cpp
@@ -50,7 +50,10 @@ PassRefPtr<MathMLElement> MathMLElement::create(const QualifiedName& tagName, Do
bool MathMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
- if (attrName == MathMLNames::mathcolorAttr || attrName == MathMLNames::mathbackgroundAttr) {
+ if (attrName == mathcolorAttr || attrName == mathbackgroundAttr
+ || attrName == colorAttr || attrName == backgroundAttr
+ || attrName == fontsizeAttr || attrName == fontstyleAttr
+ || attrName == fontweightAttr || attrName == fontfamilyAttr) {
result = eMathML;
return false;
}
@@ -59,15 +62,27 @@ bool MathMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEnt
void MathMLElement::parseMappedAttribute(Attribute* attr)
{
- if (attr->name() == MathMLNames::mathbackgroundAttr)
+ if (attr->name() == mathbackgroundAttr)
addCSSProperty(attr, CSSPropertyBackgroundColor, attr->value());
- else if (attr->name() == MathMLNames::mathcolorAttr)
- addCSSProperty(attr, CSSPropertyColor, attr->value());
- else if (attr->name() == MathMLNames::mathsizeAttr) {
+ else if (attr->name() == mathsizeAttr) {
// The following three values of mathsize are handled in WebCore/css/mathml.css
if (attr->value() != "normal" && attr->value() != "small" && attr->value() != "big")
addCSSProperty(attr, CSSPropertyFontSize, attr->value());
- }
+ } else if (attr->name() == mathcolorAttr)
+ addCSSProperty(attr, CSSPropertyColor, attr->value());
+ // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute
+ else if (attr->name() == fontsizeAttr)
+ addCSSProperty(attr, CSSPropertyFontSize, attr->value());
+ else if (attr->name() == backgroundAttr)
+ addCSSProperty(attr, CSSPropertyBackgroundColor, attr->value());
+ else if (attr->name() == colorAttr)
+ addCSSProperty(attr, CSSPropertyColor, attr->value());
+ else if (attr->name() == fontstyleAttr)
+ addCSSProperty(attr, CSSPropertyFontStyle, attr->value());
+ else if (attr->name() == fontweightAttr)
+ addCSSProperty(attr, CSSPropertyFontWeight, attr->value());
+ else if (attr->name() == fontfamilyAttr)
+ addCSSProperty(attr, CSSPropertyFontFamily, attr->value());
else
StyledElement::parseMappedAttribute(attr);
}
diff --git a/WebCore/mathml/MathMLInlineContainerElement.cpp b/WebCore/mathml/MathMLInlineContainerElement.cpp
index efc9f8c..8b3f43e 100644
--- a/WebCore/mathml/MathMLInlineContainerElement.cpp
+++ b/WebCore/mathml/MathMLInlineContainerElement.cpp
@@ -32,6 +32,7 @@
#include "MathMLNames.h"
#include "RenderMathMLBlock.h"
+#include "RenderMathMLFenced.h"
#include "RenderMathMLFraction.h"
#include "RenderMathMLRoot.h"
#include "RenderMathMLRow.h"
@@ -53,33 +54,32 @@ PassRefPtr<MathMLInlineContainerElement> MathMLInlineContainerElement::create(co
return adoptRef(new MathMLInlineContainerElement(tagName, document));
}
-RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- RenderObject* object;
if (hasLocalName(MathMLNames::mrowTag))
- object = new (arena) RenderMathMLRow(this);
+ return new (arena) RenderMathMLRow(this);
else if (hasLocalName(MathMLNames::msubTag))
- object = new (arena) RenderMathMLSubSup(this);
+ return new (arena) RenderMathMLSubSup(this);
else if (hasLocalName(MathMLNames::msupTag))
- object = new (arena) RenderMathMLSubSup(this);
+ return new (arena) RenderMathMLSubSup(this);
else if (hasLocalName(MathMLNames::msubsupTag))
- object = new (arena) RenderMathMLSubSup(this);
+ return new (arena) RenderMathMLSubSup(this);
else if (hasLocalName(MathMLNames::moverTag))
- object = new (arena) RenderMathMLUnderOver(this);
+ return new (arena) RenderMathMLUnderOver(this);
else if (hasLocalName(MathMLNames::munderTag))
- object = new (arena) RenderMathMLUnderOver(this);
+ return new (arena) RenderMathMLUnderOver(this);
else if (hasLocalName(MathMLNames::munderoverTag))
- object = new (arena) RenderMathMLUnderOver(this);
+ return new (arena) RenderMathMLUnderOver(this);
else if (hasLocalName(MathMLNames::mfracTag))
- object = new (arena) RenderMathMLFraction(this);
+ return new (arena) RenderMathMLFraction(this);
else if (hasLocalName(MathMLNames::msqrtTag))
- object = new (arena) RenderMathMLSquareRoot(this);
+ return new (arena) RenderMathMLSquareRoot(this);
else if (hasLocalName(MathMLNames::mrootTag))
- object = new (arena) RenderMathMLRoot(this);
+ return new (arena) RenderMathMLRoot(this);
+ else if (hasLocalName(MathMLNames::mfencedTag))
+ return new (arena) RenderMathMLFenced(this);
else
- object = new (arena) RenderMathMLBlock(this);
- object->setStyle(style);
- return object;
+ return new (arena) RenderMathMLBlock(this);
}
}
diff --git a/WebCore/mathml/MathMLMathElement.cpp b/WebCore/mathml/MathMLMathElement.cpp
index 1b6b18d..6c5c3c6 100644
--- a/WebCore/mathml/MathMLMathElement.cpp
+++ b/WebCore/mathml/MathMLMathElement.cpp
@@ -44,11 +44,9 @@ PassRefPtr<MathMLMathElement> MathMLMathElement::create(const QualifiedName& tag
return adoptRef(new MathMLMathElement(tagName, document));
}
-RenderObject* MathMLMathElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* MathMLMathElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- RenderMathMLMath* renderer = new (arena) RenderMathMLMath(this);
- renderer->setStyle(style);
- return renderer;
+ return new (arena) RenderMathMLMath(this);
}
}
diff --git a/WebCore/mathml/MathMLTextElement.cpp b/WebCore/mathml/MathMLTextElement.cpp
index 4135d6c..8f830cb 100644
--- a/WebCore/mathml/MathMLTextElement.cpp
+++ b/WebCore/mathml/MathMLTextElement.cpp
@@ -49,11 +49,8 @@ PassRefPtr<MathMLTextElement> MathMLTextElement::create(const QualifiedName& tag
RenderObject* MathMLTextElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
- if (hasLocalName(MathMLNames::moTag)) {
- RenderObject* object = new (arena) RenderMathMLOperator(this);
- object->setStyle(style);
- return object;
- }
+ if (hasLocalName(MathMLNames::moTag))
+ return new (arena) RenderMathMLOperator(this);
return MathMLElement::createRenderer(arena, style);
}
diff --git a/WebCore/mathml/RenderMathMLFenced.cpp b/WebCore/mathml/RenderMathMLFenced.cpp
new file mode 100644
index 0000000..6c0bb0b
--- /dev/null
+++ b/WebCore/mathml/RenderMathMLFenced.cpp
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(MATHML)
+
+#include "RenderMathMLFenced.h"
+
+#include "FontSelector.h"
+#include "MathMLNames.h"
+#include "RenderInline.h"
+#include "RenderMathMLOperator.h"
+#include "RenderText.h"
+
+namespace WebCore {
+
+using namespace MathMLNames;
+
+enum Braces { OpeningBraceChar = 0x28, ClosingBraceChar = 0x29 };
+
+RenderMathMLFenced::RenderMathMLFenced(Node* fenced)
+ : RenderMathMLRow(fenced)
+ , m_open(OpeningBraceChar)
+ , m_close(ClosingBraceChar)
+{
+}
+
+void RenderMathMLFenced::updateFromElement()
+{
+ Element* fenced = static_cast<Element*>(node());
+
+ // FIXME: Handle open/close values with more than one character (they should be treated like text).
+ AtomicString openValue = fenced->getAttribute(MathMLNames::openAttr);
+ if (openValue.length() > 0)
+ m_open = openValue[0];
+ AtomicString closeValue = fenced->getAttribute(MathMLNames::closeAttr);
+ if (closeValue.length() > 0)
+ m_close = closeValue[0];
+
+ AtomicString separators = static_cast<Element*>(fenced)->getAttribute(MathMLNames::separatorsAttr);
+ if (!separators.isNull()) {
+ Vector<UChar> characters;
+ for (unsigned int i = 0; i < separators.length(); i++) {
+ if (!isSpaceOrNewline(separators[i]))
+ characters.append(separators[i]);
+ }
+ m_separators = !separators.length() ? 0 : StringImpl::create(characters.data() , characters.size());
+ } else {
+ // The separator defaults to a single comma.
+ m_separators = StringImpl::create(",");
+ }
+
+ if (isEmpty())
+ makeFences();
+}
+
+RefPtr<RenderStyle> RenderMathMLFenced::makeOperatorStyle()
+{
+ RefPtr<RenderStyle> newStyle = RenderStyle::create();
+ newStyle->inheritFrom(style());
+ newStyle->setDisplay(INLINE_BLOCK);
+ newStyle->setHeight(Length(100.0, Percent));
+ newStyle->setVerticalAlign(MIDDLE);
+ return newStyle;
+}
+
+void RenderMathMLFenced::makeFences()
+{
+ RenderObject* openFence = new (renderArena()) RenderMathMLOperator(node(), m_open);
+ openFence->setStyle(makeOperatorStyle().release());
+ RenderBlock::addChild(openFence, firstChild());
+ RenderObject* closeFence = new (renderArena()) RenderMathMLOperator(node(), m_close);
+ closeFence->setStyle(makeOperatorStyle().release());
+ RenderBlock::addChild(closeFence);
+}
+
+void RenderMathMLFenced::addChild(RenderObject* child, RenderObject*)
+{
+ // make the fences if the render object is empty
+ if (isEmpty())
+ updateFromElement();
+
+ if (m_separators.get()) {
+ unsigned int count = 0;
+ for (Node* position = child->node(); position; position = position->previousSibling()) {
+ if (position->nodeType() == Node::ELEMENT_NODE)
+ count++;
+ }
+
+ if (count > 1) {
+ UChar separator;
+
+ // Use the last separator if we've run out of specified separators.
+ if ((count - 1) >= m_separators.get()->length())
+ separator = (*m_separators.get())[m_separators.get()->length() - 1];
+ else
+ separator = (*m_separators.get())[count - 1];
+
+ RenderObject* separatorObj = new (renderArena()) RenderMathMLOperator(node(), separator);
+ separatorObj->setStyle(makeOperatorStyle().release());
+ RenderBlock::addChild(separatorObj, lastChild());
+ }
+ }
+
+ // If we have a block, we'll wrap it in an inline-block.
+ if (child->isBlockFlow() && child->style()->display() != INLINE_BLOCK) {
+ // Block objects wrapper.
+
+ RenderBlock* block = new (renderArena()) RenderBlock(node());
+ RefPtr<RenderStyle> newStyle = RenderStyle::create();
+ newStyle->inheritFrom(style());
+ newStyle->setDisplay(INLINE_BLOCK);
+ block->setStyle(newStyle.release());
+
+ RenderBlock::addChild(block, lastChild());
+ block->addChild(child);
+ } else
+ RenderBlock::addChild(child, lastChild());
+}
+
+void RenderMathMLFenced::layout()
+{
+ RenderMathMLRow::layout();
+
+ int width = 0;
+ for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
+ if (current->isBoxModelObject()) {
+ RenderBoxModelObject* box = toRenderBoxModelObject(current);
+ width += box->offsetWidth();
+ }
+ }
+ width++;
+ style()->setWidth(Length(width, Fixed));
+
+ setNeedsLayoutAndPrefWidthsRecalc();
+ markContainingBlocksForLayout();
+ RenderBlock::layout();
+}
+}
+
+#endif
diff --git a/WebCore/mathml/RenderMathMLFenced.h b/WebCore/mathml/RenderMathMLFenced.h
new file mode 100644
index 0000000..63cdaa8
--- /dev/null
+++ b/WebCore/mathml/RenderMathMLFenced.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RenderMathMLFenced_h
+#define RenderMathMLFenced_h
+
+#if ENABLE(MATHML)
+
+#include "RenderMathMLRow.h"
+
+namespace WebCore {
+
+class RenderMathMLFenced : public RenderMathMLRow {
+public:
+ RenderMathMLFenced(Node *fraction);
+ virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
+ virtual void updateFromElement();
+
+protected:
+ virtual void layout();
+
+private:
+ void makeFences();
+ RefPtr<RenderStyle> makeOperatorStyle();
+ UChar m_open;
+ UChar m_close;
+ RefPtr<StringImpl> m_separators;
+};
+
+}
+
+#endif // ENABLE(MATHML)
+
+#endif // RenderMathMLFenced_h
diff --git a/WebCore/mathml/RenderMathMLFraction.cpp b/WebCore/mathml/RenderMathMLFraction.cpp
index cd0681d..72f7298 100644
--- a/WebCore/mathml/RenderMathMLFraction.cpp
+++ b/WebCore/mathml/RenderMathMLFraction.cpp
@@ -122,23 +122,22 @@ void RenderMathMLFraction::addChild(RenderObject* child, RenderObject* beforeChi
void RenderMathMLFraction::layout()
{
updateFromElement();
-
+
// Adjust the fraction line thickness for the zoom
if (lastChild() && lastChild()->isRenderBlock())
- m_lineThickness = m_lineThickness * ceil(gFractionBarWidth * style()->fontSize());
-
+ m_lineThickness = static_cast<int>(m_lineThickness * ceil(gFractionBarWidth * style()->fontSize()));
+
RenderBlock::layout();
-
+
// The row layout can affect the numerator/denominator width.
// FIXME: This is probably only needed if one of the children
// contains an mrow.
setNeedsLayoutAndPrefWidthsRecalc();
markContainingBlocksForLayout();
-
+
RenderBlock::layout();
-
}
-
+
void RenderMathMLFraction::paint(PaintInfo& info, int tx, int ty)
{
RenderMathMLBlock::paint(info, tx, ty);
diff --git a/WebCore/mathml/RenderMathMLOperator.cpp b/WebCore/mathml/RenderMathMLOperator.cpp
index 911c5d2..f9ff630 100644
--- a/WebCore/mathml/RenderMathMLOperator.cpp
+++ b/WebCore/mathml/RenderMathMLOperator.cpp
@@ -38,28 +38,28 @@ namespace WebCore {
using namespace MathMLNames;
RenderMathMLOperator::RenderMathMLOperator(Node* container)
- : RenderMathMLBlock(container),
- m_stretchHeight(0),
- m_operator(0)
+ : RenderMathMLBlock(container)
+ , m_stretchHeight(0)
+ , m_operator(0)
{
}
-
+
RenderMathMLOperator::RenderMathMLOperator(Node* container, UChar operatorChar)
- : RenderMathMLBlock(container),
- m_stretchHeight(0),
- m_operator(operatorChar)
+ : RenderMathMLBlock(container)
+ , m_stretchHeight(0)
+ , m_operator(operatorChar)
{
}
-
+
bool RenderMathMLOperator::isChildAllowed(RenderObject*, RenderStyle*) const
{
return false;
}
-static const float gOperatorSpacer = 0.1;
-static const float gOperatorExpansion = 1.2;
+static const float gOperatorSpacer = 0.1f;
+static const float gOperatorExpansion = 1.2f;
-void RenderMathMLOperator::stretchToHeight(int height)
+void RenderMathMLOperator::stretchToHeight(int height)
{
if (height == m_stretchHeight)
return;
@@ -87,15 +87,20 @@ static struct StretchyCharacter {
UChar extensionGlyph;
UChar bottomGlyph;
UChar middleGlyph;
-} stretchyCharacters[9] = {
-{ 0x28 , 0x239b, 0x239c, 0x239d, 0x0 }, // left parenthesis
-{ 0x29 , 0x239e, 0x239f, 0x23a0, 0x0 }, // right parenthesis
-{ 0x5b , 0x23a1, 0x23a2, 0x23a3, 0x0 }, // left square bracket
-{ 0x5d , 0x23a4, 0x23a5, 0x23a6, 0x0 }, // right square bracket
-{ 0x7b , 0x23a7, 0x23aa, 0x23a9, 0x23a8 }, // left curly bracket
-{ 0x7c , 0x23d0, 0x23d0, 0x23d0, 0x0 }, // vertical bar
-{ 0x7d , 0x23ab, 0x23aa, 0x23ad, 0x23ac }, // right curly bracket
-{ 0x222b, 0x2320, 0x23ae, 0x2321, 0x0 } // integral sign
+} stretchyCharacters[13] = {
+ { 0x28 , 0x239b, 0x239c, 0x239d, 0x0 }, // left parenthesis
+ { 0x29 , 0x239e, 0x239f, 0x23a0, 0x0 }, // right parenthesis
+ { 0x5b , 0x23a1, 0x23a2, 0x23a3, 0x0 }, // left square bracket
+ { 0x2308, 0x23a1, 0x23a2, 0x23a2, 0x0 }, // left ceiling
+ { 0x230a, 0x23a2, 0x23a2, 0x23a3, 0x0 }, // left floor
+ { 0x5d , 0x23a4, 0x23a5, 0x23a6, 0x0 }, // right square bracket
+ { 0x2309, 0x23a4, 0x23a5, 0x23a5, 0x0 }, // right ceiling
+ { 0x230b, 0x23a5, 0x23a5, 0x23a6, 0x0 }, // right floor
+ { 0x7b , 0x23a7, 0x23aa, 0x23a9, 0x23a8 }, // left curly bracket
+ { 0x7c , 0x23d0, 0x23d0, 0x23d0, 0x0 }, // vertical bar
+ { 0x2016, 0x2016, 0x2016, 0x2016, 0x0 }, // double vertical line
+ { 0x7d , 0x23ab, 0x23aa, 0x23ad, 0x23ac }, // right curly bracket
+ { 0x222b, 0x2320, 0x23ae, 0x2321, 0x0 } // integral sign
};
// We stack glyphs using a 14px height with a displayed glyph height
@@ -107,21 +112,24 @@ static struct StretchyCharacter {
//
// All of these settings are represented in the constants below.
+// FIXME: use fractions of style()->fontSize() for proper zooming/resizing.
static const int gGlyphFontSize = 14;
-static const int gGlyphLineHeight = 12;
+static const int gGlyphLineHeight = 11;
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;
+static const int gTopGlyphTopAdjust = 1;
+static const int gMiddleGlyphTopAdjust = -1;
+static const int gBottomGlyphTopAdjust = -3;
+static const float gMinimumRatioForStretch = 0.10f;
void RenderMathMLOperator::updateFromElement()
{
- // clear our children
- while (firstChild()) {
- RenderObject* obj = firstChild();
- removeChild(obj);
- }
+ // Destroy our current children
+ children()->destroyLeftoverChildren();
+
+ // Since we share a node with our children, destroying our children will set our node's
+ // renderer to 0, so we need to re-set it back to this.
+ node()->setRenderer(this);
// If the operator is fixed, it will be contained in m_operator
UChar firstChar = m_operator;
@@ -140,7 +148,7 @@ void RenderMathMLOperator::updateFromElement()
String opText = mo->textContent();
for (unsigned int i = 0; !firstChar && i < opText.length(); i++) {
if (!isSpaceOrNewline(opText[i]))
- firstChar = opText[i];
+ firstChar = opText[i];
}
}
}
@@ -175,22 +183,22 @@ void RenderMathMLOperator::updateFromElement()
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(style());
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.
int currentFontSize = style()->fontSize();
if (!stretchDisabled && isStretchy && m_stretchHeight > 0 && m_stretchHeight <= gMinimumStretchHeight && m_stretchHeight > currentFontSize) {
- FontDescription* desc = new FontDescription();
- desc->setIsAbsoluteSize(true);
- desc->setSpecifiedSize(m_stretchHeight);
- desc->setComputedSize(m_stretchHeight);
- newStyle->setFontDescription(*desc);
+ FontDescription desc;
+ desc.setIsAbsoluteSize(true);
+ desc.setSpecifiedSize(m_stretchHeight);
+ 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));
@@ -199,11 +207,11 @@ void RenderMathMLOperator::updateFromElement()
newStyle->setVerticalAlign(BASELINE);
}
}
-
+
container->setStyle(newStyle.release());
addChild(container);
-
- // Build the text of the operator.
+
+ // Build the text of the operator.
RenderText* text = 0;
if (m_operator)
text = new (renderArena()) RenderText(node(), StringImpl::create(&m_operator, 1));
@@ -226,12 +234,12 @@ void RenderMathMLOperator::updateFromElement()
int half = (m_stretchHeight - gGlyphHeight) / 2;
if (half <= gGlyphHeight) {
// We only have enough space for a single middle glyph.
- createGlyph(stretchyCharacters[index].topGlyph, half);
+ createGlyph(stretchyCharacters[index].topGlyph, half, gTopGlyphTopAdjust);
createGlyph(stretchyCharacters[index].middleGlyph, gGlyphHeight, gMiddleGlyphTopAdjust);
createGlyph(stretchyCharacters[index].bottomGlyph, 0, gBottomGlyphTopAdjust);
} else {
// We have to extend both the top and bottom to the middle.
- createGlyph(stretchyCharacters[index].topGlyph, gGlyphHeight);
+ createGlyph(stretchyCharacters[index].topGlyph, gGlyphHeight, gTopGlyphTopAdjust);
int remaining = half - gGlyphHeight;
while (remaining > 0) {
if (remaining < gGlyphHeight) {
@@ -269,7 +277,7 @@ void RenderMathMLOperator::updateFromElement()
} else {
// We do not have a middle glyph and so we just extend from the top to the bottom glyph.
int remaining = m_stretchHeight - 2 * gGlyphHeight;
- createGlyph(stretchyCharacters[index].topGlyph, gGlyphHeight);
+ createGlyph(stretchyCharacters[index].topGlyph, gGlyphHeight, gTopGlyphTopAdjust);
while (remaining > 0) {
if (remaining < gGlyphHeight) {
createGlyph(stretchyCharacters[index].extensionGlyph, remaining);
@@ -289,26 +297,26 @@ RefPtr<RenderStyle> RenderMathMLOperator::createStackableStyle(int size, int top
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(style());
newStyle->setDisplay(BLOCK);
-
- FontDescription* desc = new FontDescription();
- desc->setIsAbsoluteSize(true);
- desc->setSpecifiedSize(gGlyphFontSize);
- desc->setComputedSize(gGlyphFontSize);
- newStyle->setFontDescription(*desc);
+
+ FontDescription desc;
+ desc.setIsAbsoluteSize(true);
+ desc.setSpecifiedSize(gGlyphFontSize);
+ desc.setComputedSize(gGlyphFontSize);
+ newStyle->setFontDescription(desc);
newStyle->font().update(newStyle->font().fontSelector());
newStyle->setLineHeight(Length(gGlyphLineHeight, Fixed));
newStyle->setVerticalAlign(TOP);
-
+
if (size > 0)
newStyle->setMaxHeight(Length(size, Fixed));
-
+
newStyle->setOverflowY(OHIDDEN);
newStyle->setOverflowX(OHIDDEN);
if (topRelative) {
newStyle->setTop(Length(topRelative, Fixed));
newStyle->setPosition(RelativePosition);
}
-
+
return newStyle;
}
@@ -329,7 +337,7 @@ RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int size, int charRe
parent->addChild(charBlock);
parent = charBlock;
}
-
+
RenderText* text = new (renderArena()) RenderText(node(), StringImpl::create(&glyph, 1));
text->setStyle(container->style());
parent->addChild(text);
@@ -344,7 +352,7 @@ int RenderMathMLOperator::baselinePosition(bool firstLine, bool isRootLineBox) c
return firstChild()->baselinePosition(firstLine, isRootLineBox);
return RenderBlock::baselinePosition(firstLine, isRootLineBox);
}
-
+
}
#endif
diff --git a/WebCore/mathml/RenderMathMLRoot.cpp b/WebCore/mathml/RenderMathMLRoot.cpp
index c624539..4ed8c19 100644
--- a/WebCore/mathml/RenderMathMLRoot.cpp
+++ b/WebCore/mathml/RenderMathMLRoot.cpp
@@ -42,26 +42,26 @@ const int gRadicalLeftMargin = 3;
// Bottom padding of the radical (px)
const int gRadicalBasePad = 3;
// Threshold above which the radical shape is modified to look nice with big bases (%)
-const float gThresholdBaseHeight = 1.5;
+const float gThresholdBaseHeight = 1.5f;
// Radical width (%)
-const float gRadicalWidth = 0.75;
+const float gRadicalWidth = 0.75f;
// Horizontal position of the bottom point of the radical (%)
-const float gRadicalBottomPointXPos= 0.5;
+const float gRadicalBottomPointXPos= 0.5f;
// Horizontal position of the top left point of the radical (%)
-const float gRadicalTopLeftPointXPos = 0.8;
+const float gRadicalTopLeftPointXPos = 0.8f;
// Vertical position of the top left point of the radical (%)
-const float gRadicalTopLeftPointYPos = 0.625;
+const float gRadicalTopLeftPointYPos = 0.625f;
// Vertical shift of the left end point of the radical (%)
-const float gRadicalLeftEndYShift = 0.05;
+const float gRadicalLeftEndYShift = 0.05f;
// Root padding around the base (%)
-const float gRootPadding = 0.2;
+const float gRootPadding = 0.2f;
// Additional bottom root padding (%)
-const float gRootBottomPadding = 0.2;
+const float gRootBottomPadding = 0.2f;
// Radical line thickness (%)
-const float gRadicalLineThickness = 0.02;
+const float gRadicalLineThickness = 0.02f;
// Radical thick line thickness (%)
-const float gRadicalThickLineThickness = 0.1;
+const float gRadicalThickLineThickness = 0.1f;
RenderMathMLRoot::RenderMathMLRoot(Node *expression)
: RenderMathMLBlock(expression)
@@ -129,7 +129,7 @@ void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty)
if (maxHeight > thresholdHeight && thresholdHeight) {
float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
- shift = 1.;
+ shift = 1.0f;
topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
}
@@ -148,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()->visitedDependentColor(CSSPropertyColor), sRGBColorSpace);
+ info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), DeviceColorSpace);
info.context->setLineJoin(MiterJoin);
info.context->setMiterLimit(style()->fontSize());
@@ -219,7 +219,7 @@ void RenderMathMLRoot::layout()
if (maxHeight > thresholdHeight && thresholdHeight) {
float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
- shift = 1.;
+ shift = 1.0f;
int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
diff --git a/WebCore/mathml/RenderMathMLSquareRoot.cpp b/WebCore/mathml/RenderMathMLSquareRoot.cpp
index be62f57..86add7a 100644
--- a/WebCore/mathml/RenderMathMLSquareRoot.cpp
+++ b/WebCore/mathml/RenderMathMLSquareRoot.cpp
@@ -41,24 +41,24 @@ using namespace MathMLNames;
// Bottom padding of the radical (px)
const int gRadicalBasePad = 3;
// Threshold above which the radical shape is modified to look nice with big bases (%)
-const float gThresholdBaseHeight = 1.5;
+const float gThresholdBaseHeight = 1.5f;
// Radical width (%)
-const float gRadicalWidth = 0.75;
+const float gRadicalWidth = 0.75f;
// Horizontal position of the bottom point of the radical (%)
-const float gRadicalBottomPointXPos= 0.5;
+const float gRadicalBottomPointXPos= 0.5f;
// Horizontal position of the top left point of the radical (%)
-const float gRadicalTopLeftPointXPos = 0.2;
+const float gRadicalTopLeftPointXPos = 0.2f;
// Vertical position of the top left point of the radical (%)
-const float gRadicalTopLeftPointYPos = 0.5;
+const float gRadicalTopLeftPointYPos = 0.5f;
// Vertical shift of the left end point of the radical (%)
-const float gRadicalLeftEndYShift = 0.05;
+const float gRadicalLeftEndYShift = 0.05f;
// Additional bottom root padding (%)
-const float gRootBottomPadding = 0.2;
+const float gRootBottomPadding = 0.2f;
// Radical line thickness (%)
-const float gRadicalLineThickness = 0.02;
+const float gRadicalLineThickness = 0.02f;
// Radical thick line thickness (%)
-const float gRadicalThickLineThickness = 0.1;
+const float gRadicalThickLineThickness = 0.1f;
RenderMathMLSquareRoot::RenderMathMLSquareRoot(Node *expression)
: RenderMathMLBlock(expression)
@@ -102,7 +102,7 @@ void RenderMathMLSquareRoot::paint(PaintInfo& info, int tx, int ty)
if (maxHeight > thresholdHeight && thresholdHeight) {
float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
- shift = 1.;
+ shift = 1.0f;
topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
}
diff --git a/WebCore/mathml/RenderMathMLSubSup.cpp b/WebCore/mathml/RenderMathMLSubSup.cpp
index 45ad000..52ac0e3 100644
--- a/WebCore/mathml/RenderMathMLSubSup.cpp
+++ b/WebCore/mathml/RenderMathMLSubSup.cpp
@@ -44,7 +44,7 @@ using namespace MathMLNames;
static const int gTopAdjustDivisor = 3;
static const int gSubsupScriptMargin = 1;
-static const float gSubSupStretch = 1.2;
+static const float gSubSupStretch = 1.2f;
RenderMathMLSubSup::RenderMathMLSubSup(Element* element)
: RenderMathMLBlock(element)
diff --git a/WebCore/mathml/mathattrs.in b/WebCore/mathml/mathattrs.in
index 5431453..4fda481 100644
--- a/WebCore/mathml/mathattrs.in
+++ b/WebCore/mathml/mathattrs.in
@@ -3,13 +3,20 @@ namespaceURI="http://www.w3.org/1998/Math/MathML"
guardFactoryWith="ENABLE(MATHML)"
attrsNullNamespace
+background
close
+color
definitionURL
denomalign
+fontfamily
+fontsize
+fontstyle
+fontweight
linethickness
mathbackground
mathcolor
mathsize
+mathvariant
numalign
open
separators