diff options
Diffstat (limited to 'WebCore/bindings')
47 files changed, 963 insertions, 99 deletions
diff --git a/WebCore/bindings/js/JSAudioConstructor.cpp b/WebCore/bindings/js/JSAudioConstructor.cpp index 87a3880..174cc11 100644 --- a/WebCore/bindings/js/JSAudioConstructor.cpp +++ b/WebCore/bindings/js/JSAudioConstructor.cpp @@ -34,6 +34,7 @@ #include "JSHTMLAudioElement.h" #include "ScriptExecutionContext.h" #include "Text.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSCSSRuleListCustom.cpp b/WebCore/bindings/js/JSCSSRuleListCustom.cpp new file mode 100644 index 0000000..be3a9a2 --- /dev/null +++ b/WebCore/bindings/js/JSCSSRuleListCustom.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Apple Inc. All right reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCSSRuleList.h" + +#include "CSSRuleList.h" + +using namespace JSC; + +namespace WebCore { + +void JSCSSRuleList::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + CSSRuleList* list = impl(); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + unsigned length = list->length(); + for (unsigned i = 0; i < length; ++i) + markDOMObjectWrapper(markStack, globalData, list->item(i)); +} + +} diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp index 280ec93..4a137d3 100644 --- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp +++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,8 +27,8 @@ #include "JSCSSStyleDeclarationCustom.h" #include "AtomicString.h" +#include "CSSMutableStyleDeclaration.h" #include "CSSPrimitiveValue.h" -#include "CSSStyleDeclaration.h" #include "CSSValue.h" #include "PlatformString.h" #include <runtime/StringObjectThatMasqueradesAsUndefined.h> @@ -40,6 +40,21 @@ using namespace WTF; namespace WebCore { +void JSCSSStyleDeclaration::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + CSSStyleDeclaration* declaration = impl(); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + if (declaration->isMutableStyleDeclaration()) { + CSSMutableStyleDeclaration* mutableDeclaration = static_cast<CSSMutableStyleDeclaration*>(declaration); + CSSMutableStyleDeclaration::const_iterator end = mutableDeclaration->end(); + for (CSSMutableStyleDeclaration::const_iterator it = mutableDeclaration->begin(); it != end; ++it) + markDOMObjectWrapper(markStack, globalData, it->value()); + } +} + // Check for a CSS prefix. // Passed prefix is all lowercase. // First character of the prefix within the property name may be upper or lowercase. diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index 566b986..06492f9 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -28,6 +28,7 @@ #include "ExceptionCode.h" #include "Frame.h" #include "HTMLAudioElement.h" +#include "HTMLCanvasElement.h" #include "HTMLImageElement.h" #include "HTMLScriptElement.h" #include "HTMLNames.h" @@ -42,6 +43,7 @@ #include "RangeException.h" #include "ScriptController.h" #include "XMLHttpRequestException.h" +#include <runtime/JSFunction.h> #include <runtime/PrototypeFunction.h> #include <wtf/StdLibExtras.h> @@ -264,18 +266,48 @@ static inline bool isObservableThroughDOM(JSNode* jsNode) Node* node = jsNode->impl(); if (node->inDocument()) { - // 1. If a node is in the document, and its wrapper has custom properties, + // If a node is in the document, and its wrapper has custom properties, // the wrapper is observable because future access to the node through the // DOM must reflect those properties. if (jsNode->hasCustomProperties()) return true; - // 2. If a node is in the document, and has event listeners, its wrapper is + // If a node is in the document, and has event listeners, its wrapper is // observable because its wrapper is responsible for marking those event listeners. if (node->eventListeners().size()) return true; // Technically, we may overzealously mark a wrapper for a node that has only non-JS event listeners. Oh well. + + // If a node owns another object with a wrapper with custom properties, + // the wrapper must be treated as observable, because future access to + // those objects through the DOM must reflect those properties. + // FIXME: It would be better if this logic could be in the node next to + // the custom markChildren functions rather than here. + if (node->isElementNode()) { + if (NamedNodeMap* attributes = static_cast<Element*>(node)->attributeMap()) { + if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), attributes)) { + if (wrapper->hasCustomProperties()) + return true; + } + } + if (node->isStyledElement()) { + if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) { + if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), style)) { + if (wrapper->hasCustomProperties()) + return true; + } + } + } + if (static_cast<Element*>(node)->hasTagName(canvasTag)) { + if (CanvasRenderingContext2D* context = static_cast<HTMLCanvasElement*>(node)->renderingContext2D()) { + if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), context)) { + if (wrapper->hasCustomProperties()) + return true; + } + } + } + } } else { - // 3. If a wrapper is the last reference to an image or script element + // If a wrapper is the last reference to an image or script element // that is loading but not in the document, the wrapper is observable // because it is the only thing keeping the image element alive, and if // the image element is destroyed, its load event will not fire. @@ -348,6 +380,9 @@ void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocum void markDOMObjectWrapper(MarkStack& markStack, JSGlobalData& globalData, void* object) { + // FIXME: This could be changed to only mark wrappers that are "observable" + // as markDOMNodesForDocument does, allowing us to collect more wrappers, + // but doing this correctly would be challenging. if (!object) return; DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, object); diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h index 64cfc3a..5abd7a7 100644 --- a/WebCore/bindings/js/JSDOMBinding.h +++ b/WebCore/bindings/js/JSDOMBinding.h @@ -26,7 +26,6 @@ #include "Document.h" // For DOMConstructorWithDocument #include <runtime/Completion.h> #include <runtime/Lookup.h> -#include <runtime/JSFunction.h> #include <wtf/Noncopyable.h> namespace JSC { @@ -61,7 +60,7 @@ namespace WebCore { #endif }; - // FIXME: This class should colapse into DOMObject once all DOMObjects are + // FIXME: This class should collapse into DOMObject once all DOMObjects are // updated to store a globalObject pointer. class DOMObjectWithGlobalPointer : public DOMObject { public: diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 9798972..44a11e4 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -38,6 +38,7 @@ #include "JSDOMWindowShell.h" #include "JSEvent.h" #include "JSEventListener.h" +#include "JSEventSourceConstructor.h" #include "JSHTMLCollection.h" #include "JSHistory.h" #include "JSImageConstructor.h" @@ -54,6 +55,7 @@ #include "Location.h" #include "MediaPlayer.h" #include "MessagePort.h" +#include "NotificationCenter.h" #include "Page.h" #include "PlatformScreen.h" #include "RegisteredEventListener.h" @@ -61,6 +63,8 @@ #include "ScriptController.h" #include "Settings.h" #include "WindowFeatures.h" +#include <runtime/Error.h> +#include <runtime/JSFunction.h> #include <runtime/JSObject.h> #include <runtime/PrototypeFunction.h> @@ -424,6 +428,13 @@ JSValue JSDOMWindow::event(ExecState* exec) const return toJS(exec, event); } +#if ENABLE(EVENTSOURCE) +JSValue JSDOMWindow::eventSource(ExecState* exec) const +{ + return getDOMConstructor<JSEventSourceConstructor>(exec, this); +} +#endif + JSValue JSDOMWindow::image(ExecState* exec) const { return getDOMConstructor<JSImageConstructor>(exec, this); diff --git a/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp b/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp new file mode 100644 index 0000000..fb34c7b --- /dev/null +++ b/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(NOTIFICATIONS) + +#include "Document.h" +#include "JSCustomVoidCallback.h" +#include "JSEventListener.h" +#include "JSNotification.h" +#include "JSNotificationCenter.h" +#include "Notification.h" +#include "NotificationCenter.h" + +using namespace JSC; + +namespace WebCore { + +JSValue JSNotificationCenter::requestPermission(ExecState* exec, const ArgList& args) +{ + // Permission request is only valid from page context. + ScriptExecutionContext* context = impl()->context(); + if (context->isWorkerContext()) + return throwError(exec, SyntaxError); + + if (!args.at(0).isObject()) + return throwError(exec, TypeError); + + PassRefPtr<JSCustomVoidCallback> callback = JSCustomVoidCallback::create(args.at(0).getObject(), static_cast<Document*>(context)->frame()); + + impl()->requestPermission(callback); + return jsUndefined(); +} + +JSValue JSNotification::addEventListener(ExecState* exec, const ArgList& args) +{ + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); + if (!globalObject) + return jsUndefined(); + + if (RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(args.at(1))) + impl()->addEventListener(args.at(0).toString(exec), listener.release(), args.at(2).toBoolean(exec)); + + return jsUndefined(); +} + +JSValue JSNotification::removeEventListener(ExecState* exec, const ArgList& args) +{ + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); + if (!globalObject) + return jsUndefined(); + + if (JSEventListener* listener = globalObject->findJSEventListener(args.at(1))) + impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).toBoolean(exec)); + + return jsUndefined(); +} + + +} // namespace + +#endif // ENABLE(NOTIFICATIONS) diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp index 39a1fc5..25c0b00 100644 --- a/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/WebCore/bindings/js/JSDocumentCustom.cpp @@ -42,8 +42,14 @@ namespace WebCore { void JSDocument::markChildren(MarkStack& markStack) { JSNode::markChildren(markStack); - markDOMNodesForDocument(markStack, impl()); - markActiveObjectsForContext(markStack, *Heap::heap(this)->globalData(), impl()); + + Document* document = impl(); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + markDOMNodesForDocument(markStack, document); + markActiveObjectsForContext(markStack, globalData, document); + markDOMObjectWrapper(markStack, globalData, document->implementation()); + markDOMObjectWrapper(markStack, globalData, document->styleSheets()); } JSValue JSDocument::location(ExecState* exec) const diff --git a/WebCore/bindings/js/JSElementCustom.cpp b/WebCore/bindings/js/JSElementCustom.cpp index 47793d0..c7b19e3 100644 --- a/WebCore/bindings/js/JSElementCustom.cpp +++ b/WebCore/bindings/js/JSElementCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -51,6 +51,18 @@ namespace WebCore { using namespace HTMLNames; +void JSElement::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + Element* element = impl(); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + markDOMObjectWrapper(markStack, globalData, element->attributeMap()); + if (element->isStyledElement()) + markDOMObjectWrapper(markStack, globalData, static_cast<StyledElement*>(element)->inlineStyleDecl()); +} + static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* element, const String& name, const String& value) { if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && protocolIsJavaScript(deprecatedParseURL(value))) { @@ -59,7 +71,7 @@ static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* elem return false; } return true; -} +} JSValue JSElement::setAttribute(ExecState* exec, const ArgList& args) { diff --git a/WebCore/bindings/js/JSEventSourceConstructor.cpp b/WebCore/bindings/js/JSEventSourceConstructor.cpp new file mode 100644 index 0000000..c6e4825 --- /dev/null +++ b/WebCore/bindings/js/JSEventSourceConstructor.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 Ericsson AB + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Ericsson nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(EVENTSOURCE) + +#include "JSEventSourceConstructor.h" + +#include "EventSource.h" +#include "ExceptionCode.h" +#include "JSEventSource.h" +#include "ScriptExecutionContext.h" +#include <runtime/Error.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSEventSourceConstructor); + +const ClassInfo JSEventSourceConstructor::s_info = { "EventSourceContructor", 0, 0, 0 }; + +JSEventSourceConstructor::JSEventSourceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSEventSourceConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSEventSourcePrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); +} + +static JSObject* constructEventSource(ExecState* exec, JSObject* constructor, const ArgList& args) +{ + if (args.size() < 1) + return throwError(exec, SyntaxError, "Not enough arguments"); + + UString url = args.at(0).toString(exec); + if (exec->hadException()) + return 0; + + JSEventSourceConstructor* jsConstructor = static_cast<JSEventSourceConstructor*>(constructor); + ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); + if (!context) + return throwError(exec, ReferenceError, "EventSource constructor associated document is unavailable"); + + ExceptionCode ec = 0; + RefPtr<EventSource> eventSource = EventSource::create(url, context, ec); + if (ec) { + setDOMException(exec, ec); + return 0; + } + + return asObject(toJS(exec, jsConstructor->globalObject(), eventSource.release())); +} + +ConstructType JSEventSourceConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructEventSource; + return ConstructTypeHost; +} + +} // namespace WebCore + +#endif // ENABLE(EVENTSOURCE) diff --git a/WebCore/bindings/js/JSEventSourceConstructor.h b/WebCore/bindings/js/JSEventSourceConstructor.h new file mode 100644 index 0000000..b2f3cb5 --- /dev/null +++ b/WebCore/bindings/js/JSEventSourceConstructor.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2009 Ericsson AB + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Ericsson nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSEventSourceConstructor_h +#define JSEventSourceConstructor_h + +#if ENABLE(EVENTSOURCE) + +#include "JSDOMBinding.h" + +namespace WebCore { + + class JSEventSourceConstructor : public DOMConstructorObject { + public: + JSEventSourceConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static const JSC::ClassInfo s_info; + + private: + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + }; + +} // namespace WebCore + +#endif // ENABLE(EVENTSOURCE) + +#endif // JSEventSourceConstructor_h diff --git a/WebCore/bindings/js/JSEventSourceCustom.cpp b/WebCore/bindings/js/JSEventSourceCustom.cpp new file mode 100644 index 0000000..d20ccd6 --- /dev/null +++ b/WebCore/bindings/js/JSEventSourceCustom.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2009 Ericsson AB + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Ericsson nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(EVENTSOURCE) + +#include "JSEventSource.h" + +#include "EventSource.h" +#include "JSDOMGlobalObject.h" +#include "JSEventListener.h" + +using namespace JSC; + +namespace WebCore { + +void JSEventSource::markChildren(MarkStack& markStack) +{ + DOMObject::markChildren(markStack); + + markIfNotNull(markStack, m_impl->onopen()); + markIfNotNull(markStack, m_impl->onmessage()); + markIfNotNull(markStack, m_impl->onerror()); + + typedef EventSource::EventListenersMap EventListenersMap; + typedef EventSource::ListenerVector ListenerVector; + EventListenersMap& eventListeners = m_impl->eventListeners(); + for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter != eventListeners.end(); ++mapIter) { + for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter != mapIter->second.end(); ++vecIter) + (*vecIter)->markJSFunction(markStack); + } +} + +JSValue JSEventSource::addEventListener(ExecState* exec, const ArgList& args) +{ + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); + if (!globalObject) + return jsUndefined(); + RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(args.at(1)); + if (!listener) + return jsUndefined(); + impl()->addEventListener(args.at(0).toString(exec), listener.release(), args.at(2).toBoolean(exec)); + return jsUndefined(); +} + +JSValue JSEventSource::removeEventListener(ExecState* exec, const ArgList& args) +{ + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); + if (!globalObject) + return jsUndefined(); + JSEventListener* listener = globalObject->findJSEventListener(args.at(1)); + if (!listener) + return jsUndefined(); + impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).toBoolean(exec)); + return jsUndefined(); +} + +} // namespace WebCore + +#endif // ENABLE(EVENTSOURCE) diff --git a/WebCore/bindings/js/JSEventTarget.cpp b/WebCore/bindings/js/JSEventTarget.cpp index c34e10e..5825ee5 100644 --- a/WebCore/bindings/js/JSEventTarget.cpp +++ b/WebCore/bindings/js/JSEventTarget.cpp @@ -43,6 +43,11 @@ #include "XMLHttpRequest.h" #include "XMLHttpRequestUpload.h" +#if ENABLE(EVENTSOURCE) +#include "EventSource.h" +#include "JSEventSource.h" +#endif + #if ENABLE(OFFLINE_WEB_APPLICATIONS) #include "DOMApplicationCache.h" #include "JSDOMApplicationCache.h" @@ -60,6 +65,11 @@ #include "Worker.h" #endif +#if ENABLE(NOTIFICATIONS) +#include "JSNotification.h" +#include "Notification.h" +#endif + using namespace JSC; namespace WebCore { @@ -69,6 +79,11 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ if (!target) return jsNull(); +#if ENABLE(EVENTSOURCE) + if (EventSource* eventSource = target->toEventSource()) + return toJS(exec, globalObject, eventSource); +#endif + #if ENABLE(SVG) // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node. if (SVGElementInstance* instance = target->toSVGElementInstance()) @@ -111,6 +126,11 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ return toJSDOMGlobalObject(workerContext); #endif +#if ENABLE(NOTIFICATIONS) + if (Notification* notification = target->toNotification()) + return toJS(exec, notification); +#endif + ASSERT_NOT_REACHED(); return jsNull(); } @@ -118,7 +138,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ EventTarget* toEventTarget(JSC::JSValue value) { #define CONVERT_TO_EVENT_TARGET(type) \ - if (value.isObject(&JS##type::s_info)) \ + if (value.inherits(&JS##type::s_info)) \ return static_cast<JS##type*>(asObject(value))->impl(); CONVERT_TO_EVENT_TARGET(Node) @@ -126,9 +146,13 @@ EventTarget* toEventTarget(JSC::JSValue value) CONVERT_TO_EVENT_TARGET(XMLHttpRequestUpload) CONVERT_TO_EVENT_TARGET(MessagePort) - if (value.isObject(&JSDOMWindowShell::s_info)) + if (value.inherits(&JSDOMWindowShell::s_info)) return static_cast<JSDOMWindowShell*>(asObject(value))->impl(); +#if ENABLE(EVENTSOURCE) + CONVERT_TO_EVENT_TARGET(EventSource) +#endif + #if ENABLE(OFFLINE_WEB_APPLICATIONS) CONVERT_TO_EVENT_TARGET(DOMApplicationCache) #endif @@ -147,6 +171,10 @@ EventTarget* toEventTarget(JSC::JSValue value) CONVERT_TO_EVENT_TARGET(SharedWorkerContext) #endif +#if ENABLE(NOTIFICATIONS) + CONVERT_TO_EVENT_TARGET(Notification) +#endif + return 0; } diff --git a/WebCore/bindings/js/JSGeolocationCustom.cpp b/WebCore/bindings/js/JSGeolocationCustom.cpp index 6379a1c..cc0ba8b 100644 --- a/WebCore/bindings/js/JSGeolocationCustom.cpp +++ b/WebCore/bindings/js/JSGeolocationCustom.cpp @@ -34,6 +34,7 @@ #include "JSCustomPositionErrorCallback.h" #include "JSDOMWindow.h" #include "PositionOptions.h" +#include <runtime/InternalFunction.h> using namespace JSC; using namespace std; @@ -43,7 +44,7 @@ namespace WebCore { static PassRefPtr<PositionCallback> createPositionCallback(ExecState* exec, JSValue value) { // The spec specifies 'FunctionOnly' for this object. - if (!value.isObject(&InternalFunction::info)) { + if (!value.inherits(&InternalFunction::info)) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } @@ -55,12 +56,12 @@ static PassRefPtr<PositionCallback> createPositionCallback(ExecState* exec, JSVa static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(ExecState* exec, JSValue value) { - // Argument is optional (hence undefined is allowed), and null is allowed. + // Argument is optional (hence undefined is allowed), and null is allowed. if (value.isUndefinedOrNull()) return 0; // The spec specifies 'FunctionOnly' for this object. - if (!value.isObject(&InternalFunction::info)) { + if (!value.inherits(&InternalFunction::info)) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } @@ -91,7 +92,7 @@ static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValu JSValue enableHighAccuracyValue = object->get(exec, Identifier(exec, "enableHighAccuracy")); if (exec->hadException()) return 0; - if(!enableHighAccuracyValue.isUndefined()) { + if (!enableHighAccuracyValue.isUndefined()) { options->setEnableHighAccuracy(enableHighAccuracyValue.toBoolean(exec)); if (exec->hadException()) return 0; diff --git a/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp b/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp new file mode 100644 index 0000000..921e243 --- /dev/null +++ b/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Apple Inc. All right reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSHTMLCanvasElement.h" + +#include "HTMLCanvasElement.h" + +using namespace JSC; + +namespace WebCore { + +void JSHTMLCanvasElement::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl()); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + markDOMObjectWrapper(markStack, globalData, canvas->renderingContext2D()); +} + +} diff --git a/WebCore/bindings/js/JSHTMLInputElementCustom.cpp b/WebCore/bindings/js/JSHTMLInputElementCustom.cpp index 6b47622..e5166ee 100644 --- a/WebCore/bindings/js/JSHTMLInputElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLInputElementCustom.cpp @@ -29,6 +29,7 @@ #include "Document.h" #include "HTMLInputElement.h" #include "Settings.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSHistoryCustom.cpp b/WebCore/bindings/js/JSHistoryCustom.cpp index a3b15e1..a11266d 100644 --- a/WebCore/bindings/js/JSHistoryCustom.cpp +++ b/WebCore/bindings/js/JSHistoryCustom.cpp @@ -31,6 +31,7 @@ #include "Frame.h" #include "History.h" +#include <runtime/JSFunction.h> #include <runtime/PrototypeFunction.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSImageConstructor.cpp b/WebCore/bindings/js/JSImageConstructor.cpp index faaaf41..0f4a991 100644 --- a/WebCore/bindings/js/JSImageConstructor.cpp +++ b/WebCore/bindings/js/JSImageConstructor.cpp @@ -25,6 +25,7 @@ #include "JSHTMLImageElement.h" #include "JSNode.h" #include "ScriptExecutionContext.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSInspectorBackendCustom.cpp b/WebCore/bindings/js/JSInspectorBackendCustom.cpp index b2eb2d1..30e6dc2 100644 --- a/WebCore/bindings/js/JSInspectorBackendCustom.cpp +++ b/WebCore/bindings/js/JSInspectorBackendCustom.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2009 Joseph Pecoraro * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,6 +35,8 @@ #include "JSInspectorBackend.h" #include "Console.h" +#include "Cookie.h" +#include "CookieJar.h" #if ENABLE(DATABASE) #include "Database.h" #include "JSDatabase.h" @@ -51,6 +54,10 @@ #include "JSRange.h" #include "Node.h" #include "Page.h" +#if ENABLE(DOM_STORAGE) +#include "Storage.h" +#include "JSStorage.h" +#endif #include "TextIterator.h" #include "VisiblePosition.h" #include <runtime/JSArray.h> @@ -70,21 +77,12 @@ using namespace JSC; namespace WebCore { -JSValue JSInspectorBackend::highlightDOMNode(JSC::ExecState*, const JSC::ArgList& args) +JSValue JSInspectorBackend::highlightDOMNode(JSC::ExecState* exec, const JSC::ArgList& args) { if (args.size() < 1) return jsUndefined(); - JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0)); - if (!wrapper) - return jsUndefined(); - - Node* node = toNode(wrapper->unwrappedObject()); - if (!node) - return jsUndefined(); - - impl()->highlight(node); - + impl()->highlight(args.at(0).toInt32(exec)); return jsUndefined(); } @@ -158,6 +156,68 @@ JSValue JSInspectorBackend::inspectedWindow(ExecState*, const ArgList&) return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow); } +JSValue JSInspectorBackend::cookies(ExecState* exec, const ArgList&) +{ + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + + Document* document = ic->inspectedPage()->mainFrame()->document(); + Vector<Cookie> cookies; + bool isImplemented = getRawCookies(document, document->cookieURL(), cookies); + + if (!isImplemented) + return jsUndefined(); + + MarkedArgumentBuffer result; + Identifier nameIdentifier(exec, "name"); + Identifier valueIdentifier(exec, "value"); + Identifier domainIdentifier(exec, "domain"); + Identifier pathIdentifier(exec, "path"); + Identifier expiresIdentifier(exec, "expires"); + Identifier sizeIdentifier(exec, "size"); + Identifier httpOnlyIdentifier(exec, "httpOnly"); + Identifier secureIdentifier(exec, "secure"); + Identifier sessionIdentifier(exec, "session"); + + unsigned length = cookies.size(); + for (unsigned i = 0; i < length; ++i) { + const Cookie& cookie = cookies[i]; + JSObject* cookieObject = constructEmptyObject(exec); + cookieObject->putDirect(nameIdentifier, jsString(exec, cookie.name)); + cookieObject->putDirect(valueIdentifier, jsString(exec, cookie.value)); + cookieObject->putDirect(domainIdentifier, jsString(exec, cookie.domain)); + cookieObject->putDirect(pathIdentifier, jsString(exec, cookie.path)); + cookieObject->putDirect(expiresIdentifier, jsNumber(exec, cookie.expires)); + cookieObject->putDirect(sizeIdentifier, jsNumber(exec, cookie.name.length() + cookie.value.length())); + cookieObject->putDirect(httpOnlyIdentifier, jsBoolean(cookie.httpOnly)); + cookieObject->putDirect(secureIdentifier, jsBoolean(cookie.secure)); + cookieObject->putDirect(sessionIdentifier, jsBoolean(cookie.session)); + result.append(cookieObject); + } + + return constructArray(exec, result); +} + +JSValue JSInspectorBackend::deleteCookie(ExecState* exec, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + + String cookieName = args.at(0).toString(exec); + if (exec->hadException()) + return jsUndefined(); + + Document* document = ic->inspectedPage()->mainFrame()->document(); + WebCore::deleteCookie(document, document->cookieURL(), cookieName); + + return jsUndefined(); +} + JSValue JSInspectorBackend::setting(ExecState* exec, const ArgList& args) { if (args.size() < 1) @@ -280,4 +340,107 @@ JSValue JSInspectorBackend::profiles(JSC::ExecState* exec, const JSC::ArgList&) #endif +JSValue JSInspectorBackend::nodeForId(ExecState* exec, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + + Node* node = impl()->nodeForId(args.at(0).toInt32(exec)); + if (!node) + return jsUndefined(); + + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + + JSLock lock(SilenceAssertionsOnly); + JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame()); + return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), toJS(exec, deprecatedGlobalObjectForPrototype(inspectedWindow->globalExec()), node)); +} + +JSValue JSInspectorBackend::idForNode(ExecState* exec, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + + JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0)); + if (!wrapper) + return jsUndefined(); + + Node* node = toNode(wrapper->unwrappedObject()); + if (node) + return jsNumber(exec, impl()->idForNode(node)); + return jsUndefined(); +} + +JSValue JSInspectorBackend::wrapObject(ExecState*, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + + return impl()->wrapObject(ScriptValue(args.at(0))).jsValue(); +} + +JSValue JSInspectorBackend::unwrapObject(ExecState* exec, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + + return impl()->unwrapObject(args.at(0).toString(exec)).jsValue(); +} + +JSValue JSInspectorBackend::pushNodePathToFrontend(ExecState* exec, const ArgList& args) +{ + if (args.size() < 2) + return jsUndefined(); + + JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0)); + if (!wrapper) + return jsUndefined(); + + Node* node = toNode(wrapper->unwrappedObject()); + if (!node) + return jsUndefined(); + + bool selectInUI = args.at(1).toBoolean(exec); + return jsNumber(exec, impl()->pushNodePathToFrontend(node, selectInUI)); +} + +#if ENABLE(DATABASE) +JSValue JSInspectorBackend::selectDatabase(ExecState*, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + + JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0)); + if (!wrapper) + return jsUndefined(); + + Database* database = toDatabase(wrapper->unwrappedObject()); + if (database) + impl()->selectDatabase(database); + return jsUndefined(); +} +#endif + +#if ENABLE(DOM_STORAGE) +JSValue JSInspectorBackend::selectDOMStorage(ExecState*, const ArgList& args) +{ + if (args.size() < 1) + return jsUndefined(); + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + + JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0)); + if (!wrapper) + return jsUndefined(); + + Storage* storage = toStorage(wrapper->unwrappedObject()); + if (storage) + impl()->selectDOMStorage(storage); + return jsUndefined(); +} +#endif + } // namespace WebCore diff --git a/WebCore/bindings/js/JSLazyEventListener.cpp b/WebCore/bindings/js/JSLazyEventListener.cpp index 7caff2b..cf0ed44 100644 --- a/WebCore/bindings/js/JSLazyEventListener.cpp +++ b/WebCore/bindings/js/JSLazyEventListener.cpp @@ -23,6 +23,7 @@ #include "Frame.h" #include "JSNode.h" #include <runtime/FunctionConstructor.h> +#include <runtime/JSFunction.h> #include <runtime/JSLock.h> #include <wtf/RefCountedLeakCounter.h> diff --git a/WebCore/bindings/js/JSLocationCustom.cpp b/WebCore/bindings/js/JSLocationCustom.cpp index d7d32f4..0289bc0 100644 --- a/WebCore/bindings/js/JSLocationCustom.cpp +++ b/WebCore/bindings/js/JSLocationCustom.cpp @@ -31,6 +31,7 @@ #include "KURL.h" #include "Location.h" #include "ScriptController.h" +#include <runtime/JSFunction.h> #include <runtime/PrototypeFunction.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSMessageChannelConstructor.cpp b/WebCore/bindings/js/JSMessageChannelConstructor.cpp index 25a5cb2..9721ba3 100644 --- a/WebCore/bindings/js/JSMessageChannelConstructor.cpp +++ b/WebCore/bindings/js/JSMessageChannelConstructor.cpp @@ -30,6 +30,7 @@ #include "JSDocument.h" #include "JSMessageChannel.h" #include "MessageChannel.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSNodeFilterCustom.cpp b/WebCore/bindings/js/JSNodeFilterCustom.cpp index 09fd110..2a99a93 100644 --- a/WebCore/bindings/js/JSNodeFilterCustom.cpp +++ b/WebCore/bindings/js/JSNodeFilterCustom.cpp @@ -48,7 +48,7 @@ JSValue JSNodeFilter::acceptNode(ExecState* exec, const ArgList& args) PassRefPtr<NodeFilter> toNodeFilter(JSValue value) { - if (value.isObject(&JSNodeFilter::s_info)) + if (value.inherits(&JSNodeFilter::s_info)) return static_cast<JSNodeFilter*>(asObject(value))->impl(); return NodeFilter::create(JSNodeFilterCondition::create(value)); diff --git a/WebCore/bindings/js/JSOptionConstructor.cpp b/WebCore/bindings/js/JSOptionConstructor.cpp index 2b8bd5d..7da0666 100644 --- a/WebCore/bindings/js/JSOptionConstructor.cpp +++ b/WebCore/bindings/js/JSOptionConstructor.cpp @@ -25,6 +25,7 @@ #include "JSHTMLOptionElement.h" #include "ScriptExecutionContext.h" #include "Text.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSStyleSheetCustom.cpp b/WebCore/bindings/js/JSStyleSheetCustom.cpp index 43249dc..d711b6f 100644 --- a/WebCore/bindings/js/JSStyleSheetCustom.cpp +++ b/WebCore/bindings/js/JSStyleSheetCustom.cpp @@ -56,12 +56,19 @@ void JSStyleSheet::markChildren(MarkStack& markStack) { Base::markChildren(markStack); + StyleSheet* sheet = impl(); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + unsigned length = sheet->length(); + for (unsigned i = 0; i < length; ++i) + markDOMObjectWrapper(markStack, globalData, sheet->item(i)); + // This prevents us from having a style sheet with a dangling ownerNode pointer. // A better solution would be to handle this on the DOM side -- if the style sheet // is kept around, then we want the node to stay around too. One possibility would // be to make ref/deref on the style sheet ref/deref the node instead, but there's // a lot of disentangling of the CSS DOM objects that would need to happen first. - if (Node* ownerNode = impl()->ownerNode()) { + if (Node* ownerNode = sheet->ownerNode()) { if (JSNode* ownerNodeWrapper = getCachedDOMNodeWrapper(ownerNode->document(), ownerNode)) markStack.append(ownerNodeWrapper); } diff --git a/WebCore/bindings/js/JSStyleSheetListCustom.cpp b/WebCore/bindings/js/JSStyleSheetListCustom.cpp index 1da6418..7bf9389 100644 --- a/WebCore/bindings/js/JSStyleSheetListCustom.cpp +++ b/WebCore/bindings/js/JSStyleSheetListCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,6 +35,18 @@ using namespace JSC; namespace WebCore { +void JSStyleSheetList::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + StyleSheetList* list = impl(); + JSGlobalData& globalData = *Heap::heap(this)->globalData(); + + unsigned length = list->length(); + for (unsigned i = 0; i < length; ++i) + markDOMObjectWrapper(markStack, globalData, list->item(i)); +} + bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheetList, const Identifier& propertyName) { return styleSheetList->getNamedItem(propertyName); diff --git a/WebCore/bindings/js/JSWebSocketConstructor.cpp b/WebCore/bindings/js/JSWebSocketConstructor.cpp index ca2e104..5b34765 100644 --- a/WebCore/bindings/js/JSWebSocketConstructor.cpp +++ b/WebCore/bindings/js/JSWebSocketConstructor.cpp @@ -37,6 +37,7 @@ #include "JSWebSocket.h" #include "ScriptExecutionContext.h" #include "WebSocket.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSWebSocketCustom.cpp b/WebCore/bindings/js/JSWebSocketCustom.cpp index 3aa4b8b..401b33d 100644 --- a/WebCore/bindings/js/JSWebSocketCustom.cpp +++ b/WebCore/bindings/js/JSWebSocketCustom.cpp @@ -38,6 +38,7 @@ #include "KURL.h" #include "WebSocket.h" #include "NotImplemented.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSWorkerConstructor.cpp b/WebCore/bindings/js/JSWorkerConstructor.cpp index 9943cfb..69c05e7 100644 --- a/WebCore/bindings/js/JSWorkerConstructor.cpp +++ b/WebCore/bindings/js/JSWorkerConstructor.cpp @@ -34,6 +34,7 @@ #include "JSDOMWindowCustom.h" #include "JSWorker.h" #include "Worker.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSWorkerContextCustom.cpp b/WebCore/bindings/js/JSWorkerContextCustom.cpp index 919c81f..7ece7a0 100644 --- a/WebCore/bindings/js/JSWorkerContextCustom.cpp +++ b/WebCore/bindings/js/JSWorkerContextCustom.cpp @@ -43,6 +43,10 @@ #include "WorkerNavigator.h" #include <interpreter/Interpreter.h> +#if ENABLE(EVENTSOURCE) +#include "JSEventSourceConstructor.h" +#endif + using namespace JSC; namespace WebCore { @@ -77,6 +81,13 @@ bool JSWorkerContext::getOwnPropertySlotDelegate(ExecState* exec, const Identifi return false; } +#if ENABLE(EVENTSOURCE) +JSValue JSWorkerContext::eventSource(ExecState* exec) const +{ + return getDOMConstructor<JSEventSourceConstructor>(exec, this); +} +#endif + JSValue JSWorkerContext::xmlHttpRequest(ExecState* exec) const { return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, this); diff --git a/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp b/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp index a644c9e..91fff9a 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp @@ -23,6 +23,7 @@ #include "JSXMLHttpRequest.h" #include "ScriptExecutionContext.h" #include "XMLHttpRequest.h" +#include <runtime/Error.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index a591fae..95bc16e 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -123,9 +123,9 @@ JSValue JSXMLHttpRequest::send(ExecState* exec, const ArgList& args) JSValue val = args.at(0); if (val.isUndefinedOrNull()) impl()->send(ec); - else if (val.isObject(&JSDocument::s_info)) + else if (val.inherits(&JSDocument::s_info)) impl()->send(toDocument(val), ec); - else if (val.isObject(&JSFile::s_info)) + else if (val.inherits(&JSFile::s_info)) impl()->send(toFile(val), ec); else impl()->send(val.toString(exec), ec); diff --git a/WebCore/bindings/js/JSXSLTProcessorCustom.cpp b/WebCore/bindings/js/JSXSLTProcessorCustom.cpp index 01e53a6..441bbc9 100644 --- a/WebCore/bindings/js/JSXSLTProcessorCustom.cpp +++ b/WebCore/bindings/js/JSXSLTProcessorCustom.cpp @@ -49,7 +49,7 @@ namespace WebCore { JSValue JSXSLTProcessor::importStylesheet(ExecState*, const ArgList& args) { JSValue nodeVal = args.at(0); - if (nodeVal.isObject(&JSNode::s_info)) { + if (nodeVal.inherits(&JSNode::s_info)) { JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); impl()->importStylesheet(node->impl()); return jsUndefined(); @@ -62,7 +62,7 @@ JSValue JSXSLTProcessor::transformToFragment(ExecState* exec, const ArgList& arg { JSValue nodeVal = args.at(0); JSValue docVal = args.at(1); - if (nodeVal.isObject(&JSNode::s_info) && docVal.isObject(&JSDocument::s_info)) { + if (nodeVal.inherits(&JSNode::s_info) && docVal.inherits(&JSDocument::s_info)) { WebCore::Node* node = static_cast<JSNode*>(asObject(nodeVal))->impl(); Document* doc = static_cast<Document*>(static_cast<JSDocument*>(asObject(docVal))->impl()); return toJS(exec, impl()->transformToFragment(node, doc).get()); @@ -74,7 +74,7 @@ JSValue JSXSLTProcessor::transformToFragment(ExecState* exec, const ArgList& arg JSValue JSXSLTProcessor::transformToDocument(ExecState* exec, const ArgList& args) { JSValue nodeVal = args.at(0); - if (nodeVal.isObject(&JSNode::s_info)) { + if (nodeVal.inherits(&JSNode::s_info)) { JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); RefPtr<Document> resultDocument = impl()->transformToDocument(node->impl()); if (resultDocument) diff --git a/WebCore/bindings/js/ScriptControllerHaiku.cpp b/WebCore/bindings/js/ScriptControllerHaiku.cpp index b573b97..3fe471d 100644 --- a/WebCore/bindings/js/ScriptControllerHaiku.cpp +++ b/WebCore/bindings/js/ScriptControllerHaiku.cpp @@ -28,8 +28,8 @@ #include "ScriptController.h" #include "PluginView.h" -#include "runtime_root.h" #include "runtime.h" +#include "runtime_root.h" namespace WebCore { diff --git a/WebCore/bindings/js/ScriptObjectQuarantine.cpp b/WebCore/bindings/js/ScriptObjectQuarantine.cpp index 89553ef..f96f89e 100644 --- a/WebCore/bindings/js/ScriptObjectQuarantine.cpp +++ b/WebCore/bindings/js/ScriptObjectQuarantine.cpp @@ -38,6 +38,7 @@ #include "JSNode.h" #include "ScriptObject.h" #include "ScriptValue.h" +#include "Storage.h" #include <runtime/JSLock.h> @@ -80,10 +81,11 @@ bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObj #endif #if ENABLE(DOM_STORAGE) -bool getQuarantinedScriptObject(Frame* frame, Storage* storage, ScriptObject& quarantinedObject) +bool getQuarantinedScriptObject(Storage* storage, ScriptObject& quarantinedObject) { - ASSERT(frame); ASSERT(storage); + Frame* frame = storage->frame(); + ASSERT(frame); JSDOMGlobalObject* globalObject = toJSDOMWindow(frame); ExecState* exec = globalObject->globalExec(); diff --git a/WebCore/bindings/js/ScriptObjectQuarantine.h b/WebCore/bindings/js/ScriptObjectQuarantine.h index d70acd7..df52379 100644 --- a/WebCore/bindings/js/ScriptObjectQuarantine.h +++ b/WebCore/bindings/js/ScriptObjectQuarantine.h @@ -37,7 +37,6 @@ namespace WebCore { class Database; class DOMWindow; - class Frame; class Node; class ScriptObject; class ScriptValue; @@ -49,7 +48,7 @@ namespace WebCore { bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObject); #endif #if ENABLE(DOM_STORAGE) - bool getQuarantinedScriptObject(Frame* frame, Storage* storage, ScriptObject& quarantinedObject); + bool getQuarantinedScriptObject(Storage* storage, ScriptObject& quarantinedObject); #endif bool getQuarantinedScriptObject(Node* node, ScriptObject& quarantinedObject); bool getQuarantinedScriptObject(DOMWindow* domWindow, ScriptObject& quarantinedObject); diff --git a/WebCore/bindings/js/ScriptValue.cpp b/WebCore/bindings/js/ScriptValue.cpp index d427cee..6eac102 100644 --- a/WebCore/bindings/js/ScriptValue.cpp +++ b/WebCore/bindings/js/ScriptValue.cpp @@ -74,4 +74,11 @@ bool ScriptValue::isUndefined() const return m_value.get().isUndefined(); } +bool ScriptValue::isObject() const +{ + if (!m_value) + return false; + return m_value.get().isObject(); +} + } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptValue.h b/WebCore/bindings/js/ScriptValue.h index 209ce06..19bb693 100644 --- a/WebCore/bindings/js/ScriptValue.h +++ b/WebCore/bindings/js/ScriptValue.h @@ -50,6 +50,7 @@ public: bool isEqual(ScriptState*, const ScriptValue&) const; bool isNull() const; bool isUndefined() const; + bool isObject() const; bool hasNoValue() const { return m_value == JSC::JSValue(); } private: diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 1918aef..f6de50e 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -667,6 +667,12 @@ sub GenerateHeader push(@headerContent, " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . " {\n" . + " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType" . ($dataNode->extendedAttributes->{"CustomMarkFunction"} ? "" : ", JSC::HasDefaultMark") . "));\n" . + " }\n"); + } elsif ($dataNode->extendedAttributes->{"CustomMarkFunction"}) { + push(@headerContent, + " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . + " {\n" . " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType));\n" . " }\n"); } @@ -1373,7 +1379,7 @@ sub GenerateImplementation push(@implContent, " if (!castedThisObj)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); } else { - push(@implContent, " if (!thisValue.isObject(&${className}::s_info))\n"); + push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n"); push(@implContent, " return throwError(exec, TypeError);\n"); push(@implContent, " $className* castedThisObj = static_cast<$className*>(asObject(thisValue));\n"); } @@ -1537,7 +1543,7 @@ sub GenerateImplementation push(@implContent, "{\n"); - push(@implContent, " return value.isObject(&${className}::s_info) ? " . ($podType ? "($podType) *" : "") . "static_cast<$className*>(asObject(value))->impl() : "); + push(@implContent, " return value.inherits(&${className}::s_info) ? " . ($podType ? "($podType) *" : "") . "static_cast<$className*>(asObject(value))->impl() : "); if ($podType and $podType ne "float") { push(@implContent, "$podType();\n}\n"); } else { diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index 439f368..1eb3e85 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -975,51 +975,24 @@ sub GenerateBatchedAttributeData $setter = "V8Custom::v8${customAccessor}AccessorSetter"; } } + } else { + # Default Getter and Setter + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; + $setter = "${interfaceName}Internal::${attrName}AttrSetter"; - # Custom Getter and Setter - } elsif ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { - $getter = "V8Custom::v8${customAccessor}AccessorGetter"; - if ($interfaceName eq "WorkerContext" and $attrName eq "self") { - $setter = "0"; - $propAttr = "v8::ReadOnly"; - } else { + # Custom Setter + if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { $hasCustomSetter = 1; $setter = "V8Custom::v8${customAccessor}AccessorSetter"; } - # Custom Setter - } elsif ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"}) { - $hasCustomSetter = 1; - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "V8Custom::v8${customAccessor}AccessorSetter"; - - # Custom Getter - } elsif ($attrExt->{"CustomGetter"}) { - $getter = "V8Custom::v8${customAccessor}AccessorGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; - - # Replaceable - } elsif ($attrExt->{"Replaceable"}) { - # Replaceable accessor is put on instance template with ReadOnly attribute. - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "0"; - - # Mark to avoid duplicate v8::ReadOnly flags in output. - $hasCustomSetter = 1; - - # Handle the special case of window.top being marked upstream as Replaceable. - # FIXME: Investigate why [Replaceable] is not marked as ReadOnly - # upstream and reach parity. - if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) { - $propAttr .= "|v8::ReadOnly"; + # Custom Getter + if ($attrExt->{"CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { + $getter = "V8Custom::v8${customAccessor}AccessorGetter"; } - - # Normal - } else { - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; } + # Replaceable if ($attrExt->{"Replaceable"} && !$hasCustomSetter) { $setter = "0"; $propAttr .= "|v8::ReadOnly"; @@ -1653,6 +1626,7 @@ sub IsRefPtrType return 1 if $type eq "Plugin"; return 1 if $type eq "ProcessingInstruction"; return 1 if $type eq "Range"; + return 1 if $type eq "RGBColor"; return 1 if $type eq "Text"; return 1 if $type eq "TextMetrics"; return 1 if $type eq "TimeRanges"; diff --git a/WebCore/bindings/v8/ScriptObjectQuarantine.cpp b/WebCore/bindings/v8/ScriptObjectQuarantine.cpp index 053cf68..c9f379b 100644 --- a/WebCore/bindings/v8/ScriptObjectQuarantine.cpp +++ b/WebCore/bindings/v8/ScriptObjectQuarantine.cpp @@ -38,6 +38,7 @@ #include "Page.h" #include "ScriptObject.h" #include "ScriptValue.h" +#include "Storage.h" #include "V8Binding.h" #include "V8Proxy.h" @@ -61,10 +62,11 @@ bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObj return false; } -bool getQuarantinedScriptObject(Frame* frame, Storage* storage, ScriptObject& quarantinedObject) +bool getQuarantinedScriptObject(Storage* storage, ScriptObject& quarantinedObject) { - ASSERT(frame); ASSERT(storage); + Frame* frame = storage->frame(); + ASSERT(frame); #if ENABLE(DOM_STORAGE) v8::HandleScope handleScope; diff --git a/WebCore/bindings/v8/ScriptObjectQuarantine.h b/WebCore/bindings/v8/ScriptObjectQuarantine.h index 3b7ccff..712dd9b 100644 --- a/WebCore/bindings/v8/ScriptObjectQuarantine.h +++ b/WebCore/bindings/v8/ScriptObjectQuarantine.h @@ -42,7 +42,6 @@ namespace WebCore { class Database; class DOMWindow; - class Frame; class Node; class ScriptObject; class ScriptValue; @@ -51,7 +50,7 @@ namespace WebCore { ScriptValue quarantineValue(ScriptState*, const ScriptValue&); bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObject); - bool getQuarantinedScriptObject(Frame* frame, Storage* storage, ScriptObject& quarantinedObject); + bool getQuarantinedScriptObject(Storage* storage, ScriptObject& quarantinedObject); bool getQuarantinedScriptObject(Node* node, ScriptObject& quarantinedObject); bool getQuarantinedScriptObject(DOMWindow* domWindow, ScriptObject& quarantinedObject); diff --git a/WebCore/bindings/v8/ScriptValue.h b/WebCore/bindings/v8/ScriptValue.h index 004851b..ddc3577 100644 --- a/WebCore/bindings/v8/ScriptValue.h +++ b/WebCore/bindings/v8/ScriptValue.h @@ -110,7 +110,12 @@ public: { return m_value->IsUndefined(); } - + + bool isObject() const + { + return m_value->IsObject(); + } + bool hasNoValue() const { return m_value.IsEmpty(); diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp index c5d580a..c0367d5 100644 --- a/WebCore/bindings/v8/V8Binding.cpp +++ b/WebCore/bindings/v8/V8Binding.cpp @@ -154,14 +154,12 @@ AtomicString v8StringToAtomicWebCoreString(v8::Handle<v8::String> v8String) { WebCoreStringResource* stringResource = WebCoreStringResource::toStringResource(v8String); if (!stringResource) { + if (!v8String->CanMakeExternal()) + return v8StringToWebCoreString(v8String, DoNotExternalize, AtomicStringType); // If this string hasn't been externalized, we force it now. - String plain = v8StringToWebCoreString(v8String, Externalize, AtomicStringType); - // If the string is empty there's no room to cache an atomic - // string so we bail out. - if (plain.isEmpty()) - return plain; + v8StringToWebCoreString(v8String, Externalize, AtomicStringType); stringResource = WebCoreStringResource::toStringResource(v8String); - ASSERT(stringResource != NULL); + ASSERT(stringResource); } return stringResource->atomicString(); } diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h index 80fed1d..945dcbb 100644 --- a/WebCore/bindings/v8/custom/V8CustomBinding.h +++ b/WebCore/bindings/v8/custom/V8CustomBinding.h @@ -218,7 +218,7 @@ namespace WebCore { DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DStrokeStyle); DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DFillStyle); - DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowEvent); + DECLARE_PROPERTY_ACCESSOR(DOMWindowEvent); DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowCrypto); DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowLocation); DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowOpener); @@ -402,12 +402,23 @@ namespace WebCore { DECLARE_CALLBACK(InspectorBackendSetting); DECLARE_CALLBACK(InspectorBackendInspectedWindow); DECLARE_CALLBACK(InspectorBackendSetSetting); + DECLARE_CALLBACK(InspectorBackendCookies); + DECLARE_CALLBACK(InspectorBackendDeleteCookie); DECLARE_CALLBACK(InspectorBackendCurrentCallFrame); DECLARE_CALLBACK(InspectorBackendDebuggerEnabled); DECLARE_CALLBACK(InspectorBackendPauseOnExceptions); DECLARE_CALLBACK(InspectorBackendProfilerEnabled); + DECLARE_CALLBACK(InspectorBackendNodeForId); + DECLARE_CALLBACK(InspectorBackendIdForNode); + DECLARE_CALLBACK(InspectorBackendWrapObject); + DECLARE_CALLBACK(InspectorBackendUnwrapObject); + DECLARE_CALLBACK(InspectorBackendPushNodePathToFrontend); #if ENABLE(DATABASE) DECLARE_CALLBACK(InspectorBackendDatabaseTableNames); + DECLARE_CALLBACK(InspectorBackendSelectDatabase); +#endif +#if ENABLE(DOM_STORAGE) + DECLARE_CALLBACK(InspectorBackendSelectDOMStorage); #endif DECLARE_CALLBACK(InspectorBackendWrapCallback); diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index 7d0b9e6..13d40bc 100644 --- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -145,14 +145,37 @@ static v8::Handle<v8::Value> convertBase64(const String& str, bool encode) ACCESSOR_GETTER(DOMWindowEvent) { + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + if (holder.IsEmpty()) + return v8::Undefined(); + + Frame* frame = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder)->frame(); + if (!frame || !V8Proxy::canAccessFrame(frame, true)) + return v8::Undefined(); + + v8::Local<v8::Context> context = V8Proxy::context(frame); v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event"); - v8::Local<v8::Context> context = v8::Context::GetCurrent(); v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbol); if (jsEvent.IsEmpty()) return v8::Undefined(); return jsEvent; } +ACCESSOR_SETTER(DOMWindowEvent) +{ + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + if (holder.IsEmpty()) + return; + + Frame* frame = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder)->frame(); + if (!frame || !V8Proxy::canAccessFrame(frame, true)) + return; + + v8::Local<v8::Context> context = V8Proxy::context(frame); + v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event"); + context->Global()->SetHiddenValue(eventSymbol, value); +} + ACCESSOR_GETTER(DOMWindowCrypto) { // FIXME: Implement me. diff --git a/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp b/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp index 2571df4..cb9b3a9 100644 --- a/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp +++ b/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp @@ -57,13 +57,8 @@ CALLBACK_FUNC_DECL(InspectorBackendHighlightDOMNode) if (args.Length() < 1) return v8::Undefined(); - Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); - if (!node) - return v8::Undefined(); - InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); - inspectorBackend->highlight(node); - + inspectorBackend->highlight(args[0]->ToInt32()->Value()); return v8::Undefined(); } @@ -209,10 +204,123 @@ CALLBACK_FUNC_DECL(InspectorBackendSetSetting) return v8::Undefined(); } +CALLBACK_FUNC_DECL(InspectorBackendCookies) +{ + INC_STATS("InspectorBackend.cookies()"); + // FIXME: Not yet implemented. + return v8::Undefined(); +} + +CALLBACK_FUNC_DECL(InspectorBackendDeleteCookie) +{ + INC_STATS("InspectorBackend.deleteCookie()"); + // FIXME: Not yet implemented. (see WebCore/bindings/js/JSInspectorBackendCustom.cpp#deleteCookie) + return v8::Undefined(); +} + CALLBACK_FUNC_DECL(InspectorBackendWrapCallback) { INC_STATS("InspectorBackend.wrapCallback()"); return args[0]; } +CALLBACK_FUNC_DECL(InspectorBackendNodeForId) +{ + INC_STATS("InspectorBackend.nodeForId()"); + if (args.Length() < 1) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + + Node* node = inspectorBackend->nodeForId(args[0]->ToInt32()->Value()); + if (!node) + return v8::Undefined(); + + InspectorController* ic = inspectorBackend->inspectorController(); + if (!ic) + return v8::Undefined(); + + return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node); +} + +CALLBACK_FUNC_DECL(InspectorBackendIdForNode) +{ + INC_STATS("InspectorBackend.idForNode()"); + if (args.Length() < 1) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); + if (node) + return v8::Number::New(inspectorBackend->idForNode(node)); + return v8::Undefined(); +} + +CALLBACK_FUNC_DECL(InspectorBackendWrapObject) +{ + INC_STATS("InspectorBackend.wrapObject()"); + if (args.Length() < 1) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + return inspectorBackend->wrapObject(ScriptValue(args[0])).v8Value(); +} + +CALLBACK_FUNC_DECL(InspectorBackendUnwrapObject) +{ + INC_STATS("InspectorBackend.unwrapObject()"); + if (args.Length() < 1) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + return inspectorBackend->unwrapObject(toWebCoreStringWithNullCheck(args[0])).v8Value(); +} + +CALLBACK_FUNC_DECL(InspectorBackendPushNodePathToFrontend) +{ + INC_STATS("InspectorBackend.pushNodePathToFrontend()"); + if (args.Length() < 2) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); + bool selectInUI = args[1]->ToBoolean()->Value(); + if (node) + return v8::Number::New(inspectorBackend->pushNodePathToFrontend(node, selectInUI)); + + return v8::Undefined(); +} + +#if ENABLE(DATABASE) +CALLBACK_FUNC_DECL(InspectorBackendSelectDatabase) +{ + INC_STATS("InspectorBackend.selectDatabase()"); + if (args.Length() < 1) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + Database* database = V8DOMWrapper::convertToNativeObject<Database>(V8ClassIndex::DATABASE, v8::Handle<v8::Object>::Cast(args[0])); + if (database) + inspectorBackend->selectDatabase(database); + + return v8::Undefined(); +} +#endif + +#if ENABLE(DOM_STORAGE) +CALLBACK_FUNC_DECL(InspectorBackendSelectDOMStorage) +{ + INC_STATS("InspectorBackend.selectDOMStorage()"); + if (args.Length() < 1) + return v8::Undefined(); + + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + Storage* storage = V8DOMWrapper::convertToNativeObject<Storage>(V8ClassIndex::STORAGE, v8::Handle<v8::Object>::Cast(args[0])); + if (storage) + inspectorBackend->selectDOMStorage(storage); + + return v8::Undefined(); +} +#endif + } // namespace WebCore |