18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 1997 Martin Jones (mjones@kde.org)
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 1997 Torben Weis (weis@kde.org)
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 1998 Waldo Bastian (bastian@kde.org)
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 1999 Lars Knoll (knoll@kde.org)
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 1999 Antti Koivisto (koivisto@kde.org)
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is free software; you can redistribute it and/or
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modify it under the terms of the GNU Library General Public
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * License as published by the Free Software Foundation; either
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * version 2 of the License, or (at your option) any later version.
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is distributed in the hope that it will be useful,
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * but WITHOUT ANY WARRANTY; without even the implied warranty of
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Library General Public License for more details.
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * You should have received a copy of the GNU Library General Public License
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * along with this library; see the file COPYING.LIB.  If not, write to
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Boston, MA 02110-1301, USA.
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
245f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "config.h"
268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "HTMLTablePartElement.h"
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "CSSHelper.h"
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "CSSPropertyNames.h"
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "CSSValueKeywords.h"
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "Document.h"
328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "HTMLNames.h"
335f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian#include "MappedAttribute.h"
348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore {
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectusing namespace HTMLNames;
388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectbool HTMLTablePartElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{
418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    if (attrName == backgroundAttr) {
428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        result = (MappedAttributeEntry)(eLastEntry + document()->docID());
438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        return false;
448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    }
458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    if (attrName == bgcolorAttr ||
478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        attrName == bordercolorAttr ||
488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        attrName == valignAttr ||
498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        attrName == heightAttr) {
508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        result = eUniversal;
518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        return false;
528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    }
538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    if (attrName == alignAttr) {
558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        result = eCell; // All table parts will just share in the TD space.
568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        return false;
578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    }
588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    return HTMLElement::mapToEntry(attrName, result);
608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}
618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectvoid HTMLTablePartElement::parseMappedAttribute(MappedAttribute *attr)
638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{
648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    if (attr->name() == bgcolorAttr)
658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    else if (attr->name() == backgroundAttr) {
670bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch        String url = deprecatedParseURL(attr->value());
688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        if (!url.isEmpty())
698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    } else if (attr->name() == bordercolorAttr) {
718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        if (!attr->value().isEmpty()) {
728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSColor(attr, CSSPropertyBorderColor, attr->value());
738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        }
788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    } else if (attr->name() == valignAttr) {
798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        if (!attr->value().isEmpty())
808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    } else if (attr->name() == alignAttr) {
828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        const AtomicString& v = attr->value();
838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        if (equalIgnoringCase(v, "middle") || equalIgnoringCase(v, "center"))
848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitCenter);
858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        else if (equalIgnoringCase(v, "absmiddle"))
868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyTextAlign, CSSValueCenter);
878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        else if (equalIgnoringCase(v, "left"))
888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitLeft);
898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        else if (equalIgnoringCase(v, "right"))
908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitRight);
918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        else
928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSProperty(attr, CSSPropertyTextAlign, v);
938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    } else if (attr->name() == heightAttr) {
948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        if (!attr->value().isEmpty())
958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            addCSSLength(attr, CSSPropertyHeight, attr->value());
968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    } else
978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        HTMLElement::parseMappedAttribute(attr);
988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}
998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}
101