diff options
author | nsylvain@google.com <nsylvain@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-27 03:39:08 +0000 |
---|---|---|
committer | nsylvain@google.com <nsylvain@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-27 03:39:08 +0000 |
commit | fcb205c6833804f93a7c839c7171a9063ae27f4f (patch) | |
tree | 0f5229014f4001f437ef8f95734af380e1e919c6 /chrome/tools/test | |
parent | 6edf302b20907adad845bd0bcae80ffc5f905571 (diff) | |
download | chromium_src-fcb205c6833804f93a7c839c7171a9063ae27f4f.zip chromium_src-fcb205c6833804f93a7c839c7171a9063ae27f4f.tar.gz chromium_src-fcb205c6833804f93a7c839c7171a9063ae27f4f.tar.bz2 |
Add a reference build at version #21.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools/test')
163 files changed, 12279 insertions, 0 deletions
diff --git a/chrome/tools/test/reference_build/chrome/First Run b/chrome/tools/test/reference_build/chrome/First Run new file mode 100644 index 0000000..852ad16 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/First Run @@ -0,0 +1 @@ +krome
diff --git a/chrome/tools/test/reference_build/chrome/chrome.dll b/chrome/tools/test/reference_build/chrome/chrome.dll Binary files differnew file mode 100644 index 0000000..15cdcc7 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/chrome.dll diff --git a/chrome/tools/test/reference_build/chrome/chrome.exe b/chrome/tools/test/reference_build/chrome/chrome.exe Binary files differnew file mode 100644 index 0000000..d21a355 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/chrome.exe diff --git a/chrome/tools/test/reference_build/chrome/chrome_dll.pdb b/chrome/tools/test/reference_build/chrome/chrome_dll.pdb Binary files differnew file mode 100644 index 0000000..22037a0 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/chrome_dll.pdb diff --git a/chrome/tools/test/reference_build/chrome/chrome_exe.pdb b/chrome/tools/test/reference_build/chrome/chrome_exe.pdb Binary files differnew file mode 100644 index 0000000..46f8634 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/chrome_exe.pdb diff --git a/chrome/tools/test/reference_build/chrome/crash_service.exe b/chrome/tools/test/reference_build/chrome/crash_service.exe Binary files differnew file mode 100644 index 0000000..165b623 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/crash_service.exe diff --git a/chrome/tools/test/reference_build/chrome/icudt38.dll b/chrome/tools/test/reference_build/chrome/icudt38.dll Binary files differnew file mode 100644 index 0000000..4acc4c5 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/icudt38.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/ar.dll b/chrome/tools/test/reference_build/chrome/locales/ar.dll Binary files differnew file mode 100644 index 0000000..e2db626 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/ar.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/bg.dll b/chrome/tools/test/reference_build/chrome/locales/bg.dll Binary files differnew file mode 100644 index 0000000..75805c1 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/bg.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/ca.dll b/chrome/tools/test/reference_build/chrome/locales/ca.dll Binary files differnew file mode 100644 index 0000000..5d9a9c1 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/ca.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/cs.dll b/chrome/tools/test/reference_build/chrome/locales/cs.dll Binary files differnew file mode 100644 index 0000000..1384ca5 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/cs.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/da.dll b/chrome/tools/test/reference_build/chrome/locales/da.dll Binary files differnew file mode 100644 index 0000000..404be03 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/da.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/de.dll b/chrome/tools/test/reference_build/chrome/locales/de.dll Binary files differnew file mode 100644 index 0000000..d150a9f --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/de.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/el.dll b/chrome/tools/test/reference_build/chrome/locales/el.dll Binary files differnew file mode 100644 index 0000000..ada1908 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/el.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/en-GB.dll b/chrome/tools/test/reference_build/chrome/locales/en-GB.dll Binary files differnew file mode 100644 index 0000000..017fc64 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/en-GB.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/en-US.dll b/chrome/tools/test/reference_build/chrome/locales/en-US.dll Binary files differnew file mode 100644 index 0000000..97a25b0 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/en-US.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/es-419.dll b/chrome/tools/test/reference_build/chrome/locales/es-419.dll Binary files differnew file mode 100644 index 0000000..b5b0df9 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/es-419.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/es.dll b/chrome/tools/test/reference_build/chrome/locales/es.dll Binary files differnew file mode 100644 index 0000000..dcf572d --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/es.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/et.dll b/chrome/tools/test/reference_build/chrome/locales/et.dll Binary files differnew file mode 100644 index 0000000..36ea580 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/et.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/fi.dll b/chrome/tools/test/reference_build/chrome/locales/fi.dll Binary files differnew file mode 100644 index 0000000..91f894e --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/fi.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/fil.dll b/chrome/tools/test/reference_build/chrome/locales/fil.dll Binary files differnew file mode 100644 index 0000000..ff8aade --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/fil.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/fr.dll b/chrome/tools/test/reference_build/chrome/locales/fr.dll Binary files differnew file mode 100644 index 0000000..047f576 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/fr.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/he.dll b/chrome/tools/test/reference_build/chrome/locales/he.dll Binary files differnew file mode 100644 index 0000000..161a0e1 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/he.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/hi.dll b/chrome/tools/test/reference_build/chrome/locales/hi.dll Binary files differnew file mode 100644 index 0000000..f55ea3e --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/hi.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/hr.dll b/chrome/tools/test/reference_build/chrome/locales/hr.dll Binary files differnew file mode 100644 index 0000000..30a8c5f --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/hr.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/hu.dll b/chrome/tools/test/reference_build/chrome/locales/hu.dll Binary files differnew file mode 100644 index 0000000..d9f0343 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/hu.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/id.dll b/chrome/tools/test/reference_build/chrome/locales/id.dll Binary files differnew file mode 100644 index 0000000..6ce37e8 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/id.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/it.dll b/chrome/tools/test/reference_build/chrome/locales/it.dll Binary files differnew file mode 100644 index 0000000..e4477b7 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/it.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/ja.dll b/chrome/tools/test/reference_build/chrome/locales/ja.dll Binary files differnew file mode 100644 index 0000000..ba2d7b3 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/ja.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/ko.dll b/chrome/tools/test/reference_build/chrome/locales/ko.dll Binary files differnew file mode 100644 index 0000000..a4a96ec --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/ko.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/lt.dll b/chrome/tools/test/reference_build/chrome/locales/lt.dll Binary files differnew file mode 100644 index 0000000..e6830a5d6 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/lt.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/lv.dll b/chrome/tools/test/reference_build/chrome/locales/lv.dll Binary files differnew file mode 100644 index 0000000..da1e650 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/lv.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/nb.dll b/chrome/tools/test/reference_build/chrome/locales/nb.dll Binary files differnew file mode 100644 index 0000000..7e35028 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/nb.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/nl.dll b/chrome/tools/test/reference_build/chrome/locales/nl.dll Binary files differnew file mode 100644 index 0000000..7da3012 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/nl.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/pl.dll b/chrome/tools/test/reference_build/chrome/locales/pl.dll Binary files differnew file mode 100644 index 0000000..e2c46d5 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/pl.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/pt-BR.dll b/chrome/tools/test/reference_build/chrome/locales/pt-BR.dll Binary files differnew file mode 100644 index 0000000..2ae51c7 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/pt-BR.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/pt-PT.dll b/chrome/tools/test/reference_build/chrome/locales/pt-PT.dll Binary files differnew file mode 100644 index 0000000..53e600c --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/pt-PT.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/ro.dll b/chrome/tools/test/reference_build/chrome/locales/ro.dll Binary files differnew file mode 100644 index 0000000..1593f94 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/ro.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/ru.dll b/chrome/tools/test/reference_build/chrome/locales/ru.dll Binary files differnew file mode 100644 index 0000000..263b7e8 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/ru.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/sk.dll b/chrome/tools/test/reference_build/chrome/locales/sk.dll Binary files differnew file mode 100644 index 0000000..a62232c --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/sk.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/sl.dll b/chrome/tools/test/reference_build/chrome/locales/sl.dll Binary files differnew file mode 100644 index 0000000..def9521 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/sl.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/sr.dll b/chrome/tools/test/reference_build/chrome/locales/sr.dll Binary files differnew file mode 100644 index 0000000..49186bf --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/sr.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/sv.dll b/chrome/tools/test/reference_build/chrome/locales/sv.dll Binary files differnew file mode 100644 index 0000000..f928889 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/sv.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/th.dll b/chrome/tools/test/reference_build/chrome/locales/th.dll Binary files differnew file mode 100644 index 0000000..4839e38 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/th.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/tr.dll b/chrome/tools/test/reference_build/chrome/locales/tr.dll Binary files differnew file mode 100644 index 0000000..555f900 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/tr.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/uk.dll b/chrome/tools/test/reference_build/chrome/locales/uk.dll Binary files differnew file mode 100644 index 0000000..b1b0bf2 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/uk.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/vi.dll b/chrome/tools/test/reference_build/chrome/locales/vi.dll Binary files differnew file mode 100644 index 0000000..d154e7a --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/vi.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/zh-CN.dll b/chrome/tools/test/reference_build/chrome/locales/zh-CN.dll Binary files differnew file mode 100644 index 0000000..a0df3f3 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/zh-CN.dll diff --git a/chrome/tools/test/reference_build/chrome/locales/zh-TW.dll b/chrome/tools/test/reference_build/chrome/locales/zh-TW.dll Binary files differnew file mode 100644 index 0000000..b357ed8 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/locales/zh-TW.dll diff --git a/chrome/tools/test/reference_build/chrome/plugins/gears/gears.dll b/chrome/tools/test/reference_build/chrome/plugins/gears/gears.dll Binary files differnew file mode 100644 index 0000000..319f3c1 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/plugins/gears/gears.dll diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/BreakpointsSidebarPane.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/BreakpointsSidebarPane.js new file mode 100644 index 0000000..3bb33dc --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/BreakpointsSidebarPane.js @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.BreakpointsSidebarPane = function() +{ + WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints")); +} + +WebInspector.BreakpointsSidebarPane.prototype = { + +} + +WebInspector.BreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/CallStackSidebarPane.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/CallStackSidebarPane.js new file mode 100644 index 0000000..849e562d --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/CallStackSidebarPane.js @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.CallStackSidebarPane = function() +{ + WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); +} + +WebInspector.CallStackSidebarPane.prototype = { + +} + +WebInspector.CallStackSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Console.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/Console.js new file mode 100644 index 0000000..1292531 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Console.js @@ -0,0 +1,701 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.Console = function() +{ + this.messages = []; + + WebInspector.View.call(this, document.getElementById("console")); + + this.messagesElement = document.getElementById("console-messages"); + this.messagesElement.addEventListener("selectstart", this._messagesSelectStart.bind(this), false); + this.messagesElement.addEventListener("click", this._messagesClicked.bind(this), true); + + // The messagesElement is the focusable element so clicking anywhere in the + // console area will focus the prompt. + this.messagesElement.focused = this._messagesFocused.bind(this); + this.messagesElement.handleKeyEvent = this._promptKeyDown.bind(this); + + this.promptElement = document.getElementById("console-prompt"); + this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), " .=:[({;"); + + this.toggleButton = document.getElementById("console-status-bar-item"); + this.toggleButton.title = WebInspector.UIString("Show console."); + this.toggleButton.addEventListener("click", this._toggleButtonClicked.bind(this), false); + + this.clearButton = document.getElementById("clear-console-status-bar-item"); + this.clearButton.title = WebInspector.UIString("Clear console log."); + this.clearButton.addEventListener("click", this._clearButtonClicked.bind(this), false); + + document.getElementById("main-status-bar").addEventListener("mousedown", this._startStatusBarDragging.bind(this), true); +} + +WebInspector.Console.prototype = { + show: function() + { + if (this._animating || this.visible) + return; + + WebInspector.View.prototype.show.call(this); + + this._animating = true; + + this.toggleButton.addStyleClass("toggled-on"); + this.toggleButton.title = WebInspector.UIString("Hide console."); + + document.body.addStyleClass("console-visible"); + + var anchoredItems = document.getElementById("anchored-status-bar-items"); + // Temporally set properties and classes to mimic the post-animation values so panels + // like Elements in their updateStatusBarItems call will size things to fit the final location. + document.getElementById("main-status-bar").style.setProperty("padding-left", (anchoredItems.offsetWidth - 1) + "px"); + document.body.removeStyleClass("console-visible"); + if ("updateStatusBarItems" in WebInspector.currentPanel) + WebInspector.currentPanel.updateStatusBarItems(); + document.body.addStyleClass("console-visible"); + var animations = [ + {element: document.getElementById("main"), end: {bottom: this.element.offsetHeight}}, + {element: document.getElementById("main-status-bar"), start: {"padding-left": anchoredItems.offsetWidth - 1}, end: {"padding-left": 0}}, + {element: document.getElementById("other-console-status-bar-items"), start: {opacity: 0}, end: {opacity: 1}} + ]; + + var consoleStatusBar = document.getElementById("console-status-bar"); + consoleStatusBar.insertBefore(anchoredItems, consoleStatusBar.firstChild); + + function animationFinished() + { + if ("updateStatusBarItems" in WebInspector.currentPanel) + WebInspector.currentPanel.updateStatusBarItems(); + WebInspector.currentFocusElement = this.messagesElement; + delete this._animating; + } + + WebInspector.animateStyle(animations, window.event && window.event.shiftKey ? 2000 : 250, animationFinished.bind(this)); + + if (!this.prompt.isCaretInsidePrompt()) + this.prompt.moveCaretToEndOfPrompt(); + }, + + hide: function() + { + if (this._animating || !this.visible) + return; + + WebInspector.View.prototype.hide.call(this); + + this._animating = true; + + this.toggleButton.removeStyleClass("toggled-on"); + this.toggleButton.title = WebInspector.UIString("Show console."); + + if (WebInspector.currentFocusElement === this.messagesElement) + WebInspector.currentFocusElement = this._previousFocusElement; + delete this._previousFocusElement; + + var anchoredItems = document.getElementById("anchored-status-bar-items"); + + var animations = [ + {element: document.getElementById("main"), end: {bottom: 0}}, + {element: document.getElementById("main-status-bar"), start: {"padding-left": 0}, end: {"padding-left": anchoredItems.offsetWidth - 1}}, + {element: document.getElementById("other-console-status-bar-items"), start: {opacity: 1}, end: {opacity: 0}} + ]; + + function animationFinished() + { + var mainStatusBar = document.getElementById("main-status-bar"); + mainStatusBar.insertBefore(anchoredItems, mainStatusBar.firstChild); + mainStatusBar.style.removeProperty("padding-left"); + document.body.removeStyleClass("console-visible"); + delete this._animating; + } + + WebInspector.animateStyle(animations, window.event && window.event.shiftKey ? 2000 : 250, animationFinished.bind(this)); + }, + + addMessage: function(msg) + { + if (msg.url in WebInspector.resourceURLMap) { + msg.resource = WebInspector.resourceURLMap[msg.url]; + WebInspector.panels.resources.addMessageToResource(msg.resource, msg); + } else { + // If the resource was loaded before the inspector, we still want to + // add to the global error/warning counts. Normally, this is done + // through the resource. + switch (msg.level) { + case WebInspector.ConsoleMessage.MessageLevel.Warning: + ++WebInspector.warnings; + break; + case WebInspector.ConsoleMessage.MessageLevel.Error: + ++WebInspector.errors; + break; + } + } + + this.messages.push(msg); + + var element = msg.toMessageElement(); + this.messagesElement.insertBefore(element, this.promptElement); + this.promptElement.scrollIntoView(false); + }, + + clearMessages: function() + { + WebInspector.panels.resources.clearMessages(); + + this.messages = []; + + while (this.messagesElement.firstChild != this.promptElement) + this.messagesElement.removeChild(this.messagesElement.firstChild); + + // Note: If the resources are loaded, panels.resources.clearMessages() + // will reset each resource's warning/error count to 0, which will in + // turn reset the global counters. But if we don't have the resources + // loaded, then this needs to be done manually here. We could do this + // only in the case of !WebInspector.panels.resources, but there are + // edge cases to handle with some resources loaded and some not, and + // since this is just a reset to 0, its safe to do it twice. + WebInspector.warnings = 0; + WebInspector.errors = 0; + }, + + completions: function(wordRange, bestMatchOnly) + { + // Pass less characters to scanBackwards so the range will be a more complete expression. + var expression = this.prompt.scanBackwards(" =:{;", wordRange.startContainer, wordRange.startOffset); + var expressionString = expression.toString(); + var lastIndex = expressionString.length - 1; + + var dotNotation = (expressionString[lastIndex] === "."); + var bracketNotation = (expressionString[lastIndex] === "["); + + if (dotNotation || bracketNotation) + expressionString = expressionString.substr(0, lastIndex); + + var prefix = wordRange.toString(); + if (!expressionString && !prefix) + return; + + var result = InspectorController.inspectedWindow(); + if (expressionString) { + try { + result = this._evalInInspectedWindow(expressionString); + } catch(e) { + // Do nothing, the prefix will be considered a window property. + } + } + + if (bracketNotation) { + if (prefix.length && prefix[0] === "'") + var quoteUsed = "'"; + else + var quoteUsed = "\""; + } + + var results = []; + var properties = Object.sortedProperties(result); + for (var i = 0; i < properties.length; ++i) { + var property = properties[i]; + if (bracketNotation) + property = quoteUsed + property.escapeCharacters(quoteUsed + "\\") + quoteUsed + "]"; + if (property.length < prefix.length) + continue; + if (property.indexOf(prefix) !== 0) + continue; + results.push(property); + if (bestMatchOnly) + break; + } + + return results; + }, + + _toggleButtonClicked: function() + { + this.visible = !this.visible; + }, + + _clearButtonClicked: function() + { + this.clearMessages(); + }, + + _messagesSelectStart: function(event) + { + if (this._selectionTimeout) + clearTimeout(this._selectionTimeout); + + this.prompt.clearAutoComplete(); + + function moveBackIfOutside() + { + delete this._selectionTimeout; + if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCollapsed) + this.prompt.moveCaretToEndOfPrompt(); + this.prompt.autoCompleteSoon(); + } + + this._selectionTimeout = setTimeout(moveBackIfOutside.bind(this), 100); + }, + + _messagesClicked: function(event) + { + var link = event.target.enclosingNodeOrSelfWithNodeName("a"); + if (!link) { + return; + } else if (!link.representedNode) { + // TODO(jparent): Be more user friendly here. Can we at least + // navigate to a cached view of the resource? + alert("Please load this page with the inspector open to view resources."); + event.preventDefault(); + return; + } + + WebInspector.updateFocusedNode(link.representedNode); + event.stopPropagation(); + event.preventDefault(); + }, + + _promptKeyDown: function(event) + { + switch (event.keyIdentifier) { + case "Enter": + this._enterKeyPressed(event); + return; + } + + this.prompt.handleKeyEvent(event); + }, + + _messagesFocused: function(previousFocusElement) + { + this._previousFocusElement = previousFocusElement; + if (!this.prompt.isCaretInsidePrompt()) + this.prompt.moveCaretToEndOfPrompt(); + }, + + _startStatusBarDragging: function(event) + { + if (!this.visible || event.target !== document.getElementById("main-status-bar")) + return; + + WebInspector.elementDragStart(document.getElementById("main-status-bar"), this._statusBarDragging.bind(this), this._endStatusBarDragging.bind(this), event, "row-resize"); + + this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop; + + event.stopPropagation(); + }, + + _statusBarDragging: function(event) + { + var mainElement = document.getElementById("main"); + + var height = window.innerHeight - event.pageY + this._statusBarDragOffset; + height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - mainElement.totalOffsetTop - Preferences.minConsoleHeight); + + mainElement.style.bottom = height + "px"; + this.element.style.height = height + "px"; + + event.preventDefault(); + event.stopPropagation(); + }, + + _endStatusBarDragging: function(event) + { + WebInspector.elementDragEnd(event); + + delete this._statusBarDragOffset; + + event.stopPropagation(); + }, + + _evalInInspectedWindow: function(expression) + { + return InspectorController.inspectedWindow().eval(expression); + }, + + _enterKeyPressed: function(event) + { + if (event.altKey) + return; + + event.preventDefault(); + event.stopPropagation(); + + this.prompt.clearAutoComplete(true); + + var str = this.prompt.text; + if (!str.length) + return; + + var result; + var exception = false; + try { + result = this._evalInInspectedWindow(str); + } catch(e) { + result = e; + exception = true; + } + + this.prompt.history.push(str); + this.prompt.historyOffset = 0; + this.prompt.text = ""; + + var level = exception ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log; + this.addMessage(new WebInspector.ConsoleCommand(str, result, this._format(result), level)); + }, + + _format: function(output, plaintext) + { + var type = Object.type(output, InspectorController.inspectedWindow()); + if (type === "object") { + if (output instanceof InspectorController.inspectedWindow().Node) + type = "node"; + } + + // We don't perform any special formatting on these types, so we just + // pass them through the simple _formatvalue function. + var undecoratedTypes = { + "undefined": 1, + "null": 1, + "boolean": 1, + "number": 1, + "date": 1, + "function": 1, + }; + + var formatter; + if (type in undecoratedTypes) + formatter = "_formatvalue"; + else { + formatter = "_format" + type; + if (!(formatter in this)) { + formatter = "_formatobject"; + type = "object"; + } + } + + var span = document.createElement("span"); + span.addStyleClass("console-formatted-" + type); + this[formatter](output, span, plaintext); + return span; + }, + + _formatvalue: function(val, elem, plaintext) + { + elem.appendChild(document.createTextNode(val)); + }, + + _formatstring: function(str, elem, plaintext) + { + elem.appendChild(document.createTextNode("\"" + str + "\"")); + }, + + _formatregexp: function(re, elem, plaintext) + { + var formatted = String(re).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1); + elem.appendChild(document.createTextNode(formatted)); + }, + + _formatarray: function(arr, elem, plaintext) + { + elem.appendChild(document.createTextNode("[")); + for (var i = 0; i < arr.length; ++i) { + elem.appendChild(this._format(arr[i])); + if (i < arr.length - 1) + elem.appendChild(document.createTextNode(", ")); + } + elem.appendChild(document.createTextNode("]")); + }, + + _formatnode: function(node, elem, plaintext) + { + var anchor = document.createElement("a"); + anchor.innerHTML = nodeTitleInfo.call(node).title; + anchor.representedNode = node; + anchor.addEventListener("mouseover", function() { WebInspector.highlightDOMNode(node) }, false); + anchor.addEventListener("mouseout", function() { WebInspector.hideDOMNodeHighlight() }, false); + elem.appendChild(anchor); + }, + + _formatobject: function(obj, elem, plaintext) + { + elem.appendChild(document.createTextNode(Object.describe(obj))); + }, + + _formaterror: function(obj, elem, plaintext) + { + elem.appendChild(document.createTextNode(obj.name + ": " + obj.message + " ")); + + if (obj.sourceURL) { + var urlElement = document.createElement("a"); + urlElement.className = "console-message-url webkit-html-resource-link"; + urlElement.href = obj.sourceURL; + urlElement.lineNumber = obj.line; + + if (obj.line > 0) + urlElement.textContent = WebInspector.UIString("%s (line %d)", obj.sourceURL, obj.line); + else + urlElement.textContent = obj.sourceURL; + + elem.appendChild(urlElement); + } + }, +} + +WebInspector.Console.prototype.__proto__ = WebInspector.View.prototype; + +WebInspector.ConsoleMessage = function(source, level, line, url) +{ + this.source = source; + this.level = level; + this.line = line; + this.url = url; + + // This _format call passes in true for the plainText argument. The result's textContent is + // used for inline message bubbles in SourceFrames, or other plain-text representations. + this.message = this._format(Array.prototype.slice.call(arguments, 4), true).textContent; + + // The formatedMessage property is used for the rich and interactive console. + this.formattedMessage = this._format(Array.prototype.slice.call(arguments, 4), false); +} + +WebInspector.ConsoleMessage.prototype = { + _format: function(parameters, plaintext) + { + var formattedResult = document.createElement("span"); + + if (!parameters.length) + return formattedResult; + + function formatForConsole(obj) + { + return WebInspector.console._format(obj, plainText); + } + + if (Object.type(parameters[0], InspectorController.inspectedWindow()) === "string") { + var formatters = {} + for (var i in String.standardFormatters) + formatters[i] = String.standardFormatters[i]; + + // Firebug uses %o for formatting objects. + formatters.o = formatForConsole; + // Firebug allows both %i and %d for formatting integers. + formatters.i = formatters.d; + + function append(a, b) + { + if (!(b instanceof Node)) + b = document.createTextNode(b); + + a.appendChild(b); + return a; + } + + var result = String.format(parameters[0], parameters.slice(1), formatters, formattedResult, append); + formattedResult = result.formattedResult; + parameters = result.unusedSubstitutions; + if (parameters.length) + formattedResult.appendChild(document.createTextNode(" ")); + } + + for (var i = 0; i < parameters.length; ++i) { + formattedResult.appendChild(formatForConsole(parameters[i])); + if (i < parameters.length - 1) + formattedResult.appendChild(document.createTextNode(" ")); + } + return formattedResult; + }, + + get shortURL() + { + if (this.resource) + return this.resource.displayName; + return this.url; + }, + + toMessageElement: function() + { + var element = document.createElement("div"); + element.message = this; + element.className = "console-message"; + + switch (this.source) { + case WebInspector.ConsoleMessage.MessageSource.HTML: + element.addStyleClass("console-html-source"); + break; + case WebInspector.ConsoleMessage.MessageSource.XML: + element.addStyleClass("console-xml-source"); + break; + case WebInspector.ConsoleMessage.MessageSource.JS: + element.addStyleClass("console-js-source"); + break; + case WebInspector.ConsoleMessage.MessageSource.CSS: + element.addStyleClass("console-css-source"); + break; + case WebInspector.ConsoleMessage.MessageSource.Other: + element.addStyleClass("console-other-source"); + break; + } + + switch (this.level) { + case WebInspector.ConsoleMessage.MessageLevel.Tip: + element.addStyleClass("console-tip-level"); + break; + case WebInspector.ConsoleMessage.MessageLevel.Log: + element.addStyleClass("console-log-level"); + break; + case WebInspector.ConsoleMessage.MessageLevel.Warning: + element.addStyleClass("console-warning-level"); + break; + case WebInspector.ConsoleMessage.MessageLevel.Error: + element.addStyleClass("console-error-level"); + } + + var messageTextElement = document.createElement("span"); + messageTextElement.className = "console-message-text"; + messageTextElement.appendChild(this.formattedMessage); + element.appendChild(messageTextElement); + + element.appendChild(document.createTextNode(" ")); + + if (this.url && this.url !== "undefined") { + var urlElement = document.createElement("a"); + urlElement.className = "console-message-url webkit-html-resource-link"; + urlElement.href = this.url; + urlElement.lineNumber = this.line; + + if (this.line > 0) + urlElement.textContent = WebInspector.UIString("%s (line %d)", this.url, this.line); + else + urlElement.textContent = this.url; + + element.appendChild(urlElement); + } + + return element; + }, + + toString: function() + { + var sourceString; + switch (this.source) { + case WebInspector.ConsoleMessage.MessageSource.HTML: + sourceString = "HTML"; + break; + case WebInspector.ConsoleMessage.MessageSource.XML: + sourceString = "XML"; + break; + case WebInspector.ConsoleMessage.MessageSource.JS: + sourceString = "JS"; + break; + case WebInspector.ConsoleMessage.MessageSource.CSS: + sourceString = "CSS"; + break; + case WebInspector.ConsoleMessage.MessageSource.Other: + sourceString = "Other"; + break; + } + + var levelString; + switch (this.level) { + case WebInspector.ConsoleMessage.MessageLevel.Tip: + levelString = "Tip"; + break; + case WebInspector.ConsoleMessage.MessageLevel.Log: + levelString = "Log"; + break; + case WebInspector.ConsoleMessage.MessageLevel.Warning: + levelString = "Warning"; + break; + case WebInspector.ConsoleMessage.MessageLevel.Error: + levelString = "Error"; + break; + } + + return sourceString + " " + levelString + ": " + this.formattedMessage.textContent + "\n" + this.url + " line " + this.line; + } +} + +// Note: Keep these constants in sync with the ones in Chrome.h +WebInspector.ConsoleMessage.MessageSource = { + HTML: 0, + XML: 1, + JS: 2, + CSS: 3, + Other: 4, +} + +WebInspector.ConsoleMessage.MessageLevel = { + Tip: 0, + Log: 1, + Warning: 2, + Error: 3 +} + +WebInspector.ConsoleCommand = function(command, result, formattedResultElement, level) +{ + this.command = command; + this.formattedResultElement = formattedResultElement; + this.level = level; +} + +WebInspector.ConsoleCommand.prototype = { + toMessageElement: function() + { + var element = document.createElement("div"); + element.command = this; + element.className = "console-user-command"; + + var commandTextElement = document.createElement("span"); + commandTextElement.className = "console-message-text"; + commandTextElement.textContent = this.command; + element.appendChild(commandTextElement); + + var resultElement = document.createElement("div"); + resultElement.className = "console-message"; + element.appendChild(resultElement); + + switch (this.level) { + case WebInspector.ConsoleMessage.MessageLevel.Log: + resultElement.addStyleClass("console-log-level"); + break; + case WebInspector.ConsoleMessage.MessageLevel.Warning: + resultElement.addStyleClass("console-warning-level"); + break; + case WebInspector.ConsoleMessage.MessageLevel.Error: + resultElement.addStyleClass("console-error-level"); + } + + var resultTextElement = document.createElement("span"); + resultTextElement.className = "console-message-text"; + resultTextElement.appendChild(this.formattedResultElement); + resultElement.appendChild(resultTextElement); + + return element; + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Database.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/Database.js new file mode 100644 index 0000000..ef42e15 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Database.js @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.Database = function(database, domain, name, version) +{ + this.database = database; + this.domain = domain; + this.name = name; + this.version = version; +} + +WebInspector.Database.prototype = { + get database() + { + return this._database; + }, + + set database(x) + { + if (this._database === x) + return; + this._database = x; + }, + + get name() + { + return this._name; + }, + + set name(x) + { + if (this._name === x) + return; + this._name = x; + }, + + get version() + { + return this._version; + }, + + set version(x) + { + if (this._version === x) + return; + this._version = x; + }, + + get domain() + { + return this._domain; + }, + + set domain(x) + { + if (this._domain === x) + return; + this._domain = x; + }, + + get displayDomain() + { + return WebInspector.Resource.prototype.__lookupGetter__("displayDomain").call(this); + }, + + get tableNames() + { + return InspectorController.databaseTableNames(this.database).sort(); + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabaseQueryView.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabaseQueryView.js new file mode 100644 index 0000000..c5792af --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabaseQueryView.js @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.DatabaseQueryView = function(database) +{ + WebInspector.View.call(this); + + this.database = database; + + this.element.addStyleClass("database-view"); + this.element.addStyleClass("query"); + this.element.addStyleClass("focusable"); + + this.element.addEventListener("selectstart", this._selectStart.bind(this), false); + this.element.focused = this._focused.bind(this); + this.element.handleKeyEvent = this._promptKeyDown.bind(this); + + this.promptElement = document.createElement("div"); + this.promptElement.className = "database-query-prompt"; + this.promptElement.appendChild(document.createElement("br")); + this.element.appendChild(this.promptElement); + + this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), " "); +} + +WebInspector.DatabaseQueryView.prototype = { + show: function(parentElement) + { + WebInspector.View.prototype.show.call(this, parentElement); + + function moveBackIfOutside() + { + if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCollapsed) + this.prompt.moveCaretToEndOfPrompt(); + } + + setTimeout(moveBackIfOutside.bind(this), 0); + }, + + completions: function(wordRange, bestMatchOnly) + { + var prefix = wordRange.toString().toLowerCase(); + if (!prefix.length) + return; + + var results = []; + + function accumulateMatches(textArray) + { + if (bestMatchOnly && results.length) + return; + for (var i = 0; i < textArray.length; ++i) { + var text = textArray[i].toLowerCase(); + if (text.length < prefix.length) + continue; + if (text.indexOf(prefix) !== 0) + continue; + results.push(textArray[i]); + if (bestMatchOnly) + return; + } + } + + accumulateMatches(this.database.tableNames.map(function(name) { return name + " " })); + accumulateMatches(["SELECT ", "FROM ", "WHERE ", "LIMIT ", "DELETE FROM ", "CREATE ", "DROP ", "TABLE ", "INDEX ", "UPDATE ", "INSERT INTO ", "VALUES ("]); + + return results; + }, + + _promptKeyDown: function(event) + { + switch (event.keyIdentifier) { + case "Enter": + this._enterKeyPressed(event); + return; + } + + this.prompt.handleKeyEvent(event); + }, + + _focused: function(previousFocusElement) + { + this._previousFocusElement = previousFocusElement; + if (!this.prompt.isCaretInsidePrompt()) + this.prompt.moveCaretToEndOfPrompt(); + }, + + _selectStart: function(event) + { + if (this._selectionTimeout) + clearTimeout(this._selectionTimeout); + + this.prompt.clearAutoComplete(); + + function moveBackIfOutside() + { + delete this._selectionTimeout; + if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCollapsed) + this.prompt.moveCaretToEndOfPrompt(); + this.prompt.autoCompleteSoon(); + } + + this._selectionTimeout = setTimeout(moveBackIfOutside.bind(this), 100); + }, + + _enterKeyPressed: function(event) + { + event.preventDefault(); + event.stopPropagation(); + + this.prompt.clearAutoComplete(true); + + var query = this.prompt.text; + if (!query.length) + return; + + this.prompt.history.push(query); + this.prompt.historyOffset = 0; + this.prompt.text = ""; + + function queryTransaction(tx) + { + tx.executeSql(query, null, InspectorController.wrapCallback(this._queryFinished.bind(this, query)), InspectorController.wrapCallback(this._queryError.bind(this, query))); + } + + this.database.database.transaction(InspectorController.wrapCallback(queryTransaction.bind(this)), InspectorController.wrapCallback(this._queryError.bind(this, query))); + }, + + _queryFinished: function(query, tx, result) + { + this._appendQueryResult(query, WebInspector.panels.databases._tableForResult(result)); + + if (query.match(/^create /i) || query.match(/^drop table /i)) + WebInspector.panels.databases.updateDatabaseTables(this.database); + }, + + _queryError: function(query, tx, error) + { + if (error.code == 1) + var message = error.message; + else if (error.code == 2) + var message = WebInspector.UIString("Database no longer has expected version."); + else + var message = WebInspector.UIString("An unexpected error %s occured.", error.code); + + this._appendQueryResult(query, message, "error"); + }, + + _appendQueryResult: function(query, result, resultClassName) + { + var element = document.createElement("div"); + element.className = "database-user-query"; + + var commandTextElement = document.createElement("span"); + commandTextElement.className = "database-query-text"; + commandTextElement.textContent = query; + element.appendChild(commandTextElement); + + var resultElement = document.createElement("div"); + resultElement.className = "database-query-result"; + + if (resultClassName) + resultElement.addStyleClass(resultClassName); + + if (typeof result === "string" || result instanceof String) + resultElement.textContent = result; + else if (result && result.nodeName) + resultElement.appendChild(result); + + if (resultElement.childNodes.length) + element.appendChild(resultElement); + + this.element.insertBefore(element, this.promptElement); + this.promptElement.scrollIntoView(false); + } +} + +WebInspector.DatabaseQueryView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabaseTableView.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabaseTableView.js new file mode 100644 index 0000000..ccf7590 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabaseTableView.js @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.DatabaseTableView = function(database, tableName) +{ + WebInspector.View.call(this); + + this.database = database; + this.tableName = tableName; + + this.element.addStyleClass("database-view"); + this.element.addStyleClass("table"); +} + +WebInspector.DatabaseTableView.prototype = { + show: function(parentElement) + { + WebInspector.View.prototype.show.call(this, parentElement); + this.update(); + }, + + update: function() + { + function queryTransaction(tx) + { + tx.executeSql("SELECT * FROM " + this.tableName, null, InspectorController.wrapCallback(this._queryFinished.bind(this)), InspectorController.wrapCallback(this._queryError.bind(this))); + } + + this.database.database.transaction(InspectorController.wrapCallback(queryTransaction.bind(this)), InspectorController.wrapCallback(this._queryError.bind(this))); + }, + + _queryFinished: function(tx, result) + { + this.element.removeChildren(); + + var table = WebInspector.panels.databases._tableForResult(result); + if (!table) { + var emptyMsgElement = document.createElement("div"); + emptyMsgElement.className = "database-table-empty"; + emptyMsgElement.textContent = WebInspector.UIString("The “%s”\ntable is empty.", this.tableName); + this.element.appendChild(emptyMsgElement); + return; + } + + var rowCount = table.getElementsByTagName("tr").length; + var columnCount = table.getElementsByTagName("tr").item(0).getElementsByTagName("th").length; + + var tr = document.createElement("tr"); + tr.className = "database-result-filler-row"; + table.appendChild(tr); + + if (!(rowCount % 2)) + tr.addStyleClass("alternate"); + + for (var i = 0; i < columnCount; ++i) { + var td = document.createElement("td"); + tr.appendChild(td); + } + + this.element.appendChild(table); + }, + + _queryError: function(tx, error) + { + this.element.removeChildren(); + + var errorMsgElement = document.createElement("div"); + errorMsgElement.className = "database-table-error"; + errorMsgElement.textContent = WebInspector.UIString("An error occurred trying to\nread the “%s” table.", this.tableName); + this.element.appendChild(errorMsgElement); + }, + +} + +WebInspector.DatabaseTableView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabasesPanel.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabasesPanel.js new file mode 100644 index 0000000..79adab0 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/DatabasesPanel.js @@ -0,0 +1,367 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.DatabasesPanel = function(database) +{ + WebInspector.Panel.call(this); + + this.sidebarElement = document.createElement("div"); + this.sidebarElement.id = "databases-sidebar"; + this.sidebarElement.className = "sidebar"; + this.element.appendChild(this.sidebarElement); + + this.sidebarResizeElement = document.createElement("div"); + this.sidebarResizeElement.className = "sidebar-resizer-vertical"; + this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false); + this.element.appendChild(this.sidebarResizeElement); + + this.sidebarTreeElement = document.createElement("ol"); + this.sidebarTreeElement.className = "sidebar-tree"; + this.sidebarElement.appendChild(this.sidebarTreeElement); + + this.sidebarTree = new TreeOutline(this.sidebarTreeElement); + + this.databaseViews = document.createElement("div"); + this.databaseViews.id = "database-views"; + this.element.appendChild(this.databaseViews); + + this.reset(); +} + +WebInspector.DatabasesPanel.prototype = { + toolbarItemClass: "databases", + + get toolbarItemLabel() + { + return WebInspector.UIString("Databases"); + }, + + show: function() + { + WebInspector.Panel.prototype.show.call(this); + this._updateSidebarWidth(); + }, + + reset: function() + { + if (this._databases) { + var databasesLength = this._databases.length; + for (var i = 0; i < databasesLength; ++i) { + var database = this._databases[i]; + + delete database._tableViews; + delete database._queryView; + } + } + + this._databases = []; + + this.sidebarTree.removeChildren(); + this.databaseViews.removeChildren(); + }, + + handleKeyEvent: function(event) + { + this.sidebarTree.handleKeyEvent(event); + }, + + addDatabase: function(database) + { + this._databases.push(database); + + var databaseTreeElement = new WebInspector.DatabaseSidebarTreeElement(database); + database._databasesTreeElement = databaseTreeElement; + + this.sidebarTree.appendChild(databaseTreeElement); + }, + + showDatabase: function(database, tableName) + { + if (!database) + return; + + if (this.visibleDatabaseView) + this.visibleDatabaseView.hide(); + + var view; + if (tableName) { + if (!("_tableViews" in database)) + database._tableViews = {}; + view = database._tableViews[tableName]; + if (!view) { + view = new WebInspector.DatabaseTableView(database, tableName); + database._tableViews[tableName] = view; + } + } else { + view = database._queryView; + if (!view) { + view = new WebInspector.DatabaseQueryView(database); + database._queryView = view; + } + } + + view.show(this.databaseViews); + + this.visibleDatabaseView = view; + }, + + closeVisibleView: function() + { + if (this.visibleDatabaseView) + this.visibleDatabaseView.hide(); + delete this.visibleDatabaseView; + }, + + updateDatabaseTables: function(database) + { + if (!database || !database._databasesTreeElement) + return; + + database._databasesTreeElement.shouldRefreshChildren = true; + + if (!("_tableViews" in database)) + return; + + var tableNamesHash = {}; + var tableNames = database.tableNames; + var tableNamesLength = tableNames.length; + for (var i = 0; i < tableNamesLength; ++i) + tableNamesHash[tableNames[i]] = true; + + for (var tableName in database._tableViews) { + if (!(tableName in tableNamesHash)) { + if (this.visibleDatabaseView === database._tableViews[tableName]) + this.closeVisibleView(); + delete database._tableViews[tableName]; + } + } + }, + + _tableForResult: function(result) + { + if (!result.rows.length) + return null; + + var rows = result.rows; + var length = rows.length; + var columnWidths = []; + + var table = document.createElement("table"); + table.className = "database-result-table"; + + var headerRow = document.createElement("tr"); + table.appendChild(headerRow); + + var j = 0; + for (var column in rows.item(0)) { + var th = document.createElement("th"); + headerRow.appendChild(th); + + var div = document.createElement("div"); + div.textContent = column; + div.title = column; + th.appendChild(div); + + columnWidths[j++] = column.length; + } + + for (var i = 0; i < length; ++i) { + var row = rows.item(i); + var tr = document.createElement("tr"); + if (i % 2) + tr.className = "alternate"; + table.appendChild(tr); + + var j = 0; + for (var column in row) { + var td = document.createElement("td"); + tr.appendChild(td); + + var text = row[column]; + var div = document.createElement("div"); + div.textContent = text; + div.title = text; + td.appendChild(div); + + if (text.length > columnWidths[j]) + columnWidths[j] = text.length; + ++j; + } + } + + var totalColumnWidths = 0; + length = columnWidths.length; + for (var i = 0; i < length; ++i) + totalColumnWidths += columnWidths[i]; + + // Calculate the percentage width for the columns. + var minimumPrecent = 5; + var recoupPercent = 0; + for (var i = 0; i < length; ++i) { + columnWidths[i] = Math.round((columnWidths[i] / totalColumnWidths) * 100); + if (columnWidths[i] < minimumPrecent) { + recoupPercent += (minimumPrecent - columnWidths[i]); + columnWidths[i] = minimumPrecent; + } + } + + // Enforce the minimum percentage width. + while (recoupPercent > 0) { + for (var i = 0; i < length; ++i) { + if (columnWidths[i] > minimumPrecent) { + --columnWidths[i]; + --recoupPercent; + if (!recoupPercent) + break; + } + } + } + + length = headerRow.childNodes.length; + for (var i = 0; i < length; ++i) { + var th = headerRow.childNodes[i]; + th.style.width = columnWidths[i] + "%"; + } + + return table; + }, + + _startSidebarDragging: function(event) + { + WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize"); + }, + + _sidebarDragging: function(event) + { + this._updateSidebarWidth(event.pageX); + + event.preventDefault(); + }, + + _endSidebarDragging: function(event) + { + WebInspector.elementDragEnd(event); + }, + + _updateSidebarWidth: function(width) + { + if (this.sidebarElement.offsetWidth <= 0) { + // The stylesheet hasn't loaded yet, so we need to update later. + setTimeout(this._updateSidebarWidth.bind(this), 0, width); + return; + } + + if (!("_currentSidebarWidth" in this)) + this._currentSidebarWidth = this.sidebarElement.offsetWidth; + + if (typeof width === "undefined") + width = this._currentSidebarWidth; + + width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2); + + this._currentSidebarWidth = width; + + this.sidebarElement.style.width = width + "px"; + this.databaseViews.style.left = width + "px"; + this.sidebarResizeElement.style.left = (width - 3) + "px"; + } +} + +WebInspector.DatabasesPanel.prototype.__proto__ = WebInspector.Panel.prototype; + +WebInspector.DatabaseSidebarTreeElement = function(database) +{ + this.database = database; + + WebInspector.SidebarTreeElement.call(this, "database-sidebar-tree-item", "", "", database, true); + + this.refreshTitles(); +} + +WebInspector.DatabaseSidebarTreeElement.prototype = { + onselect: function() + { + WebInspector.panels.databases.showDatabase(this.database); + }, + + oncollapse: function() + { + // Request a refresh after every collapse so the next + // expand will have an updated table list. + this.shouldRefreshChildren = true; + }, + + onpopulate: function() + { + this.removeChildren(); + + var tableNames = this.database.tableNames; + var tableNamesLength = tableNames.length; + for (var i = 0; i < tableNamesLength; ++i) + this.appendChild(new WebInspector.SidebarDatabaseTableTreeElement(this.database, tableNames[i])); + }, + + get mainTitle() + { + return this.database.name; + }, + + set mainTitle(x) + { + // Do nothing. + }, + + get subtitle() + { + return this.database.displayDomain; + }, + + set subtitle(x) + { + // Do nothing. + } +} + +WebInspector.DatabaseSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + +WebInspector.SidebarDatabaseTableTreeElement = function(database, tableName) +{ + this.database = database; + this.tableName = tableName; + + WebInspector.SidebarTreeElement.call(this, "database-table-sidebar-tree-item small", tableName, "", null, false); +} + +WebInspector.SidebarDatabaseTableTreeElement.prototype = { + onselect: function() + { + WebInspector.panels.databases.showDatabase(this.database, this.tableName); + } +} + +WebInspector.SidebarDatabaseTableTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/ElementsPanel.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/ElementsPanel.js new file mode 100644 index 0000000..6a5978a --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/ElementsPanel.js @@ -0,0 +1,1182 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.ElementsPanel = function() +{ + WebInspector.Panel.call(this); + + this.element.addStyleClass("elements"); + + this.contentElement = document.createElement("div"); + this.contentElement.id = "elements-content"; + this.contentElement.className = "outline-disclosure"; + + function clearNodeHighlight(event) + { + if (!event.relatedTarget || + !this.contentElement.isAncestor(event.relatedTarget) && + !this.crumbsElement.isAncestor(event.relatedTarget)) { + WebInspector.hideDOMNodeHighlight(); + } + } + + this.treeListElement = document.createElement("ol"); + this.treeListElement.addEventListener("mousedown", this._onmousedown.bind(this), false); + this.treeListElement.addEventListener("dblclick", this._ondblclick.bind(this), false); + this.treeListElement.addEventListener("mousemove", this._onmousemove.bind(this), false); + this.treeListElement.addEventListener("mouseout", clearNodeHighlight.bind(this), false); + + this.treeOutline = new TreeOutline(this.treeListElement); + this.treeOutline.panel = this; + + this.contentElement.appendChild(this.treeListElement); + + this.crumbsElement = document.createElement("div"); + this.crumbsElement.className = "crumbs"; + this.crumbsElement.addEventListener("mouseout", clearNodeHighlight.bind(this), false); + + this.sidebarPanes = {}; + this.sidebarPanes.styles = new WebInspector.StylesSidebarPane(); + this.sidebarPanes.metrics = new WebInspector.MetricsSidebarPane(); + this.sidebarPanes.properties = new WebInspector.PropertiesSidebarPane(); + + this.sidebarPanes.styles.onexpand = this.updateStyles.bind(this); + this.sidebarPanes.metrics.onexpand = this.updateMetrics.bind(this); + this.sidebarPanes.properties.onexpand = this.updateProperties.bind(this); + + this.sidebarPanes.styles.expanded = true; + + this.sidebarElement = document.createElement("div"); + this.sidebarElement.id = "elements-sidebar"; + + this.sidebarElement.appendChild(this.sidebarPanes.styles.element); + this.sidebarElement.appendChild(this.sidebarPanes.metrics.element); + this.sidebarElement.appendChild(this.sidebarPanes.properties.element); + + this.sidebarResizeElement = document.createElement("div"); + this.sidebarResizeElement.className = "sidebar-resizer-vertical"; + this.sidebarResizeElement.addEventListener("mousedown", this.rightSidebarResizerDragStart.bind(this), false); + + this.element.appendChild(this.contentElement); + this.element.appendChild(this.sidebarElement); + this.element.appendChild(this.sidebarResizeElement); + + this.reset(); +} + +WebInspector.ElementsPanel.prototype = { + toolbarItemClass: "elements", + + get toolbarItemLabel() + { + return WebInspector.UIString("Elements"); + }, + + get statusBarItems() + { + return [this.crumbsElement]; + }, + + updateStatusBarItems: function() + { + this.updateBreadcrumbSizes(); + }, + + show: function() + { + WebInspector.Panel.prototype.show.call(this); + this.sidebarResizeElement.style.right = (this.sidebarElement.offsetWidth - 3) + "px"; + this.updateBreadcrumb(); + this.updateTreeSelection(); + }, + + hide: function() + { + WebInspector.Panel.prototype.hide.call(this); + WebInspector.hideDOMNodeHighlight(); + }, + + resize: function() + { + this.updateTreeSelection(); + this.updateBreadcrumbSizes(); + }, + + reset: function() + { + this.rootDOMNode = null; + this.focusedDOMNode = null; + + var inspectedWindow = InspectorController.inspectedWindow(); + if (!inspectedWindow || !inspectedWindow.document) + return; + + if (!inspectedWindow.document.firstChild) { + // FIXME: This whole if block can be simplified once we can add an event listener to + // the inspected page and have it get called in the Inspector's context. + + var elementsPanel = this; + /* We don't implement wrapCallback yet (if ever) + var contentLoaded = InspectorController.wrapCallback(function() + { + // This function will be called in the inspected page's context. + elementsPanel._domContentLoaded = true; + }); + */ + var contentLoaded = function() + { + // This function will be called in the inspected page's context. + elementsPanel._domContentLoaded = true; + }; + + function checkContentLoaded() + { + if (!this._domContentLoaded) + return; + this.reset(); + inspectedWindow.document.removeEventListener("DOMContentLoaded", contentLoaded, false); + clearInterval(contentLoadedPollingInterval); + delete this._domContentLoaded; + } + + this._domContentLoaded = false; + var contentLoadedPollingInterval = setInterval(checkContentLoaded.bind(this), 100); + + inspectedWindow.document.addEventListener("DOMContentLoaded", contentLoaded, false); + return; + } + + var inspectedRootDocument = inspectedWindow.document; + this.rootDOMNode = inspectedRootDocument; + + var canidateFocusNode = inspectedRootDocument.body || inspectedRootDocument.documentElement; + if (canidateFocusNode) { + this.focusedDOMNode = canidateFocusNode; + if (this.treeOutline.selectedTreeElement) + this.treeOutline.selectedTreeElement.expand(); + } + }, + + updateTreeSelection: function() + { + if (!this.treeOutline || !this.treeOutline.selectedTreeElement) + return; + var element = this.treeOutline.selectedTreeElement; + element.updateSelection(); + }, + + get rootDOMNode() + { + return this._rootDOMNode; + }, + + set rootDOMNode(x) + { + if (this._rootDOMNode === x) + return; + + this._rootDOMNode = x; + + this.updateBreadcrumb(); + this.updateTreeOutline(); + }, + + get focusedDOMNode() + { + return this._focusedDOMNode; + }, + + set focusedDOMNode(x) + { + if (this._focusedDOMNode === x) { + var nodeItem = this.revealNode(x); + if (nodeItem) + nodeItem.select(); + return; + } + + this._focusedDOMNode = x; + + this._focusedNodeChanged(); + + var nodeItem = this.revealNode(x); + if (nodeItem) + nodeItem.select(); + }, + + _focusedNodeChanged: function(forceUpdate) + { + this.updateBreadcrumb(forceUpdate); + + for (var pane in this.sidebarPanes) + this.sidebarPanes[pane].needsUpdate = true; + + this.updateStyles(true); + this.updateMetrics(); + this.updateProperties(); + }, + + revealNode: function(node) + { + var nodeItem = this.treeOutline.findTreeElement(node, this._isAncestorIncludingParentFrames.bind(this), this._parentNodeOrFrameElement.bind(this)); + if (!nodeItem) + return; + + nodeItem.reveal(); + return nodeItem; + }, + + updateTreeOutline: function() + { + this.treeOutline.removeChildrenRecursive(); + + if (!this.rootDOMNode) + return; + + // FIXME: this could use findTreeElement to reuse a tree element if it already exists + var node = (Preferences.ignoreWhitespace ? firstChildSkippingWhitespace.call(this.rootDOMNode) : this.rootDOMNode.firstChild); + while (node) { + this.treeOutline.appendChild(new WebInspector.DOMNodeTreeElement(node)); + node = Preferences.ignoreWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling; + } + + this.updateTreeSelection(); + }, + + updateBreadcrumb: function(forceUpdate) + { + if (!this.visible) + return; + + var crumbs = this.crumbsElement; + + var handled = false; + var foundRoot = false; + var crumb = crumbs.firstChild; + while (crumb) { + if (crumb.representedObject === this.rootDOMNode) + foundRoot = true; + + if (foundRoot) + crumb.addStyleClass("dimmed"); + else + crumb.removeStyleClass("dimmed"); + + if (crumb.representedObject === this.focusedDOMNode) { + crumb.addStyleClass("selected"); + handled = true; + } else { + crumb.removeStyleClass("selected"); + } + + crumb = crumb.nextSibling; + } + + if (handled && !forceUpdate) { + // We don't need to rebuild the crumbs, but we need to adjust sizes + // to reflect the new focused or root node. + this.updateBreadcrumbSizes(); + return; + } + + crumbs.removeChildren(); + + var panel = this; + var selectCrumbFunction = function(event) { + var crumb = event.currentTarget; + if (crumb.hasStyleClass("collapsed")) { + // Clicking a collapsed crumb will expose the hidden crumbs. + if (crumb === panel.crumbsElement.firstChild) { + // If the focused crumb is the first child, pick the farthest crumb + // that is still hidden. This allows the user to expose every crumb. + var currentCrumb = crumb; + while (currentCrumb) { + var hidden = currentCrumb.hasStyleClass("hidden"); + var collapsed = currentCrumb.hasStyleClass("collapsed"); + if (!hidden && !collapsed) + break; + crumb = currentCrumb; + currentCrumb = currentCrumb.nextSibling; + } + } + + panel.updateBreadcrumbSizes(crumb); + } else { + // Clicking a dimmed crumb or double clicking (event.detail >= 2) + // will change the root node in addition to the focused node. + if (event.detail >= 2 || crumb.hasStyleClass("dimmed")) + panel.rootDOMNode = crumb.representedObject.parentNode; + panel.focusedDOMNode = crumb.representedObject; + } + + WebInspector.currentFocusElement = document.getElementById("main-panels"); + + event.preventDefault(); + }; + + var mouseOverCrumbFunction = function(event) { + if (event.currentTarget.isDescendant(event.relatedTarget)) { + return; + } + panel.mouseOverCrumb = true; + + WebInspector.highlightDOMNode(event.currentTarget.representedObject); + + if ("mouseOutTimeout" in panel) { + clearTimeout(panel.mouseOutTimeout); + delete panel.mouseOutTimeout; + } + }; + + var mouseOutCrumbFunction = function(event) { + if (event.currentTarget.isDescendant(event.relatedTarget) || + event.relatedTarget && event.relatedTarget.representedObject) { + return; + } + + delete panel.mouseOverCrumb; + + if ("mouseOutTimeout" in panel) { + clearTimeout(panel.mouseOutTimeout); + delete panel.mouseOutTimeout; + } + + var timeoutFunction = function() { + if (!panel.mouseOverCrumb) + panel.updateBreadcrumbSizes(); + }; + + panel.mouseOutTimeout = setTimeout(timeoutFunction, 500); + }; + + foundRoot = false; + for (var current = this.focusedDOMNode; current; current = this._parentNodeOrFrameElement(current)) { + if (current.nodeType === Node.DOCUMENT_NODE) + continue; + + if (current === this.rootDOMNode) + foundRoot = true; + + var crumb = document.createElement("span"); + crumb.className = "crumb"; + crumb.representedObject = current; + crumb.addEventListener("mousedown", selectCrumbFunction, false); + crumb.addEventListener("mouseover", mouseOverCrumbFunction.bind(crumb), false); + crumb.addEventListener("mouseout", mouseOutCrumbFunction, false); + + var crumbTitle; + switch (current.nodeType) { + case Node.ELEMENT_NODE: + crumbTitle = current.nodeName.toLowerCase(); + + var nameElement = document.createElement("span"); + nameElement.textContent = crumbTitle; + crumb.appendChild(nameElement); + + var idAttribute = current.getAttribute("id"); + if (idAttribute) { + var idElement = document.createElement("span"); + crumb.appendChild(idElement); + + var part = "#" + idAttribute; + crumbTitle += part; + idElement.appendChild(document.createTextNode(part)); + + // Mark the name as extra, since the ID is more important. + nameElement.className = "extra"; + } + + var classAttribute = current.getAttribute("class"); + if (classAttribute) { + var classes = classAttribute.split(/\s+/); + var foundClasses = {}; + + if (classes.length) { + var classesElement = document.createElement("span"); + classesElement.className = "extra"; + crumb.appendChild(classesElement); + + for (var i = 0; i < classes.length; ++i) { + var className = classes[i]; + if (className && !(className in foundClasses)) { + var part = "." + className; + crumbTitle += part; + classesElement.appendChild(document.createTextNode(part)); + foundClasses[className] = true; + } + } + } + } + + break; + + case Node.TEXT_NODE: + if (isNodeWhitespace.call(current)) + crumbTitle = WebInspector.UIString("(whitespace)"); + else + crumbTitle = WebInspector.UIString("(text)"); + break + + case Node.COMMENT_NODE: + crumbTitle = "<!-->"; + break; + + case Node.DOCUMENT_TYPE_NODE: + crumbTitle = "<!DOCTYPE>"; + break; + + default: + crumbTitle = current.nodeName.toLowerCase(); + } + + if (!crumb.childNodes.length) { + var nameElement = document.createElement("span"); + nameElement.textContent = crumbTitle; + crumb.appendChild(nameElement); + } + + crumb.title = crumbTitle; + + if (foundRoot) + crumb.addStyleClass("dimmed"); + if (current === this.focusedDOMNode) + crumb.addStyleClass("selected"); + if (!crumbs.childNodes.length) + crumb.addStyleClass("end"); + + crumbs.appendChild(crumb); + } + + if (crumbs.hasChildNodes()) + crumbs.lastChild.addStyleClass("start"); + + this.updateBreadcrumbSizes(); + }, + + updateBreadcrumbSizes: function(focusedCrumb) + { + if (!this.visible) + return; + + if (document.body.offsetWidth <= 0) { + // The stylesheet hasn't loaded yet, so we need to update later. + setTimeout(this.updateBreadcrumbSizes.bind(this), 0); + return; + } + + var crumbs = this.crumbsElement; + if (!crumbs.childNodes.length || crumbs.offsetWidth <= 0) + return; // No crumbs, do nothing. + + // A Zero index is the right most child crumb in the breadcrumb. + var selectedIndex = 0; + var focusedIndex = 0; + var selectedCrumb; + + var i = 0; + var crumb = crumbs.firstChild; + while (crumb) { + // Find the selected crumb and index. + if (!selectedCrumb && crumb.hasStyleClass("selected")) { + selectedCrumb = crumb; + selectedIndex = i; + } + + // Find the focused crumb index. + if (crumb === focusedCrumb) + focusedIndex = i; + + // Remove any styles that affect size before + // deciding to shorten any crumbs. + if (crumb !== crumbs.lastChild) + crumb.removeStyleClass("start"); + if (crumb !== crumbs.firstChild) + crumb.removeStyleClass("end"); + + crumb.removeStyleClass("compact"); + crumb.removeStyleClass("collapsed"); + crumb.removeStyleClass("hidden"); + + crumb = crumb.nextSibling; + ++i; + } + + // Restore the start and end crumb classes in case they got removed in coalesceCollapsedCrumbs(). + // The order of the crumbs in the document is opposite of the visual order. + crumbs.firstChild.addStyleClass("end"); + crumbs.lastChild.addStyleClass("start"); + + function crumbsAreSmallerThanContainer() + { + var rightPadding = 20; + var errorWarningElement = document.getElementById("error-warning-count"); + if (!WebInspector.console.visible && errorWarningElement) + rightPadding += errorWarningElement.offsetWidth; + return ((crumbs.totalOffsetLeft + crumbs.offsetWidth + rightPadding) < window.innerWidth); + } + + if (crumbsAreSmallerThanContainer()) + return; // No need to compact the crumbs, they all fit at full size. + + var BothSides = 0; + var AncestorSide = -1; + var ChildSide = 1; + + function makeCrumbsSmaller(shrinkingFunction, direction, significantCrumb) + { + if (!significantCrumb) + significantCrumb = (focusedCrumb || selectedCrumb); + + if (significantCrumb === selectedCrumb) + var significantIndex = selectedIndex; + else if (significantCrumb === focusedCrumb) + var significantIndex = focusedIndex; + else { + var significantIndex = 0; + for (var i = 0; i < crumbs.childNodes.length; ++i) { + if (crumbs.childNodes[i] === significantCrumb) { + significantIndex = i; + break; + } + } + } + + function shrinkCrumbAtIndex(index) + { + var shrinkCrumb = crumbs.childNodes[index]; + if (shrinkCrumb && shrinkCrumb !== significantCrumb) + shrinkingFunction(shrinkCrumb); + if (crumbsAreSmallerThanContainer()) + return true; // No need to compact the crumbs more. + return false; + } + + // Shrink crumbs one at a time by applying the shrinkingFunction until the crumbs + // fit in the container or we run out of crumbs to shrink. + if (direction) { + // Crumbs are shrunk on only one side (based on direction) of the signifcant crumb. + var index = (direction > 0 ? 0 : crumbs.childNodes.length - 1); + while (index !== significantIndex) { + if (shrinkCrumbAtIndex(index)) + return true; + index += (direction > 0 ? 1 : -1); + } + } else { + // Crumbs are shrunk in order of descending distance from the signifcant crumb, + // with a tie going to child crumbs. + var startIndex = 0; + var endIndex = crumbs.childNodes.length - 1; + while (startIndex != significantIndex || endIndex != significantIndex) { + var startDistance = significantIndex - startIndex; + var endDistance = endIndex - significantIndex; + if (startDistance >= endDistance) + var index = startIndex++; + else + var index = endIndex--; + if (shrinkCrumbAtIndex(index)) + return true; + } + } + + // We are not small enough yet, return false so the caller knows. + return false; + } + + function coalesceCollapsedCrumbs() + { + var crumb = crumbs.firstChild; + var collapsedRun = false; + var newStartNeeded = false; + var newEndNeeded = false; + while (crumb) { + var hidden = crumb.hasStyleClass("hidden"); + if (!hidden) { + var collapsed = crumb.hasStyleClass("collapsed"); + if (collapsedRun && collapsed) { + crumb.addStyleClass("hidden"); + crumb.removeStyleClass("compact"); + crumb.removeStyleClass("collapsed"); + + if (crumb.hasStyleClass("start")) { + crumb.removeStyleClass("start"); + newStartNeeded = true; + } + + if (crumb.hasStyleClass("end")) { + crumb.removeStyleClass("end"); + newEndNeeded = true; + } + + continue; + } + + collapsedRun = collapsed; + + if (newEndNeeded) { + newEndNeeded = false; + crumb.addStyleClass("end"); + } + } else + collapsedRun = true; + crumb = crumb.nextSibling; + } + + if (newStartNeeded) { + crumb = crumbs.lastChild; + while (crumb) { + if (!crumb.hasStyleClass("hidden")) { + crumb.addStyleClass("start"); + break; + } + crumb = crumb.previousSibling; + } + } + } + + function compact(crumb) + { + if (crumb.hasStyleClass("hidden")) + return; + crumb.addStyleClass("compact"); + } + + function collapse(crumb, dontCoalesce) + { + if (crumb.hasStyleClass("hidden")) + return; + crumb.addStyleClass("collapsed"); + crumb.removeStyleClass("compact"); + if (!dontCoalesce) + coalesceCollapsedCrumbs(); + } + + function compactDimmed(crumb) + { + if (crumb.hasStyleClass("dimmed")) + compact(crumb); + } + + function collapseDimmed(crumb) + { + if (crumb.hasStyleClass("dimmed")) + collapse(crumb); + } + + if (!focusedCrumb) { + // When not focused on a crumb we can be biased and collapse less important + // crumbs that the user might not care much about. + + // Compact child crumbs. + if (makeCrumbsSmaller(compact, ChildSide)) + return; + + // Collapse child crumbs. + if (makeCrumbsSmaller(collapse, ChildSide)) + return; + + // Compact dimmed ancestor crumbs. + if (makeCrumbsSmaller(compactDimmed, AncestorSide)) + return; + + // Collapse dimmed ancestor crumbs. + if (makeCrumbsSmaller(collapseDimmed, AncestorSide)) + return; + } + + // Compact ancestor crumbs, or from both sides if focused. + if (makeCrumbsSmaller(compact, (focusedCrumb ? BothSides : AncestorSide))) + return; + + // Collapse ancestor crumbs, or from both sides if focused. + if (makeCrumbsSmaller(collapse, (focusedCrumb ? BothSides : AncestorSide))) + return; + + if (!selectedCrumb) + return; + + // Compact the selected crumb. + compact(selectedCrumb); + if (crumbsAreSmallerThanContainer()) + return; + + // Collapse the selected crumb as a last resort. Pass true to prevent coalescing. + collapse(selectedCrumb, true); + }, + + updateStyles: function(forceUpdate) + { + var stylesSidebarPane = this.sidebarPanes.styles; + if (!stylesSidebarPane.expanded || !stylesSidebarPane.needsUpdate) + return; + + stylesSidebarPane.update(this.focusedDOMNode, null, forceUpdate); + stylesSidebarPane.needsUpdate = false; + }, + + updateMetrics: function() + { + var metricsSidebarPane = this.sidebarPanes.metrics; + if (!metricsSidebarPane.expanded || !metricsSidebarPane.needsUpdate) + return; + + metricsSidebarPane.update(this.focusedDOMNode); + metricsSidebarPane.needsUpdate = false; + }, + + updateProperties: function() + { + var propertiesSidebarPane = this.sidebarPanes.properties; + if (!propertiesSidebarPane.expanded || !propertiesSidebarPane.needsUpdate) + return; + + propertiesSidebarPane.update(this.focusedDOMNode); + propertiesSidebarPane.needsUpdate = false; + }, + + handleKeyEvent: function(event) + { + this.treeOutline.handleKeyEvent(event); + }, + + handleCopyEvent: function(event) + { + // Don't prevent the normal copy if the user has a selection. + if (!window.getSelection().isCollapsed) + return; + + switch (this.focusedDOMNode.nodeType) { + case Node.ELEMENT_NODE: + var data = this.focusedDOMNode.outerHTML; + break; + + case Node.COMMENT_NODE: + var data = "<!--" + this.focusedDOMNode.nodeValue + "-->"; + break; + + default: + case Node.TEXT_NODE: + var data = this.focusedDOMNode.nodeValue; + } + + event.clipboardData.clearData(); + event.preventDefault(); + + if (data) + event.clipboardData.setData("text/plain", data); + }, + + rightSidebarResizerDragStart: function(event) + { + WebInspector.elementDragStart(this.sidebarElement, this.rightSidebarResizerDrag.bind(this), this.rightSidebarResizerDragEnd.bind(this), event, "col-resize"); + }, + + rightSidebarResizerDragEnd: function(event) + { + WebInspector.elementDragEnd(event); + }, + + rightSidebarResizerDrag: function(event) + { + var x = event.pageX; + var newWidth = Number.constrain(window.innerWidth - x, Preferences.minElementsSidebarWidth, window.innerWidth * 0.66); + + this.sidebarElement.style.width = newWidth + "px"; + this.contentElement.style.right = newWidth + "px"; + this.sidebarResizeElement.style.right = (newWidth - 3) + "px"; + + this.updateTreeSelection(); + + event.preventDefault(); + }, + + _getDocumentForNode: function(node) + { + return node.nodeType == Node.DOCUMENT_NODE ? node : node.ownerDocument; + }, + + _parentNodeOrFrameElement: function(node) + { + var parent = node.parentNode; + if (parent) + return parent; + + var document = this._getDocumentForNode(node); + return document.defaultView.frameElement; + }, + + _isAncestorIncludingParentFrames: function(a, b) + { + for (var node = b; node; node = this._getDocumentForNode(node).defaultView.frameElement) + if (isAncestorNode.call(a, node)) + return true; + return false; + }, + + _treeElementFromEvent: function(event) + { + var outline = this.treeOutline; + + var root = this.treeListElement; + + // We choose this X coordinate based on the knowledge that our list + // items extend nearly to the right edge of the outer <ol>. + var x = root.totalOffsetLeft + root.offsetWidth - 20; + + var y = event.pageY; + + // Our list items have 1-pixel cracks between them vertically. We avoid + // the cracks by checking slightly above and slightly below the mouse + // and seeing if we hit the same element each time. + var elementUnderMouse = outline.treeElementFromPoint(x, y); + var elementAboveMouse = outline.treeElementFromPoint(x, y - 2); + var element; + if (elementUnderMouse === elementAboveMouse) + element = elementUnderMouse; + else + element = outline.treeElementFromPoint(x, y + 2); + + return element; + }, + + _ondblclick: function(event) + { + var element = this._treeElementFromEvent(event); + + if (!element) + return; + + element.ondblclick(); + }, + + _onmousedown: function(event) + { + var element = this._treeElementFromEvent(event); + + if (!element || element.isEventWithinDisclosureTriangle(event)) + return; + + element.select(); + }, + + _onmousemove: function(event) + { + var element = this._treeElementFromEvent(event); + if (element) + WebInspector.highlightDOMNode(element.representedObject); + else + WebInspector.hideDOMNodeHighlight(); + }, +} + +WebInspector.ElementsPanel.prototype.__proto__ = WebInspector.Panel.prototype; + +WebInspector.DOMNodeTreeElement = function(node) +{ + var hasChildren = node.contentDocument || (Preferences.ignoreWhitespace ? (firstChildSkippingWhitespace.call(node) ? true : false) : node.hasChildNodes()); + var titleInfo = nodeTitleInfo.call(node, hasChildren, WebInspector.linkifyURL); + + if (titleInfo.hasChildren) + this.whitespaceIgnored = Preferences.ignoreWhitespace; + + TreeElement.call(this, titleInfo.title, node, titleInfo.hasChildren); +} + +WebInspector.DOMNodeTreeElement.prototype = { + updateSelection: function() + { + var listItemElement = this.listItemElement; + if (!listItemElement) + return; + + if (document.body.offsetWidth <= 0) { + // The stylesheet hasn't loaded yet, so we need to update later. + setTimeout(this.updateSelection.bind(this), 0); + return; + } + + if (!this.selectionElement) { + this.selectionElement = document.createElement("div"); + this.selectionElement.className = "selection selected"; + listItemElement.insertBefore(this.selectionElement, listItemElement.firstChild); + } + + this.selectionElement.style.height = listItemElement.offsetHeight + "px"; + }, + + onattach: function() + { + this.listItemElement.addEventListener("mousedown", this.onmousedown.bind(this), false); + + this._makeURLsActivateOnModifiedClick(); + }, + + _makeURLsActivateOnModifiedClick: function() + { + var links = this.listItemElement.querySelectorAll("li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-resource-link"); + if (!links) + return; + + var isMac = InspectorController.platform().indexOf("mac") == 0; + + for (var i = 0; i < links.length; ++i) { + var link = links[i]; + var isExternal = link.hasStyleClass("webkit-html-external-link"); + var href = link.getAttribute("href"); + var title; + if (isMac) { + if (isExternal) + title = WebInspector.UIString("Option-click to visit %s.", href); + else + title = WebInspector.UIString("Option-click to show %s.", href); + } else { + if (isExternal) + title = WebInspector.UIString("Alt-click to visit %s.", href); + else + title = WebInspector.UIString("Alt-click to show %s.", href); + } + link.setAttribute("title", title); + link.followOnAltClick = true; + } + }, + + onpopulate: function() + { + if (this.children.length || this.whitespaceIgnored !== Preferences.ignoreWhitespace) + return; + + this.removeChildren(); + this.whitespaceIgnored = Preferences.ignoreWhitespace; + + var treeElement = this; + function appendChildrenOfNode(node) + { + var child = (Preferences.ignoreWhitespace ? firstChildSkippingWhitespace.call(node) : node.firstChild); + while (child) { + treeElement.appendChild(new WebInspector.DOMNodeTreeElement(child)); + child = Preferences.ignoreWhitespace ? nextSiblingSkippingWhitespace.call(child) : child.nextSibling; + } + } + + if (this.representedObject.contentDocument) + appendChildrenOfNode(this.representedObject.contentDocument); + + appendChildrenOfNode(this.representedObject); + + if (this.representedObject.nodeType == Node.ELEMENT_NODE) { + var title = "<span class=\"webkit-html-tag close\"></" + this.representedObject.nodeName.toLowerCase().escapeHTML() + "></span>"; + var item = new TreeElement(title, this.representedObject, false); + item.selectable = false; + this.appendChild(item); + } + }, + + onexpand: function() + { + this.treeOutline.panel.updateTreeSelection(); + }, + + oncollapse: function() + { + this.treeOutline.panel.updateTreeSelection(); + }, + + onreveal: function() + { + if (this.listItemElement) + this.listItemElement.scrollIntoViewIfNeeded(false); + }, + + onselect: function() + { + this._selectedByCurrentMouseDown = true; + this.treeOutline.panel.focusedDOMNode = this.representedObject; + this.updateSelection(); + }, + + onmousedown: function(event) + { + if (this._editing) + return; + + if (this._selectedByCurrentMouseDown) + delete this._selectedByCurrentMouseDown; + else if (this._startEditing(event)) { + event.preventDefault(); + return; + } + + // Prevent selecting the nearest word on double click. + if (event.detail >= 2) + event.preventDefault(); + }, + + ondblclick: function(treeElement, event) + { + if (this._editing) + return; + + var panel = this.treeOutline.panel; + panel.rootDOMNode = this.parent.representedObject; + panel.focusedDOMNode = this.representedObject; + + if (this.hasChildren && !this.expanded) + this.expand(); + }, + + _startEditing: function(event) + { + if (this.treeOutline.panel.focusedDOMNode != this.representedObject) + return; + + if (this.representedObject.nodeType != Node.ELEMENT_NODE && this.representedObject.nodeType != Node.TEXT_NODE) + return false; + + var textNode = event.target.enclosingNodeOrSelfWithClass("webkit-html-text-node"); + if (textNode) + return this._startEditingTextNode(textNode); + + var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-attribute"); + if (attribute) + return this._startEditingAttribute(attribute, event); + + return false; + }, + + _startEditingAttribute: function(attribute, event) + { + if (WebInspector.isBeingEdited(attribute)) + return true; + + var attributeNameElement = attribute.getElementsByClassName("webkit-html-attribute-name")[0]; + if (!attributeNameElement) + return false; + + var isURL = event.target.enclosingNodeOrSelfWithClass("webkit-html-external-link") || event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link"); + if (isURL && event.altKey) + return false; + + var attributeName = attributeNameElement.innerText; + + function removeZeroWidthSpaceRecursive(node) + { + if (node.nodeType === Node.TEXT_NODE) { + node.nodeValue = node.nodeValue.replace(/\u200B/g, ""); + return; + } + + if (node.nodeType !== Node.ELEMENT_NODE) + return; + + for (var child = node.firstChild; child; child = child.nextSibling) + removeZeroWidthSpaceRecursive(child); + } + + // Remove zero-width spaces that were added by nodeTitleInfo. + removeZeroWidthSpaceRecursive(attribute); + + this._editing = true; + + WebInspector.startEditing(attribute, this._attributeEditingCommitted.bind(this), this._editingCancelled.bind(this), attributeName); + window.getSelection().setBaseAndExtent(event.target, 0, event.target, 1); + + return true; + }, + + _startEditingTextNode: function(textNode) + { + if (WebInspector.isBeingEdited(textNode)) + return true; + + this._editing = true; + + WebInspector.startEditing(textNode, this._textNodeEditingCommitted.bind(this), this._editingCancelled.bind(this)); + window.getSelection().setBaseAndExtent(textNode, 0, textNode, 1); + + return true; + }, + + _attributeEditingCommitted: function(element, newText, oldText, attributeName) + { + delete this._editing; + + var parseContainerElement = document.createElement("span"); + parseContainerElement.innerHTML = "<span " + newText + "></span>"; + var parseElement = parseContainerElement.firstChild; + if (!parseElement || !parseElement.hasAttributes()) { + editingCancelled(element, context); + return; + } + + var foundOriginalAttribute = false; + for (var i = 0; i < parseElement.attributes.length; ++i) { + var attr = parseElement.attributes[i]; + foundOriginalAttribute = foundOriginalAttribute || attr.name === attributeName; + InspectorController.inspectedWindow().Element.prototype.setAttribute.call(this.representedObject, attr.name, attr.value); + } + + if (!foundOriginalAttribute) + InspectorController.inspectedWindow().Element.prototype.removeAttribute.call(this.representedObject, attributeName); + + this._updateTitle(); + this.treeOutline.panel._focusedNodeChanged(true); + }, + + _textNodeEditingCommitted: function(element, newText) + { + delete this._editing; + + var textNode; + if (this.representedObject.nodeType == Node.ELEMENT_NODE) { + // We only show text nodes inline in elements if the element only + // has a single child, and that child is a text node. + textNode = this.representedObject.firstChild; + } else if (this.representedObject.nodeType == Node.TEXT_NODE) + textNode = this.representedObject; + + textNode.nodeValue = newText; + this._updateTitle(); + }, + + + _editingCancelled: function(element, context) + { + delete this._editing; + + this._updateTitle(); + }, + + _updateTitle: function() + { + this.title = nodeTitleInfo.call(this.representedObject, this.hasChildren, WebInspector.linkifyURL).title; + delete this.selectionElement; + this.updateSelection(); + this._makeURLsActivateOnModifiedClick(); + }, +} + +WebInspector.DOMNodeTreeElement.prototype.__proto__ = TreeElement.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/FontView.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/FontView.js new file mode 100644 index 0000000..2059c04 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/FontView.js @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.FontView = function(resource) +{ + WebInspector.ResourceView.call(this, resource); + + this.element.addStyleClass("font"); + + var uniqueFontName = "WebInspectorFontPreview" + this.resource.identifier; + + this.fontPreviewElement = document.createElement("div"); + this.fontPreviewElement.className = "preview"; + this.contentElement.appendChild(this.fontPreviewElement); + + this.fontPreviewElement.style.setProperty("font-family", uniqueFontName, null); + this.fontPreviewElement.innerHTML = "ABCDEFGHIJKLM<br>NOPQRSTUVWXYZ<br>abcdefghijklm<br>nopqrstuvwxyz<br>1234567890"; + + this.updateFontPreviewSize(); +} + +WebInspector.FontView.prototype = { + show: function() + { + WebInspector.ResourceView.prototype.show.call(this); + this.updateFontPreviewSize(); + }, + + resize: function() + { + this.updateFontPreviewSize(); + }, + + updateFontPreviewSize: function () + { + if (!this.fontPreviewElement || !this.visible) + return; + + this.fontPreviewElement.removeStyleClass("preview"); + + var measureFontSize = 50; + this.fontPreviewElement.style.setProperty("position", "absolute", null); + this.fontPreviewElement.style.setProperty("font-size", measureFontSize + "px", null); + this.fontPreviewElement.style.removeProperty("height"); + + var height = this.fontPreviewElement.offsetHeight; + var width = this.fontPreviewElement.offsetWidth; + + var containerHeight = this.contentElement.offsetHeight; + var containerWidth = this.contentElement.offsetWidth; + + if (!height || !width || !containerHeight || !containerWidth) { + this.fontPreviewElement.style.removeProperty("font-size"); + this.fontPreviewElement.style.removeProperty("position"); + this.fontPreviewElement.addStyleClass("preview"); + return; + } + + var lineCount = this.fontPreviewElement.getElementsByTagName("br").length + 1; + var realLineHeight = Math.floor(height / lineCount); + var fontSizeLineRatio = measureFontSize / realLineHeight; + var widthRatio = containerWidth / width; + var heightRatio = containerHeight / height; + + if (heightRatio < widthRatio) + var finalFontSize = Math.floor(realLineHeight * heightRatio * fontSizeLineRatio) - 1; + else + var finalFontSize = Math.floor(realLineHeight * widthRatio * fontSizeLineRatio) - 1; + + this.fontPreviewElement.style.setProperty("font-size", finalFontSize + "px", null); + this.fontPreviewElement.style.setProperty("height", this.fontPreviewElement.offsetHeight + "px", null); + this.fontPreviewElement.style.removeProperty("position"); + + this.fontPreviewElement.addStyleClass("preview"); + } +} + +WebInspector.FontView.prototype.__proto__ = WebInspector.ResourceView.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/ImageView.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/ImageView.js new file mode 100644 index 0000000..001ffdd --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/ImageView.js @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.ImageView = function(resource) +{ + WebInspector.ResourceView.call(this, resource); + + this.element.addStyleClass("image"); + + var container = document.createElement("div"); + container.className = "image"; + this.contentElement.appendChild(container); + + this.imagePreviewElement = document.createElement("img"); + this.imagePreviewElement.setAttribute("src", this.resource.url); + + container.appendChild(this.imagePreviewElement); + + container = document.createElement("div"); + container.className = "info"; + this.contentElement.appendChild(container); + + var imageNameElement = document.createElement("h1"); + imageNameElement.className = "title"; + imageNameElement.textContent = this.resource.displayName; + container.appendChild(imageNameElement); + + var infoListElement = document.createElement("dl"); + infoListElement.className = "infoList"; + + var imageProperties = [ + { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", this.imagePreviewElement.naturalWidth, this.imagePreviewElement.height) }, + { name: WebInspector.UIString("File size"), value: Number.bytesToString(this.resource.contentLength, WebInspector.UIString.bind(WebInspector)) }, + { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType } + ]; + + var listHTML = ''; + for (var i = 0; i < imageProperties.length; ++i) + listHTML += "<dt>" + imageProperties[i].name + "</dt><dd>" + imageProperties[i].value + "</dd>"; + + infoListElement.innerHTML = listHTML; + container.appendChild(infoListElement); +} + +WebInspector.ImageView.prototype = { + +} + +WebInspector.ImageView.prototype.__proto__ = WebInspector.ResourceView.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/back.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/back.png Binary files differnew file mode 100644 index 0000000..9363960 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/back.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/checker.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/checker.png Binary files differnew file mode 100644 index 0000000..8349908 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/checker.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/clearConsoleButtons.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/clearConsoleButtons.png Binary files differnew file mode 100644 index 0000000..140a4fb --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/clearConsoleButtons.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/consoleButtons.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/consoleButtons.png Binary files differnew file mode 100644 index 0000000..fb5f0897 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/consoleButtons.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/database.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/database.png Binary files differnew file mode 100644 index 0000000..339efa6 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/database.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/databaseTable.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/databaseTable.png Binary files differnew file mode 100644 index 0000000..3718708 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/databaseTable.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/databasesIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/databasesIcon.png Binary files differnew file mode 100644 index 0000000..8ae9ef6 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/databasesIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerContinue.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerContinue.png Binary files differnew file mode 100644 index 0000000..d90a855 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerContinue.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerPause.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerPause.png Binary files differnew file mode 100644 index 0000000..97f958a --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerPause.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepInto.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepInto.png Binary files differnew file mode 100644 index 0000000..277f126 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepInto.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepOut.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepOut.png Binary files differnew file mode 100644 index 0000000..3032e32 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepOut.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepOver.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepOver.png Binary files differnew file mode 100644 index 0000000..7d47245 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggerStepOver.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggingButtons.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggingButtons.png Binary files differnew file mode 100644 index 0000000..c9cc618 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/debuggingButtons.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDown.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDown.png Binary files differnew file mode 100644 index 0000000..cffc835 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDown.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDownBlack.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDownBlack.png Binary files differnew file mode 100644 index 0000000..4b49c13 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDownBlack.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDownWhite.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDownWhite.png Binary files differnew file mode 100644 index 0000000..aebae12 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallDownWhite.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRight.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRight.png Binary files differnew file mode 100644 index 0000000..a3102ea --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRight.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightBlack.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightBlack.png Binary files differnew file mode 100644 index 0000000..2c45859 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightBlack.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDown.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDown.png Binary files differnew file mode 100644 index 0000000..035c069 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDown.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDownBlack.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDownBlack.png Binary files differnew file mode 100644 index 0000000..86f67bd --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDownBlack.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDownWhite.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDownWhite.png Binary files differnew file mode 100644 index 0000000..972d794 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightDownWhite.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightWhite.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightWhite.png Binary files differnew file mode 100644 index 0000000..a10168f --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/disclosureTriangleSmallRightWhite.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/dockButtons.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/dockButtons.png Binary files differnew file mode 100644 index 0000000..4b01d66 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/dockButtons.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/elementsIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/elementsIcon.png Binary files differnew file mode 100644 index 0000000..cd38af1 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/elementsIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/errorIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/errorIcon.png Binary files differnew file mode 100644 index 0000000..c697263 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/errorIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/errorMediumIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/errorMediumIcon.png Binary files differnew file mode 100644 index 0000000..6ca32bb --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/errorMediumIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/forward.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/forward.png Binary files differnew file mode 100644 index 0000000..ad70f3e --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/forward.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/glossyHeader.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/glossyHeader.png Binary files differnew file mode 100644 index 0000000..8c80b6b --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/glossyHeader.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/glossyHeaderPressed.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/glossyHeaderPressed.png Binary files differnew file mode 100644 index 0000000..6b0dd60 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/glossyHeaderPressed.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/goArrow.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/goArrow.png Binary files differnew file mode 100644 index 0000000..f318a56 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/goArrow.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/largerResourcesButtons.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/largerResourcesButtons.png Binary files differnew file mode 100644 index 0000000..caf3f14 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/largerResourcesButtons.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneBottomGrow.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneBottomGrow.png Binary files differnew file mode 100644 index 0000000..d55b865 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneBottomGrow.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneBottomGrowActive.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneBottomGrowActive.png Binary files differnew file mode 100644 index 0000000..ef3f259 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneBottomGrowActive.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneGrowHandleLine.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneGrowHandleLine.png Binary files differnew file mode 100644 index 0000000..4eaf61b --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/paneGrowHandleLine.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceCSSIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceCSSIcon.png Binary files differnew file mode 100644 index 0000000..aead6a7 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceCSSIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceDocumentIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceDocumentIcon.png Binary files differnew file mode 100644 index 0000000..1683a09 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceDocumentIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceDocumentIconSmall.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceDocumentIconSmall.png Binary files differnew file mode 100644 index 0000000..468ced9 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceDocumentIconSmall.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceJSIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceJSIcon.png Binary files differnew file mode 100644 index 0000000..9ef6ed0 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourceJSIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcePlainIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcePlainIcon.png Binary files differnew file mode 100644 index 0000000..0ed37b6 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcePlainIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcePlainIconSmall.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcePlainIconSmall.png Binary files differnew file mode 100644 index 0000000..0fa967d --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcePlainIconSmall.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesIcon.png Binary files differnew file mode 100644 index 0000000..f7d79e3 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesSizeGraphIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesSizeGraphIcon.png Binary files differnew file mode 100644 index 0000000..e60dbe5 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesSizeGraphIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesTimeGraphIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesTimeGraphIcon.png Binary files differnew file mode 100644 index 0000000..c6953e9 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/resourcesTimeGraphIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/scriptsIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/scriptsIcon.png Binary files differnew file mode 100644 index 0000000..31eb1c0e --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/scriptsIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segment.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segment.png Binary files differnew file mode 100644 index 0000000..759266e --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segment.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentEnd.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentEnd.png Binary files differnew file mode 100644 index 0000000..72672ff --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentEnd.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentHover.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentHover.png Binary files differnew file mode 100644 index 0000000..c5017f4 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentHover.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentHoverEnd.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentHoverEnd.png Binary files differnew file mode 100644 index 0000000..d51363d --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentHoverEnd.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentSelected.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentSelected.png Binary files differnew file mode 100644 index 0000000..c92f584 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentSelected.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentSelectedEnd.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentSelectedEnd.png Binary files differnew file mode 100644 index 0000000..be5e0852 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/segmentSelectedEnd.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/splitviewDimple.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/splitviewDimple.png Binary files differnew file mode 100644 index 0000000..584ffd4 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/splitviewDimple.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/splitviewDividerBackground.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/splitviewDividerBackground.png Binary files differnew file mode 100644 index 0000000..1120a7f --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/splitviewDividerBackground.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarBackground.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarBackground.png Binary files differnew file mode 100644 index 0000000..b466a49 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarBackground.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarBottomBackground.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarBottomBackground.png Binary files differnew file mode 100644 index 0000000..fb5c9e4 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarBottomBackground.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarButtons.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarButtons.png Binary files differnew file mode 100644 index 0000000..e8090cb --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarButtons.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarMenuButton.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarMenuButton.png Binary files differnew file mode 100644 index 0000000..9b3abdd --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarMenuButton.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarMenuButtonSelected.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarMenuButtonSelected.png Binary files differnew file mode 100644 index 0000000..8189c43 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarMenuButtonSelected.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarResizerHorizontal.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarResizerHorizontal.png Binary files differnew file mode 100644 index 0000000..56deeab --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarResizerHorizontal.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarResizerVertical.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarResizerVertical.png Binary files differnew file mode 100644 index 0000000..7fc145277 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/statusbarResizerVertical.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillBlue.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillBlue.png Binary files differnew file mode 100644 index 0000000..c897faa --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillBlue.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillGray.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillGray.png Binary files differnew file mode 100644 index 0000000..2128896 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillGray.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillGreen.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillGreen.png Binary files differnew file mode 100644 index 0000000..9b66125 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillGreen.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillOrange.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillOrange.png Binary files differnew file mode 100644 index 0000000..dd944fb --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillOrange.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillPurple.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillPurple.png Binary files differnew file mode 100644 index 0000000..21b96f7 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillPurple.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillRed.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillRed.png Binary files differnew file mode 100644 index 0000000..f5e213b --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillRed.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillYellow.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillYellow.png Binary files differnew file mode 100644 index 0000000..ae2a5a23 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/timelinePillYellow.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipBalloon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipBalloon.png Binary files differnew file mode 100644 index 0000000..4cdf738 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipBalloon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipBalloonBottom.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipBalloonBottom.png Binary files differnew file mode 100644 index 0000000..3317a5a --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipBalloonBottom.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipIcon.png Binary files differnew file mode 100644 index 0000000..8ca6124 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipIconPressed.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipIconPressed.png Binary files differnew file mode 100644 index 0000000..443e410 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/tipIconPressed.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/toolbarItemSelected.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/toolbarItemSelected.png Binary files differnew file mode 100644 index 0000000..bd681f18 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/toolbarItemSelected.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeDownTriangleBlack.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeDownTriangleBlack.png Binary files differnew file mode 100644 index 0000000..0821112 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeDownTriangleBlack.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeDownTriangleWhite.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeDownTriangleWhite.png Binary files differnew file mode 100644 index 0000000..1667b51 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeDownTriangleWhite.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeRightTriangleBlack.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeRightTriangleBlack.png Binary files differnew file mode 100644 index 0000000..90de820 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeRightTriangleBlack.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeRightTriangleWhite.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeRightTriangleWhite.png Binary files differnew file mode 100644 index 0000000..2b6a82f --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/treeRightTriangleWhite.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/userInputIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/userInputIcon.png Binary files differnew file mode 100644 index 0000000..325023f --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/userInputIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/userInputPreviousIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/userInputPreviousIcon.png Binary files differnew file mode 100644 index 0000000..068d572 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/userInputPreviousIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningIcon.png Binary files differnew file mode 100644 index 0000000..d5e4c82 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningMediumIcon.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningMediumIcon.png Binary files differnew file mode 100644 index 0000000..291e111 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningMediumIcon.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningsErrors.png b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningsErrors.png Binary files differnew file mode 100644 index 0000000..878b593 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Images/warningsErrors.png diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/MetricsSidebarPane.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/MetricsSidebarPane.js new file mode 100644 index 0000000..e805560 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/MetricsSidebarPane.js @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.MetricsSidebarPane = function() +{ + WebInspector.SidebarPane.call(this, WebInspector.UIString("Metrics")); +} + +WebInspector.MetricsSidebarPane.prototype = { + update: function(node) + { + var body = this.bodyElement; + + body.removeChildren(); + + if (!node) + return; + + var style; + if (node.nodeType === Node.ELEMENT_NODE) + style = node.ownerDocument.defaultView.getComputedStyle(node); + if (!style) + return; + + var metricsElement = document.createElement("div"); + metricsElement.className = "metrics"; + + function boxPartValue(style, name, suffix) + { + var value = style.getPropertyValue(name + suffix); + if (value === "" || value === "0px") + value = "\u2012"; + return value.replace(/px$/, ""); + } + + // Display types for which margin is ignored. + var noMarginDisplayType = { + "table-cell": true, + "table-column": true, + "table-column-group": true, + "table-footer-group": true, + "table-header-group": true, + "table-row": true, + "table-row-group": true + }; + + // Display types for which padding is ignored. + var noPaddingDisplayType = { + "table-column": true, + "table-column-group": true, + "table-footer-group": true, + "table-header-group": true, + "table-row": true, + "table-row-group": true + }; + + var boxes = ["content", "padding", "border", "margin"]; + var boxLabels = [WebInspector.UIString("content"), WebInspector.UIString("padding"), WebInspector.UIString("border"), WebInspector.UIString("margin")]; + var previousBox; + for (var i = 0; i < boxes.length; ++i) { + var name = boxes[i]; + + if (name === "margin" && noMarginDisplayType[style.display]) + continue; + if (name === "padding" && noPaddingDisplayType[style.display]) + continue; + + var boxElement = document.createElement("div"); + boxElement.className = name; + + if (name === "content") { + var width = style.width.replace(/px$/, ""); + var height = style.height.replace(/px$/, ""); + boxElement.textContent = width + " \u00D7 " + height; + } else { + var suffix = (name === "border" ? "-width" : ""); + + var labelElement = document.createElement("div"); + labelElement.className = "label"; + labelElement.textContent = boxLabels[i]; + boxElement.appendChild(labelElement); + + var topElement = document.createElement("div"); + topElement.className = "top"; + topElement.textContent = boxPartValue(style, name + "-top", suffix); + boxElement.appendChild(topElement); + + var leftElement = document.createElement("div"); + leftElement.className = "left"; + leftElement.textContent = boxPartValue(style, name + "-left", suffix); + boxElement.appendChild(leftElement); + + if (previousBox) + boxElement.appendChild(previousBox); + + var rightElement = document.createElement("div"); + rightElement.className = "right"; + rightElement.textContent = boxPartValue(style, name + "-right", suffix); + boxElement.appendChild(rightElement); + + var bottomElement = document.createElement("div"); + bottomElement.className = "bottom"; + bottomElement.textContent = boxPartValue(style, name + "-bottom", suffix); + boxElement.appendChild(bottomElement); + } + + previousBox = boxElement; + } + + metricsElement.appendChild(previousBox); + body.appendChild(metricsElement); + } +} + +WebInspector.MetricsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Panel.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/Panel.js new file mode 100644 index 0000000..edf5751 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Panel.js @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.Panel = function() +{ + WebInspector.View.call(this); + + this.element.addStyleClass("panel"); +} + +WebInspector.Panel.prototype = { + get toolbarItem() + { + if (this._toolbarItem) + return this._toolbarItem; + + // Sample toolbar item as markup: + // <button class="toolbar-item resources toggleable"> + // <img class="toolbar-icon"> + // <div class="toolbar-label">Resources</div> + // </button> + + this._toolbarItem = document.createElement("button"); + this._toolbarItem.className = "toolbar-item toggleable"; + this._toolbarItem.panel = this; + + if ("toolbarItemClass" in this) + this._toolbarItem.addStyleClass(this.toolbarItemClass); + + var iconElement = document.createElement("img"); + iconElement.className = "toolbar-icon"; + this._toolbarItem.appendChild(iconElement); + + if ("toolbarItemLabel" in this) { + var labelElement = document.createElement("div"); + labelElement.className = "toolbar-label"; + labelElement.textContent = this.toolbarItemLabel; + this._toolbarItem.appendChild(labelElement); + } + + return this._toolbarItem; + }, + + show: function() + { + WebInspector.View.prototype.show.call(this); + + var statusBarItems = this.statusBarItems; + if (statusBarItems) { + this._statusBarItemContainer = document.createElement("div"); + for (var i = 0; i < statusBarItems.length; ++i) + this._statusBarItemContainer.appendChild(statusBarItems[i]); + document.getElementById("main-status-bar").appendChild(this._statusBarItemContainer); + } + + if ("_toolbarItem" in this) + this._toolbarItem.addStyleClass("toggled-on"); + + WebInspector.currentFocusElement = document.getElementById("main-panels"); + }, + + hide: function() + { + WebInspector.View.prototype.hide.call(this); + + if (this._statusBarItemContainer && this._statusBarItemContainer.parentNode) + this._statusBarItemContainer.parentNode.removeChild(this._statusBarItemContainer); + delete this._statusBarItemContainer; + if ("_toolbarItem" in this) + this._toolbarItem.removeStyleClass("toggled-on"); + }, + + attach: function() + { + document.getElementById("main-panels").appendChild(this.element); + } +} + +WebInspector.Panel.prototype.__proto__ = WebInspector.View.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/PropertiesSection.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/PropertiesSection.js new file mode 100644 index 0000000..160dae4 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/PropertiesSection.js @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.PropertiesSection = function(title, subtitle) +{ + this.element = document.createElement("div"); + this.element.className = "section"; + + this.headerElement = document.createElement("div"); + this.headerElement.className = "header"; + + this.titleElement = document.createElement("div"); + this.titleElement.className = "title"; + + this.subtitleElement = document.createElement("div"); + this.subtitleElement.className = "subtitle"; + + this.headerElement.appendChild(this.subtitleElement); + this.headerElement.appendChild(this.titleElement); + + this.headerElement.addEventListener("click", this.toggleExpanded.bind(this), false); + + this.propertiesElement = document.createElement("ol"); + this.propertiesElement.className = "properties"; + this.propertiesTreeOutline = new TreeOutline(this.propertiesElement); + this.propertiesTreeOutline.section = this; + + this.element.appendChild(this.headerElement); + this.element.appendChild(this.propertiesElement); + + this.title = title; + this.subtitle = subtitle; + this.expanded = false; +} + +WebInspector.PropertiesSection.prototype = { + get title() + { + return this._title; + }, + + set title(x) + { + if (this._title === x) + return; + this._title = x; + this.titleElement.textContent = x; + }, + + get subtitle() + { + return this._subtitle; + }, + + set subtitle(x) + { + if (this._subtitle === x) + return; + this._subtitle = x; + this.subtitleElement.innerHTML = x; + }, + + get expanded() + { + return this._expanded; + }, + + set expanded(x) + { + if (x) + this.expand(); + else + this.collapse(); + }, + + get populated() + { + return this._populated; + }, + + set populated(x) + { + this._populated = x; + if (!x && this.onpopulate && this._expanded) { + this.onpopulate(this); + this._populated = true; + } + }, + + expand: function() + { + if (this._expanded) + return; + this._expanded = true; + this.element.addStyleClass("expanded"); + + if (!this._populated && this.onpopulate) { + this.onpopulate(this); + this._populated = true; + } + }, + + collapse: function() + { + if (!this._expanded) + return; + this._expanded = false; + this.element.removeStyleClass("expanded"); + }, + + toggleExpanded: function() + { + this.expanded = !this.expanded; + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/PropertiesSidebarPane.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/PropertiesSidebarPane.js new file mode 100644 index 0000000..0266d53 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/PropertiesSidebarPane.js @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.PropertiesSidebarPane = function() +{ + WebInspector.SidebarPane.call(this, WebInspector.UIString("Properties")); +} + +WebInspector.PropertiesSidebarPane.prototype = { + update: function(object) + { + var body = this.bodyElement; + + body.removeChildren(); + + this.sections = []; + + if (!object) + return; + + for (var prototype = object; prototype; prototype = prototype.__proto__) { + var section = new WebInspector.ObjectPropertiesSection(prototype); + this.sections.push(section); + body.appendChild(section.element); + } + } +} + +WebInspector.PropertiesSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + +WebInspector.ObjectPropertiesSection = function(object) +{ + var title = Object.describe(object); + var subtitle; + if (title.match(/Prototype$/)) { + title = title.replace(/Prototype$/, ""); + subtitle = WebInspector.UIString("Prototype"); + } + + this.object = object; + + WebInspector.PropertiesSection.call(this, title, subtitle); +} + +WebInspector.ObjectPropertiesSection.prototype = { + onpopulate: function() + { + var properties = Object.sortedProperties(this.object); + for (var i = 0; i < properties.length; ++i) { + var propertyName = properties[i]; + if (!this.object.hasOwnProperty(propertyName) || propertyName === "__treeElementIdentifier") + continue; + this.propertiesTreeOutline.appendChild(new WebInspector.ObjectPropertyTreeElement(this.object, propertyName)); + } + } +} + +WebInspector.ObjectPropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype; + +WebInspector.ObjectPropertyTreeElement = function(parentObject, propertyName) +{ + this.parentObject = parentObject; + this.propertyName = propertyName; + + var childObject = this.safePropertyValue(parentObject, propertyName); + var isGetter = parentObject.__lookupGetter__(propertyName); + + var title = "<span class=\"name\">" + propertyName.escapeHTML() + "</span>: "; + if (!isGetter) + title += "<span class=\"value\">" + Object.describe(childObject, true).escapeHTML() + "</span>"; + else + // FIXME: this should show something like "getter" once we can change localization (bug 16734). + title += "<span class=\"value dimmed\">—</span>"; + + var hasSubProperties = false; + var type = typeof childObject; + if (childObject && (type === "object" || type === "function")) { + for (subPropertyName in childObject) { + if (subPropertyName === "__treeElementIdentifier") + continue; + hasSubProperties = true; + break; + } + } + + TreeElement.call(this, title, null, hasSubProperties); +} + +WebInspector.ObjectPropertyTreeElement.prototype = { + safePropertyValue: function(object, propertyName) + { + var getter = object.__lookupGetter__(propertyName); + if (getter) + return; + return object[propertyName]; + }, + + onpopulate: function() + { + if (this.children.length) + return; + + var childObject = this.safePropertyValue(this.parentObject, this.propertyName); + var properties = Object.sortedProperties(childObject); + for (var i = 0; i < properties.length; ++i) { + var propertyName = properties[i]; + if (propertyName === "__treeElementIdentifier") + continue; + this.appendChild(new WebInspector.ObjectPropertyTreeElement(childObject, propertyName)); + } + } +} + +WebInspector.ObjectPropertyTreeElement.prototype.__proto__ = TreeElement.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/Resource.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/Resource.js new file mode 100644 index 0000000..b21cebd --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/Resource.js @@ -0,0 +1,544 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.Resource = function(requestHeaders, url, domain, path, lastPathComponent, identifier, mainResource, cached) +{ + this.identifier = identifier; + + this.startTime = -1; + this.endTime = -1; + this.mainResource = mainResource; + this.requestHeaders = requestHeaders; + this.url = url; + this.domain = domain; + this.path = path; + this.lastPathComponent = lastPathComponent; + this.cached = cached; + + this.category = WebInspector.resourceCategories.other; +} + +// Keep these in sync with WebCore::InspectorResource::Type +WebInspector.Resource.Type = { + Document: 0, + Stylesheet: 1, + Image: 2, + Font: 3, + Script: 4, + XHR: 5, + Other: 6, + + isTextType: function(type) + { + return (type === this.Document) || (type === this.Stylesheet) || (type === this.Script) || (type === this.XHR); + }, + + toString: function(type) + { + switch (type) { + case this.Document: + return WebInspector.UIString("document"); + case this.Stylesheet: + return WebInspector.UIString("stylesheet"); + case this.Image: + return WebInspector.UIString("image"); + case this.Font: + return WebInspector.UIString("font"); + case this.Script: + return WebInspector.UIString("script"); + case this.XHR: + return WebInspector.UIString("XHR"); + case this.Other: + default: + return WebInspector.UIString("other"); + } + } +} + +WebInspector.Resource.prototype = { + get url() + { + return this._url; + }, + + set url(x) + { + if (this._url === x) + return; + + var oldURL = this._url; + this._url = x; + WebInspector.resourceURLChanged(this, oldURL); + }, + + get domain() + { + return this._domain; + }, + + set domain(x) + { + if (this._domain === x) + return; + this._domain = x; + }, + + get lastPathComponent() + { + return this._lastPathComponent; + }, + + set lastPathComponent(x) + { + if (this._lastPathComponent === x) + return; + this._lastPathComponent = x; + this._lastPathComponentLowerCase = x ? x.toLowerCase() : null; + }, + + get displayName() + { + var title = this.lastPathComponent; + if (!title) + title = this.displayDomain; + if (!title) + title = this.url; + return title; + }, + + get displayDomain() + { + // WebInspector.Database calls this, so don't access more than this.domain. + if (this.domain && (!WebInspector.mainResource || (WebInspector.mainResource && this.domain !== WebInspector.mainResource.domain))) + return this.domain; + return ""; + }, + + get startTime() + { + return this._startTime; + }, + + set startTime(x) + { + if (this._startTime === x) + return; + + this._startTime = x; + + if (WebInspector.panels.resources) + WebInspector.panels.resources.refreshResource(this); + }, + + get responseReceivedTime() + { + return this._responseReceivedTime; + }, + + set responseReceivedTime(x) + { + if (this._responseReceivedTime === x) + return; + + this._responseReceivedTime = x; + + if (WebInspector.panels.resources) + WebInspector.panels.resources.refreshResource(this); + }, + + get endTime() + { + return this._endTime; + }, + + set endTime(x) + { + if (this._endTime === x) + return; + + this._endTime = x; + + if (WebInspector.panels.resources) + WebInspector.panels.resources.refreshResource(this); + }, + + get contentLength() + { + return this._contentLength; + }, + + set contentLength(x) + { + if (this._contentLength === x) + return; + + this._contentLength = x; + + if (WebInspector.panels.resources) + WebInspector.panels.resources.refreshResource(this); + }, + + get expectedContentLength() + { + return this._expectedContentLength; + }, + + set expectedContentLength(x) + { + if (this._expectedContentLength === x) + return; + this._expectedContentLength = x; + }, + + get finished() + { + return this._finished; + }, + + set finished(x) + { + if (this._finished === x) + return; + + this._finished = x; + + if (x) { + this._checkTips(); + this._checkWarnings(); + } + }, + + get failed() + { + return this._failed; + }, + + set failed(x) + { + this._failed = x; + }, + + get category() + { + return this._category; + }, + + set category(x) + { + if (this._category === x) + return; + + var oldCategory = this._category; + if (oldCategory) + oldCategory.removeResource(this); + + this._category = x; + + if (this._category) + this._category.addResource(this); + + if (WebInspector.panels.resources) { + WebInspector.panels.resources.refreshResource(this); + WebInspector.panels.resources.recreateViewForResourceIfNeeded(this); + } + }, + + get mimeType() + { + return this._mimeType; + }, + + set mimeType(x) + { + if (this._mimeType === x) + return; + + this._mimeType = x; + }, + + get type() + { + return this._type; + }, + + set type(x) + { + if (this._type === x) + return; + + this._type = x; + + switch (x) { + case WebInspector.Resource.Type.Document: + this.category = WebInspector.resourceCategories.documents; + break; + case WebInspector.Resource.Type.Stylesheet: + this.category = WebInspector.resourceCategories.stylesheets; + break; + case WebInspector.Resource.Type.Script: + this.category = WebInspector.resourceCategories.scripts; + break; + case WebInspector.Resource.Type.Image: + this.category = WebInspector.resourceCategories.images; + break; + case WebInspector.Resource.Type.Font: + this.category = WebInspector.resourceCategories.fonts; + break; + case WebInspector.Resource.Type.XHR: + this.category = WebInspector.resourceCategories.xhr; + break; + case WebInspector.Resource.Type.Other: + default: + this.category = WebInspector.resourceCategories.other; + break; + } + }, + + get documentNode() { + if ("identifier" in this) + return InspectorController.getResourceDocumentNode(this.identifier); + return null; + }, + + get requestHeaders() + { + if (this._requestHeaders === undefined) + this._requestHeaders = {}; + return this._requestHeaders; + }, + + set requestHeaders(x) + { + if (this._requestHeaders === x) + return; + + this._requestHeaders = x; + delete this._sortedRequestHeaders; + + if (WebInspector.panels.resources) + WebInspector.panels.resources.refreshResource(this); + }, + + get sortedRequestHeaders() + { + if (this._sortedRequestHeaders !== undefined) + return this._sortedRequestHeaders; + + this._sortedRequestHeaders = []; + for (var key in this.requestHeaders) + this._sortedRequestHeaders.push({header: key, value: this.requestHeaders[key]}); + this._sortedRequestHeaders.sort(function(a,b) { return a.header.localeCompare(b.header) }); + + return this._sortedRequestHeaders; + }, + + get responseHeaders() + { + if (this._responseHeaders === undefined) + this._responseHeaders = {}; + return this._responseHeaders; + }, + + set responseHeaders(x) + { + if (this._responseHeaders === x) + return; + + this._responseHeaders = x; + delete this._sortedResponseHeaders; + + if (WebInspector.panels.resources) + WebInspector.panels.resources.refreshResource(this); + }, + + get sortedResponseHeaders() + { + if (this._sortedResponseHeaders !== undefined) + return this._sortedResponseHeaders; + + this._sortedResponseHeaders = []; + for (var key in this.responseHeaders) + this._sortedResponseHeaders.push({header: key, value: this.responseHeaders[key]}); + this._sortedResponseHeaders.sort(function(a,b) { return a.header.localeCompare(b.header) }); + + return this._sortedResponseHeaders; + }, + + get errors() + { + if (!("_errors" in this)) + this._errors = 0; + return this._errors; + }, + + set errors(x) + { + if (this._errors === x) + return; + + var difference = x - this._errors; + WebInspector.errors += difference; + this._errors = x; + }, + + get warnings() + { + if (!("_warnings" in this)) + this._warnings = 0; + return this._warnings; + }, + + set warnings(x) + { + if (this._warnings === x) + return; + + var difference = x - this._warnings; + WebInspector.warnings += difference; + this._warnings = x; + }, + + get tips() + { + if (!("_tips" in this)) + this._tips = {}; + return this._tips; + }, + + _addTip: function(tip) + { + if (tip.id in this.tips) + return; + + this.tips[tip.id] = tip; + + // FIXME: Re-enable this code once we have a scope bar in the Console. + // Otherwise, we flood the Console with too many tips. + /* + var msg = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Other, + WebInspector.ConsoleMessage.MessageLevel.Tip, -1, this.url, tip.message); + WebInspector.consolePanel.addMessage(msg); + */ + }, + + _checkTips: function() + { + for (var tip in WebInspector.Tips) + this._checkTip(WebInspector.Tips[tip]); + }, + + _checkTip: function(tip) + { + var addTip = false; + switch (tip.id) { + case WebInspector.Tips.ResourceNotCompressed.id: + addTip = this._shouldCompress(); + break; + } + + if (addTip) + this._addTip(tip); + }, + + _shouldCompress: function() + { + return WebInspector.Resource.Type.isTextType(this.type) + && this.domain + && !("Content-Encoding" in this.responseHeaders) + && this.contentLength !== undefined + && this.contentLength >= 512; + }, + + _mimeTypeIsConsistentWithType: function() + { + if (typeof this.type === "undefined" + || this.type === WebInspector.Resource.Type.Other + || this.type === WebInspector.Resource.Type.XHR) + return true; + + if (this.mimeType in WebInspector.MIMETypes) + return this.type in WebInspector.MIMETypes[this.mimeType]; + + return true; + }, + + _checkWarnings: function() + { + for (var warning in WebInspector.Warnings) + this._checkWarning(WebInspector.Warnings[warning]); + }, + + _checkWarning: function(warning) + { + var addWarning = false; + var msg; + switch (warning.id) { + case WebInspector.Warnings.IncorrectMIMEType.id: + if (!this._mimeTypeIsConsistentWithType()) + msg = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Other, + WebInspector.ConsoleMessage.MessageLevel.Warning, -1, this.url, + String.sprintf(WebInspector.Warnings.IncorrectMIMEType.message, + WebInspector.Resource.Type.toString(this.type), this.mimeType)); + break; + } + + if (msg) + WebInspector.console.addMessage(msg); + } +} + +WebInspector.Resource.CompareByTime = function(a, b) +{ + if (a.responseReceivedTime < b.responseReceivedTime) + return -1; + if (a.responseReceivedTime > b.responseReceivedTime) + return 1; + if (a.startTime < b.startTime) + return -1; + if (a.startTime > b.startTime) + return 1; + if (a.endTime < b.endTime) + return -1; + if (a.endTime > b.endTime) + return 1; + return 0; +} + +WebInspector.Resource.CompareBySize = function(a, b) +{ + if (a.contentLength < b.contentLength) + return -1; + if (a.contentLength > b.contentLength) + return 1; + return 0; +} + +WebInspector.Resource.CompareByDescendingSize = function(a, b) +{ + return this.CompareBySize(a, b) * -1; +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourceCategory.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourceCategory.js new file mode 100644 index 0000000..c5591ea --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourceCategory.js @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.ResourceCategory = function(title, name) +{ + this.name = name; + this.title = title; + this.resources = []; +} + +WebInspector.ResourceCategory.prototype = { + toString: function() + { + return this.title; + }, + + addResource: function(resource) + { + var a = resource; + var resourcesLength = this.resources.length; + for (var i = 0; i < resourcesLength; ++i) { + var b = this.resources[i]; + if (a._lastPathComponentLowerCase && b._lastPathComponentLowerCase) + if (a._lastPathComponentLowerCase < b._lastPathComponentLowerCase) + break; + else if (a.name && b.name) + if (a.name < b.name) + break; + } + + this.resources.splice(i, 0, resource); + }, + + removeResource: function(resource) + { + var resourcesLength = this.resources.length; + for (var i = 0; i < resourcesLength; ++i) { + if (this.resources[i] === resource) { + this.resources.splice(i, 1); + break; + } + } + }, + + removeAllResources: function(resource) + { + this.resources = []; + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourceView.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourceView.js new file mode 100644 index 0000000..46d8a66 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourceView.js @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.ResourceView = function(resource) +{ + WebInspector.View.call(this); + + this.element.addStyleClass("resource-view"); + + this.resource = resource; + + this.contentElement = document.createElement("div"); + this.contentElement.className = "resource-view-content"; + this.element.appendChild(this.contentElement); +} + +WebInspector.ResourceView.prototype = { + attach: function() + { + document.getElementById("resource-views").appendChild(this.element); + } +} + +WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourcesPanel.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourcesPanel.js new file mode 100644 index 0000000..57c45c7 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/ResourcesPanel.js @@ -0,0 +1,1354 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.ResourcesPanel = function() +{ + WebInspector.Panel.call(this); + + this.element.addStyleClass("resources"); + + this.resourceViews = document.createElement("div"); + this.resourceViews.id = "resource-views"; + this.element.appendChild(this.resourceViews); + + this.containerElement = document.createElement("div"); + this.containerElement.id = "resources-container"; + this.containerElement.addEventListener("scroll", this._updateDividersLabelBarPosition.bind(this), false); + this.element.appendChild(this.containerElement); + + this.sidebarElement = document.createElement("div"); + this.sidebarElement.id = "resources-sidebar"; + this.sidebarElement.className = "sidebar"; + this.containerElement.appendChild(this.sidebarElement); + + this.sidebarResizeElement = document.createElement("div"); + this.sidebarResizeElement.className = "sidebar-resizer-vertical"; + this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false); + this.element.appendChild(this.sidebarResizeElement); + + this.containerContentElement = document.createElement("div"); + this.containerContentElement.id = "resources-container-content"; + this.containerElement.appendChild(this.containerContentElement); + + this.summaryElement = document.createElement("div"); + this.summaryElement.id = "resources-summary"; + this.containerContentElement.appendChild(this.summaryElement); + + this.dividersElement = document.createElement("div"); + this.dividersElement.id = "resources-dividers"; + this.containerContentElement.appendChild(this.dividersElement); + + this.dividersLabelBarElement = document.createElement("div"); + this.dividersLabelBarElement.id = "resources-dividers-label-bar"; + this.containerContentElement.appendChild(this.dividersLabelBarElement); + + this.summaryGraphElement = document.createElement("canvas"); + this.summaryGraphElement.setAttribute("width", "450"); + this.summaryGraphElement.setAttribute("height", "38"); + this.summaryGraphElement.id = "resources-summary-graph"; + this.summaryElement.appendChild(this.summaryGraphElement); + + this.legendElement = document.createElement("div"); + this.legendElement.id = "resources-graph-legend"; + this.summaryElement.appendChild(this.legendElement); + + this.sidebarTreeElement = document.createElement("ol"); + this.sidebarTreeElement.className = "sidebar-tree"; + this.sidebarElement.appendChild(this.sidebarTreeElement); + + this.sidebarTree = new TreeOutline(this.sidebarTreeElement); + + var timeGraphItem = new WebInspector.SidebarTreeElement("resources-time-graph-sidebar-item", WebInspector.UIString("Time")); + timeGraphItem.calculator = new WebInspector.ResourceTransferTimeCalculator(); + timeGraphItem.onselect = this._graphSelected.bind(this); + timeGraphItem.calculator._graphsTreeElement = timeGraphItem; + + var sizeGraphItem = new WebInspector.SidebarTreeElement("resources-size-graph-sidebar-item", WebInspector.UIString("Size")); + sizeGraphItem.calculator = new WebInspector.ResourceTransferSizeCalculator(); + sizeGraphItem.onselect = this._graphSelected.bind(this); + sizeGraphItem.calculator._graphsTreeElement = sizeGraphItem; + + this.graphsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("GRAPHS"), {}, true); + this.sidebarTree.appendChild(this.graphsTreeElement); + + this.graphsTreeElement.appendChild(timeGraphItem); + this.graphsTreeElement.appendChild(sizeGraphItem); + this.graphsTreeElement.expand(); + + this.resourcesTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RESOURCES"), {}, true); + this.sidebarTree.appendChild(this.resourcesTreeElement); + + this.resourcesTreeElement.expand(); + + this.largerResourcesButton = document.createElement("button"); + this.largerResourcesButton.id = "resources-larger-resources-status-bar-item"; + this.largerResourcesButton.className = "status-bar-item toggled-on"; + this.largerResourcesButton.title = WebInspector.UIString("Use large resource rows."); + this.largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false); + + this.sortingSelectElement = document.createElement("select"); + this.sortingSelectElement.className = "status-bar-item"; + this.sortingSelectElement.addEventListener("change", this._changeSortingFunction.bind(this), false); + + var sortingOption = document.createElement("option"); + sortingOption.label = WebInspector.UIString("Sort by Time"); + sortingOption.sortingFunction = WebInspector.ResourceSidebarTreeElement.CompareByTime; + this.sortingSelectElement.appendChild(sortingOption); + + sortingOption = document.createElement("option"); + sortingOption.label = WebInspector.UIString("Sort by Size"); + sortingOption.sortingFunction = WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize; + this.sortingSelectElement.appendChild(sortingOption); + + this.sortingFunction = WebInspector.ResourceSidebarTreeElement.CompareByTime; + + this.reset(); + + timeGraphItem.select(); +} + +WebInspector.ResourcesPanel.prototype = { + toolbarItemClass: "resources", + + get toolbarItemLabel() + { + return WebInspector.UIString("Resources"); + }, + + get statusBarItems() + { + return [this.largerResourcesButton, this.sortingSelectElement]; + }, + + show: function() + { + WebInspector.Panel.prototype.show.call(this); + this._updateDividersLabelBarPosition(); + this._updateSidebarWidth(); + this.refreshIfNeeded(); + }, + + resize: function() + { + this._updateGraphDividersIfNeeded(); + this._updateGraphBars(); + + var visibleResourceView = this.visibleResourceView; + if (visibleResourceView && "resize" in visibleResourceView) + visibleResourceView.resize(); + }, + + get visibleResourceView() + { + if (this.visibleResource) + return this.visibleResource._resourcesView; + return null; + }, + + get calculator() + { + return this._calculator; + }, + + set calculator(x) + { + this._calculator = x; + if (this._calculator) + this._calculator.reset(); + this._refreshAllResources(false, true, true); + this._updateGraphDividersIfNeeded(true); + this._updateSummaryGraph(); + }, + + get sortingFunction() + { + return this._sortingFunction; + }, + + set sortingFunction(x) + { + this._sortingFunction = x; + this._sortResourcesIfNeeded(); + }, + + get needsRefresh() + { + return this._needsRefresh; + }, + + set needsRefresh(x) + { + if (this._needsRefresh === x) + return; + this._needsRefresh = x; + if (x && this.visible) + this.refresh(); + }, + + refreshIfNeeded: function() + { + if (this.needsRefresh) + this.refresh(); + }, + + refresh: function() + { + this.needsRefresh = false; + + var staleResourcesLength = this._staleResources.length; + for (var i = 0; i < staleResourcesLength; ++i) + this.refreshResource(this._staleResources[i], false, true, true); + + this._staleResources = []; + + this._updateGraphDividersIfNeeded(); + this._sortResourcesIfNeeded(); + this._updateSummaryGraph(); + }, + + reset: function() + { + this.closeVisibleResource(); + + if (this._calculator) + this._calculator.reset(); + + if (this._resources) { + var resourcesLength = this._resources.length; + for (var i = 0; i < resourcesLength; ++i) { + var resource = this._resources[i]; + + resource.warnings = 0; + resource.errors = 0; + + delete resource._resourcesTreeElement; + delete resource._resourcesView; + } + } + + this._resources = []; + this._staleResources = []; + + this.resourcesTreeElement.removeChildren(); + this.resourceViews.removeChildren(); + + this._updateGraphDividersIfNeeded(true); + + this._drawSummaryGraph(); // draws an empty graph + }, + + addResource: function(resource) + { + this._resources.push(resource); + + var resourceTreeElement = new WebInspector.ResourceSidebarTreeElement(resource); + resource._resourcesTreeElement = resourceTreeElement; + + resourceTreeElement.updateGraphSideWidth(this.dividersElement.offsetWidth); + + this.resourcesTreeElement.appendChild(resourceTreeElement); + + this.refreshResource(resource); + }, + + removeResource: function(resource) + { + if (this.visibleResourceView === resource._resourcesView) + this.closeVisibleResource(); + + var resourcesLength = this._resources.length; + for (var i = 0; i < resourcesLength; ++i) { + if (this._resources[i] === resource) { + this._resources.splice(i, 1); + break; + } + } + + this.resourcesTreeElement.removeChild(resource._resourcesTreeElement); + + resource.warnings = 0; + resource.errors = 0; + + delete resource._resourcesTreeElement; + delete resource._resourcesView; + }, + + addMessageToResource: function(resource, msg) + { + if (!resource) + return; + + switch (msg.level) { + case WebInspector.ConsoleMessage.MessageLevel.Warning: + ++resource.warnings; + break; + case WebInspector.ConsoleMessage.MessageLevel.Error: + ++resource.errors; + break; + } + + resource._resourcesTreeElement.updateErrorsAndWarnings(); + + var view = this._resourceView(resource); + if (view.addMessage) + view.addMessage(msg); + }, + + clearMessages: function() + { + var resourcesLength = this._resources.length; + for (var i = 0; i < resourcesLength; ++i) { + var resource = this._resources[i]; + resource.warnings = 0; + resource.errors = 0; + + resource._resourcesTreeElement.updateErrorsAndWarnings(); + + var view = resource._resourcesView; + if (!view || !view.clearMessages) + continue; + view.clearMessages(); + } + }, + + refreshResource: function(resource, skipBoundaryUpdate, skipSort, immediate) + { + if (!this.visible) { + this._staleResources.push(resource); + this.needsRefresh = true; + return; + } + + if (!skipBoundaryUpdate) { + if (this._updateGraphBoundriesIfNeeded(resource, immediate)) + return; // _updateGraphBoundriesIfNeeded refreshes all resources if it returns true, so just return. + } + + if (!skipSort) { + if (immediate) + this._sortResourcesIfNeeded(); + else + this._sortResourcesSoonIfNeeded(); + } + + this._updateSummaryGraphSoon(); + + if (!resource._resourcesTreeElement) + return; + + resource._resourcesTreeElement.refresh(); + + var percentages = this.calculator.computeBarGraphPercentages(resource); + + var barLeftElement = resource._resourcesTreeElement.barLeftElement; + barLeftElement.style.left = percentages.start + "%"; + barLeftElement.style.right = (100 - percentages.end) + "%"; + + var barRightElement = resource._resourcesTreeElement.barRightElement; + barRightElement.style.left = percentages.middle + "%"; + barRightElement.style.right = (100 - percentages.end) + "%"; + }, + + recreateViewForResourceIfNeeded: function(resource) + { + if (!resource || !resource._resourcesView) + return; + + var newView = this._createResourceView(resource); + if (newView.prototype === resource._resourcesView.prototype) + return; + + resource.warnings = 0; + resource.errors = 0; + + resource._resourcesTreeElement.updateErrorsAndWarnings(); + + resource._resourcesView.detach(); + delete resource._resourcesView; + + resource._resourcesView = newView; + + if (resource !== this.visibleResource) + return; + + newView.show(); + }, + + showResource: function(resource, line) + { + if (!resource) + return; + + this.containerElement.addStyleClass("viewing-resource"); + + if (this.visibleResource && this.visibleResource._resourcesView) + this.visibleResource._resourcesView.hide(); + + var view = this._resourceView(resource); + view.show(); + + if (line && view.showLine) + view.showLine(line); + + if (resource._resourcesTreeElement) { + resource._resourcesTreeElement.reveal(); + resource._resourcesTreeElement.select(true); + } + + this.visibleResource = resource; + + this._updateSidebarWidth(); + }, + + closeVisibleResource: function() + { + this.containerElement.removeStyleClass("viewing-resource"); + this._updateDividersLabelBarPosition(); + + if (this.visibleResource && this.visibleResource._resourcesView) + this.visibleResource._resourcesView.hide(); + delete this.visibleResource; + + if (this._calculator && this._calculator._graphsTreeElement) + this._calculator._graphsTreeElement.select(true); + + this._updateSidebarWidth(); + }, + + sourceFrameForResource: function(resource) + { + var view = this._resourceView(resource); + if (!view) + return null; + + if (!view.setupSourceFrameIfNeeded) + return null; + + // Setting up the source frame requires that we be attached. + if (!this.element.parentNode) + this.attach(); + + view.setupSourceFrameIfNeeded(); + return view.frameElement; + }, + + handleKeyEvent: function(event) + { + this.sidebarTree.handleKeyEvent(event); + }, + + _makeLegendElement: function(label, value, color) + { + var legendElement = document.createElement("label"); + legendElement.className = "resources-graph-legend-item"; + + if (color) { + var swatch = document.createElement("canvas"); + swatch.className = "resources-graph-legend-swatch"; + swatch.setAttribute("width", "13"); + swatch.setAttribute("height", "24"); + + legendElement.appendChild(swatch); + + this._drawSwatch(swatch, color); + } + + var labelElement = document.createElement("div"); + labelElement.className = "resources-graph-legend-label"; + legendElement.appendChild(labelElement); + + var headerElement = document.createElement("div"); + var headerElement = document.createElement("div"); + headerElement.className = "resources-graph-legend-header"; + headerElement.textContent = label; + labelElement.appendChild(headerElement); + + var valueElement = document.createElement("div"); + valueElement.className = "resources-graph-legend-value"; + valueElement.textContent = value; + labelElement.appendChild(valueElement); + + return legendElement; + }, + + _sortResourcesSoonIfNeeded: function() + { + if ("_sortResourcesTimeout" in this) + return; + this._sortResourcesTimeout = setTimeout(this._sortResourcesIfNeeded.bind(this), 500); + }, + + _sortResourcesIfNeeded: function() + { + if ("_sortResourcesTimeout" in this) { + clearTimeout(this._sortResourcesTimeout); + delete this._sortResourcesTimeout; + } + + var sortedElements = [].concat(this.resourcesTreeElement.children); + sortedElements.sort(this.sortingFunction); + + var sortedElementsLength = sortedElements.length; + for (var i = 0; i < sortedElementsLength; ++i) { + var treeElement = sortedElements[i]; + if (treeElement === this.resourcesTreeElement.children[i]) + continue; + this.resourcesTreeElement.removeChild(treeElement); + this.resourcesTreeElement.insertChild(treeElement, i); + } + }, + + _updateGraphBoundriesIfNeeded: function(resource, immediate) + { + var didChange = this.calculator.updateBoundries(resource); + + if (didChange) { + if (immediate) { + this._refreshAllResources(true, true, immediate); + this._updateGraphDividersIfNeeded(); + } else { + this._refreshAllResourcesSoon(true, true, immediate); + this._updateGraphDividersSoonIfNeeded(); + } + } + + return didChange; + }, + + _updateGraphDividersSoonIfNeeded: function() + { + if ("_updateGraphDividersTimeout" in this) + return; + this._updateGraphDividersTimeout = setTimeout(this._updateGraphDividersIfNeeded.bind(this), 500); + }, + + _updateGraphDividersIfNeeded: function(force) + { + if ("_updateGraphDividersTimeout" in this) { + clearTimeout(this._updateGraphDividersTimeout); + delete this._updateGraphDividersTimeout; + } + + if (!this.visible) { + this.needsRefresh = true; + return; + } + + if (document.body.offsetWidth <= 0) { + // The stylesheet hasn't loaded yet, so we need to update later. + setTimeout(this._updateGraphDividersIfNeeded.bind(this), 0); + return; + } + + var dividerCount = Math.round(this.dividersElement.offsetWidth / 64); + var slice = this.calculator.boundarySpan / dividerCount; + if (!force && this._currentDividerSlice === slice) + return; + + this._currentDividerSlice = slice; + + this.dividersElement.removeChildren(); + this.dividersLabelBarElement.removeChildren(); + + for (var i = 1; i <= dividerCount; ++i) { + var divider = document.createElement("div"); + divider.className = "resources-divider"; + if (i === dividerCount) + divider.addStyleClass("last"); + divider.style.left = ((i / dividerCount) * 100) + "%"; + + this.dividersElement.appendChild(divider); + } + + for (var i = 1; i <= dividerCount; ++i) { + var divider = document.createElement("div"); + divider.className = "resources-divider"; + if (i === dividerCount) + divider.addStyleClass("last"); + divider.style.left = ((i / dividerCount) * 100) + "%"; + + var label = document.createElement("div"); + label.className = "resources-divider-label"; + if (!isNaN(slice)) + label.textContent = this.calculator.formatValue(slice * i); + divider.appendChild(label); + + this.dividersLabelBarElement.appendChild(divider); + } + }, + + _updateGraphBars: function() + { + if (!this.visible) { + this.needsRefresh = true; + return; + } + + if (document.body.offsetWidth <= 0) { + // The stylesheet hasn't loaded yet, so we need to update later. + setTimeout(this._updateGraphBars.bind(this), 0); + return; + } + + var dividersElementWidth = this.dividersElement.offsetWidth; + var resourcesLength = this._resources.length; + for (var i = 0; i < resourcesLength; ++i) { + var resourceTreeItem = this._resources[i]._resourcesTreeElement; + if (!resourceTreeItem) + continue; + resourceTreeItem.updateGraphSideWidth(dividersElementWidth); + } + }, + + _refreshAllResourcesSoon: function(skipBoundaryUpdate, skipSort, immediate) + { + if ("_refreshAllResourcesTimeout" in this) + return; + this._refreshAllResourcesTimeout = setTimeout(this._refreshAllResources.bind(this), 500, skipBoundaryUpdate, skipSort, immediate); + }, + + _refreshAllResources: function(skipBoundaryUpdate, skipSort, immediate) + { + if ("_refreshAllResourcesTimeout" in this) { + clearTimeout(this._refreshAllResourcesTimeout); + delete this._refreshAllResourcesTimeout; + } + + var resourcesLength = this._resources.length; + for (var i = 0; i < resourcesLength; ++i) + this.refreshResource(this._resources[i], skipBoundaryUpdate, skipSort, immediate); + }, + + _fadeOutRect: function(ctx, x, y, w, h, a1, a2) + { + ctx.save(); + + var gradient = ctx.createLinearGradient(x, y, x, y + h); + gradient.addColorStop(0.0, "rgba(0, 0, 0, " + (1.0 - a1) + ")"); + gradient.addColorStop(0.8, "rgba(0, 0, 0, " + (1.0 - a2) + ")"); + gradient.addColorStop(1.0, "rgba(0, 0, 0, 1.0)"); + + ctx.globalCompositeOperation = "destination-out"; + + ctx.fillStyle = gradient; + ctx.fillRect(x, y, w, h); + + ctx.restore(); + }, + + _drawSwatch: function(canvas, color) + { + var ctx = canvas.getContext("2d"); + + function drawSwatchSquare() { + ctx.fillStyle = color; + ctx.fillRect(0, 0, 13, 13); + + var gradient = ctx.createLinearGradient(0, 0, 13, 13); + gradient.addColorStop(0.0, "rgba(255, 255, 255, 0.2)"); + gradient.addColorStop(1.0, "rgba(255, 255, 255, 0.0)"); + + ctx.fillStyle = gradient; + ctx.fillRect(0, 0, 13, 13); + + gradient = ctx.createLinearGradient(13, 13, 0, 0); + gradient.addColorStop(0.0, "rgba(0, 0, 0, 0.2)"); + gradient.addColorStop(1.0, "rgba(0, 0, 0, 0.0)"); + + ctx.fillStyle = gradient; + ctx.fillRect(0, 0, 13, 13); + + ctx.strokeStyle = "rgba(0, 0, 0, 0.6)"; + ctx.strokeRect(0.5, 0.5, 12, 12); + } + + ctx.clearRect(0, 0, 13, 24); + + drawSwatchSquare(); + + ctx.save(); + + ctx.translate(0, 25); + ctx.scale(1, -1); + + drawSwatchSquare(); + + ctx.restore(); + + this._fadeOutRect(ctx, 0, 13, 13, 13, 0.5, 0.0); + }, + + _drawSummaryGraph: function(segments) + { + if (!this.summaryGraphElement) + return; + + if (!segments || !segments.length) { + segments = [{color: "white", value: 1}]; + this._showingEmptySummaryGraph = true; + } else + delete this._showingEmptySummaryGraph; + + // Calculate the total of all segments. + var total = 0; + for (var i = 0; i < segments.length; ++i) + total += segments[i].value; + + // Calculate the percentage of each segment, rounded to the nearest percent. + var percents = segments.map(function(s) { return Math.max(Math.round(100 * s.value / total), 1) }); + + // Calculate the total percentage. + var percentTotal = 0; + for (var i = 0; i < percents.length; ++i) + percentTotal += percents[i]; + + // Make sure our percentage total is not greater-than 100, it can be greater + // if we rounded up for a few segments. + while (percentTotal > 100) { + for (var i = 0; i < percents.length && percentTotal > 100; ++i) { + if (percents[i] > 1) { + --percents[i]; + --percentTotal; + } + } + } + + // Make sure our percentage total is not less-than 100, it can be less + // if we rounded down for a few segments. + while (percentTotal < 100) { + for (var i = 0; i < percents.length && percentTotal < 100; ++i) { + ++percents[i]; + ++percentTotal; + } + } + + var ctx = this.summaryGraphElement.getContext("2d"); + + var x = 0; + var y = 0; + var w = 450; + var h = 19; + var r = (h / 2); + + function drawPillShadow() + { + // This draws a line with a shadow that is offset away from the line. The line is stroked + // twice with different X shadow offsets to give more feathered edges. Later we erase the + // line with destination-out 100% transparent black, leaving only the shadow. This only + // works if nothing has been drawn into the canvas yet. + + ctx.beginPath(); + ctx.moveTo(x + 4, y + h - 3 - 0.5); + ctx.lineTo(x + w - 4, y + h - 3 - 0.5); + ctx.closePath(); + + ctx.save(); + + ctx.shadowBlur = 2; + ctx.shadowColor = "rgba(0, 0, 0, 0.5)"; + ctx.shadowOffsetX = 3; + ctx.shadowOffsetY = 5; + + ctx.strokeStyle = "white"; + ctx.lineWidth = 1; + + ctx.stroke(); + + ctx.shadowOffsetX = -3; + + ctx.stroke(); + + ctx.restore(); + + ctx.save(); + + ctx.globalCompositeOperation = "destination-out"; + ctx.strokeStyle = "rgba(0, 0, 0, 1)"; + ctx.lineWidth = 1; + + ctx.stroke(); + + ctx.restore(); + } + + function drawPill() + { + // Make a rounded rect path. + ctx.beginPath(); + ctx.moveTo(x, y + r); + ctx.lineTo(x, y + h - r); + ctx.quadraticCurveTo(x, y + h, x + r, y + h); + ctx.lineTo(x + w - r, y + h); + ctx.quadraticCurveTo(x + w, y + h, x + w, y + h - r); + ctx.lineTo(x + w, y + r); + ctx.quadraticCurveTo(x + w, y, x + w - r, y); + ctx.lineTo(x + r, y); + ctx.quadraticCurveTo(x, y, x, y + r); + ctx.closePath(); + + // Clip to the rounded rect path. + ctx.save(); + ctx.clip(); + + // Fill the segments with the associated color. + var previousSegmentsWidth = 0; + for (var i = 0; i < segments.length; ++i) { + var segmentWidth = Math.round(w * percents[i] / 100); + ctx.fillStyle = segments[i].color; + ctx.fillRect(x + previousSegmentsWidth, y, segmentWidth, h); + previousSegmentsWidth += segmentWidth; + } + + // Draw the segment divider lines. + ctx.lineWidth = 1; + for (var i = 1; i < 20; ++i) { + ctx.beginPath(); + ctx.moveTo(x + (i * Math.round(w / 20)) + 0.5, y); + ctx.lineTo(x + (i * Math.round(w / 20)) + 0.5, y + h); + ctx.closePath(); + + ctx.strokeStyle = "rgba(0, 0, 0, 0.2)"; + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(x + (i * Math.round(w / 20)) + 1.5, y); + ctx.lineTo(x + (i * Math.round(w / 20)) + 1.5, y + h); + ctx.closePath(); + + ctx.strokeStyle = "rgba(255, 255, 255, 0.2)"; + ctx.stroke(); + } + + // Draw the pill shading. + var lightGradient = ctx.createLinearGradient(x, y, x, y + (h / 1.5)); + lightGradient.addColorStop(0.0, "rgba(220, 220, 220, 0.6)"); + lightGradient.addColorStop(0.4, "rgba(220, 220, 220, 0.2)"); + lightGradient.addColorStop(1.0, "rgba(255, 255, 255, 0.0)"); + + var darkGradient = ctx.createLinearGradient(x, y + (h / 3), x, y + h); + darkGradient.addColorStop(0.0, "rgba(0, 0, 0, 0.0)"); + darkGradient.addColorStop(0.8, "rgba(0, 0, 0, 0.2)"); + darkGradient.addColorStop(1.0, "rgba(0, 0, 0, 0.5)"); + + ctx.fillStyle = darkGradient; + ctx.fillRect(x, y, w, h); + + ctx.fillStyle = lightGradient; + ctx.fillRect(x, y, w, h); + + ctx.restore(); + } + + ctx.clearRect(x, y, w, (h * 2)); + + drawPillShadow(); + drawPill(); + + ctx.save(); + + ctx.translate(0, (h * 2) + 1); + ctx.scale(1, -1); + + drawPill(); + + ctx.restore(); + + this._fadeOutRect(ctx, x, y + h + 1, w, h, 0.5, 0.0); + }, + + _updateSummaryGraphSoon: function() + { + if ("_updateSummaryGraphTimeout" in this) + return; + this._updateSummaryGraphTimeout = setTimeout(this._updateSummaryGraph.bind(this), (this._showingEmptySummaryGraph ? 0 : 500)); + }, + + _updateSummaryGraph: function() + { + if ("_updateSummaryGraphTimeout" in this) { + clearTimeout(this._updateSummaryGraphTimeout); + delete this._updateSummaryGraphTimeout; + } + + var graphInfo = this.calculator.computeSummaryValues(this._resources); + + var categoryOrder = ["documents", "stylesheets", "images", "scripts", "xhr", "fonts", "other"]; + var categoryColors = {documents: {r: 47, g: 102, b: 236}, stylesheets: {r: 157, g: 231, b: 119}, images: {r: 164, g: 60, b: 255}, scripts: {r: 255, g: 121, b: 0}, xhr: {r: 231, g: 231, b: 10}, fonts: {r: 255, g: 82, b: 62}, other: {r: 186, g: 186, b: 186}}; + var fillSegments = []; + + this.legendElement.removeChildren(); + + if (this.totalLegendLabel) + this.totalLegendLabel.parentNode.removeChild(this.totalLegendLabel); + + for (var i = 0; i < categoryOrder.length; ++i) { + var category = categoryOrder[i]; + var size = graphInfo.categoryValues[category]; + if (!size) + continue; + + var color = categoryColors[category]; + var colorString = "rgb(" + color.r + ", " + color.g + ", " + color.b + ")"; + + var fillSegment = {color: colorString, value: size}; + fillSegments.push(fillSegment); + + var legendLabel = this._makeLegendElement(WebInspector.resourceCategories[category].title, this.calculator.formatValue(size), colorString); + this.legendElement.appendChild(legendLabel); + } + + if (graphInfo.total) { + var totalLegendLabel = this._makeLegendElement(WebInspector.UIString("Total"), this.calculator.formatValue(graphInfo.total)); + totalLegendLabel.addStyleClass("total"); + this.legendElement.appendChild(totalLegendLabel); + } + + this._drawSummaryGraph(fillSegments); + }, + + _updateDividersLabelBarPosition: function() + { + var scrollTop = this.containerElement.scrollTop; + var dividersTop = (scrollTop < this.summaryElement.offsetHeight ? this.summaryElement.offsetHeight : scrollTop); + this.dividersElement.style.top = scrollTop + "px"; + this.dividersLabelBarElement.style.top = dividersTop + "px"; + }, + + _graphSelected: function(treeElement) + { + this.calculator = treeElement.calculator; + this.closeVisibleResource(); + this.containerElement.scrollTop = 0; + }, + + _toggleLargerResources: function() + { + if (!this.resourcesTreeElement._childrenListNode) + return; + + if (this.resourcesTreeElement._childrenListNode.hasStyleClass("small")) { + this.resourcesTreeElement._childrenListNode.removeStyleClass("small"); + this.largerResourcesButton.addStyleClass("toggled-on"); + } else { + this.resourcesTreeElement._childrenListNode.addStyleClass("small"); + this.largerResourcesButton.removeStyleClass("toggled-on"); + } + }, + + _changeSortingFunction: function() + { + var selectedOption = this.sortingSelectElement[this.sortingSelectElement.selectedIndex]; + this.sortingFunction = selectedOption.sortingFunction; + }, + + _resourceView: function(resource) + { + if (!resource) + return null; + if (!resource._resourcesView) + resource._resourcesView = this._createResourceView(resource); + return resource._resourcesView; + }, + + _createResourceView: function(resource) + { + switch (resource.category) { + case WebInspector.resourceCategories.documents: + case WebInspector.resourceCategories.stylesheets: + case WebInspector.resourceCategories.scripts: + case WebInspector.resourceCategories.xhr: + return new WebInspector.SourceView(resource); + case WebInspector.resourceCategories.images: + return new WebInspector.ImageView(resource); + case WebInspector.resourceCategories.fonts: + return new WebInspector.FontView(resource); + default: + return new WebInspector.ResourceView(resource); + } + }, + + _startSidebarDragging: function(event) + { + WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize"); + }, + + _sidebarDragging: function(event) + { + this._updateSidebarWidth(event.pageX); + + event.preventDefault(); + }, + + _endSidebarDragging: function(event) + { + WebInspector.elementDragEnd(event); + }, + + _updateSidebarWidth: function(width) + { + if (this.sidebarElement.offsetWidth <= 0) { + // The stylesheet hasn't loaded yet, so we need to update later. + setTimeout(this._updateSidebarWidth.bind(this), 0, width); + return; + } + + if (!("_currentSidebarWidth" in this)) + this._currentSidebarWidth = this.sidebarElement.offsetWidth; + + if (typeof width === "undefined") + width = this._currentSidebarWidth; + + width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2); + + this._currentSidebarWidth = width; + + if (this.visibleResource) { + this.containerElement.style.width = width + "px"; + this.sidebarElement.style.removeProperty("width"); + } else { + this.sidebarElement.style.width = width + "px"; + this.containerElement.style.removeProperty("width"); + } + + this.containerContentElement.style.left = width + "px"; + this.resourceViews.style.left = width + "px"; + this.sidebarResizeElement.style.left = (width - 3) + "px"; + + this._updateGraphBars(); + this._updateGraphDividersIfNeeded(); + } +} + +WebInspector.ResourcesPanel.prototype.__proto__ = WebInspector.Panel.prototype; + +WebInspector.ResourceCalculator = function() +{ +} + +WebInspector.ResourceCalculator.prototype = { + computeSummaryValues: function(resources) + { + var total = 0; + var categoryValues = {}; + + var resourcesLength = resources.length; + for (var i = 0; i < resourcesLength; ++i) { + var resource = resources[i]; + var value = this._value(resource); + if (typeof value === "undefined") + continue; + if (!(resource.category.name in categoryValues)) + categoryValues[resource.category.name] = 0; + categoryValues[resource.category.name] += value; + total += value; + } + + return {categoryValues: categoryValues, total: total}; + }, + + computeBarGraphPercentages: function(resource) + { + return {start: 0, middle: 0, end: (this._value(resource) / this.boundarySpan) * 100}; + }, + + get boundarySpan() + { + return this.maximumBoundary - this.minimumBoundary; + }, + + updateBoundries: function(resource) + { + this.minimumBoundary = 0; + + var value = this._value(resource); + if (typeof this.maximumBoundary === "undefined" || value > this.maximumBoundary) { + this.maximumBoundary = value; + return true; + } + + return false; + }, + + reset: function() + { + delete this.minimumBoundary; + delete this.maximumBoundary; + }, + + _value: function(resource) + { + return 0; + }, + + formatValue: function(value) + { + return value.toString(); + } +} + +WebInspector.ResourceTransferTimeCalculator = function() +{ + WebInspector.ResourceCalculator.call(this); +} + +WebInspector.ResourceTransferTimeCalculator.prototype = { + computeSummaryValues: function(resources) + { + var resourcesByCategory = {}; + var resourcesLength = resources.length; + for (var i = 0; i < resourcesLength; ++i) { + var resource = resources[i]; + if (!(resource.category.name in resourcesByCategory)) + resourcesByCategory[resource.category.name] = []; + resourcesByCategory[resource.category.name].push(resource); + } + + var earliestStart; + var latestEnd; + var categoryValues = {}; + for (var category in resourcesByCategory) { + resourcesByCategory[category].sort(WebInspector.Resource.CompareByTime); + categoryValues[category] = 0; + + var segment = {start: -1, end: -1}; + + var categoryResources = resourcesByCategory[category]; + var resourcesLength = categoryResources.length; + for (var i = 0; i < resourcesLength; ++i) { + var resource = categoryResources[i]; + if (resource.startTime === -1 || resource.endTime === -1) + continue; + + if (typeof earliestStart === "undefined") + earliestStart = resource.startTime; + else + earliestStart = Math.min(earliestStart, resource.startTime); + + if (typeof latestEnd === "undefined") + latestEnd = resource.endTime; + else + latestEnd = Math.max(latestEnd, resource.endTime); + + if (resource.startTime <= segment.end) { + segment.end = Math.max(segment.end, resource.endTime); + continue; + } + + categoryValues[category] += segment.end - segment.start; + + segment.start = resource.startTime; + segment.end = resource.endTime; + } + + // Add the last segment + categoryValues[category] += segment.end - segment.start; + } + + return {categoryValues: categoryValues, total: latestEnd - earliestStart}; + }, + + computeBarGraphPercentages: function(resource) + { + if (resource.startTime !== -1) + var start = ((resource.startTime - this.minimumBoundary) / this.boundarySpan) * 100; + else + var start = 100; + + if (resource.responseReceivedTime !== -1) + var middle = ((resource.responseReceivedTime - this.minimumBoundary) / this.boundarySpan) * 100; + else + var middle = 100; + + if (resource.endTime !== -1) + var end = ((resource.endTime - this.minimumBoundary) / this.boundarySpan) * 100; + else + var end = 100; + + return {start: start, middle: middle, end: end}; + }, + + updateBoundries: function(resource) + { + var didChange = false; + if (resource.startTime !== -1 && (typeof this.minimumBoundary === "undefined" || resource.startTime < this.minimumBoundary)) { + this.minimumBoundary = resource.startTime; + didChange = true; + } + + if (resource.endTime !== -1 && (typeof this.maximumBoundary === "undefined" || resource.endTime > this.maximumBoundary)) { + this.maximumBoundary = resource.endTime; + didChange = true; + } + + return didChange; + }, + + formatValue: function(value) + { + return Number.secondsToString(value, WebInspector.UIString.bind(WebInspector)); + } +} + +WebInspector.ResourceTransferTimeCalculator.prototype.__proto__ = WebInspector.ResourceCalculator.prototype; + +WebInspector.ResourceTransferSizeCalculator = function() +{ + WebInspector.ResourceCalculator.call(this); +} + +WebInspector.ResourceTransferSizeCalculator.prototype = { + _value: function(resource) + { + return resource.contentLength; + }, + + formatValue: function(value) + { + return Number.bytesToString(value, WebInspector.UIString.bind(WebInspector)); + } +} + +WebInspector.ResourceTransferSizeCalculator.prototype.__proto__ = WebInspector.ResourceCalculator.prototype; + +WebInspector.ResourceSidebarTreeElement = function(resource) +{ + this.resource = resource; + + WebInspector.SidebarTreeElement.call(this, "resource-sidebar-tree-item", "", "", resource); + + this.refreshTitles(); + + this.graphSideElement = document.createElement("div"); + this.graphSideElement.className = "resources-graph-side"; + + this.barAreaElement = document.createElement("div"); + this.barAreaElement.className = "resources-graph-bar-area"; + this.graphSideElement.appendChild(this.barAreaElement); + + this.barLeftElement = document.createElement("div"); + this.barLeftElement.className = "resources-graph-bar waiting"; + this.barAreaElement.appendChild(this.barLeftElement); + + this.barRightElement = document.createElement("div"); + this.barRightElement.className = "resources-graph-bar"; + this.barAreaElement.appendChild(this.barRightElement); +} + +WebInspector.ResourceSidebarTreeElement.prototype = { + onattach: function() + { + WebInspector.SidebarTreeElement.prototype.onattach.call(this); + + this._listItemNode.appendChild(this.graphSideElement); + this._listItemNode.addStyleClass("resources-category-" + this.resource.category.name); + }, + + onselect: function() + { + WebInspector.panels.resources.showResource(this.resource); + }, + + get mainTitle() + { + return this.resource.displayName; + }, + + set mainTitle(x) + { + // Do nothing. + }, + + get subtitle() + { + var subtitle = this.resource.displayDomain; + + if (this.resource.path && this.resource.lastPathComponent) { + var lastPathComponentIndex = this.resource.path.lastIndexOf("/" + this.resource.lastPathComponent); + if (lastPathComponentIndex != -1) + subtitle += this.resource.path.substring(0, lastPathComponentIndex); + } + + return subtitle; + }, + + set subtitle(x) + { + // Do nothing. + }, + + refresh: function() + { + this.refreshTitles(); + + var newClassName = "sidebar-tree-item resource-sidebar-tree-item resources-category-" + this.resource.category.name; + if (this._listItemNode && this._listItemNode.className !== newClassName) + this._listItemNode.className = newClassName; + }, + + updateErrorsAndWarnings: function() + { + if (this.resource.warnings || this.resource.errors) + this.bubbleText = (this.resource.warnings + this.resource.errors); + else + this.bubbleText = ""; + + if (this.resource.warnings) + this.bubbleElement.addStyleClass("warning"); + else + this.bubbleElement.removeStyleClass("warning"); + + if (this.resource.errors) + this.bubbleElement.addStyleClass("error"); + else + this.bubbleElement.removeStyleClass("error"); + }, + + updateGraphSideWidth: function(width) + { + width += 1; // Add one to account for the sidebar border width. + this.graphSideElement.style.right = -width + "px"; + this.graphSideElement.style.width = width + "px"; + } +} + +WebInspector.ResourceSidebarTreeElement.CompareByTime = function(a, b) +{ + return WebInspector.Resource.CompareByTime(a.resource, b.resource); +} + +WebInspector.ResourceSidebarTreeElement.CompareBySize = function(a, b) +{ + return WebInspector.Resource.CompareBySize(a.resource, b.resource); +} + +WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize = function(a, b) +{ + return WebInspector.Resource.CompareByDescendingSize(a.resource, b.resource); +} + +WebInspector.ResourceSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/ScriptsPanel.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/ScriptsPanel.js new file mode 100644 index 0000000..dbc0e4c --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/ScriptsPanel.js @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.ScriptsPanel = function() +{ + WebInspector.Panel.call(this); + + this.element.addStyleClass("scripts"); + + this.topStatusBar = document.createElement("div"); + this.topStatusBar.className = "status-bar"; + this.topStatusBar.id = "scripts-status-bar"; + this.element.appendChild(this.topStatusBar); + + this.backButton = document.createElement("button"); + this.backButton.className = "status-bar-item"; + this.backButton.id = "scripts-back"; + this.backButton.title = WebInspector.UIString("Show the previous script resource."); + this.backButton.disabled = true; + this.backButton.appendChild(document.createElement("img")); + this.topStatusBar.appendChild(this.backButton); + + this.forwardButton = document.createElement("button"); + this.forwardButton.className = "status-bar-item"; + this.forwardButton.id = "scripts-forward"; + this.forwardButton.title = WebInspector.UIString("Show the next script resource."); + this.forwardButton.disabled = true; + this.forwardButton.appendChild(document.createElement("img")); + this.topStatusBar.appendChild(this.forwardButton); + + this.filesSelectElement = document.createElement("select"); + this.filesSelectElement.className = "status-bar-item"; + this.filesSelectElement.id = "scripts-files"; + this.topStatusBar.appendChild(this.filesSelectElement); + + this.functionsSelectElement = document.createElement("select"); + this.functionsSelectElement.className = "status-bar-item"; + this.functionsSelectElement.id = "scripts-functions"; + this.topStatusBar.appendChild(this.functionsSelectElement); + + this.sidebarButtonsElement = document.createElement("div"); + this.sidebarButtonsElement.id = "scripts-sidebar-buttons"; + this.topStatusBar.appendChild(this.sidebarButtonsElement); + + this.pauseButton = document.createElement("button"); + this.pauseButton.className = "status-bar-item"; + this.pauseButton.id = "scripts-pause"; + this.pauseButton.title = WebInspector.UIString("Pause script execution."); + this.pauseButton.disabled = true; + this.pauseButton.appendChild(document.createElement("img")); + this.sidebarButtonsElement.appendChild(this.pauseButton); + + this.stepOverButton = document.createElement("button"); + this.stepOverButton.className = "status-bar-item"; + this.stepOverButton.id = "scripts-step-over"; + this.stepOverButton.title = WebInspector.UIString("Step over next function call."); + this.stepOverButton.disabled = true; + this.stepOverButton.appendChild(document.createElement("img")); + this.sidebarButtonsElement.appendChild(this.stepOverButton); + + this.stepIntoButton = document.createElement("button"); + this.stepIntoButton.className = "status-bar-item"; + this.stepIntoButton.id = "scripts-step-into"; + this.stepIntoButton.title = WebInspector.UIString("Step into next function call."); + this.stepIntoButton.disabled = true; + this.stepIntoButton.appendChild(document.createElement("img")); + this.sidebarButtonsElement.appendChild(this.stepIntoButton); + + this.stepOutButton = document.createElement("button"); + this.stepOutButton.className = "status-bar-item"; + this.stepOutButton.id = "scripts-step-out"; + this.stepOutButton.title = WebInspector.UIString("Step out of current function."); + this.stepOutButton.disabled = true; + this.stepOutButton.appendChild(document.createElement("img")); + this.sidebarButtonsElement.appendChild(this.stepOutButton); + + this.debuggerStatusElement = document.createElement("div"); + this.debuggerStatusElement.id = "scripts-debugger-status"; + this.sidebarButtonsElement.appendChild(this.debuggerStatusElement); + + this.scriptResourceViews = document.createElement("div"); + this.scriptResourceViews.id = "script-resource-views"; + + this.sidebarElement = document.createElement("div"); + this.sidebarElement.id = "scripts-sidebar"; + + this.sidebarResizeElement = document.createElement("div"); + this.sidebarResizeElement.className = "sidebar-resizer-vertical"; + this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarResizeDrag.bind(this), false); + + this.sidebarResizeWidgetElement = document.createElement("div"); + this.sidebarResizeWidgetElement.id = "scripts-sidebar-resizer-widget"; + this.sidebarResizeWidgetElement.addEventListener("mousedown", this._startSidebarResizeDrag.bind(this), false); + this.topStatusBar.appendChild(this.sidebarResizeWidgetElement); + + this.sidebarPanes = {}; + this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane(); + this.sidebarPanes.breakpoints = new WebInspector.BreakpointsSidebarPane(); + + for (var pane in this.sidebarPanes) + this.sidebarElement.appendChild(this.sidebarPanes[pane].element); + + this.element.appendChild(this.scriptResourceViews); + this.element.appendChild(this.sidebarElement); + this.element.appendChild(this.sidebarResizeElement); + + this.debuggingButton = document.createElement("button"); + this.debuggingButton.id = "scripts-debugging-status-bar-item"; + this.debuggingButton.className = "status-bar-item"; + this.debuggingButton.addEventListener("click", this._toggleDebugging.bind(this), false); + + this.reset(); +} + +WebInspector.ScriptsPanel.prototype = { + toolbarItemClass: "scripts", + + get toolbarItemLabel() + { + return WebInspector.UIString("Scripts"); + }, + + get statusBarItems() + { + return [this.debuggingButton]; + }, + + show: function() + { + WebInspector.Panel.prototype.show.call(this); + this.sidebarResizeElement.style.right = (this.sidebarElement.offsetWidth - 3) + "px"; + }, + + reset: function() + { + this._updateDebuggerButtons(); + }, + + _startSidebarResizeDrag: function(event) + { + WebInspector.elementDragStart(this.sidebarElement, this._sidebarResizeDrag.bind(this), this._endSidebarResizeDrag.bind(this), event, "col-resize"); + + if (event.target === this.sidebarResizeWidgetElement) + this._dragOffset = (event.target.offsetWidth - (event.pageX - event.target.totalOffsetLeft)); + else + this._dragOffset = 0; + }, + + _endSidebarResizeDrag: function(event) + { + WebInspector.elementDragEnd(event); + + delete this._dragOffset; + }, + + _sidebarResizeDrag: function(event) + { + var x = event.pageX + this._dragOffset; + var newWidth = Number.constrain(window.innerWidth - x, Preferences.minScriptsSidebarWidth, window.innerWidth * 0.66); + + this.sidebarElement.style.width = newWidth + "px"; + this.sidebarButtonsElement.style.width = newWidth + "px"; + this.scriptResourceViews.style.right = newWidth + "px"; + this.sidebarResizeWidgetElement.style.right = newWidth + "px"; + this.sidebarResizeElement.style.right = (newWidth - 3) + "px"; + + event.preventDefault(); + }, + + _updateDebuggerButtons: function() + { + if (InspectorController.debuggerAttached()) { + this.debuggingButton.title = WebInspector.UIString("Stop debugging."); + this.debuggingButton.addStyleClass("toggled-on"); + this.pauseButton.disabled = false; + } else { + this.debuggingButton.title = WebInspector.UIString("Start debugging and reload inspected page."); + this.debuggingButton.removeStyleClass("toggled-on"); + this.pauseButton.disabled = true; + } + }, + + _toggleDebugging: function() + { + if (InspectorController.debuggerAttached()) + InspectorController.stopDebugging(); + else + InspectorController.startDebuggingAndReloadInspectedPage(); + this._updateDebuggerButtons(); + }, +} + +WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/SidebarPane.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/SidebarPane.js new file mode 100644 index 0000000..53f9d6d --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/SidebarPane.js @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.SidebarPane = function(title) +{ + this.element = document.createElement("div"); + this.element.className = "pane"; + + this.titleElement = document.createElement("div"); + this.titleElement.className = "title"; + this.titleElement.addEventListener("click", this.toggleExpanded.bind(this), false); + + this.bodyElement = document.createElement("div"); + this.bodyElement.className = "body"; + + this.element.appendChild(this.titleElement); + this.element.appendChild(this.bodyElement); + + this.title = title; + this.growbarVisible = false; + this.expanded = false; +} + +WebInspector.SidebarPane.prototype = { + get title() + { + return this._title; + }, + + set title(x) + { + if (this._title === x) + return; + this._title = x; + this.titleElement.textContent = x; + }, + + get growbarVisible() + { + return this._growbarVisible; + }, + + set growbarVisible(x) + { + if (this._growbarVisible === x) + return; + + this._growbarVisible = x; + + if (x && !this._growbarElement) { + this._growbarElement = document.createElement("div"); + this._growbarElement.className = "growbar"; + this.element.appendChild(this._growbarElement); + } else if (!x && this._growbarElement) { + if (this._growbarElement.parentNode) + this._growbarElement.parentNode(this._growbarElement); + delete this._growbarElement; + } + }, + + get expanded() + { + return this._expanded; + }, + + set expanded(x) + { + if (x) + this.expand(); + else + this.collapse(); + }, + + expand: function() + { + if (this._expanded) + return; + this._expanded = true; + this.element.addStyleClass("expanded"); + if (this.onexpand) + this.onexpand(this); + }, + + collapse: function() + { + if (!this._expanded) + return; + this._expanded = false; + this.element.removeStyleClass("expanded"); + if (this.oncollapse) + this.oncollapse(this); + }, + + toggleExpanded: function() + { + this.expanded = !this.expanded; + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/SidebarTreeElement.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/SidebarTreeElement.js new file mode 100644 index 0000000..3d3ba4c --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/SidebarTreeElement.js @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.SidebarSectionTreeElement = function(title, representedObject, hasChildren) +{ + TreeElement.call(this, title.escapeHTML(), representedObject || {}, hasChildren); +} + +WebInspector.SidebarSectionTreeElement.prototype = { + selectable: false, + + onattach: function() + { + this._listItemNode.addStyleClass("sidebar-tree-section"); + }, + + onreveal: function() + { + if (this.listItemElement) + this.listItemElement.scrollIntoViewIfNeeded(false); + } +} + +WebInspector.SidebarSectionTreeElement.prototype.__proto__ = TreeElement.prototype; + +WebInspector.SidebarTreeElement = function(className, title, subtitle, representedObject, hasChildren) +{ + TreeElement.call(this, "", representedObject || {}, hasChildren); + + if (hasChildren) { + this.disclosureButton = document.createElement("button"); + this.disclosureButton.className = "disclosure-button"; + } + + this.statusElement = document.createElement("div"); + this.statusElement.className = "status"; + + this.titlesElement = document.createElement("div"); + this.titlesElement.className = "titles"; + + this.titleElement = document.createElement("span"); + this.titleElement.className = "title"; + this.titlesElement.appendChild(this.titleElement); + + this.subtitleElement = document.createElement("span"); + this.subtitleElement.className = "subtitle"; + this.titlesElement.appendChild(this.subtitleElement); + + this.className = className; + this.mainTitle = title; + this.subtitle = subtitle; +} + +WebInspector.SidebarTreeElement.prototype = { + get mainTitle() + { + return this._mainTitle; + }, + + set mainTitle(x) + { + this._mainTitle = x; + this.refreshTitles(); + }, + + get subtitle() + { + return this._subtitle; + }, + + set subtitle(x) + { + this._subtitle = x; + this.refreshTitles(); + }, + + get bubbleText() + { + return this._bubbleText; + }, + + set bubbleText(x) + { + if (!this.bubbleElement) { + this.bubbleElement = document.createElement("div"); + this.bubbleElement.className = "bubble"; + this.statusElement.appendChild(this.bubbleElement); + } + + this._bubbleText = x; + this.bubbleElement.textContent = x; + }, + + refreshTitles: function() + { + var mainTitle = this.mainTitle; + if (this.titleElement.textContent !== mainTitle) + this.titleElement.textContent = mainTitle; + + var subtitle = this.subtitle; + if (subtitle) { + if (this.subtitleElement.textContent !== subtitle) + this.subtitleElement.textContent = subtitle; + this.titlesElement.removeStyleClass("no-subtitle"); + } else + this.titlesElement.addStyleClass("no-subtitle"); + }, + + isEventWithinDisclosureTriangle: function(event) + { + return event.target === this.disclosureButton; + }, + + onattach: function() + { + this._listItemNode.addStyleClass("sidebar-tree-item"); + + if (this.className) + this._listItemNode.addStyleClass(this.className); + + if (this.hasChildren && this.disclosureButton) + this._listItemNode.appendChild(this.disclosureButton); + + var iconElement = document.createElement("img"); + iconElement.className = "icon"; + + this._listItemNode.appendChild(iconElement); + this._listItemNode.appendChild(this.statusElement); + this._listItemNode.appendChild(this.titlesElement); + }, + + onreveal: function() + { + if (this._listItemNode) + this._listItemNode.scrollIntoViewIfNeeded(false); + } +} + +WebInspector.SidebarTreeElement.prototype.__proto__ = TreeElement.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/SourceView.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/SourceView.js new file mode 100644 index 0000000..8d888e4 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/SourceView.js @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.SourceView = function(resource) +{ + WebInspector.ResourceView.call(this, resource); + + this.element.addStyleClass("source"); + + this.messages = []; + this._frameNeedsSetup = true; + + this.frameElement = document.createElement("iframe"); + this.frameElement.className = "source-view-frame"; + this.frameElement.setAttribute("viewsource", "true"); + this.contentElement.appendChild(this.frameElement); +} + +WebInspector.SourceView.prototype = { + show: function() + { + WebInspector.ResourceView.prototype.show.call(this); + this.setupSourceFrameIfNeeded(); + }, + + setupSourceFrameIfNeeded: function() + { + if (this.resource.finished && !this.resource.failed && this._frameNeedsSetup) { + delete this._frameNeedsSetup; + + this.attach(); + + InspectorController.addSourceToFrame(this.resource.identifier, this.frameElement); + WebInspector.addMainEventListeners(this.frameElement.contentDocument); + + var length = this.messages.length; + for (var i = 0; i < length; ++i) + this._addMessageToSource(this.messages[i]); + } + }, + + sourceRow: function(lineNumber) + { + if (!lineNumber) + return; + + this.setupSourceFrameIfNeeded(); + + var doc = this.frameElement.contentDocument; + var rows = doc.getElementsByTagName("table")[0].rows; + + // Line numbers are a 1-based index, but the rows collection is 0-based. + --lineNumber; + if (lineNumber >= rows.length) + lineNumber = rows.length - 1; + + return rows[lineNumber]; + }, + + showLine: function(lineNumber) + { + var row = this.sourceRow(lineNumber); + if (!row) + return; + row.scrollIntoViewIfNeeded(true); + }, + + addMessage: function(msg) + { + this.messages.push(msg); + if (!this._frameNeedsSetup) + this._addMessageToSource(msg); + }, + + clearMessages: function() + { + this.messages = []; + + if (this._frameNeedsSetup) + return; + + var bubbles = this.frameElement.contentDocument.querySelectorAll(".webkit-html-message-bubble"); + if (!bubbles) + return; + + for (var i = 0; i < bubbles.length; ++i) { + var bubble = bubbles[i]; + bubble.parentNode.removeChild(bubble); + } + }, + + _addMessageToSource: function(msg) + { + var row = this.sourceRow(msg.line); + if (!row) + return; + + var doc = this.frameElement.contentDocument; + var cell = row.getElementsByTagName("td")[1]; + + var errorDiv = cell.lastChild; + if (!errorDiv || errorDiv.nodeName.toLowerCase() !== "div" || !errorDiv.hasStyleClass("webkit-html-message-bubble")) { + errorDiv = doc.createElement("div"); + errorDiv.className = "webkit-html-message-bubble"; + cell.appendChild(errorDiv); + } + + var imageURL; + switch (msg.level) { + case WebInspector.ConsoleMessage.MessageLevel.Error: + errorDiv.addStyleClass("webkit-html-error-message"); + imageURL = "Images/errorIcon.png"; + break; + case WebInspector.ConsoleMessage.MessageLevel.Warning: + errorDiv.addStyleClass("webkit-html-warning-message"); + imageURL = "Images/warningIcon.png"; + break; + } + + var lineDiv = doc.createElement("div"); + lineDiv.className = "webkit-html-message-line"; + errorDiv.appendChild(lineDiv); + + // Create the image element in the Inspector's document so we can use relative image URLs. + var image = document.createElement("img"); + image.src = imageURL; + image.className = "webkit-html-message-icon"; + + // Adopt the image element since it wasn't created in doc. + image = doc.adoptNode(image); + lineDiv.appendChild(image); + + lineDiv.appendChild(doc.createTextNode(msg.message)); + } +} + +WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/StylesSidebarPane.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/StylesSidebarPane.js new file mode 100644 index 0000000..d68d604 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/StylesSidebarPane.js @@ -0,0 +1,652 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.StylesSidebarPane = function() +{ + WebInspector.SidebarPane.call(this, WebInspector.UIString("Styles")); +} + +WebInspector.StylesSidebarPane.prototype = { + update: function(node, editedSection, forceUpdate) + { + var refresh = false; + + if (forceUpdate) + delete this.node; + + if (!forceUpdate && (!node || node === this.node)) + refresh = true; + + if (node && node.nodeType === Node.TEXT_NODE && node.parentNode) + node = node.parentNode; + + if (node && node.nodeType !== Node.ELEMENT_NODE) + node = null; + + if (node) + this.node = node; + else + node = this.node; + + var body = this.bodyElement; + if (!refresh || !node) { + body.removeChildren(); + this.sections = []; + } + + if (!node) + return; + + var styleRules = []; + + if (refresh) { + for (var i = 0; i < this.sections.length; ++i) { + var section = this.sections[i]; + if (section.computedStyle) + section.styleRule.style = node.ownerDocument.defaultView.getComputedStyle(node); + var styleRule = { section: section, style: section.styleRule.style, computedStyle: section.computedStyle }; + styleRules.push(styleRule); + } + } else { + var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node); + styleRules.push({ computedStyle: true, selectorText: WebInspector.UIString("Computed Style"), style: computedStyle, editable: false }); + + var nodeName = node.nodeName.toLowerCase(); + for (var i = 0; i < node.attributes.length; ++i) { + var attr = node.attributes[i]; + if (attr.style) { + var attrStyle = { style: attr.style, editable: false }; + attrStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", attr.name); + attrStyle.selectorText = nodeName + "[" + attr.name; + if (attr.value.length) + attrStyle.selectorText += "=" + attr.value; + attrStyle.selectorText += "]"; + styleRules.push(attrStyle); + } + } + + if (node.style && node.style.length) { + var inlineStyle = { selectorText: WebInspector.UIString("Inline Style Attribute"), style: node.style }; + inlineStyle.subtitle = WebInspector.UIString("element’s “%s” attribute", "style"); + styleRules.push(inlineStyle); + } + + var matchedStyleRules = node.ownerDocument.defaultView.getMatchedCSSRules(node, "", !Preferences.showUserAgentStyles); + if (matchedStyleRules) { + // Add rules in reverse order to match the cascade order. + for (var i = (matchedStyleRules.length - 1); i >= 0; --i) { + var rule = matchedStyleRules[i]; + styleRules.push({ style: rule.style, selectorText: rule.selectorText, parentStyleSheet: rule.parentStyleSheet }); + } + } + } + + var usedProperties = {}; + var priorityUsed = false; + + // Walk the style rules and make a list of all used and overloaded properties. + for (var i = 0; i < styleRules.length; ++i) { + var styleRule = styleRules[i]; + if (styleRule.computedStyle) + continue; + + styleRule.usedProperties = {}; + + var style = styleRule.style; + for (var j = 0; j < style.length; ++j) { + var name = style[j]; + + if (!priorityUsed && style.getPropertyPriority(name).length) + priorityUsed = true; + + // If the property name is already used by another rule then this rule's + // property is overloaded, so don't add it to the rule's usedProperties. + if (!(name in usedProperties)) + styleRule.usedProperties[name] = true; + + if (name === "font") { + // The font property is not reported as a shorthand. Report finding the individual + // properties so they are visible in computed style. + // FIXME: remove this when http://bugs.webkit.org/show_bug.cgi?id=15598 is fixed. + styleRule.usedProperties["font-family"] = true; + styleRule.usedProperties["font-size"] = true; + styleRule.usedProperties["font-style"] = true; + styleRule.usedProperties["font-variant"] = true; + styleRule.usedProperties["font-weight"] = true; + styleRule.usedProperties["line-height"] = true; + } + } + + // Add all the properties found in this style to the used properties list. + // Do this here so only future rules are affect by properties used in this rule. + for (var name in styleRules[i].usedProperties) + usedProperties[name] = true; + } + + if (priorityUsed) { + // Walk the properties again and account for !important. + var foundPriorityProperties = []; + + // Walk in reverse to match the order !important overrides. + for (var i = (styleRules.length - 1); i >= 0; --i) { + if (styleRules[i].computedStyle) + continue; + + var style = styleRules[i].style; + var uniqueProperties = getUniqueStyleProperties(style); + for (var j = 0; j < uniqueProperties.length; ++j) { + var name = uniqueProperties[j]; + if (style.getPropertyPriority(name).length) { + if (!(name in foundPriorityProperties)) + styleRules[i].usedProperties[name] = true; + else + delete styleRules[i].usedProperties[name]; + foundPriorityProperties[name] = true; + } else if (name in foundPriorityProperties) + delete styleRules[i].usedProperties[name]; + } + } + } + + if (refresh) { + // Walk the style rules and update the sections with new overloaded and used properties. + for (var i = 0; i < styleRules.length; ++i) { + var styleRule = styleRules[i]; + var section = styleRule.section; + section._usedProperties = (styleRule.usedProperties || usedProperties); + section.update((section === editedSection) || styleRule.computedStyle); + } + } else { + // Make a property section for each style rule. + for (var i = 0; i < styleRules.length; ++i) { + var styleRule = styleRules[i]; + var subtitle = styleRule.subtitle; + delete styleRule.subtitle; + + var computedStyle = styleRule.computedStyle; + delete styleRule.computedStyle; + + var ruleUsedProperties = styleRule.usedProperties; + delete styleRule.usedProperties; + + var editable = styleRule.editable; + delete styleRule.editable; + + // Default editable to true if it was omitted. + if (typeof editable === "undefined") + editable = true; + + var section = new WebInspector.StylePropertiesSection(styleRule, subtitle, computedStyle, (ruleUsedProperties || usedProperties), editable); + section.expanded = true; + section.pane = this; + + body.appendChild(section.element); + this.sections.push(section); + } + } + } +} + +WebInspector.StylesSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + +WebInspector.StylePropertiesSection = function(styleRule, subtitle, computedStyle, usedProperties, editable) +{ + WebInspector.PropertiesSection.call(this, styleRule.selectorText); + + this.styleRule = styleRule; + this.computedStyle = computedStyle; + this.editable = (editable && !computedStyle); + + // Prevent editing the user agent rules. + if (this.styleRule.parentStyleSheet && !this.styleRule.parentStyleSheet.ownerNode && !this.styleRule.parentStyleSheet.href) + this.editable = false; + + this._usedProperties = usedProperties; + + if (computedStyle) { + if (Preferences.showInheritedComputedStyleProperties) + this.element.addStyleClass("show-inherited"); + + var showInheritedLabel = document.createElement("label"); + var showInheritedInput = document.createElement("input"); + showInheritedInput.type = "checkbox"; + showInheritedInput.checked = Preferences.showInheritedComputedStyleProperties; + + var computedStyleSection = this; + var showInheritedToggleFunction = function(event) { + Preferences.showInheritedComputedStyleProperties = showInheritedInput.checked; + if (Preferences.showInheritedComputedStyleProperties) + computedStyleSection.element.addStyleClass("show-inherited"); + else + computedStyleSection.element.removeStyleClass("show-inherited"); + event.stopPropagation(); + }; + + showInheritedLabel.addEventListener("click", showInheritedToggleFunction, false); + + showInheritedLabel.appendChild(showInheritedInput); + showInheritedLabel.appendChild(document.createTextNode(WebInspector.UIString("Show inherited"))); + this.subtitleElement.appendChild(showInheritedLabel); + } else { + if (!subtitle) { + if (this.styleRule.parentStyleSheet && this.styleRule.parentStyleSheet.href) { + var url = this.styleRule.parentStyleSheet.href; + subtitle = WebInspector.linkifyURL(url, url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "").escapeHTML()); + this.subtitleElement.addStyleClass("file"); + } else if (this.styleRule.parentStyleSheet && !this.styleRule.parentStyleSheet.ownerNode) + subtitle = WebInspector.UIString("user agent stylesheet"); + else + subtitle = WebInspector.UIString("inline stylesheet"); + } + + this.subtitle = subtitle; + } +} + +WebInspector.StylePropertiesSection.prototype = { + get usedProperties() + { + return this._usedProperties || {}; + }, + + set usedProperties(x) + { + this._usedProperties = x; + this.update(); + }, + + isPropertyInherited: function(property) + { + if (!this.computedStyle || !this._usedProperties) + return false; + // These properties should always show for Computed Style. + var alwaysShowComputedProperties = { "display": true, "height": true, "width": true }; + return !(property in this.usedProperties) && !(property in alwaysShowComputedProperties); + }, + + isPropertyOverloaded: function(property, shorthand) + { + if (this.computedStyle || !this._usedProperties) + return false; + + var used = (property in this.usedProperties); + if (used || !shorthand) + return !used; + + // Find out if any of the individual longhand properties of the shorthand + // are used, if none are then the shorthand is overloaded too. + var longhandProperties = getLonghandProperties(this.styleRule.style, property); + for (var j = 0; j < longhandProperties.length; ++j) { + var individualProperty = longhandProperties[j]; + if (individualProperty in this.usedProperties) + return false; + } + + return true; + }, + + update: function(full) + { + if (full || this.computedStyle) { + this.propertiesTreeOutline.removeChildren(); + this.populated = false; + } else { + var child = this.propertiesTreeOutline.children[0]; + while (child) { + child.overloaded = this.isPropertyOverloaded(child.name, child.shorthand); + child = child.traverseNextTreeElement(false, null, true); + } + } + }, + + onpopulate: function() + { + var style = this.styleRule.style; + if (!style.length) + return; + + var foundShorthands = {}; + var uniqueProperties = getUniqueStyleProperties(style); + uniqueProperties.sort(); + + for (var i = 0; i < uniqueProperties.length; ++i) { + var name = uniqueProperties[i]; + var shorthand = style.getPropertyShorthand(name); + + if (shorthand && shorthand in foundShorthands) + continue; + + if (shorthand) { + foundShorthands[shorthand] = true; + name = shorthand; + } + + var isShorthand = (shorthand ? true : false); + var inherited = this.isPropertyInherited(name); + var overloaded = this.isPropertyOverloaded(name, isShorthand); + + var item = new WebInspector.StylePropertyTreeElement(style, name, isShorthand, inherited, overloaded); + this.propertiesTreeOutline.appendChild(item); + } + } +} + +WebInspector.StylePropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype; + +WebInspector.StylePropertyTreeElement = function(style, name, shorthand, inherited, overloaded) +{ + this.style = style; + this.name = name; + this.shorthand = shorthand; + this._inherited = inherited; + this._overloaded = overloaded; + + // Pass an empty title, the title gets made later in onattach. + TreeElement.call(this, "", null, shorthand); +} + +WebInspector.StylePropertyTreeElement.prototype = { + get inherited() + { + return this._inherited; + }, + + set inherited(x) + { + if (x === this._inherited) + return; + this._inherited = x; + this.updateState(); + }, + + get overloaded() + { + return this._overloaded; + }, + + set overloaded(x) + { + if (x === this._overloaded) + return; + this._overloaded = x; + this.updateState(); + }, + + onattach: function() + { + this.updateTitle(); + }, + + updateTitle: function() + { + // "Nicknames" for some common values that are easier to read. + var valueNicknames = { + "rgb(0, 0, 0)": "black", + "#000": "black", + "#000000": "black", + "rgb(255, 255, 255)": "white", + "#fff": "white", + "#ffffff": "white", + "#FFF": "white", + "#FFFFFF": "white", + "rgba(0, 0, 0, 0)": "transparent", + "rgb(255, 0, 0)": "red", + "rgb(0, 255, 0)": "lime", + "rgb(0, 0, 255)": "blue", + "rgb(255, 255, 0)": "yellow", + "rgb(255, 0, 255)": "magenta", + "rgb(0, 255, 255)": "cyan" + }; + + var priority = (this.shorthand ? getShorthandPriority(this.style, this.name) : this.style.getPropertyPriority(this.name)); + var value = (this.shorthand ? getShorthandValue(this.style, this.name) : this.style.getPropertyValue(this.name)); + var htmlValue = value; + + if (priority && !priority.length) + delete priority; + if (priority) + priority = "!" + priority; + + if (value) { + var urls = value.match(/url\([^)]+\)/); + if (urls) { + for (var i = 0; i < urls.length; ++i) { + var url = urls[i].substring(4, urls[i].length - 1); + htmlValue = htmlValue.replace(urls[i], "url(" + WebInspector.linkifyURL(url) + ")"); + } + } else { + if (value in valueNicknames) + htmlValue = valueNicknames[value]; + htmlValue = htmlValue.escapeHTML(); + } + } else + htmlValue = value = ""; + + this.updateState(); + + var nameElement = document.createElement("span"); + nameElement.className = "name"; + nameElement.textContent = this.name; + + var valueElement = document.createElement("span"); + valueElement.className = "value"; + valueElement.innerHTML = htmlValue; + + if (priority) { + var priorityElement = document.createElement("span"); + priorityElement.className = "priority"; + priorityElement.textContent = priority; + } + + this.listItemElement.removeChildren(); + + this.listItemElement.appendChild(nameElement); + this.listItemElement.appendChild(document.createTextNode(": ")); + this.listItemElement.appendChild(valueElement); + + if (priorityElement) { + this.listItemElement.appendChild(document.createTextNode(" ")); + this.listItemElement.appendChild(priorityElement); + } + + this.listItemElement.appendChild(document.createTextNode(";")); + + if (value) { + // FIXME: this dosen't catch keyword based colors like black and white + var colors = value.match(/((rgb|hsl)a?\([^)]+\))|(#[0-9a-fA-F]{6})|(#[0-9a-fA-F]{3})/g); + if (colors) { + var colorsLength = colors.length; + for (var i = 0; i < colorsLength; ++i) { + var swatchElement = document.createElement("span"); + swatchElement.className = "swatch"; + swatchElement.style.setProperty("background-color", colors[i]); + this.listItemElement.appendChild(swatchElement); + } + } + } + + this.tooltip = this.name + ": " + (valueNicknames[value] || value) + (priority ? " " + priority : ""); + }, + + updateState: function() + { + if (!this.listItemElement) + return; + + var value = (this.shorthand ? getShorthandValue(this.style, this.name) : this.style.getPropertyValue(this.name)); + if (this.style.isPropertyImplicit(this.name) || value === "initial") + this.listItemElement.addStyleClass("implicit"); + else + this.listItemElement.removeStyleClass("implicit"); + + if (this.inherited) + this.listItemElement.addStyleClass("inherited"); + else + this.listItemElement.removeStyleClass("inherited"); + + if (this.overloaded) + this.listItemElement.addStyleClass("overloaded"); + else + this.listItemElement.removeStyleClass("overloaded"); + }, + + onpopulate: function() + { + // Only populate once and if this property is a shorthand. + if (this.children.length || !this.shorthand) + return; + + var longhandProperties = getLonghandProperties(this.style, this.name); + for (var i = 0; i < longhandProperties.length; ++i) { + var name = longhandProperties[i]; + + if (this.treeOutline.section) { + var inherited = this.treeOutline.section.isPropertyInherited(name); + var overloaded = this.treeOutline.section.isPropertyOverloaded(name); + } + + var item = new WebInspector.StylePropertyTreeElement(this.style, name, false, inherited, overloaded); + this.appendChild(item); + } + }, + + ondblclick: function(element, event) + { + this.startEditing(event.target); + }, + + startEditing: function(selectElement) + { + // FIXME: we don't allow editing of longhand properties under a shorthand right now. + if (this.parent.shorthand) + return; + + if (WebInspector.isBeingEdited(this.listItemElement) || (this.treeOutline.section && !this.treeOutline.section.editable)) + return; + + var wasExpanded = this.expanded; + this.collapse(); + // Lie about out children to prevent toggling on click. + this.hasChildren = false; + + if (!selectElement) + selectElement = this.listItemElement; + + window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1); + + WebInspector.startEditing(this.listItemElement, this.editingCommitted.bind(this), this.editingCancelled.bind(this), wasExpanded); + }, + + editingEnded: function(wasExpanded) + { + this.hasChildren = (this.children.length ? true : false); + if (wasExpanded) + this.expand(); + }, + + editingCancelled: function(e, wasExpanded) + { + this.editingEnded(wasExpanded); + this.updateTitle(); + }, + + editingCommitted: function(e, userInput, previousContent, wasExpanded) + { + this.editingEnded(); + + if (userInput === previousContent) + return; // nothing changed, so do nothing else + + var userInputLength = userInput.trimWhitespace().length; + + // Create a new element to parse the user input CSS. + var parseElement = document.createElement("span"); + parseElement.setAttribute("style", userInput); + + var userInputStyle = parseElement.style; + if (userInputStyle.length || !userInputLength) { + // The input was parsable or the user deleted everything, so remove the + // original property from the real style declaration. If this represents + // a shorthand remove all the longhand properties. + if (this.shorthand) { + var longhandProperties = getLonghandProperties(this.style, this.name); + for (var i = 0; i < longhandProperties.length; ++i) + this.style.removeProperty(longhandProperties[i]); + } else + this.style.removeProperty(this.name); + } + + if (!userInputLength) { + // The user deleted the everything, so remove the tree element and update. + if (this.treeOutline.section && this.treeOutline.section.pane) + this.treeOutline.section.pane.update(); + this.parent.removeChild(this); + return; + } + + if (!userInputStyle.length) { + // The user typed something, but it didn't parse. Just abort and restore + // the original title for this property. + this.updateTitle(); + return; + } + + // Iterate of the properties on the test element's style declaration and + // add them to the real style declaration. We take care to move shorthands. + var foundShorthands = {}; + var uniqueProperties = getUniqueStyleProperties(userInputStyle); + for (var i = 0; i < uniqueProperties.length; ++i) { + var name = uniqueProperties[i]; + var shorthand = userInputStyle.getPropertyShorthand(name); + + if (shorthand && shorthand in foundShorthands) + continue; + + if (shorthand) { + var value = getShorthandValue(userInputStyle, shorthand); + var priority = getShorthandPriority(userInputStyle, shorthand); + foundShorthands[shorthand] = true; + } else { + var value = userInputStyle.getPropertyValue(name); + var priority = userInputStyle.getPropertyPriority(name); + } + + // Set the property on the real style declaration. + this.style.setProperty((shorthand || name), value, priority); + } + + if (this.treeOutline.section && this.treeOutline.section.pane) + this.treeOutline.section.pane.update(null, this.treeOutline.section); + else if (this.treeOutline.section) + this.treeOutline.section.update(true); + else + this.updateTitle(); // FIXME: this will not show new properties. But we don't hit his case yet. + } +} + +WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototype; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/TextPrompt.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/TextPrompt.js new file mode 100644 index 0000000..264cb4c --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/TextPrompt.js @@ -0,0 +1,354 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.TextPrompt = function(element, completions, stopCharacters) +{ + this.element = element; + this.completions = completions; + this.completionStopCharacters = stopCharacters; + this.history = []; + this.historyOffset = 0; +} + +WebInspector.TextPrompt.prototype = { + get text() + { + return this.element.textContent; + }, + + set text(x) + { + if (!x) { + // Append a break element instead of setting textContent to make sure the selection is inside the prompt. + this.element.removeChildren(); + this.element.appendChild(document.createElement("br")); + } else + this.element.textContent = x; + + this.moveCaretToEndOfPrompt(); + }, + + handleKeyEvent: function(event) + { + switch (event.keyIdentifier) { + case "Up": + this._upKeyPressed(event); + break; + case "Down": + this._downKeyPressed(event); + break; + case "U+0009": // Tab + this._tabKeyPressed(event); + break; + case "Right": + if (!this.acceptAutoComplete()) + this.autoCompleteSoon(); + break; + default: + this.clearAutoComplete(); + this.autoCompleteSoon(); + break; + } + }, + + acceptAutoComplete: function() + { + if (!this.autoCompleteElement || !this.autoCompleteElement.parentNode) + return false; + + var text = this.autoCompleteElement.textContent; + var textNode = document.createTextNode(text); + this.autoCompleteElement.parentNode.replaceChild(textNode, this.autoCompleteElement); + delete this.autoCompleteElement; + + var finalSelectionRange = document.createRange(); + finalSelectionRange.setStart(textNode, text.length); + finalSelectionRange.setEnd(textNode, text.length); + + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(finalSelectionRange); + + return true; + }, + + clearAutoComplete: function(includeTimeout) + { + if (includeTimeout && "_completeTimeout" in this) { + clearTimeout(this._completeTimeout); + delete this._completeTimeout; + } + + if (!this.autoCompleteElement) + return; + + if (this.autoCompleteElement.parentNode) + this.autoCompleteElement.parentNode.removeChild(this.autoCompleteElement); + delete this.autoCompleteElement; + + if (!this._userEnteredRange || !this._userEnteredText) + return; + + this._userEnteredRange.deleteContents(); + + var userTextNode = document.createTextNode(this._userEnteredText); + this._userEnteredRange.insertNode(userTextNode); + + var selectionRange = document.createRange(); + selectionRange.setStart(userTextNode, this._userEnteredText.length); + selectionRange.setEnd(userTextNode, this._userEnteredText.length); + + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(selectionRange); + + delete this._userEnteredRange; + delete this._userEnteredText; + }, + + autoCompleteSoon: function() + { + if (!("_completeTimeout" in this)) + this._completeTimeout = setTimeout(this.complete.bind(this, true), 250); + }, + + complete: function(auto) + { + this.clearAutoComplete(true); + + var selection = window.getSelection(); + if (!selection.rangeCount) + return; + + var selectionRange = selection.getRangeAt(0); + if (!selectionRange.commonAncestorContainer.isDescendant(this.element)) + return; + if (auto && !this.isCaretAtEndOfPrompt()) + return; + + var wordPrefixRange = this.scanBackwards(this.completionStopCharacters, selectionRange.startContainer, selectionRange.startOffset, this.element); + + var completions = this.completions(wordPrefixRange, auto); + + if (!completions || !completions.length) + return; + + var fullWordRange = document.createRange(); + fullWordRange.setStart(wordPrefixRange.startContainer, wordPrefixRange.startOffset); + fullWordRange.setEnd(selectionRange.endContainer, selectionRange.endOffset); + + if (completions.length === 1 || selection.isCollapsed || auto) { + var completionText = completions[0]; + } else { + var currentText = fullWordRange.toString(); + + var foundIndex = null; + for (var i = 0; i < completions.length; ++i) { + if (completions[i] === currentText) + foundIndex = i; + } + + if (foundIndex === null || (foundIndex + 1) >= completions.length) + var completionText = completions[0]; + else + var completionText = completions[foundIndex + 1]; + } + + var wordPrefixLength = wordPrefixRange.toString().length; + + this._userEnteredRange = fullWordRange; + this._userEnteredText = fullWordRange.toString(); + + fullWordRange.deleteContents(); + + var finalSelectionRange = document.createRange(); + + if (auto) { + var prefixText = completionText.substring(0, wordPrefixLength); + var suffixText = completionText.substring(wordPrefixLength); + + var prefixTextNode = document.createTextNode(prefixText); + fullWordRange.insertNode(prefixTextNode); + + this.autoCompleteElement = document.createElement("span"); + this.autoCompleteElement.className = "auto-complete-text"; + this.autoCompleteElement.textContent = suffixText; + + prefixTextNode.parentNode.insertBefore(this.autoCompleteElement, prefixTextNode.nextSibling); + + finalSelectionRange.setStart(prefixTextNode, wordPrefixLength); + finalSelectionRange.setEnd(prefixTextNode, wordPrefixLength); + } else { + var completionTextNode = document.createTextNode(completionText); + fullWordRange.insertNode(completionTextNode); + + if (completions.length > 1) + finalSelectionRange.setStart(completionTextNode, wordPrefixLength); + else + finalSelectionRange.setStart(completionTextNode, completionText.length); + + finalSelectionRange.setEnd(completionTextNode, completionText.length); + } + + selection.removeAllRanges(); + selection.addRange(finalSelectionRange); + }, + + scanBackwards: function(stopCharacters, endNode, endOffset, stayWithinElement) + { + var startNode; + var startOffset = 0; + var node = endNode; + + if (!stayWithinElement) + stayWithinElement = this.element; + + while (node) { + if (node === stayWithinElement) { + if (!startNode) + startNode = stayWithinElement; + break; + } + + if (node.nodeType === Node.TEXT_NODE) { + var start = (node === endNode ? endOffset : node.nodeValue.length); + for (var i = (start - 1); i >= 0; --i) { + var character = node.nodeValue[i]; + if (stopCharacters.indexOf(character) !== -1) { + startNode = node; + startOffset = i + 1; + break; + } + } + } + + if (startNode) + break; + + node = node.traversePreviousNode(); + } + + var result = document.createRange(); + result.setStart(startNode, startOffset); + result.setEnd(endNode, endOffset); + + return result; + }, + + isCaretInsidePrompt: function() + { + return this.element.isInsertionCaretInside(); + }, + + isCaretAtEndOfPrompt: function() + { + var selection = window.getSelection(); + if (!selection.rangeCount || !selection.isCollapsed) + return false; + + var selectionRange = selection.getRangeAt(0); + var node = selectionRange.startContainer; + if (node !== this.element && !node.isDescendant(this.element)) + return false; + + if (node.nodeType === Node.TEXT_NODE && selectionRange.startOffset < node.nodeValue.length) + return false; + + var foundNextText = false; + while (node) { + if (node.nodeType === Node.TEXT_NODE && node.nodeValue.length) { + if (foundNextText) + return false; + foundNextText = true; + } + + node = node.traverseNextNode(false, this.element); + } + + return true; + }, + + moveCaretToEndOfPrompt: function() + { + var selection = window.getSelection(); + var selectionRange = document.createRange(); + + var offset = this.element.childNodes.length; + selectionRange.setStart(this.element, offset); + selectionRange.setEnd(this.element, offset); + + selection.removeAllRanges(); + selection.addRange(selectionRange); + }, + + _tabKeyPressed: function(event) + { + event.preventDefault(); + event.stopPropagation(); + + this.complete(); + }, + + _upKeyPressed: function(event) + { + event.preventDefault(); + event.stopPropagation(); + + if (this.historyOffset == this.history.length) + return; + + this.clearAutoComplete(true); + + if (this.historyOffset == 0) + this.tempSavedCommand = this.text; + + ++this.historyOffset; + this.text = this.history[this.history.length - this.historyOffset]; + }, + + _downKeyPressed: function(event) + { + event.preventDefault(); + event.stopPropagation(); + + if (this.historyOffset == 0) + return; + + this.clearAutoComplete(true); + + --this.historyOffset; + + if (this.historyOffset == 0) { + this.text = this.tempSavedCommand; + delete this.tempSavedCommand; + return; + } + + this.text = this.history[this.history.length - this.historyOffset]; + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/View.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/View.js new file mode 100644 index 0000000..9e22482 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/View.js @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +WebInspector.View = function(element) +{ + this.element = element || document.createElement("div"); + this._visible = false; +} + +WebInspector.View.prototype = { + get visible() + { + return this._visible; + }, + + set visible(x) + { + if (this._visible === x) + return; + + if (x) + this.show(); + else + this.hide(); + }, + + show: function(parentElement) + { + this._visible = true; + if (!this.element.parentNode && parentElement) + parentElement.appendChild(this.element); + if (!this.element.parentNode && this.attach) + this.attach(); + this.element.addStyleClass("visible"); + }, + + hide: function() + { + this.element.removeStyleClass("visible"); + this._visible = false; + }, + + detach: function() + { + if (this.element.parentNode) + this.element.parentNode.removeChild(this.element); + } +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/html4-overrides.css b/chrome/tools/test/reference_build/chrome/resources/Inspector/html4-overrides.css new file mode 100644 index 0000000..ef4f658 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/html4-overrides.css @@ -0,0 +1,68 @@ +/* Copyright 2008 Google Inc. All Rights Reserved. */ +/* Author: ojan@google.com (Ojan Vafai) */ + +/* These styles override the default styling for HTML elements as defined in + WebCore/css/html4.css. So far we have used this file exclusively for + making our form elements match Firefoxes. If we find other needs for this + file we should seriously consider if this is the right place of them. */ + +input:not([type]), +input[type="text"], +input[type="password"], +input[type="search"] { + margin:0; + padding:1px 0; +} + +input[type="checkbox"] { + margin:3px 3px 3px 4px; +} + +input[type="radio"] { + margin:3px 3px 0 5px; +} + +/* Not sure this is the right color. #EBEBE4 is what Firefox uses. + TODO(ojan): Figure out how to support legacy input rendering. + TODO(ojan): Add input[type="file"] once we figure out our file inputs. + TODO(ojan): Add input[type="image"] once we figure out our image inputs. + TODO(ojan): We probably do the wrong thing if you put an invalid input type. + do we care? +*/ +textarea:disabled, +input:not([type]):disabled, +input[type="text"]:disabled, +input[type="password"]:disabled, +input[type="search"]:disabled { + background-color: #EBEBE4; +} + +/* Chrome should render input[type="search"] the same as input with no type. + This search thing is an Apple-ism to get mac style search inputs. */ +input[type="search"] { + -webkit-appearance: textfield; + -webkit-box-sizing: content-box; +} + +input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button { + /* Matches Firefox */ + padding: 0 6px; + margin: 0; +} + +/* Chrome selects are not rounded. Custom borders for them shouldn't be either. */ +keygen, +select, +select[size="0"], +select[size="1"] { + -webkit-border-radius: 0; + margin: 0; +} + +textarea { + font-family: monospace; + margin: 1px 0; + + /* Matches IE */ + padding: 2px; +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.css b/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.css new file mode 100644 index 0000000..946a4b1 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.css @@ -0,0 +1,2103 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +body { + cursor: default; + height: 100%; + width: 100%; + overflow: hidden; + font-family: Lucida Grande, sans-serif; + font-size: 10px; + margin: 0; + -webkit-text-size-adjust: none; + -webkit-user-select: none; +} + +* { + -webkit-box-sizing: border-box; +} + +iframe, a img { + border: none; +} + +img { + -webkit-user-drag: none; +} + +.hidden { + display: none !important; +} + +#toolbar { + position: absolute; + top: 0; + left: 0; + right: 0; + height: 56px; + display: -webkit-box; + padding: 0 5px; + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(191, 191, 191)), to(rgb(151, 151, 151)));*/ + background-color: rgb(191, 191, 191); + border-bottom: 1px solid rgb(80, 80, 80); + -webkit-box-orient: horizontal; + -webkit-background-origin: padding; + -webkit-background-clip: padding; +} + +body.inactive #toolbar { + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(233, 233, 233)), to(rgb(207, 207, 207)));*/ + background-color: rgb(233, 233, 233); +} + +body.detached.platform-mac-leopard #toolbar { + background: transparent !important; +} + +.toolbar-item { + display: -webkit-box; + padding: 4px 6px; + margin: 0; + background-color: transparent; + border-style: none; + border-color: transparent; + outline: none; + -webkit-box-orient: vertical; + -webkit-box-align: center; + -webkit-box-pack: end; +} + +.toolbar-item.toggleable.toggled-on { + border-width: 0 2px 0 2px; + padding: 4px 4px; + -webkit-border-image: url(Images/toolbarItemSelected.png) 0 2 0 2; +} + +.toolbar-item.flexable-space { + -webkit-box-flex: 1; + visibility: hidden; +} + +.toolbar-item input { + margin-bottom: 8px; +} + +.toolbar-icon { + width: 32px; + height: 32px; +} + +.toolbar-label { + font-size: 11px; + font-family: Lucida Grande, sans-serif; + text-shadow: rgba(255, 255, 255, 0.5) 0 1px 0; +} + +.toolbar-item.elements .toolbar-icon { + content: url(Images/elementsIcon.png); +} + +.toolbar-item.resources .toolbar-icon { + content: url(Images/resourcesIcon.png); +} + +.toolbar-item.scripts .toolbar-icon { + content: url(Images/scriptsIcon.png); +} + +.toolbar-item.databases .toolbar-icon { + content: url(Images/databasesIcon.png); +} + +#searchResults { + position: absolute; + top: -100px; + left: 0; + right: 0; + height: 100px; + z-index: -1; + background-color: white; + border-bottom: 1px solid rgb(180, 180, 180); + overflow-y: auto; + overflow-x: hidden; + -webkit-box-sizing: border-box; +} + +.search-results-section { + color: gray; + width: 28px; + float: left; + margin-left: -45px; + text-align: right; + font-size: 10px; + margin-top: 1px; + white-space: nowrap; +} + +.selected .search-results-section { + color: rgba(255, 255, 255, 0.8); +} + +body.inactive .focused .selected .search-results-section { + color: rgba(0, 0, 0, 0.5); +} + +.blurred .selected .search-results-section { + color: rgba(0, 0, 0, 0.5); +} + +#searchResults > ol > ol > li { + padding-left: 45px; + white-space: nowrap; +} + +.search-matched-string { + background-color: #ff8; +} + +.selected .search-matched-string { + background-color: transparent; +} + +#searchResultsResizer { + position: absolute; + height: 5px; + left: 0; + right: 0; + cursor: row-resize; +} + +#main { + position: absolute; + z-index: 1; + top: 56px; + left: 0; + right: 0; + bottom: 0; + overflow: hidden; + background-color: white; +} + +#main-panels { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 23px; + overflow: hidden; +} + +#main-status-bar { + position: absolute; + bottom: 0; + left: 0; + right: 0; +} + +body.console-visible #main-status-bar { + height: 24px; + background-image: url(Images/statusbarResizerVertical.png), url(Images/statusbarBackground.png); + background-repeat: no-repeat, repeat-x; + background-position: right center, center; + cursor: row-resize; +} + +body.console-visible #main-status-bar * { + cursor: default; +} + +body.console-visible #main-panels { + bottom: 24px; +} + +.status-bar { + background-color: rgb(235, 235, 235); + background-image: url(Images/statusbarBackground.png); + background-repeat: repeat-x; + white-space: nowrap; + height: 23px; + overflow: hidden; + z-index: 12; +} + +.status-bar > div { + display: inline-block; + vertical-align: top; +} + +.status-bar-item { + display: inline-block; + height: 24px; + padding: 0; + margin-left: -1px; + margin-right: 0; + vertical-align: top; + border: 0 transparent none; + background-color: transparent; +} + +.status-bar-item:active { + position: relative; + z-index: 200; +} + +button.status-bar-item { + width: 32px; + background-image: url(Images/statusbarButtons.png); + background-position: 0 0; + outline: none; +} + +button.status-bar-item:active { + background-position: 32px 0; +} + +button.status-bar-item:disabled { + background-position: 0 0 !important; +} + +select.status-bar-item { + min-width: 48px; + border-width: 0 17px 0 2px; + outline: none; + padding: 0 2px 0 6px; + font-weight: bold; + color: rgb(48, 48, 48); + text-shadow: rgba(255, 255, 255, 0.75) 0 1px 0; + -webkit-border-image: url(Images/statusbarMenuButton.png) 0 17 0 2; + -webkit-border-radius: 0; + -webkit-appearance: none; +} + +select.status-bar-item:active { + color: black; + -webkit-border-image: url(Images/statusbarMenuButtonSelected.png) 0 17 0 2; +} + +#dock-status-bar-item { + background-image: url(Images/dockButtons.png); +} + +body.attached #dock-status-bar-item:active { + background-position: 32px 0; +} + +body.detached #dock-status-bar-item { + background-position: 0 24px; +} + +body.detached #dock-status-bar-item.toggled-on:active { + background-position: 32px 24px; +} + +#console-status-bar-item { + background-image: url(Images/consoleButtons.png); +} + +#console-status-bar-item:active { + background-position: 32px 0; +} + +#console-status-bar-item.toggled-on { + background-position: 0 24px; +} + +#console-status-bar-item.toggled-on:active { + background-position: 32px 24px; +} + +#clear-console-status-bar-item { + background-image: url(Images/clearConsoleButtons.png); +} + +#clear-console-status-bar-item:active { + background-position: 32px 0; +} + +#error-warning-count { + position: absolute; + right: 16px; + top: 0; + cursor: pointer; + padding: 6px 2px; + font-size: 10px; + height: 19px; +} + +#error-warning-count:hover { + border-bottom: 1px solid rgb(96, 96, 96); +} + +#error-count::before { + content: url(Images/errorIcon.png); + width: 10px; + height: 10px; + vertical-align: -1px; + margin-right: 2px; +} + +#error-count + #warning-count { + margin-left: 6px; +} + +#warning-count::before { + content: url(Images/warningIcon.png); + width: 10px; + height: 10px; + vertical-align: -1px; + margin-right: 2px; +} + +#console { + display: none; + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 200px; + background-color: white; + background-image: url(Images/statusbarBottomBackground.png); + background-repeat: repeat-x; + background-position: bottom; +} + +body.console-visible #console { + display: block; +} + +#console-status-bar { + position: absolute; + bottom: 0; + left: 0; + right: 0; + background: none; +} + +#console-messages { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 23px; + font-size: 10px; + font-family: Monaco, Lucida Console, monospace; + padding: 2px 0; + overflow-y: overlay; + -webkit-user-select: text; + -webkit-text-size-adjust: auto; +} + +#console-prompt { + position: relative; + outline: none; + padding: 1px 22px 1px 24px; + min-height: 16px; + white-space: pre-wrap; + -webkit-user-modify: read-write-plaintext-only; +} + +#console-prompt::before { + background-image: url(Images/userInputIcon.png); +} + +.console-message, .console-user-command { + position: relative; + border-bottom: 1px solid rgb(240, 240, 240); + padding: 1px 22px 1px 24px; + min-height: 16px; +} + +.console-message::before, .console-user-command::before, #console-prompt::before { + position: absolute; + display: block; + content: ""; + left: 7px; + top: 0.8em; + width: 10px; + height: 10px; + margin-top: -5px; + -webkit-user-select: none; +} + +.console-message-text { + white-space: pre-wrap; +} + +.console-error-level .console-message-text { + color: red; +} + +.console-error-level::before { + background-image: url(Images/errorIcon.png); +} + +.console-warning-level::before { + background-image: url(Images/warningIcon.png); +} + +.console-user-command .console-message { + margin-left: -24px; + padding-right: 0; + border-bottom: none; +} + +.console-user-command::before { + background-image: url(Images/userInputPreviousIcon.png); +} + +.console-user-command > .console-message-text { + color: rgb(0, 128, 255); +} + +.console-message-url { + color: rgb(33%, 33%, 33%) !important; + cursor: pointer; +} + +.console-message-url::after { + display: inline-block; + content: url(Images/goArrow.png); + margin-left: 3px; + width: 12px; + height: 12px; + vertical-align: top; + opacity: 0.75; + -webkit-user-select: none; +} + +.console-message-url:hover { + color: rgb(15%, 15%, 15%); +} + +.console-message-url:hover::after { + opacity: 1; +} + +.auto-complete-text { + color: rgb(128, 128, 128); + -webkit-user-select: none; + -webkit-user-modify: read-only; +} + +.panel { + display: none; + overflow: hidden; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.panel.visible { + display: block; +} + +.resource-view { + display: none; + overflow: hidden; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.resource-view.visible { + display: block; +} + +.resource-view .resource-view-content { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; +} + +.resource-view.font { + font-size: 60px; + white-space: pre-wrap; + word-wrap: break-word; + text-align: center; +} + +.resource-view.font .preview { + position: absolute; + margin-top: auto; + margin-bottom: auto; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.resource-view.image .resource-view-content > .image { + position: relative; + height: 70%; + padding: 20px; +} + +.resource-view.image .resource-view-content > .info { + position: relative; + height: 30%; + padding-top: 10px; + overflow: auto; + font-size: 11px; +} + +.resource-view.image img { + margin: auto; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + max-width: 80%; + max-height: 80%; + background-image: url(Images/checker.png); + -webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5); +} + +.resource-view.image .title { + text-align: center; + font-size: 13px; +} + +.resource-view.image .infoList { + margin: 0; +} + +.resource-view.image .infoList dt { + font-weight: bold; + display: inline-block; + width: 50%; + text-align: right; +} + +.resource-view.image .infoList dd { + display: inline-block; + padding-left: 10px; + width: 50%; + text-align: left; + margin: 0; +} + +.resource-view.image .infoList dd::after { + white-space: pre; + content: "\A"; +} + +#elements-content { + display: block; + overflow: auto; + padding: 0; + position: absolute; + top: 0; + left: 0; + right: 225px; + bottom: 0; +} + +#elements-sidebar { + position: absolute; + top: 0; + right: 0; + bottom: 0; + width: 225px; + background-color: rgb(232, 232, 232); + border-left: 1px solid rgb(64%, 64%, 64%); + cursor: default; + overflow: auto; +} + +.crumbs { + font-size: 11px; + line-height: 19px; + text-shadow: rgba(255, 255, 255, 0.75) 0 1px 0; + color: rgb(20, 20, 20); + margin-left: -1px; + padding-right: 12px; +} + +.crumbs .crumb { + height: 24px; + border-width: 0 12px 0 2px; + -webkit-border-image: url(Images/segment.png) 0 12 0 2; + margin-right: -12px; + padding-left: 18px; + padding-right: 2px; + white-space: nowrap; + line-height: 23px; + float: right; +} + +.crumbs .crumb.collapsed > * { + display: none; +} + +.crumbs .crumb.collapsed::before { + content: "\2026"; + font-weight: bold; +} + +.crumbs .crumb.compact .extra { + display: none; +} + +.crumbs .crumb.dimmed { + color: rgba(0, 0, 0, 0.45); +} + +.crumbs .crumb.start { + padding-left: 7px; +} + +.crumbs .crumb.end { + border-width: 0 2px 0 2px; + padding-right: 6px; + -webkit-border-image: url(Images/segmentEnd.png) 0 2 0 2; +} + +.crumbs .crumb.selected { + -webkit-border-image: url(Images/segmentSelected.png) 0 12 0 2; + color: black; + text-shadow: rgba(255, 255, 255, 0.5) 0 1px 0; +} + +.crumbs .crumb.selected:hover { + -webkit-border-image: url(Images/segmentSelected.png) 0 12 0 2; +} + +.crumbs .crumb.selected.end, .crumbs .crumb.selected.end:hover { + -webkit-border-image: url(Images/segmentSelectedEnd.png) 0 2 0 2; +} + +.crumbs .crumb:hover { + -webkit-border-image: url(Images/segmentHover.png) 0 12 0 2; + color: black; +} + +.crumbs .crumb.dimmed:hover { + -webkit-border-image: url(Images/segmentHover.png) 0 12 0 2; + color: rgba(0, 0, 0, 0.75); +} + +.crumbs .crumb.end:hover { + -webkit-border-image: url(Images/segmentHoverEnd.png) 0 2 0 2; +} + +.outline-disclosure li .selection { + display: none; + position: absolute; + left: 0; + right: 0; + height: 15px; + z-index: -1; +} + +.outline-disclosure li.selected .selection { + display: block; +} + +.focused .outline-disclosure li.selected .selection { + background-color: rgb(56, 121, 217); +} + +.blurred .outline-disclosure li.selected .selection, body.inactive .outline-disclosure li.selected .selection { + background-color: rgb(212, 212, 212); +} + +.outline-disclosure > ol { + position: relative; + padding: 2px 6px !important; + margin: 0; + color: black; + cursor: default; + min-width: 100%; +} + +.outline-disclosure, .outline-disclosure ol { + list-style-type: none; + font-size: 11px; + -webkit-padding-start: 12px; + margin: 0; +} + +.outline-disclosure li { + padding: 0 0 2px 14px; + margin-top: 1px; + margin-bottom: 1px; + word-wrap: break-word; + text-indent: -2px +} + +.blurred .outline-disclosure li.selected, body.inactive .outline-disclosure li.selected { + color: black; +} + +.outline-disclosure li.selected { + color: white; +} + +.outline-disclosure li.parent { + text-indent: -12px +} + +.elements.panel .outline-disclosure li .webkit-html-tag.close { + margin-left: -12px; +} + +.outline-disclosure li.parent::before { + content: url(Images/treeRightTriangleBlack.png); + float: left; + width: 8px; + height: 8px; + margin-top: 1px; + padding-right: 2px; +} + +.blurred .outline-disclosure li.parent.selected::before, body.inactive .outline-disclosure li.parent.selected::before { + content: url(Images/treeRightTriangleBlack.png); +} + +.outline-disclosure li.parent.selected::before { + content: url(Images/treeRightTriangleWhite.png); +} + +.blurred .outline-disclosure li.parent.expanded.selected::before, body.inactive .outline-disclosure li.parent.expanded.selected::before { + content: url(Images/treeDownTriangleBlack.png); +} + +.outline-disclosure li.parent.expanded::before { + content: url(Images/treeDownTriangleBlack.png); +} + +.outline-disclosure li.parent.expanded.selected::before { + content: url(Images/treeDownTriangleWhite.png); +} + +.outline-disclosure ol.children { + display: none; +} + +.outline-disclosure ol.children.expanded { + display: block; +} + +.webkit-html-comment { + /* Keep this in sync with view-source.css (.webkit-html-comment) */ + color: rgb(35, 110, 37); +} + +.webkit-html-tag { + /* Keep this in sync with view-source.css (.webkit-html-tag) */ + color: rgb(136, 18, 128); +} + +.webkit-html-doctype { + /* Keep this in sync with view-source.css (.webkit-html-doctype) */ + color: rgb(192, 192, 192); +} + +.webkit-html-attribute-name { + /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ + color: rgb(153, 69, 0); +} + +.webkit-html-attribute-value { + /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */ + color: rgb(26, 26, 166); +} + +.webkit-html-external-link, .webkit-html-resource-link { + /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */ + color: #00e; +} + +.webkit-html-external-link { + /* Keep this in sync with view-source.css (.webkit-html-external-link) */ + text-decoration: none; +} + +.webkit-html-external-link:hover { + /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */ + text-decoration: underline; +} + +body:not(.inactive) .focused .outline-disclosure li.selected * { + color: inherit; +} + +.section { + position: relative; + margin-top: 1px; +} + +.section .header { + padding: 3px 8px 4px 16px; + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(160, 172, 205)), to(rgb(132, 146, 190)));*/ + background-color: rgb(160, 172, 205); + min-height: 18px; + white-space: nowrap; +} + +.section .header::before { + position: absolute; + top: 4px; + left: 6px; + width: 8px; + height: 8px; + content: url(Images/treeRightTriangleWhite.png); +} + +.section.expanded .header::before { + content: url(Images/treeDownTriangleWhite.png); +} + +.section .header .title { + color: white; + font-weight: bold; + word-wrap: break-word; + white-space: normal; +} + +.section .header label { + display: none; +} + +.section.expanded .header label { + display: inline; +} + +.section .header input[type=checkbox] { + height: 10px; + width: 10px; + margin-left: 0; + margin-top: 0; + margin-bottom: 0; + vertical-align: 2px; +} + +.section .header .subtitle { + float: right; + font-size: 10px; + margin-left: 5px; + max-width: 55%; + color: rgba(255, 255, 255, 0.7); + text-overflow: ellipsis; + overflow: hidden; +} + +.section .header .subtitle a { + color: inherit; +} + +.section .properties { + display: none; + margin: 0; + padding: 2px 6px 5px; + list-style: none; + background-color: white; +} + +.section.expanded .properties { + display: block; +} + +.section .properties li { + margin-left: 10px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + -webkit-user-select: text; + cursor: auto; + outline: none; +} + +.section .properties li.parent { + margin-left: 0; +} + +.section .properties ol { + display: none; + margin: 0; + -webkit-padding-start: 12px; + list-style: none; +} + +.section .properties ol.expanded { + display: block; +} + +.section .properties li.parent::before { + content: url(Images/treeRightTriangleBlack.png); + opacity: 0.75; + float: left; + width: 8px; + height: 8px; + margin-top: 0; + padding-right: 2px; + -webkit-user-select: none; + cursor: default; +} + +.section .properties li.parent.expanded::before { + content: url(Images/treeDownTriangleBlack.png); + margin-top: 1px; +} + +.editing { + -webkit-user-select: text; + -webkit-box-shadow: rgba(0, 0, 0, .5) 3px 3px 4px; + outline: 1px solid rgb(66%, 66%, 66%) !important; + background-color: white; + -webkit-user-modify: read-write-plaintext-only; + text-overflow: clip; + padding-left: 2px; + margin-bottom: -1px; + padding-bottom: 1px; + text-decoration: none !important; + opacity: 1.0 !important; +} + +.editing, .editing * { + color: black !important; +} + +.section .properties li.editing { + margin-left: 8px; + text-overflow: clip; +} + +.section .properties li.editing.parent::before { + display: none; +} + +.section .properties .overloaded { + text-decoration: line-through; +} + +.section .properties .implicit, .section .properties .inherited { + opacity: 0.5; +} + +.section:not(.show-inherited) .properties .inherited { + display: none; +} + +.section .properties .name { + color: rgb(136, 19, 145); +} + +.section .properties .value.dimmed { + color: rgb(100, 100, 100); +} + +.section .properties .number { + color: blue; +} + +.section .properties .priority { + color: rgb(128, 0, 0); +} + +.section .properties .keyword { + color: rgb(136, 19, 79); +} + +.section .properties .color { + color: rgb(118, 15, 21); +} + +.swatch { + display: inline-block; + vertical-align: baseline; + margin-left: 4px; + margin-bottom: -1px; + width: 1em; + height: 1em; + border: 1px solid rgb(180, 180, 180); +} + +.pane { + margin-top: 1px; +} + +.pane > .title { + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(221, 226, 239)), color-stop(0.5, rgb(220, 225, 238)), color-stop(0.5, rgb(194, 203, 219)), to(rgb(217, 222, 234)));*/ + background-color: rgb(221, 226, 239); + height: 16px; + padding: 0 6px; + border-top: 1px solid rgb(129, 129, 129); + border-bottom: 1px solid rgb(129, 129, 129); + font-weight: bold; + font-size: 11px; + color: rgb(85, 85, 85); + -webkit-background-origin: padding; + -webkit-background-clip: padding; +} + +.pane > .title:active { + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(186, 191, 202)), color-stop(0.5, rgb(185, 190, 201)), color-stop(0.5, rgb(163, 171, 185)), to(rgb(183, 187, 197)));*/ + background-color: rgb(186, 191, 202); +} + +.pane > .title::before { + content: url(Images/treeRightTriangleBlack.png); + opacity: 0.75; + float: left; + width: 8px; + height: 8px; + margin-right: 3px; + margin-top: 0; +} + +.pane.expanded > .title::before { + margin-top: 1px; + content: url(Images/treeDownTriangleBlack.png); +} + +.pane > .body { + position: relative; + display: none; + overflow-y: auto; + overflow-x: hidden; +} + +.pane.expanded > .body, .pane.expanded > .growbar { + display: block; +} + +.pane > .growbar { + display: none; + background-image: url(Images/paneGrowHandleLine.png), url(Images/paneBottomGrow.png); + background-repeat: no-repeat, repeat-x; + background-position: center center, bottom; + height: 5px; +} + +.metrics { + padding: 8px; + font-size: 10px; + text-align: center; + white-space: nowrap; +} + +.metrics .label { + position: absolute; + margin-top: -10px; + font-size: 9px; + color: grey; + background-color: rgb(232, 232, 232); + margin-left: 3px; + padding-left: 2px; + padding-right: 2px; +} + +.metrics .margin { + border: 1px dashed; + display: inline-block; + padding: 3px; + margin: 3px; +} + +.metrics .border { + border: 1px black solid; + display: inline-block; + vertical-align: middle; + padding: 3px; + margin: 3px; +} + +.metrics .padding { + border: 1px grey dashed; + display: inline-block; + vertical-align: middle; + padding: 3px; + margin: 3px; +} + +.metrics .content { + position: static; + border: 1px grey solid; + display: inline-block; + vertical-align: middle; + padding: 3px; + margin: 3px; + min-width: 80px; + text-align: center; + overflow: visible; +} + +.metrics .left { + display: inline-block; + text-align: center; + vertical-align: middle; +} + +.metrics .right { + display: inline-block; + text-align: center; + vertical-align: middle; +} + +.metrics .top { + text-align: center; +} + +.metrics .bottom { + text-align: center; +} + +.sidebar { + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 200px; + overflow-y: auto; + overflow-x: hidden; + background-color: rgb(214, 221, 229); + border-right: 1px solid rgb(64%, 64%, 64%); +} + +body.inactive .sidebar { + background-color: rgb(232, 232, 232); +} + +/** + Comment back in to support databases +.database-sidebar-tree-item .icon { + content: url(Images/database.png); +} + +.database-table-sidebar-tree-item .icon { + content: url(Images/databaseTable.png); +} + +#database-views { + position: absolute; + top: 0; + right: 0; + left: 200px; + bottom: 0; +} + +.database-view { + display: none; + overflow: hidden; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.database-view.visible { + display: block; +} + +.database-view.table { + font-size: 10px; + overflow-y: auto; + overflow-x: hidden; +} + +.database-view.table .database-result-table { + border: none; + height: 100%; +} + +.database-view.table .database-table-empty, .database-view.table .database-table-error { + position: absolute; + top: 0; + bottom: 25%; + left: 0; + right: 0; + font-size: 24px; + color: rgb(75%, 75%, 75%); + margin-top: auto; + margin-bottom: auto; + height: 50px; + line-height: 26px; + text-align: center; + font-weight: bold; + padding: 10px; + white-space: pre-wrap; +} + +.database-view.table .database-table-error { + color: rgb(66%, 33%, 33%); +} + +.database-result-table .database-result-filler-row { + height: auto; +} + +.database-result-table .database-result-filler-row.alternate td { + background-position-y: 16px; +} + +.database-result-filler-row td { + //background-image: -webkit-gradient(linear, left top, left bottom, from(white), color-stop(0.5, white), color-stop(0.5, rgb(234, 243, 255)), to(rgb(234, 243, 255))); + background-color: white; + -webkit-background-size: auto 32px; + -webkit-background-origin: padding; + -webkit-background-clip: padding; +} + +.database-result-table { + border: 1px solid #aaa; + table-layout: fixed; + border-spacing: 0; + border-collapse: collapse; + width: 100%; +} + +.database-result-table th { + text-align: left; + background: url(Images/glossyHeader.png) repeat-x; + border-right: 1px solid #aaa; + height: 15px; + border-bottom: 1px solid #aaa; + font-weight: normal; + vertical-align: middle; + padding: 0 4px; + white-space: nowrap; +} + +.database-result-table tr { + height: 16px; +} + +.database-result-table tr.alternate { + background-color: rgb(236, 243, 254); +} + +.database-result-table td { + vertical-align: top; + padding: 2px 4px; + white-space: nowrap; + border-right: 1px solid #aaa; + -webkit-user-select: text; +} + +.database-result-table td > div, .database-result-table th > div { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.database-view.query { + font-size: 10px; + font-family: Monaco, Lucida Console, monospace; + padding: 2px 0; + overflow-y: overlay; + overflow-x: hidden; + -webkit-text-size-adjust: auto; +} + +.database-query-prompt { + position: relative; + outline: none; + padding: 1px 22px 1px 24px; + min-height: 16px; + white-space: pre-wrap; + -webkit-user-modify: read-write-plaintext-only; + -webkit-user-select: text; +} + +.database-user-query::before, .database-query-prompt::before, .database-query-result::before { + position: absolute; + display: block; + content: ""; + left: 7px; + top: 0.8em; + width: 10px; + height: 10px; + margin-top: -5px; + -webkit-user-select: none; +} + +.database-query-prompt::before { + background-image: url(Images/userInputIcon.png); +} + +.database-user-query { + position: relative; + border-bottom: 1px solid rgb(240, 240, 240); + padding: 1px 22px 1px 24px; + min-height: 16px; +} + +.database-user-query::before { + background-image: url(Images/userInputPreviousIcon.png); +} + +.database-query-text { + color: rgb(0, 128, 255); + -webkit-user-select: text; +} + +.database-query-result { + position: relative; + padding: 1px 22px 1px 24px; + min-height: 16px; + margin-left: -24px; + padding-right: 0; +} + +.database-query-result.error { + color: red; + -webkit-user-select: text; +} + +.database-query-result.error::before { + background-image: url(Images/errorIcon.png); +}*/ + +#scripts-debugging-status-bar-item { + background-image: url(Images/debuggingButtons.png); +} + +#scripts-debugging-status-bar-item:active { + background-position: 32px 0; +} + +#scripts-debugging-status-bar-item.toggled-on { + background-position: 0 24px; +} + +#scripts-debugging-status-bar-item.toggled-on:active { + background-position: 32px 24px; +} + +#scripts-status-bar { + position: absolute; + top: -1px; + left: 0; + right: 0; + height: 24px; +} + +#scripts-status-bar .status-bar-item img { + margin-top: 2px; +} + +#scripts-status-bar .status-bar-item:disabled img { + opacity: 0.5; +} + +#scripts-back img { + content: url(Images/back.png); +} + +#scripts-forward img { + content: url(Images/forward.png); +} + +#scripts-pause img { + content: url(Images/debuggerPause.png); +} + +#scripts-step-over img { + content: url(Images/debuggerStepOver.png); +} + +#scripts-step-into img { + content: url(Images/debuggerStepInto.png); +} + +#scripts-step-out img { + content: url(Images/debuggerStepOut.png); +} + +#scripts-debugger-status { + position: absolute; + line-height: 24px; + top: 0; + right: 8px; +} + +#scripts-debugger-status:empty { + display: none; +} + +#scripts-sidebar-resizer-widget { + position: absolute; + top: 0; + bottom: 0; + right: 225px; + width: 16px; + cursor: col-resize; + background-image: url(Images/statusbarResizerHorizontal.png); + background-repeat: no-repeat; + background-position: center; +} + +#scripts-sidebar-buttons { + position: absolute; + right: 0; + top: 0; + bottom: 0; + width: 225px; + overflow: hidden; + border-left: 1px solid rgb(64%, 64%, 64%); +} + +#script-resource-views { + display: block; + overflow: auto; + padding: 0; + position: absolute; + top: 23px; + left: 0; + right: 225px; + bottom: 0; +} + +#scripts-sidebar { + position: absolute; + top: 23px; + right: 0; + bottom: 0; + width: 225px; + background-color: rgb(232, 232, 232); + border-left: 1px solid rgb(64%, 64%, 64%); + cursor: default; + overflow: auto; +} + +#resources-larger-resources-status-bar-item { + background-image: url(Images/largerResourcesButtons.png); +} + +#resources-larger-resources-status-bar-item:active { + background-position: 32px 0; +} + +#resources-larger-resources-status-bar-item.toggled-on { + background-position: 0 24px; +} + +#resources-larger-resources-status-bar-item.toggled-on:active { + background-position: 32px 24px; +} + +#resources-container { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + border-right: 0 none transparent; + overflow-y: auto; + overflow-x: hidden; +} + +#resources-container.viewing-resource { + right: auto; + width: 200px; + border-right: 1px solid rgb(64%, 64%, 64%); +} + +#resources-container.viewing-resource #resources-sidebar { + width: 100%; + border-right: 0 none transparent; +} + +#resources-sidebar { + min-height: 100%; + bottom: auto; + overflow: visible; +} + +#resources-container-content { + position: absolute; + top: 0; + right: 0; + left: 200px; + min-height: 100%; +} + +#resources-container.viewing-resource #resources-container-content { + display: none; +} + +#resources-summary { + position: absolute; + padding-top: 20px; + top: 0; + left: 0; + right: 0; + height: 93px; + margin-left: -1px; + border-left: 1px solid rgb(102, 102, 102); + background-color: rgb(101, 111, 130); + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.5)));*/ + background-color: transparent; + background-repeat: repeat-x; + background-position: bottom; + text-align: center; + text-shadow: black 0 1px 1px; + white-space: nowrap; + color: white; + -webkit-background-size: 1px 6px; + -webkit-background-origin: padding; + -webkit-background-clip: padding; +} + +#resources-graph-legend { + margin-top: -10px; + padding-left: 15px; +} + +.resources-graph-legend-item { + display: inline-block; + font-weight: bold; + margin-right: 15px; + vertical-align: top; +} + +.resources-graph-legend-item.total { + margin-left: 10px; +} + +.resources-graph-legend-label { + display: inline-block; + text-align: left; +} + +.resources-graph-legend-header { + font-size: 12px; +} + +.resources-graph-legend-value { + font-size: 10px; +} + +.resources-graph-legend-swatch { + vertical-align: top; + margin-top: 1px; + margin-right: 3px; +} + +.resources-summary-graph { + vertical-align: middle; +} + +#resources-dividers { + position: absolute; + left: 0; + right: 0; + height: 100%; + top: 0; + z-index: -100; +} + +#resources-dividers-label-bar { + position: absolute; + top: 93px; + left: 0px; + right: 0; + background-color: rgba(255, 255, 255, 0.8); + background-clip: padding; + border-bottom: 1px solid rgba(0, 0, 0, 0.3); + height: 20px; + z-index: 200; +} + +.resources-divider { + position: absolute; + width: 1px; + top: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.1); +} + +.resources-divider.last { + background-color: transparent; +} + +.resources-divider-label { + position: absolute; + top: 4px; + right: 3px; + font-size: 9px; + color: rgb(50%, 50%, 50%); + white-space: nowrap; +} + +.resources-graph-bar { + position: absolute; + top: 0; + bottom: 0; + margin: auto -7px; + border-width: 6px 7px 6px 7px; + height: 13px; + min-width: 14px; + opacity: 0.65; + -webkit-border-image: url(Images/timelinePillGray.png) 6 7 6 7; +} + +.resources-graph-bar.waiting { + opacity: 0.35; +} + +.resource-sidebar-tree-item.resources-category-documents .resources-graph-bar { + -webkit-border-image: url(Images/timelinePillBlue.png) 6 7 6 7; +} + +.resource-sidebar-tree-item.resources-category-stylesheets .resources-graph-bar { + -webkit-border-image: url(Images/timelinePillGreen.png) 6 7 6 7; +} + +.resource-sidebar-tree-item.resources-category-images .resources-graph-bar { + -webkit-border-image: url(Images/timelinePillPurple.png) 6 7 6 7; +} + +.resource-sidebar-tree-item.resources-category-fonts .resources-graph-bar { + -webkit-border-image: url(Images/timelinePillRed.png) 6 7 6 7; +} + +.resource-sidebar-tree-item.resources-category-scripts .resources-graph-bar { + -webkit-border-image: url(Images/timelinePillOrange.png) 6 7 6 7; +} + +.resource-sidebar-tree-item.resources-category-xhr .resources-graph-bar { + -webkit-border-image: url(Images/timelinePillYellow.png) 6 7 6 7; +} + +.tip-button { + background-image: url(Images/tipIcon.png); + border: none; + width: 16px; + height: 16px; + float: right; + background-color: transparent; + margin-top: 1px; +} + +.tip-button:active { + background-image: url(Images/tipIconPressed.png); +} + +.tip-balloon { + position: absolute; + left: 145px; + top: -5px; + z-index: 1000; + border-width: 51px 15px 18px 37px; + -webkit-border-image: url(Images/tipBalloon.png) 51 15 18 37; + width: 265px; +} + +.tip-balloon.bottom { + position: absolute; + left: 145px; + top: auto; + bottom: -7px; + z-index: 1000; + border-width: 18px 15px 51px 37px; + -webkit-border-image: url(Images/tipBalloonBottom.png) 18 15 51 37; +} + +.tip-balloon-content { + margin-top: -40px; + margin-bottom: -2px; + margin-left: 2px; +} + +.tip-balloon.bottom .tip-balloon-content { + margin-top: -10px; + margin-bottom: -35px; +} + +#resource-views { + position: absolute; + top: 0; + right: 0; + left: 200px; + bottom: 0; +} + +.source-view-frame { + width: 100%; + height: 100%; +} + +.sidebar-resizer-vertical { + position: absolute; + top: 0; + bottom: 0; + width: 5px; + z-index: 500; + cursor: col-resize; +} + +.sidebar-tree, .sidebar-tree .children { + position: relative; + padding: 0; + margin: 0; + list-style: none; + font-size: 11px; +} + +.sidebar-tree-section { + position: relative; + height: 18px; + padding: 4px 10px 6px 10px; + white-space: nowrap; + margin-top: 1px; + color: rgb(92, 110, 129); + font-weight: bold; + text-shadow: rgba(255, 255, 255, 0.75) 0 1px 0; +} + +.sidebar-tree-item { + position: relative; + height: 36px; + padding: 0 5px 0 5px; + white-space: nowrap; + margin-top: 1px; + line-height: 34px; + border-top: 1px solid transparent; +} + +.sidebar-tree .children { + display: none; +} + +.sidebar-tree .children.expanded { + display: block; +} + +.sidebar-tree-section + .children > .sidebar-tree-item { + padding-left: 10px !important; +} + +.sidebar-tree-section + .children.small > .sidebar-tree-item { + padding-left: 17px !important; +} + +.sidebar-tree > .children > .sidebar-tree-item { + padding-left: 37px; +} + +.sidebar-tree.hide-disclosure-buttons > .children { + display: none; +} + +.sidebar-tree > .children.hide-disclosure-buttons > .children { + display: none; +} + +.sidebar-tree.some-expandable:not(.hide-disclosure-buttons) > .sidebar-tree-item:not(.parent) .icon { + margin-left: 16px; +} + +.sidebar-tree-item .disclosure-button { + float: left; + width: 16px; + height: 100%; + border: 0; + background-color: transparent; + background-image: url(Images/disclosureTriangleSmallRight.png); + background-repeat: no-repeat; + background-position: center; + -webkit-apearance: none; +} + +.sidebar-tree.hide-disclosure-buttons .sidebar-tree-item .disclosure-button { + display: none; +} + +body.inactive .sidebar-tree-item .disclosure-button { + background-image: url(Images/disclosureTriangleSmallRightBlack.png); +} + +body.inactive .sidebar-tree-item.expanded .disclosure-button { + background-image: url(Images/disclosureTriangleSmallDownBlack.png); +} + +body.inactive .sidebar-tree-item .disclosure-button:active { + background-image: url(Images/disclosureTriangleSmallRightDownBlack.png); +} + +.sidebar-tree-item.selected .disclosure-button { + background-image: url(Images/disclosureTriangleSmallRightWhite.png) !important; +} + +.sidebar-tree-item.expanded .disclosure-button { + background-image: url(Images/disclosureTriangleSmallDown.png); +} + +.sidebar-tree-item.selected.expanded .disclosure-button { + background-image: url(Images/disclosureTriangleSmallDownWhite.png) !important; +} + +.sidebar-tree-item.selected .disclosure-button:active { + background-image: url(Images/disclosureTriangleSmallRightDownWhite.png) !important; +} + +.sidebar-tree-item .disclosure-button:active { + background-image: url(Images/disclosureTriangleSmallRightDown.png); +} + +.sidebar-tree-item .icon { + float: left; + width: 32px; + height: 32px; + margin-top: 1px; + margin-right: 3px; +} + +.sidebar-tree-item .status { + float: right; + height: 16px; + margin-top: 9px; + margin-left: 4px; + line-height: 1em; +} + +.sidebar-tree-item .status:empty { + display: none; +} + +.sidebar-tree-item .status .bubble { + display: inline-block; + height: 14px; + min-width: 16px; + margin-top: 1px; + background-color: rgb(128, 151, 189); + vertical-align: middle; + white-space: nowrap; + padding: 1px 4px; + text-align: center; + font-size: 11px; + font-family: Helvetia, Arial, sans-serif; + font-weight: bold; + text-shadow: none; + color: white; + -webkit-border-radius: 7px; +} + +.sidebar-tree-item .status .bubble:empty { + display: none; +} + +.sidebar-tree-item.selected .status .bubble { + background-color: white !important; + color: rgb(132, 154, 190) !important; +} + +.focused .sidebar-tree-item.selected .status .bubble { + color: rgb(36, 98, 172) !important; +} + +body.inactive .sidebar-tree-item.selected .status .bubble { + color: rgb(159, 159, 159) !important; +} + +.sidebar-tree.small .sidebar-tree-item, .sidebar-tree .children.small .sidebar-tree-item, .sidebar-tree-item.small { + height: 20px; + line-height: 18px; +} + +.sidebar-tree.small .sidebar-tree-item .icon, .sidebar-tree .children.small .sidebar-tree-item .icon, .sidebar-tree-item.small .icon { + width: 16px; + height: 16px; +} + +.sidebar-tree.small .sidebar-tree-item .status, .sidebar-tree .children.small .sidebar-tree-item .status, .sidebar-tree-item.small .status { + margin-top: 1px; +} + +.sidebar-tree-item.selected { + color: white; + border-top: 1px solid rgb(145, 160, 192); + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(162, 177, 207)), to(rgb(120, 138, 177)));*/ + background-color: rgb(162, 177, 207); + text-shadow: rgba(0, 0, 0, 0.33) 0 1px 0; + font-weight: bold; + -webkit-background-origin: padding; + -webkit-background-clip: padding; +} + +.focused .sidebar-tree-item.selected { + border-top: 1px solid rgb(68, 128, 200); + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(92, 147, 213)), to(rgb(21, 83, 170)));*/ + background-color: rgb(92, 147, 213); +} + +body.inactive .sidebar-tree-item.selected { + border-top: 1px solid rgb(151, 151, 151); + /*background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(180, 180, 180)), to(rgb(138, 138, 138)));*/ + background-color: rgb(180, 180, 180); +} + +.sidebar-tree-item .titles { + position: relative; + top: 5px; + line-height: 11px; + padding-bottom: 1px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +.sidebar-tree-item .titles.no-subtitle { + top: 10px; +} + +.sidebar-tree.small .sidebar-tree-item .titles, .sidebar-tree .children.small .sidebar-tree-item .titles, .sidebar-tree-item.small .titles { + top: 2px; + line-height: normal; +} + +.sidebar-tree:not(.small) .sidebar-tree-item:not(.small) .title::after, .sidebar-tree .children:not(.small) .sidebar-tree-item .title::after { + content: "\A"; + white-space: pre; +} + +.sidebar-tree-item .subtitle { + font-size: 9px; + color: rgba(0, 0, 0, 0.7); +} + +.sidebar-tree.small .sidebar-tree-item .subtitle, .sidebar-tree .children.small .sidebar-tree-item .subtitle, .sidebar-tree-item.small .subtitle { + display: none; +} + +.sidebar-tree-item.selected .subtitle { + color: rgba(255, 255, 255, 0.9); +} + +.sidebar-tree-item .resources-graph-side { + position: absolute; + height: 100%; + top: 0; + right: 0; +} + +.sidebar-tree-item .resources-graph-bar-area { + position: absolute; + top: 0; + bottom: 0; + right: 8px; + left: 9px; +} + +#resources-container:not(.viewing-resource) .resource-sidebar-tree-item:nth-of-type(2n) { + background-color: rgba(0, 0, 0, 0.05); +} + +#resources-container:not(.viewing-resource) .resource-sidebar-tree-item:nth-of-type(2n) .resources-graph-side { + background-color: rgba(0, 0, 0, 0.05); +} + +#resources-container.viewing-resource #resources-sidebar .sidebar-tree-item .resources-graph-side { + display: none; +} + +.resources-time-graph-sidebar-item .icon { + content: url(Images/resourcesTimeGraphIcon.png); +} + +.resources-size-graph-sidebar-item .icon { + content: url(Images/resourcesSizeGraphIcon.png); +} + +.resources-size-graph-sidebar-item .icon { + content: url(Images/resourcesSizeGraphIcon.png); +} + +.resource-sidebar-tree-item .icon { + content: url(Images/resourcePlainIcon.png); +} + +.children.small .resource-sidebar-tree-item .icon { + content: url(Images/resourcePlainIconSmall.png); +} + +.resource-sidebar-tree-item.resources-category-documents .icon { + content: url(Images/resourceDocumentIcon.png); +} + +.children.small .resource-sidebar-tree-item.resources-category-documents .icon { + content: url(Images/resourceDocumentIconSmall.png); +} + +.resource-sidebar-tree-item.resources-category-stylesheets .icon { + content: url(Images/resourceCSSIcon.png); +} + +.children.small .resource-sidebar-tree-item.resources-category-stylesheets .icon { + content: url(Images/resourceDocumentIconSmall.png); +} + +.resource-sidebar-tree-item.resources-category-images .icon { + content: url(Images/resourcePlainIcon.png); +} + +.children.small .resource-sidebar-tree-item.resources-category-images .icon { + content: url(Images/resourcePlainIconSmall.png); +} + +.resource-sidebar-tree-item.resources-category-fonts .icon { + content: url(Images/resourcePlainIcon.png); +} + +.children.small .resource-sidebar-tree-item.resources-category-fonts .icon { + content: url(Images/resourcePlainIconSmall.png); +} + +.resource-sidebar-tree-item.resources-category-scripts .icon { + content: url(Images/resourceJSIcon.png); +} + +.children.small .resource-sidebar-tree-item.resources-category-scripts .icon { + content: url(Images/resourceDocumentIconSmall.png); +} + +.resource-sidebar-tree-item.resources-category-xhr .icon { + content: url(Images/resourcePlainIcon.png); +} + +.children.small .resource-sidebar-tree-item.resources-category-xhr .icon { + content: url(Images/resourceDocumentIconSmall.png); +} + +.resource-sidebar-tree-item .bubble.warning { + background-color: rgb(232, 164, 0); +} + +.resource-sidebar-tree-item .bubble.error { + background-color: rgb(216, 35, 35); +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.html b/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.html new file mode 100644 index 0000000..1c0d49e --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.html @@ -0,0 +1,78 @@ +<!-- +Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <link rel="stylesheet" type="text/css" href="inspector.css"> + <script type="text/javascript" src="utilities.js"></script> + <script type="text/javascript" src="treeoutline.js"></script> + <script type="text/javascript" src="inspector.js"></script> + <script type="text/javascript" src="TextPrompt.js"></script> + <script type="text/javascript" src="View.js"></script> + <script type="text/javascript" src="Console.js"></script> + <script type="text/javascript" src="Resource.js"></script> + <script type="text/javascript" src="ResourceCategory.js"></script> + <script type="text/javascript" src="Database.js"></script> + <script type="text/javascript" src="SidebarPane.js"></script> + <script type="text/javascript" src="SidebarTreeElement.js"></script> + <script type="text/javascript" src="PropertiesSection.js"></script> + <script type="text/javascript" src="BreakpointsSidebarPane.js"></script> + <script type="text/javascript" src="CallStackSidebarPane.js"></script> + <script type="text/javascript" src="MetricsSidebarPane.js"></script> + <script type="text/javascript" src="PropertiesSidebarPane.js"></script> + <script type="text/javascript" src="StylesSidebarPane.js"></script> + <script type="text/javascript" src="Panel.js"></script> + <script type="text/javascript" src="ElementsPanel.js"></script> + <script type="text/javascript" src="ResourcesPanel.js"></script> + <script type="text/javascript" src="ScriptsPanel.js"></script> + <!--script type="text/javascript" src="DatabasesPanel.js"></script--> + <script type="text/javascript" src="ResourceView.js"></script> + <script type="text/javascript" src="SourceView.js"></script> + <script type="text/javascript" src="FontView.js"></script> + <script type="text/javascript" src="ImageView.js"></script> + <!--script type="text/javascript" src="DatabaseTableView.js"></script> + <script type="text/javascript" src="DatabaseQueryView.js"></script--> +</head> +<body class="detached"> + <div id="toolbar"> + <div class="toolbar-item flexable-space"></div> + <div class="toolbar-item"><input id="search" type="search" results="20" incremental="incremental" onsearch="WebInspector.performSearch(this.value)"><div id="search-toolbar-label" class="toolbar-label"></div></div> + </div> + <div id="main"> + <div id="searchResults" class="focusable hidden"></div> + <div id="searchResultsResizer" class="hidden"></div> + <div id="main-panels" class="focusable focused"></div> + <div id="main-status-bar" class="status-bar"><div id="anchored-status-bar-items"><button id="dock-status-bar-item" class="status-bar-item toggled"></button><button id="console-status-bar-item" class="status-bar-item"></button><div id="error-warning-count" class="hidden"></div></div></div> + </div> + <div id="console"> + <div id="console-messages" class="focusable blurred"><div id="console-prompt"><br></div></div> + <div id="console-status-bar" class="status-bar"><div id="other-console-status-bar-items"><button id="clear-console-status-bar-item" class="status-bar-item"></button></div></div> + </div> +</body> +</html> diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.js new file mode 100644 index 0000000..a1e1805a --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/inspector.js @@ -0,0 +1,1183 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +var Preferences = { + ignoreWhitespace: true, + showUserAgentStyles: true, + maxInlineTextChildLength: 80, + maxTextSearchResultLength: 80, + minConsoleHeight: 75, + minSidebarWidth: 100, + minElementsSidebarWidth: 200, + minScriptsSidebarWidth: 200, + showInheritedComputedStyleProperties: false, + showMissingLocalizedStrings: false +} + +var WebInspector = { + resources: [], + resourceURLMap: {}, + searchResultsHeight: 100, + localizedStrings: {}, + missingLocalizedStrings: {}, + + get currentFocusElement() + { + return this._currentFocusElement; + }, + + set currentFocusElement(x) + { + if (!x || this._currentFocusElement === x) + return; + + if (this._currentFocusElement) { + this._currentFocusElement.removeStyleClass("focused"); + this._currentFocusElement.addStyleClass("blurred"); + if (this._currentFocusElement.blur) + this._currentFocusElement.blur(); + if (this._currentFocusElement.blurred) + this._currentFocusElement.blurred(x); + } + + var previousFocusElement = this._currentFocusElement; + this._currentFocusElement = x; + + if (x) { + x.addStyleClass("focused"); + x.removeStyleClass("blurred"); + if (this._currentFocusElement.focus) + this._currentFocusElement.focus(); + if (this._currentFocusElement.focused) + this._currentFocusElement.focused(previousFocusElement); + + // 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 = document.createRange(); + selectionRange.setStart(this._currentFocusElement, 0); + selectionRange.setEnd(this._currentFocusElement, 0); + + selection.removeAllRanges(); + selection.addRange(selectionRange); + } + } + }, + + get currentPanel() + { + return this._currentPanel; + }, + + set currentPanel(x) + { + if (this._currentPanel === x) + return; + + if (this._currentPanel) + this._currentPanel.hide(); + + this._currentPanel = x; + + if (x) + x.show(); + }, + + get attached() + { + return this._attached; + }, + + set attached(x) + { + if (this._attached === x) + return; + + this._attached = x; + + var dockToggleButton = document.getElementById("dock-status-bar-item"); + var body = document.body; + + if (x) { + InspectorController.attach(); + body.removeStyleClass("detached"); + body.addStyleClass("attached"); + dockToggleButton.title = WebInspector.UIString("Undock into separate window."); + } else { + InspectorController.detach(); + body.removeStyleClass("attached"); + body.addStyleClass("detached"); + dockToggleButton.title = WebInspector.UIString("Dock to main window."); + } + }, + + get showingSearchResults() + { + return this._showingSearchResults; + }, + + set showingSearchResults(x) + { + if (this._showingSearchResults === x) + return; + + this._showingSearchResults = x; + + var resultsContainer = document.getElementById("searchResults"); + var searchResultsResizer = document.getElementById("searchResultsResizer"); + + if (x) { + resultsContainer.removeStyleClass("hidden"); + searchResultsResizer.removeStyleClass("hidden"); + + var animations = [ + {element: resultsContainer, end: {top: 0}}, + {element: searchResultsResizer, end: {top: WebInspector.searchResultsHeight - 3}}, + {element: document.getElementById("main-panels"), end: {top: WebInspector.searchResultsHeight}} + ]; + + WebInspector.animateStyle(animations, 250); + } else { + searchResultsResizer.addStyleClass("hidden"); + + var animations = [ + {element: resultsContainer, end: {top: -WebInspector.searchResultsHeight}}, + {element: searchResultsResizer, end: {top: 0}}, + {element: document.getElementById("main-panels"), end: {top: 0}} + ]; + + var animationFinished = function() + { + resultsContainer.addStyleClass("hidden"); + resultsContainer.removeChildren(); + delete this.searchResultsTree; + }; + + WebInspector.animateStyle(animations, 250, animationFinished); + } + }, + get errors() + { + return this._errors || 0; + }, + + set errors(x) + { + x = Math.max(x, 0); + + if (this._errors === x) + return; + this._errors = x; + this._updateErrorAndWarningCounts(); + }, + + get warnings() + { + return this._warnings || 0; + }, + + set warnings(x) + { + x = Math.max(x, 0); + + if (this._warnings === x) + return; + this._warnings = x; + this._updateErrorAndWarningCounts(); + }, + + _updateErrorAndWarningCounts: function() + { + var errorWarningElement = document.getElementById("error-warning-count"); + if (!errorWarningElement) + return; + if (!this.errors && !this.warnings) { + errorWarningElement.addStyleClass("hidden"); + return; + } + + errorWarningElement.removeStyleClass("hidden"); + + errorWarningElement.removeChildren(); + + if (this.errors) { + var errorElement = document.createElement("span"); + errorElement.id = "error-count"; + errorElement.textContent = this.errors; + errorWarningElement.appendChild(errorElement); + } + + if (this.warnings) { + var warningsElement = document.createElement("span"); + warningsElement.id = "warning-count"; + warningsElement.textContent = this.warnings; + errorWarningElement.appendChild(warningsElement); + } + + if (this.errors) { + if (this.warnings) { + if (this.errors == 1) { + if (this.warnings == 1) + errorWarningElement.title = WebInspector.UIString("%d error, %d warning", this.errors, this.warnings); + else + errorWarningElement.title = WebInspector.UIString("%d error, %d warnings", this.errors, this.warnings); + } else if (this.warnings == 1) + errorWarningElement.title = WebInspector.UIString("%d errors, %d warning", this.errors, this.warnings); + else + errorWarningElement.title = WebInspector.UIString("%d errors, %d warnings", this.errors, this.warnings); + } else if (this.errors == 1) + errorWarningElement.title = WebInspector.UIString("%d error", this.errors); + else + errorWarningElement.title = WebInspector.UIString("%d errors", this.errors); + } else if (this.warnings == 1) + errorWarningElement.title = WebInspector.UIString("%d warning", this.warnings); + else if (this.warnings) + errorWarningElement.title = WebInspector.UIString("%d warnings", this.warnings); + else + errorWarningElement.title = null; + } +} + +WebInspector.loaded = function() +{ + var platform = InspectorController.platform(); + document.body.addStyleClass("platform-" + platform); + + this.console = new WebInspector.Console(); + + this.panels = { + elements: new WebInspector.ElementsPanel(), + resources: new WebInspector.ResourcesPanel() + // We don't use the databases tab, so don't show it. + // , databases: new WebInspector.DatabasesPanel() + }; + + var toolbarElement = document.getElementById("toolbar"); + for (var panelName in this.panels) { + var panel = this.panels[panelName]; + var panelToolbarItem = panel.toolbarItem; + panelToolbarItem.addEventListener("click", this._toolbarItemClicked.bind(this)); + if (previousToolbarItem) + toolbarElement.insertBefore(panelToolbarItem, previousToolbarItem.nextSibling); + else + toolbarElement.insertBefore(panelToolbarItem, toolbarElement.firstChild); + var previousToolbarItem = panelToolbarItem; + } + + this.currentPanel = this.panels.elements; + + this.resourceCategories = { + documents: new WebInspector.ResourceCategory(WebInspector.UIString("Documents"), "documents"), + stylesheets: new WebInspector.ResourceCategory(WebInspector.UIString("Stylesheets"), "stylesheets"), + images: new WebInspector.ResourceCategory(WebInspector.UIString("Images"), "images"), + scripts: new WebInspector.ResourceCategory(WebInspector.UIString("Scripts"), "scripts"), + xhr: new WebInspector.ResourceCategory(WebInspector.UIString("XHR"), "xhr"), + fonts: new WebInspector.ResourceCategory(WebInspector.UIString("Fonts"), "fonts"), + other: new WebInspector.ResourceCategory(WebInspector.UIString("Other"), "other") + }; + + this.Tips = { + ResourceNotCompressed: {id: 0, message: WebInspector.UIString("You could save bandwidth by having your web server compress this transfer with gzip or zlib.")} + }; + + this.Warnings = { + IncorrectMIMEType: {id: 0, message: WebInspector.UIString("Resource interpreted as %s but transferred with MIME type %s.")} + }; + + this.addMainEventListeners(document); + + window.addEventListener("unload", this.windowUnload.bind(this), true); + window.addEventListener("resize", this.windowResize.bind(this), true); + + document.addEventListener("mousedown", this.changeFocus.bind(this), true); + document.addEventListener("focus", this.changeFocus.bind(this), true); + document.addEventListener("keydown", this.documentKeyDown.bind(this), true); + document.addEventListener("beforecopy", this.documentCanCopy.bind(this), true); + document.addEventListener("copy", this.documentCopy.bind(this), true); + + document.getElementById("searchResultsResizer").addEventListener("mousedown", this.searchResultsResizerDragStart, true); + + var mainPanelsElement = document.getElementById("main-panels"); + mainPanelsElement.handleKeyEvent = this.mainKeyDown.bind(this); + mainPanelsElement.handleCopyEvent = this.mainCopy.bind(this); + + this.currentFocusElement = mainPanelsElement; + + var dockToggleButton = document.getElementById("dock-status-bar-item"); + dockToggleButton.addEventListener("click", this.toggleAttach.bind(this), false); + + if (this.attached) + dockToggleButton.title = WebInspector.UIString("Undock into separate window."); + else + dockToggleButton.title = WebInspector.UIString("Dock to main window."); + + var errorWarningCount = document.getElementById("error-warning-count"); + errorWarningCount.addEventListener("click", this.console.show.bind(this.console), false); + this._updateErrorAndWarningCounts(); + document.getElementById("search-toolbar-label").textContent = WebInspector.UIString("Search"); + + if (platform === "mac-leopard") + document.getElementById("toolbar").addEventListener("mousedown", this.toolbarDragStart, true); + + InspectorController.loaded(); +} + +var windowLoaded = function() +{ + var localizedStringsURL = InspectorController.localizedStringsURL(); + if (localizedStringsURL) { + var localizedStringsScriptElement = document.createElement("script"); + localizedStringsScriptElement.addEventListener("load", WebInspector.loaded.bind(WebInspector), false); + localizedStringsScriptElement.type = "text/javascript"; + localizedStringsScriptElement.src = localizedStringsURL; + document.getElementsByTagName("head").item(0).appendChild(localizedStringsScriptElement); + } else + WebInspector.loaded(); + + window.removeEventListener("load", windowLoaded, false); + delete windowLoaded; +}; + +window.addEventListener("load", windowLoaded, false); + +WebInspector.windowUnload = function(event) +{ + InspectorController.windowUnloading(); +} + +WebInspector.windowResize = function(event) +{ + if (this.currentPanel && this.currentPanel.resize) + this.currentPanel.resize(); +} + +WebInspector.windowFocused = function(event) +{ + if (event.target.nodeType === Node.DOCUMENT_NODE) + document.body.removeStyleClass("inactive"); +} + +WebInspector.windowBlured = function(event) +{ + if (event.target.nodeType === Node.DOCUMENT_NODE) + document.body.addStyleClass("inactive"); + this.hideDOMNodeHighlight(); +} + +WebInspector.changeFocus = function(event) +{ + var nextFocusElement; + + var current = event.target; + while (current) { + if (current.nodeName.toLowerCase() === "input") + nextFocusElement = current; + current = current.parentNode; + } + + if (!nextFocusElement) + nextFocusElement = event.target.enclosingNodeOrSelfWithClass("focusable"); + + this.currentFocusElement = nextFocusElement; +} + +WebInspector.documentClick = function(event) +{ + var anchor = event.target.enclosingNodeOrSelfWithNodeName("a"); + if (!anchor) + return; + + if (anchor.followOnAltClick && !event.altKey) { + event.preventDefault(); + return; + } + + if (!anchor.hasStyleClass("webkit-html-resource-link")) + return; + + if (WebInspector.showResourceForURL(anchor.href, anchor.lineNumber)) { + event.preventDefault(); + event.stopPropagation(); + } +} + +WebInspector.documentKeyDown = function(event) +{ + if (!this.currentFocusElement) + return; + if (this.currentFocusElement.handleKeyEvent) + this.currentFocusElement.handleKeyEvent(event); + else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "KeyDown"]) + WebInspector[this.currentFocusElement.id + "KeyDown"](event); + + if (!event.handled) { + switch (event.keyIdentifier) { + case "U+001B": // Escape key + this.console.visible = !this.console.visible; + event.preventDefault(); + break; + } + } +} + +WebInspector.documentCanCopy = function(event) +{ + if (!this.currentFocusElement) + return; + // Calling preventDefault() will say "we support copying, so enable the Copy menu". + if (this.currentFocusElement.handleCopyEvent) + event.preventDefault(); + else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"]) + event.preventDefault(); +} + +WebInspector.documentCopy = function(event) +{ + if (!this.currentFocusElement) + return; + if (this.currentFocusElement.handleCopyEvent) + this.currentFocusElement.handleCopyEvent(event); + else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"]) + WebInspector[this.currentFocusElement.id + "Copy"](event); +} + +WebInspector.mainKeyDown = function(event) +{ + if (this.currentPanel && this.currentPanel.handleKeyEvent) + this.currentPanel.handleKeyEvent(event); +} + +WebInspector.mainCopy = function(event) +{ + if (this.currentPanel && this.currentPanel.handleCopyEvent) + this.currentPanel.handleCopyEvent(event); +} + +WebInspector.searchResultsKeyDown = function(event) +{ + if (this.searchResultsTree) + this.searchResultsTree.handleKeyEvent(event); +} + +WebInspector.animateStyle = function(animations, duration, callback, complete) +{ + if (complete === undefined) + complete = 0; + var slice = (1000 / 30); // 30 frames per second + + var defaultUnit = "px"; + var propertyUnit = {opacity: ""}; + + for (var i = 0; i < animations.length; ++i) { + var animation = animations[i]; + var element = null; + var start = null; + var current = null; + var end = null; + for (key in animation) { + if (key === "element") + element = animation[key]; + else if (key === "start") + start = animation[key]; + else if (key === "current") + current = animation[key]; + else if (key === "end") + end = animation[key]; + } + + if (!element || !end) + continue; + + var computedStyle = element.ownerDocument.defaultView.getComputedStyle(element); + if (!start) { + start = {}; + for (key in end) + start[key] = parseInt(computedStyle.getPropertyValue(key)); + animation.start = start; + } else if (complete == 0) + for (key in start) + element.style.setProperty(key, start[key] + (key in propertyUnit ? propertyUnit[key] : defaultUnit)); + + if (!current) { + current = {}; + for (key in start) + current[key] = start[key]; + animation.current = current; + } + + function cubicInOut(t, b, c, d) + { + if ((t/=d/2) < 1) return c/2*t*t*t + b; + return c/2*((t-=2)*t*t + 2) + b; + } + + var style = element.style; + for (key in end) { + var startValue = start[key]; + var currentValue = current[key]; + var endValue = end[key]; + if ((complete + slice) < duration) { + var delta = (endValue - startValue) / (duration / slice); + var newValue = cubicInOut(complete, startValue, endValue - startValue, duration); + style.setProperty(key, newValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit)); + current[key] = newValue; + } else { + style.setProperty(key, endValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit)); + } + } + } + + if (complete < duration) + setTimeout(WebInspector.animateStyle, slice, animations, duration, callback, complete + slice); + else if (callback) + callback(); +} + +WebInspector.toggleAttach = function() +{ + this.attached = !this.attached; +} + +WebInspector.toolbarDragStart = function(event) +{ + if (WebInspector.attached) + return; + + var target = event.target; + if (target.hasStyleClass("toolbar-item") && target.hasStyleClass("toggleable")) + return; + + var toolbar = document.getElementById("toolbar"); + if (target !== toolbar && !target.hasStyleClass("toolbar-item")) + return; + + toolbar.lastScreenX = event.screenX; + toolbar.lastScreenY = event.screenY; + + document.addEventListener("mousemove", WebInspector.toolbarDrag, true); + document.addEventListener("mouseup", WebInspector.toolbarDragEnd, true); + document.body.style.cursor = "default"; + + event.preventDefault(); +} + +WebInspector.toolbarDragEnd = function(event) +{ + var toolbar = document.getElementById("toolbar"); + delete toolbar.lastScreenX; + delete toolbar.lastScreenY; + + document.removeEventListener("mousemove", WebInspector.toolbarDrag, true); + document.removeEventListener("mouseup", WebInspector.toolbarDragEnd, true); + document.body.style.removeProperty("cursor"); + + event.preventDefault(); +} + +WebInspector.toolbarDrag = function(event) +{ + var toolbar = document.getElementById("toolbar"); + + var x = event.screenX - toolbar.lastScreenX; + var y = event.screenY - toolbar.lastScreenY; + + toolbar.lastScreenX = event.screenX; + toolbar.lastScreenY = event.screenY; + + // We cannot call window.moveBy here because it restricts the movement of the window + // at the edges. + InspectorController.moveByUnrestricted(x, y); + + event.preventDefault(); +} + +WebInspector.searchResultsResizerDragStart = function(event) +{ + WebInspector.elementDragStart(document.getElementById("searchResults"), WebInspector.searchResultsResizerDrag, WebInspector.searchResultsResizerDragEnd, event, "row-resize"); +} + +WebInspector.searchResultsResizerDragEnd = function(event) +{ + WebInspector.elementDragEnd(event); +} + +WebInspector.searchResultsResizerDrag = function(event) +{ + var y = event.pageY - document.getElementById("main").offsetTop; + var newHeight = Number.constrain(y, 100, window.innerHeight - 100); + + WebInspector.searchResultsHeight = newHeight; + + document.getElementById("searchResults").style.height = WebInspector.searchResultsHeight + "px"; + document.getElementById("main-panels").style.top = newHeight + "px"; + document.getElementById("searchResultsResizer").style.top = (newHeight - 3) + "px"; + + event.preventDefault(); +} + +WebInspector.elementDragStart = function(element, dividerDrag, elementDragEnd, event, cursor) +{ + if (this._elementDraggingEventListener || this._elementEndDraggingEventListener) + this.elementDragEnd(event); + + this._elementDraggingEventListener = dividerDrag; + this._elementEndDraggingEventListener = elementDragEnd; + + document.addEventListener("mousemove", dividerDrag, true); + document.addEventListener("mouseup", elementDragEnd, true); + + document.body.style.cursor = cursor; + + event.preventDefault(); +} + +WebInspector.elementDragEnd = function(event) +{ + document.removeEventListener("mousemove", this._elementDraggingEventListener, true); + document.removeEventListener("mouseup", this._elementEndDraggingEventListener, true); + + document.body.style.removeProperty("cursor"); + + delete this._elementDraggingEventListener; + delete this._elementEndDraggingEventListener; + + event.preventDefault(); +} + +WebInspector.showConsole = function() +{ + this.console.show(); +} + +WebInspector.showTimeline = function() +{ + this.currentPanel = this.panels.resources; +} + +WebInspector.addResource = function(resource) +{ + this.resources.push(resource); + this.resourceURLMap[resource.url] = resource; + + if (resource.mainResource) { + this.mainResource = resource; + this.panels.elements.reset(); + } + + this.panels.resources.addResource(resource); +} + +WebInspector.removeResource = function(resource) +{ + resource.category.removeResource(resource); + delete this.resourceURLMap[resource.url]; + + var resourcesLength = this.resources.length; + for (var i = 0; i < resourcesLength; ++i) { + if (this.resources[i] === resource) { + this.resources.splice(i, 1); + break; + } + } + + this.panels.resources.removeResource(resource); +} + +WebInspector.addDatabase = function(database) +{ + if (this.panels.databases) + this.panels.databases.addDatabase(database); +} + +WebInspector.reset = function() +{ + for (var panelName in this.panels) { + var panel = this.panels[panelName]; + if ("reset" in panel) + panel.reset(); + } + + for (var category in this.resourceCategories) + this.resourceCategories[category].removeAllResources(); + + this.resources = []; + this.resourceURLMap = {}; + + delete this.mainResource; + + this.console.clearMessages(); +} + +WebInspector.resourceURLChanged = function(resource, oldURL) +{ + delete this.resourceURLMap[oldURL]; + this.resourceURLMap[resource.url] = resource; +} + +WebInspector.addMessageToConsole = function(msg) +{ + this.console.addMessage(msg); +} + +WebInspector.drawLoadingPieChart = function(canvas, percent) { + var g = canvas.getContext("2d"); + var darkColor = "rgb(122, 168, 218)"; + var lightColor = "rgb(228, 241, 251)"; + var cx = 8; + var cy = 8; + var r = 7; + + g.beginPath(); + g.arc(cx, cy, r, 0, Math.PI * 2, false); + g.closePath(); + + g.lineWidth = 1; + g.strokeStyle = darkColor; + g.fillStyle = lightColor; + g.fill(); + g.stroke(); + + var startangle = -Math.PI / 2; + var endangle = startangle + (percent * Math.PI * 2); + + g.beginPath(); + g.moveTo(cx, cy); + g.arc(cx, cy, r, startangle, endangle, false); + g.closePath(); + + g.fillStyle = darkColor; + g.fill(); +} + +WebInspector.updateFocusedNode = function(node) +{ + if (!node) + // FIXME: Should we deselect if null is passed in? + return; + + this.currentPanel = this.panels.elements; + this.panels.elements.focusedDOMNode = node; +} + +WebInspector.resourceForURL = function(url) +{ + for (var resourceURL in this.resourceURLMap) { + if (resourceURL.hasSubstring(url)) + return this.resourceURLMap[resourceURL]; + } + + return null; +} + +WebInspector.showResourceForURL = function(url, line) +{ + var resource = this.resourceForURL(url); + if (!resource) + return false; + + this.currentPanel = this.panels.resources; + this.panels.resources.showResource(resource, line); + return true; +} + +WebInspector.linkifyURL = function(url, linkText, classes, isExternal) +{ + if (linkText === undefined) + linkText = url.escapeHTML(); + classes = (classes === undefined) ? "" : classes + " "; + classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource-link"; + var link = "<a href=\"" + url + "\" class=\"" + classes + "\" title=\"" + url + "\" target=\"_blank\">" + linkText + "</a>"; + return link; +} + +WebInspector.addMainEventListeners = function(doc) +{ + doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), true); + doc.defaultView.addEventListener("blur", this.windowBlured.bind(this), true); + doc.addEventListener("click", this.documentClick.bind(this), true); +} + +WebInspector.performSearch = function(query) +{ + if (!query || !query.length) { + this.showingSearchResults = false; + return; + } + + var resultsContainer = document.getElementById("searchResults"); + resultsContainer.removeChildren(); + + var isXPath = query.indexOf("/") !== -1; + + var xpathQuery; + if (isXPath) + xpathQuery = query; + else { + var escapedQuery = query.escapeCharacters("'"); + xpathQuery = "//*[contains(name(),'" + escapedQuery + "') or contains(@*,'" + escapedQuery + "')] | //text()[contains(.,'" + escapedQuery + "')] | //comment()[contains(.,'" + escapedQuery + "')]"; + } + + var resourcesToSearch = [].concat(this.resourceCategories.documents.resources, this.resourceCategories.stylesheets.resources, this.resourceCategories.scripts.resources, this.resourceCategories.other.resources); + + var files = []; + for (var i = 0; i < resourcesToSearch.length; ++i) { + var resource = resourcesToSearch[i]; + + var sourceResults = []; + if (!isXPath) { + var sourceFrame = this.panels.resources.sourceFrameForResource(resource); + if (sourceFrame) + sourceResults = InspectorController.search(sourceFrame.contentDocument, query); + } + + var domResults = []; + const searchResultsProperty = "__includedInInspectorSearchResults"; + function addNodesToDOMResults(nodes, length, getItem) + { + for (var i = 0; i < length; ++i) { + var node = getItem(nodes, i); + if (searchResultsProperty in node) + continue; + node[searchResultsProperty] = true; + domResults.push(node); + } + } + + function cleanUpDOMResultsNodes() + { + for (var i = 0; i < domResults.length; ++i) + delete domResults[i][searchResultsProperty]; + } + + if (resource.category === this.resourceCategories.documents) { + var doc = resource.documentNode; + try { + var result = InspectorController.inspectedWindow().Document.prototype.evaluate.call(doc, xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE); + addNodesToDOMResults(result, result.snapshotLength, function(l, i) { return l.snapshotItem(i); }); + } catch(err) { + // ignore any exceptions. the query might be malformed, but we allow that. + } + + var result = InspectorController.inspectedWindow().Document.prototype.querySelectorAll.call(doc, query); + addNodesToDOMResults(result, result.length, function(l, i) { return l.item(i); }); + + cleanUpDOMResultsNodes(); + } + + if ((!sourceResults || !sourceResults.length) && !domResults.length) + continue; + + files.push({resource: resource, sourceResults: sourceResults, domResults: domResults}); + } + + if (!files.length) + return; + + this.showingSearchResults = true; + + var fileList = document.createElement("ol"); + fileList.className = "outline-disclosure"; + resultsContainer.appendChild(fileList); + + this.searchResultsTree = new TreeOutline(fileList); + this.searchResultsTree.expandTreeElementsWhenArrowing = true; + + var sourceResultSelected = function(element) + { + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(element.representedObject.range); + + var oldFocusElement = this.currentFocusElement; + this.currentPanel = this.panels.resources; + this.currentFocusElement = oldFocusElement; + + this.panels.resources.showResource(element.representedObject.resource); + + element.representedObject.line.scrollIntoViewIfNeeded(true); + element.listItemElement.scrollIntoViewIfNeeded(false); + } + + var domResultSelected = function(element) + { + var oldFocusElement = this.currentFocusElement; + this.currentPanel = this.panels.elements; + this.currentFocusElement = oldFocusElement; + + this.panels.elements.focusedDOMNode = element.representedObject.node; + element.listItemElement.scrollIntoViewIfNeeded(false); + } + + for (var i = 0; i < files.length; ++i) { + var file = files[i]; + + var fileItem = new TreeElement(file.resource.displayName, {}, true); + fileItem.expanded = true; + fileItem.selectable = false; + this.searchResultsTree.appendChild(fileItem); + + if (file.sourceResults && file.sourceResults.length) { + for (var j = 0; j < file.sourceResults.length; ++j) { + var range = file.sourceResults[j]; + var sourceDocument = range.startContainer.ownerDocument; + + var line = range.startContainer; + while (line.parentNode && line.nodeName.toLowerCase() != "tr") + line = line.parentNode; + var lineRange = sourceDocument.createRange(); + lineRange.selectNodeContents(line); + + // Don't include any error bubbles in the search result + var end = line.lastChild.lastChild; + if (end.nodeName.toLowerCase() == "div" && end.hasStyleClass("webkit-html-message-bubble")) { + while (end && end.nodeName.toLowerCase() == "div" && end.hasStyleClass("webkit-html-message-bubble")) + end = end.previousSibling; + lineRange.setEndAfter(end); + } + + var beforeRange = sourceDocument.createRange(); + beforeRange.setStart(lineRange.startContainer, lineRange.startOffset); + beforeRange.setEnd(range.startContainer, range.startOffset); + + var afterRange = sourceDocument.createRange(); + afterRange.setStart(range.endContainer, range.endOffset); + afterRange.setEnd(lineRange.endContainer, lineRange.endOffset); + + var beforeText = beforeRange.toString().trimLeadingWhitespace(); + var text = range.toString(); + var afterText = afterRange.toString().trimTrailingWhitespace(); + + var length = beforeText.length + text.length + afterText.length; + if (length > Preferences.maxTextSearchResultLength) { + var beforeAfterLength = (Preferences.maxTextSearchResultLength - text.length) / 2; + if (beforeText.length > beforeAfterLength) + beforeText = "\u2026" + beforeText.substr(-beforeAfterLength); + if (afterText.length > beforeAfterLength) + afterText = afterText.substr(0, beforeAfterLength) + "\u2026"; + } + + var title = "<div class=\"selection selected\"></div>"; + if (j == 0) + title += "<div class=\"search-results-section\">" + WebInspector.UIString("Source") + "</div>"; + title += beforeText.escapeHTML() + "<span class=\"search-matched-string\">" + text.escapeHTML() + "</span>" + afterText.escapeHTML(); + var item = new TreeElement(title, {resource: file.resource, line: line, range: range}, false); + item.onselect = sourceResultSelected.bind(this); + fileItem.appendChild(item); + } + } + + if (file.domResults.length) { + for (var j = 0; j < file.domResults.length; ++j) { + var node = file.domResults[j]; + var title = "<div class=\"selection selected\"></div>"; + if (j == 0) + title += "<div class=\"search-results-section\">" + WebInspector.UIString("DOM") + "</div>"; + title += nodeTitleInfo.call(node).title; + var item = new TreeElement(title, {resource: file.resource, node: node}, false); + item.onselect = domResultSelected.bind(this); + fileItem.appendChild(item); + } + } + } +} + +WebInspector.UIString = function(string) +{ + if (string in this.localizedStrings) + string = this.localizedStrings[string]; + else { + if (!(string in this.missingLocalizedStrings)) { + console.error("Localized string \"" + string + "\" not found."); + this.missingLocalizedStrings[string] = true; + } + + if (Preferences.showMissingLocalizedStrings) + string += " (not localized)"; + } + + return String.vsprintf(string, Array.prototype.slice.call(arguments, 1)); +} + +WebInspector.isBeingEdited = function(element) +{ + return element.__editing; +} + +WebInspector.startEditing = function(element, committedCallback, cancelledCallback, context) +{ + if (element.__editing) + return; + element.__editing = true; + + var oldText = element.textContent; + var handleKeyEvent = element.handleKeyEvent; + var blurred = element.blurred; + + element.addStyleClass("editing"); + element.addStyleClass("focusable"); + + var previousFocusElement = WebInspector.currentFocusElement; + + function cleanUpAfterEditing() { + delete this.__editing; + + this.removeStyleClass("editing"); + this.removeStyleClass("focusable"); + + this.handleKeyEvent = handleKeyEvent; + this.blurred = blurred; + + WebInspector.currentFocusElement = previousFocusElement; + } + + function editingCancelled() { + this.innerText = oldText; + + cleanUpAfterEditing.call(this); + + cancelledCallback(this, context); + } + + function editingCommitted() { + cleanUpAfterEditing.call(this); + + committedCallback(this, this.textContent, oldText, context); + } + + element.handleKeyEvent = function(event) { + if (event.keyIdentifier === "Enter") { + editingCommitted.call(element); + event.preventDefault(); + } else if (event.keyCode === 27) { // Escape key + editingCancelled.call(element); + event.preventDefault(); + event.handled = true; + } + } + + element.blurred = function() { editingCancelled.call(element); } + + WebInspector.currentFocusElement = element; +} + +WebInspector._toolbarItemClicked = function(event) +{ + var toolbarItem = event.currentTarget; + this.currentPanel = toolbarItem.panel; +} + +// This table maps MIME types to the Resource.Types which are valid for them. +// The following line: +// "text/html": {0: 1}, +// means that text/html is a valid MIME type for resources that have type +// WebInspector.Resource.Type.Document (which has a value of 0). +WebInspector.MIMETypes = { + "text/html": {0: true}, + "text/xml": {0: true}, + "text/plain": {0: true}, + "application/xhtml+xml": {0: true}, + "text/css": {1: true}, + "text/xsl": {1: true}, + "image/jpeg": {2: true}, + "image/png": {2: true}, + "image/gif": {2: true}, + "image/bmp": {2: true}, + "image/x-icon": {2: true}, + "image/x-xbitmap": {2: true}, + "font/ttf": {3: true}, + "font/opentype": {3: true}, + "application/x-font-type1": {3: true}, + "application/x-font-ttf": {3: true}, + "application/x-truetype-font": {3: true}, + "text/javascript": {4: true}, + "text/ecmascript": {4: true}, + "application/javascript": {4: true}, + "application/ecmascript": {4: true}, + "application/x-javascript": {4: true}, + "text/javascript1.1": {4: true}, + "text/javascript1.2": {4: true}, + "text/javascript1.3": {4: true}, + "text/jscript": {4: true}, + "text/livescript": {4: true}, +} + +/** + * This is used to keep track of the timer that is being used to highlight a + * node. + * @type {number} + * @private + */ +WebInspector._showTimerId = 0; + +/** + * Whether we are currently highlighting any node at the moment. + * @type {boolean} + * @private + */ +WebInspector._highlightIsShown = false; + +/** + * The time to wait before showing the highlighting of a node. + * @type {number} + */ +WebInspector._showHighlightDelayMs = 300; + +/** + * Highlights the given node after a short timeout. If there is already a shown + * node then the current node is highlighted immediately. + * @param {Node} node The node to highlight. + */ +WebInspector.highlightDOMNode = function(node) { + if (this._highlightIsShown) { + InspectorController.highlightDOMNode(node); + } else { + if (this._showTimerId) { + clearTimeout(this._showTimerId); + } + this._showTimerId = setTimeout((function() { + InspectorController.highlightDOMNode(node); + this._highlightIsShown = true; + }).bind(this), this._showHighlightDelayMs); + } +}; + +/** + * Removes the highlight of the current node. + */ +WebInspector.hideDOMNodeHighlight = function() +{ + if (this._highlightIsShown) { + InspectorController.hideDOMNodeHighlight(); + this._highlightIsShown = false; + } + if (this._showTimerId) { + clearTimeout(this._showTimerId); + } +}; diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/quirks-overrides.css b/chrome/tools/test/reference_build/chrome/resources/Inspector/quirks-overrides.css new file mode 100644 index 0000000..b0300ee --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/quirks-overrides.css @@ -0,0 +1,12 @@ +/* Copyright 2008 Google Inc. All Rights Reserved. */ +/* Author: ojan@google.com (Ojan Vafai) */ + +/* These styles override the default styling for HTML elements in quirks-mode + as defined in WebCore/css/quirks.css. So far we have used this file exclusively for + making our form elements match Firefoxes. If we find other needs for this + file we should seriously consider if this is the right place of them. */ + +textarea { + /* Matches IE's text offsets in quirksmode (causes text to wrap the same as IE). */ + padding: 2px 0 0 2px; +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/treeoutline.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/treeoutline.js new file mode 100644 index 0000000..1248055 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/treeoutline.js @@ -0,0 +1,756 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +function TreeOutline(listNode) +{ + this.children = []; + this.selectedTreeElement = null; + this._childrenListNode = listNode; + this._childrenListNode.removeChildren(); + this._knownTreeElements = []; + this._treeElementsExpandedState = []; + this.expandTreeElementsWhenArrowing = false; + this.root = true; + this.hasChildren = false; + this.expanded = true; + this.selected = false; + this.treeOutline = this; +} + +TreeOutline._knownTreeElementNextIdentifier = 1; + +TreeOutline._appendChild = function(child) +{ + if (!child) + throw("child can't be undefined or null"); + + var lastChild = this.children[this.children.length - 1]; + if (lastChild) { + lastChild.nextSibling = child; + child.previousSibling = lastChild; + } else { + child.previousSibling = null; + child.nextSibling = null; + } + + this.children.push(child); + this.hasChildren = true; + child.parent = this; + child.treeOutline = this.treeOutline; + child.treeOutline._rememberTreeElement(child); + + var current = child.children[0]; + while (current) { + current.treeOutline = this.treeOutline; + current.treeOutline._rememberTreeElement(current); + current = current.traverseNextTreeElement(false, child, true); + } + + if (child.hasChildren && child.treeOutline._treeElementsExpandedState[child.identifier] !== undefined) + child.expanded = child.treeOutline._treeElementsExpandedState[child.identifier]; + + if (!this._childrenListNode) { + this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol"); + this._childrenListNode.parentTreeElement = this; + this._childrenListNode.addStyleClass("children"); + if (this.hidden) + this._childrenListNode.addStyleClass("hidden"); + } + + child._attach(); +} + +TreeOutline._insertChild = function(child, index) +{ + if (!child) + throw("child can't be undefined or null"); + + var previousChild = (index > 0 ? this.children[index - 1] : null); + if (previousChild) { + previousChild.nextSibling = child; + child.previousSibling = previousChild; + } else { + child.previousSibling = null; + } + + var nextChild = this.children[index]; + if (nextChild) { + nextChild.previousSibling = child; + child.nextSibling = nextChild; + } else { + child.nextSibling = null; + } + + this.children.splice(index, 0, child); + this.hasChildren = true; + child.parent = this; + child.treeOutline = this.treeOutline; + child.treeOutline._rememberTreeElement(child); + + var current = child.children[0]; + while (current) { + current.treeOutline = this.treeOutline; + current.treeOutline._rememberTreeElement(current); + current = current.traverseNextTreeElement(false, child, true); + } + + if (child.hasChildren && child.treeOutline._treeElementsExpandedState[child.identifier] !== undefined) + child.expanded = child.treeOutline._treeElementsExpandedState[child.identifier]; + + if (!this._childrenListNode) { + this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol"); + this._childrenListNode.parentTreeElement = this; + this._childrenListNode.addStyleClass("children"); + if (this.hidden) + this._childrenListNode.addStyleClass("hidden"); + } + + child._attach(); +} + +TreeOutline._removeChild = function(child) +{ + if (!child) + throw("child can't be undefined or null"); + + for (var i = 0; i < this.children.length; ++i) { + if (this.children[i] === child) { + this.children.splice(i, 1); + break; + } + } + + child.deselect(); + + if (child.previousSibling) + child.previousSibling.nextSibling = child.nextSibling; + if (child.nextSibling) + child.nextSibling.previousSibling = child.previousSibling; + + if (child.treeOutline) + child.treeOutline._forgetTreeElement(child); + child._detach(); + child.treeOutline = null; + child.parent = null; + child.nextSibling = null; + child.previousSibling = null; +} + +TreeOutline._removeChildren = function() +{ + for (var i = 0; i < this.children.length; ++i) { + var child = this.children[i]; + child.deselect(); + if (child.treeOutline) + child.treeOutline._forgetTreeElement(child); + child._detach(); + child.treeOutline = null; + child.parent = null; + child.nextSibling = null; + child.previousSibling = null; + } + + this.children = []; + + if (this._childrenListNode) + this._childrenListNode.offsetTop; // force layout +} + +TreeOutline._removeChildrenRecursive = function() +{ + var childrenToRemove = this.children; + + var child = this.children[0]; + while (child) { + if (child.children.length) + childrenToRemove = childrenToRemove.concat(child.children); + child = child.traverseNextTreeElement(false, this, true); + } + + for (var i = 0; i < childrenToRemove.length; ++i) { + var child = childrenToRemove[i]; + child.deselect(); + if (child.treeOutline) + child.treeOutline._forgetTreeElement(child); + child._detach(); + child.children = []; + child.treeOutline = null; + child.parent = null; + child.nextSibling = null; + child.previousSibling = null; + } + + this.children = []; +} + +TreeOutline.prototype._rememberTreeElement = function(element) +{ + if (!this._knownTreeElements[element.identifier]) + this._knownTreeElements[element.identifier] = []; + + // check if the element is already known + var elements = this._knownTreeElements[element.identifier]; + for (var i = 0; i < elements.length; ++i) + if (elements[i] === element) + return; + + // add the element + elements.push(element); +} + +TreeOutline.prototype._forgetTreeElement = function(element) +{ + if (!this._knownTreeElements[element.identifier]) + return; + + var elements = this._knownTreeElements[element.identifier]; + for (var i = 0; i < elements.length; ++i) { + if (elements[i] === element) { + elements.splice(i, 1); + break; + } + } +} + +TreeOutline.prototype.findTreeElement = function(representedObject, isAncestor, getParent) +{ + if (!representedObject) + return null; + + if ("__treeElementIdentifier" in representedObject) { + var elements = this._knownTreeElements[representedObject.__treeElementIdentifier]; + if (elements) { + for (var i = 0; i < elements.length; ++i) + if (elements[i].representedObject === representedObject) + return elements[i]; + } + } + + if (!isAncestor || !(isAncestor instanceof Function) || !getParent || !(getParent instanceof Function)) + return null; + + var item; + var found = false; + for (var i = 0; i < this.children.length; ++i) { + item = this.children[i]; + if (item.representedObject === representedObject || isAncestor(item.representedObject, representedObject)) { + found = true; + break; + } + } + + if (!found) + return null; + + var ancestors = []; + var currentObject = representedObject; + while (currentObject) { + ancestors.unshift(currentObject); + if (currentObject === item.representedObject) + break; + currentObject = getParent(currentObject); + } + + for (var i = 0; i < ancestors.length; ++i) { + item = this.findTreeElement(ancestors[i], isAncestor, getParent); + if (ancestors[i] !== representedObject && item && item.onpopulate) + item.onpopulate(item); + } + + return item; +} + +TreeOutline.prototype.treeElementFromPoint = function(x, y) +{ + var node = this._childrenListNode.ownerDocument.elementFromPoint(x, y); + var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"]); + if (listNode) + return listNode.parentTreeElement || listNode.treeElement; + return null; +} + +TreeOutline.prototype.handleKeyEvent = function(event) +{ + if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ctrlKey) + return false; + + var handled = false; + var nextSelectedElement; + if (event.keyIdentifier === "Up" && !event.altKey) { + nextSelectedElement = this.selectedTreeElement.traversePreviousTreeElement(true); + while (nextSelectedElement && !nextSelectedElement.selectable) + nextSelectedElement = nextSelectedElement.traversePreviousTreeElement(!this.expandTreeElementsWhenArrowing); + handled = nextSelectedElement ? true : false; + } else if (event.keyIdentifier === "Down" && !event.altKey) { + nextSelectedElement = this.selectedTreeElement.traverseNextTreeElement(true); + while (nextSelectedElement && !nextSelectedElement.selectable) + nextSelectedElement = nextSelectedElement.traverseNextTreeElement(!this.expandTreeElementsWhenArrowing); + handled = nextSelectedElement ? true : false; + } else if (event.keyIdentifier === "Left") { + if (this.selectedTreeElement.expanded) { + if (event.altKey) + this.selectedTreeElement.collapseRecursively(); + else + this.selectedTreeElement.collapse(); + handled = true; + } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.parent.root) { + handled = true; + if (this.selectedTreeElement.parent.selectable) { + nextSelectedElement = this.selectedTreeElement.parent; + handled = nextSelectedElement ? true : false; + } else if (this.selectedTreeElement.parent) + this.selectedTreeElement.parent.collapse(); + } + } else if (event.keyIdentifier === "Right") { + if (!this.selectedTreeElement.revealed()) { + this.selectedTreeElement.reveal(); + handled = true; + } else if (this.selectedTreeElement.hasChildren) { + handled = true; + if (this.selectedTreeElement.expanded) { + nextSelectedElement = this.selectedTreeElement.children[0]; + handled = nextSelectedElement ? true : false; + } else { + if (event.altKey) + this.selectedTreeElement.expandRecursively(); + else + this.selectedTreeElement.expand(); + } + } + } + + if (nextSelectedElement) { + nextSelectedElement.reveal(); + nextSelectedElement.select(); + } + + if (handled) { + event.preventDefault(); + event.stopPropagation(); + } + + return handled; +} + +TreeOutline.prototype.expand = function() +{ + // this is the root, do nothing +} + +TreeOutline.prototype.collapse = function() +{ + // this is the root, do nothing +} + +TreeOutline.prototype.revealed = function() +{ + return true; +} + +TreeOutline.prototype.reveal = function() +{ + // this is the root, do nothing +} + +TreeOutline.prototype.appendChild = TreeOutline._appendChild; +TreeOutline.prototype.insertChild = TreeOutline._insertChild; +TreeOutline.prototype.removeChild = TreeOutline._removeChild; +TreeOutline.prototype.removeChildren = TreeOutline._removeChildren; +TreeOutline.prototype.removeChildrenRecursive = TreeOutline._removeChildrenRecursive; + +function TreeElement(title, representedObject, hasChildren) +{ + this._title = title; + this.representedObject = (representedObject || {}); + + if (this.representedObject.__treeElementIdentifier) + this.identifier = this.representedObject.__treeElementIdentifier; + else { + this.identifier = TreeOutline._knownTreeElementNextIdentifier++; + this.representedObject.__treeElementIdentifier = this.identifier; + } + + this._hidden = false; + this.expanded = false; + this.selected = false; + this.hasChildren = hasChildren; + this.children = []; + this.treeOutline = null; + this.parent = null; + this.previousSibling = null; + this.nextSibling = null; + this._listItemNode = null; +} + +TreeElement.prototype = { + selectable: true, + arrowToggleWidth: 10, + + get listItemElement() { + return this._listItemNode; + }, + + get childrenListElement() { + return this._childrenListNode; + }, + + get title() { + return this._title; + }, + + set title(x) { + this._title = x; + if (this._listItemNode) + this._listItemNode.innerHTML = x; + }, + + get tooltip() { + return this._tooltip; + }, + + set tooltip(x) { + this._tooltip = x; + if (this._listItemNode) + this._listItemNode.title = x ? x : ""; + }, + + get hidden() { + return this._hidden; + }, + + set hidden(x) { + if (this._hidden === x) + return; + + this._hidden = x; + + if (x) { + if (this._listItemNode) + this._listItemNode.addStyleClass("hidden"); + if (this._childrenListNode) + this._childrenListNode.addStyleClass("hidden"); + } else { + if (this._listItemNode) + this._listItemNode.removeStyleClass("hidden"); + if (this._childrenListNode) + this._childrenListNode.removeStyleClass("hidden"); + } + }, + + get shouldRefreshChildren() { + return this._shouldRefreshChildren; + }, + + set shouldRefreshChildren(x) { + this._shouldRefreshChildren = x; + if (x && this.expanded) + this.expand(); + } +} + +TreeElement.prototype.appendChild = TreeOutline._appendChild; +TreeElement.prototype.insertChild = TreeOutline._insertChild; +TreeElement.prototype.removeChild = TreeOutline._removeChild; +TreeElement.prototype.removeChildren = TreeOutline._removeChildren; +TreeElement.prototype.removeChildrenRecursive = TreeOutline._removeChildrenRecursive; + +TreeElement.prototype._attach = function() +{ + if (!this._listItemNode || this.parent._shouldRefreshChildren) { + if (this._listItemNode && this._listItemNode.parentNode) + this._listItemNode.parentNode.removeChild(this._listItemNode); + + this._listItemNode = this.treeOutline._childrenListNode.ownerDocument.createElement("li"); + this._listItemNode.treeElement = this; + this._listItemNode.innerHTML = this._title; + this._listItemNode.title = this._tooltip ? this._tooltip : ""; + + if (this.hidden) + this._listItemNode.addStyleClass("hidden"); + if (this.hasChildren) + this._listItemNode.addStyleClass("parent"); + if (this.expanded) + this._listItemNode.addStyleClass("expanded"); + if (this.selected) + this._listItemNode.addStyleClass("selected"); + + this._listItemNode.addEventListener("mousedown", TreeElement.treeElementSelected, false); + this._listItemNode.addEventListener("click", TreeElement.treeElementToggled, false); + this._listItemNode.addEventListener("dblclick", TreeElement.treeElementDoubleClicked, false); + + if (this.onattach) + this.onattach(this); + } + + this.parent._childrenListNode.insertBefore(this._listItemNode, (this.nextSibling ? this.nextSibling._listItemNode : null)); + if (this._childrenListNode) + this.parent._childrenListNode.insertBefore(this._childrenListNode, this._listItemNode.nextSibling); + if (this.selected) + this.select(); + if (this.expanded) + this.expand(); +} + +TreeElement.prototype._detach = function() +{ + if (this._listItemNode && this._listItemNode.parentNode) + this._listItemNode.parentNode.removeChild(this._listItemNode); + if (this._childrenListNode && this._childrenListNode.parentNode) + this._childrenListNode.parentNode.removeChild(this._childrenListNode); +} + +TreeElement.treeElementSelected = function(event) +{ + var element = event.currentTarget; + if (!element || !element.treeElement || !element.treeElement.selectable) + return; + + if (element.treeElement.isEventWithinDisclosureTriangle(event)) + return; + + element.treeElement.select(); +} + +TreeElement.treeElementToggled = function(event) +{ + var element = event.currentTarget; + if (!element || !element.treeElement) + return; + + if (!element.treeElement.isEventWithinDisclosureTriangle(event)) + return; + + if (element.treeElement.expanded) { + if (event.altKey) + element.treeElement.collapseRecursively(); + else + element.treeElement.collapse(); + } else { + if (event.altKey) + element.treeElement.expandRecursively(); + else + element.treeElement.expand(); + } +} + +TreeElement.treeElementDoubleClicked = function(event) +{ + var element = event.currentTarget; + if (!element || !element.treeElement) + return; + + if (element.treeElement.ondblclick) + element.treeElement.ondblclick(element.treeElement, event); + else if (element.treeElement.hasChildren && !element.treeElement.expanded) + element.treeElement.expand(); +} + +TreeElement.prototype.collapse = function() +{ + if (this._listItemNode) + this._listItemNode.removeStyleClass("expanded"); + if (this._childrenListNode) + this._childrenListNode.removeStyleClass("expanded"); + + this.expanded = false; + if (this.treeOutline) + this.treeOutline._treeElementsExpandedState[this.identifier] = true; + + if (this.oncollapse) + this.oncollapse(this); +} + +TreeElement.prototype.collapseRecursively = function() +{ + var item = this; + while (item) { + if (item.expanded) + item.collapse(); + item = item.traverseNextTreeElement(false, this, true); + } +} + +TreeElement.prototype.expand = function() +{ + if (!this.hasChildren || (this.expanded && !this._shouldRefreshChildren && this._childrenListNode)) + return; + + if (!this._childrenListNode || this._shouldRefreshChildren) { + if (this._childrenListNode && this._childrenListNode.parentNode) + this._childrenListNode.parentNode.removeChild(this._childrenListNode); + + this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol"); + this._childrenListNode.parentTreeElement = this; + this._childrenListNode.addStyleClass("children"); + + if (this.hidden) + this._childrenListNode.addStyleClass("hidden"); + + if (this.onpopulate) + this.onpopulate(this); + + for (var i = 0; i < this.children.length; ++i) + this.children[i]._attach(); + + delete this._shouldRefreshChildren; + } + + if (this._listItemNode) { + this._listItemNode.addStyleClass("expanded"); + if (this._childrenListNode.parentNode != this._listItemNode.parentNode) + this.parent._childrenListNode.insertBefore(this._childrenListNode, this._listItemNode.nextSibling); + } + + if (this._childrenListNode) + this._childrenListNode.addStyleClass("expanded"); + + this.expanded = true; + if (this.treeOutline) + this.treeOutline._treeElementsExpandedState[this.identifier] = true; + + if (this.onexpand) + this.onexpand(this); +} + +TreeElement.prototype.expandRecursively = function() +{ + var item = this; + while (item) { + item.expand(); + item = item.traverseNextTreeElement(false, this); + } +} + +TreeElement.prototype.reveal = function() +{ + var currentAncestor = this.parent; + while (currentAncestor && !currentAncestor.root) { + if (!currentAncestor.expanded) + currentAncestor.expand(); + currentAncestor = currentAncestor.parent; + } + + if (this.onreveal) + this.onreveal(this); +} + +TreeElement.prototype.revealed = function() +{ + var currentAncestor = this.parent; + while (currentAncestor && !currentAncestor.root) { + if (!currentAncestor.expanded) + return false; + currentAncestor = currentAncestor.parent; + } + + return true; +} + +TreeElement.prototype.select = function(supressOnSelect) +{ + if (!this.treeOutline || !this.selectable || this.selected) + return; + + if (this.treeOutline.selectedTreeElement) + this.treeOutline.selectedTreeElement.deselect(); + + this.selected = true; + this.treeOutline.selectedTreeElement = this; + if (this._listItemNode) + this._listItemNode.addStyleClass("selected"); + + if (this.onselect && !supressOnSelect) + this.onselect(this); +} + +TreeElement.prototype.deselect = function(supressOnDeselect) +{ + if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !this.selected) + return; + + this.selected = false; + this.treeOutline.selectedTreeElement = null; + if (this._listItemNode) + this._listItemNode.removeStyleClass("selected"); + + if (this.ondeselect && !supressOnDeselect) + this.ondeselect(this); +} + +TreeElement.prototype.traverseNextTreeElement = function(skipHidden, stayWithin, dontPopulate) +{ + if (!dontPopulate && this.hasChildren && this.onpopulate) + this.onpopulate(this); + + var element = skipHidden ? (this.revealed() ? this.children[0] : null) : this.children[0]; + if (element && (!skipHidden || (skipHidden && this.expanded))) + return element; + + if (this === stayWithin) + return null; + + element = skipHidden ? (this.revealed() ? this.nextSibling : null) : this.nextSibling; + if (element) + return element; + + element = this; + while (element && !element.root && !(skipHidden ? (element.revealed() ? element.nextSibling : null) : element.nextSibling) && element.parent !== stayWithin) + element = element.parent; + + if (!element) + return null; + + return (skipHidden ? (element.revealed() ? element.nextSibling : null) : element.nextSibling); +} + +TreeElement.prototype.traversePreviousTreeElement = function(skipHidden, dontPopulate) +{ + var element = skipHidden ? (this.revealed() ? this.previousSibling : null) : this.previousSibling; + if (!dontPopulate && element && element.hasChildren && element.onpopulate) + element.onpopulate(element); + + while (element && (skipHidden ? (element.revealed() && element.expanded ? element.children[element.children.length - 1] : null) : element.children[element.children.length - 1])) { + if (!dontPopulate && element.hasChildren && element.onpopulate) + element.onpopulate(element); + element = (skipHidden ? (element.revealed() && element.expanded ? element.children[element.children.length - 1] : null) : element.children[element.children.length - 1]); + } + + if (element) + return element; + + if (!this.parent || this.parent.root) + return null; + + return this.parent; +} + +TreeElement.prototype.isEventWithinDisclosureTriangle = function(event) +{ + var left = this._listItemNode.totalOffsetLeft; + return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren; +} diff --git a/chrome/tools/test/reference_build/chrome/resources/Inspector/utilities.js b/chrome/tools/test/reference_build/chrome/resources/Inspector/utilities.js new file mode 100644 index 0000000..5d295d4 --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/resources/Inspector/utilities.js @@ -0,0 +1,908 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +Object.type = function(obj, win) +{ + if (obj === null) + return "null"; + + var type = typeof obj; + if (type !== "object" && type !== "function") + return type; + + win = win || window; + + if (obj instanceof win.String) + return "string"; + if (obj instanceof win.Array) + return "array"; + if (obj instanceof win.Boolean) + return "boolean"; + if (obj instanceof win.Number) + return "number"; + if (obj instanceof win.Date) + return "date"; + if (obj instanceof win.RegExp) + return "regexp"; + if (obj instanceof win.Error) + return "error"; + return type; +} + +Object.describe = function(obj, abbreviated) +{ + var type1 = Object.type(obj); + var type2 = Object.prototype.toString.call(obj).replace(/^\[object (.*)\]$/i, "$1"); + + switch (type1) { + case "object": + return type2; + case "array": + return "[" + obj.toString() + "]"; + case "string": + if (obj.length > 100) + return "\"" + obj.substring(0, 100) + "\u2026\""; + return "\"" + obj + "\""; + case "function": + var objectText = String(obj); + if (!/^function /.test(objectText)) + objectText = (type2 == "object") ? type1 : type2; + else if (abbreviated) + objectText = /.*/.exec(obj)[0].replace(/ +$/g, ""); + return objectText; + case "regexp": + return String(obj).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1); + default: + return String(obj); + } +} + +Object.sortedProperties = function(obj) +{ + var properties = []; + for (var prop in obj) + properties.push(prop); + properties.sort(); + return properties; +} + +Function.prototype.bind = function(thisObject) +{ + var func = this; + var args = Array.prototype.slice.call(arguments, 1); + return function() { return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0))) }; +} + +Element.prototype.removeStyleClass = function(className) +{ + // Test for the simple case before using a RegExp. + if (this.className === className) { + this.className = ""; + return; + } + + var regex = new RegExp("(^|\\s+)" + className.escapeForRegExp() + "($|\\s+)"); + if (regex.test(this.className)) + this.className = this.className.replace(regex, " "); +} + +Element.prototype.addStyleClass = function(className) +{ + if (className && !this.hasStyleClass(className)) + this.className += (this.className.length ? " " + className : className); +} + +Element.prototype.hasStyleClass = function(className) +{ + if (!className) + return false; + // Test for the simple case before using a RegExp. + if (this.className === className) + return true; + var regex = new RegExp("(^|\\s)" + className.escapeForRegExp() + "($|\\s)"); + return regex.test(this.className); +} + +Node.prototype.enclosingNodeOrSelfWithNodeNameInArray = function(nameArray) +{ + for (var node = this; node && (node !== document); node = node.parentNode) + for (var i = 0; i < nameArray.length; ++i) + if (node.nodeName.toLowerCase() === nameArray[i].toLowerCase()) + return node; + return null; +} + +Node.prototype.enclosingNodeOrSelfWithNodeName = function(nodeName) +{ + return this.enclosingNodeOrSelfWithNodeNameInArray([nodeName]); +} + +Node.prototype.enclosingNodeOrSelfWithClass = function(className) +{ + for (var node = this; node && (node !== document); node = node.parentNode) + if (node.nodeType === Node.ELEMENT_NODE && node.hasStyleClass(className)) + return node; + return null; +} + +Node.prototype.enclosingNodeWithClass = function(className) +{ + if (!this.parentNode) + return null; + return this.parentNode.enclosingNodeOrSelfWithClass(className); +} + +Element.prototype.query = function(query) +{ + return document.evaluate(query, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; +} + +Element.prototype.removeChildren = function() +{ + while (this.firstChild) + this.removeChild(this.firstChild); +} + +Element.prototype.isInsertionCaretInside = function() +{ + var selection = window.getSelection(); + if (!selection.rangeCount || !selection.isCollapsed) + return false; + var selectionRange = selection.getRangeAt(0); + return selectionRange.startContainer === this || selectionRange.startContainer.isDescendant(this); +} + +Element.prototype.__defineGetter__("totalOffsetLeft", function() +{ + var total = 0; + for (var element = this; element; element = element.offsetParent) + total += element.offsetLeft; + return total; +}); + +Element.prototype.__defineGetter__("totalOffsetTop", function() +{ + var total = 0; + for (var element = this; element; element = element.offsetParent) + total += element.offsetTop; + return total; +}); + +Element.prototype.firstChildSkippingWhitespace = firstChildSkippingWhitespace; +Element.prototype.lastChildSkippingWhitespace = lastChildSkippingWhitespace; + +Node.prototype.isWhitespace = isNodeWhitespace; +Node.prototype.nodeTypeName = nodeTypeName; +Node.prototype.displayName = nodeDisplayName; +Node.prototype.contentPreview = nodeContentPreview; +Node.prototype.isAncestor = isAncestorNode; +Node.prototype.isDescendant = isDescendantNode; +Node.prototype.firstCommonAncestor = firstCommonNodeAncestor; +Node.prototype.nextSiblingSkippingWhitespace = nextSiblingSkippingWhitespace; +Node.prototype.previousSiblingSkippingWhitespace = previousSiblingSkippingWhitespace; +Node.prototype.traverseNextNode = traverseNextNode; +Node.prototype.traversePreviousNode = traversePreviousNode; +Node.prototype.onlyTextChild = onlyTextChild; + +String.prototype.hasSubstring = function(string, caseInsensitive) +{ + if (!caseInsensitive) + return this.indexOf(string) !== -1; + return this.match(new RegExp(string.escapeForRegExp(), "i")); +} + +String.prototype.escapeCharacters = function(chars) +{ + var foundChar = false; + for (var i = 0; i < chars.length; ++i) { + if (this.indexOf(chars.charAt(i)) !== -1) { + foundChar = true; + break; + } + } + + if (!foundChar) + return this; + + var result = ""; + for (var i = 0; i < this.length; ++i) { + if (chars.indexOf(this.charAt(i)) !== -1) + result += "\\"; + result += this.charAt(i); + } + + return result; +} + +String.prototype.escapeForRegExp = function() +{ + return this.escapeCharacters("^[]{}()\\.$*+?|"); +} + +String.prototype.escapeHTML = function() +{ + return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); +} + +String.prototype.collapseWhitespace = function() +{ + return this.replace(/[\s\xA0]+/g, " "); +} + +String.prototype.trimLeadingWhitespace = function() +{ + return this.replace(/^[\s\xA0]+/g, ""); +} + +String.prototype.trimTrailingWhitespace = function() +{ + return this.replace(/[\s\xA0]+$/g, ""); +} + +String.prototype.trimWhitespace = function() +{ + return this.replace(/^[\s\xA0]+|[\s\xA0]+$/g, ""); +} + +String.prototype.trimURL = function(baseURLDomain) +{ + var result = this.replace(new RegExp("^http[s]?:\/\/", "i"), ""); + if (baseURLDomain) + result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp(), "i"), ""); + return result; +} + +function getShorthandValue(style, shorthandProperty) +{ + var value = style.getPropertyValue(shorthandProperty); + if (!value) { + // Some shorthands (like border) return a null value, so compute a shorthand value. + // FIXME: remove this when http://bugs.webkit.org/show_bug.cgi?id=15823 is fixed. + + var foundProperties = {}; + for (var i = 0; i < style.length; ++i) { + var individualProperty = style[i]; + if (individualProperty in foundProperties || style.getPropertyShorthand(individualProperty) !== shorthandProperty) + continue; + + var individualValue = style.getPropertyValue(individualProperty); + if (style.isPropertyImplicit(individualProperty) || individualValue === "initial") + continue; + + foundProperties[individualProperty] = true; + + if (!value) + value = ""; + else if (value.length) + value += " "; + value += individualValue; + } + } + return value; +} + +function getShorthandPriority(style, shorthandProperty) +{ + var priority = style.getPropertyPriority(shorthandProperty); + if (!priority) { + for (var i = 0; i < style.length; ++i) { + var individualProperty = style[i]; + if (style.getPropertyShorthand(individualProperty) !== shorthandProperty) + continue; + priority = style.getPropertyPriority(individualProperty); + break; + } + } + return priority; +} + +function getLonghandProperties(style, shorthandProperty) +{ + var properties = []; + var foundProperties = {}; + + for (var i = 0; i < style.length; ++i) { + var individualProperty = style[i]; + if (individualProperty in foundProperties || style.getPropertyShorthand(individualProperty) !== shorthandProperty) + continue; + foundProperties[individualProperty] = true; + properties.push(individualProperty); + } + + return properties; +} + +function getUniqueStyleProperties(style) +{ + var properties = []; + var foundProperties = {}; + + for (var i = 0; i < style.length; ++i) { + var property = style[i]; + if (property in foundProperties) + continue; + foundProperties[property] = true; + properties.push(property); + } + + return properties; +} + +function isNodeWhitespace() +{ + if (!this || this.nodeType !== Node.TEXT_NODE) + return false; + if (!this.nodeValue.length) + return true; + return this.nodeValue.match(/^[\s\xA0]+$/); +} + +function nodeTypeName() +{ + if (!this) + return "(unknown)"; + + switch (this.nodeType) { + case Node.ELEMENT_NODE: return "Element"; + case Node.ATTRIBUTE_NODE: return "Attribute"; + case Node.TEXT_NODE: return "Text"; + case Node.CDATA_SECTION_NODE: return "Character Data"; + case Node.ENTITY_REFERENCE_NODE: return "Entity Reference"; + case Node.ENTITY_NODE: return "Entity"; + case Node.PROCESSING_INSTRUCTION_NODE: return "Processing Instruction"; + case Node.COMMENT_NODE: return "Comment"; + case Node.DOCUMENT_NODE: return "Document"; + case Node.DOCUMENT_TYPE_NODE: return "Document Type"; + case Node.DOCUMENT_FRAGMENT_NODE: return "Document Fragment"; + case Node.NOTATION_NODE: return "Notation"; + } + + return "(unknown)"; +} + +function nodeDisplayName() +{ + if (!this) + return ""; + + switch (this.nodeType) { + case Node.DOCUMENT_NODE: + return "Document"; + + case Node.ELEMENT_NODE: + var name = "<" + this.nodeName.toLowerCase(); + + if (this.hasAttributes()) { + var value = this.getAttribute("id"); + if (value) + name += " id=\"" + value + "\""; + value = this.getAttribute("class"); + if (value) + name += " class=\"" + value + "\""; + if (this.nodeName.toLowerCase() === "a") { + value = this.getAttribute("name"); + if (value) + name += " name=\"" + value + "\""; + value = this.getAttribute("href"); + if (value) + name += " href=\"" + value + "\""; + } else if (this.nodeName.toLowerCase() === "img") { + value = this.getAttribute("src"); + if (value) + name += " src=\"" + value + "\""; + } else if (this.nodeName.toLowerCase() === "iframe") { + value = this.getAttribute("src"); + if (value) + name += " src=\"" + value + "\""; + } else if (this.nodeName.toLowerCase() === "input") { + value = this.getAttribute("name"); + if (value) + name += " name=\"" + value + "\""; + value = this.getAttribute("type"); + if (value) + name += " type=\"" + value + "\""; + } else if (this.nodeName.toLowerCase() === "form") { + value = this.getAttribute("action"); + if (value) + name += " action=\"" + value + "\""; + } + } + + return name + ">"; + + case Node.TEXT_NODE: + if (isNodeWhitespace.call(this)) + return "(whitespace)"; + return "\"" + this.nodeValue + "\""; + + case Node.COMMENT_NODE: + return "<!--" + this.nodeValue + "-->"; + + case Node.DOCUMENT_TYPE_NODE: + var docType = "<!DOCTYPE " + this.nodeName; + if (this.publicId) { + docType += " PUBLIC \"" + this.publicId + "\""; + if (this.systemId) + docType += " \"" + this.systemId + "\""; + } else if (this.systemId) + docType += " SYSTEM \"" + this.systemId + "\""; + if (this.internalSubset) + docType += " [" + this.internalSubset + "]"; + return docType + ">"; + } + + return this.nodeName.toLowerCase().collapseWhitespace(); +} + +function nodeContentPreview() +{ + if (!this || !this.hasChildNodes || !this.hasChildNodes()) + return ""; + + var limit = 0; + var preview = ""; + + // always skip whitespace here + var currentNode = traverseNextNode.call(this, true, this); + while (currentNode) { + if (currentNode.nodeType === Node.TEXT_NODE) + preview += currentNode.nodeValue.escapeHTML(); + else + preview += nodeDisplayName.call(currentNode).escapeHTML(); + + currentNode = traverseNextNode.call(currentNode, true, this); + + if (++limit > 4) { + preview += "…"; // ellipsis + break; + } + } + + return preview.collapseWhitespace(); +} + +function isAncestorNode(ancestor) +{ + if (!this || !ancestor) + return false; + + var currentNode = ancestor.parentNode; + while (currentNode) { + if (this === currentNode) + return true; + currentNode = currentNode.parentNode; + } + + return false; +} + +function isDescendantNode(descendant) +{ + return isAncestorNode.call(descendant, this); +} + +function firstCommonNodeAncestor(node) +{ + if (!this || !node) + return; + + var node1 = this.parentNode; + var node2 = node.parentNode; + + if ((!node1 || !node2) || node1 !== node2) + return null; + + while (node1 && node2) { + if (!node1.parentNode || !node2.parentNode) + break; + if (node1 !== node2) + break; + + node1 = node1.parentNode; + node2 = node2.parentNode; + } + + return node1; +} + +function nextSiblingSkippingWhitespace() +{ + if (!this) + return; + var node = this.nextSibling; + while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) + node = node.nextSibling; + return node; +} + +function previousSiblingSkippingWhitespace() +{ + if (!this) + return; + var node = this.previousSibling; + while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) + node = node.previousSibling; + return node; +} + +function firstChildSkippingWhitespace() +{ + if (!this) + return; + var node = this.firstChild; + while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) + node = nextSiblingSkippingWhitespace.call(node); + return node; +} + +function lastChildSkippingWhitespace() +{ + if (!this) + return; + var node = this.lastChild; + while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) + node = previousSiblingSkippingWhitespace.call(node); + return node; +} + +function traverseNextNode(skipWhitespace, stayWithin) +{ + if (!this) + return; + + var node = skipWhitespace ? firstChildSkippingWhitespace.call(this) : this.firstChild; + if (node) + return node; + + if (stayWithin && this === stayWithin) + return null; + + node = skipWhitespace ? nextSiblingSkippingWhitespace.call(this) : this.nextSibling; + if (node) + return node; + + node = this; + while (node && !(skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling) && (!stayWithin || !node.parentNode || node.parentNode !== stayWithin)) + node = node.parentNode; + if (!node) + return null; + + return skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling; +} + +function traversePreviousNode(skipWhitespace) +{ + if (!this) + return; + var node = skipWhitespace ? previousSiblingSkippingWhitespace.call(this) : this.previousSibling; + while (node && (skipWhitespace ? lastChildSkippingWhitespace.call(node) : node.lastChild) ) + node = skipWhitespace ? lastChildSkippingWhitespace.call(node) : node.lastChild; + if (node) + return node; + return this.parentNode; +} + +function onlyTextChild(ignoreWhitespace) +{ + if (!this) + return null; + + var firstChild = ignoreWhitespace ? firstChildSkippingWhitespace.call(this) : this.firstChild; + if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE) + return null; + + var sibling = ignoreWhitespace ? nextSiblingSkippingWhitespace.call(firstChild) : firstChild.nextSibling; + return sibling ? null : firstChild; +} + +function nodeTitleInfo(hasChildren, linkify) +{ + var info = {title: "", hasChildren: hasChildren}; + + switch (this.nodeType) { + case Node.DOCUMENT_NODE: + info.title = "Document"; + break; + + case Node.ELEMENT_NODE: + info.title = "<span class=\"webkit-html-tag\"><" + this.nodeName.toLowerCase().escapeHTML(); + + if (this.hasAttributes()) { + for (var i = 0; i < this.attributes.length; ++i) { + var attr = this.attributes[i]; + var value = attr.value.escapeHTML(); + value = value.replace(/([\/;:\)\]\}])/g, "$1​"); + + info.title += " <span class=\"webkit-html-attribute\"><span class=\"webkit-html-attribute-name\">" + attr.name.escapeHTML() + "</span>=​\""; + + if (linkify && (attr.name === "src" || attr.name === "href")) + info.title += linkify(attr.value, value, "webkit-html-attribute-value", this.nodeName.toLowerCase() == "a"); + else + info.title += "<span class=\"webkit-html-attribute-value\">" + value + "</span>"; + info.title += "\"</span>"; + } + } + info.title += "></span>​"; + + // If this element only has a single child that is a text node, + // just show that text and the closing tag inline rather than + // create a subtree for them + + var textChild = onlyTextChild.call(this, Preferences.ignoreWhitespace); + var showInlineText = textChild && textChild.textContent.length < Preferences.maxInlineTextChildLength; + + if (showInlineText) { + info.title += "<span class=\"webkit-html-text-node\">" + textChild.nodeValue.escapeHTML() + "</span>​<span class=\"webkit-html-tag\"></" + this.nodeName.toLowerCase().escapeHTML() + "></span>"; + info.hasChildren = false; + } + break; + + case Node.TEXT_NODE: + if (isNodeWhitespace.call(this)) + info.title = "(whitespace)"; + else + info.title = "\"<span class=\"webkit-html-text-node\">" + this.nodeValue.escapeHTML() + "</span>\""; + break + + case Node.COMMENT_NODE: + info.title = "<span class=\"webkit-html-comment\"><!--" + this.nodeValue.escapeHTML() + "--></span>"; + break; + + case Node.DOCUMENT_TYPE_NODE: + info.title = "<span class=\"webkit-html-doctype\"><!DOCTYPE " + this.nodeName; + if (this.publicId) { + info.title += " PUBLIC \"" + this.publicId + "\""; + if (this.systemId) + info.title += " \"" + this.systemId + "\""; + } else if (this.systemId) + info.title += " SYSTEM \"" + this.systemId + "\""; + if (this.internalSubset) + info.title += " [" + this.internalSubset + "]"; + info.title += "></span>"; + break; + default: + info.title = this.nodeName.toLowerCase().collapseWhitespace().escapeHTML(); + } + + return info; +} + +Number.secondsToString = function(seconds, formatterFunction) +{ + if (!formatterFunction) + formatterFunction = String.sprintf; + + var ms = seconds * 1000; + if (ms < 1000) + return formatterFunction("%.0fms", ms); + + if (seconds < 60) + return formatterFunction("%.2fs", seconds); + + var minutes = seconds / 60; + if (minutes < 60) + return formatterFunction("%.1fmin", minutes); + + var hours = minutes / 60; + if (hours < 24) + return formatterFunction("%.1fhrs", hours); + + var days = hours / 24; + return formatterFunction("%.1f days", days); +} + +Number.bytesToString = function(bytes, formatterFunction) +{ + if (!formatterFunction) + formatterFunction = String.sprintf; + + if (bytes < 1024) + return formatterFunction("%.0fB", bytes); + + var kilobytes = bytes / 1024; + if (kilobytes < 1024) + return formatterFunction("%.2fKB", kilobytes); + + var megabytes = kilobytes / 1024; + return formatterFunction("%.3fMB", megabytes); +} + +Number.constrain = function(num, min, max) +{ + if (num < min) + num = min; + else if (num > max) + num = max; + return num; +} + +HTMLTextAreaElement.prototype.moveCursorToEnd = function() +{ + var length = this.value.length; + this.setSelectionRange(length, length); +} + +String.sprintf = function(format) +{ + return String.vsprintf(format, Array.prototype.slice.call(arguments, 1)); +} + +String.tokenizeFormatString = function(format) +{ + var tokens = []; + var substitutionIndex = 0; + + function addStringToken(str) + { + tokens.push({ type: "string", value: str }); + } + + function addSpecifierToken(specifier, precision, substitutionIndex) + { + tokens.push({ type: "specifier", specifier: specifier, precision: precision, substitutionIndex: substitutionIndex }); + } + + var index = 0; + for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; precentIndex = format.indexOf("%", index)) { + addStringToken(format.substring(index, precentIndex)); + index = precentIndex + 1; + + if (format[index] === "%") { + addStringToken("%"); + ++index; + continue; + } + + if (!isNaN(format[index])) { + // The first character is a number, it might be a substitution index. + var number = parseInt(format.substring(index)); + while (!isNaN(format[index])) + ++index; + // If the number is greater than zero and ends with a "$", + // then this is a substitution index. + if (number > 0 && format[index] === "$") { + substitutionIndex = (number - 1); + ++index; + } + } + + var precision = -1; + if (format[index] === ".") { + // This is a precision specifier. If no digit follows the ".", + // then the precision should be zero. + ++index; + precision = parseInt(format.substring(index)); + if (isNaN(precision)) + precision = 0; + while (!isNaN(format[index])) + ++index; + } + + addSpecifierToken(format[index], precision, substitutionIndex); + + ++substitutionIndex; + ++index; + } + + addStringToken(format.substring(index)); + + return tokens; +} + +String.standardFormatters = { + d: function(substitution) + { + substitution = parseInt(substitution); + return !isNaN(substitution) ? substitution : 0; + }, + + f: function(substitution, token) + { + substitution = parseFloat(substitution); + if (substitution && token.precision > -1) + substitution = substitution.toFixed(token.precision); + return !isNaN(substitution) ? substitution : (token.precision > -1 ? Number(0).toFixed(token.precision) : 0); + }, + + s: function(substitution) + { + return substitution; + }, +}; + +String.vsprintf = function(format, substitutions) +{ + return String.format(format, substitutions, String.standardFormatters, "", function(a, b) { return a + b; }).formattedResult; +} + +String.format = function(format, substitutions, formatters, initialValue, append) +{ + if (!format || !substitutions || !substitutions.length) + return { formattedResult: append(initialValue, format), unusedSubstitutions: substitutions }; + + function prettyFunctionName() + { + return "String.format(\"" + format + "\", \"" + substitutions.join("\", \"") + "\")"; + } + + function warn(msg) + { + console.warn(prettyFunctionName() + ": " + msg); + } + + function error(msg) + { + console.error(prettyFunctionName() + ": " + msg); + } + + var result = initialValue; + var tokens = String.tokenizeFormatString(format); + var usedSubstitutionIndexes = {}; + + for (var i = 0; i < tokens.length; ++i) { + var token = tokens[i]; + + if (token.type === "string") { + result = append(result, token.value); + continue; + } + + if (token.type !== "specifier") { + error("Unknown token type \"" + token.type + "\" found."); + continue; + } + + if (token.substitutionIndex >= substitutions.length) { + // If there are not enough substitutions for the current substitutionIndex + // just output the format specifier literally and move on. + error("not enough substitution arguments. Had " + substitutions.length + " but needed " + (token.substitutionIndex + 1) + ", so substitution was skipped."); + result = append(result, "%" + (token.precision > -1 ? token.precision : "") + token.specifier); + continue; + } + + usedSubstitutionIndexes[token.substitutionIndex] = true; + + if (!(token.specifier in formatters)) { + // Encountered an unsupported format character, treat as a string. + warn("unsupported format character \u201C" + token.specifier + "\u201D. Treating as a string."); + result = append(result, substitutions[token.substitutionIndex]); + continue; + } + + result = append(result, formatters[token.specifier](substitutions[token.substitutionIndex], token)); + } + + var unusedSubstitutions = []; + for (var i = 0; i < substitutions.length; ++i) { + if (i in usedSubstitutionIndexes) + continue; + unusedSubstitutions.push(substitutions[i]); + } + + return { formattedResult: result, unusedSubstitutions: unusedSubstitutions }; +} diff --git a/chrome/tools/test/reference_build/chrome/themes/default.dll b/chrome/tools/test/reference_build/chrome/themes/default.dll Binary files differnew file mode 100644 index 0000000..c10ef51b --- /dev/null +++ b/chrome/tools/test/reference_build/chrome/themes/default.dll |