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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 styleSheetHeader.requestContent().then(onStyleSheetContent.bind(this, styleS
heetHeader.id)); | 418 styleSheetHeader.requestContent().then(onStyleSheetContent.bind(this, styleS
heetHeader.id)); |
419 | 419 |
420 /** | 420 /** |
421 * @param {string} styleSheetId | 421 * @param {string} styleSheetId |
422 * @param {?string} text | 422 * @param {?string} text |
423 * @this {Elements.StylesSidebarPane} | 423 * @this {Elements.StylesSidebarPane} |
424 */ | 424 */ |
425 function onStyleSheetContent(styleSheetId, text) { | 425 function onStyleSheetContent(styleSheetId, text) { |
426 text = text || ''; | 426 text = text || ''; |
427 var lines = text.split('\n'); | 427 var lines = text.split('\n'); |
428 var range = Common.TextRange.createFromLocation(lines.length - 1, lines[li
nes.length - 1].length); | 428 var range = TextUtils.TextRange.createFromLocation(lines.length - 1, lines
[lines.length - 1].length); |
429 this._addBlankSection(this._sectionBlocks[0].sections[0], styleSheetId, ra
nge); | 429 this._addBlankSection(this._sectionBlocks[0].sections[0], styleSheetId, ra
nge); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 /** | 433 /** |
434 * @param {!Elements.StylePropertiesSection} insertAfterSection | 434 * @param {!Elements.StylePropertiesSection} insertAfterSection |
435 * @param {string} styleSheetId | 435 * @param {string} styleSheetId |
436 * @param {!Common.TextRange} ruleLocation | 436 * @param {!TextUtils.TextRange} ruleLocation |
437 */ | 437 */ |
438 _addBlankSection(insertAfterSection, styleSheetId, ruleLocation) { | 438 _addBlankSection(insertAfterSection, styleSheetId, ruleLocation) { |
439 var node = this.node(); | 439 var node = this.node(); |
440 var blankSection = new Elements.BlankStylePropertiesSection( | 440 var blankSection = new Elements.BlankStylePropertiesSection( |
441 this, insertAfterSection._matchedStyles, node ? Components.DOMPresentati
onUtils.simpleSelector(node) : '', | 441 this, insertAfterSection._matchedStyles, node ? Components.DOMPresentati
onUtils.simpleSelector(node) : '', |
442 styleSheetId, ruleLocation, insertAfterSection._style); | 442 styleSheetId, ruleLocation, insertAfterSection._style); |
443 | 443 |
444 this._sectionsContainer.insertBefore(blankSection.element, insertAfterSectio
n.element.nextSibling); | 444 this._sectionsContainer.insertBefore(blankSection.element, insertAfterSectio
n.element.nextSibling); |
445 | 445 |
446 for (var block of this._sectionBlocks) { | 446 for (var block of this._sectionBlocks) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 return link; | 686 return link; |
687 } | 687 } |
688 | 688 |
689 return createTextNode(''); | 689 return createTextNode(''); |
690 } | 690 } |
691 | 691 |
692 /** | 692 /** |
693 * @param {!SDK.CSSModel} cssModel | 693 * @param {!SDK.CSSModel} cssModel |
694 * @param {!Components.Linkifier} linkifier | 694 * @param {!Components.Linkifier} linkifier |
695 * @param {string} styleSheetId | 695 * @param {string} styleSheetId |
696 * @param {!Common.TextRange} ruleLocation | 696 * @param {!TextUtils.TextRange} ruleLocation |
697 * @return {!Node} | 697 * @return {!Node} |
698 */ | 698 */ |
699 static _linkifyRuleLocation(cssModel, linkifier, styleSheetId, ruleLocation) { | 699 static _linkifyRuleLocation(cssModel, linkifier, styleSheetId, ruleLocation) { |
700 var styleSheetHeader = cssModel.styleSheetHeaderForId(styleSheetId); | 700 var styleSheetHeader = cssModel.styleSheetHeaderForId(styleSheetId); |
701 var lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.startLine)
; | 701 var lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.startLine)
; |
702 var columnNumber = styleSheetHeader.columnNumberInSource(ruleLocation.startL
ine, ruleLocation.startColumn); | 702 var columnNumber = styleSheetHeader.columnNumberInSource(ruleLocation.startL
ine, ruleLocation.startColumn); |
703 var matchingSelectorLocation = new SDK.CSSLocation(styleSheetHeader, lineNum
ber, columnNumber); | 703 var matchingSelectorLocation = new SDK.CSSLocation(styleSheetHeader, lineNum
ber, columnNumber); |
704 return linkifier.linkifyCSSLocation(matchingSelectorLocation); | 704 return linkifier.linkifyCSSLocation(matchingSelectorLocation); |
705 } | 705 } |
706 | 706 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 891 |
892 return curElement ? curElement._section : null; | 892 return curElement ? curElement._section : null; |
893 } | 893 } |
894 | 894 |
895 /** | 895 /** |
896 * @param {!Common.Event} event | 896 * @param {!Common.Event} event |
897 */ | 897 */ |
898 _onNewRuleClick(event) { | 898 _onNewRuleClick(event) { |
899 event.data.consume(); | 899 event.data.consume(); |
900 var rule = this._style.parentRule; | 900 var rule = this._style.parentRule; |
901 var range = Common.TextRange.createFromLocation(rule.style.range.endLine, ru
le.style.range.endColumn + 1); | 901 var range = TextUtils.TextRange.createFromLocation(rule.style.range.endLine,
rule.style.range.endColumn + 1); |
902 this._parentPane._addBlankSection(this, /** @type {string} */ (rule.styleShe
etId), range); | 902 this._parentPane._addBlankSection(this, /** @type {string} */ (rule.styleShe
etId), range); |
903 } | 903 } |
904 | 904 |
905 /** | 905 /** |
906 * @param {string} propertyName | 906 * @param {string} propertyName |
907 * @param {!Common.Event} event | 907 * @param {!Common.Event} event |
908 */ | 908 */ |
909 _onInsertShadowPropertyClick(propertyName, event) { | 909 _onInsertShadowPropertyClick(propertyName, event) { |
910 event.data.consume(true); | 910 event.data.consume(true); |
911 var treeElement = this.addNewBlankProperty(); | 911 var treeElement = this.addNewBlankProperty(); |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 this._markSelectorMatches(); | 1556 this._markSelectorMatches(); |
1557 } | 1557 } |
1558 }; | 1558 }; |
1559 | 1559 |
1560 Elements.BlankStylePropertiesSection = class extends Elements.StylePropertiesSec
tion { | 1560 Elements.BlankStylePropertiesSection = class extends Elements.StylePropertiesSec
tion { |
1561 /** | 1561 /** |
1562 * @param {!Elements.StylesSidebarPane} stylesPane | 1562 * @param {!Elements.StylesSidebarPane} stylesPane |
1563 * @param {!SDK.CSSMatchedStyles} matchedStyles | 1563 * @param {!SDK.CSSMatchedStyles} matchedStyles |
1564 * @param {string} defaultSelectorText | 1564 * @param {string} defaultSelectorText |
1565 * @param {string} styleSheetId | 1565 * @param {string} styleSheetId |
1566 * @param {!Common.TextRange} ruleLocation | 1566 * @param {!TextUtils.TextRange} ruleLocation |
1567 * @param {!SDK.CSSStyleDeclaration} insertAfterStyle | 1567 * @param {!SDK.CSSStyleDeclaration} insertAfterStyle |
1568 */ | 1568 */ |
1569 constructor(stylesPane, matchedStyles, defaultSelectorText, styleSheetId, rule
Location, insertAfterStyle) { | 1569 constructor(stylesPane, matchedStyles, defaultSelectorText, styleSheetId, rule
Location, insertAfterStyle) { |
1570 var cssModel = /** @type {!SDK.CSSModel} */ (stylesPane.cssModel()); | 1570 var cssModel = /** @type {!SDK.CSSModel} */ (stylesPane.cssModel()); |
1571 var rule = SDK.CSSStyleRule.createDummyRule(cssModel, defaultSelectorText); | 1571 var rule = SDK.CSSStyleRule.createDummyRule(cssModel, defaultSelectorText); |
1572 super(stylesPane, matchedStyles, rule.style); | 1572 super(stylesPane, matchedStyles, rule.style); |
1573 this._normal = false; | 1573 this._normal = false; |
1574 this._ruleLocation = ruleLocation; | 1574 this._ruleLocation = ruleLocation; |
1575 this._styleSheetId = styleSheetId; | 1575 this._styleSheetId = styleSheetId; |
1576 this._selectorRefElement.removeChildren(); | 1576 this._selectorRefElement.removeChildren(); |
1577 this._selectorRefElement.appendChild(Elements.StylePropertiesSection._linkif
yRuleLocation( | 1577 this._selectorRefElement.appendChild(Elements.StylePropertiesSection._linkif
yRuleLocation( |
1578 cssModel, this._parentPane._linkifier, styleSheetId, this._actualRuleLoc
ation())); | 1578 cssModel, this._parentPane._linkifier, styleSheetId, this._actualRuleLoc
ation())); |
1579 if (insertAfterStyle && insertAfterStyle.parentRule) | 1579 if (insertAfterStyle && insertAfterStyle.parentRule) |
1580 this._createMediaList(insertAfterStyle.parentRule.media); | 1580 this._createMediaList(insertAfterStyle.parentRule.media); |
1581 this.element.classList.add('blank-section'); | 1581 this.element.classList.add('blank-section'); |
1582 } | 1582 } |
1583 | 1583 |
1584 /** | 1584 /** |
1585 * @return {!Common.TextRange} | 1585 * @return {!TextUtils.TextRange} |
1586 */ | 1586 */ |
1587 _actualRuleLocation() { | 1587 _actualRuleLocation() { |
1588 var prefix = this._rulePrefix(); | 1588 var prefix = this._rulePrefix(); |
1589 var lines = prefix.split('\n'); | 1589 var lines = prefix.split('\n'); |
1590 var editRange = new Common.TextRange(0, 0, lines.length - 1, lines.peekLast(
).length); | 1590 var editRange = new TextUtils.TextRange(0, 0, lines.length - 1, lines.peekLa
st().length); |
1591 return this._ruleLocation.rebaseAfterTextEdit(Common.TextRange.createFromLoc
ation(0, 0), editRange); | 1591 return this._ruleLocation.rebaseAfterTextEdit(TextUtils.TextRange.createFrom
Location(0, 0), editRange); |
1592 } | 1592 } |
1593 | 1593 |
1594 /** | 1594 /** |
1595 * @return {string} | 1595 * @return {string} |
1596 */ | 1596 */ |
1597 _rulePrefix() { | 1597 _rulePrefix() { |
1598 return this._ruleLocation.startLine === 0 && this._ruleLocation.startColumn
=== 0 ? '' : '\n\n'; | 1598 return this._ruleLocation.startLine === 0 && this._ruleLocation.startColumn
=== 0 ? '' : '\n\n'; |
1599 } | 1599 } |
1600 | 1600 |
1601 /** | 1601 /** |
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3013 var regexes = [SDK.CSSMetadata.VariableRegex, SDK.CSSMetadata.URLRegex]; | 3013 var regexes = [SDK.CSSMetadata.VariableRegex, SDK.CSSMetadata.URLRegex]; |
3014 var processors = [createTextNode, this._processURL.bind(this)]; | 3014 var processors = [createTextNode, this._processURL.bind(this)]; |
3015 if (this._bezierHandler && SDK.cssMetadata().isBezierAwareProperty(this._pro
pertyName)) { | 3015 if (this._bezierHandler && SDK.cssMetadata().isBezierAwareProperty(this._pro
pertyName)) { |
3016 regexes.push(UI.Geometry.CubicBezier.Regex); | 3016 regexes.push(UI.Geometry.CubicBezier.Regex); |
3017 processors.push(this._bezierHandler); | 3017 processors.push(this._bezierHandler); |
3018 } | 3018 } |
3019 if (this._colorHandler && SDK.cssMetadata().isColorAwareProperty(this._prope
rtyName)) { | 3019 if (this._colorHandler && SDK.cssMetadata().isColorAwareProperty(this._prope
rtyName)) { |
3020 regexes.push(Common.Color.Regex); | 3020 regexes.push(Common.Color.Regex); |
3021 processors.push(this._colorHandler); | 3021 processors.push(this._colorHandler); |
3022 } | 3022 } |
3023 var results = Common.TextUtils.splitStringByRegexes(this._propertyValue, reg
exes); | 3023 var results = TextUtils.TextUtils.splitStringByRegexes(this._propertyValue,
regexes); |
3024 for (var i = 0; i < results.length; i++) { | 3024 for (var i = 0; i < results.length; i++) { |
3025 var result = results[i]; | 3025 var result = results[i]; |
3026 var processor = result.regexIndex === -1 ? createTextNode : processors[res
ult.regexIndex]; | 3026 var processor = result.regexIndex === -1 ? createTextNode : processors[res
ult.regexIndex]; |
3027 valueElement.appendChild(processor(result.value)); | 3027 valueElement.appendChild(processor(result.value)); |
3028 } | 3028 } |
3029 valueElement.normalize(); | 3029 valueElement.normalize(); |
3030 return valueElement; | 3030 return valueElement; |
3031 } | 3031 } |
3032 | 3032 |
3033 /** | 3033 /** |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3092 } | 3092 } |
3093 | 3093 |
3094 /** | 3094 /** |
3095 * @override | 3095 * @override |
3096 * @return {!UI.ToolbarItem} | 3096 * @return {!UI.ToolbarItem} |
3097 */ | 3097 */ |
3098 item() { | 3098 item() { |
3099 return this._button; | 3099 return this._button; |
3100 } | 3100 } |
3101 }; | 3101 }; |
OLD | NEW |