Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * @param {!WebInspector.CSSRule} editedRule | 250 * @param {!WebInspector.CSSRule} editedRule |
| 251 * @param {!WebInspector.TextRange} oldRange | 251 * @param {!WebInspector.TextRange} oldRange |
| 252 * @param {!WebInspector.TextRange} newRange | 252 * @param {!WebInspector.TextRange} newRange |
| 253 */ | 253 */ |
| 254 _styleSheetRuleEdited: function(editedRule, oldRange, newRange) | 254 _styleSheetRuleEdited: function(editedRule, oldRange, newRange) |
| 255 { | 255 { |
| 256 if (!editedRule.styleSheetId) | 256 if (!editedRule.styleSheetId) |
| 257 return; | 257 return; |
| 258 for (var pseudoId in this.sections) { | 258 for (var block of this._sectionBlocks) { |
| 259 var styleRuleSections = this.sections[pseudoId]; | 259 for (var section of block.sections()) |
| 260 for (var i = 0; i < styleRuleSections.length; ++i) { | |
| 261 var section = styleRuleSections[i]; | |
| 262 if (section.computedStyle) | |
| 263 continue; | |
| 264 section._styleSheetRuleEdited(editedRule, oldRange, newRange); | 260 section._styleSheetRuleEdited(editedRule, oldRange, newRange); |
| 265 } | |
| 266 } | 261 } |
| 267 }, | 262 }, |
| 268 | 263 |
| 269 /** | 264 /** |
| 270 * @param {!WebInspector.CSSMedia} oldMedia | 265 * @param {!WebInspector.CSSMedia} oldMedia |
| 271 * @param {!WebInspector.CSSMedia} newMedia | 266 * @param {!WebInspector.CSSMedia} newMedia |
| 272 */ | 267 */ |
| 273 _styleSheetMediaEdited: function(oldMedia, newMedia) | 268 _styleSheetMediaEdited: function(oldMedia, newMedia) |
| 274 { | 269 { |
| 275 if (!oldMedia.parentStyleSheetId) | 270 if (!oldMedia.parentStyleSheetId) |
| 276 return; | 271 return; |
| 277 for (var pseudoId in this.sections) { | 272 for (var block of this._sectionBlocks) { |
| 278 var styleRuleSections = this.sections[pseudoId]; | 273 for (var section of block.sections()) |
| 279 for (var i = 0; i < styleRuleSections.length; ++i) { | |
| 280 var section = styleRuleSections[i]; | |
| 281 if (section.computedStyle) | |
| 282 continue; | |
| 283 section._styleSheetMediaEdited(oldMedia, newMedia); | 274 section._styleSheetMediaEdited(oldMedia, newMedia); |
| 284 } | |
| 285 } | 275 } |
| 286 }, | 276 }, |
| 287 | 277 |
| 288 /** | 278 /** |
| 289 * @param {!Event} event | 279 * @param {!Event} event |
| 290 */ | 280 */ |
| 291 _contextMenuEventFired: function(event) | 281 _contextMenuEventFired: function(event) |
| 292 { | 282 { |
| 293 // We start editing upon click -> default navigation to resources panel is not available | 283 // We start editing upon click -> default navigation to resources panel is not available |
| 294 // Hence we add a soft context menu for hrefs. | 284 // Hence we add a soft context menu for hrefs. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.FrameResized, this._frameResized, this); | 392 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.FrameResized, this._frameResized, this); |
| 403 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); | 393 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); |
| 404 this._updateAnimationsPlaybackRate(); | 394 this._updateAnimationsPlaybackRate(); |
| 405 }, | 395 }, |
| 406 | 396 |
| 407 /** | 397 /** |
| 408 * @param {!WebInspector.StylePropertiesSection=} editedSection | 398 * @param {!WebInspector.StylePropertiesSection=} editedSection |
| 409 */ | 399 */ |
| 410 _refreshUpdate: function(editedSection) | 400 _refreshUpdate: function(editedSection) |
| 411 { | 401 { |
| 412 var node = this._validateNode(); | 402 var node = this.node(); |
| 413 if (!node) | 403 if (!node) |
| 414 return; | 404 return; |
| 415 | 405 |
| 416 this._innerRefreshUpdate(node, editedSection); | 406 for (var block of this._sectionBlocks) { |
| 407 for (var section of block.sections()) { | |
| 408 if (section.isBlank) | |
| 409 continue; | |
| 410 section.update(section === editedSection); | |
| 411 } | |
| 412 } | |
| 413 | |
| 414 this._computedStylePane.update(); | |
| 417 if (this._filterRegex) | 415 if (this._filterRegex) |
| 418 this._updateFilter(); | 416 this._updateFilter(); |
| 417 this._nodeStylesUpdatedForTest(node, false); | |
| 419 }, | 418 }, |
| 420 | 419 |
| 421 /** | 420 /** |
| 422 * @override | 421 * @override |
| 423 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | 422 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback |
| 424 */ | 423 */ |
| 425 doUpdate: function(finishedCallback) | 424 doUpdate: function(finishedCallback) |
| 426 { | 425 { |
| 427 this._updateForcedPseudoStateInputs(); | 426 this._updateForcedPseudoStateInputs(); |
| 428 | 427 |
| 429 var node = this._validateNode(); | |
| 430 if (!node) { | |
| 431 finishedCallback(); | |
| 432 return; | |
| 433 } | |
| 434 | |
| 435 this._fetchMatchedCascade() | 428 this._fetchMatchedCascade() |
| 436 .then(this._innerRebuildUpdate.bind(this)) | 429 .then(this._innerRebuildUpdate.bind(this)) |
| 437 .then(finishedCallback); | 430 .then(finishedCallback); |
| 438 }, | 431 }, |
| 439 | 432 |
| 440 _resetCache: function() | 433 _resetCache: function() |
| 441 { | 434 { |
| 442 delete this._matchedCascadePromise; | 435 delete this._matchedCascadePromise; |
| 443 this._resetComputedCache(); | 436 this._resetComputedCache(); |
| 444 }, | 437 }, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 var keyframes = player.source().keyframesRule().keyframes(); | 601 var keyframes = player.source().keyframesRule().keyframes(); |
| 609 for (var j = 0; j < keyframes.length; j++) | 602 for (var j = 0; j < keyframes.length; j++) |
| 610 animationCascade.appendModelFromStyle(keyframes[j].style(), ""); | 603 animationCascade.appendModelFromStyle(keyframes[j].style(), ""); |
| 611 for (var property of animationCascade.allUsedProperties()) | 604 for (var property of animationCascade.allUsedProperties()) |
| 612 animationProperties.set(property, player.name()); | 605 animationProperties.set(property, player.name()); |
| 613 } | 606 } |
| 614 callback(animationProperties); | 607 callback(animationProperties); |
| 615 } | 608 } |
| 616 }, | 609 }, |
| 617 | 610 |
| 618 _validateNode: function() | |
| 619 { | |
| 620 if (!this.node()) { | |
| 621 this._sectionsContainer.removeChildren(); | |
| 622 this.sections = {}; | |
| 623 return null; | |
| 624 } | |
| 625 return this.node(); | |
| 626 }, | |
| 627 | |
| 628 /** | 611 /** |
| 629 * @param {boolean} editing | 612 * @param {boolean} editing |
| 630 */ | 613 */ |
| 631 setEditingStyle: function(editing) | 614 setEditingStyle: function(editing) |
| 632 { | 615 { |
| 633 this._isEditingStyle = editing; | 616 this._isEditingStyle = editing; |
| 634 }, | 617 }, |
| 635 | 618 |
| 636 _styleSheetOrMediaQueryResultChanged: function() | 619 _styleSheetOrMediaQueryResultChanged: function() |
| 637 { | 620 { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 /** | 666 /** |
| 684 * @param {?WebInspector.DOMNode} node | 667 * @param {?WebInspector.DOMNode} node |
| 685 */ | 668 */ |
| 686 _canAffectCurrentStyles: function(node) | 669 _canAffectCurrentStyles: function(node) |
| 687 { | 670 { |
| 688 var currentNode = this.node(); | 671 var currentNode = this.node(); |
| 689 return currentNode && (currentNode === node || node.parentNode === curre ntNode.parentNode || node.isAncestor(currentNode)); | 672 return currentNode && (currentNode === node || node.parentNode === curre ntNode.parentNode || node.isAncestor(currentNode)); |
| 690 }, | 673 }, |
| 691 | 674 |
| 692 /** | 675 /** |
| 693 * @param {!WebInspector.DOMNode} node | |
| 694 * @param {!WebInspector.StylePropertiesSection=} editedSection | |
| 695 */ | |
| 696 _innerRefreshUpdate: function(node, editedSection) | |
| 697 { | |
| 698 for (var pseudoId in this.sections) { | |
| 699 var sections = this.sections[pseudoId].filter(nonBlankSections); | |
| 700 for (var section of sections) | |
| 701 section.update(section === editedSection); | |
| 702 } | |
| 703 | |
| 704 this._computedStylePane.update(); | |
| 705 | |
| 706 this._nodeStylesUpdatedForTest(node, false); | |
| 707 | |
| 708 /** | |
| 709 * @param {!WebInspector.StylePropertiesSection} section | |
| 710 * @return {boolean} | |
| 711 */ | |
| 712 function nonBlankSections(section) | |
| 713 { | |
| 714 return !section.isBlank; | |
| 715 } | |
| 716 }, | |
| 717 | |
| 718 /** | |
| 719 * @param {?{matched: !WebInspector.SectionCascade, pseudo: !Map.<number, !W ebInspector.SectionCascade>}} cascades | 676 * @param {?{matched: !WebInspector.SectionCascade, pseudo: !Map.<number, !W ebInspector.SectionCascade>}} cascades |
| 720 */ | 677 */ |
| 721 _innerRebuildUpdate: function(cascades) | 678 _innerRebuildUpdate: function(cascades) |
| 722 { | 679 { |
| 723 this._linkifier.reset(); | 680 this._linkifier.reset(); |
| 724 this._sectionsContainer.removeChildren(); | 681 this._sectionsContainer.removeChildren(); |
| 725 this.sections = {}; | 682 this._sectionBlocks = []; |
| 726 | 683 |
| 727 var node = this.node(); | 684 var node = this.node(); |
| 728 if (!cascades || !node) | 685 if (!cascades || !node) |
| 729 return; | 686 return; |
| 730 | 687 |
| 688 this._sectionBlocks = this._rebuildSectionsForMatchedStyleRules(cascades .matched); | |
| 689 var pseudoIds = cascades.pseudo.keysArray().sort(); | |
| 690 for (var pseudoId of pseudoIds) { | |
| 691 var block = WebInspector.SectionBlock.createPseudoIdBlock(pseudoId); | |
| 692 var cascade = cascades.pseudo.get(pseudoId); | |
| 693 for (sectionModel of cascade.sectionModels()) { | |
| 694 var section = new WebInspector.StylePropertiesSection(this, sect ionModel); | |
| 695 block.appendSection(section); | |
| 696 } | |
| 697 this._sectionBlocks.push(block); | |
| 698 } | |
| 699 | |
| 731 if (!!node.pseudoType()) | 700 if (!!node.pseudoType()) |
| 732 this._appendTopPadding(); | 701 this._appendTopPadding(); |
| 733 | 702 |
| 734 this.sections[0] = this._rebuildSectionsForStyleRules(cascades.matched); | 703 for (var block of this._sectionBlocks) { |
| 735 this._computedStylePane.update(); | 704 var titleElement = block.titleElement(); |
| 736 | 705 if (titleElement) |
| 737 var pseudoIds = cascades.pseudo.keysArray().sort(); | 706 this._sectionsContainer.appendChild(titleElement); |
| 738 for (var pseudoId of pseudoIds) { | 707 for (var section of block.sections()) |
| 739 this._appendSectionPseudoIdSeparator(pseudoId); | 708 this._sectionsContainer.appendChild(section.element); |
| 740 this.sections[pseudoId] = this._rebuildSectionsForStyleRules(cascade s.pseudo.get(pseudoId)); | |
| 741 } | 709 } |
| 742 | 710 |
| 743 if (this._filterRegex) | 711 if (this._filterRegex) |
| 744 this._updateFilter(); | 712 this._updateFilter(); |
| 745 | 713 |
| 746 this._nodeStylesUpdatedForTest(node, true); | 714 this._nodeStylesUpdatedForTest(node, true); |
| 715 this._computedStylePane.update(); | |
| 747 }, | 716 }, |
| 748 | 717 |
| 749 /** | 718 /** |
| 750 * @param {!WebInspector.DOMNode} node | 719 * @param {!WebInspector.DOMNode} node |
| 751 * @param {!WebInspector.StylesSidebarPane.MatchedRulesPayload} styles | 720 * @param {!WebInspector.StylesSidebarPane.MatchedRulesPayload} styles |
| 752 * @return {!Map<number, !WebInspector.SectionCascade>} | 721 * @return {!Map<number, !WebInspector.SectionCascade>} |
| 753 */ | 722 */ |
| 754 _buildPseudoCascades: function(node, styles) | 723 _buildPseudoCascades: function(node, styles) |
| 755 { | 724 { |
| 756 var pseudoCascades = new Map(); | 725 var pseudoCascades = new Map(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 }, | 809 }, |
| 841 | 810 |
| 842 _appendTopPadding: function() | 811 _appendTopPadding: function() |
| 843 { | 812 { |
| 844 var separatorElement = createElement("div"); | 813 var separatorElement = createElement("div"); |
| 845 separatorElement.className = "styles-sidebar-placeholder"; | 814 separatorElement.className = "styles-sidebar-placeholder"; |
| 846 this._sectionsContainer.appendChild(separatorElement); | 815 this._sectionsContainer.appendChild(separatorElement); |
| 847 }, | 816 }, |
| 848 | 817 |
| 849 /** | 818 /** |
| 850 * @param {number} pseudoId | 819 * @param {!WebInspector.SectionCascade} matchedCascade |
| 820 * @return {!Array.<!WebInspector.SectionBlock>} | |
| 851 */ | 821 */ |
| 852 _appendSectionPseudoIdSeparator: function(pseudoId) | 822 _rebuildSectionsForMatchedStyleRules: function(matchedCascade) |
| 853 { | 823 { |
| 854 var separatorElement = createElement("div"); | 824 var blocks = [new WebInspector.SectionBlock(null)]; |
| 855 separatorElement.className = "sidebar-separator"; | 825 var lastParentNode = null; |
| 856 var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId]; | 826 for (var sectionModel of matchedCascade.sectionModels()) { |
| 857 if (pseudoName) | 827 var parentNode = sectionModel.parentNode(); |
| 858 separatorElement.textContent = WebInspector.UIString("Pseudo ::%s el ement", pseudoName); | 828 if (parentNode && parentNode !== lastParentNode) { |
| 859 else | 829 lastParentNode = parentNode; |
| 860 separatorElement.textContent = WebInspector.UIString("Pseudo element "); | 830 var block = WebInspector.SectionBlock.createInheritedNodeBlock(l astParentNode); |
| 861 this._sectionsContainer.appendChild(separatorElement); | 831 blocks.push(block); |
| 832 } | |
| 833 | |
| 834 var section = new WebInspector.StylePropertiesSection(this, sectionM odel); | |
| 835 blocks.peekLast().appendSection(section); | |
| 836 } | |
| 837 return blocks; | |
| 862 }, | 838 }, |
| 863 | 839 |
| 864 /** | 840 /** |
| 865 * @param {!WebInspector.DOMNode} node | |
| 866 */ | |
| 867 _appendSectionInheritedNodeSeparator: function(node) | |
| 868 { | |
| 869 var separatorElement = createElement("div"); | |
| 870 separatorElement.className = "sidebar-separator"; | |
| 871 var link = WebInspector.DOMPresentationUtils.linkifyNodeReference(node); | |
| 872 separatorElement.createTextChild(WebInspector.UIString("Inherited from") + " "); | |
| 873 separatorElement.appendChild(link); | |
| 874 this._sectionsContainer.appendChild(separatorElement); | |
| 875 }, | |
| 876 | |
| 877 /** | |
| 878 * @param {!WebInspector.SectionCascade} cascade | |
| 879 * @return {!Array.<!WebInspector.StylePropertiesSection>} | |
| 880 */ | |
| 881 _rebuildSectionsForStyleRules: function(cascade) | |
| 882 { | |
| 883 var sections = []; | |
| 884 var lastParentNode = null; | |
| 885 for (var sectionModel of cascade.sectionModels()) { | |
| 886 var parentNode = sectionModel.parentNode(); | |
| 887 if (parentNode && parentNode !== lastParentNode) { | |
| 888 lastParentNode = parentNode; | |
| 889 this._appendSectionInheritedNodeSeparator(lastParentNode); | |
| 890 } | |
| 891 | |
| 892 var section = new WebInspector.StylePropertiesSection(this, sectionM odel); | |
| 893 section._markSelectorMatches(); | |
| 894 section.onpopulate(); | |
| 895 this._sectionsContainer.appendChild(section.element); | |
| 896 sections.push(section); | |
| 897 } | |
| 898 return sections; | |
| 899 }, | |
| 900 | |
| 901 /** | |
| 902 * @param {!WebInspector.CSSStyleDeclaration} style | 841 * @param {!WebInspector.CSSStyleDeclaration} style |
| 903 * @return {boolean} | 842 * @return {boolean} |
| 904 */ | 843 */ |
| 905 _containsInherited: function(style) | 844 _containsInherited: function(style) |
| 906 { | 845 { |
| 907 var properties = style.allProperties; | 846 var properties = style.allProperties; |
| 908 for (var i = 0; i < properties.length; ++i) { | 847 for (var i = 0; i < properties.length; ++i) { |
| 909 var property = properties[i]; | 848 var property = properties[i]; |
| 910 // Does this style contain non-overridden inherited property? | 849 // Does this style contain non-overridden inherited property? |
| 911 if (property.isLive && WebInspector.CSSMetadata.isPropertyInherited( property.name)) | 850 if (property.isLive && WebInspector.CSSMetadata.isPropertyInherited( property.name)) |
| 912 return true; | 851 return true; |
| 913 } | 852 } |
| 914 return false; | 853 return false; |
| 915 }, | 854 }, |
| 916 | 855 |
| 917 /** | 856 /** |
| 918 * @param {!WebInspector.Event} event | 857 * @param {!WebInspector.Event} event |
| 919 */ | 858 */ |
| 920 _colorFormatSettingChanged: function(event) | 859 _colorFormatSettingChanged: function(event) |
| 921 { | 860 { |
| 922 for (var pseudoId in this.sections) { | 861 for (var block of this._sectionBlocks) { |
| 923 var sections = this.sections[pseudoId]; | 862 for (var section of block.sections()) |
| 924 for (var i = 0; i < sections.length; ++i) | 863 section.update(true); |
| 925 sections[i].update(true); | |
| 926 } | 864 } |
| 927 }, | 865 }, |
| 928 | 866 |
| 929 /** | 867 /** |
| 930 * @param {?Event} event | 868 * @param {?Event} event |
| 931 */ | 869 */ |
| 932 _createNewRuleInViaInspectorStyleSheet: function(event) | 870 _createNewRuleInViaInspectorStyleSheet: function(event) |
| 933 { | 871 { |
| 934 var cssModel = this._target.cssModel; | 872 var cssModel = this._target.cssModel; |
| 935 this._userOperation = true; | 873 this._userOperation = true; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 957 | 895 |
| 958 /** | 896 /** |
| 959 * @param {string} styleSheetId | 897 * @param {string} styleSheetId |
| 960 * @param {string} text | 898 * @param {string} text |
| 961 * @this {WebInspector.StylesSidebarPane} | 899 * @this {WebInspector.StylesSidebarPane} |
| 962 */ | 900 */ |
| 963 function onStyleSheetContent(styleSheetId, text) | 901 function onStyleSheetContent(styleSheetId, text) |
| 964 { | 902 { |
| 965 var lines = text.split("\n"); | 903 var lines = text.split("\n"); |
| 966 var range = WebInspector.TextRange.createFromLocation(lines.length - 1, lines[lines.length - 1].length); | 904 var range = WebInspector.TextRange.createFromLocation(lines.length - 1, lines[lines.length - 1].length); |
| 967 this._addBlankSection(this.sections[0][0], styleSheetId, range); | 905 this._addBlankSection(this._sectionBlocks[0].sections()[0], styleShe etId, range); |
| 968 } | 906 } |
| 969 }, | 907 }, |
| 970 | 908 |
| 971 /** | 909 /** |
| 972 * @param {!WebInspector.StylePropertiesSection} insertAfterSection | 910 * @param {!WebInspector.StylePropertiesSection} insertAfterSection |
| 973 * @param {string} styleSheetId | 911 * @param {string} styleSheetId |
| 974 * @param {!WebInspector.TextRange} ruleLocation | 912 * @param {!WebInspector.TextRange} ruleLocation |
| 975 */ | 913 */ |
| 976 _addBlankSection: function(insertAfterSection, styleSheetId, ruleLocation) | 914 _addBlankSection: function(insertAfterSection, styleSheetId, ruleLocation) |
| 977 { | 915 { |
| 978 this.expand(); | 916 this.expand(); |
| 979 var node = this.node(); | 917 var node = this.node(); |
| 980 var blankSection = new WebInspector.BlankStylePropertiesSection(this, no de ? WebInspector.DOMPresentationUtils.simpleSelector(node) : "", styleSheetId, ruleLocation, insertAfterSection.styleRule); | 918 var blankSection = new WebInspector.BlankStylePropertiesSection(this, no de ? WebInspector.DOMPresentationUtils.simpleSelector(node) : "", styleSheetId, ruleLocation, insertAfterSection.styleRule); |
| 981 | 919 |
| 982 this._sectionsContainer.insertBefore(blankSection.element, insertAfterSe ction.element.nextSibling); | 920 this._sectionsContainer.insertBefore(blankSection.element, insertAfterSe ction.element.nextSibling); |
| 983 | 921 |
| 984 var index = this.sections[0].indexOf(insertAfterSection); | 922 for (var block of this._sectionBlocks) { |
| 985 this.sections[0].splice(index + 1, 0, blankSection); | 923 var index = block.findSection(insertAfterSection); |
| 986 blankSection.startEditingSelector(); | 924 if (index === -1) |
| 925 continue; | |
| 926 block.insertSection(blankSection, index + 1); | |
| 927 blankSection.startEditingSelector(); | |
| 928 } | |
| 987 }, | 929 }, |
| 988 | 930 |
| 989 /** | 931 /** |
| 990 * @param {!WebInspector.StylePropertiesSection} section | 932 * @param {!WebInspector.StylePropertiesSection} section |
| 991 */ | 933 */ |
| 992 removeSection: function(section) | 934 removeSection: function(section) |
| 993 { | 935 { |
| 994 for (var pseudoId in this.sections) { | 936 for (var block of this._sectionBlocks) { |
| 995 var sections = this.sections[pseudoId]; | 937 var index = block.findSection(section); |
| 996 var index = sections.indexOf(section); | |
| 997 if (index === -1) | 938 if (index === -1) |
| 998 continue; | 939 continue; |
| 999 sections.splice(index, 1); | 940 block.removeSection(index); |
| 1000 section.element.remove(); | 941 section.element.remove(); |
| 1001 } | 942 } |
| 1002 }, | 943 }, |
| 1003 | 944 |
| 1004 /** | 945 /** |
| 1005 * @param {!Event} event | 946 * @param {!Event} event |
| 1006 */ | 947 */ |
| 1007 _toggleElementStatePane: function(event) | 948 _toggleElementStatePane: function(event) |
| 1008 { | 949 { |
| 1009 event.consume(); | 950 event.consume(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1025 | 966 |
| 1026 var inputs = []; | 967 var inputs = []; |
| 1027 this._elementStatePane.inputs = inputs; | 968 this._elementStatePane.inputs = inputs; |
| 1028 | 969 |
| 1029 /** | 970 /** |
| 1030 * @param {!Event} event | 971 * @param {!Event} event |
| 1031 * @this {WebInspector.StylesSidebarPane} | 972 * @this {WebInspector.StylesSidebarPane} |
| 1032 */ | 973 */ |
| 1033 function clickListener(event) | 974 function clickListener(event) |
| 1034 { | 975 { |
| 1035 var node = this._validateNode(); | 976 var node = this.node(); |
| 1036 if (!node) | 977 if (!node) |
| 1037 return; | 978 return; |
| 1038 node.target().cssModel.forcePseudoState(node, event.target.state, ev ent.target.checked); | 979 node.target().cssModel.forcePseudoState(node, event.target.state, ev ent.target.checked); |
| 1039 } | 980 } |
| 1040 | 981 |
| 1041 /** | 982 /** |
| 1042 * @param {string} state | 983 * @param {string} state |
| 1043 * @return {!Element} | 984 * @return {!Element} |
| 1044 * @this {WebInspector.StylesSidebarPane} | 985 * @this {WebInspector.StylesSidebarPane} |
| 1045 */ | 986 */ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 /** | 1099 /** |
| 1159 * @return {?RegExp} | 1100 * @return {?RegExp} |
| 1160 */ | 1101 */ |
| 1161 filterRegex: function() | 1102 filterRegex: function() |
| 1162 { | 1103 { |
| 1163 return this._filterRegex; | 1104 return this._filterRegex; |
| 1164 }, | 1105 }, |
| 1165 | 1106 |
| 1166 _updateFilter: function() | 1107 _updateFilter: function() |
| 1167 { | 1108 { |
| 1168 for (var pseudoId in this.sections) { | 1109 for (var block of this._sectionBlocks) { |
| 1169 var sections = this.sections[pseudoId]; | 1110 for (var section of block.sections()) |
| 1170 for (var i = 0; i < sections.length; ++i) { | |
| 1171 var section = sections[i]; | |
| 1172 section._updateFilter(); | 1111 section._updateFilter(); |
| 1173 } | |
| 1174 } | 1112 } |
| 1175 }, | 1113 }, |
| 1176 | 1114 |
| 1177 /** | 1115 /** |
| 1178 * @override | 1116 * @override |
| 1179 */ | 1117 */ |
| 1180 wasShown: function() | 1118 wasShown: function() |
| 1181 { | 1119 { |
| 1182 WebInspector.ElementsSidebarPane.prototype.wasShown.call(this); | 1120 WebInspector.ElementsSidebarPane.prototype.wasShown.call(this); |
| 1183 this.element.ownerDocument.body.addEventListener("keydown", this._keyDow nBound, false); | 1121 this.element.ownerDocument.body.addEventListener("keydown", this._keyDow nBound, false); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1284 input.value = value; | 1222 input.value = value; |
| 1285 input.focus(); | 1223 input.focus(); |
| 1286 searchHandler(); | 1224 searchHandler(); |
| 1287 } | 1225 } |
| 1288 | 1226 |
| 1289 return input; | 1227 return input; |
| 1290 } | 1228 } |
| 1291 | 1229 |
| 1292 /** | 1230 /** |
| 1293 * @constructor | 1231 * @constructor |
| 1232 * @param {?Element} titleElement | |
| 1233 */ | |
| 1234 WebInspector.SectionBlock = function(titleElement) | |
| 1235 { | |
| 1236 this._titleElement = titleElement; | |
| 1237 this._sections = []; | |
| 1238 } | |
| 1239 | |
| 1240 /** | |
| 1241 * @param {number} pseudoId | |
| 1242 * @return {!WebInspector.SectionBlock} | |
| 1243 */ | |
| 1244 WebInspector.SectionBlock.createPseudoIdBlock = function(pseudoId) | |
| 1245 { | |
| 1246 var separatorElement = createElement("div"); | |
| 1247 separatorElement.className = "sidebar-separator"; | |
| 1248 var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId]; | |
| 1249 if (pseudoName) | |
| 1250 separatorElement.textContent = WebInspector.UIString("Pseudo ::%s elemen t", pseudoName); | |
| 1251 else | |
| 1252 separatorElement.textContent = WebInspector.UIString("Pseudo element"); | |
| 1253 return new WebInspector.SectionBlock(separatorElement); | |
| 1254 } | |
| 1255 | |
| 1256 /** | |
| 1257 * @param {!WebInspector.DOMNode} node | |
| 1258 * @return {!WebInspector.SectionBlock} | |
| 1259 */ | |
| 1260 WebInspector.SectionBlock.createInheritedNodeBlock = function(node) | |
| 1261 { | |
| 1262 var separatorElement = createElement("div"); | |
| 1263 separatorElement.className = "sidebar-separator"; | |
| 1264 var link = WebInspector.DOMPresentationUtils.linkifyNodeReference(node); | |
| 1265 separatorElement.createTextChild(WebInspector.UIString("Inherited from") + " "); | |
| 1266 separatorElement.appendChild(link); | |
| 1267 return new WebInspector.SectionBlock(separatorElement); | |
| 1268 } | |
| 1269 | |
| 1270 WebInspector.SectionBlock.prototype = { | |
| 1271 /** | |
| 1272 * @return {?Element} | |
| 1273 */ | |
| 1274 titleElement: function() | |
| 1275 { | |
| 1276 return this._titleElement; | |
| 1277 }, | |
| 1278 | |
| 1279 /** | |
| 1280 * @param {!WebInspector.StylePropertiesSection} section | |
| 1281 */ | |
| 1282 appendSection: function(section) | |
|
pfeldman
2015/03/13 17:53:33
You encapsulate nothing. Lets remove these.
lushnikov
2015/03/13 18:08:08
Done.
| |
| 1283 { | |
| 1284 this._sections.push(section); | |
| 1285 }, | |
| 1286 | |
| 1287 /** | |
| 1288 * @return {!Array.<!WebInspector.StylePropertiesSection>} | |
| 1289 */ | |
| 1290 sections: function() | |
| 1291 { | |
| 1292 return this._sections; | |
| 1293 }, | |
| 1294 | |
| 1295 /** | |
| 1296 * @param {!WebInspector.StylePropertiesSection} section | |
| 1297 * @return {number} | |
| 1298 */ | |
| 1299 findSection: function(section) | |
| 1300 { | |
| 1301 return this._sections.indexOf(section); | |
| 1302 }, | |
| 1303 | |
| 1304 /** | |
| 1305 * @param {!WebInspector.StylePropertiesSection} section | |
| 1306 * @param {number} position | |
| 1307 */ | |
| 1308 insertSection: function(section, position) | |
| 1309 { | |
| 1310 this._sections.splice(position, 0, section); | |
| 1311 }, | |
| 1312 | |
| 1313 /** | |
| 1314 * @param {number} position | |
| 1315 */ | |
| 1316 removeSection: function(position) | |
| 1317 { | |
| 1318 this._sections.splice(position, 1); | |
| 1319 } | |
| 1320 } | |
| 1321 | |
| 1322 /** | |
| 1323 * @constructor | |
| 1294 * @param {!WebInspector.StylesSidebarPane} parentPane | 1324 * @param {!WebInspector.StylesSidebarPane} parentPane |
| 1295 * @param {!WebInspector.StylesSectionModel} styleRule | 1325 * @param {!WebInspector.StylesSectionModel} styleRule |
| 1296 */ | 1326 */ |
| 1297 WebInspector.StylePropertiesSection = function(parentPane, styleRule) | 1327 WebInspector.StylePropertiesSection = function(parentPane, styleRule) |
| 1298 { | 1328 { |
| 1299 this._parentPane = parentPane; | 1329 this._parentPane = parentPane; |
| 1300 this.styleRule = styleRule; | 1330 this.styleRule = styleRule; |
| 1301 this.editable = styleRule.editable(); | 1331 this.editable = styleRule.editable(); |
| 1302 | 1332 |
| 1303 var rule = styleRule.rule(); | 1333 var rule = styleRule.rule(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1353 this._updateRuleOrigin(); | 1383 this._updateRuleOrigin(); |
| 1354 selectorContainer.insertBefore(this._selectorRefElement, selectorContainer.f irstChild); | 1384 selectorContainer.insertBefore(this._selectorRefElement, selectorContainer.f irstChild); |
| 1355 this.titleElement.appendChild(selectorContainer); | 1385 this.titleElement.appendChild(selectorContainer); |
| 1356 this._selectorContainer = selectorContainer; | 1386 this._selectorContainer = selectorContainer; |
| 1357 | 1387 |
| 1358 if (this.navigable) | 1388 if (this.navigable) |
| 1359 this.element.classList.add("navigable"); | 1389 this.element.classList.add("navigable"); |
| 1360 | 1390 |
| 1361 if (!this.editable) | 1391 if (!this.editable) |
| 1362 this.element.classList.add("read-only"); | 1392 this.element.classList.add("read-only"); |
| 1393 | |
| 1394 this._markSelectorMatches(); | |
| 1395 this.onpopulate(); | |
| 1363 } | 1396 } |
| 1364 | 1397 |
| 1365 WebInspector.StylePropertiesSection.prototype = { | 1398 WebInspector.StylePropertiesSection.prototype = { |
| 1366 /** | 1399 /** |
| 1367 * @return {?WebInspector.StylePropertiesSection} | 1400 * @return {?WebInspector.StylePropertiesSection} |
| 1368 */ | 1401 */ |
| 1369 firstSibling: function() | 1402 firstSibling: function() |
| 1370 { | 1403 { |
| 1371 var parent = this.element.parentElement; | 1404 var parent = this.element.parentElement; |
| 1372 if (!parent) | 1405 if (!parent) |
| (...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3596 | 3629 |
| 3597 WebInspector.StylesSidebarPane.MatchedRulesPayload.prototype = { | 3630 WebInspector.StylesSidebarPane.MatchedRulesPayload.prototype = { |
| 3598 /** | 3631 /** |
| 3599 * @return {boolean} | 3632 * @return {boolean} |
| 3600 */ | 3633 */ |
| 3601 fulfilled: function() | 3634 fulfilled: function() |
| 3602 { | 3635 { |
| 3603 return !!(this.matchedCSSRules && this.pseudoElements && this.inherited) ; | 3636 return !!(this.matchedCSSRules && this.pseudoElements && this.inherited) ; |
| 3604 } | 3637 } |
| 3605 } | 3638 } |
| OLD | NEW |