X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2FWebKit%2FSource%2Fdevtools%2Ffront_end%2FStyleSheetOutlineDialog.js;h=978ddb33a1576eb826c317a6ed7695d34d4b8bfc;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=b7f21e5e0e88c42371e6821b8096d456f9d09fa9;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/WebKit/Source/devtools/front_end/StyleSheetOutlineDialog.js b/src/third_party/WebKit/Source/devtools/front_end/StyleSheetOutlineDialog.js index b7f21e5..978ddb3 100644 --- a/src/third_party/WebKit/Source/devtools/front_end/StyleSheetOutlineDialog.js +++ b/src/third_party/WebKit/Source/devtools/front_end/StyleSheetOutlineDialog.js @@ -29,18 +29,17 @@ /** * @constructor * @extends {WebInspector.SelectionDialogContentProvider} - * @param {!WebInspector.View} view * @param {!WebInspector.UISourceCode} uiSourceCode * @param {function(number, number)} selectItemCallback */ -WebInspector.StyleSheetOutlineDialog = function(view, uiSourceCode, selectItemCallback) +WebInspector.StyleSheetOutlineDialog = function(uiSourceCode, selectItemCallback) { WebInspector.SelectionDialogContentProvider.call(this); this._selectItemCallback = selectItemCallback; this._rules = []; - this._view = view; - this._uiSourceCode = uiSourceCode; - this._requestItems(); + this._outlineWorker = new Worker("ScriptFormatterWorker.js"); + this._outlineWorker.onmessage = this._didBuildOutlineChunk.bind(this); + this._outlineWorker.postMessage({ method: "cssOutline", params: { content: uiSourceCode.workingCopy() } }); } /** @@ -52,13 +51,29 @@ WebInspector.StyleSheetOutlineDialog.show = function(view, uiSourceCode, selectI { if (WebInspector.Dialog.currentInstance()) return null; - var delegate = new WebInspector.StyleSheetOutlineDialog(view, uiSourceCode, selectItemCallback); + var delegate = new WebInspector.StyleSheetOutlineDialog(uiSourceCode, selectItemCallback); var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(delegate); WebInspector.Dialog.show(view.element, filteredItemSelectionDialog); } WebInspector.StyleSheetOutlineDialog.prototype = { /** + * @param {!MessageEvent} event + */ + _didBuildOutlineChunk: function(event) + { + var data = /** @type {!WebInspector.StyleSheetOutlineDialog.MessageEventData} */ (event.data); + var chunk = data.chunk; + for (var i = 0; i < chunk.length; ++i) + this._rules.push(chunk[i]); + + if (data.total === data.index) + this.dispose(); + + this.refresh(); + }, + + /** * @return {number} */ itemCount: function() @@ -72,7 +87,8 @@ WebInspector.StyleSheetOutlineDialog.prototype = { */ itemKeyAt: function(itemIndex) { - return this._rules[itemIndex].selectorText; + var rule = this._rules[itemIndex]; + return rule.selectorText || rule.atRule; }, /** @@ -83,7 +99,7 @@ WebInspector.StyleSheetOutlineDialog.prototype = { itemScoreAt: function(itemIndex, query) { var rule = this._rules[itemIndex]; - return -rule.rawLocation.lineNumber; + return -rule.lineNumber; }, /** @@ -95,46 +111,9 @@ WebInspector.StyleSheetOutlineDialog.prototype = { renderItem: function(itemIndex, query, titleElement, subtitleElement) { var rule = this._rules[itemIndex]; - titleElement.textContent = rule.selectorText; + titleElement.textContent = rule.selectorText || rule.atRule; this.highlightRanges(titleElement, query); - subtitleElement.textContent = ":" + (rule.rawLocation.lineNumber + 1); - }, - - _requestItems: function() - { - /** - * @param {?Protocol.Error} error - * @param {!Array.} infos - * @this {WebInspector.StyleSheetOutlineDialog} - */ - function didGetAllStyleSheets(error, infos) - { - if (error) - return; - - for (var i = 0; i < infos.length; ++i) { - var info = infos[i]; - if (info.sourceURL === this._uiSourceCode.url) { - WebInspector.CSSStyleSheet.createForId(info.styleSheetId, didGetStyleSheet.bind(this)); - return; - } - } - } - - CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this)); - - /** - * @param {?WebInspector.CSSStyleSheet} styleSheet - * @this {WebInspector.StyleSheetOutlineDialog} - */ - function didGetStyleSheet(styleSheet) - { - if (!styleSheet) - return; - - this._rules = styleSheet.rules; - this.refresh(); - } + subtitleElement.textContent = ":" + (rule.lineNumber + 1); }, /** @@ -144,10 +123,23 @@ WebInspector.StyleSheetOutlineDialog.prototype = { selectItem: function(itemIndex, promptValue) { var rule = this._rules[itemIndex]; - var lineNumber = rule.rawLocation.lineNumber; + var lineNumber = rule.lineNumber; if (!isNaN(lineNumber) && lineNumber >= 0) - this._selectItemCallback(lineNumber, rule.rawLocation.columnNumber); + this._selectItemCallback(lineNumber, rule.columnNumber); + }, + + dispose: function() + { + if (this._outlineWorker) { + this._outlineWorker.terminate(); + delete this._outlineWorker; + } }, __proto__: WebInspector.SelectionDialogContentProvider.prototype } + +/** + * @typedef {{index: number, total: number, chunk: !Array.}} + */ +WebInspector.StyleSheetOutlineDialog.MessageEventData;