Commit 09208a7e authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[TablesNG] Make LayoutCaption NG compatible

LayoutNGCaptions can be created in both Legacy and NG tables.
Only Legacy tables require AddCaption/RemoveCaption calls.

Bug: 958381
Change-Id: I43131f66b794dc43bea41d6b39fdf66eac72aa86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363556
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799824}
parent d145615b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h"
#include "third_party/blink/renderer/core/layout/layout_analyzer.h" #include "third_party/blink/renderer/core/layout/layout_analyzer.h"
#include "third_party/blink/renderer/core/layout/layout_table.h"
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h"
#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h"
...@@ -53,6 +54,24 @@ void LayoutNGTableCaption::CalculateAndSetMargins( ...@@ -53,6 +54,24 @@ void LayoutNGTableCaption::CalculateAndSetMargins(
containing_block_style.Direction())); containing_block_style.Direction()));
} }
void LayoutNGTableCaption::InsertedIntoTree() {
LayoutBlockFlow::InsertedIntoTree();
LayoutNGTableInterface* table_interface = TableInterface();
if (!table_interface->ToLayoutObject()->IsLayoutNGMixin())
To<LayoutTable>(table_interface->ToMutableLayoutObject())->AddCaption(this);
}
void LayoutNGTableCaption::WillBeRemovedFromTree() {
LayoutBlockFlow::WillBeRemovedFromTree();
LayoutNGTableInterface* table_interface = TableInterface();
if (!table_interface->ToLayoutObject()->IsLayoutNGMixin()) {
To<LayoutTable>(table_interface->ToMutableLayoutObject())
->RemoveCaption(this);
}
}
void LayoutNGTableCaption::UpdateBlockLayout(bool relayout_children) { void LayoutNGTableCaption::UpdateBlockLayout(bool relayout_children) {
LayoutAnalyzer::BlockScope analyzer(*this); LayoutAnalyzer::BlockScope analyzer(*this);
...@@ -73,4 +92,8 @@ void LayoutNGTableCaption::UpdateBlockLayout(bool relayout_children) { ...@@ -73,4 +92,8 @@ void LayoutNGTableCaption::UpdateBlockLayout(bool relayout_children) {
"table algorithm doesn't exist yet!"; "table algorithm doesn't exist yet!";
} }
LayoutNGTableInterface* LayoutNGTableCaption::TableInterface() const {
return ToInterface<LayoutNGTableInterface>(Parent());
}
} // namespace blink } // namespace blink
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
namespace blink { namespace blink {
class LayoutNGTableInterface;
class CORE_EXPORT LayoutNGTableCaption final class CORE_EXPORT LayoutNGTableCaption final
: public LayoutNGBlockFlowMixin<LayoutTableCaption> { : public LayoutNGBlockFlowMixin<LayoutTableCaption> {
public: public:
...@@ -21,8 +23,15 @@ class CORE_EXPORT LayoutNGTableCaption final ...@@ -21,8 +23,15 @@ class CORE_EXPORT LayoutNGTableCaption final
const char* GetName() const override { return "LayoutNGTableCaption"; } const char* GetName() const override { return "LayoutNGTableCaption"; }
private: private:
// Legacy-only API.
void InsertedIntoTree() override;
// Legacy-only API.
void WillBeRemovedFromTree() override;
// Legacy-only API.
void CalculateAndSetMargins(const NGConstraintSpace&, void CalculateAndSetMargins(const NGConstraintSpace&,
const NGPhysicalFragment&); const NGPhysicalFragment&);
LayoutNGTableInterface* TableInterface() const;
}; };
// wtf/casting.h helper. // wtf/casting.h helper.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment