2 * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
3 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2010 François Sausset (sausset@gmail.com). All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "MathMLElement.h"
34 #include "MathMLNames.h"
35 #include "RenderObject.h"
39 using namespace MathMLNames;
41 MathMLElement::MathMLElement(const QualifiedName& tagName, Document* document)
42 : StyledElement(tagName, document, CreateStyledElement)
46 PassRefPtr<MathMLElement> MathMLElement::create(const QualifiedName& tagName, Document* document)
48 return adoptRef(new MathMLElement(tagName, document));
51 bool MathMLElement::isPresentationAttribute(const QualifiedName& name) const
53 if (name == mathbackgroundAttr || name == mathsizeAttr || name == mathcolorAttr || name == fontsizeAttr || name == backgroundAttr || name == colorAttr || name == fontstyleAttr || name == fontweightAttr || name == fontfamilyAttr)
55 return StyledElement::isPresentationAttribute(name);
58 void MathMLElement::collectStyleForAttribute(const Attribute& attribute, StylePropertySet* style)
60 if (attribute.name() == mathbackgroundAttr)
61 addPropertyToAttributeStyle(style, CSSPropertyBackgroundColor, attribute.value());
62 else if (attribute.name() == mathsizeAttr) {
63 // The following three values of mathsize are handled in WebCore/css/mathml.css
64 if (attribute.value() != "normal" && attribute.value() != "small" && attribute.value() != "big")
65 addPropertyToAttributeStyle(style, CSSPropertyFontSize, attribute.value());
66 } else if (attribute.name() == mathcolorAttr)
67 addPropertyToAttributeStyle(style, CSSPropertyColor, attribute.value());
68 // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute
69 else if (attribute.name() == fontsizeAttr)
70 addPropertyToAttributeStyle(style, CSSPropertyFontSize, attribute.value());
71 else if (attribute.name() == backgroundAttr)
72 addPropertyToAttributeStyle(style, CSSPropertyBackgroundColor, attribute.value());
73 else if (attribute.name() == colorAttr)
74 addPropertyToAttributeStyle(style, CSSPropertyColor, attribute.value());
75 else if (attribute.name() == fontstyleAttr)
76 addPropertyToAttributeStyle(style, CSSPropertyFontStyle, attribute.value());
77 else if (attribute.name() == fontweightAttr)
78 addPropertyToAttributeStyle(style, CSSPropertyFontWeight, attribute.value());
79 else if (attribute.name() == fontfamilyAttr)
80 addPropertyToAttributeStyle(style, CSSPropertyFontFamily, attribute.value());
82 ASSERT(!isPresentationAttribute(attribute.name()));
83 StyledElement::collectStyleForAttribute(attribute, style);
89 #endif // ENABLE(MATHML)