1 /**
2  * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3  *           (C) 1997 Torben Weis (weis@kde.org)
4  *           (C) 1998 Waldo Bastian (bastian@kde.org)
5  *           (C) 1999 Lars Knoll (knoll@kde.org)
6  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
7  * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB.  If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24 
25 #include "config.h"
26 #include "HTMLTablePartElement.h"
27 
28 #include "Attribute.h"
29 #include "CSSPropertyNames.h"
30 #include "CSSValueKeywords.h"
31 #include "Document.h"
32 #include "HTMLNames.h"
33 #include "HTMLParserIdioms.h"
34 
35 namespace WebCore {
36 
37 using namespace HTMLNames;
38 
mapToEntry(const QualifiedName & attrName,MappedAttributeEntry & result) const39 bool HTMLTablePartElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
40 {
41     if (attrName == backgroundAttr) {
42         result = (MappedAttributeEntry)(eLastEntry + document()->docID());
43         return false;
44     }
45 
46     if (attrName == bgcolorAttr ||
47         attrName == bordercolorAttr ||
48         attrName == valignAttr ||
49         attrName == heightAttr) {
50         result = eUniversal;
51         return false;
52     }
53 
54     if (attrName == alignAttr) {
55         result = eCell; // All table parts will just share in the TD space.
56         return false;
57     }
58 
59     return HTMLElement::mapToEntry(attrName, result);
60 }
61 
parseMappedAttribute(Attribute * attr)62 void HTMLTablePartElement::parseMappedAttribute(Attribute* attr)
63 {
64     if (attr->name() == bgcolorAttr)
65         addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
66     else if (attr->name() == backgroundAttr) {
67         String url = stripLeadingAndTrailingHTMLSpaces(attr->value());
68         if (!url.isEmpty())
69             addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
70     } else if (attr->name() == bordercolorAttr) {
71         if (!attr->value().isEmpty()) {
72             addCSSColor(attr, CSSPropertyBorderColor, attr->value());
73             addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
74             addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
75             addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
76             addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
77         }
78     } else if (attr->name() == valignAttr) {
79         if (!attr->value().isEmpty())
80             addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
81     } else if (attr->name() == alignAttr) {
82         const AtomicString& v = attr->value();
83         if (equalIgnoringCase(v, "middle") || equalIgnoringCase(v, "center"))
84             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitCenter);
85         else if (equalIgnoringCase(v, "absmiddle"))
86             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueCenter);
87         else if (equalIgnoringCase(v, "left"))
88             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitLeft);
89         else if (equalIgnoringCase(v, "right"))
90             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitRight);
91         else
92             addCSSProperty(attr, CSSPropertyTextAlign, v);
93     } else if (attr->name() == heightAttr) {
94         if (!attr->value().isEmpty())
95             addCSSLength(attr, CSSPropertyHeight, attr->value());
96     } else
97         HTMLElement::parseMappedAttribute(attr);
98 }
99 
100 }
101