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

Side by Side Diff: sky/engine/core/frame/LocalDOMWindow.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « sky/engine/core/frame/LocalDOMWindow.h ('k') | sky/engine/core/frame/LocalFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 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 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "sky/engine/config.h" 27 #include "sky/engine/config.h"
28 #include "sky/engine/core/frame/LocalDOMWindow.h" 28 #include "sky/engine/core/frame/LocalDOMWindow.h"
29 29
30 #include <algorithm> 30 #include <algorithm>
31 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 31 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
32 #include "sky/engine/bindings/core/v8/Dictionary.h" 32 #include "sky/engine/bindings2/exception_messages.h"
33 #include "sky/engine/bindings/core/v8/ExceptionMessages.h" 33 #include "sky/engine/bindings2/exception_state.h"
34 #include "sky/engine/bindings/core/v8/ExceptionState.h" 34 #include "sky/engine/bindings2/exception_state_placeholder.h"
35 #include "sky/engine/bindings/core/v8/ExceptionStatePlaceholder.h"
36 #include "sky/engine/bindings/core/v8/ScriptCallStackFactory.h"
37 #include "sky/engine/bindings/core/v8/ScriptController.h"
38 #include "sky/engine/bindings/core/v8/SerializedScriptValue.h"
39 #include "sky/engine/core/app/Application.h" 35 #include "sky/engine/core/app/Application.h"
40 #include "sky/engine/core/css/CSSComputedStyleDeclaration.h" 36 #include "sky/engine/core/css/CSSComputedStyleDeclaration.h"
41 #include "sky/engine/core/css/DOMWindowCSS.h" 37 #include "sky/engine/core/css/DOMWindowCSS.h"
42 #include "sky/engine/core/css/MediaQueryList.h" 38 #include "sky/engine/core/css/MediaQueryList.h"
43 #include "sky/engine/core/css/MediaQueryMatcher.h" 39 #include "sky/engine/core/css/MediaQueryMatcher.h"
44 #include "sky/engine/core/css/resolver/StyleResolver.h" 40 #include "sky/engine/core/css/resolver/StyleResolver.h"
45 #include "sky/engine/core/dom/Document.h" 41 #include "sky/engine/core/dom/Document.h"
46 #include "sky/engine/core/dom/Element.h" 42 #include "sky/engine/core/dom/Element.h"
47 #include "sky/engine/core/dom/ExceptionCode.h" 43 #include "sky/engine/core/dom/ExceptionCode.h"
48 #include "sky/engine/core/dom/ExecutionContext.h" 44 #include "sky/engine/core/dom/ExecutionContext.h"
49 #include "sky/engine/core/dom/RequestAnimationFrameCallback.h" 45 #include "sky/engine/core/dom/RequestAnimationFrameCallback.h"
50 #include "sky/engine/core/editing/Editor.h" 46 #include "sky/engine/core/editing/Editor.h"
51 #include "sky/engine/core/events/DOMWindowEventQueue.h" 47 #include "sky/engine/core/events/DOMWindowEventQueue.h"
52 #include "sky/engine/core/events/EventListener.h" 48 #include "sky/engine/core/events/EventListener.h"
53 #include "sky/engine/core/events/HashChangeEvent.h" 49 #include "sky/engine/core/events/HashChangeEvent.h"
54 #include "sky/engine/core/events/PageTransitionEvent.h" 50 #include "sky/engine/core/events/PageTransitionEvent.h"
55 #include "sky/engine/core/frame/Console.h"
56 #include "sky/engine/core/frame/DOMWindowLifecycleNotifier.h" 51 #include "sky/engine/core/frame/DOMWindowLifecycleNotifier.h"
57 #include "sky/engine/core/frame/FrameConsole.h" 52 #include "sky/engine/core/frame/FrameConsole.h"
58 #include "sky/engine/core/frame/FrameHost.h" 53 #include "sky/engine/core/frame/FrameHost.h"
59 #include "sky/engine/core/frame/FrameView.h" 54 #include "sky/engine/core/frame/FrameView.h"
60 #include "sky/engine/core/frame/LocalFrame.h" 55 #include "sky/engine/core/frame/LocalFrame.h"
61 #include "sky/engine/core/frame/Location.h" 56 #include "sky/engine/core/frame/Location.h"
62 #include "sky/engine/core/frame/Screen.h" 57 #include "sky/engine/core/frame/Screen.h"
63 #include "sky/engine/core/frame/Settings.h" 58 #include "sky/engine/core/frame/Settings.h"
64 #include "sky/engine/core/inspector/ConsoleMessage.h" 59 #include "sky/engine/core/inspector/ConsoleMessage.h"
65 #include "sky/engine/core/inspector/ConsoleMessageStorage.h"
66 #include "sky/engine/core/loader/FrameLoaderClient.h" 60 #include "sky/engine/core/loader/FrameLoaderClient.h"
67 #include "sky/engine/core/page/ChromeClient.h" 61 #include "sky/engine/core/page/ChromeClient.h"
68 #include "sky/engine/core/page/EventHandler.h" 62 #include "sky/engine/core/page/EventHandler.h"
69 #include "sky/engine/core/page/Page.h" 63 #include "sky/engine/core/page/Page.h"
70 #include "sky/engine/core/rendering/style/RenderStyle.h" 64 #include "sky/engine/core/rendering/style/RenderStyle.h"
65 #include "sky/engine/core/script/dart_controller.h"
71 #include "sky/engine/platform/EventDispatchForbiddenScope.h" 66 #include "sky/engine/platform/EventDispatchForbiddenScope.h"
72 #include "sky/engine/platform/PlatformScreen.h" 67 #include "sky/engine/platform/PlatformScreen.h"
73 #include "sky/engine/platform/geometry/FloatRect.h" 68 #include "sky/engine/platform/geometry/FloatRect.h"
74 #include "sky/engine/platform/weborigin/KURL.h" 69 #include "sky/engine/platform/weborigin/KURL.h"
75 #include "sky/engine/platform/weborigin/SecurityPolicy.h" 70 #include "sky/engine/platform/weborigin/SecurityPolicy.h"
76 #include "sky/engine/public/platform/Platform.h" 71 #include "sky/engine/public/platform/Platform.h"
77 #include "sky/engine/core/inspector/ScriptCallStack.h"
78 #include "sky/engine/wtf/MainThread.h" 72 #include "sky/engine/wtf/MainThread.h"
79 #include "sky/engine/wtf/MathExtras.h" 73 #include "sky/engine/wtf/MathExtras.h"
80 #include "sky/engine/wtf/text/WTFString.h" 74 #include "sky/engine/wtf/text/WTFString.h"
81 75
82 using std::min; 76 using std::min;
83 using std::max; 77 using std::max;
84 78
85 namespace blink { 79 namespace blink {
86 80
87 static void disableSuddenTermination() 81 static void disableSuddenTermination()
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 215
222 PassRefPtr<Document> LocalDOMWindow::installNewDocument(const DocumentInit& init ) 216 PassRefPtr<Document> LocalDOMWindow::installNewDocument(const DocumentInit& init )
223 { 217 {
224 ASSERT(init.frame() == m_frame); 218 ASSERT(init.frame() == m_frame);
225 219
226 clearDocument(); 220 clearDocument();
227 221
228 m_document = Document::create(init); 222 m_document = Document::create(init);
229 m_application = Application::create(m_document.get(), m_document.get(), m_do cument->url().string()); 223 m_application = Application::create(m_document.get(), m_document.get(), m_do cument->url().string());
230 m_eventQueue = DOMWindowEventQueue::create(m_document.get()); 224 m_eventQueue = DOMWindowEventQueue::create(m_document.get());
225 m_frame->dart().CreateIsolateFor(m_document.get());
231 m_document->attach(); 226 m_document->attach();
232 227
233 m_frame->script().updateDocument();
234 return m_document; 228 return m_document;
235 } 229 }
236 230
237 EventQueue* LocalDOMWindow::eventQueue() const 231 EventQueue* LocalDOMWindow::eventQueue() const
238 { 232 {
239 return m_eventQueue.get(); 233 return m_eventQueue.get();
240 } 234 }
241 235
242 void LocalDOMWindow::enqueueWindowEvent(PassRefPtr<Event> event) 236 void LocalDOMWindow::enqueueWindowEvent(PassRefPtr<Event> event)
243 { 237 {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 321 }
328 322
329 void LocalDOMWindow::frameDestroyed() 323 void LocalDOMWindow::frameDestroyed()
330 { 324 {
331 FrameDestructionObserver::frameDestroyed(); 325 FrameDestructionObserver::frameDestroyed();
332 reset(); 326 reset();
333 } 327 }
334 328
335 void LocalDOMWindow::willDetachFrameHost() 329 void LocalDOMWindow::willDetachFrameHost()
336 { 330 {
337 m_frame->console().messageStorage()->frameWindowDiscarded(this); 331 // FIXME(sky): remove
338 } 332 }
339 333
340 void LocalDOMWindow::willDestroyDocumentInFrame() 334 void LocalDOMWindow::willDestroyDocumentInFrame()
341 { 335 {
342 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may 336 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may
343 // unregister themselves from the LocalDOMWindow as a result of the call to willDestroyGlobalObjectInFrame. 337 // unregister themselves from the LocalDOMWindow as a result of the call to willDestroyGlobalObjectInFrame.
344 Vector<DOMWindowProperty*> properties; 338 Vector<DOMWindowProperty*> properties;
345 copyToVector(m_properties, properties); 339 copyToVector(m_properties, properties);
346 for (size_t i = 0; i < properties.size(); ++i) 340 for (size_t i = 0; i < properties.size(); ++i)
347 properties[i]->willDestroyGlobalObjectInFrame(); 341 properties[i]->willDestroyGlobalObjectInFrame();
(...skipping 23 matching lines...) Expand all
371 { 365 {
372 willDestroyDocumentInFrame(); 366 willDestroyDocumentInFrame();
373 resetDOMWindowProperties(); 367 resetDOMWindowProperties();
374 } 368 }
375 369
376 void LocalDOMWindow::resetDOMWindowProperties() 370 void LocalDOMWindow::resetDOMWindowProperties()
377 { 371 {
378 m_properties.clear(); 372 m_properties.clear();
379 373
380 m_screen = nullptr; 374 m_screen = nullptr;
381 m_console = nullptr;
382 m_location = nullptr; 375 m_location = nullptr;
383 #if ENABLE(ASSERT) 376 #if ENABLE(ASSERT)
384 m_hasBeenReset = true; 377 m_hasBeenReset = true;
385 #endif 378 #endif
386 } 379 }
387 380
388 int LocalDOMWindow::orientation() const 381 int LocalDOMWindow::orientation() const
389 { 382 {
390 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 383 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled());
391 384
392 int orientation = screenOrientationAngle(m_frame->view()); 385 int orientation = screenOrientationAngle(m_frame->view());
393 // For backward compatibility, we want to return a value in the range of 386 // For backward compatibility, we want to return a value in the range of
394 // [-90; 180] instead of [0; 360[ because window.orientation used to behave 387 // [-90; 180] instead of [0; 360[ because window.orientation used to behave
395 // like that in WebKit (this is a WebKit proprietary API). 388 // like that in WebKit (this is a WebKit proprietary API).
396 if (orientation == 270) 389 if (orientation == 270)
397 return -90; 390 return -90;
398 return orientation; 391 return orientation;
399 } 392 }
400 393
401 Screen& LocalDOMWindow::screen() const 394 Screen& LocalDOMWindow::screen() const
402 { 395 {
403 if (!m_screen) 396 if (!m_screen)
404 m_screen = Screen::create(m_frame); 397 m_screen = Screen::create(m_frame);
405 return *m_screen; 398 return *m_screen;
406 } 399 }
407 400
408 Console& LocalDOMWindow::console() const
409 {
410 if (!m_console)
411 m_console = Console::create(m_frame);
412 return *m_console;
413 }
414
415 FrameConsole* LocalDOMWindow::frameConsole() const 401 FrameConsole* LocalDOMWindow::frameConsole() const
416 { 402 {
417 return &m_frame->console(); 403 return &m_frame->console();
418 } 404 }
419 405
420 Location& LocalDOMWindow::location() const 406 Location& LocalDOMWindow::location() const
421 { 407 {
422 if (!m_location) 408 if (!m_location)
423 m_location = Location::create(m_frame); 409 m_location = Location::create(m_frame);
424 return *m_location; 410 return *m_location;
425 } 411 }
426 412
427 DOMSelection* LocalDOMWindow::getSelection() 413 DOMSelection* LocalDOMWindow::getSelection()
428 { 414 {
429 return m_frame->document()->getSelection(); 415 return m_frame->document()->getSelection();
430 } 416 }
431 417
432 void LocalDOMWindow::focus(ExecutionContext* context) 418 void LocalDOMWindow::focus()
433 { 419 {
434 if (!m_frame) 420 if (!m_frame)
435 return; 421 return;
436 422
437 FrameHost* host = m_frame->host(); 423 FrameHost* host = m_frame->host();
438 if (!host) 424 if (!host)
439 return; 425 return;
440 426
441 host->page().focus(); 427 host->page().focus();
442 428
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 lifecycleNotifier().notifyRemoveAllEventListeners(this); 672 lifecycleNotifier().notifyRemoveAllEventListeners(this);
687 673
688 removeAllUnloadEventListeners(this); 674 removeAllUnloadEventListeners(this);
689 } 675 }
690 676
691 void LocalDOMWindow::removeAllEventListeners() 677 void LocalDOMWindow::removeAllEventListeners()
692 { 678 {
693 removeAllEventListenersInternal(DoBroadcastListenerRemoval); 679 removeAllEventListenersInternal(DoBroadcastListenerRemoval);
694 } 680 }
695 681
696 void LocalDOMWindow::setLocation(const String& urlString, LocalDOMWindow* callin gWindow, LocalDOMWindow* enteredWindow, SetLocationLocking locking) 682 void LocalDOMWindow::setLocation(const String& urlString, SetLocationLocking loc king)
697 { 683 {
698 // FIXME(sky): remove. 684 // FIXME(sky): remove.
699 } 685 }
700 686
701 void LocalDOMWindow::printErrorMessage(const String& message) 687 void LocalDOMWindow::printErrorMessage(const String& message)
702 { 688 {
703 if (message.isEmpty()) 689 if (message.isEmpty())
704 return; 690 return;
705 691
706 frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, ErrorMess ageLevel, message)); 692 frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, ErrorMess ageLevel, message));
(...skipping 10 matching lines...) Expand all
717 { 703 {
718 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier()); 704 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier());
719 } 705 }
720 706
721 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo tifier() 707 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo tifier()
722 { 708 {
723 return DOMWindowLifecycleNotifier::create(this); 709 return DOMWindowLifecycleNotifier::create(this);
724 } 710 }
725 711
726 } // namespace blink 712 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/frame/LocalDOMWindow.h ('k') | sky/engine/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698