Fix the exception of zooming browser operation in flutterweb using Canvaskit rendering mode (flutter/engine#33194)
This commit is contained in:
@@ -165,8 +165,6 @@ class Surface {
|
||||
return _surface!;
|
||||
}
|
||||
|
||||
_currentDevicePixelRatio = window.devicePixelRatio;
|
||||
|
||||
// If the current canvas size is smaller than the requested size then create
|
||||
// a new, larger, canvas. Then update the GR context so we can create a new
|
||||
// SkSurface.
|
||||
@@ -188,8 +186,11 @@ class Surface {
|
||||
|
||||
_createNewCanvas(newSize);
|
||||
_currentCanvasPhysicalSize = newSize;
|
||||
} else if (window.devicePixelRatio != _currentDevicePixelRatio) {
|
||||
_updateLogicalHtmlCanvasSize();
|
||||
}
|
||||
|
||||
_currentDevicePixelRatio = window.devicePixelRatio;
|
||||
_currentSurfaceSize = size;
|
||||
_translateCanvas();
|
||||
return _surface = _createNewSurface(size);
|
||||
|
||||
@@ -176,6 +176,15 @@ void testMain() {
|
||||
expect(lowDpr.height(), 16);
|
||||
expect(surface.htmlCanvas!.style.width, '20px');
|
||||
expect(surface.htmlCanvas!.style.height, '32px');
|
||||
|
||||
// See https://github.com/flutter/flutter/issues/77084#issuecomment-1120151172
|
||||
window.debugOverrideDevicePixelRatio(2.0);
|
||||
final CkSurface changeRatioAndSize =
|
||||
surface.acquireFrame(const ui.Size(9.9, 15.9)).skiaSurface;
|
||||
expect(changeRatioAndSize.width(), 10);
|
||||
expect(changeRatioAndSize.height(), 16);
|
||||
expect(surface.htmlCanvas!.style.width, '5px');
|
||||
expect(surface.htmlCanvas!.style.height, '8px');
|
||||
});
|
||||
}, skip: isIosSafari);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user