Commit d185acb6 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

RubyNG: Introduce LayoutNGRubyBase

- Make LayoutNGMixin<LayoutRubyBase> a friend of LayoutRubyBase because
  LayoutNGMixin<LayoutRubyBase> accesses some private functions.

- Add an Element* argument to LayoutRubyBase constructor.
  LayoutNGMixin assumes that the constructor of its base class has an
  Element* argument.

This CL has no behavior changes because changes are behind a
runtime flag.

Bug: 1069817
Change-Id: I0876d76efa8a66a39ba06b4c6df3ccd6f7e3f31d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2151378Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759550}
parent b225b380
...@@ -404,6 +404,8 @@ blink_core_sources("layout") { ...@@ -404,6 +404,8 @@ blink_core_sources("layout") {
"ng/layout_ng_progress.h", "ng/layout_ng_progress.h",
"ng/layout_ng_ruby_as_block.cc", "ng/layout_ng_ruby_as_block.cc",
"ng/layout_ng_ruby_as_block.h", "ng/layout_ng_ruby_as_block.h",
"ng/layout_ng_ruby_base.cc",
"ng/layout_ng_ruby_base.h",
"ng/layout_ng_ruby_run.cc", "ng/layout_ng_ruby_run.cc",
"ng/layout_ng_ruby_run.h", "ng/layout_ng_ruby_run.h",
"ng/layout_ng_table_caption.cc", "ng/layout_ng_table_caption.cc",
......
...@@ -30,16 +30,27 @@ ...@@ -30,16 +30,27 @@
#include "third_party/blink/renderer/core/layout/layout_ruby_base.h" #include "third_party/blink/renderer/core/layout/layout_ruby_base.h"
#include "third_party/blink/renderer/core/layout/layout_ruby_run.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_ruby_base.h"
namespace blink { namespace blink {
LayoutRubyBase::LayoutRubyBase() : LayoutBlockFlow(nullptr) { LayoutRubyBase::LayoutRubyBase(Element* element) : LayoutBlockFlow(nullptr) {
DCHECK(!element);
SetInline(false); SetInline(false);
} }
LayoutRubyBase::~LayoutRubyBase() = default; LayoutRubyBase::~LayoutRubyBase() = default;
LayoutRubyBase* LayoutRubyBase::CreateAnonymous(Document* document) { LayoutRubyBase* LayoutRubyBase::CreateAnonymous(Document* document,
LayoutRubyBase* layout_object = new LayoutRubyBase(); const LayoutRubyRun& ruby_run) {
LayoutRubyBase* layout_object;
if (ruby_run.IsLayoutNGObject()) {
DCHECK(RuntimeEnabledFeatures::LayoutNGRubyEnabled());
layout_object = new LayoutNGRubyBase();
} else {
layout_object = new LayoutRubyBase(nullptr);
}
layout_object->SetDocumentForAnonymous(document); layout_object->SetDocumentForAnonymous(document);
return layout_object; return layout_object;
} }
......
...@@ -36,11 +36,14 @@ ...@@ -36,11 +36,14 @@
namespace blink { namespace blink {
class LayoutRubyRun; class LayoutRubyRun;
template <typename Base>
class LayoutNGMixin;
class LayoutRubyBase final : public LayoutBlockFlow { class LayoutRubyBase : public LayoutBlockFlow {
public: public:
~LayoutRubyBase() override; ~LayoutRubyBase() override;
static LayoutRubyBase* CreateAnonymous(Document*); static LayoutRubyBase* CreateAnonymous(Document*,
const LayoutRubyRun& ruby_run);
const char* GetName() const override { return "LayoutRubyBase"; } const char* GetName() const override { return "LayoutRubyBase"; }
...@@ -51,7 +54,9 @@ class LayoutRubyBase final : public LayoutBlockFlow { ...@@ -51,7 +54,9 @@ class LayoutRubyBase final : public LayoutBlockFlow {
bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const override; bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const override;
private: private:
LayoutRubyBase(); // The argument must be nullptr. It's necessary for the LayoutNGMixin
// constructor.
explicit LayoutRubyBase(Element*);
ETextAlign TextAlignmentForLine(bool ends_with_soft_break) const override; ETextAlign TextAlignmentForLine(bool ends_with_soft_break) const override;
void AdjustInlineDirectionLineBounds( void AdjustInlineDirectionLineBounds(
...@@ -66,6 +71,7 @@ class LayoutRubyBase final : public LayoutBlockFlow { ...@@ -66,6 +71,7 @@ class LayoutRubyBase final : public LayoutBlockFlow {
void MoveBlockChildren(LayoutRubyBase* to_base, void MoveBlockChildren(LayoutRubyBase* to_base,
LayoutObject* before_child = nullptr); LayoutObject* before_child = nullptr);
friend class LayoutNGMixin<LayoutRubyBase>;
// Allow LayoutRubyRun to manipulate the children within ruby bases. // Allow LayoutRubyRun to manipulate the children within ruby bases.
friend class LayoutRubyRun; friend class LayoutRubyRun;
}; };
......
...@@ -184,7 +184,7 @@ void LayoutRubyRun::RemoveChild(LayoutObject* child) { ...@@ -184,7 +184,7 @@ void LayoutRubyRun::RemoveChild(LayoutObject* child) {
LayoutRubyBase* LayoutRubyRun::CreateRubyBase() const { LayoutRubyBase* LayoutRubyRun::CreateRubyBase() const {
LayoutRubyBase* layout_object = LayoutRubyBase* layout_object =
LayoutRubyBase::CreateAnonymous(&GetDocument()); LayoutRubyBase::CreateAnonymous(&GetDocument(), *this);
scoped_refptr<ComputedStyle> new_style = scoped_refptr<ComputedStyle> new_style =
ComputedStyle::CreateAnonymousStyleWithDisplay(StyleRef(), ComputedStyle::CreateAnonymousStyleWithDisplay(StyleRef(),
EDisplay::kBlock); EDisplay::kBlock);
......
...@@ -342,6 +342,7 @@ void LayoutNGBlockFlowMixin<Base>::UpdateMargins() { ...@@ -342,6 +342,7 @@ void LayoutNGBlockFlowMixin<Base>::UpdateMargins() {
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutBlockFlow>; template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutBlockFlow>;
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutProgress>; template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutProgress>;
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutRubyAsBlock>; template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutRubyAsBlock>;
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutRubyBase>;
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutRubyRun>; template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutRubyRun>;
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutTableCaption>; template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutTableCaption>;
template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutTableCell>; template class CORE_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutTableCell>;
......
...@@ -100,6 +100,8 @@ extern template class CORE_EXTERN_TEMPLATE_EXPORT ...@@ -100,6 +100,8 @@ extern template class CORE_EXTERN_TEMPLATE_EXPORT
LayoutNGBlockFlowMixin<LayoutProgress>; LayoutNGBlockFlowMixin<LayoutProgress>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT extern template class CORE_EXTERN_TEMPLATE_EXPORT
LayoutNGBlockFlowMixin<LayoutRubyAsBlock>; LayoutNGBlockFlowMixin<LayoutRubyAsBlock>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT
LayoutNGBlockFlowMixin<LayoutRubyBase>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT extern template class CORE_EXTERN_TEMPLATE_EXPORT
LayoutNGBlockFlowMixin<LayoutRubyRun>; LayoutNGBlockFlowMixin<LayoutRubyRun>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT extern template class CORE_EXTERN_TEMPLATE_EXPORT
......
...@@ -279,6 +279,7 @@ template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutBlock>; ...@@ -279,6 +279,7 @@ template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutBlock>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutBlockFlow>; template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutBlockFlow>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutProgress>; template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutProgress>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyAsBlock>; template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyAsBlock>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyBase>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyRun>; template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyRun>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutTableCaption>; template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutTableCaption>;
template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutTableCell>; template class CORE_TEMPLATE_EXPORT LayoutNGMixin<LayoutTableCell>;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/layout/layout_block_flow.h" #include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_progress.h" #include "third_party/blink/renderer/core/layout/layout_progress.h"
#include "third_party/blink/renderer/core/layout/layout_ruby.h" #include "third_party/blink/renderer/core/layout/layout_ruby.h"
#include "third_party/blink/renderer/core/layout/layout_ruby_base.h"
#include "third_party/blink/renderer/core/layout/layout_ruby_run.h" #include "third_party/blink/renderer/core/layout/layout_ruby_run.h"
#include "third_party/blink/renderer/core/layout/layout_table_caption.h" #include "third_party/blink/renderer/core/layout/layout_table_caption.h"
#include "third_party/blink/renderer/core/layout/layout_table_cell.h" #include "third_party/blink/renderer/core/layout/layout_table_cell.h"
...@@ -52,6 +53,7 @@ extern template class CORE_EXTERN_TEMPLATE_EXPORT ...@@ -52,6 +53,7 @@ extern template class CORE_EXTERN_TEMPLATE_EXPORT
extern template class CORE_EXTERN_TEMPLATE_EXPORT LayoutNGMixin<LayoutProgress>; extern template class CORE_EXTERN_TEMPLATE_EXPORT LayoutNGMixin<LayoutProgress>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT extern template class CORE_EXTERN_TEMPLATE_EXPORT
LayoutNGMixin<LayoutRubyAsBlock>; LayoutNGMixin<LayoutRubyAsBlock>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyBase>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyRun>; extern template class CORE_EXTERN_TEMPLATE_EXPORT LayoutNGMixin<LayoutRubyRun>;
extern template class CORE_EXTERN_TEMPLATE_EXPORT extern template class CORE_EXTERN_TEMPLATE_EXPORT
LayoutNGMixin<LayoutTableCaption>; LayoutNGMixin<LayoutTableCaption>;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/layout/ng/layout_ng_ruby_base.h"
namespace blink {
LayoutNGRubyBase::LayoutNGRubyBase()
: LayoutNGBlockFlowMixin<LayoutRubyBase>(nullptr) {}
LayoutNGRubyBase::~LayoutNGRubyBase() = default;
void LayoutNGRubyBase::UpdateBlockLayout(bool relayout_children) {
UpdateNGBlockLayout();
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_LAYOUT_NG_RUBY_BASE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_LAYOUT_NG_RUBY_BASE_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/layout_ruby_base.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow_mixin.h"
namespace blink {
// A LayoutNG version of LayoutRubyBase.
class CORE_EXPORT LayoutNGRubyBase final
: public LayoutNGBlockFlowMixin<LayoutRubyBase> {
public:
explicit LayoutNGRubyBase();
~LayoutNGRubyBase() override;
const char* GetName() const override { return "LayoutNGRubyBase"; }
void UpdateBlockLayout(bool relayout_children) override;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_LAYOUT_NG_RUBY_BASE_H_
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