diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js')
-rw-r--r-- | src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js | 91 |
1 files changed, 27 insertions, 64 deletions
diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js index 55e286e..74c2bb6 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js @@ -61,6 +61,25 @@ WebInspector.ProfileType.prototype = { buttonClicked: function() { + }, + + viewForProfile: function(profile) + { + if (!profile._profileView) + profile._profileView = this.createView(profile); + return profile._profileView; + }, + + // Must be implemented by subclasses. + createView: function(profile) + { + throw new Error("Needs implemented."); + }, + + // Must be implemented by subclasses. + createSidebarTreeElementForProfile: function(profile) + { + throw new Error("Needs implemented."); } } @@ -68,6 +87,8 @@ WebInspector.ProfilesPanel = function() { WebInspector.Panel.call(this); + this.createSidebar(); + this.element.addStyleClass("profiles"); this._profileTypesByIdMap = {}; this._profileTypeButtonsByIdMap = {}; @@ -80,21 +101,6 @@ WebInspector.ProfilesPanel = function() this.element.appendChild(this.panelEnablerView.element); - this.sidebarElement = document.createElement("div"); - this.sidebarElement.id = "profiles-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.profileViews = document.createElement("div"); this.profileViews.id = "profile-views"; this.element.appendChild(this.profileViews); @@ -143,7 +149,6 @@ WebInspector.ProfilesPanel.prototype = { show: function() { WebInspector.Panel.prototype.show.call(this); - this._updateSidebarWidth(); if (this._shouldPopulateProfiles) this._populateProfiles(); }, @@ -192,11 +197,6 @@ WebInspector.ProfilesPanel.prototype = { this._updateInterface(); }, - handleKeyEvent: function(event) - { - this.sidebarTree.handleKeyEvent(event); - }, - registerProfileType: function(profileType) { this._profileTypesByIdMap[profileType.id] = profileType; @@ -212,10 +212,12 @@ WebInspector.ProfilesPanel.prototype = { addProfileHeader: function(typeId, profile) { - var sidebarParent = this.getProfileType(typeId).treeElement; + var profileType = this.getProfileType(typeId); + var sidebarParent = profileType.treeElement; var small = false; var alternateTitle; + profile.__profilesPanelProfileType = profileType; this._profiles.push(profile); this._profilesIdMap[this._makeKey(profile.uid, typeId)] = profile; @@ -257,7 +259,7 @@ WebInspector.ProfilesPanel.prototype = { } } - var profileTreeElement = new WebInspector.ProfileSidebarTreeElement(profile); + var profileTreeElement = profileType.createSidebarTreeElementForProfile(profile); profileTreeElement.small = small; if (alternateTitle) profileTreeElement.mainTitle = alternateTitle; @@ -276,7 +278,7 @@ WebInspector.ProfilesPanel.prototype = { if (this.visibleView) this.visibleView.hide(); - var view = profile.viewForProfile(); + var view = profile.__profilesPanelProfileType.viewForProfile(profile); view.show(this.profileViews); @@ -449,49 +451,10 @@ WebInspector.ProfilesPanel.prototype = { delete this._shouldPopulateProfiles; }, - _startSidebarDragging: function(event) - { - WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize"); - }, - - _sidebarDragging: function(event) + updateMainViewWidth: function(width) { - 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 or the window is closed, - // so we can't calculate what is need. Return early. - 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.profileViews.style.left = width + "px"; this.profileViewStatusBarItemsContainer.style.left = width + "px"; - this.sidebarResizeElement.style.left = (width - 3) + "px"; - - var visibleView = this.visibleView; - if (visibleView && "resize" in visibleView) - visibleView.resize(); } } |