Source/WebCore/ChangeLog

 12011-10-03 Mikhail Naganov <mnaganov@chromium.org>
 2
 3 Web Inspector: Factor out object properties popup.
 4 https://bugs.webkit.org/show_bug.cgi?id=69234
 5
 6 Also, for HTML elements, show a non-empty id value in the element name.
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 * WebCore.gypi:
 11 * WebCore.vcproj/WebCore.vcproj:
 12 * inspector/front-end/ObjectPopoverHelper.js: Added.
 13 * inspector/front-end/SourceFrame.js: Extracted from here.
 14 (WebInspector.SourceFrame.prototype._initializeTextViewer):
 15 (WebInspector.SourceFrame.prototype._mouseDown):
 16 (WebInspector.SourceFrame.prototype._onShowPopover.showObjectPopover):
 17 (WebInspector.SourceFrame.prototype._onShowPopover):
 18 * inspector/front-end/WebKit.qrc:
 19 * inspector/front-end/inspector.html:
 20
1212011-09-30 Pavel Feldman <pfeldman@google.com>
222
323 Web Inspector: [chromium] expose inspector protocol version to the embedder.

Source/WebCore/WebCore.gypi

62736273 'inspector/front-end/NetworkLog.js',
62746274 'inspector/front-end/NetworkPanel.js',
62756275 'inspector/front-end/Object.js',
 6276 'inspector/front-end/ObjectPopoverHelper.js',
62766277 'inspector/front-end/ObjectPropertiesSection.js',
62776278 'inspector/front-end/Panel.js',
62786279 'inspector/front-end/PanelEnablerView.js',

Source/WebCore/WebCore.vcproj/WebCore.vcproj

6938169381 >
6938269382 </File>
6938369383 <File
 69384 RelativePath="..\inspector\front-end\ObjectPopoverHelper.js.js"
 69385 >
 69386 </File>
 69387 <File
6938469388 RelativePath="..\inspector\front-end\ObjectPropertiesSection.js"
6938569389 >
6938669390 </File>

Source/WebCore/inspector/front-end/ObjectPopoverHelper.js

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31WebInspector.ObjectPopoverHelper = function(panelElement, getAnchor, queryObject, onHide, disableOnClick)
 32{
 33 WebInspector.PopoverHelper.call(this, panelElement, getAnchor, this._showObjectPopover.bind(this), onHide, disableOnClick);
 34 this._queryObject = queryObject;
 35 panelElement.addEventListener("scroll", this.hidePopover.bind(this), true);
 36};
 37
 38WebInspector.ObjectPopoverHelper.prototype = {
 39 _showObjectPopover: function(element, popover)
 40 {
 41 function showObjectPopover(result, wasThrown)
 42 {
 43 if (popover.disposed)
 44 return;
 45 if (wasThrown) {
 46 this.hidePopover();
 47 return;
 48 }
 49 var popoverContentElement = null;
 50 if (result.type !== "object") {
 51 popoverContentElement = document.createElement("span");
 52 popoverContentElement.className = "monospace console-formatted-" + result.type;
 53 popoverContentElement.style.whiteSpace = "pre";
 54 popoverContentElement.textContent = result.description;
 55 if (result.type === "string")
 56 popoverContentElement.textContent = "\"" + popoverContentElement.textContent + "\"";
 57 popover.show(popoverContentElement, element);
 58 } else {
 59 popoverContentElement = document.createElement("div");
 60
 61 var titleElement = document.createElement("div");
 62 titleElement.className = "source-frame-popover-title monospace";
 63 titleElement.textContent = result.description;
 64 popoverContentElement.appendChild(titleElement);
 65
 66 var section = new WebInspector.ObjectPropertiesSection(result);
 67 // For HTML DOM wrappers, append "#id" to title, if not empty.
 68 if (result.description.substr(0, 4) === "HTML") {
 69 var oldUpdateProperties = section.updateProperties;
 70 section.updateProperties = function(properties, rootTreeElementConstructor, rootPropertyComparer)
 71 {
 72 for (var i = 0; i < properties.length; ++i) {
 73 if (properties[i].name === "id") {
 74 if (properties[i].value.description)
 75 titleElement.textContent += "#" + properties[i].value.description;
 76 break;
 77 }
 78 }
 79 oldUpdateProperties.call(this, properties, rootTreeElementConstructor, rootPropertyComparer);
 80 };
 81 }
 82 section.expanded = true;
 83 section.element.addStyleClass("source-frame-popover-tree");
 84 section.headerElement.addStyleClass("hidden");
 85 popoverContentElement.appendChild(section.element);
 86
 87 const popoverWidth = 300;
 88 const popoverHeight = 250;
 89 popover.show(popoverContentElement, element, popoverWidth, popoverHeight);
 90 }
 91 }
 92 this._queryObject(element, showObjectPopover.bind(this));
 93 }
 94}
 95
 96WebInspector.ObjectPopoverHelper.prototype.__proto__ = WebInspector.PopoverHelper.prototype;

Source/WebCore/inspector/front-end/SourceFrame.js

@@WebInspector.SourceFrame.prototype = {
289289
290290 var element = this._textViewer.element;
291291 if (this._delegate.debuggingSupported()) {
292  this._popoverHelper = new WebInspector.PopoverHelper(element,
 292 this._popoverHelper = new WebInspector.ObjectPopoverHelper(element,
293293 this._getPopoverAnchor.bind(this), this._onShowPopover.bind(this), this._onHidePopover.bind(this), true);
294294 element.addEventListener("mousedown", this._mouseDown.bind(this), true);
295  element.addEventListener("scroll", this._scroll.bind(this), true);
296295 }
297296
298297 this._textViewer.beginUpdates();

@@WebInspector.SourceFrame.prototype = {
642641 return this._delegate.suggestedFileName();
643642 },
644643
645  _scroll: function(event)
646  {
647  if (this._popoverHelper)
648  this._popoverHelper.hidePopover();
649  },
650 
651644 _mouseDown: function(event)
652645 {
653  if (this._popoverHelper)
654  this._popoverHelper.hidePopover();
655646 if (event.button != 0 || event.altKey || event.ctrlKey || event.metaKey)
656647 return;
657648 var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");

@@WebInspector.SourceFrame.prototype = {
730721 return container;
731722 },
732723
733  _onShowPopover: function(element, popover)
 724 _onShowPopover: function(element, showCallback)
734725 {
735726 if (!this._textViewer.readOnly) {
736727 this._popoverHelper.hidePopover();

@@WebInspector.SourceFrame.prototype = {
740731
741732 function showObjectPopover(result, wasThrown)
742733 {
743  if (popover.disposed)
744  return;
745  if (wasThrown || !this._delegate.debuggerPaused()) {
 734 if (!this._delegate.debuggerPaused()) {
746735 this._popoverHelper.hidePopover();
747736 return;
748737 }
749  var popoverContentElement = null;
750  if (result.type !== "object") {
751  popoverContentElement = document.createElement("span");
752  popoverContentElement.className = "monospace console-formatted-" + result.type;
753  popoverContentElement.style.whiteSpace = "pre";
754  popoverContentElement.textContent = result.description;
755  if (result.type === "string")
756  popoverContentElement.textContent = "\"" + popoverContentElement.textContent + "\"";
757  popover.show(popoverContentElement, element);
758  } else {
759  var popoverContentElement = document.createElement("div");
760 
761  var titleElement = document.createElement("div");
762  titleElement.className = "source-frame-popover-title monospace";
763  titleElement.textContent = result.description;
764  popoverContentElement.appendChild(titleElement);
765 
766  var section = new WebInspector.ObjectPropertiesSection(result);
767  section.expanded = true;
768  section.element.addStyleClass("source-frame-popover-tree");
769  section.headerElement.addStyleClass("hidden");
770  popoverContentElement.appendChild(section.element);
771 
772  const popoverWidth = 300;
773  const popoverHeight = 250;
774  popover.show(popoverContentElement, element, popoverWidth, popoverHeight);
775  }
 738 showCallback(result, wasThrown);
776739 this._highlightElement.addStyleClass("source-frame-eval-expression");
777740 }
778741

Source/WebCore/inspector/front-end/WebKit.qrc

7575 <file>NetworkManager.js</file>
7676 <file>NetworkPanel.js</file>
7777 <file>Object.js</file>
 78 <file>ObjectPopoverHelper.js</file>
7879 <file>ObjectPropertiesSection.js</file>
7980 <file>Panel.js</file>
8081 <file>PanelEnablerView.js</file>

Source/WebCore/inspector/front-end/inspector.html

@@THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8888 <script type="text/javascript" src="PropertiesSection.js"></script>
8989 <script type="text/javascript" src="RemoteObject.js"></script>
9090 <script type="text/javascript" src="ObjectPropertiesSection.js"></script>
 91 <script type="text/javascript" src="ObjectPopoverHelper.js"></script>
9192 <script type="text/javascript" src="BreakpointsSidebarPane.js"></script>
9293 <script type="text/javascript" src="DOMBreakpointsSidebarPane.js"></script>
9394 <script type="text/javascript" src="CallStackSidebarPane.js"></script>