diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-09 09:42:44 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-09 09:42:44 +0100 |
commit | a59391482883479a9b28a6f1ace6d1ebd08a7ecd (patch) | |
tree | fa539db054a20a67bff2fc891c33b0f4ec632916 /Source/WebCore/inspector | |
parent | cfd86b747d32ac22246a1aa908eaa720c63a88c1 (diff) | |
download | qtwebkit-a59391482883479a9b28a6f1ace6d1ebd08a7ecd.tar.gz |
Imported WebKit commit 7bcdfab9a40db7d16b4b95bb77d78b8a59c9e701 (http://svn.webkit.org/repository/webkit/trunk@134025)
New snapshot with numerious build fixes, including MSVC 2012 and ARM Thumb-2.
Diffstat (limited to 'Source/WebCore/inspector')
39 files changed, 655 insertions, 518 deletions
diff --git a/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js b/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js index eeb3ee396..58b136c3d 100644 --- a/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js +++ b/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js @@ -38,7 +38,8 @@ var TypeUtils = { /** * http://www.khronos.org/registry/typedarray/specs/latest/#7 - * @type {!Array.<Function>} + * @const + * @type {!Array.<function(new:ArrayBufferView, ArrayBufferView)>} */ _typedArrayClasses: (function(typeNames) { var result = []; @@ -51,7 +52,7 @@ var TypeUtils = { /** * @param {*} array - * @return {Function} + * @return {function(new:ArrayBufferView, ArrayBufferView)|null} */ typedArrayClass: function(array) { @@ -86,7 +87,7 @@ var TypeUtils = { var typedArrayClass = TypeUtils.typedArrayClass(obj); if (typedArrayClass) - return new typedArrayClass(obj); + return new typedArrayClass(/** @type {ArrayBufferView} */ (obj)); if (obj instanceof HTMLImageElement) return obj.cloneNode(true); @@ -560,7 +561,7 @@ ReplayableCall.prototype = { /** * @constructor - * @param {Object} wrappedObject + * @param {!Object} wrappedObject */ function Resource(wrappedObject) { @@ -629,7 +630,7 @@ Resource.prototype = { }, /** - * @param {*} value + * @param {!Object} value */ setWrappedObject: function(value) { @@ -706,11 +707,11 @@ Resource.prototype = { /** * @param {Object} data * @param {Cache} cache - * @return {Resource|ReplayableResource} + * @return {Resource} */ replay: function(data, cache) { - var resource = /** @type {ReplayableResource} */ (cache.get(data.id)); + var resource = /** @type {Resource} */ (cache.get(data.id)); if (resource) return resource; this._id = data.id; @@ -743,11 +744,11 @@ Resource.prototype = { }, /** - * @param {*} object + * @param {!Object} object */ _bindObjectToResource: function(object) { - Object.defineProperty(/** @type {!Object} */ (object), "__resourceObject", { + Object.defineProperty(object, "__resourceObject", { value: this, writable: false, enumerable: false, @@ -879,11 +880,11 @@ Resource.prototype = { }, /** - * @return {Object.<string, Function>} + * @return {!Object.<string, Function>} */ _customWrapFunctions: function() { - return {}; // May be overridden by subclasses. + return Object.create(null); // May be overridden by subclasses. } } @@ -939,15 +940,15 @@ Resource.WrapFunction.prototype = { } /** - * @param {!Function} resourceConstructor - * @return {Function} + * @param {function(new:Resource, !Object)} resourceConstructor + * @return {function(this:Resource.WrapFunction)} */ Resource.WrapFunction.resourceFactoryMethod = function(resourceConstructor) { /** @this Resource.WrapFunction */ return function() { - var wrappedObject = this.result(); + var wrappedObject = /** @type {Object} */ (this.result()); if (!wrappedObject) return; var resource = new resourceConstructor(wrappedObject); @@ -961,8 +962,8 @@ Resource.WrapFunction.resourceFactoryMethod = function(resourceConstructor) /** * @constructor - * @param {Resource} originalResource - * @param {Object} data + * @param {!Resource} originalResource + * @param {!Object} data */ function ReplayableResource(originalResource, data) { @@ -994,6 +995,39 @@ ReplayableResource.replay = function(obj, cache) return (obj instanceof ReplayableResource) ? obj.replay(cache).wrappedObject() : obj; } +/** + * @constructor + * @extends {Resource} + */ +function LogEverythingResource(wrappedObject) +{ + Resource.call(this, wrappedObject); +} + +LogEverythingResource.prototype = { + /** + * @override + * @return {!Object.<string, Function>} + */ + _customWrapFunctions: function() + { + var wrapFunctions = Object.create(null); + var wrappedObject = this.wrappedObject(); + if (wrappedObject) { + for (var property in wrappedObject) { + /** @this Resource.WrapFunction */ + wrapFunctions[property] = function() + { + this._resource.pushCall(this.call()); + } + } + } + return wrapFunctions; + }, + + __proto__: Resource.prototype +} + //////////////////////////////////////////////////////////////////////////////// // WebGL //////////////////////////////////////////////////////////////////////////////// @@ -1171,13 +1205,12 @@ WebGLTextureResource.prototype = { this.pushCall(call); }, - pushCall_texParameteri: WebGLTextureResource.prototype.pushCall_texParameterf, - - pushCall_copyTexSubImage2D: WebGLTextureResource.prototype.pushCall_copyTexImage2D, - __proto__: WebGLBoundResource.prototype } +WebGLTextureResource.prototype.pushCall_texParameteri = WebGLTextureResource.prototype.pushCall_texParameterf; +WebGLTextureResource.prototype.pushCall_copyTexSubImage2D = WebGLTextureResource.prototype.pushCall_copyTexImage2D; + /** * @constructor * @extends {Resource} @@ -1399,8 +1432,8 @@ WebGLRenderbufferResource.prototype = { /** * @constructor * @extends {Resource} - * @param {WebGLRenderingContext} glContext - * @param {Function} replayContextCallback + * @param {!WebGLRenderingContext} glContext + * @param {function():WebGLRenderingContext} replayContextCallback */ function WebGLRenderingContextResource(glContext, replayContextCallback) { @@ -1649,12 +1682,12 @@ WebGLRenderingContextResource.prototype = { this._replayContextCallback = data.replayContextCallback; this._customErrors = null; - var gl = Resource.wrappedObject(this._replayContextCallback()); + var gl = /** @type {!WebGLRenderingContext} */ (Resource.wrappedObject(this._replayContextCallback())); this.setWrappedObject(gl); var glState = data.glState; - gl.bindFramebuffer(gl.FRAMEBUFFER, ReplayableResource.replay(glState.FRAMEBUFFER_BINDING, cache)); - gl.bindRenderbuffer(gl.RENDERBUFFER, ReplayableResource.replay(glState.RENDERBUFFER_BINDING, cache)); + gl.bindFramebuffer(gl.FRAMEBUFFER, /** @type {WebGLFramebuffer} */ (ReplayableResource.replay(glState.FRAMEBUFFER_BINDING, cache))); + gl.bindRenderbuffer(gl.RENDERBUFFER, /** @type {WebGLRenderbuffer} */ (ReplayableResource.replay(glState.RENDERBUFFER_BINDING, cache))); // Enable or disable server-side GL capabilities. WebGLRenderingContextResource.GLCapabilities.forEach(function(parameter) { @@ -1696,10 +1729,10 @@ WebGLRenderingContextResource.prototype = { gl.scissor(glState.SCISSOR_BOX[0], glState.SCISSOR_BOX[1], glState.SCISSOR_BOX[2], glState.SCISSOR_BOX[3]); gl.viewport(glState.VIEWPORT[0], glState.VIEWPORT[1], glState.VIEWPORT[2], glState.VIEWPORT[3]); - gl.useProgram(ReplayableResource.replay(glState.CURRENT_PROGRAM, cache)); + gl.useProgram(/** @type {WebGLProgram} */ (ReplayableResource.replay(glState.CURRENT_PROGRAM, cache))); // VERTEX_ATTRIB_ARRAYS - var maxVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); + var maxVertexAttribs = /** @type {number} */ (gl.getParameter(gl.MAX_VERTEX_ATTRIBS)); for (var i = 0; i < maxVertexAttribs; ++i) { var state = glState.vertexAttribStates[i] || {}; if (state.VERTEX_ATTRIB_ARRAY_ENABLED) @@ -1708,22 +1741,22 @@ WebGLRenderingContextResource.prototype = { gl.disableVertexAttribArray(i); if (state.CURRENT_VERTEX_ATTRIB) gl.vertexAttrib4fv(i, state.CURRENT_VERTEX_ATTRIB); - var buffer = ReplayableResource.replay(state.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, cache); + var buffer = /** @type {WebGLBuffer} */ (ReplayableResource.replay(state.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, cache)); if (buffer) { gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.vertexAttribPointer(i, state.VERTEX_ATTRIB_ARRAY_SIZE, state.VERTEX_ATTRIB_ARRAY_TYPE, state.VERTEX_ATTRIB_ARRAY_NORMALIZED, state.VERTEX_ATTRIB_ARRAY_STRIDE, state.VERTEX_ATTRIB_ARRAY_POINTER); } } - gl.bindBuffer(gl.ARRAY_BUFFER, ReplayableResource.replay(glState.ARRAY_BUFFER_BINDING, cache)); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ReplayableResource.replay(glState.ELEMENT_ARRAY_BUFFER_BINDING, cache)); + gl.bindBuffer(gl.ARRAY_BUFFER, /** @type {WebGLBuffer} */ (ReplayableResource.replay(glState.ARRAY_BUFFER_BINDING, cache))); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, /** @type {WebGLBuffer} */ (ReplayableResource.replay(glState.ELEMENT_ARRAY_BUFFER_BINDING, cache))); // TEXTURES - var maxTextureImageUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + var maxTextureImageUnits = /** @type {number} */ (gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)); for (var i = 0; i < maxTextureImageUnits; ++i) { gl.activeTexture(gl.TEXTURE0 + i); var state = glState.textureBindings[i] || {}; - gl.bindTexture(gl.TEXTURE_2D, ReplayableResource.replay(state.TEXTURE_2D, cache)); - gl.bindTexture(gl.TEXTURE_CUBE_MAP, ReplayableResource.replay(state.TEXTURE_CUBE_MAP, cache)); + gl.bindTexture(gl.TEXTURE_2D, /** @type {WebGLTexture} */ (ReplayableResource.replay(state.TEXTURE_2D, cache))); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, /** @type {WebGLTexture} */ (ReplayableResource.replay(state.TEXTURE_CUBE_MAP, cache))); } gl.activeTexture(glState.ACTIVE_TEXTURE); @@ -1787,7 +1820,7 @@ WebGLRenderingContextResource.prototype = { /** * @override - * @return {Object.<string, Function>} + * @return {!Object.<string, Function>} */ _customWrapFunctions: function() { @@ -1874,8 +1907,8 @@ WebGLRenderingContextResource.prototype = { /** * @constructor * @extends {Resource} - * @param {CanvasRenderingContext2D} context - * @param {Function} replayContextCallback + * @param {!CanvasRenderingContext2D} context + * @param {function():CanvasRenderingContext2D} replayContextCallback */ function CanvasRenderingContext2DResource(context, replayContextCallback) { @@ -1964,7 +1997,7 @@ CanvasRenderingContext2DResource.prototype = { { this._replayContextCallback = data.replayContextCallback; - var ctx = Resource.wrappedObject(this._replayContextCallback()); + var ctx = /** @type {!CanvasRenderingContext2D} */ (Resource.wrappedObject(this._replayContextCallback())); this.setWrappedObject(ctx); if (data.originalImageData) { @@ -2191,7 +2224,7 @@ CanvasRenderingContext2DResource.prototype = { /** * @override - * @return {Object.<string, Function>} + * @return {!Object.<string, Function>} */ _customWrapFunctions: function() { @@ -2199,10 +2232,9 @@ CanvasRenderingContext2DResource.prototype = { if (!wrapFunctions) { wrapFunctions = Object.create(null); - // FIXME: Save state of the CanvasGradient objects. - wrapFunctions["createLinearGradient"] = Resource.WrapFunction.resourceFactoryMethod(Resource); - wrapFunctions["createRadialGradient"] = Resource.WrapFunction.resourceFactoryMethod(Resource); - wrapFunctions["createPattern"] = Resource.WrapFunction.resourceFactoryMethod(Resource); + wrapFunctions["createLinearGradient"] = Resource.WrapFunction.resourceFactoryMethod(LogEverythingResource); + wrapFunctions["createRadialGradient"] = Resource.WrapFunction.resourceFactoryMethod(LogEverythingResource); + wrapFunctions["createPattern"] = Resource.WrapFunction.resourceFactoryMethod(LogEverythingResource); /** * @param {string} methodName @@ -2443,7 +2475,7 @@ ResourceTrackingManager.prototype = { }, /** - * @param {Function} callback + * @param {function()} callback */ _setZeroTimeouts: function(callback) { @@ -2470,7 +2502,7 @@ var InjectedScript = function() InjectedScript.prototype = { /** - * @param {WebGLRenderingContext} glContext + * @param {!WebGLRenderingContext} glContext * @return {Object} */ wrapWebGLContext: function(glContext) @@ -2481,7 +2513,7 @@ InjectedScript.prototype = { }, /** - * @param {CanvasRenderingContext2D} context + * @param {!CanvasRenderingContext2D} context * @return {Object} */ wrapCanvas2DContext: function(context) @@ -2581,7 +2613,7 @@ InjectedScript.prototype = { }, /** - * @param {WebGLRenderingContext} originalGlContext + * @param {!WebGLRenderingContext} originalGlContext * @return {WebGLRenderingContext} */ _constructWebGLReplayContext: function(originalGlContext) @@ -2612,7 +2644,7 @@ InjectedScript.prototype = { }, /** - * @param {CanvasRenderingContext2D} originalContext + * @param {!CanvasRenderingContext2D} originalContext * @return {CanvasRenderingContext2D} */ _constructCanvas2DReplayContext: function(originalContext) diff --git a/Source/WebCore/inspector/Inspector.json b/Source/WebCore/inspector/Inspector.json index 57bd79a72..51d86b861 100644 --- a/Source/WebCore/inspector/Inspector.json +++ b/Source/WebCore/inspector/Inspector.json @@ -1242,8 +1242,8 @@ "type": "object", "description": "Data entry.", "properties": [ - { "name": "key", "$ref": "Key", "description": "Key." }, - { "name": "primaryKey", "$ref": "Key", "description": "Primary key." }, + { "name": "key", "$ref": "Runtime.RemoteObject", "description": "Key." }, + { "name": "primaryKey", "$ref": "Runtime.RemoteObject", "description": "Primary key." }, { "name": "value", "$ref": "Runtime.RemoteObject", "description": "Value." } ] }, diff --git a/Source/WebCore/inspector/InspectorClient.cpp b/Source/WebCore/inspector/InspectorClient.cpp index 867e0bbd3..cd625b37b 100644 --- a/Source/WebCore/inspector/InspectorClient.cpp +++ b/Source/WebCore/inspector/InspectorClient.cpp @@ -55,7 +55,7 @@ bool InspectorClient::doDispatchMessageOnFrontendPage(Page* frontendPage, const if (!scriptController) return false; - String dispatchToFrontend = "WebInspector.dispatchMessageFromBackend(" + message + ");"; + String dispatchToFrontend = "InspectorFrontendAPI.dispatchMessageAsync(" + message + ");"; // FIXME: This should execute the script in the appropriate world. scriptController->evaluate(ScriptSourceCode(dispatchToFrontend)); diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index da149be02..1b0893472 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -1042,6 +1042,9 @@ PassOwnPtr<HighlightConfig> InspectorDOMAgent::highlightConfigFromInspectorObjec bool showInfo = false; // Default: false (do not show a tooltip). highlightInspectorObject->getBoolean("showInfo", &showInfo); highlightConfig->showInfo = showInfo; + bool showRulers = false; // Default: false (do not show rulers). + highlightInspectorObject->getBoolean("showRulers", &showRulers); + highlightConfig->showRulers = showRulers; highlightConfig->content = parseConfigColor("contentColor", highlightInspectorObject); highlightConfig->contentOutline = parseConfigColor("contentOutlineColor", highlightInspectorObject); highlightConfig->padding = parseConfigColor("paddingColor", highlightInspectorObject); diff --git a/Source/WebCore/inspector/InspectorFrontendHost.cpp b/Source/WebCore/inspector/InspectorFrontendHost.cpp index 82db0bbfe..19b712d5b 100644 --- a/Source/WebCore/inspector/InspectorFrontendHost.cpp +++ b/Source/WebCore/inspector/InspectorFrontendHost.cpp @@ -60,21 +60,21 @@ namespace WebCore { #if ENABLE(CONTEXT_MENUS) class FrontendMenuProvider : public ContextMenuProvider { public: - static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptObject webInspector, const Vector<ContextMenuItem>& items) + static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptObject frontendApiObject, const Vector<ContextMenuItem>& items) { - return adoptRef(new FrontendMenuProvider(frontendHost, webInspector, items)); + return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject, items)); } void disconnect() { - m_webInspector = ScriptObject(); + m_frontendApiObject = ScriptObject(); m_frontendHost = 0; } private: - FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptObject webInspector, const Vector<ContextMenuItem>& items) + FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptObject frontendApiObject, const Vector<ContextMenuItem>& items) : m_frontendHost(frontendHost) - , m_webInspector(webInspector) + , m_frontendApiObject(frontendApiObject) , m_items(items) { } @@ -96,7 +96,7 @@ private: UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); int itemNumber = item->action() - ContextMenuItemBaseCustomTag; - ScriptFunctionCall function(m_webInspector, "contextMenuItemSelected"); + ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSelected"); function.appendArgument(itemNumber); function.call(); } @@ -105,7 +105,7 @@ private: virtual void contextMenuCleared() { if (m_frontendHost) { - ScriptFunctionCall function(m_webInspector, "contextMenuCleared"); + ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared"); function.call(); m_frontendHost->m_menuProvider = 0; @@ -114,7 +114,7 @@ private: } InspectorFrontendHost* m_frontendHost; - ScriptObject m_webInspector; + ScriptObject m_frontendApiObject; Vector<ContextMenuItem> m_items; }; #endif @@ -270,12 +270,12 @@ void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe { ASSERT(m_frontendPage); ScriptState* frontendScriptState = scriptStateFromPage(debuggerWorld(), m_frontendPage); - ScriptObject webInspectorObj; - if (!ScriptGlobalObject::get(frontendScriptState, "WebInspector", webInspectorObj)) { + ScriptObject frontendApiObject; + if (!ScriptGlobalObject::get(frontendScriptState, "InspectorFrontendAPI", frontendApiObject)) { ASSERT_NOT_REACHED(); return; } - RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, webInspectorObj, items); + RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items); ContextMenuController* menuController = m_frontendPage->contextMenuController(); menuController->showContextMenu(event, menuProvider); m_menuProvider = menuProvider.get(); diff --git a/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp b/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp index 63401dd6e..32e1c7d4f 100644 --- a/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp +++ b/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp @@ -36,34 +36,33 @@ #include "DOMStringList.h" #include "DOMWindow.h" +#include "DOMWindowIndexedDatabase.h" #include "Document.h" +#include "Event.h" +#include "EventListener.h" +#include "EventTarget.h" #include "ExceptionCode.h" #include "Frame.h" -#include "GroupSettings.h" -#include "IDBCallbacks.h" #include "IDBCursor.h" -#include "IDBCursorBackendInterface.h" -#include "IDBDatabaseBackendInterface.h" +#include "IDBCursorWithValue.h" +#include "IDBDatabase.h" #include "IDBDatabaseCallbacks.h" -#include "IDBFactoryBackendInterface.h" -#include "IDBIndexBackendInterface.h" +#include "IDBFactory.h" +#include "IDBIndex.h" #include "IDBKey.h" #include "IDBKeyPath.h" #include "IDBKeyRange.h" #include "IDBMetadata.h" -#include "IDBObjectStoreBackendInterface.h" -#include "IDBPendingTransactionMonitor.h" +#include "IDBObjectStore.h" +#include "IDBOpenDBRequest.h" +#include "IDBRequest.h" #include "IDBTransaction.h" -#include "IDBTransactionBackendInterface.h" #include "InjectedScript.h" #include "InspectorFrontend.h" #include "InspectorPageAgent.h" #include "InspectorState.h" #include "InspectorValues.h" #include "InstrumentingAgents.h" -#include "Page.h" -#include "PageGroup.h" -#include "PageGroupIndexedDatabase.h" #include "SecurityOrigin.h" #include <wtf/Vector.h> @@ -81,6 +80,7 @@ using WebCore::TypeBuilder::IndexedDB::ObjectStoreIndex; typedef WebCore::InspectorBackendDispatcher::IndexedDBCommandHandler::RequestDatabaseNamesForFrameCallback RequestDatabaseNamesForFrameCallback; typedef WebCore::InspectorBackendDispatcher::IndexedDBCommandHandler::RequestDatabaseCallback RequestDatabaseCallback; typedef WebCore::InspectorBackendDispatcher::IndexedDBCommandHandler::RequestDataCallback RequestDataCallback; +typedef WebCore::InspectorBackendDispatcher::CallbackBase RequestCallback; namespace WebCore { @@ -90,59 +90,8 @@ static const char indexedDBAgentEnabled[] = "indexedDBAgentEnabled"; namespace { -class InspectorIDBCallback : public IDBCallbacks { -public: - virtual ~InspectorIDBCallback() { } - - virtual void onError(PassRefPtr<IDBDatabaseError>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<DOMStringList>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<IDBCursorBackendInterface>, PassRefPtr<IDBKey>, PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<IDBKey>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<SerializedScriptValue>) OVERRIDE { } - virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) OVERRIDE { } - virtual void onSuccess(int64_t value) OVERRIDE { return onSuccess(SerializedScriptValue::numberValue(value)); } - virtual void onSuccess() OVERRIDE { return onSuccess(SerializedScriptValue::undefinedValue()); } - virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>) OVERRIDE { } - virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) OVERRIDE { } - virtual void onUpgradeNeeded(int64_t, PassRefPtr<WebCore::IDBTransactionBackendInterface>, PassRefPtr<WebCore::IDBDatabaseBackendInterface>) OVERRIDE { } - virtual void onBlocked() OVERRIDE { } -}; - -class InspectorIDBDatabaseCallbacks : public IDBDatabaseCallbacks { -public: - static PassRefPtr<InspectorIDBDatabaseCallbacks> create() - { - return adoptRef(new InspectorIDBDatabaseCallbacks()); - } - - virtual ~InspectorIDBDatabaseCallbacks() { } - - virtual void onVersionChange(const String& version) { } - virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) { } - virtual void onForcedClose() { } -private: - InspectorIDBDatabaseCallbacks() { } -}; - - -class InspectorIDBTransactionCallback : public IDBTransactionCallbacks { -public: - static PassRefPtr<InspectorIDBTransactionCallback> create() - { - return adoptRef(new InspectorIDBTransactionCallback()); - } - - virtual ~InspectorIDBTransactionCallback() { } - - virtual void onAbort(PassRefPtr<IDBDatabaseError>) { } - virtual void onComplete() { } -private: - InspectorIDBTransactionCallback() { } -}; - -class GetDatabaseNamesCallback : public InspectorIDBCallback { +class GetDatabaseNamesCallback : public EventListener { + WTF_MAKE_NONCOPYABLE(GetDatabaseNamesCallback); public: static PassRefPtr<GetDatabaseNamesCallback> create(PassRefPtr<RequestDatabaseNamesForFrameCallback> requestCallback, const String& securityOrigin) { @@ -151,11 +100,32 @@ public: virtual ~GetDatabaseNamesCallback() { } - virtual void onSuccess(PassRefPtr<DOMStringList> databaseNamesList) + virtual bool operator==(const EventListener& other) OVERRIDE + { + return this == &other; + } + + virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE { if (!m_requestCallback->isActive()) return; + if (event->type() != eventNames().successEvent) { + m_requestCallback->sendFailure("Unexpected event type."); + return; + } + IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); + ExceptionCode ec = 0; + RefPtr<IDBAny> requestResult = idbRequest->result(ec); + if (ec) { + m_requestCallback->sendFailure("Could not get result in callback."); + return; + } + if (requestResult->type() != IDBAny::DOMStringListType) { + m_requestCallback->sendFailure("Unexpected result type."); + return; + } + RefPtr<DOMStringList> databaseNamesList = requestResult->domStringList(); RefPtr<TypeBuilder::Array<String> > databaseNames = TypeBuilder::Array<String>::create(); for (size_t i = 0; i < databaseNamesList->length(); ++i) databaseNames->addItem(databaseNamesList->item(i)); @@ -163,48 +133,32 @@ public: RefPtr<SecurityOriginWithDatabaseNames> result = SecurityOriginWithDatabaseNames::create() .setSecurityOrigin(m_securityOrigin) .setDatabaseNames(databaseNames); - m_requestCallback->sendSuccess(result); } private: GetDatabaseNamesCallback(PassRefPtr<RequestDatabaseNamesForFrameCallback> requestCallback, const String& securityOrigin) - : m_requestCallback(requestCallback) + : EventListener(EventListener::CPPEventListenerType) + , m_requestCallback(requestCallback) , m_securityOrigin(securityOrigin) { } RefPtr<RequestDatabaseNamesForFrameCallback> m_requestCallback; String m_securityOrigin; }; -class DatabaseConnection { -public: - DatabaseConnection() - : m_idbDatabaseCallbacks(InspectorIDBDatabaseCallbacks::create()) { } - - ~DatabaseConnection() - { - if (m_idbDatabase) - m_idbDatabase->close(m_idbDatabaseCallbacks); - } - - void connect(PassRefPtr<IDBDatabaseBackendInterface> database) { m_idbDatabase = database; } - PassRefPtr<IDBDatabaseCallbacks> callbacks() { return m_idbDatabaseCallbacks; } - -private: - RefPtr<IDBDatabaseBackendInterface> m_idbDatabase; - RefPtr<IDBDatabaseCallbacks> m_idbDatabaseCallbacks; -}; - class ExecutableWithDatabase : public RefCounted<ExecutableWithDatabase> { public: + ExecutableWithDatabase(ScriptExecutionContext* context) + : m_context(context) { } virtual ~ExecutableWithDatabase() { }; - void start(IDBFactoryBackendInterface*, SecurityOrigin*, ScriptExecutionContext*, const String& databaseName); - void connect(PassRefPtr<IDBDatabaseBackendInterface> database) { m_connection.connect(database); } - virtual void execute(PassRefPtr<IDBDatabaseBackendInterface>) = 0; + void start(IDBFactory*, SecurityOrigin*, const String& databaseName); + virtual void execute(PassRefPtr<IDBDatabase>) = 0; + virtual RequestCallback* requestCallback() = 0; + ScriptExecutionContext* context() { return m_context; }; private: - DatabaseConnection m_connection; + ScriptExecutionContext* m_context; }; -class OpenDatabaseCallback : public InspectorIDBCallback { +class OpenDatabaseCallback : public EventListener { public: static PassRefPtr<OpenDatabaseCallback> create(ExecutableWithDatabase* executableWithDatabase) { @@ -213,49 +167,76 @@ public: virtual ~OpenDatabaseCallback() { } - virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface> prpDatabase) + virtual bool operator==(const EventListener& other) OVERRIDE + { + return this == &other; + } + + virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE { - RefPtr<IDBDatabaseBackendInterface> idbDatabase = prpDatabase; - m_executableWithDatabase->connect(idbDatabase); + if (event->type() != eventNames().successEvent) { + m_executableWithDatabase->requestCallback()->sendFailure("Unexpected event type."); + return; + } + + IDBOpenDBRequest* idbOpenDBRequest = static_cast<IDBOpenDBRequest*>(event->target()); + ExceptionCode ec = 0; + RefPtr<IDBAny> requestResult = idbOpenDBRequest->result(ec); + if (ec) { + m_executableWithDatabase->requestCallback()->sendFailure("Could not get result in callback."); + return; + } + if (requestResult->type() != IDBAny::IDBDatabaseType) { + m_executableWithDatabase->requestCallback()->sendFailure("Unexpected result type."); + return; + } + + RefPtr<IDBDatabase> idbDatabase = requestResult->idbDatabase(); m_executableWithDatabase->execute(idbDatabase); + idbDatabase->close(); } private: OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase) - : m_executableWithDatabase(executableWithDatabase) { } + : EventListener(EventListener::CPPEventListenerType) + , m_executableWithDatabase(executableWithDatabase) { } RefPtr<ExecutableWithDatabase> m_executableWithDatabase; }; -void ExecutableWithDatabase::start(IDBFactoryBackendInterface* idbFactory, SecurityOrigin* securityOrigin, ScriptExecutionContext* context, const String& databaseName) +void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin* securityOrigin, const String& databaseName) { RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); - idbFactory->open(databaseName, IDBDatabaseMetadata::NoIntVersion, callback, m_connection.callbacks(), securityOrigin, context, String()); + ExceptionCode ec = 0; + RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(context(), databaseName, ec); + if (ec) { + requestCallback()->sendFailure("Could not open database."); + return; + } + idbOpenDBRequest->addEventListener(eventNames().successEvent, callback, false); } -static PassRefPtr<IDBTransactionBackendInterface> transactionForDatabase(IDBDatabaseBackendInterface* idbDatabase, const String& objectStoreName) +static PassRefPtr<IDBTransaction> transactionForDatabase(ScriptExecutionContext* scriptExecutionContext, IDBDatabase* idbDatabase, const String& objectStoreName) { ExceptionCode ec = 0; - RefPtr<DOMStringList> transactionObjectStoreNamesList = DOMStringList::create(); - transactionObjectStoreNamesList->append(objectStoreName); - RefPtr<IDBTransactionBackendInterface> idbTransaction = idbDatabase->transaction(transactionObjectStoreNamesList.get(), IDBTransaction::READ_ONLY, ec); + RefPtr<IDBTransaction> idbTransaction = idbDatabase->transaction(scriptExecutionContext, objectStoreName, IDBTransaction::modeReadOnly(), ec); if (ec) return 0; return idbTransaction; } -static PassRefPtr<IDBObjectStoreBackendInterface> objectStoreForTransaction(IDBTransactionBackendInterface* idbTransaction, const String& objectStoreName) +static PassRefPtr<IDBObjectStore> objectStoreForTransaction(IDBTransaction* idbTransaction, const String& objectStoreName) { ExceptionCode ec = 0; - RefPtr<IDBObjectStoreBackendInterface> idbObjectStore = idbTransaction->objectStore(objectStoreName, ec); + RefPtr<IDBObjectStore> idbObjectStore = idbTransaction->objectStore(objectStoreName, ec); if (ec) return 0; return idbObjectStore; } -static PassRefPtr<IDBIndexBackendInterface> indexForObjectStore(IDBObjectStoreBackendInterface* idbObjectStore, const String& indexName) +static PassRefPtr<IDBIndex> indexForObjectStore(IDBObjectStore* idbObjectStore, const String& indexName) { ExceptionCode ec = 0; - RefPtr<IDBIndexBackendInterface> idbIndex = idbObjectStore->index(indexName, ec); + RefPtr<IDBIndex> idbIndex = idbObjectStore->index(indexName, ec); if (ec) return 0; return idbIndex; @@ -288,19 +269,19 @@ static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath) return keyPath.release(); } -class DatabaseLoaderCallback : public ExecutableWithDatabase { +class DatabaseLoader : public ExecutableWithDatabase { public: - static PassRefPtr<DatabaseLoaderCallback> create(PassRefPtr<RequestDatabaseCallback> requestCallback) + static PassRefPtr<DatabaseLoader> create(ScriptExecutionContext* context, PassRefPtr<RequestDatabaseCallback> requestCallback) { - return adoptRef(new DatabaseLoaderCallback(requestCallback)); + return adoptRef(new DatabaseLoader(context, requestCallback)); } - virtual ~DatabaseLoaderCallback() { } + virtual ~DatabaseLoader() { } - virtual void execute(PassRefPtr<IDBDatabaseBackendInterface> prpDatabase) + virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) { - RefPtr<IDBDatabaseBackendInterface> idbDatabase = prpDatabase; - if (!m_requestCallback->isActive()) + RefPtr<IDBDatabase> idbDatabase = prpDatabase; + if (!requestCallback()->isActive()) return; const IDBDatabaseMetadata databaseMetadata = idbDatabase->metadata(); @@ -339,9 +320,11 @@ public: m_requestCallback->sendSuccess(result); } + virtual RequestCallback* requestCallback() { return m_requestCallback.get(); } private: - DatabaseLoaderCallback(PassRefPtr<RequestDatabaseCallback> requestCallback) - : m_requestCallback(requestCallback) { } + DatabaseLoader(ScriptExecutionContext* context, PassRefPtr<RequestDatabaseCallback> requestCallback) + : ExecutableWithDatabase(context) + , m_requestCallback(requestCallback) { } RefPtr<RequestDatabaseCallback> m_requestCallback; }; @@ -416,75 +399,53 @@ static PassRefPtr<IDBKeyRange> idbKeyRangeFromKeyRange(InspectorObject* keyRange return idbKeyRange.release(); } -static PassRefPtr<Key> keyFromIDBKey(IDBKey* idbKey) -{ - if (!idbKey || !idbKey->isValid()) - return 0; - - RefPtr<Key> key; - switch (idbKey->type()) { - case IDBKey::InvalidType: - case IDBKey::MinType: - return 0; - case IDBKey::NumberType: { - RefPtr<Key> tmpKey = Key::create().setType(Key::Type::Number); - key = tmpKey; - key->setNumber(idbKey->number()); - break; - } - case IDBKey::StringType: { - RefPtr<Key> tmpKey = Key::create().setType(Key::Type::String); - key = tmpKey; - key->setString(idbKey->string()); - break; - } - case IDBKey::DateType: { - RefPtr<Key> tmpKey = Key::create().setType(Key::Type::Date); - key = tmpKey; - key->setDate(idbKey->date()); - break; - } - case IDBKey::ArrayType: { - RefPtr<Key> tmpKey = Key::create().setType(Key::Type::Array); - key = tmpKey; - RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::Key> > array = TypeBuilder::Array<TypeBuilder::IndexedDB::Key>::create(); - IDBKey::KeyArray keyArray = idbKey->array(); - for (size_t i = 0; i < keyArray.size(); ++i) - array->addItem(keyFromIDBKey(keyArray[i].get())); - key->setArray(array); - break; - } - } - return key.release(); -} - -class DataLoaderCallback; +class DataLoader; -class OpenCursorCallback : public InspectorIDBCallback { +class OpenCursorCallback : public EventListener { public: - static PassRefPtr<OpenCursorCallback> create(InjectedScript injectedScript, PassRefPtr<DataLoaderCallback> dataLoaderCallback, PassRefPtr<IDBTransactionBackendInterface> idbTransaction, PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize) + static PassRefPtr<OpenCursorCallback> create(InjectedScript injectedScript, PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize) { - return adoptRef(new OpenCursorCallback(injectedScript, dataLoaderCallback, idbTransaction, requestCallback, skipCount, pageSize)); + return adoptRef(new OpenCursorCallback(injectedScript, requestCallback, skipCount, pageSize)); } virtual ~OpenCursorCallback() { } - virtual void onSuccess(PassRefPtr<SerializedScriptValue>) + virtual bool operator==(const EventListener& other) OVERRIDE { - end(false); + return this == &other; } - virtual void onSuccess(PassRefPtr<IDBCursorBackendInterface> idbCursor, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValue> value) + virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE { - m_idbCursor = idbCursor; - onSuccess(key, primaryKey, value); - } + if (event->type() != eventNames().successEvent) { + m_requestCallback->sendFailure("Unexpected event type."); + return; + } + + IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); + ExceptionCode ec = 0; + RefPtr<IDBAny> requestResult = idbRequest->result(ec); + if (ec) { + m_requestCallback->sendFailure("Could not get result in callback."); + return; + } + if (requestResult->type() == IDBAny::ScriptValueType) { + end(false); + return; + } + if (requestResult->type() != IDBAny::IDBCursorWithValueType) { + m_requestCallback->sendFailure("Unexpected result type."); + return; + } + + RefPtr<IDBCursorWithValue> idbCursor = requestResult->idbCursorWithValue(); - virtual void onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValue> value) - { if (m_skipCount) { - --m_skipCount; - next(); + ExceptionCode ec = 0; + idbCursor->advance(m_skipCount, ec); + if (ec) + m_requestCallback->sendFailure("Could not advance cursor."); + m_skipCount = 0; return; } @@ -493,99 +454,91 @@ public: return; } - RefPtr<TypeBuilder::Runtime::RemoteObject> wrappedValue = m_injectedScript.wrapSerializedObject(value.get(), String()); + // Continue cursor before making injected script calls, otherwise transaction might be finished. + idbCursor->continueFunction(0, ec); + if (ec) { + m_requestCallback->sendFailure("Could not continue cursor."); + return; + } + RefPtr<DataEntry> dataEntry = DataEntry::create() - .setKey(keyFromIDBKey(key.get())) - .setPrimaryKey(keyFromIDBKey(primaryKey.get())) - .setValue(wrappedValue); + .setKey(m_injectedScript.wrapObject(idbCursor->key(), String())) + .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(), String())) + .setValue(m_injectedScript.wrapObject(idbCursor->value(), String())); m_result->addItem(dataEntry); - next(); - } - - void next() - { - ExceptionCode ec = 0; - m_idbCursor->continueFunction(0, this, ec); - m_idbCursor->postSuccessHandlerCallback(); - m_idbTransaction->didCompleteTaskEvents(); } void end(bool hasMore) { - m_dataLoaderCallback.clear(); if (!m_requestCallback->isActive()) return; - - if (m_idbCursor) - m_idbCursor->postSuccessHandlerCallback(); - m_idbTransaction->didCompleteTaskEvents(); - m_requestCallback->sendSuccess(m_result.release(), hasMore); } private: - OpenCursorCallback(InjectedScript injectedScript, PassRefPtr<DataLoaderCallback> dataLoaderCallback, PassRefPtr<IDBTransactionBackendInterface> idbTransaction, PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize) - : m_injectedScript(injectedScript) - , m_dataLoaderCallback(dataLoaderCallback) - , m_idbTransaction(idbTransaction) + OpenCursorCallback(InjectedScript injectedScript, PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize) + : EventListener(EventListener::CPPEventListenerType) + , m_injectedScript(injectedScript) , m_requestCallback(requestCallback) , m_skipCount(skipCount) , m_pageSize(pageSize) { m_result = Array<DataEntry>::create(); - m_idbTransaction->setCallbacks(InspectorIDBTransactionCallback::create().get()); } InjectedScript m_injectedScript; - RefPtr<DataLoaderCallback> m_dataLoaderCallback; - RefPtr<IDBTransactionBackendInterface> m_idbTransaction; RefPtr<RequestDataCallback> m_requestCallback; int m_skipCount; unsigned m_pageSize; RefPtr<Array<DataEntry> > m_result; - RefPtr<IDBCursorBackendInterface> m_idbCursor; }; -class DataLoaderCallback : public ExecutableWithDatabase { +class DataLoader : public ExecutableWithDatabase { public: - static PassRefPtr<DataLoaderCallback> create(PassRefPtr<RequestDataCallback> requestCallback, const InjectedScript& injectedScript, const String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) + static PassRefPtr<DataLoader> create(ScriptExecutionContext* context, PassRefPtr<RequestDataCallback> requestCallback, const InjectedScript& injectedScript, const String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) { - return adoptRef(new DataLoaderCallback(requestCallback, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize)); + return adoptRef(new DataLoader(context, requestCallback, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize)); } - virtual ~DataLoaderCallback() { } + virtual ~DataLoader() { } - virtual void execute(PassRefPtr<IDBDatabaseBackendInterface> prpDatabase) + virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) { - RefPtr<IDBDatabaseBackendInterface> idbDatabase = prpDatabase; - if (!m_requestCallback->isActive()) + RefPtr<IDBDatabase> idbDatabase = prpDatabase; + if (!requestCallback()->isActive()) return; - - RefPtr<IDBTransactionBackendInterface> idbTransaction = transactionForDatabase(idbDatabase.get(), m_objectStoreName); - if (!idbTransaction) + RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context(), idbDatabase.get(), m_objectStoreName); + if (!idbTransaction) { + m_requestCallback->sendFailure("Could not get transaction"); return; - RefPtr<IDBObjectStoreBackendInterface> idbObjectStore = objectStoreForTransaction(idbTransaction.get(), m_objectStoreName); - if (!idbObjectStore) + } + RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTransaction.get(), m_objectStoreName); + if (!idbObjectStore) { + m_requestCallback->sendFailure("Could not get object store"); return; + } - RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::create(m_injectedScript, this, idbTransaction.get(), m_requestCallback, m_skipCount, m_pageSize); + RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::create(m_injectedScript, m_requestCallback, m_skipCount, m_pageSize); + ExceptionCode ec = 0; + RefPtr<IDBRequest> idbRequest; if (!m_indexName.isEmpty()) { - RefPtr<IDBIndexBackendInterface> idbIndex = indexForObjectStore(idbObjectStore.get(), m_indexName); - if (!idbIndex) + RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get(), m_indexName); + if (!idbIndex) { + m_requestCallback->sendFailure("Could not get index"); return; + } - ExceptionCode ec = 0; - idbIndex->openCursor(m_idbKeyRange, IDBCursor::NEXT, openCursorCallback, idbTransaction.get(), ec); - } else { - ExceptionCode ec = 0; - idbObjectStore->openCursor(m_idbKeyRange, IDBCursor::NEXT, openCursorCallback, IDBTransactionBackendInterface::NormalTask, idbTransaction.get(), ec); - } + idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>(m_idbKeyRange), ec); + } else + idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKeyRange>(m_idbKeyRange), ec); + idbRequest->addEventListener(eventNames().successEvent, openCursorCallback, false); } -private: - DataLoaderCallback(PassRefPtr<RequestDataCallback> requestCallback, const InjectedScript& injectedScript, const String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) - : m_requestCallback(requestCallback) + virtual RequestCallback* requestCallback() { return m_requestCallback.get(); } + DataLoader(ScriptExecutionContext* scriptExecutionContext, PassRefPtr<RequestDataCallback> requestCallback, const InjectedScript& injectedScript, const String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) + : ExecutableWithDatabase(scriptExecutionContext) + , m_requestCallback(requestCallback) , m_injectedScript(injectedScript) , m_objectStoreName(objectStoreName) , m_indexName(indexName) @@ -668,10 +621,14 @@ static Document* assertDocument(ErrorString* errorString, const String& frameId, return document; } -static IDBFactoryBackendInterface* assertIDBFactory(ErrorString* errorString, Document* document) +static IDBFactory* assertIDBFactory(ErrorString* errorString, Document* document) { - Page* page = document ? document->page() : 0; - IDBFactoryBackendInterface* idbFactory = page ? PageGroupIndexedDatabase::from(page->group())->factoryBackend() : 0; + DOMWindow* domWindow = document->domWindow(); + if (!domWindow) { + *errorString = "No IndexedDB factory for given frame found"; + return 0; + } + IDBFactory* idbFactory = DOMWindowIndexedDatabase::indexedDB(domWindow); if (!idbFactory) *errorString = "No IndexedDB factory for given frame found"; @@ -684,13 +641,11 @@ void InspectorIndexedDBAgent::requestDatabaseNamesForFrame(ErrorString* errorStr Document* document = assertDocument(errorString, frameId, m_pageAgent); if (!document) return; - IDBFactoryBackendInterface* idbFactory = assertIDBFactory(errorString, document); + IDBFactory* idbFactory = assertIDBFactory(errorString, document); if (!idbFactory) return; - - RefPtr<GetDatabaseNamesCallback> callback = GetDatabaseNamesCallback::create(requestCallback, document->securityOrigin()->toString()); - GroupSettings* groupSettings = document->page()->group().groupSettings(); - idbFactory->getDatabaseNames(callback.get(), document->securityOrigin(), document, groupSettings->indexedDBDatabasePath()); + RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document); + idbRequest->addEventListener(eventNames().successEvent, GetDatabaseNamesCallback::create(requestCallback, document->securityOrigin()->toString()), false); } void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const String& frameId, const String& databaseName, PassRefPtr<RequestDatabaseCallback> requestCallback) @@ -698,12 +653,12 @@ void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St Document* document = assertDocument(errorString, frameId, m_pageAgent); if (!document) return; - IDBFactoryBackendInterface* idbFactory = assertIDBFactory(errorString, document); + IDBFactory* idbFactory = assertIDBFactory(errorString, document); if (!idbFactory) return; - RefPtr<DatabaseLoaderCallback> databaseLoaderCallback = DatabaseLoaderCallback::create(requestCallback); - databaseLoaderCallback->start(idbFactory, document->securityOrigin(), document, databaseName); + RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(document, requestCallback); + databaseLoader->start(idbFactory, document->securityOrigin(), databaseName); } void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String& frameId, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const RefPtr<InspectorObject>* keyRange, PassRefPtr<RequestDataCallback> requestCallback) @@ -714,7 +669,7 @@ void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String Document* document = assertDocument(errorString, frame); if (!document) return; - IDBFactoryBackendInterface* idbFactory = assertIDBFactory(errorString, document); + IDBFactory* idbFactory = assertIDBFactory(errorString, document); if (!idbFactory) return; @@ -726,8 +681,8 @@ void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String return; } - RefPtr<DataLoaderCallback> dataLoaderCallback = DataLoaderCallback::create(requestCallback, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize); - dataLoaderCallback->start(idbFactory, document->securityOrigin(), document, databaseName); + RefPtr<DataLoader> dataLoader = DataLoader::create(document, requestCallback, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize); + dataLoader->start(idbFactory, document->securityOrigin(), databaseName); } } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorOverlay.cpp b/Source/WebCore/inspector/InspectorOverlay.cpp index 3ceab7fd9..c5e9f8aac 100644 --- a/Source/WebCore/inspector/InspectorOverlay.cpp +++ b/Source/WebCore/inspector/InspectorOverlay.cpp @@ -109,7 +109,7 @@ static void buildNodeHighlight(Node* node, const HighlightConfig& highlightConfi if (!renderer || !containingFrame) return; - highlight->setColors(highlightConfig); + highlight->setDataFromConfig(highlightConfig); FrameView* containingView = containingFrame->view(); FrameView* mainView = containingFrame->page()->mainFrame()->view(); IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRootView(renderer->absoluteBoundingBoxRect())); @@ -186,7 +186,7 @@ static void buildRectHighlight(Page* page, IntRect* rect, const HighlightConfig& { if (!page) return; - highlight->setColors(highlightConfig); + highlight->setDataFromConfig(highlightConfig); FloatRect highlightRect(*rect); highlight->type = HighlightTypeRects; highlight->quads.append(highlightRect); @@ -336,6 +336,7 @@ static PassRefPtr<InspectorObject> buildObjectForHighlight(FrameView* mainView, for (size_t i = 0; i < highlight.quads.size(); ++i) array->pushArray(buildArrayForQuad(highlight.quads[i])); object->setArray("quads", array.release()); + object->setBoolean("showRulers", highlight.showRulers); object->setString("contentColor", highlight.contentColor.serialized()); object->setString("contentOutlineColor", highlight.contentOutlineColor.serialized()); object->setString("paddingColor", highlight.paddingColor.serialized()); diff --git a/Source/WebCore/inspector/InspectorOverlay.h b/Source/WebCore/inspector/InspectorOverlay.h index b351f9e1e..6c8aa3717 100644 --- a/Source/WebCore/inspector/InspectorOverlay.h +++ b/Source/WebCore/inspector/InspectorOverlay.h @@ -31,7 +31,7 @@ #include "Color.h" #include "FloatQuad.h" -#include "LayoutTypes.h" +#include "LayoutRect.h" #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> @@ -58,6 +58,7 @@ public: Color border; Color margin; bool showInfo; + bool showRulers; }; enum HighlightType { @@ -66,13 +67,20 @@ enum HighlightType { }; struct Highlight { - void setColors(const HighlightConfig& highlightConfig) + Highlight() + : type(HighlightTypeNode) + , showRulers(false) + { + } + + void setDataFromConfig(const HighlightConfig& highlightConfig) { contentColor = highlightConfig.content; contentOutlineColor = highlightConfig.contentOutline; paddingColor = highlightConfig.padding; borderColor = highlightConfig.border; marginColor = highlightConfig.margin; + showRulers = highlightConfig.showRulers; } Color contentColor; @@ -85,6 +93,7 @@ struct Highlight { // When the type is Rects, this is just a list of quads. HighlightType type; Vector<FloatQuad> quads; + bool showRulers; }; class InspectorOverlay { diff --git a/Source/WebCore/inspector/InspectorOverlayPage.html b/Source/WebCore/inspector/InspectorOverlayPage.html index 2fc8bd635..4c4f903b1 100644 --- a/Source/WebCore/inspector/InspectorOverlayPage.html +++ b/Source/WebCore/inspector/InspectorOverlayPage.html @@ -124,6 +124,8 @@ function drawPausedInDebuggerMessage(message) function _drawGrid(highlight, rulerAtRight, rulerAtBottom) { + if (!highlight.showRulers) + return; context.save(); var width = canvas.width; @@ -403,6 +405,8 @@ function _drawElementTitle(highlight) function _drawRulers(highlight, rulerAtRight, rulerAtBottom) { + if (!highlight.showRulers) + return; context.save(); var width = canvas.width; var height = canvas.height; diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.cpp b/Source/WebCore/inspector/InspectorTimelineAgent.cpp index aad827ef7..e12101010 100644 --- a/Source/WebCore/inspector/InspectorTimelineAgent.cpp +++ b/Source/WebCore/inspector/InspectorTimelineAgent.cpp @@ -398,19 +398,8 @@ void InspectorTimelineAgent::didScheduleResourceRequest(const String& url, Frame void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request, Frame* frame) { - pushGCEventRecords(); - RefPtr<InspectorObject> recordRaw = TimelineRecordFactory::createGenericRecord(timestamp(), m_maxCallStackDepth); String requestId = IdentifiersFactory::requestId(identifier); - recordRaw->setObject("data", TimelineRecordFactory::createResourceSendRequestData(requestId, request)); - recordRaw->setString("type", TimelineRecordType::ResourceSendRequest); - if (frame && m_pageAgent) { - String frameId(m_pageAgent->frameId(frame)); - recordRaw->setString("frameId", frameId); - } - setHeapSizeStatistics(recordRaw.get()); - // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now. - RefPtr<TypeBuilder::Timeline::TimelineEvent> record = TypeBuilder::Timeline::TimelineEvent::runtimeCast(recordRaw.release()); - m_frontend->eventRecorded(record.release()); + appendRecord(TimelineRecordFactory::createResourceSendRequestData(requestId, request), TimelineRecordType::ResourceSendRequest, true, frame); } void InspectorTimelineAgent::willReceiveResourceData(unsigned long identifier, Frame* frame, int length) diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.h b/Source/WebCore/inspector/InspectorTimelineAgent.h index 36e2b117b..4b618b170 100644 --- a/Source/WebCore/inspector/InspectorTimelineAgent.h +++ b/Source/WebCore/inspector/InspectorTimelineAgent.h @@ -36,7 +36,7 @@ #include "InspectorBaseAgent.h" #include "InspectorFrontend.h" #include "InspectorValues.h" -#include "LayoutTypes.h" +#include "LayoutRect.h" #include "PlatformInstrumentation.h" #include "ScriptGCEvent.h" #include "ScriptGCEventListener.h" diff --git a/Source/WebCore/inspector/TimelineRecordFactory.cpp b/Source/WebCore/inspector/TimelineRecordFactory.cpp index 776b59f6f..8dee5300d 100644 --- a/Source/WebCore/inspector/TimelineRecordFactory.cpp +++ b/Source/WebCore/inspector/TimelineRecordFactory.cpp @@ -37,7 +37,7 @@ #include "Event.h" #include "InspectorValues.h" #include "IntRect.h" -#include "LayoutTypesInlineMethods.h" +#include "LayoutRect.h" #include "ResourceRequest.h" #include "ResourceResponse.h" #include "ScriptCallStack.h" diff --git a/Source/WebCore/inspector/TimelineRecordFactory.h b/Source/WebCore/inspector/TimelineRecordFactory.h index c5dcec2b7..eeee67203 100644 --- a/Source/WebCore/inspector/TimelineRecordFactory.h +++ b/Source/WebCore/inspector/TimelineRecordFactory.h @@ -31,7 +31,7 @@ #ifndef TimelineRecordFactory_h #define TimelineRecordFactory_h -#include "LayoutTypes.h" +#include "LayoutRect.h" #include <wtf/Forward.h> namespace WebCore { diff --git a/Source/WebCore/inspector/front-end/CanvasProfileView.js b/Source/WebCore/inspector/front-end/CanvasProfileView.js index 35d557eef..df7f5109a 100644 --- a/Source/WebCore/inspector/front-end/CanvasProfileView.js +++ b/Source/WebCore/inspector/front-end/CanvasProfileView.js @@ -100,8 +100,9 @@ WebInspector.CanvasProfileView.prototype = { function didReceiveTraceLog(error, traceLog) { this._traceLogElement.textContent = ""; - if (!traceLog) + if (error || !traceLog) return; + var fragment = document.createDocumentFragment(); var calls = traceLog.calls; for (var i = 0, n = calls.length; i < n; ++i) { var call = calls[i]; @@ -128,20 +129,39 @@ WebInspector.CanvasProfileView.prototype = { if (typeof call.result !== "undefined") traceLogItem.appendChild(document.createTextNode(" => " + call.result)); - this._traceLogElement.appendChild(traceLogItem); + fragment.appendChild(traceLogItem); + } + this._traceLogElement.appendChild(fragment); + + var lastItem = this._traceLogElement.lastChild; + if (lastItem) { + lastItem.scrollIntoViewIfNeeded(); + this._replayTraceLog(lastItem); } } CanvasAgent.getTraceLog(this._profile.traceLogId(), didReceiveTraceLog.bind(this)); }, + /** + * @param {Event} e + */ _onTraceLogItemClick: function(e) { - var item = e.target; + this._replayTraceLog(/** @type {Element} */ (e.target)); + }, + + /** + * @param {Element} item + */ + _replayTraceLog: function(item) + { if (!item || !item.traceLogId) return; var time = Date.now(); function didReplayTraceLog(error, dataURL) { + if (error) + return; this._debugInfoElement.textContent = "Replay time: " + (Date.now() - time) + "ms"; if (this._activeTraceLogItem) this._activeTraceLogItem.style.backgroundColor = ""; diff --git a/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js b/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js index 7af304679..ff61bdbf0 100644 --- a/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js +++ b/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js @@ -54,8 +54,9 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate) lineNumbers: true, gutters: ["CodeMirror-linenumbers", "breakpoints"] }); - CodeMirror.on(this._codeMirror, "change", this._change.bind(this)); - CodeMirror.on(this._codeMirror, "gutterClick", this._gutterClick.bind(this)); + + this._codeMirror.on("change", this._change.bind(this)); + this._codeMirror.on("gutterClick", this._gutterClick.bind(this)); this._lastRange = this.range(); @@ -117,8 +118,7 @@ WebInspector.CodeMirrorTextEditor.prototype = { revealLine: function(lineNumber) { this._codeMirror.setCursor({ line: lineNumber, ch: 0 }); - var coords = this._codeMirror.cursorCoords(); - this._codeMirror.scrollTo(coords.x, coords.y); + this._codeMirror.scrollIntoView(); }, _gutterClick: function(instance, lineNumber, gutter, event) @@ -276,8 +276,8 @@ WebInspector.CodeMirrorTextEditor.prototype = { */ selection: function(textRange) { - var start = this._codeMirror.cursorCoords(true); - var end = this._codeMirror.cursorCoords(false); + var start = this._codeMirror.getCursor(true); + var end = this._codeMirror.getCursor(false); if (start.line > end.line || (start.line == end.line && start.ch > end.ch)) return this._toRange(end, start); diff --git a/Source/WebCore/inspector/front-end/DOMAgent.js b/Source/WebCore/inspector/front-end/DOMAgent.js index 402064173..ea6917b78 100644 --- a/Source/WebCore/inspector/front-end/DOMAgent.js +++ b/Source/WebCore/inspector/front-end/DOMAgent.js @@ -1242,7 +1242,7 @@ WebInspector.DOMAgent.prototype = { _buildHighlightConfig: function(mode) { mode = mode || "all"; - var highlightConfig = { showInfo: mode === "all" }; + var highlightConfig = { showInfo: mode === "all", showRulers: WebInspector.settings.showMetricsRulers.get() }; if (mode === "all" || mode === "content") highlightConfig.contentColor = WebInspector.Color.PageHighlight.Content.toProtocolRGBA(); diff --git a/Source/WebCore/inspector/front-end/DataGrid.js b/Source/WebCore/inspector/front-end/DataGrid.js index 24a349752..66c024d9a 100644 --- a/Source/WebCore/inspector/front-end/DataGrid.js +++ b/Source/WebCore/inspector/front-end/DataGrid.js @@ -436,49 +436,33 @@ WebInspector.DataGrid.prototype = { }, /** - * @param {number=} maxDescentLevel + * @param {Array.<number>} widths + * @param {number} minPercent + * @param {number=} maxPercent */ - autoSizeColumns: function(minPercent, maxPercent, maxDescentLevel) + _autoSizeWidths: function(widths, minPercent, maxPercent) { if (minPercent) - minPercent = Math.min(minPercent, Math.floor(100 / this._columnCount)); - var widths = {}; - var columns = this.columns; - for (var columnIdentifier in columns) - widths[columnIdentifier] = (columns[columnIdentifier].title || "").length; - - maxDescentLevel = maxDescentLevel || 0; - var children = this._enumerateChildren(this._rootNode, [], maxDescentLevel + 1); - for (var i = 0; i < children.length; ++i) { - var node = children[i]; - for (var columnIdentifier in columns) { - var text = node.data[columnIdentifier] || ""; - if (text.length > widths[columnIdentifier]) - widths[columnIdentifier] = text.length; - } - } - - var totalColumnWidths = 0; - for (var columnIdentifier in columns) - totalColumnWidths += widths[columnIdentifier]; - - var recoupPercent = 0; - for (var columnIdentifier in columns) { - var width = Math.round(100 * widths[columnIdentifier] / totalColumnWidths); - if (minPercent && width < minPercent) { - recoupPercent += (minPercent - width); + minPercent = Math.min(minPercent, Math.floor(100 / widths.length)); + var totalWidth = 0; + for (var i = 0; i < widths.length; ++i) + totalWidth += widths[i]; + var totalPercentWidth = 0; + for (var i = 0; i < widths.length; ++i) { + var width = Math.round(100 * widths[i] / totalWidth); + if (minPercent && width < minPercent) width = minPercent; - } else if (maxPercent && width > maxPercent) { - recoupPercent -= (width - maxPercent); + else if (maxPercent && width > maxPercent) width = maxPercent; - } - widths[columnIdentifier] = width; + totalPercentWidth += width; + widths[i] = width; } + var recoupPercent = totalPercentWidth - 100; while (minPercent && recoupPercent > 0) { - for (var columnIdentifier in columns) { - if (widths[columnIdentifier] > minPercent) { - --widths[columnIdentifier]; + for (var i = 0; i < widths.length; ++i) { + if (widths[i] > minPercent) { + --widths[i]; --recoupPercent; if (!recoupPercent) break; @@ -487,9 +471,9 @@ WebInspector.DataGrid.prototype = { } while (maxPercent && recoupPercent < 0) { - for (var columnIdentifier in columns) { - if (widths[columnIdentifier] < maxPercent) { - ++widths[columnIdentifier]; + for (var i = 0; i < widths.length; ++i) { + if (widths[i] < maxPercent) { + ++widths[i]; ++recoupPercent; if (!recoupPercent) break; @@ -497,8 +481,36 @@ WebInspector.DataGrid.prototype = { } } - for (var columnIdentifier in columns) - columns[columnIdentifier].element.style.width = widths[columnIdentifier] + "%"; + return widths; + }, + + /** + * @param {number} minPercent + * @param {number=} maxPercent + * @param {number=} maxDescentLevel + */ + autoSizeColumns: function(minPercent, maxPercent, maxDescentLevel) + { + var widths = []; + var columnIdentifiers = Object.keys(this.columns); + for (var i = 0; i < columnIdentifiers.length; ++i) + widths[i] = (this.columns[columnIdentifiers[i]].title || "").length; + + maxDescentLevel = maxDescentLevel || 0; + var children = this._enumerateChildren(this._rootNode, [], maxDescentLevel + 1); + for (var i = 0; i < children.length; ++i) { + var node = children[i]; + for (var j = 0; j < columnIdentifiers.length; ++j) { + var text = node.data[columnIdentifiers[j]] || ""; + if (text.length > widths[j]) + widths[j] = text.length; + } + } + + widths = this._autoSizeWidths(widths, minPercent, maxPercent); + + for (var i = 0; i < columnIdentifiers.length; ++i) + this.columns[columnIdentifiers[i]].element.style.width = widths[i] + "%"; this._columnWidthsInitialized = false; this.updateWidths(); }, diff --git a/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js b/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js index d32b2e454..fa1a6e8a1 100644 --- a/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js +++ b/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js @@ -65,10 +65,8 @@ WebInspector.DebuggerScriptMapping.prototype = { */ _mappingForScript: function(script) { - if (WebInspector.experimentsSettings.snippetsSupport.isEnabled()) { - if (this._snippetMapping && this._snippetMapping.snippetIdForSourceURL(script.sourceURL)) - return this._snippetMapping; - } + if (WebInspector.experimentsSettings.snippetsSupport.isEnabled() && script.isSnippet()) + return this._snippetMapping; if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL) { if (this._compilerMapping.loadSourceMapForScript(script)) diff --git a/Source/WebCore/inspector/front-end/ElementsPanel.js b/Source/WebCore/inspector/front-end/ElementsPanel.js index a0e6e1a18..dbe08aa4f 100644 --- a/Source/WebCore/inspector/front-end/ElementsPanel.js +++ b/Source/WebCore/inspector/front-end/ElementsPanel.js @@ -627,17 +627,8 @@ WebInspector.ElementsPanel.prototype = { var crumbs = this.crumbsElement; var handled = false; - var foundRoot = false; var crumb = crumbs.firstChild; while (crumb) { - if (crumb.representedObject === this.treeOutline.rootDOMNode) - foundRoot = true; - - if (foundRoot) - crumb.addStyleClass("dimmed"); - else - crumb.removeStyleClass("dimmed"); - if (crumb.representedObject === this.selectedDOMNode()) { crumb.addStyleClass("selected"); handled = true; @@ -685,14 +676,10 @@ WebInspector.ElementsPanel.prototype = { event.preventDefault(); } - foundRoot = false; for (var current = this.selectedDOMNode(); current; current = current.parentNode) { if (current.nodeType() === Node.DOCUMENT_NODE) continue; - if (current === this.treeOutline.rootDOMNode) - foundRoot = true; - crumb = document.createElement("span"); crumb.className = "crumb"; crumb.representedObject = current; @@ -727,8 +714,6 @@ WebInspector.ElementsPanel.prototype = { crumb.title = crumbTitle; } - if (foundRoot) - crumb.addStyleClass("dimmed"); if (current === this.selectedDOMNode()) crumb.addStyleClass("selected"); if (!crumbs.childNodes.length) @@ -946,18 +931,6 @@ WebInspector.ElementsPanel.prototype = { coalesceCollapsedCrumbs(); } - function compactDimmed(crumb) - { - if (crumb.hasStyleClass("dimmed")) - compact(crumb); - } - - function collapseDimmed(crumb) - { - if (crumb.hasStyleClass("dimmed")) - collapse(crumb, false); - } - if (!focusedCrumb) { // When not focused on a crumb we can be biased and collapse less important // crumbs that the user might not care much about. @@ -969,14 +942,6 @@ WebInspector.ElementsPanel.prototype = { // Collapse child crumbs. if (makeCrumbsSmaller(collapse, ChildSide)) return; - - // Compact dimmed ancestor crumbs. - if (makeCrumbsSmaller(compactDimmed, AncestorSide)) - return; - - // Collapse dimmed ancestor crumbs. - if (makeCrumbsSmaller(collapseDimmed, AncestorSide)) - return; } // Compact ancestor crumbs, or from both sides if focused. diff --git a/Source/WebCore/inspector/front-end/IndexedDBModel.js b/Source/WebCore/inspector/front-end/IndexedDBModel.js index e6440c1bd..45d145e46 100644 --- a/Source/WebCore/inspector/front-end/IndexedDBModel.js +++ b/Source/WebCore/inspector/front-end/IndexedDBModel.js @@ -61,31 +61,6 @@ WebInspector.IndexedDBModel.KeyPathTypes = { ArrayType: "array" }; -/** - * @param {IndexedDBAgent.Key} key - */ -WebInspector.IndexedDBModel.idbKeyFromKey = function(key) -{ - var idbKey; - switch (key.type) { - case WebInspector.IndexedDBModel.KeyTypes.NumberType: - idbKey = key.number; - break; - case WebInspector.IndexedDBModel.KeyTypes.StringType: - idbKey = key.string; - break; - case WebInspector.IndexedDBModel.KeyTypes.DateType: - idbKey = new Date(key.date); - break; - case WebInspector.IndexedDBModel.KeyTypes.ArrayType: - idbKey = []; - for (var i = 0; i < key.array.length; ++i) - idbKey.push(WebInspector.IndexedDBModel.idbKeyFromKey(key.array[i])); - break; - } - return idbKey; -} - WebInspector.IndexedDBModel.keyFromIDBKey = function(idbKey) { if (typeof(idbKey) === "undefined" || idbKey === null) @@ -473,8 +448,8 @@ WebInspector.IndexedDBModel.prototype = { var entries = []; for (var i = 0; i < dataEntries.length; ++i) { - var key = WebInspector.IndexedDBModel.idbKeyFromKey(dataEntries[i].key); - var primaryKey = WebInspector.IndexedDBModel.idbKeyFromKey(dataEntries[i].primaryKey); + var key = WebInspector.RemoteObject.fromPayload(dataEntries[i].key); + var primaryKey = WebInspector.RemoteObject.fromPayload(dataEntries[i].primaryKey); var value = WebInspector.RemoteObject.fromPayload(dataEntries[i].value); entries.push(new WebInspector.IndexedDBModel.Entry(key, primaryKey, value)); } @@ -490,8 +465,8 @@ WebInspector.IndexedDBModel.prototype = { /** * @constructor - * @param {*} key - * @param {*} primaryKey + * @param {WebInspector.RemoteObject} key + * @param {WebInspector.RemoteObject} primaryKey * @param {WebInspector.RemoteObject} value */ WebInspector.IndexedDBModel.Entry = function(key, primaryKey, value) diff --git a/Source/WebCore/inspector/front-end/IndexedDBViews.js b/Source/WebCore/inspector/front-end/IndexedDBViews.js index 41e2de987..07ac91956 100644 --- a/Source/WebCore/inspector/front-end/IndexedDBViews.js +++ b/Source/WebCore/inspector/front-end/IndexedDBViews.js @@ -334,8 +334,7 @@ WebInspector.IDBDataView.prototype = { data["value"] = entries[i].value; var primaryKey = JSON.stringify(this._isIndex ? entries[i].primaryKey : entries[i].key); - var valueTitle = this._objectStore.name + "[" + primaryKey + "]"; - var node = new WebInspector.IDBDataGridNode(valueTitle, data); + var node = new WebInspector.IDBDataGridNode(data); this._dataGrid.rootNode().appendChild(node); } @@ -364,8 +363,9 @@ WebInspector.IDBDataView.prototype = { { this._dataGrid.rootNode().removeChildren(); for (var i = 0; i < this._entries.length; ++i) { - var value = this._entries[i].value; - value.release(); + this._entries[i].key.release(); + this._entries[i].primaryKey.release(); + this._entries[i].value.release(); } this._entries = []; }, @@ -376,14 +376,11 @@ WebInspector.IDBDataView.prototype = { /** * @constructor * @extends {WebInspector.DataGridNode} - * @param {string} valueTitle * @param {*} data */ -WebInspector.IDBDataGridNode = function(valueTitle, data) +WebInspector.IDBDataGridNode = function(data) { WebInspector.DataGridNode.call(this, data, false); - - this._valueTitle = valueTitle; this.selectable = false; } @@ -398,13 +395,10 @@ WebInspector.IDBDataGridNode.prototype = { switch (columnIdentifier) { case "value": - cell.removeChildren(); - this._formatValue(cell, value); - break; case "key": case "primaryKey": cell.removeChildren(); - this._formatValue(cell, new WebInspector.LocalJSONObject(value)); + this._formatValue(cell, value); break; default: } diff --git a/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js b/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js index f1bb82bea..ac276b407 100644 --- a/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js +++ b/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js @@ -161,6 +161,26 @@ var InspectorFrontendAPI = { InspectorFrontendAPI._pendingCommands = []; if (window.opener) window.opener.postMessage(["loadCompleted"], "*"); + }, + + contextMenuItemSelected: function(id) + { + WebInspector.contextMenuItemSelected(id); + }, + + contextMenuCleared: function() + { + WebInspector.contextMenuCleared(); + }, + + dispatchMessageAsync: function(messageObject) + { + WebInspector.dispatch(messageObject); + }, + + dispatchMessage: function(messageObject) + { + InspectorBackend.dispatch(messageObject); } } diff --git a/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js b/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js index b92824b99..7609405bb 100644 --- a/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js +++ b/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js @@ -106,6 +106,7 @@ WebInspector.JavaScriptSourceFrame.prototype = { _onFormattedChanged: function(event) { var content = /** @type {string} */ (event.data.content); + this._textEditor.setReadOnly(this._uiSourceCode.formatted()); this._innerSetContent(content); }, diff --git a/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js b/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js index 8a5cf157e..8f1b01872 100644 --- a/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js +++ b/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js @@ -314,7 +314,7 @@ WebInspector.MemoryBlockViewProperties._initialize = function() } addBlock("hsl( 0, 0%, 60%)", "ProcessPrivateMemory", "Total"); addBlock("hsl( 0, 0%, 80%)", "OwnersTypePlaceholder", "OwnersTypePlaceholder"); - addBlock("hsl( 0, 0%, 80%)", "Other", "Other"); + addBlock("hsl( 0, 0%, 60%)", "Other", "Other"); addBlock("hsl(220, 80%, 70%)", "Page", "Page structures"); addBlock("hsl(100, 60%, 50%)", "JSHeap", "JavaScript heap"); addBlock("hsl( 90, 40%, 80%)", "JSExternalResources", "JavaScript external resources"); diff --git a/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js b/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js index 10fa86c96..b094bfb8d 100644 --- a/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js +++ b/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js @@ -70,6 +70,8 @@ WebInspector.NetworkUISourceCodeProvider.prototype = { var script = /** @type {WebInspector.Script} */ (event.data); if (!script.sourceURL || script.isInlineScript()) return; + if (WebInspector.experimentsSettings.snippetsSupport.isEnabled() && script.isSnippet()) + return; var isDynamicAnonymousScript; // Only add uiSourceCodes for // - content scripts; diff --git a/Source/WebCore/inspector/front-end/RemoteObject.js b/Source/WebCore/inspector/front-end/RemoteObject.js index bd59d179b..be3c91a9b 100644 --- a/Source/WebCore/inspector/front-end/RemoteObject.js +++ b/Source/WebCore/inspector/front-end/RemoteObject.js @@ -324,6 +324,8 @@ WebInspector.RemoteObject.prototype = { release: function() { + if (!this._objectId) + return; RuntimeAgent.releaseObject(this._objectId); }, diff --git a/Source/WebCore/inspector/front-end/Script.js b/Source/WebCore/inspector/front-end/Script.js index 445c5d140..e79447752 100644 --- a/Source/WebCore/inspector/front-end/Script.js +++ b/Source/WebCore/inspector/front-end/Script.js @@ -50,6 +50,8 @@ WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endL this._locations = []; } +WebInspector.Script.snippetSourceURLPrefix = "snippets:///"; + WebInspector.Script.prototype = { /** * @return {string} @@ -170,6 +172,14 @@ WebInspector.Script.prototype = { }, /** + * @return {boolean} + */ + isSnippet: function() + { + return this.sourceURL && this.sourceURL.startsWith(WebInspector.Script.snippetSourceURLPrefix); + }, + + /** * @param {number} lineNumber * @param {number=} columnNumber * @return {WebInspector.UILocation} diff --git a/Source/WebCore/inspector/front-end/ScriptSnippetModel.js b/Source/WebCore/inspector/front-end/ScriptSnippetModel.js index bd1f45b8f..a197083cd 100644 --- a/Source/WebCore/inspector/front-end/ScriptSnippetModel.js +++ b/Source/WebCore/inspector/front-end/ScriptSnippetModel.js @@ -51,8 +51,6 @@ WebInspector.ScriptSnippetModel = function(workspace, networkWorkspaceProvider) this._loadSnippets(); } -WebInspector.ScriptSnippetModel.snippetSourceURLPrefix = "snippets:///"; - WebInspector.ScriptSnippetModel.prototype = { /** * @return {WebInspector.SnippetScriptMapping} @@ -302,6 +300,8 @@ WebInspector.ScriptSnippetModel.prototype = { _addScript: function(script) { var snippetId = this._snippetIdForSourceURL(script.sourceURL); + if (!snippetId) + return; var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId]; if (!uiSourceCode || this._evaluationSourceURL(uiSourceCode) !== script.sourceURL) { @@ -381,10 +381,9 @@ WebInspector.ScriptSnippetModel.prototype = { */ _evaluationSourceURL: function(uiSourceCode) { - var snippetPrefix = WebInspector.ScriptSnippetModel.snippetSourceURLPrefix; var evaluationSuffix = "_" + uiSourceCode._evaluationIndex; var snippetId = this._snippetIdForUISourceCode.get(uiSourceCode); - return snippetPrefix + snippetId + evaluationSuffix; + return WebInspector.Script.snippetSourceURLPrefix + snippetId + evaluationSuffix; }, /** @@ -393,7 +392,7 @@ WebInspector.ScriptSnippetModel.prototype = { */ _snippetIdForSourceURL: function(sourceURL) { - var snippetPrefix = WebInspector.ScriptSnippetModel.snippetSourceURLPrefix; + var snippetPrefix = WebInspector.Script.snippetSourceURLPrefix; if (!sourceURL.startsWith(snippetPrefix)) return null; var splittedURL = sourceURL.substring(snippetPrefix.length).split("_"); diff --git a/Source/WebCore/inspector/front-end/Settings.js b/Source/WebCore/inspector/front-end/Settings.js index cf3532dd4..1ae21083b 100644 --- a/Source/WebCore/inspector/front-end/Settings.js +++ b/Source/WebCore/inspector/front-end/Settings.js @@ -109,6 +109,7 @@ WebInspector.Settings = function() this.cssReloadEnabled = this.createSetting("cssReloadEnabled", false); this.cssReloadTimeout = this.createSetting("cssReloadTimeout", 1000); this.showCpuOnTimelineRuler = this.createSetting("showCpuOnTimelineRuler", false); + this.showMetricsRulers = this.createSetting("showMetricsRulers", false); // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused diff --git a/Source/WebCore/inspector/front-end/SettingsScreen.js b/Source/WebCore/inspector/front-end/SettingsScreen.js index c98361cf9..00a835574 100644 --- a/Source/WebCore/inspector/front-end/SettingsScreen.js +++ b/Source/WebCore/inspector/front-end/SettingsScreen.js @@ -267,6 +267,7 @@ WebInspector.GenericSettingsTab = function() p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles)); p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap)); p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show Shadow DOM"), WebInspector.settings.showShadowDOM)); + p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show rulers"), WebInspector.settings.showMetricsRulers)); p = this._appendSection(WebInspector.UIString("Rendering")); p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects)); diff --git a/Source/WebCore/inspector/front-end/TimelineFrameController.js b/Source/WebCore/inspector/front-end/TimelineFrameController.js index 06380966e..ea10594db 100644 --- a/Source/WebCore/inspector/front-end/TimelineFrameController.js +++ b/Source/WebCore/inspector/front-end/TimelineFrameController.js @@ -107,6 +107,35 @@ WebInspector.TimelineFrameController.prototype = { /** * @constructor + * @param {Array.<WebInspector.TimelineFrame>} frames + */ +WebInspector.FrameStatistics = function(frames) +{ + this.frameCount = frames.length; + this.minDuration = Infinity; + this.maxDuration = 0; + this.timeByCategory = {}; + this.startOffset = frames[0].startTimeOffset; + var lastFrame = frames[this.frameCount - 1]; + this.endOffset = lastFrame.startTimeOffset + lastFrame.duration; + + var totalDuration = 0; + var sumOfSquares = 0; + for (var i = 0; i < this.frameCount; ++i) { + var duration = frames[i].duration; + totalDuration += duration; + sumOfSquares += duration * duration; + this.minDuration = Math.min(this.minDuration, duration); + this.maxDuration = Math.max(this.maxDuration, duration); + WebInspector.TimelineModel.aggregateTimeByCategory(this.timeByCategory, frames[i].timeByCategory); + } + this.average = totalDuration / this.frameCount; + var variance = sumOfSquares / this.frameCount - this.average * this.average; + this.stddev = Math.sqrt(variance); +} + +/** + * @constructor */ WebInspector.TimelineFrame = function() { diff --git a/Source/WebCore/inspector/front-end/TimelineModel.js b/Source/WebCore/inspector/front-end/TimelineModel.js index 924d353a6..d729c5cec 100644 --- a/Source/WebCore/inspector/front-end/TimelineModel.js +++ b/Source/WebCore/inspector/front-end/TimelineModel.js @@ -129,6 +129,16 @@ WebInspector.TimelineModel.aggregateTimeForRecord = function(total, rawRecord) total[categoryName] = (total[categoryName] || 0) + ownTime; } +/** + * @param {Object} total + * @param {Object} addend + */ +WebInspector.TimelineModel.aggregateTimeByCategory = function(total, addend) +{ + for (var category in addend) + total[category] = (total[category] || 0) + addend[category]; +} + WebInspector.TimelineModel.prototype = { startRecord: function() { diff --git a/Source/WebCore/inspector/front-end/TimelinePanel.js b/Source/WebCore/inspector/front-end/TimelinePanel.js index d31c80a9b..3b50eaacc 100644 --- a/Source/WebCore/inspector/front-end/TimelinePanel.js +++ b/Source/WebCore/inspector/front-end/TimelinePanel.js @@ -206,7 +206,8 @@ WebInspector.TimelinePanel.prototype = { { return this._statusBarButtons.select("element").concat([ this._miscStatusBarItems, - this.recordsCounter + this.recordsCounter, + this.frameStatistics ]); }, @@ -254,7 +255,15 @@ WebInspector.TimelinePanel.prototype = { } this.recordsCounter = document.createElement("span"); - this.recordsCounter.className = "timeline-records-counter"; + this.recordsCounter.className = "timeline-records-stats"; + + this.frameStatistics = document.createElement("span"); + this.frameStatistics.className = "timeline-records-stats hidden"; + function getAnchor() + { + return this.frameStatistics; + } + this._frameStatisticsPopoverHelper = new WebInspector.PopoverHelper(this.frameStatistics, getAnchor.bind(this), this._showFrameStatistics.bind(this)); }, _createTimelineCategoryStatusBarCheckbox: function(category, onCheckboxClicked) @@ -392,7 +401,32 @@ WebInspector.TimelinePanel.prototype = { _updateRecordsCounter: function(recordsInWindowCount) { - this.recordsCounter.textContent = WebInspector.UIString("%d of %d captured records are visible", recordsInWindowCount, this._allRecordsCount); + this.recordsCounter.textContent = WebInspector.UIString("%d of %d records shown", recordsInWindowCount, this._allRecordsCount); + }, + + _updateFrameStatistics: function(frames) + { + if (frames.length) { + this._lastFrameStatistics = new WebInspector.FrameStatistics(frames); + var details = WebInspector.UIString("avg: %s, \u03c3: %s", + Number.secondsToString(this._lastFrameStatistics.average, true), Number.secondsToString(this._lastFrameStatistics.stddev, true)); + } else + this._lastFrameStatistics = null; + this.frameStatistics.textContent = WebInspector.UIString("%d of %d frames shown", frames.length, this._presentationModel.frames().length); + if (details) { + this.frameStatistics.appendChild(document.createTextNode(" (")); + this.frameStatistics.createChild("span", "timeline-frames-stats").textContent = details; + this.frameStatistics.appendChild(document.createTextNode(")")); + } + }, + + /** + * @param {Element} anchor + * @param {WebInspector.Popover} popover + */ + _showFrameStatistics: function(anchor, popover) + { + popover.show(WebInspector.TimelinePresentationModel.generatePopupContentForFrameStatistics(this._lastFrameStatistics), anchor); }, _updateEventDividers: function() @@ -414,14 +448,8 @@ WebInspector.TimelinePanel.prototype = { this._timelineGrid.addEventDividers(dividers); }, - _shouldShowFrames: function() + _updateFrameBars: function(frames) { - return this._frameMode && this._presentationModel.frames().length > 0 && this.calculator.boundarySpan() < 1.0; - }, - - _updateFrames: function() - { - var frames = this._presentationModel.frames(); var clientWidth = this._graphRowsElementWidth; if (this._frameContainer) this._frameContainer.removeChildren(); @@ -440,8 +468,6 @@ WebInspector.TimelinePanel.prototype = { var frame = frames[i]; var frameStart = this._calculator.computePosition(frame.startTime); var frameEnd = this._calculator.computePosition(frame.endTime); - if (frameEnd <= 0 || frameStart >= clientWidth) - continue; var frameStrip = document.createElement("div"); frameStrip.className = "timeline-frame-strip"; @@ -488,11 +514,15 @@ WebInspector.TimelinePanel.prototype = { if (frameMode) { this.element.addStyleClass("timeline-frame-overview"); + this.recordsCounter.addStyleClass("hidden"); + this.frameStatistics.removeStyleClass("hidden"); this._frameController = new WebInspector.TimelineFrameController(this._model, this._overviewPane, this._presentationModel); } else { this._frameController.dispose(); this._frameController = null; this.element.removeStyleClass("timeline-frame-overview"); + this.recordsCounter.removeStyleClass("hidden"); + this.frameStatistics.addStyleClass("hidden"); } } if (shouldShowMemory === this._memoryStatistics.visible()) @@ -707,14 +737,19 @@ WebInspector.TimelinePanel.prototype = { var recordsInWindowCount = this._refreshRecords(); this._updateRecordsCounter(recordsInWindowCount); - if(!this._boundariesAreValid) { + if (!this._boundariesAreValid) { this._updateEventDividers(); - if (this._shouldShowFrames()) { - this._timelineGrid.removeDividers(); - this._updateFrames(); - } else { + var frames = this._frameController && this._presentationModel.filteredFrames(this._overviewPane.windowStartTime(), this._overviewPane.windowEndTime()); + if (frames) { + this._updateFrameStatistics(frames); + const maxFramesForFrameBars = 30; + if (frames.length && frames.length < maxFramesForFrameBars) { + this._timelineGrid.removeDividers(); + this._updateFrameBars(frames); + } else + this._timelineGrid.updateDividers(this._calculator); + } else this._timelineGrid.updateDividers(this._calculator); - } if (this._mainThreadMonitoringEnabled) this._refreshMainThreadBars(); } diff --git a/Source/WebCore/inspector/front-end/TimelinePresentationModel.js b/Source/WebCore/inspector/front-end/TimelinePresentationModel.js index 744ee89f8..cce0c3ad3 100644 --- a/Source/WebCore/inspector/front-end/TimelinePresentationModel.js +++ b/Source/WebCore/inspector/front-end/TimelinePresentationModel.js @@ -257,7 +257,7 @@ WebInspector.TimelinePresentationModel.prototype = { reset: function() { this._linkifier.reset(); - this._rootRecord = new WebInspector.TimelinePresentationModel.Record(this, { type: WebInspector.TimelineModel.RecordType.Root }, null, null, false); + this._rootRecord = new WebInspector.TimelinePresentationModel.Record(this, { type: WebInspector.TimelineModel.RecordType.Root }, null, null, null, false); this._sendRequestRecords = {}; this._scheduledResourceRequests = {}; this._timerRecords = {}; @@ -296,14 +296,12 @@ WebInspector.TimelinePresentationModel.prototype = { { const recordTypes = WebInspector.TimelineModel.RecordType; var isHiddenRecord = record.type in WebInspector.TimelinePresentationModel._hiddenRecords; - var connectedToOldRecord = false; - if (record.type === recordTypes.Time) - parentRecord = this._rootRecord; - else if (!isHiddenRecord) { + var origin; + if (!isHiddenRecord) { var newParentRecord = this._findParentRecord(record); if (newParentRecord) { + origin = parentRecord; parentRecord = newParentRecord; - connectedToOldRecord = true; } } @@ -327,7 +325,7 @@ WebInspector.TimelinePresentationModel.prototype = { } } - var formattedRecord = new WebInspector.TimelinePresentationModel.Record(this, record, parentRecord, scriptDetails, isHiddenRecord); + var formattedRecord = new WebInspector.TimelinePresentationModel.Record(this, record, parentRecord, origin, scriptDetails, isHiddenRecord); if (isHiddenRecord) return formattedRecord; @@ -340,20 +338,20 @@ WebInspector.TimelinePresentationModel.prototype = { formattedRecord.calculateAggregatedStats(WebInspector.TimelinePresentationModel.categories()); - if (connectedToOldRecord) { - record = formattedRecord; - do { - var parent = record.parent; - parent._cpuTime += formattedRecord._cpuTime; - if (parent.lastChildEndTime < record.lastChildEndTime) - parent.lastChildEndTime = record.lastChildEndTime; - for (var category in formattedRecord.aggregatedStats) - parent.aggregatedStats[category] += formattedRecord.aggregatedStats[category]; - record = parent; - } while (record.parent); - } else { - if (parentRecord !== this._rootRecord) - parentRecord.selfTime -= formattedRecord.endTime - formattedRecord.startTime; + if (origin) { + var lastChildEndTime = formattedRecord.lastChildEndTime; + var aggregatedStats = formattedRecord.aggregatedStats; + for (var currentRecord = formattedRecord.parent; !currentRecord.isRoot(); currentRecord = currentRecord.parent) { + currentRecord._cpuTime += formattedRecord._cpuTime; + if (currentRecord.lastChildEndTime < lastChildEndTime) + currentRecord.lastChildEndTime = lastChildEndTime; + for (var category in aggregatedStats) + currentRecord.aggregatedStats[category] += aggregatedStats[category]; + } + } + origin = formattedRecord.origin(); + if (!origin.isRoot()) { + origin.selfTime -= formattedRecord.endTime - formattedRecord.startTime; } return formattedRecord; }, @@ -370,6 +368,9 @@ WebInspector.TimelinePresentationModel.prototype = { case recordTypes.ResourceReceivedData: return this._sendRequestRecords[record.data["requestId"]]; + case recordTypes.ResourceSendRequest: + return this._rootRecord; + case recordTypes.TimerFire: return this._timerRecords[record.data["timerId"]]; @@ -379,6 +380,9 @@ WebInspector.TimelinePresentationModel.prototype = { case recordTypes.FireAnimationFrame: return this._requestAnimationFrameRecords[record.data["id"]]; + case recordTypes.Time: + return this._rootRecord; + case recordTypes.TimeEnd: return this._timeRecords[record.data["message"]]; } @@ -433,6 +437,23 @@ WebInspector.TimelinePresentationModel.prototype = { return recordsInWindow; }, + filteredFrames: function(startTime, endTime) + { + function compareStartTime(value, object) + { + return value - object.startTime; + } + function compareEndTime(value, object) + { + return value - object.endTime; + } + var firstFrame = insertionIndexForObjectInListSortedByFunction(startTime, this._frames, compareStartTime); + var lastFrame = insertionIndexForObjectInListSortedByFunction(endTime, this._frames, compareEndTime); + while (lastFrame < this._frames.length && this._frames[lastFrame].endTime <= endTime) + ++lastFrame; + return this._frames.slice(firstFrame, lastFrame); + }, + isVisible: function(record) { for (var i = 0; i < this._filters.length; ++i) { @@ -480,10 +501,11 @@ WebInspector.TimelinePresentationModel.prototype = { * @param {WebInspector.TimelinePresentationModel} presentationModel * @param {Object} record * @param {WebInspector.TimelinePresentationModel.Record} parentRecord + * @param {WebInspector.TimelinePresentationModel.Record} origin * @param {Object|undefined} scriptDetails * @param {boolean} hidden */ -WebInspector.TimelinePresentationModel.Record = function(presentationModel, record, parentRecord, scriptDetails, hidden) +WebInspector.TimelinePresentationModel.Record = function(presentationModel, record, parentRecord, origin, scriptDetails, hidden) { this._linkifier = presentationModel._linkifier; this._aggregatedStats = []; @@ -493,6 +515,8 @@ WebInspector.TimelinePresentationModel.Record = function(presentationModel, reco this.parent = parentRecord; parentRecord.children.push(this); } + if (origin) + this._origin = origin; this._selfTime = this.endTime - this.startTime; this._lastChildEndTime = this.endTime; @@ -566,8 +590,12 @@ WebInspector.TimelinePresentationModel.Record = function(presentationModel, reco break; case recordTypes.TimeEnd: - var timeRecord = presentationModel._timeRecords[record.data["message"]]; + var message = record.data["message"]; + var timeRecord = presentationModel._timeRecords[message]; + delete presentationModel._timeRecords[message]; if (timeRecord) { + this.timeRecord = timeRecord; + timeRecord.timeEndRecord = this; var intervalDuration = this.startTime - timeRecord.startTime; this.intervalDuration = intervalDuration; timeRecord.intervalDuration = intervalDuration; @@ -632,6 +660,22 @@ WebInspector.TimelinePresentationModel.Record.prototype = { }, /** + * @return {boolean} + */ + isRoot: function() + { + return this.type === WebInspector.TimelineModel.RecordType.Root; + }, + + /** + * @return {WebInspector.TimelinePresentationModel.Record} + */ + origin: function() + { + return this._origin || this.parent; + }, + + /** * @return {Array.<WebInspector.TimelinePresentationModel.Record>} */ get children() @@ -834,6 +878,7 @@ WebInspector.TimelinePresentationModel.Record.prototype = { break; case recordTypes.Time: case recordTypes.TimeEnd: + contentHelper._appendTextRow(WebInspector.UIString("Message"), this.data["message"]); if (typeof this.intervalDuration === "number") contentHelper._appendTextRow(WebInspector.UIString("Interval Duration"), Number.secondsToString(this.intervalDuration, true)); break; @@ -917,6 +962,8 @@ WebInspector.TimelinePresentationModel.Record.prototype = { case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse: case WebInspector.TimelineModel.RecordType.ResourceFinish: return WebInspector.displayNameForURL(this.url); + case WebInspector.TimelineModel.RecordType.Time: + case WebInspector.TimelineModel.RecordType.TimeEnd: case WebInspector.TimelineModel.RecordType.TimeStamp: return this.data["message"]; default: @@ -1100,6 +1147,33 @@ WebInspector.TimelinePresentationModel.generatePopupContentForFrame = function(f } /** + * @param {WebInspector.FrameStatistics} statistics + */ +WebInspector.TimelinePresentationModel.generatePopupContentForFrameStatistics = function(statistics) +{ + /** + * @param {number} time + */ + function formatTimeAndFPS(time) + { + return WebInspector.UIString("%s (%.0f FPS)", Number.secondsToString(time, true), 1 / time); + } + + var contentHelper = new WebInspector.TimelinePresentationModel.PopupContentHelper(WebInspector.UIString("Selected Range")); + + contentHelper._appendTextRow(WebInspector.UIString("Selected range"), WebInspector.UIString("%s\u2013%s (%d frames)", + Number.secondsToString(statistics.startOffset, true), Number.secondsToString(statistics.endOffset, true), statistics.frameCount)); + contentHelper._appendTextRow(WebInspector.UIString("Minimum Time"), formatTimeAndFPS(statistics.minDuration)); + contentHelper._appendTextRow(WebInspector.UIString("Average Time"), formatTimeAndFPS(statistics.average)); + contentHelper._appendTextRow(WebInspector.UIString("Maximum Time"), formatTimeAndFPS(statistics.maxDuration)); + contentHelper._appendTextRow(WebInspector.UIString("Standard Deviation"), Number.secondsToString(statistics.stddev, true)); + contentHelper._appendElementRow(WebInspector.UIString("Time by category"), + WebInspector.TimelinePresentationModel._generateAggregatedInfo(statistics.timeByCategory)); + + return contentHelper._contentTable; +} + +/** * @param {CanvasRenderingContext2D} context * @param {number} width * @param {number} height diff --git a/Source/WebCore/inspector/front-end/UISourceCodeFrame.js b/Source/WebCore/inspector/front-end/UISourceCodeFrame.js index 43d762dbe..490aa03c3 100644 --- a/Source/WebCore/inspector/front-end/UISourceCodeFrame.js +++ b/Source/WebCore/inspector/front-end/UISourceCodeFrame.js @@ -83,6 +83,7 @@ WebInspector.UISourceCodeFrame.prototype = { _onFormattedChanged: function(event) { var content = /** @type {string} */ (event.data.content); + this._textEditor.setReadOnly(this._uiSourceCode.formatted()); this._innerSetContent(content); }, diff --git a/Source/WebCore/inspector/front-end/breadcrumbList.css b/Source/WebCore/inspector/front-end/breadcrumbList.css index 752f96906..6b0818b95 100644 --- a/Source/WebCore/inspector/front-end/breadcrumbList.css +++ b/Source/WebCore/inspector/front-end/breadcrumbList.css @@ -65,10 +65,6 @@ display: none; } -.crumbs .crumb.dimmed { - color: rgba(0, 0, 0, 0.45); -} - .crumbs .crumb.start { padding-left: 7px; } @@ -98,11 +94,6 @@ color: black; } -.crumbs .crumb.dimmed:hover { - -webkit-border-image: url(Images/segmentHover.png) 0 12 0 2; - color: rgba(0, 0, 0, 0.75); -} - .crumbs .crumb.end:hover { -webkit-border-image: url(Images/segmentHoverEnd.png) 0 2 0 2; } diff --git a/Source/WebCore/inspector/front-end/canvasProfiler.css b/Source/WebCore/inspector/front-end/canvasProfiler.css index cb4b4a530..06f83907c 100644 --- a/Source/WebCore/inspector/front-end/canvasProfiler.css +++ b/Source/WebCore/inspector/front-end/canvasProfiler.css @@ -39,13 +39,13 @@ .canvas-trace-log { position: absolute; - top: 10px; - left: 0; + top: 400px; + left: 5px; + right: 5px; bottom: 10px; font-size: 13px; overflow: auto; white-space: nowrap; - padding: 0 20px; } .canvas-trace-log div { @@ -53,15 +53,18 @@ } #canvas-replay-image-container { - position: absolute; - right: 0; - top: 0; - padding: 10px; + height: 400px; + text-align: center; + padding: 5px 5px 16px 5px; background-color: white; } #canvas-replay-image { - width: 400px; - height: 400px; + zoom: 100; + height: auto; + width: auto; + max-width: 100%; + max-height: 100%; + margin: auto; display: block; } diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js index d67fb0cb1..587cb6233 100644 --- a/Source/WebCore/inspector/front-end/inspector.js +++ b/Source/WebCore/inspector/front-end/inspector.js @@ -526,11 +526,6 @@ WebInspector.dispatch = function(message) { }, 0); } -WebInspector.dispatchMessageFromBackend = function(messageObject) -{ - WebInspector.dispatch(messageObject); -} - WebInspector.windowResize = function(event) { if (WebInspector.inspectorView) diff --git a/Source/WebCore/inspector/front-end/timelinePanel.css b/Source/WebCore/inspector/front-end/timelinePanel.css index 64a1adc7d..de7cabe52 100644 --- a/Source/WebCore/inspector/front-end/timelinePanel.css +++ b/Source/WebCore/inspector/front-end/timelinePanel.css @@ -429,17 +429,23 @@ background-color: rgb(66, 129, 235) !important; } -.timeline-records-counter, .storage-application-cache-status, .storage-application-cache-connectivity { +.timeline-records-stats, .storage-application-cache-status, .storage-application-cache-connectivity { font-size: 11px; text-shadow: white 0 1px 0; } -.timeline-records-counter { +.timeline-records-stats { float: right; margin-top: 5px; margin-right: 6px; } +.timeline-frames-stats { + pointer-events: auto; + text-decoration: underline; + cursor: pointer; +} + #resources-container-content { overflow: visible; min-height: 100%; |