| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "JSDOMApplicationCache.h" | 27 #include "JSDOMApplicationCache.h" |
| 28 | 28 |
| 29 #if ENABLE(OFFLINE_WEB_APPLICATIONS) | 29 #if ENABLE(OFFLINE_WEB_APPLICATIONS) || ENABLE(APPLICATION_CACHE) |
| 30 | 30 |
| 31 #include "AtomicString.h" | 31 #include "AtomicString.h" |
| 32 #include "DOMApplicationCache.h" | 32 #include "DOMApplicationCache.h" |
| 33 #include "DOMWindow.h" | 33 #include "DOMWindow.h" |
| 34 #include "Event.h" | 34 #include "Event.h" |
| 35 #include "Frame.h" | 35 #include "Frame.h" |
| 36 #include "FrameLoader.h" | 36 #include "FrameLoader.h" |
| 37 #include "JSDOMWindowCustom.h" | 37 #include "JSDOMWindowCustom.h" |
| 38 #include "JSEvent.h" | 38 #include "JSEvent.h" |
| 39 #include "JSEventListener.h" | 39 #include "JSEventListener.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 typedef DOMApplicationCache::EventListenersMap EventListenersMap; | 58 typedef DOMApplicationCache::EventListenersMap EventListenersMap; |
| 59 typedef DOMApplicationCache::ListenerVector ListenerVector; | 59 typedef DOMApplicationCache::ListenerVector ListenerVector; |
| 60 EventListenersMap& eventListeners = m_impl->eventListeners(); | 60 EventListenersMap& eventListeners = m_impl->eventListeners(); |
| 61 for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter !
= eventListeners.end(); ++mapIter) { | 61 for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter !
= eventListeners.end(); ++mapIter) { |
| 62 for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter
!= mapIter->second.end(); ++vecIter) | 62 for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter
!= mapIter->second.end(); ++vecIter) |
| 63 (*vecIter)->markJSFunction(); | 63 (*vecIter)->markJSFunction(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 #if ENABLE(APPLICATION_CACHE_DYNAMIC_ENTRIES) | 67 #if ENABLE(OFFLINE_WEB_APPLICATIONS) && ENABLE(APPLICATION_CACHE_DYNAMIC_ENTRIES
) |
| 68 | 68 |
| 69 JSValue JSDOMApplicationCache::hasItem(ExecState* exec, const ArgList& args) | 69 JSValue JSDOMApplicationCache::hasItem(ExecState* exec, const ArgList& args) |
| 70 { | 70 { |
| 71 Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); | 71 Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); |
| 72 if (!frame) | 72 if (!frame) |
| 73 return jsUndefined(); | 73 return jsUndefined(); |
| 74 const KURL& url = frame->loader()->completeURL(args.at(0).toString(exec)); | 74 const KURL& url = frame->loader()->completeURL(args.at(0).toString(exec)); |
| 75 | 75 |
| 76 ExceptionCode ec = 0; | 76 ExceptionCode ec = 0; |
| 77 bool result = impl()->hasItem(url, ec); | 77 bool result = impl()->hasItem(url, ec); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 98 if (!frame) | 98 if (!frame) |
| 99 return jsUndefined(); | 99 return jsUndefined(); |
| 100 const KURL& url = frame->loader()->completeURL(args.at(0).toString(exec)); | 100 const KURL& url = frame->loader()->completeURL(args.at(0).toString(exec)); |
| 101 | 101 |
| 102 ExceptionCode ec = 0; | 102 ExceptionCode ec = 0; |
| 103 impl()->remove(url, ec); | 103 impl()->remove(url, ec); |
| 104 setDOMException(exec, ec); | 104 setDOMException(exec, ec); |
| 105 return jsUndefined(); | 105 return jsUndefined(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 #endif // ENABLE(APPLICATION_CACHE_DYNAMIC_ENTRIES) | 108 #endif // ENABLE(OFFLINE_WEB_APPLICATIONS) && ENABLE(APPLICATION_CACHE_DYNAMIC_E
NTRIES) |
| 109 | 109 |
| 110 JSValue JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList&
args) | 110 JSValue JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList&
args) |
| 111 { | 111 { |
| 112 JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutio
nContext()); | 112 JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutio
nContext()); |
| 113 if (!globalObject) | 113 if (!globalObject) |
| 114 return jsUndefined(); | 114 return jsUndefined(); |
| 115 RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener
(args.at(1)); | 115 RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener
(args.at(1)); |
| 116 if (!listener) | 116 if (!listener) |
| 117 return jsUndefined(); | 117 return jsUndefined(); |
| 118 impl()->addEventListener(args.at(0).toString(exec), listener.release(), args
.at(2).toBoolean(exec)); | 118 impl()->addEventListener(args.at(0).toString(exec), listener.release(), args
.at(2).toBoolean(exec)); |
| 119 return jsUndefined(); | 119 return jsUndefined(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 JSValue JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgLis
t& args) | 122 JSValue JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgLis
t& args) |
| 123 { | 123 { |
| 124 JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutio
nContext()); | 124 JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutio
nContext()); |
| 125 if (!globalObject) | 125 if (!globalObject) |
| 126 return jsUndefined(); | 126 return jsUndefined(); |
| 127 JSEventListener* listener = globalObject->findJSEventListener(args.at(1)); | 127 JSEventListener* listener = globalObject->findJSEventListener(args.at(1)); |
| 128 if (!listener) | 128 if (!listener) |
| 129 return jsUndefined(); | 129 return jsUndefined(); |
| 130 impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).
toBoolean(exec)); | 130 impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).
toBoolean(exec)); |
| 131 return jsUndefined(); | 131 return jsUndefined(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace WebCore | 134 } // namespace WebCore |
| 135 | 135 |
| 136 #endif // ENABLE(OFFLINE_WEB_APPLICATIONS) | 136 #endif // ENABLE(OFFLINE_WEB_APPLICATIONS) || ENABLE(APPLICATION_CACHE) |
| OLD | NEW |