Commit a007ecdf authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Ribbon: Support CSSUnresolvedProperty in CSSPropertyRef.

This makes it possible to use CSSPropertyRef to get instances which
represent aliases.

R=futhark@chromium.org

Change-Id: I6098c02678bb36bb08ecb28764893245e747a350
Reviewed-on: https://chromium-review.googlesource.com/c/1323111
Commit-Queue: Anders Ruud <andruud@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606460}
parent a33f61f6
......@@ -9,7 +9,7 @@
namespace blink {
CSSPropertyRef::CSSPropertyRef(const String& name, const Document& document)
: property_id_(cssPropertyID(name)) {
: property_id_(unresolvedCSSPropertyID(name)) {
if (property_id_ == CSSPropertyVariable)
custom_property_ = CustomProperty(AtomicString(name), document);
}
......
......@@ -52,7 +52,13 @@ class CORE_EXPORT CSSPropertyRef {
DCHECK(IsValid());
if (property_id_ == CSSPropertyVariable)
return custom_property_;
return CSSProperty::Get(property_id_);
return CSSProperty::Get(resolveCSSPropertyID(property_id_));
}
const CSSUnresolvedProperty& GetUnresolvedProperty() const {
if (isPropertyAlias(property_id_))
return *CSSUnresolvedProperty::GetAliasProperty(property_id_);
return GetProperty();
}
void Trace(blink::Visitor* visitor) { visitor->Trace(custom_property_); }
......
......@@ -75,4 +75,29 @@ TEST_F(CSSPropertyRefTest, FromStaticVariableInstance) {
EXPECT_FALSE(ref.IsValid());
}
TEST_F(CSSPropertyRefTest, GetUnresolvedPropertyStandard) {
CSSPropertyRef ref("font-size", GetDocument());
EXPECT_TRUE(ref.GetUnresolvedProperty().IsResolvedProperty());
}
TEST_F(CSSPropertyRefTest, GetUnresolvedPropertyCustom) {
CSSPropertyRef ref("--x", GetDocument());
EXPECT_TRUE(ref.GetUnresolvedProperty().IsResolvedProperty());
}
TEST_F(CSSPropertyRefTest, GetUnresolvedPropertyAlias) {
// -webkit-transform is an arbitrarily chosen alias.
CSSPropertyRef ref("-webkit-transform", GetDocument());
const auto& unresolved = ref.GetUnresolvedProperty();
EXPECT_FALSE(unresolved.IsResolvedProperty());
EXPECT_EQ("-webkit-transform", unresolved.GetPropertyNameString());
}
TEST_F(CSSPropertyRefTest, GetResolvedPropertyAlias) {
// -webkit-transform is an arbitrarily chosen alias.
CSSPropertyRef ref("-webkit-transform", GetDocument());
EXPECT_TRUE(ref.GetProperty().IsResolvedProperty());
EXPECT_EQ("transform", ref.GetProperty().GetPropertyNameString());
}
} // namespace blink
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