| 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, 2009 Apple Inc. All rights reserved. |
| 8 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 9 | * |
| 10 | * This library is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU Library General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This library is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * Library General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Library General Public License |
| 21 | * along with this library; see the file COPYING.LIB. If not, write to |
| 22 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 23 | * Boston, MA 02110-1301, USA. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #include "RenderBox.h" |
| 29 | |
| 30 | namespace WebCore { |
| 31 | |
| 32 | class RenderTable; |
| 33 | class RenderTableCell; |
| 34 | |
| 35 | class RenderTableCol final : public RenderBox { |
| 36 | WTF_MAKE_ISO_ALLOCATED(RenderTableCol); |
| 37 | public: |
| 38 | RenderTableCol(Element&, RenderStyle&&); |
| 39 | Element& element() const { return downcast<Element>(nodeForNonAnonymous()); } |
| 40 | |
| 41 | void clearPreferredLogicalWidthsDirtyBits(); |
| 42 | |
| 43 | unsigned span() const { return m_span; } |
| 44 | void setSpan(unsigned span) { m_span = span; } |
| 45 | |
| 46 | bool isTableColumnGroupWithColumnChildren() const { return firstChild(); } |
| 47 | bool isTableColumn() const { return style().display() == DisplayType::TableColumn; } |
| 48 | bool isTableColumnGroup() const { return style().display() == DisplayType::TableColumnGroup; } |
| 49 | |
| 50 | RenderTableCol* enclosingColumnGroup() const; |
| 51 | RenderTableCol* enclosingColumnGroupIfAdjacentBefore() const; |
| 52 | RenderTableCol* enclosingColumnGroupIfAdjacentAfter() const; |
| 53 | |
| 54 | // Returns the next column or column-group. |
| 55 | RenderTableCol* nextColumn() const; |
| 56 | |
| 57 | const BorderValue& borderAdjoiningCellStartBorder() const; |
| 58 | const BorderValue& borderAdjoiningCellEndBorder() const; |
| 59 | const BorderValue& borderAdjoiningCellBefore(const RenderTableCell&) const; |
| 60 | const BorderValue& borderAdjoiningCellAfter(const RenderTableCell&) const; |
| 61 | |
| 62 | LayoutUnit offsetLeft() const override; |
| 63 | LayoutUnit offsetTop() const override; |
| 64 | LayoutUnit offsetWidth() const override; |
| 65 | LayoutUnit offsetHeight() const override; |
| 66 | void updateFromElement() override; |
| 67 | |
| 68 | private: |
| 69 | const char* renderName() const override { return "RenderTableCol" ; } |
| 70 | bool isRenderTableCol() const override { return true; } |
| 71 | void computePreferredLogicalWidths() override { ASSERT_NOT_REACHED(); } |
| 72 | |
| 73 | void insertedIntoTree() override; |
| 74 | void willBeRemovedFromTree() override; |
| 75 | |
| 76 | bool isChildAllowed(const RenderObject&, const RenderStyle&) const override; |
| 77 | bool canHaveChildren() const override; |
| 78 | bool requiresLayer() const override { return false; } |
| 79 | |
| 80 | LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override; |
| 81 | void imageChanged(WrappedImagePtr, const IntRect* = 0) override; |
| 82 | |
| 83 | void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; |
| 84 | void paint(PaintInfo&, const LayoutPoint&) override { } |
| 85 | |
| 86 | RenderTable* table() const; |
| 87 | |
| 88 | unsigned m_span { 1 }; |
| 89 | }; |
| 90 | |
| 91 | inline RenderTableCol* RenderTableCol::enclosingColumnGroupIfAdjacentBefore() const |
| 92 | { |
| 93 | if (previousSibling()) |
| 94 | return nullptr; |
| 95 | return enclosingColumnGroup(); |
| 96 | } |
| 97 | |
| 98 | inline RenderTableCol* RenderTableCol::enclosingColumnGroupIfAdjacentAfter() const |
| 99 | { |
| 100 | if (nextSibling()) |
| 101 | return nullptr; |
| 102 | return enclosingColumnGroup(); |
| 103 | } |
| 104 | |
| 105 | } // namespace WebCore |
| 106 | |
| 107 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableCol, isRenderTableCol()) |
| 108 | |