Title: [185282] trunk/Source/WebInspectorUI
Revision
185282
Author
commit-qu...@webkit.org
Date
2015-06-05 18:23:12 -0700 (Fri, 05 Jun 2015)

Log Message

Web Inspector: Fixing code style and adding more limitations for bug 141262
https://bugs.webkit.org/show_bug.cgi?id=145668

Patch by Devin Rousso <drou...@apple.com> on 2015-06-05
Reviewed by Timothy Hatcher.

* UserInterface/Models/CSSCompletions.js:
(WebInspector.CSSCompletions.prototype.isValidPropertyName): Loops through the full property list and returns true only if a property exactly matches the given property name.
(WebInspector.CSSCompletions): Added isValidPropertyName function.
* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype._createTextMarkerForPropertyIfNeeded): Added logic to limit the invalid class marker to only the property value if the property name is an actual property and to prevent invalid style from being applied incorrectly.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (185281 => 185282)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-06-06 01:19:36 UTC (rev 185281)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-06-06 01:23:12 UTC (rev 185282)
@@ -1,5 +1,18 @@
 2015-06-05  Devin Rousso  <drou...@apple.com>
 
+        Web Inspector: Fixing code style and adding more limitations for bug 141262
+        https://bugs.webkit.org/show_bug.cgi?id=145668
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/CSSCompletions.js:
+        (WebInspector.CSSCompletions.prototype.isValidPropertyName): Loops through the full property list and returns true only if a property exactly matches the given property name.
+        (WebInspector.CSSCompletions): Added isValidPropertyName function.
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype._createTextMarkerForPropertyIfNeeded): Added logic to limit the invalid class marker to only the property value if the property name is an actual property and to prevent invalid style from being applied incorrectly.
+
+2015-06-05  Devin Rousso  <drou...@apple.com>
+
         Web Inspector: Highlighting a CSS section does not deselect previously highlighted CSS sections
         https://bugs.webkit.org/show_bug.cgi?id=145399
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js (185281 => 185282)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2015-06-06 01:19:36 UTC (rev 185281)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2015-06-06 01:23:12 UTC (rev 185282)
@@ -276,14 +276,9 @@
         return this._shorthands[longhand] || [];
     }
 
-    nameMatchesValidPropertyExactly(name)
+    isValidPropertyName(name)
     {
-        for (var property of this._values) {
-            if (property === name)
-                return true;
-        }
-
-        return false;
+        return this._values.includes(name);
     }
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js (185281 => 185282)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js	2015-06-06 01:19:36 UTC (rev 185281)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js	2015-06-06 01:23:12 UTC (rev 185282)
@@ -506,7 +506,7 @@
 
         var propertyNameIsValid = false;
         if (WebInspector.CSSCompletions.cssNameCompletions)
-            propertyNameIsValid = WebInspector.CSSCompletions.cssNameCompletions.nameMatchesValidPropertyExactly(property.name);
+            propertyNameIsValid = WebInspector.CSSCompletions.cssNameCompletions.isValidPropertyName(property.name);
 
         var classNames = ["css-style-declaration-property"];
 
@@ -549,8 +549,11 @@
 
         this._removeCheckboxPlaceholder(from.line);
 
-        if (!property.valid && propertyNameIsValid) {
-            var start = {line: from.line, ch: from.ch + property.text.indexOf(property.value)};
+        if (!property.valid && propertyNameIsValid && !property.text.trim().endsWith(":")) {
+            // The property.text.trim().endsWith(":") is for the situation when a property only has a name and colon and the user leaves the value blank (it looks weird to have an invalid marker through just the colon).
+            // Creating the synthesizedText is necessary for if the user adds multiple spaces before the value, causing the markText to mark one of the spaces instead.
+            var synthesizedText = property.name + ": " + property.value + ";";
+            var start = {line: from.line, ch: from.ch + synthesizedText.indexOf(property.value)};
             var end = {line: to.line, ch: start.ch + property.value.length};
 
             this._codeMirror.markText(start, end, {className: "invalid"});
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to