Commit ca07627f authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Use LayoutObjectFactory in LayoutBlock::CreateAnonymousWithParentAndDisplay().

Which object type to create depends on whether we are to use LayoutNG or
not. This was already working correctly for block flow, but not for
flexbox. Since we can no longer assume that a flexbox is of type
LayoutFlexibleBox (LayoutNGFlexibleBox inherits directly from
LayoutBlock), it would be impossible to call the protected method
SetDocumentForAnonymous() on a LayoutBlock from
LayoutFlexibleBox::CreateAnonymous(). So just move everything into
LayoutBlock::CreateAnonymousWithParentAndDisplay().

No behavior changes intended for block flows. For flexbox, on the other
hand, we're now able to create anonymous LayoutNGFlexibleBox objects,
This doesn't seem to affect any enabled tests, though.
Support for LayoutNGFlexibleBox is behind the LayoutNGFlexBox
runtime flag, which normally isn't enabled.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: If0d1b0607c65ac46253e9d91a77faafa1de6486d
Reviewed-on: https://chromium-review.googlesource.com/1100817Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567368}
parent 9bbcad05
......@@ -50,6 +50,7 @@
#include "third_party/blink/renderer/core/layout/layout_flow_thread.h"
#include "third_party/blink/renderer/core/layout/layout_grid.h"
#include "third_party/blink/renderer/core/layout/layout_multi_column_spanner_placeholder.h"
#include "third_party/blink/renderer/core/layout/layout_object_factory.h"
#include "third_party/blink/renderer/core/layout/layout_table_cell.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
......@@ -1955,13 +1956,18 @@ LayoutBlock* LayoutBlock::CreateAnonymousWithParentAndDisplay(
ComputedStyle::CreateAnonymousStyleWithDisplay(parent->StyleRef(),
new_display);
parent->UpdateAnonymousChildStyle(nullptr, *new_style);
LayoutBlock* layout_block;
if (new_display == EDisplay::kFlex) {
return LayoutFlexibleBox::CreateAnonymous(&parent->GetDocument(),
std::move(new_style));
layout_block = LayoutObjectFactory::CreateFlexibleBox(parent->GetDocument(),
*new_style);
} else {
DCHECK_EQ(new_display, EDisplay::kBlock);
layout_block =
LayoutObjectFactory::CreateBlockFlow(parent->GetDocument(), *new_style);
}
DCHECK_EQ(new_display, EDisplay::kBlock);
return LayoutBlockFlow::CreateAnonymous(&parent->GetDocument(),
std::move(new_style));
layout_block->SetDocumentForAnonymous(&parent->GetDocument());
layout_block->SetStyle(std::move(new_style));
return layout_block;
}
bool LayoutBlock::RecalcNormalFlowChildOverflowIfNeeded(
......
......@@ -65,15 +65,6 @@ LayoutFlexibleBox::LayoutFlexibleBox(Element* element)
LayoutFlexibleBox::~LayoutFlexibleBox() = default;
LayoutFlexibleBox* LayoutFlexibleBox::CreateAnonymous(
Document* document,
scoped_refptr<ComputedStyle> style) {
LayoutFlexibleBox* layout_object = new LayoutFlexibleBox(nullptr);
layout_object->SetDocumentForAnonymous(document);
layout_object->SetStyle(style);
return layout_object;
}
void LayoutFlexibleBox::ComputeIntrinsicLogicalWidths(
LayoutUnit& min_logical_width,
LayoutUnit& max_logical_width) const {
......
......@@ -46,9 +46,6 @@ class CORE_EXPORT LayoutFlexibleBox : public LayoutBlock {
LayoutFlexibleBox(Element*);
~LayoutFlexibleBox() override;
static LayoutFlexibleBox* CreateAnonymous(Document*,
scoped_refptr<ComputedStyle>);
const char* GetName() const override { return "LayoutFlexibleBox"; }
bool IsFlexibleBox() const final { return true; }
......
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