Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 23987002: Fixing visibilityState APIs in Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 9d221b16bd2d08ad8a1280257e08d23a4fdc71af..c748abdf5c22abab74ffbc958ebd2df90ab28852 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -12706,11 +12706,14 @@ class HtmlDocument extends Document native "HTMLDocument" {
Element get pointerLockElement =>
_webkitPointerLockElement;
- @DomName('Document.webkitVisibilityState')
+ @DomName('Document.visibilityState')
@SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
+ @SupportedBrowser(SupportedBrowser.FIREFOX)
+ @SupportedBrowser(SupportedBrowser.IE, '10')
@Experimental()
- String get visibilityState => _webkitVisibilityState;
+ String get visibilityState => JS('String',
+ '(#.visibilityState || #.mozVisibilityState || #.msVisibilityState ||'
+ '#.webkitVisibilityState)', this, this, this, this);
@Experimental
void register(String tag, Type customElementClass) {
@@ -12720,6 +12723,36 @@ class HtmlDocument extends Document native "HTMLDocument" {
@Creates('Null') // Set from Dart code; does not instantiate a native type.
// Note: used to polyfill <template>
Document _templateContentsOwner;
+
+ @DomName('Document.visibilityChange')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.FIREFOX)
+ @SupportedBrowser(SupportedBrowser.IE, '10')
+ @Experimental()
+ static const EventStreamProvider<Event> visibilityChangeEvent =
+ const _CustomEventStreamProvider<Event>(
+ _determineVisibilityChangeEventType);
+
+ static String _determineVisibilityChangeEventType(EventTarget e) {
+ if (JS('bool', '(typeof #.hidden !== "undefined")', e)) {
+ // Opera 12.10 and Firefox 18 and later support
+ return 'visibilitychange';
+ } else if (JS('bool', '(typeof #.mozHidden !== "undefined")', e)) {
+ return 'mozvisibilitychange';
+ } else if (JS('bool', '(typeof #.msHidden !== "undefined")', e)) {
+ return 'msvisibilitychange';
+ } else if (JS('bool', '(typeof #.webkitHidden !== "undefined")', e)) {
+ return 'webkitvisibilitychange';
+ }
+ return 'visibilitychange';
+ }
+
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.FIREFOX)
+ @SupportedBrowser(SupportedBrowser.IE, '10')
+ @Experimental()
+ Stream<Event> get onVisibilityChange =>
+ visibilityChangeEvent.forTarget(this);
}
// 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
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698