Commit 8c382437 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[ribbon] Add CSSProperty::GetCSSPropertyName.

This CL adds a function to get a CSSPropertyName from a CSSProperty.

Change-Id: I76f0a09367a082142dd38bc48f82200a630be527
Reviewed-on: https://chromium-review.googlesource.com/c/1429643Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625202}
parent 0679a597
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_
#include "third_party/blink/renderer/core/css/css_property_name.h"
#include "third_party/blink/renderer/core/css/css_property_names.h" #include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_value.h" #include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h" #include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h"
...@@ -44,6 +45,9 @@ class CSSProperty : public CSSUnresolvedProperty { ...@@ -44,6 +45,9 @@ class CSSProperty : public CSSUnresolvedProperty {
NOTREACHED(); NOTREACHED();
return CSSPropertyInvalid; return CSSPropertyInvalid;
} }
virtual CSSPropertyName GetCSSPropertyName() const {
return CSSPropertyName(PropertyID());
}
bool IDEquals(CSSPropertyID id) const { return PropertyID() == id; } bool IDEquals(CSSPropertyID id) const { return PropertyID() == id; }
bool IsResolvedProperty() const override { return true; } bool IsResolvedProperty() const override { return true; }
virtual bool IsInterpolable() const { return false; } virtual bool IsInterpolable() const { return false; }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/css/css_property_name.h" #include "third_party/blink/renderer/core/css/css_property_name.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
namespace blink { namespace blink {
...@@ -47,4 +48,9 @@ TEST(CSSPropertyNameTest, From) { ...@@ -47,4 +48,9 @@ TEST(CSSPropertyNameTest, From) {
EXPECT_EQ(*CSSPropertyName::From("--x"), CSSPropertyName("--x")); EXPECT_EQ(*CSSPropertyName::From("--x"), CSSPropertyName("--x"));
} }
TEST(CSSPropertyNameTest, FromNativeCSSProperty) {
CSSPropertyName name = GetCSSPropertyFontSize().GetCSSPropertyName();
EXPECT_EQ(CSSPropertyName(CSSPropertyFontSize), name);
}
} // namespace blink } // namespace blink
...@@ -30,6 +30,10 @@ const AtomicString& CustomProperty::GetPropertyNameAtomicString() const { ...@@ -30,6 +30,10 @@ const AtomicString& CustomProperty::GetPropertyNameAtomicString() const {
return name_; return name_;
} }
CSSPropertyName CustomProperty::GetCSSPropertyName() const {
return CSSPropertyName(name_);
}
void CustomProperty::ApplyInitial(StyleResolverState& state) const { void CustomProperty::ApplyInitial(StyleResolverState& state) const {
state.Style()->RemoveVariable(name_, IsInherited()); state.Style()->RemoveVariable(name_, IsInherited());
} }
......
...@@ -30,6 +30,7 @@ class CORE_EXPORT CustomProperty : public Variable { ...@@ -30,6 +30,7 @@ class CORE_EXPORT CustomProperty : public Variable {
bool IsInherited() const override; bool IsInherited() const override;
const AtomicString& GetPropertyNameAtomicString() const override; const AtomicString& GetPropertyNameAtomicString() const override;
CSSPropertyName GetCSSPropertyName() const override;
void ApplyInitial(StyleResolverState&) const override; void ApplyInitial(StyleResolverState&) const override;
void ApplyInherit(StyleResolverState&) const override; void ApplyInherit(StyleResolverState&) const override;
......
...@@ -194,4 +194,9 @@ TEST_F(CustomPropertyTest, ParseSingleValueValidatedUntyped) { ...@@ -194,4 +194,9 @@ TEST_F(CustomPropertyTest, ParseSingleValueValidatedUntyped) {
EXPECT_FALSE(value2); EXPECT_FALSE(value2);
} }
TEST_F(CustomPropertyTest, GetCSSPropertyName) {
CustomProperty property("--x", GetDocument());
EXPECT_EQ(CSSPropertyName("--x"), property.GetCSSPropertyName());
}
} // namespace blink } // namespace blink
...@@ -22,6 +22,10 @@ class CORE_EXPORT Variable : public Longhand { ...@@ -22,6 +22,10 @@ class CORE_EXPORT Variable : public Longhand {
bool IsInherited() const override { return true; } bool IsInherited() const override { return true; }
bool IsAffectedByAll() const override { return false; } bool IsAffectedByAll() const override { return false; }
CSSPropertyID PropertyID() const override { return CSSPropertyVariable; } CSSPropertyID PropertyID() const override { return CSSPropertyVariable; }
CSSPropertyName GetCSSPropertyName() const override {
NOTREACHED();
return CSSPropertyName("");
}
const char* GetPropertyName() const override { return "variable"; } const char* GetPropertyName() const override { return "variable"; }
const WTF::AtomicString& GetPropertyNameAtomicString() const override { const WTF::AtomicString& GetPropertyNameAtomicString() const override {
DEFINE_STATIC_LOCAL(const AtomicString, name, ("variable")); DEFINE_STATIC_LOCAL(const AtomicString, name, ("variable"));
......
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