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, 2010 Apple Inc. All rights reserved. 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 "HTMLTableColElement.h" 27 28#include "Attribute.h" 29#include "CSSPropertyNames.h" 30#include "HTMLNames.h" 31#include "HTMLTableElement.h" 32#include "RenderTableCol.h" 33#include "Text.h" 34 35namespace WebCore { 36 37using namespace HTMLNames; 38 39inline HTMLTableColElement::HTMLTableColElement(const QualifiedName& tagName, Document* document) 40 : HTMLTablePartElement(tagName, document) 41 , m_span(1) 42{ 43} 44 45PassRefPtr<HTMLTableColElement> HTMLTableColElement::create(const QualifiedName& tagName, Document* document) 46{ 47 return adoptRef(new HTMLTableColElement(tagName, document)); 48} 49 50bool HTMLTableColElement::isPresentationAttribute(const QualifiedName& name) const 51{ 52 if (name == widthAttr) 53 return true; 54 return HTMLTablePartElement::isPresentationAttribute(name); 55} 56 57void HTMLTableColElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) 58{ 59 if (name == widthAttr) 60 addHTMLLengthToStyle(style, CSSPropertyWidth, value); 61 else 62 HTMLTablePartElement::collectStyleForPresentationAttribute(name, value, style); 63} 64 65void HTMLTableColElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 66{ 67 if (name == spanAttr) { 68 m_span = !value.isNull() ? value.toInt() : 1; 69 if (renderer() && renderer()->isRenderTableCol()) 70 renderer()->updateFromElement(); 71 } else if (name == widthAttr) { 72 if (!value.isEmpty()) { 73 if (renderer() && renderer()->isRenderTableCol()) { 74 RenderTableCol* col = toRenderTableCol(renderer()); 75 int newWidth = width().toInt(); 76 if (newWidth != col->width()) 77 col->setNeedsLayoutAndPrefWidthsRecalc(); 78 } 79 } 80 } else 81 HTMLTablePartElement::parseAttribute(name, value); 82} 83 84const StylePropertySet* HTMLTableColElement::additionalPresentationAttributeStyle() 85{ 86 if (!hasLocalName(colgroupTag)) 87 return 0; 88 if (HTMLTableElement* table = findParentTable()) 89 return table->additionalGroupStyle(false); 90 return 0; 91} 92 93void HTMLTableColElement::setSpan(int n) 94{ 95 setAttribute(spanAttr, String::number(n)); 96} 97 98String HTMLTableColElement::width() const 99{ 100 return getAttribute(widthAttr); 101} 102 103} 104