| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 class ScriptCallStack; | 57 class ScriptCallStack; |
| 58 class SecurityOrigin; | 58 class SecurityOrigin; |
| 59 | 59 |
| 60 enum PageshowEventPersistence { | 60 enum PageshowEventPersistence { |
| 61 PageshowEventNotPersisted = 0, | 61 PageshowEventNotPersisted = 0, |
| 62 PageshowEventPersisted = 1 | 62 PageshowEventPersisted = 1 |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Note: if you're thinking of returning something DOM-related by reference, | 65 // Note: if you're thinking of returning something DOM-related by reference, |
| 66 // please ping dcheng@chromium.org first. You probably don't want to do that. | 66 // please ping dcheng@chromium.org first. You probably don't want to do that. |
| 67 class CORE_EXPORT LocalDOMWindow final : public DOMWindow, public WillBeHeapSupp
lementable<LocalDOMWindow>, public DOMWindowLifecycleNotifier { | 67 class CORE_EXPORT LocalDOMWindow final : public DOMWindow, public HeapSupplement
able<LocalDOMWindow>, public DOMWindowLifecycleNotifier { |
| 68 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LocalDOMWindow); | 68 USING_GARBAGE_COLLECTED_MIXIN(LocalDOMWindow); |
| 69 WILL_BE_USING_PRE_FINALIZER(LocalDOMWindow, dispose); | 69 USING_PRE_FINALIZER(LocalDOMWindow, dispose); |
| 70 public: | 70 public: |
| 71 static PassRefPtrWillBeRawPtr<Document> createDocument(const String& mimeTyp
e, const DocumentInit&, bool forceXHTML); | 71 static RawPtr<Document> createDocument(const String& mimeType, const Documen
tInit&, bool forceXHTML); |
| 72 static PassRefPtrWillBeRawPtr<LocalDOMWindow> create(LocalFrame& frame) | 72 static RawPtr<LocalDOMWindow> create(LocalFrame& frame) |
| 73 { | 73 { |
| 74 return adoptRefWillBeNoop(new LocalDOMWindow(frame)); | 74 return (new LocalDOMWindow(frame)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 ~LocalDOMWindow() override; | 77 ~LocalDOMWindow() override; |
| 78 | 78 |
| 79 DECLARE_VIRTUAL_TRACE(); | 79 DECLARE_VIRTUAL_TRACE(); |
| 80 | 80 |
| 81 PassRefPtrWillBeRawPtr<Document> installNewDocument(const String& mimeType,
const DocumentInit&, bool forceXHTML = false); | 81 RawPtr<Document> installNewDocument(const String& mimeType, const DocumentIn
it&, bool forceXHTML = false); |
| 82 | 82 |
| 83 // EventTarget overrides: | 83 // EventTarget overrides: |
| 84 ExecutionContext* executionContext() const override; | 84 ExecutionContext* executionContext() const override; |
| 85 const LocalDOMWindow* toDOMWindow() const override; | 85 const LocalDOMWindow* toDOMWindow() const override; |
| 86 LocalDOMWindow* toDOMWindow() override; | 86 LocalDOMWindow* toDOMWindow() override; |
| 87 | 87 |
| 88 // DOMWindow overrides: | 88 // DOMWindow overrides: |
| 89 bool isLocalDOMWindow() const override { return true; } | 89 bool isLocalDOMWindow() const override { return true; } |
| 90 LocalFrame* frame() const override; | 90 LocalFrame* frame() const override; |
| 91 Screen* screen() const override; | 91 Screen* screen() const override; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // crbug.com/434497 | 131 // crbug.com/434497 |
| 132 void scrollBy(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const
override; | 132 void scrollBy(double x, double y, ScrollBehavior = ScrollBehaviorAuto) const
override; |
| 133 void scrollBy(const ScrollToOptions&) const override; | 133 void scrollBy(const ScrollToOptions&) const override; |
| 134 void scrollTo(double x, double y) const override; | 134 void scrollTo(double x, double y) const override; |
| 135 void scrollTo(const ScrollToOptions&) const override; | 135 void scrollTo(const ScrollToOptions&) const override; |
| 136 | 136 |
| 137 void moveBy(int x, int y) const override; | 137 void moveBy(int x, int y) const override; |
| 138 void moveTo(int x, int y) const override; | 138 void moveTo(int x, int y) const override; |
| 139 void resizeBy(int x, int y) const override; | 139 void resizeBy(int x, int y) const override; |
| 140 void resizeTo(int width, int height) const override; | 140 void resizeTo(int width, int height) const override; |
| 141 PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&) override; | 141 RawPtr<MediaQueryList> matchMedia(const String&) override; |
| 142 PassRefPtrWillBeRawPtr<CSSStyleDeclaration> getComputedStyle(Element*, const
String& pseudoElt) const override; | 142 RawPtr<CSSStyleDeclaration> getComputedStyle(Element*, const String& pseudoE
lt) const override; |
| 143 PassRefPtrWillBeRawPtr<CSSRuleList> getMatchedCSSRules(Element*, const Strin
g& pseudoElt) const override; | 143 RawPtr<CSSRuleList> getMatchedCSSRules(Element*, const String& pseudoElt) co
nst override; |
| 144 int requestAnimationFrame(FrameRequestCallback*) override; | 144 int requestAnimationFrame(FrameRequestCallback*) override; |
| 145 int webkitRequestAnimationFrame(FrameRequestCallback*) override; | 145 int webkitRequestAnimationFrame(FrameRequestCallback*) override; |
| 146 void cancelAnimationFrame(int id) override; | 146 void cancelAnimationFrame(int id) override; |
| 147 int requestIdleCallback(IdleRequestCallback*, const IdleRequestOptions&) ove
rride; | 147 int requestIdleCallback(IdleRequestCallback*, const IdleRequestOptions&) ove
rride; |
| 148 void cancelIdleCallback(int id) override; | 148 void cancelIdleCallback(int id) override; |
| 149 void schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent>, LocalDOMWindo
w* source, SecurityOrigin* target, PassRefPtr<ScriptCallStack> stackTrace); | 149 void schedulePostMessage(RawPtr<MessageEvent>, LocalDOMWindow* source, Secur
ityOrigin* target, PassRefPtr<ScriptCallStack> stackTrace); |
| 150 | 150 |
| 151 void registerProperty(DOMWindowProperty*); | 151 void registerProperty(DOMWindowProperty*); |
| 152 void unregisterProperty(DOMWindowProperty*); | 152 void unregisterProperty(DOMWindowProperty*); |
| 153 | 153 |
| 154 void reset(); | 154 void reset(); |
| 155 | 155 |
| 156 unsigned pendingUnloadEventListeners() const; | 156 unsigned pendingUnloadEventListeners() const; |
| 157 | 157 |
| 158 bool allowPopUp(); // Call on first window, not target window. | 158 bool allowPopUp(); // Call on first window, not target window. |
| 159 static bool allowPopUp(LocalFrame& firstFrame); | 159 static bool allowPopUp(LocalFrame& firstFrame); |
| 160 | 160 |
| 161 Element* frameElement() const; | 161 Element* frameElement() const; |
| 162 | 162 |
| 163 PassRefPtrWillBeRawPtr<DOMWindow> open(const String& urlString, const Atomic
String& frameName, const String& windowFeaturesString, | 163 RawPtr<DOMWindow> open(const String& urlString, const AtomicString& frameNam
e, const String& windowFeaturesString, |
| 164 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow); | 164 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow); |
| 165 | 165 |
| 166 FrameConsole* frameConsole() const; | 166 FrameConsole* frameConsole() const; |
| 167 | 167 |
| 168 void printErrorMessage(const String&) const; | 168 void printErrorMessage(const String&) const; |
| 169 | 169 |
| 170 void postMessageTimerFired(PostMessageTimer*); | 170 void postMessageTimerFired(PostMessageTimer*); |
| 171 void removePostMessageTimer(PostMessageTimer*); | 171 void removePostMessageTimer(PostMessageTimer*); |
| 172 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigi
n, PassRefPtrWillBeRawPtr<Event>, PassRefPtr<ScriptCallStack>); | 172 void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigi
n, RawPtr<Event>, PassRefPtr<ScriptCallStack>); |
| 173 | 173 |
| 174 // Events | 174 // Events |
| 175 // EventTarget API | 175 // EventTarget API |
| 176 void removeAllEventListeners() override; | 176 void removeAllEventListeners() override; |
| 177 | 177 |
| 178 using EventTarget::dispatchEvent; | 178 using EventTarget::dispatchEvent; |
| 179 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeR
awPtr<EventTarget> prpTarget); | 179 bool dispatchEvent(RawPtr<Event> prpEvent, RawPtr<EventTarget> prpTarget); |
| 180 | 180 |
| 181 void finishedLoading(); | 181 void finishedLoading(); |
| 182 | 182 |
| 183 // Dispatch the (deprecated) orientationchange event to this DOMWindow and | 183 // Dispatch the (deprecated) orientationchange event to this DOMWindow and |
| 184 // recurse on its child frames. | 184 // recurse on its child frames. |
| 185 void sendOrientationChangeEvent(); | 185 void sendOrientationChangeEvent(); |
| 186 | 186 |
| 187 void willDetachDocumentFromFrame(); | 187 void willDetachDocumentFromFrame(); |
| 188 | 188 |
| 189 EventQueue* eventQueue() const; | 189 EventQueue* eventQueue() const; |
| 190 void enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event>); | 190 void enqueueWindowEvent(RawPtr<Event>); |
| 191 void enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event>); | 191 void enqueueDocumentEvent(RawPtr<Event>); |
| 192 void enqueuePageshowEvent(PageshowEventPersistence); | 192 void enqueuePageshowEvent(PageshowEventPersistence); |
| 193 void enqueueHashchangeEvent(const String& oldURL, const String& newURL); | 193 void enqueueHashchangeEvent(const String& oldURL, const String& newURL); |
| 194 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue>); | 194 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue>); |
| 195 void dispatchWindowLoadEvent(); | 195 void dispatchWindowLoadEvent(); |
| 196 void documentWasClosed(); | 196 void documentWasClosed(); |
| 197 void statePopped(PassRefPtr<SerializedScriptValue>); | 197 void statePopped(PassRefPtr<SerializedScriptValue>); |
| 198 | 198 |
| 199 // FIXME: This shouldn't be public once LocalDOMWindow becomes ExecutionCont
ext. | 199 // FIXME: This shouldn't be public once LocalDOMWindow becomes ExecutionCont
ext. |
| 200 void clearEventQueue(); | 200 void clearEventQueue(); |
| 201 | 201 |
| 202 void acceptLanguagesChanged(); | 202 void acceptLanguagesChanged(); |
| 203 | 203 |
| 204 protected: | 204 protected: |
| 205 // EventTarget overrides. | 205 // EventTarget overrides. |
| 206 bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillB
eRawPtr<EventListener>, const EventListenerOptions&) override; | 206 bool addEventListenerInternal(const AtomicString& eventType, RawPtr<EventLis
tener>, const EventListenerOptions&) override; |
| 207 bool removeEventListenerInternal(const AtomicString& eventType, PassRefPtrWi
llBeRawPtr<EventListener>, const EventListenerOptions&) override; | 207 bool removeEventListenerInternal(const AtomicString& eventType, RawPtr<Event
Listener>, const EventListenerOptions&) override; |
| 208 | 208 |
| 209 private: | 209 private: |
| 210 // Rather than simply inheriting LocalFrameLifecycleObserver like most other | 210 // Rather than simply inheriting LocalFrameLifecycleObserver like most other |
| 211 // classes, LocalDOMWindow hides its LocalFrameLifecycleObserver with | 211 // classes, LocalDOMWindow hides its LocalFrameLifecycleObserver with |
| 212 // composition. This prevents conflicting overloads between DOMWindow, which | 212 // composition. This prevents conflicting overloads between DOMWindow, which |
| 213 // has a frame() accessor that returns Frame* for bindings code, and | 213 // has a frame() accessor that returns Frame* for bindings code, and |
| 214 // LocalFrameLifecycleObserver, which has a frame() accessor that returns a | 214 // LocalFrameLifecycleObserver, which has a frame() accessor that returns a |
| 215 // LocalFrame*. | 215 // LocalFrame*. |
| 216 class WindowFrameObserver final : public NoBaseWillBeGarbageCollected<Window
FrameObserver>, public LocalFrameLifecycleObserver { | 216 class WindowFrameObserver final : public GarbageCollected<WindowFrameObserve
r>, public LocalFrameLifecycleObserver { |
| 217 USING_FAST_MALLOC_WILL_BE_REMOVED(WindowFrameObserver); | 217 USING_GARBAGE_COLLECTED_MIXIN(WindowFrameObserver); |
| 218 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WindowFrameObserver); | |
| 219 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(WindowFrameObserver); | |
| 220 public: | 218 public: |
| 221 static PassOwnPtrWillBeRawPtr<WindowFrameObserver> create(LocalDOMWindow
*, LocalFrame&); | 219 static RawPtr<WindowFrameObserver> create(LocalDOMWindow*, LocalFrame&); |
| 222 | 220 |
| 223 DECLARE_VIRTUAL_TRACE(); | 221 DECLARE_VIRTUAL_TRACE(); |
| 224 | 222 |
| 225 // LocalFrameLifecycleObserver overrides: | 223 // LocalFrameLifecycleObserver overrides: |
| 226 void willDetachFrameHost() override; | 224 void willDetachFrameHost() override; |
| 227 void contextDestroyed() override; | 225 void contextDestroyed() override; |
| 228 | 226 |
| 229 private: | 227 private: |
| 230 WindowFrameObserver(LocalDOMWindow*, LocalFrame&); | 228 WindowFrameObserver(LocalDOMWindow*, LocalFrame&); |
| 231 | 229 |
| 232 RawPtrWillBeMember<LocalDOMWindow> m_window; | 230 Member<LocalDOMWindow> m_window; |
| 233 }; | 231 }; |
| 234 friend WTF::OwnedPtrDeleter<WindowFrameObserver>; | 232 friend WTF::OwnedPtrDeleter<WindowFrameObserver>; |
| 235 | 233 |
| 236 explicit LocalDOMWindow(LocalFrame&); | 234 explicit LocalDOMWindow(LocalFrame&); |
| 237 void dispose(); | 235 void dispose(); |
| 238 | 236 |
| 239 void dispatchLoadEvent(); | 237 void dispatchLoadEvent(); |
| 240 void clearDocument(); | 238 void clearDocument(); |
| 241 void willDestroyDocumentInFrame(); | 239 void willDestroyDocumentInFrame(); |
| 242 | 240 |
| 243 void willDetachFrameHost(); | 241 void willDetachFrameHost(); |
| 244 void frameDestroyed(); | 242 void frameDestroyed(); |
| 245 | 243 |
| 246 OwnPtrWillBeMember<WindowFrameObserver> m_frameObserver; | 244 Member<WindowFrameObserver> m_frameObserver; |
| 247 RefPtrWillBeMember<Document> m_document; | 245 Member<Document> m_document; |
| 248 | 246 |
| 249 bool m_shouldPrintWhenFinishedLoading; | 247 bool m_shouldPrintWhenFinishedLoading; |
| 250 #if ENABLE(ASSERT) | 248 #if ENABLE(ASSERT) |
| 251 bool m_hasBeenReset; | 249 bool m_hasBeenReset; |
| 252 #endif | 250 #endif |
| 253 | 251 |
| 254 WillBeHeapHashSet<RawPtrWillBeWeakMember<DOMWindowProperty>> m_properties; | 252 HeapHashSet<WeakMember<DOMWindowProperty>> m_properties; |
| 255 | 253 |
| 256 mutable PersistentWillBeMember<Screen> m_screen; | 254 mutable Member<Screen> m_screen; |
| 257 mutable PersistentWillBeMember<History> m_history; | 255 mutable Member<History> m_history; |
| 258 mutable RefPtrWillBeMember<BarProp> m_locationbar; | 256 mutable Member<BarProp> m_locationbar; |
| 259 mutable RefPtrWillBeMember<BarProp> m_menubar; | 257 mutable Member<BarProp> m_menubar; |
| 260 mutable RefPtrWillBeMember<BarProp> m_personalbar; | 258 mutable Member<BarProp> m_personalbar; |
| 261 mutable RefPtrWillBeMember<BarProp> m_scrollbars; | 259 mutable Member<BarProp> m_scrollbars; |
| 262 mutable RefPtrWillBeMember<BarProp> m_statusbar; | 260 mutable Member<BarProp> m_statusbar; |
| 263 mutable RefPtrWillBeMember<BarProp> m_toolbar; | 261 mutable Member<BarProp> m_toolbar; |
| 264 mutable PersistentWillBeMember<Console> m_console; | 262 mutable Member<Console> m_console; |
| 265 mutable PersistentWillBeMember<Navigator> m_navigator; | 263 mutable Member<Navigator> m_navigator; |
| 266 mutable RefPtrWillBeMember<StyleMedia> m_media; | 264 mutable Member<StyleMedia> m_media; |
| 267 | 265 |
| 268 String m_status; | 266 String m_status; |
| 269 String m_defaultStatus; | 267 String m_defaultStatus; |
| 270 | 268 |
| 271 mutable PersistentWillBeMember<ApplicationCache> m_applicationCache; | 269 mutable Member<ApplicationCache> m_applicationCache; |
| 272 | 270 |
| 273 RefPtrWillBeMember<DOMWindowEventQueue> m_eventQueue; | 271 Member<DOMWindowEventQueue> m_eventQueue; |
| 274 RefPtr<SerializedScriptValue> m_pendingStateObject; | 272 RefPtr<SerializedScriptValue> m_pendingStateObject; |
| 275 | 273 |
| 276 WillBeHeapHashSet<OwnPtrWillBeMember<PostMessageTimer>> m_postMessageTimers; | 274 HeapHashSet<Member<PostMessageTimer>> m_postMessageTimers; |
| 277 }; | 275 }; |
| 278 | 276 |
| 279 DEFINE_TYPE_CASTS(LocalDOMWindow, DOMWindow, x, x->isLocalDOMWindow(), x.isLocal
DOMWindow()); | 277 DEFINE_TYPE_CASTS(LocalDOMWindow, DOMWindow, x, x->isLocalDOMWindow(), x.isLocal
DOMWindow()); |
| 280 | 278 |
| 281 inline String LocalDOMWindow::status() const | 279 inline String LocalDOMWindow::status() const |
| 282 { | 280 { |
| 283 return m_status; | 281 return m_status; |
| 284 } | 282 } |
| 285 | 283 |
| 286 inline String LocalDOMWindow::defaultStatus() const | 284 inline String LocalDOMWindow::defaultStatus() const |
| 287 { | 285 { |
| 288 return m_defaultStatus; | 286 return m_defaultStatus; |
| 289 } | 287 } |
| 290 | 288 |
| 291 } // namespace blink | 289 } // namespace blink |
| 292 | 290 |
| 293 #endif // LocalDOMWindow_h | 291 #endif // LocalDOMWindow_h |
| OLD | NEW |