| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (!isEntangled()) | 62 if (!isEntangled()) |
| 63 return; | 63 return; |
| 64 ASSERT(m_scriptExecutionContext); | 64 ASSERT(m_scriptExecutionContext); |
| 65 | 65 |
| 66 OwnPtr<MessagePortChannelArray> channels; | 66 OwnPtr<MessagePortChannelArray> channels; |
| 67 // Make sure we aren't connected to any of the passed-in ports. | 67 // Make sure we aren't connected to any of the passed-in ports. |
| 68 if (ports) { | 68 if (ports) { |
| 69 for (unsigned int i = 0; i < ports->size(); ++i) { | 69 for (unsigned int i = 0; i < ports->size(); ++i) { |
| 70 MessagePort* dataPort = (*ports)[i].get(); | 70 MessagePort* dataPort = (*ports)[i].get(); |
| 71 if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort))
{ | 71 if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort))
{ |
| 72 es.throwDOMException(DataCloneError); | 72 es.throwUninformativeAndGenericDOMException(DataCloneError); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 channels = MessagePort::disentanglePorts(ports, es); | 76 channels = MessagePort::disentanglePorts(ports, es); |
| 77 if (es.hadException()) | 77 if (es.hadException()) |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 m_entangledChannel->postMessageToRemote(message, channels.release()); | 80 m_entangledChannel->postMessageToRemote(message, channels.release()); |
| 81 } | 81 } |
| 82 | 82 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (!ports || !ports->size()) | 195 if (!ports || !ports->size()) |
| 196 return nullptr; | 196 return nullptr; |
| 197 | 197 |
| 198 // HashSet used to efficiently check for duplicates in the passed-in array. | 198 // HashSet used to efficiently check for duplicates in the passed-in array. |
| 199 HashSet<MessagePort*> portSet; | 199 HashSet<MessagePort*> portSet; |
| 200 | 200 |
| 201 // Walk the incoming array - if there are any duplicate ports, or null ports
or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec). | 201 // Walk the incoming array - if there are any duplicate ports, or null ports
or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec). |
| 202 for (unsigned int i = 0; i < ports->size(); ++i) { | 202 for (unsigned int i = 0; i < ports->size(); ++i) { |
| 203 MessagePort* port = (*ports)[i].get(); | 203 MessagePort* port = (*ports)[i].get(); |
| 204 if (!port || port->isNeutered() || portSet.contains(port)) { | 204 if (!port || port->isNeutered() || portSet.contains(port)) { |
| 205 es.throwDOMException(DataCloneError); | 205 es.throwUninformativeAndGenericDOMException(DataCloneError); |
| 206 return nullptr; | 206 return nullptr; |
| 207 } | 207 } |
| 208 portSet.add(port); | 208 portSet.add(port); |
| 209 } | 209 } |
| 210 | 210 |
| 211 // Passed-in ports passed validity checks, so we can disentangle them. | 211 // Passed-in ports passed validity checks, so we can disentangle them. |
| 212 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA
rray(ports->size())); | 212 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA
rray(ports->size())); |
| 213 for (unsigned int i = 0 ; i < ports->size() ; ++i) { | 213 for (unsigned int i = 0 ; i < ports->size() ; ++i) { |
| 214 OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(); | 214 OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(); |
| 215 (*portArray)[i] = channel.release(); | 215 (*portArray)[i] = channel.release(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 235 { | 235 { |
| 236 return &m_eventTargetData; | 236 return &m_eventTargetData; |
| 237 } | 237 } |
| 238 | 238 |
| 239 EventTargetData* MessagePort::ensureEventTargetData() | 239 EventTargetData* MessagePort::ensureEventTargetData() |
| 240 { | 240 { |
| 241 return &m_eventTargetData; | 241 return &m_eventTargetData; |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace WebCore | 244 } // namespace WebCore |
| OLD | NEW |