Skip to content

Commit 077465d

Browse files
committed
Fixes #412
Adds Screen, Navigator.language, and HTMLHtmlElement to dart:html [email protected] Review URL: https://codereview.chromium.org/1607073002 .
1 parent 5b45c6e commit 077465d

File tree

6 files changed

+273
-69
lines changed

6 files changed

+273
-69
lines changed

pkg/dev_compiler/lib/runtime/dart/html.js

Lines changed: 93 additions & 2 deletions
Large diffs are not rendered by default.

pkg/dev_compiler/lib/src/codegen/js_codegen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
17761776
return _emitTopLevelName(element);
17771777
}
17781778

1779-
JS.Expression _emitTopLevelName(Element e, {String suffix : ''}) {
1779+
JS.Expression _emitTopLevelName(Element e, {String suffix: ''}) {
17801780
var libName = _libraryName(e.library);
17811781
var nameExpr = _propertyName((_getJSExportName(e) ?? e.name) + suffix);
17821782

pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Messages from compiling unmodifiable_wrappers.dart
2-
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/src/unmodifiable_wrappers.dart, line 33, col 7)
3-
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/src/unmodifiable_wrappers.dart, line 136, col 7)
2+
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/src/unmodifiable_wrappers.dart, line 33, col 7)
3+
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/src/unmodifiable_wrappers.dart, line 136, col 7)
44
warning: [DOWN_CAST_COMPOSITE] _throw() (dynamic) will need runtime check to cast to type E (package:collection/src/unmodifiable_wrappers.dart, line 88, col 28)
55
warning: [DOWN_CAST_COMPOSITE] _throw() (dynamic) will need runtime check to cast to type E (package:collection/src/unmodifiable_wrappers.dart, line 94, col 21)
66
warning: [DOWN_CAST_COMPOSITE] _throw() (dynamic) will need runtime check to cast to type V (package:collection/src/unmodifiable_wrappers.dart, line 218, col 41)

pkg/dev_compiler/test/codegen/expect/collection/wrappers.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ severe: [INVALID_METHOD_OVERRIDE] Invalid override. The type of _DelegatingItera
44
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 117, col 7)
55
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (package:collection/wrappers.dart, line 117, col 25)
66
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (package:collection/wrappers.dart, line 117, col 25)
7-
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 216, col 7)
7+
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 216, col 7)
88
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (package:collection/wrappers.dart, line 216, col 24)
99
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (package:collection/wrappers.dart, line 216, col 24)
10-
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 269, col 7)
10+
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 269, col 7)
1111
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (package:collection/wrappers.dart, line 269, col 26)
1212
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (package:collection/wrappers.dart, line 269, col 26)
13-
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 367, col 7)
14-
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 452, col 7)
13+
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 367, col 7)
14+
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 452, col 7)
1515
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((V) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<V>.expand (<T>((V) → Iterable<T>) → Iterable<T>). (package:collection/wrappers.dart, line 452, col 25)
1616
severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((V) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<V>.map (<T>((V) → T) → Iterable<T>). (package:collection/wrappers.dart, line 452, col 25)
1717
warning: [DOWN_CAST_COMPOSITE] _base.fold(initialValue, combine) (dynamic) will need runtime check to cast to type T (package:collection/wrappers.dart, line 49, col 7)

pkg/dev_compiler/tool/input_sdk/lib/html/ddc/html_ddc.dart

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8443,6 +8443,32 @@ class HtmlDocument extends Document {
84438443
// BSD-style license that can be found in the LICENSE file.
84448444

84458445

8446+
@DocsEditable()
8447+
@DomName('HTMLHtmlElement')
8448+
@Native("HTMLHtmlElement")
8449+
class HtmlHtmlElement extends HtmlElement {
8450+
// To suppress missing implicit constructor warnings.
8451+
factory HtmlHtmlElement._() { throw new UnsupportedError("Not supported"); }
8452+
8453+
@DomName('HTMLHtmlElement.HTMLHtmlElement')
8454+
@DocsEditable()
8455+
factory HtmlHtmlElement() => document.createElement("html");
8456+
8457+
8458+
@Deprecated("Internal Use Only")
8459+
static HtmlHtmlElement internalCreateHtmlHtmlElement() {
8460+
return new HtmlHtmlElement.internal_();
8461+
}
8462+
8463+
@Deprecated("Internal Use Only")
8464+
HtmlHtmlElement.internal_() : super.internal_();
8465+
8466+
}
8467+
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
8468+
// for details. All rights reserved. Use of this source code is governed by a
8469+
// BSD-style license that can be found in the LICENSE file.
8470+
8471+
84468472
/**
84478473
* A client-side XHR request for getting data from a URL,
84488474
* formally known as XMLHttpRequest.
@@ -10936,6 +10962,9 @@ class MouseEvent extends UIEvent {
1093610962
class Navigator extends DartHtmlDomObject implements NavigatorCpu {
1093710963

1093810964

10965+
@DomName('Navigator.language')
10966+
String get language => JS('String', '#.language || #.userLanguage', this.raw,
10967+
this.raw);
1093910968

1094010969

1094110970
// To suppress missing implicit constructor warnings.
@@ -12250,6 +12279,74 @@ class Range extends DartHtmlDomObject {
1225012279

1225112280
@DomName('RequestAnimationFrameCallback')
1225212281
typedef void RequestAnimationFrameCallback(num highResTime);
12282+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
12283+
// for details. All rights reserved. Use of this source code is governed by a
12284+
// BSD-style license that can be found in the LICENSE file.
12285+
12286+
12287+
@DocsEditable()
12288+
@DomName('Screen')
12289+
@Native("Screen")
12290+
class Screen extends DartHtmlDomObject {
12291+
12292+
@DomName('Screen.availHeight')
12293+
@DomName('Screen.availLeft')
12294+
@DomName('Screen.availTop')
12295+
@DomName('Screen.availWidth')
12296+
Rectangle get available => new Rectangle(_availLeft, _availTop, _availWidth,
12297+
_availHeight);
12298+
// To suppress missing implicit constructor warnings.
12299+
factory Screen._() { throw new UnsupportedError("Not supported"); }
12300+
12301+
@Deprecated("Internal Use Only")
12302+
static Screen internalCreateScreen() {
12303+
return new Screen.internal_();
12304+
}
12305+
12306+
@Deprecated("Internal Use Only")
12307+
Screen.internal_() { }
12308+
12309+
bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(this, other);
12310+
int get hashCode => unwrap_jso(this).hashCode;
12311+
12312+
@JSName('availHeight')
12313+
@DomName('Screen.availHeight')
12314+
@DocsEditable()
12315+
int get _availHeight => wrap_jso(JS("int", "#.availHeight", this.raw));
12316+
12317+
@JSName('availLeft')
12318+
@DomName('Screen.availLeft')
12319+
@DocsEditable()
12320+
@Experimental() // nonstandard
12321+
int get _availLeft => wrap_jso(JS("int", "#.availLeft", this.raw));
12322+
12323+
@JSName('availTop')
12324+
@DomName('Screen.availTop')
12325+
@DocsEditable()
12326+
@Experimental() // nonstandard
12327+
int get _availTop => wrap_jso(JS("int", "#.availTop", this.raw));
12328+
12329+
@JSName('availWidth')
12330+
@DomName('Screen.availWidth')
12331+
@DocsEditable()
12332+
int get _availWidth => wrap_jso(JS("int", "#.availWidth", this.raw));
12333+
12334+
@DomName('Screen.colorDepth')
12335+
@DocsEditable()
12336+
int get colorDepth => wrap_jso(JS("int", "#.colorDepth", this.raw));
12337+
12338+
@DomName('Screen.height')
12339+
@DocsEditable()
12340+
int get height => wrap_jso(JS("int", "#.height", this.raw));
12341+
12342+
@DomName('Screen.pixelDepth')
12343+
@DocsEditable()
12344+
int get pixelDepth => wrap_jso(JS("int", "#.pixelDepth", this.raw));
12345+
12346+
@DomName('Screen.width')
12347+
@DocsEditable()
12348+
int get width => wrap_jso(JS("int", "#.width", this.raw));
12349+
}
1225312350
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1225412351
// for details. All rights reserved. Use of this source code is governed by a
1225512352
// BSD-style license that can be found in the LICENSE file.
@@ -13183,6 +13280,18 @@ class Window extends EventTarget implements WindowBase {
1318313280
@Returns('Window|=Object')
1318413281
dynamic get _get_parent => wrap_jso(JS("dynamic", "#.parent", this.raw));
1318513282

13283+
/**
13284+
* Information about the screen displaying this window.
13285+
*
13286+
* ## Other resources
13287+
*
13288+
* * [The Screen interface specification]
13289+
* (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13290+
*/
13291+
@DomName('Window.screen')
13292+
@DocsEditable()
13293+
Screen get screen => wrap_jso(JS("Screen", "#.screen", this.raw));
13294+
1318613295
/**
1318713296
* The distance from the left side of the screen to the left side of this
1318813297
* window.
@@ -19511,6 +19620,7 @@ final htmlBlinkMap = {
1951119620
'HTMLDocument': () => HtmlDocument,
1951219621
'HTMLElement': () => HtmlElement,
1951319622
'HTMLHeadElement': () => HeadElement,
19623+
'HTMLHtmlElement': () => HtmlHtmlElement,
1951419624
'HTMLInputElement': () => InputElement,
1951519625
'HTMLStyleElement': () => StyleElement,
1951619626
'HTMLTemplateElement': () => TemplateElement,
@@ -19526,6 +19636,7 @@ final htmlBlinkMap = {
1952619636
'ParentNode': () => ParentNode,
1952719637
'ProgressEvent': () => ProgressEvent,
1952819638
'Range': () => Range,
19639+
'Screen': () => Screen,
1952919640
'ShadowRoot': () => ShadowRoot,
1953019641
'Text': () => Text,
1953119642
'UIEvent': () => UIEvent,
@@ -19561,6 +19672,7 @@ final htmlBlinkFunctionMap = {
1956119672
'HTMLDocument': () => HtmlDocument.internalCreateHtmlDocument,
1956219673
'HTMLElement': () => HtmlElement.internalCreateHtmlElement,
1956319674
'HTMLHeadElement': () => HeadElement.internalCreateHeadElement,
19675+
'HTMLHtmlElement': () => HtmlHtmlElement.internalCreateHtmlHtmlElement,
1956419676
'HTMLInputElement': () => InputElement.internalCreateInputElement,
1956519677
'HTMLStyleElement': () => StyleElement.internalCreateStyleElement,
1956619678
'HTMLTemplateElement': () => TemplateElement.internalCreateTemplateElement,
@@ -19574,6 +19686,7 @@ final htmlBlinkFunctionMap = {
1957419686
'NodeList': () => NodeList.internalCreateNodeList,
1957519687
'ProgressEvent': () => ProgressEvent.internalCreateProgressEvent,
1957619688
'Range': () => Range.internalCreateRange,
19689+
'Screen': () => Screen.internalCreateScreen,
1957719690
'ShadowRoot': () => ShadowRoot.internalCreateShadowRoot,
1957819691
'Text': () => Text.internalCreateText,
1957919692
'UIEvent': () => UIEvent.internalCreateUIEvent,

0 commit comments

Comments
 (0)