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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 function createRange() | 356 function createRange() |
357 { | 357 { |
358 return document.createRange(); | 358 return document.createRange(); |
359 } | 359 } |
360 | 360 |
361 var arrowKeyOrMouseWheelEvent = (event.keyIdentifier === "Up" || event.keyId
entifier === "Down" || event.type === "mousewheel"); | 361 var arrowKeyOrMouseWheelEvent = (event.keyIdentifier === "Up" || event.keyId
entifier === "Down" || event.type === "mousewheel"); |
362 var pageKeyPressed = (event.keyIdentifier === "PageUp" || event.keyIdentifie
r === "PageDown"); | 362 var pageKeyPressed = (event.keyIdentifier === "PageUp" || event.keyIdentifie
r === "PageDown"); |
363 if (!arrowKeyOrMouseWheelEvent && !pageKeyPressed) | 363 if (!arrowKeyOrMouseWheelEvent && !pageKeyPressed) |
364 return false; | 364 return false; |
365 | 365 |
366 var selection = window.getSelection(); | 366 var selection = element.window().getSelection(); |
367 if (!selection.rangeCount) | 367 if (!selection.rangeCount) |
368 return false; | 368 return false; |
369 | 369 |
370 var selectionRange = selection.getRangeAt(0); | 370 var selectionRange = selection.getRangeAt(0); |
371 if (!selectionRange.commonAncestorContainer.isSelfOrDescendant(element)) | 371 if (!selectionRange.commonAncestorContainer.isSelfOrDescendant(element)) |
372 return false; | 372 return false; |
373 | 373 |
374 var originalValue = element.textContent; | 374 var originalValue = element.textContent; |
375 var wordRange = selectionRange.startContainer.rangeOfWord(selectionRange.sta
rtOffset, WebInspector.StyleValueDelimiters, element); | 375 var wordRange = selectionRange.startContainer.rangeOfWord(selectionRange.sta
rtOffset, WebInspector.StyleValueDelimiters, element); |
376 var wordString = wordRange.toString(); | 376 var wordString = wordRange.toString(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 { | 690 { |
691 if (element instanceof HTMLInputElement) | 691 if (element instanceof HTMLInputElement) |
692 return element.type in WebInspector._textInputTypes; | 692 return element.type in WebInspector._textInputTypes; |
693 | 693 |
694 if (element instanceof HTMLTextAreaElement) | 694 if (element instanceof HTMLTextAreaElement) |
695 return true; | 695 return true; |
696 | 696 |
697 return false; | 697 return false; |
698 } | 698 } |
699 | 699 |
| 700 /** |
| 701 * @param {?Node} x |
| 702 */ |
700 WebInspector.setCurrentFocusElement = function(x) | 703 WebInspector.setCurrentFocusElement = function(x) |
701 { | 704 { |
702 if (WebInspector._glassPane && x && !WebInspector._glassPane.element.isAnces
tor(x)) | 705 if (WebInspector._glassPane && x && !WebInspector._glassPane.element.isAnces
tor(x)) |
703 return; | 706 return; |
704 if (WebInspector._currentFocusElement !== x) | 707 if (WebInspector._currentFocusElement !== x) |
705 WebInspector._previousFocusElement = WebInspector._currentFocusElement; | 708 WebInspector._previousFocusElement = WebInspector._currentFocusElement; |
706 WebInspector._currentFocusElement = x; | 709 WebInspector._currentFocusElement = x; |
707 | 710 |
708 if (WebInspector._currentFocusElement) { | 711 if (WebInspector._currentFocusElement) { |
709 WebInspector._currentFocusElement.focus(); | 712 WebInspector._currentFocusElement.focus(); |
710 | 713 |
711 // Make a caret selection inside the new element if there isn't a range
selection and there isn't already a caret selection inside. | 714 // Make a caret selection inside the new element if there isn't a range
selection and there isn't already a caret selection inside. |
712 // This is needed (at least) to remove caret from console when focus is
moved to some element in the panel. | 715 // This is needed (at least) to remove caret from console when focus is
moved to some element in the panel. |
713 // The code below should not be applied to text fields and text areas, h
ence _isTextEditingElement check. | 716 // The code below should not be applied to text fields and text areas, h
ence _isTextEditingElement check. |
714 var selection = window.getSelection(); | 717 var selection = x.window().getSelection(); |
715 if (!WebInspector._isTextEditingElement(WebInspector._currentFocusElemen
t) && selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCar
etInside()) { | 718 if (!WebInspector._isTextEditingElement(WebInspector._currentFocusElemen
t) && selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCar
etInside()) { |
716 var selectionRange = WebInspector._currentFocusElement.ownerDocument
.createRange(); | 719 var selectionRange = WebInspector._currentFocusElement.ownerDocument
.createRange(); |
717 selectionRange.setStart(WebInspector._currentFocusElement, 0); | 720 selectionRange.setStart(WebInspector._currentFocusElement, 0); |
718 selectionRange.setEnd(WebInspector._currentFocusElement, 0); | 721 selectionRange.setEnd(WebInspector._currentFocusElement, 0); |
719 | 722 |
720 selection.removeAllRanges(); | 723 selection.removeAllRanges(); |
721 selection.addRange(selectionRange); | 724 selection.addRange(selectionRange); |
722 } | 725 } |
723 } else if (WebInspector._previousFocusElement) | 726 } else if (WebInspector._previousFocusElement) |
724 WebInspector._previousFocusElement.blur(); | 727 WebInspector._previousFocusElement.blur(); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 this.scheduleInvoke(); | 983 this.scheduleInvoke(); |
981 } | 984 } |
982 var methods = this._handlers.get(object); | 985 var methods = this._handlers.get(object); |
983 if (!methods) { | 986 if (!methods) { |
984 methods = new Set(); | 987 methods = new Set(); |
985 this._handlers.set(object, methods); | 988 this._handlers.set(object, methods); |
986 } | 989 } |
987 methods.add(method); | 990 methods.add(method); |
988 }, | 991 }, |
989 | 992 |
| 993 /** |
| 994 * @suppressGlobalPropertiesCheck |
| 995 */ |
990 scheduleInvoke: function() | 996 scheduleInvoke: function() |
991 { | 997 { |
992 if (this._handlers) | 998 if (this._handlers) |
993 requestAnimationFrame(this._invoke.bind(this)); | 999 requestAnimationFrame(this._invoke.bind(this)); |
994 }, | 1000 }, |
995 | 1001 |
996 _invoke: function() | 1002 _invoke: function() |
997 { | 1003 { |
998 var handlers = this._handlers; | 1004 var handlers = this._handlers; |
999 this._handlers = null; | 1005 this._handlers = null; |
(...skipping 29 matching lines...) Expand all Loading... |
1029 * @param {function()} method | 1035 * @param {function()} method |
1030 */ | 1036 */ |
1031 WebInspector.invokeOnceAfterBatchUpdate = function(object, method) | 1037 WebInspector.invokeOnceAfterBatchUpdate = function(object, method) |
1032 { | 1038 { |
1033 if (!WebInspector._postUpdateHandlers) | 1039 if (!WebInspector._postUpdateHandlers) |
1034 WebInspector._postUpdateHandlers = new WebInspector.InvokeOnceHandlers(t
rue); | 1040 WebInspector._postUpdateHandlers = new WebInspector.InvokeOnceHandlers(t
rue); |
1035 WebInspector._postUpdateHandlers.add(object, method); | 1041 WebInspector._postUpdateHandlers.add(object, method); |
1036 } | 1042 } |
1037 | 1043 |
1038 /** | 1044 /** |
| 1045 * @param {!Window} window |
1039 * @param {!Function} func | 1046 * @param {!Function} func |
1040 * @param {!Array.<{from:number, to:number}>} params | 1047 * @param {!Array.<{from:number, to:number}>} params |
1041 * @param {number} frames | 1048 * @param {number} frames |
1042 * @param {function()=} animationComplete | 1049 * @param {function()=} animationComplete |
1043 * @return {function()} | 1050 * @return {function()} |
1044 */ | 1051 */ |
1045 WebInspector.animateFunction = function(func, params, frames, animationComplete) | 1052 WebInspector.animateFunction = function(window, func, params, frames, animationC
omplete) |
1046 { | 1053 { |
1047 var values = new Array(params.length); | 1054 var values = new Array(params.length); |
1048 var deltas = new Array(params.length); | 1055 var deltas = new Array(params.length); |
1049 for (var i = 0; i < params.length; ++i) { | 1056 for (var i = 0; i < params.length; ++i) { |
1050 values[i] = params[i].from; | 1057 values[i] = params[i].from; |
1051 deltas[i] = (params[i].to - params[i].from) / frames; | 1058 deltas[i] = (params[i].to - params[i].from) / frames; |
1052 } | 1059 } |
1053 | 1060 |
1054 var raf = requestAnimationFrame(animationStep); | 1061 var raf = window.requestAnimationFrame(animationStep); |
1055 | 1062 |
1056 var framesLeft = frames; | 1063 var framesLeft = frames; |
1057 | 1064 |
1058 function animationStep() | 1065 function animationStep() |
1059 { | 1066 { |
1060 if (--framesLeft < 0) { | 1067 if (--framesLeft < 0) { |
1061 if (animationComplete) | 1068 if (animationComplete) |
1062 animationComplete(); | 1069 animationComplete(); |
1063 return; | 1070 return; |
1064 } | 1071 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 /** | 1228 /** |
1222 * @param {!Window} window | 1229 * @param {!Window} window |
1223 */ | 1230 */ |
1224 WebInspector.initializeUIUtils = function(window) | 1231 WebInspector.initializeUIUtils = function(window) |
1225 { | 1232 { |
1226 window.addEventListener("focus", WebInspector._windowFocused.bind(WebInspect
or, window.document), false); | 1233 window.addEventListener("focus", WebInspector._windowFocused.bind(WebInspect
or, window.document), false); |
1227 window.addEventListener("blur", WebInspector._windowBlurred.bind(WebInspecto
r, window.document), false); | 1234 window.addEventListener("blur", WebInspector._windowBlurred.bind(WebInspecto
r, window.document), false); |
1228 window.document.addEventListener("focus", WebInspector._focusChanged.bind(We
bInspector, window.document), true); | 1235 window.document.addEventListener("focus", WebInspector._focusChanged.bind(We
bInspector, window.document), true); |
1229 window.document.addEventListener("blur", WebInspector._documentBlurred.bind(
WebInspector, window.document), true); | 1236 window.document.addEventListener("blur", WebInspector._documentBlurred.bind(
WebInspector, window.document), true); |
1230 } | 1237 } |
OLD | NEW |