diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-05 15:22:31 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-31 11:40:03 +0100 |
commit | e0d9f51b7c854b9496cfc983f8c72e3cfe38835b (patch) | |
tree | 835327ef786571cf36e8e0e91149d6ef06b7d3bf | |
parent | 52d3b56298fe498be2dcd225d702e97756610cc2 (diff) | |
download | qtwebengine-chromium-e0d9f51b7c854b9496cfc983f8c72e3cfe38835b.tar.gz |
Work-around MSVC bug with base::Optional<LayoutUnit>
For some reason it can't be passed by copy.
Change-Id: I76707f447c98bc4be8e6dfe0cd2c29f04e0b56fe
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
9 files changed, 24 insertions, 19 deletions
diff --git a/chromium/base/optional.h b/chromium/base/optional.h index 79b466c1fab..acb45423086 100644 --- a/chromium/base/optional.h +++ b/chromium/base/optional.h @@ -910,6 +910,11 @@ constexpr Optional<T> make_optional(std::initializer_list<U> il, return Optional<T>(in_place, il, std::forward<Args>(args)...); } +template<typename T> +constexpr Optional<T> pass_optional(const Optional<T> &opt) { + return opt ? make_optional(*opt) : nullopt; +} + // Partial specialization for a function template is not allowed. Also, it is // not allowed to add overload function to std namespace, while it is allowed // to specialize the template in std. Thus, swap() (kind of) overloading is diff --git a/chromium/third_party/blink/renderer/core/layout/layout_box.cc b/chromium/third_party/blink/renderer/core/layout/layout_box.cc index be772cbd111..01d833b82fa 100644 --- a/chromium/third_party/blink/renderer/core/layout/layout_box.cc +++ b/chromium/third_party/blink/renderer/core/layout/layout_box.cc @@ -2400,7 +2400,7 @@ scoped_refptr<const NGLayoutResult> LayoutBox::CachedLayoutResult( LayoutUnit bfc_line_offset = new_space.BfcOffset().line_offset; base::Optional<LayoutUnit> bfc_block_offset = - cached_layout_result->BfcBlockOffset(); + base::pass_optional(cached_layout_result->BfcBlockOffset()); LayoutUnit block_offset_delta; NGMarginStrut end_margin_strut = cached_layout_result->EndMarginStrut(); @@ -2503,7 +2503,7 @@ scoped_refptr<const NGLayoutResult> LayoutBox::CachedLayoutResult( scoped_refptr<const NGLayoutResult> new_result = base::AdoptRef(new NGLayoutResult(*cached_layout_result, new_space, end_margin_strut, bfc_line_offset, - bfc_block_offset, block_offset_delta)); + std::move(bfc_block_offset), block_offset_delta)); if (needs_cached_result_update) SetCachedLayoutResult(*new_result, break_token); diff --git a/chromium/third_party/blink/renderer/core/layout/layout_grid.cc b/chromium/third_party/blink/renderer/core/layout/layout_grid.cc index 65994667e48..54ad8819d1c 100644 --- a/chromium/third_party/blink/renderer/core/layout/layout_grid.cc +++ b/chromium/third_party/blink/renderer/core/layout/layout_grid.cc @@ -425,7 +425,7 @@ LayoutUnit LayoutGrid::GuttersSize( if (span <= 1) return LayoutUnit(); - LayoutUnit gap = GridGap(direction, available_size); + LayoutUnit gap = GridGap(direction, base::pass_optional(available_size)); // Fast path, no collapsing tracks. if (!grid.HasAutoRepeatEmptyTracks(direction)) @@ -668,7 +668,7 @@ size_t LayoutGrid::ComputeAutoRepeatTracksCount( // Add gutters as if there where only 1 auto repeat track. Gaps between auto // repeat tracks will be added later when computing the repetitions. - LayoutUnit gap_size = GridGap(direction, available_size); + LayoutUnit gap_size = GridGap(direction, available_size.value()); tracks_size += gap_size * (track_sizes.size() + auto_repeat_track_list_length - 1); @@ -764,7 +764,7 @@ void LayoutGrid::PlaceItemsOnGrid( kForRows, ConvertLayoutUnitToOptional( AvailableLogicalHeightForPercentageComputation())); size_t auto_repeat_columns = - ComputeAutoRepeatTracksCount(kForColumns, available_logical_width); + ComputeAutoRepeatTracksCount(kForColumns, base::pass_optional(available_logical_width)); auto_repeat_rows = ClampAutoRepeatTracks(kForRows, auto_repeat_rows); auto_repeat_columns = ClampAutoRepeatTracks(kForColumns, auto_repeat_columns); diff --git a/chromium/third_party/blink/renderer/core/layout/layout_table_section.cc b/chromium/third_party/blink/renderer/core/layout/layout_table_section.cc index f3b49bc2729..d8a4acb11ea 100644 --- a/chromium/third_party/blink/renderer/core/layout/layout_table_section.cc +++ b/chromium/third_party/blink/renderer/core/layout/layout_table_section.cc @@ -2013,7 +2013,7 @@ void LayoutTableSection::AdjustRowForPagination(LayoutTableRow& row_object, row_is_at_top_of_column = !offset_from_top_of_page || offset_from_top_of_page <= OffsetForRepeatedHeader() || - offset_from_top_of_page <= Table()->VBorderSpacing(); + offset_from_top_of_page <= LayoutUnit(Table()->VBorderSpacing()); } if (!row_is_at_top_of_column) diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc b/chromium/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc index 07d9515ee0f..276f79b97aa 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc @@ -375,7 +375,7 @@ NGLogicalOutOfFlowPosition ComputePartialAbsoluteWithChildInlineSize( max_inline_size, static_position.offset.inline_offset, static_position.inline_edge == NGLogicalStaticPosition::InlineEdge::kInlineStart, - is_start_dominant, false /* is_block_direction */, inline_size, + is_start_dominant, false /* is_block_direction */, base::pass_optional(inline_size), &position.size.inline_size, &position.inset.inline_start, &position.inset.inline_end, &position.margins.inline_start, &position.margins.inline_end); @@ -439,7 +439,7 @@ void ComputeFullAbsoluteWithChildBlockSize( min_block_size, max_block_size, static_position.offset.block_offset, static_position.block_edge == NGLogicalStaticPosition::BlockEdge::kBlockStart, - is_start_dominant, true /* is_block_direction */, block_size, + is_start_dominant, true /* is_block_direction */, base::pass_optional(block_size), &position->size.block_size, &position->inset.block_start, &position->inset.block_end, &position->margins.block_start, &position->margins.block_end); diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc index 13114b5c084..56578321384 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc @@ -1446,7 +1446,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::HandleInflow( /* is_new_fc */ false); NGConstraintSpace child_space = CreateConstraintSpaceForChild( child, child_data, child_available_size_, /* is_new_fc */ false, - forced_bfc_block_offset, has_clearance_past_adjoining_floats); + base::pass_optional(forced_bfc_block_offset), has_clearance_past_adjoining_floats); scoped_refptr<const NGLayoutResult> layout_result = LayoutInflow(child_space, child_break_token, early_break_, &child, inline_child_layout_context); @@ -1472,7 +1472,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow( NGInlineChildLayoutContext* inline_child_layout_context, scoped_refptr<const NGInlineBreakToken>* previous_inline_break_token) { base::Optional<LayoutUnit> child_bfc_block_offset = - layout_result->BfcBlockOffset(); + base::pass_optional(layout_result->BfcBlockOffset()); bool is_self_collapsing = layout_result->IsSelfCollapsing(); @@ -1624,7 +1624,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow( child_bfc_block_offset) { NGConstraintSpace new_child_space = CreateConstraintSpaceForChild( child, *child_data, child_available_size_, /* is_new_fc */ false, - child_bfc_block_offset); + base::pass_optional(child_bfc_block_offset)); layout_result = LayoutInflow(new_child_space, child_break_token, early_break_, &child, inline_child_layout_context); @@ -1639,7 +1639,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow( DCHECK(child_bfc_block_offset); new_child_space = CreateConstraintSpaceForChild( child, *child_data, child_available_size_, /* is_new_fc */ false, - child_bfc_block_offset); + base::pass_optional(child_bfc_block_offset)); layout_result = LayoutInflow(new_child_space, child_break_token, early_break_, &child, inline_child_layout_context); @@ -1684,7 +1684,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow( NGFragment fragment(ConstraintSpace().GetWritingMode(), physical_fragment); LogicalOffset logical_offset = CalculateLogicalOffset( - fragment, layout_result->BfcLineOffset(), child_bfc_block_offset); + fragment, layout_result->BfcLineOffset(), base::pass_optional(child_bfc_block_offset)); if (ConstraintSpace().HasBlockFragmentation()) { // Floats only cause container separation for the outermost block child that @@ -1727,7 +1727,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow( } *previous_inflow_position = ComputeInflowPosition( - *previous_inflow_position, child, *child_data, child_bfc_block_offset, + *previous_inflow_position, child, *child_data, base::pass_optional(child_bfc_block_offset), logical_offset, *layout_result, fragment, self_collapsing_child_had_clearance); diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_block_node.cc b/chromium/third_party/blink/renderer/core/layout/ng/ng_block_node.cc index 32e6ad5c630..ff6509c2b53 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_block_node.cc @@ -1226,7 +1226,7 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::RunLegacyLayout( if (needs_cached_result_update) { layout_result = base::AdoptRef(new NGLayoutResult( *layout_result, constraint_space, layout_result->EndMarginStrut(), - layout_result->BfcLineOffset(), layout_result->BfcBlockOffset(), + layout_result->BfcLineOffset(), base::pass_optional(layout_result->BfcBlockOffset()), LayoutUnit() /* block_offset_delta */)); box_->SetCachedLayoutResult(*layout_result, /* break_token */ nullptr); } diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h b/chromium/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h index eb57e54cc5d..d4b749c8d34 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h @@ -429,14 +429,14 @@ class CORE_EXPORT NGConstraintSpace final { // This value should be propagated to child layouts if the current layout // hasn't resolved its BFC offset yet. base::Optional<LayoutUnit> ForcedBfcBlockOffset() const { - return HasRareData() ? rare_data_->ForcedBfcBlockOffset() : base::nullopt; + return HasRareData() ? base::pass_optional(rare_data_->ForcedBfcBlockOffset()) : base::nullopt; } // If present, this is a hint as to where place any adjoining objects. This // isn't necessarily the final position, just where they ended up in a // previous layout pass. base::Optional<LayoutUnit> OptimisticBfcBlockOffset() const { - return HasRareData() ? rare_data_->OptimisticBfcBlockOffset() + return HasRareData() ? base::pass_optional(rare_data_->OptimisticBfcBlockOffset()) : base::nullopt; } diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_layout_result.h b/chromium/third_party/blink/renderer/core/layout/ng/ng_layout_result.h index 46123a06de0..7ef0b8f9d23 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/ng_layout_result.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_layout_result.h @@ -116,7 +116,7 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> { const base::Optional<LayoutUnit> BfcBlockOffset() const { if (HasRareData()) - return rare_data_->bfc_block_offset; + return base::pass_optional(rare_data_->bfc_block_offset); if (bitfields_.has_oof_positioned_offset) { DCHECK(physical_fragment_->IsOutOfFlowPositioned()); @@ -321,7 +321,7 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> { RareData(LayoutUnit bfc_line_offset, base::Optional<LayoutUnit> bfc_block_offset) : bfc_line_offset(bfc_line_offset), - bfc_block_offset(bfc_block_offset) {} + bfc_block_offset(base::pass_optional(bfc_block_offset)) {} LayoutUnit bfc_line_offset; base::Optional<LayoutUnit> bfc_block_offset; |