Commit b18ebe26 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] Fix paint invalidation of LayoutText

Root cause of missing invalidations:
LayoutObject::AdjustStyleDifference was not marking LayoutText with NG rendering
as NeedPaintInvalidation. This caused invalidation not to propagate to document.
It was not marked because
LayoutObject:1789 ToLayoutText(this)->HasTextBoxes() always returned false for NG.

The fix was to make HasTextBoxes() NG-aware. This caused 2 callers
of HasTextBoxes() to behave incorrectly. Created HasLegacyTextBoxes(),
and added a TODO to remove them.

Bug: 819372
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: If2c4ddc0c9c707d11bb9115ef26ac578387c8359
Reviewed-on: https://chromium-review.googlesource.com/961526
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543885}
parent 0f1af763
...@@ -306,12 +306,25 @@ void LayoutText::DeleteTextBoxes() { ...@@ -306,12 +306,25 @@ void LayoutText::DeleteTextBoxes() {
Optional<FloatPoint> LayoutText::GetUpperLeftCorner() const { Optional<FloatPoint> LayoutText::GetUpperLeftCorner() const {
DCHECK(!IsBR()); DCHECK(!IsBR());
if (!HasTextBoxes()) // TODO(layoutng) Implement GetUpperLeftCorner for layoutng
if (!HasLegacyTextBoxes())
return WTF::nullopt; return WTF::nullopt;
return FloatPoint(LinesBoundingBox().X(), return FloatPoint(LinesBoundingBox().X(),
FirstTextBox()->Root().LineTop().ToFloat()); FirstTextBox()->Root().LineTop().ToFloat());
} }
bool LayoutText::HasTextBoxes() const {
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
auto fragments = NGPaintFragment::InlineFragmentsFor(this);
if (fragments.IsInLayoutNGInlineFormattingContext())
return !(fragments.begin() == fragments.end());
// When legacy is forced, IsInLayoutNGInlineFormattingContext is false,
// and we fall back to normal HasTextBox
return FirstTextBox();
}
return FirstTextBox();
}
scoped_refptr<StringImpl> LayoutText::OriginalText() const { scoped_refptr<StringImpl> LayoutText::OriginalText() const {
Node* e = GetNode(); Node* e = GetNode();
return (e && e->IsTextNode()) ? ToText(e)->DataImpl() : nullptr; return (e && e->IsTextNode()) ? ToText(e)->DataImpl() : nullptr;
...@@ -2298,7 +2311,7 @@ LayoutRect LayoutText::DebugRect() const { ...@@ -2298,7 +2311,7 @@ LayoutRect LayoutText::DebugRect() const {
LayoutRect(IntRect(first_run_offset.X(), first_run_offset.Y(), LayoutRect(IntRect(first_run_offset.X(), first_run_offset.Y(),
lines_box.Width(), lines_box.Height())); lines_box.Width(), lines_box.Height()));
LayoutBlock* block = ContainingBlock(); LayoutBlock* block = ContainingBlock();
if (block && HasTextBoxes()) if (block && HasLegacyTextBoxes())
block->AdjustChildDebugRect(rect); block->AdjustChildDebugRect(rect);
return rect; return rect;
......
...@@ -204,7 +204,11 @@ class CORE_EXPORT LayoutText : public LayoutObject { ...@@ -204,7 +204,11 @@ class CORE_EXPORT LayoutText : public LayoutObject {
// True if we have inline text box children which implies rendered text (or // True if we have inline text box children which implies rendered text (or
// whitespace) output. // whitespace) output.
bool HasTextBoxes() const { return FirstTextBox(); } bool HasTextBoxes() const;
// TODO(layoutng) Legacy-only implementation of HasTextBoxes.
// All callers should call HasTextBoxes instead, and take NG into account.
bool HasLegacyTextBoxes() const { return FirstTextBox(); }
// Returns the Position in DOM that corresponds to the given offset in the // Returns the Position in DOM that corresponds to the given offset in the
// |text_| string. // |text_| string.
......
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