Skip to content
Permalink
Browse files
Web Inspector: Remove unused dontCreateIfMissing argument from CSSS…
…tyleDeclaration.prototype.propertyForName

https://bugs.webkit.org/show_bug.cgi?id=233198

Reviewed by Devin Rousso.

Source/WebInspectorUI:

`dontCreateIfMissing` was always set to `true`.

* UserInterface/Models/CSSStyleDeclaration.js:
(WI.CSSStyleDeclaration.prototype.propertyForName):
Drive-by: inline findMatch function, which was only used once.

* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles.prototype._parseStylePropertyPayload):
* UserInterface/Models/Font.js:
(WI.Font):
* UserInterface/Views/BoxModelDetailsSectionRow.js:
(WI.BoxModelDetailsSectionRow.prototype._getPropertyValue):
* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype._addVariableTokens):

LayoutTests:

* inspector/css/overridden-property.html:
* inspector/css/pseudo-element-matches-for-pseudo-element-node.html:



Canonical link: https://commits.webkit.org/244314@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285896 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
NV committed Nov 17, 2021
1 parent 97c1ddc commit 69e2ca1d304df04627b9651a9b7eeceefe66a2a3
Showing 9 changed files with 57 additions and 57 deletions.
@@ -1,3 +1,13 @@
2021-11-16 Nikita Vasilyev <nvasilyev@apple.com>

Web Inspector: Remove unused `dontCreateIfMissing` argument from CSSStyleDeclaration.prototype.propertyForName
https://bugs.webkit.org/show_bug.cgi?id=233198

Reviewed by Devin Rousso.

* inspector/css/overridden-property.html:
* inspector/css/pseudo-element-matches-for-pseudo-element-node.html:

2021-11-16 Rob Buis <rbuis@igalia.com>

[css-contain] Support contain:paint
@@ -92,11 +92,10 @@
name: "OverriddenProperty.OverriddenByShorthand",
test(resolve, reject) {
getStyleDeclaration(".longhand-overridden-by-shorthand", (style) => {
const dontCreateIfMissing = true;
let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
let borderTopColorProperty = style.propertyForName("border-top-color");
InspectorTest.expectTrue(borderTopColorProperty.overridden, "border-top-color is overridden.");

let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
let borderColorProperty = style.propertyForName("border-color");
InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");

resolve();
@@ -108,11 +107,10 @@
name: "OverriddenProperty.OverriddenByImportantShorthand",
test(resolve, reject) {
getStyleDeclaration(".longhand-overridden-by-important-shorthand", (style) => {
const dontCreateIfMissing = true;
let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
let borderColorProperty = style.propertyForName("border-color");
InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");

let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
let borderTopColorProperty = style.propertyForName("border-top-color");
InspectorTest.expectTrue(borderTopColorProperty.overridden, "border-top-color is overridden.");

resolve();
@@ -124,11 +122,10 @@
name: "OverriddenProperty.NotOverriddenByImportantLonghand",
test(resolve, reject) {
getStyleDeclaration(".shorthand-overridden-by-important-longhand", (style) => {
const dontCreateIfMissing = true;
let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
let borderTopColorProperty = style.propertyForName("border-top-color");
InspectorTest.expectFalse(borderTopColorProperty.overridden, "border-top-color is NOT overridden.");

let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
let borderColorProperty = style.propertyForName("border-color");
InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");

resolve();
@@ -140,11 +137,10 @@
name: "OverriddenProperty.NotOverriddenByLonghand",
test(resolve, reject) {
getStyleDeclaration(".shorthand-not-overridden-by-longhand", (style) => {
const dontCreateIfMissing = true;
let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
let borderColorProperty = style.propertyForName("border-color");
InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");

let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
let borderTopColorProperty = style.propertyForName("border-top-color");
InspectorTest.expectFalse(borderTopColorProperty.overridden, "border-top-color is NOT overridden.");

resolve();
@@ -156,11 +152,10 @@
name: "OverriddenProperty.MixedCaseVariablesNotOverridden",
test(resolve, reject) {
getStyleDeclaration(".mixed-case-variables-not-overridden", (style) => {
const dontCreateIfMissing = true;
let lowercaseVariableProperty = style.propertyForName("--foo", dontCreateIfMissing);
let lowercaseVariableProperty = style.propertyForName("--foo");
InspectorTest.expectFalse(lowercaseVariableProperty.overridden, "`--foo` is NOT overridden.");

let uppercaseVariableProperty = style.propertyForName("--FOO", dontCreateIfMissing);
let uppercaseVariableProperty = style.propertyForName("--FOO");
InspectorTest.expectFalse(uppercaseVariableProperty.overridden, "`--FOO` is NOT overridden.");

resolve();
@@ -17,8 +17,7 @@
InspectorTest.expectThat(nodeStyles.computedStyle, "Has Computed Styles");

function logProperty(propertyName) {
const dontCreateIfMissing = true;
let property = nodeStyles.computedStyle.propertyForName(propertyName, dontCreateIfMissing);
let property = nodeStyles.computedStyle.propertyForName(propertyName);
InspectorTest.log(`PROPERTY: ${property.name}: ${property.value};`);
}

@@ -1,3 +1,25 @@
2021-11-16 Nikita Vasilyev <nvasilyev@apple.com>

Web Inspector: Remove unused `dontCreateIfMissing` argument from CSSStyleDeclaration.prototype.propertyForName
https://bugs.webkit.org/show_bug.cgi?id=233198

Reviewed by Devin Rousso.

`dontCreateIfMissing` was always set to `true`.

* UserInterface/Models/CSSStyleDeclaration.js:
(WI.CSSStyleDeclaration.prototype.propertyForName):
Drive-by: inline findMatch function, which was only used once.

* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles.prototype._parseStylePropertyPayload):
* UserInterface/Models/Font.js:
(WI.Font):
* UserInterface/Views/BoxModelDetailsSectionRow.js:
(WI.BoxModelDetailsSectionRow.prototype._getPropertyValue):
* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype._addVariableTokens):

2021-11-15 Patrick Angle <pangle@apple.com>

Web Inspector: Styles: Autocomplete should support mid-line completions
@@ -301,7 +301,7 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
return this._node.appropriateSelectorFor(true);
}

propertyForName(name, dontCreateIfMissing)
propertyForName(name)
{
console.assert(name);
if (!name)
@@ -313,39 +313,16 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
// Editable styles don't use the map since they need to
// account for overridden properties.

function findMatch(properties)
{
for (var i = 0; i < properties.length; ++i) {
var property = properties[i];
if (property.canonicalName !== name && property.name !== name)
continue;
if (bestMatchProperty && !bestMatchProperty.overridden && property.overridden)
continue;
bestMatchProperty = property;
}
let bestMatchProperty = null;
for (let property of this.enabledProperties) {
if (property.canonicalName !== name && property.name !== name)
continue;
if (bestMatchProperty && !bestMatchProperty.overridden && property.overridden)
continue;
bestMatchProperty = property;
}

var bestMatchProperty = null;

findMatch(this.enabledProperties);

if (bestMatchProperty)
return bestMatchProperty;

if (dontCreateIfMissing || !this.editable)
return null;

findMatch(this._pendingProperties, true);

if (bestMatchProperty)
return bestMatchProperty;

var newProperty = new WI.CSSProperty(NaN, null, name);
newProperty.ownerStyle = this;

this._pendingProperties.push(newProperty);

return newProperty;
return bestMatchProperty;
}

resolveVariableValue(text)
@@ -385,7 +362,7 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
if (variableNameIndex === -1)
continue;

let variableProperty = this.propertyForName(variableTokens[variableNameIndex].value, true);
let variableProperty = this.propertyForName(variableTokens[variableNameIndex].value);
if (variableProperty)
return variableProperty.value.trim();

@@ -545,7 +545,7 @@ WI.DOMNodeStyles = class DOMNodeStyles extends WI.Object

if (styleDeclaration) {
// Use propertyForName when the index is NaN since propertyForName is fast in that case.
var property = isNaN(index) ? styleDeclaration.propertyForName(name, true) : styleDeclaration.enabledProperties[index];
var property = isNaN(index) ? styleDeclaration.propertyForName(name) : styleDeclaration.enabledProperties[index];

// Reuse a property if the index and name matches. Otherwise it is a different property
// and should be created from scratch. This works in the simple cases where only existing
@@ -206,8 +206,7 @@ WI.Font = class Font

_computedPropertyValueForName(domNodeStyle, name)
{
const dontCreateIfMissing = true;
return domNodeStyle.computedStyle?.propertyForName(name, dontCreateIfMissing)?.value || "";
return domNodeStyle.computedStyle?.propertyForName(name)?.value || "";
}
};

@@ -80,8 +80,7 @@ WI.BoxModelDetailsSectionRow = class BoxModelDetailsSectionRow extends WI.Detail

_getPropertyValue(style, propertyName)
{
const dontCreateIfMissing = true;
let property = style.propertyForName(propertyName, dontCreateIfMissing);
let property = style.propertyForName(propertyName);
if (!property)
return null;
return property.value;
@@ -870,8 +870,7 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object
let contents = rawTokens.slice(0, variableNameIndex + 1);

if (WI.settings.experimentalEnableStylesJumpToVariableDeclaration.value && this._property.ownerStyle.type !== WI.CSSStyleDeclaration.Type.Computed && this._delegate && this._delegate.spreadsheetStylePropertySelectByProperty) {
const dontCreateIfMissing = true;
let effectiveVariableProperty = this._property.ownerStyle.nodeStyles.effectivePropertyForName(rawTokens[variableNameIndex].value, dontCreateIfMissing);
let effectiveVariableProperty = this._property.ownerStyle.nodeStyles.effectivePropertyForName(rawTokens[variableNameIndex].value);
if (effectiveVariableProperty) {
let arrowElement = WI.createGoToArrowButton();
arrowElement.classList.add("select-variable-property");

0 comments on commit 69e2ca1

Please sign in to comment.