Commit 0d02dc4e authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Drop "ui" module from toolbox.

BUG=none

Review URL: https://codereview.chromium.org/675753002

git-svn-id: svn://svn.chromium.org/blink/trunk@184355 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 620838bd
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
'front_end/components/TimelineGrid.js', 'front_end/components/TimelineGrid.js',
], ],
'devtools_host_js_files': [ 'devtools_host_js_files': [
'front_end/host/DOMExtension.js',
'front_end/host/InspectorFrontendHost.js', 'front_end/host/InspectorFrontendHost.js',
'front_end/host/Platform.js', 'front_end/host/Platform.js',
'front_end/host/ToolboxHost.js', 'front_end/host/ToolboxHost.js',
...@@ -226,7 +227,6 @@ ...@@ -226,7 +227,6 @@
'front_end/ui/ContextMenu.js', 'front_end/ui/ContextMenu.js',
'front_end/ui/DataGrid.js', 'front_end/ui/DataGrid.js',
'front_end/ui/Dialog.js', 'front_end/ui/Dialog.js',
'front_end/ui/DOMExtension.js',
'front_end/ui/DOMSyntaxHighlighter.js', 'front_end/ui/DOMSyntaxHighlighter.js',
'front_end/ui/DropDownMenu.js', 'front_end/ui/DropDownMenu.js',
'front_end/ui/EmptyView.js', 'front_end/ui/EmptyView.js',
......
...@@ -198,11 +198,9 @@ WebInspector.ChunkedFileReader.prototype = { ...@@ -198,11 +198,9 @@ WebInspector.ChunkedFileReader.prototype = {
/** /**
* @param {function(!File)} callback * @param {function(!File)} callback
* @return {!Node} * @return {!Node}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/ */
WebInspector.createFileSelectorElement = function(callback) { WebInspector.createFileSelectorElement = function(callback) {
var fileSelectorElement = document.createElement("input"); var fileSelectorElement = createElement("input");
fileSelectorElement.type = "file"; fileSelectorElement.type = "file";
fileSelectorElement.style.display = "none"; fileSelectorElement.style.display = "none";
fileSelectorElement.setAttribute("tabindex", -1); fileSelectorElement.setAttribute("tabindex", -1);
......
...@@ -84,12 +84,10 @@ WebInspector.Linkifier.handleLink = function(url, lineNumber) ...@@ -84,12 +84,10 @@ WebInspector.Linkifier.handleLink = function(url, lineNumber)
* @param {string=} title * @param {string=} title
* @param {string=} classes * @param {string=} classes
* @return {!Element} * @return {!Element}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/ */
WebInspector.Linkifier.linkifyUsingRevealer = function(revealable, text, fallbackHref, fallbackLineNumber, title, classes) WebInspector.Linkifier.linkifyUsingRevealer = function(revealable, text, fallbackHref, fallbackLineNumber, title, classes)
{ {
var a = document.createElement("a"); var a = createElement("a");
a.className = (classes || "") + " webkit-html-resource-link"; a.className = (classes || "") + " webkit-html-resource-link";
a.textContent = text.trimMiddle(WebInspector.Linkifier.MaxLengthForDisplayedURLs); a.textContent = text.trimMiddle(WebInspector.Linkifier.MaxLengthForDisplayedURLs);
a.title = title || text; a.title = title || text;
...@@ -230,12 +228,10 @@ WebInspector.Linkifier.prototype = { ...@@ -230,12 +228,10 @@ WebInspector.Linkifier.prototype = {
/** /**
* @param {string=} classes * @param {string=} classes
* @return {!Element} * @return {!Element}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/ */
_createAnchor: function(classes) _createAnchor: function(classes)
{ {
var anchor = document.createElement("a"); var anchor = createElement("a");
anchor.className = (classes || "") + " webkit-html-resource-link"; anchor.className = (classes || "") + " webkit-html-resource-link";
/** /**
......
...@@ -94,12 +94,10 @@ WebInspector.displayNameForURL = function(url) ...@@ -94,12 +94,10 @@ WebInspector.displayNameForURL = function(url)
* @param {string} string * @param {string} string
* @param {function(string,string,number=,number=):!Node} linkifier * @param {function(string,string,number=,number=):!Node} linkifier
* @return {!DocumentFragment} * @return {!DocumentFragment}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/ */
WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linkifier) WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linkifier)
{ {
var container = document.createDocumentFragment(); var container = createDocumentFragment();
var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|data:|www\.)[\w$\-_+*'=\|\/\\(){}[\]^%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({^%@&#~]/; var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|data:|www\.)[\w$\-_+*'=\|\/\\(){}[\]^%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({^%@&#~]/;
var lineColumnRegEx = /:(\d+)(:(\d+))?$/; var lineColumnRegEx = /:(\d+)(:(\d+))?$/;
...@@ -111,7 +109,7 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki ...@@ -111,7 +109,7 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki
linkString = linkString[0]; linkString = linkString[0];
var linkIndex = string.indexOf(linkString); var linkIndex = string.indexOf(linkString);
var nonLink = string.substring(0, linkIndex); var nonLink = string.substring(0, linkIndex);
container.appendChild(document.createTextNode(nonLink)); container.appendChild(createTextNode(nonLink));
var title = linkString; var title = linkString;
var realURL = (linkString.startsWith("www.") ? "http://" + linkString : linkString); var realURL = (linkString.startsWith("www.") ? "http://" + linkString : linkString);
...@@ -136,7 +134,7 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki ...@@ -136,7 +134,7 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki
} }
if (string) if (string)
container.appendChild(document.createTextNode(string)); container.appendChild(createTextNode(string));
return container; return container;
} }
...@@ -148,8 +146,6 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki ...@@ -148,8 +146,6 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki
* @param {boolean=} isExternal * @param {boolean=} isExternal
* @param {string=} tooltipText * @param {string=} tooltipText
* @return {!Element} * @return {!Element}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/ */
WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, tooltipText) WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, tooltipText)
{ {
...@@ -158,7 +154,7 @@ WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too ...@@ -158,7 +154,7 @@ WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too
classes = (classes ? classes + " " : ""); classes = (classes ? classes + " " : "");
classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource-link"; classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource-link";
var a = document.createElement("a"); var a = createElement("a");
var href = sanitizeHref(url); var href = sanitizeHref(url);
if (href !== null) if (href !== null)
a.href = href; a.href = href;
......
...@@ -276,24 +276,6 @@ Constraints.prototype.addHeight = function(value) ...@@ -276,24 +276,6 @@ Constraints.prototype.addHeight = function(value)
return new Constraints(this.minimum.addHeight(value.minimum), this.preferred.addHeight(value.preferred)); return new Constraints(this.minimum.addHeight(value.minimum), this.preferred.addHeight(value.preferred));
} }
/**
* @param {?Element=} containerElement
* @return {!Size}
*/
Element.prototype.measurePreferredSize = function(containerElement)
{
containerElement = containerElement || this.ownerDocument.body;
containerElement.appendChild(this);
var fakingComponentRoot = WebInspector.installComponentRootStyles(this);
this.positionAt(0, 0);
var result = new Size(this.offsetWidth, this.offsetHeight);
this.positionAt(undefined, undefined);
this.remove();
if (fakingComponentRoot)
WebInspector.uninstallComponentRootStyles(this);
return result;
}
/** /**
* @param {!Event} event * @param {!Event} event
* @return {boolean} * @return {boolean}
......
...@@ -9,12 +9,7 @@ WebInspector.ToolboxHost = function() {} ...@@ -9,12 +9,7 @@ WebInspector.ToolboxHost = function() {}
WebInspector.ToolboxHost.prototype = { WebInspector.ToolboxHost.prototype = {
/** /**
* @param {!Element} rootElement * @param {!Document} document
*/ */
toolboxLoaded: function(rootElement) {}, toolboxLoaded: function(document) {}
/**
* @return {!InspectorFrontendHostAPI}
*/
inspectorFrontendHost: function() {}
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"common" "common"
], ],
"scripts": [ "scripts": [
"DOMExtension.js",
"InspectorFrontendHost.js", "InspectorFrontendHost.js",
"Platform.js", "Platform.js",
"ToolboxHost.js", "ToolboxHost.js",
......
...@@ -45,7 +45,11 @@ WebInspector.AdvancedApp.prototype = { ...@@ -45,7 +45,11 @@ WebInspector.AdvancedApp.prototype = {
this._toggleEmulationButton.element.classList.toggle("warning", !!message); this._toggleEmulationButton.element.classList.toggle("warning", !!message);
}, },
presentUI: function() /**
* @param {!Document} document
* @override
*/
presentUI: function(document)
{ {
var rootView = new WebInspector.RootView(); var rootView = new WebInspector.RootView();
...@@ -68,7 +72,7 @@ WebInspector.AdvancedApp.prototype = { ...@@ -68,7 +72,7 @@ WebInspector.AdvancedApp.prototype = {
WebInspector.inspectorView.showInitialPanel(); WebInspector.inspectorView.showInitialPanel();
console.timeStamp("AdvancedApp.attachToBody"); console.timeStamp("AdvancedApp.attachToBody");
rootView.attachToBody(); rootView.attachToDocument(document);
this._inspectedPagePlaceholder.update(); this._inspectedPagePlaceholder.update();
}, },
...@@ -88,15 +92,22 @@ WebInspector.AdvancedApp.prototype = { ...@@ -88,15 +92,22 @@ WebInspector.AdvancedApp.prototype = {
}, },
/** /**
* @param {!Element} rootElement * @param {!Document} toolboxDocument
* @override * @override
*/ */
toolboxLoaded: function(rootElement) toolboxLoaded: function(toolboxDocument)
{ {
WebInspector.initializeUIUtils(toolboxDocument.defaultView);
WebInspector.installComponentRootStyles(/** @type {!Element} */ (toolboxDocument.body));
WebInspector.ContextMenu.installHandler(toolboxDocument);
var rootView = new WebInspector.RootView();
var inspectedPagePlaceholder = new WebInspector.InspectedPagePlaceholder(); var inspectedPagePlaceholder = new WebInspector.InspectedPagePlaceholder();
inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPagePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, true)); inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPagePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, true));
this._toolboxResponsiveDesignView = new WebInspector.ResponsiveDesignView(inspectedPagePlaceholder); this._toolboxResponsiveDesignView = new WebInspector.ResponsiveDesignView(inspectedPagePlaceholder);
this._toolboxResponsiveDesignView.show(rootElement); this._toolboxResponsiveDesignView.show(rootView.element);
rootView.attachToDocument(toolboxDocument);
this._updatePageResizer(); this._updatePageResizer();
}, },
......
...@@ -10,7 +10,10 @@ WebInspector.App = function() ...@@ -10,7 +10,10 @@ WebInspector.App = function()
}; };
WebInspector.App.prototype = { WebInspector.App.prototype = {
presentUI: function() /**
* @param {!Document} document
*/
presentUI: function(document)
{ {
} }
}; };
......
...@@ -263,7 +263,7 @@ WebInspector.Main.prototype = { ...@@ -263,7 +263,7 @@ WebInspector.Main.prototype = {
// It is important to kick controller lifetime after apps are instantiated. // It is important to kick controller lifetime after apps are instantiated.
WebInspector.dockController.initialize(); WebInspector.dockController.initialize();
console.timeStamp("Main._presentUI"); console.timeStamp("Main._presentUI");
WebInspector.app.presentUI(); WebInspector.app.presentUI(document);
if (!WebInspector.isWorkerFrontend()) if (!WebInspector.isWorkerFrontend())
WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController(); WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController();
......
...@@ -25,7 +25,11 @@ WebInspector.ScreencastApp = function() ...@@ -25,7 +25,11 @@ WebInspector.ScreencastApp = function()
}; };
WebInspector.ScreencastApp.prototype = { WebInspector.ScreencastApp.prototype = {
presentUI: function() /**
* @param {!Document} document
* @override
*/
presentUI: function(document)
{ {
var rootView = new WebInspector.RootView(); var rootView = new WebInspector.RootView();
...@@ -35,7 +39,7 @@ WebInspector.ScreencastApp.prototype = { ...@@ -35,7 +39,7 @@ WebInspector.ScreencastApp.prototype = {
WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); WebInspector.inspectorView.show(this._rootSplitView.sidebarElement());
WebInspector.inspectorView.showInitialPanel(); WebInspector.inspectorView.showInitialPanel();
rootView.attachToBody(); rootView.attachToDocument(document);
}, },
/** /**
......
...@@ -12,12 +12,16 @@ WebInspector.SimpleApp = function() ...@@ -12,12 +12,16 @@ WebInspector.SimpleApp = function()
}; };
WebInspector.SimpleApp.prototype = { WebInspector.SimpleApp.prototype = {
presentUI: function() /**
* @param {!Document} document
* @override
*/
presentUI: function(document)
{ {
var rootView = new WebInspector.RootView(); var rootView = new WebInspector.RootView();
WebInspector.inspectorView.show(rootView.element); WebInspector.inspectorView.show(rootView.element);
WebInspector.inspectorView.showInitialPanel(); WebInspector.inspectorView.showInitialPanel();
rootView.attachToBody(); rootView.attachToDocument(document);
}, },
__proto__: WebInspector.App.prototype __proto__: WebInspector.App.prototype
......
...@@ -359,7 +359,7 @@ WebInspector.FilteredItemSelectionDialog.prototype = { ...@@ -359,7 +359,7 @@ WebInspector.FilteredItemSelectionDialog.prototype = {
if (!this._rowHeight) { if (!this._rowHeight) {
var delegateIndex = this._filteredItems[index]; var delegateIndex = this._filteredItems[index];
var element = this._createItemElement(delegateIndex); var element = this._createItemElement(delegateIndex);
this._rowHeight = element.measurePreferredSize(this._viewportControl.contentElement()).height; this._rowHeight = WebInspector.measurePreferredSize(element, this._viewportControl.contentElement()).height;
} }
return this._rowHeight; return this._rowHeight;
}, },
......
[ [
{
"name": "ui",
"type": "autostart"
},
{ {
"name": "host", "name": "host",
"type": "autostart" "type": "autostart"
......
...@@ -11,15 +11,8 @@ WebInspector.Toolbox = function() ...@@ -11,15 +11,8 @@ WebInspector.Toolbox = function()
if (!window.opener) if (!window.opener)
return; return;
var delegate = /** @type {!WebInspector.ToolboxHost} */ (window.opener.WebInspector["app"]); var host = /** @type {!WebInspector.ToolboxHost} */ (window.opener.WebInspector["app"]);
host.toolboxLoaded(document);
WebInspector.initializeUIUtils(window);
WebInspector.zoomManager = new WebInspector.ZoomManager(window, delegate.inspectorFrontendHost());
WebInspector.ContextMenu.installHandler(document);
var rootView = new WebInspector.RootView();
delegate.toolboxLoaded(rootView.element);
rootView.attachToBody();
} }
// FIXME: This stub is invoked from the backend and should be removed // FIXME: This stub is invoked from the backend and should be removed
......
{ {
"dependencies": [ "dependencies": [
"ui",
"host", "host",
"common" "common"
], ],
......
...@@ -97,7 +97,7 @@ WebInspector.Popover.prototype = { ...@@ -97,7 +97,7 @@ WebInspector.Popover.prototype = {
var window = document.defaultView; var window = document.defaultView;
// Temporarily attach in order to measure preferred dimensions. // Temporarily attach in order to measure preferred dimensions.
var preferredSize = view ? view.measurePreferredSize() : this._contentElement.measurePreferredSize(); var preferredSize = view ? view.measurePreferredSize() : WebInspector.measurePreferredSize(this._contentElement);
preferredWidth = preferredWidth || preferredSize.width; preferredWidth = preferredWidth || preferredSize.width;
preferredHeight = preferredHeight || preferredSize.height; preferredHeight = preferredHeight || preferredSize.height;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
/** /**
* @constructor * @constructor
* @extends {WebInspector.VBox} * @extends {WebInspector.VBox}
* @suppressGlobalPropertiesCheck
*/ */
WebInspector.RootView = function() WebInspector.RootView = function()
{ {
...@@ -13,29 +12,30 @@ WebInspector.RootView = function() ...@@ -13,29 +12,30 @@ WebInspector.RootView = function()
this.markAsRoot(); this.markAsRoot();
this.element.classList.add("root-view"); this.element.classList.add("root-view");
this.element.setAttribute("spellcheck", false); this.element.setAttribute("spellcheck", false);
// This view is not designed to change owner document.
window.addEventListener("resize", this.doResize.bind(this), false);
} }
WebInspector.RootView.prototype = { WebInspector.RootView.prototype = {
/** /**
* @public // FIXME: this is a workaround for validator bug (http://crbug.com/425506). * @param {!Document} document
* @suppressGlobalPropertiesCheck
*/ */
attachToBody: function() attachToDocument: function(document)
{ {
document.defaultView.addEventListener("resize", this.doResize.bind(this), false);
this._window = document.defaultView;
this.doResize(); this.doResize();
this.show(document.body); this.show(document.body);
}, },
doResize: function() doResize: function()
{ {
var size = this.constraints().minimum; if (this._window) {
var zoom = WebInspector.zoomManager.zoomFactor(); var size = this.constraints().minimum;
var right = Math.min(0, window.innerWidth - size.width / zoom); var zoom = WebInspector.zoomManager.zoomFactor();
this.element.style.marginRight = right + "px"; var right = Math.min(0, this._window.innerWidth - size.width / zoom);
var bottom = Math.min(0, window.innerHeight - size.height / zoom); this.element.style.marginRight = right + "px";
this.element.style.marginBottom = bottom + "px"; var bottom = Math.min(0, this._window.innerHeight - size.height / zoom);
this.element.style.marginBottom = bottom + "px";
}
WebInspector.VBox.prototype.doResize.call(this); WebInspector.VBox.prototype.doResize.call(this);
}, },
......
...@@ -927,6 +927,25 @@ WebInspector.revertDomChanges = function(domChanges) ...@@ -927,6 +927,25 @@ WebInspector.revertDomChanges = function(domChanges)
} }
} }
/**
* @param {!Element} element
* @param {?Element=} containerElement
* @return {!Size}
*/
WebInspector.measurePreferredSize = function(element, containerElement)
{
containerElement = containerElement || element.ownerDocument.body;
containerElement.appendChild(element);
var fakingComponentRoot = WebInspector.installComponentRootStyles(element);
element.positionAt(0, 0);
var result = new Size(element.offsetWidth, element.offsetHeight);
element.positionAt(undefined, undefined);
element.remove();
if (fakingComponentRoot)
WebInspector.uninstallComponentRootStyles(element);
return result;
}
/** /**
* @constructor * @constructor
* @param {boolean} autoInvoke * @param {boolean} autoInvoke
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
"host" "host"
], ],
"scripts": [ "scripts": [
"DOMExtension.js",
"View.js", "View.js",
"treeoutline.js", "treeoutline.js",
"ActionRegistry.js", "ActionRegistry.js",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment