Title: [206101] trunk/Source/WebInspectorUI
Revision
206101
Author
mattba...@apple.com
Date
2016-09-19 10:53:37 -0700 (Mon, 19 Sep 2016)

Log Message

Web Inspector: Make it easier to create a view from an existing DOM element
https://bugs.webkit.org/show_bug.cgi?id=162165
<rdar://problem/28365848>

Reviewed by Timothy Hatcher.

* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
Pass id string for views created from existing DOM elements.

* UserInterface/Views/View.js:
(WebInspector.View):
Change `element` to `elementOrIdentifier`. If the value is a string,
treat it as an element identifier. If the identifier is invalid, create
a default element.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (206100 => 206101)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-09-19 17:36:58 UTC (rev 206100)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-09-19 17:53:37 UTC (rev 206101)
@@ -1,3 +1,21 @@
+2016-09-19  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: Make it easier to create a view from an existing DOM element
+        https://bugs.webkit.org/show_bug.cgi?id=162165
+        <rdar://problem/28365848>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.contentLoaded):
+        Pass id string for views created from existing DOM elements.
+
+        * UserInterface/Views/View.js:
+        (WebInspector.View):
+        Change `element` to `elementOrIdentifier`. If the value is a string,
+        treat it as an element identifier. If the identifier is invalid, create
+        a default element.
+
 2016-09-19  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Color picker in Style sidebar stops working after 1st color change

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (206100 => 206101)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-09-19 17:36:58 UTC (rev 206100)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-09-19 17:53:37 UTC (rev 206101)
@@ -227,11 +227,11 @@
     document.body.classList.add(this.debuggableType);
 
     // Create the user interface elements.
-    this.toolbar = new WebInspector.Toolbar(document.getElementById("toolbar"), null, true);
+    this.toolbar = new WebInspector.Toolbar("toolbar", null, true);
     this.toolbar.displayMode = WebInspector.Toolbar.DisplayMode.IconOnly;
     this.toolbar.sizeMode = WebInspector.Toolbar.SizeMode.Small;
 
-    this.tabBar = new WebInspector.TabBar(document.getElementById("tab-bar"));
+    this.tabBar = new WebInspector.TabBar("tab-bar");
     this.tabBar.addEventListener(WebInspector.TabBar.Event.NewTabItemClicked, this._newTabItemClicked, this);
     this.tabBar.addEventListener(WebInspector.TabBar.Event.OpenDefaultTab, this._openDefaultTab, this);
 
@@ -239,10 +239,10 @@
     this._contentElement.setAttribute("role", "main");
     this._contentElement.setAttribute("aria-label", WebInspector.UIString("Content"));
 
-    this.splitContentBrowser = new WebInspector.ContentBrowser(document.getElementById("split-content-browser"), this, true, true);
+    this.splitContentBrowser = new WebInspector.ContentBrowser("split-content-browser", this, true, true);
     this.splitContentBrowser.navigationBar.element.addEventListener("mousedown", this._consoleResizerMouseDown.bind(this));
 
-    this.quickConsole = new WebInspector.QuickConsole(document.getElementById("quick-console"));
+    this.quickConsole = new WebInspector.QuickConsole("quick-console");
     this.quickConsole.addEventListener(WebInspector.QuickConsole.Event.DidResize, this._quickConsoleDidResize, this);
 
     this._consoleRepresentedObject = new WebInspector.LogObject;
@@ -252,10 +252,10 @@
     this.breakpointPopoverController = new WebInspector.BreakpointPopoverController;
 
     // FIXME: The sidebars should be flipped in RTL languages.
-    this.navigationSidebar = new WebInspector.Sidebar(document.getElementById("navigation-sidebar"), WebInspector.Sidebar.Sides.Left);
+    this.navigationSidebar = new WebInspector.Sidebar("navigation-sidebar", WebInspector.Sidebar.Sides.Left);
     this.navigationSidebar.addEventListener(WebInspector.Sidebar.Event.WidthDidChange, this._sidebarWidthDidChange, this);
 
-    this.detailsSidebar = new WebInspector.Sidebar(document.getElementById("details-sidebar"), WebInspector.Sidebar.Sides.Right, null, null, WebInspector.UIString("Details"), true);
+    this.detailsSidebar = new WebInspector.Sidebar("details-sidebar", WebInspector.Sidebar.Sides.Right, null, null, WebInspector.UIString("Details"), true);
     this.detailsSidebar.addEventListener(WebInspector.Sidebar.Event.WidthDidChange, this._sidebarWidthDidChange, this);
 
     this.searchKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, "F", this._focusSearchField.bind(this));
@@ -276,7 +276,7 @@
     this._showTabAtIndexKeyboardShortcuts = [1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Option, `${i}`, this._showTabAtIndex.bind(this, i)));
     this._openNewTabKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Option, "T", this.showNewTabTab.bind(this));
 
-    this.tabBrowser = new WebInspector.TabBrowser(document.getElementById("tab-browser"), this.tabBar, this.navigationSidebar, this.detailsSidebar);
+    this.tabBrowser = new WebInspector.TabBrowser("tab-browser", this.tabBar, this.navigationSidebar, this.detailsSidebar);
     this.tabBrowser.addEventListener(WebInspector.TabBrowser.Event.SelectedTabContentViewDidChange, this._tabBrowserSelectedTabContentViewDidChange, this);
 
     this.tabBar.addEventListener(WebInspector.TabBar.Event.TabBarItemAdded, this._updateNewTabButtonState, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/View.js (206100 => 206101)


--- trunk/Source/WebInspectorUI/UserInterface/Views/View.js	2016-09-19 17:36:58 UTC (rev 206100)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/View.js	2016-09-19 17:53:37 UTC (rev 206101)
@@ -25,11 +25,18 @@
 
 WebInspector.View = class View extends WebInspector.Object
 {
-    constructor(element)
+    constructor(elementOrIdentifier)
     {
         super();
 
-        this._element = element || document.createElement("div");
+        if (elementOrIdentifier instanceof HTMLElement)
+            this._element = elementOrIdentifier;
+        else if (typeof elementOrIdentifier === "string") {
+            this._element = document.getElementById(elementOrIdentifier);
+            console.assert(this._element, "Couldn't create view for unknown element " + elementOrIdentifier);
+        }
+
+        this._element = this._element || document.createElement("div");
         this._element.__view = this;
         this._parentView = null;
         this._subviews = [];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to