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