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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js

Issue 2588833004: DevTools: better hasSelection check to include composed trees (Closed)
Patch Set: ac Created 3 years, 12 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // FIXME: crbug.com/447523, use selection.isCollapsed when it is fixed for sha dow dom. 270 // FIXME: crbug.com/447523, use selection.isCollapsed when it is fixed for sha dow dom.
271 var selection = this.getComponentSelection(); 271 var selection = this.getComponentSelection();
272 var range = selection && selection.rangeCount ? selection.getRangeAt(0) : null ; 272 var range = selection && selection.rangeCount ? selection.getRangeAt(0) : null ;
273 return range ? range.collapsed : true; 273 return range ? range.collapsed : true;
274 }; 274 };
275 275
276 /** 276 /**
277 * @return {boolean} 277 * @return {boolean}
278 */ 278 */
279 Node.prototype.hasSelection = function() { 279 Node.prototype.hasSelection = function() {
280 // FIXME: use contains(node, {includeShadow: true}) when it is fixed for shado w dom.
dgozman 2016/12/22 01:59:33 TODO(luoe)
luoe 2016/12/22 02:03:56 Done.
281 var contents = this.querySelectorAll('content');
282 for (var content of contents) {
283 if (Array.prototype.some.call(content.getDistributedNodes(), node => node.ha sSelection()))
allada 2016/12/20 18:41:36 Why Array.prototype.some.call? Why not just acces
luoe 2016/12/20 19:23:58 getDistributedNodes() returns a NodeList, which do
allada 2016/12/21 23:28:26 I see.
284 return true;
285 }
280 if (this.isComponentSelectionCollapsed()) 286 if (this.isComponentSelectionCollapsed())
281 return false; 287 return false;
282 return this.getComponentSelection().containsNode(this, true); 288 return this.getComponentSelection().containsNode(this, true);
283 }; 289 };
284 290
285 /** 291 /**
286 * @return {!Selection} 292 * @return {!Selection}
287 */ 293 */
288 Node.prototype.getDeepSelection = function() { 294 Node.prototype.getDeepSelection = function() {
289 var activeElement = this.ownerDocument.activeElement; 295 var activeElement = this.ownerDocument.activeElement;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 function windowLoaded() { 824 function windowLoaded() {
819 window.removeEventListener('DOMContentLoaded', windowLoaded, false); 825 window.removeEventListener('DOMContentLoaded', windowLoaded, false);
820 callback(); 826 callback();
821 } 827 }
822 828
823 if (document.readyState === 'complete' || document.readyState === 'interactive ') 829 if (document.readyState === 'complete' || document.readyState === 'interactive ')
824 callback(); 830 callback();
825 else 831 else
826 window.addEventListener('DOMContentLoaded', windowLoaded, false); 832 window.addEventListener('DOMContentLoaded', windowLoaded, false);
827 } 833 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698