| |
| /* |
| * weinre is available under *either* the terms of the modified BSD license *or* the |
| * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. |
| * |
| * Copyright (c) 2010, 2011 IBM Corporation |
| */ |
| |
| require ../common/Weinre |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| class WebInspectorDOMHandlerImpl |
| this.inspectedNodes = [] |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getChildNodes(/*int*/ nodeId, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| var children = Weinre.nodeStore.serializeNodeChildren(node, 1) |
| WebInspector.setChildNodes(nodeId, children) |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method setAttribute(/*int*/ elementId, /*string*/ name, /*string*/ value, callback) |
| var element = Weinre.nodeStore.getNode(elementId) |
| if (!element) { |
| console.log(arguments.callee.signature + " passed an invalid elementId: " + elementId) |
| return |
| } |
| |
| element.setAttribute(name, value) |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method removeAttribute(/*int*/ elementId, /*string*/ name, callback) |
| var element = Weinre.nodeStore.getNode(elementId) |
| if (!element) { |
| console.log(arguments.callee.signature + " passed an invalid elementId: " + elementId) |
| return |
| } |
| |
| element.removeAttribute(name) |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method setTextNodeValue(/*int*/ nodeId, /*string*/ value, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| node.nodeValue = value |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getEventListenersForNode(/*int*/ nodeId, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method copyNode(/*int*/ nodeId, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method removeNode(/*int*/ nodeId, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| if (!node.parentNode) { |
| console.log(arguments.callee.signature + " passed a parentless node: " + node) |
| return |
| } |
| |
| node.parentNode.removeChild(node) |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method changeTagName(/*int*/ nodeId, /*string*/ newTagName, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getOuterHTML(/*int*/ nodeId, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| value = node.outerHTML |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback, [value]) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method setOuterHTML(/*int*/ nodeId, /*string*/ outerHTML, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| node.outerHTML = outerHTML |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method addInspectedNode(/*int*/ nodeId, callback) |
| this.inspectedNodes.unshift(nodeId) |
| if (this.inspectedNodes.length > 5) { |
| this.inspectedNodes = this.inspectedNodes.slice(0,5) |
| } |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method performSearch(/*string*/ query, /*boolean*/ runSynchronously, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method searchCanceled(callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method pushNodeByPathToFrontend(/*string*/ path, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getStyles(/*int*/ nodeId, /*boolean*/ authOnly, callback) |
| var result = {} |
| |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| var result = { |
| inlineStyle: Weinre.cssStore.getInlineStyle(node), |
| computedStyle: Weinre.cssStore.getComputedStyle(node), |
| matchedCSSRules: Weinre.cssStore.getMatchedCSSRules(node), |
| styleAttributes: Weinre.cssStore.getStyleAttributes(node), |
| pseudoElements: Weinre.cssStore.getPseudoElements(node), |
| } |
| |
| var parentNode = node.parentNode |
| var currentStyle = result |
| |
| while (parentNode) { |
| var parentStyle = { |
| inlineStyle: Weinre.cssStore.getInlineStyle(parentNode), |
| matchedCSSRules: Weinre.cssStore.getMatchedCSSRules(parentNode), |
| } |
| |
| currentStyle.parent = parentStyle |
| |
| currentStyle = parentStyle |
| parentNode = parentNode.parentNode |
| } |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback, [result]) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getAllStyles(callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getInlineStyle(/*int*/ nodeId, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| var result = Weinre.cssStore.getInlineStyle(node) |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback, [result]) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getComputedStyle(/*int*/ nodeId, callback) |
| var node = Weinre.nodeStore.getNode(nodeId) |
| if (!node) { |
| console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId) |
| return |
| } |
| |
| var result = Weinre.cssStore.getComputedStyle(node) |
| |
| if (callback) { |
| Weinre.WeinreTargetCommands.sendClientCallback(callback, [result]) |
| } |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getStyleSheet(/*int*/ styleSheetId, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getStyleSourceData(/*int*/ styleSheetId, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method applyStyleText(/*int*/ styleId, /*string*/ styleText, /*string*/ propertyName, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method setStyleText(/*int*/ styleId, /*string*/ styleText, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method setStyleProperty(/*int*/ styleId, /*string*/ name, /*string*/ value, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method toggleStyleEnabled(/*int*/ styleId, /*string*/ propertyName, /*boolean*/ disabled, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method setRuleSelector(/*int*/ ruleId, /*string*/ selector, /*int*/ selectedNodeId, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method addRule(/*string*/ selector, /*int*/ selectedNodeId, callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |
| //----------------------------------------------------------------------------- |
| // |
| //----------------------------------------------------------------------------- |
| method getSupportedCSSProperties(callback) |
| // callback: function() |
| Weinre.notImplemented(arguments.callee.signature) |
| |