| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
| 5 * Copyright (C) 2009 Joseph Pecoraro | 5 * Copyright (C) 2009 Joseph Pecoraro |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * | 10 * |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 while (element) { | 187 while (element) { |
| 188 if (element.__editing) | 188 if (element.__editing) |
| 189 return true; | 189 return true; |
| 190 element = element.parentElementOrShadowHost(); | 190 element = element.parentElementOrShadowHost(); |
| 191 } | 191 } |
| 192 return false; | 192 return false; |
| 193 } | 193 } |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * @return {boolean} |
| 197 */ |
| 198 WebInspector.isEditing = function() |
| 199 { |
| 200 if (WebInspector.__editingCount) |
| 201 return true; |
| 202 |
| 203 var element = WebInspector.currentFocusElement(); |
| 204 if (!element) |
| 205 return false; |
| 206 return element.classList.contains("text-prompt") || element.nodeName === "IN
PUT" || element.nodeName === "TEXTAREA"; |
| 207 } |
| 208 |
| 209 /** |
| 196 * @param {!Element} element | 210 * @param {!Element} element |
| 197 * @param {boolean} value | 211 * @param {boolean} value |
| 198 * @return {boolean} | 212 * @return {boolean} |
| 199 */ | 213 */ |
| 200 WebInspector.markBeingEdited = function(element, value) | 214 WebInspector.markBeingEdited = function(element, value) |
| 201 { | 215 { |
| 202 if (value) { | 216 if (value) { |
| 203 if (element.__editing) | 217 if (element.__editing) |
| 204 return false; | 218 return false; |
| 205 element.classList.add("being-edited"); | 219 element.classList.add("being-edited"); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 635 } |
| 622 | 636 |
| 623 /** | 637 /** |
| 624 * @return {!Element} | 638 * @return {!Element} |
| 625 */ | 639 */ |
| 626 WebInspector.currentFocusElement = function() | 640 WebInspector.currentFocusElement = function() |
| 627 { | 641 { |
| 628 return WebInspector._currentFocusElement; | 642 return WebInspector._currentFocusElement; |
| 629 } | 643 } |
| 630 | 644 |
| 631 WebInspector._focusChanged = function(event) | 645 /** |
| 646 * @param {!Document} document |
| 647 * @param {!Event} event |
| 648 */ |
| 649 WebInspector._focusChanged = function(document, event) |
| 632 { | 650 { |
| 633 WebInspector.setCurrentFocusElement(event.target); | 651 var node = document.activeElement; |
| 652 while (node && node.shadowRoot) |
| 653 node = node.shadowRoot.activeElement; |
| 654 WebInspector.setCurrentFocusElement(node); |
| 634 } | 655 } |
| 635 | 656 |
| 636 /** | 657 /** |
| 637 * @param {!Document} document | 658 * @param {!Document} document |
| 638 * @param {!Event} event | 659 * @param {!Event} event |
| 639 */ | 660 */ |
| 640 WebInspector._documentBlurred = function(document, event) | 661 WebInspector._documentBlurred = function(document, event) |
| 641 { | 662 { |
| 642 // We want to know when currentFocusElement loses focus to nowhere. | 663 // We want to know when currentFocusElement loses focus to nowhere. |
| 643 // This is the case when event.relatedTarget is null (no element is being fo
cused) | 664 // This is the case when event.relatedTarget is null (no element is being fo
cused) |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 __proto__: WebInspector.Object.prototype | 1135 __proto__: WebInspector.Object.prototype |
| 1115 } | 1136 } |
| 1116 | 1137 |
| 1117 /** | 1138 /** |
| 1118 * @param {!Window} window | 1139 * @param {!Window} window |
| 1119 */ | 1140 */ |
| 1120 WebInspector.initializeUIUtils = function(window) | 1141 WebInspector.initializeUIUtils = function(window) |
| 1121 { | 1142 { |
| 1122 window.addEventListener("focus", WebInspector._windowFocused.bind(WebInspect
or, window.document), false); | 1143 window.addEventListener("focus", WebInspector._windowFocused.bind(WebInspect
or, window.document), false); |
| 1123 window.addEventListener("blur", WebInspector._windowBlurred.bind(WebInspecto
r, window.document), false); | 1144 window.addEventListener("blur", WebInspector._windowBlurred.bind(WebInspecto
r, window.document), false); |
| 1124 window.document.addEventListener("focus", WebInspector._focusChanged, true); | 1145 window.document.addEventListener("focus", WebInspector._focusChanged.bind(We
bInspector, window.document), true); |
| 1125 window.document.addEventListener("blur", WebInspector._documentBlurred.bind(
WebInspector, window.document), true); | 1146 window.document.addEventListener("blur", WebInspector._documentBlurred.bind(
WebInspector, window.document), true); |
| 1126 } | 1147 } |
| OLD | NEW |