Changeset 228487 in webkit
- Timestamp:
- Feb 14, 2018 2:45:50 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r228479 r228487 1 2018-02-14 Nikita Vasilyev <nvasilyev@apple.com> 2 3 Web Inspector: Styles: completion popover doesn't hide when switching panels 4 https://bugs.webkit.org/show_bug.cgi?id=182464 5 <rdar://problem/37202763> 6 7 Reviewed by Timothy Hatcher. 8 9 Save the position of the anchor, an element the popover is shown for, and hide the completion popover 10 when the position changes. 11 12 * UserInterface/Views/CompletionSuggestionsView.js: 13 (WI.CompletionSuggestionsView.prototype.showUntilAnchorMoves): 14 When the popover is visible, check every 200ms if the anchor moved. 15 16 (WI.CompletionSuggestionsView.prototype.hide): 17 * UserInterface/Views/SpreadsheetTextField.js: 18 (WI.SpreadsheetTextField.prototype._updateCompletions): 19 (WI.SpreadsheetTextField.prototype._getCaretRect): 20 getBoundingClientRect returns {x: 0, y: 0} when it can't determine node's position. 21 This happens when a node isn't attached to DOM, attached to DOM but not visible, and 22 a number of odd cases. 23 1 24 2018-02-14 Matt Baker <mattbaker@apple.com> 2 25 -
trunk/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js
r223283 r228487 34 34 35 35 this._selectedIndex = NaN; 36 this._anchorBounds = null; 36 37 37 38 this._element = document.createElement("div"); … … 158 159 } 159 160 161 showUntilAnchorMoves(getAnchorBounds) 162 { 163 this._anchorBounds = getAnchorBounds(); 164 if (!this._anchorBounds) { 165 this.hide(); 166 return; 167 } 168 169 this.show(this._anchorBounds); 170 171 let hideWhenMoved = () => { 172 let anchorBounds = getAnchorBounds(); 173 if (!anchorBounds || !anchorBounds.equals(this._anchorBounds)) 174 this.hide(); 175 }; 176 177 if (this._hideWhenMovedIdentifier) 178 clearInterval(this._hideWhenMovedIdentifier); 179 180 this._hideWhenMovedIdentifier = setInterval(hideWhenMoved, 200); 181 } 182 160 183 hide() 161 184 { 162 185 this._element.remove(); 186 this._anchorBounds = null; 187 if (this._hideWhenMovedIdentifier) { 188 clearInterval(this._hideWhenMovedIdentifier); 189 this._hideWhenMovedIdentifier = 0; 190 } 163 191 } 164 192 -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js
r227585 r228487 378 378 this._suggestionsView.hide(); 379 379 } else { 380 let caretRect = this._getCaretRect(prefix, completionPrefix); 381 this._suggestionsView.show(caretRect); 380 let startOffset = prefix.length - completionPrefix.length; 381 this._suggestionsView.showUntilAnchorMoves(() => { 382 return this._getCaretRect(startOffset); 383 }); 382 384 } 383 385 … … 390 392 } 391 393 392 _getCaretRect(prefix, completionPrefix) 393 { 394 let startOffset = prefix.length - completionPrefix.length; 394 _getCaretRect(startOffset) 395 { 395 396 let selection = window.getSelection(); 396 397 397 if (startOffset > 0 && selection.rangeCount) { 398 let isHidden = (clientRect) => { 399 return clientRect.x === 0 && clientRect.y === 0 400 }; 401 402 if (selection.rangeCount) { 398 403 let range = selection.getRangeAt(0).cloneRange(); 399 404 range.setStart(range.startContainer, startOffset); 400 405 let clientRect = range.getBoundingClientRect(); 401 return WI.Rect.rectFromClientRect(clientRect); 406 407 if (!isHidden(clientRect)) { 408 // This happens after deleting value. However, when focusing 409 // on an empty value clientRect is visible. 410 return WI.Rect.rectFromClientRect(clientRect); 411 } 402 412 } 403 413 404 414 let clientRect = this._element.getBoundingClientRect(); 415 if (isHidden(clientRect)) 416 return null; 417 405 418 const leftPadding = parseInt(getComputedStyle(this._element).paddingLeft) || 0; 406 419 return new WI.Rect(clientRect.left + leftPadding, clientRect.top, clientRect.width, clientRect.height);
Note: See TracChangeset
for help on using the changeset viewer.