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

Side by Side Diff: Source/core/events/MessageEvent.cpp

Issue 26558004: Revert 158219 "Move dom/*Event* to events to match the DOM vs. E..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1651/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/events/MessageEvent.h ('k') | Source/core/events/MessageEvent.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2007 Henry Mason (hmason@mac.com)
3 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
25 *
26 */
27
28 #include "config.h"
29 #include "core/events/MessageEvent.h"
30
31 #include "core/events/EventNames.h"
32 #include "core/page/DOMWindow.h"
33
34 namespace WebCore {
35
36 static inline bool isValidSource(EventTarget* source)
37 {
38 return !source || source->toDOMWindow() || source->toMessagePort();
39 }
40
41 MessageEventInit::MessageEventInit()
42 {
43 }
44
45 MessageEvent::MessageEvent()
46 : m_dataType(DataTypeScriptValue)
47 {
48 ScriptWrappable::init(this);
49 }
50
51 MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& ini tializer)
52 : Event(type, initializer)
53 , m_dataType(DataTypeScriptValue)
54 , m_origin(initializer.origin)
55 , m_lastEventId(initializer.lastEventId)
56 , m_source(isValidSource(initializer.source.get()) ? initializer.source : 0)
57 , m_ports(adoptPtr(new MessagePortArray(initializer.ports)))
58 {
59 ScriptWrappable::init(this);
60 ASSERT(isValidSource(m_source.get()));
61 }
62
63 MessageEvent::MessageEvent(const String& origin, const String& lastEventId, Pass RefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports)
64 : Event(eventNames().messageEvent, false, false)
65 , m_dataType(DataTypeScriptValue)
66 , m_origin(origin)
67 , m_lastEventId(lastEventId)
68 , m_source(source)
69 , m_ports(ports)
70 {
71 ScriptWrappable::init(this);
72 ASSERT(isValidSource(m_source.get()));
73 }
74
75 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<M essagePortArray> ports)
76 : Event(eventNames().messageEvent, false, false)
77 , m_dataType(DataTypeSerializedScriptValue)
78 , m_dataAsSerializedScriptValue(data)
79 , m_origin(origin)
80 , m_lastEventId(lastEventId)
81 , m_source(source)
82 , m_ports(ports)
83 {
84 ScriptWrappable::init(this);
85 if (m_dataAsSerializedScriptValue)
86 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC ontext();
87 ASSERT(isValidSource(m_source.get()));
88 }
89
90 MessageEvent::MessageEvent(const String& data, const String& origin)
91 : Event(eventNames().messageEvent, false, false)
92 , m_dataType(DataTypeString)
93 , m_dataAsString(data)
94 , m_origin(origin)
95 {
96 ScriptWrappable::init(this);
97 }
98
99 MessageEvent::MessageEvent(PassRefPtr<Blob> data, const String& origin)
100 : Event(eventNames().messageEvent, false, false)
101 , m_dataType(DataTypeBlob)
102 , m_dataAsBlob(data)
103 , m_origin(origin)
104 {
105 ScriptWrappable::init(this);
106 }
107
108 MessageEvent::MessageEvent(PassRefPtr<ArrayBuffer> data, const String& origin)
109 : Event(eventNames().messageEvent, false, false)
110 , m_dataType(DataTypeArrayBuffer)
111 , m_dataAsArrayBuffer(data)
112 , m_origin(origin)
113 {
114 ScriptWrappable::init(this);
115 }
116
117 MessageEvent::~MessageEvent()
118 {
119 }
120
121 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo ol cancelable, const String& origin, const String& lastEventId, DOMWindow* sourc e, PassOwnPtr<MessagePortArray> ports)
122 {
123 if (dispatched())
124 return;
125
126 initEvent(type, canBubble, cancelable);
127
128 m_dataType = DataTypeScriptValue;
129 m_origin = origin;
130 m_lastEventId = lastEventId;
131 m_source = source;
132 m_ports = ports;
133 }
134
135 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo ol cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, con st String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports)
136 {
137 if (dispatched())
138 return;
139
140 initEvent(type, canBubble, cancelable);
141
142 m_dataType = DataTypeSerializedScriptValue;
143 m_dataAsSerializedScriptValue = data;
144 m_origin = origin;
145 m_lastEventId = lastEventId;
146 m_source = source;
147 m_ports = ports;
148
149 if (m_dataAsSerializedScriptValue)
150 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC ontext();
151 }
152
153 const AtomicString& MessageEvent::interfaceName() const
154 {
155 return eventNames().interfaceForMessageEvent;
156 }
157
158 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/events/MessageEvent.h ('k') | Source/core/events/MessageEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698