Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /** | 7 /** |
| 8 * An object representing the top-level context object for web scripting. | 8 * An object representing the top-level context object for web scripting. |
| 9 * | 9 * |
| 10 * In a web browser, a [Window] object represents the actual browser window. | 10 * In a web browser, a [Window] object represents the actual browser window. |
| 11 * In a multi-tabbed browser, each tab has its own [Window] object. A [Window] | 11 * In a multi-tabbed browser, each tab has its own [Window] object. A [Window] |
| 12 * is the container that displays a [Document]'s content. All web scripting | 12 * is the container that displays a [Document]'s content. All web scripting |
| 13 * happens within the context of a [Window] object. | 13 * happens within the context of a [Window] object. |
| 14 * | 14 * |
| 15 * **Note:** This class represents any window, whereas [LocalWindow] is | 15 * **Note:** This class represents any window, whereas [LocalWindow] is |
| 16 * used to access the properties and content of the current window. | 16 * used to access the properties and content of the current window. |
| 17 * | 17 * |
| 18 * See also: | 18 * See also: |
| 19 * | 19 * |
| 20 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN. | 20 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN. |
| 21 * * [Window](http://www.w3.org/TR/Window/) from the W3C. | 21 * * [Window](http://www.w3.org/TR/Window/) from the W3C. |
| 22 */ | 22 */ |
| 23 abstract class Window { | 23 abstract class Window { |
| 24 // Fields. | 24 // Fields. |
| 25 | |
| 26 /** | |
| 27 * The [Location] object representing the current location of this window. | |
|
Kathy Walrath
2012/11/20 00:04:21
I think we can just say:
* The current location o
Andrei Mouravski
2012/11/20 00:15:38
Done.
| |
| 28 * | |
| 29 * Location currentLocation = window.location; | |
| 30 * print(currentLocation.href); // 'http://www.example.com:80/' | |
| 31 */ | |
| 25 Location get location; | 32 Location get location; |
| 26 History get history; | 33 History get history; |
| 27 | 34 |
| 35 /** | |
| 36 * Indicates whether the window is closed. | |
|
Kathy Walrath
2012/11/20 00:04:21
the -> this
Andrei Mouravski
2012/11/20 00:15:38
Done.
| |
| 37 * | |
| 38 * print(window.closed); // 'false' | |
| 39 * window.close(); | |
| 40 * print(window.closed); // 'true' | |
| 41 */ | |
| 28 bool get closed; | 42 bool get closed; |
| 43 | |
| 44 /** | |
| 45 * A reference to the [Window] that opened this [Window]. | |
|
Kathy Walrath
2012/11/20 00:04:21
change to:
A reference to the window that opened
Andrei Mouravski
2012/11/20 00:15:38
Done.
| |
| 46 * | |
| 47 * Window thisWindow = window; | |
| 48 * Window otherWindow = thisWindow.open('http://www.example.com/', 'foo'); | |
| 49 * print(otherWindow.opener == thisWindow); // 'true' | |
| 50 */ | |
| 29 Window get opener; | 51 Window get opener; |
| 52 | |
| 53 /** | |
| 54 * A reference to the parent of this [Window]. | |
|
Kathy Walrath
2012/11/20 00:04:21
[Window] -> window
Andrei Mouravski
2012/11/20 00:15:38
Done.
| |
| 55 * | |
| 56 * If this [Window] has no parent, [parent] will return a reference to | |
| 57 * the [Window] itself. | |
| 58 * | |
| 59 * IFrameElement myIFrame = new IFrameElement(); | |
| 60 * window.document.body.elements.add(myIFrame); | |
| 61 * print(myIframe.contentWindow.parent == window) // 'true' | |
| 62 * | |
| 63 * print(window.parent == window) // 'true' | |
| 64 */ | |
| 30 Window get parent; | 65 Window get parent; |
| 66 | |
| 67 /** | |
| 68 * A reference to the topmost [Window] in the [Window] heirarchy. | |
|
Kathy Walrath
2012/11/20 00:04:21
again, [Window] -> window
Andrei Mouravski
2012/11/20 00:15:38
Done.
| |
| 69 * | |
| 70 * If this [Window] is the topmost [Window], [top] will return a reference to | |
| 71 * the [Window] itself. | |
| 72 * | |
| 73 * // Add an IFrame to the current window. | |
| 74 * IFrameElement myIFrame = new IFrameElement(); | |
| 75 * window.document.body.elements.add(myIFrame); | |
| 76 * | |
| 77 * // Add an IFrame inside of the other IFrame. | |
| 78 * IFrameElement innerIFrame = new IFrameElement(); | |
| 79 * myIFrame.elements.add(innerIFrame); | |
| 80 * | |
| 81 * print(myIframe.contentWindow.top == window) // 'true' | |
| 82 * print(innerIFrame.contentWindow.top == window) // 'true' | |
| 83 * | |
| 84 * print(window.top == window) // 'true' | |
| 85 */ | |
| 31 Window get top; | 86 Window get top; |
| 32 | 87 |
| 33 // Methods. | 88 // Methods. |
| 34 void focus(); | 89 void focus(); |
| 35 void blur(); | 90 void blur(); |
| 36 void close(); | 91 void close(); |
| 37 void postMessage(var message, String targetOrigin, [List messagePorts = null]) ; | 92 void postMessage(var message, String targetOrigin, [List messagePorts = null]) ; |
| 38 } | 93 } |
| 39 | 94 |
| 40 abstract class Location { | 95 abstract class Location { |
| 41 void set href(String val); | 96 void set href(String val); |
| 42 } | 97 } |
| 43 | 98 |
| 44 abstract class History { | 99 abstract class History { |
| 45 void back(); | 100 void back(); |
| 46 void forward(); | 101 void forward(); |
| 47 void go(int distance); | 102 void go(int distance); |
| 48 } | 103 } |
| OLD | NEW |