| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/frame/DOMWindowProperty.h" | 36 #include "core/frame/DOMWindowProperty.h" |
| 37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class LocalDOMWindow; | 41 class LocalDOMWindow; |
| 42 class ExceptionState; | 42 class ExceptionState; |
| 43 class Frame; | 43 class Frame; |
| 44 class KURL; | 44 class KURL; |
| 45 | 45 |
| 46 // This class corresponds to the JS Location API, which is the only DOM API besi
des Window that is operable | 46 // This class corresponds to the JS Location API, which is the only DOM API |
| 47 // in a RemoteFrame. Rather than making DOMWindowProperty support RemoteFrames a
nd generating a lot | 47 // besides Window that is operable in a RemoteFrame. Rather than making |
| 48 // code churn, Location is implemented as a one-off with some custom lifetime ma
nagement code. Namely, | 48 // DOMWindowProperty support RemoteFrames and generating a lot code churn, |
| 49 // it needs a manual call to reset() from DOMWindow::reset() to ensure it doesn'
t retain a stale Frame pointer. | 49 // Location is implemented as a one-off with some custom lifetime management |
| 50 // code. Namely, it needs a manual call to reset() from DOMWindow::reset() to |
| 51 // ensure it doesn't retain a stale Frame pointer. |
| 50 class CORE_EXPORT Location final : public GarbageCollected<Location>, | 52 class CORE_EXPORT Location final : public GarbageCollected<Location>, |
| 51 public ScriptWrappable { | 53 public ScriptWrappable { |
| 52 DEFINE_WRAPPERTYPEINFO(); | 54 DEFINE_WRAPPERTYPEINFO(); |
| 53 | 55 |
| 54 public: | 56 public: |
| 55 static Location* create(Frame* frame) { return new Location(frame); } | 57 static Location* create(Frame* frame) { return new Location(frame); } |
| 56 | 58 |
| 57 Frame* frame() const { return m_frame.get(); } | 59 Frame* frame() const { return m_frame.get(); } |
| 58 void reset() { m_frame = nullptr; } | 60 void reset() { m_frame = nullptr; } |
| 59 | 61 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 String search() const; | 107 String search() const; |
| 106 void setHash(LocalDOMWindow* currentWindow, | 108 void setHash(LocalDOMWindow* currentWindow, |
| 107 LocalDOMWindow* enteredWindow, | 109 LocalDOMWindow* enteredWindow, |
| 108 const String&, | 110 const String&, |
| 109 ExceptionState&); | 111 ExceptionState&); |
| 110 String hash() const; | 112 String hash() const; |
| 111 String origin() const; | 113 String origin() const; |
| 112 | 114 |
| 113 DOMStringList* ancestorOrigins() const; | 115 DOMStringList* ancestorOrigins() const; |
| 114 | 116 |
| 115 // Just return the |this| object the way the normal valueOf function on the Ob
ject prototype would. | 117 // Just return the |this| object the way the normal valueOf function on the |
| 116 // The valueOf function is only added to make sure that it cannot be overwritt
en on location | 118 // Object prototype would. The valueOf function is only added to make sure |
| 117 // objects, since that would provide a hook to change the string conversion be
havior of location objects. | 119 // that it cannot be overwritten on location objects, since that would provide |
| 120 // a hook to change the string conversion behavior of location objects. |
| 118 ScriptValue valueOf(const ScriptValue& thisObject) { return thisObject; } | 121 ScriptValue valueOf(const ScriptValue& thisObject) { return thisObject; } |
| 119 | 122 |
| 120 DECLARE_VIRTUAL_TRACE(); | 123 DECLARE_VIRTUAL_TRACE(); |
| 121 | 124 |
| 122 private: | 125 private: |
| 123 explicit Location(Frame*); | 126 explicit Location(Frame*); |
| 124 | 127 |
| 125 enum class SetLocation { Normal, ReplaceThisFrame }; | 128 enum class SetLocation { Normal, ReplaceThisFrame }; |
| 126 void setLocation(const String&, | 129 void setLocation(const String&, |
| 127 LocalDOMWindow* currentWindow, | 130 LocalDOMWindow* currentWindow, |
| 128 LocalDOMWindow* enteredWindow, | 131 LocalDOMWindow* enteredWindow, |
| 129 ExceptionState* = nullptr, | 132 ExceptionState* = nullptr, |
| 130 SetLocation = SetLocation::Normal); | 133 SetLocation = SetLocation::Normal); |
| 131 | 134 |
| 132 const KURL& url() const; | 135 const KURL& url() const; |
| 133 | 136 |
| 134 Member<Frame> m_frame; | 137 Member<Frame> m_frame; |
| 135 }; | 138 }; |
| 136 | 139 |
| 137 } // namespace blink | 140 } // namespace blink |
| 138 | 141 |
| 139 #endif // Location_h | 142 #endif // Location_h |
| OLD | NEW |