Title: [215755] trunk/Source/WebInspectorUI
Revision
215755
Author
commit-qu...@webkit.org
Date
2017-04-25 13:38:00 -0700 (Tue, 25 Apr 2017)

Log Message

Web Inspector: "Space" localized string is not loaded in combined and minified builds
https://bugs.webkit.org/show_bug.cgi?id=171283
<rdar://problem/30871371>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2017-04-25
Reviewed by Brian Burg.

In combined and minified builds, the document.write() to load the
localized strings script doesn't happen before the KeyboardShortcut
global code in Main.js evaluates, so there is no UIString because
window.localizedStrings hasn't populated yet. Since this is the only
instance, populate the display UIString lazily and provide warnings
in minified builds if this happens.

* UserInterface/Base/LoadLocalizedStrings.js:
(WebInspector.UIString):
Provide a warning if a UIString was attempted before the strings have loaded.

* UserInterface/Base/Main.js:
(WebInspector.loaded):
For this rare instance, populate the display name of the string when we are
sure strings have loaded.

* UserInterface/Models/KeyboardShortcut.js:
Revert the UIString here, but note that it will be populated later.

* UserInterface/Models/Resource.js:
(WebInspector.Resource.prototype.setCachedResponseBodySize):
* UserInterface/Views/DOMTreeElement.js:
(WebInspector.DOMTreeElement.prototype._statusImageContextmenu):
Address console.asserts not ending in semicolon warnings produced during
optimized builds. Without semicolons they are not stripped.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (215754 => 215755)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-04-25 20:33:39 UTC (rev 215754)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-04-25 20:38:00 UTC (rev 215755)
@@ -1,3 +1,37 @@
+2017-04-25  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: "Space" localized string is not loaded in combined and minified builds
+        https://bugs.webkit.org/show_bug.cgi?id=171283
+        <rdar://problem/30871371>
+
+        Reviewed by Brian Burg.
+
+        In combined and minified builds, the document.write() to load the
+        localized strings script doesn't happen before the KeyboardShortcut
+        global code in Main.js evaluates, so there is no UIString because
+        window.localizedStrings hasn't populated yet. Since this is the only
+        instance, populate the display UIString lazily and provide warnings
+        in minified builds if this happens.
+
+        * UserInterface/Base/LoadLocalizedStrings.js:
+        (WebInspector.UIString):
+        Provide a warning if a UIString was attempted before the strings have loaded.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.loaded):
+        For this rare instance, populate the display name of the string when we are
+        sure strings have loaded.
+
+        * UserInterface/Models/KeyboardShortcut.js:
+        Revert the UIString here, but note that it will be populated later.
+
+        * UserInterface/Models/Resource.js:
+        (WebInspector.Resource.prototype.setCachedResponseBodySize):
+        * UserInterface/Views/DOMTreeElement.js:
+        (WebInspector.DOMTreeElement.prototype._statusImageContextmenu):
+        Address console.asserts not ending in semicolon warnings produced during
+        optimized builds. Without semicolons they are not stripped.
+
 2017-04-25  Fujii Hironori  <hironori.fu...@sony.com>
 
         Web Inspector: TypeError:​ sourceCodeLocation.populateLiveDisplayLocationTooltip is not a function

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js (215754 => 215755)


--- trunk/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js	2017-04-25 20:33:39 UTC (rev 215754)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js	2017-04-25 20:38:00 UTC (rev 215755)
@@ -27,7 +27,7 @@
     if (WebInspector.dontLocalizeUserInterface)
         return;
 
-    var localizedStringsURL = InspectorFrontendHost.localizedStringsURL();
+    let localizedStringsURL = InspectorFrontendHost.localizedStringsURL();
     console.assert(localizedStringsURL);
     if (localizedStringsURL)
         document.write("<script src="" + localizedStringsURL + "\"></script>");
@@ -49,6 +49,9 @@
     if (window.localizedStrings && string in window.localizedStrings)
         return window.localizedStrings[string];
 
+    if (!window.localizedStrings)
+        console.error(`Attempted to load localized string "${string}" before localizedStrings was initialized.`);
+
     if (!this._missingLocalizedStrings)
         this._missingLocalizedStrings = {};
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (215754 => 215755)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2017-04-25 20:33:39 UTC (rev 215754)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2017-04-25 20:38:00 UTC (rev 215755)
@@ -112,6 +112,9 @@
     // This lets us save a state cookie before any managers or sidebars do any resets that would affect state (namely TimelineManager).
     WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ProvisionalLoadStarted, this._provisionalLoadStarted, this);
 
+    // Populate any UIStrings that must be done early after localized strings have loaded.
+    WebInspector.KeyboardShortcut.Key.Space._displayName = WebInspector.UIString("Space");
+
     // Create the singleton managers next, before the user interface elements, so the user interface can register
     // as event listeners on these managers.
     this.targetManager = new WebInspector.TargetManager;

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/KeyboardShortcut.js (215754 => 215755)


--- trunk/Source/WebInspectorUI/UserInterface/Models/KeyboardShortcut.js	2017-04-25 20:33:39 UTC (rev 215754)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/KeyboardShortcut.js	2017-04-25 20:38:00 UTC (rev 215755)
@@ -232,7 +232,7 @@
     Tab: new WebInspector.Key(9, "\u21e5"),
     Enter: new WebInspector.Key(13, "\u21a9"),
     Escape: new WebInspector.Key(27, "\u238b"),
-    Space: new WebInspector.Key(32, WebInspector.UIString("Space")),
+    Space: new WebInspector.Key(32, "Space"), // UIString populated in WebInspector.loaded.
     PageUp: new WebInspector.Key(33, "\u21de"),
     PageDown: new WebInspector.Key(34, "\u21df"),
     End: new WebInspector.Key(35, "\u2198"),

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (215754 => 215755)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2017-04-25 20:33:39 UTC (rev 215754)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2017-04-25 20:38:00 UTC (rev 215755)
@@ -691,7 +691,7 @@
 
     setCachedResponseBodySize(size)
     {
-        console.assert(!isNaN(size), "Size should be a valid number.")
+        console.assert(!isNaN(size), "Size should be a valid number.");
         console.assert(isNaN(this._cachedResponseBodySize), "This should only be set once.");
         console.assert(this._estimatedSize === size, "The legacy path was updated already and matches.");
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (215754 => 215755)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2017-04-25 20:33:39 UTC (rev 215754)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2017-04-25 20:38:00 UTC (rev 215755)
@@ -1789,7 +1789,7 @@
 
         contextMenu.appendItem(WebInspector.UIString("Reveal Breakpoint"), () => {
             let breakpointTreeElement = this.selfOrDescendant((treeElement) => treeElement.breakpointStatus && treeElement.breakpointStatus !== WebInspector.DOMTreeElement.BreakpointStatus.None);
-            console.assert(breakpointTreeElement, "Missing breakpoint descendant.", this)
+            console.assert(breakpointTreeElement, "Missing breakpoint descendant.", this);
             if (!breakpointTreeElement)
                 return;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to