1 /**
2 * This file is part of the DOM implementation for KDE.
3 *
4 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
5 * (C) 1997 Torben Weis (weis@kde.org)
6 * (C) 1998 Waldo Bastian (bastian@kde.org)
7 * (C) 1999 Lars Knoll (knoll@kde.org)
8 * (C) 1999 Antti Koivisto (koivisto@kde.org)
9 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 */
26 #include "config.h"
27 #include "HTMLTablePartElement.h"
28
29 #include "CSSHelper.h"
30 #include "CSSPropertyNames.h"
31 #include "CSSValueKeywords.h"
32 #include "Document.h"
33 #include "HTMLNames.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(MappedAttribute * attr)62 void HTMLTablePartElement::parseMappedAttribute(MappedAttribute *attr)
63 {
64 if (attr->name() == bgcolorAttr)
65 addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
66 else if (attr->name() == backgroundAttr) {
67 String url = parseURL(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