Commit 451942a4 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Replace WTF::MakeUnique with std::make_unique on core/css/ and core/layout/

CL #2 out of 10.

Add include <memory> where needed according to "git cl lint".

Add some other include lines suggested by lint.

Bug: 755727
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Ie75a1450ad57bc283a57d777a050a103f361de8e
Reviewed-on: https://chromium-review.googlesource.com/765562Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516130}
parent 0657d7be
......@@ -74,16 +74,16 @@ static bool ExpressionCompare(const MediaQueryExp& a, const MediaQueryExp& b) {
}
std::unique_ptr<MediaQuery> MediaQuery::CreateNotAll() {
return WTF::MakeUnique<MediaQuery>(MediaQuery::kNot, MediaTypeNames::all,
ExpressionHeapVector());
return std::make_unique<MediaQuery>(MediaQuery::kNot, MediaTypeNames::all,
ExpressionHeapVector());
}
std::unique_ptr<MediaQuery> MediaQuery::Create(
RestrictorType restrictor,
String media_type,
ExpressionHeapVector expressions) {
return WTF::MakeUnique<MediaQuery>(restrictor, std::move(media_type),
std::move(expressions));
return std::make_unique<MediaQuery>(restrictor, std::move(media_type),
std::move(expressions));
}
MediaQuery::MediaQuery(RestrictorType restrictor,
......
......@@ -29,7 +29,9 @@
#ifndef MediaQuery_h
#define MediaQuery_h
#include <memory>
#include <utility>
#include "core/CoreExport.h"
#include "platform/heap/Handle.h"
#include "platform/wtf/Vector.h"
......@@ -61,7 +63,7 @@ class CORE_EXPORT MediaQuery {
String CssText() const;
std::unique_ptr<MediaQuery> Copy() const {
return WTF::MakeUnique<MediaQuery>(*this);
return std::make_unique<MediaQuery>(*this);
}
private:
......
......@@ -167,7 +167,7 @@ PendingInvalidations& StyleInvalidator::EnsurePendingInvalidations(
PendingInvalidationMap::AddResult add_result =
pending_invalidation_map_.insert(&node, nullptr);
if (add_result.is_new_entry)
add_result.stored_value->value = WTF::MakeUnique<PendingInvalidations>();
add_result.stored_value->value = std::make_unique<PendingInvalidations>();
return *add_result.stored_value->value;
}
......
......@@ -27,11 +27,11 @@
namespace blink {
CSSParserSelector::CSSParserSelector()
: selector_(WTF::MakeUnique<CSSSelector>()) {}
: selector_(std::make_unique<CSSSelector>()) {}
CSSParserSelector::CSSParserSelector(const QualifiedName& tag_q_name,
bool is_implicit)
: selector_(WTF::MakeUnique<CSSSelector>(tag_q_name, is_implicit)) {}
: selector_(std::make_unique<CSSSelector>(tag_q_name, is_implicit)) {}
CSSParserSelector::~CSSParserSelector() {
if (!tag_history_)
......@@ -101,7 +101,7 @@ void CSSParserSelector::PrependTagSelector(const QualifiedName& tag_q_name,
second->selector_ = std::move(selector_);
second->tag_history_ = std::move(tag_history_);
tag_history_ = std::move(second);
selector_ = WTF::MakeUnique<CSSSelector>(tag_q_name, is_implicit);
selector_ = std::make_unique<CSSSelector>(tag_q_name, is_implicit);
}
bool CSSParserSelector::IsHostPseudoSelector() const {
......
......@@ -44,7 +44,7 @@ class CORE_EXPORT CSSParserSelector {
}
static std::unique_ptr<CSSParserSelector> Create(const QualifiedName& name,
bool is_implicit = false) {
return WTF::MakeUnique<CSSParserSelector>(name, is_implicit);
return std::make_unique<CSSParserSelector>(name, is_implicit);
}
~CSSParserSelector();
......
......@@ -532,7 +532,7 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumePseudo(
DisallowPseudoElementsScope scope(this);
std::unique_ptr<CSSSelectorList> selector_list =
WTF::MakeUnique<CSSSelectorList>();
std::make_unique<CSSSelectorList>();
*selector_list = ConsumeCompoundSelectorList(block);
if (!selector_list->IsValid() || !block.AtEnd())
return nullptr;
......
......@@ -7,6 +7,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include <memory>
#include "platform/CrossThreadFunctional.h"
#include "platform/WaitableEvent.h"
#include "platform/WebTaskRunner.h"
......@@ -56,7 +58,7 @@ class MultiThreadedTest : public ::testing::Test {
for (int i = 0; i < num_threads_; ++i) {
threads.push_back(WebThreadSupportingGC::Create(""));
waits.push_back(WTF::MakeUnique<WaitableEvent>());
waits.push_back(std::make_unique<WaitableEvent>());
}
for (int i = 0; i < num_threads_; ++i) {
......
......@@ -1254,9 +1254,10 @@ double GridTrackSizingAlgorithm::ComputeFlexFactorUnitSize(
if (base_size > hypothetical_factor_unit_size * flex_factor) {
left_over_space -= base_size;
flex_factor_sum -= flex_factor;
if (!additional_tracks_to_treat_as_inflexible)
if (!additional_tracks_to_treat_as_inflexible) {
additional_tracks_to_treat_as_inflexible =
WTF::MakeUnique<TrackIndexSet>();
std::make_unique<TrackIndexSet>();
}
additional_tracks_to_treat_as_inflexible->insert(index);
valid_flex_factor_unit = false;
}
......@@ -1384,9 +1385,9 @@ void GridTrackSizingAlgorithm::Setup(GridTrackSizingDirection direction,
: available_space);
if (available_space) {
strategy_ = WTF::MakeUnique<DefiniteSizeStrategy>(*this);
strategy_ = std::make_unique<DefiniteSizeStrategy>(*this);
} else {
strategy_ = WTF::MakeUnique<IndefiniteSizeStrategy>(*this);
strategy_ = std::make_unique<IndefiniteSizeStrategy>(*this);
is_in_perform_layout_ =
layout_grid_->GetDocument().View()->IsInPerformLayout();
}
......
......@@ -2299,7 +2299,7 @@ void LayoutBlockFlow::SetMustDiscardMarginBefore(bool value) {
return;
if (!rare_data_)
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
rare_data_->discard_margin_before_ = value;
}
......@@ -2314,7 +2314,7 @@ void LayoutBlockFlow::SetMustDiscardMarginAfter(bool value) {
return;
if (!rare_data_)
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
rare_data_->discard_margin_after_ = value;
}
......@@ -2377,7 +2377,7 @@ void LayoutBlockFlow::SetMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg) {
if (pos == LayoutBlockFlowRareData::PositiveMarginBeforeDefault(this) &&
neg == LayoutBlockFlowRareData::NegativeMarginBeforeDefault(this))
return;
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
}
rare_data_->margins_.SetPositiveMarginBefore(pos);
rare_data_->margins_.SetNegativeMarginBefore(neg);
......@@ -2388,7 +2388,7 @@ void LayoutBlockFlow::SetMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) {
if (pos == LayoutBlockFlowRareData::PositiveMarginAfterDefault(this) &&
neg == LayoutBlockFlowRareData::NegativeMarginAfterDefault(this))
return;
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
}
rare_data_->margins_.SetPositiveMarginAfter(pos);
rare_data_->margins_.SetNegativeMarginAfter(neg);
......@@ -4288,7 +4288,7 @@ void LayoutBlockFlow::SetPaginationStrutPropagatedFromChild(LayoutUnit strut) {
if (!rare_data_) {
if (!strut)
return;
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
}
rare_data_->pagination_strut_propagated_from_child_ = strut;
}
......@@ -4297,7 +4297,7 @@ void LayoutBlockFlow::SetFirstForcedBreakOffset(LayoutUnit block_offset) {
if (!rare_data_) {
if (!block_offset)
return;
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
}
rare_data_->first_forced_break_offset_ = block_offset;
}
......@@ -4509,7 +4509,7 @@ LayoutBlockFlow::LayoutBlockFlowRareData& LayoutBlockFlow::EnsureRareData() {
if (rare_data_)
return *rare_data_;
rare_data_ = WTF::MakeUnique<LayoutBlockFlowRareData>(this);
rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this);
return *rare_data_;
}
......
......@@ -1582,7 +1582,7 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject {
LayoutBoxRareData& EnsureRareData() {
if (!rare_data_)
rare_data_ = WTF::MakeUnique<LayoutBoxRareData>();
rare_data_ = std::make_unique<LayoutBoxRareData>();
return *rare_data_.get();
}
......
......@@ -488,7 +488,7 @@ void LayoutBoxModelObject::InvalidateStickyConstraints() {
void LayoutBoxModelObject::CreateLayerAfterStyleChange() {
DCHECK(!HasLayer() && !Layer());
GetMutableForPainting().FirstFragment().EnsureRarePaintData().SetLayer(
WTF::MakeUnique<PaintLayer>(*this));
std::make_unique<PaintLayer>(*this));
SetHasLayer(true);
Layer()->InsertOnlyThisLayerAfterStyleChange();
}
......
......@@ -1783,7 +1783,7 @@ void LayoutGrid::UpdateBaselineAlignmentContextIfNeeded(
SelfAlignmentForChild(baseline_axis, child).GetPosition();
if (add_result.is_new_entry) {
add_result.stored_value->value =
WTF::MakeUnique<BaselineContext>(child, align, ascent, descent);
std::make_unique<BaselineContext>(child, align, ascent, descent);
} else {
auto* context = add_result.stored_value->value.get();
context->UpdateSharedGroup(child, align, ascent, descent);
......
......@@ -103,9 +103,9 @@ void LayoutTable::StyleDidChange(StyleDifference diff,
// explicit width is specified on the table. Auto width implies auto table
// layout.
if (Style()->IsFixedTableLayout())
table_layout_ = WTF::MakeUnique<TableLayoutAlgorithmFixed>(this);
table_layout_ = std::make_unique<TableLayoutAlgorithmFixed>(this);
else
table_layout_ = WTF::MakeUnique<TableLayoutAlgorithmAuto>(this);
table_layout_ = std::make_unique<TableLayoutAlgorithmAuto>(this);
}
if (!old_style)
......
......@@ -1059,7 +1059,7 @@ void LayoutTableCell::UpdateCollapsedBorderValues() const {
collapsed_border_values_valid_ = true;
auto new_values = WTF::MakeUnique<CollapsedBorderValues>(
auto new_values = std::make_unique<CollapsedBorderValues>(
ComputeCollapsedStartBorder(), ComputeCollapsedEndBorder(),
ComputeCollapsedBeforeBorder(), ComputeCollapsedAfterBorder());
......
......@@ -1299,7 +1299,7 @@ void InlineFlowBox::SetLayoutOverflow(const LayoutRect& rect,
return;
if (!overflow_)
overflow_ = WTF::MakeUnique<SimpleOverflowModel>(frame_box, frame_box);
overflow_ = std::make_unique<SimpleOverflowModel>(frame_box, frame_box);
overflow_->SetLayoutOverflow(rect);
}
......@@ -1311,7 +1311,7 @@ void InlineFlowBox::SetVisualOverflow(const LayoutRect& rect,
return;
if (!overflow_)
overflow_ = WTF::MakeUnique<SimpleOverflowModel>(frame_box, frame_box);
overflow_ = std::make_unique<SimpleOverflowModel>(frame_box, frame_box);
overflow_->SetVisualOverflow(rect);
}
......
......@@ -397,7 +397,7 @@ static std::unique_ptr<LayoutInline> CreateLayoutInline(
void (*initialize_style)(ComputedStyle*)) {
scoped_refptr<ComputedStyle> style(ComputedStyle::Create());
initialize_style(style.get());
std::unique_ptr<LayoutInline> node = WTF::MakeUnique<LayoutInline>(nullptr);
std::unique_ptr<LayoutInline> node = std::make_unique<LayoutInline>(nullptr);
node->SetStyleInternal(std::move(style));
return node;
}
......
......@@ -4,6 +4,11 @@
#include "core/layout/ng/inline/ng_inline_layout_algorithm.h"
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include "core/layout/ng/inline/ng_baseline.h"
#include "core/layout/ng/inline/ng_bidi_paragraph.h"
#include "core/layout/ng/inline/ng_inline_box_state.h"
......@@ -518,7 +523,7 @@ LayoutUnit NGInlineLayoutAlgorithm::ComputeContentSize(
scoped_refptr<NGLayoutResult> NGInlineLayoutAlgorithm::Layout() {
std::unique_ptr<NGExclusionSpace> initial_exclusion_space(
WTF::MakeUnique<NGExclusionSpace>(ConstraintSpace().ExclusionSpace()));
std::make_unique<NGExclusionSpace>(ConstraintSpace().ExclusionSpace()));
bool is_empty_inline = Node().IsEmptyInline();
......@@ -570,16 +575,16 @@ scoped_refptr<NGLayoutResult> NGInlineLayoutAlgorithm::Layout() {
// Copy the state stack from the unfinished break token if provided. This
// enforces the layout inputs immutability constraint. If we weren't
// provided with a break token we just create an empty state stack.
box_states_ = break_token ? WTF::MakeUnique<NGInlineLayoutStateStack>(
box_states_ = break_token ? std::make_unique<NGInlineLayoutStateStack>(
break_token->StateStack())
: WTF::MakeUnique<NGInlineLayoutStateStack>();
: std::make_unique<NGInlineLayoutStateStack>();
// Reset any state that may have been modified in a previous pass.
positioned_floats.clear();
unpositioned_floats_.clear();
container_builder_.Reset();
exclusion_space =
WTF::MakeUnique<NGExclusionSpace>(*initial_exclusion_space);
std::make_unique<NGExclusionSpace>(*initial_exclusion_space);
NGLineInfo line_info;
NGLineBreaker line_breaker(Node(), constraint_space_, &positioned_floats,
......
......@@ -4,6 +4,11 @@
#include "core/layout/ng/inline/ng_inline_node.h"
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include "core/layout/BidiRun.h"
#include "core/layout/LayoutMultiColumnFlowThread.h"
#include "core/layout/LayoutObject.h"
......@@ -444,7 +449,7 @@ const NGOffsetMapping* NGInlineNode::ComputeOffsetMappingIfNeeded() {
NGOffsetMappingBuilder& mapping_builder = builder.GetOffsetMappingBuilder();
mapping_builder.SetDestinationString(Text());
MutableData()->offset_mapping_ =
WTF::MakeUnique<NGOffsetMapping>(mapping_builder.Build());
std::make_unique<NGOffsetMapping>(mapping_builder.Build());
}
return Data().offset_mapping_.get();
......@@ -553,7 +558,7 @@ void NGInlineNode::ShapeTextForFirstLineIfNeeded(NGInlineNodeData* data) {
if (block_style == first_line_style)
return;
auto first_line_items = WTF::MakeUnique<Vector<NGInlineItem>>();
auto first_line_items = std::make_unique<Vector<NGInlineItem>>();
first_line_items->AppendVector(data->items_);
for (auto& item : *first_line_items) {
if (item.style_) {
......
......@@ -4,6 +4,9 @@
#include "core/layout/ng/layout_ng_mixin.h"
#include <memory>
#include <utility>
#include "core/layout/HitTestLocation.h"
#include "core/layout/ng/inline/ng_inline_fragment_iterator.h"
#include "core/layout/ng/inline/ng_inline_node_data.h"
......@@ -31,7 +34,7 @@ NGInlineNodeData* LayoutNGMixin<Base>::GetNGInlineNodeData() const {
template <typename Base>
void LayoutNGMixin<Base>::ResetNGInlineNodeData() {
ng_inline_node_data_ = WTF::MakeUnique<NGInlineNodeData>();
ng_inline_node_data_ = std::make_unique<NGInlineNodeData>();
}
// The current fragment from the last layout cycle for this box.
......@@ -141,7 +144,7 @@ LayoutNGMixin<Base>::CachedLayoutResultForTesting() {
template <typename Base>
void LayoutNGMixin<Base>::SetPaintFragment(
scoped_refptr<const NGPhysicalFragment> fragment) {
paint_fragment_ = WTF::MakeUnique<NGPaintFragment>(std::move(fragment));
paint_fragment_ = std::make_unique<NGPaintFragment>(std::move(fragment));
}
template <typename Base>
......
......@@ -4,6 +4,10 @@
#include "core/layout/ng/ng_block_layout_algorithm.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "core/layout/LayoutObject.h"
#include "core/layout/ng/inline/ng_inline_node.h"
#include "core/layout/ng/inline/ng_physical_line_box_fragment.h"
......@@ -810,7 +814,7 @@ bool NGBlockLayoutAlgorithm::HandleInflow(
if (layout_result->Status() == NGLayoutResult::kSuccess) {
DCHECK(layout_result->ExclusionSpace());
exclusion_space_ =
WTF::MakeUnique<NGExclusionSpace>(*layout_result->ExclusionSpace());
std::make_unique<NGExclusionSpace>(*layout_result->ExclusionSpace());
}
// A line-box may have a list of floats which we add as children.
......@@ -884,7 +888,7 @@ bool NGBlockLayoutAlgorithm::HandleInflow(
DCHECK(layout_result->ExclusionSpace());
exclusion_space_ =
WTF::MakeUnique<NGExclusionSpace>(*layout_result->ExclusionSpace());
std::make_unique<NGExclusionSpace>(*layout_result->ExclusionSpace());
}
// We must have an actual fragment at this stage.
......
......@@ -4,6 +4,9 @@
#include "core/layout/ng/ng_constraint_space.h"
#include <algorithm>
#include <memory>
#include "core/layout/LayoutBlock.h"
#include "core/layout/LayoutView.h"
#include "core/layout/ng/ng_constraint_space_builder.h"
......@@ -73,7 +76,7 @@ NGConstraintSpace::NGConstraintSpace(
margin_strut_(margin_strut),
bfc_offset_(bfc_offset),
floats_bfc_offset_(floats_bfc_offset),
exclusion_space_(WTF::MakeUnique<NGExclusionSpace>(exclusion_space)),
exclusion_space_(std::make_unique<NGExclusionSpace>(exclusion_space)),
clearance_offset_(clearance_offset) {
unpositioned_floats_.swap(unpositioned_floats);
baseline_requests_.swap(baseline_requests);
......
......@@ -3,6 +3,10 @@
// found in the LICENSE file.
#include "core/layout/ng/ng_layout_opportunity_iterator.h"
#include <algorithm>
#include <memory>
#include "core/layout/ng/ng_exclusion.h"
#include "core/layout/ng/ng_exclusion_space.h"
#include "platform/wtf/text/StringBuilder.h"
......@@ -208,7 +212,7 @@ void InsertExclusion(NGLayoutOpportunityTreeNode* node,
opportunities.push_back(top_layout_opp);
node->exclusions.push_back(exclusion);
node->combined_exclusion = WTF::MakeUnique<NGExclusion>(*exclusion);
node->combined_exclusion = std::make_unique<NGExclusion>(*exclusion);
return;
}
......
......@@ -54,7 +54,7 @@ namespace blink {
static std::unique_ptr<Shape> CreateInsetShape(const FloatRoundedRect& bounds) {
DCHECK_GE(bounds.Rect().Width(), 0);
DCHECK_GE(bounds.Rect().Height(), 0);
return WTF::MakeUnique<BoxShape>(bounds);
return std::make_unique<BoxShape>(bounds);
}
static std::unique_ptr<Shape> CreateCircleShape(const FloatPoint& center,
......@@ -221,7 +221,7 @@ std::unique_ptr<Shape> Shape::CreateShape(const BasicShape* basic_shape,
std::unique_ptr<Shape> Shape::CreateEmptyRasterShape(WritingMode writing_mode,
float margin) {
std::unique_ptr<RasterShapeIntervals> intervals =
WTF::MakeUnique<RasterShapeIntervals>(0, 0);
std::make_unique<RasterShapeIntervals>(0, 0);
std::unique_ptr<RasterShape> raster_shape =
WTF::WrapUnique(new RasterShape(std::move(intervals), IntSize()));
raster_shape->writing_mode_ = writing_mode;
......
......@@ -60,7 +60,7 @@ LayoutSVGShape::~LayoutSVGShape() {}
void LayoutSVGShape::CreatePath() {
if (!path_)
path_ = WTF::MakeUnique<Path>();
path_ = std::make_unique<Path>();
*path_ = ToSVGGeometryElement(GetElement())->AsPath();
if (rare_data_.get())
rare_data_->cached_non_scaling_stroke_path_.Clear();
......@@ -331,7 +331,7 @@ float LayoutSVGShape::StrokeWidth() const {
LayoutSVGShapeRareData& LayoutSVGShape::EnsureRareData() const {
if (!rare_data_)
rare_data_ = WTF::MakeUnique<LayoutSVGShapeRareData>();
rare_data_ = std::make_unique<LayoutSVGShapeRareData>();
return *rare_data_.get();
}
......
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