Chromium Code Reviews| 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) 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |