Title: [98855] trunk/Source
Revision
98855
Author
pfeld...@chromium.org
Date
2011-10-31 07:32:40 -0700 (Mon, 31 Oct 2011)

Log Message

Web Inspector: move localization support into UIUtil.js, reduce externs.
https://bugs.webkit.org/show_bug.cgi?id=71220

Reviewed by Yury Semikhatsky.

Source/WebCore:

* inspector/compile-front-end.sh:
* inspector/front-end/AdvancedSearchController.js:
(WebInspector.SearchView.prototype.focus):
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype.afterShow):
* inspector/front-end/Drawer.js:
* inspector/front-end/GoToLineDialog.js:
(WebInspector.GoToLineDialog.prototype._hide):
* inspector/front-end/HelpScreen.js:
(WebInspector.HelpScreen.prototype.show):
(WebInspector.HelpScreen.prototype.hide):
(WebInspector.HelpScreen.prototype._onBlur):
* inspector/front-end/InspectorFrontendHostStub.js:
* inspector/front-end/KeyboardShortcut.js:
(WebInspector.KeyboardShortcut._keyName):
* inspector/front-end/Panel.js:
(WebInspector.Panel.prototype.wasShown):
* inspector/front-end/SearchController.js:
(WebInspector.SearchController.prototype._onSearchFieldManualFocus):
(WebInspector.SearchController.prototype._onKeyDown):
* inspector/front-end/Settings.js:
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
* inspector/front-end/Toolbar.js:
(WebInspector.Toolbar.prototype._toolbarDragStart):
* inspector/front-end/UIUtils.js:
(WebInspector.startEditing.cleanUpAfterEditing):
(WebInspector.startEditing.var):
(WebInspector.startEditing):
(WebInspector.UIString):
(WebInspector.useLowerCaseMenuTitles):
(WebInspector.platform):
(WebInspector.isMac):
(WebInspector.platformFlavor):
(WebInspector.port):
(WebInspector.installPortStyles):
(WebInspector._windowFocused):
(WebInspector._windowBlurred):
(WebInspector.previousFocusElement):
(WebInspector.currentFocusElement):
(WebInspector._focusChanged):
(WebInspector.setCurrentFocusElement):
* inspector/front-end/externs.js:
(Event.prototype.initWebKitWheelEvent):
(window.getComputedStyle):
(InspectorBackend.runAfterPendingDispatches):
* inspector/front-end/inspector.js:
(WebInspector.documentKeyDown):
(WebInspector.addMainEventListeners):

Source/WebKit/chromium:

* src/js/DevTools.js:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98854 => 98855)


--- trunk/Source/WebCore/ChangeLog	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/ChangeLog	2011-10-31 14:32:40 UTC (rev 98855)
@@ -1,3 +1,60 @@
+2011-10-31  Pavel Feldman  <pfeld...@google.com>
+
+        Web Inspector: move localization support into UIUtil.js, reduce externs.
+        https://bugs.webkit.org/show_bug.cgi?id=71220
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/compile-front-end.sh:
+        * inspector/front-end/AdvancedSearchController.js:
+        (WebInspector.SearchView.prototype.focus):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype.afterShow):
+        * inspector/front-end/Drawer.js:
+        * inspector/front-end/GoToLineDialog.js:
+        (WebInspector.GoToLineDialog.prototype._hide):
+        * inspector/front-end/HelpScreen.js:
+        (WebInspector.HelpScreen.prototype.show):
+        (WebInspector.HelpScreen.prototype.hide):
+        (WebInspector.HelpScreen.prototype._onBlur):
+        * inspector/front-end/InspectorFrontendHostStub.js:
+        * inspector/front-end/KeyboardShortcut.js:
+        (WebInspector.KeyboardShortcut._keyName):
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.wasShown):
+        * inspector/front-end/SearchController.js:
+        (WebInspector.SearchController.prototype._onSearchFieldManualFocus):
+        (WebInspector.SearchController.prototype._onKeyDown):
+        * inspector/front-end/Settings.js:
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        * inspector/front-end/Toolbar.js:
+        (WebInspector.Toolbar.prototype._toolbarDragStart):
+        * inspector/front-end/UIUtils.js:
+        (WebInspector.startEditing.cleanUpAfterEditing):
+        (WebInspector.startEditing.var):
+        (WebInspector.startEditing):
+        (WebInspector.UIString):
+        (WebInspector.useLowerCaseMenuTitles):
+        (WebInspector.platform):
+        (WebInspector.isMac):
+        (WebInspector.platformFlavor):
+        (WebInspector.port):
+        (WebInspector.installPortStyles):
+        (WebInspector._windowFocused):
+        (WebInspector._windowBlurred):
+        (WebInspector.previousFocusElement):
+        (WebInspector.currentFocusElement):
+        (WebInspector._focusChanged):
+        (WebInspector.setCurrentFocusElement):
+        * inspector/front-end/externs.js:
+        (Event.prototype.initWebKitWheelEvent):
+        (window.getComputedStyle):
+        (InspectorBackend.runAfterPendingDispatches):
+        * inspector/front-end/inspector.js:
+        (WebInspector.documentKeyDown):
+        (WebInspector.addMainEventListeners):
+
 2011-10-31  Andreas Kling  <kl...@webkit.org>
 
         Kill StyleBase.

Modified: trunk/Source/WebCore/inspector/compile-front-end.sh (98854 => 98855)


--- trunk/Source/WebCore/inspector/compile-front-end.sh	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/compile-front-end.sh	2011-10-31 14:32:40 UTC (rev 98855)
@@ -37,15 +37,14 @@
     --module jsmodule_util:2 \
         --js Source/WebCore/inspector/front-end/utilities.js \
         --js Source/WebCore/inspector/front-end/treeoutline.js \
-    --module jsmodule_host:1 \
-        --js Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js \
-    --module jsmodule_common:6:jsmodule_util,jsmodule_host \
+    --module jsmodule_common:7:jsmodule_util \
         --js Source/WebCore/inspector/front-end/BinarySearch.js \
         --js Source/WebCore/inspector/front-end/Object.js \
         --js Source/WebCore/inspector/front-end/PartialQuickSort.js \
         --js Source/WebCore/inspector/front-end/Settings.js \
         --js Source/WebCore/inspector/front-end/UserMetrics.js \
         --js Source/WebCore/inspector/front-end/HandlerRegistry.js \
+        --js Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js \
     --module jsmodule_sdk:25:jsmodule_common \
         --js Source/WebCore/inspector/front-end/CompilerSourceMapping.js \
         --js Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js \

Modified: trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -337,7 +337,7 @@
 
     focus: function()
     {
-        WebInspector.currentFocusElement = this._search;
+        WebInspector.setCurrentFocusElement(this._search);
         this._search.select();
     },
 
@@ -671,3 +671,8 @@
     this.file = file;
     this.searchMatches = searchMatches;
 }
+
+/**
+ * @type {WebInspector.AdvancedSearchController}
+ */
+WebInspector.advancedSearchController = null;
\ No newline at end of file

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleView.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -232,7 +232,7 @@
 
     afterShow: function()
     {
-        WebInspector.currentFocusElement = this.promptElement;
+        WebInspector.setCurrentFocusElement(this.promptElement);
     },
 
     storeScrollPositions: function()

Modified: trunk/Source/WebCore/inspector/front-end/Drawer.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/Drawer.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/Drawer.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -144,8 +144,8 @@
 
         this._savedHeight = this.element.offsetHeight;
 
-        if (this.element === WebInspector.currentFocusElement || this.element.isAncestor(WebInspector.currentFocusElement))
-            WebInspector.currentFocusElement = WebInspector.previousFocusElement;
+        if (this.element === WebInspector.currentFocusElement() || this.element.isAncestor(WebInspector.currentFocusElement()))
+            WebInspector.setCurrentFocusElement(WebInspector.previousFocusElement());
 
         var anchoredItems = document.getElementById("anchored-status-bar-items");
 

Modified: trunk/Source/WebCore/inspector/front-end/GoToLineDialog.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/GoToLineDialog.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/GoToLineDialog.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -64,8 +64,8 @@
     this._view = view;
     view.element.appendChild(this._element);
 
-    this._previousFocusElement = WebInspector.currentFocusElement;
-    WebInspector.currentFocusElement = this._input;
+    this._previousFocusElement = WebInspector.currentFocusElement();
+    WebInspector.setCurrentFocusElement(this._input);
     this._input.select();
 }
 
@@ -107,7 +107,7 @@
             return;
         this._isHiding = true;
 
-        WebInspector.currentFocusElement = this._previousFocusElement;
+        WebInspector.setCurrentFocusElement(this._previousFocusElement);
         WebInspector.GoToLineDialog._instance = null;
         this._element.parentElement.removeChild(this._element);
     },

Modified: trunk/Source/WebCore/inspector/front-end/HelpScreen.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/HelpScreen.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/HelpScreen.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -63,8 +63,8 @@
         document.body.appendChild(this._element);
         this._isShown = true;
         this._onHide = onHide;
-        this._previousFocusElement = WebInspector.currentFocusElement;
-        WebInspector.currentFocusElement = this.contentElement;
+        this._previousFocusElement = WebInspector.currentFocusElement();
+        WebInspector.setCurrentFocusElement(this.contentElement);
     },
 
     hide: function()
@@ -74,7 +74,7 @@
 
         this._isShown = false;
         document.body.removeChild(this._element);
-        WebInspector.currentFocusElement = this._previousFocusElement;
+        WebInspector.setCurrentFocusElement(this._previousFocusElement);
         if (this._onHide) {
             this._onHide();
             delete this._onHide;
@@ -93,6 +93,6 @@
     {
          // Pretend we're modal, grab focus back if we're still shown.
         if (this._isShown)
-            WebInspector.currentFocusElement = this.contentElement;
+            WebInspector.setCurrentFocusElement(this.contentElement);
     }
 }

Modified: trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -28,21 +28,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.PlatformFlavor = {
-    WindowsVista: "windows-vista",
-    MacTiger: "mac-tiger",
-    MacLeopard: "mac-leopard",
-    MacSnowLeopard: "mac-snowleopard"
-}
-
-WebInspector.isMac = function()
-{
-    if (typeof WebInspector._isMac === "undefined")
-        WebInspector._isMac = WebInspector.platform === "mac";
-
-    return WebInspector._isMac;
-}
-
 if (!window.InspectorFrontendHost) {
 
 /**
@@ -53,8 +38,6 @@
     this._attachedWindowHeight = 0;
 }
 
-WebInspector._platformFlavor = WebInspector.PlatformFlavor.MacLeopard;
-
 WebInspector.InspectorFrontendHostStub.prototype = {
     platform: function()
     {
@@ -170,5 +153,6 @@
 }
 
 var InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub();
+Preferences.localizeUI = false;
 
 }

Modified: trunk/Source/WebCore/inspector/front-end/KeyboardShortcut.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/KeyboardShortcut.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/KeyboardShortcut.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -142,7 +142,7 @@
         return key.toUpperCase();
     if (typeof key.name === "string")
         return key.name;
-    return key.name[WebInspector.platform] || key.name.other;
+    return key.name[WebInspector.platform()] || key.name.other;
 }
 
 WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers = function(keyCode, modifiers)

Modified: trunk/Source/WebCore/inspector/front-end/Panel.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/Panel.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/Panel.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -79,7 +79,7 @@
         if ("_toolbarItem" in this)
             this._toolbarItem.addStyleClass("toggled-on");
 
-        WebInspector.currentFocusElement = this.defaultFocusedElement;
+        WebInspector.setCurrentFocusElement(this.defaultFocusedElement);
 
         this.restoreSidebarWidth();
         WebInspector.extensionServer.notifyPanelShown(this.name);

Modified: trunk/Source/WebCore/inspector/front-end/SearchController.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/SearchController.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/SearchController.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -190,7 +190,7 @@
 
     _onSearchFieldManualFocus: function(event)
     {
-        WebInspector.currentFocusElement = event.target;
+        WebInspector.setCurrentFocusElement(event.target);
     },
 
     _onKeyDown: function(event)
@@ -200,15 +200,15 @@
             // If focus belongs here and text is empty - nothing to do, return unhandled.
             // When search was selected manually and is currently blank, we'd like Esc stay unhandled
             // and hit console drawer handler.
-            if (event.target.value === "" && WebInspector.currentFocusElement === WebInspector.previousFocusElement)
+            if (event.target.value === "" && WebInspector.currentFocusElement() === WebInspector.previousFocusElement())
                 return;
             event.preventDefault();
             event.stopPropagation();
 
             this.cancelSearch();
-            WebInspector.currentFocusElement = WebInspector.previousFocusElement;
-            if (WebInspector.currentFocusElement === event.target)
-                WebInspector.currentFocusElement.currentFocusElement.select();
+            WebInspector.setCurrentFocusElement(WebInspector.previousFocusElement());
+            if (WebInspector.currentFocusElement() === event.target)
+                WebInspector.currentFocusElement().select();
             return false;
         }
 

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -57,7 +57,8 @@
     canDisableCache: false,
     showNetworkPanelInitiatorColumn: false,
     haveExtensions: false,
-    sharedWorkersListURL: undefined
+    sharedWorkersListURL: undefined,
+    localizeUI: true
 }
 
 /**

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -43,7 +43,7 @@
     this._textModel = new WebInspector.TextEditorModel();
 
     var textViewerDelegate = new WebInspector.TextViewerDelegateForSourceFrame(this);
-    this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url, textViewerDelegate);
+    this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform(), this._url, textViewerDelegate);
 
     this.popoverHelper = new WebInspector.ObjectPopoverHelper(this._textViewer.element,
             this._getPopoverAnchor.bind(this), this.onShowPopover.bind(this), this.onHidePopover.bind(this), true);

Modified: trunk/Source/WebCore/inspector/front-end/Toolbar.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/Toolbar.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/Toolbar.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -67,7 +67,7 @@
 
     _toolbarDragStart: function(event)
     {
-        if ((!WebInspector.attached && WebInspector.platformFlavor !== WebInspector.PlatformFlavor.MacLeopard && WebInspector.platformFlavor !== WebInspector.PlatformFlavor.MacSnowLeopard) || WebInspector.port == "qt")
+        if ((!WebInspector.attached && WebInspector.platformFlavor() !== WebInspector.PlatformFlavor.MacLeopard && WebInspector.platformFlavor() !== WebInspector.PlatformFlavor.MacSnowLeopard) || WebInspector.port() == "qt")
             return;
 
         var target = event.target;

Modified: trunk/Source/WebCore/inspector/front-end/UIUtils.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/UIUtils.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/UIUtils.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -288,8 +288,8 @@
         if (pasteCallback)
             element.removeEventListener("paste", pasteEventListener, true);
 
-        if (element === WebInspector.currentFocusElement || element.isAncestor(WebInspector.currentFocusElement))
-            WebInspector.currentFocusElement = WebInspector.previousFocusElement;
+        if (element === WebInspector.currentFocusElement() || element.isAncestor(WebInspector.currentFocusElement()))
+            WebInspector.setCurrentFocusElement(WebInspector.previousFocusElement());
     }
 
     /** @this {Element} */
@@ -361,7 +361,7 @@
     if (pasteCallback)
         element.addEventListener("paste", pasteEventListener, true);
 
-    WebInspector.currentFocusElement = element;
+    WebInspector.setCurrentFocusElement(element);
     return {
         cancel: editingCancelled.bind(element),
         commit: editingCommitted.bind(element)
@@ -421,7 +421,35 @@
         return WebInspector.UIString("%.0fMB", megabytes);
 }
 
+WebInspector._missingLocalizedStrings = {};
 
+/**
+ * @param {string} string
+ * @param {...*} vararg
+ */
+WebInspector.UIString = function(string, vararg)
+{
+    if (Preferences.localizeUI) {
+        if (window.localizedStrings && string in window.localizedStrings)
+            string = window.localizedStrings[string];
+        else {
+            if (!(string in WebInspector._missingLocalizedStrings)) {
+                console.warn("Localized string \"" + string + "\" not found.");
+                WebInspector._missingLocalizedStrings[string] = true;
+            }
+    
+            if (Preferences.showMissingLocalizedStrings)
+                string += " (not localized)";
+        }
+    }
+    return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));
+}
+
+WebInspector.useLowerCaseMenuTitles = function()
+{
+    return WebInspector.platform() === "windows" && Preferences.useLowerCaseMenuTitlesOnWindows;
+}
+
 WebInspector.formatLocalized = function(format, substitutions, formatters, initialValue, append)
 {
     return String.format(WebInspector.UIString(format), substitutions, formatters, initialValue, append);
@@ -441,3 +469,142 @@
 {
     return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy link address" : "Copy Link Address");
 }
+
+WebInspector.platform = function()
+{
+    if (!WebInspector._platform)
+        WebInspector._platform = InspectorFrontendHost.platform();
+    return WebInspector._platform;
+}
+
+WebInspector.isMac = function()
+{
+    if (typeof WebInspector._isMac === "undefined")
+        WebInspector._isMac = WebInspector.platform() === "mac";
+
+    return WebInspector._isMac;
+}
+
+WebInspector.PlatformFlavor = {
+    WindowsVista: "windows-vista",
+    MacTiger: "mac-tiger",
+    MacLeopard: "mac-leopard",
+    MacSnowLeopard: "mac-snowleopard"
+}
+
+WebInspector.platformFlavor = function()
+{
+    function detectFlavor()
+    {
+        const userAgent = navigator.userAgent;
+
+        if (WebInspector.platform() === "windows") {
+            var match = userAgent.match(/Windows NT (\d+)\.(?:\d+)/);
+            if (match && match[1] >= 6)
+                return WebInspector.PlatformFlavor.WindowsVista;
+            return null;
+        } else if (WebInspector.platform() === "mac") {
+            var match = userAgent.match(/Mac OS X\s*(?:(\d+)_(\d+))?/);
+            if (!match || match[1] != 10)
+                return WebInspector.PlatformFlavor.MacSnowLeopard;
+            switch (Number(match[2])) {
+                case 4:
+                    return WebInspector.PlatformFlavor.MacTiger;
+                case 5:
+                    return WebInspector.PlatformFlavor.MacLeopard;
+                case 6:
+                default:
+                    return WebInspector.PlatformFlavor.MacSnowLeopard;
+            }
+        }
+    }
+
+    if (!WebInspector._platformFlavor)
+        WebInspector._platformFlavor = detectFlavor();
+
+    return WebInspector._platformFlavor;
+}
+
+WebInspector.port = function()
+{
+    if (!WebInspector._port)
+        WebInspector._port = InspectorFrontendHost.port();
+
+    return WebInspector._port;
+}
+
+WebInspector.installPortStyles = function()
+{
+    var platform = WebInspector.platform();
+    document.body.addStyleClass("platform-" + platform);
+    var flavor = WebInspector.platformFlavor();
+    if (flavor)
+        document.body.addStyleClass("platform-" + flavor);
+    var port = WebInspector.port();
+    document.body.addStyleClass("port-" + port);
+}
+
+WebInspector._windowFocused = function(event)
+{
+    if (event.target.document.nodeType === Node.DOCUMENT_NODE)
+        document.body.removeStyleClass("inactive");
+}
+
+WebInspector._windowBlurred = function(event)
+{
+    if (event.target.document.nodeType === Node.DOCUMENT_NODE)
+        document.body.addStyleClass("inactive");
+}
+
+WebInspector.previousFocusElement = function()
+{
+    return WebInspector._previousFocusElement;
+}
+
+WebInspector.currentFocusElement = function()
+{
+    return WebInspector._currentFocusElement;
+}
+
+WebInspector._focusChanged = function(event)
+{
+    WebInspector.setCurrentFocusElement(event.target);
+}
+
+WebInspector.setCurrentFocusElement = function(x)
+{
+    if (WebInspector._currentFocusElement !== x)
+        WebInspector._previousFocusElement = WebInspector._currentFocusElement;
+    WebInspector._currentFocusElement = x;
+
+    if (WebInspector._currentFocusElement) {
+        WebInspector._currentFocusElement.focus();
+
+        // Make a caret selection inside the new element if there isn't a range selection and
+        // there isn't already a caret selection inside.
+        var selection = window.getSelection();
+        if (selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCaretInside()) {
+            var selectionRange = WebInspector._currentFocusElement.ownerDocument.createRange();
+            selectionRange.setStart(WebInspector._currentFocusElement, 0);
+            selectionRange.setEnd(WebInspector._currentFocusElement, 0);
+
+            selection.removeAllRanges();
+            selection.addRange(selectionRange);
+        }
+    } else if (WebInspector._previousFocusElement)
+        WebInspector._previousFocusElement.blur();
+}
+
+;(function() {
+
+function windowLoaded()
+{
+    window.addEventListener("focus", WebInspector._windowFocused, false);
+    window.addEventListener("blur", WebInspector._windowBlurred, false);
+    document.addEventListener("focus", WebInspector._focusChanged.bind(this), true);
+    window.removeEventListener("DOMContentLoaded", windowLoaded, false);
+}
+
+window.addEventListener("DOMContentLoaded", windowLoaded, false);
+
+})();

Modified: trunk/Source/WebCore/inspector/front-end/externs.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/externs.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/externs.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -28,6 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+// WebKit Web Facing API
 var console = {}
 /** @param {...*} vararg */
 console.warn = function(vararg) {}
@@ -37,46 +38,49 @@
 console.error = function(vararg) {}
 console.trace = function() {}
 
-var WebInspector = {}
-
-/**
- * @param {string} str
- * @param {...*} varArgs
- */
-WebInspector.UIString = function(str, varArgs) {}
-var InspectorBackend = {}
-InspectorBackend.runAfterPendingDispatches = function(message) {}
-
 var JSON = {}
 /** @param {string} str */
 JSON.parse = function(str) {}
-
 /** @param {Object} obj */
 /** @return {string} */
 JSON.stringify = function(str) {}
 
-/**
- * @param {boolean=} param
- */
+/** @param {boolean=} param */
 Element.prototype.scrollIntoViewIfNeeded = function(param) {}
+/** @type {boolean} */
+Event.prototype.isMetaOrCtrlForTest = false;
+/** @param {...*} vararg */
+Event.prototype.initWebKitWheelEvent = function(vararg) {}
+/** @param {Element} element */
+window.getComputedStyle = function(element) {}
 
-/**
- * @param {boolean=} onlyFirst
- */
+/** @param {boolean=} onlyFirst */
 Array.prototype.remove = function(obj, onlyFirst) {}
-
 Array.prototype.keySet = function() {}
 
+DOMApplicationCache.prototype.UNCACHED = 0;
+DOMApplicationCache.prototype.IDLE = 1;
+DOMApplicationCache.prototype.CHECKING = 2;
+DOMApplicationCache.prototype.DOWNLOADING = 3;
+DOMApplicationCache.prototype.UPDATEREADY = 4;
+DOMApplicationCache.prototype.OBSOLETE = 5;
+
+
+
+// Inspector Backend
+var InspectorBackend = {}
+InspectorBackend.runAfterPendingDispatches = function(message) {}
+
+
+// FIXME: remove everything below.
+var WebInspector = {}
+
 WebInspector.extensionServer = {}
 WebInspector.extensionServer.notifyResourceContentCommitted = function(resource, content) {}
 WebInspector.extensionServer.notifyPanelShown = function(panel) {}
 WebInspector.extensionServer.notifyPanelHidden = function(panel) {}
 WebInspector.extensionServer.notifyObjectSelected = function(object) {}
 
-WebInspector.debuggerPresentationModel = {
-    linkifyLocation: function(url, lineNumber, columnNumber, className) {}
-}
-
 /**
  * @param {NetworkAgent.RequestId} requestId
  * @return {?WebInspector.Resource}
@@ -85,13 +89,6 @@
 {
 }
 
-/**
- * @return {boolean}
- */
-WebInspector.useLowerCaseMenuTitles = function()
-{
-}
-
 WebInspector.panels = {};
 
 /**
@@ -110,44 +107,12 @@
 WebInspector.setCurrentPanel = function(panel) {}
 
 /**
- * @type {?Element}
- */
-WebInspector.currentFocusElement = null;
-
-/**
- * @type {?Element}
- */
-WebInspector.previousFocusElement = null;
-
-/**
  * @param {WebInspector.View} view
  */
 WebInspector.showViewInDrawer = function(view) {}
 
-/**
- * @type {WebInspector.AdvancedSearchController}
- */
-WebInspector.advancedSearchController = null;
 
 /**
- * @type {string}
- */
-WebInspector.platformFlavor = "";
-
-/** @param {Element} element */
-window.getComputedStyle = function(element) {}
-
-/**
- * @type {boolean}
- */
-Event.prototype.isMetaOrCtrlForTest = false;
-
-/**
- * @param {...*} vararg
- */
-Event.prototype.initWebKitWheelEvent = function(vararg) {}
-
-/**
  * @param {string=} messageLevel
  * @param {boolean=} showConsole
  */
@@ -157,13 +122,6 @@
 
 WebInspector.openResource = function(url, external) {}
 
-DOMApplicationCache.prototype.UNCACHED = 0;
-DOMApplicationCache.prototype.IDLE = 1;
-DOMApplicationCache.prototype.CHECKING = 2;
-DOMApplicationCache.prototype.DOWNLOADING = 3;
-DOMApplicationCache.prototype.UPDATEREADY = 4;
-DOMApplicationCache.prototype.OBSOLETE = 5;
-
 WebInspector.openRequestInNetworkPanel = function(request) {}
 
 var InjectedFakeWorker = function() {}

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (98854 => 98855)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -29,95 +29,6 @@
  */
 
 var WebInspector = {
-    resources: {},
-    missingLocalizedStrings: {},
-    pendingDispatches: 0,
-
-    get platform()
-    {
-        if (!("_platform" in this))
-            this._platform = InspectorFrontendHost.platform();
-
-        return this._platform;
-    },
-
-    get platformFlavor()
-    {
-        if (!("_platformFlavor" in this))
-            this._platformFlavor = this._detectPlatformFlavor();
-
-        return this._platformFlavor;
-    },
-
-    _detectPlatformFlavor: function()
-    {
-        const userAgent = navigator.userAgent;
-
-        if (this.platform === "windows") {
-            var match = userAgent.match(/Windows NT (\d+)\.(?:\d+)/);
-            if (match && match[1] >= 6)
-                return WebInspector.PlatformFlavor.WindowsVista;
-            return null;
-        } else if (this.platform === "mac") {
-            var match = userAgent.match(/Mac OS X\s*(?:(\d+)_(\d+))?/);
-            if (!match || match[1] != 10)
-                return WebInspector.PlatformFlavor.MacSnowLeopard;
-            switch (Number(match[2])) {
-                case 4:
-                    return WebInspector.PlatformFlavor.MacTiger;
-                case 5:
-                    return WebInspector.PlatformFlavor.MacLeopard;
-                case 6:
-                default:
-                    return WebInspector.PlatformFlavor.MacSnowLeopard;
-            }
-        }
-
-        return null;
-    },
-
-    get port()
-    {
-        if (!("_port" in this))
-            this._port = InspectorFrontendHost.port();
-
-        return this._port;
-    },
-
-    get previousFocusElement()
-    {
-        return this._previousFocusElement;
-    },
-
-    get currentFocusElement()
-    {
-        return this._currentFocusElement;
-    },
-
-    set currentFocusElement(x)
-    {
-        if (this._currentFocusElement !== x)
-            this._previousFocusElement = this._currentFocusElement;
-        this._currentFocusElement = x;
-
-        if (this._currentFocusElement) {
-            this._currentFocusElement.focus();
-
-            // Make a caret selection inside the new element if there isn't a range selection and
-            // there isn't already a caret selection inside.
-            var selection = window.getSelection();
-            if (selection.isCollapsed && !this._currentFocusElement.isInsertionCaretInside()) {
-                var selectionRange = this._currentFocusElement.ownerDocument.createRange();
-                selectionRange.setStart(this._currentFocusElement, 0);
-                selectionRange.setEnd(this._currentFocusElement, 0);
-
-                selection.removeAllRanges();
-                selection.addRange(selectionRange);
-            }
-        } else if (this._previousFocusElement)
-            this._previousFocusElement.blur();
-    },
-
     currentPanel: function()
     {
         return this._currentPanel;
@@ -445,13 +356,8 @@
 {
     InspectorFrontendHost.loaded();
 
-    var platform = WebInspector.platform;
-    document.body.addStyleClass("platform-" + platform);
-    var flavor = WebInspector.platformFlavor;
-    if (flavor)
-        document.body.addStyleClass("platform-" + flavor);
-    var port = WebInspector.port;
-    document.body.addStyleClass("port-" + port);
+    WebInspector.installPortStyles();
+
     if (WebInspector.socket)
         document.body.addStyleClass("remote");
 
@@ -584,29 +490,6 @@
     this.toolbar.resize();
 }
 
-WebInspector.windowFocused = function(event)
-{
-    // Fires after blur, so when focusing on either the main inspector
-    // or an <iframe> within the inspector we should always remove the
-    // "inactive" class.
-    if (event.target.document.nodeType === Node.DOCUMENT_NODE)
-        document.body.removeStyleClass("inactive");
-}
-
-WebInspector.windowBlurred = function(event)
-{
-    // Leaving the main inspector or an <iframe> within the inspector.
-    // We can add "inactive" now, and if we are moving the focus to another
-    // part of the inspector then windowFocused will correct this.
-    if (event.target.document.nodeType === Node.DOCUMENT_NODE)
-        document.body.addStyleClass("inactive");
-}
-
-WebInspector.focusChanged = function(event)
-{
-    this.currentFocusElement = event.target;
-}
-
 WebInspector.setAttachedWindow = function(attached)
 {
     this.attached = attached;
@@ -727,8 +610,8 @@
         return;
     }
 
-    if (this.currentFocusElement && this.currentFocusElement.handleKeyEvent) {
-        this.currentFocusElement.handleKeyEvent(event);
+    if (WebInspector.currentFocusElement() && WebInspector.currentFocusElement().handleKeyEvent) {
+        WebInspector.currentFocusElement().handleKeyEvent(event);
         if (event.handled) {
             event.preventDefault();
             return;
@@ -1050,14 +933,10 @@
 
 WebInspector.addMainEventListeners = function(doc)
 {
-    doc.addEventListener("focus", this.focusChanged.bind(this), true);
     doc.addEventListener("keydown", this.documentKeyDown.bind(this), false);
     doc.addEventListener("beforecopy", this.documentCanCopy.bind(this), true);
     doc.addEventListener("copy", this.documentCopy.bind(this), true);
     doc.addEventListener("contextmenu", this.contextMenuEventFired.bind(this), true);
-
-    doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), false);
-    doc.defaultView.addEventListener("blur", this.windowBlurred.bind(this), false);
     doc.addEventListener("click", this.documentClick.bind(this), true);
 }
 
@@ -1067,29 +946,6 @@
     this.reset();
 }
 
-WebInspector.UIString = function(string)
-{
-    if (window.localizedStrings && string in window.localizedStrings)
-        string = window.localizedStrings[string];
-    else {
-        if (!(string in WebInspector.missingLocalizedStrings)) {
-            if (!WebInspector.InspectorBackendStub)
-                console.warn("Localized string \"" + string + "\" not found.");
-            WebInspector.missingLocalizedStrings[string] = true;
-        }
-
-        if (Preferences.showMissingLocalizedStrings)
-            string += " (not localized)";
-    }
-
-    return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));
-}
-
-WebInspector.useLowerCaseMenuTitles = function()
-{
-    return WebInspector.platform === "windows" && Preferences.useLowerCaseMenuTitlesOnWindows;
-}
-
 WebInspector._toolbarItemClicked = function(event)
 {
     var toolbarItem = event.currentTarget;

Modified: trunk/Source/WebKit/chromium/ChangeLog (98854 => 98855)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-10-31 14:32:40 UTC (rev 98855)
@@ -1,3 +1,12 @@
+2011-10-31  Pavel Feldman  <pfeld...@google.com>
+
+        Web Inspector: move localization support into UIUtil.js, reduce externs.
+        https://bugs.webkit.org/show_bug.cgi?id=71220
+
+        Reviewed by Yury Semikhatsky.
+
+        * src/js/DevTools.js:
+
 2011-10-31  Adam Barth  <aba...@webkit.org>
 
         [Chromium] The Chromium port calls OwnPtr::get and RefPtr::get way more often than needed

Modified: trunk/Source/WebKit/chromium/src/js/DevTools.js (98854 => 98855)


--- trunk/Source/WebKit/chromium/src/js/DevTools.js	2011-10-31 14:15:09 UTC (rev 98854)
+++ trunk/Source/WebKit/chromium/src/js/DevTools.js	2011-10-31 14:32:40 UTC (rev 98855)
@@ -58,6 +58,7 @@
     Preferences.showNetworkPanelInitiatorColumn = true;
     Preferences.haveExtensions = true;
     Preferences.sharedWorkersListURL = "chrome://workers/";
+    Preferences.localizeUI = false;
 })();
 
 // Recognize WebP as a valid image mime type.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to