diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-15 16:08:57 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-15 16:08:57 +0200 |
commit | 5466563f4b5b6b86523e3f89bb7f77e5b5270c78 (patch) | |
tree | 8caccf7cd03a15207cde3ba282c88bf132482a91 /Source/WebCore/inspector | |
parent | 33b26980cb24288b5a9f2590ccf32a949281bb79 (diff) | |
download | qtwebkit-5466563f4b5b6b86523e3f89bb7f77e5b5270c78.tar.gz |
Imported WebKit commit 0dc6cd75e1d4836eaffbb520be96fac4847cc9d2 (http://svn.webkit.org/repository/webkit/trunk@131300)
WebKit update which introduces the QtWebKitWidgets module that contains the WK1
widgets based API. (In fact it renames QtWebKit to QtWebKitWidgets while we're
working on completing the entire split as part of
https://bugs.webkit.org/show_bug.cgi?id=99314
Diffstat (limited to 'Source/WebCore/inspector')
234 files changed, 4354 insertions, 3021 deletions
diff --git a/Source/WebCore/inspector/CodeGeneratorInspector.py b/Source/WebCore/inspector/CodeGeneratorInspector.py index 6f4d1f701..81711ff54 100755 --- a/Source/WebCore/inspector/CodeGeneratorInspector.py +++ b/Source/WebCore/inspector/CodeGeneratorInspector.py @@ -56,7 +56,7 @@ TYPE_NAME_FIX_MAP = { } -TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor", +TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor", "Runtime.InternalPropertyDescriptor", "Debugger.FunctionDetails", "Debugger.CallFrame", "Canvas.TraceLog", # This should be a temporary hack. TimelineEvent should be created via generated C++ API. "Timeline.TimelineEvent"]) @@ -1319,7 +1319,7 @@ class TypeBindings: validator_writer.newline(" InspectorObject::iterator %s;\n" % it_name) validator_writer.newline(" %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"])) validator_writer.newline(" ASSERT(%s != object->end());\n" % it_name) - validator_writer.newline(" %s(%s->second.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) + validator_writer.newline(" %s(%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) validator_writer.newline(" }\n") if closed_field_set: @@ -1331,7 +1331,7 @@ class TypeBindings: validator_writer.newline(" InspectorObject::iterator %s;\n" % it_name) validator_writer.newline(" %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"])) validator_writer.newline(" if (%s != object->end()) {\n" % it_name) - validator_writer.newline(" %s(%s->second.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) + validator_writer.newline(" %s(%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) if closed_field_set: validator_writer.newline(" ++foundPropertiesCount;\n") validator_writer.newline(" }\n") @@ -2044,7 +2044,7 @@ $messageHandlers return; } - ((*this).*it->second)(callId, messageObject.get()); + ((*this).*it->value)(callId, messageObject.get()); } void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<InspectorObject> result, const char* commandName, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError) @@ -2133,7 +2133,7 @@ R InspectorBackendDispatcherImpl::getPropertyValueImpl(InspectorObject* object, return value; } - if (!as_method(valueIterator->second.get(), &value)) + if (!as_method(valueIterator->value.get(), &value)) protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be '%s'.", name.utf8().data(), type_name)); else if (valueFound) diff --git a/Source/WebCore/inspector/DOMPatchSupport.cpp b/Source/WebCore/inspector/DOMPatchSupport.cpp index c03dce471..8e6c1800d 100644 --- a/Source/WebCore/inspector/DOMPatchSupport.cpp +++ b/Source/WebCore/inspector/DOMPatchSupport.cpp @@ -237,24 +237,24 @@ DOMPatchSupport::diff(const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPt for (size_t i = 0; i < newList.size(); ++i) { DiffTable::iterator it = newTable.add(newList[i]->m_sha1, Vector<size_t>()).iterator; - it->second.append(i); + it->value.append(i); } for (size_t i = 0; i < oldList.size(); ++i) { DiffTable::iterator it = oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).iterator; - it->second.append(i); + it->value.append(i); } for (DiffTable::iterator newIt = newTable.begin(); newIt != newTable.end(); ++newIt) { - if (newIt->second.size() != 1) + if (newIt->value.size() != 1) continue; - DiffTable::iterator oldIt = oldTable.find(newIt->first); - if (oldIt == oldTable.end() || oldIt->second.size() != 1) + DiffTable::iterator oldIt = oldTable.find(newIt->key); + if (oldIt == oldTable.end() || oldIt->value.size() != 1) continue; - newMap[newIt->second[0]] = make_pair(newList[newIt->second[0]].get(), oldIt->second[0]); - oldMap[oldIt->second[0]] = make_pair(oldList[oldIt->second[0]].get(), newIt->second[0]); + newMap[newIt->value[0]] = make_pair(newList[newIt->value[0]].get(), oldIt->value[0]); + oldMap[oldIt->value[0]] = make_pair(oldList[oldIt->value[0]].get(), newIt->value[0]); } for (size_t i = 0; newList.size() > 0 && i < newList.size() - 1; ++i) { @@ -364,7 +364,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector // 2. Patch nodes marked for merge. for (HashMap<Digest*, Digest*>::iterator it = merges.begin(); it != merges.end(); ++it) { - if (!innerPatchNode(it->second, it->first, ec)) + if (!innerPatchNode(it->value, it->key, ec)) return false; } @@ -463,7 +463,7 @@ bool DOMPatchSupport::removeChildAndMoveToNew(Digest* oldDigest, ExceptionCode& // high that it will get merged back into the original DOM during the further patching. UnusedNodesMap::iterator it = m_unusedNodesMap.find(oldDigest->m_sha1); if (it != m_unusedNodesMap.end()) { - Digest* newDigest = it->second; + Digest* newDigest = it->value; Node* newNode = newDigest->m_node; if (!m_domEditor->replaceChild(newNode->parentNode(), oldNode, newNode, ec)) return false; diff --git a/Source/WebCore/inspector/InjectedScript.cpp b/Source/WebCore/inspector/InjectedScript.cpp index 6a44ca7b5..67dd39e90 100644 --- a/Source/WebCore/inspector/InjectedScript.cpp +++ b/Source/WebCore/inspector/InjectedScript.cpp @@ -45,6 +45,7 @@ using WebCore::TypeBuilder::Array; using WebCore::TypeBuilder::Debugger::CallFrame; using WebCore::TypeBuilder::Runtime::PropertyDescriptor; +using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor; using WebCore::TypeBuilder::Debugger::FunctionDetails; using WebCore::TypeBuilder::Runtime::RemoteObject; @@ -141,6 +142,22 @@ void InjectedScript::getProperties(ErrorString* errorString, const String& objec *properties = Array<PropertyDescriptor>::runtimeCast(result); } +void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, RefPtr<Array<InternalPropertyDescriptor> >* properties) +{ + ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties"); + function.appendArgument(objectId); + + RefPtr<InspectorValue> result; + makeCall(function, &result); + if (!result || result->type() != InspectorValue::TypeArray) { + *errorString = "Internal error"; + return; + } + RefPtr<Array<InternalPropertyDescriptor> > array = Array<InternalPropertyDescriptor>::runtimeCast(result); + if (array->length() > 0) + *properties = array; +} + Node* InjectedScript::nodeForObjectId(const String& objectId) { if (hasNoValue() || !canAccessInspectedWindow()) diff --git a/Source/WebCore/inspector/InjectedScript.h b/Source/WebCore/inspector/InjectedScript.h index 44274278d..8a6f33b16 100644 --- a/Source/WebCore/inspector/InjectedScript.h +++ b/Source/WebCore/inspector/InjectedScript.h @@ -79,6 +79,7 @@ public: void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<InspectorObject>* result); void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result); void getProperties(ErrorString*, const String& objectId, bool ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result); + void getInternalProperties(ErrorString*, const String& objectId, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >* result); Node* nodeForObjectId(const String& objectId); void releaseObject(const String& objectId); diff --git a/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js b/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js index 26afeeb54..3295fc4c9 100644 --- a/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js +++ b/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js @@ -215,10 +215,10 @@ StackTraceV8.prototype = { this._stackTrace = this._error.stack; Error.prepareStackTrace = oldPrepareStackTrace; delete this._error; // No longer needed, free memory. - } -} + }, -StackTraceV8.prototype.__proto__ = StackTrace.prototype; + __proto__: StackTrace.prototype +} /** * @constructor @@ -288,6 +288,9 @@ function Call(thisObject, functionName, args, result, stackTrace) this._args = Array.prototype.slice.call(args, 0); this._result = result; this._stackTrace = stackTrace || null; + + if (!this._functionName) + console.assert(this._args.length === 2 && typeof this._args[0] === "string"); } Call.prototype = { @@ -308,6 +311,14 @@ Call.prototype = { }, /** + * @return {boolean} + */ + isPropertySetter: function() + { + return !this._functionName; + }, + + /** * @return {Array} */ args: function() @@ -382,18 +393,24 @@ Call.prototype = { replay: function(replayableCall, cache) { var replayObject = ReplayableResource.replay(replayableCall.resource(), cache); - var replayFunction = replayObject[replayableCall.functionName()]; - console.assert(typeof replayFunction === "function", "Expected a function to replay"); var replayArgs = replayableCall.args().map(function(obj) { return ReplayableResource.replay(obj, cache); }); - var replayResult = replayFunction.apply(replayObject, replayArgs); - if (replayableCall.result() instanceof ReplayableResource) { - var resource = replayableCall.result().replay(cache); - if (!resource.wrappedObject()) - resource.setWrappedObject(replayResult); - } + var replayResult = undefined; + if (replayableCall.isPropertySetter()) + replayObject[replayArgs[0]] = replayArgs[1]; + else { + var replayFunction = replayObject[replayableCall.functionName()]; + console.assert(typeof replayFunction === "function", "Expected a function to replay"); + replayResult = replayFunction.apply(replayObject, replayArgs); + if (replayableCall.result() instanceof ReplayableResource) { + var resource = replayableCall.result().replay(cache); + if (!resource.wrappedObject()) + resource.setWrappedObject(replayResult); + } + } + this._thisObject = replayObject; this._functionName = replayableCall.functionName(); this._args = replayArgs; @@ -439,6 +456,14 @@ ReplayableCall.prototype = { }, /** + * @return {boolean} + */ + isPropertySetter: function() + { + return !this._functionName; + }, + + /** * @return {Array.<ReplayableResource|*>} */ args: function() @@ -544,7 +569,7 @@ Resource.prototype = { }, /** - * @param {Object} value + * @param {*} value */ setWrappedObject: function(value) { @@ -594,7 +619,7 @@ Resource.prototype = { */ toReplayable: function(cache) { - var result = cache.get(this._id); + var result = /** @type {ReplayableResource} */ cache.get(this._id); if (result) return result; var data = { @@ -621,11 +646,11 @@ Resource.prototype = { /** * @param {Object} data * @param {Cache} cache - * @return {Resource} + * @return {Resource|ReplayableResource} */ replay: function(data, cache) { - var resource = cache.get(data.id); + var resource = /** @type {ReplayableResource} */ cache.get(data.id); if (resource) return resource; this._id = data.id; @@ -658,11 +683,11 @@ Resource.prototype = { }, /** - * @param {!Object} object + * @param {*} object */ _bindObjectToResource: function(object) { - Object.defineProperty(object, "__resourceObject", { + Object.defineProperty(/** @type {!Object} */ (object), "__resourceObject", { value: this, writable: false, enumerable: false, @@ -699,12 +724,7 @@ Resource.prototype = { { return wrappedObject[property]; }, - set: function(value) - { - // FIXME: Log the setter calls. - console.error("FIXME: Setting an attribute %s was not logged.", property); - wrappedObject[property] = value; - }, + set: self._wrapPropertySetter(self, wrappedObject, property), enumerable: true }); } @@ -773,6 +793,30 @@ Resource.prototype = { }, /** + * @param {Resource} resource + * @param {Object} originalObject + * @param {string} propertyName + * @return {Function} + */ + _wrapPropertySetter: function(resource, originalObject, propertyName) + { + return function(value) + { + var manager = resource.manager(); + if (!manager || !manager.capturing()) { + originalObject[propertyName] = value; + return; + } + var args = [propertyName, value]; + manager.captureArguments(resource, args); + originalObject[propertyName] = value; + var stackTrace = StackTrace.create(1, arguments.callee); + var call = new Call(resource, "", args, undefined, stackTrace); + manager.captureCall(call); + }; + }, + + /** * @return {Object.<string, Function>} */ _customWrapFunctions: function() @@ -976,10 +1020,10 @@ WebGLBoundResource.prototype = { this._state.BINDING = target; this.pushCall(new Call(WebGLRenderingContextResource.forObject(this), bindMethodName, [target, this])); } - } -} + }, -WebGLBoundResource.prototype.__proto__ = Resource.prototype; + __proto__: Resource.prototype +} /** * @constructor @@ -1063,13 +1107,14 @@ WebGLTextureResource.prototype = { console.error("ASSERT_NOT_REACHED: Could not properly process a gl." + call.functionName() + " call while the DRAWING BUFFER is bound."); } this.pushCall(call); - } -} + }, -WebGLTextureResource.prototype.pushCall_texParameteri = WebGLTextureResource.prototype.pushCall_texParameterf; -WebGLTextureResource.prototype.pushCall_copyTexSubImage2D = WebGLTextureResource.prototype.pushCall_copyTexImage2D; + pushCall_texParameteri: WebGLTextureResource.prototype.pushCall_texParameterf, -WebGLTextureResource.prototype.__proto__ = WebGLBoundResource.prototype; + pushCall_copyTexSubImage2D: WebGLTextureResource.prototype.pushCall_copyTexImage2D, + + __proto__: WebGLBoundResource.prototype +} /** * @constructor @@ -1190,10 +1235,10 @@ WebGLProgramResource.prototype = { // FIXME: remove any older calls that no longer contribute to the resource state. // FIXME: handle multiple attachShader && detachShader. Resource.prototype.pushCall.call(this, call); - } -} + }, -WebGLProgramResource.prototype.__proto__ = Resource.prototype; + __proto__: Resource.prototype +} /** * @constructor @@ -1214,10 +1259,10 @@ WebGLShaderResource.prototype = { // FIXME: remove any older calls that no longer contribute to the resource state. // FIXME: handle multiple shaderSource calls. Resource.prototype.pushCall.call(this, call); - } -} + }, -WebGLShaderResource.prototype.__proto__ = Resource.prototype; + __proto__: Resource.prototype +} /** * @constructor @@ -1238,10 +1283,10 @@ WebGLBufferResource.prototype = { // FIXME: remove any older calls that no longer contribute to the resource state. // FIXME: Optimize memory for bufferSubData. WebGLBoundResource.prototype.pushCall.call(this, call); - } -} + }, -WebGLBufferResource.prototype.__proto__ = WebGLBoundResource.prototype; + __proto__: WebGLBoundResource.prototype +} /** * @constructor @@ -1261,10 +1306,10 @@ WebGLFramebufferResource.prototype = { { // FIXME: remove any older calls that no longer contribute to the resource state. WebGLBoundResource.prototype.pushCall.call(this, call); - } -} + }, -WebGLFramebufferResource.prototype.__proto__ = WebGLBoundResource.prototype; + __proto__: WebGLBoundResource.prototype +} /** * @constructor @@ -1284,10 +1329,10 @@ WebGLRenderbufferResource.prototype = { { // FIXME: remove any older calls that no longer contribute to the resource state. WebGLBoundResource.prototype.pushCall.call(this, call); - } -} + }, -WebGLRenderbufferResource.prototype.__proto__ = WebGLBoundResource.prototype; + __proto__: WebGLBoundResource.prototype +} /** * @constructor @@ -1755,10 +1800,10 @@ WebGLRenderingContextResource.prototype = { WebGLRenderingContextResource._wrapFunctions = wrapFunctions; } return wrapFunctions; - } -} + }, -WebGLRenderingContextResource.prototype.__proto__ = Resource.prototype; + __proto__: Resource.prototype +} //////////////////////////////////////////////////////////////////////////////// // 2D Canvas @@ -1976,10 +2021,10 @@ CanvasRenderingContext2DResource.prototype = { CanvasRenderingContext2DResource._wrapFunctions = wrapFunctions; } return wrapFunctions; - } -}; + }, -CanvasRenderingContext2DResource.prototype.__proto__ = Resource.prototype; + __proto__: Resource.prototype +} /** * @constructor @@ -2270,14 +2315,20 @@ InjectedScript.prototype = { var stackTrace = call.stackTrace(); var callFrame = stackTrace ? stackTrace.callFrame(0) || {} : {}; var traceLogItem = { - functionName: call.functionName(), - arguments: args, sourceURL: callFrame.sourceURL, lineNumber: callFrame.lineNumber, columnNumber: callFrame.columnNumber }; - if (call.result()) - traceLogItem.result = call.result() + ""; + if (call.functionName()) { + traceLogItem.functionName = call.functionName(); + traceLogItem.arguments = args; + } else { + traceLogItem.property = args[0]; + traceLogItem.value = args[1]; + } + var callResult = call.result(); + if (callResult !== undefined && callResult !== null) + traceLogItem.result = callResult + ""; result.calls.push(traceLogItem); } return result; diff --git a/Source/WebCore/inspector/InjectedScriptExterns.js b/Source/WebCore/inspector/InjectedScriptExterns.js index 317087a0d..436bdd03f 100644 --- a/Source/WebCore/inspector/InjectedScriptExterns.js +++ b/Source/WebCore/inspector/InjectedScriptExterns.js @@ -38,6 +38,7 @@ console.log = function(vararg) { } */ function InjectedScriptHost() { } InjectedScriptHost.prototype.storageId = function(object) { } +InjectedScriptHost.prototype.getInternalProperties = function(object) { } /** * @param {Function} func */ diff --git a/Source/WebCore/inspector/InjectedScriptHost.idl b/Source/WebCore/inspector/InjectedScriptHost.idl index d144dd09a..883b5ffd1 100644 --- a/Source/WebCore/inspector/InjectedScriptHost.idl +++ b/Source/WebCore/inspector/InjectedScriptHost.idl @@ -30,24 +30,22 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -module core { - interface [ - Conditional=INSPECTOR - ] InjectedScriptHost { - void clearConsoleMessages(); +[ + Conditional=INSPECTOR +] interface InjectedScriptHost { + void clearConsoleMessages(); - void copyText(in DOMString text); - [Custom] void inspect(in DOMObject objectId, in DOMObject hints); - [Custom] DOMObject inspectedObject(in int num); - [Custom] DOMObject internalConstructorName(in DOMObject object); - [Custom] boolean isHTMLAllCollection(in DOMObject object); - [Custom] DOMString type(in DOMObject object); - [Custom] DOMObject functionDetails(in DOMObject object); - [Custom] Array getEventListeners(in Node node); - - [Custom] DOMString databaseId(in DOMObject database); - [Custom] DOMString storageId(in DOMObject storage); - [Custom] DOMObject evaluate(in DOMString text); - }; -} + void copyText(in DOMString text); + [Custom] void inspect(in DOMObject objectId, in DOMObject hints); + [Custom] DOMObject inspectedObject(in int num); + [Custom] DOMObject internalConstructorName(in DOMObject object); + [Custom] boolean isHTMLAllCollection(in DOMObject object); + [Custom] DOMString type(in DOMObject object); + [Custom] DOMObject functionDetails(in DOMObject object); + [Custom] Array getInternalProperties(in DOMObject object); + [Custom] Array getEventListeners(in Node node); + [Custom] DOMString databaseId(in DOMObject database); + [Custom] DOMString storageId(in DOMObject storage); + [Custom] DOMObject evaluate(in DOMString text); +}; diff --git a/Source/WebCore/inspector/InjectedScriptManager.cpp b/Source/WebCore/inspector/InjectedScriptManager.cpp index 52ec7490a..1d5e31757 100644 --- a/Source/WebCore/inspector/InjectedScriptManager.cpp +++ b/Source/WebCore/inspector/InjectedScriptManager.cpp @@ -82,10 +82,10 @@ InjectedScript InjectedScriptManager::injectedScriptForId(int id) { IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(id); if (it != m_idToInjectedScript.end()) - return it->second; + return it->value; for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scriptStateToId.end(); ++it) { - if (it->second == id) - return injectedScriptFor(it->first); + if (it->value == id) + return injectedScriptFor(it->key); } return InjectedScript(); } @@ -94,7 +94,7 @@ int InjectedScriptManager::injectedScriptIdFor(ScriptState* scriptState) { ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); if (it != m_scriptStateToId.end()) - return it->second; + return it->value; int id = m_nextInjectedScriptId++; m_scriptStateToId.set(scriptState, id); return id; @@ -126,11 +126,11 @@ void InjectedScriptManager::discardInjectedScriptsFor(DOMWindow* window) Vector<long> idsToRemove; IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end(); for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != end; ++it) { - ScriptState* scriptState = it->second.scriptState(); + ScriptState* scriptState = it->value.scriptState(); if (window != domWindowFromScriptState(scriptState)) continue; m_scriptStateToId.remove(scriptState); - idsToRemove.append(it->first); + idsToRemove.append(it->key); } for (size_t i = 0; i < idsToRemove.size(); i++) @@ -139,7 +139,7 @@ void InjectedScriptManager::discardInjectedScriptsFor(DOMWindow* window) // Now remove script states that have id but no injected script. Vector<ScriptState*> scriptStatesToRemove; for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scriptStateToId.end(); ++it) { - ScriptState* scriptState = it->first; + ScriptState* scriptState = it->key; if (window == domWindowFromScriptState(scriptState)) scriptStatesToRemove.append(scriptState); } @@ -155,7 +155,7 @@ bool InjectedScriptManager::canAccessInspectedWorkerContext(ScriptState*) void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) { for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it) - it->second.releaseObjectGroup(objectGroup); + it->value.releaseObjectGroup(objectGroup); } String InjectedScriptManager::injectedScriptSource() @@ -173,9 +173,9 @@ InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedSc { ScriptStateToId::iterator it = m_scriptStateToId.find(inspectedScriptState); if (it != m_scriptStateToId.end()) { - IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->second); + IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->value); if (it1 != m_idToInjectedScript.end()) - return it1->second; + return it1->value; } if (!m_inspectedStateAccessCheck(inspectedScriptState)) diff --git a/Source/WebCore/inspector/InjectedScriptSource.js b/Source/WebCore/inspector/InjectedScriptSource.js index 1688015a4..ecf66af08 100644 --- a/Source/WebCore/inspector/InjectedScriptSource.js +++ b/Source/WebCore/inspector/InjectedScriptSource.js @@ -34,6 +34,42 @@ (function (InjectedScriptHost, inspectedWindow, injectedScriptId) { /** + * @param {Arguments} array + * @param {number=} index + * @return {Array.<*>} + */ +function slice(array, index) +{ + var result = []; + for (var i = index || 0; i < array.length; ++i) + result.push(array[i]); + return result; +} + +/** + * Please use this bind, not the one from Function.prototype + * @param {function()} func + * @param {Object} thisObject + * @param {...number} var_args + */ +function bind(func, thisObject, var_args) +{ + var args = slice(arguments, 2); + + /** + * @param {...number} var_args + */ + function bound(var_args) + { + return func.apply(thisObject, args.concat(slice(arguments))); + } + bound.toString = function() { + return "bound: " + func; + }; + return bound; +} + +/** * @constructor */ var InjectedScript = function() @@ -170,7 +206,7 @@ InjectedScript.prototype = { /** * @param {string} objectId - * @return {*} + * @return {Object} */ _parseObjectId: function(objectId) { @@ -234,7 +270,32 @@ InjectedScript.prototype = { descriptor.configurable = false; if (!("enumerable" in descriptor)) descriptor.enumerable = false; - + } + return descriptors; + }, + + /** + * @param {string} objectId + * @return {Array.<Object>|boolean} + */ + getInternalProperties: function(objectId, ownProperties) + { + var parsedObjectId = this._parseObjectId(objectId); + var object = this._objectForId(parsedObjectId); + var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; + if (!this._isDefined(object)) + return false; + var descriptors = []; + var internalProperties = InjectedScriptHost.getInternalProperties(object); + if (internalProperties) { + for (var i = 0; i < internalProperties.length; i++) { + var property = internalProperties[i]; + var descriptor = { + name: property.name, + value: this._wrapObject(property.value, objectGroupName) + }; + descriptors.push(descriptor); + } } return descriptors; }, @@ -359,7 +420,7 @@ InjectedScript.prototype = { objectId = args[i].objectId; if (objectId) { var parsedArgId = this._parseObjectId(objectId); - if (!parsedArgId || parsedArgId.injectedScriptId !== injectedScriptId) + if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScriptId) return "Arguments should belong to the same JavaScript world as the target object."; var resolvedArg = this._objectForId(parsedArgId); @@ -545,7 +606,7 @@ InjectedScript.prototype = { var object = this.findObjectById(objectId); if (!object || this._subtype(object) !== "node") return null; - return object; + return /** @type {Node} */ object; }, /** @@ -581,7 +642,7 @@ InjectedScript.prototype = { */ _isDefined: function(object) { - return object || this._isHTMLAllCollection(object); + return !!object || this._isHTMLAllCollection(object); }, /** @@ -636,6 +697,8 @@ InjectedScript.prototype = { if (this.isPrimitiveValue(obj)) return null; + obj = /** @type {Object} */ obj; + // Type is object, get subtype. var subtype = this._subtype(obj); @@ -721,6 +784,8 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, return; } + object = /** @type {Object} */ object; + this.objectId = injectedScript._bind(object, objectGroupName); var subtype = injectedScript._subtype(object); if (subtype) @@ -729,12 +794,12 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, this.description = injectedScript._describe(object); if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllCollection(object))) - this._generatePreview(/** @type {!Object} */ object); + this._generatePreview(object); } InjectedScript.RemoteObject.prototype = { /** - * @param {!Object} object + * @param {Object} object */ _generatePreview: function(object) { @@ -742,7 +807,7 @@ InjectedScript.RemoteObject.prototype = { var isArray = this.subtype === "array"; var elementsToDump = isArray ? 100 : 5; - var propertyNames = Object.getOwnPropertyNames(object); + var propertyNames = Object.getOwnPropertyNames(/** @type {!Object} */(object)); preview.lossless = true; preview.overflow = false; var properties = preview.properties = []; @@ -758,7 +823,7 @@ InjectedScript.RemoteObject.prototype = { if (isArray && name === "length") continue; - var descriptor = Object.getOwnPropertyDescriptor(object, name); + var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */(object), name); if (!("value" in descriptor) || !descriptor.enumerable) { preview.lossless = false; continue; @@ -791,7 +856,7 @@ InjectedScript.RemoteObject.prototype = { continue; var subtype = injectedScript._subtype(value); - var property = { name: name, type: type, value: this._abbreviateString(injectedScript._describe(value), maxLength, subtype === "regexp") }; + var property = { name: name, type: type, value: this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp") }; if (subtype) property.subtype = subtype; properties.push(property); @@ -906,7 +971,7 @@ function CommandLineAPI(commandLineAPIImpl, callFrame) if (member in inspectedWindow || inScopeVariables(member)) continue; - this[member] = commandLineAPIImpl[member].bind(commandLineAPIImpl); + this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl); } for (var i = 0; i < 5; ++i) { @@ -914,7 +979,7 @@ function CommandLineAPI(commandLineAPIImpl, callFrame) if (member in inspectedWindow || inScopeVariables(member)) continue; - this.__defineGetter__("$" + i, commandLineAPIImpl._inspectedObject.bind(commandLineAPIImpl, i)); + this.__defineGetter__("$" + i, bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i)); } this.$_ = injectedScript._lastResult; @@ -971,7 +1036,7 @@ CommandLineAPIImpl.prototype = { }, /** - * @param {Node} node + * @param {Node|undefined} node * @return {boolean} */ _canQuerySelectorOnNode: function(node) diff --git a/Source/WebCore/inspector/Inspector.json b/Source/WebCore/inspector/Inspector.json index 21d927c21..24ebe8828 100644 --- a/Source/WebCore/inspector/Inspector.json +++ b/Source/WebCore/inspector/Inspector.json @@ -404,6 +404,14 @@ ], "description": "Toggles mouse event-based touch event emulation.", "hidden": true + }, + { + "name": "setCompositingBordersVisible", + "description": "Controls the visibility of compositing borders.", + "parameters": [ + { "name": "visible", "type": "boolean", "description": "True for showing compositing borders." } + ], + "hidden": true } ], "events": [ @@ -498,6 +506,15 @@ ] }, { + "id": "InternalPropertyDescriptor", + "type": "object", + "description": "Object internal property descriptor. This property isn't normally visible in JavaScript code.", + "properties": [ + { "name": "name", "type": "string", "description": "Conventional property name." }, + { "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." } + ] + }, + { "id": "CallArgument", "type": "object", "description": "Represents function call argument. Either remote object id <code>objectId</code> or primitive <code>value</code> or neither of (for undefined) them should be specified.", @@ -565,7 +582,8 @@ { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." } ], "returns": [ - { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor"}, "description": "Object properties." } + { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor"}, "description": "Object properties." }, + { "name": "internalProperties", "optional": true, "type": "array", "items": { "$ref": "InternalPropertyDescriptor"}, "description": "Internal object properties." } ], "description": "Returns properties of a given object. Object group of the result is inherited from the target object." }, @@ -589,14 +607,15 @@ "description": "Tells inspected instance(worker or page) that it can run in case it was started paused." }, { - "name": "setReportExecutionContextCreation", - "parameters": [ - { "name": "enabled", "type": "boolean", "description": "Reporting enabled state." } - ], + "name": "enable", "hidden": true, - "description": "Enables reporting about creation of execution contexts by means of <code>executionContextCreated</code> event. When the reporting gets enabled the event will be sent immediately for each existing execution context." + "description": "Enables reporting of execution contexts creation by means of <code>executionContextCreated</code> event. When the reporting gets enabled the event will be sent immediately for each existing execution context." + }, + { + "name": "disable", + "hidden": true, + "description": "Disables reporting of execution contexts creation." } - ], "events": [ { @@ -1149,7 +1168,8 @@ "description": "Database with an array of object stores.", "properties": [ { "name": "name", "type": "string", "description": "Database name." }, - { "name": "version", "type": "string", "description": "Database version." }, + { "name": "version", "type": "string", "description": "Deprecated string database version." }, + { "name": "intVersion", "type": "integer", "description": "Integer database version." }, { "name": "objectStores", "type": "array", "items": { "$ref": "ObjectStore" }, "description": "Object stores in this database." } ] }, @@ -2760,7 +2780,8 @@ { "name": "endLine", "type": "integer", "description": "Last line of the script." }, { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, { "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." }, - { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." } + { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL." } ], "description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger." }, @@ -3100,8 +3121,10 @@ "id": "Call", "type": "object", "properties": [ - { "name": "functionName", "type": "string" }, - { "name": "arguments", "type": "array", "items": { "type": "string" } }, + { "name": "functionName", "type": "string", "optional": true }, + { "name": "arguments", "type": "array", "items": { "type": "string" }, "optional": true }, + { "name": "property", "type": "string", "optional": true }, + { "name": "value", "type": "string", "optional": true }, { "name": "result", "type": "string", "optional": true }, { "name": "sourceURL", "type": "string", "optional": true }, { "name": "lineNumber", "type": "integer", "optional": true }, diff --git a/Source/WebCore/inspector/InspectorBaseAgent.cpp b/Source/WebCore/inspector/InspectorBaseAgent.cpp index f3fd92b3a..ffa9555d4 100644 --- a/Source/WebCore/inspector/InspectorBaseAgent.cpp +++ b/Source/WebCore/inspector/InspectorBaseAgent.cpp @@ -34,10 +34,14 @@ #include "InspectorBaseAgent.h" +#include "WebCoreMemoryInstrumentation.h" + namespace WebCore { -InspectorBaseAgentInterface::InspectorBaseAgentInterface(const String& name) - : m_name(name) +InspectorBaseAgentInterface::InspectorBaseAgentInterface(const String& name, InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState) + : m_instrumentingAgents(instrumentingAgents) + , m_state(inspectorState) + , m_name(name) { } @@ -45,6 +49,14 @@ InspectorBaseAgentInterface::~InspectorBaseAgentInterface() { } +void InspectorBaseAgentInterface::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector); + info.addMember(m_name); + info.addWeakPointer(m_instrumentingAgents); + info.addWeakPointer(m_state); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorBaseAgent.h b/Source/WebCore/inspector/InspectorBaseAgent.h index 800f96736..849763fa5 100644 --- a/Source/WebCore/inspector/InspectorBaseAgent.h +++ b/Source/WebCore/inspector/InspectorBaseAgent.h @@ -32,6 +32,7 @@ #define InspectorBaseAgent_h #include "InspectorBackendDispatcher.h" +#include <wtf/Forward.h> #include <wtf/Vector.h> #include <wtf/text/WTFString.h> @@ -43,7 +44,7 @@ class InstrumentingAgents; class InspectorBaseAgentInterface { public: - explicit InspectorBaseAgentInterface(const String& name); + InspectorBaseAgentInterface(const String&, InstrumentingAgents*, InspectorState*); virtual ~InspectorBaseAgentInterface(); virtual void setFrontend(InspectorFrontend*) { } @@ -53,6 +54,13 @@ public: virtual void discardAgent() { } String name() { return m_name; } + + virtual void reportMemoryUsage(MemoryObjectInfo*) const; + +protected: + InstrumentingAgents* m_instrumentingAgents; + InspectorState* m_state; + private: String m_name; }; @@ -69,14 +77,9 @@ public: protected: InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState) - : InspectorBaseAgentInterface(name) - , m_instrumentingAgents(instrumentingAgents) - , m_state(inspectorState) + : InspectorBaseAgentInterface(name, instrumentingAgents, inspectorState) { } - - InstrumentingAgents* m_instrumentingAgents; - InspectorState* m_state; }; } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorCSSAgent.cpp b/Source/WebCore/inspector/InspectorCSSAgent.cpp index bbe88d2c0..5cd9c60c9 100644 --- a/Source/WebCore/inspector/InspectorCSSAgent.cpp +++ b/Source/WebCore/inspector/InspectorCSSAgent.cpp @@ -188,10 +188,10 @@ inline void SelectorProfile::commitSelector(bool matched) RuleMatchingStatsMap::AddResult result = m_ruleMatchingStats.add(makeKey(), RuleMatchingStats(m_currentMatchData, matchTimeMs, 1, matched ? 1 : 0)); if (!result.isNewEntry) { - result.iterator->second.totalTime += matchTimeMs; - result.iterator->second.hits += 1; + result.iterator->value.totalTime += matchTimeMs; + result.iterator->value.hits += 1; if (matched) - result.iterator->second.matches += 1; + result.iterator->value.matches += 1; } } @@ -204,7 +204,7 @@ inline void SelectorProfile::commitSelectorTime() if (it == m_ruleMatchingStats.end()) return; - it->second.totalTime += processingTimeMs; + it->value.totalTime += processingTimeMs; } PassRefPtr<TypeBuilder::CSS::SelectorProfile> SelectorProfile::toInspectorObject() const @@ -212,12 +212,12 @@ PassRefPtr<TypeBuilder::CSS::SelectorProfile> SelectorProfile::toInspectorObject RefPtr<TypeBuilder::Array<TypeBuilder::CSS::SelectorProfileEntry> > selectorProfileData = TypeBuilder::Array<TypeBuilder::CSS::SelectorProfileEntry>::create(); for (RuleMatchingStatsMap::const_iterator it = m_ruleMatchingStats.begin(); it != m_ruleMatchingStats.end(); ++it) { RefPtr<TypeBuilder::CSS::SelectorProfileEntry> entry = TypeBuilder::CSS::SelectorProfileEntry::create() - .setSelector(it->second.selector) - .setUrl(it->second.url) - .setLineNumber(it->second.lineNumber) - .setTime(it->second.totalTime) - .setHitCount(it->second.hits) - .setMatchCount(it->second.matches); + .setSelector(it->value.selector) + .setUrl(it->value.url) + .setLineNumber(it->value.lineNumber) + .setTime(it->value.totalTime) + .setHitCount(it->value.hits) + .setMatchCount(it->value.matches); selectorProfileData->addItem(entry.release()); } @@ -272,7 +272,7 @@ void UpdateRegionLayoutTask::onTimer(Timer<UpdateRegionLayoutTask>*) Vector<std::pair<WebKitNamedFlow*, int> > namedFlows; for (HashMap<WebKitNamedFlow*, int>::iterator it = m_namedFlows.begin(), end = m_namedFlows.end(); it != end; ++it) - namedFlows.append(std::make_pair(it->first, it->second)); + namedFlows.append(std::make_pair(it->key, it->value)); for (unsigned i = 0, size = namedFlows.size(); i < size; ++i) { WebKitNamedFlow* namedFlow = namedFlows.at(i).first; @@ -663,7 +663,7 @@ bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy if (it == m_nodeIdToForcedPseudoState.end()) return false; - unsigned forcedPseudoState = it->second; + unsigned forcedPseudoState = it->value; switch (pseudoType) { case CSSSelector::PseudoActive: return forcedPseudoState & PseudoActive; @@ -904,7 +904,7 @@ void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, c unsigned forcedPseudoState = computePseudoClassMask(forcedPseudoClasses.get()); NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.find(nodeId); - unsigned currentForcedPseudoState = it == m_nodeIdToForcedPseudoState.end() ? 0 : it->second; + unsigned currentForcedPseudoState = it == m_nodeIdToForcedPseudoState.end() ? 0 : it->value; bool needStyleRecalc = forcedPseudoState != currentForcedPseudoState; if (!needStyleRecalc) return; @@ -995,7 +995,7 @@ InspectorStyleSheetForInlineStyle* InspectorCSSAgent::asInspectorStyleSheet(Elem return inspectorStyleSheet.get(); } - return it->second.get(); + return it->value.get(); } Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) @@ -1098,7 +1098,7 @@ InspectorStyleSheet* InspectorCSSAgent::assertStyleSheetForId(ErrorString* error *errorString = "No style sheet with given id found"; return 0; } - return it->second.get(); + return it->value.get(); } TypeBuilder::CSS::StyleSheetOrigin::Enum InspectorCSSAgent::detectOrigin(CSSStyleSheet* pageStyleSheet, Document* ownerDocument) @@ -1266,7 +1266,7 @@ void InspectorCSSAgent::didRemoveDOMNode(Node* node) if (it == m_nodeToInspectorStyleSheet.end()) return; - m_idToInspectorStyleSheet.remove(it->second->id()); + m_idToInspectorStyleSheet.remove(it->value->id()); m_nodeToInspectorStyleSheet.remove(node); } @@ -1279,7 +1279,7 @@ void InspectorCSSAgent::didModifyDOMAttr(Element* element) if (it == m_nodeToInspectorStyleSheet.end()) return; - it->second->didModifyElementAttribute(); + it->value->didModifyElementAttribute(); } void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet) @@ -1292,7 +1292,7 @@ void InspectorCSSAgent::resetPseudoStates() { HashSet<Document*> documentsToChange; for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.begin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { - Element* element = toElement(m_domAgent->nodeForId(it->first)); + Element* element = toElement(m_domAgent->nodeForId(it->key)); if (element && element->ownerDocument()) documentsToChange.add(element->ownerDocument()); } diff --git a/Source/WebCore/inspector/InspectorClient.h b/Source/WebCore/inspector/InspectorClient.h index e8d2659d5..2d4fb3f26 100644 --- a/Source/WebCore/inspector/InspectorClient.h +++ b/Source/WebCore/inspector/InspectorClient.h @@ -29,6 +29,7 @@ #include "InspectorStateClient.h" #include <wtf/Forward.h> +#include <wtf/HashSet.h> namespace WebCore { @@ -71,6 +72,8 @@ public: virtual bool supportsFrameInstrumentation() { return false; } + virtual void getAllocatedObjects(HashSet<const void*>&) { } + static bool doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message); }; diff --git a/Source/WebCore/inspector/InspectorConsoleAgent.cpp b/Source/WebCore/inspector/InspectorConsoleAgent.cpp index aceb2da4a..9e622c04c 100644 --- a/Source/WebCore/inspector/InspectorConsoleAgent.cpp +++ b/Source/WebCore/inspector/InspectorConsoleAgent.cpp @@ -42,6 +42,7 @@ #include "ScriptArguments.h" #include "ScriptCallFrame.h" #include "ScriptCallStack.h" +#include "ScriptController.h" #include "ScriptObject.h" #include "ScriptProfiler.h" #include <wtf/CurrentTime.h> @@ -60,12 +61,15 @@ static const char monitoringXHR[] = "monitoringXHR"; static const char consoleMessagesEnabled[] = "consoleMessagesEnabled"; } +int InspectorConsoleAgent::s_enabledAgentCount = 0; + InspectorConsoleAgent::InspectorConsoleAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager) : InspectorBaseAgent<InspectorConsoleAgent>("Console", instrumentingAgents, state) , m_injectedScriptManager(injectedScriptManager) , m_frontend(0) , m_previousMessage(0) , m_expiredConsoleMessageCount(0) + , m_enabled(false) { m_instrumentingAgents->setInspectorConsoleAgent(this); } @@ -80,6 +84,13 @@ InspectorConsoleAgent::~InspectorConsoleAgent() void InspectorConsoleAgent::enable(ErrorString*) { + if (m_enabled) + return; + m_enabled = true; + if (!s_enabledAgentCount) + ScriptController::setCaptureCallStackForUncaughtExceptions(true); + ++s_enabledAgentCount; + m_state->setBoolean(ConsoleAgentState::consoleMessagesEnabled, true); if (m_expiredConsoleMessageCount) { @@ -94,6 +105,11 @@ void InspectorConsoleAgent::enable(ErrorString*) void InspectorConsoleAgent::disable(ErrorString*) { + if (!m_enabled) + return; + m_enabled = false; + if (!(--s_enabledAgentCount)) + ScriptController::setCaptureCallStackForUncaughtExceptions(false); m_state->setBoolean(ConsoleAgentState::consoleMessagesEnabled, false); } @@ -103,7 +119,7 @@ void InspectorConsoleAgent::clearMessages(ErrorString*) m_expiredConsoleMessageCount = 0; m_previousMessage = 0; m_injectedScriptManager->releaseObjectGroup("console"); - if (m_frontend && m_state->getBoolean(ConsoleAgentState::consoleMessagesEnabled)) + if (m_frontend && m_enabled) m_frontend->messagesCleared(); } @@ -132,7 +148,8 @@ void InspectorConsoleAgent::setFrontend(InspectorFrontend* frontend) void InspectorConsoleAgent::clearFrontend() { m_frontend = 0; - m_state->setBoolean(ConsoleAgentState::consoleMessagesEnabled, false); + String errorString; + disable(&errorString); } void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) @@ -178,7 +195,7 @@ void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCal if (it == m_times.end()) return; - double startTime = it->second; + double startTime = it->value; m_times.remove(it); double elapsed = monotonicallyIncreasingTime() - startTime; @@ -201,7 +218,7 @@ void InspectorConsoleAgent::count(PassRefPtr<ScriptArguments> arguments, PassRef if (it == m_counts.end()) count = 1; else { - count = it->second + 1; + count = it->value + 1; m_counts.remove(it); } @@ -279,12 +296,12 @@ void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console if (m_previousMessage && !isGroupMessage(m_previousMessage->type()) && m_previousMessage->isEqual(consoleMessage.get())) { m_previousMessage->incrementCount(); - if (m_frontend && m_state->getBoolean(ConsoleAgentState::consoleMessagesEnabled)) + if (m_frontend && m_enabled) m_previousMessage->updateRepeatCountInConsole(m_frontend); } else { m_previousMessage = consoleMessage.get(); m_consoleMessages.append(consoleMessage); - if (m_frontend && m_state->getBoolean(ConsoleAgentState::consoleMessagesEnabled)) + if (m_frontend && m_enabled) m_previousMessage->addToFrontend(m_frontend, m_injectedScriptManager, true); } diff --git a/Source/WebCore/inspector/InspectorConsoleAgent.h b/Source/WebCore/inspector/InspectorConsoleAgent.h index 52be11818..7f4339313 100644 --- a/Source/WebCore/inspector/InspectorConsoleAgent.h +++ b/Source/WebCore/inspector/InspectorConsoleAgent.h @@ -61,6 +61,7 @@ public: virtual void enable(ErrorString*); virtual void disable(ErrorString*); virtual void clearMessages(ErrorString*); + bool enabled() { return m_enabled; } void reset(); virtual void setFrontend(InspectorFrontend*); @@ -100,6 +101,9 @@ protected: int m_expiredConsoleMessageCount; HashMap<String, unsigned> m_counts; HashMap<String, double> m_times; + bool m_enabled; +private: + static int s_enabledAgentCount; }; } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp index 9bd43311f..8bad7cc0c 100644 --- a/Source/WebCore/inspector/InspectorController.cpp +++ b/Source/WebCore/inspector/InspectorController.cpp @@ -71,6 +71,8 @@ #include "Page.h" #include "ScriptObject.h" #include "Settings.h" +#include "WebCoreMemoryInstrumentation.h" +#include <wtf/MemoryInstrumentationVector.h> #include <wtf/UnusedParam.h> namespace WebCore { @@ -114,7 +116,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC OwnPtr<InspectorDOMStorageAgent> domStorageAgentPtr(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), m_state.get())); InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get(); m_agents.append(domStorageAgentPtr.release()); - m_agents.append(InspectorMemoryAgent::create(m_instrumentingAgents.get(), m_state.get(), m_page, domStorageAgent)); + m_agents.append(InspectorMemoryAgent::create(m_instrumentingAgents.get(), inspectorClient, m_state.get(), m_page)); m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), InspectorTimelineAgent::PageInspector, inspectorClient)); m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent)); @@ -223,8 +225,6 @@ void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan for (Agents::iterator it = m_agents.begin(); it != m_agents.end(); ++it) (*it)->setFrontend(frontend); - if (!InspectorInstrumentation::hasFrontends()) - ScriptController::setCaptureCallStackForUncaughtExceptions(true); InspectorInstrumentation::frontendCreated(); ASSERT(m_inspectorClient); @@ -252,8 +252,6 @@ void InspectorController::disconnectFrontend() m_inspectorFrontend.clear(); InspectorInstrumentation::frontendDeleted(); - if (!InspectorInstrumentation::hasFrontends()) - ScriptController::setCaptureCallStackForUncaughtExceptions(false); } void InspectorController::show() @@ -293,6 +291,11 @@ void InspectorController::setProcessId(long processId) IdentifiersFactory::setProcessId(processId); } +void InspectorController::webViewResized(const IntSize& size) +{ + m_overlay->resize(size); +} + void InspectorController::evaluateForTestInFrontend(long callId, const String& script) { m_inspectorAgent->evaluateForTestInFrontend(callId, script); @@ -379,6 +382,32 @@ void InspectorController::setResourcesDataSizeLimitsFromInternals(int maximumRes m_resourceAgent->setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize); } +void InspectorController::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorController); + info.addMember(m_inspectorAgent); + info.addMember(m_instrumentingAgents); + info.addMember(m_injectedScriptManager); + info.addMember(m_state); + info.addMember(m_overlay); + + info.addMember(m_inspectorAgent); + info.addMember(m_domAgent); + info.addMember(m_resourceAgent); + info.addMember(m_pageAgent); +#if ENABLE(JAVASCRIPT_DEBUGGER) + info.addMember(m_debuggerAgent); + info.addMember(m_profilerAgent); +#endif + + info.addMember(m_inspectorBackendDispatcher); + info.addMember(m_inspectorFrontendClient); + info.addMember(m_inspectorFrontend); + info.addMember(m_page); + info.addMember(m_inspectorClient); + info.addMember(m_agents); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorController.h b/Source/WebCore/inspector/InspectorController.h index 0331e13d5..2e89092e2 100644 --- a/Source/WebCore/inspector/InspectorController.h +++ b/Source/WebCore/inspector/InspectorController.h @@ -58,6 +58,7 @@ class InspectorProfilerAgent; class InspectorResourceAgent; class InspectorState; class InstrumentingAgents; +class IntSize; class Page; class PostWorkerNotificationToFrontendTask; class Node; @@ -91,6 +92,7 @@ public: void disconnectFrontend(); void reconnectFrontend(InspectorFrontendChannel*, const String& inspectorStateCookie); void setProcessId(long); + void webViewResized(const IntSize&); void inspect(Node*); void drawHighlight(GraphicsContext&) const; @@ -112,6 +114,8 @@ public: InspectorClient* inspectorClient() const { return m_inspectorClient; } InspectorPageAgent* pageAgent() const { return m_pageAgent; } + void reportMemoryUsage(MemoryObjectInfo*) const; + private: InspectorController(Page*, InspectorClient*); diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index a533e5253..da149be02 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -470,7 +470,7 @@ Node* InspectorDOMAgent::nodeForId(int id) HashMap<int, Node*>::iterator it = m_idToNode.find(id); if (it != m_idToNode.end()) - return it->second; + return it->value; return 0; } @@ -916,9 +916,9 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim SearchResults::iterator resultsIt = m_searchResults.add(*searchId, Vector<RefPtr<Node> >()).iterator; for (ListHashSet<Node*>::iterator it = resultCollector.begin(); it != resultCollector.end(); ++it) - resultsIt->second.append(*it); + resultsIt->value.append(*it); - *resultCount = resultsIt->second.size(); + *resultCount = resultsIt->value.size(); } void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& searchId, int fromIndex, int toIndex, RefPtr<TypeBuilder::Array<int> >& nodeIds) @@ -929,7 +929,7 @@ void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& return; } - int size = it->second.size(); + int size = it->value.size(); if (fromIndex < 0 || toIndex > size || fromIndex >= toIndex) { *errorString = "Invalid search result range"; return; @@ -937,7 +937,7 @@ void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& nodeIds = TypeBuilder::Array<int>::create(); for (int i = fromIndex; i < toIndex; ++i) - nodeIds->addItem(pushNodePathToFrontend((it->second)[i].get())); + nodeIds->addItem(pushNodePathToFrontend((it->value)[i].get())); } void InspectorDOMAgent::discardSearchResults(ErrorString*, const String& searchId) @@ -957,9 +957,22 @@ bool InspectorDOMAgent::handleMousePress() return false; } -void InspectorDOMAgent::inspect(Node* node) +bool InspectorDOMAgent::handleTouchEvent(Node* node) +{ + if (!m_searchingForNode) + return false; + if (node && m_inspectModeHighlightConfig) { + m_overlay->highlightNode(node, *m_inspectModeHighlightConfig); + inspect(node); + return true; + } + return false; +} + +void InspectorDOMAgent::inspect(Node* inspectedNode) { ErrorString error; + RefPtr<Node> node = inspectedNode; setSearchingForNode(&error, false, 0); if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE) diff --git a/Source/WebCore/inspector/InspectorDOMAgent.h b/Source/WebCore/inspector/InspectorDOMAgent.h index 2f61a0a74..3b7265283 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.h +++ b/Source/WebCore/inspector/InspectorDOMAgent.h @@ -177,6 +177,7 @@ public: PassRefPtr<TypeBuilder::Runtime::RemoteObject> resolveNode(Node*, const String& objectGroup); bool handleMousePress(); + bool handleTouchEvent(Node*); void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); void inspect(Node*); void focusNode(); diff --git a/Source/WebCore/inspector/InspectorDOMDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorDOMDebuggerAgent.cpp index 8032295d8..c4fcb82b7 100644 --- a/Source/WebCore/inspector/InspectorDOMDebuggerAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMDebuggerAgent.cpp @@ -402,8 +402,8 @@ void InspectorDOMDebuggerAgent::willSendXMLHttpRequest(const String& url) else { RefPtr<InspectorObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints); for (InspectorObject::iterator it = xhrBreakpoints->begin(); it != xhrBreakpoints->end(); ++it) { - if (url.contains(it->first)) { - breakpointURL = it->first; + if (url.contains(it->key)) { + breakpointURL = it->key; break; } } diff --git a/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp b/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp index 90a0a9e60..ebdf1f395 100644 --- a/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp @@ -45,7 +45,9 @@ #include "Storage.h" #include "StorageArea.h" #include "VoidCallback.h" +#include "WebCoreMemoryInstrumentation.h" +#include <wtf/MemoryInstrumentationHashMap.h> #include <wtf/Vector.h> namespace WebCore { @@ -77,7 +79,7 @@ void InspectorDOMStorageAgent::clearFrontend() { DOMStorageResourcesMap::iterator domStorageEnd = m_resources.end(); for (DOMStorageResourcesMap::iterator it = m_resources.begin(); it != domStorageEnd; ++it) - it->second->unbind(); + it->value->unbind(); m_frontend = 0; disable(0); } @@ -96,7 +98,7 @@ void InspectorDOMStorageAgent::enable(ErrorString*) DOMStorageResourcesMap::iterator resourcesEnd = m_resources.end(); for (DOMStorageResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) - it->second->bind(m_frontend); + it->value->bind(m_frontend); } void InspectorDOMStorageAgent::disable(ErrorString*) @@ -165,8 +167,8 @@ String InspectorDOMStorageAgent::storageId(SecurityOrigin* securityOrigin, bool ASSERT(securityOrigin); DOMStorageResourcesMap::iterator domStorageEnd = m_resources.end(); for (DOMStorageResourcesMap::iterator it = m_resources.begin(); it != domStorageEnd; ++it) { - if (it->second->isSameOriginAndType(securityOrigin, isLocalStorage)) - return it->first; + if (it->value->isSameOriginAndType(securityOrigin, isLocalStorage)) + return it->key; } return String(); } @@ -176,14 +178,14 @@ InspectorDOMStorageResource* InspectorDOMStorageAgent::getDOMStorageResourceForI DOMStorageResourcesMap::iterator it = m_resources.find(storageId); if (it == m_resources.end()) return 0; - return it->second.get(); + return it->value.get(); } void InspectorDOMStorageAgent::didUseDOMStorage(StorageArea* storageArea, bool isLocalStorage, Frame* frame) { DOMStorageResourcesMap::iterator domStorageEnd = m_resources.end(); for (DOMStorageResourcesMap::iterator it = m_resources.begin(); it != domStorageEnd; ++it) { - if (it->second->isSameOriginAndType(frame->document()->securityOrigin(), isLocalStorage)) + if (it->value->isSameOriginAndType(frame->document()->securityOrigin(), isLocalStorage)) return; } @@ -214,15 +216,14 @@ void InspectorDOMStorageAgent::clearResources() m_resources.clear(); } -size_t InspectorDOMStorageAgent::memoryBytesUsedByStorageCache() const +void InspectorDOMStorageAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - size_t size = 0; - for (DOMStorageResourcesMap::const_iterator it = m_resources.begin(); it != m_resources.end(); ++it) - size += it->second->storageArea()->memoryBytesUsedByCache(); - return size; + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorDOMStorageAgent); + InspectorBaseAgent<InspectorDOMStorageAgent>::reportMemoryUsage(memoryObjectInfo); + info.addMember(m_resources); + info.addMember(m_frontend); } - } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorDOMStorageAgent.h b/Source/WebCore/inspector/InspectorDOMStorageAgent.h index a4f87b0e6..1822c6ab0 100644 --- a/Source/WebCore/inspector/InspectorDOMStorageAgent.h +++ b/Source/WebCore/inspector/InspectorDOMStorageAgent.h @@ -78,8 +78,7 @@ public: void didUseDOMStorage(StorageArea*, bool isLocalStorage, Frame*); void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*); - // Called from InspectorMemoryAgent - size_t memoryBytesUsedByStorageCache() const; + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; private: InspectorDOMStorageAgent(InstrumentingAgents*, InspectorState*); diff --git a/Source/WebCore/inspector/InspectorDOMStorageResource.cpp b/Source/WebCore/inspector/InspectorDOMStorageResource.cpp index f7a8368fd..029e39228 100644 --- a/Source/WebCore/inspector/InspectorDOMStorageResource.cpp +++ b/Source/WebCore/inspector/InspectorDOMStorageResource.cpp @@ -85,6 +85,16 @@ void InspectorDOMStorageResource::unbind() m_frontend = 0; } +void InspectorDOMStorageResource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorDOMStorageResources); + info.addMember(m_storageArea); + info.addMember(m_frame); + info.addMember(m_frontend); + info.addMember(m_id); + info.addPrivateBuffer(m_storageArea->memoryBytesUsedByCache()); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorDOMStorageResource.h b/Source/WebCore/inspector/InspectorDOMStorageResource.h index ac059cba8..10d46d750 100644 --- a/Source/WebCore/inspector/InspectorDOMStorageResource.h +++ b/Source/WebCore/inspector/InspectorDOMStorageResource.h @@ -58,6 +58,8 @@ public: StorageArea* storageArea() const { return m_storageArea.get(); } Frame* frame() const { return m_frame.get(); } + void reportMemoryUsage(MemoryObjectInfo*) const; + private: InspectorDOMStorageResource(StorageArea*, bool isLocalStorage, Frame*); diff --git a/Source/WebCore/inspector/InspectorDatabaseAgent.cpp b/Source/WebCore/inspector/InspectorDatabaseAgent.cpp index 1099c4059..0c20a3c7c 100644 --- a/Source/WebCore/inspector/InspectorDatabaseAgent.cpp +++ b/Source/WebCore/inspector/InspectorDatabaseAgent.cpp @@ -245,7 +245,7 @@ void InspectorDatabaseAgent::enable(ErrorString*) DatabaseResourcesMap::iterator databasesEnd = m_resources.end(); for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != databasesEnd; ++it) - it->second->bind(m_frontend); + it->value->bind(m_frontend); } void InspectorDatabaseAgent::disable(ErrorString*) @@ -303,8 +303,8 @@ void InspectorDatabaseAgent::executeSQL(ErrorString*, const String& databaseId, String InspectorDatabaseAgent::databaseId(Database* database) { for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { - if (it->second->database() == database) - return it->first; + if (it->value->database() == database) + return it->key; } return String(); } @@ -312,8 +312,8 @@ String InspectorDatabaseAgent::databaseId(Database* database) InspectorDatabaseResource* InspectorDatabaseAgent::findByFileName(const String& fileName) { for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { - if (it->second->database()->fileName() == fileName) - return it->second.get(); + if (it->value->database()->fileName() == fileName) + return it->value.get(); } return 0; } @@ -323,7 +323,7 @@ Database* InspectorDatabaseAgent::databaseForId(const String& databaseId) DatabaseResourcesMap::iterator it = m_resources.find(databaseId); if (it == m_resources.end()) return 0; - return it->second->database(); + return it->value->database(); } } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorDebuggerAgent.cpp index aa047c914..a77c06fb5 100644 --- a/Source/WebCore/inspector/InspectorDebuggerAgent.cpp +++ b/Source/WebCore/inspector/InspectorDebuggerAgent.cpp @@ -248,9 +248,9 @@ void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int li ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) { - if (!matches(it->second.url, url, isRegex)) + if (!matches(it->value.url, url, isRegex)) continue; - RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(breakpointId, it->first, breakpoint); + RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(breakpointId, it->key, breakpoint); if (location) locations->addItem(location); } @@ -302,8 +302,8 @@ void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakp BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpointIds.end()) return; - for (size_t i = 0; i < debugServerBreakpointIdsIterator->second.size(); ++i) - scriptDebugServer().removeBreakpoint(debugServerBreakpointIdsIterator->second[i]); + for (size_t i = 0; i < debugServerBreakpointIdsIterator->value.size(); ++i) + scriptDebugServer().removeBreakpoint(debugServerBreakpointIdsIterator->value[i]); m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIterator); } @@ -331,7 +331,7 @@ PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); if (scriptIterator == m_scripts.end()) return 0; - Script& script = scriptIterator->second; + Script& script = scriptIterator->value; if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint.lineNumber) return 0; @@ -344,7 +344,7 @@ PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpointIds.end()) debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).iterator; - debugServerBreakpointIdsIterator->second.append(debugServerBreakpointId); + debugServerBreakpointIdsIterator->value.append(debugServerBreakpointId); RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create() .setScriptId(scriptId) @@ -370,7 +370,7 @@ void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s ScriptsMap::iterator it = m_scripts.find(scriptId); if (it != m_scripts.end()) - results = ContentSearchUtils::searchInTextByLines(it->second.source, query, caseSensitive, isRegex); + results = ContentSearchUtils::searchInTextByLines(it->value.source, query, caseSensitive, isRegex); else *error = "No script for id: " + scriptId; } @@ -403,7 +403,7 @@ void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s { ScriptsMap::iterator it = m_scripts.find(scriptId); if (it != m_scripts.end()) - *scriptSource = it->second.source; + *scriptSource = it->value.source; else *error = "No script for id: " + scriptId; } @@ -630,29 +630,35 @@ void InspectorDebuggerAgent::didParseSource(const String& scriptId, const Script const bool* isContentScript = script.isContentScript ? &script.isContentScript : 0; String sourceMapURL = sourceMapURLForScript(script); String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; - m_frontend->scriptParsed(scriptId, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam); + String sourceURL; + if (!script.startLine && !script.startColumn) + sourceURL = ContentSearchUtils::findSourceURL(script.source); + bool hasSourceURL = !sourceURL.isEmpty(); + String scriptURL = hasSourceURL ? sourceURL : script.url; + bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0; + m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam); m_scripts.set(scriptId, script); - if (script.url.isEmpty()) + if (scriptURL.isEmpty()) return; RefPtr<InspectorObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); for (InspectorObject::iterator it = breakpointsCookie->begin(); it != breakpointsCookie->end(); ++it) { - RefPtr<InspectorObject> breakpointObject = it->second->asObject(); + RefPtr<InspectorObject> breakpointObject = it->value->asObject(); bool isRegex; breakpointObject->getBoolean("isRegex", &isRegex); String url; breakpointObject->getString("url", &url); - if (!matches(script.url, url, isRegex)) + if (!matches(scriptURL, url, isRegex)) continue; ScriptBreakpoint breakpoint; breakpointObject->getNumber("lineNumber", &breakpoint.lineNumber); breakpointObject->getNumber("columnNumber", &breakpoint.columnNumber); breakpointObject->getString("condition", &breakpoint.condition); - RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(it->first, scriptId, breakpoint); + RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(it->key, scriptId, breakpoint); if (location) - m_frontend->breakpointResolved(it->first, location); + m_frontend->breakpointResolved(it->key, location); } } diff --git a/Source/WebCore/inspector/InspectorFrontendHost.idl b/Source/WebCore/inspector/InspectorFrontendHost.idl index 9f4b40d8b..8ddc9a6fd 100644 --- a/Source/WebCore/inspector/InspectorFrontendHost.idl +++ b/Source/WebCore/inspector/InspectorFrontendHost.idl @@ -30,43 +30,41 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -module core { - interface [ - Conditional=INSPECTOR - ] InspectorFrontendHost { - void loaded(); - void closeWindow(); - void bringToFront(); - void setZoomFactor(in float zoom); - void inspectedURLChanged(in DOMString newURL); +[ + Conditional=INSPECTOR +] interface InspectorFrontendHost { + void loaded(); + void closeWindow(); + void bringToFront(); + void setZoomFactor(in float zoom); + void inspectedURLChanged(in DOMString newURL); - void requestAttachWindow(); - void requestDetachWindow(); - void requestSetDockSide(in DOMString side); - void setAttachedWindowHeight(in unsigned long height); - void moveWindowBy(in float x, in float y); - void setInjectedScriptForOrigin(in DOMString origin, in DOMString script); + void requestAttachWindow(); + void requestDetachWindow(); + void requestSetDockSide(in DOMString side); + void setAttachedWindowHeight(in unsigned long height); + void moveWindowBy(in float x, in float y); + void setInjectedScriptForOrigin(in DOMString origin, in DOMString script); - DOMString localizedStringsURL(); - DOMString hiddenPanels(); + DOMString localizedStringsURL(); + DOMString hiddenPanels(); - void copyText(in DOMString text); - void openInNewTab(in DOMString url); - boolean canSave(); - void save(in DOMString url, in DOMString content, in boolean forceSaveAs); - void append(in DOMString url, in DOMString content); + void copyText(in DOMString text); + void openInNewTab(in DOMString url); + boolean canSave(); + void save(in DOMString url, in DOMString content, in boolean forceSaveAs); + void append(in DOMString url, in DOMString content); - boolean canInspectWorkers(); + boolean canInspectWorkers(); - [Custom] DOMString platform(); - [Custom] DOMString port(); - [Custom] void showContextMenu(in MouseEvent event, in DOMObject items); - void sendMessageToBackend(in DOMString message); + [Custom] DOMString platform(); + [Custom] DOMString port(); + [Custom] void showContextMenu(in MouseEvent event, in DOMObject items); + void sendMessageToBackend(in DOMString message); - [Custom] void recordActionTaken(in unsigned long actionCode); - [Custom] void recordPanelShown(in unsigned long panelCode); - [Custom] void recordSettingChanged(in unsigned long settingChanged); - - DOMString loadResourceSynchronously(in DOMString url); - }; -} + [Custom] void recordActionTaken(in unsigned long actionCode); + [Custom] void recordPanelShown(in unsigned long panelCode); + [Custom] void recordSettingChanged(in unsigned long settingChanged); + + DOMString loadResourceSynchronously(in DOMString url); +}; diff --git a/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp b/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp index f12bd0dac..194d7a573 100644 --- a/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp +++ b/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp @@ -305,12 +305,12 @@ public: RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore> > objectStores = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore>::create(); for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator it = databaseMetadata.objectStores.begin(); it != databaseMetadata.objectStores.end(); ++it) { - const IDBObjectStoreMetadata& objectStoreMetadata = it->second; + const IDBObjectStoreMetadata& objectStoreMetadata = it->value; RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStoreIndex> > indexes = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStoreIndex>::create(); for (IDBObjectStoreMetadata::IndexMap::const_iterator it = objectStoreMetadata.indexes.begin(); it != objectStoreMetadata.indexes.end(); ++it) { - const IDBIndexMetadata& indexMetadata = it->second; + const IDBIndexMetadata& indexMetadata = it->value; RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::create() .setName(indexMetadata.name) @@ -329,6 +329,7 @@ public: } RefPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::create() .setName(databaseMetadata.name) + .setIntVersion(databaseMetadata.intVersion) .setVersion(databaseMetadata.version) .setObjectStores(objectStores); diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp index eb06071e4..81dded3e0 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.cpp +++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp @@ -46,6 +46,7 @@ #include "InspectorApplicationCacheAgent.h" #include "InspectorDOMDebuggerAgent.h" #include "InspectorCSSAgent.h" +#include "InspectorCanvasAgent.h" #include "InspectorConsoleAgent.h" #include "InspectorController.h" #include "WorkerInspectorController.h" @@ -261,6 +262,13 @@ void InspectorInstrumentation::didScrollImpl(InstrumentingAgents* instrumentingA pageAgent->didScroll(); } +bool InspectorInstrumentation::handleTouchEventImpl(InstrumentingAgents* instrumentingAgents, Node* node) +{ + if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent()) + return domAgent->handleTouchEvent(node); + return false; +} + bool InspectorInstrumentation::handleMousePressImpl(InstrumentingAgents* instrumentingAgents) { if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent()) @@ -745,7 +753,7 @@ void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrum double finishTime = 0.0; // FIXME: Expose all of the timing details to inspector and have it calculate finishTime. if (monotonicFinishTime) - finishTime = loader->timing()->convertMonotonicTimeToDocumentTime(monotonicFinishTime); + finishTime = loader->timing()->monotonicTimeToPseudoWallTime(monotonicFinishTime); if (timelineAgent) timelineAgent->didFinishLoadingResource(identifier, false, finishTime, loader->frame()); @@ -1134,23 +1142,30 @@ bool InspectorInstrumentation::collectingHTMLParseErrors(InstrumentingAgents* in return false; } -bool InspectorInstrumentation::hasFrontendForScriptContext(ScriptExecutionContext* scriptExecutionContext) +bool InspectorInstrumentation::canvasAgentEnabled(ScriptExecutionContext* scriptExecutionContext) { - if (!scriptExecutionContext) - return false; + InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext); + return instrumentingAgents && instrumentingAgents->inspectorCanvasAgent(); +} -#if ENABLE(WORKERS) - if (scriptExecutionContext->isWorkerContext()) { - WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext); - WorkerInspectorController* workerInspectorController = workerContext->workerInspectorController(); - return workerInspectorController && workerInspectorController->hasFrontend(); - } -#endif +bool InspectorInstrumentation::consoleAgentEnabled(ScriptExecutionContext* scriptExecutionContext) +{ + InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext); + InspectorConsoleAgent* consoleAgent = instrumentingAgents ? instrumentingAgents->inspectorConsoleAgent() : 0; + return consoleAgent && consoleAgent->enabled(); +} - ASSERT(scriptExecutionContext->isDocument()); - Document* document = static_cast<Document*>(scriptExecutionContext); - Page* page = document->page(); - return page && page->inspectorController()->hasFrontend(); +bool InspectorInstrumentation::runtimeAgentEnabled(Frame* frame) +{ + InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame); + InspectorRuntimeAgent* runtimeAgent = instrumentingAgents ? instrumentingAgents->inspectorRuntimeAgent() : 0; + return runtimeAgent && runtimeAgent->enabled(); +} + +bool InspectorInstrumentation::timelineAgentEnabled(ScriptExecutionContext* scriptExecutionContext) +{ + InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext); + return instrumentingAgents && instrumentingAgents->inspectorTimelineAgent(); } void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* instrumentingAgents, bool isDOMEvent, const String& eventName, bool synchronous) diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h index 400c443b8..4588865c6 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.h +++ b/Source/WebCore/inspector/InspectorInstrumentation.h @@ -37,14 +37,9 @@ #include "Frame.h" #include "Page.h" #include "ScriptExecutionContext.h" +#include "ScriptState.h" #include "StorageArea.h" -#if USE(JSC) -namespace JSC { -class ExecState; -} -#endif - namespace WebCore { class CSSRule; @@ -82,12 +77,6 @@ class WorkerContext; class WorkerContextProxy; class XMLHttpRequest; -#if USE(JSC) -typedef JSC::ExecState ScriptState; -#else -class ScriptState; -#endif - #if ENABLE(WEB_SOCKETS) struct WebSocketFrame; class WebSocketHandshakeRequest; @@ -121,6 +110,7 @@ public: static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags); static bool handleMousePress(Page*); + static bool handleTouchEvent(Page*, Node*); static bool forcePseudoState(Element*, CSSSelector::PseudoType); static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url); @@ -263,11 +253,17 @@ public: static void frontendCreated() { s_frontendCounter += 1; } static void frontendDeleted() { s_frontendCounter -= 1; } static bool hasFrontends() { return s_frontendCounter; } - static bool hasFrontendForScriptContext(ScriptExecutionContext*); + static bool canvasAgentEnabled(ScriptExecutionContext*); + static bool consoleAgentEnabled(ScriptExecutionContext*); + static bool runtimeAgentEnabled(Frame*); + static bool timelineAgentEnabled(ScriptExecutionContext*); static bool collectingHTMLParseErrors(Page*); #else static bool hasFrontends() { return false; } - static bool hasFrontendForScriptContext(ScriptExecutionContext*) { return false; } + static bool canvasAgentEnabled(ScriptExecutionContext*) { return false; } + static bool consoleAgentEnabled(ScriptExecutionContext*) { return false; } + static bool runtimeAgentEnabled(Frame*) { return false; } + static bool timelineAgentEnabled(ScriptExecutionContext*) { return false; } static bool collectingHTMLParseErrors(Page*) { return false; } #endif @@ -303,6 +299,7 @@ private: static void didUpdateRegionLayoutImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*); static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags); + static bool handleTouchEventImpl(InstrumentingAgents*, Node*); static bool handleMousePressImpl(InstrumentingAgents*); static bool forcePseudoStateImpl(InstrumentingAgents*, Element*, CSSSelector::PseudoType); @@ -610,6 +607,16 @@ inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const #endif } +inline bool InspectorInstrumentation::handleTouchEvent(Page* page, Node* node) +{ +#if ENABLE(INSPECTOR) + FAST_RETURN_IF_NO_FRONTENDS(false); + if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) + return handleTouchEventImpl(instrumentingAgents, node); +#endif + return false; +} + inline bool InspectorInstrumentation::handleMousePress(Page* page) { #if ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorMemoryAgent.cpp b/Source/WebCore/inspector/InspectorMemoryAgent.cpp index 2cef9ad56..badcb795b 100644 --- a/Source/WebCore/inspector/InspectorMemoryAgent.cpp +++ b/Source/WebCore/inspector/InspectorMemoryAgent.cpp @@ -39,6 +39,7 @@ #include "Document.h" #include "EventListenerMap.h" #include "Frame.h" +#include "InspectorClient.h" #include "InspectorDOMStorageAgent.h" #include "InspectorFrontend.h" #include "InspectorState.h" @@ -52,9 +53,10 @@ #include "ScriptGCEvent.h" #include "ScriptProfiler.h" #include "StyledElement.h" -#include <wtf/ArrayBuffer.h> #include <wtf/ArrayBufferView.h> #include <wtf/HashSet.h> +#include <wtf/MemoryInstrumentationArrayBufferView.h> +#include <wtf/NonCopyingSort.h> #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> @@ -69,28 +71,88 @@ using WebCore::TypeBuilder::Memory::StringStatistics; // Use a type alias instead of 'using' here which would cause a conflict on Mac. typedef WebCore::TypeBuilder::Memory::MemoryBlock InspectorMemoryBlock; +typedef WebCore::TypeBuilder::Array<InspectorMemoryBlock> InspectorMemoryBlocks; namespace WebCore { -namespace MemoryBlockName { -static const char jsHeapAllocated[] = "JSHeapAllocated"; -static const char jsHeapUsed[] = "JSHeapUsed"; -static const char jsExternalResources[] = "JSExternalResources"; -static const char jsExternalArrays[] = "JSExternalArrays"; -static const char jsExternalStrings[] = "JSExternalStrings"; -static const char inspectorData[] = "InspectorData"; -static const char inspectorDOMData[] = "InspectorDOMData"; -static const char inspectorJSHeapData[] = "InspectorJSHeapData"; -static const char processPrivateMemory[] = "ProcessPrivateMemory"; - -static const char renderTreeUsed[] = "RenderTreeUsed"; -static const char renderTreeAllocated[] = "RenderTreeAllocated"; - -static const char domStorageCache[] = "DOMStorageCache"; -} - namespace { +class MemoryUsageStatsGenerator { +public: + MemoryUsageStatsGenerator(MemoryInstrumentationClientImpl* client) : m_client(client) { } + + void dump(InspectorMemoryBlocks* children) + { + m_sizesMap = m_client->sizesMap(); + + Vector<String> objectTypes; + objectTypes.appendRange(m_sizesMap.keys().begin(), m_sizesMap.keys().end()); + + for (Vector<String>::const_iterator i = objectTypes.begin(); i != objectTypes.end(); ++i) + updateParentSizes(*i, m_sizesMap.get(*i)); + + objectTypes.clear(); + objectTypes.appendRange(m_sizesMap.keys().begin(), m_sizesMap.keys().end()); + nonCopyingSort(objectTypes.begin(), objectTypes.end(), stringCompare); + + size_t index = 0; + while (index < objectTypes.size()) + index = buildObjectForIndex(index, objectTypes, children); + + addMemoryInstrumentationDebugData(children); + } + +private: + static bool stringCompare(const String& a, const String& b) { return WTF::codePointCompare(a, b) < 0; } + + void updateParentSizes(String objectType, const size_t size) + { + for (size_t dotPosition = objectType.reverseFind('.'); dotPosition != notFound; dotPosition = objectType.reverseFind('.', dotPosition)) { + objectType = objectType.substring(0, dotPosition); + TypeNameToSizeMap::AddResult result = m_sizesMap.add(objectType, size); + if (!result.isNewEntry) + result.iterator->value += size; + } + } + + size_t buildObjectForIndex(size_t index, const Vector<String>& objectTypes, InspectorMemoryBlocks* array) + { + String typeName = objectTypes[index]; + RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(typeName); + block->setSize(m_sizesMap.get(typeName)); + String prefix = typeName; + prefix.append('.'); + array->addItem(block); + ++index; + RefPtr<InspectorMemoryBlocks> children; + while (index < objectTypes.size() && objectTypes[index].startsWith(prefix)) { + if (!children) + children = InspectorMemoryBlocks::create(); + index = buildObjectForIndex(index, objectTypes, children.get()); + } + if (children) + block->setChildren(children.release()); + return index; + } + + void addMemoryInstrumentationDebugData(InspectorMemoryBlocks* children) + { + if (m_client->checkInstrumentedObjects()) { + RefPtr<InspectorMemoryBlock> totalInstrumented = InspectorMemoryBlock::create().setName("InstrumentedObjectsCount"); + totalInstrumented->setSize(m_client->totalCountedObjects()); + + RefPtr<InspectorMemoryBlock> incorrectlyInstrumented = InspectorMemoryBlock::create().setName("InstrumentedButNotAllocatedObjectsCount"); + incorrectlyInstrumented->setSize(m_client->totalObjectsNotInAllocatedSet()); + + children->addItem(totalInstrumented); + children->addItem(incorrectlyInstrumented); + } + } + + MemoryInstrumentationClientImpl* m_client; + TypeNameToSizeMap m_sizesMap; +}; + String nodeName(Node* node) { if (node->document()->isXHTMLDocument()) @@ -144,8 +206,8 @@ public: { RefPtr<TypeBuilder::Array<TypeBuilder::Memory::NodeCount> > childrenStats = TypeBuilder::Array<TypeBuilder::Memory::NodeCount>::create(); for (HashMap<String, int>::iterator it = m_nodeNameToCount.begin(); it != m_nodeNameToCount.end(); ++it) { - RefPtr<NodeCount> nodeCount = NodeCount::create().setNodeName(it->first) - .setCount(it->second); + RefPtr<NodeCount> nodeCount = NodeCount::create().setNodeName(it->key) + .setCount(it->value); childrenStats->addItem(nodeCount); } return childrenStats.release(); @@ -155,8 +217,8 @@ public: { RefPtr<TypeBuilder::Array<TypeBuilder::Memory::ListenerCount> > listenerStats = TypeBuilder::Array<TypeBuilder::Memory::ListenerCount>::create(); for (HashMap<AtomicString, int>::iterator it = m_eventTypeToCount.begin(); it != m_eventTypeToCount.end(); ++it) { - RefPtr<ListenerCount> listenerCount = ListenerCount::create().setType(it->first) - .setCount(it->second); + RefPtr<ListenerCount> listenerCount = ListenerCount::create().setType(it->key) + .setCount(it->value); listenerStats->addItem(listenerCount); } return listenerStats.release(); @@ -304,65 +366,46 @@ private: int m_sharedStringSize; }; -class ExternalResourceVisitor : public ExternalStringVisitor, public ExternalArrayVisitor { +class ExternalStringsRoot : public ExternalStringVisitor { public: - explicit ExternalResourceVisitor(VisitedObjects& visitedObjects) - : m_visitedObjects(visitedObjects) - , m_jsExternalStringSize(0) - , m_externalArraySize(0) - { } - - size_t externalStringSize() const { return m_jsExternalStringSize; } - size_t externalArraySize() const { return m_externalArraySize; } + ExternalStringsRoot() : m_memoryClassInfo(0) { } -private: - virtual void visitJSExternalArray(ArrayBufferView* bufferView) + void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - ArrayBuffer* buffer = bufferView->buffer().get(); - if (m_visitedObjects.add(buffer).isNewEntry) - m_externalArraySize += buffer->byteLength(); + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::ExternalStrings); + m_memoryClassInfo = &info; + ScriptProfiler::visitExternalStrings(const_cast<ExternalStringsRoot*>(this)); + m_memoryClassInfo = 0; } + +private: virtual void visitJSExternalString(StringImpl* string) { - if (m_visitedObjects.add(string).isNewEntry) - m_jsExternalStringSize += string->sizeInBytes(); + m_memoryClassInfo->addMember(string); } - VisitedObjects& m_visitedObjects; - size_t m_jsExternalStringSize; - size_t m_externalArraySize; + mutable MemoryClassInfo* m_memoryClassInfo; }; -class InspectorDataCounter { +class ExternalArraysRoot : public ExternalArrayVisitor { public: - void addComponent(const String& name, size_t size) - { - m_components.append(ComponentInfo(name, size)); - } + ExternalArraysRoot() : m_memoryClassInfo(0) { } - PassRefPtr<InspectorMemoryBlock> dumpStatistics() + void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - size_t totalSize = 0; - RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(MemoryBlockName::inspectorData); - for (Vector<ComponentInfo>::iterator it = m_components.begin(); it != m_components.end(); ++it) { - RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(it->m_name); - block->setSize(it->m_size); - totalSize += it->m_size; - } - block->setSize(totalSize); - return block; + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::ExternalArrays); + m_memoryClassInfo = &info; + ScriptProfiler::visitExternalArrays(const_cast<ExternalArraysRoot*>(this)); + m_memoryClassInfo = 0; } private: - class ComponentInfo { - public: - ComponentInfo(const String& name, size_t size) : m_name(name), m_size(size) { } - - const String m_name; - size_t m_size; - }; + virtual void visitJSExternalArray(ArrayBufferView* arrayBufferView) + { + m_memoryClassInfo->addMember(arrayBufferView); + } - Vector<ComponentInfo> m_components; + mutable MemoryClassInfo* m_memoryClassInfo; }; } // namespace @@ -388,44 +431,28 @@ void InspectorMemoryAgent::getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Arr strings = counterVisitor.strings(); } -static PassRefPtr<InspectorMemoryBlock> jsHeapInfo() +static void reportJSHeapInfo(WTF::MemoryInstrumentationClient& memoryInstrumentationClient) { HeapInfo info; ScriptGCEvent::getHeapSize(info); - RefPtr<InspectorMemoryBlock> jsHeapAllocated = InspectorMemoryBlock::create().setName(MemoryBlockName::jsHeapAllocated); - jsHeapAllocated->setSize(static_cast<int>(info.totalJSHeapSize)); - - RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); - RefPtr<InspectorMemoryBlock> jsHeapUsed = InspectorMemoryBlock::create().setName(MemoryBlockName::jsHeapUsed); - jsHeapUsed->setSize(static_cast<int>(info.usedJSHeapSize)); - children->addItem(jsHeapUsed); - - jsHeapAllocated->setChildren(children); - return jsHeapAllocated.release(); + memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::JSHeapUsed, info.usedJSHeapSize); + memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::JSHeapUnused, info.totalJSHeapSize - info.usedJSHeapSize); } -static PassRefPtr<InspectorMemoryBlock> renderTreeInfo(Page* page) +static void reportRenderTreeInfo(WTF::MemoryInstrumentationClient& memoryInstrumentationClient, Page* page) { ArenaSize arenaSize = page->renderTreeSize(); - RefPtr<InspectorMemoryBlock> renderTreeAllocated = InspectorMemoryBlock::create().setName(MemoryBlockName::renderTreeAllocated); - renderTreeAllocated->setSize(arenaSize.allocated); - - RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); - RefPtr<InspectorMemoryBlock> renderTreeUsed = InspectorMemoryBlock::create().setName(MemoryBlockName::renderTreeUsed); - renderTreeUsed->setSize(arenaSize.treeSize); - children->addItem(renderTreeUsed); - - renderTreeAllocated->setChildren(children); - return renderTreeAllocated.release(); + memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::RenderTreeUsed, arenaSize.treeSize); + memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::RenderTreeUnused, arenaSize.allocated - arenaSize.treeSize); } namespace { class DOMTreesIterator : public NodeWrapperVisitor { public: - DOMTreesIterator(Page* page, MemoryInstrumentationImpl& memoryInstrumentation) + DOMTreesIterator(MemoryInstrumentationImpl& memoryInstrumentation, Page* page) : m_page(page) , m_memoryInstrumentation(memoryInstrumentation) { @@ -454,72 +481,23 @@ public: m_memoryInstrumentation.addRootObject(memoryCache()); } - PassRefPtr<InspectorMemoryBlock> buildObjectForMemoryCache() const - { - size_t totalSize = 0; - - RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::MemoryCacheStructures); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceRaw); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceCSS); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceFont); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceImage); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceScript); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceSVG); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceShader); - totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceXSLT); - - RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(WebCoreMemoryTypes::MemoryCache); - block->setSize(totalSize); - block->setChildren(children.release()); - return block.release(); - } - - PassRefPtr<InspectorMemoryBlock> buildObjectForPage() const - { - size_t totalSize = 0; - - RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > domChildren = TypeBuilder::Array<InspectorMemoryBlock>::create(); - totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::DOM); - totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::Image); - totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::CSS); - totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::Binding); - totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::Loader); - - RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(WebCoreMemoryTypes::Page); - dom->setSize(totalSize); - dom->setChildren(domChildren.release()); - return dom.release(); - } - - void dumpStatistics(TypeBuilder::Array<InspectorMemoryBlock>* children, InspectorDataCounter* inspectorData) - { - children->addItem(buildObjectForMemoryCache()); - children->addItem(buildObjectForPage()); - - inspectorData->addComponent(MemoryBlockName::inspectorDOMData, m_memoryInstrumentation.selfSize()); - } private: - size_t addMemoryBlockFor(TypeBuilder::Array<InspectorMemoryBlock>* array, MemoryObjectType typeName) const - { - RefPtr<InspectorMemoryBlock> result = InspectorMemoryBlock::create().setName(typeName); - size_t size = m_memoryInstrumentation.totalSize(typeName); - result->setSize(size); - array->addItem(result); - return size; - } - Page* m_page; MemoryInstrumentationImpl& m_memoryInstrumentation; }; } -static void collectDomTreeInfo(Page* page, VisitedObjects& visitedObjects, TypeBuilder::Array<InspectorMemoryBlock>* children, InspectorDataCounter* inspectorData) +static void collectDomTreeInfo(MemoryInstrumentationImpl& memoryInstrumentation, Page* page) { - MemoryInstrumentationImpl memoryInstrumentation(visitedObjects); - DOMTreesIterator domTreesIterator(page, memoryInstrumentation); + ExternalStringsRoot stringsRoot; + memoryInstrumentation.addRootObject(stringsRoot); + + ExternalArraysRoot arraysRoot; + memoryInstrumentation.addRootObject(arraysRoot); + + DOMTreesIterator domTreesIterator(memoryInstrumentation, page); ScriptProfiler::visitNodeWrappers(&domTreesIterator); @@ -533,11 +511,9 @@ static void collectDomTreeInfo(Page* page, VisitedObjects& visitedObjects, TypeB domTreesIterator.visitBindings(); domTreesIterator.visitMemoryCache(); - - domTreesIterator.dumpStatistics(children, inspectorData); } -static void addPlatformComponentsInfo(PassRefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children) +static void addPlatformComponentsInfo(PassRefPtr<InspectorMemoryBlocks> children) { Vector<MemoryUsageSupport::ComponentInfo> components; MemoryUsageSupport::memoryUsageByComponents(components); @@ -548,50 +524,27 @@ static void addPlatformComponentsInfo(PassRefPtr<TypeBuilder::Array<InspectorMem } } -static PassRefPtr<InspectorMemoryBlock> jsExternalResourcesInfo(VisitedObjects& visitedObjects) +void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<InspectorMemoryBlock>& processMemory) { - ExternalResourceVisitor visitor(visitedObjects); - ScriptProfiler::visitExternalStrings(&visitor); - ScriptProfiler::visitExternalArrays(&visitor); + MemoryInstrumentationClientImpl memoryInstrumentationClient; + m_inspectorClient->getAllocatedObjects(memoryInstrumentationClient.allocatedObjects()); + MemoryInstrumentationImpl memoryInstrumentation(&memoryInstrumentationClient); - RefPtr<InspectorMemoryBlock> externalResourcesStats = InspectorMemoryBlock::create().setName(MemoryBlockName::jsExternalResources); - externalResourcesStats->setSize(visitor.externalStringSize() + visitor.externalArraySize()); - RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); + reportJSHeapInfo(memoryInstrumentationClient); + reportRenderTreeInfo(memoryInstrumentationClient, m_page); + collectDomTreeInfo(memoryInstrumentation, m_page); // FIXME: collect for all pages? - RefPtr<InspectorMemoryBlock> externalStringStats = InspectorMemoryBlock::create().setName(MemoryBlockName::jsExternalStrings); - externalStringStats->setSize(visitor.externalStringSize()); - children->addItem(externalStringStats); - - RefPtr<InspectorMemoryBlock> externalArrayStats = InspectorMemoryBlock::create().setName(MemoryBlockName::jsExternalArrays); - externalArrayStats->setSize(visitor.externalArraySize()); - children->addItem(externalArrayStats); + RefPtr<InspectorMemoryBlocks> children = InspectorMemoryBlocks::create(); + addPlatformComponentsInfo(children); - return externalResourcesStats.release(); -} + memoryInstrumentation.addRootObject(this); + memoryInstrumentation.addRootObject(memoryInstrumentation); + memoryInstrumentation.addRootObject(memoryInstrumentationClient); -static PassRefPtr<InspectorMemoryBlock> dumpDOMStorageCache(size_t cacheSize) -{ - RefPtr<InspectorMemoryBlock> domStorageCache = InspectorMemoryBlock::create().setName(MemoryBlockName::domStorageCache); - domStorageCache->setSize(cacheSize); - return domStorageCache; -} + MemoryUsageStatsGenerator statsGenerator(&memoryInstrumentationClient); + statsGenerator.dump(children.get()); -void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<InspectorMemoryBlock>& processMemory) -{ - processMemory = InspectorMemoryBlock::create().setName(MemoryBlockName::processPrivateMemory); - - InspectorDataCounter inspectorData; - inspectorData.addComponent(MemoryBlockName::inspectorJSHeapData, ScriptProfiler::profilerSnapshotsSize()); - - VisitedObjects visitedObjects; - RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); - children->addItem(jsHeapInfo()); - children->addItem(renderTreeInfo(m_page)); // FIXME: collect for all pages? - children->addItem(jsExternalResourcesInfo(visitedObjects)); - collectDomTreeInfo(m_page, visitedObjects, children.get(), &inspectorData); // FIXME: collect for all pages? - children->addItem(inspectorData.dumpStatistics()); - children->addItem(dumpDOMStorageCache(m_domStorageAgent->memoryBytesUsedByStorageCache())); - addPlatformComponentsInfo(children); + processMemory = InspectorMemoryBlock::create().setName(WebCoreMemoryTypes::ProcessPrivateMemory); processMemory->setChildren(children); size_t privateBytes = 0; @@ -600,10 +553,18 @@ void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<Ins processMemory->setSize(privateBytes); } -InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMStorageAgent* domStorageAgent) +void InspectorMemoryAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector); + InspectorBaseAgent<InspectorMemoryAgent>::reportMemoryUsage(memoryObjectInfo); + info.addMember(m_inspectorClient); + info.addMember(m_page); +} + +InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorState* state, Page* page) : InspectorBaseAgent<InspectorMemoryAgent>("Memory", instrumentingAgents, state) + , m_inspectorClient(client) , m_page(page) - , m_domStorageAgent(domStorageAgent) { } diff --git a/Source/WebCore/inspector/InspectorMemoryAgent.h b/Source/WebCore/inspector/InspectorMemoryAgent.h index 3b648642e..61f11580c 100644 --- a/Source/WebCore/inspector/InspectorMemoryAgent.h +++ b/Source/WebCore/inspector/InspectorMemoryAgent.h @@ -39,6 +39,7 @@ namespace WebCore { +class InspectorClient; class InspectorDOMStorageAgent; class InspectorState; class InstrumentingAgents; @@ -51,19 +52,22 @@ class InspectorMemoryAgent : public InspectorBaseAgent<InspectorMemoryAgent>, pu public: typedef Vector<OwnPtr<InspectorBaseAgentInterface> > InspectorAgents; - static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMStorageAgent* domStorageAgent) + static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorState* state, Page* page) { - return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, state, page, domStorageAgent)); + return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, client, state, page)); } virtual ~InspectorMemoryAgent(); virtual void getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Memory::DOMGroup> >& domGroups, RefPtr<TypeBuilder::Memory::StringStatistics>& strings); virtual void getProcessMemoryDistribution(ErrorString*, RefPtr<TypeBuilder::Memory::MemoryBlock>& processMemory); + virtual void reportMemoryUsage(MemoryObjectInfo*) const; + private: - InspectorMemoryAgent(InstrumentingAgents*, InspectorState*, Page*, InspectorDOMStorageAgent*); + InspectorMemoryAgent(InstrumentingAgents*, InspectorClient*, InspectorState*, Page*); + + InspectorClient* m_inspectorClient; Page* m_page; - InspectorDOMStorageAgent* m_domStorageAgent; }; } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorOverlay.cpp b/Source/WebCore/inspector/InspectorOverlay.cpp index 7a87b0f0e..70681413c 100644 --- a/Source/WebCore/inspector/InspectorOverlay.cpp +++ b/Source/WebCore/inspector/InspectorOverlay.cpp @@ -205,12 +205,18 @@ InspectorOverlay::~InspectorOverlay() void InspectorOverlay::paint(GraphicsContext& context) { - if (m_pausedInDebuggerMessage.isNull() && !m_highlightNode && !m_highlightRect) + if (m_pausedInDebuggerMessage.isNull() && !m_highlightNode && !m_highlightRect && m_size.isEmpty()) return; GraphicsContextStateSaver stateSaver(context); FrameView* view = overlayPage()->mainFrame()->view(); ASSERT(!view->needsLayout()); + + context.beginTransparencyLayer(1); + context.setCompositeOperation(CompositeCopy); + view->paint(&context, IntRect(0, 0, view->width(), view->height())); + + context.endTransparencyLayer(); } void InspectorOverlay::drawOutline(GraphicsContext* context, const LayoutRect& rect, const Color& color) @@ -231,6 +237,12 @@ void InspectorOverlay::getHighlight(Highlight* highlight) const buildRectHighlight(m_page, m_highlightRect.get(), m_rectHighlightConfig, highlight); } +void InspectorOverlay::resize(const IntSize& size) +{ + m_size = size; + update(); +} + void InspectorOverlay::setPausedInDebuggerMessage(const String* message) { m_pausedInDebuggerMessage = message ? *message : String(); @@ -265,7 +277,7 @@ Node* InspectorOverlay::highlightedNode() const void InspectorOverlay::update() { - if (!m_highlightNode && !m_highlightRect && m_pausedInDebuggerMessage.isNull()) { + if (!m_highlightNode && !m_highlightRect && m_pausedInDebuggerMessage.isNull() && m_size.isEmpty()) { m_client->hideHighlight(); return; } @@ -275,12 +287,16 @@ void InspectorOverlay::update() return; FrameView* overlayView = overlayPage()->mainFrame()->view(); - IntRect visibleRect = enclosingIntRect(view->visibleContentRect()); - overlayView->resize(visibleRect.width(), visibleRect.height()); + IntSize viewportSize = enclosingIntRect(view->visibleContentRect()).size(); + IntSize frameViewFullSize = enclosingIntRect(view->visibleContentRect(true)).size(); + IntSize size = m_size.isEmpty() ? frameViewFullSize : m_size; + overlayView->resize(size); // Clear canvas and paint things. - reset(); + reset(viewportSize, m_size.isEmpty() ? IntSize() : frameViewFullSize); + // Include scrollbars to avoid masking them by the gutter. + drawGutter(); drawNodeHighlight(); drawRectHighlight(); drawPausedInDebuggerMessage(); @@ -294,7 +310,7 @@ void InspectorOverlay::update() m_client->highlight(); } -static RefPtr<InspectorObject> buildObjectForPoint(const FloatPoint& point) +static PassRefPtr<InspectorObject> buildObjectForPoint(const FloatPoint& point) { RefPtr<InspectorObject> object = InspectorObject::create(); object->setNumber("x", point.x()); @@ -302,7 +318,7 @@ static RefPtr<InspectorObject> buildObjectForPoint(const FloatPoint& point) return object.release(); } -static RefPtr<InspectorArray> buildArrayForQuad(const FloatQuad& quad) +static PassRefPtr<InspectorArray> buildArrayForQuad(const FloatQuad& quad) { RefPtr<InspectorArray> array = InspectorArray::create(); array->pushObject(buildObjectForPoint(quad.p1())); @@ -312,7 +328,7 @@ static RefPtr<InspectorArray> buildArrayForQuad(const FloatQuad& quad) return array.release(); } -static RefPtr<InspectorObject> buildObjectForHighlight(FrameView* mainView, const Highlight& highlight) +static PassRefPtr<InspectorObject> buildObjectForHighlight(FrameView* mainView, const Highlight& highlight) { RefPtr<InspectorObject> object = InspectorObject::create(); RefPtr<InspectorArray> array = InspectorArray::create(); @@ -337,6 +353,19 @@ static RefPtr<InspectorObject> buildObjectForHighlight(FrameView* mainView, cons return object.release(); } +static PassRefPtr<InspectorObject> buildObjectForSize(const IntSize& size) +{ + RefPtr<InspectorObject> result = InspectorObject::create(); + result->setNumber("width", size.width()); + result->setNumber("height", size.height()); + return result.release(); +} + +void InspectorOverlay::drawGutter() +{ + evaluateInOverlay("drawGutter", ""); +} + void InspectorOverlay::drawNodeHighlight() { if (!m_highlightNode) @@ -445,9 +474,13 @@ Page* InspectorOverlay::overlayPage() return m_overlayPage.get(); } -void InspectorOverlay::reset() +void InspectorOverlay::reset(const IntSize& viewportSize, const IntSize& frameViewFullSize) { - evaluateInOverlay("reset", String::number(m_page->deviceScaleFactor())); + RefPtr<InspectorObject> resetData = InspectorObject::create(); + resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor()); + resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); + resetData->setObject("frameViewFullSize", buildObjectForSize(frameViewFullSize)); + evaluateInOverlay("reset", resetData.release()); } void InspectorOverlay::evaluateInOverlay(const String& method, const String& argument) diff --git a/Source/WebCore/inspector/InspectorOverlay.h b/Source/WebCore/inspector/InspectorOverlay.h index 31a63051c..56f83bb7b 100644 --- a/Source/WebCore/inspector/InspectorOverlay.h +++ b/Source/WebCore/inspector/InspectorOverlay.h @@ -100,6 +100,7 @@ public: void paint(GraphicsContext&); void drawOutline(GraphicsContext*, const LayoutRect&, const Color&); void getHighlight(Highlight*) const; + void resize(const IntSize&); void setPausedInDebuggerMessage(const String*); @@ -112,11 +113,12 @@ public: private: InspectorOverlay(Page*, InspectorClient*); + void drawGutter(); void drawNodeHighlight(); void drawRectHighlight(); void drawPausedInDebuggerMessage(); Page* overlayPage(); - void reset(); + void reset(const IntSize& viewportSize, const IntSize& frameViewFullSize); void evaluateInOverlay(const String& method, const String& argument); void evaluateInOverlay(const String& method, PassRefPtr<InspectorValue> argument); @@ -128,6 +130,7 @@ private: OwnPtr<IntRect> m_highlightRect; OwnPtr<Page> m_overlayPage; HighlightConfig m_rectHighlightConfig; + IntSize m_size; }; } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorOverlayPage.html b/Source/WebCore/inspector/InspectorOverlayPage.html index 20c421813..2fc8bd635 100644 --- a/Source/WebCore/inspector/InspectorOverlayPage.html +++ b/Source/WebCore/inspector/InspectorOverlayPage.html @@ -89,6 +89,24 @@ body.platform-linux { #node-id { color: rgb(26, 26, 166); } + +#right-gutter { + display: none; + right: 0; + top: 0; + bottom: 0; + position: absolute; + background-color: darkgray; +} + +#bottom-gutter { + display: none; + left: 0; + right: 0; + bottom: 0; + position: absolute; + background-color: darkgray; +} </style> <script> const lightGridColor = "rgba(0,0,0,0.2)"; @@ -266,14 +284,41 @@ function quadEquals(quad1, quad2) quad1[3].x === quad2[3].x && quad1[3].y === quad2[3].y; } -function reset(deviceScaleFactor) +function drawGutter() +{ + var frameWidth = frameViewFullSize.width; + var frameHeight = frameViewFullSize.height; + + if (!frameWidth || document.body.offsetWidth <= frameWidth) + rightGutter.style.removeProperty("display"); + else { + rightGutter.style.display = "block"; + rightGutter.style.left = frameWidth + "px"; + } + + if (!frameHeight || document.body.offsetHeight <= frameHeight) + bottomGutter.style.removeProperty("display"); + else { + bottomGutter.style.display = "block"; + bottomGutter.style.top = frameHeight + "px"; + } +} + +function reset(resetData) { + var deviceScaleFactor = resetData.deviceScaleFactor; + var viewportSize = resetData.viewportSize; + window.frameViewFullSize = resetData.frameViewFullSize; + window.canvas = document.getElementById("canvas"); window.context = canvas.getContext("2d"); - canvas.width = deviceScaleFactor * document.body.offsetWidth; - canvas.height = deviceScaleFactor * document.body.offsetHeight; - canvas.style.width = document.body.offsetWidth + "px"; - canvas.style.height = document.body.offsetHeight + "px"; + window.rightGutter = document.getElementById("right-gutter"); + window.bottomGutter = document.getElementById("bottom-gutter"); + + canvas.width = deviceScaleFactor * viewportSize.width; + canvas.height = deviceScaleFactor * viewportSize.height; + canvas.style.width = viewportSize.width + "px"; + canvas.style.height = viewportSize.height + "px"; context.scale(deviceScaleFactor, deviceScaleFactor); document.getElementById("paused-in-debugger").style.visibility = "hidden"; @@ -517,5 +562,7 @@ function log(text) <span id="tag-name"></span><span id="node-id"></span><span id="class-name"></span> <span id="node-width"></span><span class="px">px</span><span class="px"> × </span><span id="node-height"></span><span class="px">px</span> </div> +<div id="right-gutter"></div> +<div id="bottom-gutter"></div> <div id="log"></div> </html> diff --git a/Source/WebCore/inspector/InspectorPageAgent.cpp b/Source/WebCore/inspector/InspectorPageAgent.cpp index ef39e6f13..b35f12830 100644 --- a/Source/WebCore/inspector/InspectorPageAgent.cpp +++ b/Source/WebCore/inspector/InspectorPageAgent.cpp @@ -67,10 +67,10 @@ #include "MemoryCache.h" #include "Page.h" #include "RegularExpression.h" +#include "ResourceBuffer.h" #include "ScriptObject.h" #include "SecurityOrigin.h" #include "Settings.h" -#include "SharedBuffer.h" #include "TextEncoding.h" #include "TextResourceDecoder.h" #include "UserGestureIndicator.h" @@ -98,13 +98,13 @@ static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; #endif } -static bool decodeSharedBuffer(PassRefPtr<SharedBuffer> buffer, const String& textEncodingName, String* result) +static bool decodeBuffer(const char* buffer, unsigned size, const String& textEncodingName, String* result) { if (buffer) { TextEncoding encoding(textEncodingName); if (!encoding.isValid()) encoding = WindowsLatin1Encoding(); - *result = encoding.decode(buffer->data(), buffer->size()); + *result = encoding.decode(buffer, size); return true; } return false; @@ -166,7 +166,7 @@ bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, S *base64Encoded = !hasTextContent(cachedResource); if (*base64Encoded) { - RefPtr<SharedBuffer> buffer = hasZeroSize ? SharedBuffer::create() : cachedResource->data(); + RefPtr<SharedBuffer> buffer = hasZeroSize ? SharedBuffer::create() : cachedResource->resourceBuffer()->sharedBuffer(); if (!buffer) return false; @@ -189,7 +189,7 @@ bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, S *result = static_cast<CachedScript*>(cachedResource)->script(); return true; case CachedResource::RawResource: { - SharedBuffer* buffer = cachedResource->data(); + ResourceBuffer* buffer = cachedResource->resourceBuffer(); if (!buffer) return false; RefPtr<TextResourceDecoder> decoder = createXHRTextDecoder(cachedResource->response().mimeType(), cachedResource->response().textEncodingName()); @@ -201,31 +201,37 @@ bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, S return true; } default: - return decodeSharedBuffer(cachedResource->data(), cachedResource->encoding(), result); + ResourceBuffer* buffer = cachedResource->resourceBuffer(); + return decodeBuffer(buffer ? buffer->data() : 0, buffer ? buffer->size() : 0, cachedResource->encoding(), result); } } return false; } -static bool mainResourceContent(Frame* frame, bool withBase64Encode, String* result) +bool InspectorPageAgent::mainResourceContent(Frame* frame, bool withBase64Encode, String* result) { - RefPtr<SharedBuffer> buffer = frame->loader()->documentLoader()->mainResourceData(); + RefPtr<ResourceBuffer> buffer = frame->loader()->documentLoader()->mainResourceData(); if (!buffer) return false; String textEncodingName = frame->document()->inputEncoding(); - return InspectorPageAgent::sharedBufferContent(buffer, textEncodingName, withBase64Encode, result); + return InspectorPageAgent::dataContent(buffer->data(), buffer->size(), textEncodingName, withBase64Encode, result); } // static bool InspectorPageAgent::sharedBufferContent(PassRefPtr<SharedBuffer> buffer, const String& textEncodingName, bool withBase64Encode, String* result) { + return dataContent(buffer ? buffer->data() : 0, buffer ? buffer->size() : 0, textEncodingName, withBase64Encode, result); +} + +bool InspectorPageAgent::dataContent(const char* data, unsigned size, const String& textEncodingName, bool withBase64Encode, String* result) +{ if (withBase64Encode) { - *result = base64Encode(buffer->data(), buffer->size()); + *result = base64Encode(data, size); return true; } - return decodeSharedBuffer(buffer, textEncodingName, result); + return decodeBuffer(data, size, textEncodingName, result); } PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOverlay* overlay) @@ -452,7 +458,7 @@ static Vector<CachedResource*> cachedResourcesForFrame(Frame* frame) const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources(); CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end(); for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) { - CachedResource* cachedResource = it->second.get(); + CachedResource* cachedResource = it->value.get(); switch (cachedResource->type()) { case CachedResource::ImageResource: @@ -756,7 +762,7 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor InspectorObject::const_iterator end = scripts->end(); for (InspectorObject::const_iterator it = scripts->begin(); it != end; ++it) { String scriptText; - if (it->second->asString(&scriptText)) + if (it->value->asString(&scriptText)) m_injectedScriptManager->injectScript(scriptText, mainWorldScriptState(frame)); } } @@ -788,8 +794,8 @@ void InspectorPageAgent::frameDetached(Frame* frame) { HashMap<Frame*, String>::iterator iterator = m_frameToIdentifier.find(frame); if (iterator != m_frameToIdentifier.end()) { - m_frontend->frameDetached(iterator->second); - m_identifierToFrame.remove(iterator->second); + m_frontend->frameDetached(iterator->value); + m_identifierToFrame.remove(iterator->value); m_frameToIdentifier.remove(iterator); } } @@ -1102,6 +1108,16 @@ void InspectorPageAgent::setTouchEmulationEnabled(ErrorString* error, bool enabl #endif } +void InspectorPageAgent::setCompositingBordersVisible(ErrorString*, bool visible) +{ + Settings* settings = m_page->settings(); + if (!settings) + return; + + settings->setShowDebugBorders(visible); + settings->setShowRepaintCounter(visible); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorPageAgent.h b/Source/WebCore/inspector/InspectorPageAgent.h index 7b71b211f..0ce43bef5 100644 --- a/Source/WebCore/inspector/InspectorPageAgent.h +++ b/Source/WebCore/inspector/InspectorPageAgent.h @@ -118,6 +118,7 @@ public: virtual void clearDeviceOrientationOverride(ErrorString*); virtual void canOverrideDeviceOrientation(ErrorString*, bool*); virtual void setTouchEmulationEnabled(ErrorString*, bool); + virtual void setCompositingBordersVisible(ErrorString*, bool); // Geolocation override helpers. GeolocationPosition* overrideGeolocationPosition(GeolocationPosition*); @@ -160,6 +161,9 @@ private: void updateTouchEventEmulationInPage(bool); #endif + static bool mainResourceContent(Frame*, bool withBase64Encode, String* result); + static bool dataContent(const char* data, unsigned size, const String& textEncodingName, bool withBase64Encode, String* result); + PassRefPtr<TypeBuilder::Page::Frame> buildObjectForFrame(Frame*); PassRefPtr<TypeBuilder::Page::FrameResourceTree> buildObjectForFrameTree(Frame*); Page* m_page; diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.cpp b/Source/WebCore/inspector/InspectorProfilerAgent.cpp index 9c864c5dd..6c28ed231 100644 --- a/Source/WebCore/inspector/InspectorProfilerAgent.cpp +++ b/Source/WebCore/inspector/InspectorProfilerAgent.cpp @@ -48,7 +48,9 @@ #include "ScriptObject.h" #include "ScriptProfile.h" #include "ScriptProfiler.h" +#include "WebCoreMemoryInstrumentation.h" #include "WorkerScriptDebugServer.h" +#include <wtf/MemoryInstrumentationHashMap.h> #include <wtf/OwnPtr.h> #include <wtf/text/StringConcatenate.h> @@ -256,10 +258,10 @@ void InspectorProfilerAgent::getProfileHeaders(ErrorString*, RefPtr<TypeBuilder: ProfilesMap::iterator profilesEnd = m_profiles.end(); for (ProfilesMap::iterator it = m_profiles.begin(); it != profilesEnd; ++it) - headers->addItem(createProfileHeader(*it->second)); + headers->addItem(createProfileHeader(*it->value)); HeapSnapshotsMap::iterator snapshotsEnd = m_snapshots.end(); for (HeapSnapshotsMap::iterator it = m_snapshots.begin(); it != snapshotsEnd; ++it) - headers->addItem(createSnapshotHeader(*it->second)); + headers->addItem(createSnapshotHeader(*it->value)); } namespace { @@ -287,16 +289,16 @@ void InspectorProfilerAgent::getProfile(ErrorString* errorString, const String& return; } profileObject = TypeBuilder::Profiler::Profile::create(); - profileObject->setHead(it->second->buildInspectorObjectForHead()); - if (it->second->bottomUpHead()) - profileObject->setBottomUpHead(it->second->buildInspectorObjectForBottomUpHead()); + profileObject->setHead(it->value->buildInspectorObjectForHead()); + if (it->value->bottomUpHead()) + profileObject->setBottomUpHead(it->value->buildInspectorObjectForBottomUpHead()); } else if (type == HeapProfileType) { HeapSnapshotsMap::iterator it = m_snapshots.find(uid); if (it == m_snapshots.end()) { *errorString = "Profile wasn't found"; return; } - RefPtr<ScriptHeapSnapshot> snapshot = it->second; + RefPtr<ScriptHeapSnapshot> snapshot = it->value; profileObject = TypeBuilder::Profiler::Profile::create(); if (m_frontend) { OutputStream stream(m_frontend, uid); @@ -482,6 +484,19 @@ void InspectorProfilerAgent::getHeapObjectId(ErrorString* errorString, const Str *heapSnapshotObjectId = String::number(id); } +void InspectorProfilerAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorProfilerAgent); + InspectorBaseAgent<InspectorProfilerAgent>::reportMemoryUsage(memoryObjectInfo); + info.addMember(m_consoleAgent); + info.addMember(m_injectedScriptManager); + info.addMember(m_frontend); + info.addMember(m_profiles); + info.addMember(m_snapshots); + + info.addPrivateBuffer(ScriptProfiler::profilerSnapshotsSize()); +} + } // namespace WebCore #endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.h b/Source/WebCore/inspector/InspectorProfilerAgent.h index d548bbfa4..823b7e6f0 100644 --- a/Source/WebCore/inspector/InspectorProfilerAgent.h +++ b/Source/WebCore/inspector/InspectorProfilerAgent.h @@ -100,6 +100,8 @@ public: virtual void getObjectByHeapObjectId(ErrorString*, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result); virtual void getHeapObjectId(ErrorString*, const String& objectId, String* heapSnapshotObjectId); + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; + protected: InspectorProfilerAgent(InstrumentingAgents*, InspectorConsoleAgent*, InspectorState*, InjectedScriptManager*); virtual void startProfiling(const String& title) = 0; diff --git a/Source/WebCore/inspector/InspectorResourceAgent.cpp b/Source/WebCore/inspector/InspectorResourceAgent.cpp index 7defb3595..8d15b8e50 100644 --- a/Source/WebCore/inspector/InspectorResourceAgent.cpp +++ b/Source/WebCore/inspector/InspectorResourceAgent.cpp @@ -54,6 +54,7 @@ #include "NetworkResourcesData.h" #include "Page.h" #include "ProgressTracker.h" +#include "ResourceBuffer.h" #include "ResourceError.h" #include "ResourceLoader.h" #include "ResourceRequest.h" @@ -105,14 +106,14 @@ static PassRefPtr<InspectorObject> buildObjectForHeaders(const HTTPHeaderMap& he RefPtr<InspectorObject> headersObject = InspectorObject::create(); HTTPHeaderMap::const_iterator end = headers.end(); for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) - headersObject->setString(it->first.string(), it->second); + headersObject->setString(it->key.string(), it->value); return headersObject; } static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(const ResourceLoadTiming& timing, DocumentLoader* loader) { return TypeBuilder::Network::ResourceTiming::create() - .setRequestTime(timing.convertResourceLoadTimeToDocumentTime(loader->timing(), 0)) + .setRequestTime(loader->timing()->monotonicTimeToPseudoWallTime(timing.convertResourceLoadTimeToMonotonicTime(0))) .setProxyStart(timing.proxyStart) .setProxyEnd(timing.proxyEnd) .setDnsStart(timing.dnsStart) @@ -216,8 +217,8 @@ void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL InspectorObject::const_iterator end = headers->end(); for (InspectorObject::const_iterator it = headers->begin(); it != end; ++it) { String value; - if (it->second->asString(&value)) - request.setHTTPHeaderField(it->first, value); + if (it->value->asString(&value)) + request.setHTTPHeaderField(it->key, value); } } @@ -302,8 +303,10 @@ void InspectorResourceAgent::didReceiveData(unsigned long identifier, const char void InspectorResourceAgent::didFinishLoading(unsigned long identifier, DocumentLoader* loader, double finishTime) { String requestId = IdentifiersFactory::requestId(identifier); - if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::DocumentResource) - m_resourcesData->addResourceSharedBuffer(requestId, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding()); + if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::DocumentResource) { + RefPtr<ResourceBuffer> buffer = loader->frameLoader()->documentLoader()->mainResourceData(); + m_resourcesData->addResourceSharedBuffer(requestId, buffer ? buffer->sharedBuffer() : 0, loader->frame()->document()->inputEncoding()); + } m_resourcesData->maybeDecodeDataToContent(requestId); @@ -319,8 +322,10 @@ void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLo if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::DocumentResource) { Frame* frame = loader ? loader->frame() : 0; - if (frame && frame->loader()->documentLoader() && frame->document()) - m_resourcesData->addResourceSharedBuffer(requestId, frame->loader()->documentLoader()->mainResourceData(), frame->document()->inputEncoding()); + if (frame && frame->loader()->documentLoader() && frame->document()) { + RefPtr<ResourceBuffer> buffer = frame->loader()->documentLoader()->mainResourceData(); + m_resourcesData->addResourceSharedBuffer(requestId, buffer ? buffer->sharedBuffer() : 0, frame->document()->inputEncoding()); + } } bool canceled = error.isCancellation(); @@ -365,7 +370,7 @@ void InspectorResourceAgent::documentThreadableLoaderStartedLoadingForClient(uns if (it == m_pendingXHRReplayData.end()) return; - XHRReplayData* xhrReplayData = it->second.get(); + XHRReplayData* xhrReplayData = it->value.get(); String requestId = IdentifiersFactory::requestId(identifier); m_resourcesData->setXHRReplayData(requestId, xhrReplayData); } @@ -375,7 +380,7 @@ void InspectorResourceAgent::willLoadXHR(ThreadableLoaderClient* client, const S RefPtr<XHRReplayData> xhrReplayData = XHRReplayData::create(method, url, async, formData, includeCredentials); HTTPHeaderMap::const_iterator end = headers.end(); for (HTTPHeaderMap::const_iterator it = headers.begin(); it!= end; ++it) - xhrReplayData->addHeader(it->first, it->second); + xhrReplayData->addHeader(it->key, it->value); m_pendingXHRReplayData.set(client, xhrReplayData); } @@ -624,7 +629,7 @@ void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId) xhr->open(xhrReplayData->method(), xhrReplayData->url(), xhrReplayData->async(), code); HTTPHeaderMap::const_iterator end = xhrReplayData->headers().end(); for (HTTPHeaderMap::const_iterator it = xhrReplayData->headers().begin(); it!= end; ++it) - xhr->setRequestHeader(it->first, it->second, code); + xhr->setRequestHeader(it->key, it->value, code); xhr->sendFromInspector(xhrReplayData->formData(), code); } diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp index 7e4fd4b62..80be50c2a 100644 --- a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp @@ -58,6 +58,7 @@ static bool asBool(const bool* const b) InspectorRuntimeAgent::InspectorRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager) : InspectorBaseAgent<InspectorRuntimeAgent>("Runtime", instrumentingAgents, state) + , m_enabled(false) , m_injectedScriptManager(injectedScriptManager) #if ENABLE(JAVASCRIPT_DEBUGGER) , m_scriptDebugServer(0) @@ -135,7 +136,7 @@ void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const Strin } } -void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, const bool* const ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result) +void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, const bool* const ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& internalProperties) { InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); if (injectedScript.hasNoValue()) { @@ -149,6 +150,7 @@ void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String muteConsole(); injectedScript.getProperties(errorString, objectId, ownProperties ? *ownProperties : false, &result); + injectedScript.getInternalProperties(errorString, objectId, &internalProperties); unmuteConsole(); #if ENABLE(JAVASCRIPT_DEBUGGER) diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.h b/Source/WebCore/inspector/InspectorRuntimeAgent.h index f8e345e2b..29e57d22f 100644 --- a/Source/WebCore/inspector/InspectorRuntimeAgent.h +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.h @@ -57,7 +57,10 @@ class InspectorRuntimeAgent : public InspectorBaseAgent<InspectorRuntimeAgent>, public: virtual ~InspectorRuntimeAgent(); + bool enabled() { return m_enabled; } // Part of the protocol. + virtual void enable(ErrorString*) { m_enabled = true; } + virtual void disable(ErrorString*) { m_enabled = false; } virtual void evaluate(ErrorString*, const String& expression, const String* objectGroup, @@ -76,7 +79,7 @@ public: RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown); virtual void releaseObject(ErrorString*, const String& objectId); - virtual void getProperties(ErrorString*, const String& objectId, const bool* ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result); + virtual void getProperties(ErrorString*, const String& objectId, const bool* ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& internalProperties); virtual void releaseObjectGroup(ErrorString*, const String& objectGroup); virtual void run(ErrorString*); @@ -95,6 +98,7 @@ protected: virtual void unmuteConsole() = 0; InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; } + bool m_enabled; private: InjectedScriptManager* m_injectedScriptManager; diff --git a/Source/WebCore/inspector/InspectorState.cpp b/Source/WebCore/inspector/InspectorState.cpp index 70a243984..baf10c971 100644 --- a/Source/WebCore/inspector/InspectorState.cpp +++ b/Source/WebCore/inspector/InspectorState.cpp @@ -80,7 +80,7 @@ bool InspectorState::getBoolean(const String& propertyName) InspectorObject::iterator it = m_properties->find(propertyName); bool value = false; if (it != m_properties->end()) - it->second->asBoolean(&value); + it->value->asBoolean(&value); return value; } @@ -89,7 +89,7 @@ String InspectorState::getString(const String& propertyName) InspectorObject::iterator it = m_properties->find(propertyName); String value; if (it != m_properties->end()) - it->second->asString(&value); + it->value->asString(&value); return value; } @@ -98,7 +98,7 @@ long InspectorState::getLong(const String& propertyName) InspectorObject::iterator it = m_properties->find(propertyName); long value = 0; if (it != m_properties->end()) - it->second->asNumber(&value); + it->value->asNumber(&value); return value; } @@ -107,7 +107,7 @@ double InspectorState::getDouble(const String& propertyName) InspectorObject::iterator it = m_properties->find(propertyName); double value = 0; if (it != m_properties->end()) - it->second->asNumber(&value); + it->value->asNumber(&value); return value; } @@ -118,7 +118,7 @@ PassRefPtr<InspectorObject> InspectorState::getObject(const String& propertyName m_properties->setObject(propertyName, InspectorObject::create()); it = m_properties->find(propertyName); } - return it->second->asObject(); + return it->value->asObject(); } } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorStyleSheet.cpp b/Source/WebCore/inspector/InspectorStyleSheet.cpp index 5b94de6c1..cc3ccf8e6 100644 --- a/Source/WebCore/inspector/InspectorStyleSheet.cpp +++ b/Source/WebCore/inspector/InspectorStyleSheet.cpp @@ -497,6 +497,8 @@ PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con RefPtr<Array<TypeBuilder::CSS::ShorthandEntry> > shorthandEntries = Array<TypeBuilder::CSS::ShorthandEntry>::create(); HashMap<String, RefPtr<TypeBuilder::CSS::CSSProperty> > propertyNameToPreviousActiveProperty; HashSet<String> foundShorthands; + String previousPriority; + String previousStatus; for (Vector<InspectorStyleProperty>::iterator it = properties.begin(), itEnd = properties.end(); it != itEnd; ++it) { const CSSPropertySourceData& propertyEntry = it->sourceData; @@ -532,11 +534,20 @@ PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con String canonicalPropertyName = propertyId ? getPropertyNameString(propertyId) : name; HashMap<String, RefPtr<TypeBuilder::CSS::CSSProperty> >::iterator activeIt = propertyNameToPreviousActiveProperty.find(canonicalPropertyName); if (activeIt != propertyNameToPreviousActiveProperty.end()) { - if (propertyEntry.parsedOk) - shouldInactivate = true; - else { + if (propertyEntry.parsedOk) { + bool successPriority = activeIt->value->getString(TypeBuilder::CSS::CSSProperty::Priority, &previousPriority); + bool successStatus = activeIt->value->getString(TypeBuilder::CSS::CSSProperty::Status, &previousStatus); + if (successStatus && previousStatus != "inactive") { + if (propertyEntry.important || !successPriority) // Priority not set == "not important". + shouldInactivate = true; + else if (status == TypeBuilder::CSS::CSSProperty::Status::Active) { + // Inactivate a non-important property following the same-named important property. + status = TypeBuilder::CSS::CSSProperty::Status::Inactive; + } + } + } else { bool previousParsedOk; - bool success = activeIt->second->getBoolean(TypeBuilder::CSS::CSSProperty::ParsedOk, &previousParsedOk); + bool success = activeIt->value->getBoolean(TypeBuilder::CSS::CSSProperty::ParsedOk, &previousParsedOk); if (success && !previousParsedOk) shouldInactivate = true; } @@ -544,7 +555,7 @@ PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con propertyNameToPreviousActiveProperty.set(canonicalPropertyName, property); if (shouldInactivate) { - activeIt->second->setStatus(TypeBuilder::CSS::CSSProperty::Status::Inactive); + activeIt->value->setStatus(TypeBuilder::CSS::CSSProperty::Status::Inactive); propertyNameToPreviousActiveProperty.set(canonicalPropertyName, property); } } else { @@ -1057,7 +1068,7 @@ PassRefPtr<InspectorStyle> InspectorStyleSheet::inspectorStyleForId(const Inspec RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(id, style, this); return inspectorStyle.release(); } - return it->second; + return it->value; } void InspectorStyleSheet::rememberInspectorStyle(RefPtr<InspectorStyle> inspectorStyle) diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.cpp b/Source/WebCore/inspector/InspectorTimelineAgent.cpp index a994cdd11..1a2281529 100644 --- a/Source/WebCore/inspector/InspectorTimelineAgent.cpp +++ b/Source/WebCore/inspector/InspectorTimelineAgent.cpp @@ -234,8 +234,6 @@ void InspectorTimelineAgent::didDispatchEvent() void InspectorTimelineAgent::didInvalidateLayout(Frame* frame) { - if (frame->view()->layoutPending()) - return; appendRecord(InspectorObject::create(), TimelineRecordType::InvalidateLayout, true, frame); } diff --git a/Source/WebCore/inspector/InspectorValues.cpp b/Source/WebCore/inspector/InspectorValues.cpp index e4ead17e5..ada2617cc 100644 --- a/Source/WebCore/inspector/InspectorValues.cpp +++ b/Source/WebCore/inspector/InspectorValues.cpp @@ -717,7 +717,7 @@ PassRefPtr<InspectorValue> InspectorObjectBase::get(const String& name) const Dictionary::const_iterator it = m_data.find(name); if (it == m_data.end()) return 0; - return it->second; + return it->value; } void InspectorObjectBase::remove(const String& name) @@ -739,9 +739,9 @@ void InspectorObjectBase::writeJSON(StringBuilder* output) const ASSERT(it != m_data.end()); if (i) output->append(','); - doubleQuoteString(it->first, output); + doubleQuoteString(it->key, output); output->append(':'); - it->second->writeJSON(output); + it->value->writeJSON(output); } output->append('}'); } diff --git a/Source/WebCore/inspector/InspectorWorkerAgent.cpp b/Source/WebCore/inspector/InspectorWorkerAgent.cpp index 1b7cedbc3..e90f7cb4b 100644 --- a/Source/WebCore/inspector/InspectorWorkerAgent.cpp +++ b/Source/WebCore/inspector/InspectorWorkerAgent.cpp @@ -205,9 +205,9 @@ void InspectorWorkerAgent::workerContextTerminated(WorkerContextProxy* proxy) { m_dedicatedWorkers.remove(proxy); for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) { - if (proxy == it->second->proxy()) { - m_inspectorFrontend->worker()->workerTerminated(it->first); - delete it->second; + if (proxy == it->value->proxy()) { + m_inspectorFrontend->worker()->workerTerminated(it->key); + delete it->value; m_idToChannel.remove(it); return; } @@ -217,14 +217,14 @@ void InspectorWorkerAgent::workerContextTerminated(WorkerContextProxy* proxy) void InspectorWorkerAgent::createWorkerFrontendChannelsForExistingWorkers() { for (DedicatedWorkers::iterator it = m_dedicatedWorkers.begin(); it != m_dedicatedWorkers.end(); ++it) - createWorkerFrontendChannel(it->first, it->second); + createWorkerFrontendChannel(it->key, it->value); } void InspectorWorkerAgent::destroyWorkerFrontendChannels() { for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) { - it->second->disconnectFromWorkerContext(); - delete it->second; + it->value->disconnectFromWorkerContext(); + delete it->value; } m_idToChannel.clear(); } diff --git a/Source/WebCore/inspector/JavaScriptCallFrame.idl b/Source/WebCore/inspector/JavaScriptCallFrame.idl index d373d5d82..17011e492 100644 --- a/Source/WebCore/inspector/JavaScriptCallFrame.idl +++ b/Source/WebCore/inspector/JavaScriptCallFrame.idl @@ -23,33 +23,30 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -module inspector { +[ + Conditional=JAVASCRIPT_DEBUGGER, + OmitConstructor, + DoNotCheckConstants +] interface JavaScriptCallFrame { - interface [ - Conditional=JAVASCRIPT_DEBUGGER, - OmitConstructor, - DoNotCheckConstants - ] JavaScriptCallFrame { + // Scope type + const unsigned short GLOBAL_SCOPE = 0; + const unsigned short LOCAL_SCOPE = 1; + const unsigned short WITH_SCOPE = 2; + const unsigned short CLOSURE_SCOPE = 3; + const unsigned short CATCH_SCOPE = 4; - // Scope type - const unsigned short GLOBAL_SCOPE = 0; - const unsigned short LOCAL_SCOPE = 1; - const unsigned short WITH_SCOPE = 2; - const unsigned short CLOSURE_SCOPE = 3; - const unsigned short CATCH_SCOPE = 4; + [Custom] void evaluate(in DOMString script); + [Custom] DOMObject restart(); - [Custom] void evaluate(in DOMString script); - [Custom] DOMObject restart(); + readonly attribute JavaScriptCallFrame caller; + readonly attribute long sourceID; + readonly attribute long line; + readonly attribute long column; + [CustomGetter] readonly attribute Array scopeChain; + [Custom] unsigned short scopeType(in int scopeIndex); + [CustomGetter] readonly attribute Object thisObject; + readonly attribute DOMString functionName; + [CustomGetter] readonly attribute DOMString type; +}; - readonly attribute JavaScriptCallFrame caller; - readonly attribute long sourceID; - readonly attribute long line; - readonly attribute long column; - readonly attribute [CustomGetter] Array scopeChain; - [Custom] unsigned short scopeType(in int scopeIndex); - readonly attribute [CustomGetter] Object thisObject; - readonly attribute DOMString functionName; - readonly attribute [CustomGetter] DOMString type; - }; - -} diff --git a/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp b/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp index 946888ce2..e93d66f4f 100644 --- a/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp +++ b/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp @@ -34,11 +34,63 @@ #include "MemoryInstrumentationImpl.h" +#include "WebCoreMemoryInstrumentation.h" +#include <wtf/Assertions.h> +#include <wtf/MemoryInstrumentationHashMap.h> +#include <wtf/MemoryInstrumentationHashSet.h> +#include <wtf/MemoryInstrumentationVector.h> +#include <wtf/text/StringHash.h> + namespace WebCore { -MemoryInstrumentationImpl::MemoryInstrumentationImpl(VisitedObjects& visitedObjects) - : m_visitedObjects(visitedObjects) +TypeNameToSizeMap MemoryInstrumentationClientImpl::sizesMap() const { + // TypeToSizeMap uses const char* as the key. + // Thus it could happen that we have two different keys with equal string. + TypeNameToSizeMap sizesMap; + for (TypeToSizeMap::const_iterator i = m_totalSizes.begin(); i != m_totalSizes.end(); ++i) { + String objectType(i->key); + TypeNameToSizeMap::AddResult result = sizesMap.add(objectType, i->value); + if (!result.isNewEntry) + result.iterator->value += i->value; + } + + return sizesMap; +} + +void MemoryInstrumentationClientImpl::countObjectSize(MemoryObjectType objectType, size_t size) +{ + ASSERT(objectType); + TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size); + if (!result.isNewEntry) + result.iterator->value += size; + ++m_totalCountedObjects; +} + +bool MemoryInstrumentationClientImpl::visited(const void* object) +{ + return !m_visitedObjects.add(object).isNewEntry; +} + +void MemoryInstrumentationClientImpl::checkCountedObject(const void* object) +{ + if (!checkInstrumentedObjects()) + return; + if (!m_allocatedObjects.contains(object)) { + ++m_totalObjectsNotInAllocatedSet; +#if 0 + printf("Found unknown object referenced by pointer: %p\n", object); + WTFReportBacktrace(); +#endif + } +} + +void MemoryInstrumentationClientImpl::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorMemoryAgent); + info.addMember(m_totalSizes); + info.addMember(m_visitedObjects); + info.addMember(m_allocatedObjects); } void MemoryInstrumentationImpl::processDeferredInstrumentedPointers() @@ -50,28 +102,17 @@ void MemoryInstrumentationImpl::processDeferredInstrumentedPointers() } } -void MemoryInstrumentationImpl::countObjectSize(MemoryObjectType objectType, size_t size) -{ - ASSERT(objectType); - TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size); - if (!result.isNewEntry) - result.iterator->second += size; -} - void MemoryInstrumentationImpl::deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase> pointer) { m_deferredInstrumentedPointers.append(pointer); } -bool MemoryInstrumentationImpl::visited(const void* object) +void MemoryInstrumentationImpl::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - return !m_visitedObjects.add(object).isNewEntry; + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorMemoryAgent); + info.addMember(m_deferredInstrumentedPointers); } -size_t MemoryInstrumentationImpl::selfSize() const -{ - return calculateContainerSize(m_visitedObjects) + calculateContainerSize(m_deferredInstrumentedPointers); -} } // namespace WebCore diff --git a/Source/WebCore/inspector/MemoryInstrumentationImpl.h b/Source/WebCore/inspector/MemoryInstrumentationImpl.h index 8a2aee5e0..8af8d60c5 100644 --- a/Source/WebCore/inspector/MemoryInstrumentationImpl.h +++ b/Source/WebCore/inspector/MemoryInstrumentationImpl.h @@ -37,41 +37,74 @@ #include <wtf/HashSet.h> #include <wtf/MemoryInstrumentation.h> #include <wtf/Vector.h> +#include <wtf/text/StringHash.h> using WTF::MemoryObjectType; namespace WebCore { typedef HashSet<const void*> VisitedObjects; +typedef HashMap<String, size_t> TypeNameToSizeMap; -class MemoryInstrumentationImpl : public WTF::MemoryInstrumentation { +class MemoryInstrumentationClientImpl : public WTF::MemoryInstrumentationClient { public: - explicit MemoryInstrumentationImpl(VisitedObjects&); + MemoryInstrumentationClientImpl() + : m_totalCountedObjects(0) + , m_totalObjectsNotInAllocatedSet(0) + { } - size_t selfSize() const; size_t totalSize(MemoryObjectType objectType) const { TypeToSizeMap::const_iterator i = m_totalSizes.find(objectType); - return i == m_totalSizes.end() ? 0 : i->second; + return i == m_totalSizes.end() ? 0 : i->value; } size_t reportedSizeForAllTypes() const { size_t size = 0; for (TypeToSizeMap::const_iterator i = m_totalSizes.begin(); i != m_totalSizes.end(); ++i) - size += i->second; + size += i->value; return size; } -private: + TypeNameToSizeMap sizesMap() const; + VisitedObjects& allocatedObjects() { return m_allocatedObjects; } + + bool checkInstrumentedObjects() const { return !m_allocatedObjects.isEmpty(); } + size_t visitedObjects() const { return m_visitedObjects.size(); } + size_t totalCountedObjects() const { return m_totalCountedObjects; } + size_t totalObjectsNotInAllocatedSet() const { return m_totalObjectsNotInAllocatedSet; } + virtual void countObjectSize(MemoryObjectType, size_t) OVERRIDE; - virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) OVERRIDE; virtual bool visited(const void*) OVERRIDE; - virtual void processDeferredInstrumentedPointers() OVERRIDE; + virtual void checkCountedObject(const void*) OVERRIDE; + + void reportMemoryUsage(MemoryObjectInfo*) const; +private: typedef HashMap<MemoryObjectType, size_t> TypeToSizeMap; TypeToSizeMap m_totalSizes; - VisitedObjects& m_visitedObjects; + VisitedObjects m_visitedObjects; + VisitedObjects m_allocatedObjects; + size_t m_totalCountedObjects; + size_t m_totalObjectsNotInAllocatedSet; +}; + +class MemoryInstrumentationImpl : public WTF::MemoryInstrumentation { +public: + explicit MemoryInstrumentationImpl(WTF::MemoryInstrumentationClient* client) + : MemoryInstrumentation(client) + { + } + + size_t selfSize() const; + + void reportMemoryUsage(MemoryObjectInfo*) const; + +private: + virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) OVERRIDE; + virtual void processDeferredInstrumentedPointers() OVERRIDE; + Vector<OwnPtr<InstrumentedPointerBase> > m_deferredInstrumentedPointers; }; diff --git a/Source/WebCore/inspector/NetworkResourcesData.cpp b/Source/WebCore/inspector/NetworkResourcesData.cpp index 4198fb51d..788ebea55 100644 --- a/Source/WebCore/inspector/NetworkResourcesData.cpp +++ b/Source/WebCore/inspector/NetworkResourcesData.cpp @@ -291,8 +291,8 @@ void NetworkResourcesData::setXHRReplayData(const String& requestId, XHRReplayDa ReusedRequestIds::iterator it; ReusedRequestIds::iterator end = m_reusedXHRReplayDataRequestIds.end(); for (it = m_reusedXHRReplayDataRequestIds.begin(); it != end; ++it) { - if (it->second == requestId) - setXHRReplayData(it->first, xhrReplayData); + if (it->value == requestId) + setXHRReplayData(it->key, xhrReplayData); } return; } @@ -318,10 +318,10 @@ Vector<String> NetworkResourcesData::removeCachedResource(CachedResource* cached ResourceDataMap::iterator it; ResourceDataMap::iterator end = m_requestIdToResourceDataMap.end(); for (it = m_requestIdToResourceDataMap.begin(); it != end; ++it) { - ResourceData* resourceData = it->second; + ResourceData* resourceData = it->value; if (resourceData->cachedResource() == cachedResource) { resourceData->setCachedResource(0); - result.append(it->first); + result.append(it->key); } } @@ -338,9 +338,9 @@ void NetworkResourcesData::clear(const String& preservedLoaderId) ResourceDataMap::iterator it; ResourceDataMap::iterator end = m_requestIdToResourceDataMap.end(); for (it = m_requestIdToResourceDataMap.begin(); it != end; ++it) { - ResourceData* resourceData = it->second; + ResourceData* resourceData = it->value; if (!preservedLoaderId.isNull() && resourceData->loaderId() == preservedLoaderId) - preservedMap.set(it->first, it->second); + preservedMap.set(it->key, it->value); else delete resourceData; } diff --git a/Source/WebCore/inspector/PageRuntimeAgent.cpp b/Source/WebCore/inspector/PageRuntimeAgent.cpp index 254957a7f..74c3b7ff9 100644 --- a/Source/WebCore/inspector/PageRuntimeAgent.cpp +++ b/Source/WebCore/inspector/PageRuntimeAgent.cpp @@ -50,7 +50,7 @@ using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; namespace WebCore { namespace PageRuntimeAgentState { -static const char reportExecutionContextCreation[] = "reportExecutionContextCreation"; +static const char runtimeEnabled[] = "runtimeEnabled"; }; PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent, InspectorAgent* inspectorAgent) @@ -76,47 +76,44 @@ void PageRuntimeAgent::clearFrontend() { m_instrumentingAgents->setPageRuntimeAgent(0); m_frontend = 0; - m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, false); + String errorString; + disable(&errorString); } void PageRuntimeAgent::restore() { - if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation)) + if (m_state->getBoolean(PageRuntimeAgentState::runtimeEnabled)) { + String error; + enable(&error); + } +} + +void PageRuntimeAgent::enable(ErrorString* errorString) +{ + if (m_enabled) return; + + InspectorRuntimeAgent::enable(errorString); + m_state->setBoolean(PageRuntimeAgentState::runtimeEnabled, true); // Only report existing contexts if the page did commit load, otherwise we may // unintentionally initialize contexts in the frames which may trigger some listeners // that are expected to be triggered only after the load is committed, see http://crbug.com/131623 - if (m_inspectorAgent->didCommitLoadFired()) { - String error; - setReportExecutionContextCreation(&error, true); - } + if (m_inspectorAgent->didCommitLoadFired()) + reportExecutionContextCreation(); } -void PageRuntimeAgent::setReportExecutionContextCreation(ErrorString*, bool enable) +void PageRuntimeAgent::disable(ErrorString* errorString) { - m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, enable); - if (!enable) + if (!m_enabled) return; - Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; - for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) { - if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) - continue; - String frameId = m_pageAgent->frameId(frame); - ScriptState* scriptState = mainWorldScriptState(frame); - notifyContextCreated(frameId, scriptState, 0, true); - frame->script()->collectIsolatedContexts(isolatedContexts); - if (isolatedContexts.isEmpty()) - continue; - for (size_t i = 0; i< isolatedContexts.size(); i++) - notifyContextCreated(frameId, isolatedContexts[i].first, isolatedContexts[i].second, false); - isolatedContexts.clear(); - } + InspectorRuntimeAgent::disable(errorString); + m_state->setBoolean(PageRuntimeAgentState::runtimeEnabled, false); } void PageRuntimeAgent::didClearWindowObject(Frame* frame) { - if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation)) + if (!m_enabled) return; ASSERT(m_frontend); String frameId = m_pageAgent->frameId(frame); @@ -126,7 +123,7 @@ void PageRuntimeAgent::didClearWindowObject(Frame* frame) void PageRuntimeAgent::didCreateIsolatedContext(Frame* frame, ScriptState* scriptState, SecurityOrigin* origin) { - if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation)) + if (!m_enabled) return; ASSERT(m_frontend); String frameId = m_pageAgent->frameId(frame); @@ -155,6 +152,25 @@ void PageRuntimeAgent::unmuteConsole() Console::unmute(); } +void PageRuntimeAgent::reportExecutionContextCreation() +{ + Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; + for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) + continue; + String frameId = m_pageAgent->frameId(frame); + + ScriptState* scriptState = mainWorldScriptState(frame); + notifyContextCreated(frameId, scriptState, 0, true); + frame->script()->collectIsolatedContexts(isolatedContexts); + if (isolatedContexts.isEmpty()) + continue; + for (size_t i = 0; i< isolatedContexts.size(); i++) + notifyContextCreated(frameId, isolatedContexts[i].first, isolatedContexts[i].second, false); + isolatedContexts.clear(); + } +} + void PageRuntimeAgent::notifyContextCreated(const String& frameId, ScriptState* scriptState, SecurityOrigin* securityOrigin, bool isPageContext) { ASSERT(securityOrigin || isPageContext); diff --git a/Source/WebCore/inspector/PageRuntimeAgent.h b/Source/WebCore/inspector/PageRuntimeAgent.h index 9c92d807a..5278aa737 100644 --- a/Source/WebCore/inspector/PageRuntimeAgent.h +++ b/Source/WebCore/inspector/PageRuntimeAgent.h @@ -55,7 +55,8 @@ public: virtual void setFrontend(InspectorFrontend*); virtual void clearFrontend(); virtual void restore(); - virtual void setReportExecutionContextCreation(ErrorString*, bool); + virtual void enable(ErrorString*); + virtual void disable(ErrorString*); void didClearWindowObject(Frame*); void didCreateIsolatedContext(Frame*, ScriptState*, SecurityOrigin*); @@ -66,6 +67,7 @@ private: virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId); virtual void muteConsole(); virtual void unmuteConsole(); + void reportExecutionContextCreation(); void notifyContextCreated(const String& frameId, ScriptState*, SecurityOrigin*, bool isPageContext); Page* m_inspectedPage; diff --git a/Source/WebCore/inspector/ScriptProfile.idl b/Source/WebCore/inspector/ScriptProfile.idl index ebbee2e8e..46c0e99c3 100644 --- a/Source/WebCore/inspector/ScriptProfile.idl +++ b/Source/WebCore/inspector/ScriptProfile.idl @@ -24,16 +24,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -module core { +[ + Conditional=JAVASCRIPT_DEBUGGER, + OmitConstructor, + V8CustomToJSObject +] interface ScriptProfile { + readonly attribute DOMString title; + readonly attribute unsigned long uid; + readonly attribute ScriptProfileNode head; +}; - interface [ - Conditional=JAVASCRIPT_DEBUGGER, - OmitConstructor, - V8CustomToJSObject - ] ScriptProfile { - readonly attribute DOMString title; - readonly attribute unsigned long uid; - readonly attribute ScriptProfileNode head; - }; - -} diff --git a/Source/WebCore/inspector/ScriptProfileNode.idl b/Source/WebCore/inspector/ScriptProfileNode.idl index a14798c05..3b28b8867 100644 --- a/Source/WebCore/inspector/ScriptProfileNode.idl +++ b/Source/WebCore/inspector/ScriptProfileNode.idl @@ -24,22 +24,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -module core { +[ + Conditional=JAVASCRIPT_DEBUGGER, + OmitConstructor, + V8CustomToJSObject +] interface ScriptProfileNode { + readonly attribute DOMString functionName; + readonly attribute DOMString url; + readonly attribute unsigned long lineNumber; + readonly attribute double totalTime; + readonly attribute double selfTime; + readonly attribute unsigned long numberOfCalls; + sequence<ScriptProfileNode> children(); + readonly attribute boolean visible; + [CustomGetter] readonly attribute unsigned long callUID; +}; - interface [ - Conditional=JAVASCRIPT_DEBUGGER, - OmitConstructor, - V8CustomToJSObject - ] ScriptProfileNode { - readonly attribute DOMString functionName; - readonly attribute DOMString url; - readonly attribute unsigned long lineNumber; - readonly attribute double totalTime; - readonly attribute double selfTime; - readonly attribute unsigned long numberOfCalls; - sequence<ScriptProfileNode> children(); - readonly attribute boolean visible; - readonly attribute [CustomGetter] unsigned long callUID; - }; - -} diff --git a/Source/WebCore/inspector/WorkerRuntimeAgent.cpp b/Source/WebCore/inspector/WorkerRuntimeAgent.cpp index 30c077001..d74e2acfb 100644 --- a/Source/WebCore/inspector/WorkerRuntimeAgent.cpp +++ b/Source/WebCore/inspector/WorkerRuntimeAgent.cpp @@ -49,11 +49,6 @@ WorkerRuntimeAgent::~WorkerRuntimeAgent() { } -void WorkerRuntimeAgent::setReportExecutionContextCreation(ErrorString* error, bool) -{ - *error = "Isolated contexts are not supported for workers."; -} - InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, const int* executionContextId) { if (executionContextId) { diff --git a/Source/WebCore/inspector/WorkerRuntimeAgent.h b/Source/WebCore/inspector/WorkerRuntimeAgent.h index 6311093bf..9f1997b74 100644 --- a/Source/WebCore/inspector/WorkerRuntimeAgent.h +++ b/Source/WebCore/inspector/WorkerRuntimeAgent.h @@ -47,7 +47,6 @@ public: return adoptPtr(new WorkerRuntimeAgent(instrumentingAgents, state, injectedScriptManager, context)); } virtual ~WorkerRuntimeAgent(); - virtual void setReportExecutionContextCreation(ErrorString*, bool); private: WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*); diff --git a/Source/WebCore/inspector/compile-front-end.py b/Source/WebCore/inspector/compile-front-end.py index 76dcaef34..a7b42f12e 100755 --- a/Source/WebCore/inspector/compile-front-end.py +++ b/Source/WebCore/inspector/compile-front-end.py @@ -46,8 +46,10 @@ modules = [ "dependencies": [], "sources": [ "Color.js", + "DOMExtension.js", "Object.js", "ParsedURL.js", + "Progress.js", "Settings.js", "UIString.js", "UserMetrics.js", @@ -84,6 +86,7 @@ modules = [ "NetworkLog.js", "NetworkUISourceCodeProvider.js", "PresentationConsoleMessageHelper.js", + "RuntimeModel.js", "SASSSourceMapping.js", "Script.js", "ScriptFormatter.js", @@ -113,7 +116,6 @@ modules = [ "sources": [ "Checkbox.js", "ContextMenu.js", - "DOMExtension.js", "DOMSyntaxHighlighter.js", "DataGrid.js", "DefaultTextEditor.js", @@ -128,7 +130,7 @@ modules = [ "PanelEnablerView.js", "Placard.js", "Popover.js", - "ProgressBar.js", + "ProgressIndicator.js", "PropertiesSection.js", "SearchController.js", "Section.js", @@ -170,7 +172,6 @@ modules = [ "NativeBreakpointsSidebarPane.js", "ObjectPopoverHelper.js", "ObjectPropertiesSection.js", - "RuntimeModel.js", "SourceFrame.js", "ResourceView.js", ] @@ -224,9 +225,16 @@ modules = [ ] }, { - "name": "scripts", + "name": "workers", "dependencies": ["components"], "sources": [ + "WorkerManager.js", + ] + }, + { + "name": "scripts", + "dependencies": ["components", "workers"], + "sources": [ "BreakpointsSidebarPane.js", "CallStackSidebarPane.js", "FilteredItemSelectionDialog.js", @@ -299,13 +307,6 @@ modules = [ ] }, { - "name": "workers", - "dependencies": ["components"], - "sources": [ - "WorkerManager.js", - ] - }, - { "name": "tests", "dependencies": ["components"], "sources": [ @@ -339,9 +340,17 @@ modules = [ "name": "host_stub", "dependencies": ["ui"], "sources": [ + "InspectorFrontendAPI.js", "InspectorFrontendHostStub.js", ] }, + { + "name": "inspector", + "dependencies": ["components"], + "sources": [ + "DockController.js", + ] + }, ] modules_by_name = {} diff --git a/Source/WebCore/inspector/front-end/AdvancedSearchController.js b/Source/WebCore/inspector/front-end/AdvancedSearchController.js index b500a663b..9dfa78cd5 100644 --- a/Source/WebCore/inspector/front-end/AdvancedSearchController.js +++ b/Source/WebCore/inspector/front-end/AdvancedSearchController.js @@ -222,8 +222,6 @@ WebInspector.SearchView = function(controller) WebInspector.SearchView.maxQueriesCount = 20; WebInspector.SearchView.prototype = { - __proto__: WebInspector.View.prototype, - /** * @return {Array.<Element>} */ @@ -387,10 +385,11 @@ WebInspector.SearchView.prototype = { this._save(); this._controller.startSearch(this.searchConfig); - } + }, + + __proto__: WebInspector.View.prototype } -//WebInspector.SearchView.prototype.__proto__ = WebInspector.View.prototype; /** * @constructor @@ -667,10 +666,10 @@ WebInspector.FileBasedSearchResultsPane.prototype = { contentSpan.textContent = lineContent; WebInspector.highlightRangesWithStyleClass(contentSpan, matchRanges, "highlighted-match"); return contentSpan; - } -} + }, -WebInspector.FileBasedSearchResultsPane.prototype.__proto__ = WebInspector.SearchResultsPane.prototype; + __proto__: WebInspector.SearchResultsPane.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js b/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js index f46928db7..d59447070 100644 --- a/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js +++ b/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js @@ -271,6 +271,7 @@ WebInspector.ApplicationCacheItemsView.prototype = { // InspectorBackend.deleteCachedResource(...) // this._update(); }, + + __proto__: WebInspector.View.prototype } -WebInspector.ApplicationCacheItemsView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/Source/WebCore/inspector/front-end/ApplicationCacheModel.js b/Source/WebCore/inspector/front-end/ApplicationCacheModel.js index 9b8f2b00b..b5529a666 100644 --- a/Source/WebCore/inspector/front-end/ApplicationCacheModel.js +++ b/Source/WebCore/inspector/front-end/ApplicationCacheModel.js @@ -218,10 +218,10 @@ WebInspector.ApplicationCacheModel.prototype = { { this._onLine = isNowOnline; this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.EventTypes.NetworkStateChanged, isNowOnline); - } -} + }, -WebInspector.ApplicationCacheModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/AuditCategories.js b/Source/WebCore/inspector/front-end/AuditCategories.js index b32b418d0..ffd3f6342 100644 --- a/Source/WebCore/inspector/front-end/AuditCategories.js +++ b/Source/WebCore/inspector/front-end/AuditCategories.js @@ -45,10 +45,10 @@ WebInspector.AuditCategories.PagePerformance.prototype = { this.addRule(new WebInspector.AuditRules.CssInHeadRule(), WebInspector.AuditRule.Severity.Severe); this.addRule(new WebInspector.AuditRules.StylesScriptsOrderRule(), WebInspector.AuditRule.Severity.Severe); this.addRule(new WebInspector.AuditRules.VendorPrefixedCSSProperties(), WebInspector.AuditRule.Severity.Warning); - } -} + }, -WebInspector.AuditCategories.PagePerformance.prototype.__proto__ = WebInspector.AuditCategory.prototype; + __proto__: WebInspector.AuditCategory.prototype +} /** * @constructor @@ -73,7 +73,7 @@ WebInspector.AuditCategories.NetworkUtilization.prototype = { this.addRule(new WebInspector.AuditRules.ParallelizeDownloadRule(4, 10, 0.5), WebInspector.AuditRule.Severity.Warning); this.addRule(new WebInspector.AuditRules.BrowserCacheControlRule(), WebInspector.AuditRule.Severity.Severe); this.addRule(new WebInspector.AuditRules.ProxyCacheControlRule(), WebInspector.AuditRule.Severity.Warning); - } -} + }, -WebInspector.AuditCategories.NetworkUtilization.prototype.__proto__ = WebInspector.AuditCategory.prototype; + __proto__: WebInspector.AuditCategory.prototype +} diff --git a/Source/WebCore/inspector/front-end/AuditLauncherView.js b/Source/WebCore/inspector/front-end/AuditLauncherView.js index 97d088653..2939f1b21 100644 --- a/Source/WebCore/inspector/front-end/AuditLauncherView.js +++ b/Source/WebCore/inspector/front-end/AuditLauncherView.js @@ -249,7 +249,7 @@ WebInspector.AuditLauncherView.prototype = { { this._launchButton.textContent = this._auditRunning ? WebInspector.UIString("Stop") : WebInspector.UIString("Run"); this._launchButton.disabled = !this._currentCategoriesCount; - } -} + }, -WebInspector.AuditLauncherView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/AuditResultView.js b/Source/WebCore/inspector/front-end/AuditResultView.js index 4cfc43168..dbd7a89c7 100644 --- a/Source/WebCore/inspector/front-end/AuditResultView.js +++ b/Source/WebCore/inspector/front-end/AuditResultView.js @@ -46,10 +46,9 @@ WebInspector.AuditResultView = function(categoryResults) } WebInspector.AuditResultView.prototype = { + __proto__: WebInspector.View.prototype } -WebInspector.AuditResultView.prototype.__proto__ = WebInspector.View.prototype; - /** * @constructor * @extends {WebInspector.SidebarPane} @@ -118,7 +117,7 @@ WebInspector.AuditCategoryResultPane.prototype = { treeElement.expand(); } return treeElement; - } -} + }, -WebInspector.AuditCategoryResultPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/AuditRules.js b/Source/WebCore/inspector/front-end/AuditRules.js index 14b59ac47..383482f5b 100644 --- a/Source/WebCore/inspector/front-end/AuditRules.js +++ b/Source/WebCore/inspector/front-end/AuditRules.js @@ -120,10 +120,10 @@ WebInspector.AuditRules.GzipRule.prototype = { _shouldCompress: function(request) { return request.type.isTextType() && request.parsedURL.host && request.resourceSize !== undefined && request.resourceSize > 150; - } -} + }, -WebInspector.AuditRules.GzipRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -164,10 +164,10 @@ WebInspector.AuditRules.CombineExternalResourcesRule.prototype = { summary.value = "There are multiple resources served from same domain. Consider combining them into as few files as possible."; callback(result); - } -} + }, -WebInspector.AuditRules.CombineExternalResourcesRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -177,7 +177,9 @@ WebInspector.AuditRules.CombineJsResourcesRule = function(allowedPerDomain) { WebInspector.AuditRules.CombineExternalResourcesRule.call(this, "page-externaljs", "Combine external JavaScript", WebInspector.resourceTypes.Script, "JavaScript", allowedPerDomain); } -WebInspector.AuditRules.CombineJsResourcesRule.prototype.__proto__ = WebInspector.AuditRules.CombineExternalResourcesRule.prototype; +WebInspector.AuditRules.CombineJsResourcesRule.prototype = { + __proto__: WebInspector.AuditRules.CombineExternalResourcesRule.prototype +} /** * @constructor @@ -187,7 +189,9 @@ WebInspector.AuditRules.CombineCssResourcesRule = function(allowedPerDomain) { WebInspector.AuditRules.CombineExternalResourcesRule.call(this, "page-externalcss", "Combine external CSS", WebInspector.resourceTypes.Stylesheet, "CSS", allowedPerDomain); } -WebInspector.AuditRules.CombineCssResourcesRule.prototype.__proto__ = WebInspector.AuditRules.CombineExternalResourcesRule.prototype; +WebInspector.AuditRules.CombineCssResourcesRule.prototype = { + __proto__: WebInspector.AuditRules.CombineExternalResourcesRule.prototype +} /** * @constructor @@ -225,10 +229,10 @@ WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype = { summary.value = "The following domains only serve one resource each. If possible, avoid the extra DNS lookups by serving these resources from existing domains."; callback(result); - } -} + }, -WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -301,10 +305,10 @@ WebInspector.AuditRules.ParallelizeDownloadRule.prototype = { result.violationCount = requestsOnBusiestHost.length; callback(result); - } -} + }, -WebInspector.AuditRules.ParallelizeDownloadRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * The reported CSS rule size is incorrect (parsed != original in WebKit), @@ -453,10 +457,10 @@ WebInspector.AuditRules.UnusedCssRule.prototype = { } CSSAgent.getAllStyleSheets(allStylesCallback); - } -} + }, -WebInspector.AuditRules.UnusedCssRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -599,10 +603,10 @@ WebInspector.AuditRules.CacheControlRule.prototype = { isCacheableResource: function(request) { return request.statusCode !== undefined && WebInspector.AuditRules.CacheableResponseCodes[request.statusCode]; - } -} + }, -WebInspector.AuditRules.CacheControlRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -668,10 +672,10 @@ WebInspector.AuditRules.BrowserCacheControlRule.prototype = { !this.hasResponseHeader(request, "Set-Cookie") && !this.freshnessLifetimeGreaterThan(request, 11 * WebInspector.AuditRules.CacheControlRule.MillisPerMonth) && this.freshnessLifetimeGreaterThan(request, WebInspector.AuditRules.CacheControlRule.MillisPerMonth); - } -} + }, -WebInspector.AuditRules.BrowserCacheControlRule.prototype.__proto__ = WebInspector.AuditRules.CacheControlRule.prototype; + __proto__: WebInspector.AuditRules.CacheControlRule.prototype +} /** * @constructor @@ -708,10 +712,10 @@ WebInspector.AuditRules.ProxyCacheControlRule.prototype = { _setCookieCacheableCheck: function(request) { return this.hasResponseHeader(request, "Set-Cookie") && this.isPubliclyCacheable(request); - } -} + }, -WebInspector.AuditRules.ProxyCacheControlRule.prototype.__proto__ = WebInspector.AuditRules.CacheControlRule.prototype; + __proto__: WebInspector.AuditRules.CacheControlRule.prototype +} /** * @constructor @@ -840,10 +844,10 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = { if (progress.isCanceled()) return; WebInspector.domAgent.requestDocument(onDocumentAvailable); - } -} + }, -WebInspector.AuditRules.ImageDimensionsRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -930,10 +934,10 @@ WebInspector.AuditRules.CssInHeadRule.prototype = { } WebInspector.domAgent.requestDocument(onDocumentAvailable); - } -} + }, -WebInspector.AuditRules.CssInHeadRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -1018,10 +1022,10 @@ WebInspector.AuditRules.StylesScriptsOrderRule.prototype = { } WebInspector.domAgent.requestDocument(onDocumentAvailable); - } -} + }, -WebInspector.AuditRules.StylesScriptsOrderRule.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -1122,10 +1126,10 @@ WebInspector.AuditRules.CSSRuleBase.prototype = { visitProperty: function(styleSheet, property, result) { // Subclasses can implement. - } -} + }, -WebInspector.AuditRules.CSSRuleBase.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -1185,10 +1189,10 @@ WebInspector.AuditRules.VendorPrefixedCSSProperties.prototype = { ++result.violationCount; this._ruleResult.addSnippet(String.sprintf("\"" + this._webkitPrefix + "%s\" is used, but \"%s\" is supported.", normalPropertyName, normalPropertyName)); } - } -} + }, -WebInspector.AuditRules.VendorPrefixedCSSProperties.prototype.__proto__ = WebInspector.AuditRules.CSSRuleBase.prototype; + __proto__: WebInspector.AuditRules.CSSRuleBase.prototype +} /** * @constructor @@ -1238,10 +1242,10 @@ WebInspector.AuditRules.CookieRuleBase.prototype = { if (WebInspector.Cookies.cookieMatchesResourceURL(cookie, requests[i].url)) callback(requests[i], cookie); } - } -} + }, -WebInspector.AuditRules.CookieRuleBase.prototype.__proto__ = WebInspector.AuditRule.prototype; + __proto__: WebInspector.AuditRule.prototype +} /** * @constructor @@ -1347,10 +1351,10 @@ WebInspector.AuditRules.CookieSizeRule.prototype = { entry.addURLs(bigAvgCookieDomains); result.violationCount += bigAvgCookieDomains.length; } - } -} + }, -WebInspector.AuditRules.CookieSizeRule.prototype.__proto__ = WebInspector.AuditRules.CookieRuleBase.prototype; + __proto__: WebInspector.AuditRules.CookieRuleBase.prototype +} /** * @constructor @@ -1394,7 +1398,7 @@ WebInspector.AuditRules.StaticCookielessRule.prototype = { _collectorCallback: function(matchingResourceData, request, cookie) { matchingResourceData[request.url] = (matchingResourceData[request.url] || 0) + cookie.size; - } -} + }, -WebInspector.AuditRules.StaticCookielessRule.prototype.__proto__ = WebInspector.AuditRules.CookieRuleBase.prototype; + __proto__: WebInspector.AuditRules.CookieRuleBase.prototype +} diff --git a/Source/WebCore/inspector/front-end/AuditsPanel.js b/Source/WebCore/inspector/front-end/AuditsPanel.js index e48dbc046..5d005a487 100644 --- a/Source/WebCore/inspector/front-end/AuditsPanel.js +++ b/Source/WebCore/inspector/front-end/AuditsPanel.js @@ -239,10 +239,10 @@ WebInspector.AuditsPanel.prototype = { { this.auditsItemTreeElement.revealAndSelect(); this.auditResultsTreeElement.removeChildren(); - } -} + }, -WebInspector.AuditsPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} /** * @constructor @@ -497,10 +497,10 @@ WebInspector.AuditsSidebarTreeElement.prototype = { refresh: function() { this.refreshTitles(); - } -} + }, -WebInspector.AuditsSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + __proto__: WebInspector.SidebarTreeElement.prototype +} /** * @constructor @@ -524,10 +524,10 @@ WebInspector.AuditResultSidebarTreeElement.prototype = { get selectable() { return true; - } -} + }, -WebInspector.AuditResultSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + __proto__: WebInspector.SidebarTreeElement.prototype +} // Contributed audit rules should go into this namespace. WebInspector.AuditRules = {}; diff --git a/Source/WebCore/inspector/front-end/BottomUpProfileDataGridTree.js b/Source/WebCore/inspector/front-end/BottomUpProfileDataGridTree.js index f5982ad85..55d81fec0 100644 --- a/Source/WebCore/inspector/front-end/BottomUpProfileDataGridTree.js +++ b/Source/WebCore/inspector/front-end/BottomUpProfileDataGridTree.js @@ -143,10 +143,10 @@ WebInspector.BottomUpProfileDataGridNode.prototype = { // In bottom up mode, our parents are our children since we display an inverted tree. // However, we don't want to show the very top parent since it is redundant. return !!(profileNode.parent && profileNode.parent.parent); - } -} + }, -WebInspector.BottomUpProfileDataGridNode.prototype.__proto__ = WebInspector.ProfileDataGridNode.prototype; + __proto__: WebInspector.ProfileDataGridNode.prototype +} /** * @constructor @@ -266,8 +266,7 @@ WebInspector.BottomUpProfileDataGridTree.prototype = { this.sort(this.lastComparator, true); }, - _sharedPopulate: WebInspector.BottomUpProfileDataGridNode.prototype._sharedPopulate -} - -WebInspector.BottomUpProfileDataGridTree.prototype.__proto__ = WebInspector.ProfileDataGridTree.prototype; + _sharedPopulate: WebInspector.BottomUpProfileDataGridNode.prototype._sharedPopulate, + __proto__: WebInspector.ProfileDataGridTree.prototype +} diff --git a/Source/WebCore/inspector/front-end/BreakpointManager.js b/Source/WebCore/inspector/front-end/BreakpointManager.js index 8e9d4b655..16f34e914 100644 --- a/Source/WebCore/inspector/front-end/BreakpointManager.js +++ b/Source/WebCore/inspector/front-end/BreakpointManager.js @@ -49,6 +49,8 @@ WebInspector.BreakpointManager = function(breakpointStorage, debuggerModel, work this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this); this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._workspaceReset, this); this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this); + this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, this._uiSourceCodeAdded, this); + this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, this._uiSourceCodeRemoved, this); } WebInspector.BreakpointManager.Events = { @@ -56,13 +58,18 @@ WebInspector.BreakpointManager.Events = { BreakpointRemoved: "breakpoint-removed" } +WebInspector.BreakpointManager.breakpointStorageId = function(uiSourceCode) +{ + return uiSourceCode.formatted() ? "deobfuscated:" + uiSourceCode.url : uiSourceCode.url; +} + WebInspector.BreakpointManager.prototype = { /** * @param {WebInspector.UISourceCode} uiSourceCode */ restoreBreakpoints: function(uiSourceCode) { - var sourceFileId = uiSourceCode.breakpointStorageId(); + var sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode); if (!sourceFileId || this._sourceFilesWithRestoredBreakpoints[sourceFileId]) return; this._sourceFilesWithRestoredBreakpoints[sourceFileId] = true; @@ -74,6 +81,7 @@ WebInspector.BreakpointManager.prototype = { continue; this._debuggerModel.removeBreakpoint(debuggerId); delete this._breakpointForDebuggerId[debuggerId]; + delete breakpoint._debuggerId; } this._storage._restoreBreakpoints(uiSourceCode); }, @@ -89,6 +97,40 @@ WebInspector.BreakpointManager.prototype = { }, /** + * @param {WebInspector.Event} event + */ + _uiSourceCodeRemoved: function(event) + { + var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data; + if (!(uiSourceCode instanceof WebInspector.JavaScriptSource)) + return; + if (uiSourceCode.divergedVersion) + return; + + var sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode); + if (!sourceFileId) + return; + + var breakpoints = this._breakpoints.slice(); + for (var i = 0; i < breakpoints.length; ++i) { + var breakpoint = breakpoints[i]; + for (var stringifiedLocation in breakpoint._uiLocations) { + var uiLocation = breakpoint._uiLocations[stringifiedLocation]; + if (uiLocation.uiSourceCode === uiSourceCode) + breakpoint.remove(true); + } + } + + delete this._sourceFilesWithRestoredBreakpoints[sourceFileId]; + + var uiSourceCodes = this._workspace.uiSourceCodes(); + for (var i = 0; i < uiSourceCodes.length; ++i) { + if (WebInspector.BreakpointManager.breakpointStorageId(uiSourceCodes[i]) === sourceFileId) + this.restoreBreakpoints(uiSourceCodes[i]); + } + }, + + /** * @param {WebInspector.UISourceCode} uiSourceCode * @param {number} lineNumber * @param {string} condition @@ -133,17 +175,17 @@ WebInspector.BreakpointManager.prototype = { }, /** - * @param {WebInspector.UISourceCode} uiSourceCode - * @return {Array.<Object>} + * @param {function(WebInspector.BreakpointManager.Breakpoint, WebInspector.UILocation)} filter + * @return {Array.<{breakpoint: WebInspector.BreakpointManager.Breakpoint, uiLocation: WebInspector.UILocation}>} */ - breakpointLocationsForUISourceCode: function(uiSourceCode) + _filteredBreakpointLocations: function(filter) { var result = []; for (var i = 0; i < this._breakpoints.length; ++i) { var breakpoint = this._breakpoints[i]; for (var stringifiedLocation in breakpoint._uiLocations) { var uiLocation = breakpoint._uiLocations[stringifiedLocation]; - if (uiLocation.uiSourceCode === uiSourceCode) + if (filter(breakpoint, uiLocation)) result.push({breakpoint: breakpoint, uiLocation: uiLocation}); } } @@ -151,6 +193,28 @@ WebInspector.BreakpointManager.prototype = { }, /** + * @param {WebInspector.UISourceCode} uiSourceCode + * @return {Array.<{breakpoint: WebInspector.BreakpointManager.Breakpoint, uiLocation: WebInspector.UILocation}>} + */ + breakpointLocationsForUISourceCode: function(uiSourceCode) + { + function filter(breakpoint, uiLocation) + { + return uiLocation.uiSourceCode === uiSourceCode; + } + + return this._filteredBreakpointLocations(filter); + }, + + /** + * @return {Array.<{breakpoint: WebInspector.BreakpointManager.Breakpoint, uiLocation: WebInspector.UILocation}>} + */ + allBreakpointLocations: function() + { + return this._filteredBreakpointLocations(function(breakpoint, uiLocation) { return true; }); + }, + + /** * @param {boolean} toggleState */ toggleAllBreakpoints: function(toggleState) @@ -257,10 +321,10 @@ WebInspector.BreakpointManager.prototype = { if (!lineBreakpoints.length) delete breakpoints[uiLocation.lineNumber]; this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation}); - } -} + }, -WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -274,7 +338,7 @@ WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, uiSource { this._breakpointManager = breakpointManager; this._primaryUILocation = new WebInspector.UILocation(uiSourceCode, lineNumber, 0); - this._sourceCodeStorageId = uiSourceCode.breakpointStorageId(); + this._sourceCodeStorageId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode); /** @type {Array.<WebInspector.Script.Location>} */ this._liveLocations = []; /** @type {Object.<string, WebInspector.UILocation>} */ @@ -369,7 +433,8 @@ WebInspector.BreakpointManager.Breakpoint.prototype = { this._condition = condition; this._breakpointManager._storage._updateBreakpoint(this); - if (this._enabled && !this._primaryUILocation.uiSourceCode.isDivergedFromVM()) { + var scriptFile = this._primaryUILocation.uiSourceCode.scriptFile(); + if (this._enabled && !(scriptFile && scriptFile.hasDivergedFromVM())) { this._setInDebugger(); return; } @@ -377,11 +442,15 @@ WebInspector.BreakpointManager.Breakpoint.prototype = { this._fakeBreakpointAtPrimaryLocation(); }, - remove: function() + /** + * @param {boolean=} keepInStorage + */ + remove: function(keepInStorage) { + var removeFromStorage = !keepInStorage; this._resetLocations(); this._removeFromDebugger(); - this._breakpointManager._removeBreakpoint(this, true); + this._breakpointManager._removeBreakpoint(this, removeFromStorage); }, _setInDebugger: function() @@ -456,7 +525,7 @@ WebInspector.BreakpointManager.Breakpoint.prototype = { */ _breakpointStorageId: function() { - return this._primaryUILocation.uiSourceCode.breakpointStorageId() + ":" + this._primaryUILocation.lineNumber; + return WebInspector.BreakpointManager.breakpointStorageId(this._primaryUILocation.uiSourceCode) + ":" + this._primaryUILocation.lineNumber; }, _fakeBreakpointAtPrimaryLocation: function() @@ -492,7 +561,7 @@ WebInspector.BreakpointManager.Storage.prototype = { _restoreBreakpoints: function(uiSourceCode) { this._muted = true; - var breakpointStorageId = uiSourceCode.breakpointStorageId(); + var breakpointStorageId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode); for (var id in this._breakpoints) { var breakpoint = this._breakpoints[id]; if (breakpoint.sourceFileId === breakpointStorageId) @@ -539,7 +608,7 @@ WebInspector.BreakpointManager.Storage.prototype = { WebInspector.BreakpointManager.Storage.Item = function(breakpoint) { var primaryUILocation = breakpoint.primaryUILocation(); - this.sourceFileId = primaryUILocation.uiSourceCode.breakpointStorageId(); + this.sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(primaryUILocation.uiSourceCode); this.lineNumber = primaryUILocation.lineNumber; this.condition = breakpoint.condition(); this.enabled = breakpoint.enabled(); diff --git a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js index 4bdd4af7b..bc4bb6b02 100644 --- a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js @@ -45,6 +45,11 @@ WebInspector.JavaScriptBreakpointsSidebarPane = function(breakpointManager, show this.bodyElement.appendChild(this.emptyElement); this._items = new Map(); + + var breakpointLocations = this._breakpointManager.allBreakpointLocations(); + for (var i = 0; i < breakpointLocations.length; ++i) + this._addBreakpoint(breakpointLocations[i].breakpoint, breakpointLocations[i].uiLocation); + this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this); this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpointRemoved, this); } @@ -59,7 +64,15 @@ WebInspector.JavaScriptBreakpointsSidebarPane.prototype = { var breakpoint = /** @type {WebInspector.BreakpointManager.Breakpoint} */ event.data.breakpoint; var uiLocation = /** @type {WebInspector.UILocation} */ event.data.uiLocation; + this._addBreakpoint(breakpoint, uiLocation); + }, + /** + * @param {WebInspector.BreakpointManager.Breakpoint} breakpoint + * @param {WebInspector.UILocation} uiLocation + */ + _addBreakpoint: function(breakpoint, uiLocation) + { var element = document.createElement("li"); element.addStyleClass("cursor-pointer"); element.addEventListener("contextmenu", this._breakpointContextMenu.bind(this, breakpoint), true); @@ -239,10 +252,10 @@ WebInspector.JavaScriptBreakpointsSidebarPane.prototype = { this.bodyElement.appendChild(this.emptyElement); } this._items.clear(); - } -} + }, -WebInspector.JavaScriptBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -419,10 +432,10 @@ WebInspector.XHRBreakpointsSidebarPane.prototype = { if (breakpoint && typeof breakpoint.url === "string") this._setBreakpoint(breakpoint.url, breakpoint.enabled); } - } -} + }, -WebInspector.XHRBreakpointsSidebarPane.prototype.__proto__ = WebInspector.NativeBreakpointsSidebarPane.prototype; + __proto__: WebInspector.NativeBreakpointsSidebarPane.prototype +} /** * @constructor @@ -620,7 +633,7 @@ WebInspector.EventListenerBreakpointsSidebarPane.prototype = { if (breakpoint && typeof breakpoint.eventName === "string") this._setBreakpoint(breakpoint.eventName); } - } -} + }, -WebInspector.EventListenerBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/CPUProfileView.js b/Source/WebCore/inspector/front-end/CPUProfileView.js index 641553cd7..df8d07d08 100644 --- a/Source/WebCore/inspector/front-end/CPUProfileView.js +++ b/Source/WebCore/inspector/front-end/CPUProfileView.js @@ -531,10 +531,10 @@ WebInspector.CPUProfileView.prototype = { nodesToTraverse.push({ parent: children[i], children: children[i].children }); } } - } -} + }, -WebInspector.CPUProfileView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -622,10 +622,10 @@ WebInspector.CPUProfileType.prototype = { createProfile: function(profile) { return new WebInspector.CPUProfileHeader(this, profile.title, profile.uid); - } -} + }, -WebInspector.CPUProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; + __proto__: WebInspector.ProfileType.prototype +} /** * @constructor @@ -655,7 +655,7 @@ WebInspector.CPUProfileHeader.prototype = { createView: function(profilesPanel) { return new WebInspector.CPUProfileView(this); - } -} + }, -WebInspector.CPUProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; + __proto__: WebInspector.ProfileHeader.prototype +} diff --git a/Source/WebCore/inspector/front-end/CSSCompletions.js b/Source/WebCore/inspector/front-end/CSSCompletions.js index 9e3798535..8c606bed3 100644 --- a/Source/WebCore/inspector/front-end/CSSCompletions.js +++ b/Source/WebCore/inspector/front-end/CSSCompletions.js @@ -90,6 +90,126 @@ WebInspector.CSSCompletions.cssPropertiesMetainfoKeySet = function() return WebInspector.CSSCompletions._cssPropertiesMetainfoKeySet; } +// Weight of CSS properties based their usage on few popular websites https://gist.github.com/3751436 +WebInspector.CSSCompletions.Weight = { + "-webkit-animation": 1, + "-webkit-animation-duration": 1, + "-webkit-animation-iteration-count": 1, + "-webkit-animation-name": 1, + "-webkit-animation-timing-function": 1, + "-webkit-appearance": 1, + "-webkit-background-clip": 2, + "-webkit-border-horizontal-spacing": 1, + "-webkit-border-vertical-spacing": 1, + "-webkit-box-shadow": 24, + "-webkit-font-smoothing": 2, + "-webkit-transform": 1, + "-webkit-transition": 8, + "-webkit-transition-delay": 7, + "-webkit-transition-duration": 7, + "-webkit-transition-property": 7, + "-webkit-transition-timing-function": 6, + "-webkit-user-select": 1, + "background": 222, + "background-attachment": 144, + "background-clip": 143, + "background-color": 222, + "background-image": 201, + "background-origin": 142, + "background-size": 25, + "border": 121, + "border-bottom": 121, + "border-bottom-color": 121, + "border-bottom-left-radius": 50, + "border-bottom-right-radius": 50, + "border-bottom-style": 114, + "border-bottom-width": 120, + "border-collapse": 3, + "border-left": 95, + "border-left-color": 95, + "border-left-style": 89, + "border-left-width": 94, + "border-radius": 50, + "border-right": 93, + "border-right-color": 93, + "border-right-style": 88, + "border-right-width": 93, + "border-top": 111, + "border-top-color": 111, + "border-top-left-radius": 49, + "border-top-right-radius": 49, + "border-top-style": 104, + "border-top-width": 109, + "bottom": 16, + "box-shadow": 25, + "box-sizing": 2, + "clear": 23, + "color": 237, + "cursor": 34, + "direction": 4, + "display": 210, + "fill": 2, + "filter": 1, + "float": 105, + "font": 174, + "font-family": 25, + "font-size": 174, + "font-style": 9, + "font-weight": 89, + "height": 161, + "left": 54, + "letter-spacing": 3, + "line-height": 75, + "list-style": 17, + "list-style-image": 8, + "list-style-position": 8, + "list-style-type": 17, + "margin": 241, + "margin-bottom": 226, + "margin-left": 225, + "margin-right": 213, + "margin-top": 241, + "max-height": 5, + "max-width": 11, + "min-height": 9, + "min-width": 6, + "opacity": 24, + "outline": 10, + "outline-color": 10, + "outline-style": 10, + "outline-width": 10, + "overflow": 57, + "overflow-x": 56, + "overflow-y": 57, + "padding": 216, + "padding-bottom": 208, + "padding-left": 216, + "padding-right": 206, + "padding-top": 216, + "position": 136, + "resize": 1, + "right": 29, + "stroke": 1, + "stroke-width": 1, + "table-layout": 1, + "text-align": 66, + "text-decoration": 53, + "text-indent": 9, + "text-overflow": 8, + "text-shadow": 19, + "text-transform": 5, + "top": 71, + "unicode-bidi": 1, + "vertical-align": 37, + "visibility": 11, + "white-space": 24, + "width": 255, + "word-wrap": 6, + "z-index": 32, + "zoom": 10 +}; + + WebInspector.CSSCompletions.prototype = { startsWith: function(prefix) { @@ -103,10 +223,22 @@ WebInspector.CSSCompletions.prototype = { return results; }, - firstStartsWith: function(prefix) + /** + * @param {Array.<string>} properties + * @return {number} + */ + mostUsedOf: function(properties) { - var foundIndex = this._firstIndexOfPrefix(prefix); - return (foundIndex === -1 ? "" : this._values[foundIndex]); + var maxWeight = 0; + var index = 0; + for (var i = 0; i < properties.length; i++) { + var weight = WebInspector.CSSCompletions.Weight[properties[i]]; + if (weight > maxWeight) { + maxWeight = weight; + index = i; + } + } + return index; }, _firstIndexOfPrefix: function(prefix) diff --git a/Source/WebCore/inspector/front-end/CSSNamedFlowCollectionsView.js b/Source/WebCore/inspector/front-end/CSSNamedFlowCollectionsView.js index 239c507b0..b2a302402 100644 --- a/Source/WebCore/inspector/front-end/CSSNamedFlowCollectionsView.js +++ b/Source/WebCore/inspector/front-end/CSSNamedFlowCollectionsView.js @@ -371,10 +371,10 @@ WebInspector.CSSNamedFlowCollectionsView.prototype = { this._tabbedPane.removeEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this); this._tabbedPane.removeEventListener(WebInspector.TabbedPane.EventTypes.TabClosed, this._tabClosed, this); - } -} + }, -WebInspector.CSSNamedFlowCollectionsView.prototype.__proto__ = WebInspector.SplitView.prototype; + __proto__: WebInspector.SplitView.prototype +} /** * @constructor @@ -410,7 +410,7 @@ WebInspector.FlowTreeElement.prototype = { } this._overset = newOverset; - } -} + }, -WebInspector.FlowTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/CSSNamedFlowView.js b/Source/WebCore/inspector/front-end/CSSNamedFlowView.js index afb8c1daf..c6a09f208 100644 --- a/Source/WebCore/inspector/front-end/CSSNamedFlowView.js +++ b/Source/WebCore/inspector/front-end/CSSNamedFlowView.js @@ -250,7 +250,7 @@ WebInspector.CSSNamedFlowView.prototype = { this._mergeRegions(this._flow.regions, newFlow.regions); this._flow = newFlow; - } -} + }, -WebInspector.CSSNamedFlowView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/CSSSelectorProfileView.js b/Source/WebCore/inspector/front-end/CSSSelectorProfileView.js index 70993a2ea..e10f8dc6e 100644 --- a/Source/WebCore/inspector/front-end/CSSSelectorProfileView.js +++ b/Source/WebCore/inspector/front-end/CSSSelectorProfileView.js @@ -74,10 +74,10 @@ WebInspector.CSSSelectorDataGridNode.prototype = { } return cell; - } -} + }, -WebInspector.CSSSelectorDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; + __proto__: WebInspector.DataGridNode.prototype +} /** * @constructor @@ -259,10 +259,10 @@ WebInspector.CSSSelectorProfileView.prototype = { this.refreshShowAsPercents(); event.consume(true); - } -} + }, -WebInspector.CSSSelectorProfileView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -364,10 +364,10 @@ WebInspector.CSSSelectorProfileType.prototype = { { title = title || WebInspector.UIString("Recording\u2026"); return new WebInspector.CSSProfileHeader(this, title); - } -} + }, -WebInspector.CSSSelectorProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; + __proto__: WebInspector.ProfileType.prototype +} /** @@ -401,7 +401,7 @@ WebInspector.CSSProfileHeader.prototype = { { var profile = /** @type {CSSAgent.SelectorProfile} */this._protocolData; return new WebInspector.CSSSelectorProfileView(profile); - } -} + }, -WebInspector.CSSProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; + __proto__: WebInspector.ProfileHeader.prototype +} diff --git a/Source/WebCore/inspector/front-end/CSSStyleModel.js b/Source/WebCore/inspector/front-end/CSSStyleModel.js index e071f60fa..669e77e1d 100644 --- a/Source/WebCore/inspector/front-end/CSSStyleModel.js +++ b/Source/WebCore/inspector/front-end/CSSStyleModel.js @@ -38,7 +38,7 @@ WebInspector.CSSStyleModel = function() this._sourceMappings = {}; WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoRequested, this._undoRedoRequested, this); WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoCompleted, this._undoRedoCompleted, this); - this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding(this); + this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding(); this._namedFlowCollections = {}; WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._resetNamedFlowCollections, this); InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); @@ -87,8 +87,8 @@ WebInspector.CSSStyleModel.prototype = { /** * @param {function(?*)} userCallback * @param {?Protocol.Error} error - * @param {Array.<CSSAgent.CSSRule>=} matchedPayload - * @param {Array.<CSSAgent.PseudoIdRules>=} pseudoPayload + * @param {Array.<CSSAgent.RuleMatch>=} matchedPayload + * @param {Array.<CSSAgent.PseudoIdMatches>=} pseudoPayload * @param {Array.<CSSAgent.InheritedStyleEntry>=} inheritedPayload */ function callback(userCallback, error, matchedPayload, pseudoPayload, inheritedPayload) @@ -501,10 +501,10 @@ WebInspector.CSSStyleModel.prototype = { { var sourceMapping = this._sourceMappings[rawLocation.url]; return sourceMapping ? sourceMapping.rawLocationToUILocation(rawLocation) : null; - } -} + }, -WebInspector.CSSStyleModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -1100,30 +1100,59 @@ WebInspector.CSSStyleSheet.prototype = { /** * @constructor */ -WebInspector.CSSStyleModelResourceBinding = function(cssModel) +WebInspector.CSSStyleModelResourceBinding = function() { - this._cssModel = cssModel; this._frameAndURLToStyleSheetId = {}; this._styleSheetIdToHeader = {}; - this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._styleSheetChanged, this); WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this); } WebInspector.CSSStyleModelResourceBinding.prototype = { /** - * @param {WebInspector.StyleSource} styleSource - * @param {string} content - * @param {boolean} majorChange - * @param {function(?string)} userCallback + * @param {WebInspector.Resource} resource + * @param {function(?CSSAgent.StyleSheetId)} callback */ - setStyleContent: function(styleSource, content, majorChange, userCallback) + requestStyleSheetIdForResource: function(resource, callback) { - var resource = styleSource.resource(); - if (this._styleSheetIdForResource(resource)) { - this._innerSetContent(resource, content, majorChange, userCallback, null); - return; + function innerCallback() + { + callback(this._styleSheetIdForResource(resource)); } - this._loadStyleSheetHeaders(this._innerSetContent.bind(this, resource, content, majorChange, userCallback)); + + if (this._styleSheetIdForResource(resource)) + innerCallback.call(this); + else + this._loadStyleSheetHeaders(innerCallback.bind(this)); + }, + + /** + * @param {CSSAgent.StyleSheetId} styleSheetId + * @param {function(?string)} callback + */ + requestResourceURLForStyleSheetId: function(styleSheetId, callback) + { + function innerCallback() + { + var header = this._styleSheetIdToHeader[styleSheetId]; + if (!header) { + callback(null); + return; + } + + var frame = WebInspector.resourceTreeModel.frameForId(header.frameId); + if (!frame) { + callback(null); + return; + } + + var styleSheetURL = header.origin === "inspector" ? this._viaInspectorResourceURL(header.sourceURL) : header.sourceURL; + callback(styleSheetURL); + } + + if (this._styleSheetIdToHeader[styleSheetId]) + innerCallback.call(this); + else + this._loadStyleSheetHeaders(innerCallback.bind(this)); }, /** @@ -1146,35 +1175,6 @@ WebInspector.CSSStyleModelResourceBinding.prototype = { }, /** - * @param {WebInspector.Resource} resource - * @param {string} content - * @param {boolean} majorChange - * @param {function(?string)} userCallback - * @param {?string} error - */ - _innerSetContent: function(resource, content, majorChange, userCallback, error) - { - if (error) { - userCallback(error); - return; - } - - var styleSheetId = this._styleSheetIdForResource(resource); - if (!styleSheetId) { - userCallback("No stylesheet found: " + resource.frameId + ":" + resource.url); - return; - } - - this._isSettingContent = true; - function callbackWrapper(error) - { - userCallback(error); - delete this._isSettingContent; - } - this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, callbackWrapper.bind(this)); - }, - - /** * @param {function(?string)} callback */ _loadStyleSheetHeaders: function(callback) @@ -1205,62 +1205,6 @@ WebInspector.CSSStyleModelResourceBinding.prototype = { }, /** - * @param {WebInspector.Event} event - */ - _styleSheetChanged: function(event) - { - if (this._isSettingContent) - return; - - if (!event.data.majorChange) - return; - - /** - * @param {?string} error - * @param {string} content - */ - function callback(error, content) - { - if (!error) - this._innerStyleSheetChanged(event.data.styleSheetId, content); - } - CSSAgent.getStyleSheetText(event.data.styleSheetId, callback.bind(this)); - }, - - /** - * @param {CSSAgent.StyleSheetId} styleSheetId - * @param {string} content - */ - _innerStyleSheetChanged: function(styleSheetId, content) - { - function setContent() - { - var header = this._styleSheetIdToHeader[styleSheetId]; - if (!header) - return; - - var frame = WebInspector.resourceTreeModel.frameForId(header.frameId); - if (!frame) - return; - - var styleSheetURL = header.origin === "inspector" ? this._viaInspectorResourceURL(header.sourceURL) : header.sourceURL; - - var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(styleSheetURL); - if (!uiSourceCode) - return; - - if (uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesheet) - uiSourceCode.addRevision(content); - } - - if (!this._styleSheetIdToHeader[styleSheetId]) { - this._loadStyleSheetHeaders(setContent.bind(this)); - return; - } - setContent.call(this); - }, - - /** * @param {CSSAgent.StyleSheetId} styleSheetId * @param {function(?WebInspector.Resource)} callback */ diff --git a/Source/WebCore/inspector/front-end/CallStackSidebarPane.js b/Source/WebCore/inspector/front-end/CallStackSidebarPane.js index 5d543f734..9c71edb69 100644 --- a/Source/WebCore/inspector/front-end/CallStackSidebarPane.js +++ b/Source/WebCore/inspector/front-end/CallStackSidebarPane.js @@ -155,10 +155,10 @@ WebInspector.CallStackSidebarPane.prototype = { this._selectNextCallFrameOnStack(); event.consume(); } - } -} + }, -WebInspector.CallStackSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -178,7 +178,7 @@ WebInspector.CallStackSidebarPane.Placard = function(callFrame, pane) WebInspector.CallStackSidebarPane.Placard.prototype = { _update: function(uiLocation) { - this.subtitle = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber); + this.subtitle = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber).trimMiddle(100); }, _placardContextMenu: function(event) @@ -197,7 +197,7 @@ WebInspector.CallStackSidebarPane.Placard.prototype = { _restartFrame: function() { this._callFrame.restart(undefined); - } -} + }, -WebInspector.CallStackSidebarPane.Placard.prototype.__proto__ = WebInspector.Placard.prototype; + __proto__: WebInspector.Placard.prototype +} diff --git a/Source/WebCore/inspector/front-end/CanvasProfileView.js b/Source/WebCore/inspector/front-end/CanvasProfileView.js index 061ad8a37..35d557eef 100644 --- a/Source/WebCore/inspector/front-end/CanvasProfileView.js +++ b/Source/WebCore/inspector/front-end/CanvasProfileView.js @@ -110,17 +110,22 @@ WebInspector.CanvasProfileView.prototype = { traceLogItem.stepNo = i; traceLogItem.appendChild(document.createTextNode("(" + (i+1) + ") ")); + var sourceText = call.functionName || "context." + call.property; if (call.sourceURL) { // FIXME(62725): stack trace line/column numbers are one-based. var lineNumber = Math.max(0, call.lineNumber - 1) || 0; var columnNumber = Math.max(0, call.columnNumber - 1) || 0; var linkElement = this._linkifier.linkifyLocation(call.sourceURL, lineNumber, columnNumber); - linkElement.textContent = call.functionName; + linkElement.textContent = sourceText; traceLogItem.appendChild(linkElement); } else - traceLogItem.appendChild(document.createTextNode(call.functionName)); + traceLogItem.appendChild(document.createTextNode(sourceText)); + + if (call.arguments) + traceLogItem.appendChild(document.createTextNode("(" + call.arguments.join(", ") + ")")); + else + traceLogItem.appendChild(document.createTextNode(" = " + call.value)); - traceLogItem.appendChild(document.createTextNode("(" + call.arguments.join(", ") + ")")); if (typeof call.result !== "undefined") traceLogItem.appendChild(document.createTextNode(" => " + call.result)); this._traceLogElement.appendChild(traceLogItem); @@ -145,10 +150,10 @@ WebInspector.CanvasProfileView.prototype = { this._replayImageElement.src = dataURL; } CanvasAgent.replayTraceLog(item.traceLogId, item.stepNo, didReplayTraceLog.bind(this)); - } -} + }, -WebInspector.CanvasProfileView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -227,10 +232,10 @@ WebInspector.CanvasProfileType.prototype = { createProfile: function(profile) { return new WebInspector.CanvasProfileHeader(this, profile.title, -1); - } -} + }, -WebInspector.CanvasProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; + __proto__: WebInspector.ProfileType.prototype +} /** * @constructor @@ -272,7 +277,7 @@ WebInspector.CanvasProfileHeader.prototype = { createView: function(profilesPanel) { return new WebInspector.CanvasProfileView(this); - } -} + }, -WebInspector.CanvasProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; + __proto__: WebInspector.ProfileHeader.prototype +} diff --git a/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js b/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js index c9fded13b..c45784be0 100644 --- a/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js +++ b/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js @@ -378,7 +378,7 @@ WebInspector.CodeMirrorTextEditor.prototype = { _toRange: function(start, end) { return new WebInspector.TextRange(start.line, start.ch, end.line, end.ch); - } -} + }, -WebInspector.CodeMirrorTextEditor.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/CompilerScriptMapping.js b/Source/WebCore/inspector/front-end/CompilerScriptMapping.js index 7f4b9dae3..05e2b7387 100644 --- a/Source/WebCore/inspector/front-end/CompilerScriptMapping.js +++ b/Source/WebCore/inspector/front-end/CompilerScriptMapping.js @@ -84,7 +84,7 @@ WebInspector.CompilerScriptMapping.prototype = { */ addScript: function(script) { - var originalUISourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, true); + var originalUISourceCode = new WebInspector.JavaScriptSource(script.sourceURL, script, true); this._originalUISourceCodeForScriptId[script.scriptId] = originalUISourceCode; this._scriptForOriginalUISource.put(originalUISourceCode, script); this._workspace.project().addUISourceCode(originalUISourceCode); @@ -109,7 +109,7 @@ WebInspector.CompilerScriptMapping.prototype = { contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, sourceContent); else contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL); - var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, null, contentProvider, false); + var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, contentProvider, false); uiSourceCode.setSourceMapping(this); uiSourceCode.isContentScript = script.isContentScript; this._uiSourceCodeByURL[sourceURL] = uiSourceCode; diff --git a/Source/WebCore/inspector/front-end/ConsoleMessage.js b/Source/WebCore/inspector/front-end/ConsoleMessage.js index f290a6bad..df3355a0e 100644 --- a/Source/WebCore/inspector/front-end/ConsoleMessage.js +++ b/Source/WebCore/inspector/front-end/ConsoleMessage.js @@ -447,6 +447,11 @@ WebInspector.ConsoleMessageImpl.prototype = { return obj.description; } + function styleFormatter(obj) + { + formattedResult.setAttribute("style", obj.description); + } + // Firebug uses %o for formatting objects. formatters.o = parameterFormatter.bind(this, false); formatters.s = valueFormatter; @@ -455,15 +460,18 @@ WebInspector.ConsoleMessageImpl.prototype = { formatters.i = valueFormatter; formatters.d = valueFormatter; + // Firebug uses %c for styling the message. + formatters.c = styleFormatter; + // Support %O to force object formatting, instead of the type-based %o formatting. formatters.O = parameterFormatter.bind(this, true); function append(a, b) { - if (!(b instanceof Node)) - a.appendChild(WebInspector.linkifyStringAsFragment(b.toString())); - else + if (b instanceof Node) a.appendChild(b); + else if (b) + a.appendChild(WebInspector.linkifyStringAsFragment(b.toString())); return a; } @@ -687,6 +695,8 @@ WebInspector.ConsoleMessageImpl.prototype = { return false; var l = this._stackTrace; var r = msg._stackTrace; + if (l.length !== r.length) + return false; for (var i = 0; i < l.length; i++) { if (l[i].url !== r[i].url || l[i].functionName !== r[i].functionName || @@ -716,7 +726,7 @@ WebInspector.ConsoleMessageImpl.prototype = { clone: function() { return WebInspector.ConsoleMessage.create(this.source, this.level, this._messageText, this.type, this.url, this.line, this.repeatCount, this._parameters, this._stackTrace, this._request ? this._request.requestId : undefined, this._isOutdated); - } -} + }, -WebInspector.ConsoleMessageImpl.prototype.__proto__ = WebInspector.ConsoleMessage.prototype; + __proto__: WebInspector.ConsoleMessage.prototype +} diff --git a/Source/WebCore/inspector/front-end/ConsoleModel.js b/Source/WebCore/inspector/front-end/ConsoleModel.js index 040296ea7..fd37e35d9 100644 --- a/Source/WebCore/inspector/front-end/ConsoleModel.js +++ b/Source/WebCore/inspector/front-end/ConsoleModel.js @@ -143,10 +143,10 @@ WebInspector.ConsoleModel.prototype = { msgCopy.repeatDelta = msgCopy.repeatCount; this.addMessage(msgCopy); } - } -} + }, -WebInspector.ConsoleModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/ConsolePanel.js b/Source/WebCore/inspector/front-end/ConsolePanel.js index 8012b19c1..c6e7c2b67 100644 --- a/Source/WebCore/inspector/front-end/ConsolePanel.js +++ b/Source/WebCore/inspector/front-end/ConsolePanel.js @@ -150,7 +150,7 @@ WebInspector.ConsolePanel.prototype = { this._searchResults.length = 0; if (this.isShowing()) WebInspector.searchController.updateSearchMatchesCount(0, this); - } -} + }, -WebInspector.ConsolePanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} diff --git a/Source/WebCore/inspector/front-end/ConsoleView.js b/Source/WebCore/inspector/front-end/ConsoleView.js index 04011165a..eeb5cf2de 100644 --- a/Source/WebCore/inspector/front-end/ConsoleView.js +++ b/Source/WebCore/inspector/front-end/ConsoleView.js @@ -27,8 +27,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -const ExpressionStopCharacters = " =:[({;,!+-*/&|^<>"; - /** * @extends {WebInspector.View} * @constructor @@ -114,7 +112,7 @@ WebInspector.ConsoleView = function(hideContextSelector) this._linkifier = new WebInspector.Linkifier(); - this.prompt = new WebInspector.TextPromptWithHistory(this.completionsForTextPrompt.bind(this), ExpressionStopCharacters + "."); + this.prompt = new WebInspector.TextPromptWithHistory(WebInspector.runtimeModel.completionsForTextPrompt.bind(WebInspector.runtimeModel)); this.prompt.setSuggestBoxEnabled("generic-suggest"); this.prompt.renderAsBlock(); this.prompt.attach(this.promptElement); @@ -176,14 +174,14 @@ WebInspector.ConsoleView.prototype = { { var context = this._currentFrame(); if (!context) { - delete this._currentExecutionContext; + WebInspector.runtimeModel.setCurrentExecutionContext(null); this._contextSelector.element.addStyleClass("hidden"); return; } var executionContexts = context.executionContexts(); if (executionContexts.length) - this._currentExecutionContext = executionContexts[0]; + WebInspector.runtimeModel.setCurrentExecutionContext(executionContexts[0]); if (executionContexts.length === 1) { this._contextSelector.element.addStyleClass("hidden"); @@ -200,8 +198,8 @@ WebInspector.ConsoleView.prototype = { */ _appendContextOption: function(executionContext) { - if (!this._currentExecutionContext) - this._currentExecutionContext = executionContext; + if (!WebInspector.runtimeModel.currentExecutionContext()) + WebInspector.runtimeModel.setCurrentExecutionContext(executionContext); var option = document.createElement("option"); option.text = executionContext.name; option.title = executionContext.id; @@ -215,7 +213,7 @@ WebInspector.ConsoleView.prototype = { _contextChanged: function(event) { var option = this._contextSelector.selectedOption(); - this._currentExecutionContext = option ? option._executionContext : undefined; + WebInspector.runtimeModel.setCurrentExecutionContext(option ? option._executionContext : null); }, /** @@ -432,143 +430,6 @@ WebInspector.ConsoleView.prototype = { this._linkifier.reset(); }, - completionsForTextPrompt: function(textPrompt, wordRange, force, completionsReadyCallback) - { - // Pass less stop characters to rangeOfWord so the range will be a more complete expression. - var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOffset, ExpressionStopCharacters, textPrompt.proxyElement, "backward"); - var expressionString = expressionRange.toString(); - var prefix = wordRange.toString(); - this.completionsForExpression(expressionString, prefix, force, completionsReadyCallback); - }, - - completionsForExpression: function(expressionString, prefix, force, completionsReadyCallback) - { - var lastIndex = expressionString.length - 1; - - var dotNotation = (expressionString[lastIndex] === "."); - var bracketNotation = (expressionString[lastIndex] === "["); - - if (dotNotation || bracketNotation) - expressionString = expressionString.substr(0, lastIndex); - - if (expressionString && parseInt(expressionString, 10) == expressionString) { - // User is entering float value, do not suggest anything. - completionsReadyCallback([]); - return; - } - - if (!prefix && !expressionString && !force) { - completionsReadyCallback([]); - return; - } - - if (!expressionString && WebInspector.debuggerModel.selectedCallFrame()) - WebInspector.debuggerModel.getSelectedCallFrameVariables(receivedPropertyNames.bind(this)); - else - this.evalInInspectedWindow(expressionString, "completion", true, true, false, evaluated.bind(this)); - - function evaluated(result, wasThrown) - { - if (!result || wasThrown) { - completionsReadyCallback([]); - return; - } - - function getCompletions(primitiveType) - { - var object; - if (primitiveType === "string") - object = new String(""); - else if (primitiveType === "number") - object = new Number(0); - else if (primitiveType === "boolean") - object = new Boolean(false); - else - object = this; - - var resultSet = {}; - for (var o = object; o; o = o.__proto__) { - try { - var names = Object.getOwnPropertyNames(o); - for (var i = 0; i < names.length; ++i) - resultSet[names[i]] = true; - } catch (e) { - } - } - return resultSet; - } - - if (result.type === "object" || result.type === "function") - result.callFunctionJSON(getCompletions, undefined, receivedPropertyNames.bind(this)); - else if (result.type === "string" || result.type === "number" || result.type === "boolean") - this.evalInInspectedWindow("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, receivedPropertyNamesFromEval.bind(this)); - } - - function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) - { - if (result && !wasThrown) - receivedPropertyNames.call(this, result.value); - else - completionsReadyCallback([]); - } - - function receivedPropertyNames(propertyNames) - { - RuntimeAgent.releaseObjectGroup("completion"); - if (!propertyNames) { - completionsReadyCallback([]); - return; - } - var includeCommandLineAPI = (!dotNotation && !bracketNotation); - if (includeCommandLineAPI) { - const commandLineAPI = ["dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear"]; - for (var i = 0; i < commandLineAPI.length; ++i) - propertyNames[commandLineAPI[i]] = true; - } - this._reportCompletions(completionsReadyCallback, dotNotation, bracketNotation, expressionString, prefix, Object.keys(propertyNames)); - } - }, - - _reportCompletions: function(completionsReadyCallback, dotNotation, bracketNotation, expressionString, prefix, properties) { - if (bracketNotation) { - if (prefix.length && prefix[0] === "'") - var quoteUsed = "'"; - else - var quoteUsed = "\""; - } - - var results = []; - - if (!expressionString) { - const keywords = ["break", "case", "catch", "continue", "default", "delete", "do", "else", "finally", "for", "function", "if", "in", - "instanceof", "new", "return", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with"]; - properties = properties.concat(keywords); - } - - properties.sort(); - - for (var i = 0; i < properties.length; ++i) { - var property = properties[i]; - - if (dotNotation && !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(property)) - continue; - - if (bracketNotation) { - if (!/^[0-9]+$/.test(property)) - property = quoteUsed + property.escapeCharacters(quoteUsed + "\\") + quoteUsed; - property += "]"; - } - - if (property.length < prefix.length) - continue; - if (prefix.length && !property.startsWith(prefix)) - continue; - - results.push(property); - } - completionsReadyCallback(results); - }, - _handleContextMenuEvent: function(event) { if (!window.getSelection().isCollapsed) { @@ -672,47 +533,6 @@ WebInspector.ConsoleView.prototype = { } }, - /** - * @param {string} expression - * @param {string} objectGroup - * @param {boolean} includeCommandLineAPI - * @param {boolean} doNotPauseOnExceptionsAndMuteConsole - * @param {boolean} returnByValue - * @param {function(?WebInspector.RemoteObject, boolean, RuntimeAgent.RemoteObject=)} callback - */ - evalInInspectedWindow: function(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback) - { - if (WebInspector.debuggerModel.selectedCallFrame()) { - WebInspector.debuggerModel.evaluateOnSelectedCallFrame(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback); - return; - } - - if (!expression) { - // There is no expression, so the completion should happen against global properties. - expression = "this"; - } - - /** - * @param {?Protocol.Error} error - * @param {RuntimeAgent.RemoteObject} result - * @param {boolean=} wasThrown - */ - function evalCallback(error, result, wasThrown) - { - if (error) { - console.error(error); - callback(null, false); - return; - } - - if (returnByValue) - callback(null, !!wasThrown, wasThrown ? null : result); - else - callback(WebInspector.RemoteObject.fromPayload(result), !!wasThrown); - } - RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this._currentExecutionContext ? this._currentExecutionContext.id : undefined, returnByValue, evalCallback); - }, - evaluateUsingTextPrompt: function(expression, showResultOnly) { this._appendCommand(expression, this.prompt.text, false, showResultOnly); @@ -733,27 +553,6 @@ WebInspector.ConsoleView.prototype = { this._appendCommand(str, "", true, false); }, - runScript: function(scriptId) - { - DebuggerAgent.runScript(scriptId, this._currentExecutionContext ? this._currentExecutionContext.id : undefined, "console", false, runCallback.bind(this)); - WebInspector.userMetrics.ConsoleEvaluated.record(); - - /** - * @param {?string} error - * @param {?RuntimeAgent.RemoteObject} result - * @param {boolean=} wasThrown - */ - function runCallback(error, result, wasThrown) - { - if (error) { - console.error(error); - return; - } - - this._printResult(result, wasThrown, null); - } - }, - _printResult: function(result, wasThrown, originatingCommand) { if (!result) @@ -783,7 +582,7 @@ WebInspector.ConsoleView.prototype = { this._printResult(result, wasThrown, commandMessage); } - this.evalInInspectedWindow(text, "console", useCommandLineAPI, false, false, printResult.bind(this)); + WebInspector.runtimeModel.evaluate(text, "console", useCommandLineAPI, false, false, printResult.bind(this)); WebInspector.userMetrics.ConsoleEvaluated.record(); }, @@ -829,10 +628,10 @@ WebInspector.ConsoleView.prototype = { WebInspector.log(counter > 1 ? counter + " x " + previousTitle : previousTitle); } MemoryAgent.getDOMNodeCount(callback); - } -} + }, -WebInspector.ConsoleView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -910,10 +709,10 @@ WebInspector.ConsoleCommandResult.prototype = { var element = WebInspector.ConsoleMessageImpl.prototype.toMessageElement.call(this); element.addStyleClass("console-user-command-result"); return element; - } -} + }, -WebInspector.ConsoleCommandResult.prototype.__proto__ = WebInspector.ConsoleMessageImpl.prototype; + __proto__: WebInspector.ConsoleMessageImpl.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/ContentProvider.js b/Source/WebCore/inspector/front-end/ContentProvider.js index 2c6f5198c..47f2a8d3a 100644 --- a/Source/WebCore/inspector/front-end/ContentProvider.js +++ b/Source/WebCore/inspector/front-end/ContentProvider.js @@ -35,7 +35,7 @@ WebInspector.ContentProvider = function() { } WebInspector.ContentProvider.prototype = { /** - * @return {?string} + * @return {string} */ contentURL: function() { }, diff --git a/Source/WebCore/inspector/front-end/ContentProviders.js b/Source/WebCore/inspector/front-end/ContentProviders.js index 9c19953dd..54530dfaa 100644 --- a/Source/WebCore/inspector/front-end/ContentProviders.js +++ b/Source/WebCore/inspector/front-end/ContentProviders.js @@ -73,11 +73,11 @@ WebInspector.ConcatenatedScriptsContentProvider.prototype = { }, /** - * @return {?string} + * @return {string} */ contentURL: function() { - return null; + return ""; }, /** @@ -177,13 +177,14 @@ WebInspector.ConcatenatedScriptsContentProvider.prototype = { } return content; - } -} + }, -WebInspector.ConcatenatedScriptsContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype; + __proto__: WebInspector.ContentProvider.prototype +} /** * @constructor + * @param {string} sourceURL * @implements {WebInspector.ContentProvider} */ WebInspector.CompilerSourceMappingContentProvider = function(sourceURL) @@ -193,7 +194,7 @@ WebInspector.CompilerSourceMappingContentProvider = function(sourceURL) WebInspector.CompilerSourceMappingContentProvider.prototype = { /** - * @return {?string} + * @return {string} */ contentURL: function() { @@ -232,10 +233,10 @@ WebInspector.CompilerSourceMappingContentProvider.prototype = { searchInContent: function(query, caseSensitive, isRegex, callback) { callback([]); - } -} + }, -WebInspector.CompilerSourceMappingContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype; + __proto__: WebInspector.ContentProvider.prototype +} /** * @constructor @@ -253,11 +254,11 @@ WebInspector.StaticContentProvider = function(contentType, content, mimeType) WebInspector.StaticContentProvider.prototype = { /** - * @return {?string} + * @return {string} */ contentURL: function() { - return null; + return ""; }, /** @@ -305,7 +306,7 @@ WebInspector.StaticContentProvider.prototype = { // searchInContent should call back later. window.setTimeout(performSearch.bind(this), 0); - } -} + }, -WebInspector.StaticContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype; + __proto__: WebInspector.ContentProvider.prototype +} diff --git a/Source/WebCore/inspector/front-end/ContextMenu.js b/Source/WebCore/inspector/front-end/ContextMenu.js index 6821c4a9a..deecc274e 100644 --- a/Source/WebCore/inspector/front-end/ContextMenu.js +++ b/Source/WebCore/inspector/front-end/ContextMenu.js @@ -143,10 +143,10 @@ WebInspector.ContextSubMenuItem.prototype = { for (var i = 0; i < this._items.length; ++i) result.subItems.push(this._items[i]._buildDescriptor()); return result; - } -} + }, -WebInspector.ContextSubMenuItem.prototype.__proto__ = WebInspector.ContextMenuItem.prototype; + __proto__: WebInspector.ContextMenuItem.prototype +} /** * @constructor @@ -206,10 +206,10 @@ WebInspector.ContextMenu.prototype = { provider.appendApplicableItems(this, target); this.appendSeparator(); } - } -} + }, -WebInspector.ContextMenu.prototype.__proto__ = WebInspector.ContextSubMenuItem.prototype; + __proto__: WebInspector.ContextSubMenuItem.prototype +} /** * @interface diff --git a/Source/WebCore/inspector/front-end/CookieItemsView.js b/Source/WebCore/inspector/front-end/CookieItemsView.js index 1698d3253..9fa23547a 100644 --- a/Source/WebCore/inspector/front-end/CookieItemsView.js +++ b/Source/WebCore/inspector/front-end/CookieItemsView.js @@ -155,10 +155,10 @@ WebInspector.CookieItemsView.prototype = { contextMenu.appendItem(WebInspector.UIString("Refresh"), this._update.bind(this)); contextMenu.show(event); } - } -} + }, -WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -197,60 +197,7 @@ WebInspector.SimpleCookiesTable.prototype = { this._dataGrid.rootNode().appendChild(node); } this._dataGrid.rootNode().children[0].selected = true; - } -} - -WebInspector.SimpleCookiesTable.prototype.__proto__ = WebInspector.View.prototype; - -WebInspector.Cookies = {} - -WebInspector.Cookies.getCookiesAsync = function(callback) -{ - function mycallback(error, cookies, cookiesString) - { - if (error) - return; - if (cookiesString) - callback(WebInspector.Cookies.buildCookiesFromString(cookiesString), false); - else - callback(cookies, true); - } - - PageAgent.getCookies(mycallback); -} - -WebInspector.Cookies.buildCookiesFromString = function(rawCookieString) -{ - var rawCookies = rawCookieString.split(/;\s*/); - var cookies = []; - - if (!(/^\s*$/.test(rawCookieString))) { - for (var i = 0; i < rawCookies.length; ++i) { - var cookie = rawCookies[i]; - var delimIndex = cookie.indexOf("="); - var name = cookie.substring(0, delimIndex); - var value = cookie.substring(delimIndex + 1); - var size = name.length + value.length; - cookies.push({ name: name, value: value, size: size }); - } - } - - return cookies; -} - -WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL) -{ - var url = resourceURL.asParsedURL(); - if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.domain, url.host)) - return false; - return (url.path.startsWith(cookie.path) - && (!cookie.port || url.port == cookie.port) - && (!cookie.secure || url.scheme === "https")); -} + }, -WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain) -{ - if (cookieDomain.charAt(0) !== '.') - return resourceDomain === cookieDomain; - return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)?" + cookieDomain.substring(1).escapeForRegExp() + "$"), "i"); + __proto__: WebInspector.View.prototype } diff --git a/Source/WebCore/inspector/front-end/CookieParser.js b/Source/WebCore/inspector/front-end/CookieParser.js index b61937710..a369ac8d9 100644 --- a/Source/WebCore/inspector/front-end/CookieParser.js +++ b/Source/WebCore/inspector/front-end/CookieParser.js @@ -255,16 +255,8 @@ WebInspector.Cookie.prototype = { */ expires: function(requestDate) { - // RFC 6265 indicates that the max-age attribute takes precedence over the expires attribute - if (this._attributes["max-age"]) { - var targetDate = requestDate === null ? new Date() : requestDate; - return new Date(targetDate.getTime() + 1000 * this._attributes["max-age"]); - } - - if (this._attributes["expires"]) - return new Date(this._attributes["expires"]); - - return null; + return this._attributes["expires"] ? new Date(this._attributes["expires"]) : + (this._attributes["max-age"] ? new Date(requestDate.getTime() + 1000 * this._attributes["max-age"]) : null); }, /** @@ -289,3 +281,56 @@ WebInspector.Cookie.Type = { Request: 0, Response: 1 }; + +WebInspector.Cookies = {} + +WebInspector.Cookies.getCookiesAsync = function(callback) +{ + function mycallback(error, cookies, cookiesString) + { + if (error) + return; + if (cookiesString) + callback(WebInspector.Cookies.buildCookiesFromString(cookiesString), false); + else + callback(cookies, true); + } + + PageAgent.getCookies(mycallback); +} + +WebInspector.Cookies.buildCookiesFromString = function(rawCookieString) +{ + var rawCookies = rawCookieString.split(/;\s*/); + var cookies = []; + + if (!(/^\s*$/.test(rawCookieString))) { + for (var i = 0; i < rawCookies.length; ++i) { + var cookie = rawCookies[i]; + var delimIndex = cookie.indexOf("="); + var name = cookie.substring(0, delimIndex); + var value = cookie.substring(delimIndex + 1); + var size = name.length + value.length; + cookies.push({ name: name, value: value, size: size }); + } + } + + return cookies; +} + +WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL) +{ + var url = resourceURL.asParsedURL(); + if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.domain, url.host)) + return false; + return (url.path.startsWith(cookie.path) + && (!cookie.port || url.port == cookie.port) + && (!cookie.secure || url.scheme === "https")); +} + +WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain) +{ + if (cookieDomain.charAt(0) !== '.') + return resourceDomain === cookieDomain; + return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)?" + cookieDomain.substring(1).escapeForRegExp() + "$"), "i"); +} diff --git a/Source/WebCore/inspector/front-end/CookiesTable.js b/Source/WebCore/inspector/front-end/CookiesTable.js index 881e9e668..706b78b8e 100644 --- a/Source/WebCore/inspector/front-end/CookiesTable.js +++ b/Source/WebCore/inspector/front-end/CookiesTable.js @@ -202,7 +202,7 @@ WebInspector.CookiesTable.prototype = { data[2] = cookie.domain || ""; data[3] = cookie.path || ""; data[4] = cookie.type === WebInspector.Cookie.Type.Request ? "" : - (cookie.session ? WebInspector.UIString("Session") : cookie.expires().toUTCString()); + (cookie.session ? WebInspector.UIString("Session") : new Date(cookie.expires).toGMTString()); data[5] = cookie.size; const checkmark = "\u2713"; data[6] = (cookie.httpOnly ? checkmark : ""); @@ -217,7 +217,7 @@ WebInspector.CookiesTable.prototype = { _onDeleteFromGrid: function(deleteCallback, node) { deleteCallback(node.cookie); - } -} + }, -WebInspector.CookiesTable.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/DOMAgent.js b/Source/WebCore/inspector/front-end/DOMAgent.js index 5f4f06162..f39a3cbb8 100644 --- a/Source/WebCore/inspector/front-end/DOMAgent.js +++ b/Source/WebCore/inspector/front-end/DOMAgent.js @@ -67,6 +67,14 @@ WebInspector.DOMNode = function(domAgent, doc, isInShadowTree, payload) { this.lastChild = null; this.parentNode = null; + if (payload.shadowRoots && WebInspector.settings.showShadowDOM.get()) { + for (var i = 0; i < payload.shadowRoots.length; ++i) { + var root = payload.shadowRoots[i]; + var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, true, root); + this._shadowRoots.push(node); + } + } + if (payload.children) this._setChildrenPayload(payload.children); @@ -76,14 +84,6 @@ WebInspector.DOMNode = function(domAgent, doc, isInShadowTree, payload) { this._renumber(); } - if (payload.shadowRoots && WebInspector.experimentsSettings.showShadowDOM.isEnabled()) { - for (var i = 0; i < payload.shadowRoots.length; ++i) { - var root = payload.shadowRoots[i]; - var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, true, root); - this._shadowRoots.push(node); - } - } - if (this._nodeType === Node.ELEMENT_NODE) { // HTML and BODY from internal iframes should not overwrite top-level ones. if (this.ownerDocument && !this.ownerDocument.documentElement && this._nodeName === "HTML") @@ -136,6 +136,14 @@ WebInspector.DOMNode.prototype = { }, /** + * @return {boolean} + */ + hasShadowRoots: function() + { + return !!this._shadowRoots.length; + }, + + /** * @return {number} */ nodeType: function() @@ -764,12 +772,15 @@ WebInspector.DOMDocument = function(domAgent, payload) { WebInspector.DOMNode.call(this, domAgent, this, false, payload); this.documentURL = payload.documentURL || ""; - this.baseURL = payload.baseURL; + this.baseURL = /** @type {string} */ payload.baseURL; + console.assert(this.baseURL); this.xmlVersion = payload.xmlVersion; this._listeners = {}; } -WebInspector.DOMDocument.prototype.__proto__ = WebInspector.DOMNode.prototype; +WebInspector.DOMDocument.prototype = { + __proto__: WebInspector.DOMNode.prototype +} /** * @extends {WebInspector.Object} @@ -1332,10 +1343,10 @@ WebInspector.DOMAgent.prototype = { this.dispatchEventToListeners(WebInspector.DOMAgent.Events.UndoRedoRequested); DOMAgent.redo(callback); - } -} + }, -WebInspector.DOMAgent.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/DOMBreakpointsSidebarPane.js b/Source/WebCore/inspector/front-end/DOMBreakpointsSidebarPane.js index abd75baca..c1b355e90 100644 --- a/Source/WebCore/inspector/front-end/DOMBreakpointsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/DOMBreakpointsSidebarPane.js @@ -323,7 +323,7 @@ WebInspector.DOMBreakpointsSidebarPane.prototype = { } pathToBreakpoints[path].push(breakpoint); } - } -} + }, -WebInspector.DOMBreakpointsSidebarPane.prototype.__proto__ = WebInspector.NativeBreakpointsSidebarPane.prototype; + __proto__: WebInspector.NativeBreakpointsSidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/DOMExtension.js b/Source/WebCore/inspector/front-end/DOMExtension.js index 3e5926409..c8eea3642 100644 --- a/Source/WebCore/inspector/front-end/DOMExtension.js +++ b/Source/WebCore/inspector/front-end/DOMExtension.js @@ -177,7 +177,7 @@ Element.prototype.pruneEmptyTextNodes = function() var sibling = this.firstChild; while (sibling) { var nextSibling = sibling.nextSibling; - if (sibling.nodeType === this.TEXT_NODE && sibling.nodeValue === "") + if (sibling.nodeType === Node.TEXT_NODE && sibling.nodeValue === "") this.removeChild(sibling); sibling = nextSibling; } diff --git a/Source/WebCore/inspector/front-end/DOMStorage.js b/Source/WebCore/inspector/front-end/DOMStorage.js index df977711a..7af442b2d 100644 --- a/Source/WebCore/inspector/front-end/DOMStorage.js +++ b/Source/WebCore/inspector/front-end/DOMStorage.js @@ -135,10 +135,10 @@ WebInspector.DOMStorageModel.prototype = { for (var storageId in this._storages) result.push(this._storages[storageId]); return result; - } -} + }, -WebInspector.DOMStorageModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/DOMStorageItemsView.js b/Source/WebCore/inspector/front-end/DOMStorageItemsView.js index d0bffb628..883fa7342 100644 --- a/Source/WebCore/inspector/front-end/DOMStorageItemsView.js +++ b/Source/WebCore/inspector/front-end/DOMStorageItemsView.js @@ -149,7 +149,7 @@ WebInspector.DOMStorageItemsView.prototype = { this.domStorage.removeItem(node.data[0]); this.update(); - } -} + }, -WebInspector.DOMStorageItemsView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/DataGrid.js b/Source/WebCore/inspector/front-end/DataGrid.js index 09790f5e2..114d82d90 100644 --- a/Source/WebCore/inspector/front-end/DataGrid.js +++ b/Source/WebCore/inspector/front-end/DataGrid.js @@ -1000,6 +1000,8 @@ WebInspector.DataGrid.prototype = { ColumnResizePadding: 10, CenterResizerOverBorderAdjustment: 3, + + __proto__: WebInspector.View.prototype } WebInspector.DataGrid.ResizeMethod = { @@ -1008,8 +1010,6 @@ WebInspector.DataGrid.ResizeMethod = { Last: "last" } -WebInspector.DataGrid.prototype.__proto__ = WebInspector.View.prototype; - /** * @constructor * @extends {WebInspector.Object} @@ -1635,10 +1635,10 @@ WebInspector.DataGridNode.prototype = { this._savedPosition.parent.insertChild(this, this._savedPosition.index); delete this._savedPosition; - } -} + }, -WebInspector.DataGridNode.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -1655,7 +1655,7 @@ WebInspector.CreationDataGridNode.prototype = { { delete this.isCreationNode; delete this.makeNormal; - } -} + }, -WebInspector.CreationDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; + __proto__: WebInspector.DataGridNode.prototype +} diff --git a/Source/WebCore/inspector/front-end/Database.js b/Source/WebCore/inspector/front-end/Database.js index caaedb587..9758c25aa 100644 --- a/Source/WebCore/inspector/front-end/Database.js +++ b/Source/WebCore/inspector/front-end/Database.js @@ -171,10 +171,10 @@ WebInspector.DatabaseModel.prototype = { { this._databases.push(database); this.dispatchEventToListeners(WebInspector.DatabaseModel.Events.DatabaseAdded, database); - } -} + }, -WebInspector.DatabaseModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/DatabaseQueryView.js b/Source/WebCore/inspector/front-end/DatabaseQueryView.js index db06c1cb2..374b66dc8 100644 --- a/Source/WebCore/inspector/front-end/DatabaseQueryView.js +++ b/Source/WebCore/inspector/front-end/DatabaseQueryView.js @@ -46,7 +46,7 @@ WebInspector.DatabaseQueryView = function(database) this.prompt = new WebInspector.TextPromptWithHistory(this.completions.bind(this), " "); this.prompt.attach(this._promptElement); - + this.element.addEventListener("click", this._messagesClicked.bind(this), true); } @@ -61,7 +61,13 @@ WebInspector.DatabaseQueryView.prototype = { this.prompt.moveCaretToEndOfPrompt(); }, - completions: function(textPrompt, wordRange, force, completionsReadyCallback) + /** + * @param {Element} proxyElement + * @param {Range} wordRange + * @param {boolean} force + * @param {function(Array.<string>, number=)} completionsReadyCallback + */ + completions: function(proxyElement, wordRange, force, completionsReadyCallback) { var prefix = wordRange.toString().toLowerCase(); if (!prefix.length && !force) @@ -193,7 +199,7 @@ WebInspector.DatabaseQueryView.prototype = { resultElement.className = "database-query-result"; element.appendChild(resultElement); return resultElement; - } -} + }, -WebInspector.DatabaseQueryView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/DatabaseTableView.js b/Source/WebCore/inspector/front-end/DatabaseTableView.js index fec50cdf5..0d5e5f832 100644 --- a/Source/WebCore/inspector/front-end/DatabaseTableView.js +++ b/Source/WebCore/inspector/front-end/DatabaseTableView.js @@ -95,7 +95,7 @@ WebInspector.DatabaseTableView.prototype = { _refreshButtonClicked: function(event) { this.update(); - } -} + }, -WebInspector.DatabaseTableView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/DebuggerModel.js b/Source/WebCore/inspector/front-end/DebuggerModel.js index 21fb45ba1..326a9be24 100644 --- a/Source/WebCore/inspector/front-end/DebuggerModel.js +++ b/Source/WebCore/inspector/front-end/DebuggerModel.js @@ -371,10 +371,12 @@ WebInspector.DebuggerModel.prototype = { * @param {number} endLine * @param {number} endColumn * @param {boolean} isContentScript + * @param {string=} sourceMapURL + * @param {boolean=} hasSourceURL */ - _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL) + _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL) { - var script = new WebInspector.Script(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL); + var script = new WebInspector.Script(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL); this._registerScript(script); this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script); }, @@ -586,10 +588,10 @@ WebInspector.DebuggerModel.prototype = { this._pausedScript(newCallFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData); } - } -} + }, -WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} WebInspector.DebuggerEventTypes = { JavaScriptPause: 0, @@ -637,10 +639,11 @@ WebInspector.DebuggerDispatcher.prototype = { * @param {number} endColumn * @param {boolean=} isContentScript * @param {string=} sourceMapURL + * @param {boolean=} hasSourceURL */ - scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL) + scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL) { - this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, !!isContentScript, sourceMapURL); + this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, !!isContentScript, sourceMapURL, hasSourceURL); }, /** diff --git a/Source/WebCore/inspector/front-end/DefaultTextEditor.js b/Source/WebCore/inspector/front-end/DefaultTextEditor.js index 69c87ce12..a41dd8028 100644 --- a/Source/WebCore/inspector/front-end/DefaultTextEditor.js +++ b/Source/WebCore/inspector/front-end/DefaultTextEditor.js @@ -574,10 +574,10 @@ WebInspector.DefaultTextEditor.prototype = { if (!this.readOnly()) WebInspector.markBeingEdited(this.element, false); this._freeCachedElements(); - } -} + }, -WebInspector.DefaultTextEditor.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -1061,10 +1061,10 @@ WebInspector.TextEditorGutterPanel.prototype = { if (!decorations.length) delete this._decorations[lineNumber]; } - } -} + }, -WebInspector.TextEditorGutterPanel.prototype.__proto__ = WebInspector.TextEditorChunkedPanel.prototype; + __proto__: WebInspector.TextEditorChunkedPanel.prototype +} /** * @constructor @@ -1563,11 +1563,10 @@ WebInspector.TextEditorMainPanel.prototype = { if (lineNumber === range.startLine) newRange.startColumn = Math.max(0, newRange.startColumn - lineIndentLength); + if (lineNumber === range.endLine) + newRange.endColumn = Math.max(0, newRange.endColumn - lineIndentLength); } - if (lineIndentLength) - newRange.endColumn = Math.max(0, newRange.endColumn - lineIndentLength); - this._lastEditedRange = newRange; return newRange; @@ -2030,7 +2029,7 @@ WebInspector.TextEditorMainPanel.prototype = { var rangeBoundary = lineRow.rangeBoundaryForOffset(column); else { var offset = column; - for (var i = chunk.startLine; i < line; ++i) + for (var i = chunk.startLine; i < line && i < this._textModel.linesCount; ++i) offset += this._textModel.lineLength(i) + 1; // \n lineRow = chunk.element; if (lineRow.firstChild) @@ -2509,10 +2508,10 @@ WebInspector.TextEditorMainPanel.prototype = { textContents = textContent.split("\n"); for (var i = 0; i < textContents.length; ++i) lines.push(textContents[i]); - } -} + }, -WebInspector.TextEditorMainPanel.prototype.__proto__ = WebInspector.TextEditorChunkedPanel.prototype; + __proto__: WebInspector.TextEditorChunkedPanel.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/Dialog.js b/Source/WebCore/inspector/front-end/Dialog.js index 634e1fcc9..eb5797dc8 100644 --- a/Source/WebCore/inspector/front-end/Dialog.js +++ b/Source/WebCore/inspector/front-end/Dialog.js @@ -178,7 +178,8 @@ WebInspector.DialogDelegate.prototype = { onEnter: function() { }, - willHide: function() { } -}; + willHide: function() { }, + + __proto__: WebInspector.Object.prototype +} -WebInspector.DialogDelegate.prototype.__proto__ = WebInspector.Object.prototype; diff --git a/Source/WebCore/inspector/front-end/DirectoryContentView.js b/Source/WebCore/inspector/front-end/DirectoryContentView.js index 21ced2515..144260fcb 100644 --- a/Source/WebCore/inspector/front-end/DirectoryContentView.js +++ b/Source/WebCore/inspector/front-end/DirectoryContentView.js @@ -86,10 +86,10 @@ WebInspector.DirectoryContentView.prototype = { { var column = /** @type {string} */ this.sortColumnIdentifier; this.sortNodes(WebInspector.DirectoryContentView.Node.comparator(column, this.sortOrder === "descending"), false); - } -} + }, -WebInspector.DirectoryContentView.prototype.__proto__ = WebInspector.DataGrid.prototype; + __proto__: WebInspector.DataGrid.prototype +} /** * @constructor @@ -193,7 +193,7 @@ WebInspector.DirectoryContentView.Node.prototype = { data[indexes.Size] = Number.bytesToString(metadata.size); data[indexes.ModificationTime] = new Date(metadata.modificationTime).toGMTString(); this.data = data; - } -} + }, -WebInspector.DirectoryContentView.Node.prototype.__proto__ = WebInspector.DataGridNode.prototype; + __proto__: WebInspector.DataGridNode.prototype +} diff --git a/Source/WebCore/inspector/front-end/DockController.js b/Source/WebCore/inspector/front-end/DockController.js new file mode 100644 index 000000000..56694686f --- /dev/null +++ b/Source/WebCore/inspector/front-end/DockController.js @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @constructor + */ +WebInspector.DockController = function() +{ + this._dockToggleButton = new WebInspector.StatusBarButton("", "dock-status-bar-item", 3); + this._dockToggleButtonOption = new WebInspector.StatusBarButton("", "dock-status-bar-item", 3); + this._dockToggleButton.addEventListener("click", this._toggleDockState, this); + this._dockToggleButtonOption.addEventListener("click", this._toggleDockState, this); + if (Preferences.showDockToRight) + this._dockToggleButton.makeLongClickEnabled(this._createDockOptions.bind(this)); + + this._dockSide = WebInspector.queryParamsObject["dockSide"]; + this._innerSetDocked(WebInspector.queryParamsObject["docked"] === "true"); +} + +WebInspector.DockController.State = { + DockedToBottom: "bottom", + DockedToRight: "right", + Undocked: "undocked" +} + +WebInspector.DockController.prototype = { + /** + * @return {Element} + */ + get element() + { + return this._dockToggleButton.element; + }, + + /** + * @param {boolean} docked + */ + setDocked: function(docked) + { + var isDocked = this._state !== WebInspector.DockController.State.Undocked; + if (docked !== isDocked) + this._innerSetDocked(docked); + }, + + /** + * @param {boolean} docked + */ + _innerSetDocked: function(docked) + { + if (this._state) + WebInspector.settings.lastDockState.set(this._state); + + if (!docked) { + this._state = WebInspector.DockController.State.Undocked; + WebInspector.userMetrics.WindowDocked.record(); + } else if (this._dockSide === "right") { + this._state = WebInspector.DockController.State.DockedToRight; + WebInspector.userMetrics.WindowUndocked.record(); + } else { + this._state = WebInspector.DockController.State.DockedToBottom; + WebInspector.userMetrics.WindowUndocked.record(); + } + this._updateUI(); + }, + + /** + * @param {boolean} unavailable + */ + setDockingUnavailable: function(unavailable) + { + this._isDockingUnavailable = unavailable; + this._updateUI(); + }, + + _updateUI: function() + { + var body = document.body; + switch (this._state) { + case WebInspector.DockController.State.DockedToBottom: + body.removeStyleClass("undocked"); + body.removeStyleClass("dock-to-right"); + this.setCompactMode(true); + break; + case WebInspector.DockController.State.DockedToRight: + body.removeStyleClass("undocked"); + body.addStyleClass("dock-to-right"); + this.setCompactMode(false); + break; + case WebInspector.DockController.State.Undocked: + body.addStyleClass("undocked"); + body.removeStyleClass("dock-to-right"); + this.setCompactMode(false); + break; + } + + if (this._isDockingUnavailable) { + this._dockToggleButton.state = "undock"; + this._dockToggleButton.disabled = true; + return; + } + + this._dockToggleButton.disabled = false; + + // Choose different last state based on the current one if missing or if is the same. + var states = [WebInspector.DockController.State.DockedToBottom, WebInspector.DockController.State.Undocked, WebInspector.DockController.State.DockedToRight]; + states.remove(this._state); + var lastState = WebInspector.settings.lastDockState.get(); + + states.remove(lastState); + if (states.length === 2) { // last state was not from the list of potential values + lastState = states[0]; + states.remove(lastState); + } + this._decorateButtonForTargetState(this._dockToggleButton, lastState); + this._decorateButtonForTargetState(this._dockToggleButtonOption, states[0]); + }, + + /** + * @param {WebInspector.StatusBarButton} button + * @param {string} state + */ + _decorateButtonForTargetState: function(button, state) + { + switch (state) { + case WebInspector.DockController.State.DockedToBottom: + button.title = WebInspector.UIString("Dock to main window."); + button.state = "bottom"; + break; + case WebInspector.DockController.State.DockedToRight: + button.title = WebInspector.UIString("Dock to main window."); + button.state = "right"; + break; + case WebInspector.DockController.State.Undocked: + button.title = WebInspector.UIString("Undock into separate window."); + button.state = "undock"; + break; + } + }, + + _createDockOptions: function() + { + return [this._dockToggleButtonOption]; + }, + + /** + * @param {WebInspector.Event} e + */ + _toggleDockState: function(e) + { + var state = e.target.state; + switch (state) { + case "undock": + InspectorFrontendHost.requestDetachWindow(); + WebInspector.userMetrics.WindowUndocked.record(); + break; + case "right": + case "bottom": + this._dockSide = state; + InspectorFrontendHost.requestSetDockSide(this._dockSide); + if (this._state === WebInspector.DockController.State.Undocked) + InspectorFrontendHost.requestAttachWindow(); + else + this._innerSetDocked(true); + break; + } + }, + + /** + * @return {boolean} + */ + isCompactMode: function() + { + return this._isCompactMode; + }, + + /** + * @param {boolean} isCompactMode + */ + setCompactMode: function(isCompactMode) + { + var body = document.body; + this._isCompactMode = isCompactMode; + if (WebInspector.toolbar) + WebInspector.toolbar.setCompactMode(isCompactMode); + if (isCompactMode) + body.addStyleClass("compact"); + else + body.removeStyleClass("compact"); + } +} diff --git a/Source/WebCore/inspector/front-end/ElementsPanel.js b/Source/WebCore/inspector/front-end/ElementsPanel.js index 2fa6fc3db..b7bb2f6ac 100644 --- a/Source/WebCore/inspector/front-end/ElementsPanel.js +++ b/Source/WebCore/inspector/front-end/ElementsPanel.js @@ -103,6 +103,8 @@ WebInspector.ElementsPanel = function() this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this)); this._popoverHelper.setTimeout(0); + WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, this._updateBreadcrumbIfNeeded, this); + WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrRemoved, this._updateBreadcrumbIfNeeded, this); WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.NodeRemoved, this._nodeRemoved, this); WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._documentUpdatedEvent, this); WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.InspectElementRequested, this._inspectElementRequested, this); @@ -596,6 +598,24 @@ WebInspector.ElementsPanel.prototype = { this._mouseOutOfCrumbsTimeout = setTimeout(this.updateBreadcrumbSizes.bind(this), 1000); }, + _updateBreadcrumbIfNeeded: function(event) + { + var name = event.data.name; + if (name !== "class" && name !== "id") + return; + + var node = /** @type {WebInspector.DOMNode} */ event.data.node; + var crumbs = this.crumbsElement; + var crumb = crumbs.firstChild; + while (crumb) { + if (crumb.representedObject === node) { + this.updateBreadcrumb(true); + break; + } + crumb = crumb.nextSibling; + } + }, + /** * @param {boolean=} forceUpdate */ @@ -1117,7 +1137,7 @@ WebInspector.ElementsPanel.prototype = { } contextMenu.appendItem(WebInspector.UIString("Reveal in Elements Panel"), revealElement.bind(this)); - } -} + }, -WebInspector.ElementsPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} diff --git a/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js b/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js index d524d15a8..b7ced2af3 100644 --- a/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js +++ b/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js @@ -50,7 +50,7 @@ WebInspector.ElementsPanelDescriptor.prototype = { if (remoteObject.subtype !== "node") return; this.panel().appendApplicableItems(contextMenu, target); - } -} + }, -WebInspector.ElementsPanelDescriptor.prototype.__proto__ = WebInspector.PanelDescriptor.prototype; + __proto__: WebInspector.PanelDescriptor.prototype +} diff --git a/Source/WebCore/inspector/front-end/ElementsTreeOutline.js b/Source/WebCore/inspector/front-end/ElementsTreeOutline.js index 07843c96b..20f149e37 100644 --- a/Source/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/Source/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -586,10 +586,10 @@ WebInspector.ElementsTreeOutline.prototype = { newTreeItem.expand(); } return newTreeItem; - } -} + }, -WebInspector.ElementsTreeOutline.prototype.__proto__ = TreeOutline.prototype; + __proto__: TreeOutline.prototype +} /** * @interface @@ -647,10 +647,10 @@ WebInspector.ElementsTreeOutline.PseudoStateDecorator.prototype = { if (descendantCount === 1) return WebInspector.UIString("%d descendant with forced state", descendantCount); return WebInspector.UIString("%d descendants with forced state", descendantCount); - } -} + }, -WebInspector.ElementsTreeOutline.PseudoStateDecorator.prototype.__proto__ = WebInspector.ElementsTreeOutline.ElementDecorator.prototype; + __proto__: WebInspector.ElementsTreeOutline.ElementDecorator.prototype +} /** * @constructor @@ -1387,6 +1387,8 @@ WebInspector.ElementsTreeElement.prototype = { event.consume(true); } + initialValue = this._convertWhitespaceToEntities(initialValue); + this._htmlEditElement = document.createElement("div"); this._htmlEditElement.className = "source-code elements-tree-editor"; this._htmlEditElement.textContent = initialValue; @@ -1857,6 +1859,9 @@ WebInspector.ElementsTreeElement.prototype = { if (!firstChild || firstChild.nodeType() !== Node.TEXT_NODE) return null; + if (node.hasShadowRoots()) + return null; + var sibling = firstChild.nextSibling; return sibling ? null : firstChild; }, @@ -1985,10 +1990,10 @@ WebInspector.ElementsTreeElement.prototype = { var node = /** @type {WebInspector.DOMNode} */ this.representedObject; WebInspector.RemoteObject.resolveNode(node, "", scrollIntoViewCallback); - } -} + }, -WebInspector.ElementsTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/EmptyView.js b/Source/WebCore/inspector/front-end/EmptyView.js index 4b7ceee5e..d7a65af27 100644 --- a/Source/WebCore/inspector/front-end/EmptyView.js +++ b/Source/WebCore/inspector/front-end/EmptyView.js @@ -51,6 +51,7 @@ WebInspector.EmptyView.prototype = { if (this.isShowing()) this.element.textContent = this._text; }, + + __proto__: WebInspector.View.prototype } -WebInspector.EmptyView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js b/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js index 55ebdb084..294afbbd7 100644 --- a/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js +++ b/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js @@ -133,10 +133,10 @@ WebInspector.EventListenersSidebarPane.prototype = { var selectedOption = this.settingsSelectElement[this.settingsSelectElement.selectedIndex]; WebInspector.settings.eventListenersFilter.set(selectedOption.value); this.update(this._selectedNode); - } -} + }, -WebInspector.EventListenersSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -164,10 +164,10 @@ WebInspector.EventListenersSection.prototype = { { var eventListenerBar = new WebInspector.EventListenerBar(eventListener, this._nodeId, this._linkifier); this._eventBars.appendChild(eventListenerBar.element); - } -} + }, -WebInspector.EventListenersSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype; + __proto__: WebInspector.PropertiesSection.prototype +} /** * @constructor @@ -256,7 +256,7 @@ WebInspector.EventListenerBar.prototype = { else this.subtitleElement.textContent = WebInspector.UIString("(anonymous function)"); } - } -} + }, -WebInspector.EventListenerBar.prototype.__proto__ = WebInspector.ObjectPropertiesSection.prototype; + __proto__: WebInspector.ObjectPropertiesSection.prototype +} diff --git a/Source/WebCore/inspector/front-end/ExtensionAPI.js b/Source/WebCore/inspector/front-end/ExtensionAPI.js index a45d83bc3..583a7171d 100644 --- a/Source/WebCore/inspector/front-end/ExtensionAPI.js +++ b/Source/WebCore/inspector/front-end/ExtensionAPI.js @@ -378,10 +378,10 @@ PanelWithSidebarImpl.prototype = { callback(new ExtensionSidebarPane(id)); } extensionServer.sendRequest(request, callback && callbackWrapper); - } -} + }, -PanelWithSidebarImpl.prototype.__proto__ = ExtensionViewImpl.prototype; + __proto__: ExtensionViewImpl.prototype +} /** * @constructor @@ -430,10 +430,10 @@ ExtensionPanelImpl.prototype = { id: this._id }; extensionServer.sendRequest(request); - } -}; + }, -ExtensionPanelImpl.prototype.__proto__ = ExtensionViewImpl.prototype; + __proto__: ExtensionViewImpl.prototype +} /** * @constructor @@ -750,6 +750,9 @@ function ExtensionServerClient() } ExtensionServerClient.prototype = { + /** + * @param {function()=} callback + */ sendRequest: function(message, callback) { if (typeof callback === "function") diff --git a/Source/WebCore/inspector/front-end/ExtensionPanel.js b/Source/WebCore/inspector/front-end/ExtensionPanel.js index f96d9e99e..043bcc162 100644 --- a/Source/WebCore/inspector/front-end/ExtensionPanel.js +++ b/Source/WebCore/inspector/front-end/ExtensionPanel.js @@ -88,10 +88,10 @@ WebInspector.ExtensionPanel.prototype = { { WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PreviousSearchResult); WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this); - } -} + }, -WebInspector.ExtensionPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} /** * @constructor @@ -240,7 +240,7 @@ WebInspector.ExtensionSidebarPane.prototype = { section.editable = false; this._objectPropertiesView.element.appendChild(section.element); callback(); - } -} + }, -WebInspector.ExtensionSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/ExtensionView.js b/Source/WebCore/inspector/front-end/ExtensionView.js index 170db0b6b..01aecd69c 100644 --- a/Source/WebCore/inspector/front-end/ExtensionView.js +++ b/Source/WebCore/inspector/front-end/ExtensionView.js @@ -68,10 +68,10 @@ WebInspector.ExtensionView.prototype = { this._frameIndex = Array.prototype.indexOf.call(window.frames, this._iframe.contentWindow); if (this.isShowing()) WebInspector.extensionServer.notifyViewShown(this._id, this._frameIndex); - } -} + }, -WebInspector.ExtensionView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -94,7 +94,7 @@ WebInspector.ExtensionNotifierView.prototype = { willHide: function() { WebInspector.extensionServer.notifyViewHidden(this._id); - } -} + }, -WebInspector.ExtensionNotifierView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/FileContentView.js b/Source/WebCore/inspector/front-end/FileContentView.js index c074128ee..b8ccd9ad1 100644 --- a/Source/WebCore/inspector/front-end/FileContentView.js +++ b/Source/WebCore/inspector/front-end/FileContentView.js @@ -85,10 +85,10 @@ WebInspector.FileContentView.prototype = { if (this._file.isTextFile) this._file.requestMetadata(this._metadataReceived.bind(this)); - } -} + }, -WebInspector.FileContentView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -104,7 +104,7 @@ WebInspector.FileContentView.FileContentProvider = function(file, metadata) WebInspector.FileContentView.FileContentProvider.prototype = { /** - * @return {?string} + * @return {string} */ contentURL: function() { diff --git a/Source/WebCore/inspector/front-end/FileManager.js b/Source/WebCore/inspector/front-end/FileManager.js index ad101d74a..6b108d3f0 100644 --- a/Source/WebCore/inspector/front-end/FileManager.js +++ b/Source/WebCore/inspector/front-end/FileManager.js @@ -108,9 +108,9 @@ WebInspector.FileManager.prototype = { appendedToURL: function(url) { this.dispatchEventToListeners(WebInspector.FileManager.EventTypes.AppendedToURL, url); - } -} + }, -WebInspector.FileManager.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} WebInspector.fileManager = new WebInspector.FileManager(); diff --git a/Source/WebCore/inspector/front-end/FileSystemModel.js b/Source/WebCore/inspector/front-end/FileSystemModel.js index 81439ce80..ca5bf7300 100644 --- a/Source/WebCore/inspector/front-end/FileSystemModel.js +++ b/Source/WebCore/inspector/front-end/FileSystemModel.js @@ -412,16 +412,17 @@ WebInspector.FileSystemModel.prototype = { if (Object.isEmpty(this._fileSystemsForOrigin[origin])) delete this._fileSystemsForOrigin[origin]; } - } + }, + + __proto__: WebInspector.Object.prototype } + WebInspector.FileSystemModel.EventTypes = { FileSystemAdded: "FileSystemAdded", FileSystemRemoved: "FileSystemRemoved" } -WebInspector.FileSystemModel.prototype.__proto__ = WebInspector.Object.prototype; - /** * @constructor * @param {WebInspector.FileSystemModel} fileSystemModel @@ -552,10 +553,10 @@ WebInspector.FileSystemModel.Directory.prototype = { requestDirectoryContent: function(callback) { this.fileSystemModel.requestDirectoryContent(this, callback); - } -} + }, -WebInspector.FileSystemModel.Directory.prototype.__proto__ = WebInspector.FileSystemModel.Entry.prototype; + __proto__: WebInspector.FileSystemModel.Entry.prototype +} /** * @constructor @@ -608,7 +609,7 @@ WebInspector.FileSystemModel.File.prototype = { requestFileContent: function(readAsText, start, end, charset, callback) { this.fileSystemModel.requestFileContent(this, readAsText, start, end, charset, callback); - } -} + }, -WebInspector.FileSystemModel.File.prototype.__proto__ = WebInspector.FileSystemModel.Entry.prototype; + __proto__: WebInspector.FileSystemModel.Entry.prototype +} diff --git a/Source/WebCore/inspector/front-end/FileSystemView.js b/Source/WebCore/inspector/front-end/FileSystemView.js index 60b9f4259..174e3450b 100644 --- a/Source/WebCore/inspector/front-end/FileSystemView.js +++ b/Source/WebCore/inspector/front-end/FileSystemView.js @@ -103,10 +103,10 @@ WebInspector.FileSystemView.prototype = { _delete: function() { this._directoryTree.selectedTreeElement.deleteEntry(); - } -} + }, -WebInspector.FileSystemView.prototype.__proto__ = WebInspector.SplitView.prototype; + __proto__: WebInspector.SplitView.prototype +} /** * @constructor @@ -227,7 +227,7 @@ WebInspector.FileSystemView.EntryTreeElement.prototype = { { if (this._entry != this._entry.fileSystem.root) this.parent.refresh(); - } -} + }, -WebInspector.FileSystemView.EntryTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/FileUtils.js b/Source/WebCore/inspector/front-end/FileUtils.js index a0bea203e..7e95bdfc8 100644 --- a/Source/WebCore/inspector/front-end/FileUtils.js +++ b/Source/WebCore/inspector/front-end/FileUtils.js @@ -36,11 +36,19 @@ WebInspector.OutputStreamDelegate = function() } WebInspector.OutputStreamDelegate.prototype = { - onTransferStarted: function(source) { }, + onTransferStarted: function() { }, - onChunkTransferred: function(source) { }, + onTransferFinished: function() { }, - onError: function(source, event) { } + /** + * @param {WebInspector.ChunkedReader} reader + */ + onChunkTransferred: function(reader) { }, + + /** + * @param {WebInspector.ChunkedReader} reader + */ + onError: function(reader, event) { }, } /** @@ -61,7 +69,34 @@ WebInspector.OutputStream.prototype = { } /** + * @interface + */ +WebInspector.ChunkedReader = function() +{ +} + +WebInspector.ChunkedReader.prototype = { + /** + * @return {number} + */ + fileSize: function() { }, + + /** + * @return {number} + */ + loadedSize: function() { }, + + /** + * @return {string} + */ + fileName: function() { }, + + cancel: function() { } +} + +/** * @constructor + * @implements {WebInspector.ChunkedReader} * @param {!File} file * @param {number} chunkSize * @param {!WebInspector.OutputStreamDelegate} delegate @@ -87,7 +122,7 @@ WebInspector.ChunkedFileReader.prototype = { this._reader = new FileReader(); this._reader.onload = this._onChunkLoaded.bind(this); this._reader.onerror = this._delegate.onError.bind(this._delegate, this); - this._delegate.onTransferStarted(this); + this._delegate.onTransferStarted(); this._loadChunk(); }, @@ -96,16 +131,25 @@ WebInspector.ChunkedFileReader.prototype = { this._isCanceled = true; }, + /** + * @return {number} + */ loadedSize: function() { return this._loadedSize; }, + /** + * @return {number} + */ fileSize: function() { return this._fileSize; }, + /** + * @return {string} + */ fileName: function() { return this._file.name; @@ -134,7 +178,7 @@ WebInspector.ChunkedFileReader.prototype = { this._file = null; this._reader = null; this._output.close(); - this._delegate.onTransferFinished(this); + this._delegate.onTransferFinished(); return; } @@ -152,6 +196,7 @@ WebInspector.ChunkedFileReader.prototype = { /** * @constructor + * @implements {WebInspector.ChunkedReader} * @param {string} url * @param {!WebInspector.OutputStreamDelegate} delegate */ @@ -179,7 +224,7 @@ WebInspector.ChunkedXHRReader.prototype = { this._xhr.onerror = this._delegate.onError.bind(this._delegate, this); this._xhr.send(null); - this._delegate.onTransferStarted(this); + this._delegate.onTransferStarted(); }, cancel: function() @@ -188,16 +233,25 @@ WebInspector.ChunkedXHRReader.prototype = { this._xhr.abort(); }, + /** + * @return {number} + */ loadedSize: function() { return this._loadedSize; }, + /** + * @return {number} + */ fileSize: function() { return this._fileSize; }, + /** + * @return {string} + */ fileName: function() { return this._url; @@ -236,7 +290,7 @@ WebInspector.ChunkedXHRReader.prototype = { return; this._output.close(); - this._delegate.onTransferFinished(this); + this._delegate.onTransferFinished(); } } diff --git a/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js b/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js index 41340a894..6d6cb4b58 100644 --- a/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js +++ b/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js @@ -202,7 +202,7 @@ WebInspector.FilteredItemSelectionDialog.prototype = { regExpString = regExpString.replace(/(?!^)(\\\.|[_:-])/g, "[^._:-]*$1"); else regExpString = regExpString.replace(/(?!^)(\\\.|[A-Z_:-])/g, "[^.A-Z_:-]*$1"); - regExpString = "^" + "[^a-zA-Z0-9]*" + regExpString; + regExpString = regExpString; return new RegExp(regExpString, (ignoreCase ? "i" : "") + (isGlobal ? "g" : "")); }, @@ -409,10 +409,10 @@ WebInspector.FilteredItemSelectionDialog.prototype = { if (itemElement.offsetTop > this._itemElementsContainer.scrollTop + this._itemHeight * (this._rowsPerViewport + 1)) return false; return true; - } -} + }, -WebInspector.FilteredItemSelectionDialog.prototype.__proto__ = WebInspector.DialogDelegate.prototype; + __proto__: WebInspector.DialogDelegate.prototype +} /** * @interface @@ -600,10 +600,10 @@ WebInspector.JavaScriptOutlineDialog.prototype = { rewriteQuery: function(query) { return query; - } -} + }, -WebInspector.JavaScriptOutlineDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype; + __proto__: WebInspector.SelectionDialogContentProvider.prototype +} /** * @constructor @@ -707,10 +707,10 @@ WebInspector.OpenResourceDialog.prototype = { var lineNumberMatch = query.match(/([^:]+)(\:[\d]*)$/); this._queryLineNumber = lineNumberMatch ? lineNumberMatch[2] : ""; return lineNumberMatch ? lineNumberMatch[1] : query; - } -} + }, -WebInspector.OpenResourceDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype; + __proto__: WebInspector.SelectionDialogContentProvider.prototype +} /** * @param {WebInspector.ScriptsPanel} panel diff --git a/Source/WebCore/inspector/front-end/FontView.js b/Source/WebCore/inspector/front-end/FontView.js index a09c37221..64dbd5b6b 100644 --- a/Source/WebCore/inspector/front-end/FontView.js +++ b/Source/WebCore/inspector/front-end/FontView.js @@ -135,7 +135,7 @@ WebInspector.FontView.prototype = { var finalFontSize = Math.floor(WebInspector.FontView._measureFontSize * Math.min(widthRatio, heightRatio)) - 2; this.fontPreviewElement.style.setProperty("font-size", finalFontSize + "px", null); - } -} + }, -WebInspector.FontView.prototype.__proto__ = WebInspector.ResourceView.prototype; + __proto__: WebInspector.ResourceView.prototype +} diff --git a/Source/WebCore/inspector/front-end/GoToLineDialog.js b/Source/WebCore/inspector/front-end/GoToLineDialog.js index a44dc3ef3..ac41b7ad9 100644 --- a/Source/WebCore/inspector/front-end/GoToLineDialog.js +++ b/Source/WebCore/inspector/front-end/GoToLineDialog.js @@ -108,7 +108,7 @@ WebInspector.GoToLineDialog.prototype = { onEnter: function() { this._applyLineNumber(); - } -} + }, -WebInspector.GoToLineDialog.prototype.__proto__ = WebInspector.DialogDelegate.prototype; + __proto__: WebInspector.DialogDelegate.prototype +} diff --git a/Source/WebCore/inspector/front-end/HandlerRegistry.js b/Source/WebCore/inspector/front-end/HandlerRegistry.js index ef47a7694..5c8cc74d2 100644 --- a/Source/WebCore/inspector/front-end/HandlerRegistry.js +++ b/Source/WebCore/inspector/front-end/HandlerRegistry.js @@ -175,15 +175,16 @@ WebInspector.HandlerRegistry.prototype = { if (WebInspector.resourceForURL(resourceURL)) contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open link in Resources panel" : "Open Link in Resources Panel"), WebInspector.openResource.bind(null, resourceURL, true)); contextMenu.appendItem(WebInspector.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(InspectorFrontendHost, resourceURL)); - } + }, + + __proto__: WebInspector.Object.prototype } + WebInspector.HandlerRegistry.EventTypes = { HandlersUpdated: "HandlersUpdated" } -WebInspector.HandlerRegistry.prototype.__proto__ = WebInspector.Object.prototype; - /** * @constructor */ diff --git a/Source/WebCore/inspector/front-end/HeapSnapshot.js b/Source/WebCore/inspector/front-end/HeapSnapshot.js index 169654056..a44d7f6f4 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshot.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshot.js @@ -1904,10 +1904,11 @@ WebInspector.HeapSnapshotEdgesProvider.prototype = { this._iterationOrder.sortRange(compareNodeAndEdge, leftBound, rightBound, count); else this._iterationOrder.sortRange(compareNodeAndNode, leftBound, rightBound, count); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype +} -WebInspector.HeapSnapshotEdgesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype; /** * @constructor @@ -1981,7 +1982,8 @@ WebInspector.HeapSnapshotNodesProvider.prototype = { } this._iterationOrder.sortRange(sortByComparator, leftBound, rightBound, count); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype +} -WebInspector.HeapSnapshotNodesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype; diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js b/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js index 3a22b8bac..1ca3fbb27 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js @@ -252,10 +252,11 @@ WebInspector.HeapSnapshotSortableDataGrid.prototype = { return; if (!--this._recursiveSortingDepth) this.dispatchEventToListeners("sorting complete"); - } -}; + }, + + __proto__: WebInspector.DataGrid.prototype +} -WebInspector.HeapSnapshotSortableDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype; /** @@ -393,10 +394,10 @@ WebInspector.HeapSnapshotViewportDataGrid.prototype = { WebInspector.HeapSnapshotSortableDataGrid.prototype.highlightNode.call(this, this._nodeToHighlightAfterScroll); this._nodeToHighlightAfterScroll = null; } - } -} + }, -WebInspector.HeapSnapshotViewportDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype; + __proto__: WebInspector.HeapSnapshotSortableDataGrid.prototype +} /** * @constructor @@ -450,10 +451,11 @@ WebInspector.HeapSnapshotContainmentDataGrid.prototype = { sortingChanged: function() { this.rootNode().sort(); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotSortableDataGrid.prototype +} -WebInspector.HeapSnapshotContainmentDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype; /** * @constructor @@ -488,9 +490,10 @@ WebInspector.HeapSnapshotRetainmentDataGrid.prototype = { this.rootNode().removeChildren(); this.resetSortingCache(); }, + + __proto__: WebInspector.HeapSnapshotContainmentDataGrid.prototype } -WebInspector.HeapSnapshotRetainmentDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotContainmentDataGrid.prototype; /** * @constructor @@ -597,9 +600,9 @@ WebInspector.HeapSnapshotConstructorsDataGrid.prototype = { this._populateChildren(); }, -}; + __proto__: WebInspector.HeapSnapshotViewportDataGrid.prototype +} -WebInspector.HeapSnapshotConstructorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotViewportDataGrid.prototype; /** * @constructor @@ -682,10 +685,11 @@ WebInspector.HeapSnapshotDiffDataGrid.prototype = { // we first need to collect information about the nodes in the first snapshot and // then pass it to the second snapshot to calclulate the diff. this.baseSnapshot.aggregatesForDiff(aggregatesForDiffReceived.bind(this)); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotViewportDataGrid.prototype +} -WebInspector.HeapSnapshotDiffDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotViewportDataGrid.prototype; /** * @constructor @@ -769,7 +773,8 @@ WebInspector.HeapSnapshotDominatorsDataGrid.prototype = { } this.snapshot.dominatorIdsForNode(parseInt(id, 10), didGetDominators.bind(this)); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotSortableDataGrid.prototype +} -WebInspector.HeapSnapshotDominatorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype; diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js b/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js index 88564f1f8..40e815400 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js @@ -331,10 +331,11 @@ WebInspector.HeapSnapshotGridNode.prototype = { } this._provider().sortAndRewind(this.comparator(), afterSort.bind(this)); - } -}; + }, + + __proto__: WebInspector.DataGridNode.prototype +} -WebInspector.HeapSnapshotGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; /** * @constructor @@ -505,10 +506,10 @@ WebInspector.HeapSnapshotGenericObjectNode.prototype = { return fullName.substr(0, startPos + 2) + url + fullName.substr(endPos); } else return fullName; - } -} + }, -WebInspector.HeapSnapshotGenericObjectNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype; + __proto__: WebInspector.HeapSnapshotGridNode.prototype +} /** * @constructor @@ -636,10 +637,10 @@ WebInspector.HeapSnapshotObjectNode.prototype = { separatorSpan.className = "grayed"; separatorSpan.textContent = this.showRetainingEdges ? " in " : " :: "; div.appendChild(separatorSpan); - } -} + }, -WebInspector.HeapSnapshotObjectNode.prototype.__proto__ = WebInspector.HeapSnapshotGenericObjectNode.prototype; + __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype +} /** * @constructor @@ -720,10 +721,10 @@ WebInspector.HeapSnapshotInstanceNode.prototype = { get isDeletedNode() { return this._isDeletedNode; - } -} + }, -WebInspector.HeapSnapshotInstanceNode.prototype.__proto__ = WebInspector.HeapSnapshotGenericObjectNode.prototype; + __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype +} /** * @constructor @@ -850,10 +851,11 @@ WebInspector.HeapSnapshotConstructorNode.prototype = { get _shallowSizePercent() { return this._shallowSize / this.dataGrid.snapshot.totalSize * 100.0; - } -}; + }, + + __proto__: WebInspector.HeapSnapshotGridNode.prototype +} -WebInspector.HeapSnapshotConstructorNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype; /** * @constructor @@ -1017,10 +1019,11 @@ WebInspector.HeapSnapshotDiffNode.prototype = { data["sizeDelta"] = this._signForDelta(this._sizeDelta) + Number.withThousandsSeparator(Math.abs(this._sizeDelta)); return data; - } -}; + }, + + __proto__: WebInspector.HeapSnapshotGridNode.prototype +} -WebInspector.HeapSnapshotDiffNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype; /** * @constructor @@ -1104,7 +1107,8 @@ WebInspector.HeapSnapshotDominatorObjectNode.prototype = { _emptyData: function() { return {}; - } -}; + }, + + __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype +} -WebInspector.HeapSnapshotDominatorObjectNode.prototype.__proto__ = WebInspector.HeapSnapshotGenericObjectNode.prototype; diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js b/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js index 1b24ba20f..9ebeb8f76 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js @@ -42,10 +42,10 @@ WebInspector.HeapSnapshotWorkerWrapper.prototype = { }, terminate: function() { - } -} + }, -WebInspector.HeapSnapshotWorkerWrapper.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -84,10 +84,11 @@ WebInspector.HeapSnapshotRealWorker.prototype = { terminate: function() { this._worker.terminate(); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotWorkerWrapper.prototype +} -WebInspector.HeapSnapshotRealWorker.prototype.__proto__ = WebInspector.HeapSnapshotWorkerWrapper.prototype; /** * @constructor @@ -165,10 +166,11 @@ WebInspector.HeapSnapshotFakeWorker.prototype = { this.dispatchEventToListeners("message", message); } this._asyncTaskQueue.addTask(send.bind(this)); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotWorkerWrapper.prototype +} -WebInspector.HeapSnapshotFakeWorker.prototype.__proto__ = WebInspector.HeapSnapshotWorkerWrapper.prototype; /** * @constructor @@ -295,10 +297,11 @@ WebInspector.HeapSnapshotWorker.prototype = { _postMessage: function(message) { this._worker.postMessage(message); - } -}; + }, + + __proto__: WebInspector.Object.prototype +} -WebInspector.HeapSnapshotWorker.prototype.__proto__ = WebInspector.Object.prototype; /** * @constructor @@ -360,21 +363,10 @@ WebInspector.HeapSnapshotProxyObject.prototype = { WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId) { WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId); - this._started = false; this._pendingSnapshotConsumers = []; } WebInspector.HeapSnapshotLoaderProxy.prototype = { - startTransfer: function() - { - this._started = true; - }, - - isStarted: function() - { - return this._started; - }, - /** * @param {function(WebInspector.HeapSnapshotProxy)} callback */ @@ -385,10 +377,11 @@ WebInspector.HeapSnapshotLoaderProxy.prototype = { /** * @param {string} chunk + * @param {function(WebInspector.OutputStream)=} callback */ - write: function(chunk) + write: function(chunk, callback) { - this.callMethod(null, "write", chunk); + this.callMethod(callback, "write", chunk); }, close: function() @@ -406,15 +399,14 @@ WebInspector.HeapSnapshotLoaderProxy.prototype = { { for (var i = 0; i < this._pendingSnapshotConsumers.length; ++i) this._pendingSnapshotConsumers[i](snapshotProxy); - - this._started = false; this._pendingSnapshotConsumers = []; } this.callMethod(buildSnapshot.bind(this), "close"); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotProxyObject.prototype +} -WebInspector.HeapSnapshotLoaderProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype; /** * @constructor @@ -524,10 +516,11 @@ WebInspector.HeapSnapshotProxy.prototype = { get uid() { return this._staticData.uid; - } -}; + }, + + __proto__: WebInspector.HeapSnapshotProxyObject.prototype +} -WebInspector.HeapSnapshotProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype; /** * @constructor @@ -557,7 +550,8 @@ WebInspector.HeapSnapshotProviderProxy.prototype = { sortAndRewind: function(comparator, callback) { this.callMethod(callback, "sortAndRewind", comparator); - } -}; + }, + + __proto__: WebInspector.HeapSnapshotProxyObject.prototype +} -WebInspector.HeapSnapshotProviderProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype; diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotView.js b/Source/WebCore/inspector/front-end/HeapSnapshotView.js index 35ed79677..a094b458a 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotView.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotView.js @@ -732,10 +732,11 @@ WebInspector.HeapSnapshotView.prototype = { filterOption.label = title; this.filterSelectElement.appendChild(filterOption); } - } -}; + }, + + __proto__: WebInspector.View.prototype +} -WebInspector.HeapSnapshotView.prototype.__proto__ = WebInspector.View.prototype; /** * @constructor @@ -794,10 +795,10 @@ WebInspector.HeapSnapshotProfileType.prototype = { createProfile: function(profile) { return new WebInspector.HeapProfileHeader(this, profile.title, profile.uid, profile.maxJSObjectId || 0); - } -} + }, -WebInspector.HeapSnapshotProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; + __proto__: WebInspector.ProfileType.prototype +} /** * @constructor @@ -812,7 +813,7 @@ WebInspector.HeapProfileHeader = function(type, title, uid, maxJSObjectId) WebInspector.ProfileHeader.call(this, type, title, uid); this.maxJSObjectId = maxJSObjectId; /** - * @type {WebInspector.FileOutputStream} + * @type {WebInspector.OutputStream} */ this._receiver = null; /** @@ -857,6 +858,8 @@ WebInspector.HeapProfileHeader.prototype = { } this._numberOfChunks = 0; + this._savedChunks = 0; + this._savingToFile = false; if (!this._receiver) { this._setupWorker(); this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"); @@ -889,15 +892,22 @@ WebInspector.HeapProfileHeader.prototype = { }, /** - * @param {number} savedChunksCount + * @param {number} value + * @param {number} maxValue */ - _saveStatusUpdate: function(savedChunksCount) + _updateTransferProgress: function(value, maxValue) { - if (savedChunksCount === this._totalNumberOfChunks) { - this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize); - this.sidebarElement.wait = false; - } else - this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 %d\%", (savedChunksCount * 100 / this._totalNumberOfChunks).toFixed(2)); + var percentValue = ((maxValue ? (value / maxValue) : 0) * 100).toFixed(2); + if (this._savingToFile) + this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 %d\%", percentValue); + else + this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026 %d\%", percentValue); + }, + + _updateSnapshotStatus: function() + { + this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize); + this.sidebarElement.wait = false; }, /** @@ -909,31 +919,32 @@ WebInspector.HeapProfileHeader.prototype = { this._receiver.write(chunk, callback.bind(this)); function callback() { - this._saveStatusUpdate(++this._savedChunks); - if (this._totalNumberOfChunks === this._savedChunks) - this._snapshotReceived(null); + this._updateTransferProgress(++this._savedChunks, this._totalNumberOfChunks); + if (this._totalNumberOfChunks === this._savedChunks) { + if (this._savingToFile) + this._updateSnapshotStatus(); + else + this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026"); + + this._receiver.close(); + } } }, _snapshotReceived: function(snapshotProxy) { - this._receiver.close(); this._receiver = null; if (snapshotProxy) this._snapshotProxy = snapshotProxy; - this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize); - this.sidebarElement.wait = false; + this._updateSnapshotStatus(); var worker = /** @type {WebInspector.HeapSnapshotWorker} */ this._snapshotProxy.worker; this.isTemporary = false; worker.startCheckingForLongRunningCalls(); }, - finishHeapSnapshot: function(transferFinished) + finishHeapSnapshot: function() { this._totalNumberOfChunks = this._numberOfChunks; - this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026"); - if (!transferFinished && this._receiver) - this._receiver.close(); }, /** @@ -954,9 +965,10 @@ WebInspector.HeapProfileHeader.prototype = { function onOpen() { this._savedChunks = 0; - this._saveStatusUpdate(0); + this._updateTransferProgress(0, this._totalNumberOfChunks); ProfilerAgent.getProfile(this.profileType().id, this.uid); } + this._savingToFile = true; this._fileName = this._fileName || "Heap-" + new Date().toISO8601Compact() + ".heapsnapshot"; this._receiver = new WebInspector.FileOutputStream(); this._receiver.open(this._fileName, onOpen.bind(this)); @@ -981,6 +993,7 @@ WebInspector.HeapProfileHeader.prototype = { this.sidebarElement.wait = true; this._setupWorker(); this._numberOfChunks = 0; + this._savingToFile = false; var delegate = new WebInspector.HeapSnapshotLoadFromFileDelegate(this); var fileReader = this._createFileReader(file, delegate); @@ -990,10 +1003,10 @@ WebInspector.HeapProfileHeader.prototype = { _createFileReader: function(file, delegate) { return new WebInspector.ChunkedFileReader(file, 10000000, delegate); - } -} + }, -WebInspector.HeapProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; + __proto__: WebInspector.ProfileHeader.prototype +} /** * @constructor @@ -1005,34 +1018,39 @@ WebInspector.HeapSnapshotLoadFromFileDelegate = function(snapshotHeader) } WebInspector.HeapSnapshotLoadFromFileDelegate.prototype = { - onTransferStarted: function(source) + onTransferStarted: function() { }, - onChunkTransferred: function(source) + /** + * @param {WebInspector.ChunkedReader} reader + */ + onChunkTransferred: function(reader) { - this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString( - "Loading\u2026 %d%", (source.loadedSize() * 100 / source.fileSize()).toFixed(2)); + this._snapshotHeader._updateTransferProgress(reader.loadedSize(), reader.fileSize()); }, - onTransferFinished: function(source) + onTransferFinished: function() { - this._snapshotHeader.finishHeapSnapshot(true); + this._snapshotHeader.finishHeapSnapshot(); }, - onError: function (source, e) + /** + * @param {WebInspector.ChunkedReader} reader + */ + onError: function (reader, e) { switch(e.target.error.code) { case e.target.error.NOT_FOUND_ERR: - this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString("'%s' not found.", source.fileName()); + this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString("'%s' not found.", reader.fileName()); break; case e.target.error.NOT_READABLE_ERR: - this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString("'%s' is not readable", source.fileName()); + this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString("'%s' is not readable", reader.fileName()); break; case e.target.error.ABORT_ERR: break; default: - this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString("'%s' error %d", source.fileName(), e.target.error.code); + this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString("'%s' error %d", reader.fileName(), e.target.error.code); } } } diff --git a/Source/WebCore/inspector/front-end/HelpScreen.js b/Source/WebCore/inspector/front-end/HelpScreen.js index 0855a1269..48525e665 100644 --- a/Source/WebCore/inspector/front-end/HelpScreen.js +++ b/Source/WebCore/inspector/front-end/HelpScreen.js @@ -118,7 +118,7 @@ WebInspector.HelpScreen.prototype = { // Pretend we're modal, grab focus back if we're still shown. if (this.isShowing() && !this.element.isSelfOrAncestor(event.target)) WebInspector.setCurrentFocusElement(this.element); - } -} + }, -WebInspector.HelpScreen.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/ImageView.js b/Source/WebCore/inspector/front-end/ImageView.js index 7b5cf13e0..d2c79b30b 100644 --- a/Source/WebCore/inspector/front-end/ImageView.js +++ b/Source/WebCore/inspector/front-end/ImageView.js @@ -140,7 +140,7 @@ WebInspector.ImageView.prototype = { _openInNewTab: function(event) { InspectorFrontendHost.openInNewTab(this.resource.url); - } -} + }, -WebInspector.ImageView.prototype.__proto__ = WebInspector.ResourceView.prototype; + __proto__: WebInspector.ResourceView.prototype +} diff --git a/Source/WebCore/inspector/front-end/IndexedDBModel.js b/Source/WebCore/inspector/front-end/IndexedDBModel.js index 6f9fa4200..0c4fed07e 100644 --- a/Source/WebCore/inspector/front-end/IndexedDBModel.js +++ b/Source/WebCore/inspector/front-end/IndexedDBModel.js @@ -392,7 +392,7 @@ WebInspector.IndexedDBModel.prototype = { if (!this._frames[frameId]) return; - var databaseModel = new WebInspector.IndexedDBModel.Database(databaseId, databaseWithObjectStores.version); + var databaseModel = new WebInspector.IndexedDBModel.Database(databaseId, databaseWithObjectStores.version, databaseWithObjectStores.intVersion); this._databases.put(databaseId, databaseModel); for (var i = 0; i < databaseWithObjectStores.objectStores.length; ++i) { var objectStore = databaseWithObjectStores.objectStores[i]; @@ -483,10 +483,10 @@ WebInspector.IndexedDBModel.prototype = { var keyRange = WebInspector.IndexedDBModel.keyRangeFromIDBKeyRange(idbKeyRange); IndexedDBAgent.requestData(frameId, databaseName, objectStoreName, indexName, skipCount, pageSize, keyRange ? keyRange : undefined, innerCallback.bind(this)); - } -} + }, -WebInspector.IndexedDBModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -538,10 +538,11 @@ WebInspector.IndexedDBModel.DatabaseId.prototype = { * @param {WebInspector.IndexedDBModel.DatabaseId} databaseId * @param {string} version */ -WebInspector.IndexedDBModel.Database = function(databaseId, version) +WebInspector.IndexedDBModel.Database = function(databaseId, version, intVersion) { this.databaseId = databaseId; this.version = version; + this.intVersion = intVersion; this.objectStores = {}; } diff --git a/Source/WebCore/inspector/front-end/IndexedDBViews.js b/Source/WebCore/inspector/front-end/IndexedDBViews.js index fad4e5577..d30006a78 100644 --- a/Source/WebCore/inspector/front-end/IndexedDBViews.js +++ b/Source/WebCore/inspector/front-end/IndexedDBViews.js @@ -53,9 +53,13 @@ WebInspector.IDBDatabaseView = function(database) this._nameTreeElement.selectable = false; this._headersTreeOutline.appendChild(this._nameTreeElement); - this._versionTreeElement = new TreeElement("", null, false); - this._versionTreeElement.selectable = false; - this._headersTreeOutline.appendChild(this._versionTreeElement); + this._intVersionTreeElement = new TreeElement("", null, false); + this._intVersionTreeElement.selectable = false; + this._headersTreeOutline.appendChild(this._intVersionTreeElement); + + this._stringVersionTreeElement = new TreeElement("", null, false); + this._stringVersionTreeElement.selectable = false; + this._headersTreeOutline.appendChild(this._stringVersionTreeElement); this.update(database); } @@ -78,7 +82,8 @@ WebInspector.IDBDatabaseView.prototype = { { this._securityOriginTreeElement.title = this._formatHeader(WebInspector.UIString("Security origin"), this._database.databaseId.securityOrigin); this._nameTreeElement.title = this._formatHeader(WebInspector.UIString("Name"), this._database.databaseId.name); - this._versionTreeElement.title = this._formatHeader(WebInspector.UIString("Version"), this._database.version); + this._stringVersionTreeElement.title = this._formatHeader(WebInspector.UIString("String Version"), this._database.version); + this._intVersionTreeElement.title = this._formatHeader(WebInspector.UIString("Integer Version"), this._database.intVersion); }, /** @@ -89,9 +94,10 @@ WebInspector.IDBDatabaseView.prototype = { this._database = database; this._refreshDatabase(); }, + + __proto__: WebInspector.View.prototype } -WebInspector.IDBDatabaseView.prototype.__proto__ = WebInspector.View.prototype; /** * @constructor @@ -362,10 +368,10 @@ WebInspector.IDBDataView.prototype = { value.release(); } this._entries = []; - } -} + }, -WebInspector.IDBDataView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -427,7 +433,8 @@ WebInspector.IDBDataGridNode.prototype = { contents.addStyleClass("primitive-value"); contents.appendChild(document.createTextNode(value.description)); } - } -}; + }, + + __proto__: WebInspector.DataGridNode.prototype +} -WebInspector.IDBDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; diff --git a/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js b/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js index 06363986e..70b7cfdd7 100644 --- a/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js +++ b/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js @@ -28,7 +28,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -InspectorFrontendAPI = { +var InspectorFrontendAPI = { _pendingCommands: [], isDebuggingEnabled: function() @@ -76,7 +76,8 @@ InspectorFrontendAPI = { setAttachedWindow: function(attached) { - WebInspector.attached = attached; + if (WebInspector.dockController) + WebInspector.dockController.setDocked(attached); }, showConsole: function() diff --git a/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js index dc2701cd0..d706b5977 100644 --- a/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js +++ b/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js @@ -70,10 +70,12 @@ WebInspector.InspectorFrontendHostStub.prototype = { requestAttachWindow: function() { + InspectorFrontendAPI.setAttachedWindow(true); }, requestDetachWindow: function() { + InspectorFrontendAPI.setAttachedWindow(false); }, requestSetDockSide: function() @@ -141,9 +143,7 @@ WebInspector.InspectorFrontendHostStub.prototype = { save: function(url, content, forceSaveAs) { - var builder = new WebKitBlobBuilder(); - builder.append(content); - var blob = builder.getBlob("application/octet-stream"); + var blob = new Blob([content], { type: "application/octet-stream" }); var fr = new FileReader(); fr.onload = function(e) { @@ -217,6 +217,8 @@ WebInspector.ClipboardAccessDeniedScreen = function() } } -WebInspector.ClipboardAccessDeniedScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype; +WebInspector.ClipboardAccessDeniedScreen.prototype = { + __proto__: WebInspector.HelpScreen.prototype +} } diff --git a/Source/WebCore/inspector/front-end/InspectorView.js b/Source/WebCore/inspector/front-end/InspectorView.js index b521a9d1d..229b2df2f 100644 --- a/Source/WebCore/inspector/front-end/InspectorView.js +++ b/Source/WebCore/inspector/front-end/InspectorView.js @@ -132,10 +132,23 @@ WebInspector.InspectorView.prototype = { _keyDown: function(event) { + if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) + return; + + // Ctrl/Cmd + 1-9 should show corresponding panel. + if (!event.shiftKey && !event.altKey && event.keyCode > 0x30 && event.keyCode < 0x3A) { + var panelName = this._panelOrder[event.keyCode - 0x31]; + if (panelName) { + this.showPanel(panelName); + event.consume(true); + } + return; + } + // BUG85312: On French AZERTY keyboards, AltGr-]/[ combinations (synonymous to Ctrl-Alt-]/[ on Windows) are used to enter ]/[, // so for a ]/[-related keydown we delay the panel switch using a timer, to see if there is a keypress event following this one. // If there is, we cancel the timer and do not consider this a panel switch. - if (!WebInspector.isWin() || (!this._openBracketIdentifiers.hasOwnProperty(event.keyIdentifier) && !this._closeBracketIdentifiers.hasOwnProperty(event.keyIdentifier))) { + if (!WebInspector.isWin() || (!this._openBracketIdentifiers[event.keyIdentifier] && !this._closeBracketIdentifiers[event.keyIdentifier])) { this._keyDownInternal(event); return; } @@ -145,8 +158,8 @@ WebInspector.InspectorView.prototype = { _keyDownInternal: function(event) { - if (this._openBracketIdentifiers.hasOwnProperty(event.keyIdentifier)) { - var isRotateLeft = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey; + if (this._openBracketIdentifiers[event.keyIdentifier]) { + var isRotateLeft = !event.shiftKey && !event.altKey; if (isRotateLeft) { var index = this._panelOrder.indexOf(this.currentPanel().name); index = (index === 0) ? this._panelOrder.length - 1 : index - 1; @@ -155,7 +168,7 @@ WebInspector.InspectorView.prototype = { return; } - var isGoBack = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && event.altKey; + var isGoBack = event.altKey; if (isGoBack && this._canGoBackInHistory()) { this._goBackInHistory(); event.consume(true); @@ -163,8 +176,8 @@ WebInspector.InspectorView.prototype = { return; } - if (this._closeBracketIdentifiers.hasOwnProperty(event.keyIdentifier)) { - var isRotateRight = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey; + if (this._closeBracketIdentifiers[event.keyIdentifier]) { + var isRotateRight = !event.shiftKey && !event.altKey; if (isRotateRight) { var index = this._panelOrder.indexOf(this.currentPanel().name); index = (index + 1) % this._panelOrder.length; @@ -173,7 +186,7 @@ WebInspector.InspectorView.prototype = { return; } - var isGoForward = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && event.altKey; + var isGoForward = event.altKey; if (isGoForward && this._canGoForwardInHistory()) { this._goForwardInHistory(); event.consume(true); @@ -246,10 +259,10 @@ WebInspector.InspectorView.prototype = { { WebInspector.searchController.disableSearchUntilExplicitAction(); this.setCurrentPanel(panel); - } -} + }, -WebInspector.InspectorView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @type {WebInspector.InspectorView} diff --git a/Source/WebCore/inspector/front-end/JavaScriptSource.js b/Source/WebCore/inspector/front-end/JavaScriptSource.js index a641c2d18..35f918e0e 100644 --- a/Source/WebCore/inspector/front-end/JavaScriptSource.js +++ b/Source/WebCore/inspector/front-end/JavaScriptSource.js @@ -32,97 +32,14 @@ * @constructor * @extends {WebInspector.UISourceCode} * @param {string} url - * @param {WebInspector.Resource} resource * @param {WebInspector.ContentProvider} contentProvider + * @param {boolean} isEditable */ -WebInspector.JavaScriptSource = function(url, resource, contentProvider, isEditable) +WebInspector.JavaScriptSource = function(url, contentProvider, isEditable) { - WebInspector.UISourceCode.call(this, url, resource, contentProvider); - this._isEditable = isEditable; + WebInspector.UISourceCode.call(this, url, contentProvider, isEditable); } WebInspector.JavaScriptSource.prototype = { - /** - * @param {number} lineNumber - * @param {number} columnNumber - * @return {WebInspector.DebuggerModel.Location} - */ - uiLocationToRawLocation: function(lineNumber, columnNumber) - { - var rawLocation = WebInspector.UISourceCode.prototype.uiLocationToRawLocation.call(this, lineNumber, columnNumber); - var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ rawLocation; - return debuggerModelLocation; - }, - - /** - * @return {boolean} - */ - supportsEnabledBreakpointsWhileEditing: function() - { - return false; - }, - - /** - * @return {string} - */ - breakpointStorageId: function() - { - return this.formatted() ? "deobfuscated:" + this.url : this.url; - }, - - /** - * @return {boolean} - */ - isEditable: function() - { - return this._isEditable && WebInspector.debuggerModel.canSetScriptSource(); - }, - - /** - * @return {boolean} - */ - isDivergedFromVM: function() - { - // FIXME: We should return true if this._isDivergedFromVM is set as well once we provide a way to set breakpoints after LiveEdit failure. - return this.isDirty(); - }, - - /** - * @param {function(?string)} callback - */ - workingCopyCommitted: function(callback) - { - /** - * @param {?string} error - */ - function innerCallback(error) - { - this._isDivergedFromVM = !!error; - callback(error); - } - - var rawLocation = this.uiLocationToRawLocation(0, 0); - var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId); - WebInspector.debuggerModel.setScriptSource(script.scriptId, this.workingCopy(), innerCallback.bind(this)); - }, - - /** - * @param {string} query - * @param {boolean} caseSensitive - * @param {boolean} isRegex - * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback - */ - searchInContent: function(query, caseSensitive, isRegex, callback) - { - var content = this.content(); - var provider = content ? new WebInspector.StaticContentProvider(this._contentProvider.contentType(), content) : this._contentProvider; - provider.searchInContent(query, caseSensitive, isRegex, callback); - }, - - formattedChanged: function() - { - WebInspector.breakpointManager.restoreBreakpoints(this); - } + __proto__: WebInspector.UISourceCode.prototype } - -WebInspector.JavaScriptSource.prototype.__proto__ = WebInspector.UISourceCode.prototype; diff --git a/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js b/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js index fdd730ad3..3edeff8a5 100644 --- a/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js +++ b/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js @@ -39,6 +39,7 @@ WebInspector.JavaScriptSourceFrame = function(scriptsPanel, javaScriptSource) this._scriptsPanel = scriptsPanel; this._breakpointManager = WebInspector.breakpointManager; this._javaScriptSource = javaScriptSource; + this._scriptFile = this._javaScriptSource.scriptFile(); var locations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource); for (var i = 0; i < locations.length; ++i) @@ -56,7 +57,9 @@ WebInspector.JavaScriptSourceFrame = function(scriptsPanel, javaScriptSource) this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this); this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpointRemoved, this); - this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this); + this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._onFormattedChanged, this); + this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyChanged, this); + this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this); this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded, this._consoleMessageAdded, this); this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageRemoved, this._consoleMessageRemoved, this); this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this); @@ -92,18 +95,40 @@ WebInspector.JavaScriptSourceFrame.prototype = { return; this._isCommittingEditing = true; - this._javaScriptSource.commitWorkingCopy(this._didEditContent.bind(this)); + var breakpoints = this._getBreakpointDecorations(); + this._javaScriptSource.commitWorkingCopy(this._didEditContent.bind(this, breakpoints)); delete this._isCommittingEditing; }, /** * @param {WebInspector.Event} event */ - _onContentChanged: function(event) + _onFormattedChanged: function(event) { - if (this._isCommittingEditing) - return; var content = /** @type {string} */ event.data.content; + this._innerSetContent(content); + }, + + /** + * @param {WebInspector.Event} event + */ + _onWorkingCopyChanged: function(event) + { + this._innerSetContent(this._javaScriptSource.workingCopy()); + }, + + /** + * @param {WebInspector.Event} event + */ + _onWorkingCopyCommitted: function(event) + { + this._innerSetContent(this._javaScriptSource.workingCopy()); + }, + + _innerSetContent: function(content) + { + if (this._isSettingWorkingCopy || this._isCommittingEditing) + return; if (this._javaScriptSource.togglingFormatter()) this.setContent(content, false, this._javaScriptSource.mimeType()); @@ -152,57 +177,88 @@ WebInspector.JavaScriptSourceFrame.prototype = { onTextChanged: function(oldRange, newRange) { WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange); - this._removeBreakpointsBeforeEditing(); + + var wasDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM(); + + this._preserveDecorations = true; + this._isSettingWorkingCopy = true; this._javaScriptSource.setWorkingCopy(this._textEditor.text()); - this._restoreBreakpointsAfterEditing(); + delete this._isSettingWorkingCopy; + delete this._preserveDecorations; + + if (this._supportsEnabledBreakpointsWhileEditing()) + return; + + var isDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM(); + if (!wasDiverged && isDiverged) + this._muteBreakpointsWhileEditing(); + else if (wasDiverged && !isDiverged) { + var breakpoints = this._getBreakpointDecorations(); + this._restoreBreakpointsAfterEditing(breakpoints); + } }, - _didEditContent: function(error) + _getBreakpointDecorations: function() { - if (error) { - WebInspector.showErrorMessage(error); - return; + var breakpoints = {}; + // Restore all muted breakpoints. + for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) { + var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint"); + if (breakpointDecoration) + breakpoints[lineNumber] = breakpointDecoration; } - if (!this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) - this._restoreBreakpointsAfterEditing(); + + return breakpoints; }, - _removeBreakpointsBeforeEditing: function() + _muteBreakpointsWhileEditing: function() { - var supportsBreakpointsOnEdit = this._javaScriptSource.supportsEnabledBreakpointsWhileEditing(); - if (!this._javaScriptSource.isDirty() || supportsBreakpointsOnEdit) { - // Disable all breakpoints in the model, store them as muted breakpoints. - var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource); - var lineNumbers = {}; - this._preserveDecorations = true; - for (var i = 0; i < breakpointLocations.length; ++i) { - var breakpoint = breakpointLocations[i].breakpoint; - breakpointLocations[i].breakpoint.remove(); - } - delete this._preserveDecorations; + var breakpoints = this._getBreakpointDecorations(); + for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) { + var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint"); + if (!breakpointDecoration) + continue; + this._removeBreakpointDecoration(lineNumber); + this._addBreakpointDecoration(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled, true); + } + }, - for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) { - var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint"); - if (breakpointDecoration) - this._addBreakpointDecoration(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled, !supportsBreakpointsOnEdit); - } - this.clearExecutionLine(); + _supportsEnabledBreakpointsWhileEditing: function() + { + return this._javaScriptSource.isSnippet; + }, + + _didEditContent: function(breakpoints, error) + { + if (!this._supportsEnabledBreakpointsWhileEditing()) + this._restoreBreakpointsAfterEditing(breakpoints); + + if (error) { + WebInspector.showErrorMessage(error); + return; } }, - _restoreBreakpointsAfterEditing: function() + _restoreBreakpointsAfterEditing: function(breakpoints) { - if (!this._javaScriptSource.isDirty() || this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) { - // Restore all muted breakpoints. - for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) { - var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint"); - if (breakpointDecoration) { - // Remove fake decoration - this._removeBreakpointDecoration(lineNumber); - // Set new breakpoint - this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled); - } - } + var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource); + var lineNumbers = {}; + for (var i = 0; i < breakpointLocations.length; ++i) { + var breakpoint = breakpointLocations[i].breakpoint; + breakpointLocations[i].breakpoint.remove(); + } + + for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) + this._removeBreakpointDecoration(lineNumber); + + // Restore all muted breakpoints. + for (var lineNumberString in breakpoints) { + var lineNumber = parseInt(lineNumberString, 10); + if (isNaN(lineNumber)) + continue; + var breakpointDecoration = breakpoints[lineNumberString]; + // Set new breakpoint + this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled); } }, @@ -331,13 +387,15 @@ WebInspector.JavaScriptSourceFrame.prototype = { */ _addBreakpointDecoration: function(lineNumber, condition, enabled, mutedWhileEditing) { + if (this._preserveDecorations) + return; var breakpoint = { condition: condition, enabled: enabled }; this.textEditor.setAttribute(lineNumber, "breakpoint", breakpoint); - var disabled = !enabled || (mutedWhileEditing && !this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()); + var disabled = !enabled || mutedWhileEditing; this.textEditor.addBreakpoint(lineNumber, disabled, !!condition); }, @@ -514,7 +572,7 @@ WebInspector.JavaScriptSourceFrame.prototype = { */ _handleGutterClick: function(event) { - if (this._javaScriptSource.isDirty() && !this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) + if (this._javaScriptSource.isDirty() && !this._supportsEnabledBreakpointsWhileEditing()) return; var lineNumber = event.data.lineNumber; @@ -566,9 +624,9 @@ WebInspector.JavaScriptSourceFrame.prototype = { */ _continueToLine: function(lineNumber) { - var rawLocation = this._javaScriptSource.uiLocationToRawLocation(lineNumber, 0); + var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ this._javaScriptSource.uiLocationToRawLocation(lineNumber, 0); WebInspector.debuggerModel.continueToLocation(rawLocation); - } -} + }, -WebInspector.JavaScriptSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype; + __proto__: WebInspector.SourceFrame.prototype +} diff --git a/Source/WebCore/inspector/front-end/Linkifier.js b/Source/WebCore/inspector/front-end/Linkifier.js index 91986bdae..c668a45c6 100644 --- a/Source/WebCore/inspector/front-end/Linkifier.js +++ b/Source/WebCore/inspector/front-end/Linkifier.js @@ -125,7 +125,7 @@ WebInspector.Linkifier.DefaultFormatter.prototype = { if (this._maxLength) text = text.trimMiddle(this._maxLength); anchor.textContent = text; - } -} + }, -WebInspector.Linkifier.DefaultFormatter.prototype.__proto__ = WebInspector.LinkifierFormatter.prototype; + __proto__: WebInspector.LinkifierFormatter.prototype +} diff --git a/Source/WebCore/inspector/front-end/MemoryStatistics.js b/Source/WebCore/inspector/front-end/MemoryStatistics.js index b4596e194..e75cd02b3 100644 --- a/Source/WebCore/inspector/front-end/MemoryStatistics.js +++ b/Source/WebCore/inspector/front-end/MemoryStatistics.js @@ -126,10 +126,10 @@ WebInspector.SwatchCheckbox.prototype = { { this.checked = !this.checked; this.dispatchEventToListeners(WebInspector.SwatchCheckbox.Events.Changed); - } -} + }, -WebInspector.SwatchCheckbox.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/MetricsSidebarPane.js b/Source/WebCore/inspector/front-end/MetricsSidebarPane.js index b1d8ab36e..b29343031 100644 --- a/Source/WebCore/inspector/front-end/MetricsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/MetricsSidebarPane.js @@ -419,7 +419,7 @@ WebInspector.MetricsSidebarPane.prototype = { { this.editingEnded(element, context); this._applyUserInput(element, userInput, previousContent, context, true); - } -} + }, -WebInspector.MetricsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/NativeBreakpointsSidebarPane.js b/Source/WebCore/inspector/front-end/NativeBreakpointsSidebarPane.js index e6154745a..8c34ac6f8 100644 --- a/Source/WebCore/inspector/front-end/NativeBreakpointsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/NativeBreakpointsSidebarPane.js @@ -76,7 +76,7 @@ WebInspector.NativeBreakpointsSidebarPane.prototype = { this.bodyElement.removeChild(this.listElement); this.bodyElement.appendChild(this.emptyElement); } - } -} + }, -WebInspector.NativeBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js b/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js index e32959268..1c0cb67fd 100644 --- a/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js +++ b/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js @@ -57,10 +57,10 @@ WebInspector.NativeMemorySnapshotView.prototype = { get profile() { return this._profile; - } -} + }, -WebInspector.NativeMemorySnapshotView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -145,10 +145,10 @@ WebInspector.NativeMemoryProfileType.prototype = { createProfile: function(profile) { return new WebInspector.NativeMemoryProfileHeader(this, profile.title, -1); - } -} + }, -WebInspector.NativeMemoryProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; + __proto__: WebInspector.ProfileType.prototype +} /** * @constructor @@ -183,10 +183,10 @@ WebInspector.NativeMemoryProfileHeader.prototype = { createView: function(profilesPanel) { return new WebInspector.NativeMemorySnapshotView(this); - } -} + }, -WebInspector.NativeMemoryProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; + __proto__: WebInspector.ProfileHeader.prototype +} /** * @constructor @@ -219,17 +219,17 @@ WebInspector.MemoryBlockViewProperties._initialize = function() addBlock("hsl( 0, 0%, 80%)", "OwnersTypePlaceholder", "OwnersTypePlaceholder"); addBlock("hsl( 0, 0%, 80%)", "Other", "Other"); addBlock("hsl(300, 30%, 80%)", "Page", "Page's structures"); - addBlock("hsl( 90, 60%, 80%)", "JSHeapAllocated", "JavaScript heap"); - addBlock("hsl( 90, 80%, 80%)", "JSHeapUsed", "Used JavaScript heap"); + addBlock("hsl( 90, 60%, 80%)", "JSHeap", "JavaScript heap"); + addBlock("hsl( 90, 80%, 80%)", "JSHeap.Used", "Used JavaScript heap"); addBlock("hsl( 90, 30%, 80%)", "JSExternalResources", "JavaScript external resources"); addBlock("hsl( 90, 40%, 80%)", "JSExternalArrays", "JavaScript external arrays"); addBlock("hsl( 90, 50%, 80%)", "JSExternalStrings", "JavaScript external strings"); - addBlock("hsl(210, 60%, 80%)", "InspectorData", "Inspector data"); + addBlock("hsl(210, 60%, 80%)", "WebInspector", "Inspector data"); addBlock("hsl( 30, 60%, 80%)", "MemoryCache", "Memory cache resources"); addBlock("hsl( 40, 60%, 80%)", "GlyphCache", "Glyph cache resources"); addBlock("hsl( 35, 60%, 80%)", "DOMStorageCache", "DOM storage cache"); - addBlock("hsl( 60, 60%, 80%)", "RenderTreeAllocated", "Render tree"); - addBlock("hsl( 60, 60%, 80%)", "RenderTreeUsed", "Render tree used"); + addBlock("hsl( 60, 60%, 80%)", "RenderTree", "Render tree"); + addBlock("hsl( 60, 60%, 80%)", "RenderTree.Used", "Render tree used"); } WebInspector.MemoryBlockViewProperties._forMemoryBlock = function(memoryBlock) @@ -369,10 +369,10 @@ WebInspector.NativeMemoryPieChart.prototype = { _clear: function() { var ctx = this._canvas.getContext("2d"); ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); - } -} + }, -WebInspector.NativeMemoryPieChart.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -474,9 +474,13 @@ WebInspector.NativeMemoryBarChart.prototype = { } var unusedSize = 0; if (!!child.children) { - unusedSize = child.size; - for (var j = 0; j < child.children.length; ++j) - unusedSize -= child.children[j].size; + var unusedName = name + ".Unused"; + for (var j = 0; j < child.children.length; ++j) { + if (child.children[j].name === unusedName) { + unusedSize = child.children[j].size; + break; + } + } } var unusedLength = unusedSize * barLengthSizeRatio; var barLength = child.size * barLengthSizeRatio; @@ -489,7 +493,7 @@ WebInspector.NativeMemoryBarChart.prototype = { var memoryBlockViewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(memoryBlock); this._totalDiv.textContent = memoryBlockViewProperties._description + ": " + (memoryBlock.size / MB).toFixed(1) + "\u2009MB"; - } -} + }, -WebInspector.NativeMemoryBarChart.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/NavigatorView.js b/Source/WebCore/inspector/front-end/NavigatorView.js index a02217474..97f88e8e5 100644 --- a/Source/WebCore/inspector/front-end/NavigatorView.js +++ b/Source/WebCore/inspector/front-end/NavigatorView.js @@ -94,7 +94,13 @@ WebInspector.NavigatorView.prototype = { this._updateScriptTitle(uiSourceCode) }, - _uiSourceCodeContentChanged: function(event) + _uiSourceCodeWorkingCopyCommitted: function(event) + { + var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target; + this._updateScriptTitle(uiSourceCode) + }, + + _uiSourceCodeFormattedChanged: function(event) { var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target; this._updateScriptTitle(uiSourceCode); @@ -149,29 +155,6 @@ WebInspector.NavigatorView.prototype = { }, /** - * @param {WebInspector.UISourceCode} oldUISourceCode - * @param {WebInspector.UISourceCode} uiSourceCode - */ - replaceUISourceCode: function(oldUISourceCode, uiSourceCode) - { - var added = false; - var selected = false; - if (this._scriptTreeElementsByUISourceCode.get(oldUISourceCode)) { - added = true; - - if (this._lastSelectedUISourceCode === oldUISourceCode) - selected = true; - this.removeUISourceCode(oldUISourceCode); - } - - if (!added) - return; - this.addUISourceCode(uiSourceCode); - if (selected) - this.revealUISourceCode(uiSourceCode); - }, - - /** * @param {WebInspector.UISourceCode} uiSourceCode * @param {boolean} focusSource */ @@ -210,7 +193,8 @@ WebInspector.NavigatorView.prototype = { { uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this); uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this); - uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this); + uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this); + uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this); }, /** @@ -220,7 +204,8 @@ WebInspector.NavigatorView.prototype = { { uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this); uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this); - uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this); + uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this); + uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this); }, _showScriptFoldersSettingChanged: function() @@ -347,10 +332,10 @@ WebInspector.NavigatorView.prototype = { var contextMenu = new WebInspector.ContextMenu(); contextMenu.appendApplicableItems(uiSourceCode); contextMenu.show(event); - } -} + }, -WebInspector.NavigatorView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -429,10 +414,10 @@ WebInspector.NavigatorTreeOutline.prototype = { { this._treeSearchBoxElement.removeChild(this.searchInputElement); this._treeSearchBoxElement.removeStyleClass("visible"); - } -} + }, -WebInspector.NavigatorTreeOutline.prototype.__proto__ = TreeOutline.prototype; + __proto__: TreeOutline.prototype +} /** * @constructor @@ -505,10 +490,10 @@ WebInspector.BaseNavigatorTreeElement.prototype = { matchesSearchText: function(searchText) { return this.titleText.match(new RegExp("^" + searchText.escapeForRegExp(), "i")); - } -} + }, -WebInspector.BaseNavigatorTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -553,10 +538,10 @@ WebInspector.NavigatorFolderTreeElement.prototype = { this.collapse(); else this.expand(); - } -} + }, -WebInspector.NavigatorFolderTreeElement.prototype.__proto__ = WebInspector.BaseNavigatorTreeElement.prototype; + __proto__: WebInspector.BaseNavigatorTreeElement.prototype +} /** * @constructor @@ -645,7 +630,7 @@ WebInspector.NavigatorSourceTreeElement.prototype = { _handleContextMenuEvent: function(event) { this._navigatorView.handleContextMenu(event, this._uiSourceCode); - } -} + }, -WebInspector.NavigatorSourceTreeElement.prototype.__proto__ = WebInspector.BaseNavigatorTreeElement.prototype; + __proto__: WebInspector.BaseNavigatorTreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/NetworkItemView.js b/Source/WebCore/inspector/front-end/NetworkItemView.js index 45cdfaba4..91b95130c 100644 --- a/Source/WebCore/inspector/front-end/NetworkItemView.js +++ b/Source/WebCore/inspector/front-end/NetworkItemView.js @@ -100,10 +100,10 @@ WebInspector.NetworkItemView.prototype = { request: function() { return this._request; - } -} + }, -WebInspector.NetworkItemView.prototype.__proto__ = WebInspector.TabbedPane.prototype; + __proto__: WebInspector.TabbedPane.prototype +} /** * @constructor @@ -170,7 +170,7 @@ WebInspector.RequestContentView.prototype = { { if (this.canHighlightLine()) this._innerView.highlightLine(line); - } -} + }, -WebInspector.RequestContentView.prototype.__proto__ = WebInspector.RequestView.prototype; + __proto__: WebInspector.RequestView.prototype +} diff --git a/Source/WebCore/inspector/front-end/NetworkManager.js b/Source/WebCore/inspector/front-end/NetworkManager.js index ddfd953e4..e56c7ebd5 100644 --- a/Source/WebCore/inspector/front-end/NetworkManager.js +++ b/Source/WebCore/inspector/front-end/NetworkManager.js @@ -113,10 +113,10 @@ WebInspector.NetworkManager.prototype = { _userAgentSettingChanged: function() { NetworkAgent.setUserAgentOverride(WebInspector.settings.userAgent.get()); - } -} + }, -WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/NetworkPanel.js b/Source/WebCore/inspector/front-end/NetworkPanel.js index 5fb8982ac..52848639c 100644 --- a/Source/WebCore/inspector/front-end/NetworkPanel.js +++ b/Source/WebCore/inspector/front-end/NetworkPanel.js @@ -1261,10 +1261,11 @@ WebInspector.NetworkLogView.prototype = { { node.element.addStyleClass("highlighted-row"); this._highlightedNode = node; - } -}; + }, + + __proto__: WebInspector.View.prototype +} -WebInspector.NetworkLogView.prototype.__proto__ = WebInspector.View.prototype; WebInspector.NetworkLogView.EventTypes = { ViewCleared: "ViewCleared", @@ -1520,10 +1521,10 @@ WebInspector.NetworkPanel.prototype = { this.revealAndHighlightRequest(/** @type {WebInspector.NetworkRequest} */ target); } contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Reveal in network panel" : "Reveal in Network Panel"), reveal.bind(this)); - } -} + }, -WebInspector.NetworkPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} /** * @constructor @@ -1725,10 +1726,10 @@ WebInspector.NetworkTimeCalculator.prototype = { _upperBound: function(request) { return 0; - } -} + }, -WebInspector.NetworkTimeCalculator.prototype.__proto__ = WebInspector.NetworkBaseCalculator.prototype; + __proto__: WebInspector.NetworkBaseCalculator.prototype +} /** * @constructor @@ -1753,10 +1754,10 @@ WebInspector.NetworkTransferTimeCalculator.prototype = { _upperBound: function(request) { return request.endTime; - } -} + }, -WebInspector.NetworkTransferTimeCalculator.prototype.__proto__ = WebInspector.NetworkTimeCalculator.prototype; + __proto__: WebInspector.NetworkTimeCalculator.prototype +} /** * @constructor @@ -1776,10 +1777,10 @@ WebInspector.NetworkTransferDurationCalculator.prototype = { _upperBound: function(request) { return request.duration; - } -} + }, -WebInspector.NetworkTransferDurationCalculator.prototype.__proto__ = WebInspector.NetworkTimeCalculator.prototype; + __proto__: WebInspector.NetworkTimeCalculator.prototype +} /** * @constructor @@ -1942,8 +1943,8 @@ WebInspector.NetworkDataGridNode.prototype = { _fileName: function() { var fileName = this._request.displayName; - if (this._request.queryString) - fileName += "?" + this._request.queryString; + if (this._request.queryString()) + fileName += "?" + this._request.queryString(); return fileName; }, @@ -2164,13 +2165,16 @@ WebInspector.NetworkDataGridNode.prototype = { this._labelRightElement.style.setProperty("left", this._percentages.middle + "%"); this._labelRightElement.style.setProperty("right", (100 - this._percentages.end) + "%"); } - } + }, + + __proto__: WebInspector.DataGridNode.prototype } + WebInspector.NetworkDataGridNode.NameComparator = function(a, b) { - var aFileName = a._request.displayName + (a._request.queryString ? a._request.queryString : ""); - var bFileName = b._request.displayName + (b._request.queryString ? b._request.queryString : ""); + var aFileName = a._request.displayName + (a._request.queryString() ? a._request.queryString() : ""); + var bFileName = b._request.displayName + (b._request.queryString() ? b._request.queryString() : ""); if (aFileName > bFileName) return 1; if (bFileName > aFileName) @@ -2216,5 +2220,3 @@ WebInspector.NetworkDataGridNode.RequestPropertyComparator = function(propertyNa return revert ? 1 : -1; return 0; } - -WebInspector.NetworkDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; diff --git a/Source/WebCore/inspector/front-end/NetworkPanelDescriptor.js b/Source/WebCore/inspector/front-end/NetworkPanelDescriptor.js index 4a4fecfd2..1621d77d0 100644 --- a/Source/WebCore/inspector/front-end/NetworkPanelDescriptor.js +++ b/Source/WebCore/inspector/front-end/NetworkPanelDescriptor.js @@ -48,7 +48,7 @@ WebInspector.NetworkPanelDescriptor.prototype = { if (!(target instanceof WebInspector.NetworkRequest)) return; this.panel().appendApplicableItems(contextMenu, target); - } -} + }, -WebInspector.NetworkPanelDescriptor.prototype.__proto__ = WebInspector.PanelDescriptor.prototype; + __proto__: WebInspector.PanelDescriptor.prototype +} diff --git a/Source/WebCore/inspector/front-end/NetworkRequest.js b/Source/WebCore/inspector/front-end/NetworkRequest.js index 464d9fbeb..961c55e23 100644 --- a/Source/WebCore/inspector/front-end/NetworkRequest.js +++ b/Source/WebCore/inspector/front-end/NetworkRequest.js @@ -55,7 +55,6 @@ WebInspector.NetworkRequest = function(requestId, url, documentURL, frameId, loa this.receiveHeadersEnd = 0; this._type = WebInspector.resourceTypes.Other; - this._content = undefined; this._contentEncoded = false; this._pendingContentCallbacks = []; this._frames = []; @@ -579,16 +578,29 @@ WebInspector.NetworkRequest.prototype = { }, /** + * @return {?string} + */ + queryString: function() + { + if (this._queryString) + return this._queryString; + var queryString = this.url.split("?", 2)[1]; + if (!queryString) + return null; + this._queryString = queryString.split("#", 2)[0]; + return this._queryString; + }, + + /** * @return {?Array.<Object>} */ get queryParameters() { if (this._parsedQueryParameters) return this._parsedQueryParameters; - var queryString = this.url.split("?", 2)[1]; + var queryString = this.queryString(); if (!queryString) return null; - queryString = queryString.split("#", 2)[0]; this._parsedQueryParameters = this._parseParameters(queryString); return this._parsedQueryParameters; }, @@ -676,7 +688,7 @@ WebInspector.NetworkRequest.prototype = { }, /** - * @return {?string} + * @return {string} */ contentURL: function() { @@ -761,22 +773,30 @@ WebInspector.NetworkRequest.prototype = { populateImageSource: function(image) { /** + * @this {WebInspector.NetworkRequest} * @param {?string} content * @param {boolean} contentEncoded * @param {string} mimeType */ function onResourceContent(content, contentEncoded, mimeType) { - const maxDataUrlSize = 1024 * 1024; - // If resource content is not available or won't fit a data URL, fall back to using original URL. - if (this._content == null || this._content.length > maxDataUrlSize) - return this.url; - image.src = "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content; + var imageSrc = this.asDataURL(); + if (imageSrc === null) + imageSrc = this.url; + image.src = imageSrc; } this.requestContent(onResourceContent.bind(this)); }, + /** + * @return {?string} + */ + asDataURL: function() + { + return WebInspector.contentAsDataURL(this._content, this.mimeType, this._contentEncoded); + }, + _innerRequestContent: function() { if (this._contentRequested) @@ -849,7 +869,7 @@ WebInspector.NetworkRequest.prototype = { this._frames.splice(0, 10); } this._frames.push(object); - } -} + }, -WebInspector.NetworkRequest.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js b/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js index f1625f64c..fa3eadd1e 100644 --- a/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js +++ b/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js @@ -38,6 +38,7 @@ WebInspector.NetworkUISourceCodeProvider = function(workspace) WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this); this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this); this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectDidReset, this._projectDidReset, this); + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this); this._uiSourceCodeForResource = {}; } @@ -61,6 +62,29 @@ WebInspector.NetworkUISourceCodeProvider.prototype = { /** * @param {WebInspector.Event} event */ + _parsedScriptSource: function(event) + { + var script = /** @type {WebInspector.Script} */ event.data; + if (!script.hasSourceURL && !script.isContentScript) + return; + if (!script.sourceURL) + return; + // Filter out embedder injected content scripts. + if (script.isContentScript && !script.hasSourceURL) { + var parsedURL = new WebInspector.ParsedURL(script.sourceURL); + if (!parsedURL.host) + return; + } + if (this._uiSourceCodeForResource[script.sourceURL]) + return; + var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, script, true); + this._uiSourceCodeForResource[script.sourceURL] = uiSourceCode; + this._workspace.project().addUISourceCode(uiSourceCode); + }, + + /** + * @param {WebInspector.Event} event + */ _resourceAdded: function(event) { var resource = /** @type {WebInspector.Resource} */ event.data; @@ -72,10 +96,10 @@ WebInspector.NetworkUISourceCodeProvider.prototype = { uiSourceCode = new WebInspector.StyleSource(resource); break; case WebInspector.resourceTypes.Document: - uiSourceCode = new WebInspector.JavaScriptSource(resource.url, resource, resource, false); + uiSourceCode = new WebInspector.JavaScriptSource(resource.url, resource, false); break; case WebInspector.resourceTypes.Script: - uiSourceCode = new WebInspector.JavaScriptSource(resource.url, resource, resource, true); + uiSourceCode = new WebInspector.JavaScriptSource(resource.url, resource, true); break; } if (uiSourceCode) { diff --git a/Source/WebCore/inspector/front-end/ObjectPopoverHelper.js b/Source/WebCore/inspector/front-end/ObjectPopoverHelper.js index c4f425e68..380f4db8f 100644 --- a/Source/WebCore/inspector/front-end/ObjectPopoverHelper.js +++ b/Source/WebCore/inspector/front-end/ObjectPopoverHelper.js @@ -153,7 +153,7 @@ WebInspector.ObjectPopoverHelper.prototype = { } } this._sectionUpdateProperties(properties, rootTreeElementConstructor, rootPropertyComparer); - } -} + }, -WebInspector.ObjectPopoverHelper.prototype.__proto__ = WebInspector.PopoverHelper.prototype; + __proto__: WebInspector.PopoverHelper.prototype +} diff --git a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js index c58ff53fe..9c8587807 100644 --- a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js +++ b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js @@ -123,10 +123,10 @@ WebInspector.ObjectPropertiesSection.prototype = { var infoElement = new TreeElement(title, null, false); this.propertiesTreeOutline.appendChild(infoElement); } - } -} + }, -WebInspector.ObjectPropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype; + __proto__: WebInspector.PropertiesSection.prototype +} WebInspector.ObjectPropertiesSection.CompareProperties = function(propertyA, propertyB) { @@ -370,7 +370,9 @@ WebInspector.ObjectPropertyTreeElement.prototype = { } }; this.property.parentObject.setPropertyValue(this.property.name, expression.trim(), callback.bind(this)); - } + }, + + __proto__: TreeElement.prototype } /** @@ -407,8 +409,6 @@ WebInspector.ObjectPropertyTreeElement.populate = function(treeElement, value) { value.getOwnProperties(callback); } -WebInspector.ObjectPropertyTreeElement.prototype.__proto__ = TreeElement.prototype; - /** * @constructor * @extends {TreeElement} @@ -482,10 +482,10 @@ WebInspector.FunctionScopeMainTreeElement.prototype = { } DebuggerAgent.getFunctionDetails(this._remoteObject.objectId, didGetDetails.bind(this)); - } -}; + }, -WebInspector.FunctionScopeMainTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -506,10 +506,10 @@ WebInspector.ScopeTreeElement.prototype = { onpopulate: function() { return WebInspector.ObjectPropertyTreeElement.populate(this, this._remoteObject); - } -}; + }, -WebInspector.ScopeTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -730,10 +730,10 @@ WebInspector.ArrayGroupingTreeElement.prototype = { onattach: function() { this.listItemElement.addStyleClass("name"); - } -} + }, -WebInspector.ArrayGroupingTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -742,11 +742,12 @@ WebInspector.ArrayGroupingTreeElement.prototype.__proto__ = TreeElement.prototyp */ WebInspector.ObjectPropertyPrompt = function(commitHandler, cancelHandler, renderAsBlock) { - const ExpressionStopCharacters = " =:[({;,!+-*/&|^<>."; // Same as in ConsoleView.js + "." - WebInspector.TextPrompt.call(this, WebInspector.consoleView.completionsForTextPrompt.bind(WebInspector.consoleView), ExpressionStopCharacters); + WebInspector.TextPrompt.call(this, WebInspector.runtimeModel.completionsForTextPrompt.bind(WebInspector.runtimeModel)); this.setSuggestBoxEnabled("generic-suggest"); if (renderAsBlock) this.renderAsBlock(); } -WebInspector.ObjectPropertyPrompt.prototype.__proto__ = WebInspector.TextPrompt.prototype; +WebInspector.ObjectPropertyPrompt.prototype = { + __proto__: WebInspector.TextPrompt.prototype +} diff --git a/Source/WebCore/inspector/front-end/Panel.js b/Source/WebCore/inspector/front-end/Panel.js index 8cee1761c..f05db2044 100644 --- a/Source/WebCore/inspector/front-end/Panel.js +++ b/Source/WebCore/inspector/front-end/Panel.js @@ -247,10 +247,10 @@ WebInspector.Panel.prototype = { unregisterShortcut: function(key) { delete this._shortcuts[key]; - } -} + }, -WebInspector.Panel.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/PanelEnablerView.js b/Source/WebCore/inspector/front-end/PanelEnablerView.js index 5e762b862..feab74a44 100644 --- a/Source/WebCore/inspector/front-end/PanelEnablerView.js +++ b/Source/WebCore/inspector/front-end/PanelEnablerView.js @@ -94,7 +94,7 @@ WebInspector.PanelEnablerView.prototype = { get alwaysEnabled() { return this.enabledAlways.checked; - } -} + }, -WebInspector.PanelEnablerView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/ProfileDataGridTree.js b/Source/WebCore/inspector/front-end/ProfileDataGridTree.js index ccbc7f098..284f3b87a 100644 --- a/Source/WebCore/inspector/front-end/ProfileDataGridTree.js +++ b/Source/WebCore/inspector/front-end/ProfileDataGridTree.js @@ -294,10 +294,10 @@ WebInspector.ProfileDataGridNode.prototype = { else this.appendChild(orphanedChild); } - } -} + }, -WebInspector.ProfileDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; + __proto__: WebInspector.DataGridNode.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/ProfileLauncherView.js b/Source/WebCore/inspector/front-end/ProfileLauncherView.js index cfe22bee9..67726f47c 100644 --- a/Source/WebCore/inspector/front-end/ProfileLauncherView.js +++ b/Source/WebCore/inspector/front-end/ProfileLauncherView.js @@ -127,7 +127,7 @@ WebInspector.ProfileLauncherView.prototype = { { this._isProfiling = false; this._updateControls(); - } -} + }, -WebInspector.ProfileLauncherView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/ProfilesPanel.js b/Source/WebCore/inspector/front-end/ProfilesPanel.js index d0d20aa69..1e594e2f0 100644 --- a/Source/WebCore/inspector/front-end/ProfilesPanel.js +++ b/Source/WebCore/inspector/front-end/ProfilesPanel.js @@ -428,11 +428,14 @@ WebInspector.ProfilesPanel.prototype = { element.treeElement.handleContextMenuEvent(event); return; } - var contextMenu = new WebInspector.ContextMenu(); - if (this.visibleView instanceof WebInspector.HeapSnapshotView) - this.visibleView.populateContextMenu(contextMenu, event); - contextMenu.appendItem(WebInspector.UIString("Load profile\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement)); - contextMenu.show(event); + if (element !== this.element || event.srcElement === this.sidebarElement) { + var contextMenu = new WebInspector.ContextMenu(); + if (this.visibleView instanceof WebInspector.HeapSnapshotView) + this.visibleView.populateContextMenu(contextMenu, event); + contextMenu.appendItem(WebInspector.UIString("Load Heap Snapshot\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement)); + contextMenu.show(event); + } + }, /** @@ -671,7 +674,7 @@ WebInspector.ProfilesPanel.prototype = { var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; if (!profile) return; - profile.finishHeapSnapshot(false); + profile.finishHeapSnapshot(); }, /** @@ -1112,10 +1115,10 @@ WebInspector.ProfilesPanel.prototype = { contextMenu.appendItem(WebInspector.UIString("Reveal in Dominators View"), revealInView.bind(this, "Dominators")); contextMenu.appendItem(WebInspector.UIString("Reveal in Summary View"), revealInView.bind(this, "Summary")); - } -} + }, -WebInspector.ProfilesPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} /** * @constructor @@ -1246,17 +1249,21 @@ WebInspector.ProfileSidebarTreeElement.prototype = { { var profile = this.profile; var contextMenu = new WebInspector.ContextMenu(); - if (profile.canSaveToFile()) - contextMenu.appendItem(WebInspector.UIString("Save profile\u2026"), profile.saveToFile.bind(profile)); - // FIXME: use context menu provider var profilesPanel = WebInspector.ProfilesPanel._instance; - contextMenu.appendItem(WebInspector.UIString("Load profile\u2026"), profilesPanel._fileSelectorElement.click.bind(profilesPanel._fileSelectorElement)); - contextMenu.appendItem(WebInspector.UIString("Delete profile"), this.ondelete.bind(this)); + // FIXME: use context menu provider + if (profile.canSaveToFile()) { + contextMenu.appendItem(WebInspector.UIString("Save Heap Snapshot\u2026"), profile.saveToFile.bind(profile)); + contextMenu.appendItem(WebInspector.UIString("Load Heap Snapshot\u2026"), profilesPanel._fileSelectorElement.click.bind(profilesPanel._fileSelectorElement)); + contextMenu.appendItem(WebInspector.UIString("Delete Heap Snapshot"), this.ondelete.bind(this)); + } else { + contextMenu.appendItem(WebInspector.UIString("Load Heap Snapshot\u2026"), profilesPanel._fileSelectorElement.click.bind(profilesPanel._fileSelectorElement)); + contextMenu.appendItem(WebInspector.UIString("Delete profile"), this.ondelete.bind(this)); + } contextMenu.show(event); - } -} + }, -WebInspector.ProfileSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + __proto__: WebInspector.SidebarTreeElement.prototype +} /** * @constructor @@ -1274,10 +1281,10 @@ WebInspector.ProfileGroupSidebarTreeElement.prototype = { { if (this.children.length > 0) WebInspector.ProfilesPanel._instance.showProfile(this.children[this.children.length - 1].profile); - } -} + }, -WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + __proto__: WebInspector.SidebarTreeElement.prototype +} /** * @constructor @@ -1300,10 +1307,10 @@ WebInspector.ProfilesSidebarTreeElement.prototype = { get selectable() { return true; - } -} + }, -WebInspector.ProfilesSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + __proto__: WebInspector.SidebarTreeElement.prototype +} importScript("ProfileDataGridTree.js"); importScript("BottomUpProfileDataGridTree.js"); diff --git a/Source/WebCore/inspector/front-end/ProgressBar.js b/Source/WebCore/inspector/front-end/Progress.js index 22a4513f2..4cd050891 100644 --- a/Source/WebCore/inspector/front-end/ProgressBar.js +++ b/Source/WebCore/inspector/front-end/Progress.js @@ -67,102 +67,6 @@ WebInspector.Progress.prototype = { /** * @constructor - * @implements {WebInspector.Progress} - * @extends {WebInspector.Object} - */ -WebInspector.ProgressIndicator = function() -{ - this.element = document.createElement("div"); - this.element.className = "progress-bar-container"; - this._labelElement = this.element.createChild("span"); - this._progressElement = this.element.createChild("progress"); - this._stopButton = new WebInspector.StatusBarButton(WebInspector.UIString("Cancel"), "progress-bar-stop-button"); - this._stopButton.addEventListener("click", this.cancel, this); - this.element.appendChild(this._stopButton.element); - this._isCanceled = false; - this._worked = 0; -} - -WebInspector.ProgressIndicator.Events = { - Done: "Done" -} - -WebInspector.ProgressIndicator.prototype = { - /** - * @param {Element} parent - */ - show: function(parent) - { - parent.appendChild(this.element); - }, - - hide: function() - { - var parent = this.element.parentElement; - if (parent) - parent.removeChild(this.element); - }, - - done: function() - { - if (this._isDone) - return; - this._isDone = true; - this.hide(); - this.dispatchEventToListeners(WebInspector.ProgressIndicator.Events.Done); - }, - - cancel: function() - { - this._isCanceled = true; - }, - - isCanceled: function() - { - return this._isCanceled; - }, - - /** - * @param {string} title - */ - setTitle: function(title) - { - this._labelElement.textContent = title; - }, - - /** - * @param {number} totalWork - */ - setTotalWork: function(totalWork) - { - this._progressElement.max = totalWork; - }, - - /** - * @param {number} worked - * @param {string=} title - */ - setWorked: function(worked, title) - { - this._worked = worked; - this._progressElement.value = worked; - if (title) - this.setTitle(title); - }, - - /** - * @param {number=} worked - */ - worked: function(worked) - { - this.setWorked(this._worked + (worked || 1)); - } -} - -WebInspector.ProgressIndicator.prototype.__proto__ = WebInspector.Object.prototype; - -/** - * @constructor * @param {WebInspector.Progress} parent */ WebInspector.CompositeProgress = function(parent) diff --git a/Source/WebCore/inspector/front-end/ProgressIndicator.js b/Source/WebCore/inspector/front-end/ProgressIndicator.js new file mode 100644 index 000000000..cb9d2ef23 --- /dev/null +++ b/Source/WebCore/inspector/front-end/ProgressIndicator.js @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @constructor + * @implements {WebInspector.Progress} + * @extends {WebInspector.Object} + */ +WebInspector.ProgressIndicator = function() +{ + this.element = document.createElement("div"); + this.element.className = "progress-bar-container"; + this._labelElement = this.element.createChild("span"); + this._progressElement = this.element.createChild("progress"); + this._stopButton = new WebInspector.StatusBarButton(WebInspector.UIString("Cancel"), "progress-bar-stop-button"); + this._stopButton.addEventListener("click", this.cancel, this); + this.element.appendChild(this._stopButton.element); + this._isCanceled = false; + this._worked = 0; +} + +WebInspector.ProgressIndicator.Events = { + Done: "Done" +} + +WebInspector.ProgressIndicator.prototype = { + /** + * @param {Element} parent + */ + show: function(parent) + { + parent.appendChild(this.element); + }, + + hide: function() + { + var parent = this.element.parentElement; + if (parent) + parent.removeChild(this.element); + }, + + done: function() + { + if (this._isDone) + return; + this._isDone = true; + this.hide(); + this.dispatchEventToListeners(WebInspector.ProgressIndicator.Events.Done); + }, + + cancel: function() + { + this._isCanceled = true; + }, + + isCanceled: function() + { + return this._isCanceled; + }, + + /** + * @param {string} title + */ + setTitle: function(title) + { + this._labelElement.textContent = title; + }, + + /** + * @param {number} totalWork + */ + setTotalWork: function(totalWork) + { + this._progressElement.max = totalWork; + }, + + /** + * @param {number} worked + * @param {string=} title + */ + setWorked: function(worked, title) + { + this._worked = worked; + this._progressElement.value = worked; + if (title) + this.setTitle(title); + }, + + /** + * @param {number=} worked + */ + worked: function(worked) + { + this.setWorked(this._worked + (worked || 1)); + }, + + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/PropertiesSection.js b/Source/WebCore/inspector/front-end/PropertiesSection.js index 4f760e68e..3aa4fc446 100644 --- a/Source/WebCore/inspector/front-end/PropertiesSection.js +++ b/Source/WebCore/inspector/front-end/PropertiesSection.js @@ -47,4 +47,6 @@ WebInspector.PropertiesSection = function(title, subtitle) this.element.appendChild(this.propertiesElement); } -WebInspector.PropertiesSection.prototype.__proto__ = WebInspector.Section.prototype; +WebInspector.PropertiesSection.prototype = { + __proto__: WebInspector.Section.prototype +} diff --git a/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js b/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js index b2fbc527c..0f7bbf6d0 100644 --- a/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js +++ b/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js @@ -99,7 +99,7 @@ WebInspector.PropertiesSidebarPane.prototype = { body.appendChild(section.element); } } - } -} + }, -WebInspector.PropertiesSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/RequestCookiesView.js b/Source/WebCore/inspector/front-end/RequestCookiesView.js index d8d5da840..e21e61996 100644 --- a/Source/WebCore/inspector/front-end/RequestCookiesView.js +++ b/Source/WebCore/inspector/front-end/RequestCookiesView.js @@ -81,7 +81,7 @@ WebInspector.RequestCookiesView.prototype = { return; this._buildCookiesTable(); this._cookiesTable.updateWidths(); - } -} + }, -WebInspector.RequestCookiesView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/RequestHTMLView.js b/Source/WebCore/inspector/front-end/RequestHTMLView.js index 817f81305..63facf378 100644 --- a/Source/WebCore/inspector/front-end/RequestHTMLView.js +++ b/Source/WebCore/inspector/front-end/RequestHTMLView.js @@ -32,10 +32,12 @@ * @constructor * @extends {WebInspector.RequestView} * @param {WebInspector.NetworkRequest} request + * @param {string} dataURL */ -WebInspector.RequestHTMLView = function(request) +WebInspector.RequestHTMLView = function(request, dataURL) { WebInspector.RequestView.call(this, request); + this._dataURL = dataURL; this.element.addStyleClass("html"); } @@ -61,11 +63,10 @@ WebInspector.RequestHTMLView.prototype = { // is deleted when iframe is removed from its parent. this.element.removeChildren(); var iframe = document.createElement("iframe"); - this.element.appendChild(iframe); iframe.setAttribute("sandbox", ""); // Forbid to run JavaScript and set unique origin. + iframe.setAttribute("src", this._dataURL); + this.element.appendChild(iframe); + }, - iframe.contentDocument.body.innerHTML = this.request.content; - } + __proto__: WebInspector.RequestView.prototype } - -WebInspector.RequestHTMLView.prototype.__proto__ = WebInspector.RequestView.prototype; diff --git a/Source/WebCore/inspector/front-end/RequestHeadersView.js b/Source/WebCore/inspector/front-end/RequestHeadersView.js index 75cb0245f..40badcb54 100644 --- a/Source/WebCore/inspector/front-end/RequestHeadersView.js +++ b/Source/WebCore/inspector/front-end/RequestHeadersView.js @@ -160,10 +160,11 @@ WebInspector.RequestHeadersView.prototype = { _refreshQueryString: function() { + var queryString = this._request.queryString(); var queryParameters = this._request.queryParameters; this._queryStringTreeElement.hidden = !queryParameters; if (queryParameters) - this._refreshParms(WebInspector.UIString("Query String Parameters"), queryParameters, this._queryStringTreeElement); + this._refreshParams(WebInspector.UIString("Query String Parameters"), queryParameters, queryString, this._queryStringTreeElement); }, _refreshUrlFragment: function() @@ -198,58 +199,75 @@ WebInspector.RequestHeadersView.prototype = { var formParameters = this._request.formParameters; if (formParameters) { this._formDataTreeElement.hidden = false; - this._refreshParms(WebInspector.UIString("Form Data"), formParameters, this._formDataTreeElement); + this._refreshParams(WebInspector.UIString("Form Data"), formParameters, formData, this._formDataTreeElement); } else { this._requestPayloadTreeElement.hidden = false; - this._refreshRequestPayload(formData); + this._populateTreeElementWithSourceText(this._requestPayloadTreeElement, formData) } }, - _refreshRequestPayload: function(formData) + _populateTreeElementWithSourceText: function(treeElement, sourceText) { - this._requestPayloadTreeElement.removeChildren(); + treeElement.removeChildren(); - var title = document.createElement("div"); - title.className = "raw-form-data header-value source-code"; - title.textContent = formData; + var sourceTreeElement = new TreeElement(null, null, false); + sourceTreeElement.selectable = false; + treeElement.appendChild(sourceTreeElement); - var parmTreeElement = new TreeElement(title, null, false); - parmTreeElement.selectable = false; - this._requestPayloadTreeElement.appendChild(parmTreeElement); + var sourceTextElement = document.createElement("span"); + sourceTextElement.addStyleClass("header-value"); + sourceTextElement.addStyleClass("source-code"); + sourceTextElement.textContent = String(sourceText).trim(); + sourceTreeElement.listItemElement.appendChild(sourceTextElement); }, - _refreshParms: function(title, parms, parmsTreeElement) + _refreshParams: function(title, params, sourceText, paramsTreeElement) { - parmsTreeElement.removeChildren(); + paramsTreeElement.removeChildren(); - parmsTreeElement.listItemElement.removeChildren(); - parmsTreeElement.listItemElement.appendChild(document.createTextNode(title)); + paramsTreeElement.listItemElement.removeChildren(); + paramsTreeElement.listItemElement.appendChild(document.createTextNode(title)); var headerCount = document.createElement("span"); headerCount.addStyleClass("header-count"); - headerCount.textContent = WebInspector.UIString(" (%d)", parms.length); - parmsTreeElement.listItemElement.appendChild(headerCount); + headerCount.textContent = WebInspector.UIString(" (%d)", params.length); + paramsTreeElement.listItemElement.appendChild(headerCount); + + function toggleViewSource() + { + paramsTreeElement._viewSource = !paramsTreeElement._viewSource; + this._refreshParams(title, params, sourceText, paramsTreeElement); + } + + var viewSourceToggleTitle = paramsTreeElement._viewSource ? WebInspector.UIString("view parsed") : WebInspector.UIString("view source"); + var viewSourceToggleButton = this._createToggleButton(viewSourceToggleTitle); + viewSourceToggleButton.addEventListener("click", toggleViewSource.bind(this)); + paramsTreeElement.listItemElement.appendChild(viewSourceToggleButton); + + if (paramsTreeElement._viewSource) { + this._populateTreeElementWithSourceText(paramsTreeElement, sourceText); + return; + } var toggleTitle = this._decodeRequestParameters ? WebInspector.UIString("view URL encoded") : WebInspector.UIString("view decoded"); var toggleButton = this._createToggleButton(toggleTitle); - toggleButton.addEventListener("click", this._toggleURLdecoding.bind(this)); - parmsTreeElement.listItemElement.appendChild(toggleButton); - + toggleButton.addEventListener("click", this._toggleURLDecoding.bind(this)); + paramsTreeElement.listItemElement.appendChild(toggleButton); - for (var i = 0; i < parms.length; ++i) { + for (var i = 0; i < params.length; ++i) { var paramNameValue = document.createDocumentFragment(); - var name = this._formatParameter(parms[i].name + ":", "header-name", this._decodeRequestParameters); - var value = this._formatParameter(parms[i].value, "header-value source-code", this._decodeRequestParameters); + var name = this._formatParameter(params[i].name + ":", "header-name", this._decodeRequestParameters); + var value = this._formatParameter(params[i].value, "header-value source-code", this._decodeRequestParameters); paramNameValue.appendChild(name); paramNameValue.appendChild(value); var parmTreeElement = new TreeElement(paramNameValue, null, false); parmTreeElement.selectable = false; - parmsTreeElement.appendChild(parmTreeElement); + paramsTreeElement.appendChild(parmTreeElement); } }, - _toggleURLdecoding: function(event) + _toggleURLDecoding: function(event) { this._decodeRequestParameters = !this._decodeRequestParameters; this._refreshQueryString(); @@ -369,18 +387,8 @@ WebInspector.RequestHeadersView.prototype = { _refreshHeadersText: function(title, headers, headersText, headersTreeElement) { - headersTreeElement.removeChildren(); - + this._populateTreeElementWithSourceText(headersTreeElement, headersText); this._refreshHeadersTitle(title, headersTreeElement, headers.length); - var headerTreeElement = new TreeElement(null, null, false); - headerTreeElement.selectable = false; - headersTreeElement.appendChild(headerTreeElement); - - var headersTextElement = document.createElement("span"); - headersTextElement.addStyleClass("header-value"); - headersTextElement.addStyleClass("source-code"); - headersTextElement.textContent = String(headersText).trim(); - headerTreeElement.listItemElement.appendChild(headersTextElement); }, _toggleRequestHeadersText: function(event) @@ -407,7 +415,7 @@ WebInspector.RequestHeadersView.prototype = { { var toggleTitle = isHeadersTextShown ? WebInspector.UIString("view parsed") : WebInspector.UIString("view source"); return this._createToggleButton(toggleTitle); - } -} + }, -WebInspector.RequestHeadersView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/RequestJSONView.js b/Source/WebCore/inspector/front-end/RequestJSONView.js index 436acb4b8..56d5c5bc1 100644 --- a/Source/WebCore/inspector/front-end/RequestJSONView.js +++ b/Source/WebCore/inspector/front-end/RequestJSONView.js @@ -100,10 +100,10 @@ WebInspector.RequestJSONView.prototype = { section.expand(); section.editable = false; this.element.appendChild(section.element); - } -} + }, -WebInspector.RequestJSONView.prototype.__proto__ = WebInspector.RequestView.prototype; + __proto__: WebInspector.RequestView.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/RequestPreviewView.js b/Source/WebCore/inspector/front-end/RequestPreviewView.js index 4bf3a24d4..64581e532 100644 --- a/Source/WebCore/inspector/front-end/RequestPreviewView.js +++ b/Source/WebCore/inspector/front-end/RequestPreviewView.js @@ -68,8 +68,13 @@ WebInspector.RequestPreviewView.prototype = { _createPreviewView: function() { - if (this.request.hasErrorStatusCode() && this.request.content) - return new WebInspector.RequestHTMLView(this.request); + if (this.request.content) { + if (this.request.hasErrorStatusCode() || (this.request.type === WebInspector.resourceTypes.XHR && this.request.mimeType === "text/html")) { + var dataURL = this.request.asDataURL(); + if (dataURL !== null) + return new WebInspector.RequestHTMLView(this.request, dataURL); + } + } if (this.request.type === WebInspector.resourceTypes.XHR && this.request.content) { var parsedJSON = WebInspector.RequestJSONView.parseJSON(this.request.content); @@ -90,7 +95,7 @@ WebInspector.RequestPreviewView.prototype = { return this._createEmptyView(); return WebInspector.RequestView.nonSourceViewForRequest(this.request); - } -} + }, -WebInspector.RequestPreviewView.prototype.__proto__ = WebInspector.RequestContentView.prototype; + __proto__: WebInspector.RequestContentView.prototype +} diff --git a/Source/WebCore/inspector/front-end/RequestResponseView.js b/Source/WebCore/inspector/front-end/RequestResponseView.js index 54977cf50..284bae910 100644 --- a/Source/WebCore/inspector/front-end/RequestResponseView.js +++ b/Source/WebCore/inspector/front-end/RequestResponseView.js @@ -63,7 +63,7 @@ WebInspector.RequestResponseView.prototype = { this.sourceView.show(this.element); this.innerView = this.sourceView; } - } -} + }, -WebInspector.RequestResponseView.prototype.__proto__ = WebInspector.RequestContentView.prototype; + __proto__: WebInspector.RequestContentView.prototype +} diff --git a/Source/WebCore/inspector/front-end/RequestTimingView.js b/Source/WebCore/inspector/front-end/RequestTimingView.js index 824008854..663e85a4c 100644 --- a/Source/WebCore/inspector/front-end/RequestTimingView.js +++ b/Source/WebCore/inspector/front-end/RequestTimingView.js @@ -70,9 +70,12 @@ WebInspector.RequestTimingView.prototype = { this._tableElement = WebInspector.RequestTimingView.createTimingTable(this._request); this.element.appendChild(this._tableElement); - } + }, + + __proto__: WebInspector.View.prototype } + WebInspector.RequestTimingView.createTimingTable = function(request) { var tableElement = document.createElement("table"); @@ -157,5 +160,3 @@ WebInspector.RequestTimingView.createTimingTable = function(request) } return tableElement; } - -WebInspector.RequestTimingView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/Source/WebCore/inspector/front-end/RequestView.js b/Source/WebCore/inspector/front-end/RequestView.js index 5c2164147..359e3ebd1 100644 --- a/Source/WebCore/inspector/front-end/RequestView.js +++ b/Source/WebCore/inspector/front-end/RequestView.js @@ -46,10 +46,10 @@ WebInspector.RequestView.prototype = { hasContent: function() { return false; - } -} + }, -WebInspector.RequestView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @param {WebInspector.NetworkRequest} request diff --git a/Source/WebCore/inspector/front-end/Resource.js b/Source/WebCore/inspector/front-end/Resource.js index 83c5a5fb8..4b2b3993e 100644 --- a/Source/WebCore/inspector/front-end/Resource.js +++ b/Source/WebCore/inspector/front-end/Resource.js @@ -211,7 +211,7 @@ WebInspector.Resource.prototype = { }, /** - * @return {?string} + * @return {string} */ contentURL: function() { @@ -276,26 +276,15 @@ WebInspector.Resource.prototype = { { function onResourceContent() { - image.src = this._contentURL(); + var imageSrc = WebInspector.contentAsDataURL(this._content, this.mimeType, this._contentEncoded); + if (imageSrc === null) + imageSrc = this.url; + image.src = imageSrc; } this.requestContent(onResourceContent.bind(this)); }, - /** - * @return {string} - */ - _contentURL: function() - { - const maxDataUrlSize = 1024 * 1024; - // If resource content is not available or won't fit a data URL, fall back to using original URL. - if (this._content == null || this._content.length > maxDataUrlSize) - return this.url; - - return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content; - }, - - _requestFinished: function() { this._request.removeEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, this._requestFinished, this); @@ -360,8 +349,8 @@ WebInspector.Resource.prototype = { isHidden: function() { return !!this._isHidden; - } -} + }, -WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/ResourceScriptMapping.js b/Source/WebCore/inspector/front-end/ResourceScriptMapping.js index 6dfeb11ff..a86a73dc5 100644 --- a/Source/WebCore/inspector/front-end/ResourceScriptMapping.js +++ b/Source/WebCore/inspector/front-end/ResourceScriptMapping.js @@ -40,11 +40,7 @@ WebInspector.ResourceScriptMapping = function(workspace) this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); /** @type {Object.<string, WebInspector.UISourceCode>} */ - this._uiSourceCodeForScriptId = {}; - this._scriptIdForUISourceCode = new Map(); - this._temporaryUISourceCodes = new Map(); - /** @type {Object.<string, number>} */ - this._nextDynamicScriptIndexForURL = {}; + this._temporaryUISourceCodeForScriptId = {}; this._scripts = []; } @@ -57,10 +53,41 @@ WebInspector.ResourceScriptMapping.prototype = { { var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ rawLocation; var script = WebInspector.debuggerModel.scriptForId(debuggerModelLocation.scriptId); - var uiSourceCode = this._uiSourceCodeForScriptId[debuggerModelLocation.scriptId]; + var uiSourceCode = this._workspaceUISourceCodeForScript(script); + if (!uiSourceCode) + uiSourceCode = this._getOrCreateTemporaryUISourceCode(script); + else if (uiSourceCode.scriptFile() && uiSourceCode.scriptFile().hasDivergedFromVM()) { + var temporaryUISourceCode = this._getOrCreateTemporaryUISourceCode(script); + temporaryUISourceCode.divergedVersion = uiSourceCode; + uiSourceCode = temporaryUISourceCode; + } + console.assert(!!uiSourceCode); return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0); }, + _hasDivergedFromVMChanged: function(event) + { + var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data; + var scripts = this._scriptsForUISourceCode(uiSourceCode); + if (!scripts.length) + return; + for (var i = 0; i < scripts.length; ++i) + scripts[i].setSourceMapping(this); + if (uiSourceCode.scriptFile() && !uiSourceCode.scriptFile().hasDivergedFromVM()) + this._deleteTemporaryUISourceCodeForScripts(scripts); + }, + + /** + * @param {WebInspector.Script} script + * @return {WebInspector.UISourceCode} + */ + _workspaceUISourceCodeForScript: function(script) + { + if (script.isAnonymousScript() || this._isDynamicScript(script)) + return null; + return this._workspace.uiSourceCodeForURL(script.sourceURL); + }, + /** * @param {WebInspector.UISourceCode} uiSourceCode * @param {number} lineNumber @@ -69,9 +96,9 @@ WebInspector.ResourceScriptMapping.prototype = { */ uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) { - var scriptId = this._scriptIdForUISourceCode.get(uiSourceCode); - var script = WebInspector.debuggerModel.scriptForId(scriptId); - return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber); + var scripts = this._scriptsForUISourceCode(uiSourceCode); + console.assert(scripts.length); + return WebInspector.debuggerModel.createRawLocation(scripts[0], lineNumber, columnNumber); }, /** @@ -79,20 +106,35 @@ WebInspector.ResourceScriptMapping.prototype = { */ addScript: function(script) { - console.assert(!this._uiSourceCodeForScriptId[script.scriptId]); - - var isDynamicScript = false; - if (!script.isAnonymousScript()) { + if (!script.isAnonymousScript()) this._scripts.push(script); - var uiSourceCode = this._workspace.uiSourceCodeForURL(script.sourceURL); - isDynamicScript = !!uiSourceCode && uiSourceCode.contentType() === WebInspector.resourceTypes.Document && !script.isInlineScript(); - if (uiSourceCode && !isDynamicScript && !this._temporaryUISourceCodes.get(uiSourceCode)) - this._bindUISourceCodeToScripts(uiSourceCode, [script]); + script.setSourceMapping(this); + var uiSourceCode = this._workspaceUISourceCodeForScript(script); + if (uiSourceCode) { + this._bindUISourceCodeToScripts(uiSourceCode, [script]); + return; } - if (!this._uiSourceCodeForScriptId[script.scriptId]) - this._addOrReplaceTemporaryUISourceCode(script, isDynamicScript); - console.assert(this._uiSourceCodeForScriptId[script.scriptId]); + var scripts = script.isInlineScript() ? this._scriptsForSourceURL(script.sourceURL, true) : [script]; + if (this._deleteTemporaryUISourceCodeForScripts(scripts)) + uiSourceCode = this._getOrCreateTemporaryUISourceCode(script); + }, + + /** + * @param {Array.<WebInspector.Script>} scripts + * @return {boolean} + */ + _deleteTemporaryUISourceCodeForScripts: function(scripts) + { + var temporaryUISourceCode; + for (var i = 0; i < scripts.length; ++i) { + var script = scripts[i]; + temporaryUISourceCode = temporaryUISourceCode || this._temporaryUISourceCodeForScriptId[script.scriptId]; + delete this._temporaryUISourceCodeForScriptId[script.scriptId]; + } + if (temporaryUISourceCode) + this._workspace.project().removeTemporaryUISourceCode(temporaryUISourceCode); + return !!temporaryUISourceCode; }, /** @@ -102,14 +144,27 @@ WebInspector.ResourceScriptMapping.prototype = { _bindUISourceCodeToScripts: function(uiSourceCode, scripts) { console.assert(scripts.length); - - for (var i = 0; i < scripts.length; ++i) { - this._uiSourceCodeForScriptId[scripts[i].scriptId] = uiSourceCode; + for (var i = 0; i < scripts.length; ++i) scripts[i].setSourceMapping(this); - } uiSourceCode.isContentScript = scripts[0].isContentScript; uiSourceCode.setSourceMapping(this); - this._scriptIdForUISourceCode.put(uiSourceCode, scripts[0].scriptId); + if (!uiSourceCode.isTemporary) { + var scriptFile = new WebInspector.ResourceScriptFile(uiSourceCode); + uiSourceCode.setScriptFile(scriptFile); + scriptFile.addEventListener(WebInspector.ScriptFile.Events.HasDivergedFromVMChanged, this._hasDivergedFromVMChanged, this); + } + }, + + /** + * @param {WebInspector.Script} script + * @return {boolean} + */ + _isDynamicScript: function(script) + { + if (script.isAnonymousScript() || script.isInlineScript()) + return false; + var inlineScriptsWithTheSameURL = this._scriptsForSourceURL(script.sourceURL, true); + return !!inlineScriptsWithTheSameURL.length; }, /** @@ -129,54 +184,45 @@ WebInspector.ResourceScriptMapping.prototype = { /** * @param {WebInspector.Script} script - * @param {boolean} isDynamicScript + * @return {WebInspector.UISourceCode} */ - _addOrReplaceTemporaryUISourceCode: function(script, isDynamicScript) + _getOrCreateTemporaryUISourceCode: function(script) { - var scripts = script.isInlineScript() ? this._scriptsForSourceURL(script.sourceURL, true) : [script]; - - var oldUISourceCode; - for (var i = 0; i < scripts.length; ++i) { - oldUISourceCode = this._uiSourceCodeForScriptId[scripts[i].scriptId]; - if (oldUISourceCode) - break; - } - console.assert(!oldUISourceCode || this._temporaryUISourceCodes.get(oldUISourceCode)); + var temporaryUISourceCode = this._temporaryUISourceCodeForScriptId[script.scriptId]; + if (temporaryUISourceCode) + return temporaryUISourceCode; + var scripts = script.isInlineScript() ? this._scriptsForSourceURL(script.sourceURL, true) : [script]; var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider(scripts) : script; - var url = script.sourceURL; - if (isDynamicScript) { - var nextIndex = this._nextDynamicScriptIndexForURL[script.sourceURL] || 1; - url += " (" + nextIndex + ")"; - this._nextDynamicScriptIndexForURL[script.sourceURL] = nextIndex + 1; - } - var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, !script.isInlineScript()); - this._temporaryUISourceCodes.put(uiSourceCode, uiSourceCode); - this._bindUISourceCodeToScripts(uiSourceCode, scripts); - - if (!script.sourceURL) - return uiSourceCode; - - if (oldUISourceCode) - this._uiSourceCodeReplaced(oldUISourceCode, uiSourceCode); - else - this._workspace.project().addUISourceCode(uiSourceCode); - return uiSourceCode; + var isDynamicScript = this._isDynamicScript(script); + var url = isDynamicScript ? "" : script.sourceURL; + temporaryUISourceCode = new WebInspector.JavaScriptSource(url, contentProvider, false); + temporaryUISourceCode.isTemporary = true; + for (var i = 0; i < scripts.length; ++i) + this._temporaryUISourceCodeForScriptId[scripts[i].scriptId] = temporaryUISourceCode; + this._bindUISourceCodeToScripts(temporaryUISourceCode, scripts); + this._workspace.project().addTemporaryUISourceCode(temporaryUISourceCode); + return temporaryUISourceCode; }, _uiSourceCodeAddedToWorkspace: function(event) { var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data; - console.assert(!this._scriptIdForUISourceCode.get(uiSourceCode) || this._temporaryUISourceCodes.get(uiSourceCode)); - if (!uiSourceCode.url || this._temporaryUISourceCodes.get(uiSourceCode)) + console.assert(!!uiSourceCode.url); + + var scripts = this._scriptsForUISourceCode(uiSourceCode); + if (!scripts.length) return; - this._addUISourceCode(uiSourceCode); + + this._deleteTemporaryUISourceCodeForScripts(scripts); + this._bindUISourceCodeToScripts(uiSourceCode, scripts); }, /** * @param {WebInspector.UISourceCode} uiSourceCode + * @return {Array.<WebInspector.Script>} */ - _addUISourceCode: function(uiSourceCode) + _scriptsForUISourceCode: function(uiSourceCode) { var isInlineScript; switch (uiSourceCode.contentType()) { @@ -187,41 +233,123 @@ WebInspector.ResourceScriptMapping.prototype = { isInlineScript = false; break; default: - return; + return []; } - var scripts = this._scriptsForSourceURL(uiSourceCode.url, isInlineScript); - if (!scripts.length) - return; + return this._scriptsForSourceURL(uiSourceCode.url, isInlineScript); + }, - var oldUISourceCode = this._uiSourceCodeForScriptId[scripts[0].scriptId]; - this._bindUISourceCodeToScripts(uiSourceCode, scripts); + _reset: function() + { + this._temporaryUISourceCodeForScriptId = {}; + this._scripts = []; + }, +} + +/** + * @interface + */ +WebInspector.ScriptFile = function() +{ +} + +WebInspector.ScriptFile.Events = { + HasDivergedFromVMChanged: "HasDivergedFromVMChanged", +} + +WebInspector.ScriptFile.prototype = { + /** + * @return {boolean} + */ + hasDivergedFromVM: function() { return false; }, + + /** + * @return {boolean} + */ + isDivergingFromVM: function() { return false; }, + + /** + * @param {string} eventType + * @param {function(WebInspector.Event)} listener + * @param {Object=} thisObject + */ + addEventListener: function(eventType, listener, thisObject) { }, + + /** + * @param {string} eventType + * @param {function(WebInspector.Event)} listener + * @param {Object=} thisObject + */ + removeEventListener: function(eventType, listener, thisObject) { } +} + +/** + * @constructor + * @implements {WebInspector.ScriptFile} + * @extends {WebInspector.Object} + * @param {WebInspector.UISourceCode} uiSourceCode + */ +WebInspector.ResourceScriptFile = function(uiSourceCode) +{ + WebInspector.ScriptFile.call(this); + this._uiSourceCode = uiSourceCode; +} + +WebInspector.ResourceScriptFile.prototype = { + /** + * @param {function(?string)} callback + */ + workingCopyCommitted: function(callback) + { + /** + * @param {?string} error + */ + function innerCallback(error) + { + if (error) + this._hasDivergedFromVM = true; + else + delete this._hasDivergedFromVM; + this.fireHasDivergedFromVMChanged(); - if (oldUISourceCode) { - console.assert(this._temporaryUISourceCodes.get(oldUISourceCode)); - this._uiSourceCodeReplaced(oldUISourceCode, uiSourceCode); + callback(error); } + var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ this._uiSourceCode.uiLocationToRawLocation(0, 0); + if (!rawLocation) { + callback(null); + return; + } + var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId); + WebInspector.debuggerModel.setScriptSource(script.scriptId, this._uiSourceCode.workingCopy(), innerCallback.bind(this)); + }, - console.assert(this._scriptIdForUISourceCode.get(uiSourceCode) && !this._temporaryUISourceCodes.get(uiSourceCode)); + workingCopyChanged: function() + { + this.fireHasDivergedFromVMChanged(); + }, + + fireHasDivergedFromVMChanged: function() + { + this._isDivergingFromVM = true; + this.dispatchEventToListeners(WebInspector.ScriptFile.Events.HasDivergedFromVMChanged, this._uiSourceCode); + delete this._isDivergingFromVM; }, /** - * @param {WebInspector.UISourceCode} oldUISourceCode - * @param {WebInspector.UISourceCode} uiSourceCode + * @return {boolean} */ - _uiSourceCodeReplaced: function(oldUISourceCode, uiSourceCode) + hasDivergedFromVM: function() { - this._temporaryUISourceCodes.remove(oldUISourceCode); - this._scriptIdForUISourceCode.remove(oldUISourceCode); - this._workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode); + return this._uiSourceCode.isDirty() || this._hasDivergedFromVM; }, - _reset: function() + /** + * @return {boolean} + */ + isDivergingFromVM: function() { - this._uiSourceCodeForScriptId = {}; - this._scriptIdForUISourceCode.clear(); - this._temporaryUISourceCodes.clear(); - this._nextDynamicScriptIndexForURL = {}; - this._scripts = []; + return this._isDivergingFromVM; }, + + __proto__: WebInspector.Object.prototype } diff --git a/Source/WebCore/inspector/front-end/ResourceTreeModel.js b/Source/WebCore/inspector/front-end/ResourceTreeModel.js index d503dae60..f5527915c 100644 --- a/Source/WebCore/inspector/front-end/ResourceTreeModel.js +++ b/Source/WebCore/inspector/front-end/ResourceTreeModel.js @@ -339,10 +339,10 @@ WebInspector.ResourceTreeModel.prototype = { _createResourceFromFramePayload: function(frame, url, type, mimeType) { return new WebInspector.Resource(null, url, frame.url, frame.id, frame.loaderId, type, mimeType); - } -} + }, -WebInspector.ResourceTreeModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/ResourceUtils.js b/Source/WebCore/inspector/front-end/ResourceUtils.js index 5c3f49de6..87eabf540 100644 --- a/Source/WebCore/inspector/front-end/ResourceUtils.js +++ b/Source/WebCore/inspector/front-end/ResourceUtils.js @@ -226,3 +226,18 @@ WebInspector.linkifyRequestAsNode = function(request, classes) anchor.requestId = request.requestId; return anchor; } + +/** + * @param {string} content + * @param {string} mimeType + * @param {boolean} contentEncoded + * @return {?string} + */ +WebInspector.contentAsDataURL = function(content, mimeType, contentEncoded) +{ + const maxDataUrlSize = 1024 * 1024; + if (content == null || content.length > maxDataUrlSize) + return null; + + return "data:" + mimeType + (contentEncoded ? ";base64," : ",") + content; +} diff --git a/Source/WebCore/inspector/front-end/ResourceView.js b/Source/WebCore/inspector/front-end/ResourceView.js index ce50b4b6c..e48e5ea64 100644 --- a/Source/WebCore/inspector/front-end/ResourceView.js +++ b/Source/WebCore/inspector/front-end/ResourceView.js @@ -44,10 +44,10 @@ WebInspector.ResourceView.prototype = { hasContent: function() { return false; - } -} + }, -WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @param {WebInspector.Resource} resource @@ -97,7 +97,7 @@ WebInspector.ResourceSourceFrame.prototype = { contextMenu.appendApplicableItems(this._resource); if (this._resource.request) contextMenu.appendApplicableItems(this._resource.request); - } -} + }, -WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype; + __proto__: WebInspector.SourceFrame.prototype +} diff --git a/Source/WebCore/inspector/front-end/ResourceWebSocketFrameView.js b/Source/WebCore/inspector/front-end/ResourceWebSocketFrameView.js index 59acd6518..9884828ba 100644 --- a/Source/WebCore/inspector/front-end/ResourceWebSocketFrameView.js +++ b/Source/WebCore/inspector/front-end/ResourceWebSocketFrameView.js @@ -95,4 +95,6 @@ WebInspector.ResourceWebSocketFrameView.OpCodes = { PongFrame: 10 }; -WebInspector.ResourceWebSocketFrameView.prototype.__proto__ = WebInspector.View.prototype; +WebInspector.ResourceWebSocketFrameView.prototype = { + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/ResourcesPanel.js b/Source/WebCore/inspector/front-end/ResourcesPanel.js index 8ddcd2520..c505c97e0 100644 --- a/Source/WebCore/inspector/front-end/ResourcesPanel.js +++ b/Source/WebCore/inspector/front-end/ResourcesPanel.js @@ -854,10 +854,10 @@ WebInspector.ResourcesPanel.prototype = { this._previousHoveredElement.hovered = false; delete this._previousHoveredElement; } - } -} + }, -WebInspector.ResourcesPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} /** * @constructor @@ -982,10 +982,10 @@ WebInspector.BaseStorageTreeElement.prototype = { get searchMatchesCount() { return 0; - } -} + }, -WebInspector.BaseStorageTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -1027,10 +1027,10 @@ WebInspector.StorageCategoryTreeElement.prototype = { oncollapse: function() { WebInspector.settings[this._expandedSettingKey].set(false); - } -} + }, -WebInspector.StorageCategoryTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1147,10 +1147,10 @@ WebInspector.FrameTreeElement.prototype = { break; } parentTreeElement.insertChild(childTreeElement, i); - } -} + }, -WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1317,10 +1317,10 @@ WebInspector.FrameResourceTreeElement.prototype = { } } return this._sourceView; - } -} + }, -WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1360,10 +1360,10 @@ WebInspector.DatabaseTreeElement.prototype = { this.appendChild(new WebInspector.DatabaseTableTreeElement(this._storagePanel, this._database, tableNames[i])); } this._database.getTableNames(tableNamesCallback.bind(this)); - } -} + }, -WebInspector.DatabaseTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1386,9 +1386,10 @@ WebInspector.DatabaseTableTreeElement.prototype = { { WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel._showDatabase(this._database, this._tableName); - } + }, + + __proto__: WebInspector.BaseStorageTreeElement.prototype } -WebInspector.DatabaseTableTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; /** * @constructor @@ -1500,10 +1501,10 @@ WebInspector.IndexedDBTreeElement.prototype = { if (index !== -1) return this._idbDatabaseTreeElements[i]; return null; - } -} + }, -WebInspector.IndexedDBTreeElement.prototype.__proto__ = WebInspector.StorageCategoryTreeElement.prototype; + __proto__: WebInspector.StorageCategoryTreeElement.prototype +} /** * @constructor @@ -1571,10 +1572,10 @@ WebInspector.FileSystemListTreeElement.prototype = { } this._fileSystemModel.refreshFileSystemList(); - } -} + }, -WebInspector.FileSystemListTreeElement.prototype.__proto__ = WebInspector.StorageCategoryTreeElement.prototype; + __proto__: WebInspector.StorageCategoryTreeElement.prototype +} /** * @constructor @@ -1677,10 +1678,10 @@ WebInspector.IDBDatabaseTreeElement.prototype = { { for (var objectStoreName in this._idbObjectStoreTreeElements) this._objectStoreRemoved(objectStoreName); - } -} + }, -WebInspector.IDBDatabaseTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1780,10 +1781,10 @@ WebInspector.IDBObjectStoreTreeElement.prototype = { this._indexRemoved(indexName); if (this._view) this._view.clear(); - } -} + }, -WebInspector.IDBObjectStoreTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1847,10 +1848,10 @@ WebInspector.IDBIndexTreeElement.prototype = { { if (this._view) this._view.clear(); - } -} + }, -WebInspector.IDBIndexTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -1872,9 +1873,10 @@ WebInspector.DOMStorageTreeElement.prototype = { { WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel._showDOMStorage(this._domStorage); - } + }, + + __proto__: WebInspector.BaseStorageTreeElement.prototype } -WebInspector.DOMStorageTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; /** * @constructor @@ -1896,9 +1898,10 @@ WebInspector.CookieTreeElement.prototype = { { WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showCookies(this, this._cookieDomain); - } + }, + + __proto__: WebInspector.BaseStorageTreeElement.prototype } -WebInspector.CookieTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; /** * @constructor @@ -1927,9 +1930,10 @@ WebInspector.ApplicationCacheManifestTreeElement.prototype = { { WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showCategoryView(this._manifestURL); - } + }, + + __proto__: WebInspector.BaseStorageTreeElement.prototype } -WebInspector.ApplicationCacheManifestTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; /** * @constructor @@ -1979,9 +1983,10 @@ WebInspector.ApplicationCacheFrameTreeElement.prototype = { { WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showApplicationCache(this._frameId); - } + }, + + __proto__: WebInspector.BaseStorageTreeElement.prototype } -WebInspector.ApplicationCacheFrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; /** * @constructor @@ -2018,10 +2023,10 @@ WebInspector.FileSystemTreeElement.prototype = { { if (this.fileSystemView && this._storagePanel.visibleView == this.fileSystemView) this._storagePanel.closeVisibleView(); - } -} + }, -WebInspector.FileSystemTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + __proto__: WebInspector.BaseStorageTreeElement.prototype +} /** * @constructor @@ -2040,10 +2045,10 @@ WebInspector.StorageCategoryView.prototype = { setText: function(text) { this._emptyView.text = text; - } -} + }, -WebInspector.StorageCategoryView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/RevisionHistoryView.js b/Source/WebCore/inspector/front-end/RevisionHistoryView.js index f80e498aa..56b822676 100644 --- a/Source/WebCore/inspector/front-end/RevisionHistoryView.js +++ b/Source/WebCore/inspector/front-end/RevisionHistoryView.js @@ -55,8 +55,8 @@ WebInspector.RevisionHistoryView = function() WebInspector.workspace.uiSourceCodes().forEach(populateRevisions.bind(this)); WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeContentCommitted, this._revisionAdded, this); - WebInspector.workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this); WebInspector.workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this); + WebInspector.workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, this._uiSourceCodeRemoved, this); WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this); this._statusElement = document.createElement("span"); @@ -161,22 +161,13 @@ WebInspector.RevisionHistoryView.prototype = { }, /** - * @param {WebInspector.Event} event - */ - _uiSourceCodeReplaced: function(event) - { - var oldUISourceCode = /** @type {WebInspector.UISourceCode} */ event.data.oldUISourceCode; - var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data.uiSourceCode; - this._removeUISourceCode(oldUISourceCode); - this._revealUISourceCode(uiSourceCode); - }, - - /** * @param {WebInspector.UISourceCode} uiSourceCode */ _removeUISourceCode: function(uiSourceCode) { var uiSourceCodeItem = this._uiSourceCodeItems.get(uiSourceCode); + if (!uiSourceCodeItem) + return; this._treeOutline.removeChild(uiSourceCodeItem); this._uiSourceCodeItems.remove(uiSourceCode); }, @@ -185,10 +176,10 @@ WebInspector.RevisionHistoryView.prototype = { { this._treeOutline.removeChildren(); this._uiSourceCodeItems.clear(); - } -} + }, -WebInspector.RevisionHistoryView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -322,7 +313,7 @@ WebInspector.RevisionHistoryTreeElement.prototype = { allowRevert: function() { this._revertElement.removeStyleClass("hidden"); - } -} + }, -WebInspector.RevisionHistoryTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/RuntimeModel.js b/Source/WebCore/inspector/front-end/RuntimeModel.js index f56335622..6f7f9e39e 100644 --- a/Source/WebCore/inspector/front-end/RuntimeModel.js +++ b/Source/WebCore/inspector/front-end/RuntimeModel.js @@ -49,6 +49,22 @@ WebInspector.RuntimeModel.Events = { WebInspector.RuntimeModel.prototype = { /** + * @param {WebInspector.ExecutionContext} executionContext + */ + setCurrentExecutionContext: function(executionContext) + { + this._currentExecutionContext = executionContext; + }, + + /** + * @return {WebInspector.ExecutionContext} + */ + currentExecutionContext: function() + { + return this._currentExecutionContext; + }, + + /** * @return {Array.<WebInspector.FrameExecutionContextList>} */ contextLists: function() @@ -95,7 +111,7 @@ WebInspector.RuntimeModel.prototype = { _didLoadCachedResources: function() { InspectorBackend.registerRuntimeDispatcher(new WebInspector.RuntimeDispatcher(this)); - RuntimeAgent.setReportExecutionContextCreation(true); + RuntimeAgent.enable(); }, _executionContextCreated: function(context) @@ -105,10 +121,208 @@ WebInspector.RuntimeModel.prototype = { if (!contextList) return; contextList._addExecutionContext(new WebInspector.ExecutionContext(context.id, context.name, context.isPageContext)); - } -} + }, -WebInspector.RuntimeModel.prototype.__proto__ = WebInspector.Object.prototype; + /** + * @param {string} expression + * @param {string} objectGroup + * @param {boolean} includeCommandLineAPI + * @param {boolean} doNotPauseOnExceptionsAndMuteConsole + * @param {boolean} returnByValue + * @param {function(?WebInspector.RemoteObject, boolean, RuntimeAgent.RemoteObject=)} callback + */ + evaluate: function(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback) + { + if (WebInspector.debuggerModel.selectedCallFrame()) { + WebInspector.debuggerModel.evaluateOnSelectedCallFrame(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback); + return; + } + + if (!expression) { + // There is no expression, so the completion should happen against global properties. + expression = "this"; + } + + /** + * @param {?Protocol.Error} error + * @param {RuntimeAgent.RemoteObject} result + * @param {boolean=} wasThrown + */ + function evalCallback(error, result, wasThrown) + { + if (error) { + console.error(error); + callback(null, false); + return; + } + + if (returnByValue) + callback(null, !!wasThrown, wasThrown ? null : result); + else + callback(WebInspector.RemoteObject.fromPayload(result), !!wasThrown); + } + RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this._currentExecutionContext ? this._currentExecutionContext.id : undefined, returnByValue, evalCallback); + }, + + /** + * @param {Element} proxyElement + * @param {Range} wordRange + * @param {boolean} force + * @param {function(Array.<string>, number=)} completionsReadyCallback + */ + completionsForTextPrompt: function(proxyElement, wordRange, force, completionsReadyCallback) + { + // Pass less stop characters to rangeOfWord so the range will be a more complete expression. + var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOffset, " =:[({;,!+-*/&|^<>", proxyElement, "backward"); + var expressionString = expressionRange.toString(); + var prefix = wordRange.toString(); + this._completionsForExpression(expressionString, prefix, force, completionsReadyCallback); + }, + + /** + * @param {string} expressionString + * @param {string} prefix + * @param {boolean} force + * @param {function(Array.<string>, number=)} completionsReadyCallback + */ + _completionsForExpression: function(expressionString, prefix, force, completionsReadyCallback) + { + var lastIndex = expressionString.length - 1; + + var dotNotation = (expressionString[lastIndex] === "."); + var bracketNotation = (expressionString[lastIndex] === "["); + + if (dotNotation || bracketNotation) + expressionString = expressionString.substr(0, lastIndex); + + if (expressionString && parseInt(expressionString, 10) == expressionString) { + // User is entering float value, do not suggest anything. + completionsReadyCallback([]); + return; + } + + if (!prefix && !expressionString && !force) { + completionsReadyCallback([]); + return; + } + + if (!expressionString && WebInspector.debuggerModel.selectedCallFrame()) + WebInspector.debuggerModel.getSelectedCallFrameVariables(receivedPropertyNames.bind(this)); + else + this.evaluate(expressionString, "completion", true, true, false, evaluated.bind(this)); + + function evaluated(result, wasThrown) + { + if (!result || wasThrown) { + completionsReadyCallback([]); + return; + } + + function getCompletions(primitiveType) + { + var object; + if (primitiveType === "string") + object = new String(""); + else if (primitiveType === "number") + object = new Number(0); + else if (primitiveType === "boolean") + object = new Boolean(false); + else + object = this; + + var resultSet = {}; + for (var o = object; o; o = o.__proto__) { + try { + var names = Object.getOwnPropertyNames(o); + for (var i = 0; i < names.length; ++i) + resultSet[names[i]] = true; + } catch (e) { + } + } + return resultSet; + } + + if (result.type === "object" || result.type === "function") + result.callFunctionJSON(getCompletions, undefined, receivedPropertyNames.bind(this)); + else if (result.type === "string" || result.type === "number" || result.type === "boolean") + this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, receivedPropertyNamesFromEval.bind(this)); + } + + function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) + { + if (result && !wasThrown) + receivedPropertyNames.call(this, result.value); + else + completionsReadyCallback([]); + } + + function receivedPropertyNames(propertyNames) + { + RuntimeAgent.releaseObjectGroup("completion"); + if (!propertyNames) { + completionsReadyCallback([]); + return; + } + var includeCommandLineAPI = (!dotNotation && !bracketNotation); + if (includeCommandLineAPI) { + const commandLineAPI = ["dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear"]; + for (var i = 0; i < commandLineAPI.length; ++i) + propertyNames[commandLineAPI[i]] = true; + } + this._reportCompletions(completionsReadyCallback, dotNotation, bracketNotation, expressionString, prefix, Object.keys(propertyNames)); + } + }, + + /** + * @param {function(Array.<string>, number=)} completionsReadyCallback + * @param {boolean} dotNotation + * @param {boolean} bracketNotation + * @param {string} expressionString + * @param {string} prefix + * @param {Array.<string>} properties + */ + _reportCompletions: function(completionsReadyCallback, dotNotation, bracketNotation, expressionString, prefix, properties) { + if (bracketNotation) { + if (prefix.length && prefix[0] === "'") + var quoteUsed = "'"; + else + var quoteUsed = "\""; + } + + var results = []; + + if (!expressionString) { + const keywords = ["break", "case", "catch", "continue", "default", "delete", "do", "else", "finally", "for", "function", "if", "in", + "instanceof", "new", "return", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with"]; + properties = properties.concat(keywords); + } + + properties.sort(); + + for (var i = 0; i < properties.length; ++i) { + var property = properties[i]; + + if (dotNotation && !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(property)) + continue; + + if (bracketNotation) { + if (!/^[0-9]+$/.test(property)) + property = quoteUsed + property.escapeCharacters(quoteUsed + "\\") + quoteUsed; + property += "]"; + } + + if (property.length < prefix.length) + continue; + if (prefix.length && !property.startsWith(prefix)) + continue; + + results.push(property); + } + completionsReadyCallback(results); + }, + + __proto__: WebInspector.Object.prototype +} /** * @type {WebInspector.RuntimeModel} @@ -231,7 +445,7 @@ WebInspector.FrameExecutionContextList.prototype = return name + "( " + subtitle + " )"; } return "<iframe>"; - } -} + }, -WebInspector.FrameExecutionContextList.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/SASSSourceMapping.js b/Source/WebCore/inspector/front-end/SASSSourceMapping.js index 0b8e96e6e..9c7cab4e7 100644 --- a/Source/WebCore/inspector/front-end/SASSSourceMapping.js +++ b/Source/WebCore/inspector/front-end/SASSSourceMapping.js @@ -114,7 +114,9 @@ WebInspector.SASSSourceMapping.prototype = { { var uiSourceCode = this._uiSourceCodeForURL[url]; if (!uiSourceCode) { - uiSourceCode = new WebInspector.SASSSource(url); + var content = InspectorFrontendHost.loadResourceSynchronously(url); + var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Stylesheet, content, "text/x-scss"); + uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, true); this._uiSourceCodeForURL[url] = uiSourceCode; this._workspace.project().addUISourceCode(uiSourceCode); WebInspector.cssModel.setSourceMapping(rawURL, this); @@ -158,26 +160,3 @@ WebInspector.SASSSourceMapping.prototype = { } } -/** - * @constructor - * @extends {WebInspector.UISourceCode} - * @param {string} sassURL - */ -WebInspector.SASSSource = function(sassURL) -{ - var content = InspectorFrontendHost.loadResourceSynchronously(sassURL); - var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Stylesheet, content, "text/x-scss"); - WebInspector.UISourceCode.call(this, sassURL, null, contentProvider); -} - -WebInspector.SASSSource.prototype = { - /** - * @return {boolean} - */ - isEditable: function() - { - return true; - } -} - -WebInspector.SASSSource.prototype.__proto__ = WebInspector.UISourceCode.prototype; diff --git a/Source/WebCore/inspector/front-end/ScopeChainSidebarPane.js b/Source/WebCore/inspector/front-end/ScopeChainSidebarPane.js index 56de87005..46bee9076 100644 --- a/Source/WebCore/inspector/front-end/ScopeChainSidebarPane.js +++ b/Source/WebCore/inspector/front-end/ScopeChainSidebarPane.js @@ -112,16 +112,18 @@ WebInspector.ScopeChainSidebarPane.prototype = { section.editInSelectedCallFrameWhenPaused = true; section.pane = this; - if (!foundLocalScope || scope.type === "local" || title in this._expandedSections) + if (scope.type === "global") + section.expanded = false; + else if (!foundLocalScope || scope.type === "local" || title in this._expandedSections) section.expanded = true; this._sections.push(section); this.bodyElement.appendChild(section.element); } - } -} + }, -WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -180,7 +182,7 @@ WebInspector.ScopeVariableTreeElement.prototype = { this._propertyPath = result; return result; - } -} + }, -WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectPropertyTreeElement.prototype; + __proto__: WebInspector.ObjectPropertyTreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/Script.js b/Source/WebCore/inspector/front-end/Script.js index 920ac2675..aaf387aa7 100644 --- a/Source/WebCore/inspector/front-end/Script.js +++ b/Source/WebCore/inspector/front-end/Script.js @@ -34,8 +34,9 @@ * @param {number} endColumn * @param {boolean} isContentScript * @param {string=} sourceMapURL + * @param {boolean=} hasSourceURL */ -WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL) +WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL) { this.scriptId = scriptId; this.sourceURL = sourceURL; @@ -45,12 +46,13 @@ WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endL this.endColumn = endColumn; this.isContentScript = isContentScript; this.sourceMapURL = sourceMapURL; + this.hasSourceURL = hasSourceURL; this._locations = []; } WebInspector.Script.prototype = { /** - * @return {?string} + * @return {string} */ contentURL: function() { @@ -230,7 +232,7 @@ WebInspector.Script.Location.prototype = { { WebInspector.LiveLocation.prototype.dispose.call(this); this._script._locations.remove(this); - } -} + }, -WebInspector.Script.Location.prototype.__proto__ = WebInspector.LiveLocation.prototype; + __proto__: WebInspector.LiveLocation.prototype +} diff --git a/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js b/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js index 13c7a0e75..d394a2ad2 100644 --- a/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js +++ b/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js @@ -218,10 +218,10 @@ HTMLScriptFormatter.prototype = { styleSheetEnded: function(cursor) { - } -} + }, -HTMLScriptFormatter.prototype.__proto__ = WebInspector.SourceHTMLTokenizer.prototype; + __proto__: WebInspector.SourceHTMLTokenizer.prototype +} function require() { diff --git a/Source/WebCore/inspector/front-end/ScriptSnippetModel.js b/Source/WebCore/inspector/front-end/ScriptSnippetModel.js index 60a667233..33535ff9a 100644 --- a/Source/WebCore/inspector/front-end/ScriptSnippetModel.js +++ b/Source/WebCore/inspector/front-end/ScriptSnippetModel.js @@ -39,6 +39,7 @@ WebInspector.ScriptSnippetModel = function(workspace) this._uiSourceCodeForScriptId = {}; this._scriptForUISourceCode = new Map(); this._snippetJavaScriptSourceForSnippetId = {}; + this._snippetIdForJavaScriptSource = new Map(); this._snippetStorage = new WebInspector.SnippetStorage("script", "Script snippet #"); this._lastSnippetEvaluationIndexSetting = WebInspector.settings.createSetting("lastSnippetEvaluationIndex", 0); @@ -81,7 +82,10 @@ WebInspector.ScriptSnippetModel.prototype = { */ _addScriptSnippet: function(snippet) { - var snippetJavaScriptSource = new WebInspector.SnippetJavaScriptSource(snippet.id, snippet.name, new WebInspector.SnippetContentProvider(snippet), this); + var snippetJavaScriptSource = new WebInspector.SnippetJavaScriptSource(snippet.name, new WebInspector.SnippetContentProvider(snippet), this); + var scriptFile = new WebInspector.SnippetScriptFile(this, snippetJavaScriptSource); + snippetJavaScriptSource.setScriptFile(scriptFile); + this._snippetIdForJavaScriptSource.put(snippetJavaScriptSource, snippet.id); snippetJavaScriptSource.setSourceMapping(this._snippetScriptMapping); this._snippetJavaScriptSourceForSnippetId[snippet.id] = snippetJavaScriptSource; this._workspace.project().addUISourceCode(snippetJavaScriptSource); @@ -93,11 +97,13 @@ WebInspector.ScriptSnippetModel.prototype = { */ deleteScriptSnippet: function(snippetJavaScriptSource) { - var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId); + var snippetId = this._snippetIdForJavaScriptSource.get(snippetJavaScriptSource); + var snippet = this._snippetStorage.snippetForId(snippetId); this._snippetStorage.deleteSnippet(snippet); this._removeBreakpoints(snippetJavaScriptSource); this._releaseSnippetScript(snippetJavaScriptSource); delete this._snippetJavaScriptSourceForSnippetId[snippet.id]; + this._snippetIdForJavaScriptSource.remove(snippetJavaScriptSource); this._workspace.project().removeUISourceCode(snippetJavaScriptSource); }, @@ -107,21 +113,14 @@ WebInspector.ScriptSnippetModel.prototype = { */ renameScriptSnippet: function(snippetJavaScriptSource, newName) { - var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId); + var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource); + var snippetId = this._snippetIdForJavaScriptSource.get(snippetJavaScriptSource); + var snippet = this._snippetStorage.snippetForId(snippetId); if (!snippet || !newName || snippet.name === newName) return; snippet.name = newName; snippetJavaScriptSource.urlChanged(snippet.name); - }, - - /** - * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource - * @return {boolean} - */ - _isDivergedFromVM: function(snippetJavaScriptSource) - { - var script = this._scriptForUISourceCode.get(snippetJavaScriptSource); - return !script; + this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations); }, /** @@ -130,7 +129,8 @@ WebInspector.ScriptSnippetModel.prototype = { */ _setScriptSnippetContent: function(snippetJavaScriptSource, newContent) { - var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId); + var snippetId = this._snippetIdForJavaScriptSource.get(snippetJavaScriptSource); + var snippet = this._snippetStorage.snippetForId(snippetId); snippet.content = newContent; }, @@ -144,8 +144,10 @@ WebInspector.ScriptSnippetModel.prototype = { return; var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource); - this._releaseSnippetScript(snippetJavaScriptSource); + var uiSourceCode = this._releaseSnippetScript(snippetJavaScriptSource); this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations); + if (uiSourceCode) + this._restoreBreakpoints(uiSourceCode, breakpointLocations); }, /** @@ -167,7 +169,8 @@ WebInspector.ScriptSnippetModel.prototype = { var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource); this._releaseSnippetScript(snippetJavaScriptSource); this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations); - var evaluationIndex = this._nextEvaluationIndex(snippetJavaScriptSource.snippetId); + var snippetId = this._snippetIdForJavaScriptSource.get(snippetJavaScriptSource); + var evaluationIndex = this._nextEvaluationIndex(snippetId); snippetJavaScriptSource._evaluationIndex = evaluationIndex; var evaluationUrl = this._evaluationSourceURL(snippetJavaScriptSource); @@ -213,11 +216,46 @@ WebInspector.ScriptSnippetModel.prototype = { var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource); this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations); - WebInspector.consoleView.runScript(scriptId); + this._runScript(scriptId); + } + }, + + /** + * @param {DebuggerAgent.ScriptId} scriptId + */ + _runScript: function(scriptId) + { + var currentExecutionContext = WebInspector.runtimeModel.currentExecutionContext(); + DebuggerAgent.runScript(scriptId, currentExecutionContext ? currentExecutionContext.id : undefined, "console", false, runCallback.bind(this)); + + /** + * @param {?string} error + * @param {?RuntimeAgent.RemoteObject} result + * @param {boolean=} wasThrown + */ + function runCallback(error, result, wasThrown) + { + if (error) { + console.error(error); + return; + } + + this._printRunScriptResult(result, wasThrown); } }, /** + * @param {?RuntimeAgent.RemoteObject} result + * @param {boolean=} wasThrown + */ + _printRunScriptResult: function(result, wasThrown) + { + var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); + var message = WebInspector.ConsoleMessage.create(WebInspector.ConsoleMessage.MessageSource.JS, level, "", undefined, undefined, undefined, undefined, [result]); + WebInspector.console.addMessage(message) + }, + + /** * @param {WebInspector.DebuggerModel.Location} rawLocation * @return {WebInspector.UILocation} */ @@ -272,20 +310,25 @@ WebInspector.ScriptSnippetModel.prototype = { console.assert(!this._scriptForUISourceCode.get(snippetJavaScriptSource)); this._uiSourceCodeForScriptId[script.scriptId] = snippetJavaScriptSource; this._scriptForUISourceCode.put(snippetJavaScriptSource, script); + snippetJavaScriptSource.scriptFile().setHasDivergedFromVM(false); script.setSourceMapping(this._snippetScriptMapping); }, /** * @param {WebInspector.Script} script + * @return {WebInspector.UISourceCode} uiSourceCode */ _createUISourceCodeForScript: function(script) { - var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, false); - uiSourceCode.setSourceMapping(this._snippetScriptMapping); + var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, script, false); + uiSourceCode.setSourceMapping(this._snippetScriptMapping); + // FIXME: Should be added to workspace as temporary. + uiSourceCode.isTemporary = true; uiSourceCode.isSnippetEvaluation = true; this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode; this._scriptForUISourceCode.put(uiSourceCode, script); script.setSourceMapping(this._snippetScriptMapping); + return uiSourceCode; }, /** @@ -301,31 +344,36 @@ WebInspector.ScriptSnippetModel.prototype = { }, /** - * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource + * @param {WebInspector.UISourceCode} uiSourceCode * @param {Array.<Object>} breakpointLocations */ - _restoreBreakpoints: function(snippetJavaScriptSource, breakpointLocations) + _restoreBreakpoints: function(uiSourceCode, breakpointLocations) { for (var i = 0; i < breakpointLocations.length; ++i) { var uiLocation = breakpointLocations[i].uiLocation; var breakpoint = breakpointLocations[i].breakpoint; - WebInspector.breakpointManager.setBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled()); + WebInspector.breakpointManager.setBreakpoint(uiSourceCode, uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled()); } }, /** * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource + * @return {WebInspector.UISourceCode} */ _releaseSnippetScript: function(snippetJavaScriptSource) { var script = this._scriptForUISourceCode.get(snippetJavaScriptSource); if (!script) - return; + return null; + snippetJavaScriptSource.scriptFile().setIsDivergingFromVM(true); + snippetJavaScriptSource.scriptFile().setHasDivergedFromVM(true); delete this._uiSourceCodeForScriptId[script.scriptId]; this._scriptForUISourceCode.remove(snippetJavaScriptSource); delete snippetJavaScriptSource._evaluationIndex; - this._createUISourceCodeForScript(script); + var uiSourceCode = this._createUISourceCodeForScript(script); + snippetJavaScriptSource.scriptFile().setIsDivergingFromVM(false); + return uiSourceCode; }, /** @@ -336,7 +384,8 @@ WebInspector.ScriptSnippetModel.prototype = { { var snippetPrefix = WebInspector.ScriptSnippetModel.snippetSourceURLPrefix; var evaluationSuffix = "_" + snippetJavaScriptSource._evaluationIndex; - return snippetPrefix + snippetJavaScriptSource.snippetId + evaluationSuffix; + var snippetId = this._snippetIdForJavaScriptSource.get(snippetJavaScriptSource); + return snippetPrefix + snippetId + evaluationSuffix; }, /** @@ -359,94 +408,99 @@ WebInspector.ScriptSnippetModel.prototype = { this._uiSourceCodeForScriptId = {}; this._scriptForUISourceCode = new Map(); this._snippetJavaScriptSourceForSnippetId = {}; + this._snippetIdForJavaScriptSource = new Map(); }, _projectDidReset: function() { this._loadSnippets(); - } -} + }, -WebInspector.ScriptSnippetModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor * @extends {WebInspector.JavaScriptSource} - * @param {string} snippetId * @param {string} snippetName * @param {WebInspector.ContentProvider} contentProvider * @param {WebInspector.ScriptSnippetModel} scriptSnippetModel */ -WebInspector.SnippetJavaScriptSource = function(snippetId, snippetName, contentProvider, scriptSnippetModel) +WebInspector.SnippetJavaScriptSource = function(snippetName, contentProvider, scriptSnippetModel) { - WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, true); - this._snippetId = snippetId; + WebInspector.JavaScriptSource.call(this, snippetName, contentProvider, true); this._scriptSnippetModel = scriptSnippetModel; this.isSnippet = true; } WebInspector.SnippetJavaScriptSource.prototype = { + __proto__: WebInspector.JavaScriptSource.prototype +} + +/** + * @constructor + * @implements {WebInspector.ScriptFile} + * @extends {WebInspector.Object} + * @param {WebInspector.ScriptSnippetModel} scriptSnippetModel + * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource + */ +WebInspector.SnippetScriptFile = function(scriptSnippetModel, snippetJavaScriptSource) +{ + WebInspector.ScriptFile.call(this); + this._scriptSnippetModel = scriptSnippetModel; + this._snippetJavaScriptSource = snippetJavaScriptSource; + this._hasDivergedFromVM = true; +} + +WebInspector.SnippetScriptFile.prototype = { /** * @return {boolean} */ - isEditable: function() + hasDivergedFromVM: function() { - return true; + return this._hasDivergedFromVM; }, /** - * @return {boolean} + * @param {boolean} hasDivergedFromVM */ - isDivergedFromVM: function() + setHasDivergedFromVM: function(hasDivergedFromVM) { - return this._scriptSnippetModel._isDivergedFromVM(this); + this._hasDivergedFromVM = hasDivergedFromVM; }, /** - * @param {function(?string)} callback + * @return {boolean} */ - workingCopyCommitted: function(callback) - { - this._scriptSnippetModel._setScriptSnippetContent(this, this.workingCopy()); - callback(null); - }, - - workingCopyChanged: function() - { - this._scriptSnippetModel._scriptSnippetEdited(this); - }, - - evaluate: function() + isDivergingFromVM: function() { - this._scriptSnippetModel.evaluateScriptSnippet(this); + return this._isDivergingFromVM; }, /** - * @return {boolean} + * @param {boolean} isDivergingFromVM */ - supportsEnabledBreakpointsWhileEditing: function() + setIsDivergingFromVM: function(isDivergingFromVM) { - return true; + this._isDivergingFromVM = isDivergingFromVM; }, /** - * @return {string} + * @param {function(?string)} callback */ - breakpointStorageId: function() + workingCopyCommitted: function(callback) { - return WebInspector.ScriptSnippetModel.snippetSourceURLPrefix + this.snippetId; + this._scriptSnippetModel._setScriptSnippetContent(this._snippetJavaScriptSource, this._snippetJavaScriptSource.workingCopy()); + callback(null); }, - /** - * @return {string} - */ - get snippetId() + workingCopyChanged: function() { - return this._snippetId; - } -} + this._scriptSnippetModel._scriptSnippetEdited(this._snippetJavaScriptSource); + }, -WebInspector.SnippetJavaScriptSource.prototype.__proto__ = WebInspector.JavaScriptSource.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -508,7 +562,9 @@ WebInspector.SnippetContentProvider = function(snippet) WebInspector.StaticContentProvider.call(this, WebInspector.resourceTypes.Script, snippet.content); } -WebInspector.SnippetContentProvider.prototype.__proto__ = WebInspector.StaticContentProvider.prototype; +WebInspector.SnippetContentProvider.prototype = { + __proto__: WebInspector.StaticContentProvider.prototype +} /** * @type {?WebInspector.ScriptSnippetModel} diff --git a/Source/WebCore/inspector/front-end/ScriptsNavigator.js b/Source/WebCore/inspector/front-end/ScriptsNavigator.js index 2eeef73c7..d094e644e 100644 --- a/Source/WebCore/inspector/front-end/ScriptsNavigator.js +++ b/Source/WebCore/inspector/front-end/ScriptsNavigator.js @@ -130,17 +130,6 @@ WebInspector.ScriptsNavigator.prototype = { }, /** - * @param {WebInspector.UISourceCode} oldUISourceCode - * @param {WebInspector.UISourceCode} uiSourceCode - */ - replaceUISourceCode: function(oldUISourceCode, uiSourceCode) - { - this._scriptsView.replaceUISourceCode(oldUISourceCode, uiSourceCode); - this._contentScriptsView.replaceUISourceCode(oldUISourceCode, uiSourceCode); - this._snippetsView.replaceUISourceCode(oldUISourceCode, uiSourceCode); - }, - - /** * @param {WebInspector.UISourceCode} uiSourceCode * @param {function(boolean)=} callback */ @@ -186,10 +175,10 @@ WebInspector.ScriptsNavigator.prototype = { this._scriptsView.reset(); this._contentScriptsView.reset(); this._snippetsView.reset(); - } -} + }, -WebInspector.ScriptsNavigator.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -241,7 +230,7 @@ WebInspector.SnippetsNavigatorView.prototype = { if (!uiSourceCode.isSnippet) return; var snippetJavaScriptSource = /** @type {WebInspector.SnippetJavaScriptSource} */ uiSourceCode; - snippetJavaScriptSource.evaluate(); + WebInspector.scriptSnippetModel.evaluateScriptSnippet(snippetJavaScriptSource); }, /** @@ -276,7 +265,7 @@ WebInspector.SnippetsNavigatorView.prototype = { _snippetCreationRequested: function() { this.dispatchEventToListeners(WebInspector.SnippetsNavigatorView.Events.SnippetCreationRequested, null); - } -} + }, -WebInspector.SnippetsNavigatorView.prototype.__proto__ = WebInspector.NavigatorView.prototype; + __proto__: WebInspector.NavigatorView.prototype +} diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js index f4dc77219..e810985a6 100644 --- a/Source/WebCore/inspector/front-end/ScriptsPanel.js +++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js @@ -194,8 +194,8 @@ WebInspector.ScriptsPanel = function(workspaceForTest) WebInspector.endBatchUpdate(); this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this); - this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this); this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this); + this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, this._uiSourceCodeRemoved, this); this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset.bind(this), this); WebInspector.advancedSearchController.registerSearchScope(new WebInspector.ScriptsSearchScope(this._workspace)); @@ -247,7 +247,7 @@ WebInspector.ScriptsPanel.prototype = { _addUISourceCode: function(uiSourceCode) { if (this._toggleFormatSourceButton.toggled) - uiSourceCode.setFormatted(true); + uiSourceCode.setFormatted(true, this._uiSourceCodeFormatted.bind(this, uiSourceCode)); this._navigator.addUISourceCode(uiSourceCode); this._editorContainer.addUISourceCode(uiSourceCode); @@ -299,7 +299,7 @@ WebInspector.ScriptsPanel.prototype = { else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert) this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion.")); else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation) - this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".", details.auxData.directiveText)); + this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".", details.auxData["directiveText"])); else { function didGetUILocation(uiLocation) { @@ -482,19 +482,6 @@ WebInspector.ScriptsPanel.prototype = { sourceFrame.detach(); }, - /** - * @param {WebInspector.Event} event - */ - _uiSourceCodeReplaced: function(event) - { - var oldUISourceCode = /** @type {WebInspector.UISourceCode} */ event.data.oldUISourceCode; - var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data.uiSourceCode; - - this._navigator.replaceUISourceCode(oldUISourceCode, uiSourceCode); - this._editorContainer.replaceFile(oldUISourceCode, uiSourceCode); - this._removeSourceFrame(oldUISourceCode); - }, - _clearCurrentExecutionLine: function() { if (this._executionSourceFrame) @@ -516,9 +503,16 @@ WebInspector.ScriptsPanel.prototype = { _revealExecutionLine: function(uiLocation) { + var uiSourceCode = uiLocation.uiSourceCode; // Some scripts (anonymous and snippets evaluations) are not added to files select by default. - this._editorContainer.addUISourceCode(uiLocation.uiSourceCode); - var sourceFrame = this._showFile(uiLocation.uiSourceCode); + if (uiSourceCode.isTemporary) { + if (this._currentUISourceCode && this._currentUISourceCode.scriptFile() && this._currentUISourceCode.scriptFile().isDivergingFromVM()) + return; + this._editorContainer.addUISourceCode(uiSourceCode); + if (uiSourceCode.formatted() !== this._toggleFormatSourceButton.toggled) + uiSourceCode.setFormatted(this._toggleFormatSourceButton.toggled, this._uiSourceCodeFormatted.bind(this, uiSourceCode)); + } + var sourceFrame = this._showFile(uiSourceCode); sourceFrame.revealLine(uiLocation.lineNumber); sourceFrame.focus(); }, @@ -599,6 +593,7 @@ WebInspector.ScriptsPanel.prototype = { } if (this._paused) { + this._updateButtonTitle(this.pauseButton, WebInspector.UIString("Resume script execution (%s).")) this.pauseButton.addStyleClass("paused"); this.pauseButton.disabled = false; @@ -608,6 +603,7 @@ WebInspector.ScriptsPanel.prototype = { this.debuggerStatusElement.textContent = WebInspector.UIString("Paused"); } else { + this._updateButtonTitle(this.pauseButton, WebInspector.UIString("Pause script execution (%s).")) this.pauseButton.removeStyleClass("paused"); this.pauseButton.disabled = this._waitingToPause; @@ -758,12 +754,11 @@ WebInspector.ScriptsPanel.prototype = { var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta; // Continue. - title = WebInspector.UIString("Pause script execution (%s)."); handler = this._togglePause.bind(this); shortcuts = []; shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F8)); shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Slash, platformSpecificModifier)); - this.pauseButton = this._createButtonAndRegisterShortcuts(section, "scripts-pause", title, handler, shortcuts, WebInspector.UIString("Pause/Continue")); + this.pauseButton = this._createButtonAndRegisterShortcuts(section, "scripts-pause", "", handler, shortcuts, WebInspector.UIString("Pause/Continue")); debugToolbar.appendChild(this.pauseButton); // Step over. @@ -805,12 +800,23 @@ WebInspector.ScriptsPanel.prototype = { return debugToolbar; }, + _updateButtonTitle: function(button, buttonTitle) + { + button.buttonTitle = buttonTitle; + var hasShortcuts = button.shortcuts && button.shortcuts.length; + if (hasShortcuts) + button.title = String.vsprintf(buttonTitle, [button.shortcuts[0].name]); + else + button.title = buttonTitle; + }, + _createButtonAndRegisterShortcuts: function(section, buttonId, buttonTitle, handler, shortcuts, shortcutDescription) { var button = document.createElement("button"); button.className = "status-bar-item"; button.id = buttonId; - button.title = String.vsprintf(buttonTitle, [shortcuts[0].name]); + button.shortcuts = shortcuts; + this._updateButtonTitle(button, buttonTitle); button.disabled = true; button.appendChild(document.createElement("img")); button.addEventListener("click", handler, false); @@ -928,12 +934,18 @@ WebInspector.ScriptsPanel.prototype = { view.replaceAllWith(query, text); }, + _uiSourceCodeFormatted: function(uiSourceCode) + { + if (uiSourceCode instanceof WebInspector.JavaScriptSource) + WebInspector.breakpointManager.restoreBreakpoints(uiSourceCode); + }, + _toggleFormatSource: function() { this._toggleFormatSourceButton.toggled = !this._toggleFormatSourceButton.toggled; var uiSourceCodes = this._workspace.uiSourceCodes(); for (var i = 0; i < uiSourceCodes.length; ++i) - uiSourceCodes[i].setFormatted(this._toggleFormatSourceButton.toggled); + uiSourceCodes[i].setFormatted(this._toggleFormatSourceButton.toggled, this._uiSourceCodeFormatted.bind(this, uiSourceCodes[i])); }, addToWatch: function(expression) @@ -1100,8 +1112,9 @@ WebInspector.ScriptsPanel.prototype = { var uiSourceCode = /** @type {WebInspector.UISourceCode} */ target; contextMenu.appendItem(WebInspector.UIString("Local modifications..."), this._showLocalHistory.bind(this, uiSourceCode)); - if (uiSourceCode.resource() && uiSourceCode.resource().request) - contextMenu.appendApplicableItems(uiSourceCode.resource().request); + var resource = WebInspector.resourceForURL(uiSourceCode.url); + if (resource && resource.request) + contextMenu.appendApplicableItems(resource.request); }, /** @@ -1138,7 +1151,7 @@ WebInspector.ScriptsPanel.prototype = { showGoToSourceDialog: function() { WebInspector.OpenResourceDialog.show(this, this._workspace, this.editorView.mainElement); - } -} + }, -WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} diff --git a/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js b/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js index 5516f1f23..99edfafef 100644 --- a/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js +++ b/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js @@ -53,7 +53,7 @@ WebInspector.ScriptsPanelDescriptor.prototype = { } this.panel().appendApplicableItems(contextMenu, target); - } -} + }, -WebInspector.ScriptsPanelDescriptor.prototype.__proto__ = WebInspector.PanelDescriptor.prototype; + __proto__: WebInspector.PanelDescriptor.prototype +} diff --git a/Source/WebCore/inspector/front-end/ScriptsSearchScope.js b/Source/WebCore/inspector/front-end/ScriptsSearchScope.js index c19d1ecf5..1f9a40eb6 100644 --- a/Source/WebCore/inspector/front-end/ScriptsSearchScope.js +++ b/Source/WebCore/inspector/front-end/ScriptsSearchScope.js @@ -124,7 +124,7 @@ WebInspector.ScriptsSearchScope.prototype = { uiSourceCodes.sort(comparator); return uiSourceCodes; - } -} + }, -WebInspector.ScriptsSearchScope.prototype.__proto__ = WebInspector.SearchScope.prototype; + __proto__: WebInspector.SearchScope.prototype +} diff --git a/Source/WebCore/inspector/front-end/Settings.js b/Source/WebCore/inspector/front-end/Settings.js index a138cb658..cc98b4cd5 100644 --- a/Source/WebCore/inspector/front-end/Settings.js +++ b/Source/WebCore/inspector/front-end/Settings.js @@ -43,7 +43,8 @@ var Preferences = { exposeDisableCache: false, applicationTitle: "Web Inspector - %s", showDockToRight: false, - exposeFileSystemInspection: false + exposeFileSystemInspection: false, + experimentsEnabled: true } var Capabilities = { @@ -65,7 +66,7 @@ WebInspector.Settings = function() { this._eventSupport = new WebInspector.Object(); - this.colorFormat = this.createSetting("colorFormat", "hex"); + this.colorFormat = this.createSetting("colorFormat", "original"); this.consoleHistory = this.createSetting("consoleHistory", []); this.debuggerEnabled = this.createSetting("debuggerEnabled", false); this.domWordWrap = this.createSetting("domWordWrap", true); @@ -92,9 +93,9 @@ WebInspector.Settings = function() this.deviceMetrics = this.createSetting("deviceMetrics", ""); this.deviceFitWindow = this.createSetting("deviceFitWindow", false); this.showScriptFolders = this.createSetting("showScriptFolders", true); - this.dockToRight = this.createSetting("dockToRight", false); this.emulateTouchEvents = this.createSetting("emulateTouchEvents", false); this.showPaintRects = this.createSetting("showPaintRects", false); + this.showShadowDOM = this.createSetting("showShadowDOM", false); this.zoomLevel = this.createSetting("zoomLevel", 0); this.savedURLs = this.createSetting("savedURLs", {}); this.javaScriptDisabled = this.createSetting("javaScriptDisabled", false); @@ -103,6 +104,7 @@ WebInspector.Settings = function() this.showHeapSnapshotObjectsHiddenProperties = this.createSetting("showHeaSnapshotObjectsHiddenProperties", false); this.searchInContentScripts = this.createSetting("searchInContentScripts", false); this.textEditorIndent = this.createSetting("textEditorIndent", " "); + this.lastDockState = this.createSetting("lastDockState", ""); // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused // periodical breakpoints duplication leading to inspector slowness. @@ -186,7 +188,6 @@ WebInspector.ExperimentsSettings = function() this._enabledForTest = {}; // Add currently running experiments here. - this.showShadowDOM = this._createExperiment("showShadowDOM", "Show shadow DOM"); this.snippetsSupport = this._createExperiment("snippetsSupport", "Snippets support"); this.nativeMemorySnapshots = this._createExperiment("nativeMemorySnapshots", "Native memory profiling"); this.liveNativeMemoryChart = this._createExperiment("liveNativeMemoryChart", "Live native memory chart"); @@ -216,7 +217,7 @@ WebInspector.ExperimentsSettings.prototype = { */ get experimentsEnabled() { - return "experiments" in WebInspector.queryParamsObject; + return Preferences.experimentsEnabled || ("experiments" in WebInspector.queryParamsObject); }, /** diff --git a/Source/WebCore/inspector/front-end/SettingsScreen.js b/Source/WebCore/inspector/front-end/SettingsScreen.js index 1c98e3e40..f57e3e802 100644 --- a/Source/WebCore/inspector/front-end/SettingsScreen.js +++ b/Source/WebCore/inspector/front-end/SettingsScreen.js @@ -107,10 +107,10 @@ WebInspector.SettingsScreen.prototype = { { this._onHide(); WebInspector.HelpScreen.prototype.willHide.call(this); - } -} + }, -WebInspector.SettingsScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype; + __proto__: WebInspector.HelpScreen.prototype +} /** * @constructor @@ -236,10 +236,10 @@ WebInspector.SettingsTab.prototype = { fieldsetElement.appendChild(element); p.appendChild(fieldsetElement); return p; - } -} + }, -WebInspector.SettingsTab.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -250,8 +250,6 @@ WebInspector.GenericSettingsTab = function() WebInspector.SettingsTab.call(this); var p = this._appendSection(); - if (Preferences.showDockToRight) - p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Dock to right"), WebInspector.settings.dockToRight)); if (Preferences.exposeDisableCache) p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled)); var disableJSElement = this._createCheckboxSetting(WebInspector.UIString("Disable JavaScript"), WebInspector.settings.javaScriptDisabled); @@ -268,6 +266,7 @@ WebInspector.GenericSettingsTab = function() [ WebInspector.Color.Format.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat)); 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 = this._appendSection(WebInspector.UIString("Rendering")); p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects)); @@ -332,10 +331,10 @@ WebInspector.GenericSettingsTab.prototype = { { // We need to manually update the checkbox state, since enabling JavaScript in the page can actually uncover the "forbidden" state. PageAgent.setScriptExecutionDisabled(WebInspector.settings.javaScriptDisabled.get(), this._updateScriptDisabledCheckbox.bind(this)); - } -} + }, -WebInspector.GenericSettingsTab.prototype.__proto__ = WebInspector.SettingsTab.prototype; + __proto__: WebInspector.SettingsTab.prototype +} /** * @constructor @@ -862,10 +861,10 @@ WebInspector.UserAgentSettingsTab.prototype = { this._gammaElement = this._createInput(cellElement, "device-orientation-override-gamma", String(deviceOrientation.gamma), this._applyDeviceOrientationUserInput.bind(this)); return fieldsetElement; - } -} + }, -WebInspector.UserAgentSettingsTab.prototype.__proto__ = WebInspector.SettingsTab.prototype; + __proto__: WebInspector.SettingsTab.prototype +} /** * @constructor @@ -917,10 +916,10 @@ WebInspector.ExperimentsSettingsTab.prototype = { label.appendChild(document.createTextNode(WebInspector.UIString(experiment.title))); p.appendChild(label); return p; - } -} + }, -WebInspector.ExperimentsSettingsTab.prototype.__proto__ = WebInspector.SettingsTab.prototype; + __proto__: WebInspector.SettingsTab.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/ShowMoreDataGridNode.js b/Source/WebCore/inspector/front-end/ShowMoreDataGridNode.js index ee7ee3990..7914a1b89 100644 --- a/Source/WebCore/inspector/front-end/ShowMoreDataGridNode.js +++ b/Source/WebCore/inspector/front-end/ShowMoreDataGridNode.js @@ -140,7 +140,8 @@ WebInspector.ShowMoreDataGridNode.prototype = { dispose: function() { - } -}; + }, + + __proto__: WebInspector.DataGridNode.prototype +} -WebInspector.ShowMoreDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; diff --git a/Source/WebCore/inspector/front-end/SidebarPane.js b/Source/WebCore/inspector/front-end/SidebarPane.js index af6ed1abd..075a6eb8b 100644 --- a/Source/WebCore/inspector/front-end/SidebarPane.js +++ b/Source/WebCore/inspector/front-end/SidebarPane.js @@ -132,7 +132,7 @@ WebInspector.SidebarPane.prototype = { { if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code) this.toggleExpanded(); - } -} + }, -WebInspector.SidebarPane.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/SidebarTreeElement.js b/Source/WebCore/inspector/front-end/SidebarTreeElement.js index 427cdc595..398abc852 100644 --- a/Source/WebCore/inspector/front-end/SidebarTreeElement.js +++ b/Source/WebCore/inspector/front-end/SidebarTreeElement.js @@ -68,10 +68,10 @@ WebInspector.SidebarSectionTreeElement.prototype = { { if (this.listItemElement) this.listItemElement.scrollIntoViewIfNeeded(false); - } -} + }, -WebInspector.SidebarSectionTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -222,7 +222,7 @@ WebInspector.SidebarTreeElement.prototype = { { if (this._listItemNode) this._listItemNode.scrollIntoViewIfNeeded(false); - } -} + }, -WebInspector.SidebarTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/SnippetJavaScriptSourceFrame.js b/Source/WebCore/inspector/front-end/SnippetJavaScriptSourceFrame.js index 587dd7bb1..75e01cfb6 100644 --- a/Source/WebCore/inspector/front-end/SnippetJavaScriptSourceFrame.js +++ b/Source/WebCore/inspector/front-end/SnippetJavaScriptSourceFrame.js @@ -54,8 +54,8 @@ WebInspector.SnippetJavaScriptSourceFrame.prototype = { _runButtonClicked: function() { - this._snippetJavaScriptSource.evaluate(); - } -} + WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._snippetJavaScriptSource); + }, -WebInspector.SnippetJavaScriptSourceFrame.prototype.__proto__ = WebInspector.JavaScriptSourceFrame.prototype; + __proto__: WebInspector.JavaScriptSourceFrame.prototype +} diff --git a/Source/WebCore/inspector/front-end/SnippetStorage.js b/Source/WebCore/inspector/front-end/SnippetStorage.js index 4a525c9c2..4bdc87368 100644 --- a/Source/WebCore/inspector/front-end/SnippetStorage.js +++ b/Source/WebCore/inspector/front-end/SnippetStorage.js @@ -120,10 +120,10 @@ WebInspector.SnippetStorage.prototype = { this._lastSnippetIdentifierSetting.set(0); this._snippetsSetting.set([]); this._snippets = {}; - } -} + }, -WebInspector.SnippetStorage.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -204,7 +204,7 @@ WebInspector.Snippet.prototype = { serializedSnippet.name = this.name; serializedSnippet.content = this.content; return serializedSnippet; - } -} + }, -WebInspector.Snippet.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js b/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js index 618913969..aa7d42b80 100644 --- a/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js +++ b/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js @@ -1565,7 +1565,7 @@ case 150: } } - } -} + }, -WebInspector.SourceCSSTokenizer.prototype.__proto__ = WebInspector.SourceTokenizer.prototype; + __proto__: WebInspector.SourceTokenizer.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js b/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js index f33f5a924..659eb93ce 100644 --- a/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js +++ b/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js @@ -333,7 +333,7 @@ WebInspector.SourceCSSTokenizer.prototype = { <*> [^] { this.tokenType = null; return cursor; } */ } - } -} + }, -WebInspector.SourceCSSTokenizer.prototype.__proto__ = WebInspector.SourceTokenizer.prototype; + __proto__: WebInspector.SourceTokenizer.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js index cb930e14f..7ccb94d45 100644 --- a/Source/WebCore/inspector/front-end/SourceFrame.js +++ b/Source/WebCore/inspector/front-end/SourceFrame.js @@ -650,10 +650,10 @@ WebInspector.SourceFrame.prototype = { if (this._url && WebInspector.fileManager.isURLSaved(this._url)) WebInspector.fileManager.save(this._url, content, false); return true; - } -} + }, -WebInspector.SourceFrame.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** @@ -706,7 +706,7 @@ WebInspector.TextEditorDelegateForSourceFrame.prototype = { { var targetLocation = WebInspector.ParsedURL.completeURL(this._sourceFrame._url, hrefValue); return WebInspector.linkifyURLAsNode(targetLocation || hrefValue, hrefValue, undefined, isExternal); - } -} + }, -WebInspector.TextEditorDelegateForSourceFrame.prototype.__proto__ = WebInspector.TextEditorDelegate.prototype; + __proto__: WebInspector.TextEditorDelegate.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.js b/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.js index b4770cc43..e114044aa 100644 --- a/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.js +++ b/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.js @@ -810,7 +810,7 @@ case 119: } } - } -} + }, -WebInspector.SourceHTMLTokenizer.prototype.__proto__ = WebInspector.SourceTokenizer.prototype; + __proto__: WebInspector.SourceTokenizer.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js b/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js index a8deedf7f..140d7cac8 100644 --- a/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js +++ b/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js @@ -385,7 +385,7 @@ WebInspector.SourceHTMLTokenizer.prototype = { <*> [^] { this.tokenType = null; return cursor; } */ } - } -} + }, -WebInspector.SourceHTMLTokenizer.prototype.__proto__ = WebInspector.SourceTokenizer.prototype; + __proto__: WebInspector.SourceTokenizer.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js b/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js index 0c7dccb69..1e0e3e8e0 100644 --- a/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js +++ b/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js @@ -2438,7 +2438,7 @@ case 300: } } - } -} + }, -WebInspector.SourceJavaScriptTokenizer.prototype.__proto__ = WebInspector.SourceTokenizer.prototype; + __proto__: WebInspector.SourceTokenizer.prototype +} diff --git a/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js b/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js index 34a678634..29345d125 100644 --- a/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js +++ b/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js @@ -192,7 +192,7 @@ WebInspector.SourceJavaScriptTokenizer.prototype = { <*> [^] { this.tokenType = null; return cursor; } */ } - } -} + }, -WebInspector.SourceJavaScriptTokenizer.prototype.__proto__ = WebInspector.SourceTokenizer.prototype; + __proto__: WebInspector.SourceTokenizer.prototype +} diff --git a/Source/WebCore/inspector/front-end/Spectrum.js b/Source/WebCore/inspector/front-end/Spectrum.js index 0cd4803e8..4e7fdc151 100644 --- a/Source/WebCore/inspector/front-end/Spectrum.js +++ b/Source/WebCore/inspector/front-end/Spectrum.js @@ -455,7 +455,7 @@ WebInspector.Spectrum.prototype = { this.hide(false); event.consume(true); } - } -} + }, -WebInspector.Spectrum.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/SplitView.js b/Source/WebCore/inspector/front-end/SplitView.js index 467899cfa..111c3e2b8 100644 --- a/Source/WebCore/inspector/front-end/SplitView.js +++ b/Source/WebCore/inspector/front-end/SplitView.js @@ -442,7 +442,7 @@ WebInspector.SplitView.prototype = { elementsToRestoreScrollPositionsFor: function() { return [ this.mainElement, this.sidebarElement ]; - } -} + }, -WebInspector.SplitView.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} diff --git a/Source/WebCore/inspector/front-end/StatusBarButton.js b/Source/WebCore/inspector/front-end/StatusBarButton.js index 9194302d5..414c6b30b 100644 --- a/Source/WebCore/inspector/front-end/StatusBarButton.js +++ b/Source/WebCore/inspector/front-end/StatusBarButton.js @@ -57,6 +57,7 @@ WebInspector.StatusBarButton = function(title, className, states) this._state = 0; this.title = title; + this.className = className; this.disabled = false; this._visible = true; } @@ -192,6 +193,10 @@ WebInspector.StatusBarButton.prototype = { _showOptions: function(buttonsProvider) { var buttons = buttonsProvider(); + var mainButtonClone = new WebInspector.StatusBarButton(this.title, this.className, this.states); + mainButtonClone.addEventListener("click", this._clicked, this); + mainButtonClone.state = this.state; + buttons.push(mainButtonClone); var mouseUpListener = mouseUp.bind(this); document.documentElement.addEventListener("mouseup", mouseUpListener, false); @@ -205,8 +210,8 @@ WebInspector.StatusBarButton.prototype = { var boundMouseOver = mouseOver.bind(this); var boundMouseOut = mouseOut.bind(this); for (var i = 0; i < buttons.length; ++i) { - buttons[i].element.addEventListener("mousemove", boundMouseOver.bind(this), false); - buttons[i].element.addEventListener("mouseout", boundMouseOut.bind(this), false); + buttons[i].element.addEventListener("mousemove", boundMouseOver, false); + buttons[i].element.addEventListener("mouseout", boundMouseOut, false); optionsBarElement.appendChild(buttons[i].element); } buttons[buttons.length - 1].element.addStyleClass("emulate-active"); @@ -239,10 +244,10 @@ WebInspector.StatusBarButton.prototype = { buttons[i]._clicked(); } } - } -} + }, -WebInspector.StatusBarButton.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/StyleSheetOutlineDialog.js b/Source/WebCore/inspector/front-end/StyleSheetOutlineDialog.js index 25141bda0..553714130 100644 --- a/Source/WebCore/inspector/front-end/StyleSheetOutlineDialog.js +++ b/Source/WebCore/inspector/front-end/StyleSheetOutlineDialog.js @@ -157,7 +157,7 @@ WebInspector.StyleSheetOutlineDialog.prototype = { rewriteQuery: function(query) { return query; - } -} + }, -WebInspector.StyleSheetOutlineDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype; + __proto__: WebInspector.SelectionDialogContentProvider.prototype +} diff --git a/Source/WebCore/inspector/front-end/StyleSource.js b/Source/WebCore/inspector/front-end/StyleSource.js index 4d21f518a..9231a260d 100644 --- a/Source/WebCore/inspector/front-end/StyleSource.js +++ b/Source/WebCore/inspector/front-end/StyleSource.js @@ -29,65 +29,13 @@ /** * @constructor * @extends {WebInspector.UISourceCode} - * @param {WebInspector.Resource} resource + * @param {WebInspector.ContentProvider} contentProvider */ -WebInspector.StyleSource = function(resource) +WebInspector.StyleSource = function(contentProvider) { - WebInspector.UISourceCode.call(this, resource.url, resource, resource); + WebInspector.UISourceCode.call(this, contentProvider.contentURL(), contentProvider, true); } -WebInspector.StyleSource.updateTimeout = 200; - WebInspector.StyleSource.prototype = { - /** - * @return {boolean} - */ - isEditable: function() - { - return true; - }, - - /** - * @param {function(?string)} callback - */ - workingCopyCommitted: function(callback) - { - this._commitIncrementalEdit(true, callback); - }, - - workingCopyChanged: function() - { - this._callOrSetTimeout(this._commitIncrementalEdit.bind(this, false, function() {})); - }, - - /** - * @param {function(?string)} callback - */ - _callOrSetTimeout: function(callback) - { - // FIXME: Extensions tests override updateTimeout because extensions don't have any control over applying changes to domain specific bindings. - if (WebInspector.StyleSource.updateTimeout >= 0) - this._incrementalUpdateTimer = setTimeout(callback, WebInspector.StyleSource.updateTimeout); - else - callback(null); - }, - - /** - * @param {boolean} majorChange - * @param {function(?string)} callback - */ - _commitIncrementalEdit: function(majorChange, callback) - { - this._clearIncrementalUpdateTimer(); - WebInspector.cssModel.resourceBinding().setStyleContent(this, this.workingCopy(), majorChange, callback); - }, - - _clearIncrementalUpdateTimer: function() - { - if (this._incrementalUpdateTimer) - clearTimeout(this._incrementalUpdateTimer); - delete this._incrementalUpdateTimer; - } + __proto__: WebInspector.UISourceCode.prototype } - -WebInspector.StyleSource.prototype.__proto__ = WebInspector.UISourceCode.prototype; diff --git a/Source/WebCore/inspector/front-end/StylesSidebarPane.js b/Source/WebCore/inspector/front-end/StylesSidebarPane.js index e18c6359c..af07068fb 100644 --- a/Source/WebCore/inspector/front-end/StylesSidebarPane.js +++ b/Source/WebCore/inspector/front-end/StylesSidebarPane.js @@ -783,10 +783,10 @@ WebInspector.StylesSidebarPane.prototype = { { if (this._spectrum.visible) this._spectrum.hide(false); - } -} + }, -WebInspector.StylesSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -826,10 +826,10 @@ WebInspector.ComputedStyleSidebarPane.prototype = { } this._stylesSidebarPane._refreshUpdate(null, true, callback.bind(this)); - } -} + }, -WebInspector.ComputedStyleSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -1045,7 +1045,7 @@ WebInspector.StylePropertiesSection.prototype = { var isShorthand = !!WebInspector.CSSCompletions.cssPropertiesMetainfo.longhands(property.name); var inherited = this.isPropertyInherited(property.name); - var overloaded = this.isPropertyOverloaded(property.name); + var overloaded = property.inactive || this.isPropertyOverloaded(property.name); var item = new WebInspector.StylePropertyTreeElement(this, this._parentPane, this.styleRule, style, property, isShorthand, inherited, overloaded); this.propertiesTreeOutline.appendChild(item); } @@ -1079,7 +1079,7 @@ WebInspector.StylePropertiesSection.prototype = { // Generate synthetic shorthand we have a value for. var shorthandProperty = new WebInspector.CSSProperty(style, style.allProperties.length, shorthand, style.shorthandValue(shorthand), "", "style", true, true, undefined); - var overloaded = this.isPropertyOverloaded(property.name, true); + var overloaded = property.inactive || this.isPropertyOverloaded(property.name, true); var item = new WebInspector.StylePropertyTreeElement(this, this._parentPane, this.styleRule, style, shorthandProperty, /* isShorthand */ true, /* inherited */ false, overloaded); this.propertiesTreeOutline.appendChild(item); generatedShorthands[shorthand] = shorthandProperty; @@ -1089,7 +1089,7 @@ WebInspector.StylePropertiesSection.prototype = { continue; // Shorthand for the property found. var inherited = this.isPropertyInherited(property.name); - var overloaded = this.isPropertyOverloaded(property.name, isShorthand); + var overloaded = property.inactive || this.isPropertyOverloaded(property.name, isShorthand); var item = new WebInspector.StylePropertyTreeElement(this, this._parentPane, this.styleRule, style, property, isShorthand, inherited, overloaded); this.propertiesTreeOutline.appendChild(item); } @@ -1342,10 +1342,10 @@ WebInspector.StylePropertiesSection.prototype = { // Do nothing but mark the selectors in group if necessary. // This is overridden by BlankStylePropertiesSection. this._markSelectorMatches(); - } -} + }, -WebInspector.StylePropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype; + __proto__: WebInspector.PropertiesSection.prototype +} /** * @constructor @@ -1450,7 +1450,7 @@ WebInspector.ComputedStylePropertiesSection.prototype = { subtitle.appendChild(section._createRuleOriginNode()); var childElement = new TreeElement(fragment, null, false); treeElement.appendChild(childElement); - if (section.isPropertyOverloaded(property.name)) + if (property.inactive || section.isPropertyOverloaded(property.name)) childElement.listItemElement.addStyleClass("overloaded"); if (!property.parsedOk) childElement.listItemElement.addStyleClass("not-parsed-ok"); @@ -1463,10 +1463,10 @@ WebInspector.ComputedStylePropertiesSection.prototype = { if (name in this._propertyTreeElements) this._propertyTreeElements[name].expand(); } - } -} + }, -WebInspector.ComputedStylePropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype; + __proto__: WebInspector.PropertiesSection.prototype +} /** * @constructor @@ -1538,10 +1538,10 @@ WebInspector.BlankStylePropertiesSection.prototype = { // FIXME: replace this instance by a normal WebInspector.StylePropertiesSection. this._normal = true; - } -} + }, -WebInspector.BlankStylePropertiesSection.prototype.__proto__ = WebInspector.StylePropertiesSection.prototype; + __proto__: WebInspector.StylePropertiesSection.prototype +} /** * @constructor @@ -2505,10 +2505,10 @@ WebInspector.StylePropertyTreeElement.prototype = { if (!this.section.computedStyle) return event.target === this._expandElement; return TreeElement.prototype.isEventWithinDisclosureTriangle.call(this, event); - } -} + }, -WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototype; + __proto__: TreeElement.prototype +} /** * @constructor @@ -2583,15 +2583,22 @@ WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype = { return this._cssCompletions.keySet().hasOwnProperty(word); }, - _buildPropertyCompletions: function(textPrompt, wordRange, force, completionsReadyCallback) + /** + * @param {Element} proxyElement + * @param {Range} wordRange + * @param {boolean} force + * @param {function(Array.<string>, number=)} completionsReadyCallback + */ + _buildPropertyCompletions: function(proxyElement, wordRange, force, completionsReadyCallback) { var prefix = wordRange.toString().toLowerCase(); if (!prefix && !force) return; var results = this._cssCompletions.startsWith(prefix); - completionsReadyCallback(results); - } -} + var selectedIndex = this._cssCompletions.mostUsedOf(results); + completionsReadyCallback(results, selectedIndex); + }, -WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype.__proto__ = WebInspector.TextPrompt.prototype; + __proto__: WebInspector.TextPrompt.prototype +} diff --git a/Source/WebCore/inspector/front-end/StylesSourceMapping.js b/Source/WebCore/inspector/front-end/StylesSourceMapping.js index 0767e9ae0..ebae4eafe 100644 --- a/Source/WebCore/inspector/front-end/StylesSourceMapping.js +++ b/Source/WebCore/inspector/front-end/StylesSourceMapping.js @@ -70,7 +70,7 @@ WebInspector.StylesSourceMapping.prototype = { var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data; if (!uiSourceCode.url || this._uiSourceCodeForURL[uiSourceCode.url]) return; - if (uiSourceCode.contentType() !== WebInspector.resourceTypes.StyleSheet) + if (uiSourceCode.contentType() !== WebInspector.resourceTypes.Stylesheet) return; this._addUISourceCode(uiSourceCode); @@ -83,6 +83,8 @@ WebInspector.StylesSourceMapping.prototype = { { this._uiSourceCodeForURL[uiSourceCode.url] = uiSourceCode; uiSourceCode.setSourceMapping(this); + var styleFile = new WebInspector.StyleFile(uiSourceCode); + uiSourceCode.setStyleFile(styleFile); WebInspector.cssModel.setSourceMapping(uiSourceCode.url, this); }, @@ -93,3 +95,165 @@ WebInspector.StylesSourceMapping.prototype = { } } +/** + * @constructor + * @param {WebInspector.UISourceCode} uiSourceCode + */ +WebInspector.StyleFile = function(uiSourceCode) +{ + this._uiSourceCode = uiSourceCode; +} + +WebInspector.StyleFile.updateTimeout = 200; + +WebInspector.StyleFile.prototype = { + /** + * @param {function(?string)} callback + */ + workingCopyCommitted: function(callback) + { + this._commitIncrementalEdit(true, callback); + }, + + workingCopyChanged: function() + { + this._callOrSetTimeout(this._commitIncrementalEdit.bind(this, false, function() {})); + }, + + /** + * @param {function(?string)} callback + */ + _callOrSetTimeout: function(callback) + { + // FIXME: Extensions tests override updateTimeout because extensions don't have any control over applying changes to domain specific bindings. + if (WebInspector.StyleFile.updateTimeout >= 0) + this._incrementalUpdateTimer = setTimeout(callback, WebInspector.StyleFile.updateTimeout); + else + callback(null); + }, + + /** + * @param {boolean} majorChange + * @param {function(?string)} callback + */ + _commitIncrementalEdit: function(majorChange, callback) + { + this._clearIncrementalUpdateTimer(); + WebInspector.styleContentBinding.setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), majorChange, callback); + }, + + _clearIncrementalUpdateTimer: function() + { + if (this._incrementalUpdateTimer) + clearTimeout(this._incrementalUpdateTimer); + delete this._incrementalUpdateTimer; + }, +} + + +/** + * @constructor + * @param {WebInspector.CSSStyleModel} cssModel + */ +WebInspector.StyleContentBinding = function(cssModel) +{ + this._cssModel = cssModel; + this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._styleSheetChanged, this); +} + +WebInspector.StyleContentBinding.prototype = { + /** + * @param {WebInspector.UISourceCode} uiSourceCode + * @param {string} content + * @param {boolean} majorChange + * @param {function(?string)} userCallback + */ + setStyleContent: function(uiSourceCode, content, majorChange, userCallback) + { + var resource = WebInspector.resourceForURL(uiSourceCode.url); + this._cssModel.resourceBinding().requestStyleSheetIdForResource(resource, callback.bind(this)); + + /** + * @param {?CSSAgent.StyleSheetId} styleSheetId + */ + function callback(styleSheetId) + { + if (!styleSheetId) { + userCallback("No stylesheet found: " + resource.frameId + ":" + resource.url); + return; + } + + this._innerSetContent(styleSheetId, content, majorChange, userCallback, null); + } + }, + + /** + * @param {CSSAgent.StyleSheetId} styleSheetId + * @param {string} content + * @param {boolean} majorChange + * @param {function(?string)} userCallback + */ + _innerSetContent: function(styleSheetId, content, majorChange, userCallback) + { + this._isSettingContent = true; + function callback(error) + { + userCallback(error); + delete this._isSettingContent; + } + this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, callback.bind(this)); + }, + + /** + * @param {WebInspector.Event} event + */ + _styleSheetChanged: function(event) + { + if (this._isSettingContent) + return; + + if (!event.data.majorChange) + return; + + /** + * @param {?string} error + * @param {string} content + */ + function callback(error, content) + { + if (!error) + this._innerStyleSheetChanged(event.data.styleSheetId, content); + } + CSSAgent.getStyleSheetText(event.data.styleSheetId, callback.bind(this)); + }, + + /** + * @param {CSSAgent.StyleSheetId} styleSheetId + * @param {string} content + */ + _innerStyleSheetChanged: function(styleSheetId, content) + { + /** + * @param {?string} styleSheetURL + */ + function callback(styleSheetURL) + { + if (typeof styleSheetURL !== "string") + return; + + var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(styleSheetURL); + if (!uiSourceCode) + return; + + if (uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesheet) + uiSourceCode.addRevision(content); + } + + this._cssModel.resourceBinding().requestResourceURLForStyleSheetId(styleSheetId, callback.bind(this)); + }, +} + +/** + * @type {?WebInspector.StyleContentBinding} + */ +WebInspector.styleContentBinding = null; diff --git a/Source/WebCore/inspector/front-end/TabbedEditorContainer.js b/Source/WebCore/inspector/front-end/TabbedEditorContainer.js index ad0576813..d4a4e9e0a 100644 --- a/Source/WebCore/inspector/front-end/TabbedEditorContainer.js +++ b/Source/WebCore/inspector/front-end/TabbedEditorContainer.js @@ -212,9 +212,17 @@ WebInspector.TabbedEditorContainer.prototype = { */ removeUISourceCode: function(uiSourceCode) { + var wasCurrent = this._currentFile === uiSourceCode; + var tabId = this._tabIds.get(uiSourceCode); if (tabId) this._tabbedPane.closeTab(tabId); + + if (wasCurrent && uiSourceCode.isTemporary) { + var newUISourceCode = WebInspector.workspace.uiSourceCodeForURL(uiSourceCode.url); + if (newUISourceCode) + this._innerShowFile(newUISourceCode, false); + } }, /** @@ -319,37 +327,14 @@ WebInspector.TabbedEditorContainer.prototype = { }, /** - * @param {WebInspector.UISourceCode} oldUISourceCode - * @param {WebInspector.UISourceCode} uiSourceCode - */ - replaceFile: function(oldUISourceCode, uiSourceCode) - { - var tabId = this._tabIds.get(oldUISourceCode); - - if (!tabId) - return; - - delete this._files[this._tabIds.get(oldUISourceCode)] - this._tabIds.remove(oldUISourceCode); - this._tabIds.put(uiSourceCode, tabId); - this._files[tabId] = uiSourceCode; - - this._tabbedPane.changeTabTitle(tabId, this._titleForFile(uiSourceCode)); - this._tabbedPane.changeTabView(tabId, this._delegate.viewForFile(uiSourceCode)); - this._tabbedPane.changeTabTooltip(tabId, this._tooltipForFile(uiSourceCode)); - - this._removeUISourceCodeListeners(oldUISourceCode); - this._addUISourceCodeListeners(uiSourceCode); - }, - - /** * @param {WebInspector.UISourceCode} uiSourceCode */ _addUISourceCodeListeners: function(uiSourceCode) { uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this); uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this); - uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this); + uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this); + uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this); }, /** @@ -359,7 +344,8 @@ WebInspector.TabbedEditorContainer.prototype = { { uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this); uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this); - uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this); + uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this); + uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this); }, /** @@ -386,7 +372,13 @@ WebInspector.TabbedEditorContainer.prototype = { this._updateFileTitle(uiSourceCode); }, - _uiSourceCodeContentChanged: function(event) + _uiSourceCodeWorkingCopyCommitted: function(event) + { + var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target; + this._updateFileTitle(uiSourceCode); + }, + + _uiSourceCodeFormattedChanged: function(event) { var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target; this._updateFileTitle(uiSourceCode); @@ -416,10 +408,10 @@ WebInspector.TabbedEditorContainer.prototype = { currentFile: function() { return this._currentFile; - } -} + }, -WebInspector.TabbedEditorContainer.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -455,10 +447,10 @@ WebInspector.TabbedEditorContainer.HistoryItem.prototype = { serializedHistoryItem.selectionRange = this.selectionRange; serializedHistoryItem.scrollLineNumber = this.scrollLineNumber; return serializedHistoryItem; - } -} + }, -WebInspector.TabbedEditorContainer.HistoryItem.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -585,7 +577,7 @@ WebInspector.TabbedEditorContainer.History.prototype = { for (var i = 0; i < this._items.length; ++i) serializedHistory.push(this._items[i].serializeToObject()); return serializedHistory; - } -} + }, -WebInspector.TabbedEditorContainer.History.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/TabbedPane.js b/Source/WebCore/inspector/front-end/TabbedPane.js index 3e8e8ab19..19b787fa9 100644 --- a/Source/WebCore/inspector/front-end/TabbedPane.js +++ b/Source/WebCore/inspector/front-end/TabbedPane.js @@ -532,10 +532,10 @@ WebInspector.TabbedPane.prototype = { if (oldIndex < index) --index; this._tabs.splice(index, 0, tab); - } -} + }, -WebInspector.TabbedPane.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** diff --git a/Source/WebCore/inspector/front-end/TextEditorModel.js b/Source/WebCore/inspector/front-end/TextEditorModel.js index 068cf997b..6a8b2dead 100644 --- a/Source/WebCore/inspector/front-end/TextEditorModel.js +++ b/Source/WebCore/inspector/front-end/TextEditorModel.js @@ -528,7 +528,7 @@ WebInspector.TextEditorModel.prototype = { resetUndoStack: function() { this._undoStack = []; - } -} + }, -WebInspector.TextEditorModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/TextPrompt.js b/Source/WebCore/inspector/front-end/TextPrompt.js index c40df4f0c..6ca3ca58f 100644 --- a/Source/WebCore/inspector/front-end/TextPrompt.js +++ b/Source/WebCore/inspector/front-end/TextPrompt.js @@ -30,8 +30,8 @@ /** * @constructor * @extends WebInspector.Object - * @param {function(WebInspector.TextPrompt, Range, boolean, function(Array.<string>=))} completions - * @param {string} stopCharacters + * @param {function(Element, Range, boolean, function(Array.<string>, number=))} completions + * @param {string=} stopCharacters */ WebInspector.TextPrompt = function(completions, stopCharacters) { @@ -41,7 +41,7 @@ WebInspector.TextPrompt = function(completions, stopCharacters) this._proxyElement; this._proxyElementDisplay = "inline-block"; this._loadCompletions = completions; - this._completionStopCharacters = stopCharacters; + this._completionStopCharacters = stopCharacters || " =:[({;,!+-*/&|^<>."; this._suggestForceable = true; } @@ -391,7 +391,7 @@ WebInspector.TextPrompt.prototype = { var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, this._completionStopCharacters, this._element, "backward"); this._waitingForCompletions = true; - this._loadCompletions(this, wordPrefixRange, force, this._completionsReady.bind(this, selection, auto, wordPrefixRange, !!reverse)); + this._loadCompletions(this.proxyElement, wordPrefixRange, force, this._completionsReady.bind(this, selection, auto, wordPrefixRange, !!reverse)); }, _boxForAnchorAtStart: function(selection, textRange) @@ -433,8 +433,9 @@ WebInspector.TextPrompt.prototype = { * @param {Range} originalWordPrefixRange * @param {boolean} reverse * @param {Array.<string>=} completions + * @param {number=} selectedIndex */ - _completionsReady: function(selection, auto, originalWordPrefixRange, reverse, completions) + _completionsReady: function(selection, auto, originalWordPrefixRange, reverse, completions, selectedIndex) { if (!this._waitingForCompletions || !completions || !completions.length) { this.hideSuggestBox(); @@ -451,29 +452,31 @@ WebInspector.TextPrompt.prototype = { if (originalWordPrefixRange.toString() + selectionRange.toString() != fullWordRange.toString()) return; + selectedIndex = selectedIndex || 0; + this._userEnteredRange = fullWordRange; this._userEnteredText = fullWordRange.toString(); if (this._suggestBox) - this._suggestBox.updateSuggestions(this._boxForAnchorAtStart(selection, fullWordRange), completions, !this.isCaretAtEndOfPrompt()); + this._suggestBox.updateSuggestions(this._boxForAnchorAtStart(selection, fullWordRange), completions, selectedIndex, !this.isCaretAtEndOfPrompt()); var wordPrefixLength = originalWordPrefixRange.toString().length; if (auto) { - var completionText = completions[0]; + var completionText = completions[selectedIndex]; var commonPrefix = this._buildCommonPrefix(completions, wordPrefixLength); this._commonPrefix = commonPrefix; } else { if (completions.length === 1) { - var completionText = completions[0]; + var completionText = completions[selectedIndex]; wordPrefixLength = completionText.length; } else { var commonPrefix = this._buildCommonPrefix(completions, wordPrefixLength); wordPrefixLength = commonPrefix.length; if (selection.isCollapsed) - var completionText = completions[0]; + var completionText = completions[selectedIndex]; else { var currentText = fullWordRange.toString(); @@ -485,7 +488,7 @@ WebInspector.TextPrompt.prototype = { var nextIndex = foundIndex + (reverse ? -1 : 1); if (foundIndex === null || nextIndex >= completions.length) - var completionText = completions[0]; + var completionText = completions[selectedIndex]; else if (nextIndex < 0) var completionText = completions[completions.length - 1]; else @@ -750,15 +753,16 @@ WebInspector.TextPrompt.prototype = { return false; }, + + __proto__: WebInspector.Object.prototype } -WebInspector.TextPrompt.prototype.__proto__ = WebInspector.Object.prototype; /** * @constructor * @extends {WebInspector.TextPrompt} - * @param {function(WebInspector.TextPrompt, Range, boolean, function(Array.<string>=))} completions - * @param {string} stopCharacters + * @param {function(Element, Range, boolean, function(Array.<string>,number=))} completions + * @param {string=} stopCharacters */ WebInspector.TextPromptWithHistory = function(completions, stopCharacters) { @@ -917,10 +921,10 @@ WebInspector.TextPromptWithHistory.prototype = { } return WebInspector.TextPrompt.prototype.defaultKeyHandler.apply(this, arguments); - } -} + }, -WebInspector.TextPromptWithHistory.prototype.__proto__ = WebInspector.TextPrompt.prototype; + __proto__: WebInspector.TextPrompt.prototype +} /** * @constructor @@ -929,6 +933,8 @@ WebInspector.TextPrompt.SuggestBox = function(textPrompt, inputElement, classNam { this._textPrompt = textPrompt; this._inputElement = inputElement; + this._length = 0; + this._selectedIndex = -1; this._selectedElement = null; this._boundOnScroll = this._onscrollresize.bind(this, true); this._boundOnResize = this._onscrollresize.bind(this, false); @@ -1072,60 +1078,24 @@ WebInspector.TextPrompt.SuggestBox.prototype = { return true; }, - _onNextItem: function(event, isPageScroll) + /** + * @param {number} shift + * @param {boolean=} isCircular + * @return {boolean} is changed + */ + _selectClosest: function(shift, isCircular) { - var children = this.contentElement.childNodes; - if (!children.length) + if (!this._length) return false; - if (!this._selectedElement) - this._selectedElement = this.contentElement.firstChild; - else { - if (!isPageScroll) - this._selectedElement = this._selectedElement.nextSibling || this.contentElement.firstChild; - else { - var candidate = this._selectedElement; - - for (var itemsLeft = this._rowCountPerViewport; itemsLeft; --itemsLeft) { - if (candidate.nextSibling) - candidate = candidate.nextSibling; - else - break; - } - - this._selectedElement = candidate; - } - } - this._updateSelection(); - this._applySuggestion(undefined, true); - return true; - }, + var index = this._selectedIndex + shift; - _onPreviousItem: function(event, isPageScroll) - { - var children = this.contentElement.childNodes; - if (!children.length) - return false; - - if (!this._selectedElement) - this._selectedElement = this.contentElement.lastChild; - else { - if (!isPageScroll) - this._selectedElement = this._selectedElement.previousSibling || this.contentElement.lastChild; - else { - var candidate = this._selectedElement; - - for (var itemsLeft = this._rowCountPerViewport; itemsLeft; --itemsLeft) { - if (candidate.previousSibling) - candidate = candidate.previousSibling; - else - break; - } + if (isCircular) + index = (this._length + index) % this._length; + else + index = Number.constrain(index, 0, this._length - 1); - this._selectedElement = candidate; - } - } - this._updateSelection(); + this._selectItem(index); this._applySuggestion(undefined, true); return true; }, @@ -1133,15 +1103,16 @@ WebInspector.TextPrompt.SuggestBox.prototype = { /** * @param {AnchorBox} anchorBox * @param {Array.<string>=} completions + * @param {number=} selectedIndex * @param {boolean=} canShowForSingleItem */ - updateSuggestions: function(anchorBox, completions, canShowForSingleItem) + updateSuggestions: function(anchorBox, completions, selectedIndex, canShowForSingleItem) { if (this._suggestTimeout) { clearTimeout(this._suggestTimeout); delete this._suggestTimeout; } - this._completionsReady(anchorBox, completions, canShowForSingleItem); + this._completionsReady(anchorBox, completions, selectedIndex, canShowForSingleItem); }, _onItemMouseDown: function(text, event) @@ -1169,10 +1140,12 @@ WebInspector.TextPrompt.SuggestBox.prototype = { }, /** - * @param {boolean=} canShowForSingleItem + * @param {Array.<string>=} items + * @param {number=} selectedIndex */ - _updateItems: function(items, canShowForSingleItem) + _updateItems: function(items, selectedIndex) { + this._length = items.length; this.contentElement.removeChildren(); var userEnteredText = this._textPrompt._userEnteredText; @@ -1182,21 +1155,24 @@ WebInspector.TextPrompt.SuggestBox.prototype = { this.contentElement.appendChild(currentItemElement); } - this._selectedElement = canShowForSingleItem ? this.contentElement.firstChild : null; - this._updateSelection(); + this._selectedElement = null; + if (typeof selectedIndex === "number") + this._selectItem(selectedIndex); }, - _updateSelection: function() + /** + * @param {number} index + */ + _selectItem: function(index) { - // FIXME: might want some optimization if becomes a bottleneck. - for (var child = this.contentElement.firstChild; child; child = child.nextSibling) { - if (child !== this._selectedElement) - child.removeStyleClass("selected"); - } - if (this._selectedElement) { - this._selectedElement.addStyleClass("selected"); - this._selectedElement.scrollIntoViewIfNeeded(false); - } + if (this._selectedElement) + this._selectedElement.classList.remove("selected"); + + this._selectedIndex = index; + this._selectedElement = this.contentElement.children[index]; + this._selectedElement.classList.add("selected"); + + this._selectedElement.scrollIntoViewIfNeeded(false); }, /** @@ -1226,12 +1202,13 @@ WebInspector.TextPrompt.SuggestBox.prototype = { /** * @param {AnchorBox} anchorBox * @param {Array.<string>=} completions + * @param {number=} selectedIndex * @param {boolean=} canShowForSingleItem */ - _completionsReady: function(anchorBox, completions, canShowForSingleItem) + _completionsReady: function(anchorBox, completions, selectedIndex, canShowForSingleItem) { if (this._canShowBox(completions, canShowForSingleItem)) { - this._updateItems(completions, canShowForSingleItem); + this._updateItems(completions, selectedIndex); this._updateBoxPosition(anchorBox); if (!this.visible) this._bodyElement.appendChild(this._element); @@ -1242,22 +1219,22 @@ WebInspector.TextPrompt.SuggestBox.prototype = { upKeyPressed: function(event) { - return this._onPreviousItem(event, false); + return this._selectClosest(-1, true); }, downKeyPressed: function(event) { - return this._onNextItem(event, false); + return this._selectClosest(1, true); }, pageUpKeyPressed: function(event) { - return this._onPreviousItem(event, true); + return this._selectClosest(-this._rowCountPerViewport, false); }, pageDownKeyPressed: function(event) { - return this._onNextItem(event, true); + return this._selectClosest(this._rowCountPerViewport, false); }, enterKeyPressed: function(event) diff --git a/Source/WebCore/inspector/front-end/TimelineManager.js b/Source/WebCore/inspector/front-end/TimelineManager.js index 4e7e5d26d..afadc059f 100644 --- a/Source/WebCore/inspector/front-end/TimelineManager.js +++ b/Source/WebCore/inspector/front-end/TimelineManager.js @@ -75,10 +75,10 @@ WebInspector.TimelineManager.prototype = { _stopped: function() { this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStopped); - } -} + }, -WebInspector.TimelineManager.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/TimelineModel.js b/Source/WebCore/inspector/front-end/TimelineModel.js index deecb6e7d..5d9d4c96c 100644 --- a/Source/WebCore/inspector/front-end/TimelineModel.js +++ b/Source/WebCore/inspector/front-end/TimelineModel.js @@ -247,10 +247,10 @@ WebInspector.TimelineModel.prototype = { recordOffsetInSeconds: function(rawRecord) { return WebInspector.TimelineModel.startTimeInSeconds(rawRecord) - this._minimumRecordTime; - } -} + }, -WebInspector.TimelineModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -330,11 +330,14 @@ WebInspector.TimelineModelLoadFromFileDelegate = function(model, progress) } WebInspector.TimelineModelLoadFromFileDelegate.prototype = { - onTransferStarted: function(reader) + onTransferStarted: function() { this._progress.setTitle(WebInspector.UIString("Loading\u2026")); }, + /** + * @param {WebInspector.ChunkedReader} reader + */ onChunkTransferred: function(reader) { if (this._progress.isCanceled()) { @@ -351,11 +354,14 @@ WebInspector.TimelineModelLoadFromFileDelegate.prototype = { } }, - onTransferFinished: function(reader) + onTransferFinished: function() { this._progress.done(); }, + /** + * @param {WebInspector.ChunkedReader} reader + */ onError: function(reader, event) { this._progress.done(); diff --git a/Source/WebCore/inspector/front-end/TimelineOverviewPane.js b/Source/WebCore/inspector/front-end/TimelineOverviewPane.js index ecdfa820f..5c8ddc77c 100644 --- a/Source/WebCore/inspector/front-end/TimelineOverviewPane.js +++ b/Source/WebCore/inspector/front-end/TimelineOverviewPane.js @@ -347,10 +347,10 @@ WebInspector.TimelineOverviewPane.prototype = { if (!this.isShowing()) return; this._refreshTimeout = setTimeout(this._update.bind(this), 300); - } -} + }, -WebInspector.TimelineOverviewPane.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @constructor @@ -625,10 +625,10 @@ WebInspector.TimelineOverviewWindow.prototype = { left = Math.max(0, Math.min(max - delta, referencePoint + (left - referencePoint) * factor)); right = Math.min(max, left + delta); this._setWindowPosition(left, right); - } -} + }, -WebInspector.TimelineOverviewWindow.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -1219,10 +1219,10 @@ WebInspector.TimelineFrameOverview.prototype = { startTime: firstBar >= this._barTimes.length ? Infinity : this._barTimes[firstBar].startTime, endTime: rightOffset + snapToRightTolerancePixels > windowSpan ? Infinity : this._barTimes[lastBar].endTime } - } -} + }, -WebInspector.TimelineFrameOverview.prototype.__proto__ = WebInspector.View.prototype; + __proto__: WebInspector.View.prototype +} /** * @param {WebInspector.TimelineOverviewPane} pane diff --git a/Source/WebCore/inspector/front-end/TimelinePanel.js b/Source/WebCore/inspector/front-end/TimelinePanel.js index 4ccb7a42c..50f4b6ada 100644 --- a/Source/WebCore/inspector/front-end/TimelinePanel.js +++ b/Source/WebCore/inspector/front-end/TimelinePanel.js @@ -1153,10 +1153,10 @@ WebInspector.TimelinePanel.prototype = { this._searchRegExp = createPlainTextSearchRegex(searchQuery, "i"); delete this._searchResults; this._updateSearchHighlight(true); - } -} + }, -WebInspector.TimelinePanel.prototype.__proto__ = WebInspector.Panel.prototype; + __proto__: WebInspector.Panel.prototype +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/TimelinePresentationModel.js b/Source/WebCore/inspector/front-end/TimelinePresentationModel.js index 8065f5fa0..baa1a1c8d 100644 --- a/Source/WebCore/inspector/front-end/TimelinePresentationModel.js +++ b/Source/WebCore/inspector/front-end/TimelinePresentationModel.js @@ -439,10 +439,10 @@ WebInspector.TimelinePresentationModel.prototype = { return false; } return true; - } -} + }, -WebInspector.TimelinePresentationModel.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -1166,7 +1166,7 @@ WebInspector.TimelineCategory.prototype = { { this._hidden = hidden; this.dispatchEventToListeners(WebInspector.TimelineCategory.Events.VisibilityChanged, this); - } -} + }, -WebInspector.TimelineCategory.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} diff --git a/Source/WebCore/inspector/front-end/Toolbar.js b/Source/WebCore/inspector/front-end/Toolbar.js index 9b8995c38..5756e73d7 100644 --- a/Source/WebCore/inspector/front-end/Toolbar.js +++ b/Source/WebCore/inspector/front-end/Toolbar.js @@ -35,7 +35,7 @@ WebInspector.Toolbar = function() { this.element = document.getElementById("toolbar"); - WebInspector.installDragHandle(this.element, this._toolbarDragStart.bind(this), this._toolbarDrag.bind(this), this._toolbarDragEnd.bind(this), (WebInspector.isCompactMode() ? "row-resize" : "default")); + WebInspector.installDragHandle(this.element, this._toolbarDragStart.bind(this), this._toolbarDrag.bind(this), this._toolbarDragEnd.bind(this), "default"); this._dropdownButton = document.getElementById("toolbar-dropdown-arrow"); this._dropdownButton.addEventListener("click", this._toggleDropdown.bind(this), false); @@ -97,11 +97,19 @@ WebInspector.Toolbar.prototype = { }, /** + * @param {boolean} isCompactMode + */ + setCompactMode: function(isCompactMode) + { + this._isCompactMode = isCompactMode; + }, + + /** * @return {boolean} */ _toolbarDragStart: function(event) { - if ((!WebInspector.isCompactMode() && WebInspector.platformFlavor() !== WebInspector.PlatformFlavor.MacLeopard && WebInspector.platformFlavor() !== WebInspector.PlatformFlavor.MacSnowLeopard) || WebInspector.port() == "qt") + if ((!this._isCompactMode && WebInspector.platformFlavor() !== WebInspector.PlatformFlavor.MacLeopard && WebInspector.platformFlavor() !== WebInspector.PlatformFlavor.MacSnowLeopard) || WebInspector.port() == "qt") return false; var target = event.target; @@ -124,7 +132,7 @@ WebInspector.Toolbar.prototype = { _toolbarDrag: function(event) { - if (WebInspector.isCompactMode()) { + if (this._isCompactMode) { var height = window.innerHeight - (event.screenY - this.element.lastScreenY); InspectorFrontendHost.setAttachedWindowHeight(height); diff --git a/Source/WebCore/inspector/front-end/TopDownProfileDataGridTree.js b/Source/WebCore/inspector/front-end/TopDownProfileDataGridTree.js index cbec51a60..7dbadab2c 100644 --- a/Source/WebCore/inspector/front-end/TopDownProfileDataGridTree.js +++ b/Source/WebCore/inspector/front-end/TopDownProfileDataGridTree.js @@ -65,10 +65,10 @@ WebInspector.TopDownProfileDataGridNode.prototype = { if (child) this._merge(child, true); - } -} + }, -WebInspector.TopDownProfileDataGridNode.prototype.__proto__ = WebInspector.ProfileDataGridNode.prototype; + __proto__: WebInspector.ProfileDataGridNode.prototype +} /** * @constructor @@ -127,7 +127,7 @@ WebInspector.TopDownProfileDataGridTree.prototype = { _merge: WebInspector.TopDownProfileDataGridNode.prototype._merge, - _sharedPopulate: WebInspector.TopDownProfileDataGridNode.prototype._sharedPopulate -} + _sharedPopulate: WebInspector.TopDownProfileDataGridNode.prototype._sharedPopulate, -WebInspector.TopDownProfileDataGridTree.prototype.__proto__ = WebInspector.ProfileDataGridTree.prototype; + __proto__: WebInspector.ProfileDataGridTree.prototype +} diff --git a/Source/WebCore/inspector/front-end/UISourceCode.js b/Source/WebCore/inspector/front-end/UISourceCode.js index 47c8c3425..2bb0e1bd2 100644 --- a/Source/WebCore/inspector/front-end/UISourceCode.js +++ b/Source/WebCore/inspector/front-end/UISourceCode.js @@ -34,15 +34,15 @@ * @extends {WebInspector.Object} * @implements {WebInspector.ContentProvider} * @param {string} url - * @param {WebInspector.Resource} resource * @param {WebInspector.ContentProvider} contentProvider + * @param {boolean} isEditable */ -WebInspector.UISourceCode = function(url, resource, contentProvider) +WebInspector.UISourceCode = function(url, contentProvider, isEditable) { this._url = url; - this._resource = resource; this._parsedURL = new WebInspector.ParsedURL(url); this._contentProvider = contentProvider; + this._isEditable = isEditable; this.isContentScript = false; /** * @type Array.<function(?string,boolean,string)> @@ -61,13 +61,15 @@ WebInspector.UISourceCode = function(url, resource, contentProvider) * @type {Array.<WebInspector.Revision>} */ this.history = []; - this._restoreRevisionHistory(); + if (this.isEditable()) + this._restoreRevisionHistory(); this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping(); } WebInspector.UISourceCode.Events = { - ContentChanged: "ContentChanged", + FormattedChanged: "FormattedChanged", WorkingCopyChanged: "WorkingCopyChanged", + WorkingCopyCommitted: "WorkingCopyCommitted", TitleChanged: "TitleChanged", ConsoleMessageAdded: "ConsoleMessageAdded", ConsoleMessageRemoved: "ConsoleMessageRemoved", @@ -94,14 +96,6 @@ WebInspector.UISourceCode.prototype = { }, /** - * @return {WebInspector.Resource} - */ - resource: function() - { - return this._resource; - }, - - /** * @return {WebInspector.ParsedURL} */ get parsedURL() @@ -110,7 +104,7 @@ WebInspector.UISourceCode.prototype = { }, /** - * @return {?string} + * @return {string} */ contentURL: function() { @@ -126,6 +120,38 @@ WebInspector.UISourceCode.prototype = { }, /** + * @return {WebInspector.ScriptFile} + */ + scriptFile: function() + { + return this._scriptFile; + }, + + /** + * @param {WebInspector.ScriptFile} scriptFile + */ + setScriptFile: function(scriptFile) + { + this._scriptFile = scriptFile; + }, + + /** + * @return {WebInspector.StyleFile} + */ + styleFile: function() + { + return this._styleFile; + }, + + /** + * @param {WebInspector.StyleFile} styleFile + */ + setStyleFile: function(styleFile) + { + this._styleFile = styleFile; + }, + + /** * @param {function(?string,boolean,string)} callback */ requestContent: function(callback) @@ -148,33 +174,32 @@ WebInspector.UISourceCode.prototype = { }, /** - * @param {string} newContent + * @param {string} content */ - _setContent: function(newContent) + _commitContent: function(content) { - this.setWorkingCopy(newContent); - this.commitWorkingCopy(function() {}); + this._content = content; + this._contentLoaded = true; + + var lastRevision = this.history.length ? this.history[this.history.length - 1] : null; + if (!lastRevision || lastRevision._content !== this._content) { + var revision = new WebInspector.Revision(this, this._content, new Date()); + this.history.push(revision); + revision._persist(); + } + + var oldWorkingCopy = this._workingCopy; + delete this._workingCopy; + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyCommitted, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()}); + WebInspector.workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: this, content: this._content }); }, /** * @param {string} content - * @param {Date=} timestamp - * @param {boolean=} restoringHistory */ - addRevision: function(content, timestamp, restoringHistory) + addRevision: function(content) { - if (this.history.length) { - var lastRevision = this.history[this.history.length - 1]; - if (lastRevision._content === content) - return; - } - var revision = new WebInspector.Revision(this, content, timestamp || new Date()); - this.history.push(revision); - - this.contentChanged(revision.content || "", this.canonicalMimeType()); - if (!restoringHistory) - revision._persist(); - WebInspector.workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: this, content: content }); + this._commitContent(content); }, _restoreRevisionHistory: function() @@ -184,8 +209,17 @@ WebInspector.UISourceCode.prototype = { var registry = WebInspector.Revision._revisionHistoryRegistry(); var historyItems = registry[this.url]; - for (var i = 0; historyItems && i < historyItems.length; ++i) - this.addRevision(window.localStorage[historyItems[i].key], new Date(historyItems[i].timestamp), true); + if (!historyItems || !historyItems.length) + return; + for (var i = 0; i < historyItems.length; ++i) { + var content = window.localStorage[historyItems[i].key]; + var timestamp = new Date(historyItems[i].timestamp); + var revision = new WebInspector.Revision(this, content, timestamp); + this.history.push(revision); + } + this._content = this.history[this.history.length - 1].content; + this._contentLoaded = true; + this._mimeType = this.canonicalMimeType(); }, _clearRevisionHistory: function() @@ -204,50 +238,53 @@ WebInspector.UISourceCode.prototype = { revertToOriginal: function() { /** + * @this {WebInspector.UISourceCode} * @param {?string} content * @param {boolean} contentEncoded * @param {string} mimeType */ - function callback(content, contentEncoded, mimeType) + function callback(content, contentEncoded, mimeType) { - this._setContent(); + if (typeof content !== "string") + return; + + this.addRevision(content); } this.requestOriginalContent(callback.bind(this)); }, + /** + * @param {function(WebInspector.UISourceCode)} callback + */ revertAndClearHistory: function(callback) { - function revert(content) + /** + * @this {WebInspector.UISourceCode} + * @param {?string} content + * @param {boolean} contentEncoded + * @param {string} mimeType + */ + function revert(content, contentEncoded, mimeType) { - this._setContent(content); + if (typeof content !== "string") + return; + + this.addRevision(content); this._clearRevisionHistory(); this.history = []; - callback(); + callback(this); } this.requestOriginalContent(revert.bind(this)); }, /** - * @param {string} newContent - * @param {string} mimeType - */ - contentChanged: function(newContent, mimeType) - { - this._content = newContent; - this._mimeType = mimeType; - this._contentLoaded = true; - delete this._workingCopy; - this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {content: newContent}); - }, - - /** * @return {boolean} */ isEditable: function() { - return false; + return this._isEditable; }, /** @@ -265,18 +302,17 @@ WebInspector.UISourceCode.prototype = { */ setWorkingCopy: function(newWorkingCopy) { + this._mimeType = this.canonicalMimeType(); var oldWorkingCopy = this._workingCopy; if (this._content === newWorkingCopy) delete this._workingCopy; else this._workingCopy = newWorkingCopy; - this.workingCopyChanged(); - this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy}); - }, - - workingCopyChanged: function() - { - // Overridden. + if (this.scriptFile()) + this.scriptFile().workingCopyChanged(); + else if (this.styleFile()) + this.styleFile().workingCopyChanged(); + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()}); }, /** @@ -289,17 +325,11 @@ WebInspector.UISourceCode.prototype = { return; } - var newContent = this._workingCopy; - this.workingCopyCommitted(callback); - this.addRevision(newContent); - }, - - /** - * @param {function(?string)} callback - */ - workingCopyCommitted: function(callback) - { - // Overridden. + if (this.scriptFile()) + this.scriptFile().workingCopyCommitted(callback); + else if (this.styleFile()) + this.styleFile().workingCopyCommitted(callback); + this._commitContent(this._workingCopy); }, /** @@ -342,7 +372,9 @@ WebInspector.UISourceCode.prototype = { */ searchInContent: function(query, caseSensitive, isRegex, callback) { - this._contentProvider.searchInContent(query, caseSensitive, isRegex, callback); + var content = this.content(); + var provider = content ? new WebInspector.StaticContentProvider(this._contentProvider.contentType(), content) : this._contentProvider; + provider.searchInContent(query, caseSensitive, isRegex, callback); }, /** @@ -362,8 +394,16 @@ WebInspector.UISourceCode.prototype = { callbacks[i](content, contentEncoded, mimeType); if (this._formatOnLoad) { + function formattedCallback() + { + for (var i = 0; i < this._pendingFormattedCallbacks.length; ++i) + this._pendingFormattedCallbacks[i](); + delete this._pendingFormattedCallbacks; + + } + delete this._formatOnLoad; - this.setFormatted(true); + this.setFormatted(true, formattedCallback.bind(this)); } }, @@ -467,7 +507,7 @@ WebInspector.UISourceCode.prototype = { */ formatted: function() { - return this._formatted; + return !!this._formatted; }, /** @@ -478,8 +518,10 @@ WebInspector.UISourceCode.prototype = { { callback = callback || function() {}; if (!this.contentLoaded()) { + if (!this._pendingFormattedCallbacks) + this._pendingFormattedCallbacks = []; + this._pendingFormattedCallbacks.push(callback); this._formatOnLoad = formatted; - callback(); return; } @@ -518,11 +560,12 @@ WebInspector.UISourceCode.prototype = { function formattedChanged(content, formatterMapping) { this._togglingFormatter = true; - this.contentChanged(content, mimeType); + this._content = content; + delete this._workingCopy; + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.FormattedChanged, {content: content}); delete this._togglingFormatter; this._formatterMapping = formatterMapping; this.updateLiveLocations(); - this.formattedChanged(); callback(); } } @@ -545,13 +588,9 @@ WebInspector.UISourceCode.prototype = { this._sourceMapping = sourceMapping; }, - formattedChanged: function() - { - } + __proto__: WebInspector.Object.prototype } -WebInspector.UISourceCode.prototype.__proto__ = WebInspector.Object.prototype; - /** * @interface */ @@ -561,7 +600,8 @@ WebInspector.UISourceCodeProvider = function() WebInspector.UISourceCodeProvider.Events = { UISourceCodeAdded: "UISourceCodeAdded", - UISourceCodeReplaced: "UISourceCodeReplaced", + TemporaryUISourceCodeAdded: "TemporaryUISourceCodeAdded", + TemporaryUISourceCodeRemoved: "TemporaryUISourceCodeRemoved", UISourceCodeRemoved: "UISourceCodeRemoved" } @@ -766,13 +806,13 @@ WebInspector.Revision.prototype = { function revert(content) { if (this._uiSourceCode._content !== content) - this._uiSourceCode._setContent(content); + this._uiSourceCode.addRevision(content); } this.requestContent(revert.bind(this)); }, /** - * @return {?string} + * @return {string} */ contentURL: function() { diff --git a/Source/WebCore/inspector/front-end/UISourceCodeFrame.js b/Source/WebCore/inspector/front-end/UISourceCodeFrame.js index e93b4f8a7..7e0bf51cd 100644 --- a/Source/WebCore/inspector/front-end/UISourceCodeFrame.js +++ b/Source/WebCore/inspector/front-end/UISourceCodeFrame.js @@ -35,7 +35,9 @@ WebInspector.UISourceCodeFrame = function(uiSourceCode) { this._uiSourceCode = uiSourceCode; WebInspector.SourceFrame.call(this, this._uiSourceCode); - this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this); + this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._onFormattedChanged, this); + this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyChanged, this); + this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this); } WebInspector.UISourceCodeFrame.prototype = { @@ -62,7 +64,9 @@ WebInspector.UISourceCodeFrame.prototype = { onTextChanged: function(oldRange, newRange) { + this._isSettingWorkingCopy = true; this._uiSourceCode.setWorkingCopy(this._textEditor.text()); + delete this._isSettingWorkingCopy; }, _didEditContent: function(error) @@ -76,10 +80,34 @@ WebInspector.UISourceCodeFrame.prototype = { /** * @param {WebInspector.Event} event */ - _onContentChanged: function(event) + _onFormattedChanged: function(event) { - if (!this._isCommittingEditing) - this.setContent(this._uiSourceCode.content() || "", false, this._uiSourceCode.contentType().canonicalMimeType()); + var content = /** @type {string} */ event.data.content; + this._innerSetContent(content); + }, + + /** + * @param {WebInspector.Event} event + */ + _onWorkingCopyChanged: function(event) + { + this._innerSetContent(this._uiSourceCode.workingCopy()); + }, + + /** + * @param {WebInspector.Event} event + */ + _onWorkingCopyCommitted: function(event) + { + this._innerSetContent(this._uiSourceCode.workingCopy()); + }, + + _innerSetContent: function(content) + { + if (this._isSettingWorkingCopy || this._isCommittingEditing) + return; + + this.setContent(this._uiSourceCode.content() || "", false, this._uiSourceCode.contentType().canonicalMimeType()); }, populateTextAreaContextMenu: function(contextMenu, lineNumber) @@ -87,7 +115,7 @@ WebInspector.UISourceCodeFrame.prototype = { WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this, contextMenu, lineNumber); contextMenu.appendApplicableItems(this._uiSourceCode); contextMenu.appendSeparator(); - } -} + }, -WebInspector.UISourceCodeFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype; + __proto__: WebInspector.SourceFrame.prototype +} diff --git a/Source/WebCore/inspector/front-end/UserAgentSupport.js b/Source/WebCore/inspector/front-end/UserAgentSupport.js index ebed8079c..b3edc6677 100644 --- a/Source/WebCore/inspector/front-end/UserAgentSupport.js +++ b/Source/WebCore/inspector/front-end/UserAgentSupport.js @@ -362,3 +362,8 @@ WebInspector.UserAgentSupport.prototype = { } } + +/** + * @type {WebInspector.UserAgentSupport} + */ +WebInspector.userAgentSupport; diff --git a/Source/WebCore/inspector/front-end/View.js b/Source/WebCore/inspector/front-end/View.js index 91cb287c0..d3adff99b 100644 --- a/Source/WebCore/inspector/front-end/View.js +++ b/Source/WebCore/inspector/front-end/View.js @@ -358,10 +358,10 @@ WebInspector.View.prototype = { return; WebInspector.setCurrentFocusElement(element); - } -} + }, -WebInspector.View.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} WebInspector.View._originalAppendChild = Element.prototype.appendChild; WebInspector.View._originalInsertBefore = Element.prototype.insertBefore; diff --git a/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js b/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js index caed4f988..7aa9e5572 100644 --- a/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js @@ -110,10 +110,10 @@ WebInspector.WatchExpressionsSidebarPane.prototype = { { event.consume(); this.refreshExpressions(); - } -} + }, -WebInspector.WatchExpressionsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} /** * @constructor @@ -206,7 +206,7 @@ WebInspector.WatchExpressionsSection.prototype = { if (!expression) continue; - WebInspector.consoleView.evalInInspectedWindow(expression, this._watchObjectGroupId, false, true, false, appendResult.bind(this, expression, i)); + WebInspector.runtimeModel.evaluate(expression, this._watchObjectGroupId, false, true, false, appendResult.bind(this, expression, i)); } if (!propertyCount) { @@ -320,10 +320,10 @@ WebInspector.WatchExpressionsSection.prototype = { } this._lastMouseMovePageY = pageY; - } -} + }, -WebInspector.WatchExpressionsSection.prototype.__proto__ = WebInspector.ObjectPropertiesSection.prototype; + __proto__: WebInspector.ObjectPropertiesSection.prototype +} WebInspector.WatchExpressionsSection.CompareProperties = function(propertyA, propertyB) { @@ -411,7 +411,7 @@ WebInspector.WatchExpressionTreeElement.prototype = { this.property.name = expression; this.treeOutline.section.updateExpression(this, expression); - } -} + }, -WebInspector.WatchExpressionTreeElement.prototype.__proto__ = WebInspector.ObjectPropertyTreeElement.prototype; + __proto__: WebInspector.ObjectPropertyTreeElement.prototype +} diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc index ac64947a3..f657de7af 100644 --- a/Source/WebCore/inspector/front-end/WebKit.qrc +++ b/Source/WebCore/inspector/front-end/WebKit.qrc @@ -58,6 +58,7 @@ <file>DOMStorage.js</file> <file>DOMStorageItemsView.js</file> <file>DOMSyntaxHighlighter.js</file> + <file>DockController.js</file> <file>Drawer.js</file> <file>ElementsPanel.js</file> <file>ElementsPanelDescriptor.js</file> @@ -128,7 +129,8 @@ <file>ProfileDataGridTree.js</file> <file>ProfileLauncherView.js</file> <file>ProfilesPanel.js</file> - <file>ProgressBar.js</file> + <file>Progress.js</file> + <file>ProgressIndicator.js</file> <file>PropertiesSection.js</file> <file>PropertiesSidebarPane.js</file> <file>RemoteObject.js</file> diff --git a/Source/WebCore/inspector/front-end/WorkerManager.js b/Source/WebCore/inspector/front-end/WorkerManager.js index 9d14da9b9..149e88123 100644 --- a/Source/WebCore/inspector/front-end/WorkerManager.js +++ b/Source/WebCore/inspector/front-end/WorkerManager.js @@ -219,10 +219,10 @@ WebInspector.WorkerManager.prototype = { var screen = new WebInspector.WorkerTerminatedScreen(); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, screen.hide, screen); screen.showModal(); - } -} + }, -WebInspector.WorkerManager.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @constructor @@ -287,7 +287,7 @@ WebInspector.WorkerTerminatedScreen.prototype = { { WebInspector.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this.hide, this); WebInspector.HelpScreen.prototype.willHide.call(this); - } -} + }, -WebInspector.WorkerTerminatedScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype; + __proto__: WebInspector.HelpScreen.prototype +} diff --git a/Source/WebCore/inspector/front-end/WorkersSidebarPane.js b/Source/WebCore/inspector/front-end/WorkersSidebarPane.js index efa592161..3e344680c 100644 --- a/Source/WebCore/inspector/front-end/WorkersSidebarPane.js +++ b/Source/WebCore/inspector/front-end/WorkersSidebarPane.js @@ -118,7 +118,7 @@ WebInspector.WorkersSidebarPane.prototype = { _autoattachToWorkersClicked: function(event) { WorkerAgent.setAutoconnectToWorkers(event.target.checked); - } -} + }, -WebInspector.WorkersSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + __proto__: WebInspector.SidebarPane.prototype +} diff --git a/Source/WebCore/inspector/front-end/Workspace.js b/Source/WebCore/inspector/front-end/Workspace.js index 05087c8d5..6fcca5a1a 100644 --- a/Source/WebCore/inspector/front-end/Workspace.js +++ b/Source/WebCore/inspector/front-end/Workspace.js @@ -35,6 +35,7 @@ WebInspector.WorkspaceController = function(workspace) { this._workspace = workspace; WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); + WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this); } WebInspector.WorkspaceController.prototype = { @@ -44,6 +45,13 @@ WebInspector.WorkspaceController.prototype = { this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, this._workspace.project()); this._workspace.project().reset(); this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectDidReset, this._workspace.project()); + }, + + _frameAdded: function(event) + { + var frame = /** @type {WebInspector.ResourceTreeFrame} */ event.data; + if (frame.isMainFrame()) + WebInspector.Revision.filterOutStaleRevisions(); } } @@ -77,16 +85,11 @@ WebInspector.Project.prototype = { }, /** - * @param {WebInspector.UISourceCode} oldUISourceCode * @param {WebInspector.UISourceCode} uiSourceCode */ - replaceUISourceCode: function(oldUISourceCode, uiSourceCode) + addTemporaryUISourceCode: function(uiSourceCode) { - this._uiSourceCodes.splice(this._uiSourceCodes.indexOf(oldUISourceCode), 1); - if (this._uiSourceCodes.indexOf(uiSourceCode) === -1) - this._uiSourceCodes.push(uiSourceCode); - var data = { oldUISourceCode: oldUISourceCode, uiSourceCode: uiSourceCode }; - this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, data); + this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, uiSourceCode); }, /** @@ -99,6 +102,14 @@ WebInspector.Project.prototype = { }, /** + * @param {WebInspector.UISourceCode} uiSourceCode + */ + removeTemporaryUISourceCode: function(uiSourceCode) + { + this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, uiSourceCode); + }, + + /** * @param {string} url * @return {?WebInspector.UISourceCode} */ @@ -161,10 +172,10 @@ WebInspector.Workspace.prototype = { uiSourceCodes: function() { return this._project.uiSourceCodes(); - } -} + }, -WebInspector.Workspace.prototype.__proto__ = WebInspector.Object.prototype; + __proto__: WebInspector.Object.prototype +} /** * @type {?WebInspector.Workspace} diff --git a/Source/WebCore/inspector/front-end/elementsPanel.css b/Source/WebCore/inspector/front-end/elementsPanel.css index 568fd405f..dc2344762 100644 --- a/Source/WebCore/inspector/front-end/elementsPanel.css +++ b/Source/WebCore/inspector/front-end/elementsPanel.css @@ -33,6 +33,7 @@ #elements-content > ol { display: inline-block; + min-height: 100%; } #elements-content .editing { diff --git a/Source/WebCore/inspector/front-end/externs.js b/Source/WebCore/inspector/front-end/externs.js index 21d61a00a..ba5bbc9fe 100644 --- a/Source/WebCore/inspector/front-end/externs.js +++ b/Source/WebCore/inspector/front-end/externs.js @@ -110,7 +110,8 @@ DOMApplicationCache.prototype.DOWNLOADING = 3; DOMApplicationCache.prototype.UPDATEREADY = 4; DOMApplicationCache.prototype.OBSOLETE = 5; - +/** @type {Node} */ +Range.prototype.startContainer; // Inspector Backend var InspectorBackend = {} @@ -124,7 +125,7 @@ InspectorFrontendHostAPI.prototype.bringToFront = function() {} InspectorFrontendHostAPI.prototype.closeWindow = function() {} InspectorFrontendHostAPI.prototype.requestAttachWindow = function() {} InspectorFrontendHostAPI.prototype.requestDetachWindow = function() {} -InspectorFrontendHostAPI.prototype.requestSetDockSide = function() {} +InspectorFrontendHostAPI.prototype.requestSetDockSide = function(dockSide) {} InspectorFrontendHostAPI.prototype.setAttachedWindowHeight = function(height) {} InspectorFrontendHostAPI.prototype.moveWindowBy = function(x, y) {} InspectorFrontendHostAPI.prototype.setInjectedScriptForOrigin = function(origin, script) {} @@ -176,6 +177,8 @@ SourceMapV3.Offset = function() // FIXME: remove everything below. var WebInspector = {} +WebInspector.queryParamsObject = {} +WebInspector.toggleSearchingForNode = function() {} WebInspector.panels = {}; /** @@ -262,13 +265,6 @@ WebInspector.showPanel = function(panel) */ WebInspector.inspectedPageDomain; -/** - * @type {WebInspector.UserAgentSupport} - */ -WebInspector.userAgentSupport; - -WebInspector.isCompactMode = function() { return false; } - WebInspector.SourceJavaScriptTokenizer = {} WebInspector.SourceJavaScriptTokenizer.Keywords = {} diff --git a/Source/WebCore/inspector/front-end/helpScreen.css b/Source/WebCore/inspector/front-end/helpScreen.css index 512980ed8..dde8aa96d 100644 --- a/Source/WebCore/inspector/front-end/helpScreen.css +++ b/Source/WebCore/inspector/front-end/helpScreen.css @@ -85,6 +85,7 @@ body.compact .help-window-main { border-radius: 8px; height: 16px; width: 16px; + line-height: 12px; position: absolute; top: 6px; right: 6px; diff --git a/Source/WebCore/inspector/front-end/inspector.css b/Source/WebCore/inspector/front-end/inspector.css index 1c126ea8e..3846fbee3 100644 --- a/Source/WebCore/inspector/front-end/inspector.css +++ b/Source/WebCore/inspector/front-end/inspector.css @@ -66,8 +66,8 @@ body.inactive #toolbar { border-bottom: 1px solid rgb(64%, 64%, 64%); } -body.detached.platform-mac-leopard #toolbar, -body.detached.platform-mac-snowleopard #toolbar { +body.undocked.platform-mac-leopard #toolbar, +body.undocked.platform-mac-snowleopard #toolbar { background: transparent; } @@ -194,8 +194,8 @@ body.compact #toolbar-dropdown-arrow { background-image: inherit; } -body.detached.platform-mac-leopard #toolbar-dropdown, -body.detached.platform-mac-snowleopard #toolbar-dropdown { +body.undocked.platform-mac-leopard #toolbar-dropdown, +body.undocked.platform-mac-snowleopard #toolbar-dropdown { background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(191, 191, 191)), to(rgb(151, 151, 151))); } @@ -1020,6 +1020,11 @@ body.platform-linux .monospace, body.platform-linux .source-code { color: rgb(15%, 15%, 15%); } +ol.watch-expressions > li.hovered, +.console-message:hover { + background-color: #F0F0F0; +} + .console-message-url { float: right; margin-left: 4px; @@ -1366,7 +1371,6 @@ iframe.panel.extension { float: right; font-size: 10px; margin-left: 5px; - max-width: 55%; color: rgba(0, 0, 0, 0.7); text-overflow: ellipsis; overflow: hidden; @@ -1574,10 +1578,17 @@ li.editing .swatch, li.editing .enabled-button, li.editing-sub-part .delete-but .properties-tree.watch-expressions { padding-bottom: 8px; + padding-left: 4px !important; } -.properties-tree.watch-expressions li { +.properties-tree.watch-expressions > li { padding-top: 2px; + padding-left: 4px; +} + +.properties-tree.watch-expressions > li:not(.parent) { + margin-left: 1px; + padding-left: 15px; } .watch-expressions > li.editing-sub-part .text-prompt { @@ -1608,8 +1619,7 @@ li.editing .swatch, li.editing .enabled-button, li.editing-sub-part .delete-but background-repeat: no-repeat; border: 0 none transparent; position: absolute; - margin-left: -25px; - margin-top: 2px; + right: 8px; display: none; } diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html index cb9b8e86b..184da560c 100644 --- a/Source/WebCore/inspector/front-end/inspector.html +++ b/Source/WebCore/inspector/front-end/inspector.html @@ -159,15 +159,17 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="HandlerRegistry.js"></script> <script type="text/javascript" src="SnippetStorage.js"></script> <script type="text/javascript" src="ScriptSnippetModel.js"></script> - <script type="text/javascript" src="ProgressBar.js"></script> + <script type="text/javascript" src="Progress.js"></script> + <script type="text/javascript" src="ProgressIndicator.js"></script> <script type="text/javascript" src="StylesSourceMapping.js"></script> <script type="text/javascript" src="StyleSource.js"></script> <script type="text/javascript" src="NetworkUISourceCodeProvider.js"></script> <script type="text/javascript" src="ElementsPanelDescriptor.js"></script> <script type="text/javascript" src="NetworkPanelDescriptor.js"></script> <script type="text/javascript" src="ScriptsPanelDescriptor.js"></script> + <script type="text/javascript" src="DockController.js"></script> </head> -<body class="detached" id="-webkit-web-inspector"> +<body class="undocked" id="-webkit-web-inspector"> <div id="toolbar"> <div class="toolbar-item close-left"><button id="close-button-left"></button></div> <div id="toolbar-controls"> diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js index e77a90bfa..2ee60be18 100644 --- a/Source/WebCore/inspector/front-end/inspector.js +++ b/Source/WebCore/inspector/front-end/inspector.js @@ -72,13 +72,10 @@ var WebInspector = { _createGlobalStatusBarItems: function() { var bottomStatusBarContainer = document.getElementById("bottom-status-bar-container"); - this._dockToggleButton = new WebInspector.StatusBarButton("", "dock-status-bar-item", 3); - this._dockToggleButton.makeLongClickEnabled(this._createDockOptions.bind(this)); - this._dockToggleButton.addEventListener("click", this._toggleAttach.bind(this), false); - this._updateDockButtonState(); + // Create main dock button and options. var mainStatusBar = document.getElementById("main-status-bar"); - mainStatusBar.insertBefore(this._dockToggleButton.element, bottomStatusBarContainer); + mainStatusBar.insertBefore(this.dockController.element, bottomStatusBarContainer); this._toggleConsoleButton = new WebInspector.StatusBarButton(WebInspector.UIString("Show console."), "console-status-bar-item"); this._toggleConsoleButton.addEventListener("click", this._toggleConsoleButtonClicked.bind(this), false); @@ -93,68 +90,6 @@ var WebInspector = { mainStatusBar.appendChild(this.settingsController.statusBarItem); }, - _createDockOptions: function() - { - var alternateDockToggleButton1 = new WebInspector.StatusBarButton("Dock to main window.", "dock-status-bar-item", 3); - var alternateDockToggleButton2 = new WebInspector.StatusBarButton("Undock into separate window.", "dock-status-bar-item", 3); - - if (this.attached) { - alternateDockToggleButton1.state = WebInspector.settings.dockToRight.get() ? "bottom" : "right"; - alternateDockToggleButton2.state = "undock"; - } else { - alternateDockToggleButton1.state = WebInspector.settings.dockToRight.get() ? "bottom" : "right"; - alternateDockToggleButton2.state = WebInspector.settings.dockToRight.get() ? "right" : "bottom"; - } - - alternateDockToggleButton1.addEventListener("click", onClick.bind(this), false); - alternateDockToggleButton2.addEventListener("click", onClick.bind(this), false); - - function onClick(e) - { - var state = e.target.state; - if (state === "undock") - this._toggleAttach(); - else if (state === "right") { - if (!this.attached) - this._toggleAttach(); - WebInspector.settings.dockToRight.set(true); - } else if (state === "bottom") { - if (!this.attached) - this._toggleAttach(); - WebInspector.settings.dockToRight.set(false); - } - } - - return [alternateDockToggleButton1, alternateDockToggleButton2]; - }, - - _updateDockButtonState: function() - { - if (!this._dockToggleButton) - return; - - if (this.attached) { - this._dockToggleButton.disabled = false; - this._dockToggleButton.state = "undock"; - this._dockToggleButton.title = WebInspector.UIString("Undock into separate window."); - } else { - this._dockToggleButton.disabled = this._isDockingUnavailable; - this._dockToggleButton.state = WebInspector.settings.dockToRight.get() ? "right" : "bottom"; - this._dockToggleButton.title = WebInspector.UIString("Dock to main window."); - } - }, - - _toggleAttach: function() - { - if (!this._attached) { - InspectorFrontendHost.requestAttachWindow(); - WebInspector.userMetrics.WindowDocked.record(); - } else { - InspectorFrontendHost.requestDetachWindow(); - WebInspector.userMetrics.WindowUndocked.record(); - } - }, - _toggleConsoleButtonClicked: function() { if (this._toggleConsoleButton.disabled) @@ -223,42 +158,6 @@ var WebInspector = { } }, - get attached() - { - return this._attached; - }, - - set attached(x) - { - if (this._attached === x) - return; - - this._attached = x; - - if (x) - document.body.removeStyleClass("detached"); - else - document.body.addStyleClass("detached"); - - this._setCompactMode(x && !WebInspector.settings.dockToRight.get()); - this._updateDockButtonState(); - }, - - isCompactMode: function() - { - return this.attached && !WebInspector.settings.dockToRight.get(); - }, - - _setCompactMode: function(x) - { - var body = document.body; - if (x) - body.addStyleClass("compact"); - else - body.removeStyleClass("compact"); - WebInspector.windowResize(); - }, - _updateErrorAndWarningCounts: function() { var errorWarningElement = document.getElementById("error-warning-count"); @@ -334,13 +233,13 @@ var WebInspector = { _zoomIn: function() { - ++this._zoomLevel; + this._zoomLevel = Math.min(this._zoomLevel + 1, WebInspector.Zoom.Table.length - WebInspector.Zoom.DefaultOffset - 1); this._requestZoom(); }, _zoomOut: function() { - --this._zoomLevel; + this._zoomLevel = Math.max(this._zoomLevel - 1, -WebInspector.Zoom.DefaultOffset); this._requestZoom(); }, @@ -353,7 +252,11 @@ var WebInspector = { _requestZoom: function() { WebInspector.settings.zoomLevel.set(this._zoomLevel); - InspectorFrontendHost.setZoomFactor(Math.pow(1.2, this._zoomLevel)); + // For backwards compatibility, zoomLevel takes integers (with 0 being default zoom). + var index = this._zoomLevel + WebInspector.Zoom.DefaultOffset; + index = Math.min(WebInspector.Zoom.Table.length - 1, index); + index = Math.max(0, index); + InspectorFrontendHost.setZoomFactor(WebInspector.Zoom.Table[index]); }, toggleSearchingForNode: function() @@ -407,6 +310,7 @@ WebInspector.Events = { WebInspector.loaded = function() { InspectorBackend.loadFromJSONIfNeeded("../Inspector.json"); + WebInspector.dockController = new WebInspector.DockController(); if (WebInspector.WorkerManager.isDedicatedWorkerFrontend()) { // Do not create socket for the worker front-end. @@ -523,6 +427,7 @@ WebInspector._doLoadedDoneWithCapabilities = function() this.scriptSnippetModel = new WebInspector.ScriptSnippetModel(this.workspace); new WebInspector.DebuggerScriptMapping(this.workspace); + this.styleContentBinding = new WebInspector.StyleContentBinding(this.cssModel); new WebInspector.NetworkUISourceCodeProvider(this.workspace); new WebInspector.StylesSourceMapping(this.workspace); if (WebInspector.experimentsSettings.sass.isEnabled()) @@ -532,8 +437,6 @@ WebInspector._doLoadedDoneWithCapabilities = function() this._createGlobalStatusBarItems(); - WebInspector._installDockToRight(); - this.toolbar = new WebInspector.Toolbar(); WebInspector.startBatchUpdate(); var panelDescriptors = this._panelDescriptors(); @@ -579,36 +482,6 @@ WebInspector._doLoadedDoneWithCapabilities = function() InspectorFrontendAPI.loadCompleted(); } -WebInspector._installDockToRight = function() -{ - // Re-use Settings infrastructure for the dock-to-right settings UI - WebInspector.settings.dockToRight.set(WebInspector.queryParamsObject.dockSide === "right"); - - if (WebInspector.settings.dockToRight.get()) - document.body.addStyleClass("dock-to-right"); - - if (WebInspector.attached) - WebInspector._setCompactMode(!WebInspector.settings.dockToRight.get()); - - WebInspector.settings.dockToRight.addChangeListener(listener.bind(this)); - - function listener(event) - { - var value = WebInspector.settings.dockToRight.get(); - if (value) { - InspectorFrontendHost.requestSetDockSide("right"); - document.body.addStyleClass("dock-to-right"); - } else { - InspectorFrontendHost.requestSetDockSide("bottom"); - document.body.removeStyleClass("dock-to-right"); - } - if (WebInspector.attached) - WebInspector._setCompactMode(!value); - else - WebInspector._updateDockButtonState(); - } -} - var windowLoaded = function() { var localizedStringsURL = InspectorFrontendHost.localizedStringsURL(); @@ -621,8 +494,6 @@ var windowLoaded = function() } else WebInspector.loaded(); - WebInspector.attached = WebInspector.queryParamsObject.docked === "true"; - window.removeEventListener("DOMContentLoaded", windowLoaded, false); delete windowLoaded; }; @@ -667,8 +538,8 @@ WebInspector.windowResize = function(event) WebInspector.setDockingUnavailable = function(unavailable) { - this._isDockingUnavailable = unavailable; - this._updateDockButtonState(); + if (this.dockController) + this.dockController.setDockingUnavailable(unavailable); } WebInspector.close = function(event) @@ -1095,3 +966,8 @@ WebInspector.addMainEventListeners = function(doc) } WebInspector.ProfileURLRegExp = /webkit-profile:\/\/(.+)\/(.+)#([0-9]+)/; + +WebInspector.Zoom = { + Table: [0.25, 0.33, 0.5, 0.66, 0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5], + DefaultOffset: 6 +} diff --git a/Source/WebCore/inspector/front-end/inspectorCommon.css b/Source/WebCore/inspector/front-end/inspectorCommon.css index 89c84ba07..41b44faaf 100644 --- a/Source/WebCore/inspector/front-end/inspectorCommon.css +++ b/Source/WebCore/inspector/front-end/inspectorCommon.css @@ -17,11 +17,11 @@ body { -webkit-user-select: none; } -body.dock-to-right:not(.detached) { +body.dock-to-right:not(.undocked) { border-left: 1px solid rgb(80, 80, 80); } -body.dock-to-right.inactive:not(.detached) { +body.dock-to-right.inactive:not(.undocked) { border-left: 1px solid rgb(64%, 64%, 64%); } diff --git a/Source/WebCore/inspector/front-end/networkPanel.css b/Source/WebCore/inspector/front-end/networkPanel.css index a80c61d1e..cda6d10b1 100644 --- a/Source/WebCore/inspector/front-end/networkPanel.css +++ b/Source/WebCore/inspector/front-end/networkPanel.css @@ -191,10 +191,6 @@ margin-top: 1px; } -.resource-headers-view .outline-disclosure .raw-form-data { - white-space: pre-wrap; -} - .resource-cookies-view { display: none; position: absolute; diff --git a/Source/WebCore/inspector/front-end/treeoutline.js b/Source/WebCore/inspector/front-end/treeoutline.js index 814d33160..affc9ac3e 100644 --- a/Source/WebCore/inspector/front-end/treeoutline.js +++ b/Source/WebCore/inspector/front-end/treeoutline.js @@ -885,7 +885,7 @@ TreeElement.prototype.expandRecursively = function(maxDepth) // The Inspector uses TreeOutlines to represents object properties, so recursive expansion // in some case can be infinite, since JavaScript objects can hold circular references. // So default to a recursion cap of 3 levels, since that gives fairly good results. - if (typeof maxDepth === "undefined" || typeof maxDepth === "null") + if (isNaN(maxDepth)) maxDepth = 3; while (item) { @@ -1002,7 +1002,7 @@ TreeElement.prototype.onexpand = function() { } TreeElement.prototype.oncollapse = function() { } TreeElement.prototype.ondblclick = function() { } TreeElement.prototype.onreveal = function() { } -/** @param {boolean} selectedByUser */ +/** @param {boolean=} selectedByUser */ TreeElement.prototype.onselect = function(selectedByUser) { } /** |