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

Unified Diff: lib/dom/templates/html/frog/impl_Window.darttemplate

Issue 10534130: Wrap Location object on Firefox. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« no previous file with comments | « lib/dom/templates/html/frog/html_frog.darttemplate ('k') | lib/html/frog/html_frog.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/templates/html/frog/impl_Window.darttemplate
diff --git a/lib/dom/templates/html/frog/impl_Window.darttemplate b/lib/dom/templates/html/frog/impl_Window.darttemplate
index 6c6adbf486e92deb597b3e33b2cf1d6f1a8c809a..af67edba004acb8ab5b4dfb434cceca85334fdd8 100644
--- a/lib/dom/templates/html/frog/impl_Window.darttemplate
+++ b/lib/dom/templates/html/frog/impl_Window.darttemplate
@@ -11,6 +11,59 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
// Override top to return secure wrapper.
Window get top() => _DOMWindowCrossFrameImpl._createSafe(_top);
+
+ // API level getter and setter for Location.
+ // TODO: The cross domain safe wrapper can be inserted here or folded into
+ // _LocationWrapper.
+ Location get location() => _get_location();
+
+ // TODO: consider forcing users to do: window.location.assign('string').
+ /**
+ * Sets the window's location, which causes the browser to navigate to the new
+ * location. [value] may be a Location object or a string.
+ */
+ void set location(value) => _set_location(value);
+
+ // Firefox work-around for Location. The Firefox location object cannot be
+ // made to behave like a Dart object so must be wrapped.
+
+ Location _get_location() {
+ var result = _location;
+ if (_isDartLocation(result)) return result; // e.g. on Chrome.
+ if (null == _location_wrapper) {
+ _location_wrapper = new _LocationWrapper(result);
+ }
+ return _location_wrapper;
+ }
+
+ void _set_location(value) {
+ if (value is _LocationWrapper) {
+ _location = value._ptr;
+ } else {
+ _location = value;
+ }
+ }
+
+ var _location_wrapper; // Cached wrapped Location object.
+
+ // Native getter and setter to access raw Location object.
+ Location get _location() native 'return this.location';
+ void set _location(Location value) native 'this.location = value';
+ // Prevent compiled from thinking 'location' property is available for a Dart
+ // member.
+ _protect_location() native 'location';
+
+ static _isDartLocation(thing) {
+ // On Firefox the code that implements 'is Location' fails to find the patch
+ // stub on Object.prototype and throws an exception.
+ try {
+ return thing is Location;
+ } catch (var e) {
+ return false;
+ }
+ }
+
+
void requestLayoutFrame(TimeoutHandler callback) {
_addMeasurementFrameCallback(callback);
}
« no previous file with comments | « lib/dom/templates/html/frog/html_frog.darttemplate ('k') | lib/html/frog/html_frog.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698