Chromium Code Reviews| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 * @return {boolean} | 172 * @return {boolean} |
| 173 */ | 173 */ |
| 174 WebInspector.isBeingEdited = function(node) | 174 WebInspector.isBeingEdited = function(node) |
| 175 { | 175 { |
| 176 if (!node || node.nodeType !== Node.ELEMENT_NODE) | 176 if (!node || node.nodeType !== Node.ELEMENT_NODE) |
| 177 return false; | 177 return false; |
| 178 var element = /** {!Element} */ (node); | 178 var element = /** {!Element} */ (node); |
| 179 if (element.classList.contains("text-prompt") || element.nodeName === "INPUT " || element.nodeName === "TEXTAREA") | 179 if (element.classList.contains("text-prompt") || element.nodeName === "INPUT " || element.nodeName === "TEXTAREA") |
| 180 return true; | 180 return true; |
| 181 | 181 |
| 182 if (!WebInspector.__editingCount) | 182 if (!!WebInspector.__editingCount) |
|
vsevik
2014/10/21 12:59:56
!
pfeldman
2014/10/21 13:01:55
Done.
| |
| 183 return false; | 183 return false; |
| 184 | 184 |
| 185 while (element) { | 185 while (element) { |
| 186 if (element.__editing) | 186 if (element.__editing) |
| 187 return true; | 187 return true; |
| 188 element = element.parentElementOrShadowHost(); | 188 element = element.parentElementOrShadowHost(); |
| 189 } | 189 } |
| 190 return false; | 190 return false; |
| 191 } | 191 } |
| 192 | 192 |
| 193 /** | 193 /** |
| 194 * @return {boolean} | |
| 195 */ | |
| 196 WebInspector.isEditing = function() | |
| 197 { | |
| 198 if (WebInspector.__editingCount) | |
| 199 return true; | |
| 200 | |
| 201 var element = WebInspector.currentFocusElement(); | |
| 202 if (!element) | |
| 203 return false; | |
| 204 return element.classList.contains("text-prompt") || element.nodeName === "IN PUT" || element.nodeName === "TEXTAREA"; | |
| 205 } | |
| 206 | |
| 207 /** | |
| 194 * @param {!Element} element | 208 * @param {!Element} element |
| 195 * @param {boolean} value | 209 * @param {boolean} value |
| 196 * @return {boolean} | 210 * @return {boolean} |
| 197 */ | 211 */ |
| 198 WebInspector.markBeingEdited = function(element, value) | 212 WebInspector.markBeingEdited = function(element, value) |
| 199 { | 213 { |
| 200 if (value) { | 214 if (value) { |
| 201 if (element.__editing) | 215 if (element.__editing) |
| 202 return false; | 216 return false; |
| 203 element.classList.add("being-edited"); | 217 element.classList.add("being-edited"); |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 /** | 615 /** |
| 602 * @return {!Element} | 616 * @return {!Element} |
| 603 */ | 617 */ |
| 604 WebInspector.currentFocusElement = function() | 618 WebInspector.currentFocusElement = function() |
| 605 { | 619 { |
| 606 return WebInspector._currentFocusElement; | 620 return WebInspector._currentFocusElement; |
| 607 } | 621 } |
| 608 | 622 |
| 609 WebInspector._focusChanged = function(event) | 623 WebInspector._focusChanged = function(event) |
| 610 { | 624 { |
| 611 WebInspector.setCurrentFocusElement(event.target); | 625 var node = document.activeElement; |
| 626 while (node && node.shadowRoot) | |
| 627 node = node.shadowRoot.activeElement; | |
| 628 WebInspector.setCurrentFocusElement(node); | |
| 612 } | 629 } |
| 613 | 630 |
| 614 WebInspector._documentBlurred = function(event) | 631 WebInspector._documentBlurred = function(event) |
| 615 { | 632 { |
| 616 // We want to know when currentFocusElement loses focus to nowhere. | 633 // We want to know when currentFocusElement loses focus to nowhere. |
| 617 // This is the case when event.relatedTarget is null (no element is being fo cused) | 634 // This is the case when event.relatedTarget is null (no element is being fo cused) |
| 618 // and document.activeElement is reset to default (this is not a window blur ). | 635 // and document.activeElement is reset to default (this is not a window blur ). |
| 619 if (!event.relatedTarget && document.activeElement === document.body) | 636 if (!event.relatedTarget && document.activeElement === document.body) |
| 620 WebInspector.setCurrentFocusElement(null); | 637 WebInspector.setCurrentFocusElement(null); |
| 621 } | 638 } |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1080 delete this._longClickData; | 1097 delete this._longClickData; |
| 1081 }, | 1098 }, |
| 1082 | 1099 |
| 1083 __proto__: WebInspector.Object.prototype | 1100 __proto__: WebInspector.Object.prototype |
| 1084 } | 1101 } |
| 1085 | 1102 |
| 1086 WebInspector.initializeUIUtils = function() | 1103 WebInspector.initializeUIUtils = function() |
| 1087 { | 1104 { |
| 1088 window.addEventListener("focus", WebInspector._windowFocused, false); | 1105 window.addEventListener("focus", WebInspector._windowFocused, false); |
| 1089 window.addEventListener("blur", WebInspector._windowBlurred, false); | 1106 window.addEventListener("blur", WebInspector._windowBlurred, false); |
| 1107 document.addEventListener("blur", WebInspector._documentBlurred, true); | |
|
vsevik
2014/10/21 12:59:56
revert
pfeldman
2014/10/21 13:01:55
Done.
| |
| 1090 document.addEventListener("focus", WebInspector._focusChanged, true); | 1108 document.addEventListener("focus", WebInspector._focusChanged, true); |
| 1091 document.addEventListener("blur", WebInspector._documentBlurred, true); | |
| 1092 } | 1109 } |
| OLD | NEW |