| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback | 884 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback |
| 885 */ | 885 */ |
| 886 appendProperty: function(name, value, userCallback) | 886 appendProperty: function(name, value, userCallback) |
| 887 { | 887 { |
| 888 this.insertPropertyAt(this.allProperties.length, name, value, userCallba
ck); | 888 this.insertPropertyAt(this.allProperties.length, name, value, userCallba
ck); |
| 889 } | 889 } |
| 890 } | 890 } |
| 891 | 891 |
| 892 /** | 892 /** |
| 893 * @constructor | 893 * @constructor |
| 894 * @param {!CSSAgent.Selector} payload |
| 895 */ |
| 896 WebInspector.CSSRuleSelector = function(payload) |
| 897 { |
| 898 this.value = payload.value; |
| 899 if (payload.range) |
| 900 this.range = WebInspector.TextRange.fromObject(payload.range); |
| 901 } |
| 902 |
| 903 /** |
| 904 * @param {!CSSAgent.Selector} payload |
| 905 * @return {!WebInspector.CSSRuleSelector} |
| 906 */ |
| 907 WebInspector.CSSRuleSelector.parsePayload = function(payload) |
| 908 { |
| 909 return new WebInspector.CSSRuleSelector(payload) |
| 910 } |
| 911 |
| 912 WebInspector.CSSRuleSelector.prototype = { |
| 913 /** |
| 914 * @param {!WebInspector.TextRange} oldRange |
| 915 * @param {!WebInspector.TextRange} newRange |
| 916 */ |
| 917 sourceStyleRuleEdited: function(oldRange, newRange) |
| 918 { |
| 919 if (!this.range) |
| 920 return; |
| 921 this.range = this.range.rebaseAfterTextEdit(oldRange, newRange); |
| 922 } |
| 923 } |
| 924 |
| 925 /** |
| 926 * @constructor |
| 894 * @param {!WebInspector.CSSStyleModel} cssModel | 927 * @param {!WebInspector.CSSStyleModel} cssModel |
| 895 * @param {!CSSAgent.CSSRule} payload | 928 * @param {!CSSAgent.CSSRule} payload |
| 896 * @param {!Array.<number>=} matchingSelectors | 929 * @param {!Array.<number>=} matchingSelectors |
| 897 */ | 930 */ |
| 898 WebInspector.CSSRule = function(cssModel, payload, matchingSelectors) | 931 WebInspector.CSSRule = function(cssModel, payload, matchingSelectors) |
| 899 { | 932 { |
| 900 this._cssModel = cssModel; | 933 this._cssModel = cssModel; |
| 901 this.styleSheetId = payload.styleSheetId; | 934 this.styleSheetId = payload.styleSheetId; |
| 902 if (matchingSelectors) | 935 if (matchingSelectors) |
| 903 this.matchingSelectors = matchingSelectors; | 936 this.matchingSelectors = matchingSelectors; |
| 904 this.selectors = payload.selectorList.selectors; | 937 |
| 905 for (var i = 0; i < this.selectors.length; ++i) { | 938 /** @type {!Array.<!WebInspector.CSSRuleSelector>} */ |
| 906 var selector = this.selectors[i]; | 939 this.selectors = []; |
| 907 if (selector.range) | 940 for (var i = 0; i < payload.selectorList.selectors.length; ++i) { |
| 908 selector.range = WebInspector.TextRange.fromObject(selector.range); | 941 var selectorPayload = payload.selectorList.selectors[i]; |
| 942 this.selectors.push(WebInspector.CSSRuleSelector.parsePayload(selectorPa
yload)); |
| 909 } | 943 } |
| 910 this.selectorText = this.selectors.select("value").join(", "); | 944 this.selectorText = this.selectors.select("value").join(", "); |
| 911 | 945 |
| 912 var firstRange = this.selectors[0].range; | 946 var firstRange = this.selectors[0].range; |
| 913 if (firstRange) { | 947 if (firstRange) { |
| 914 var lastRange = this.selectors.peekLast().range; | 948 var lastRange = this.selectors.peekLast().range; |
| 915 this.selectorRange = new WebInspector.TextRange(firstRange.startLine, fi
rstRange.startColumn, lastRange.endLine, lastRange.endColumn); | 949 this.selectorRange = new WebInspector.TextRange(firstRange.startLine, fi
rstRange.startColumn, lastRange.endLine, lastRange.endColumn); |
| 916 } | 950 } |
| 917 if (this.styleSheetId) { | 951 if (this.styleSheetId) { |
| 918 var styleSheetHeader = cssModel.styleSheetHeaderForId(this.styleSheetId)
; | 952 var styleSheetHeader = cssModel.styleSheetHeaderForId(this.styleSheetId)
; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 941 /** | 975 /** |
| 942 * @param {string} styleSheetId | 976 * @param {string} styleSheetId |
| 943 * @param {!WebInspector.TextRange} oldRange | 977 * @param {!WebInspector.TextRange} oldRange |
| 944 * @param {!WebInspector.TextRange} newRange | 978 * @param {!WebInspector.TextRange} newRange |
| 945 */ | 979 */ |
| 946 sourceStyleSheetEdited: function(styleSheetId, oldRange, newRange) | 980 sourceStyleSheetEdited: function(styleSheetId, oldRange, newRange) |
| 947 { | 981 { |
| 948 if (this.styleSheetId === styleSheetId) { | 982 if (this.styleSheetId === styleSheetId) { |
| 949 if (this.selectorRange) | 983 if (this.selectorRange) |
| 950 this.selectorRange = this.selectorRange.rebaseAfterTextEdit(oldR
ange, newRange); | 984 this.selectorRange = this.selectorRange.rebaseAfterTextEdit(oldR
ange, newRange); |
| 951 for (var i = 0; i < this.selectors.length; ++i) { | 985 for (var i = 0; i < this.selectors.length; ++i) |
| 952 var selector = this.selectors[i]; | 986 this.selectors[i].sourceStyleRuleEdited(oldRange, newRange); |
| 953 if (selector.range) | |
| 954 selector.range = selector.range.rebaseAfterTextEdit(oldRange
, newRange); | |
| 955 } | |
| 956 } | 987 } |
| 957 if (this.media) { | 988 if (this.media) { |
| 958 for (var i = 0; i < this.media.length; ++i) | 989 for (var i = 0; i < this.media.length; ++i) |
| 959 this.media[i].sourceStyleSheetEdited(styleSheetId, oldRange, new
Range); | 990 this.media[i].sourceStyleSheetEdited(styleSheetId, oldRange, new
Range); |
| 960 } | 991 } |
| 961 this.style.sourceStyleSheetEdited(styleSheetId, oldRange, newRange); | 992 this.style.sourceStyleSheetEdited(styleSheetId, oldRange, newRange); |
| 962 }, | 993 }, |
| 963 | 994 |
| 964 _setFrameId: function() | 995 _setFrameId: function() |
| 965 { | 996 { |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 for (var i = 0; i < callbacks.length; ++i) | 1673 for (var i = 0; i < callbacks.length; ++i) |
| 1643 callbacks[i](computedStyle); | 1674 callbacks[i](computedStyle); |
| 1644 } | 1675 } |
| 1645 } | 1676 } |
| 1646 } | 1677 } |
| 1647 | 1678 |
| 1648 /** | 1679 /** |
| 1649 * @type {!WebInspector.CSSStyleModel} | 1680 * @type {!WebInspector.CSSStyleModel} |
| 1650 */ | 1681 */ |
| 1651 WebInspector.cssModel; | 1682 WebInspector.cssModel; |
| OLD | NEW |