diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-24 12:15:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 13:30:04 +0000 |
commit | b014812705fc80bff0a5c120dfcef88f349816dc (patch) | |
tree | 25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc | |
parent | 9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff) | |
download | qtwebengine-chromium-b014812705fc80bff0a5c120dfcef88f349816dc.tar.gz |
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc b/chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc index d7737d02982..61f6ccb7d1d 100644 --- a/chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc +++ b/chromium/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc @@ -30,6 +30,8 @@ #include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h" #include <memory> +#include "base/auto_reset.h" +#include "third_party/blink/renderer/core/frame/use_counter.h" #include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/layout/api/line_layout_block_flow.h" #include "third_party/blink/renderer/core/layout/floating_objects.h" @@ -37,7 +39,6 @@ #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/layout/layout_image.h" #include "third_party/blink/renderer/platform/length_functions.h" -#include "third_party/blink/renderer/platform/wtf/auto_reset.h" namespace blink { @@ -49,10 +50,22 @@ CSSBoxType ReferenceBox(const ShapeValue& shape_value) { void ShapeOutsideInfo::SetReferenceBoxLogicalSize( LayoutSize new_reference_box_logical_size) { + const Document& document = layout_box_.GetDocument(); bool is_horizontal_writing_mode = layout_box_.ContainingBlock()->Style()->IsHorizontalWritingMode(); + + LayoutSize margin_box_for_use_counter = new_reference_box_logical_size; + if (is_horizontal_writing_mode) { + margin_box_for_use_counter.Expand(layout_box_.MarginWidth(), + layout_box_.MarginHeight()); + } else { + margin_box_for_use_counter.Expand(layout_box_.MarginHeight(), + layout_box_.MarginWidth()); + } + switch (ReferenceBox(*layout_box_.Style()->ShapeOutside())) { case CSSBoxType::kMargin: + UseCounter::Count(document, WebFeature::kShapeOutsideMarginBox); if (is_horizontal_writing_mode) new_reference_box_logical_size.Expand(layout_box_.MarginWidth(), layout_box_.MarginHeight()); @@ -61,16 +74,25 @@ void ShapeOutsideInfo::SetReferenceBoxLogicalSize( layout_box_.MarginWidth()); break; case CSSBoxType::kBorder: + UseCounter::Count(document, WebFeature::kShapeOutsideBorderBox); break; case CSSBoxType::kPadding: + UseCounter::Count(document, WebFeature::kShapeOutsidePaddingBox); if (is_horizontal_writing_mode) new_reference_box_logical_size.Shrink(layout_box_.BorderWidth(), layout_box_.BorderHeight()); else new_reference_box_logical_size.Shrink(layout_box_.BorderHeight(), layout_box_.BorderWidth()); + + if (new_reference_box_logical_size != margin_box_for_use_counter) { + UseCounter::Count( + document, + WebFeature::kShapeOutsidePaddingBoxDifferentFromMarginBox); + } break; case CSSBoxType::kContent: + UseCounter::Count(document, WebFeature::kShapeOutsideContentBox); if (is_horizontal_writing_mode) new_reference_box_logical_size.Shrink( layout_box_.BorderAndPaddingWidth(), @@ -79,6 +101,12 @@ void ShapeOutsideInfo::SetReferenceBoxLogicalSize( new_reference_box_logical_size.Shrink( layout_box_.BorderAndPaddingHeight(), layout_box_.BorderAndPaddingWidth()); + + if (new_reference_box_logical_size != margin_box_for_use_counter) { + UseCounter::Count( + document, + WebFeature::kShapeOutsideContentBoxDifferentFromMarginBox); + } break; case CSSBoxType::kMissing: NOTREACHED(); @@ -93,6 +121,17 @@ void ShapeOutsideInfo::SetReferenceBoxLogicalSize( reference_box_logical_size_ = new_reference_box_logical_size; } +void ShapeOutsideInfo::SetPercentageResolutionInlineSize( + LayoutUnit percentage_resolution_inline_size) { + DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled()); + + if (percentage_resolution_inline_size_ == percentage_resolution_inline_size) + return; + + MarkShapeAsDirty(); + percentage_resolution_inline_size_ = percentage_resolution_inline_size; +} + static bool CheckShapeImageOrigin(Document& document, const StyleImage& style_image) { if (style_image.IsGeneratedImage()) @@ -160,24 +199,25 @@ const Shape& ShapeOutsideInfo::ComputedShape() const { if (Shape* shape = shape_.get()) return *shape; - AutoReset<bool> is_in_computing_shape(&is_computing_shape_, true); + base::AutoReset<bool> is_in_computing_shape(&is_computing_shape_, true); const ComputedStyle& style = *layout_box_.Style(); DCHECK(layout_box_.ContainingBlock()); - const ComputedStyle& containing_block_style = - *layout_box_.ContainingBlock()->Style(); + const LayoutBlock& containing_block = *layout_box_.ContainingBlock(); + const ComputedStyle& containing_block_style = containing_block.StyleRef(); WritingMode writing_mode = containing_block_style.GetWritingMode(); // Make sure contentWidth is not negative. This can happen when containing // block has a vertical scrollbar and its content is smaller than the // scrollbar width. - LayoutUnit maximum_value = - layout_box_.ContainingBlock() - ? std::max(LayoutUnit(), - layout_box_.ContainingBlock()->ContentWidth()) - : LayoutUnit(); - float margin = FloatValueForLength(layout_box_.Style()->ShapeMargin(), - maximum_value.ToFloat()); + LayoutUnit percentage_resolution_inline_size = + containing_block.IsLayoutNGMixin() + ? percentage_resolution_inline_size_ + : std::max(LayoutUnit(), containing_block.ContentWidth()); + + float margin = + FloatValueForLength(layout_box_.Style()->ShapeMargin(), + percentage_resolution_inline_size.ToFloat()); float shape_image_threshold = style.ShapeImageThreshold(); DCHECK(style.ShapeOutside()); @@ -365,8 +405,8 @@ ShapeOutsideDeltas ShapeOutsideInfo::ComputeDeltasForContainingBlockLine( containing_block.Style()->IsLeftToRightDirection() ? containing_block.MarginStartForChild(layout_box_) : containing_block.MarginEndForChild(layout_box_); - LayoutUnit raw_left_margin_box_delta( - segment.logical_left + LogicalLeftOffset() + logical_left_margin); + LayoutUnit raw_left_margin_box_delta = + segment.logical_left + LogicalLeftOffset() + logical_left_margin; LayoutUnit left_margin_box_delta = clampTo<LayoutUnit>( raw_left_margin_box_delta, LayoutUnit(), float_margin_box_width); @@ -374,10 +414,10 @@ ShapeOutsideDeltas ShapeOutsideInfo::ComputeDeltasForContainingBlockLine( containing_block.Style()->IsLeftToRightDirection() ? containing_block.MarginEndForChild(layout_box_) : containing_block.MarginStartForChild(layout_box_); - LayoutUnit raw_right_margin_box_delta( + LayoutUnit raw_right_margin_box_delta = segment.logical_right + LogicalLeftOffset() - containing_block.LogicalWidthForChild(layout_box_) - - logical_right_margin); + logical_right_margin; LayoutUnit right_margin_box_delta = clampTo<LayoutUnit>( raw_right_margin_box_delta, -float_margin_box_width, LayoutUnit()); |