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

Side by Side Diff: Source/devtools/front_end/elements/ElementsTreeOutline.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, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 /** 231 /**
232 * @param {boolean} isCut 232 * @param {boolean} isCut
233 * @param {!Event} event 233 * @param {!Event} event
234 */ 234 */
235 handleCopyOrCutKeyboardEvent: function(isCut, event) 235 handleCopyOrCutKeyboardEvent: function(isCut, event)
236 { 236 {
237 this._setClipboardData(null); 237 this._setClipboardData(null);
238 238
239 // Don't prevent the normal copy if the user has a selection. 239 // Don't prevent the normal copy if the user has a selection.
240 if (!window.getSelection().isCollapsed) 240 if (!event.target.window().getSelection().isCollapsed)
241 return; 241 return;
242 242
243 // Do not interfere with text editing. 243 // Do not interfere with text editing.
244 if (WebInspector.isEditing()) 244 if (WebInspector.isEditing())
245 return; 245 return;
246 246
247 var targetNode = this.selectedDOMNode(); 247 var targetNode = this.selectedDOMNode();
248 if (!targetNode) 248 if (!targetNode)
249 return; 249 return;
250 250
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 if (this._previousHoveredElement) { 625 if (this._previousHoveredElement) {
626 this._previousHoveredElement.hovered = false; 626 this._previousHoveredElement.hovered = false;
627 delete this._previousHoveredElement; 627 delete this._previousHoveredElement;
628 } 628 }
629 629
630 this._domModel.hideDOMNodeHighlight(); 630 this._domModel.hideDOMNodeHighlight();
631 }, 631 },
632 632
633 _ondragstart: function(event) 633 _ondragstart: function(event)
634 { 634 {
635 if (!window.getSelection().isCollapsed) 635 if (!event.target.window().getSelection().isCollapsed)
636 return false; 636 return false;
637 if (event.target.nodeName === "A") 637 if (event.target.nodeName === "A")
638 return false; 638 return false;
639 639
640 var treeElement = this._treeElementFromEvent(event); 640 var treeElement = this._treeElementFromEvent(event);
641 if (!this._isValidDragSourceOrTarget(treeElement)) 641 if (!this._isValidDragSourceOrTarget(treeElement))
642 return false; 642 return false;
643 643
644 if (treeElement._node.nodeName() === "BODY" || treeElement._node.nodeNam e() === "HEAD") 644 if (treeElement._node.nodeName() === "BODY" || treeElement._node.nodeNam e() === "HEAD")
645 return false; 645 return false;
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 else { 1821 else {
1822 WebInspector.handleElementValueModifications(event, attribute); 1822 WebInspector.handleElementValueModifications(event, attribute);
1823 return ""; 1823 return "";
1824 } 1824 }
1825 } 1825 }
1826 1826
1827 config.customFinishHandler = handleKeyDownEvents; 1827 config.customFinishHandler = handleKeyDownEvents;
1828 1828
1829 this._editing = WebInspector.InplaceEditor.startEditing(attribute, confi g); 1829 this._editing = WebInspector.InplaceEditor.startEditing(attribute, confi g);
1830 1830
1831 window.getSelection().setBaseAndExtent(elementForSelection, 0, elementFo rSelection, 1); 1831 this.listItemElement.window().getSelection().setBaseAndExtent(elementFor Selection, 0, elementForSelection, 1);
1832 1832
1833 return true; 1833 return true;
1834 }, 1834 },
1835 1835
1836 /** 1836 /**
1837 * @param {!Element} textNodeElement 1837 * @param {!Element} textNodeElement
1838 */ 1838 */
1839 _startEditingTextNode: function(textNodeElement) 1839 _startEditingTextNode: function(textNodeElement)
1840 { 1840 {
1841 if (WebInspector.isBeingEdited(textNodeElement)) 1841 if (WebInspector.isBeingEdited(textNodeElement))
1842 return true; 1842 return true;
1843 1843
1844 var textNode = this._node; 1844 var textNode = this._node;
1845 // We only show text nodes inline in elements if the element only 1845 // We only show text nodes inline in elements if the element only
1846 // has a single child, and that child is a text node. 1846 // has a single child, and that child is a text node.
1847 if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild) 1847 if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild)
1848 textNode = textNode.firstChild; 1848 textNode = textNode.firstChild;
1849 1849
1850 var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-htm l-text-node"); 1850 var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-htm l-text-node");
1851 if (container) 1851 if (container)
1852 container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present. 1852 container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present.
1853 var config = new WebInspector.InplaceEditor.Config(this._textNodeEditing Committed.bind(this, textNode), this._editingCancelled.bind(this)); 1853 var config = new WebInspector.InplaceEditor.Config(this._textNodeEditing Committed.bind(this, textNode), this._editingCancelled.bind(this));
1854 this._editing = WebInspector.InplaceEditor.startEditing(textNodeElement, config); 1854 this._editing = WebInspector.InplaceEditor.startEditing(textNodeElement, config);
1855 window.getSelection().setBaseAndExtent(textNodeElement, 0, textNodeEleme nt, 1); 1855 this.listItemElement.window().getSelection().setBaseAndExtent(textNodeEl ement, 0, textNodeElement, 1);
1856 1856
1857 return true; 1857 return true;
1858 }, 1858 },
1859 1859
1860 /** 1860 /**
1861 * @param {!Element=} tagNameElement 1861 * @param {!Element=} tagNameElement
1862 */ 1862 */
1863 _startEditingTagName: function(tagNameElement) 1863 _startEditingTagName: function(tagNameElement)
1864 { 1864 {
1865 if (!tagNameElement) { 1865 if (!tagNameElement) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 function editingCancelled() 1903 function editingCancelled()
1904 { 1904 {
1905 tagNameElement.removeEventListener('keyup', keyupListener, false); 1905 tagNameElement.removeEventListener('keyup', keyupListener, false);
1906 this._editingCancelled.apply(this, arguments); 1906 this._editingCancelled.apply(this, arguments);
1907 } 1907 }
1908 1908
1909 tagNameElement.addEventListener('keyup', keyupListener, false); 1909 tagNameElement.addEventListener('keyup', keyupListener, false);
1910 1910
1911 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind( this), editingCancelled.bind(this), tagName); 1911 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind( this), editingCancelled.bind(this), tagName);
1912 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement, config); 1912 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement, config);
1913 window.getSelection().setBaseAndExtent(tagNameElement, 0, tagNameElement , 1); 1913 this.listItemElement.window().getSelection().setBaseAndExtent(tagNameEle ment, 0, tagNameElement, 1);
1914 return true; 1914 return true;
1915 }, 1915 },
1916 1916
1917 /** 1917 /**
1918 * @param {function(string, string)} commitCallback 1918 * @param {function(string, string)} commitCallback
1919 * @param {?Protocol.Error} error 1919 * @param {?Protocol.Error} error
1920 * @param {string} initialValue 1920 * @param {string} initialValue
1921 */ 1921 */
1922 _startEditingAsHTML: function(commitCallback, error, initialValue) 1922 _startEditingAsHTML: function(commitCallback, error, initialValue)
1923 { 1923 {
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 treeOutline.rootDOMNode = node; 3163 treeOutline.rootDOMNode = node;
3164 if (!treeOutline.children[0].hasChildren) 3164 if (!treeOutline.children[0].hasChildren)
3165 treeOutline._element.classList.add("single-node"); 3165 treeOutline._element.classList.add("single-node");
3166 treeOutline.setVisible(true); 3166 treeOutline.setVisible(true);
3167 treeOutline.element.treeElementForTest = treeOutline.children[0] ; 3167 treeOutline.element.treeElementForTest = treeOutline.children[0] ;
3168 resolve(treeOutline.element); 3168 resolve(treeOutline.element);
3169 } 3169 }
3170 } 3170 }
3171 } 3171 }
3172 } 3172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698