Changeset 237401 in webkit
- Timestamp:
- Oct 24, 2018, 3:12:54 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r237397 r237401 1 2018-10-24 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: popovers for function source code are malformed 4 https://bugs.webkit.org/show_bug.cgi?id=190859 5 6 Reviewed by Joseph Pecoraro. 7 8 Previously, the `WI.Popover` would be drawn twice: once when the 9 `WI.CodeMirrorTokenTrackingController` determines that the user has hovered on a function 10 token, and once again when the source for that function is formatted (after being retrieved). 11 In the case that the formatter is able to return the prettified source within a frame (or 12 two), the `WI.Popover` is still in the middle of animating to its new size, meaning that the 13 changes made by the formatted `update` will be overridden on the next rAF (creates a flash). 14 15 * UserInterface/Views/Popover.js: 16 (WI.Popover.prototype): 17 (WI.Popover.prototype._animateFrame.drawBackground): 18 (WI.Popover.prototype._drawBackground): 19 Add a member variable to make sure that there is only ever one rAF firing at a time. 20 Drive-by: rework the background code to only use one canvas. 21 22 * UserInterface/Views/SourceCodeTextEditor.js: 23 (WI.SourceCodeTextEditor.prototype._showPopoverForFunction.didGetDetails): 24 Don't show the `WI.Popover` until the formatter has finished prettifying the function's 25 source code, as otherwise there is brief moment that the popover appears and is empty. 26 1 27 2018-10-24 Devin Rousso <drousso@apple.com> 2 28 -
trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js
r236357 r237401 48 48 this._container = this._element.appendChild(document.createElement("div")); 49 49 this._container.className = "container"; 50 51 this._drawBackgroundAnimationIdentifier = undefined; 50 52 } 51 53 … … 371 373 372 374 if (progress < 1) 373 requestAnimationFrame(drawBackground.bind(this));375 this._drawBackgroundAnimationIdentifier = requestAnimationFrame(drawBackground.bind(this)); 374 376 } 375 377 … … 379 381 _drawBackground() 380 382 { 383 if (this._drawBackgroundAnimationIdentifier) { 384 cancelAnimationFrame(this._drawBackgroundAnimationIdentifier); 385 this._drawBackgroundAnimationIdentifier = undefined; 386 } 387 381 388 let scaleFactor = window.devicePixelRatio; 382 389 … … 385 392 let scaledWidth = width * scaleFactor; 386 393 let scaledHeight = height * scaleFactor; 387 388 // Create a scratch canvas so we can draw the popover that will later be drawn into389 // the final context with a shadow.390 let scratchCanvas = document.createElement("canvas");391 scratchCanvas.width = scaledWidth;392 scratchCanvas.height = scaledHeight;393 394 let ctx = scratchCanvas.getContext("2d");395 ctx.scale(scaleFactor, scaleFactor);396 394 397 395 // Bounds of the path don't take into account the arrow, but really only the tight bounding box … … 417 415 let computedStyle = window.getComputedStyle(this._element, null); 418 416 417 let context = document.getCSSCanvasContext("2d", "popover", scaledWidth, scaledHeight); 418 context.clearRect(0, 0, scaledWidth, scaledHeight); 419 context.shadowOffsetX = 1; 420 context.shadowOffsetY = 1; 421 context.shadowBlur = 5; 422 context.shadowColor = computedStyle.getPropertyValue("--popover-shadow-color").trim(); 423 context.resetTransform(); 424 context.scale(scaleFactor, scaleFactor); 425 419 426 // Clip the frame. 420 c tx.fillStyle = computedStyle.getPropertyValue("--popover-text-color").trim();421 this._drawFrame(c tx, bounds, this._edge, this._anchorPoint);422 c tx.clip();427 context.fillStyle = computedStyle.getPropertyValue("--popover-text-color").trim(); 428 this._drawFrame(context, bounds, this._edge, this._anchorPoint); 429 context.clip(); 423 430 424 431 // Panel background color fill. 425 c tx.fillStyle = computedStyle.getPropertyValue("--popover-background-color").trim();426 427 c tx.fillRect(0, 0, width, height);432 context.fillStyle = computedStyle.getPropertyValue("--popover-background-color").trim(); 433 434 context.fillRect(0, 0, width, height); 428 435 429 436 // Stroke. 430 ctx.strokeStyle = computedStyle.getPropertyValue("--popover-border-color").trim(); 431 ctx.lineWidth = 2; 432 this._drawFrame(ctx, bounds, this._edge, this._anchorPoint); 433 ctx.stroke(); 434 435 // Draw the popover into the final context with a drop shadow. 436 let finalContext = document.getCSSCanvasContext("2d", "popover", scaledWidth, scaledHeight); 437 finalContext.clearRect(0, 0, scaledWidth, scaledHeight); 438 finalContext.shadowOffsetX = 1; 439 finalContext.shadowOffsetY = 1; 440 finalContext.shadowBlur = 5; 441 finalContext.shadowColor = computedStyle.getPropertyValue("--popover-shadow-color").trim(); 442 finalContext.drawImage(scratchCanvas, 0, 0, scaledWidth, scaledHeight); 437 context.strokeStyle = computedStyle.getPropertyValue("--popover-border-color").trim(); 438 context.lineWidth = 2; 439 this._drawFrame(context, bounds, this._edge, this._anchorPoint); 440 context.stroke(); 443 441 } 444 442 -
trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
r237232 r237401 1876 1876 readOnly: "nocursor", 1877 1877 }); 1878 codeMirror.on("update", () => {1879 this._popover.update();1880 });1881 1878 1882 1879 const isModule = false; … … 1885 1882 let workerProxy = WI.FormatterWorkerProxy.singleton(); 1886 1883 workerProxy.formatJavaScript(data.description, isModule, indentString, includeSourceMapData, ({formattedText}) => { 1884 if (candidate !== this.tokenTrackingController.candidate) 1885 return; 1886 1887 this._showPopover(content); 1887 1888 codeMirror.setValue(formattedText || data.description); 1889 this._popover.update(); 1888 1890 }); 1889 1890 this._showPopover(content);1891 1891 } 1892 1892
Note:
See TracChangeset
for help on using the changeset viewer.