[LFC][TFC] Add rowSpan and colSpan to Box
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2019 15:11:53 +0000 (15:11 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2019 15:11:53 +0000 (15:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200654
<rdar://problem/54239281>

Reviewed by Antti Koivisto.

colSpan and rowSpan are not part of the RenderStyle. We eventually need to find a more appropriate place for the "random DOM things".

* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::setRowSpan):
(WebCore::Layout::Box::setColumnSpan):
(WebCore::Layout::Box::rowSpan const):
(WebCore::Layout::Box::columnSpan const):
* layout/layouttree/LayoutBox.h:
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createLayoutBox):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248594 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/layouttree/LayoutBox.cpp
Source/WebCore/layout/layouttree/LayoutBox.h
Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

index 8747511..59c4ec9 100644 (file)
@@ -1,3 +1,22 @@
+2019-08-13  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][TFC] Add rowSpan and colSpan to Box
+        https://bugs.webkit.org/show_bug.cgi?id=200654
+        <rdar://problem/54239281>
+
+        Reviewed by Antti Koivisto.
+
+        colSpan and rowSpan are not part of the RenderStyle. We eventually need to find a more appropriate place for the "random DOM things".
+
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::setRowSpan):
+        (WebCore::Layout::Box::setColumnSpan):
+        (WebCore::Layout::Box::rowSpan const):
+        (WebCore::Layout::Box::columnSpan const):
+        * layout/layouttree/LayoutBox.h:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createLayoutBox):
+
 2019-08-13  Youenn Fablet  <youenn@apple.com>
 
         Blob registries should be keyed by session IDs
index edf2d4b..8084e2b 100644 (file)
@@ -408,6 +408,30 @@ Replaced* Box::replaced()
     return rareData().replaced.get();
 }
 
+void Box::setRowSpan(unsigned rowSpan)
+{
+    ensureRareData().rowSpan = rowSpan;
+}
+
+void Box::setColumnSpan(unsigned columnSpan)
+{
+    ensureRareData().columnSpan = columnSpan;
+}
+
+unsigned Box::rowSpan() const
+{
+    if (!hasRareData())
+        return 1;
+    return rareData().rowSpan;
+}
+
+unsigned Box::columnSpan() const
+{
+    if (!hasRareData())
+        return 1;
+    return rareData().columnSpan;
+}
+
 Box::RareDataMap& Box::rareDataMap()
 {
     static NeverDestroyed<RareDataMap> map;
index 30c441d..76c6925 100644 (file)
@@ -146,6 +146,12 @@ public:
     bool hasTextContent() const;
     String textContent() const;
 
+    // FIXME: Find a better place for random DOM things.
+    void setRowSpan(unsigned);
+    void setColumnSpan(unsigned);
+    unsigned rowSpan() const;
+    unsigned columnSpan() const;
+
     void setParent(Container& parent) { m_parent = &parent; }
     void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }
     void setPreviousSibling(Box& previousSibling) { m_previousSibling = &previousSibling; }
@@ -163,6 +169,8 @@ private:
 
         String textContent;
         std::unique_ptr<Replaced> replaced;
+        unsigned rowSpan { 1 };
+        unsigned columnSpan { 1 };
     };
 
     bool hasRareData() const { return m_hasRareData; }
index 5feecee..0027dd0 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "DisplayBox.h"
 #include "DisplayRun.h"
+#include "HTMLTableCellElement.h"
 #include "InlineFormattingState.h"
 #include "LayoutBox.h"
 #include "LayoutChildIterator.h"
@@ -46,6 +47,7 @@
 #include "RenderStyle.h"
 #include "RenderTable.h"
 #include "RenderTableCaption.h"
+#include "RenderTableCell.h"
 #include "RenderView.h"
 #include <wtf/text/TextStream.h>
 
@@ -178,6 +180,18 @@ std::unique_ptr<Box> TreeBuilder::createLayoutBox(const RenderElement& parentRen
             return { };
         }
     }
+
+    if (is<RenderTableCell>(renderer)) {
+        auto& cellElement = downcast<HTMLTableCellElement>(*renderer.element());
+        auto rowSpan = cellElement.rowSpan();
+        if (rowSpan > 1)
+            childLayoutBox->setRowSpan(rowSpan);
+
+        auto columnSpan = cellElement.colSpan();
+        if (columnSpan > 1)
+            childLayoutBox->setColumnSpan(columnSpan);
+    }
+
     return childLayoutBox;
 }