• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
27 #include "config.h"
28 #include "HTMLTablePartElement.h"
29 
30 #include "CSSHelper.h"
31 #include "CSSPropertyNames.h"
32 #include "CSSValueKeywords.h"
33 #include "Document.h"
34 #include "HTMLNames.h"
35 #include "MappedAttribute.h"
36 
37 namespace WebCore {
38 
39 using namespace HTMLNames;
40 
mapToEntry(const QualifiedName & attrName,MappedAttributeEntry & result) const41 bool HTMLTablePartElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
42 {
43     if (attrName == backgroundAttr) {
44         result = (MappedAttributeEntry)(eLastEntry + document()->docID());
45         return false;
46     }
47 
48     if (attrName == bgcolorAttr ||
49         attrName == bordercolorAttr ||
50         attrName == valignAttr ||
51         attrName == heightAttr) {
52         result = eUniversal;
53         return false;
54     }
55 
56     if (attrName == alignAttr) {
57         result = eCell; // All table parts will just share in the TD space.
58         return false;
59     }
60 
61     return HTMLElement::mapToEntry(attrName, result);
62 }
63 
parseMappedAttribute(MappedAttribute * attr)64 void HTMLTablePartElement::parseMappedAttribute(MappedAttribute *attr)
65 {
66     if (attr->name() == bgcolorAttr)
67         addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
68     else if (attr->name() == backgroundAttr) {
69         String url = deprecatedParseURL(attr->value());
70         if (!url.isEmpty())
71             addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
72     } else if (attr->name() == bordercolorAttr) {
73         if (!attr->value().isEmpty()) {
74             addCSSColor(attr, CSSPropertyBorderColor, attr->value());
75             addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
76             addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
77             addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
78             addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
79         }
80     } else if (attr->name() == valignAttr) {
81         if (!attr->value().isEmpty())
82             addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
83     } else if (attr->name() == alignAttr) {
84         const AtomicString& v = attr->value();
85         if (equalIgnoringCase(v, "middle") || equalIgnoringCase(v, "center"))
86             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitCenter);
87         else if (equalIgnoringCase(v, "absmiddle"))
88             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueCenter);
89         else if (equalIgnoringCase(v, "left"))
90             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitLeft);
91         else if (equalIgnoringCase(v, "right"))
92             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitRight);
93         else
94             addCSSProperty(attr, CSSPropertyTextAlign, v);
95     } else if (attr->name() == heightAttr) {
96         if (!attr->value().isEmpty())
97             addCSSLength(attr, CSSPropertyHeight, attr->value());
98     } else
99         HTMLElement::parseMappedAttribute(attr);
100 }
101 
102 }
103