Skip to content

Commit

Permalink
Fixes #412
Browse files Browse the repository at this point in the history
Adds Screen, Navigator.language, and HTMLHtmlElement to dart:html

[email protected]

Review URL: https://codereview.chromium.org/1607073002 .
  • Loading branch information
vsmenon committed Jan 19, 2016
1 parent 5b45c6e commit 077465d
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 69 deletions.
95 changes: 93 additions & 2 deletions pkg/dev_compiler/lib/runtime/dart/html.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/codegen/js_codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
return _emitTopLevelName(element);
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Messages from compiling unmodifiable_wrappers.dart
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/src/unmodifiable_wrappers.dart, line 33, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/src/unmodifiable_wrappers.dart, line 136, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/src/unmodifiable_wrappers.dart, line 33, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/src/unmodifiable_wrappers.dart, line 136, col 7)
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)
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)
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)
Expand Down
8 changes: 4 additions & 4 deletions pkg/dev_compiler/test/codegen/expect/collection/wrappers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ severe: [INVALID_METHOD_OVERRIDE] Invalid override. The type of _DelegatingItera
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 117, col 7)
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)
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)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 216, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 216, col 7)
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)
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)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 269, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 269, col 7)
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)
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)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 367, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 452, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 367, col 7)
severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 452, col 7)
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)
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)
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)
Expand Down
113 changes: 113 additions & 0 deletions pkg/dev_compiler/tool/input_sdk/lib/html/ddc/html_ddc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8443,6 +8443,32 @@ class HtmlDocument extends Document {
// BSD-style license that can be found in the LICENSE file.


@DocsEditable()
@DomName('HTMLHtmlElement')
@Native("HTMLHtmlElement")
class HtmlHtmlElement extends HtmlElement {
// To suppress missing implicit constructor warnings.
factory HtmlHtmlElement._() { throw new UnsupportedError("Not supported"); }

@DomName('HTMLHtmlElement.HTMLHtmlElement')
@DocsEditable()
factory HtmlHtmlElement() => document.createElement("html");


@Deprecated("Internal Use Only")
static HtmlHtmlElement internalCreateHtmlHtmlElement() {
return new HtmlHtmlElement.internal_();
}

@Deprecated("Internal Use Only")
HtmlHtmlElement.internal_() : super.internal_();

}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.


/**
* A client-side XHR request for getting data from a URL,
* formally known as XMLHttpRequest.
Expand Down Expand Up @@ -10936,6 +10962,9 @@ class MouseEvent extends UIEvent {
class Navigator extends DartHtmlDomObject implements NavigatorCpu {


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


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

@DomName('RequestAnimationFrameCallback')
typedef void RequestAnimationFrameCallback(num highResTime);
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.


@DocsEditable()
@DomName('Screen')
@Native("Screen")
class Screen extends DartHtmlDomObject {

@DomName('Screen.availHeight')
@DomName('Screen.availLeft')
@DomName('Screen.availTop')
@DomName('Screen.availWidth')
Rectangle get available => new Rectangle(_availLeft, _availTop, _availWidth,
_availHeight);
// To suppress missing implicit constructor warnings.
factory Screen._() { throw new UnsupportedError("Not supported"); }

@Deprecated("Internal Use Only")
static Screen internalCreateScreen() {
return new Screen.internal_();
}

@Deprecated("Internal Use Only")
Screen.internal_() { }

bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(this, other);
int get hashCode => unwrap_jso(this).hashCode;

@JSName('availHeight')
@DomName('Screen.availHeight')
@DocsEditable()
int get _availHeight => wrap_jso(JS("int", "#.availHeight", this.raw));

@JSName('availLeft')
@DomName('Screen.availLeft')
@DocsEditable()
@Experimental() // nonstandard
int get _availLeft => wrap_jso(JS("int", "#.availLeft", this.raw));

@JSName('availTop')
@DomName('Screen.availTop')
@DocsEditable()
@Experimental() // nonstandard
int get _availTop => wrap_jso(JS("int", "#.availTop", this.raw));

@JSName('availWidth')
@DomName('Screen.availWidth')
@DocsEditable()
int get _availWidth => wrap_jso(JS("int", "#.availWidth", this.raw));

@DomName('Screen.colorDepth')
@DocsEditable()
int get colorDepth => wrap_jso(JS("int", "#.colorDepth", this.raw));

@DomName('Screen.height')
@DocsEditable()
int get height => wrap_jso(JS("int", "#.height", this.raw));

@DomName('Screen.pixelDepth')
@DocsEditable()
int get pixelDepth => wrap_jso(JS("int", "#.pixelDepth", this.raw));

@DomName('Screen.width')
@DocsEditable()
int get width => wrap_jso(JS("int", "#.width", this.raw));
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Expand Down Expand Up @@ -13183,6 +13280,18 @@ class Window extends EventTarget implements WindowBase {
@Returns('Window|=Object')
dynamic get _get_parent => wrap_jso(JS("dynamic", "#.parent", this.raw));

/**
* Information about the screen displaying this window.
*
* ## Other resources
*
* * [The Screen interface specification]
* (http://www.w3.org/TR/cssom-view/#screen) from W3C.
*/
@DomName('Window.screen')
@DocsEditable()
Screen get screen => wrap_jso(JS("Screen", "#.screen", this.raw));

/**
* The distance from the left side of the screen to the left side of this
* window.
Expand Down Expand Up @@ -19511,6 +19620,7 @@ final htmlBlinkMap = {
'HTMLDocument': () => HtmlDocument,
'HTMLElement': () => HtmlElement,
'HTMLHeadElement': () => HeadElement,
'HTMLHtmlElement': () => HtmlHtmlElement,
'HTMLInputElement': () => InputElement,
'HTMLStyleElement': () => StyleElement,
'HTMLTemplateElement': () => TemplateElement,
Expand All @@ -19526,6 +19636,7 @@ final htmlBlinkMap = {
'ParentNode': () => ParentNode,
'ProgressEvent': () => ProgressEvent,
'Range': () => Range,
'Screen': () => Screen,
'ShadowRoot': () => ShadowRoot,
'Text': () => Text,
'UIEvent': () => UIEvent,
Expand Down Expand Up @@ -19561,6 +19672,7 @@ final htmlBlinkFunctionMap = {
'HTMLDocument': () => HtmlDocument.internalCreateHtmlDocument,
'HTMLElement': () => HtmlElement.internalCreateHtmlElement,
'HTMLHeadElement': () => HeadElement.internalCreateHeadElement,
'HTMLHtmlElement': () => HtmlHtmlElement.internalCreateHtmlHtmlElement,
'HTMLInputElement': () => InputElement.internalCreateInputElement,
'HTMLStyleElement': () => StyleElement.internalCreateStyleElement,
'HTMLTemplateElement': () => TemplateElement.internalCreateTemplateElement,
Expand All @@ -19574,6 +19686,7 @@ final htmlBlinkFunctionMap = {
'NodeList': () => NodeList.internalCreateNodeList,
'ProgressEvent': () => ProgressEvent.internalCreateProgressEvent,
'Range': () => Range.internalCreateRange,
'Screen': () => Screen.internalCreateScreen,
'ShadowRoot': () => ShadowRoot.internalCreateShadowRoot,
'Text': () => Text.internalCreateText,
'UIEvent': () => UIEvent.internalCreateUIEvent,
Expand Down
Loading

0 comments on commit 077465d

Please sign in to comment.