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 @@ ...@@ -985,8 +985,9 @@
property_methods: ["CSSValueFromComputedStyleInternal"], property_methods: ["CSSValueFromComputedStyleInternal"],
inherited: true, inherited: true,
type_name: "TextOrientation", type_name: "TextOrientation",
style_builder_custom_functions: ["value"], style_builder_custom_functions: ["initial", "inherit", "value"],
priority: "High", priority: "High",
surrogate_for: "text-orientation",
}, },
{ {
name: "writing-mode", name: "writing-mode",
......
...@@ -7809,6 +7809,15 @@ const CSSValue* WebkitTextOrientation::CSSValueFromComputedStyleInternal( ...@@ -7809,6 +7809,15 @@ const CSSValue* WebkitTextOrientation::CSSValueFromComputedStyleInternal(
return CSSIdentifierValue::Create(style.GetTextOrientation()); 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, void WebkitTextOrientation::ApplyValue(StyleResolverState& state,
const CSSValue& value) const { const CSSValue& value) const {
state.SetTextOrientation( state.SetTextOrientation(
......
...@@ -48,26 +48,33 @@ TEST_F(StyleBuilderTest, WritingModeChangeDirtiesFont) { ...@@ -48,26 +48,33 @@ TEST_F(StyleBuilderTest, WritingModeChangeDirtiesFont) {
} }
TEST_F(StyleBuilderTest, TextOrientationChangeDirtiesFont) { TEST_F(StyleBuilderTest, TextOrientationChangeDirtiesFont) {
const CSSProperty* properties[] = {
&GetCSSPropertyTextOrientation(),
&GetCSSPropertyWebkitTextOrientation(),
};
HeapVector<Member<const CSSValue>> values = { HeapVector<Member<const CSSValue>> values = {
CSSInitialValue::Create(), CSSInitialValue::Create(),
CSSInheritedValue::Create(), CSSInheritedValue::Create(),
CSSIdentifierValue::Create(CSSValueID::kMixed), CSSIdentifierValue::Create(CSSValueID::kMixed),
}; };
for (const CSSValue* value : values) { for (const CSSProperty* property : properties) {
auto parent_style = ComputedStyle::Create(); for (const CSSValue* value : values) {
auto style = ComputedStyle::Create(); auto parent_style = ComputedStyle::Create();
// This test assumes that initial 'text-orientation' is not 'upright'. auto style = ComputedStyle::Create();
ASSERT_NE(ETextOrientation::kUpright, style->GetTextOrientation()); // This test assumes that initial 'text-orientation' is not 'upright'.
style->SetTextOrientation(ETextOrientation::kUpright); ASSERT_NE(ETextOrientation::kUpright, style->GetTextOrientation());
style->SetTextOrientation(ETextOrientation::kUpright);
StyleResolverState state(GetDocument(), *GetDocument().body(), StyleResolverState state(GetDocument(), *GetDocument().body(),
parent_style.get(), parent_style.get()); parent_style.get(), parent_style.get());
state.SetStyle(style); state.SetStyle(style);
ASSERT_FALSE(state.GetFontBuilder().FontDirty()); ASSERT_FALSE(state.GetFontBuilder().FontDirty());
StyleBuilder::ApplyProperty(GetCSSPropertyTextOrientation(), state, *value); StyleBuilder::ApplyProperty(*property, state, *value);
EXPECT_TRUE(state.GetFontBuilder().FontDirty()); EXPECT_TRUE(state.GetFontBuilder().FontDirty());
}
} }
} }
......
...@@ -2579,6 +2579,37 @@ TEST_F(StyleCascadeTest, RubyPositionSurrogateCanCascadeAsOriginal) { ...@@ -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) { TEST_F(StyleCascadeTest, WebkitBorderImageCascadeOrder) {
String gradient1("linear-gradient(rgb(0, 0, 0), rgb(0, 128, 0))"); String gradient1("linear-gradient(rgb(0, 0, 0), rgb(0, 128, 0))");
String gradient2("linear-gradient(rgb(0, 0, 0), rgb(0, 200, 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