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, MutableStyleProperties& 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 int newSpan = value.toInt(); 69 m_span = newSpan ? newSpan : 1; 70 if (renderer() && renderer()->isRenderTableCol()) 71 renderer()->updateFromElement(); 72 } else if (name == widthAttr) { 73 if (!value.isEmpty()) { 74 if (renderer() && renderer()->isRenderTableCol()) { 75 RenderTableCol* col = toRenderTableCol(renderer()); 76 int newWidth = width().toInt(); 77 if (newWidth != col->width()) 78 col->setNeedsLayoutAndPrefWidthsRecalc(); 79 } 80 } 81 } else 82 HTMLTablePartElement::parseAttribute(name, value); 83} 84 85const StyleProperties* HTMLTableColElement::additionalPresentationAttributeStyle() 86{ 87 if (!hasTagName(colgroupTag)) 88 return nullptr; 89 if (HTMLTableElement* table = findParentTable()) 90 return table->additionalGroupStyle(false); 91 return nullptr; 92} 93 94void HTMLTableColElement::setSpan(int n) 95{ 96 setIntegralAttribute(spanAttr, n); 97} 98 99String HTMLTableColElement::width() const 100{ 101 return fastGetAttribute(widthAttr); 102} 103 104} 105