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 @@
'front_end/components/TimelineGrid.js',
],
'devtools_host_js_files': [
'front_end/host/DOMExtension.js',
'front_end/host/InspectorFrontendHost.js',
'front_end/host/Platform.js',
'front_end/host/ToolboxHost.js',
......@@ -226,7 +227,6 @@
'front_end/ui/ContextMenu.js',
'front_end/ui/DataGrid.js',
'front_end/ui/Dialog.js',
'front_end/ui/DOMExtension.js',
'front_end/ui/DOMSyntaxHighlighter.js',
'front_end/ui/DropDownMenu.js',
'front_end/ui/EmptyView.js',
......
......@@ -198,11 +198,9 @@ WebInspector.ChunkedFileReader.prototype = {
/**
* @param {function(!File)} callback
* @return {!Node}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/
WebInspector.createFileSelectorElement = function(callback) {
var fileSelectorElement = document.createElement("input");
var fileSelectorElement = createElement("input");
fileSelectorElement.type = "file";
fileSelectorElement.style.display = "none";
fileSelectorElement.setAttribute("tabindex", -1);
......
......@@ -84,12 +84,10 @@ WebInspector.Linkifier.handleLink = function(url, lineNumber)
* @param {string=} title
* @param {string=} classes
* @return {!Element}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/
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.textContent = text.trimMiddle(WebInspector.Linkifier.MaxLengthForDisplayedURLs);
a.title = title || text;
......@@ -230,12 +228,10 @@ WebInspector.Linkifier.prototype = {
/**
* @param {string=} classes
* @return {!Element}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/
_createAnchor: function(classes)
{
var anchor = document.createElement("a");
var anchor = createElement("a");
anchor.className = (classes || "") + " webkit-html-resource-link";
/**
......
......@@ -94,12 +94,10 @@ WebInspector.displayNameForURL = function(url)
* @param {string} string
* @param {function(string,string,number=,number=):!Node} linkifier
* @return {!DocumentFragment}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/
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 lineColumnRegEx = /:(\d+)(:(\d+))?$/;
......@@ -111,7 +109,7 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki
linkString = linkString[0];
var linkIndex = string.indexOf(linkString);
var nonLink = string.substring(0, linkIndex);
container.appendChild(document.createTextNode(nonLink));
container.appendChild(createTextNode(nonLink));
var title = linkString;
var realURL = (linkString.startsWith("www.") ? "http://" + linkString : linkString);
......@@ -136,7 +134,7 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki
}
if (string)
container.appendChild(document.createTextNode(string));
container.appendChild(createTextNode(string));
return container;
}
......@@ -148,8 +146,6 @@ WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki
* @param {boolean=} isExternal
* @param {string=} tooltipText
* @return {!Element}
* // FIXME: remove this suppression (crbug.com/425498).
* @suppressGlobalPropertiesCheck
*/
WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, tooltipText)
{
......@@ -158,7 +154,7 @@ WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too
classes = (classes ? classes + " " : "");
classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource-link";
var a = document.createElement("a");
var a = createElement("a");
var href = sanitizeHref(url);
if (href !== null)
a.href = href;
......
......@@ -276,24 +276,6 @@ Constraints.prototype.addHeight = function(value)
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
* @return {boolean}
......
......@@ -9,12 +9,7 @@ WebInspector.ToolboxHost = function() {}
WebInspector.ToolboxHost.prototype = {
/**
* @param {!Element} rootElement
* @param {!Document} document
*/
toolboxLoaded: function(rootElement) {},
/**
* @return {!InspectorFrontendHostAPI}
*/
inspectorFrontendHost: function() {}
toolboxLoaded: function(document) {}
}
......@@ -3,6 +3,7 @@
"common"
],
"scripts": [
"DOMExtension.js",
"InspectorFrontendHost.js",
"Platform.js",
"ToolboxHost.js",
......
......@@ -45,7 +45,11 @@ WebInspector.AdvancedApp.prototype = {
this._toggleEmulationButton.element.classList.toggle("warning", !!message);
},
presentUI: function()
/**
* @param {!Document} document
* @override
*/
presentUI: function(document)
{
var rootView = new WebInspector.RootView();
......@@ -68,7 +72,7 @@ WebInspector.AdvancedApp.prototype = {
WebInspector.inspectorView.showInitialPanel();
console.timeStamp("AdvancedApp.attachToBody");
rootView.attachToBody();
rootView.attachToDocument(document);
this._inspectedPagePlaceholder.update();
},
......@@ -88,15 +92,22 @@ WebInspector.AdvancedApp.prototype = {
},
/**
* @param {!Element} rootElement
* @param {!Document} toolboxDocument
* @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();
inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPagePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, true));
this._toolboxResponsiveDesignView = new WebInspector.ResponsiveDesignView(inspectedPagePlaceholder);
this._toolboxResponsiveDesignView.show(rootElement);
this._toolboxResponsiveDesignView.show(rootView.element);
rootView.attachToDocument(toolboxDocument);
this._updatePageResizer();
},
......
......@@ -10,7 +10,10 @@ WebInspector.App = function()
};
WebInspector.App.prototype = {
presentUI: function()
/**
* @param {!Document} document
*/
presentUI: function(document)
{
}
};
......
......@@ -263,7 +263,7 @@ WebInspector.Main.prototype = {
// It is important to kick controller lifetime after apps are instantiated.
WebInspector.dockController.initialize();
console.timeStamp("Main._presentUI");
WebInspector.app.presentUI();
WebInspector.app.presentUI(document);
if (!WebInspector.isWorkerFrontend())
WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController();
......
......@@ -25,7 +25,11 @@ WebInspector.ScreencastApp = function()
};
WebInspector.ScreencastApp.prototype = {
presentUI: function()
/**
* @param {!Document} document
* @override
*/
presentUI: function(document)
{
var rootView = new WebInspector.RootView();
......@@ -35,7 +39,7 @@ WebInspector.ScreencastApp.prototype = {
WebInspector.inspectorView.show(this._rootSplitView.sidebarElement());
WebInspector.inspectorView.showInitialPanel();
rootView.attachToBody();
rootView.attachToDocument(document);
},
/**
......
......@@ -12,12 +12,16 @@ WebInspector.SimpleApp = function()
};
WebInspector.SimpleApp.prototype = {
presentUI: function()
/**
* @param {!Document} document
* @override
*/
presentUI: function(document)
{
var rootView = new WebInspector.RootView();
WebInspector.inspectorView.show(rootView.element);
WebInspector.inspectorView.showInitialPanel();
rootView.attachToBody();
rootView.attachToDocument(document);
},
__proto__: WebInspector.App.prototype
......
......@@ -359,7 +359,7 @@ WebInspector.FilteredItemSelectionDialog.prototype = {
if (!this._rowHeight) {
var delegateIndex = this._filteredItems[index];
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;
},
......
[
{
"name": "ui",
"type": "autostart"
},
{
"name": "host",
"type": "autostart"
......
......@@ -11,15 +11,8 @@ WebInspector.Toolbox = function()
if (!window.opener)
return;
var delegate = /** @type {!WebInspector.ToolboxHost} */ (window.opener.WebInspector["app"]);
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();
var host = /** @type {!WebInspector.ToolboxHost} */ (window.opener.WebInspector["app"]);
host.toolboxLoaded(document);
}
// FIXME: This stub is invoked from the backend and should be removed
......
......@@ -97,7 +97,7 @@ WebInspector.Popover.prototype = {
var window = document.defaultView;
// 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;
preferredHeight = preferredHeight || preferredSize.height;
......
......@@ -5,7 +5,6 @@
/**
* @constructor
* @extends {WebInspector.VBox}
* @suppressGlobalPropertiesCheck
*/
WebInspector.RootView = function()
{
......@@ -13,29 +12,30 @@ WebInspector.RootView = function()
this.markAsRoot();
this.element.classList.add("root-view");
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 = {
/**
* @public // FIXME: this is a workaround for validator bug (http://crbug.com/425506).
* @suppressGlobalPropertiesCheck
* @param {!Document} document
*/
attachToBody: function()
attachToDocument: function(document)
{
document.defaultView.addEventListener("resize", this.doResize.bind(this), false);
this._window = document.defaultView;
this.doResize();
this.show(document.body);
},
doResize: function()
{
var size = this.constraints().minimum;
var zoom = WebInspector.zoomManager.zoomFactor();
var right = Math.min(0, window.innerWidth - size.width / zoom);
this.element.style.marginRight = right + "px";
var bottom = Math.min(0, window.innerHeight - size.height / zoom);
this.element.style.marginBottom = bottom + "px";
if (this._window) {
var size = this.constraints().minimum;
var zoom = WebInspector.zoomManager.zoomFactor();
var right = Math.min(0, this._window.innerWidth - size.width / zoom);
this.element.style.marginRight = right + "px";
var bottom = Math.min(0, this._window.innerHeight - size.height / zoom);
this.element.style.marginBottom = bottom + "px";
}
WebInspector.VBox.prototype.doResize.call(this);
},
......
......@@ -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
* @param {boolean} autoInvoke
......
......@@ -4,7 +4,6 @@
"host"
],
"scripts": [
"DOMExtension.js",
"View.js",
"treeoutline.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