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

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: a 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.
281 var contents = this.querySelectorAll('content');
282 for (var i = 0; i < contents.length; ++i) {
283 var contentElement = contents[i].getDistributedNodes();
allada 2016/12/20 02:15:28 Wouldnt it be easier to read using something like:
luoe 2016/12/20 02:41:03 Done.
284 for (var j = 0; j < contentElement.length; ++j) {
285 if (contentElement[j].hasSelection())
286 return true;
287 }
288 }
280 if (this.isComponentSelectionCollapsed()) 289 if (this.isComponentSelectionCollapsed())
281 return false; 290 return false;
282 return this.getComponentSelection().containsNode(this, true); 291 return this.getComponentSelection().containsNode(this, true);
283 }; 292 };
284 293
285 /** 294 /**
286 * @return {!Selection} 295 * @return {!Selection}
287 */ 296 */
288 Node.prototype.getDeepSelection = function() { 297 Node.prototype.getDeepSelection = function() {
289 var activeElement = this.ownerDocument.activeElement; 298 var activeElement = this.ownerDocument.activeElement;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 function windowLoaded() { 827 function windowLoaded() {
819 window.removeEventListener('DOMContentLoaded', windowLoaded, false); 828 window.removeEventListener('DOMContentLoaded', windowLoaded, false);
820 callback(); 829 callback();
821 } 830 }
822 831
823 if (document.readyState === 'complete' || document.readyState === 'interactive ') 832 if (document.readyState === 'complete' || document.readyState === 'interactive ')
824 callback(); 833 callback();
825 else 834 else
826 window.addEventListener('DOMContentLoaded', windowLoaded, false); 835 window.addEventListener('DOMContentLoaded', windowLoaded, false);
827 } 836 }
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