12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363 |
- /*
- * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Joseph Pecoraro
- * Copyright (C) 2013 Samsung Electronics. 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.
- */
- importScript("ApplicationCacheItemsView.js");
- importScript("DOMStorageItemsView.js");
- importScript("DatabaseQueryView.js");
- importScript("DatabaseTableView.js");
- importScript("DirectoryContentView.js");
- importScript("IndexedDBViews.js");
- importScript("FileContentView.js");
- importScript("FileSystemView.js");
- /**
- * @constructor
- * @extends {WebInspector.Panel}
- */
- WebInspector.ResourcesPanel = function(database)
- {
- WebInspector.Panel.call(this, "resources");
- this.registerRequiredCSS("resourcesPanel.css");
- WebInspector.settings.resourcesLastSelectedItem = WebInspector.settings.createSetting("resourcesLastSelectedItem", {});
- this.createSidebarViewWithTree();
- this.sidebarElement.addStyleClass("outline-disclosure");
- this.sidebarElement.addStyleClass("filter-all");
- this.sidebarElement.addStyleClass("children");
- this.sidebarElement.addStyleClass("small");
- this.sidebarTreeElement.removeStyleClass("sidebar-tree");
- this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Frames"), "Frames", ["frame-storage-tree-item"]);
- this.sidebarTree.appendChild(this.resourcesListTreeElement);
- this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Web SQL"), "Databases", ["database-storage-tree-item"]);
- this.sidebarTree.appendChild(this.databasesListTreeElement);
- this.indexedDBListTreeElement = new WebInspector.IndexedDBTreeElement(this);
- this.sidebarTree.appendChild(this.indexedDBListTreeElement);
- this.localStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Local Storage"), "LocalStorage", ["domstorage-storage-tree-item", "local-storage"]);
- this.sidebarTree.appendChild(this.localStorageListTreeElement);
- this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Session Storage"), "SessionStorage", ["domstorage-storage-tree-item", "session-storage"]);
- this.sidebarTree.appendChild(this.sessionStorageListTreeElement);
- this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Cookies"), "Cookies", ["cookie-storage-tree-item"]);
- this.sidebarTree.appendChild(this.cookieListTreeElement);
- this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Application Cache"), "ApplicationCache", ["application-cache-storage-tree-item"]);
- this.sidebarTree.appendChild(this.applicationCacheListTreeElement);
- if (WebInspector.experimentsSettings.fileSystemInspection.isEnabled()) {
- this.fileSystemListTreeElement = new WebInspector.FileSystemListTreeElement(this);
- this.sidebarTree.appendChild(this.fileSystemListTreeElement);
- }
- this.storageViews = this.splitView.mainElement;
- this.storageViews.addStyleClass("diff-container");
- this.storageViewStatusBarItemsContainer = document.createElement("div");
- this.storageViewStatusBarItemsContainer.className = "status-bar-items";
- /** @type {!Map.<!WebInspector.Database, !Object.<string, !WebInspector.DatabaseTableView>>} */
- this._databaseTableViews = new Map();
- /** @type {!Map.<!WebInspector.Database, !WebInspector.DatabaseQueryView>} */
- this._databaseQueryViews = new Map();
- /** @type {!Map.<!WebInspector.Database, !WebInspector.DatabaseTreeElement>} */
- this._databaseTreeElements = new Map();
- /** @type {!Map.<!WebInspector.DOMStorage, !WebInspector.DOMStorageItemsView>} */
- this._domStorageViews = new Map();
- /** @type {!Map.<!WebInspector.DOMStorage, !WebInspector.DOMStorageTreeElement>} */
- this._domStorageTreeElements = new Map();
- /** @type {!Object.<string, !WebInspector.CookieItemsView>} */
- this._cookieViews = {};
- /** @type {!Object.<string, boolean>} */
- this._domains = {};
- this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false);
- this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false);
- function viewGetter()
- {
- return this.visibleView;
- }
- WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
- if (WebInspector.resourceTreeModel.cachedResourcesLoaded())
- this._cachedResourcesLoaded();
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.Load, this._loadEventFired, this);
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._cachedResourcesLoaded, this);
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this._resetWithFrames, this);
- WebInspector.databaseModel.databases().forEach(this._addDatabase.bind(this));
- WebInspector.databaseModel.addEventListener(WebInspector.DatabaseModel.Events.DatabaseAdded, this._databaseAdded, this);
- }
- WebInspector.ResourcesPanel.prototype = {
- get statusBarItems()
- {
- return [this.storageViewStatusBarItemsContainer];
- },
- wasShown: function()
- {
- WebInspector.Panel.prototype.wasShown.call(this);
- this._initialize();
- },
- _initialize: function()
- {
- if (!this._initialized && this.isShowing() && this._cachedResourcesWereLoaded) {
- this._populateResourceTree();
- this._populateDOMStorageTree();
- this._populateApplicationCacheTree();
- this._initDefaultSelection();
- this._initialized = true;
- }
- },
- _loadEventFired: function()
- {
- this._initDefaultSelection();
- },
- _initDefaultSelection: function()
- {
- if (!this._initialized)
- return;
- var itemURL = WebInspector.settings.resourcesLastSelectedItem.get();
- if (itemURL) {
- for (var treeElement = this.sidebarTree.children[0]; treeElement; treeElement = treeElement.traverseNextTreeElement(false, this.sidebarTree, true)) {
- if (treeElement.itemURL === itemURL) {
- treeElement.revealAndSelect(true);
- return;
- }
- }
- }
- var mainResource = WebInspector.inspectedPageURL && this.resourcesListTreeElement && this.resourcesListTreeElement.expanded && WebInspector.resourceTreeModel.resourceForURL(WebInspector.inspectedPageURL);
- if (mainResource)
- this.showResource(mainResource);
- },
- _resetWithFrames: function()
- {
- this.resourcesListTreeElement.removeChildren();
- this._treeElementForFrameId = {};
- this._reset();
- },
- _reset: function()
- {
- this._domains = {};
- var queryViews = this._databaseQueryViews.values();
- for (var i = 0; i < queryViews.length; ++i)
- queryViews[i].removeEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
- this._databaseTableViews.clear();
- this._databaseQueryViews.clear();
- this._databaseTreeElements.clear();
- this._domStorageViews.clear();
- this._domStorageTreeElements.clear();
- this._cookieViews = {};
- this.databasesListTreeElement.removeChildren();
- this.localStorageListTreeElement.removeChildren();
- this.sessionStorageListTreeElement.removeChildren();
- this.cookieListTreeElement.removeChildren();
- if (this.visibleView && !(this.visibleView instanceof WebInspector.StorageCategoryView))
- this.visibleView.detach();
- this.storageViewStatusBarItemsContainer.removeChildren();
- if (this.sidebarTree.selectedTreeElement)
- this.sidebarTree.selectedTreeElement.deselect();
- },
- _populateResourceTree: function()
- {
- this._treeElementForFrameId = {};
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
- WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
- function populateFrame(frame)
- {
- this._frameAdded({data:frame});
- for (var i = 0; i < frame.childFrames.length; ++i)
- populateFrame.call(this, frame.childFrames[i]);
- var resources = frame.resources();
- for (var i = 0; i < resources.length; ++i)
- this._resourceAdded({data:resources[i]});
- }
- populateFrame.call(this, WebInspector.resourceTreeModel.mainFrame);
- },
- _frameAdded: function(event)
- {
- var frame = event.data;
- var parentFrame = frame.parentFrame;
- var parentTreeElement = parentFrame ? this._treeElementForFrameId[parentFrame.id] : this.resourcesListTreeElement;
- if (!parentTreeElement) {
- console.warn("No frame to route " + frame.url + " to.")
- return;
- }
- var frameTreeElement = new WebInspector.FrameTreeElement(this, frame);
- this._treeElementForFrameId[frame.id] = frameTreeElement;
- parentTreeElement.appendChild(frameTreeElement);
- },
- _frameDetached: function(event)
- {
- var frame = event.data;
- var frameTreeElement = this._treeElementForFrameId[frame.id];
- if (!frameTreeElement)
- return;
- delete this._treeElementForFrameId[frame.id];
- if (frameTreeElement.parent)
- frameTreeElement.parent.removeChild(frameTreeElement);
- },
- _resourceAdded: function(event)
- {
- var resource = event.data;
- var frameId = resource.frameId;
- if (resource.statusCode >= 301 && resource.statusCode <= 303)
- return;
- var frameTreeElement = this._treeElementForFrameId[frameId];
- if (!frameTreeElement) {
- // This is a frame's main resource, it will be retained
- // and re-added by the resource manager;
- return;
- }
- frameTreeElement.appendResource(resource);
- },
- _frameNavigated: function(event)
- {
- var frame = event.data;
- if (!frame.parentFrame)
- this._reset();
- var frameId = frame.id;
- var frameTreeElement = this._treeElementForFrameId[frameId];
- if (frameTreeElement)
- frameTreeElement.frameNavigated(frame);
- var applicationCacheFrameTreeElement = this._applicationCacheFrameElements[frameId];
- if (applicationCacheFrameTreeElement)
- applicationCacheFrameTreeElement.frameNavigated(frame);
- },
- _cachedResourcesLoaded: function()
- {
- this._cachedResourcesWereLoaded = true;
- this._initialize();
- },
- /**
- * @param {WebInspector.Event} event
- */
- _databaseAdded: function(event)
- {
- var database = /** @type {WebInspector.Database} */ (event.data);
- this._addDatabase(database);
- },
- /**
- * @param {WebInspector.Database} database
- */
- _addDatabase: function(database)
- {
- var databaseTreeElement = new WebInspector.DatabaseTreeElement(this, database);
- this._databaseTreeElements.put(database, databaseTreeElement);
- this.databasesListTreeElement.appendChild(databaseTreeElement);
- },
- addDocumentURL: function(url)
- {
- var parsedURL = url.asParsedURL();
- if (!parsedURL)
- return;
- var domain = parsedURL.host;
- if (!this._domains[domain]) {
- this._domains[domain] = true;
- var cookieDomainTreeElement = new WebInspector.CookieTreeElement(this, domain);
- this.cookieListTreeElement.appendChild(cookieDomainTreeElement);
- }
- },
- /**
- * @param {WebInspector.Event} event
- */
- _domStorageAdded: function(event)
- {
- var domStorage = /** @type {WebInspector.DOMStorage} */ (event.data);
- this._addDOMStorage(domStorage);
- },
- /**
- * @param {WebInspector.DOMStorage} domStorage
- */
- _addDOMStorage: function(domStorage)
- {
- console.assert(!this._domStorageTreeElements.get(domStorage));
- var domStorageTreeElement = new WebInspector.DOMStorageTreeElement(this, domStorage, (domStorage.isLocalStorage ? "local-storage" : "session-storage"));
- this._domStorageTreeElements.put(domStorage, domStorageTreeElement);
- if (domStorage.isLocalStorage)
- this.localStorageListTreeElement.appendChild(domStorageTreeElement);
- else
- this.sessionStorageListTreeElement.appendChild(domStorageTreeElement);
- },
- /**
- * @param {WebInspector.Event} event
- */
- _domStorageRemoved: function(event)
- {
- var domStorage = /** @type {WebInspector.DOMStorage} */ (event.data);
- this._removeDOMStorage(domStorage);
- },
- /**
- * @param {WebInspector.DOMStorage} domStorage
- */
- _removeDOMStorage: function(domStorage)
- {
- var treeElement = this._domStorageTreeElements.get(domStorage);
- if (!treeElement)
- return;
- var wasSelected = treeElement.selected;
- var parentListTreeElement = treeElement.parent;
- parentListTreeElement.removeChild(treeElement);
- if (wasSelected)
- parentListTreeElement.select();
- this._domStorageTreeElements.remove(treeElement);
- this._domStorageViews.remove(domStorage);
- },
- /**
- * @param {WebInspector.Database} database
- */
- selectDatabase: function(database)
- {
- if (database) {
- this._showDatabase(database);
- this._databaseTreeElements.get(database).select();
- }
- },
- /**
- * @param {WebInspector.DOMStorage} domStorage
- */
- selectDOMStorage: function(domStorage)
- {
- if (domStorage) {
- this._showDOMStorage(domStorage);
- this._domStorageTreeElements.get(domStorage).select();
- }
- },
- canShowAnchorLocation: function(anchor)
- {
- return !!WebInspector.resourceForURL(anchor.href);
- },
- showAnchorLocation: function(anchor)
- {
- var resource = WebInspector.resourceForURL(anchor.href);
- this.showResource(resource, anchor.lineNumber);
- },
- /**
- * @param {WebInspector.Resource} resource
- * @param {number=} line
- * @param {number=} column
- */
- showResource: function(resource, line, column)
- {
- var resourceTreeElement = this._findTreeElementForResource(resource);
- if (resourceTreeElement)
- resourceTreeElement.revealAndSelect(true);
- if (typeof line === "number") {
- var view = this._resourceViewForResource(resource);
- if (view.canHighlightPosition())
- view.highlightPosition(line, column);
- }
- return true;
- },
- _showResourceView: function(resource)
- {
- var view = this._resourceViewForResource(resource);
- if (!view) {
- this.visibleView.detach();
- return;
- }
- if (view.searchCanceled)
- view.searchCanceled();
- this._innerShowView(view);
- },
- _resourceViewForResource: function(resource)
- {
- if (WebInspector.ResourceView.hasTextContent(resource)) {
- var treeElement = this._findTreeElementForResource(resource);
- if (!treeElement)
- return null;
- return treeElement.sourceView();
- }
- return WebInspector.ResourceView.nonSourceViewForResource(resource);
- },
- /**
- * @param {WebInspector.Database} database
- * @param {string=} tableName
- */
- _showDatabase: function(database, tableName)
- {
- if (!database)
- return;
- var view;
- if (tableName) {
- var tableViews = this._databaseTableViews.get(database);
- if (!tableViews) {
- tableViews = /** @type {!Object.<string, !WebInspector.DatabaseTableView>} */ ({});
- this._databaseTableViews.put(database, tableViews);
- }
- view = tableViews[tableName];
- if (!view) {
- view = new WebInspector.DatabaseTableView(database, tableName);
- tableViews[tableName] = view;
- }
- } else {
- view = this._databaseQueryViews.get(database);
- if (!view) {
- view = new WebInspector.DatabaseQueryView(database);
- this._databaseQueryViews.put(database, view);
- view.addEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
- }
- }
- this._innerShowView(view);
- },
- /**
- * @param {WebInspector.View} view
- */
- showIndexedDB: function(view)
- {
- this._innerShowView(view);
- },
- /**
- * @param {WebInspector.DOMStorage} domStorage
- */
- _showDOMStorage: function(domStorage)
- {
- if (!domStorage)
- return;
- var view;
- view = this._domStorageViews.get(domStorage);
- if (!view) {
- view = new WebInspector.DOMStorageItemsView(domStorage);
- this._domStorageViews.put(domStorage, view);
- }
- this._innerShowView(view);
- },
- /**
- * @param {!WebInspector.CookieTreeElement} treeElement
- * @param {string} cookieDomain
- */
- showCookies: function(treeElement, cookieDomain)
- {
- var view = this._cookieViews[cookieDomain];
- if (!view) {
- view = new WebInspector.CookieItemsView(treeElement, cookieDomain);
- this._cookieViews[cookieDomain] = view;
- }
- this._innerShowView(view);
- },
- /**
- * @param {string} cookieDomain
- */
- clearCookies: function(cookieDomain)
- {
- this._cookieViews[cookieDomain].clear();
- },
- showApplicationCache: function(frameId)
- {
- if (!this._applicationCacheViews[frameId])
- this._applicationCacheViews[frameId] = new WebInspector.ApplicationCacheItemsView(this._applicationCacheModel, frameId);
- this._innerShowView(this._applicationCacheViews[frameId]);
- },
- /**
- * @param {WebInspector.View} view
- */
- showFileSystem: function(view)
- {
- this._innerShowView(view);
- },
- showCategoryView: function(categoryName)
- {
- if (!this._categoryView)
- this._categoryView = new WebInspector.StorageCategoryView();
- this._categoryView.setText(categoryName);
- this._innerShowView(this._categoryView);
- },
- _innerShowView: function(view)
- {
- if (this.visibleView === view)
- return;
- if (this.visibleView)
- this.visibleView.detach();
- view.show(this.storageViews);
- this.visibleView = view;
- this.storageViewStatusBarItemsContainer.removeChildren();
- var statusBarItems = view.statusBarItems || [];
- for (var i = 0; i < statusBarItems.length; ++i)
- this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]);
- },
- closeVisibleView: function()
- {
- if (!this.visibleView)
- return;
- this.visibleView.detach();
- delete this.visibleView;
- },
- _updateDatabaseTables: function(event)
- {
- var database = event.data;
- if (!database)
- return;
- var databasesTreeElement = this._databaseTreeElements.get(database);
- if (!databasesTreeElement)
- return;
- databasesTreeElement.shouldRefreshChildren = true;
- var tableViews = this._databaseTableViews.get(database);
- if (!tableViews)
- return;
- var tableNamesHash = {};
- var self = this;
- function tableNamesCallback(tableNames)
- {
- var tableNamesLength = tableNames.length;
- for (var i = 0; i < tableNamesLength; ++i)
- tableNamesHash[tableNames[i]] = true;
- for (var tableName in tableViews) {
- if (!(tableName in tableNamesHash)) {
- if (self.visibleView === tableViews[tableName])
- self.closeVisibleView();
- delete tableViews[tableName];
- }
- }
- }
- database.getTableNames(tableNamesCallback);
- },
- _populateDOMStorageTree: function()
- {
- WebInspector.domStorageModel.storages().forEach(this._addDOMStorage.bind(this));
- WebInspector.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DOMStorageAdded, this._domStorageAdded, this);
- WebInspector.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DOMStorageRemoved, this._domStorageRemoved, this);
- },
- _populateApplicationCacheTree: function()
- {
- this._applicationCacheModel = new WebInspector.ApplicationCacheModel();
- this._applicationCacheViews = {};
- this._applicationCacheFrameElements = {};
- this._applicationCacheManifestElements = {};
- this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestAdded, this._applicationCacheFrameManifestAdded, this);
- this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestRemoved, this._applicationCacheFrameManifestRemoved, this);
- this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestStatusUpdated, this._applicationCacheFrameManifestStatusChanged, this);
- this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.NetworkStateChanged, this._applicationCacheNetworkStateChanged, this);
- },
- _applicationCacheFrameManifestAdded: function(event)
- {
- var frameId = event.data;
- var manifestURL = this._applicationCacheModel.frameManifestURL(frameId);
- var status = this._applicationCacheModel.frameManifestStatus(frameId)
- var manifestTreeElement = this._applicationCacheManifestElements[manifestURL]
- if (!manifestTreeElement) {
- manifestTreeElement = new WebInspector.ApplicationCacheManifestTreeElement(this, manifestURL);
- this.applicationCacheListTreeElement.appendChild(manifestTreeElement);
- this._applicationCacheManifestElements[manifestURL] = manifestTreeElement;
- }
- var frameTreeElement = new WebInspector.ApplicationCacheFrameTreeElement(this, frameId, manifestURL);
- manifestTreeElement.appendChild(frameTreeElement);
- manifestTreeElement.expand();
- this._applicationCacheFrameElements[frameId] = frameTreeElement;
- },
- _applicationCacheFrameManifestRemoved: function(event)
- {
- var frameId = event.data;
- var frameTreeElement = this._applicationCacheFrameElements[frameId];
- if (!frameTreeElement)
- return;
- var manifestURL = frameTreeElement.manifestURL;
- delete this._applicationCacheFrameElements[frameId];
- delete this._applicationCacheViews[frameId];
- frameTreeElement.parent.removeChild(frameTreeElement);
- var manifestTreeElement = this._applicationCacheManifestElements[manifestURL];
- if (manifestTreeElement.children.length !== 0)
- return;
- delete this._applicationCacheManifestElements[manifestURL];
- manifestTreeElement.parent.removeChild(manifestTreeElement);
- },
- _applicationCacheFrameManifestStatusChanged: function(event)
- {
- var frameId = event.data;
- var status = this._applicationCacheModel.frameManifestStatus(frameId)
- if (this._applicationCacheViews[frameId])
- this._applicationCacheViews[frameId].updateStatus(status);
- },
- _applicationCacheNetworkStateChanged: function(event)
- {
- var isNowOnline = event.data;
- for (var manifestURL in this._applicationCacheViews)
- this._applicationCacheViews[manifestURL].updateNetworkState(isNowOnline);
- },
- sidebarResized: function(event)
- {
- var width = event.data;
- this.storageViewStatusBarItemsContainer.style.left = width + "px";
- },
- /**
- * @param {string} query
- * @param {boolean} shouldJump
- */
- performSearch: function(query, shouldJump)
- {
- this._resetSearchResults();
- var regex = WebInspector.SourceFrame.createSearchRegex(query);
- var totalMatchesCount = 0;
- /**
- * @param {WebInspector.Resource} resource
- * @param {number} matchesCount
- */
- function addMatchesToResource(resource, matchesCount)
- {
- this._findTreeElementForResource(resource).searchMatchesFound(matchesCount);
- totalMatchesCount += matchesCount;
- }
- /**
- * @param {?Protocol.Error} error
- * @param {Array.<PageAgent.SearchResult>} result
- */
- function searchInResourcesCallback(error, result)
- {
- if (error)
- return;
- for (var i = 0; i < result.length; i++) {
- var searchResult = result[i];
- var frameTreeElement = this._treeElementForFrameId[searchResult.frameId];
- if (!frameTreeElement)
- continue;
- var resource = frameTreeElement.resourceByURL(searchResult.url);
- // FIXME: When the same script is used in several frames and this script contains at least
- // one search result then some search results can not be matched with a resource on panel.
- // https://bugs.webkit.org/show_bug.cgi?id=66005
- if (!resource)
- continue;
- addMatchesToResource.call(this, resource, searchResult.matchesCount)
- }
- if (!--callbacksLeft)
- searchFinished.call(this);
- }
- /**
- * @param {WebInspector.Resource} resource
- * @param {Array.<WebInspector.ContentProvider.SearchMatch>} result
- */
- function searchInContentCallback(resource, result)
- {
- addMatchesToResource.call(this, resource, result.length);
- if (!--callbacksLeft)
- searchFinished.call(this);
- }
- function searchFinished()
- {
- WebInspector.searchController.updateSearchMatchesCount(totalMatchesCount, this);
- this._searchController = new WebInspector.ResourcesSearchController(this.resourcesListTreeElement, totalMatchesCount);
- if (shouldJump && this.sidebarTree.selectedTreeElement && this.sidebarTree.selectedTreeElement.searchMatchesCount)
- this.jumpToNextSearchResult();
- }
- var frames = WebInspector.resourceTreeModel.frames();
- var callbacksLeft = 1 + frames.length;
- for (var i = 0; i < frames.length; ++i) {
- var mainResource = frames[i].mainResource;
- mainResource.searchInContent(regex.source, !regex.ignoreCase, true, searchInContentCallback.bind(this, mainResource));
- }
- PageAgent.searchInResources(regex.source, !regex.ignoreCase, true, searchInResourcesCallback.bind(this));
- },
- _ensureViewSearchPerformed: function(callback)
- {
- function viewSearchPerformedCallback(searchId)
- {
- if (searchId !== this._lastViewSearchId)
- return; // Search is obsolete.
- this._viewSearchInProgress = false;
- callback();
- }
- if (!this._viewSearchInProgress) {
- if (!this.visibleView.hasSearchResults()) {
- // We give id to each search, so that we can skip callbacks for obsolete searches.
- this._lastViewSearchId = this._lastViewSearchId ? this._lastViewSearchId + 1 : 0;
- this._viewSearchInProgress = true;
- this.visibleView.performSearch(this.currentQuery, false, viewSearchPerformedCallback.bind(this, this._lastViewSearchId));
- } else
- callback();
- }
- },
- _showSearchResult: function(searchResult)
- {
- this._lastSearchResultIndex = searchResult.index;
- this._lastSearchResultTreeElement = searchResult.treeElement;
- // At first show view for treeElement.
- if (searchResult.treeElement !== this.sidebarTree.selectedTreeElement)
- this.showResource(searchResult.treeElement.representedObject);
- function callback(searchId)
- {
- if (this.sidebarTree.selectedTreeElement !== this._lastSearchResultTreeElement)
- return; // User has selected another view while we were searching.
- if (this._lastSearchResultIndex != -1)
- this.visibleView.jumpToSearchResult(this._lastSearchResultIndex);
- WebInspector.searchController.updateCurrentMatchIndex(searchResult.currentMatchIndex - 1, this);
- }
- // Then run SourceFrame search if needed and jump to search result index when done.
- this._ensureViewSearchPerformed(callback.bind(this));
- },
- _resetSearchResults: function()
- {
- function callback(resourceTreeElement)
- {
- resourceTreeElement._resetSearchResults();
- }
- this._forAllResourceTreeElements(callback);
- if (this.visibleView && this.visibleView.searchCanceled)
- this.visibleView.searchCanceled();
- this._lastSearchResultTreeElement = null;
- this._lastSearchResultIndex = -1;
- this._viewSearchInProgress = false;
- },
- searchCanceled: function()
- {
- function callback(resourceTreeElement)
- {
- resourceTreeElement._updateErrorsAndWarningsBubbles();
- }
- WebInspector.searchController.updateSearchMatchesCount(0, this);
- this._resetSearchResults();
- this._forAllResourceTreeElements(callback);
- },
- jumpToNextSearchResult: function()
- {
- if (!this.currentSearchMatches)
- return;
- var currentTreeElement = this.sidebarTree.selectedTreeElement;
- var nextSearchResult = this._searchController.nextSearchResult(currentTreeElement);
- this._showSearchResult(nextSearchResult);
- },
- jumpToPreviousSearchResult: function()
- {
- if (!this.currentSearchMatches)
- return;
- var currentTreeElement = this.sidebarTree.selectedTreeElement;
- var previousSearchResult = this._searchController.previousSearchResult(currentTreeElement);
- this._showSearchResult(previousSearchResult);
- },
- _forAllResourceTreeElements: function(callback)
- {
- var stop = false;
- for (var treeElement = this.resourcesListTreeElement; !stop && treeElement; treeElement = treeElement.traverseNextTreeElement(false, this.resourcesListTreeElement, true)) {
- if (treeElement instanceof WebInspector.FrameResourceTreeElement)
- stop = callback(treeElement);
- }
- },
- _findTreeElementForResource: function(resource)
- {
- function isAncestor(ancestor, object)
- {
- // Redirects, XHRs do not belong to the tree, it is fine to silently return false here.
- return false;
- }
- function getParent(object)
- {
- // Redirects, XHRs do not belong to the tree, it is fine to silently return false here.
- return null;
- }
- return this.sidebarTree.findTreeElement(resource, isAncestor, getParent);
- },
- showView: function(view)
- {
- if (view)
- this.showResource(view.resource);
- },
- _onmousemove: function(event)
- {
- var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY);
- if (!nodeUnderMouse)
- return;
- var listNode = nodeUnderMouse.enclosingNodeOrSelfWithNodeName("li");
- if (!listNode)
- return;
- var element = listNode.treeElement;
- if (this._previousHoveredElement === element)
- return;
- if (this._previousHoveredElement) {
- this._previousHoveredElement.hovered = false;
- delete this._previousHoveredElement;
- }
- if (element instanceof WebInspector.FrameTreeElement) {
- this._previousHoveredElement = element;
- element.hovered = true;
- }
- },
- _onmouseout: function(event)
- {
- if (this._previousHoveredElement) {
- this._previousHoveredElement.hovered = false;
- delete this._previousHoveredElement;
- }
- },
- __proto__: WebInspector.Panel.prototype
- }
- /**
- * @constructor
- * @extends {TreeElement}
- * @param {boolean=} hasChildren
- * @param {boolean=} noIcon
- */
- WebInspector.BaseStorageTreeElement = function(storagePanel, representedObject, title, iconClasses, hasChildren, noIcon)
- {
- TreeElement.call(this, "", representedObject, hasChildren);
- this._storagePanel = storagePanel;
- this._titleText = title;
- this._iconClasses = iconClasses;
- this._noIcon = noIcon;
- }
- WebInspector.BaseStorageTreeElement.prototype = {
- onattach: function()
- {
- this.listItemElement.removeChildren();
- if (this._iconClasses) {
- for (var i = 0; i < this._iconClasses.length; ++i)
- this.listItemElement.addStyleClass(this._iconClasses[i]);
- }
- var selectionElement = document.createElement("div");
- selectionElement.className = "selection";
- this.listItemElement.appendChild(selectionElement);
- if (!this._noIcon) {
- this.imageElement = document.createElement("img");
- this.imageElement.className = "icon";
- this.listItemElement.appendChild(this.imageElement);
- }
- this.titleElement = document.createElement("div");
- this.titleElement.className = "base-storage-tree-element-title";
- this._titleTextNode = document.createTextNode("");
- this.titleElement.appendChild(this._titleTextNode);
- this._updateTitle();
- this._updateSubtitle();
- this.listItemElement.appendChild(this.titleElement);
- },
- get displayName()
- {
- return this._displayName;
- },
- _updateDisplayName: function()
- {
- this._displayName = this._titleText || "";
- if (this._subtitleText)
- this._displayName += " (" + this._subtitleText + ")";
- },
- _updateTitle: function()
- {
- this._updateDisplayName();
- if (!this.titleElement)
- return;
- this._titleTextNode.textContent = this._titleText || "";
- },
- _updateSubtitle: function()
- {
- this._updateDisplayName();
- if (!this.titleElement)
- return;
- if (this._subtitleText) {
- if (!this._subtitleElement) {
- this._subtitleElement = document.createElement("span");
- this._subtitleElement.className = "base-storage-tree-element-subtitle";
- this.titleElement.appendChild(this._subtitleElement);
- }
- this._subtitleElement.textContent = "(" + this._subtitleText + ")";
- } else if (this._subtitleElement) {
- this.titleElement.removeChild(this._subtitleElement);
- delete this._subtitleElement;
- }
- },
- onselect: function(selectedByUser)
- {
- if (!selectedByUser)
- return;
- var itemURL = this.itemURL;
- if (itemURL)
- WebInspector.settings.resourcesLastSelectedItem.set(itemURL);
- },
- onreveal: function()
- {
- if (this.listItemElement)
- this.listItemElement.scrollIntoViewIfNeeded(false);
- },
- get titleText()
- {
- return this._titleText;
- },
- set titleText(titleText)
- {
- this._titleText = titleText;
- this._updateTitle();
- },
- get subtitleText()
- {
- return this._subtitleText;
- },
- set subtitleText(subtitleText)
- {
- this._subtitleText = subtitleText;
- this._updateSubtitle();
- },
- get searchMatchesCount()
- {
- return 0;
- },
- __proto__: TreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- * @param {boolean=} noIcon
- */
- WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClasses, noIcon)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClasses, true, noIcon);
- this._expandedSettingKey = "resources" + settingsKey + "Expanded";
- WebInspector.settings[this._expandedSettingKey] = WebInspector.settings.createSetting(this._expandedSettingKey, settingsKey === "Frames");
- this._categoryName = categoryName;
- }
- WebInspector.StorageCategoryTreeElement.prototype = {
- get itemURL()
- {
- return "category://" + this._categoryName;
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel.showCategoryView(this._categoryName);
- },
- onattach: function()
- {
- WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
- if (WebInspector.settings[this._expandedSettingKey].get())
- this.expand();
- },
- onexpand: function()
- {
- WebInspector.settings[this._expandedSettingKey].set(true);
- },
- oncollapse: function()
- {
- WebInspector.settings[this._expandedSettingKey].set(false);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.FrameTreeElement = function(storagePanel, frame)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, "", ["frame-storage-tree-item"]);
- this._frame = frame;
- this.frameNavigated(frame);
- }
- WebInspector.FrameTreeElement.prototype = {
- frameNavigated: function(frame)
- {
- this.removeChildren();
- this._frameId = frame.id;
- this.titleText = frame.name;
- this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
- this._categoryElements = {};
- this._treeElementForResource = {};
- this._storagePanel.addDocumentURL(frame.url);
- },
- get itemURL()
- {
- return "frame://" + encodeURI(this.displayName);
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel.showCategoryView(this.displayName);
- this.listItemElement.removeStyleClass("hovered");
- DOMAgent.hideHighlight();
- },
- set hovered(hovered)
- {
- if (hovered) {
- this.listItemElement.addStyleClass("hovered");
- DOMAgent.highlightFrame(this._frameId, WebInspector.Color.PageHighlight.Content.toProtocolRGBA(), WebInspector.Color.PageHighlight.ContentOutline.toProtocolRGBA());
- } else {
- this.listItemElement.removeStyleClass("hovered");
- DOMAgent.hideHighlight();
- }
- },
- appendResource: function(resource)
- {
- if (resource.isHidden())
- return;
- var categoryName = resource.type.name();
- var categoryElement = resource.type === WebInspector.resourceTypes.Document ? this : this._categoryElements[categoryName];
- if (!categoryElement) {
- categoryElement = new WebInspector.StorageCategoryTreeElement(this._storagePanel, resource.type.categoryTitle(), categoryName, null, true);
- this._categoryElements[resource.type.name()] = categoryElement;
- this._insertInPresentationOrder(this, categoryElement);
- }
- var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this._storagePanel, resource);
- this._insertInPresentationOrder(categoryElement, resourceTreeElement);
- this._treeElementForResource[resource.url] = resourceTreeElement;
- },
- resourceByURL: function(url)
- {
- var treeElement = this._treeElementForResource[url];
- return treeElement ? treeElement.representedObject : null;
- },
- appendChild: function(treeElement)
- {
- this._insertInPresentationOrder(this, treeElement);
- },
- _insertInPresentationOrder: function(parentTreeElement, childTreeElement)
- {
- // Insert in the alphabetical order, first frames, then resources. Document resource goes last.
- function typeWeight(treeElement)
- {
- if (treeElement instanceof WebInspector.StorageCategoryTreeElement)
- return 2;
- if (treeElement instanceof WebInspector.FrameTreeElement)
- return 1;
- return 3;
- }
- function compare(treeElement1, treeElement2)
- {
- var typeWeight1 = typeWeight(treeElement1);
- var typeWeight2 = typeWeight(treeElement2);
- var result;
- if (typeWeight1 > typeWeight2)
- result = 1;
- else if (typeWeight1 < typeWeight2)
- result = -1;
- else {
- var title1 = treeElement1.displayName || treeElement1.titleText;
- var title2 = treeElement2.displayName || treeElement2.titleText;
- result = title1.localeCompare(title2);
- }
- return result;
- }
- var children = parentTreeElement.children;
- var i;
- for (i = 0; i < children.length; ++i) {
- if (compare(childTreeElement, children[i]) < 0)
- break;
- }
- parentTreeElement.insertChild(childTreeElement, i);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.FrameResourceTreeElement = function(storagePanel, resource)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource, resource.displayName, ["resource-sidebar-tree-item", "resources-type-" + resource.type.name()]);
- this._resource = resource;
- this._resource.addEventListener(WebInspector.Resource.Events.MessageAdded, this._consoleMessageAdded, this);
- this._resource.addEventListener(WebInspector.Resource.Events.MessagesCleared, this._consoleMessagesCleared, this);
- this.tooltip = resource.url;
- }
- WebInspector.FrameResourceTreeElement.prototype = {
- get itemURL()
- {
- return this._resource.url;
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel._showResourceView(this._resource);
- },
- ondblclick: function(event)
- {
- InspectorFrontendHost.openInNewTab(this._resource.url);
- },
- onattach: function()
- {
- WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
- if (this._resource.type === WebInspector.resourceTypes.Image) {
- var previewImage = document.createElement("img");
- previewImage.className = "image-resource-icon-preview";
- this._resource.populateImageSource(previewImage);
- var iconElement = document.createElement("div");
- iconElement.className = "icon";
- iconElement.appendChild(previewImage);
- this.listItemElement.replaceChild(iconElement, this.imageElement);
- }
- this._statusElement = document.createElement("div");
- this._statusElement.className = "status";
- this.listItemElement.insertBefore(this._statusElement, this.titleElement);
- this.listItemElement.draggable = true;
- this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
- this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
- this._updateErrorsAndWarningsBubbles();
- },
- _ondragstart: function(event)
- {
- event.dataTransfer.setData("text/plain", this._resource.content);
- event.dataTransfer.effectAllowed = "copy";
- return true;
- },
- _handleContextMenuEvent: function(event)
- {
- var contextMenu = new WebInspector.ContextMenu(event);
- contextMenu.appendApplicableItems(this._resource);
- contextMenu.show();
- },
- _setBubbleText: function(x)
- {
- if (!this._bubbleElement) {
- this._bubbleElement = document.createElement("div");
- this._bubbleElement.className = "bubble";
- this._statusElement.appendChild(this._bubbleElement);
- }
- this._bubbleElement.textContent = x;
- },
- _resetBubble: function()
- {
- if (this._bubbleElement) {
- this._bubbleElement.textContent = "";
- this._bubbleElement.removeStyleClass("search-matches");
- this._bubbleElement.removeStyleClass("warning");
- this._bubbleElement.removeStyleClass("error");
- }
- },
- _resetSearchResults: function()
- {
- this._resetBubble();
- this._searchMatchesCount = 0;
- },
- get searchMatchesCount()
- {
- return this._searchMatchesCount;
- },
- searchMatchesFound: function(matchesCount)
- {
- this._resetSearchResults();
- this._searchMatchesCount = matchesCount;
- this._setBubbleText(matchesCount);
- this._bubbleElement.addStyleClass("search-matches");
- // Expand, do not scroll into view.
- var currentAncestor = this.parent;
- while (currentAncestor && !currentAncestor.root) {
- if (!currentAncestor.expanded)
- currentAncestor.expand();
- currentAncestor = currentAncestor.parent;
- }
- },
- _updateErrorsAndWarningsBubbles: function()
- {
- if (this._storagePanel.currentQuery)
- return;
- this._resetBubble();
- if (this._resource.warnings || this._resource.errors)
- this._setBubbleText(this._resource.warnings + this._resource.errors);
- if (this._resource.warnings)
- this._bubbleElement.addStyleClass("warning");
- if (this._resource.errors)
- this._bubbleElement.addStyleClass("error");
- },
- _consoleMessagesCleared: function()
- {
- // FIXME: move to the SourceFrame.
- if (this._sourceView)
- this._sourceView.clearMessages();
- this._updateErrorsAndWarningsBubbles();
- },
- _consoleMessageAdded: function(event)
- {
- var msg = event.data;
- if (this._sourceView)
- this._sourceView.addMessage(msg);
- this._updateErrorsAndWarningsBubbles();
- },
- sourceView: function()
- {
- if (!this._sourceView) {
- this._sourceView = new WebInspector.ResourceSourceFrame(this._resource);
- if (this._resource.messages) {
- for (var i = 0; i < this._resource.messages.length; i++)
- this._sourceView.addMessage(this._resource.messages[i]);
- }
- }
- return this._sourceView;
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- * @param {WebInspector.Database} database
- */
- WebInspector.DatabaseTreeElement = function(storagePanel, database)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, database.name, ["database-storage-tree-item"], true);
- this._database = database;
- }
- WebInspector.DatabaseTreeElement.prototype = {
- get itemURL()
- {
- return "database://" + encodeURI(this._database.name);
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel._showDatabase(this._database);
- },
- onexpand: function()
- {
- this._updateChildren();
- },
- _updateChildren: function()
- {
- this.removeChildren();
- function tableNamesCallback(tableNames)
- {
- var tableNamesLength = tableNames.length;
- for (var i = 0; i < tableNamesLength; ++i)
- this.appendChild(new WebInspector.DatabaseTableTreeElement(this._storagePanel, this._database, tableNames[i]));
- }
- this._database.getTableNames(tableNamesCallback.bind(this));
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.DatabaseTableTreeElement = function(storagePanel, database, tableName)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, tableName, ["database-storage-tree-item"]);
- this._database = database;
- this._tableName = tableName;
- }
- WebInspector.DatabaseTableTreeElement.prototype = {
- get itemURL()
- {
- return "database://" + encodeURI(this._database.name) + "/" + encodeURI(this._tableName);
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel._showDatabase(this._database, this._tableName);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.StorageCategoryTreeElement}
- * @param {WebInspector.ResourcesPanel} storagePanel
- */
- WebInspector.IndexedDBTreeElement = function(storagePanel)
- {
- WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspector.UIString("IndexedDB"), "IndexedDB", ["indexed-db-storage-tree-item"]);
- }
- WebInspector.IndexedDBTreeElement.prototype = {
- onexpand: function()
- {
- WebInspector.StorageCategoryTreeElement.prototype.onexpand.call(this);
- if (!this._indexedDBModel)
- this._createIndexedDBModel();
- },
- onattach: function()
- {
- WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
- this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
- },
- _handleContextMenuEvent: function(event)
- {
- var contextMenu = new WebInspector.ContextMenu(event);
- contextMenu.appendItem(WebInspector.UIString("Refresh IndexedDB"), this.refreshIndexedDB.bind(this));
- contextMenu.show();
- },
- _createIndexedDBModel: function()
- {
- this._indexedDBModel = new WebInspector.IndexedDBModel();
- this._idbDatabaseTreeElements = [];
- this._indexedDBModel.addEventListener(WebInspector.IndexedDBModel.EventTypes.DatabaseAdded, this._indexedDBAdded, this);
- this._indexedDBModel.addEventListener(WebInspector.IndexedDBModel.EventTypes.DatabaseRemoved, this._indexedDBRemoved, this);
- this._indexedDBModel.addEventListener(WebInspector.IndexedDBModel.EventTypes.DatabaseLoaded, this._indexedDBLoaded, this);
- },
- refreshIndexedDB: function()
- {
- if (!this._indexedDBModel) {
- this._createIndexedDBModel();
- return;
- }
- this._indexedDBModel.refreshDatabaseNames();
- },
- /**
- * @param {WebInspector.Event} event
- */
- _indexedDBAdded: function(event)
- {
- var databaseId = /** @type {WebInspector.IndexedDBModel.DatabaseId} */ (event.data);
- var idbDatabaseTreeElement = new WebInspector.IDBDatabaseTreeElement(this._storagePanel, this._indexedDBModel, databaseId);
- this._idbDatabaseTreeElements.push(idbDatabaseTreeElement);
- this.appendChild(idbDatabaseTreeElement);
- this._indexedDBModel.refreshDatabase(databaseId);
- },
- /**
- * @param {WebInspector.Event} event
- */
- _indexedDBRemoved: function(event)
- {
- var databaseId = /** @type {WebInspector.IndexedDBModel.DatabaseId} */ (event.data);
- var idbDatabaseTreeElement = this._idbDatabaseTreeElement(databaseId)
- if (!idbDatabaseTreeElement)
- return;
- idbDatabaseTreeElement.clear();
- this.removeChild(idbDatabaseTreeElement);
- this._idbDatabaseTreeElements.remove(idbDatabaseTreeElement);
- },
- /**
- * @param {WebInspector.Event} event
- */
- _indexedDBLoaded: function(event)
- {
- var database = /** @type {WebInspector.IndexedDBModel.Database} */ (event.data);
- var idbDatabaseTreeElement = this._idbDatabaseTreeElement(database.databaseId)
- if (!idbDatabaseTreeElement)
- return;
- idbDatabaseTreeElement.update(database);
- },
- /**
- * @param {WebInspector.IndexedDBModel.DatabaseId} databaseId
- * @return {WebInspector.IDBDatabaseTreeElement}
- */
- _idbDatabaseTreeElement: function(databaseId)
- {
- var index = -1;
- for (var i = 0; i < this._idbDatabaseTreeElements.length; ++i) {
- if (this._idbDatabaseTreeElements[i]._databaseId.equals(databaseId)) {
- index = i;
- break;
- }
- }
- if (index !== -1)
- return this._idbDatabaseTreeElements[i];
- return null;
- },
- __proto__: WebInspector.StorageCategoryTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.StorageCategoryTreeElement}
- * @param {WebInspector.ResourcesPanel} storagePanel
- */
- WebInspector.FileSystemListTreeElement = function(storagePanel)
- {
- WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspector.UIString("FileSystem"), "FileSystem", ["file-system-storage-tree-item"]);
- }
- WebInspector.FileSystemListTreeElement.prototype = {
- onexpand: function()
- {
- WebInspector.StorageCategoryTreeElement.prototype.onexpand.call(this);
- this._refreshFileSystem();
- },
- onattach: function()
- {
- WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
- this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
- },
- _handleContextMenuEvent: function(event)
- {
- var contextMenu = new WebInspector.ContextMenu(event);
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Refresh FileSystem list" : "Refresh FileSystem List"), this._refreshFileSystem.bind(this));
- contextMenu.show();
- },
- _fileSystemAdded: function(event)
- {
- var fileSystem = /** @type {WebInspector.FileSystemModel.FileSystem} */ (event.data);
- var fileSystemTreeElement = new WebInspector.FileSystemTreeElement(this._storagePanel, fileSystem);
- this.appendChild(fileSystemTreeElement);
- },
- _fileSystemRemoved: function(event)
- {
- var fileSystem = /** @type {WebInspector.FileSystemModel.FileSystem} */ (event.data);
- var fileSystemTreeElement = this._fileSystemTreeElementByName(fileSystem.name);
- if (!fileSystemTreeElement)
- return;
- fileSystemTreeElement.clear();
- this.removeChild(fileSystemTreeElement);
- },
- _fileSystemTreeElementByName: function(fileSystemName)
- {
- for (var i = 0; i < this.children.length; ++i) {
- var child = /** @type {WebInspector.FileSystemTreeElement} */ (this.children[i]);
- if (child.fileSystemName === fileSystemName)
- return this.children[i];
- }
- return null;
- },
- _refreshFileSystem: function()
- {
- if (!this._fileSystemModel) {
- this._fileSystemModel = new WebInspector.FileSystemModel();
- this._fileSystemModel.addEventListener(WebInspector.FileSystemModel.EventTypes.FileSystemAdded, this._fileSystemAdded, this);
- this._fileSystemModel.addEventListener(WebInspector.FileSystemModel.EventTypes.FileSystemRemoved, this._fileSystemRemoved, this);
- }
- this._fileSystemModel.refreshFileSystemList();
- },
- __proto__: WebInspector.StorageCategoryTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- * @param {WebInspector.ResourcesPanel} storagePanel
- * @param {WebInspector.IndexedDBModel} model
- * @param {WebInspector.IndexedDBModel.DatabaseId} databaseId
- */
- WebInspector.IDBDatabaseTreeElement = function(storagePanel, model, databaseId)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, databaseId.name + " - " + databaseId.securityOrigin, ["indexed-db-storage-tree-item"]);
- this._model = model;
- this._databaseId = databaseId;
- this._idbObjectStoreTreeElements = {};
- }
- WebInspector.IDBDatabaseTreeElement.prototype = {
- get itemURL()
- {
- return "indexedDB://" + this._databaseId.securityOrigin + "/" + this._databaseId.name;
- },
- onattach: function()
- {
- WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
- this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
- },
- _handleContextMenuEvent: function(event)
- {
- var contextMenu = new WebInspector.ContextMenu(event);
- contextMenu.appendItem(WebInspector.UIString("Refresh IndexedDB"), this._refreshIndexedDB.bind(this));
- contextMenu.show();
- },
- _refreshIndexedDB: function()
- {
- this._model.refreshDatabaseNames();
- },
- /**
- * @param {WebInspector.IndexedDBModel.Database} database
- */
- update: function(database)
- {
- this._database = database;
- var objectStoreNames = {};
- for (var objectStoreName in this._database.objectStores) {
- var objectStore = this._database.objectStores[objectStoreName];
- objectStoreNames[objectStore.name] = true;
- if (!this._idbObjectStoreTreeElements[objectStore.name]) {
- var idbObjectStoreTreeElement = new WebInspector.IDBObjectStoreTreeElement(this._storagePanel, this._model, this._databaseId, objectStore);
- this._idbObjectStoreTreeElements[objectStore.name] = idbObjectStoreTreeElement;
- this.appendChild(idbObjectStoreTreeElement);
- }
- this._idbObjectStoreTreeElements[objectStore.name].update(objectStore);
- }
- for (var objectStoreName in this._idbObjectStoreTreeElements) {
- if (!objectStoreNames[objectStoreName])
- this._objectStoreRemoved(objectStoreName);
- }
- if (this.children.length) {
- this.hasChildren = true;
- this.expand();
- }
- if (this._view)
- this._view.update(database);
- this._updateTooltip();
- },
- _updateTooltip: function()
- {
- this.tooltip = WebInspector.UIString("Version") + ": " + this._database.version;
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- if (!this._view)
- this._view = new WebInspector.IDBDatabaseView(this._database);
- this._storagePanel.showIndexedDB(this._view);
- },
- /**
- * @param {string} objectStoreName
- */
- _objectStoreRemoved: function(objectStoreName)
- {
- var objectStoreTreeElement = this._idbObjectStoreTreeElements[objectStoreName];
- objectStoreTreeElement.clear();
- this.removeChild(objectStoreTreeElement);
- delete this._idbObjectStoreTreeElements[objectStoreName];
- },
- clear: function()
- {
- for (var objectStoreName in this._idbObjectStoreTreeElements)
- this._objectStoreRemoved(objectStoreName);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- * @param {WebInspector.ResourcesPanel} storagePanel
- * @param {WebInspector.IndexedDBModel} model
- * @param {WebInspector.IndexedDBModel.DatabaseId} databaseId
- * @param {WebInspector.IndexedDBModel.ObjectStore} objectStore
- */
- WebInspector.IDBObjectStoreTreeElement = function(storagePanel, model, databaseId, objectStore)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, objectStore.name, ["indexed-db-object-store-storage-tree-item"]);
- this._model = model;
- this._databaseId = databaseId;
- this._idbIndexTreeElements = {};
- }
- WebInspector.IDBObjectStoreTreeElement.prototype = {
- get itemURL()
- {
- return "indexedDB://" + this._databaseId.securityOrigin + "/" + this._databaseId.name + "/" + this._objectStore.name;
- },
- onattach: function()
- {
- WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
- this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
- },
- _handleContextMenuEvent: function(event)
- {
- var contextMenu = new WebInspector.ContextMenu(event);
- contextMenu.appendItem(WebInspector.UIString("Clear"), this._clearObjectStore.bind(this));
- contextMenu.show();
- },
- _clearObjectStore: function()
- {
- function callback() {
- this.update(this._objectStore);
- }
- this._model.clearObjectStore(this._databaseId, this._objectStore.name, callback.bind(this));
- },
- /**
- * @param {WebInspector.IndexedDBModel.ObjectStore} objectStore
- */
- update: function(objectStore)
- {
- this._objectStore = objectStore;
- var indexNames = {};
- for (var indexName in this._objectStore.indexes) {
- var index = this._objectStore.indexes[indexName];
- indexNames[index.name] = true;
- if (!this._idbIndexTreeElements[index.name]) {
- var idbIndexTreeElement = new WebInspector.IDBIndexTreeElement(this._storagePanel, this._model, this._databaseId, this._objectStore, index);
- this._idbIndexTreeElements[index.name] = idbIndexTreeElement;
- this.appendChild(idbIndexTreeElement);
- }
- this._idbIndexTreeElements[index.name].update(index);
- }
- for (var indexName in this._idbIndexTreeElements) {
- if (!indexNames[indexName])
- this._indexRemoved(indexName);
- }
- for (var indexName in this._idbIndexTreeElements) {
- if (!indexNames[indexName]) {
- this.removeChild(this._idbIndexTreeElements[indexName]);
- delete this._idbIndexTreeElements[indexName];
- }
- }
- if (this.children.length) {
- this.hasChildren = true;
- this.expand();
- }
- if (this._view)
- this._view.update(this._objectStore);
- this._updateTooltip();
- },
- _updateTooltip: function()
- {
- var keyPathString = this._objectStore.keyPathString;
- var tooltipString = keyPathString !== null ? (WebInspector.UIString("Key path: ") + keyPathString) : "";
- if (this._objectStore.autoIncrement)
- tooltipString += "\n" + WebInspector.UIString("autoIncrement");
- this.tooltip = tooltipString
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- if (!this._view)
- this._view = new WebInspector.IDBDataView(this._model, this._databaseId, this._objectStore, null);
- this._storagePanel.showIndexedDB(this._view);
- },
- /**
- * @param {string} indexName
- */
- _indexRemoved: function(indexName)
- {
- var indexTreeElement = this._idbIndexTreeElements[indexName];
- indexTreeElement.clear();
- this.removeChild(indexTreeElement);
- delete this._idbIndexTreeElements[indexName];
- },
- clear: function()
- {
- for (var indexName in this._idbIndexTreeElements)
- this._indexRemoved(indexName);
- if (this._view)
- this._view.clear();
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- * @param {WebInspector.ResourcesPanel} storagePanel
- * @param {WebInspector.IndexedDBModel} model
- * @param {WebInspector.IndexedDBModel.DatabaseId} databaseId
- * @param {WebInspector.IndexedDBModel.ObjectStore} objectStore
- * @param {WebInspector.IndexedDBModel.Index} index
- */
- WebInspector.IDBIndexTreeElement = function(storagePanel, model, databaseId, objectStore, index)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, index.name, ["indexed-db-index-storage-tree-item"]);
- this._model = model;
- this._databaseId = databaseId;
- this._objectStore = objectStore;
- this._index = index;
- }
- WebInspector.IDBIndexTreeElement.prototype = {
- get itemURL()
- {
- return "indexedDB://" + this._databaseId.securityOrigin + "/" + this._databaseId.name + "/" + this._objectStore.name + "/" + this._index.name;
- },
- /**
- * @param {WebInspector.IndexedDBModel.Index} index
- */
- update: function(index)
- {
- this._index = index;
- if (this._view)
- this._view.update(this._index);
- this._updateTooltip();
- },
- _updateTooltip: function()
- {
- var tooltipLines = [];
- var keyPathString = this._index.keyPathString;
- tooltipLines.push(WebInspector.UIString("Key path: ") + keyPathString);
- if (this._index.unique)
- tooltipLines.push(WebInspector.UIString("unique"));
- if (this._index.multiEntry)
- tooltipLines.push(WebInspector.UIString("multiEntry"));
- this.tooltip = tooltipLines.join("\n");
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- if (!this._view)
- this._view = new WebInspector.IDBDataView(this._model, this._databaseId, this._objectStore, this._index);
- this._storagePanel.showIndexedDB(this._view);
- },
- clear: function()
- {
- if (this._view)
- this._view.clear();
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.DOMStorageTreeElement = function(storagePanel, domStorage, className)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, domStorage.securityOrigin ? domStorage.securityOrigin : WebInspector.UIString("Local Files"), ["domstorage-storage-tree-item", className]);
- this._domStorage = domStorage;
- }
- WebInspector.DOMStorageTreeElement.prototype = {
- get itemURL()
- {
- return "storage://" + this._domStorage.securityOrigin + "/" + (this._domStorage.isLocalStorage ? "local" : "session");
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel._showDOMStorage(this._domStorage);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.CookieTreeElement = function(storagePanel, cookieDomain)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, cookieDomain ? cookieDomain : WebInspector.UIString("Local Files"), ["cookie-storage-tree-item"]);
- this._cookieDomain = cookieDomain;
- }
- WebInspector.CookieTreeElement.prototype = {
- get itemURL()
- {
- return "cookies://" + this._cookieDomain;
- },
- onattach: function()
- {
- WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
- this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
- },
- /**
- * @param {Event} event
- */
- _handleContextMenuEvent: function(event)
- {
- var contextMenu = new WebInspector.ContextMenu(event);
- contextMenu.appendItem(WebInspector.UIString("Clear"), this._clearCookies.bind(this));
- contextMenu.show();
- },
- /**
- * @param {string} domain
- */
- _clearCookies: function(domain)
- {
- this._storagePanel.clearCookies(this._cookieDomain);
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel.showCookies(this, this._cookieDomain);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.ApplicationCacheManifestTreeElement = function(storagePanel, manifestURL)
- {
- var title = new WebInspector.ParsedURL(manifestURL).displayName;
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["application-cache-storage-tree-item"]);
- this.tooltip = manifestURL;
- this._manifestURL = manifestURL;
- }
- WebInspector.ApplicationCacheManifestTreeElement.prototype = {
- get itemURL()
- {
- return "appcache://" + this._manifestURL;
- },
- get manifestURL()
- {
- return this._manifestURL;
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel.showCategoryView(this._manifestURL);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- */
- WebInspector.ApplicationCacheFrameTreeElement = function(storagePanel, frameId, manifestURL)
- {
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, "", ["frame-storage-tree-item"]);
- this._frameId = frameId;
- this._manifestURL = manifestURL;
- this._refreshTitles();
- }
- WebInspector.ApplicationCacheFrameTreeElement.prototype = {
- get itemURL()
- {
- return "appcache://" + this._manifestURL + "/" + encodeURI(this.displayName);
- },
- get frameId()
- {
- return this._frameId;
- },
- get manifestURL()
- {
- return this._manifestURL;
- },
- _refreshTitles: function()
- {
- var frame = WebInspector.resourceTreeModel.frameForId(this._frameId);
- if (!frame) {
- this.subtitleText = WebInspector.UIString("new frame");
- return;
- }
- this.titleText = frame.name;
- this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
- },
- frameNavigated: function()
- {
- this._refreshTitles();
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._storagePanel.showApplicationCache(this._frameId);
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.BaseStorageTreeElement}
- * @param {WebInspector.ResourcesPanel} storagePanel
- * @param {WebInspector.FileSystemModel.FileSystem} fileSystem
- */
- WebInspector.FileSystemTreeElement = function(storagePanel, fileSystem)
- {
- var displayName = fileSystem.type + " - " + fileSystem.origin;
- WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, displayName, ["file-system-storage-tree-item"]);
- this._fileSystem = fileSystem;
- }
- WebInspector.FileSystemTreeElement.prototype = {
- get fileSystemName()
- {
- return this._fileSystem.name;
- },
- get itemURL()
- {
- return "filesystem://" + this._fileSystem.name;
- },
- onselect: function(selectedByUser)
- {
- WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
- this._fileSystemView = new WebInspector.FileSystemView(this._fileSystem);
- this._storagePanel.showFileSystem(this._fileSystemView);
- },
- clear: function()
- {
- if (this.fileSystemView && this._storagePanel.visibleView === this.fileSystemView)
- this._storagePanel.closeVisibleView();
- },
- __proto__: WebInspector.BaseStorageTreeElement.prototype
- }
- /**
- * @constructor
- * @extends {WebInspector.View}
- */
- WebInspector.StorageCategoryView = function()
- {
- WebInspector.View.call(this);
- this.element.addStyleClass("storage-view");
- this._emptyView = new WebInspector.EmptyView("");
- this._emptyView.show(this.element);
- }
- WebInspector.StorageCategoryView.prototype = {
- setText: function(text)
- {
- this._emptyView.text = text;
- },
- __proto__: WebInspector.View.prototype
- }
- /**
- * @constructor
- * @param {WebInspector.BaseStorageTreeElement} rootElement
- * @param {number} matchesCount
- */
- WebInspector.ResourcesSearchController = function(rootElement, matchesCount)
- {
- this._root = rootElement;
- this._matchesCount = matchesCount;
- this._traverser = new WebInspector.SearchResultsTreeElementsTraverser(rootElement);
- this._lastTreeElement = null;
- this._lastIndex = -1;
- }
- WebInspector.ResourcesSearchController.prototype = {
- /**
- * @param {WebInspector.BaseStorageTreeElement} currentTreeElement
- */
- nextSearchResult: function(currentTreeElement)
- {
- if (!currentTreeElement)
- return this._searchResult(this._traverser.first(), 0, 1);
- if (!currentTreeElement.searchMatchesCount)
- return this._searchResult(this._traverser.next(currentTreeElement), 0);
- if (this._lastTreeElement !== currentTreeElement || this._lastIndex === -1)
- return this._searchResult(currentTreeElement, 0);
- if (this._lastIndex === currentTreeElement.searchMatchesCount - 1)
- return this._searchResult(this._traverser.next(currentTreeElement), 0, this._currentMatchIndex % this._matchesCount + 1);
- return this._searchResult(currentTreeElement, this._lastIndex + 1, this._currentMatchIndex + 1);
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} currentTreeElement
- */
- previousSearchResult: function(currentTreeElement)
- {
- if (!currentTreeElement) {
- var treeElement = this._traverser.last();
- return this._searchResult(treeElement, treeElement.searchMatchesCount - 1, this._matchesCount);
- }
- if (currentTreeElement.searchMatchesCount && this._lastTreeElement === currentTreeElement) {
- if (this._lastIndex > 0)
- return this._searchResult(currentTreeElement, this._lastIndex - 1, this._currentMatchIndex - 1);
- else {
- var treeElement = this._traverser.previous(currentTreeElement);
- var currentMatchIndex = this._currentMatchIndex - 1 ? this._currentMatchIndex - 1 : this._matchesCount;
- return this._searchResult(treeElement, treeElement.searchMatchesCount - 1, currentMatchIndex);
- }
- }
- var treeElement = this._traverser.previous(currentTreeElement)
- return this._searchResult(treeElement, treeElement.searchMatchesCount - 1);
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} treeElement
- * @param {number} index
- * @param {number=} currentMatchIndex
- * @return {Object}
- */
- _searchResult: function(treeElement, index, currentMatchIndex)
- {
- this._lastTreeElement = treeElement;
- this._lastIndex = index;
- if (!currentMatchIndex)
- currentMatchIndex = this._traverser.matchIndex(treeElement, index);
- this._currentMatchIndex = currentMatchIndex;
- return {treeElement: treeElement, index: index, currentMatchIndex: currentMatchIndex};
- }
- }
- /**
- * @constructor
- * @param {WebInspector.BaseStorageTreeElement} rootElement
- */
- WebInspector.SearchResultsTreeElementsTraverser = function(rootElement)
- {
- this._root = rootElement;
- }
- WebInspector.SearchResultsTreeElementsTraverser.prototype = {
- /**
- * @return {WebInspector.BaseStorageTreeElement}
- */
- first: function()
- {
- return this.next(this._root);
- },
- /**
- * @return {WebInspector.BaseStorageTreeElement}
- */
- last: function()
- {
- return this.previous(this._root);
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} startTreeElement
- * @return {WebInspector.BaseStorageTreeElement}
- */
- next: function(startTreeElement)
- {
- var treeElement = startTreeElement;
- do {
- treeElement = this._traverseNext(treeElement) || this._root;
- } while (treeElement != startTreeElement && !this._elementSearchMatchesCount(treeElement));
- return treeElement;
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} startTreeElement
- * @return {WebInspector.BaseStorageTreeElement}
- */
- previous: function(startTreeElement)
- {
- var treeElement = startTreeElement;
- do {
- treeElement = this._traversePrevious(treeElement) || this._lastTreeElement();
- } while (treeElement != startTreeElement && !this._elementSearchMatchesCount(treeElement));
- return treeElement;
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} startTreeElement
- * @param {number} index
- * @return {number}
- */
- matchIndex: function(startTreeElement, index)
- {
- var matchIndex = 1;
- var treeElement = this._root;
- while (treeElement != startTreeElement) {
- matchIndex += this._elementSearchMatchesCount(treeElement);
- treeElement = this._traverseNext(treeElement) || this._root;
- if (treeElement === this._root)
- return 0;
- }
- return matchIndex + index;
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} treeElement
- * @return {number}
- */
- _elementSearchMatchesCount: function(treeElement)
- {
- return treeElement.searchMatchesCount;
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} treeElement
- * @return {WebInspector.BaseStorageTreeElement}
- */
- _traverseNext: function(treeElement)
- {
- return /** @type {WebInspector.BaseStorageTreeElement} */ (treeElement.traverseNextTreeElement(false, this._root, true));
- },
- /**
- * @param {WebInspector.BaseStorageTreeElement} treeElement
- * @return {WebInspector.BaseStorageTreeElement}
- */
- _traversePrevious: function(treeElement)
- {
- return /** @type {WebInspector.BaseStorageTreeElement} */ (treeElement.traversePreviousTreeElement(false, true));
- },
- /**
- * @return {WebInspector.BaseStorageTreeElement}
- */
- _lastTreeElement: function()
- {
- var treeElement = this._root;
- var nextTreeElement;
- while (nextTreeElement = this._traverseNext(treeElement))
- treeElement = nextTreeElement;
- return treeElement;
- }
- }
|