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 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public License
23 * along with this library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA.
26 */
27
28 #include "config.h"
29 #include "RenderTableCol.h"
30
31 #include "CachedImage.h"
32 #include "HTMLNames.h"
33 #include "HTMLTableColElement.h"
34
35 namespace WebCore {
36
37 using namespace HTMLNames;
38
RenderTableCol(Node * node)39 RenderTableCol::RenderTableCol(Node* node)
40 : RenderContainer(node), m_span(1)
41 {
42 // init RenderObject attributes
43 setInline(true); // our object is not Inline
44 updateFromElement();
45 }
46
updateFromElement()47 void RenderTableCol::updateFromElement()
48 {
49 int oldSpan = m_span;
50 Node* node = element();
51 if (node && (node->hasTagName(colTag) || node->hasTagName(colgroupTag))) {
52 HTMLTableColElement* tc = static_cast<HTMLTableColElement*>(node);
53 m_span = tc->span();
54 } else
55 m_span = !(style() && style()->display() == TABLE_COLUMN_GROUP);
56 if (m_span != oldSpan && style() && parent())
57 setNeedsLayoutAndPrefWidthsRecalc();
58 }
59
isChildAllowed(RenderObject * child,RenderStyle * style) const60 bool RenderTableCol::isChildAllowed(RenderObject* child, RenderStyle* style) const
61 {
62 return !child->isText() && style && (style->display() == TABLE_COLUMN);
63 }
64
canHaveChildren() const65 bool RenderTableCol::canHaveChildren() const
66 {
67 // Cols cannot have children. This is actually necessary to fix a bug
68 // with libraries.uc.edu, which makes a <p> be a table-column.
69 return style()->display() == TABLE_COLUMN_GROUP;
70 }
71
clippedOverflowRectForRepaint(RenderBox *)72 IntRect RenderTableCol::clippedOverflowRectForRepaint(RenderBox* /*repaintContainer*/)
73 {
74 // For now, just repaint the whole table.
75 // FIXME: Find a better way to do this, e.g., need to repaint all the cells that we
76 // might have propagated a background color or borders into.
77 // FIXME: check for repaintContainer each time here?
78 RenderObject* table = parent();
79 if (table && !table->isTable())
80 table = table->parent();
81 if (table && table->isTable())
82 return table->absoluteClippedOverflowRect();
83
84 return IntRect();
85 }
86
imageChanged(WrappedImagePtr,const IntRect *)87 void RenderTableCol::imageChanged(WrappedImagePtr, const IntRect*)
88 {
89 // FIXME: Repaint only the rect the image paints in.
90 repaint();
91 }
92
93 }
94