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

Unified Diff: sdk/lib/html/html_common/device.dart

Issue 23055008: Making almost all dom_ methods private. Exceptions will be addressed in a later CL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/html/html_common/device.dart
diff --git a/sdk/lib/html/html_common/device.dart b/sdk/lib/html/html_common/device.dart
deleted file mode 100644
index fe9ad358fe1368d8da6bf91c708cf7651accb5ed..0000000000000000000000000000000000000000
--- a/sdk/lib/html/html_common/device.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2011, 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.
-
-part of html_common;
blois 2013/08/22 20:42:23 Not sure I understand this move- is this moving in
Emily Fortuna 2013/08/22 22:10:10 Only needed if this file calls _createEvent(eventT
blois 2013/08/23 15:55:06 It's not called too often and I'd like to keep thi
-
-/**
- * Utils for device detection.
- */
-class Device {
- static bool _isOpera;
- static bool _isIE;
- static bool _isFirefox;
- static bool _isWebKit;
- static String _cachedCssPrefix;
- static String _cachedPropertyPrefix;
-
- /**
- * Gets the browser's user agent. Using this function allows tests to inject
- * the user agent.
- * Returns the user agent.
- */
- static String get userAgent => window.navigator.userAgent;
-
- /**
- * Determines if the current device is running Opera.
- */
- static bool get isOpera {
- if (_isOpera == null) {
- _isOpera = userAgent.contains("Opera", 0);
- }
- return _isOpera;
- }
-
- /**
- * Determines if the current device is running Internet Explorer.
- */
- static bool get isIE {
- if (_isIE == null) {
- _isIE = !isOpera && userAgent.contains("MSIE", 0);
- }
- return _isIE;
- }
-
- /**
- * Determines if the current device is running Firefox.
- */
- static bool get isFirefox {
- if (_isFirefox == null) {
- _isFirefox = userAgent.contains("Firefox", 0);
- }
- return _isFirefox;
- }
-
- /**
- * Determines if the current device is running WebKit.
- */
- static bool get isWebKit {
- if (_isWebKit == null) {
- _isWebKit = !isOpera && userAgent.contains("WebKit", 0);
- }
- return _isWebKit;
- }
-
- /**
- * Gets the CSS property prefix for the current platform.
- */
- static String get cssPrefix {
- if (_cachedCssPrefix == null) {
- if (isFirefox) {
- _cachedCssPrefix = '-moz-';
- } else if (isIE) {
- _cachedCssPrefix = '-ms-';
- } else if (isOpera) {
- _cachedCssPrefix = '-o-';
- } else {
- _cachedCssPrefix = '-webkit-';
- }
- }
- return _cachedCssPrefix;
- }
-
- /**
- * Prefix as used for JS property names.
- */
- static String get propertyPrefix {
- if (_cachedPropertyPrefix == null) {
- if (isFirefox) {
- _cachedPropertyPrefix = 'moz';
- } else if (isIE) {
- _cachedPropertyPrefix = 'ms';
- } else if (isOpera) {
- _cachedPropertyPrefix = 'o';
- } else {
- _cachedPropertyPrefix = 'webkit';
- }
- }
- return _cachedPropertyPrefix;
- }
-
- /**
- * Checks to see if the event class is supported by the current platform.
- */
- static bool isEventTypeSupported(String eventType) {
- // Browsers throw for unsupported event names.
- try {
- var e = document.$dom_createEvent(eventType);
blois 2013/08/22 20:42:23 Should be able to replace with new Event.eventType
- return e is Event;
- } catch (_) { }
- return false;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698