| 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 | * |
| 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 | #pragma once |
| 26 | |
| 27 | #include "RenderTableSection.h" |
| 28 | |
| 29 | namespace WebCore { |
| 30 | |
| 31 | static const unsigned unsetRowIndex = 0x7FFFFFFF; |
| 32 | static const unsigned maxRowIndex = 0x7FFFFFFE; // 2,147,483,646 |
| 33 | |
| 34 | class RenderTableRow final : public RenderBox { |
| 35 | WTF_MAKE_ISO_ALLOCATED(RenderTableRow); |
| 36 | public: |
| 37 | RenderTableRow(Element&, RenderStyle&&); |
| 38 | RenderTableRow(Document&, RenderStyle&&); |
| 39 | |
| 40 | RenderTableRow* nextRow() const; |
| 41 | RenderTableRow* previousRow() const; |
| 42 | |
| 43 | RenderTableCell* firstCell() const; |
| 44 | RenderTableCell* lastCell() const; |
| 45 | |
| 46 | RenderTable* table() const; |
| 47 | |
| 48 | void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&); |
| 49 | |
| 50 | static RenderPtr<RenderTableRow> createAnonymousWithParentRenderer(const RenderTableSection&); |
| 51 | RenderPtr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox&) const override; |
| 52 | |
| 53 | void setRowIndex(unsigned); |
| 54 | bool rowIndexWasSet() const { return m_rowIndex != unsetRowIndex; } |
| 55 | unsigned rowIndex() const; |
| 56 | |
| 57 | const BorderValue& borderAdjoiningTableStart() const; |
| 58 | const BorderValue& borderAdjoiningTableEnd() const; |
| 59 | const BorderValue& borderAdjoiningStartCell(const RenderTableCell&) const; |
| 60 | const BorderValue& borderAdjoiningEndCell(const RenderTableCell&) const; |
| 61 | |
| 62 | bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; |
| 63 | |
| 64 | RenderTableSection* section() const { return downcast<RenderTableSection>(parent()); } |
| 65 | |
| 66 | void didInsertTableCell(RenderTableCell& child, RenderObject* beforeChild); |
| 67 | |
| 68 | private: |
| 69 | static RenderPtr<RenderTableRow> createTableRowWithStyle(Document&, const RenderStyle&); |
| 70 | |
| 71 | const char* renderName() const override { return (isAnonymous() || isPseudoElement()) ? "RenderTableRow (anonymous)" : "RenderTableRow" ; } |
| 72 | |
| 73 | bool isTableRow() const override { return true; } |
| 74 | |
| 75 | bool canHaveChildren() const override { return true; } |
| 76 | void willBeRemovedFromTree() override; |
| 77 | |
| 78 | void layout() override; |
| 79 | LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override; |
| 80 | |
| 81 | bool requiresLayer() const override { return hasOverflowClip() || hasTransformRelatedProperty() || hasHiddenBackface() || hasClipPath() || createsGroup() || isStickilyPositioned(); } |
| 82 | |
| 83 | void paint(PaintInfo&, const LayoutPoint&) override; |
| 84 | |
| 85 | void imageChanged(WrappedImagePtr, const IntRect* = 0) override; |
| 86 | |
| 87 | void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; |
| 88 | |
| 89 | void firstChild() const = delete; |
| 90 | void lastChild() const = delete; |
| 91 | void nextSibling() const = delete; |
| 92 | void previousSibling() const = delete; |
| 93 | |
| 94 | unsigned m_rowIndex : 31; |
| 95 | }; |
| 96 | |
| 97 | inline void RenderTableRow::setRowIndex(unsigned rowIndex) |
| 98 | { |
| 99 | if (UNLIKELY(rowIndex > maxRowIndex)) |
| 100 | CRASH(); |
| 101 | m_rowIndex = rowIndex; |
| 102 | } |
| 103 | |
| 104 | inline unsigned RenderTableRow::rowIndex() const |
| 105 | { |
| 106 | ASSERT(rowIndexWasSet()); |
| 107 | return m_rowIndex; |
| 108 | } |
| 109 | |
| 110 | inline const BorderValue& RenderTableRow::borderAdjoiningTableStart() const |
| 111 | { |
| 112 | if (isDirectionSame(section(), table())) |
| 113 | return style().borderStart(); |
| 114 | return style().borderEnd(); |
| 115 | } |
| 116 | |
| 117 | inline const BorderValue& RenderTableRow::borderAdjoiningTableEnd() const |
| 118 | { |
| 119 | if (isDirectionSame(section(), table())) |
| 120 | return style().borderEnd(); |
| 121 | return style().borderStart(); |
| 122 | } |
| 123 | |
| 124 | inline RenderTable* RenderTableRow::table() const |
| 125 | { |
| 126 | RenderTableSection* section = this->section(); |
| 127 | if (!section) |
| 128 | return nullptr; |
| 129 | return downcast<RenderTable>(section->parent()); |
| 130 | } |
| 131 | |
| 132 | inline RenderTableRow* RenderTableRow::nextRow() const |
| 133 | { |
| 134 | return downcast<RenderTableRow>(RenderBox::nextSibling()); |
| 135 | } |
| 136 | |
| 137 | inline RenderTableRow* RenderTableRow::previousRow() const |
| 138 | { |
| 139 | return downcast<RenderTableRow>(RenderBox::previousSibling()); |
| 140 | } |
| 141 | |
| 142 | inline RenderTableRow* RenderTableSection::firstRow() const |
| 143 | { |
| 144 | return downcast<RenderTableRow>(RenderBox::firstChild()); |
| 145 | } |
| 146 | |
| 147 | inline RenderTableRow* RenderTableSection::lastRow() const |
| 148 | { |
| 149 | return downcast<RenderTableRow>(RenderBox::lastChild()); |
| 150 | } |
| 151 | |
| 152 | inline RenderPtr<RenderBox> RenderTableRow::createAnonymousBoxWithSameTypeAs(const RenderBox& renderer) const |
| 153 | { |
| 154 | return RenderTableRow::createTableRowWithStyle(renderer.document(), renderer.style()); |
| 155 | } |
| 156 | |
| 157 | } // namespace WebCore |
| 158 | |
| 159 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableRow, isTableRow()) |
| 160 | |