0

[text-combine] Make Text node children of <html> element to work

This patch changes |PropagateWritingModeAndDirectionFromBody()| in
|HTMLHtmlElement| to handle combined text for propagate valid style
to |Text| node child of <html> element.

Bug: 1241194
Change-Id: I89b05b228466528879a4aba8f8dcf078205f7426
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3115929
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#914673}
This commit is contained in:
Yoshifumi Inoue
2021-08-24 09:34:54 +00:00
committed by Chromium LUCI CQ
parent fb0d59033b
commit 65b7d78b17
2 changed files with 38 additions and 3 deletions
third_party/blink/renderer/core

@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_text_combine.h"
#include "third_party/blink/renderer/core/loader/appcache/application_cache_host_for_frame.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
@ -173,10 +174,18 @@ void HTMLHtmlElement::PropagateWritingModeAndDirectionFromBody() {
for (Node* node = firstChild(); node; node = node->nextSibling()) {
if (!node->IsTextNode() || node->NeedsReattachLayoutTree())
continue;
if (LayoutObject* layout_text = node->GetLayoutObject())
layout_text->SetStyle(new_style);
LayoutObject* const layout_text = node->GetLayoutObject();
if (!layout_text)
continue;
auto* const text_combine =
DynamicTo<LayoutNGTextCombine>(layout_text->Parent());
if (UNLIKELY(text_combine)) {
layout_text->SetStyle(text_combine->Style());
continue;
}
layout_text->SetStyle(new_style);
}
}
}
}
} // namespace blink

@ -166,6 +166,32 @@ LayoutNGBlockFlow DIV id="root"
ToSimpleLayoutTree(root_layout_object));
}
// http://crbug.com/1241194
TEST_F(LayoutNGTextCombineTest, HtmlElement) {
InsertStyleElement(
"html {"
"text-combine-upright: all;"
"writing-mode: vertical-lr;"
"}");
// Make |Text| node child in <html> element to call
// |HTMLHtmlElement::PropagateWritingModeAndDirectionFromBody()|
GetDocument().documentElement()->appendChild(
Text::Create(GetDocument(), "X"));
RunDocumentLifecycle();
EXPECT_EQ(
R"DUMP(
LayoutNGBlockFlow HTML
+--LayoutNGBlockFlow BODY
+--LayoutNGBlockFlow (anonymous)
| +--LayoutNGTextCombine (anonymous)
| | +--LayoutText #text "X"
)DUMP",
ToSimpleLayoutTree(*GetDocument().documentElement()->GetLayoutObject()));
}
TEST_F(LayoutNGTextCombineTest, InkOverflow) {
LoadAhem();
InsertStyleElement(