Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Side by Side Diff: webkit/glue/devtools/js/dom_agent.js

Issue 100199: DevTools: Implement styles editing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Dom and DomNode are used to represent remote DOM in the 6 * @fileoverview Dom and DomNode are used to represent remote DOM in the
7 * web inspector. 7 * web inspector.
8 */ 8 */
9 goog.provide('devtools.DomAgent'); 9 goog.provide('devtools.DomAgent');
10 goog.provide('devtools.DomDocument'); 10 goog.provide('devtools.DomDocument');
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 /** 822 /**
823 * Returns all properties of the given node. 823 * Returns all properties of the given node.
824 * @param {number} nodeId Node to get properties for. 824 * @param {number} nodeId Node to get properties for.
825 * @param {Array.<string>} path Path to the object. 825 * @param {Array.<string>} path Path to the object.
826 * @param {number} protoDepth Depth to the exact proto level. 826 * @param {number} protoDepth Depth to the exact proto level.
827 * @param {function(string):undefined} callback Function to call with the 827 * @param {function(string):undefined} callback Function to call with the
828 * result. 828 * result.
829 */ 829 */
830 devtools.DomAgent.prototype.getNodePropertiesAsync = function(nodeId, 830 devtools.DomAgent.prototype.getNodePropertiesAsync = function(nodeId,
831 path, protoDepth, callback) { 831 path, protoDepth, callback) {
832 var mycallback = 832 var callbackId = this.utilityFunctionCallbackWrapper_(callback);
833 goog.bind(this.utilityFunctionCallbackWrapper_, this, callback);
834 var callbackId = devtools.Callback.wrap(mycallback);
835 RemoteToolsAgent.ExecuteUtilityFunction(callbackId, 833 RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
836 'getProperties', nodeId, 834 'getProperties', nodeId,
837 goog.json.serialize([path, protoDepth])); 835 goog.json.serialize([path, protoDepth]));
838 }; 836 };
839 837
840 838
841 /** 839 /**
842 * Returns prototype chain for a given node. 840 * Returns prototype chain for a given node.
843 * @param {number} nodeId Node to get prototypes for. 841 * @param {number} nodeId Node to get prototypes for.
844 * @param {Function} callback. 842 * @param {Function} callback.
845 */ 843 */
846 devtools.DomAgent.prototype.getNodePrototypesAsync = function(nodeId, 844 devtools.DomAgent.prototype.getNodePrototypesAsync = function(nodeId,
847 callback) { 845 callback) {
848 var mycallback = 846 var callbackId = this.utilityFunctionCallbackWrapper_(callback);
849 goog.bind(this.utilityFunctionCallbackWrapper_, this, callback);
850 var callbackId = devtools.Callback.wrap(mycallback);
851 RemoteToolsAgent.ExecuteUtilityFunction(callbackId, 847 RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
852 'getPrototypes', nodeId, '[]'); 848 'getPrototypes', nodeId, '[]');
853 }; 849 };
854 850
855 851
856 /** 852 /**
857 * Returns styles for given node. 853 * Returns styles for given node.
858 * @param {devtools.DomNode} node Node to get prototypes for. 854 * @param {devtools.DomNode} node Node to get prototypes for.
859 * @param {boolean} authorOnly Returns only author styles if true. 855 * @param {boolean} authorOnly Returns only author styles if true.
860 * @param {Function} callback. 856 * @param {Function} callback.
861 */ 857 */
862 devtools.DomAgent.prototype.getNodeStylesAsync = function(node, 858 devtools.DomAgent.prototype.getNodeStylesAsync = function(node,
863 authorOnly, callback) { 859 authorOnly, callback) {
864 var mycallback = 860 var callbackId = this.utilityFunctionCallbackWrapper_(callback);
865 goog.bind(this.utilityFunctionCallbackWrapper_, this, callback);
866 var callbackId = devtools.Callback.wrap(mycallback);
867 RemoteToolsAgent.ExecuteUtilityFunction(callbackId, 861 RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
868 'getStyles', 862 'getStyles',
869 node.id_, 863 node.id_,
870 goog.json.serialize([authorOnly])); 864 goog.json.serialize([authorOnly]));
871 }; 865 };
872 866
873 867
874 /** 868 /**
875 * Toggles style with given id on/off. 869 * Toggles style with given id on/off.
876 * @param {devtools.CSSStyleDeclaration} style Style to toggle. 870 * @param {devtools.CSSStyleDeclaration} style Style to toggle.
877 * @param {boolean} enabled True if style should be enabled. 871 * @param {boolean} enabled True if style should be enabled.
878 * @param {string} name Style name. 872 * @param {string} name Style name.
879 * @param {Function} callback. 873 * @param {Function} callback.
880 */ 874 */
881 devtools.DomAgent.prototype.toggleNodeStyleAsync = function( 875 devtools.DomAgent.prototype.toggleNodeStyleAsync = function(
882 style, enabled, name, callback) { 876 style, enabled, name, callback) {
883 var mycallback = 877 var callbackId = this.utilityFunctionCallbackWrapper_(callback);
884 goog.bind(this.utilityFunctionCallbackWrapper_, this, callback);
885 var callbackId = devtools.Callback.wrap(mycallback);
886 RemoteToolsAgent.ExecuteUtilityFunction(callbackId, 878 RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
887 'toggleNodeStyle', 879 'toggleNodeStyle',
888 style.nodeId_, 880 style.nodeId_,
889 goog.json.serialize([style.id_, enabled, name])); 881 goog.json.serialize([style.id_, enabled, name]));
890 }; 882 };
891 883
892 884
893 /** 885 /**
886 * Applies new text to a style.
887 * @param {devtools.CSSStyleDeclaration} style Style to edit.
888 * @param {string} name Property name to edit.
889 * @param {string} styleText Text to set the style from.
890 * @param {Function} callback.
891 */
892 devtools.DomAgent.prototype.applyStyleTextAsync = function(
893 style, name, styleText, callback) {
894 var callbackId = this.utilityFunctionCallbackWrapper_(callback);
895 RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
yurys 2009/04/30 09:55:40 style: wrong arguments alignment
pfeldman 2009/04/30 10:00:16 Done.
896 'applyStyleText',
897 style.nodeId_,
898 goog.json.serialize([style.id_, name, styleText]));
899 };
900
901
902 /**
894 * Dumps exception if something went wrong in ExecuteUtilityFunction. 903 * Dumps exception if something went wrong in ExecuteUtilityFunction.
904 * @param {Function} callback Callback to wrap.
905 * @return {number} Callback id.
895 */ 906 */
896 devtools.DomAgent.prototype.utilityFunctionCallbackWrapper_ = 907 devtools.DomAgent.prototype.utilityFunctionCallbackWrapper_ =
897 function(callback, result, exception) { 908 function(callback) {
898 if (exception && exception.length) { 909 var mycallback = function(result, exception) {
899 debugPrint('Exception in ExecuteUtilityFunction styles:' + exception); 910 if (exception && exception.length) {
900 return; 911 debugPrint('Exception in ExecuteUtilityFunction styles:' + exception);
901 } 912 return;
902 callback(result); 913 }
914 callback(result);
915 };
916 return devtools.Callback.wrap(mycallback);
903 }; 917 };
904 918
905 919
906 /** 920 /**
907 * Represents remote CSSStyleDeclaration for using in StyleSidebarPane. 921 * Represents remote CSSStyleDeclaration for using in StyleSidebarPane.
908 * @param {id, Array<Object>} payload built by inject's getStyle from the 922 * @param {id, Array<Object>} payload built by inject's getStyle from the
909 * injected js. 923 * injected js.
910 * @constructor 924 * @constructor
911 */ 925 */
912 devtools.CSSStyleDeclaration = function(payload) { 926 devtools.CSSStyleDeclaration = function(payload) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 function onlyTextChild() { 993 function onlyTextChild() {
980 if (!this.children) { 994 if (!this.children) {
981 return null; 995 return null;
982 } else if (this.children.length == 1 && 996 } else if (this.children.length == 1 &&
983 this.children[0].nodeType == Node.TEXT_NODE) { 997 this.children[0].nodeType == Node.TEXT_NODE) {
984 return this.children[0]; 998 return this.children[0];
985 } else { 999 } else {
986 return null; 1000 return null;
987 } 1001 }
988 } 1002 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698