Added: trunk/LayoutTests/inspector/css/css-property.html (0 => 211289)
--- trunk/LayoutTests/inspector/css/css-property.html (rev 0)
+++ trunk/LayoutTests/inspector/css/css-property.html 2017-01-27 18:58:13 UTC (rev 211289)
@@ -0,0 +1,184 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test() {
+ let nodeStyles = null;
+
+ let suite = InspectorTest.createAsyncSuite("CSSProperty");
+
+ suite.addTestCase({
+ name: "CSSProperty.prototype.get valid",
+ description: "Ensure valid, invalid, and internal-only have correct valid state.",
+ test(resolve, reject) {
+ for (let rule of nodeStyles.matchedRules) {
+ if (rule.selectorText !== "div#x")
+ continue;
+
+ for (let property of rule.style.properties) {
+ switch (property.name) {
+ case "background-repeat":
+ InspectorTest.expectThat(property.valid, `"${property.name}" is a valid property.`);
+ break;
+ case "background-repeat-x":
+ case "background-repeat-y":
+ case "background-repeat-invalid":
+ InspectorTest.expectFalse(property.valid, `"${property.name}" is an invalid property.`);
+ break;
+ }
+ }
+ }
+
+ resolve();
+ }
+ });
+
+ suite.addTestCase({
+ name: "CSSProperty.prototype.get anonymous",
+ description: "Ensure valid, invalid, and internal-only have correct anonymous state.",
+ test(resolve, reject) {
+ for (let rule of nodeStyles.matchedRules) {
+ if (rule.selectorText !== "div#x")
+ continue;
+
+ for (let property of rule.style.properties) {
+ switch (property.name) {
+ case "background-repeat":
+ case "background-repeat-x":
+ case "background-repeat-invalid":
+ InspectorTest.expectFalse(property.anonymous, `"${property.name}" is not an anonymous CSS property.`);
+ break;
+ case "background-repeat-y":
+ InspectorTest.expectThat(property.anonymous, `"${property.name}" is an anonymous CSS property.`);
+ break;
+ }
+ }
+ }
+
+ resolve();
+ }
+ });
+
+ suite.addTestCase({
+ name: "CSSProperty.prototype.get implicit",
+ description: "Ensure valid, invalid, and internal-only have correct implicit state.",
+ test(resolve, reject) {
+ for (let rule of nodeStyles.matchedRules) {
+ if (rule.selectorText !== "div#x")
+ continue;
+
+ for (let property of rule.style.properties) {
+ switch (property.name) {
+ case "background-repeat":
+ case "background-repeat-x":
+ case "background-repeat-invalid":
+ InspectorTest.expectFalse(property.implicit, `"${property.name}" is not an implicit CSS property.`);
+ break;
+ case "background-repeat-y":
+ InspectorTest.expectThat(property.implicit, `"${property.name}" is an implicit CSS property.`);
+ break;
+ }
+ }
+ }
+
+ resolve();
+ }
+ });
+
+ suite.addTestCase({
+ name: "CSSProperty.prototype.get value",
+ description: "Ensure valid, invalid, and internal-only have correct value.",
+ test(resolve, reject) {
+ for (let rule of nodeStyles.matchedRules) {
+ if (rule.selectorText !== "div#x")
+ continue;
+
+ for (let property of rule.style.properties) {
+ switch (property.name) {
+ case "background-repeat":
+ case "background-repeat-x":
+ case "background-repeat-y":
+ case "background-repeat-invalid":
+ InspectorTest.expectEqual(property.value, "repeat", `"${property.name}" has the value "repeat".`);
+ break;
+ }
+ }
+ }
+
+ resolve();
+ }
+ });
+
+ suite.addTestCase({
+ name: "CSSProperty.prototype.get text",
+ description: "Ensure valid, invalid, and internal-only have correct text.",
+ test(resolve, reject) {
+ for (let rule of nodeStyles.matchedRules) {
+ if (rule.selectorText !== "div#x")
+ continue;
+
+ // It is necessary to use "_text" because the public "text" getter will attempt to
+ // synthesize a value for the CSSProperty if it is falsy. This is used for cases
+ // where a shorthand property is written in the style, since the longhand properties
+ // (with corresponding values) are still sent to the frontend.
+ for (let property of rule.style.properties) {
+ switch (property.name) {
+ case "background-repeat":
+ InspectorTest.expectEqual(property.text, "background-repeat: repeat;", `"${property.name}" has the text "background-repeat: repeat;".`);
+ InspectorTest.expectEqual(property._text, "background-repeat: repeat;", `"${property.name}" has the _text (private) "background-repeat: repeat;".`);
+ break;
+ case "background-repeat-x":
+ InspectorTest.expectEqual(property.text, "background-repeat-x: repeat;", `"${property.name}" has the text "background-repeat-x: repeat;".`);
+ InspectorTest.expectEqual(property._text, "background-repeat-x: repeat;", `"${property.name}" has the _text (private) "background-repeat-x: repeat;".`);
+ break;
+ case "background-repeat-y":
+ InspectorTest.expectEqual(property.text, "background-repeat-y: repeat;", `"${property.name}" has the text "background-repeat-y: repeat;".`);
+ InspectorTest.expectEqual(property._text, "", `"${property.name}" has the _text (private) "".`);
+ break;
+ case "background-repeat-invalid":
+ InspectorTest.expectEqual(property.text, "background-repeat-invalid: repeat;", `"${property.name}" has the text "background-repeat-invalid: repeat;".`);
+ InspectorTest.expectEqual(property._text, "background-repeat-invalid: repeat;", `"${property.name}" has the _text (private) "background-repeat-invalid: repeat;".`);
+ break;
+ }
+ }
+ }
+
+ resolve();
+ }
+ });
+
+ WebInspector.domTreeManager.requestDocument((documentNode) => {
+ WebInspector.domTreeManager.querySelector(documentNode.id, "div#x", (contentNodeId) => {
+ if (contentNodeId) {
+ let domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
+ nodeStyles = WebInspector.cssStyleManager.stylesForNode(domNode);
+
+ if (nodeStyles.needsRefresh) {
+ nodeStyles.singleFireEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, (event) => {
+ suite.runTestCasesAndFinish()
+ });
+ } else
+ suite.runTestCasesAndFinish();
+ } else {
+ InspectorTest.fail("DOM node not found.");
+ InspectorTest.completeTest();
+ }
+ });
+ });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+ <p>Testing methods of CSSProperty.</p>
+
+ <style>
+ div#x {
+ background-repeat: repeat;
+ background-repeat-x: repeat;
+ background-repeat-invalid: repeat;
+ }
+ </style>
+ <div id="x"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/css/makeprop.pl (211288 => 211289)
--- trunk/Source/WebCore/css/makeprop.pl 2017-01-27 18:44:18 UTC (rev 211288)
+++ trunk/Source/WebCore/css/makeprop.pl 2017-01-27 18:58:13 UTC (rev 211289)
@@ -58,6 +58,7 @@
my %defines = map { $_ => 1 } split(/ /, $defines);
my @names;
+my @internalProprerties;
my $numPredefinedProperties = 2;
my %nameIsInherited;
my %nameIsHighPriority;
@@ -140,7 +141,8 @@
} elsif ($styleBuilderOptions{$codegenOptionName}) {
$propertiesWithStyleBuilderOptions{$name}{$codegenOptionName} = $codegenProperties->{$codegenOptionName};
} elsif ($codegenOptionName eq "internal-only") {
- # internal-only properties exist to make it easier to parse compound properties (e.g. background-repeat) as if they were shorthands. This doesn't currently affect codegen.
+ # internal-only properties exist to make it easier to parse compound properties (e.g. background-repeat) as if they were shorthands.
+ push @internalProprerties, $name
} else {
die "Unrecognized codegen property \"$optionName\" for $name property.";
}
@@ -242,7 +244,7 @@
}
}
-print GPERF<< "EOF";
+print GPERF << "EOF";
%%
const Property* findProperty(const char* str, unsigned int len)
{
@@ -249,6 +251,22 @@
return CSSPropertyNamesHash::findPropertyImpl(str, len);
}
+bool isInternalCSSProperty(const CSSPropertyID id)
+{
+ switch (id) {
+EOF
+
+foreach my $name (@internalProprerties) {
+ print GPERF " case CSSPropertyID::CSSProperty" . $nameToId{$name} . ":\n";
+}
+
+print GPERF << "EOF";
+ return true;
+ default:
+ return false;
+ }
+}
+
const char* getPropertyName(CSSPropertyID id)
{
if (id < firstCSSProperty)
@@ -380,6 +398,7 @@
print HEADER << "EOF";
+bool isInternalCSSProperty(const CSSPropertyID);
const char* getPropertyName(CSSPropertyID);
const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID id);
WTF::String getPropertyNameString(CSSPropertyID id);
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (211288 => 211289)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2017-01-27 18:44:18 UTC (rev 211288)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2017-01-27 18:58:13 UTC (rev 211289)
@@ -654,8 +654,10 @@
propertiesObject->addItem(property.copyRef());
+ CSSPropertyID propertyId = cssPropertyID(name);
+
// Default "parsedOk" == true.
- if (!propertyEntry.parsedOk)
+ if (!propertyEntry.parsedOk || isInternalCSSProperty(propertyId))
property->setParsedOk(false);
if (it->hasRawText())
property->setText(it->rawText);
@@ -678,7 +680,7 @@
// Parsed property overrides any property with the same name. Non-parsed property overrides
// previous non-parsed property with the same name (if any).
bool shouldInactivate = false;
- CSSPropertyID propertyId = cssPropertyID(name);
+
// Canonicalize property names to treat non-prefixed and vendor-prefixed property names the same (opacity vs. -webkit-opacity).
String canonicalPropertyName = propertyId ? getPropertyNameString(propertyId) : name;
HashMap<String, RefPtr<Inspector::Protocol::CSS::CSSProperty>>::iterator activeIt = propertyNameToPreviousActiveProperty.find(canonicalPropertyName);