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

Side by Side Diff: sdk/lib/html/src/dart2js_DOMImplementation.dart

Issue 11642035: Renaming Window to WindowBase and LocalWindow to Window. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of html; 5 part of html;
6 6
7 // TODO(vsm): Unify with Dartium version. 7 // TODO(vsm): Unify with Dartium version.
8 class _DOMWindowCrossFrame implements Window { 8 class _DOMWindowCrossFrame implements WindowBase {
9 // Private window. Note, this is a window in another frame, so it 9 // Private window. Note, this is a window in another frame, so it
10 // cannot be typed as "Window" as its prototype is not patched 10 // cannot be typed as "Window" as its prototype is not patched
11 // properly. Its fields and methods can only be accessed via JavaScript. 11 // properly. Its fields and methods can only be accessed via JavaScript.
12 var _window; 12 var _window;
13 13
14 // Fields. 14 // Fields.
15 History get history => 15 HistoryBase get history =>
16 _HistoryCrossFrame._createSafe(JS('History', '#.history', _window)); 16 _HistoryCrossFrame._createSafe(JS('HistoryBase', '#.history', _window));
17 Location get location => 17 LocationBase get location =>
18 _LocationCrossFrame._createSafe(JS('Location', '#.location', _window)); 18 _LocationCrossFrame._createSafe(JS('LocationBase', '#.location', _window));
19 19
20 // TODO(vsm): Add frames to navigate subframes. See 2312. 20 // TODO(vsm): Add frames to navigate subframes. See 2312.
21 21
22 bool get closed => JS('bool', '#.closed', _window); 22 bool get closed => JS('bool', '#.closed', _window);
23 23
24 Window get opener => _createSafe(JS('Window', '#.opener', _window)); 24 WindowBase get opener => _createSafe(JS('WindowBase', '#.opener', _window));
25 25
26 Window get parent => _createSafe(JS('Window', '#.parent', _window)); 26 WindowBase get parent => _createSafe(JS('WindowBase', '#.parent', _window));
27 27
28 Window get top => _createSafe(JS('Window', '#.top', _window)); 28 WindowBase get top => _createSafe(JS('WindowBase', '#.top', _window));
29 29
30 // Methods. 30 // Methods.
31 void close() => JS('void', '#.close()', _window); 31 void close() => JS('void', '#.close()', _window);
32 32
33 void postMessage(var message, String targetOrigin, [List messagePorts = null]) { 33 void postMessage(var message, String targetOrigin, [List messagePorts = null]) {
34 if (messagePorts == null) { 34 if (messagePorts == null) {
35 JS('void', '#.postMessage(#,#)', _window, message, targetOrigin); 35 JS('void', '#.postMessage(#,#)', _window, message, targetOrigin);
36 } else { 36 } else {
37 JS('void', '#.postMessage(#,#,#)', _window, message, targetOrigin, message Ports); 37 JS('void', '#.postMessage(#,#,#)', _window, message, targetOrigin, message Ports);
38 } 38 }
39 } 39 }
40 40
41 // Implementation support. 41 // Implementation support.
42 _DOMWindowCrossFrame(this._window); 42 _DOMWindowCrossFrame(this._window);
43 43
44 static Window _createSafe(w) { 44 static WindowBase _createSafe(w) {
45 if (identical(w, window)) { 45 if (identical(w, window)) {
46 return w; 46 return w;
47 } else { 47 } else {
48 // TODO(vsm): Cache or implement equality. 48 // TODO(vsm): Cache or implement equality.
49 return new _DOMWindowCrossFrame(w); 49 return new _DOMWindowCrossFrame(w);
50 } 50 }
51 } 51 }
52 } 52 }
53 53
54 class _LocationCrossFrame implements Location { 54 class _LocationCrossFrame implements LocationBase {
55 // Private location. Note, this is a location object in another frame, so it 55 // Private location. Note, this is a location object in another frame, so it
56 // cannot be typed as "Location" as its prototype is not patched 56 // cannot be typed as "Location" as its prototype is not patched
57 // properly. Its fields and methods can only be accessed via JavaScript. 57 // properly. Its fields and methods can only be accessed via JavaScript.
58 var _location; 58 var _location;
59 59
60 void set href(String val) => _setHref(_location, val); 60 void set href(String val) => _setHref(_location, val);
61 static void _setHref(location, val) { 61 static void _setHref(location, val) {
62 JS('void', '#.href = #', location, val); 62 JS('void', '#.href = #', location, val);
63 } 63 }
64 64
65 // Implementation support. 65 // Implementation support.
66 _LocationCrossFrame(this._location); 66 _LocationCrossFrame(this._location);
67 67
68 static Location _createSafe(location) { 68 static LocationBase _createSafe(location) {
69 if (identical(location, window.location)) { 69 if (identical(location, window.location)) {
70 return location; 70 return location;
71 } else { 71 } else {
72 // TODO(vsm): Cache or implement equality. 72 // TODO(vsm): Cache or implement equality.
73 return new _LocationCrossFrame(location); 73 return new _LocationCrossFrame(location);
74 } 74 }
75 } 75 }
76 } 76 }
77 77
78 class _HistoryCrossFrame implements History { 78 class _HistoryCrossFrame implements HistoryBase {
79 // Private history. Note, this is a history object in another frame, so it 79 // Private history. Note, this is a history object in another frame, so it
80 // cannot be typed as "History" as its prototype is not patched 80 // cannot be typed as "History" as its prototype is not patched
81 // properly. Its fields and methods can only be accessed via JavaScript. 81 // properly. Its fields and methods can only be accessed via JavaScript.
82 var _history; 82 var _history;
83 83
84 void back() => JS('void', '#.back()', _history); 84 void back() => JS('void', '#.back()', _history);
85 85
86 void forward() => JS('void', '#.forward()', _history); 86 void forward() => JS('void', '#.forward()', _history);
87 87
88 void go(int distance) => JS('void', '#.go(#)', _history, distance); 88 void go(int distance) => JS('void', '#.go(#)', _history, distance);
89 89
90 // Implementation support. 90 // Implementation support.
91 _HistoryCrossFrame(this._history); 91 _HistoryCrossFrame(this._history);
92 92
93 static History _createSafe(h) { 93 static HistoryBase _createSafe(h) {
94 if (identical(h, window.history)) { 94 if (identical(h, window.history)) {
95 return h; 95 return h;
96 } else { 96 } else {
97 // TODO(vsm): Cache or implement equality. 97 // TODO(vsm): Cache or implement equality.
98 return new _HistoryCrossFrame(h); 98 return new _HistoryCrossFrame(h);
99 } 99 }
100 } 100 }
101 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698