Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: file protocol and test cases #1234

Merged
merged 17 commits into from Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions kraken/lib/src/dom/element.dart
Expand Up @@ -1558,8 +1558,6 @@ abstract class Element
}

Future<Uint8List> toBlob({ double? devicePixelRatio }) {
devicePixelRatio ??= window.devicePixelRatio;

Completer<Uint8List> completer = Completer();
forceToRepaintBoundary = true;
renderBoxModel!.owner!.flushLayout();
Expand All @@ -1568,16 +1566,11 @@ abstract class Element
Uint8List captured;
RenderBoxModel _renderBoxModel = renderBoxModel!;

// If prev flush paint with error, render object keeps NEEDS-PAINT flag,
// will cause layer not exists.
assert(!_renderBoxModel.debugNeedsPaint, () {
debugPrint('Failed toBlob at $this, flush painting may raise error.');
});
if (_renderBoxModel.hasSize && _renderBoxModel.size.isEmpty) {
// Return a blob with zero length.
captured = Uint8List(0);
} else {
Image image = await _renderBoxModel.toImage(pixelRatio: devicePixelRatio!);
Image image = await _renderBoxModel.toImage(pixelRatio: devicePixelRatio ?? window.devicePixelRatio);
ByteData? byteData = await image.toByteData(format: ImageByteFormat.png);
captured = byteData!.buffer.asUint8List();
}
Expand Down
6 changes: 3 additions & 3 deletions kraken/lib/src/dom/elements/head.dart
Expand Up @@ -117,7 +117,7 @@ class LinkElement extends Element {
try {
KrakenBundle bundle = KrakenBundle.fromUrl(url);
await bundle.resolve(contextId);
bundle.eval(contextId);
await bundle.eval(contextId);

// Successful load.
SchedulerBinding.instance!.addPostFrameCallback((_) {
Expand Down Expand Up @@ -278,7 +278,7 @@ class ScriptElement extends Element {
try {
KrakenBundle bundle = KrakenBundle.fromUrl(src.toString());
await bundle.resolve(contextId);
bundle.eval(contextId);
await bundle.eval(contextId);
// Successful load.
SchedulerBinding.instance!.addPostFrameCallback((_) {
dispatchEvent(Event(EVENT_LOAD));
Expand Down Expand Up @@ -309,7 +309,7 @@ class ScriptElement extends Element {
if (controller != null) {
KrakenBundle bundle = KrakenBundle.fromContent(script, url: controller.url);
await bundle.resolve(contextId);
bundle.eval(contextId);
await bundle.eval(contextId);
}
}
}
Expand Down