Commit 1838ccb6 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Pass layout result by reference instead of via scoped_refptr

To avoid a useless reference add/decrease

R=eae@chromium.org

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: Ic1c7fe92164a4249ce7b5c8642bd5efa7a5c8e1d
Reviewed-on: https://chromium-review.googlesource.com/1217713Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590365}
parent 5de631d1
...@@ -2532,13 +2532,14 @@ scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResult( ...@@ -2532,13 +2532,14 @@ scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResult(
return nullptr; return nullptr;
} }
scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResultForTesting() { scoped_refptr<const NGLayoutResult>
LayoutBlockFlow::CachedLayoutResultForTesting() {
return nullptr; return nullptr;
} }
void LayoutBlockFlow::SetCachedLayoutResult(const NGConstraintSpace&, void LayoutBlockFlow::SetCachedLayoutResult(const NGConstraintSpace&,
NGBreakToken*, const NGBreakToken*,
scoped_refptr<NGLayoutResult>) {} const NGLayoutResult&) {}
void LayoutBlockFlow::SetPaintFragment(const NGBreakToken*, void LayoutBlockFlow::SetPaintFragment(const NGBreakToken*,
scoped_refptr<const NGPhysicalFragment>, scoped_refptr<const NGPhysicalFragment>,
......
...@@ -455,10 +455,10 @@ class CORE_EXPORT LayoutBlockFlow : public LayoutBlock { ...@@ -455,10 +455,10 @@ class CORE_EXPORT LayoutBlockFlow : public LayoutBlock {
virtual scoped_refptr<NGLayoutResult> CachedLayoutResult( virtual scoped_refptr<NGLayoutResult> CachedLayoutResult(
const NGConstraintSpace&, const NGConstraintSpace&,
NGBreakToken*) const; NGBreakToken*) const;
virtual scoped_refptr<NGLayoutResult> CachedLayoutResultForTesting(); virtual scoped_refptr<const NGLayoutResult> CachedLayoutResultForTesting();
virtual void SetCachedLayoutResult(const NGConstraintSpace&, virtual void SetCachedLayoutResult(const NGConstraintSpace&,
NGBreakToken*, const NGBreakToken*,
scoped_refptr<NGLayoutResult>); const NGLayoutResult&);
virtual void WillCollectInlines() {} virtual void WillCollectInlines() {}
virtual void SetPaintFragment(const NGBreakToken*, virtual void SetPaintFragment(const NGBreakToken*,
scoped_refptr<const NGPhysicalFragment>, scoped_refptr<const NGPhysicalFragment>,
......
...@@ -232,9 +232,9 @@ scoped_refptr<NGLayoutResult> LayoutNGMixin<Base>::CachedLayoutResult( ...@@ -232,9 +232,9 @@ scoped_refptr<NGLayoutResult> LayoutNGMixin<Base>::CachedLayoutResult(
template <typename Base> template <typename Base>
void LayoutNGMixin<Base>::SetCachedLayoutResult( void LayoutNGMixin<Base>::SetCachedLayoutResult(
const NGConstraintSpace& constraint_space, const NGConstraintSpace& constraint_space,
NGBreakToken* break_token, const NGBreakToken* break_token,
scoped_refptr<NGLayoutResult> layout_result) { const NGLayoutResult& layout_result) {
if (break_token || layout_result->Status() != NGLayoutResult::kSuccess) { if (break_token || layout_result.Status() != NGLayoutResult::kSuccess) {
// We can't cache these yet // We can't cache these yet
return; return;
} }
...@@ -242,11 +242,11 @@ void LayoutNGMixin<Base>::SetCachedLayoutResult( ...@@ -242,11 +242,11 @@ void LayoutNGMixin<Base>::SetCachedLayoutResult(
return; return;
Base::cached_constraint_space_ = &constraint_space; Base::cached_constraint_space_ = &constraint_space;
cached_result_ = layout_result; cached_result_ = &layout_result;
} }
template <typename Base> template <typename Base>
scoped_refptr<NGLayoutResult> scoped_refptr<const NGLayoutResult>
LayoutNGMixin<Base>::CachedLayoutResultForTesting() { LayoutNGMixin<Base>::CachedLayoutResultForTesting() {
return cached_result_; return cached_result_;
} }
......
...@@ -62,10 +62,10 @@ class LayoutNGMixin : public Base { ...@@ -62,10 +62,10 @@ class LayoutNGMixin : public Base {
NGBreakToken*) const override; NGBreakToken*) const override;
void SetCachedLayoutResult(const NGConstraintSpace&, void SetCachedLayoutResult(const NGConstraintSpace&,
NGBreakToken*, const NGBreakToken*,
scoped_refptr<NGLayoutResult>) override; const NGLayoutResult&) override;
// For testing only. // For testing only.
scoped_refptr<NGLayoutResult> CachedLayoutResultForTesting() override; scoped_refptr<const NGLayoutResult> CachedLayoutResultForTesting() override;
NGPaintFragment* PaintFragment() const override { NGPaintFragment* PaintFragment() const override {
return paint_fragment_.get(); return paint_fragment_.get();
...@@ -100,7 +100,7 @@ class LayoutNGMixin : public Base { ...@@ -100,7 +100,7 @@ class LayoutNGMixin : public Base {
std::unique_ptr<NGInlineNodeData> ng_inline_node_data_; std::unique_ptr<NGInlineNodeData> ng_inline_node_data_;
scoped_refptr<NGLayoutResult> cached_result_; scoped_refptr<const NGLayoutResult> cached_result_;
scoped_refptr<NGPaintFragment> paint_fragment_; scoped_refptr<NGPaintFragment> paint_fragment_;
friend class NGBaseLayoutAlgorithmTest; friend class NGBaseLayoutAlgorithmTest;
......
...@@ -176,7 +176,7 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout( ...@@ -176,7 +176,7 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout(
// In particular, that fragment would have an incorrect offset if we // In particular, that fragment would have an incorrect offset if we
// don't re-set the result here. // don't re-set the result here.
ToLayoutBlockFlow(box_)->SetCachedLayoutResult( ToLayoutBlockFlow(box_)->SetCachedLayoutResult(
constraint_space, break_token, layout_result); constraint_space, break_token, *layout_result);
if (!constraint_space.IsIntermediateLayout() && first_child && if (!constraint_space.IsIntermediateLayout() && first_child &&
first_child.IsInline()) { first_child.IsInline()) {
block_flow->UpdatePaintFragmentFromCachedLayoutResult( block_flow->UpdatePaintFragmentFromCachedLayoutResult(
...@@ -256,7 +256,7 @@ void NGBlockNode::FinishLayout(const NGConstraintSpace& constraint_space, ...@@ -256,7 +256,7 @@ void NGBlockNode::FinishLayout(const NGConstraintSpace& constraint_space,
if (box_->IsLayoutNGMixin()) { if (box_->IsLayoutNGMixin()) {
LayoutBlockFlow* block_flow = ToLayoutBlockFlow(box_); LayoutBlockFlow* block_flow = ToLayoutBlockFlow(box_);
block_flow->SetCachedLayoutResult(constraint_space, break_token, block_flow->SetCachedLayoutResult(constraint_space, break_token,
layout_result); *layout_result);
NGLayoutInputNode first_child = FirstChild(); NGLayoutInputNode first_child = FirstChild();
if (first_child && first_child.IsInline()) { if (first_child && first_child.IsInline()) {
CopyFragmentDataToLayoutBoxForInlineChildren( CopyFragmentDataToLayoutBoxForInlineChildren(
......
...@@ -60,7 +60,7 @@ TEST_F(NGOutOfFlowLayoutPartTest, FixedInsideAbs) { ...@@ -60,7 +60,7 @@ TEST_F(NGOutOfFlowLayoutPartTest, FixedInsideAbs) {
LayoutBlockFlow* block_flow = ToLayoutBlockFlow(rel->GetLayoutObject()); LayoutBlockFlow* block_flow = ToLayoutBlockFlow(rel->GetLayoutObject());
scoped_refptr<NGConstraintSpace> space = scoped_refptr<NGConstraintSpace> space =
NGConstraintSpace::CreateFromLayoutObject(*block_flow); NGConstraintSpace::CreateFromLayoutObject(*block_flow);
scoped_refptr<NGLayoutResult> result = scoped_refptr<const NGLayoutResult> result =
block_flow->CachedLayoutResultForTesting(); block_flow->CachedLayoutResultForTesting();
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(result->OutOfFlowPositionedDescendants().size(), (size_t)2); EXPECT_EQ(result->OutOfFlowPositionedDescendants().size(), (size_t)2);
......
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