Skip to content

Commit

Permalink
Revert of Modify Layout declarations to take extra parameters and ret…
Browse files Browse the repository at this point in the history
…urn an enum. (patchset chromium#2 id:20001 of https://codereview.chromium.org/2489243002/ )

Reason for revert:
This broke the build on many bots (see the findint entry; will try to add more info on the bug).

Original issue's description:
> Modify Layout declarations to take extra parameters and return an enum.
>
> Committed: https://crrev.com/e9f4dc8eca56e715cdfa62cf31e9ef5d58009c3a
> Cr-Commit-Position: refs/heads/master@{#431215}

TBR=ikilpatrick@chromium.org,shans@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2488733004
Cr-Commit-Position: refs/heads/master@{#431220}
  • Loading branch information
vabr authored and Commit bot committed Nov 10, 2016
1 parent 0ae3afa commit bec1438
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
DCHECK(style_);
}

NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
NGFragmentBase*,
NGPhysicalFragmentBase** fragment_out,
NGBox**) {
bool NGBlockLayoutAlgorithm::Layout(NGPhysicalFragmentBase** out) {
switch (state_) {
case kStateInit: {
border_and_padding_ =
Expand Down Expand Up @@ -200,20 +197,20 @@ NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
space_for_current_child_ = CreateConstraintSpaceForCurrentChild();

state_ = kStateChildLayout;
return NotFinished;
return false;
}
case kStateChildLayout: {
if (current_child_) {
if (!LayoutCurrentChild())
return NotFinished;
return false;
current_child_ = current_child_->NextSibling();
if (current_child_) {
space_for_current_child_ = CreateConstraintSpaceForCurrentChild();
return NotFinished;
return false;
}
}
state_ = kStateFinalize;
return NotFinished;
return false;
}
case kStateFinalize: {
content_size_ += border_and_padding_.block_end;
Expand All @@ -225,14 +222,14 @@ NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
builder_->SetBlockSize(block_size)
.SetInlineOverflow(max_inline_size_)
.SetBlockOverflow(content_size_);
*fragment_out = builder_->ToFragment();
*out = builder_->ToFragment();
state_ = kStateInit;
return NewFragment;
return true;
}
};
NOTREACHED();
*fragment_out = nullptr;
return NewFragment;
*out = nullptr;
return true;
}

bool NGBlockLayoutAlgorithm::LayoutCurrentChild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm {
NGConstraintSpace* space,
NGBreakToken* break_token = nullptr);

NGLayoutStatus Layout(NGFragmentBase*,
NGPhysicalFragmentBase**,
NGBox**) override;
bool Layout(NGPhysicalFragmentBase**) override;

DECLARE_VIRTUAL_TRACE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class NGBlockLayoutAlgorithmTest : public ::testing::Test {
NGBox* first_child) {
NGBlockLayoutAlgorithm algorithm(style_, first_child, space);
NGPhysicalFragmentBase* frag;
while (!algorithm.Layout(nullptr, &frag, nullptr))
while (!algorithm.Layout(&frag))
continue;
return toNGPhysicalFragment(frag);
}
Expand Down
6 changes: 3 additions & 3 deletions third_party/WebKit/Source/core/layout/ng/ng_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool NGBox::Layout(const NGConstraintSpace* constraint_space,
}

NGPhysicalFragmentBase* fragment = nullptr;
if (!layout_algorithm_->Layout(nullptr, &fragment, nullptr))
if (!layout_algorithm_->Layout(&fragment))
return false;
fragment_ = toNGPhysicalFragment(fragment);

Expand Down Expand Up @@ -125,7 +125,7 @@ bool NGBox::ComputeMinAndMaxContentSizes(MinAndMaxContentSizes* sizes) {

// Have to synthesize this value.
NGPhysicalFragmentBase* physical_fragment;
while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr))
while (!minmax_algorithm_->Layout(&physical_fragment))
continue;
NGFragment* fragment = new NGFragment(
FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(),
Expand All @@ -145,7 +145,7 @@ bool NGBox::ComputeMinAndMaxContentSizes(MinAndMaxContentSizes* sizes) {

minmax_algorithm_ =
new NGBlockLayoutAlgorithm(Style(), FirstChild(), constraint_space);
while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr))
while (!minmax_algorithm_->Layout(&physical_fragment))
continue;

fragment = new NGFragment(FromPlatformWritingMode(Style()->getWritingMode()),
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/core/layout/ng/ng_inline_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool NGInlineBox::Layout(const NGConstraintSpace* constraint_space,
layout_algorithm_ = new NGTextLayoutAlgorithm(this, child_constraint_space);

NGPhysicalFragmentBase* fragment = nullptr;
if (!layout_algorithm_->Layout(nullptr, &fragment, nullptr))
if (!layout_algorithm_->Layout(&fragment))
return false;

// TODO(layout-dev): Implement copying of fragment data to LayoutObject tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ NGInlineLayoutAlgorithm::NGInlineLayoutAlgorithm(
DCHECK(style_);
}

NGLayoutStatus NGInlineLayoutAlgorithm::Layout(
NGFragmentBase*,
NGPhysicalFragmentBase** fragment_out,
NGBox**) {
bool NGInlineLayoutAlgorithm::Layout(NGPhysicalFragmentBase** out) {
NGFragmentBuilder builder(NGPhysicalFragmentBase::FragmentBox);

*fragment_out = builder.ToFragment();
return NewFragment;
*out = builder.ToFragment();
return true;
}

DEFINE_TRACE(NGInlineLayoutAlgorithm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class CORE_EXPORT NGInlineLayoutAlgorithm : public NGLayoutAlgorithm {
NGConstraintSpace* space,
NGBreakToken* break_token = nullptr);

NGLayoutStatus Layout(NGFragmentBase*,
NGPhysicalFragmentBase**,
NGBox**) override;
bool Layout(NGPhysicalFragmentBase**) override;

DECLARE_VIRTUAL_TRACE();

Expand Down
15 changes: 4 additions & 11 deletions third_party/WebKit/Source/core/layout/ng/ng_layout_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
namespace blink {

struct MinAndMaxContentSizes;
class NGBox;
class NGConstraintSpace;
class NGPhysicalFragmentBase;

enum NGLayoutStatus { NotFinished, ChildAlgorithmRequired, NewFragment };

// Base class for all LayoutNG algorithms.
class CORE_EXPORT NGLayoutAlgorithm
: public GarbageCollectedFinalized<NGLayoutAlgorithm> {
Expand All @@ -33,14 +30,10 @@ class CORE_EXPORT NGLayoutAlgorithm
// resulting layout information.
// This function can not be const because for interruptible layout, we have
// to be able to store state information.
// If this function returns NotFinished, it has to be called again.
// If it returns ChildAlgorithmRequired, the NGBox out parameter will
// be set with the NGBox that needs to be layed out next.
// If it returns NewFragment, the NGPhysicalFragmentBase out parameter
// will contain the new fragment.
virtual NGLayoutStatus Layout(NGFragmentBase*,
NGPhysicalFragmentBase**,
NGBox**) = 0;
// Returns true when done; when this function returns false, it has to be
// called again. The out parameter will only be set when this function
// returns true.
virtual bool Layout(NGPhysicalFragmentBase**) = 0;

enum MinAndMaxState { Success, Pending, NotImplemented };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ NGTextLayoutAlgorithm::NGTextLayoutAlgorithm(
DCHECK(inline_box_);
}

NGLayoutStatus NGTextLayoutAlgorithm::Layout(
NGFragmentBase*,
NGPhysicalFragmentBase** fragment_out,
NGBox**) {
bool NGTextLayoutAlgorithm::Layout(NGPhysicalFragmentBase** out) {
// TODO(layout-dev): implement.
*fragment_out = nullptr;
return NewFragment;
*out = nullptr;
return true;
}

DEFINE_TRACE(NGTextLayoutAlgorithm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class CORE_EXPORT NGTextLayoutAlgorithm : public NGLayoutAlgorithm {
NGConstraintSpace* space,
NGBreakToken* break_token = nullptr);

NGLayoutStatus Layout(NGFragmentBase*,
NGPhysicalFragmentBase**,
NGBox**) override;
bool Layout(NGPhysicalFragmentBase**) override;

DECLARE_VIRTUAL_TRACE();

Expand Down

0 comments on commit bec1438

Please sign in to comment.