Title: [283899] trunk/Source/WebInspectorUI
- Revision
- 283899
- Author
- [email protected]
- Date
- 2021-10-11 09:13:30 -0700 (Mon, 11 Oct 2021)
Log Message
Web Inspector: Move CSS longhand and shorthand mapping away from WI.CSSCompletions
https://bugs.webkit.org/show_bug.cgi?id=231432
<rdar://problem/84029471>
Reviewed by Devin Rousso.
`WI.CSSCompletions` has scope creep. Beyond handling filtering for CSS completions,
it holds logic to deal with CSS property name longhand-to-shorthand mapping.
But it already relies heavily on metadata about properties set on `WI.CSSKeywordCompletions`
populated as a result of the one-time initialization from `WI.CSSCompletions.initializeCSSCompletions(target)` >
`WI.CSSKeywordCompletions.addCustomCompletions(properties)`.
This change moves the longhand-to-shorthand mapping from `WI.CSSCompletions` to
`WI.CSSKeywordCompletions.ShorthandNamesForLongHandProperty` and updates relevant consumers.
The aim is to gradually remove all specialized logic for property names from `WI.CSSCompletions`.
* UserInterface/Models/CSSCompletions.js:
(WI.CSSCompletions):
(WI.CSSCompletions.prototype.isShorthandPropertyName): Deleted.
(WI.CSSCompletions.prototype.shorthandsForLonghand): Deleted.
* UserInterface/Models/CSSKeywordCompletions.js:
* UserInterface/Models/CSSProperty.js:
(WI.CSSProperty):
* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles.prototype._associateRelatedProperties):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (283898 => 283899)
--- trunk/Source/WebInspectorUI/ChangeLog 2021-10-11 16:12:49 UTC (rev 283898)
+++ trunk/Source/WebInspectorUI/ChangeLog 2021-10-11 16:13:30 UTC (rev 283899)
@@ -1,3 +1,33 @@
+2021-10-11 Razvan Caliman <[email protected]>
+
+ Web Inspector: Move CSS longhand and shorthand mapping away from WI.CSSCompletions
+ https://bugs.webkit.org/show_bug.cgi?id=231432
+ <rdar://problem/84029471>
+
+ Reviewed by Devin Rousso.
+
+ `WI.CSSCompletions` has scope creep. Beyond handling filtering for CSS completions,
+ it holds logic to deal with CSS property name longhand-to-shorthand mapping.
+
+ But it already relies heavily on metadata about properties set on `WI.CSSKeywordCompletions`
+ populated as a result of the one-time initialization from `WI.CSSCompletions.initializeCSSCompletions(target)` >
+ `WI.CSSKeywordCompletions.addCustomCompletions(properties)`.
+
+ This change moves the longhand-to-shorthand mapping from `WI.CSSCompletions` to
+ `WI.CSSKeywordCompletions.ShorthandNamesForLongHandProperty` and updates relevant consumers.
+
+ The aim is to gradually remove all specialized logic for property names from `WI.CSSCompletions`.
+
+ * UserInterface/Models/CSSCompletions.js:
+ (WI.CSSCompletions):
+ (WI.CSSCompletions.prototype.isShorthandPropertyName): Deleted.
+ (WI.CSSCompletions.prototype.shorthandsForLonghand): Deleted.
+ * UserInterface/Models/CSSKeywordCompletions.js:
+ * UserInterface/Models/CSSProperty.js:
+ (WI.CSSProperty):
+ * UserInterface/Models/DOMNodeStyles.js:
+ (WI.DOMNodeStyles.prototype._associateRelatedProperties):
+
2021-10-08 BJ Burg <[email protected]>
Web Inspector: add TabBar context menu support for WI.WebInspectorExtensionTabContentView
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js (283898 => 283899)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js 2021-10-11 16:12:49 UTC (rev 283898)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js 2021-10-11 16:13:30 UTC (rev 283899)
@@ -36,7 +36,6 @@
constructor(properties, acceptEmptyPrefix)
{
this._values = [];
- this._shorthands = {};
// The `properties` parameter can be either a list of objects with 'name' / 'longhand'
// properties when initialized from the protocol for CSSCompletions.cssNameCompletions.
@@ -53,21 +52,6 @@
let aliases = property.aliases;
if (aliases)
this._values.pushAll(aliases);
-
- var longhands = property.longhands;
- if (longhands) {
- for (var j = 0; j < longhands.length; ++j) {
- var longhandName = longhands[j];
-
- var shorthands = this._shorthands[longhandName];
- if (!shorthands) {
- shorthands = [];
- this._shorthands[longhandName] = shorthands;
- }
-
- shorthands.push(propertyName);
- }
- }
}
}
@@ -348,16 +332,6 @@
return propertiesWithPrefix[j];
}
- isShorthandPropertyName(shorthand)
- {
- return WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty.has(shorthand);
- }
-
- shorthandsForLonghand(longhand)
- {
- return this._shorthands[longhand] || [];
- }
-
isValidPropertyName(name)
{
return this._values.includes(name);
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (283898 => 283899)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js 2021-10-11 16:12:49 UTC (rev 283898)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js 2021-10-11 16:13:30 UTC (rev 283899)
@@ -225,8 +225,15 @@
if (property.inherited)
WI.CSSKeywordCompletions.InheritedProperties.add(property.name);
- if (property.longhands)
+ if (property.longhands) {
WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty.set(property.name, property.longhands);
+
+ for (let longhand of property.longhands) {
+ let shorthands = WI.CSSKeywordCompletions.ShorthandNamesForLongHandProperty.getOrInitialize(longhand, []);
+ shorthands.push(property.name);
+ }
+ }
+
}
};
@@ -252,6 +259,7 @@
// Populated by CSS.getSupportedCSSProperties.
WI.CSSKeywordCompletions.PropertyNameForAlias = new Map;
WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty = new Map;
+WI.CSSKeywordCompletions.ShorthandNamesForLongHandProperty = new Map;
WI.CSSKeywordCompletions.InheritedProperties = new Set([
// Compatibility (iOS 12): `inherited` didn't exist on `CSSPropertyInfo`
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js (283898 => 283899)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js 2021-10-11 16:12:49 UTC (rev 283898)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js 2021-10-11 16:13:30 UTC (rev 283899)
@@ -430,7 +430,7 @@
get isShorthand()
{
if (this._isShorthand === undefined) {
- this._isShorthand = WI.CSSCompletions.cssNameCompletions.isShorthandPropertyName(this._name);
+ this._isShorthand = WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty.has(this._name);
if (this._isShorthand) {
let longhands = WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty.get(this._name);
if (longhands && longhands.length === 1)
@@ -443,7 +443,7 @@
get shorthandPropertyNames()
{
if (!this._shorthandPropertyNames) {
- this._shorthandPropertyNames = WI.CSSCompletions.cssNameCompletions.shorthandsForLonghand(this._name);
+ this._shorthandPropertyNames = WI.CSSKeywordCompletions.ShorthandNamesForLongHandProperty.get(this._name) || [];
this._shorthandPropertyNames.remove("all");
}
return this._shorthandPropertyNames;
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js (283898 => 283899)
--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js 2021-10-11 16:12:49 UTC (rev 283898)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js 2021-10-11 16:13:30 UTC (rev 283899)
@@ -903,7 +903,7 @@
if (!property.valid)
continue;
- if (!WI.CSSCompletions.cssNameCompletions.isShorthandPropertyName(property.name))
+ if (!WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty.has(property.name))
continue;
if (knownShorthands[property.canonicalName] && !knownShorthands[property.canonicalName].overridden) {
@@ -923,7 +923,7 @@
var shorthandProperty = null;
if (!isEmptyObject(knownShorthands)) {
- var possibleShorthands = WI.CSSCompletions.cssNameCompletions.shorthandsForLonghand(property.canonicalName);
+ var possibleShorthands = WI.CSSKeywordCompletions.ShorthandNamesForLongHandProperty.get(property.canonicalName) || [];
for (var k = 0; k < possibleShorthands.length; ++k) {
if (possibleShorthands[k] in knownShorthands) {
shorthandProperty = knownShorthands[possibleShorthands[k]];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes