Commit 6a4003b8 authored by aroben@apple.com's avatar aroben@apple.com

Use prototypes/constructors from the inspected page when operating on...

        Use prototypes/constructors from the inspected page when operating on objects from the inspected page

        Reviewed by Tim Hatcher.

        * page/inspector/Console.js:
        (WebInspector.ConsolePanel._format): Use the Node constructor from the
        inspected Window with the instanceof operator.
        * page/inspector/ElementsPanel.js:
        (WebInspector.DOMNodeTreeElement._attributeEditingCommitted): Use the
        Element prototype from the inspected Window instead of the Element
        prototype from this Window.
        * page/inspector/inspector.js:
        (WebInspector.performSearch): Ditto for Document prototype.
        * page/inspector/utilities.js:
        (Object.type): Now takes an optional Window parameter that is used to
        find the built-in constructors.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 66641256
2008-04-14 Adam Roben <aroben@apple.com>
Use prototypes/constructors from the inspected page when operating on
objects from the inspected page
Reviewed by Tim Hatcher.
* page/inspector/Console.js:
(WebInspector.ConsolePanel._format): Use the Node constructor from the
inspected Window with the instanceof operator.
* page/inspector/ElementsPanel.js:
(WebInspector.DOMNodeTreeElement._attributeEditingCommitted): Use the
Element prototype from the inspected Window instead of the Element
prototype from this Window.
* page/inspector/inspector.js:
(WebInspector.performSearch): Ditto for Document prototype.
* page/inspector/utilities.js:
(Object.type): Now takes an optional Window parameter that is used to
find the built-in constructors.
2008-04-14 Adam Roben <aroben@apple.com>
Don't store objects from the Inspector on CSSStyleRules from the
......@@ -355,9 +355,9 @@ WebInspector.Console.prototype = {
_format: function(output)
{
var type = Object.type(output);
var type = Object.type(output, InspectorController.inspectedWindow());
if (type === "object") {
if (output instanceof Node)
if (output instanceof InspectorController.inspectedWindow().Node)
type = "node";
}
......
......@@ -1114,11 +1114,11 @@ WebInspector.DOMNodeTreeElement.prototype = {
for (var i = 0; i < parseElement.attributes.length; ++i) {
var attr = parseElement.attributes[i];
foundOriginalAttribute = foundOriginalAttribute || attr.name === attributeName;
Element.prototype.setAttribute.call(this.representedObject, attr.name, attr.value);
InspectorController.inspectedWindow().Element.prototype.setAttribute.call(this.representedObject, attr.name, attr.value);
}
if (!foundOriginalAttribute)
Element.prototype.removeAttribute.call(this.representedObject, attributeName);
InspectorController.inspectedWindow().Element.prototype.removeAttribute.call(this.representedObject, attributeName);
this._updateTitle();
this.treeOutline.panel._focusedNodeChanged(true);
......
......@@ -785,13 +785,13 @@ WebInspector.performSearch = function(query)
if (resource.category === this.resourceCategories.documents) {
var doc = resource.documentNode;
try {
var result = Document.prototype.evaluate.call(doc, xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
var result = InspectorController.inspectedWindow().Document.prototype.evaluate.call(doc, xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
addNodesToDOMResults(result, result.snapshotLength, function(l, i) { return l.snapshotItem(i); });
} catch(err) {
// ignore any exceptions. the query might be malformed, but we allow that.
}
var result = Document.prototype.querySelectorAll.call(doc, query);
var result = InspectorController.inspectedWindow().Document.prototype.querySelectorAll.call(doc, query);
addNodesToDOMResults(result, result.length, function(l, i) { return l.item(i); });
cleanUpDOMResultsNodes();
......
......@@ -26,7 +26,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Object.type = function(obj)
Object.type = function(obj, win)
{
if (obj === null)
return "null";
......@@ -35,19 +35,21 @@ Object.type = function(obj)
if (type !== "object" && type !== "function")
return type;
if (obj instanceof String)
win = win || window;
if (obj instanceof win.String)
return "string";
if (obj instanceof Array)
if (obj instanceof win.Array)
return "array";
if (obj instanceof Boolean)
if (obj instanceof win.Boolean)
return "boolean";
if (obj instanceof Number)
if (obj instanceof win.Number)
return "number";
if (obj instanceof Date)
if (obj instanceof win.Date)
return "date";
if (obj instanceof RegExp)
if (obj instanceof win.RegExp)
return "regexp";
if (obj instanceof Error)
if (obj instanceof win.Error)
return "error";
return type;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment