Changeset 31688 in webkit
- Timestamp:
- Apr 7, 2008 1:01:54 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r31687 r31688 1 2008-04-07 Timothy Hatcher <timothy@apple.com> 2 3 When the WebInspector.currentFocusElement changes, move the caret 4 selection to be inside the focused element. This makes sure the 5 caret moves in and out of the console when the focus changes. 6 7 Reviewed by Adam Roben. 8 9 * page/inspector/TextPrompt.js: 10 (TextPrompt.prototype.isCaretInsidePrompt): Just call isInsertionCaretInside. 11 * page/inspector/inspector.js: 12 (WebInspector.set currentFocusElement): Make a caret selection inside 13 the focused element if there isn't a range selection and there isn't 14 already a caret selection inside. 15 * page/inspector/utilities.js: 16 (Element.prototype.isInsertionCaretInside): Added. Tests if the 17 selection is collapsed and is inside the element. 18 1 19 2008-04-07 Brady Eidson <beidson@apple.com> 2 20 -
trunk/WebCore/page/inspector/TextPrompt.js
r31648 r31688 263 263 isCaretInsidePrompt: function() 264 264 { 265 var selection = window.getSelection(); 266 if (!selection.rangeCount || !selection.isCollapsed) 267 return false; 268 var selectionRange = selection.getRangeAt(0); 269 return selectionRange.startContainer === this.element || selectionRange.startContainer.isDescendant(this.element); 265 return this.element.isInsertionCaretInside(); 270 266 }, 271 267 -
trunk/WebCore/page/inspector/inspector.js
r31641 r31688 106 106 if (this._currentFocusElement.focused) 107 107 this._currentFocusElement.focused(); 108 109 // Make a caret selection inside the new element if there isn't a range selection and 110 // there isn't already a caret selection inside. 111 var selection = window.getSelection(); 112 if (selection.isCollapsed && !this._currentFocusElement.isInsertionCaretInside()) { 113 var selectionRange = document.createRange(); 114 selectionRange.setStart(this._currentFocusElement, 0); 115 selectionRange.setEnd(this._currentFocusElement, 0); 116 117 selection.removeAllRanges(); 118 selection.addRange(selectionRange); 119 } 108 120 } 109 121 }, -
trunk/WebCore/page/inspector/utilities.js
r31639 r31688 165 165 while (this.firstChild) 166 166 this.removeChild(this.firstChild); 167 } 168 169 Element.prototype.isInsertionCaretInside = function() 170 { 171 var selection = window.getSelection(); 172 if (!selection.rangeCount || !selection.isCollapsed) 173 return false; 174 var selectionRange = selection.getRangeAt(0); 175 return selectionRange.startContainer === this || selectionRange.startContainer.isDescendant(this); 167 176 } 168 177
Note: See TracChangeset
for help on using the changeset viewer.