Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 727823002: [DevTools] Ban getSelection, requestAnimationFrame, cancelAnimationFrame global functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 _handleEmptySpaceMouseDown: function() 1755 _handleEmptySpaceMouseDown: function()
1756 { 1756 {
1757 this._willCauseCancelEditing = this._parentPane._isEditingStyle; 1757 this._willCauseCancelEditing = this._parentPane._isEditingStyle;
1758 }, 1758 },
1759 1759
1760 _handleEmptySpaceClick: function(event) 1760 _handleEmptySpaceClick: function(event)
1761 { 1761 {
1762 if (!this.editable) 1762 if (!this.editable)
1763 return; 1763 return;
1764 1764
1765 if (!window.getSelection().isCollapsed) 1765 if (!event.target.window().getSelection().isCollapsed)
1766 return; 1766 return;
1767 1767
1768 if (this._checkWillCancelEditing()) 1768 if (this._checkWillCancelEditing())
1769 return; 1769 return;
1770 1770
1771 if (event.target.classList.contains("header") || this.element.classList. contains("read-only") || event.target.enclosingNodeOrSelfWithClass("media")) { 1771 if (event.target.classList.contains("header") || this.element.classList. contains("read-only") || event.target.enclosingNodeOrSelfWithClass("media")) {
1772 event.consume(); 1772 event.consume();
1773 return; 1773 return;
1774 } 1774 }
1775 this.expand(); 1775 this.expand();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 var element = this._selectorElement; 1815 var element = this._selectorElement;
1816 if (WebInspector.isBeingEdited(element)) 1816 if (WebInspector.isBeingEdited(element))
1817 return; 1817 return;
1818 1818
1819 element.scrollIntoViewIfNeeded(false); 1819 element.scrollIntoViewIfNeeded(false);
1820 element.textContent = element.textContent; // Reset selector marks in gr oup. 1820 element.textContent = element.textContent; // Reset selector marks in gr oup.
1821 1821
1822 var config = new WebInspector.InplaceEditor.Config(this.editingSelectorC ommitted.bind(this), this.editingSelectorCancelled.bind(this), undefined, this._ editingSelectorBlurHandler.bind(this)); 1822 var config = new WebInspector.InplaceEditor.Config(this.editingSelectorC ommitted.bind(this), this.editingSelectorCancelled.bind(this), undefined, this._ editingSelectorBlurHandler.bind(this));
1823 WebInspector.InplaceEditor.startEditing(this._selectorElement, config); 1823 WebInspector.InplaceEditor.startEditing(this._selectorElement, config);
1824 1824
1825 window.getSelection().setBaseAndExtent(element, 0, element, 1); 1825 element.window().getSelection().setBaseAndExtent(element, 0, element, 1) ;
1826 this._parentPane._isEditingStyle = true; 1826 this._parentPane._isEditingStyle = true;
1827 this._parentPane._startEditingSelector(this); 1827 this._parentPane._startEditingSelector(this);
1828 }, 1828 },
1829 1829
1830 /** 1830 /**
1831 * @param {string} text 1831 * @param {string} text
1832 */ 1832 */
1833 setSelectorText: function(text) 1833 setSelectorText: function(text)
1834 { 1834 {
1835 this._selectorElement.textContent = text; 1835 this._selectorElement.textContent = text;
1836 window.getSelection().setBaseAndExtent(this._selectorElement, 0, this._s electorElement, 1); 1836 this._selectorElement.window().getSelection().setBaseAndExtent(this._sel ectorElement, 0, this._selectorElement, 1);
1837 }, 1837 },
1838 1838
1839 /** 1839 /**
1840 * @param {!Element} editor 1840 * @param {!Element} editor
1841 * @param {!Event} blurEvent 1841 * @param {!Event} blurEvent
1842 * @return {boolean} 1842 * @return {boolean}
1843 */ 1843 */
1844 _editingSelectorBlurHandler: function(editor, blurEvent) 1844 _editingSelectorBlurHandler: function(editor, blurEvent)
1845 { 1845 {
1846 if (!blurEvent.relatedTarget) 1846 if (!blurEvent.relatedTarget)
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 enabledCheckboxElement.className = "enabled-button"; 2928 enabledCheckboxElement.className = "enabled-button";
2929 enabledCheckboxElement.type = "checkbox"; 2929 enabledCheckboxElement.type = "checkbox";
2930 enabledCheckboxElement.checked = !this.disabled; 2930 enabledCheckboxElement.checked = !this.disabled;
2931 enabledCheckboxElement.addEventListener("click", this.toggleEnabled. bind(this), false); 2931 enabledCheckboxElement.addEventListener("click", this.toggleEnabled. bind(this), false);
2932 this.listItemElement.insertBefore(enabledCheckboxElement, this.listI temElement.firstChild); 2932 this.listItemElement.insertBefore(enabledCheckboxElement, this.listI temElement.firstChild);
2933 } 2933 }
2934 }, 2934 },
2935 2935
2936 _mouseClick: function(event) 2936 _mouseClick: function(event)
2937 { 2937 {
2938 if (!window.getSelection().isCollapsed) 2938 if (!event.target.window().getSelection().isCollapsed)
2939 return; 2939 return;
2940 2940
2941 event.consume(true); 2941 event.consume(true);
2942 2942
2943 if (event.target === this.listItemElement) { 2943 if (event.target === this.listItemElement) {
2944 var section = this.section(); 2944 var section = this.section();
2945 if (!section || !section.editable) 2945 if (!section || !section.editable)
2946 return; 2946 return;
2947 2947
2948 if (section._checkWillCancelEditing()) 2948 if (section._checkWillCancelEditing())
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemAcc epted, applyItemCallback, this); 3114 this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemAcc epted, applyItemCallback, this);
3115 } 3115 }
3116 var proxyElement = this._prompt.attachAndStartEditing(selectElement, blu rListener.bind(this, context)); 3116 var proxyElement = this._prompt.attachAndStartEditing(selectElement, blu rListener.bind(this, context));
3117 3117
3118 proxyElement.addEventListener("keydown", this._editingNameValueKeyDown.b ind(this, context), false); 3118 proxyElement.addEventListener("keydown", this._editingNameValueKeyDown.b ind(this, context), false);
3119 proxyElement.addEventListener("keypress", this._editingNameValueKeyPress .bind(this, context), false); 3119 proxyElement.addEventListener("keypress", this._editingNameValueKeyPress .bind(this, context), false);
3120 proxyElement.addEventListener("input", this._editingNameValueInput.bind( this, context), false); 3120 proxyElement.addEventListener("input", this._editingNameValueInput.bind( this, context), false);
3121 if (isEditingName) 3121 if (isEditingName)
3122 proxyElement.addEventListener("paste", pasteHandler.bind(this, conte xt), false); 3122 proxyElement.addEventListener("paste", pasteHandler.bind(this, conte xt), false);
3123 3123
3124 window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1); 3124 selectElement.window().getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1);
3125 }, 3125 },
3126 3126
3127 /** 3127 /**
3128 * @param {!WebInspector.StylePropertyTreeElement.Context} context 3128 * @param {!WebInspector.StylePropertyTreeElement.Context} context
3129 * @param {!Event} event 3129 * @param {!Event} event
3130 */ 3130 */
3131 _editingNameValueKeyDown: function(context, event) 3131 _editingNameValueKeyDown: function(context, event)
3132 { 3132 {
3133 if (event.handled) 3133 if (event.handled)
3134 return; 3134 return;
3135 3135
3136 var result; 3136 var result;
3137 3137
3138 if (isEnterKey(event)) { 3138 if (isEnterKey(event)) {
3139 event.preventDefault(); 3139 event.preventDefault();
3140 result = "forward"; 3140 result = "forward";
3141 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.keyIdentifier === "U+001B") 3141 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.keyIdentifier === "U+001B")
3142 result = "cancel"; 3142 result = "cancel";
3143 else if (!context.isEditingName && this._newProperty && event.keyCode == = WebInspector.KeyboardShortcut.Keys.Backspace.code) { 3143 else if (!context.isEditingName && this._newProperty && event.keyCode == = WebInspector.KeyboardShortcut.Keys.Backspace.code) {
3144 // For a new property, when Backspace is pressed at the beginning of new property value, move back to the property name. 3144 // For a new property, when Backspace is pressed at the beginning of new property value, move back to the property name.
3145 var selection = window.getSelection(); 3145 var selection = event.target.window().getSelection();
3146 if (selection.isCollapsed && !selection.focusOffset) { 3146 if (selection.isCollapsed && !selection.focusOffset) {
3147 event.preventDefault(); 3147 event.preventDefault();
3148 result = "backward"; 3148 result = "backward";
3149 } 3149 }
3150 } else if (event.keyIdentifier === "U+0009") { // Tab key. 3150 } else if (event.keyIdentifier === "U+0009") { // Tab key.
3151 result = event.shiftKey ? "backward" : "forward"; 3151 result = event.shiftKey ? "backward" : "forward";
3152 event.preventDefault(); 3152 event.preventDefault();
3153 } 3153 }
3154 3154
3155 if (result) { 3155 if (result) {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase( ))) { 3668 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase( ))) {
3669 for (var i = 0; i < results.length; ++i) 3669 for (var i = 0; i < results.length; ++i)
3670 results[i] = results[i].toUpperCase(); 3670 results[i] = results[i].toUpperCase();
3671 } 3671 }
3672 var selectedIndex = this._cssCompletions.mostUsedOf(results); 3672 var selectedIndex = this._cssCompletions.mostUsedOf(results);
3673 completionsReadyCallback(results, selectedIndex); 3673 completionsReadyCallback(results, selectedIndex);
3674 }, 3674 },
3675 3675
3676 __proto__: WebInspector.TextPrompt.prototype 3676 __proto__: WebInspector.TextPrompt.prototype
3677 } 3677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698