Changeset 185282 in webkit


Ignore:
Timestamp:
Jun 5, 2015 6:23:12 PM (9 years ago)
Author:
commit-queue@webkit.org
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 <Devin Rousso> 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.

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r185279 r185282  
     12015-06-05  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Fixing code style and adding more limitations for bug 141262
     4        https://bugs.webkit.org/show_bug.cgi?id=145668
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Models/CSSCompletions.js:
     9        (WebInspector.CSSCompletions.prototype.isValidPropertyName): Loops through the full property list and returns true only if a property exactly matches the given property name.
     10        (WebInspector.CSSCompletions): Added isValidPropertyName function.
     11        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
     12        (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.
     13
    1142015-06-05  Devin Rousso  <drousso@apple.com>
    215
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js

    r185184 r185282  
    277277    }
    278278
    279     nameMatchesValidPropertyExactly(name)
    280     {
    281         for (var property of this._values) {
    282             if (property === name)
    283                 return true;
    284         }
    285 
    286         return false;
     279    isValidPropertyName(name)
     280    {
     281        return this._values.includes(name);
    287282    }
    288283};
  • trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js

    r185279 r185282  
    507507        var propertyNameIsValid = false;
    508508        if (WebInspector.CSSCompletions.cssNameCompletions)
    509             propertyNameIsValid = WebInspector.CSSCompletions.cssNameCompletions.nameMatchesValidPropertyExactly(property.name);
     509            propertyNameIsValid = WebInspector.CSSCompletions.cssNameCompletions.isValidPropertyName(property.name);
    510510
    511511        var classNames = ["css-style-declaration-property"];
     
    550550        this._removeCheckboxPlaceholder(from.line);
    551551
    552         if (!property.valid && propertyNameIsValid) {
    553             var start = {line: from.line, ch: from.ch + property.text.indexOf(property.value)};
     552        if (!property.valid && propertyNameIsValid && !property.text.trim().endsWith(":")) {
     553            // 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).
     554            // 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.
     555            var synthesizedText = property.name + ": " + property.value + ";";
     556            var start = {line: from.line, ch: from.ch + synthesizedText.indexOf(property.value)};
    554557            var end = {line: to.line, ch: start.ch + property.value.length};
    555558
Note: See TracChangeset for help on using the changeset viewer.