diff options
Diffstat (limited to 'WebCore/inspector/front-end/DOMAgent.js')
-rw-r--r-- | WebCore/inspector/front-end/DOMAgent.js | 290 |
1 files changed, 0 insertions, 290 deletions
diff --git a/WebCore/inspector/front-end/DOMAgent.js b/WebCore/inspector/front-end/DOMAgent.js index 470e775..37bf549 100644 --- a/WebCore/inspector/front-end/DOMAgent.js +++ b/WebCore/inspector/front-end/DOMAgent.js @@ -524,296 +524,6 @@ WebInspector.EventListeners.getEventListenersForNodeAsync = function(node, callb InspectorBackend.getEventListenersForNode(node.id, callback); } -WebInspector.CSSStyleDeclaration = function(payload) -{ - this.id = payload.styleId; - this.properties = payload.properties; - this._shorthandValues = payload.shorthandValues; - this._livePropertyMap = {}; // LIVE properties (source-based or style-based) : { name -> CSSProperty } - this._allProperties = []; // ALL properties: [ CSSProperty ] - this._longhandProperties = {}; // shorthandName -> [ CSSProperty ] - this.__disabledProperties = {}; // DISABLED properties: { index -> CSSProperty } - var payloadPropertyCount = payload.cssProperties.length; - - var propertyIndex = 0; - for (var i = 0; i < payloadPropertyCount; ++i) { - var property = new WebInspector.CSSProperty.parsePayload(this, i, payload.cssProperties[i]); - this._allProperties.push(property); - if (property.disabled) - this.__disabledProperties[i] = property; - if (!property.active && !property.styleBased) - continue; - var name = property.name; - this[propertyIndex] = name; - this._livePropertyMap[name] = property; - - // Index longhand properties. - if (property.shorthand) { // only for parsed - var longhands = this._longhandProperties[property.shorthand]; - if (!longhands) { - longhands = []; - this._longhandProperties[property.shorthand] = longhands; - } - longhands.push(property); - } - ++propertyIndex; - } - this.length = propertyIndex; -} - -WebInspector.CSSStyleDeclaration.parsePayload = function(payload) -{ - return new WebInspector.CSSStyleDeclaration(payload); -} - -WebInspector.CSSStyleDeclaration.prototype = { - get allProperties() - { - return this._allProperties; - }, - - getLiveProperty: function(name) - { - return this._livePropertyMap[name]; - }, - - getPropertyValue: function(name) - { - var property = this._livePropertyMap[name]; - return property ? property.value : ""; - }, - - getPropertyPriority: function(name) - { - var property = this._livePropertyMap[name]; - return property ? property.priority : ""; - }, - - getPropertyShorthand: function(name) - { - var property = this._livePropertyMap[name]; - return property ? property.shorthand : ""; - }, - - isPropertyImplicit: function(name) - { - var property = this._livePropertyMap[name]; - return property ? property.implicit : ""; - }, - - styleTextWithShorthands: function() - { - var cssText = ""; - var foundProperties = {}; - for (var i = 0; i < this.length; ++i) { - var individualProperty = this[i]; - var shorthandProperty = this.getPropertyShorthand(individualProperty); - var propertyName = (shorthandProperty || individualProperty); - - if (propertyName in foundProperties) - continue; - - if (shorthandProperty) { - var value = this.getShorthandValue(shorthandProperty); - var priority = this.getShorthandPriority(shorthandProperty); - } else { - var value = this.getPropertyValue(individualProperty); - var priority = this.getPropertyPriority(individualProperty); - } - - foundProperties[propertyName] = true; - - cssText += propertyName + ": " + value; - if (priority) - cssText += " !" + priority; - cssText += "; "; - } - - return cssText; - }, - - getLonghandProperties: function(name) - { - return this._longhandProperties[name] || []; - }, - - getShorthandValue: function(shorthandProperty) - { - var property = this.getLiveProperty(shorthandProperty); - return property ? property.value : this._shorthandValues[shorthandProperty]; - }, - - getShorthandPriority: function(shorthandProperty) - { - var priority = this.getPropertyPriority(shorthandProperty); - if (priority) - return priority; - - var longhands = this._longhandProperties[shorthandProperty]; - return longhands ? this.getPropertyPriority(longhands[0]) : null; - }, - - appendProperty: function(propertyName, propertyValue, userCallback) - { - function setPropertyCallback(userCallback, success, stylePayload) - { - if (!success) - userCallback(null); - else - userCallback(WebInspector.CSSStyleDeclaration.parsePayload(stylePayload)); - } - - // FIXME(apavlov): this should be migrated to the new InspectorCSSAgent API once it is enabled. - InspectorBackend.applyStyleText(this.id, propertyName + ": " + propertyValue + ";", propertyName, setPropertyCallback.bind(this, userCallback)); - }, - - propertyAt: function(index) - { - return (index < this.allProperties.length) ? this.allProperties[index] : null; - } -} - -WebInspector.CSSRule = function(payload) -{ - this.id = payload.ruleId; - this.selectorText = payload.selectorText; - this.sourceLine = payload.sourceLine; - this.sourceURL = payload.sourceURL; - this.origin = payload.origin; - this.style = WebInspector.CSSStyleDeclaration.parsePayload(payload.style); - this.style.parentRule = this; -} - -WebInspector.CSSRule.parsePayload = function(payload) -{ - return new WebInspector.CSSRule(payload); -} - -WebInspector.CSSRule.prototype = { - get isUserAgent() - { - return this.origin === "user-agent"; - }, - - get isUser() - { - return this.origin === "user"; - }, - - get isViaInspector() - { - return this.origin === "inspector"; - }, - - get isRegular() - { - return this.origin === ""; - } -} - -WebInspector.CSSProperty = function(ownerStyle, index, name, value, priority, status, parsedOk, implicit, shorthand, text) -{ - this.ownerStyle = ownerStyle; - this.index = index; - this.name = name; - this.value = value; - this.priority = priority; - this.status = status; - this.parsedOk = parsedOk; - this.implicit = implicit; - this.shorthand = shorthand; - this.text = text; -} - -WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload) -{ - var result = new WebInspector.CSSProperty( - ownerStyle, index, payload.name, payload.value, payload.priority, payload.status, payload.parsedOk, payload.implicit, payload.shorthandName, payload.text); - return result; -} - -WebInspector.CSSProperty.prototype = { - get propertyText() - { - if (this.text !== undefined) - return this.text; - - return this.name + ": " + this.value + (this.priority ? " !" + this.priority : "") + ";"; - }, - - get isLive() - { - return this.active || this.styleBased; - }, - - get active() - { - return this.status === "active"; - }, - - get styleBased() - { - return this.status === "style"; - }, - - get inactive() - { - return this.status === "inactive"; - }, - - get disabled() - { - return this.status === "disabled"; - }, - - // Replaces "propertyName: propertyValue [!important];" in the stylesheet by an arbitrary propertyText. - setText: function(propertyText, userCallback) - { - function callback(userCallback, success, stylePayload) - { - if (!userCallback) - return; - if (!success) - userCallback(null); - else { - var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload); - userCallback(style); - } - } - - if (!this.ownerStyle) - throw "No ownerStyle for property"; - InspectorBackend.applyStyleText(this.ownerStyle.id, propertyText, this.name, callback.bind(this, userCallback)); - }, - - setValue: function(newValue, userCallback) - { - var text = this.name + ": " + newValue + (this.priority ? " !" + this.priority : "") + ";" - this.setText(text, userCallback); - }, - - setDisabled: function(disabled, userCallback) - { - if (!this.ownerStyle && userCallback) - userCallback(null); - if (disabled === this.disabled && userCallback) - userCallback(this.ownerStyle); - - function callback(userCallback, stylePayload) - { - if (!userCallback) - return; - if (!stylePayload) - userCallback(null); - else { - var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload); - userCallback(style); - } - } - InspectorBackend.toggleStyleEnabled(this.ownerStyle.id, this.name, disabled, callback.bind(this, userCallback)); - } -} - WebInspector.attributesUpdated = function() { this.domAgent._attributesUpdated.apply(this.domAgent, arguments); |