Title: [197079] releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI
Revision
197079
Author
carlo...@webkit.org
Date
2016-02-25 02:02:13 -0800 (Thu, 25 Feb 2016)

Log Message

Merge r196867 - Web Inspector: Visual Styles: Modifying background expands Font section
https://bugs.webkit.org/show_bug.cgi?id=154491
<rdar://problem/24755440>

Patch by Devin Rousso <dcrousso+web...@gmail.com> on 2016-02-20
Reviewed by Timothy Hatcher.

When the user selects a new style, the Visual sidebar examines the property
editors in each subsection to see if any have a value and expands/collapses
the subsection accordingly. This issue was happening because that logic was
also being triggered when the user didn't select a new style, which is
controlled by DOMNodeStyles and the significantChange value in refresh().

* UserInterface/Base/Utilities.js:
(String.prototype.toCamelCase):
Added utility function to transform a string into a camel-cased version.

* UserInterface/Models/DOMNodeStyles.js:
(WebInspector.DOMNodeStyles.prototype.refresh.fetchedComputedStyle):
Dropped unused variable and added checks to make sure doubly-matching styles
don't count as a significant change and cause refreshes of the styles sidebar.

* UserInterface/Views/VisualStyleDetailsPanel.js:
(WebInspector.VisualStyleDetailsPanel.prototype._updateSections):
If this function has an event, meaning it was triggered by a newly selected
selector in the selector section, loop through each subsection and perform
the logic described above, but instead only to open sections.

(WebInspector.VisualStyleDetailsPanel.prototype._generateSection.replaceDashWithCapital): Deleted.
(WebInspector.VisualStyleDetailsPanel.prototype._updateProperties):
Removed logic that was already being called by _sectionModified().

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/ChangeLog (197078 => 197079)


--- releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/ChangeLog	2016-02-25 10:00:32 UTC (rev 197078)
+++ releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/ChangeLog	2016-02-25 10:02:13 UTC (rev 197079)
@@ -1,5 +1,38 @@
 2016-02-20  Devin Rousso  <dcrousso+web...@gmail.com>
 
+        Web Inspector: Visual Styles: Modifying background expands Font section
+        https://bugs.webkit.org/show_bug.cgi?id=154491
+        <rdar://problem/24755440>
+
+        Reviewed by Timothy Hatcher.
+
+        When the user selects a new style, the Visual sidebar examines the property
+        editors in each subsection to see if any have a value and expands/collapses
+        the subsection accordingly. This issue was happening because that logic was
+        also being triggered when the user didn't select a new style, which is
+        controlled by DOMNodeStyles and the significantChange value in refresh().
+
+        * UserInterface/Base/Utilities.js:
+        (String.prototype.toCamelCase):
+        Added utility function to transform a string into a camel-cased version.
+
+        * UserInterface/Models/DOMNodeStyles.js:
+        (WebInspector.DOMNodeStyles.prototype.refresh.fetchedComputedStyle):
+        Dropped unused variable and added checks to make sure doubly-matching styles
+        don't count as a significant change and cause refreshes of the styles sidebar.
+
+        * UserInterface/Views/VisualStyleDetailsPanel.js:
+        (WebInspector.VisualStyleDetailsPanel.prototype._updateSections):
+        If this function has an event, meaning it was triggered by a newly selected
+        selector in the selector section, loop through each subsection and perform
+        the logic described above, but instead only to open sections.
+
+        (WebInspector.VisualStyleDetailsPanel.prototype._generateSection.replaceDashWithCapital): Deleted.
+        (WebInspector.VisualStyleDetailsPanel.prototype._updateProperties):
+        Removed logic that was already being called by _sectionModified().
+
+2016-02-20  Devin Rousso  <dcrousso+web...@gmail.com>
+
         Web Inspector: Text Align segmented control blinks while editing other properties in Visual Styles sidebar
         https://bugs.webkit.org/show_bug.cgi?id=154487
         <rdar://problem/24754703>

Modified: releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Base/Utilities.js (197078 => 197079)


--- releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-02-25 10:00:32 UTC (rev 197078)
+++ releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-02-25 10:02:13 UTC (rev 197079)
@@ -843,6 +843,14 @@
     }
 });
 
+Object.defineProperty(String.prototype, "toCamelCase",
+{
+    value: function()
+    {
+        return this.toLowerCase().replace(/[^\w]+(\w)/g, (match, group) => group.toUpperCase());
+    }
+});
+
 Object.defineProperty(Math, "roundTo",
 {
     value: function(num, step)

Modified: releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js (197078 => 197079)


--- releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js	2016-02-25 10:00:32 UTC (rev 197078)
+++ releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js	2016-02-25 10:02:13 UTC (rev 197079)
@@ -160,28 +160,42 @@
 
             this._refreshPending = false;
 
-            var significantChange = this._previousSignificantChange || false;
-            if (!significantChange) {
-                for (var key in this._styleDeclarationsMap) {
-                    // Check if the same key exists in the previous map and has the same style objects.
-                    if (key in this._previousStyleDeclarationsMap && Object.shallowEqual(this._styleDeclarationsMap[key], this._previousStyleDeclarationsMap[key]))
+            let significantChange = false;
+            for (let key in this._styleDeclarationsMap) {
+                // Check if the same key exists in the previous map and has the same style objects.
+                if (key in this._previousStyleDeclarationsMap) {
+                    if (Object.shallowEqual(this._styleDeclarationsMap[key], this._previousStyleDeclarationsMap[key]))
                         continue;
 
-                    if (!this._includeUserAgentRulesOnNextRefresh) {
-                        // We can assume all the styles with the same key are from the same stylesheet and rule, so we only check the first.
-                        var firstStyle = this._styleDeclarationsMap[key][0];
-                        if (firstStyle && firstStyle.ownerRule && firstStyle.ownerRule.type === WebInspector.CSSStyleSheet.Type.UserAgent) {
-                            // User Agent styles get different identifiers after some edits. This would cause us to fire a significant refreshed
-                            // event more than it is helpful. And since the user agent stylesheet is static it shouldn't match differently
-                            // between refreshes for the same node. This issue is tracked by: https://webkit.org/b/110055
-                            continue;
+                    // Some styles have selectors such that they will match with the DOM node twice (for example "::before, ::after").
+                    // In this case a second style for a second matching may be generated and added which will cause the shallowEqual
+                    // to not return true, so in this case we just want to ensure that all the current styles existed previously.
+                    let styleFound = false;
+                    for (let style of this._styleDeclarationsMap[key]) {
+                        if (this._previousStyleDeclarationsMap[key].includes(style)) {
+                            styleFound = true;
+                            break;
                         }
                     }
 
-                    // This key is new or has different style objects than before. This is a significant change.
-                    significantChange = true;
-                    break;
+                    if (styleFound)
+                        continue;
                 }
+
+                if (!this._includeUserAgentRulesOnNextRefresh) {
+                    // We can assume all the styles with the same key are from the same stylesheet and rule, so we only check the first.
+                    let firstStyle = this._styleDeclarationsMap[key][0];
+                    if (firstStyle && firstStyle.ownerRule && firstStyle.ownerRule.type === WebInspector.CSSStyleSheet.Type.UserAgent) {
+                        // User Agent styles get different identifiers after some edits. This would cause us to fire a significant refreshed
+                        // event more than it is helpful. And since the user agent stylesheet is static it shouldn't match differently
+                        // between refreshes for the same node. This issue is tracked by: https://webkit.org/b/110055
+                        continue;
+                    }
+                }
+
+                // This key is new or has different style objects than before. This is a significant change.
+                significantChange = true;
+                break;
             }
 
             if (!significantChange) {
@@ -209,9 +223,6 @@
             delete this._previousRulesMap;
             delete this._previousStyleDeclarationsMap;
 
-            // Delete the previous saved significant change flag so we rescan for a significant change next time.
-            delete this._previousSignificantChange;
-
             this.dispatchEventToListeners(WebInspector.DOMNodeStyles.Event.Refreshed, {significantChange});
         }
 

Modified: releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js (197078 => 197079)


--- releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js	2016-02-25 10:00:32 UTC (rev 197078)
+++ releases/WebKitGTK/webkit-2.12/Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js	2016-02-25 10:02:13 UTC (rev 197079)
@@ -136,12 +136,8 @@
         if (!id || !displayName)
             return;
 
-        function replaceDashWithCapital(match) {
-            return match.replace("-", "").toUpperCase();
-        }
+        let camelCaseId = id.toCamelCase();
 
-        let camelCaseId = id.replace(/-\b\w/g, replaceDashWithCapital);
-
         function createOptionsElement() {
             let container = document.createElement("div");
             container.classList.add("visual-style-section-clear");
@@ -178,12 +174,13 @@
                 let section = this._sections[key];
                 let _oneSectionExpanded_ = false;
                 for (let group of section.groups) {
-                    if (!group.collapsed) {
+                    let camelCaseId = group.identifier.toCamelCase();
+                    group.collapsed = !group.expandedByUser && !this._groupHasSetProperty(this._groups[camelCaseId]);
+                    if (!group.collapsed)
                         _oneSectionExpanded_ = true;
-                        break;
-                    }
                 }
-                section.collapsed = !oneSectionExpanded;
+                if (oneSectionExpanded)
+                    section.collapsed = false;
             }
         }
     }
@@ -216,9 +213,6 @@
         if (initialPropertyTextMissing)
             initialTextList.set(group, initialPropertyText);
 
-        let groupHasSetProperty = this._groupHasSetProperty(group);
-        group.section.collapsed = !groupHasSetProperty && !group.section.expandedByUser;
-        group.section.element.classList.toggle("has-set-property", groupHasSetProperty);
         this._sectionModified(group);
 
         if (group.autocompleteCompatibleProperties) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to