Commit 04b1b678 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Make -webkit-text-orientation a surrogate of text-orientation

This is not marked as a surrogate currently, which means that it
won't cascade correctly along with text-orientation in some cases.

Change-Id: Ieee83f5176b568c9fbb75b4d6044f266a17357c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210354Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771552}
parent c1551ef1
......@@ -985,8 +985,9 @@
property_methods: ["CSSValueFromComputedStyleInternal"],
inherited: true,
type_name: "TextOrientation",
style_builder_custom_functions: ["value"],
style_builder_custom_functions: ["initial", "inherit", "value"],
priority: "High",
surrogate_for: "text-orientation",
},
{
name: "writing-mode",
......
......@@ -7809,6 +7809,15 @@ const CSSValue* WebkitTextOrientation::CSSValueFromComputedStyleInternal(
return CSSIdentifierValue::Create(style.GetTextOrientation());
}
void WebkitTextOrientation::ApplyInitial(StyleResolverState& state) const {
state.SetTextOrientation(
ComputedStyleInitialValues::InitialTextOrientation());
}
void WebkitTextOrientation::ApplyInherit(StyleResolverState& state) const {
state.SetTextOrientation(state.ParentStyle()->GetTextOrientation());
}
void WebkitTextOrientation::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.SetTextOrientation(
......
......@@ -48,26 +48,33 @@ TEST_F(StyleBuilderTest, WritingModeChangeDirtiesFont) {
}
TEST_F(StyleBuilderTest, TextOrientationChangeDirtiesFont) {
const CSSProperty* properties[] = {
&GetCSSPropertyTextOrientation(),
&GetCSSPropertyWebkitTextOrientation(),
};
HeapVector<Member<const CSSValue>> values = {
CSSInitialValue::Create(),
CSSInheritedValue::Create(),
CSSIdentifierValue::Create(CSSValueID::kMixed),
};
for (const CSSValue* value : values) {
auto parent_style = ComputedStyle::Create();
auto style = ComputedStyle::Create();
// This test assumes that initial 'text-orientation' is not 'upright'.
ASSERT_NE(ETextOrientation::kUpright, style->GetTextOrientation());
style->SetTextOrientation(ETextOrientation::kUpright);
for (const CSSProperty* property : properties) {
for (const CSSValue* value : values) {
auto parent_style = ComputedStyle::Create();
auto style = ComputedStyle::Create();
// This test assumes that initial 'text-orientation' is not 'upright'.
ASSERT_NE(ETextOrientation::kUpright, style->GetTextOrientation());
style->SetTextOrientation(ETextOrientation::kUpright);
StyleResolverState state(GetDocument(), *GetDocument().body(),
parent_style.get(), parent_style.get());
state.SetStyle(style);
StyleResolverState state(GetDocument(), *GetDocument().body(),
parent_style.get(), parent_style.get());
state.SetStyle(style);
ASSERT_FALSE(state.GetFontBuilder().FontDirty());
StyleBuilder::ApplyProperty(GetCSSPropertyTextOrientation(), state, *value);
EXPECT_TRUE(state.GetFontBuilder().FontDirty());
ASSERT_FALSE(state.GetFontBuilder().FontDirty());
StyleBuilder::ApplyProperty(*property, state, *value);
EXPECT_TRUE(state.GetFontBuilder().FontDirty());
}
}
}
......
......@@ -2579,6 +2579,37 @@ TEST_F(StyleCascadeTest, RubyPositionSurrogateCanCascadeAsOriginal) {
}
}
TEST_F(StyleCascadeTest, TextOrientationPriority) {
TestCascade cascade(GetDocument());
cascade.Add("text-orientation:upright !important");
cascade.Add("-webkit-text-orientation:sideways");
cascade.Apply();
EXPECT_EQ("upright", cascade.ComputedValue("text-orientation"));
EXPECT_EQ("upright", cascade.ComputedValue("-webkit-text-orientation"));
}
TEST_F(StyleCascadeTest, TextOrientationRevert) {
TestCascade cascade(GetDocument());
cascade.Add("text-orientation:upright", CascadeOrigin::kUserAgent);
cascade.Add("-webkit-text-orientation:mixed");
cascade.Add("-webkit-text-orientation:revert");
cascade.Apply();
EXPECT_EQ("upright", cascade.ComputedValue("text-orientation"));
EXPECT_EQ("upright", cascade.ComputedValue("-webkit-text-orientation"));
}
TEST_F(StyleCascadeTest, TextOrientationLegacyKeyword) {
TestCascade cascade(GetDocument());
cascade.Add("-webkit-text-orientation:vertical-right");
cascade.Apply();
EXPECT_EQ("mixed", cascade.ComputedValue("text-orientation"));
EXPECT_EQ("vertical-right",
cascade.ComputedValue("-webkit-text-orientation"));
}
TEST_F(StyleCascadeTest, WebkitBorderImageCascadeOrder) {
String gradient1("linear-gradient(rgb(0, 0, 0), rgb(0, 128, 0))");
String gradient2("linear-gradient(rgb(0, 0, 0), rgb(0, 200, 0))");
......
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