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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); | 44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); |
45 | 45 |
46 this.element.classList.add("styles-pane"); | 46 this.element.classList.add("styles-pane"); |
47 | 47 |
48 /** @type {!Array<!WebInspector.SectionBlock>} */ | 48 /** @type {!Array<!WebInspector.SectionBlock>} */ |
49 this._sectionBlocks = []; | 49 this._sectionBlocks = []; |
50 WebInspector.StylesSidebarPane._instance = this; | 50 WebInspector.StylesSidebarPane._instance = this; |
51 | 51 |
52 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec
tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this); | 52 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec
tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this); |
53 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.forc
eUpdate, this); | 53 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.forc
eUpdate, this); |
54 } | 54 }; |
55 | 55 |
56 /** | 56 /** |
57 * @param {!WebInspector.CSSProperty} property | 57 * @param {!WebInspector.CSSProperty} property |
58 * @return {!Element} | 58 * @return {!Element} |
59 */ | 59 */ |
60 WebInspector.StylesSidebarPane.createExclamationMark = function(property) | 60 WebInspector.StylesSidebarPane.createExclamationMark = function(property) |
61 { | 61 { |
62 var exclamationElement = createElement("label", "dt-icon-label"); | 62 var exclamationElement = createElement("label", "dt-icon-label"); |
63 exclamationElement.className = "exclamation-mark"; | 63 exclamationElement.className = "exclamation-mark"; |
64 if (!WebInspector.StylesSidebarPane.ignoreErrorsForProperty(property)) | 64 if (!WebInspector.StylesSidebarPane.ignoreErrorsForProperty(property)) |
65 exclamationElement.type = "warning-icon"; | 65 exclamationElement.type = "warning-icon"; |
66 exclamationElement.title = WebInspector.cssMetadata().isCSSPropertyName(prop
erty.name) ? WebInspector.UIString("Invalid property value") : WebInspector.UISt
ring("Unknown property name"); | 66 exclamationElement.title = WebInspector.cssMetadata().isCSSPropertyName(prop
erty.name) ? WebInspector.UIString("Invalid property value") : WebInspector.UISt
ring("Unknown property name"); |
67 return exclamationElement; | 67 return exclamationElement; |
68 } | 68 }; |
69 | 69 |
70 /** | 70 /** |
71 * @param {!WebInspector.CSSProperty} property | 71 * @param {!WebInspector.CSSProperty} property |
72 * @return {boolean} | 72 * @return {boolean} |
73 */ | 73 */ |
74 WebInspector.StylesSidebarPane.ignoreErrorsForProperty = function(property) { | 74 WebInspector.StylesSidebarPane.ignoreErrorsForProperty = function(property) { |
75 /** | 75 /** |
76 * @param {string} string | 76 * @param {string} string |
77 */ | 77 */ |
78 function hasUnknownVendorPrefix(string) | 78 function hasUnknownVendorPrefix(string) |
(...skipping 19 matching lines...) Expand all Loading... |
98 | 98 |
99 var value = property.value.toLowerCase(); | 99 var value = property.value.toLowerCase(); |
100 | 100 |
101 // IE hack. | 101 // IE hack. |
102 if (value.endsWith("\9")) | 102 if (value.endsWith("\9")) |
103 return true; | 103 return true; |
104 if (hasUnknownVendorPrefix(value)) | 104 if (hasUnknownVendorPrefix(value)) |
105 return true; | 105 return true; |
106 | 106 |
107 return false; | 107 return false; |
108 } | 108 }; |
109 | 109 |
110 WebInspector.StylesSidebarPane.prototype = { | 110 WebInspector.StylesSidebarPane.prototype = { |
111 /** | 111 /** |
112 * @param {!WebInspector.Event} event | 112 * @param {!WebInspector.Event} event |
113 */ | 113 */ |
114 _onLayoutEditorChange: function(event) | 114 _onLayoutEditorChange: function(event) |
115 { | 115 { |
116 var cssModel = /** @type {!WebInspector.CSSModel} */(event.target); | 116 var cssModel = /** @type {!WebInspector.CSSModel} */(event.target); |
117 var styleSheetId = event.data["id"]; | 117 var styleSheetId = event.data["id"]; |
118 var sourceRange = /** @type {!CSSAgent.SourceRange} */(event.data["range
"]); | 118 var sourceRange = /** @type {!CSSAgent.SourceRange} */(event.data["range
"]); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 */ | 481 */ |
482 allSections: function() | 482 allSections: function() |
483 { | 483 { |
484 var sections = []; | 484 var sections = []; |
485 for (var block of this._sectionBlocks) | 485 for (var block of this._sectionBlocks) |
486 sections = sections.concat(block.sections); | 486 sections = sections.concat(block.sections); |
487 return sections; | 487 return sections; |
488 }, | 488 }, |
489 | 489 |
490 __proto__: WebInspector.ElementsSidebarPane.prototype | 490 __proto__: WebInspector.ElementsSidebarPane.prototype |
491 } | 491 }; |
492 | 492 |
493 /** | 493 /** |
494 * @param {string} placeholder | 494 * @param {string} placeholder |
495 * @param {!Element} container | 495 * @param {!Element} container |
496 * @param {function(?RegExp)} filterCallback | 496 * @param {function(?RegExp)} filterCallback |
497 * @return {!Element} | 497 * @return {!Element} |
498 */ | 498 */ |
499 WebInspector.StylesSidebarPane.createPropertyFilterElement = function(placeholde
r, container, filterCallback) | 499 WebInspector.StylesSidebarPane.createPropertyFilterElement = function(placeholde
r, container, filterCallback) |
500 { | 500 { |
501 var input = createElement("input"); | 501 var input = createElement("input"); |
(...skipping 26 matching lines...) Expand all Loading... |
528 * @param {string} value | 528 * @param {string} value |
529 */ | 529 */ |
530 function setFilterValue(value) | 530 function setFilterValue(value) |
531 { | 531 { |
532 input.value = value; | 532 input.value = value; |
533 input.focus(); | 533 input.focus(); |
534 searchHandler(); | 534 searchHandler(); |
535 } | 535 } |
536 | 536 |
537 return input; | 537 return input; |
538 } | 538 }; |
539 | 539 |
540 /** | 540 /** |
541 * @constructor | 541 * @constructor |
542 * @param {?Element} titleElement | 542 * @param {?Element} titleElement |
543 */ | 543 */ |
544 WebInspector.SectionBlock = function(titleElement) | 544 WebInspector.SectionBlock = function(titleElement) |
545 { | 545 { |
546 this._titleElement = titleElement; | 546 this._titleElement = titleElement; |
547 this.sections = []; | 547 this.sections = []; |
548 } | 548 }; |
549 | 549 |
550 /** | 550 /** |
551 * @param {!DOMAgent.PseudoType} pseudoType | 551 * @param {!DOMAgent.PseudoType} pseudoType |
552 * @return {!WebInspector.SectionBlock} | 552 * @return {!WebInspector.SectionBlock} |
553 */ | 553 */ |
554 WebInspector.SectionBlock.createPseudoTypeBlock = function(pseudoType) | 554 WebInspector.SectionBlock.createPseudoTypeBlock = function(pseudoType) |
555 { | 555 { |
556 var separatorElement = createElement("div"); | 556 var separatorElement = createElement("div"); |
557 separatorElement.className = "sidebar-separator"; | 557 separatorElement.className = "sidebar-separator"; |
558 separatorElement.textContent = WebInspector.UIString("Pseudo ::%s element",
pseudoType); | 558 separatorElement.textContent = WebInspector.UIString("Pseudo ::%s element",
pseudoType); |
559 return new WebInspector.SectionBlock(separatorElement); | 559 return new WebInspector.SectionBlock(separatorElement); |
560 } | 560 }; |
561 | 561 |
562 /** | 562 /** |
563 * @param {string} keyframesName | 563 * @param {string} keyframesName |
564 * @return {!WebInspector.SectionBlock} | 564 * @return {!WebInspector.SectionBlock} |
565 */ | 565 */ |
566 WebInspector.SectionBlock.createKeyframesBlock = function(keyframesName) | 566 WebInspector.SectionBlock.createKeyframesBlock = function(keyframesName) |
567 { | 567 { |
568 var separatorElement = createElement("div"); | 568 var separatorElement = createElement("div"); |
569 separatorElement.className = "sidebar-separator"; | 569 separatorElement.className = "sidebar-separator"; |
570 separatorElement.textContent = WebInspector.UIString("@keyframes " + keyfram
esName); | 570 separatorElement.textContent = WebInspector.UIString("@keyframes " + keyfram
esName); |
571 return new WebInspector.SectionBlock(separatorElement); | 571 return new WebInspector.SectionBlock(separatorElement); |
572 } | 572 }; |
573 | 573 |
574 /** | 574 /** |
575 * @param {!WebInspector.DOMNode} node | 575 * @param {!WebInspector.DOMNode} node |
576 * @return {!WebInspector.SectionBlock} | 576 * @return {!WebInspector.SectionBlock} |
577 */ | 577 */ |
578 WebInspector.SectionBlock.createInheritedNodeBlock = function(node) | 578 WebInspector.SectionBlock.createInheritedNodeBlock = function(node) |
579 { | 579 { |
580 var separatorElement = createElement("div"); | 580 var separatorElement = createElement("div"); |
581 separatorElement.className = "sidebar-separator"; | 581 separatorElement.className = "sidebar-separator"; |
582 var link = WebInspector.DOMPresentationUtils.linkifyNodeReference(node); | 582 var link = WebInspector.DOMPresentationUtils.linkifyNodeReference(node); |
583 separatorElement.createTextChild(WebInspector.UIString("Inherited from") + "
"); | 583 separatorElement.createTextChild(WebInspector.UIString("Inherited from") + "
"); |
584 separatorElement.appendChild(link); | 584 separatorElement.appendChild(link); |
585 return new WebInspector.SectionBlock(separatorElement); | 585 return new WebInspector.SectionBlock(separatorElement); |
586 } | 586 }; |
587 | 587 |
588 WebInspector.SectionBlock.prototype = { | 588 WebInspector.SectionBlock.prototype = { |
589 updateFilter: function() | 589 updateFilter: function() |
590 { | 590 { |
591 var hasAnyVisibleSection = false; | 591 var hasAnyVisibleSection = false; |
592 for (var section of this.sections) | 592 for (var section of this.sections) |
593 hasAnyVisibleSection |= section._updateFilter(); | 593 hasAnyVisibleSection |= section._updateFilter(); |
594 if (this._titleElement) | 594 if (this._titleElement) |
595 this._titleElement.classList.toggle("hidden", !hasAnyVisibleSection)
; | 595 this._titleElement.classList.toggle("hidden", !hasAnyVisibleSection)
; |
596 }, | 596 }, |
597 | 597 |
598 /** | 598 /** |
599 * @return {?Element} | 599 * @return {?Element} |
600 */ | 600 */ |
601 titleElement: function() | 601 titleElement: function() |
602 { | 602 { |
603 return this._titleElement; | 603 return this._titleElement; |
604 } | 604 } |
605 } | 605 }; |
606 | 606 |
607 /** | 607 /** |
608 * @constructor | 608 * @constructor |
609 * @param {!WebInspector.StylesSidebarPane} parentPane | 609 * @param {!WebInspector.StylesSidebarPane} parentPane |
610 * @param {!WebInspector.CSSMatchedStyles} matchedStyles | 610 * @param {!WebInspector.CSSMatchedStyles} matchedStyles |
611 * @param {!WebInspector.CSSStyleDeclaration} style | 611 * @param {!WebInspector.CSSStyleDeclaration} style |
612 */ | 612 */ |
613 WebInspector.StylePropertiesSection = function(parentPane, matchedStyles, style) | 613 WebInspector.StylePropertiesSection = function(parentPane, matchedStyles, style) |
614 { | 614 { |
615 this._parentPane = parentPane; | 615 this._parentPane = parentPane; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 this.element.classList.add("navigable"); | 675 this.element.classList.add("navigable"); |
676 | 676 |
677 if (!this.editable) { | 677 if (!this.editable) { |
678 this.element.classList.add("read-only"); | 678 this.element.classList.add("read-only"); |
679 this.propertiesTreeOutline.element.classList.add("read-only"); | 679 this.propertiesTreeOutline.element.classList.add("read-only"); |
680 } | 680 } |
681 | 681 |
682 this._hoverableSelectorsMode = false; | 682 this._hoverableSelectorsMode = false; |
683 this._markSelectorMatches(); | 683 this._markSelectorMatches(); |
684 this.onpopulate(); | 684 this.onpopulate(); |
685 } | 685 }; |
686 | 686 |
687 WebInspector.StylePropertiesSection.prototype = { | 687 WebInspector.StylePropertiesSection.prototype = { |
688 /** | 688 /** |
689 * @param {boolean} isHovered | 689 * @param {boolean} isHovered |
690 */ | 690 */ |
691 _setSectionHovered: function(isHovered) | 691 _setSectionHovered: function(isHovered) |
692 { | 692 { |
693 this.element.classList.toggle("styles-panel-hovered", isHovered); | 693 this.element.classList.toggle("styles-panel-hovered", isHovered); |
694 this.propertiesTreeOutline.element.classList.toggle("styles-panel-hovere
d", isHovered); | 694 this.propertiesTreeOutline.element.classList.toggle("styles-panel-hovere
d", isHovered); |
695 if (this._hoverableSelectorsMode !== isHovered) { | 695 if (this._hoverableSelectorsMode !== isHovered) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 return this._matchedStyles.isInherited(this._style) ? WebInspector.U
IString("Style Attribute") : "element.style"; | 794 return this._matchedStyles.isInherited(this._style) ? WebInspector.U
IString("Style Attribute") : "element.style"; |
795 if (this._style.type === WebInspector.CSSStyleDeclaration.Type.Attribute
s) | 795 if (this._style.type === WebInspector.CSSStyleDeclaration.Type.Attribute
s) |
796 return node.nodeNameInCorrectCase() + "[" + WebInspector.UIString("A
ttributes Style") + "]"; | 796 return node.nodeNameInCorrectCase() + "[" + WebInspector.UIString("A
ttributes Style") + "]"; |
797 return this._style.parentRule.selectorText(); | 797 return this._style.parentRule.selectorText(); |
798 }, | 798 }, |
799 | 799 |
800 _onMouseOutSelector: function() | 800 _onMouseOutSelector: function() |
801 { | 801 { |
802 if (this._hoverTimer) | 802 if (this._hoverTimer) |
803 clearTimeout(this._hoverTimer); | 803 clearTimeout(this._hoverTimer); |
804 WebInspector.DOMModel.hideDOMNodeHighlight() | 804 WebInspector.DOMModel.hideDOMNodeHighlight(); |
805 }, | 805 }, |
806 | 806 |
807 _onMouseEnterSelector: function() | 807 _onMouseEnterSelector: function() |
808 { | 808 { |
809 if (this._hoverTimer) | 809 if (this._hoverTimer) |
810 clearTimeout(this._hoverTimer); | 810 clearTimeout(this._hoverTimer); |
811 this._hoverTimer = setTimeout(this._highlight.bind(this), 300); | 811 this._hoverTimer = setTimeout(this._highlight.bind(this), 300); |
812 }, | 812 }, |
813 | 813 |
814 _highlight: function() | 814 _highlight: function() |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 }, | 1572 }, |
1573 | 1573 |
1574 editingSelectorCancelled: function() | 1574 editingSelectorCancelled: function() |
1575 { | 1575 { |
1576 this._editingSelectorEnded(); | 1576 this._editingSelectorEnded(); |
1577 | 1577 |
1578 // Mark the selectors in group if necessary. | 1578 // Mark the selectors in group if necessary. |
1579 // This is overridden by BlankStylePropertiesSection. | 1579 // This is overridden by BlankStylePropertiesSection. |
1580 this._markSelectorMatches(); | 1580 this._markSelectorMatches(); |
1581 } | 1581 } |
1582 } | 1582 }; |
1583 | 1583 |
1584 /** | 1584 /** |
1585 * @param {!WebInspector.CSSMatchedStyles} matchedStyles | 1585 * @param {!WebInspector.CSSMatchedStyles} matchedStyles |
1586 * @param {!WebInspector.Linkifier} linkifier | 1586 * @param {!WebInspector.Linkifier} linkifier |
1587 * @param {?WebInspector.CSSRule} rule | 1587 * @param {?WebInspector.CSSRule} rule |
1588 * @return {!Node} | 1588 * @return {!Node} |
1589 */ | 1589 */ |
1590 WebInspector.StylePropertiesSection.createRuleOriginNode = function(matchedStyle
s, linkifier, rule) | 1590 WebInspector.StylePropertiesSection.createRuleOriginNode = function(matchedStyle
s, linkifier, rule) |
1591 { | 1591 { |
1592 if (!rule) | 1592 if (!rule) |
(...skipping 19 matching lines...) Expand all Loading... |
1612 if (rule.isViaInspector()) | 1612 if (rule.isViaInspector()) |
1613 return createTextNode(WebInspector.UIString("via inspector")); | 1613 return createTextNode(WebInspector.UIString("via inspector")); |
1614 | 1614 |
1615 if (header && header.ownerNode) { | 1615 if (header && header.ownerNode) { |
1616 var link = WebInspector.DOMPresentationUtils.linkifyDeferredNodeReferenc
e(header.ownerNode); | 1616 var link = WebInspector.DOMPresentationUtils.linkifyDeferredNodeReferenc
e(header.ownerNode); |
1617 link.textContent = "<style>…</style>"; | 1617 link.textContent = "<style>…</style>"; |
1618 return link; | 1618 return link; |
1619 } | 1619 } |
1620 | 1620 |
1621 return createTextNode(""); | 1621 return createTextNode(""); |
1622 } | 1622 }; |
1623 | 1623 |
1624 /** | 1624 /** |
1625 * @param {!WebInspector.CSSModel} cssModel | 1625 * @param {!WebInspector.CSSModel} cssModel |
1626 * @param {!WebInspector.Linkifier} linkifier | 1626 * @param {!WebInspector.Linkifier} linkifier |
1627 * @param {string} styleSheetId | 1627 * @param {string} styleSheetId |
1628 * @param {!WebInspector.TextRange} ruleLocation | 1628 * @param {!WebInspector.TextRange} ruleLocation |
1629 * @return {!Node} | 1629 * @return {!Node} |
1630 */ | 1630 */ |
1631 WebInspector.StylePropertiesSection._linkifyRuleLocation = function(cssModel, li
nkifier, styleSheetId, ruleLocation) | 1631 WebInspector.StylePropertiesSection._linkifyRuleLocation = function(cssModel, li
nkifier, styleSheetId, ruleLocation) |
1632 { | 1632 { |
1633 var styleSheetHeader = cssModel.styleSheetHeaderForId(styleSheetId); | 1633 var styleSheetHeader = cssModel.styleSheetHeaderForId(styleSheetId); |
1634 var lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.startLine)
; | 1634 var lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.startLine)
; |
1635 var columnNumber = styleSheetHeader.columnNumberInSource(ruleLocation.startL
ine, ruleLocation.startColumn); | 1635 var columnNumber = styleSheetHeader.columnNumberInSource(ruleLocation.startL
ine, ruleLocation.startColumn); |
1636 var matchingSelectorLocation = new WebInspector.CSSLocation(styleSheetHeader
, lineNumber, columnNumber); | 1636 var matchingSelectorLocation = new WebInspector.CSSLocation(styleSheetHeader
, lineNumber, columnNumber); |
1637 return linkifier.linkifyCSSLocation(matchingSelectorLocation); | 1637 return linkifier.linkifyCSSLocation(matchingSelectorLocation); |
1638 } | 1638 }; |
1639 | 1639 |
1640 /** | 1640 /** |
1641 * @constructor | 1641 * @constructor |
1642 * @extends {WebInspector.StylePropertiesSection} | 1642 * @extends {WebInspector.StylePropertiesSection} |
1643 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1643 * @param {!WebInspector.StylesSidebarPane} stylesPane |
1644 * @param {!WebInspector.CSSMatchedStyles} matchedStyles | 1644 * @param {!WebInspector.CSSMatchedStyles} matchedStyles |
1645 * @param {string} defaultSelectorText | 1645 * @param {string} defaultSelectorText |
1646 * @param {string} styleSheetId | 1646 * @param {string} styleSheetId |
1647 * @param {!WebInspector.TextRange} ruleLocation | 1647 * @param {!WebInspector.TextRange} ruleLocation |
1648 * @param {!WebInspector.CSSStyleDeclaration} insertAfterStyle | 1648 * @param {!WebInspector.CSSStyleDeclaration} insertAfterStyle |
1649 */ | 1649 */ |
1650 WebInspector.BlankStylePropertiesSection = function(stylesPane, matchedStyles, d
efaultSelectorText, styleSheetId, ruleLocation, insertAfterStyle) | 1650 WebInspector.BlankStylePropertiesSection = function(stylesPane, matchedStyles, d
efaultSelectorText, styleSheetId, ruleLocation, insertAfterStyle) |
1651 { | 1651 { |
1652 var cssModel = /** @type {!WebInspector.CSSModel} */(stylesPane.cssModel()); | 1652 var cssModel = /** @type {!WebInspector.CSSModel} */(stylesPane.cssModel()); |
1653 var rule = WebInspector.CSSStyleRule.createDummyRule(cssModel, defaultSelect
orText); | 1653 var rule = WebInspector.CSSStyleRule.createDummyRule(cssModel, defaultSelect
orText); |
1654 WebInspector.StylePropertiesSection.call(this, stylesPane, matchedStyles, ru
le.style); | 1654 WebInspector.StylePropertiesSection.call(this, stylesPane, matchedStyles, ru
le.style); |
1655 this._ruleLocation = ruleLocation; | 1655 this._ruleLocation = ruleLocation; |
1656 this._styleSheetId = styleSheetId; | 1656 this._styleSheetId = styleSheetId; |
1657 this._selectorRefElement.removeChildren(); | 1657 this._selectorRefElement.removeChildren(); |
1658 this._selectorRefElement.appendChild(WebInspector.StylePropertiesSection._li
nkifyRuleLocation(cssModel, this._parentPane._linkifier, styleSheetId, this._act
ualRuleLocation())); | 1658 this._selectorRefElement.appendChild(WebInspector.StylePropertiesSection._li
nkifyRuleLocation(cssModel, this._parentPane._linkifier, styleSheetId, this._act
ualRuleLocation())); |
1659 if (insertAfterStyle && insertAfterStyle.parentRule) | 1659 if (insertAfterStyle && insertAfterStyle.parentRule) |
1660 this._createMediaList(insertAfterStyle.parentRule.media); | 1660 this._createMediaList(insertAfterStyle.parentRule.media); |
1661 this.element.classList.add("blank-section"); | 1661 this.element.classList.add("blank-section"); |
1662 } | 1662 }; |
1663 | 1663 |
1664 WebInspector.BlankStylePropertiesSection.prototype = { | 1664 WebInspector.BlankStylePropertiesSection.prototype = { |
1665 /** | 1665 /** |
1666 * @return {!WebInspector.TextRange} | 1666 * @return {!WebInspector.TextRange} |
1667 */ | 1667 */ |
1668 _actualRuleLocation: function() | 1668 _actualRuleLocation: function() |
1669 { | 1669 { |
1670 var prefix = this._rulePrefix(); | 1670 var prefix = this._rulePrefix(); |
1671 var lines = prefix.split("\n"); | 1671 var lines = prefix.split("\n"); |
1672 var editRange = new WebInspector.TextRange(0, 0, lines.length - 1, lines
.peekLast().length); | 1672 var editRange = new WebInspector.TextRange(0, 0, lines.length - 1, lines
.peekLast().length); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 */ | 1770 */ |
1771 _makeNormal: function(newRule) | 1771 _makeNormal: function(newRule) |
1772 { | 1772 { |
1773 this.element.classList.remove("blank-section"); | 1773 this.element.classList.remove("blank-section"); |
1774 this._style = newRule.style; | 1774 this._style = newRule.style; |
1775 // FIXME: replace this instance by a normal WebInspector.StyleProperties
Section. | 1775 // FIXME: replace this instance by a normal WebInspector.StyleProperties
Section. |
1776 this._normal = true; | 1776 this._normal = true; |
1777 }, | 1777 }, |
1778 | 1778 |
1779 __proto__: WebInspector.StylePropertiesSection.prototype | 1779 __proto__: WebInspector.StylePropertiesSection.prototype |
1780 } | 1780 }; |
1781 | 1781 |
1782 /** | 1782 /** |
1783 * @constructor | 1783 * @constructor |
1784 * @extends {WebInspector.StylePropertiesSection} | 1784 * @extends {WebInspector.StylePropertiesSection} |
1785 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1785 * @param {!WebInspector.StylesSidebarPane} stylesPane |
1786 * @param {!WebInspector.CSSMatchedStyles} matchedStyles | 1786 * @param {!WebInspector.CSSMatchedStyles} matchedStyles |
1787 * @param {!WebInspector.CSSStyleDeclaration} style | 1787 * @param {!WebInspector.CSSStyleDeclaration} style |
1788 */ | 1788 */ |
1789 WebInspector.KeyframePropertiesSection = function(stylesPane, matchedStyles, sty
le) | 1789 WebInspector.KeyframePropertiesSection = function(stylesPane, matchedStyles, sty
le) |
1790 { | 1790 { |
1791 WebInspector.StylePropertiesSection.call(this, stylesPane, matchedStyles, st
yle); | 1791 WebInspector.StylePropertiesSection.call(this, stylesPane, matchedStyles, st
yle); |
1792 this._selectorElement.className = "keyframe-key"; | 1792 this._selectorElement.className = "keyframe-key"; |
1793 } | 1793 }; |
1794 | 1794 |
1795 WebInspector.KeyframePropertiesSection.prototype = { | 1795 WebInspector.KeyframePropertiesSection.prototype = { |
1796 /** | 1796 /** |
1797 * @override | 1797 * @override |
1798 * @return {string} | 1798 * @return {string} |
1799 */ | 1799 */ |
1800 _headerText: function() | 1800 _headerText: function() |
1801 { | 1801 { |
1802 return this._style.parentRule.key().text; | 1802 return this._style.parentRule.key().text; |
1803 }, | 1803 }, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 }, | 1865 }, |
1866 | 1866 |
1867 /** | 1867 /** |
1868 * @override | 1868 * @override |
1869 */ | 1869 */ |
1870 _highlight: function() | 1870 _highlight: function() |
1871 { | 1871 { |
1872 }, | 1872 }, |
1873 | 1873 |
1874 __proto__: WebInspector.StylePropertiesSection.prototype | 1874 __proto__: WebInspector.StylePropertiesSection.prototype |
1875 } | 1875 }; |
1876 | 1876 |
1877 /** | 1877 /** |
1878 * @constructor | 1878 * @constructor |
1879 * @extends {TreeElement} | 1879 * @extends {TreeElement} |
1880 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1880 * @param {!WebInspector.StylesSidebarPane} stylesPane |
1881 * @param {!WebInspector.CSSMatchedStyles} matchedStyles | 1881 * @param {!WebInspector.CSSMatchedStyles} matchedStyles |
1882 * @param {!WebInspector.CSSProperty} property | 1882 * @param {!WebInspector.CSSProperty} property |
1883 * @param {boolean} isShorthand | 1883 * @param {boolean} isShorthand |
1884 * @param {boolean} inherited | 1884 * @param {boolean} inherited |
1885 * @param {boolean} overloaded | 1885 * @param {boolean} overloaded |
1886 */ | 1886 */ |
1887 WebInspector.StylePropertyTreeElement = function(stylesPane, matchedStyles, prop
erty, isShorthand, inherited, overloaded) | 1887 WebInspector.StylePropertyTreeElement = function(stylesPane, matchedStyles, prop
erty, isShorthand, inherited, overloaded) |
1888 { | 1888 { |
1889 // Pass an empty title, the title gets made later in onattach. | 1889 // Pass an empty title, the title gets made later in onattach. |
1890 TreeElement.call(this, "", isShorthand); | 1890 TreeElement.call(this, "", isShorthand); |
1891 this._style = property.ownerStyle; | 1891 this._style = property.ownerStyle; |
1892 this._matchedStyles = matchedStyles; | 1892 this._matchedStyles = matchedStyles; |
1893 this.property = property; | 1893 this.property = property; |
1894 this._inherited = inherited; | 1894 this._inherited = inherited; |
1895 this._overloaded = overloaded; | 1895 this._overloaded = overloaded; |
1896 this.selectable = false; | 1896 this.selectable = false; |
1897 this._parentPane = stylesPane; | 1897 this._parentPane = stylesPane; |
1898 this.isShorthand = isShorthand; | 1898 this.isShorthand = isShorthand; |
1899 this._applyStyleThrottler = new WebInspector.Throttler(0); | 1899 this._applyStyleThrottler = new WebInspector.Throttler(0); |
1900 } | 1900 }; |
1901 | 1901 |
1902 /** @typedef {{expanded: boolean, hasChildren: boolean, isEditingName: boolean,
previousContent: string}} */ | 1902 /** @typedef {{expanded: boolean, hasChildren: boolean, isEditingName: boolean,
previousContent: string}} */ |
1903 WebInspector.StylePropertyTreeElement.Context; | 1903 WebInspector.StylePropertyTreeElement.Context; |
1904 | 1904 |
1905 WebInspector.StylePropertyTreeElement.prototype = { | 1905 WebInspector.StylePropertyTreeElement.prototype = { |
1906 /** | 1906 /** |
1907 * @return {boolean} | 1907 * @return {boolean} |
1908 */ | 1908 */ |
1909 _editable: function() | 1909 _editable: function() |
1910 { | 1910 { |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 * @override | 2859 * @override |
2860 * @param {!Event} event | 2860 * @param {!Event} event |
2861 * @return {boolean} | 2861 * @return {boolean} |
2862 */ | 2862 */ |
2863 isEventWithinDisclosureTriangle: function(event) | 2863 isEventWithinDisclosureTriangle: function(event) |
2864 { | 2864 { |
2865 return event.target === this._expandElement; | 2865 return event.target === this._expandElement; |
2866 }, | 2866 }, |
2867 | 2867 |
2868 __proto__: TreeElement.prototype | 2868 __proto__: TreeElement.prototype |
2869 } | 2869 }; |
2870 | 2870 |
2871 /** | 2871 /** |
2872 * @constructor | 2872 * @constructor |
2873 * @extends {WebInspector.TextPrompt} | 2873 * @extends {WebInspector.TextPrompt} |
2874 * @param {!Array<string>} cssCompletions | 2874 * @param {!Array<string>} cssCompletions |
2875 * @param {!WebInspector.StylePropertyTreeElement} treeElement | 2875 * @param {!WebInspector.StylePropertyTreeElement} treeElement |
2876 * @param {boolean} isEditingName | 2876 * @param {boolean} isEditingName |
2877 */ | 2877 */ |
2878 WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(cssCompletions, tree
Element, isEditingName) | 2878 WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(cssCompletions, tree
Element, isEditingName) |
2879 { | 2879 { |
(...skipping 10 matching lines...) Expand all Loading... |
2890 // If a CSS value is being edited that has a numeric or hex substring, h
int that precision modifier shortcuts are available. | 2890 // If a CSS value is being edited that has a numeric or hex substring, h
int that precision modifier shortcuts are available. |
2891 if (treeElement && treeElement.valueElement) { | 2891 if (treeElement && treeElement.valueElement) { |
2892 var cssValueText = treeElement.valueElement.textContent; | 2892 var cssValueText = treeElement.valueElement.textContent; |
2893 if (cssValueText.match(/#[\da-f]{3,6}$/i)) | 2893 if (cssValueText.match(/#[\da-f]{3,6}$/i)) |
2894 this.setTitle(WebInspector.UIString("Increment/decrement with mo
usewheel or up/down keys. %s: R ±1, Shift: G ±1, Alt: B ±1", WebInspector.isMac(
) ? "Cmd" : "Ctrl")); | 2894 this.setTitle(WebInspector.UIString("Increment/decrement with mo
usewheel or up/down keys. %s: R ±1, Shift: G ±1, Alt: B ±1", WebInspector.isMac(
) ? "Cmd" : "Ctrl")); |
2895 else if (cssValueText.match(/\d+/)) | 2895 else if (cssValueText.match(/\d+/)) |
2896 this.setTitle(WebInspector.UIString("Increment/decrement with mo
usewheel or up/down keys. %s: ±100, Shift: ±10, Alt: ±0.1", WebInspector.isMac()
? "Cmd" : "Ctrl")); | 2896 this.setTitle(WebInspector.UIString("Increment/decrement with mo
usewheel or up/down keys. %s: ±100, Shift: ±10, Alt: ±0.1", WebInspector.isMac()
? "Cmd" : "Ctrl")); |
2897 } | 2897 } |
2898 | 2898 |
2899 } | 2899 } |
2900 } | 2900 }; |
2901 | 2901 |
2902 WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype = { | 2902 WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype = { |
2903 /** | 2903 /** |
2904 * @override | 2904 * @override |
2905 * @param {!Event} event | 2905 * @param {!Event} event |
2906 */ | 2906 */ |
2907 onKeyDown: function(event) | 2907 onKeyDown: function(event) |
2908 { | 2908 { |
2909 switch (event.key) { | 2909 switch (event.key) { |
2910 case "ArrowUp": | 2910 case "ArrowUp": |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 var userEnteredText = wordRange.toString().replace("-", ""); | 3023 var userEnteredText = wordRange.toString().replace("-", ""); |
3024 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase(
))) { | 3024 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase(
))) { |
3025 for (var i = 0; i < results.length; ++i) | 3025 for (var i = 0; i < results.length; ++i) |
3026 results[i] = results[i].toUpperCase(); | 3026 results[i] = results[i].toUpperCase(); |
3027 } | 3027 } |
3028 var selectedIndex = this._isEditingName ? WebInspector.cssMetadata().mos
tUsedProperty(results) : 0; | 3028 var selectedIndex = this._isEditingName ? WebInspector.cssMetadata().mos
tUsedProperty(results) : 0; |
3029 completionsReadyCallback(results, selectedIndex); | 3029 completionsReadyCallback(results, selectedIndex); |
3030 }, | 3030 }, |
3031 | 3031 |
3032 __proto__: WebInspector.TextPrompt.prototype | 3032 __proto__: WebInspector.TextPrompt.prototype |
3033 } | 3033 }; |
3034 | 3034 |
3035 /** | 3035 /** |
3036 * @constructor | 3036 * @constructor |
3037 * @param {?WebInspector.CSSRule} rule | 3037 * @param {?WebInspector.CSSRule} rule |
3038 * @param {?WebInspector.DOMNode} node | 3038 * @param {?WebInspector.DOMNode} node |
3039 * @param {string} name | 3039 * @param {string} name |
3040 * @param {string} value | 3040 * @param {string} value |
3041 */ | 3041 */ |
3042 WebInspector.StylesSidebarPropertyRenderer = function(rule, node, name, value) | 3042 WebInspector.StylesSidebarPropertyRenderer = function(rule, node, name, value) |
3043 { | 3043 { |
3044 this._rule = rule; | 3044 this._rule = rule; |
3045 this._node = node; | 3045 this._node = node; |
3046 this._propertyName = name; | 3046 this._propertyName = name; |
3047 this._propertyValue = value; | 3047 this._propertyValue = value; |
3048 } | 3048 }; |
3049 | 3049 |
3050 WebInspector.StylesSidebarPropertyRenderer.prototype = { | 3050 WebInspector.StylesSidebarPropertyRenderer.prototype = { |
3051 /** | 3051 /** |
3052 * @param {function(string):!Node} handler | 3052 * @param {function(string):!Node} handler |
3053 */ | 3053 */ |
3054 setColorHandler: function(handler) | 3054 setColorHandler: function(handler) |
3055 { | 3055 { |
3056 this._colorHandler = handler; | 3056 this._colorHandler = handler; |
3057 }, | 3057 }, |
3058 | 3058 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3138 if (this._rule && this._rule.resourceURL()) | 3138 if (this._rule && this._rule.resourceURL()) |
3139 hrefUrl = WebInspector.ParsedURL.completeURL(this._rule.resourceURL(
), url); | 3139 hrefUrl = WebInspector.ParsedURL.completeURL(this._rule.resourceURL(
), url); |
3140 else if (this._node) | 3140 else if (this._node) |
3141 hrefUrl = this._node.resolveURL(url); | 3141 hrefUrl = this._node.resolveURL(url); |
3142 var hasResource = hrefUrl && !!WebInspector.resourceForURL(hrefUrl); | 3142 var hasResource = hrefUrl && !!WebInspector.resourceForURL(hrefUrl); |
3143 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI. | 3143 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI. |
3144 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl || url, url,
undefined, !hasResource)); | 3144 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl || url, url,
undefined, !hasResource)); |
3145 container.createTextChild(")"); | 3145 container.createTextChild(")"); |
3146 return container; | 3146 return container; |
3147 } | 3147 } |
3148 } | 3148 }; |
3149 | 3149 |
3150 /** | 3150 /** |
3151 * @constructor | 3151 * @constructor |
3152 * @implements {WebInspector.ToolbarItem.Provider} | 3152 * @implements {WebInspector.ToolbarItem.Provider} |
3153 */ | 3153 */ |
3154 WebInspector.StylesSidebarPane.ButtonProvider = function() | 3154 WebInspector.StylesSidebarPane.ButtonProvider = function() |
3155 { | 3155 { |
3156 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("New Sty
le Rule"), "add-toolbar-item"); | 3156 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("New Sty
le Rule"), "add-toolbar-item"); |
3157 this._button.addEventListener("click", this._clicked, this); | 3157 this._button.addEventListener("click", this._clicked, this); |
3158 this._button.element.createChild("div", "long-click-glyph toolbar-button-the
me"); | 3158 this._button.element.createChild("div", "long-click-glyph toolbar-button-the
me"); |
3159 new WebInspector.LongClickController(this._button.element, this._longClicked
.bind(this)); | 3159 new WebInspector.LongClickController(this._button.element, this._longClicked
.bind(this)); |
3160 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha
nged.bind(this)); | 3160 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha
nged.bind(this)); |
3161 onNodeChanged.call(this); | 3161 onNodeChanged.call(this); |
3162 | 3162 |
3163 /** | 3163 /** |
3164 * @this {WebInspector.StylesSidebarPane.ButtonProvider} | 3164 * @this {WebInspector.StylesSidebarPane.ButtonProvider} |
3165 */ | 3165 */ |
3166 function onNodeChanged() | 3166 function onNodeChanged() |
3167 { | 3167 { |
3168 var node = WebInspector.context.flavor(WebInspector.DOMNode); | 3168 var node = WebInspector.context.flavor(WebInspector.DOMNode); |
3169 node = node ? node.enclosingElementOrSelf() : null; | 3169 node = node ? node.enclosingElementOrSelf() : null; |
3170 this._button.setEnabled(!!node); | 3170 this._button.setEnabled(!!node); |
3171 } | 3171 } |
3172 } | 3172 }; |
3173 | 3173 |
3174 WebInspector.StylesSidebarPane.ButtonProvider.prototype = { | 3174 WebInspector.StylesSidebarPane.ButtonProvider.prototype = { |
3175 _clicked: function() | 3175 _clicked: function() |
3176 { | 3176 { |
3177 WebInspector.StylesSidebarPane._instance._createNewRuleInViaInspectorSty
leSheet(); | 3177 WebInspector.StylesSidebarPane._instance._createNewRuleInViaInspectorSty
leSheet(); |
3178 }, | 3178 }, |
3179 | 3179 |
3180 /** | 3180 /** |
3181 * @param {!Event} e | 3181 * @param {!Event} e |
3182 */ | 3182 */ |
3183 _longClicked: function(e) | 3183 _longClicked: function(e) |
3184 { | 3184 { |
3185 WebInspector.StylesSidebarPane._instance._onAddButtonLongClick(e); | 3185 WebInspector.StylesSidebarPane._instance._onAddButtonLongClick(e); |
3186 }, | 3186 }, |
3187 | 3187 |
3188 /** | 3188 /** |
3189 * @override | 3189 * @override |
3190 * @return {!WebInspector.ToolbarItem} | 3190 * @return {!WebInspector.ToolbarItem} |
3191 */ | 3191 */ |
3192 item: function() | 3192 item: function() |
3193 { | 3193 { |
3194 return this._button; | 3194 return this._button; |
3195 } | 3195 } |
3196 } | 3196 }; |
OLD | NEW |