Commit d31ddad9 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[NGFragmentItem] Implement TextType(), IsLineBreak() etc.

This patch implements |TextType()| and its utility functions
for |NGFragmentItem|. This fixes symbol marker and other
painting failures due to incorrect |TextType()|.

Only one is removed from FlagExpectation because the bot is
not ready yet. I will clean it up once the bot is ready.

Bug: 982194
Change-Id: Ic99c9eb564b002682fefdb590d42679dbedeae60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865738Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707053}
parent 858d1cf3
......@@ -14,8 +14,8 @@ NGFragmentItem::NGFragmentItem(const NGPhysicalTextFragment& text)
text_({text.TextShapeResult(), text.StartOffset(), text.EndOffset()}),
rect_({PhysicalOffset(), text.Size()}),
type_(kText),
sub_type_(static_cast<unsigned>(text.TextType())),
style_variant_(static_cast<unsigned>(text.StyleVariant())),
is_flow_control_(text.IsFlowControl()),
is_hidden_for_paint_(false),
text_direction_(static_cast<unsigned>(text.ResolvedDirection())) {
DCHECK_LE(text_.start_offset, text_.end_offset);
......
......@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_line_box_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_line_height_metrics.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item_client.h"
namespace blink {
......@@ -88,6 +89,7 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
return layout_object_->EffectiveStyle(StyleVariant());
}
const LayoutObject* GetLayoutObject() const { return layout_object_; }
Node* GetNode() const { return layout_object_->GetNode(); }
bool HasSameParent(const NGFragmentItem& other) const;
const PhysicalRect& Rect() const { return rect_; }
......@@ -116,8 +118,6 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
return nullptr;
}
Node* GetNode() const { return layout_object_->GetNode(); }
NGTextFragmentPaintInfo TextPaintInfo(const NGFragmentItems& items) const;
// DisplayItemClient overrides
......@@ -188,13 +188,6 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
return MutableForPainting(*this);
}
// Functions for |TextItem| and |GeneratedTextItem|
bool IsFlowControl() const {
DCHECK_EQ(Type(), kText);
return is_flow_control_;
}
bool IsHorizontal() const {
return IsHorizontalWritingMode(GetWritingMode());
}
......@@ -204,10 +197,32 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
return Style().GetWritingMode();
}
// TODO(yosin): We'll implement following functions.
bool IsLineBreak() const { return false; }
bool IsEllipsis() const { return false; }
bool IsSymbolMarker() const { return false; }
// Functions for |TextItem| and |GeneratedTextItem|
using NGTextType = NGPhysicalTextFragment::NGTextType;
NGTextType TextType() const {
DCHECK_EQ(Type(), kText);
return static_cast<NGTextType>(sub_type_);
}
// True if this is a forced line break.
bool IsLineBreak() const {
return TextType() == NGTextType::kForcedLineBreak;
}
// True if this is not for painting; i.e., a forced line break, a tabulation,
// or a soft-wrap opportunity.
bool IsFlowControl() const {
return IsLineBreak() || TextType() == NGTextType::kFlowControl;
}
// True if this is an ellpisis generated by `text-overflow: ellipsis`.
bool IsEllipsis() const {
return StyleVariant() == NGStyleVariant::kEllipsis;
}
bool IsSymbolMarker() const {
return TextType() == NGTextType::kSymbolMarker;
}
const ShapeResultView* TextShapeResult() const;
......@@ -289,10 +304,8 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
// Note: We should not add |bidi_level_| because it is used only for layout.
unsigned type_ : 2; // ItemType
unsigned sub_type_ : 3; // NGTextType
unsigned style_variant_ : 2; // NGStyleVariant
// TODO(yosin): We will change |is_flow_control_| to call |IsLineBreak()| and
// |TextType() == kFlowControl|.
unsigned is_flow_control_ : 1;
unsigned is_hidden_for_paint_ : 1;
// Note: For |TextItem| and |GeneratedTextItem|, |text_direction_| equals to
// |ShapeResult::Direction()|.
......
......@@ -112,7 +112,6 @@ crbug.com/982194 css1/classification/display.html [ Failure ]
crbug.com/982194 css1/classification/list_style.html [ Failure ]
crbug.com/982194 css1/classification/list_style_image.html [ Failure ]
crbug.com/982194 css1/classification/list_style_position.html [ Failure ]
crbug.com/982194 css1/classification/list_style_type.html [ Failure ]
crbug.com/982194 css1/formatting_model/floating_elements.html [ Failure ]
crbug.com/982194 css1/formatting_model/inline_elements.html [ Failure ]
crbug.com/982194 css1/pseudo/anchor.html [ Failure ]
......
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