Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / mathml / MathMLElement.cpp
1 /*
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.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
14  *
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.
26  */
27
28 #include "config.h"
29
30 #if ENABLE(MATHML)
31
32 #include "MathMLElement.h"
33
34 #include "MathMLNames.h"
35 #include "RenderObject.h"
36
37 namespace WebCore {
38     
39 using namespace MathMLNames;
40     
41 MathMLElement::MathMLElement(const QualifiedName& tagName, Document* document)
42     : StyledElement(tagName, document, CreateStyledElement)
43 {
44 }
45     
46 PassRefPtr<MathMLElement> MathMLElement::create(const QualifiedName& tagName, Document* document)
47 {
48     return adoptRef(new MathMLElement(tagName, document));
49 }
50
51 bool MathMLElement::isPresentationAttribute(const QualifiedName& name) const
52 {
53     if (name == mathbackgroundAttr || name == mathsizeAttr || name == mathcolorAttr || name == fontsizeAttr || name == backgroundAttr || name == colorAttr || name == fontstyleAttr || name == fontweightAttr || name == fontfamilyAttr)
54         return true;
55     return StyledElement::isPresentationAttribute(name);
56 }
57
58 void MathMLElement::collectStyleForAttribute(const Attribute& attribute, StylePropertySet* style)
59 {
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());
81     else {
82         ASSERT(!isPresentationAttribute(attribute.name()));
83         StyledElement::collectStyleForAttribute(attribute, style);
84     }
85 }
86
87 }
88
89 #endif // ENABLE(MATHML)