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