diff options
Diffstat (limited to 'WebCore/bindings/js')
28 files changed, 209 insertions, 166 deletions
diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp index 22bfee4..3b3465e 100644 --- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp +++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "JSCSSStyleDeclarationCustom.h" -#include "AtomicString.h" #include "CSSMutableStyleDeclaration.h" #include "CSSPrimitiveValue.h" #include "CSSValue.h" @@ -34,6 +33,7 @@ #include <runtime/StringObjectThatMasqueradesAsUndefined.h> #include <runtime/StringPrototype.h> #include <wtf/ASCIICType.h> +#include <wtf/text/AtomicString.h> using namespace JSC; using namespace WTF; @@ -66,17 +66,17 @@ static bool hasCSSPropertyNamePrefix(const Identifier& propertyName, const char* ASSERT(*prefix); for (const char* p = prefix; *p; ++p) ASSERT(isASCIILower(*p)); - ASSERT(propertyName.size()); + ASSERT(propertyName.length()); #endif - if (toASCIILower(propertyName.data()[0]) != prefix[0]) + if (toASCIILower(propertyName.characters()[0]) != prefix[0]) return false; - unsigned length = propertyName.size(); + unsigned length = propertyName.length(); for (unsigned i = 1; i < length; ++i) { if (!prefix[i]) - return isASCIIUpper(propertyName.data()[i]); - if (propertyName.data()[i] != prefix[i]) + return isASCIIUpper(propertyName.characters()[i]); + if (propertyName.characters()[i] != prefix[i]) return false; } return false; @@ -87,7 +87,7 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = false; - unsigned length = propertyName.size(); + unsigned length = propertyName.length(); if (!length) return String(); @@ -111,14 +111,14 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo || hasCSSPropertyNamePrefix(propertyName, "apple")) name.append('-'); else { - if (isASCIIUpper(propertyName.data()[0])) + if (isASCIIUpper(propertyName.characters()[0])) return String(); } - name.append(toASCIILower(propertyName.data()[i++])); + name.append(toASCIILower(propertyName.characters()[i++])); for (; i < length; ++i) { - UChar c = propertyName.data()[i]; + UChar c = propertyName.characters()[i]; if (!isASCIIUpper(c)) name.append(c); else { diff --git a/WebCore/bindings/js/JSCanvasNumberArrayCustom.cpp b/WebCore/bindings/js/JSCanvasNumberArrayCustom.cpp deleted file mode 100644 index be10ac0..0000000 --- a/WebCore/bindings/js/JSCanvasNumberArrayCustom.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 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 - * 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" - -#if ENABLE(3D_CANVAS) - -#include "JSCanvasNumberArray.h" - -#include "CanvasNumberArray.h" - -using namespace JSC; - -namespace WebCore { - -JSValue JSCanvasNumberArray::getByIndex(JSC::ExecState* exec, unsigned int index) -{ - JSC::JSValue result = jsNumber(exec, impl()->item(index)); - return result; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp index 8221fed..532b38b 100644 --- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp @@ -57,9 +57,9 @@ static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState*, JSValue value) return 0; JSObject* object = asObject(value); if (object->inherits(&JSCanvasGradient::s_info)) - return CanvasStyle::create(static_cast<JSCanvasGradient*>(object)->impl()); + return CanvasStyle::createFromGradient(static_cast<JSCanvasGradient*>(object)->impl()); if (object->inherits(&JSCanvasPattern::s_info)) - return CanvasStyle::create(static_cast<JSCanvasPattern*>(object)->impl()); + return CanvasStyle::createFromPattern(static_cast<JSCanvasPattern*>(object)->impl()); return 0; } diff --git a/WebCore/bindings/js/JSClipboardCustom.cpp b/WebCore/bindings/js/JSClipboardCustom.cpp index 9bdffdb..2a8d309 100644 --- a/WebCore/bindings/js/JSClipboardCustom.cpp +++ b/WebCore/bindings/js/JSClipboardCustom.cpp @@ -37,10 +37,10 @@ #include "JSNode.h" #include "Node.h" #include "PlatformString.h" -#include "StringHash.h" #include <runtime/ArrayPrototype.h> #include <runtime/Error.h> #include <wtf/HashSet.h> +#include <wtf/text/StringHash.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp index 4d7b6e1..263f2f9 100644 --- a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp +++ b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp @@ -28,7 +28,6 @@ #if ENABLE(OFFLINE_WEB_APPLICATIONS) -#include "AtomicString.h" #include "DOMApplicationCache.h" #include "DOMWindow.h" #include "Event.h" @@ -37,6 +36,7 @@ #include "JSDOMWindowCustom.h" #include "JSEvent.h" #include "JSEventListener.h" +#include <wtf/text/AtomicString.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index 8220f51..96394eb 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -501,7 +501,7 @@ AtomicStringImpl* findAtomicString(const Identifier& identifier) { if (identifier.isNull()) return 0; - UStringImpl* impl = identifier.ustring().rep(); + StringImpl* impl = identifier.impl(); ASSERT(impl->existingHash()); return AtomicString::find(impl->characters(), impl->length(), impl->existingHash()); } @@ -679,10 +679,9 @@ Frame* toDynamicFrame(ExecState* exec) return asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); } -bool processingUserGesture(ExecState* exec) +bool processingUserGesture() { - Frame* frame = toDynamicFrame(exec); - return frame && frame->script()->processingUserGesture(currentWorld(exec)); + return ScriptController::processingUserGesture(); } KURL completeURL(ExecState* exec, const String& relativeURL) diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h index 7086a89..749b0d7 100644 --- a/WebCore/bindings/js/JSDOMBinding.h +++ b/WebCore/bindings/js/JSDOMBinding.h @@ -313,7 +313,7 @@ namespace WebCore { Frame* toLexicalFrame(JSC::ExecState*); Frame* toDynamicFrame(JSC::ExecState*); - bool processingUserGesture(JSC::ExecState*); + bool processingUserGesture(); KURL completeURL(JSC::ExecState*, const String& relativeURL); inline JSC::JSValue jsString(JSC::ExecState* exec, const String& s) @@ -339,7 +339,7 @@ namespace WebCore { inline String ustringToString(const JSC::UString& u) { - return u.rep(); + return u.impl(); } inline JSC::UString stringToUString(const String& s) @@ -349,17 +349,17 @@ namespace WebCore { inline String identifierToString(const JSC::Identifier& i) { - return i.ustring().rep(); + return i.impl(); } inline AtomicString ustringToAtomicString(const JSC::UString& u) { - return AtomicString(u.rep()); + return AtomicString(u.impl()); } inline AtomicString identifierToAtomicString(const JSC::Identifier& identifier) { - return AtomicString(identifier.ustring().rep()); + return AtomicString(identifier.impl()); } } // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp b/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp index 2d41843..0194962 100644 --- a/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp +++ b/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp @@ -20,9 +20,9 @@ #include "config.h" #include "JSDOMMimeTypeArray.h" -#include "AtomicString.h" #include "DOMMimeTypeArray.h" #include "JSDOMMimeType.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp b/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp index abf3148..20ce5e5 100644 --- a/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp +++ b/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp @@ -20,9 +20,9 @@ #include "config.h" #include "JSDOMPluginArray.h" -#include "AtomicString.h" #include "DOMPluginArray.h" #include "JSDOMPlugin.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/bindings/js/JSDOMPluginCustom.cpp b/WebCore/bindings/js/JSDOMPluginCustom.cpp index c8d187e..319cb3c 100644 --- a/WebCore/bindings/js/JSDOMPluginCustom.cpp +++ b/WebCore/bindings/js/JSDOMPluginCustom.cpp @@ -19,9 +19,9 @@ #include "config.h" #include "JSDOMPlugin.h" -#include "AtomicString.h" #include "DOMPlugin.h" #include "JSDOMMimeType.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/bindings/js/JSDOMStringMapCustom.cpp b/WebCore/bindings/js/JSDOMStringMapCustom.cpp index 455c7b1..d1c1d69 100644 --- a/WebCore/bindings/js/JSDOMStringMapCustom.cpp +++ b/WebCore/bindings/js/JSDOMStringMapCustom.cpp @@ -26,8 +26,8 @@ #include "config.h" #include "JSDOMStringMap.h" -#include "AtomicString.h" #include "DOMStringMap.h" +#include <wtf/text/AtomicString.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 252ea93..2ad71f0 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -20,7 +20,6 @@ #include "config.h" #include "JSDOMWindowCustom.h" -#include "AtomicString.h" #include "Chrome.h" #include "DOMWindow.h" #include "Document.h" @@ -87,6 +86,7 @@ #include <runtime/JSFunction.h> #include <runtime/JSObject.h> #include <runtime/PrototypeFunction.h> +#include <wtf/text/AtomicString.h> using namespace JSC; @@ -271,7 +271,7 @@ bool JSDOMWindow::getOwnPropertySlot(ExecState* exec, const Identifier& property // allow window[1] or parent[1] etc. (#56983) bool ok; - unsigned i = propertyName.toArrayIndex(&ok); + unsigned i = propertyName.toArrayIndex(ok); if (ok && i < impl()->frame()->tree()->childCount()) { slot.setCustomIndex(this, i, indexGetter); return true; @@ -345,7 +345,7 @@ bool JSDOMWindow::getOwnPropertyDescriptor(ExecState* exec, const Identifier& pr } bool ok; - unsigned i = propertyName.toArrayIndex(&ok); + unsigned i = propertyName.toArrayIndex(ok); if (ok && i < impl()->frame()->tree()->childCount()) { PropertySlot slot; slot.setCustomIndex(this, i, indexGetter); @@ -512,7 +512,7 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value) if (!protocolIsJavaScript(url) || allowsAccessFrom(exec)) { // We want a new history item if this JS was called via a user gesture - frame->redirectScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture(exec)); + frame->redirectScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture()); } } @@ -606,47 +606,6 @@ JSValue JSDOMWindow::float32Array(ExecState* exec) const return getDOMConstructor<JSFloat32ArrayConstructor>(exec, this); } -// Temporary aliases to keep current WebGL content working during transition period to TypedArray spec. -// To be removed before WebGL spec is finalized. (FIXME) -JSValue JSDOMWindow::webGLArrayBuffer(ExecState* exec) const -{ - return getDOMConstructor<JSArrayBufferConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLByteArray(ExecState* exec) const -{ - return getDOMConstructor<JSInt8ArrayConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLUnsignedByteArray(ExecState* exec) const -{ - return getDOMConstructor<JSUint8ArrayConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLIntArray(ExecState* exec) const -{ - return getDOMConstructor<JSInt32ArrayConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLUnsignedIntArray(ExecState* exec) const -{ - return getDOMConstructor<JSUint32ArrayConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLShortArray(ExecState* exec) const -{ - return getDOMConstructor<JSInt16ArrayConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLUnsignedShortArray(ExecState* exec) const -{ - return getDOMConstructor<JSUint16ArrayConstructor>(exec, this); -} - -JSValue JSDOMWindow::webGLFloatArray(ExecState* exec) const -{ - return getDOMConstructor<JSFloat32ArrayConstructor>(exec, this); -} #endif JSValue JSDOMWindow::xmlHttpRequest(ExecState* exec) const @@ -724,10 +683,9 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF // We'd have to resolve all those issues to pass the URL instead of "". bool created; - // We pass in the opener frame here so it can be used for looking up the frame name, in case the active frame - // is different from the opener frame, and the name references a frame relative to the opener frame, for example - // "_self" or "_parent". - Frame* newFrame = lexicalFrame->loader()->createWindow(openerFrame->loader(), frameRequest, windowFeatures, created); + // We pass the opener frame for the lookupFrame in case the active frame is different from + // the opener frame, and the name references a frame relative to the opener frame. + Frame* newFrame = createWindow(lexicalFrame, openerFrame, frameRequest, windowFeatures, created); if (!newFrame) return 0; @@ -742,7 +700,7 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF if (!protocolIsJavaScript(url) || newWindow->allowsAccessFrom(exec)) { KURL completedURL = url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(exec, url); - bool userGesture = processingUserGesture(exec); + bool userGesture = processingUserGesture(); if (created) newFrame->loader()->changeLocation(completedURL, referrer, false, false, userGesture); @@ -753,10 +711,10 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF return newFrame; } -static bool domWindowAllowPopUp(Frame* activeFrame, ExecState* exec) +static bool domWindowAllowPopUp(Frame* activeFrame) { ASSERT(activeFrame); - if (activeFrame->script()->processingUserGesture(currentWorld(exec))) + if (ScriptController::processingUserGesture()) return true; return DOMWindow::allowPopUp(activeFrame); } @@ -781,7 +739,7 @@ JSValue JSDOMWindow::open(ExecState* exec) // Because FrameTree::find() returns true for empty strings, we must check for empty framenames. // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker. - if (!domWindowAllowPopUp(dynamicFrame, exec) && (frameName.isEmpty() || !frame->tree()->find(frameName))) + if (!domWindowAllowPopUp(dynamicFrame) && (frameName.isEmpty() || !frame->tree()->find(frameName))) return jsUndefined(); // Get the target frame for the special cases of _top and _parent. In those @@ -805,7 +763,7 @@ JSValue JSDOMWindow::open(ExecState* exec) const JSDOMWindow* targetedWindow = toJSDOMWindow(frame, currentWorld(exec)); if (!completedURL.isEmpty() && (!protocolIsJavaScript(completedURL) || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) { - bool userGesture = processingUserGesture(exec); + bool userGesture = processingUserGesture(); // For whatever reason, Firefox uses the dynamicGlobalObject to // determine the outgoingReferrer. We replicate that behavior @@ -851,7 +809,7 @@ JSValue JSDOMWindow::showModalDialog(ExecState* exec) if (!dynamicFrame) return jsUndefined(); - if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame, exec)) + if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame)) return jsUndefined(); HashMap<String, String> features; diff --git a/WebCore/bindings/js/JSDataGridColumnListCustom.cpp b/WebCore/bindings/js/JSDataGridColumnListCustom.cpp index 5ee790c..cc41093 100644 --- a/WebCore/bindings/js/JSDataGridColumnListCustom.cpp +++ b/WebCore/bindings/js/JSDataGridColumnListCustom.cpp @@ -29,10 +29,10 @@ #include "JSDataGridColumnList.h" -#include "AtomicString.h" #include "DataGridColumn.h" #include "DataGridColumnList.h" #include "JSDataGridColumn.h" +#include <wtf/text/AtomicString.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp index 7407e86..ec66cbd 100644 --- a/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/WebCore/bindings/js/JSDocumentCustom.cpp @@ -88,7 +88,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value) if (activeFrame) str = activeFrame->document()->completeURL(str).string(); - bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec)); + bool userGesture = ScriptController::processingUserGesture(); frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } diff --git a/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp index a504f25..64615b9 100644 --- a/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp +++ b/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "JSHTMLAllCollection.h" -#include "AtomicString.h" #include "HTMLAllCollection.h" #include "JSDOMBinding.h" #include "JSHTMLAllCollection.h" @@ -36,6 +35,7 @@ #include "StaticNodeList.h" #include <runtime/JSValue.h> #include <wtf/Vector.h> +#include <wtf/text/AtomicString.h> using namespace JSC; @@ -74,7 +74,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec) // Support for document.all(<index>) etc. bool ok; UString string = exec->argument(0).toString(exec); - unsigned index = string.toUInt32(&ok, false); + unsigned index = Identifier::toUInt32(string, ok); if (ok) return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection->item(index))); @@ -85,7 +85,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec) // The second arg, if set, is the index of the item we want bool ok; UString string = exec->argument(0).toString(exec); - unsigned index = exec->argument(1).toString(exec).toUInt32(&ok, false); + unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec), ok); if (ok) { String pstr = ustringToString(string); Node* node = collection->namedItem(pstr); @@ -122,7 +122,7 @@ JSValue JSHTMLAllCollection::nameGetter(ExecState* exec, JSValue slotBase, const JSValue JSHTMLAllCollection::item(ExecState* exec) { bool ok; - uint32_t index = exec->argument(0).toString(exec).toUInt32(&ok, false); + uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec), ok); if (ok) return toJS(exec, globalObject(), impl()->item(index)); return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec))); diff --git a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp index b0cfd99..6b2f350 100644 --- a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp +++ b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp @@ -20,7 +20,6 @@ #include "config.h" #include "JSHTMLCollection.h" -#include "AtomicString.h" #include "HTMLCollection.h" #include "HTMLOptionsCollection.h" #include "HTMLAllCollection.h" @@ -32,6 +31,7 @@ #include "Node.h" #include "StaticNodeList.h" #include <wtf/Vector.h> +#include <wtf/text/AtomicString.h> using namespace JSC; @@ -70,7 +70,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec) // Support for document.all(<index>) etc. bool ok; UString string = exec->argument(0).toString(exec); - unsigned index = string.toUInt32(&ok, false); + unsigned index = Identifier::toUInt32(string, ok); if (ok) return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection->item(index))); @@ -81,7 +81,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec) // The second arg, if set, is the index of the item we want bool ok; UString string = exec->argument(0).toString(exec); - unsigned index = exec->argument(1).toString(exec).toUInt32(&ok, false); + unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec), ok); if (ok) { String pstr = ustringToString(string); Node* node = collection->namedItem(pstr); @@ -118,7 +118,7 @@ JSValue JSHTMLCollection::nameGetter(ExecState* exec, JSValue slotBase, const Id JSValue JSHTMLCollection::item(ExecState* exec) { bool ok; - uint32_t index = exec->argument(0).toString(exec).toUInt32(&ok, false); + uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec), ok); if (ok) return toJS(exec, globalObject(), impl()->item(index)); return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec))); diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp index 0c891a3..06360fb 100644 --- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp +++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp @@ -183,6 +183,9 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) if (injectedScript) return InjectedScript(ScriptObject(scriptState, injectedScript)); + if (!canAccessInspectedWindow(scriptState)) + return InjectedScript(); + ASSERT(!m_injectedScriptSource.isEmpty()); pair<long, ScriptObject> injectedScriptObject = injectScript(m_injectedScriptSource, scriptState); globalObject->setInjectedScript(injectedScriptObject.second.jsObject()); diff --git a/WebCore/bindings/js/JSLocationCustom.cpp b/WebCore/bindings/js/JSLocationCustom.cpp index 76005fa..99166cd 100644 --- a/WebCore/bindings/js/JSLocationCustom.cpp +++ b/WebCore/bindings/js/JSLocationCustom.cpp @@ -191,7 +191,7 @@ static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bo return; if (!protocolIsJavaScript(url) || allowsAccessFromFrame(exec, frame)) - frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture(exec)); + frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture()); } void JSLocation::setHref(ExecState* exec, JSValue value) @@ -253,7 +253,7 @@ void JSLocation::setPort(ExecState* exec, JSValue value) KURL url = frame->loader()->url(); // FIXME: Could make this a little less ugly if String provided a toUnsignedShort function. const UString& portString = value.toString(exec); - int port = charactersToInt(portString.data(), portString.size()); + int port = charactersToInt(portString.characters(), portString.length()); if (port < 0 || port > 0xFFFF) url.removePort(); else @@ -325,7 +325,7 @@ JSValue JSLocation::reload(ExecState* exec) return jsUndefined(); if (!protocolIsJavaScript(frame->loader()->url())) - frame->redirectScheduler()->scheduleRefresh(processingUserGesture(exec)); + frame->redirectScheduler()->scheduleRefresh(processingUserGesture()); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSMessagePortCustom.cpp b/WebCore/bindings/js/JSMessagePortCustom.cpp index 227d6ed..06b4178 100644 --- a/WebCore/bindings/js/JSMessagePortCustom.cpp +++ b/WebCore/bindings/js/JSMessagePortCustom.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "JSMessagePort.h" -#include "AtomicString.h" #include "Event.h" #include "ExceptionCode.h" #include "Frame.h" @@ -36,6 +35,7 @@ #include "JSMessagePortCustom.h" #include "MessagePort.h" #include <runtime/Error.h> +#include <wtf/text/AtomicString.h> using namespace JSC; diff --git a/WebCore/bindings/js/JSNodeListCustom.cpp b/WebCore/bindings/js/JSNodeListCustom.cpp index dd59c15..c81914c 100644 --- a/WebCore/bindings/js/JSNodeListCustom.cpp +++ b/WebCore/bindings/js/JSNodeListCustom.cpp @@ -26,10 +26,10 @@ #include "config.h" #include "JSNodeList.h" -#include "AtomicString.h" #include "JSNode.h" #include "Node.h" #include "NodeList.h" +#include <wtf/text/AtomicString.h> using namespace JSC; @@ -39,7 +39,7 @@ namespace WebCore { static EncodedJSValue JSC_HOST_CALL callNodeList(ExecState* exec) { bool ok; - unsigned index = exec->argument(0).toString(exec).toUInt32(&ok); + unsigned index = Identifier::toUInt32(exec->argument(0).toString(exec), ok); if (!ok) return JSValue::encode(jsUndefined()); return JSValue::encode(toJS(exec, static_cast<JSNodeList*>(exec->callee())->impl()->item(index))); diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 98022d9..d318cbb 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -244,14 +244,26 @@ int ScriptController::eventHandlerLineNumber() const return 0; } -bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const +bool ScriptController::processingUserGesture() { - if (m_allowPopupsFromPlugin || isJavaScriptAnchorNavigation()) + ExecState* exec = JSMainThreadExecState::currentState(); + Frame* frame = exec ? toDynamicFrame(exec) : 0; + // No script is running, so it is user-initiated unless the gesture stack + // explicitly says it is not. + if (!frame) + return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; + + // FIXME: We check the plugin popup flag and javascript anchor navigation + // from the dynamic frame becuase they should only be initiated on the + // dynamic frame in which execution began if they do happen. + ScriptController* scriptController = frame->script(); + ASSERT(scriptController); + if (scriptController->allowPopupsFromPlugin() || scriptController->isJavaScriptAnchorNavigation()) return true; // If a DOM event is being processed, check that it was initiated by the user // and that it is in the whitelist of event types allowed to generate pop-ups. - if (JSDOMWindowShell* shell = existingWindowShell(world)) + if (JSDOMWindowShell* shell = scriptController->existingWindowShell(currentWorld(exec))) if (Event* event = shell->window()->currentEvent()) return event->fromUserGesture(); diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index 8dae637..2ec71b9 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -110,7 +110,7 @@ public: int eventHandlerLineNumber() const; void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; } - bool processingUserGesture(DOMWrapperWorld*) const; + static bool processingUserGesture(); bool anyPageIsProcessingUserGesture() const; static bool canAccessFromCurrentOrigin(Frame*); diff --git a/WebCore/bindings/js/ScriptDebugServer.cpp b/WebCore/bindings/js/ScriptDebugServer.cpp index d71034b..cd80de4 100644 --- a/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/WebCore/bindings/js/ScriptDebugServer.cpp @@ -268,7 +268,7 @@ void ScriptDebugServer::dispatchDidContinue(ScriptDebugListener* listener) void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType) { - String sourceID = ustringToString(JSC::UString::from(source.provider()->asID())); + String sourceID = ustringToString(JSC::UString::number(source.provider()->asID())); String url = ustringToString(source.provider()->url()); String data = ustringToString(JSC::UString(source.data(), source.length())); int firstLine = source.firstLine(); @@ -497,6 +497,10 @@ void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + // detach may have been called during pauseIfNeeded + if (!m_currentCallFrame) + return; + // Treat stepping over a return statement like stepping out. if (m_currentCallFrame == m_pauseOnCallFrame) m_pauseOnCallFrame = m_currentCallFrame->caller(); diff --git a/WebCore/bindings/js/ScriptProfile.cpp b/WebCore/bindings/js/ScriptProfile.cpp index 1fbd040..0eb2814 100644 --- a/WebCore/bindings/js/ScriptProfile.cpp +++ b/WebCore/bindings/js/ScriptProfile.cpp @@ -84,8 +84,8 @@ static PassRefPtr<InspectorObject> buildInspectorObjectFor(const JSC::ProfileNod const ProfileNodesList& children = node->children(); ProfileNodesList::const_iterator end = children.end(); for (ProfileNodesList::const_iterator iter = children.begin(); iter != end; ++iter) - childrenArray->push(buildInspectorObjectFor(iter->get())); - result->set("children", childrenArray); + childrenArray->pushObject(buildInspectorObjectFor(iter->get())); + result->setArray("children", childrenArray); return result; } diff --git a/WebCore/bindings/js/ScriptString.h b/WebCore/bindings/js/ScriptString.h index 558ad33..7401818 100644 --- a/WebCore/bindings/js/ScriptString.h +++ b/WebCore/bindings/js/ScriptString.h @@ -51,7 +51,7 @@ public: const JSC::UString& ustring() const { return m_str; } bool isNull() const { return m_str.isNull(); } - size_t size() const { return m_str.size(); } + size_t size() const { return m_str.length(); } ScriptString& operator=(const char* s) { diff --git a/WebCore/bindings/js/ScriptValue.cpp b/WebCore/bindings/js/ScriptValue.cpp index 23934cd..a58e0c7 100644 --- a/WebCore/bindings/js/ScriptValue.cpp +++ b/WebCore/bindings/js/ScriptValue.cpp @@ -109,7 +109,7 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, J return InspectorBasicValue::create(value.uncheckedGetNumber()); if (value.isString()) { UString s = value.getString(scriptState); - return InspectorString::create(String(s.data(), s.size())); + return InspectorString::create(String(s.characters(), s.length())); } if (value.isObject()) { if (isJSArray(&scriptState->globalData(), value)) { @@ -123,7 +123,7 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, J ASSERT_NOT_REACHED(); elementValue = InspectorValue::null(); } - inspectorArray->push(elementValue); + inspectorArray->pushValue(elementValue); } return inspectorArray; } @@ -139,7 +139,7 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ScriptState* scriptState, J ASSERT_NOT_REACHED(); inspectorValue = InspectorValue::null(); } - inspectorObject->set(String(name.data(), name.size()), inspectorValue); + inspectorObject->setValue(String(name.characters(), name.length()), inspectorValue); } return inspectorObject; } diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp index 6d6fa21..00ec25f 100644 --- a/WebCore/bindings/js/SerializedScriptValue.cpp +++ b/WebCore/bindings/js/SerializedScriptValue.cpp @@ -27,9 +27,11 @@ #include "config.h" #include "SerializedScriptValue.h" +#include "Blob.h" #include "File.h" #include "FileList.h" #include "ImageData.h" +#include "JSBlob.h" #include "JSDOMGlobalObject.h" #include "JSFile.h" #include "JSFileList.h" @@ -147,26 +149,86 @@ private: unsigned m_length; }; +class SerializedBlob : public SharedSerializedData { +public: + static PassRefPtr<SerializedBlob> create(const Blob* blob) + { + return adoptRef(new SerializedBlob(blob)); + } + + const KURL& url() const { return m_url; } + const String& type() const { return m_type; } + unsigned long long size() const { return m_size; } + +private: + SerializedBlob(const Blob* blob) + : m_url(blob->url().copy()) + , m_type(blob->type().crossThreadString()) + , m_size(blob->size()) + { + } + + KURL m_url; + String m_type; + unsigned long long m_size; +}; + +class SerializedFile : public SharedSerializedData { +public: + static PassRefPtr<SerializedFile> create(const File* file) + { + return adoptRef(new SerializedFile(file)); + } + + const String& path() const { return m_path; } + const KURL& url() const { return m_url; } + const String& type() const { return m_type; } + +private: + SerializedFile(const File* file) + : m_path(file->path().crossThreadString()) + , m_url(file->url().copy()) + , m_type(file->type().crossThreadString()) + { + } + + String m_path; + KURL m_url; + String m_type; +}; + class SerializedFileList : public SharedSerializedData { public: + struct FileData { + String path; + KURL url; + String type; + }; + static PassRefPtr<SerializedFileList> create(const FileList* list) { return adoptRef(new SerializedFileList(list)); } unsigned length() const { return m_files.size(); } - const String& item(unsigned idx) { return m_files[idx]; } + const FileData& item(unsigned idx) { return m_files[idx]; } private: SerializedFileList(const FileList* list) { unsigned length = list->length(); m_files.reserveCapacity(length); - for (unsigned i = 0; i < length; i++) - m_files.append(list->item(i)->path().crossThreadString()); + for (unsigned i = 0; i < length; i++) { + File* file = list->item(i); + FileData fileData; + fileData.path = file->path().crossThreadString(); + fileData.url = file->url().copy(); + fileData.type = file->type().crossThreadString(); + m_files.append(fileData); + } } - Vector<String> m_files; + Vector<FileData> m_files; }; class SerializedImageData : public SharedSerializedData { @@ -217,9 +279,15 @@ SerializedScriptValueData::SerializedScriptValueData(const ImageData* imageData) { } +SerializedScriptValueData::SerializedScriptValueData(const Blob* blob) + : m_type(BlobType) + , m_sharedData(SerializedBlob::create(blob)) +{ +} + SerializedScriptValueData::SerializedScriptValueData(const File* file) : m_type(FileType) - , m_string(file->path().crossThreadString()) + , m_sharedData(SerializedFile::create(file)) { } @@ -233,6 +301,16 @@ SerializedObject* SharedSerializedData::asObject() return static_cast<SerializedObject*>(this); } +SerializedBlob* SharedSerializedData::asBlob() +{ + return static_cast<SerializedBlob*>(this); +} + +SerializedFile* SharedSerializedData::asFile() +{ + return static_cast<SerializedFile*>(this); +} + SerializedFileList* SharedSerializedData::asFileList() { return static_cast<SerializedFileList*>(this); @@ -570,6 +648,8 @@ struct SerializingTreeWalker : public BaseWalker { JSObject* obj = asObject(value); if (obj->inherits(&JSFile::s_info)) return SerializedScriptValueData(toFile(obj)); + if (obj->inherits(&JSBlob::s_info)) + return SerializedScriptValueData(toBlob(obj)); if (obj->inherits(&JSFileList::s_info)) return SerializedScriptValueData(toFileList(obj)); if (obj->inherits(&JSImageData::s_info)) @@ -736,12 +816,21 @@ struct DeserializingTreeWalker : public BaseWalker { return jsNumber(m_exec, value.asDouble()); case SerializedScriptValueData::DateType: return new (m_exec) DateInstance(m_exec, m_globalObject->dateStructure(), value.asDouble()); + case SerializedScriptValueData::BlobType: { + if (!m_isDOMGlobalObject) + return jsNull(); + SerializedBlob* serializedBlob = value.asBlob(); + ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext(); + ASSERT(scriptExecutionContext); + return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), Blob::create(scriptExecutionContext, serializedBlob->url(), serializedBlob->type(), serializedBlob->size())); + } case SerializedScriptValueData::FileType: { if (!m_isDOMGlobalObject) return jsNull(); + SerializedFile* serializedFile = value.asFile(); ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext(); ASSERT(scriptExecutionContext); - return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), File::create(scriptExecutionContext, value.asString().crossThreadString())); + return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), File::create(scriptExecutionContext, serializedFile->path(), serializedFile->url(), serializedFile->type())); } case SerializedScriptValueData::FileListType: { if (!m_isDOMGlobalObject) @@ -751,8 +840,10 @@ struct DeserializingTreeWalker : public BaseWalker { unsigned length = serializedFileList->length(); ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext(); ASSERT(scriptExecutionContext); - for (unsigned i = 0; i < length; i++) - result->append(File::create(scriptExecutionContext, serializedFileList->item(i))); + for (unsigned i = 0; i < length; i++) { + const SerializedFileList::FileData& fileData = serializedFileList->item(i); + result->append(File::create(scriptExecutionContext, fileData.path, fileData.url, fileData.type)); + } return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), result.get()); } case SerializedScriptValueData::ImageDataType: { @@ -920,6 +1011,7 @@ struct TeardownTreeWalker { case SerializedScriptValueData::NumberType: case SerializedScriptValueData::DateType: case SerializedScriptValueData::EmptyType: + case SerializedScriptValueData::BlobType: case SerializedScriptValueData::FileType: case SerializedScriptValueData::FileListType: case SerializedScriptValueData::ImageDataType: diff --git a/WebCore/bindings/js/SerializedScriptValue.h b/WebCore/bindings/js/SerializedScriptValue.h index 93bd0de..2b7d222 100644 --- a/WebCore/bindings/js/SerializedScriptValue.h +++ b/WebCore/bindings/js/SerializedScriptValue.h @@ -33,10 +33,13 @@ typedef const struct OpaqueJSContext* JSContextRef; typedef const struct OpaqueJSValue* JSValueRef; namespace WebCore { + class Blob; class File; class FileList; class ImageData; class SerializedArray; + class SerializedBlob; + class SerializedFile; class SerializedFileList; class SerializedImageData; class SerializedObject; @@ -46,6 +49,8 @@ namespace WebCore { virtual ~SharedSerializedData() { } SerializedArray* asArray(); SerializedObject* asObject(); + SerializedBlob* asBlob(); + SerializedFile* asFile(); SerializedFileList* asFileList(); SerializedImageData* asImageData(); }; @@ -62,6 +67,7 @@ namespace WebCore { ObjectType, ArrayType, StringType, + BlobType, FileType, FileListType, ImageDataType @@ -84,10 +90,11 @@ namespace WebCore { explicit SerializedScriptValueData(const String& string) : m_type(StringType) - , m_string(string.crossThreadString()) // FIXME: Should be able to just share the Rep + , m_string(string.crossThreadString()) // FIXME: Should be able to just share the StringImpl { } - + + explicit SerializedScriptValueData(const Blob*); explicit SerializedScriptValueData(const File*); explicit SerializedScriptValueData(const FileList*); explicit SerializedScriptValueData(const ImageData*); @@ -122,7 +129,7 @@ namespace WebCore { String asString() const { - ASSERT(m_type == StringType || m_type == FileType); + ASSERT(m_type == StringType); return m_string; } @@ -140,6 +147,20 @@ namespace WebCore { return m_sharedData->asArray(); } + SerializedBlob* asBlob() const + { + ASSERT(m_type == BlobType); + ASSERT(m_sharedData); + return m_sharedData->asBlob(); + } + + SerializedFile* asFile() const + { + ASSERT(m_type == FileType); + ASSERT(m_sharedData); + return m_sharedData->asFile(); + } + SerializedFileList* asFileList() const { ASSERT(m_type == FileListType); |