⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stylessidebarpane.js

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 JS
📖 第 1 页 / 共 3 页
字号:
        this.identifier += ":" + this.subtitleElement.textContent;}WebInspector.StylePropertiesSection.prototype = {    get usedProperties()    {        return this._usedProperties || {};    },    set usedProperties(x)    {        this._usedProperties = x;        this.update();    },    expand: function(dontRememberState)    {        WebInspector.PropertiesSection.prototype.expand.call(this);        if (dontRememberState)            return;        if (!Preferences.styleRulesExpandedState)            Preferences.styleRulesExpandedState = {};        Preferences.styleRulesExpandedState[this.identifier] = true;    },    collapse: function(dontRememberState)    {        WebInspector.PropertiesSection.prototype.collapse.call(this);        if (dontRememberState)            return;        if (!Preferences.styleRulesExpandedState)            Preferences.styleRulesExpandedState = {};        Preferences.styleRulesExpandedState[this.identifier] = false;    },    isPropertyInherited: function(property)    {        if (!this.computedStyle || !this._usedProperties)            return false;        // These properties should always show for Computed Style.        var alwaysShowComputedProperties = { "display": true, "height": true, "width": true };        return !(property in this.usedProperties) && !(property in alwaysShowComputedProperties) && !(property in this.disabledComputedProperties);    },    isPropertyOverloaded: function(property, shorthand)    {        if (this.computedStyle || !this._usedProperties)            return false;        var used = (property in this.usedProperties);        if (used || !shorthand)            return !used;        // Find out if any of the individual longhand properties of the shorthand        // are used, if none are then the shorthand is overloaded too.        var longhandProperties = getLonghandProperties(this.styleRule.style, property);        for (var j = 0; j < longhandProperties.length; ++j) {            var individualProperty = longhandProperties[j];            if (individualProperty in this.usedProperties)                return false;        }        return true;    },    update: function(full)    {        if (full || this.computedStyle) {            this.propertiesTreeOutline.removeChildren();            this.populated = false;        } else {            var child = this.propertiesTreeOutline.children[0];            while (child) {                child.overloaded = this.isPropertyOverloaded(child.name, child.shorthand);                child = child.traverseNextTreeElement(false, null, true);            }        }    },    onpopulate: function()    {        var style = this.styleRule.style;        var foundShorthands = {};        var uniqueProperties = getUniqueStyleProperties(style);        var disabledProperties = style.__disabledPropertyValues || {};        for (var name in disabledProperties)            uniqueProperties.push(name);        uniqueProperties.sort();        for (var i = 0; i < uniqueProperties.length; ++i) {            var name = uniqueProperties[i];            var disabled = name in disabledProperties;            if (!disabled && this.disabledComputedProperties && !(name in this.usedProperties) && name in this.disabledComputedProperties)                disabled = true;            var shorthand = !disabled ? style.getPropertyShorthand(name) : null;            if (shorthand && shorthand in foundShorthands)                continue;            if (shorthand) {                foundShorthands[shorthand] = true;                name = shorthand;            }            var isShorthand = (shorthand ? true : false);            var inherited = this.isPropertyInherited(name);            var overloaded = this.isPropertyOverloaded(name, isShorthand);            var item = new WebInspector.StylePropertyTreeElement(style, name, isShorthand, inherited, overloaded, disabled);            this.propertiesTreeOutline.appendChild(item);        }    }}WebInspector.StylePropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype;WebInspector.StylePropertyTreeElement = function(style, name, shorthand, inherited, overloaded, disabled){    this.style = style;    this.name = name;    this.shorthand = shorthand;    this._inherited = inherited;    this._overloaded = overloaded;    this._disabled = disabled;    // Pass an empty title, the title gets made later in onattach.    TreeElement.call(this, "", null, shorthand);}WebInspector.StylePropertyTreeElement.prototype = {    get inherited()    {        return this._inherited;    },    set inherited(x)    {        if (x === this._inherited)            return;        this._inherited = x;        this.updateState();    },    get overloaded()    {        return this._overloaded;    },    set overloaded(x)    {        if (x === this._overloaded)            return;        this._overloaded = x;        this.updateState();    },    get disabled()    {        return this._disabled;    },    set disabled(x)    {        if (x === this._disabled)            return;        this._disabled = x;        this.updateState();    },    get priority()    {        if (this.disabled && this.style.__disabledPropertyPriorities && this.name in this.style.__disabledPropertyPriorities)            return this.style.__disabledPropertyPriorities[this.name];        return (this.shorthand ? getShorthandPriority(this.style, this.name) : this.style.getPropertyPriority(this.name));    },    get value()    {        if (this.disabled && this.style.__disabledPropertyValues && this.name in this.style.__disabledPropertyValues)            return this.style.__disabledPropertyValues[this.name];        return (this.shorthand ? getShorthandValue(this.style, this.name) : this.style.getPropertyValue(this.name));    },    onattach: function()    {        this.updateTitle();    },    updateTitle: function()    {        // "Nicknames" for some common values that are easier to read.        var valueNicknames = {            "rgb(0, 0, 0)": "black",            "#000": "black",            "#000000": "black",            "rgb(255, 255, 255)": "white",            "#fff": "white",            "#ffffff": "white",            "#FFF": "white",            "#FFFFFF": "white",            "rgba(0, 0, 0, 0)": "transparent",            "rgb(255, 0, 0)": "red",            "rgb(0, 255, 0)": "lime",            "rgb(0, 0, 255)": "blue",            "rgb(255, 255, 0)": "yellow",            "rgb(255, 0, 255)": "magenta",            "rgb(0, 255, 255)": "cyan"        };        var priority = this.priority;        var value = this.value;        var htmlValue = value;        if (priority && !priority.length)            delete priority;        if (priority)            priority = "!" + priority;        if (value) {            var urls = value.match(/url\([^)]+\)/);            if (urls) {                for (var i = 0; i < urls.length; ++i) {                    var url = urls[i].substring(4, urls[i].length - 1);                    htmlValue = htmlValue.replace(urls[i], "url(" + WebInspector.linkifyURL(url) + ")");                }            } else {                if (value in valueNicknames)                    htmlValue = valueNicknames[value];                htmlValue = htmlValue.escapeHTML();            }        } else            htmlValue = value = "";        this.updateState();        var enabledCheckboxElement = document.createElement("input");        enabledCheckboxElement.className = "enabled-button";        enabledCheckboxElement.type = "checkbox";        enabledCheckboxElement.checked = !this.disabled;        enabledCheckboxElement.addEventListener("change", this.toggleEnabled.bind(this), false);        var nameElement = document.createElement("span");        nameElement.className = "name";        nameElement.textContent = this.name;        var valueElement = document.createElement("span");        valueElement.className = "value";        valueElement.innerHTML = htmlValue;        if (priority) {            var priorityElement = document.createElement("span");            priorityElement.className = "priority";            priorityElement.textContent = priority;        }        this.listItemElement.removeChildren();        // Append the checkbox for root elements of an editable section.        if (this.treeOutline.section && this.treeOutline.section.editable && this.parent.root)            this.listItemElement.appendChild(enabledCheckboxElement);        this.listItemElement.appendChild(nameElement);        this.listItemElement.appendChild(document.createTextNode(": "));        this.listItemElement.appendChild(valueElement);        if (priorityElement) {            this.listItemElement.appendChild(document.createTextNode(" "));            this.listItemElement.appendChild(priorityElement);        }        this.listItemElement.appendChild(document.createTextNode(";"));        if (value) {            // FIXME: this dosen't catch keyword based colors like black and white            var colors = value.match(/((rgb|hsl)a?\([^)]+\))|(#[0-9a-fA-F]{6})|(#[0-9a-fA-F]{3})/g);            if (colors) {                var colorsLength = colors.length;                for (var i = 0; i < colorsLength; ++i) {                    var swatchElement = document.createElement("span");                    swatchElement.className = "swatch";                    swatchElement.style.setProperty("background-color", colors[i]);                    this.listItemElement.appendChild(swatchElement);                }            }        }        this.tooltip = this.name + ": " + (valueNicknames[value] || value) + (priority ? " " + priority : "");    },    updateAll: function(updateAllRules)    {        if (updateAllRules && this.treeOutline.section && this.treeOutline.section.pane)            this.treeOutline.section.pane.update(null, this.treeOutline.section);        else if (this.treeOutline.section)            this.treeOutline.section.update(true);        else            this.updateTitle(); // FIXME: this will not show new properties. But we don't hit his case yet.    },    toggleEnabled: function(event)    {        var disabled = !event.target.checked;        if (disabled) {            if (!this.style.__disabledPropertyValues || !this.style.__disabledPropertyPriorities) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -