summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bindings/js')
-rw-r--r--Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp37
-rw-r--r--Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp3
-rw-r--r--Source/WebCore/bindings/js/JSDOMBinding.cpp8
-rw-r--r--Source/WebCore/bindings/js/JSDOMBinding.h8
-rw-r--r--Source/WebCore/bindings/js/JSDOMWindowCustom.cpp28
-rw-r--r--Source/WebCore/bindings/js/JSDOMWindowShell.cpp12
-rw-r--r--Source/WebCore/bindings/js/JSDOMWindowShell.h2
-rw-r--r--Source/WebCore/bindings/js/JSDictionary.cpp24
-rw-r--r--Source/WebCore/bindings/js/JSDictionary.h3
-rw-r--r--Source/WebCore/bindings/js/JSEntryCustom.cpp4
-rw-r--r--Source/WebCore/bindings/js/JSEntrySyncCustom.cpp4
-rw-r--r--Source/WebCore/bindings/js/JSErrorHandler.cpp5
-rw-r--r--Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp3
-rw-r--r--Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp2
-rw-r--r--Source/WebCore/bindings/js/JSHistoryCustom.cpp28
-rw-r--r--Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp22
-rw-r--r--Source/WebCore/bindings/js/JSLocationCustom.cpp28
-rw-r--r--Source/WebCore/bindings/js/JSMainThreadExecState.cpp8
-rw-r--r--Source/WebCore/bindings/js/JSMainThreadExecState.h17
-rw-r--r--Source/WebCore/bindings/js/JSNodeFilterCondition.cpp3
-rw-r--r--Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp11
-rw-r--r--Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp44
-rw-r--r--Source/WebCore/bindings/js/ScriptController.cpp2
-rw-r--r--Source/WebCore/bindings/js/ScriptDebugServer.h2
-rw-r--r--Source/WebCore/bindings/js/ScriptProfiler.cpp6
-rw-r--r--Source/WebCore/bindings/js/ScriptProfiler.h5
-rw-r--r--Source/WebCore/bindings/js/ScriptState.cpp12
-rw-r--r--Source/WebCore/bindings/js/ScriptState.h3
28 files changed, 206 insertions, 128 deletions
diff --git a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
index 23fda48d6..66936ed34 100644
--- a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
+++ b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
@@ -26,13 +26,14 @@
#include "config.h"
#include "JSCSSStyleDeclarationCustom.h"
-#include "CSSMutableStyleDeclaration.h"
+#include "CSSParser.h"
#include "CSSPrimitiveValue.h"
#include "CSSPropertyNames.h"
#include "CSSValue.h"
#include "JSCSSValue.h"
#include "JSNode.h"
#include "PlatformString.h"
+#include "StylePropertySet.h"
#include <runtime/StringPrototype.h>
#include <wtf/ASCIICType.h>
#include <wtf/text/AtomicString.h>
@@ -137,6 +138,23 @@ static PropertyNamePrefix getCSSPropertyNamePrefix(const StringImpl& propertyNam
return PropertyNamePrefixNone;
}
+template<typename CharacterType>
+static inline bool containsASCIIUpperChar(const CharacterType* string, size_t length)
+{
+ for (unsigned i = 0; i < length; ++i) {
+ if (isASCIIUpper(string[i]))
+ return true;
+ }
+ return false;
+}
+
+static inline bool containsASCIIUpperChar(const StringImpl& string)
+{
+ if (string.is8Bit())
+ return containsASCIIUpperChar(string.characters8(), string.length());
+ return containsASCIIUpperChar(string.characters16(), string.length());
+}
+
static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0)
{
if (hadPixelOrPosPrefix)
@@ -146,10 +164,15 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
if (!length)
return String();
+ StringImpl* propertyNameString = propertyName.impl();
+ // If there is no uppercase character in the propertyName, there can
+ // be no prefix, nor extension and we can return the same string.
+ if (!containsASCIIUpperChar(*propertyNameString))
+ return String(propertyNameString);
+
StringBuilder builder;
builder.reserveCapacity(length);
- const StringImpl* propertyNameString = propertyName.impl();
unsigned i = 0;
switch (getCSSPropertyNamePrefix(*propertyNameString)) {
case PropertyNamePrefixNone:
@@ -176,10 +199,10 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
builder.append('-');
}
- builder.append(toASCIILower(propertyName.characters()[i++]));
+ builder.append(toASCIILower((*propertyNameString)[i++]));
for (; i < length; ++i) {
- UChar c = propertyName.characters()[i];
+ UChar c = (*propertyNameString)[i];
if (!isASCIIUpper(c))
builder.append(c);
else
@@ -191,9 +214,7 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
static bool isCSSPropertyName(const Identifier& propertyIdentifier)
{
- // FIXME: This mallocs a string for the property name and then throws it
- // away. This shows up on peacekeeper's domDynamicCreationCreateElement.
- return CSSStyleDeclaration::isPropertyName(cssPropertyName(propertyIdentifier));
+ return cssPropertyID(cssPropertyName(propertyIdentifier));
}
bool JSCSSStyleDeclaration::canGetItemsForName(ExecState*, CSSStyleDeclaration*, const Identifier& propertyName)
@@ -229,7 +250,7 @@ bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, const Identifier& prope
{
bool pixelOrPos;
String prop = cssPropertyName(propertyName, &pixelOrPos);
- if (!CSSStyleDeclaration::isPropertyName(prop))
+ if (!cssPropertyID(prop))
return false;
String propValue = valueToStringWithNullCheck(exec, value);
diff --git a/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp b/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
index 14f51f4bf..bdaf0d553 100644
--- a/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
+++ b/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
@@ -31,6 +31,7 @@
#include "ExceptionCode.h"
#include "Frame.h"
#include "JSDOMWindowCustom.h"
+#include "JSMainThreadExecState.h"
#include "SecurityOrigin.h"
#include <runtime/JSLock.h>
@@ -89,7 +90,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
args.append(jsString(exec, prefix));
m_globalObject->globalData().timeoutChecker.start();
- JSValue retval = JSC::call(exec, function, callType, callData, m_customResolver, args);
+ JSValue retval = JSMainThreadExecState::call(exec, function, callType, callData, m_customResolver, args);
m_globalObject->globalData().timeoutChecker.stop();
String result;
diff --git a/Source/WebCore/bindings/js/JSDOMBinding.cpp b/Source/WebCore/bindings/js/JSDOMBinding.cpp
index ef3efe91a..69cc1b84a 100644
--- a/Source/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/Source/WebCore/bindings/js/JSDOMBinding.cpp
@@ -216,12 +216,12 @@ DOMWindow* firstDOMWindow(ExecState* exec)
return asJSDOMWindow(exec->dynamicGlobalObject())->impl();
}
-bool allowAccessToNode(ExecState* exec, Node* node)
+bool shouldAllowAccessToNode(ExecState* exec, Node* node)
{
- return node && allowAccessToFrame(exec, node->document()->frame());
+ return node && shouldAllowAccessToFrame(exec, node->document()->frame());
}
-bool allowAccessToFrame(ExecState* exec, Frame* frame)
+bool shouldAllowAccessToFrame(ExecState* exec, Frame* frame)
{
if (!frame)
return false;
@@ -229,7 +229,7 @@ bool allowAccessToFrame(ExecState* exec, Frame* frame)
return window && window->allowsAccessFrom(exec);
}
-bool allowAccessToFrame(ExecState* exec, Frame* frame, String& message)
+bool shouldAllowAccessToFrame(ExecState* exec, Frame* frame, String& message)
{
if (!frame)
return false;
diff --git a/Source/WebCore/bindings/js/JSDOMBinding.h b/Source/WebCore/bindings/js/JSDOMBinding.h
index af147e814..7e1af20fc 100644
--- a/Source/WebCore/bindings/js/JSDOMBinding.h
+++ b/Source/WebCore/bindings/js/JSDOMBinding.h
@@ -23,7 +23,6 @@
#define JSDOMBinding_h
#include "CSSImportRule.h"
-#include "CSSMutableStyleDeclaration.h"
#include "CSSStyleSheet.h"
#include "JSDOMGlobalObject.h"
#include "JSDOMWrapper.h"
@@ -31,6 +30,7 @@
#include "Document.h"
#include "Element.h"
#include "MediaList.h"
+#include "StylePropertySet.h"
#include "StyledElement.h"
#include <heap/Weak.h>
#include <runtime/FunctionPrototype.h>
@@ -281,9 +281,9 @@ enum ParameterMissingPolicy {
JSC::JSObject* toJSSequence(JSC::ExecState*, JSC::JSValue, unsigned&);
// FIXME: Implement allowAccessToContext(JSC::ExecState*, ScriptExecutionContext*);
- bool allowAccessToNode(JSC::ExecState*, Node*);
- bool allowAccessToFrame(JSC::ExecState*, Frame*);
- bool allowAccessToFrame(JSC::ExecState*, Frame*, String& message);
+ bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
+ bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*);
+ bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, String& message);
// FIXME: Implement allowAccessToDOMWindow(JSC::ExecState*, DOMWindow*);
// FIXME: Remove these functions in favor of activeContext and
diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 40d896476..baf80d360 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -388,35 +388,17 @@ void JSDOMWindow::getOwnPropertyNames(JSObject* object, ExecState* exec, Propert
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
-void JSDOMWindow::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
-{
- JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
- // Only allow defining getters by frames in the same origin.
- if (!thisObject->allowsAccessFrom(exec))
- return;
-
- // Don't allow shadowing location using defineGetter.
- if (propertyName == "location")
- return;
-
- Base::defineGetter(thisObject, exec, propertyName, getterFunction, attributes);
-}
-
-void JSDOMWindow::defineSetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
-{
- JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
- // Only allow defining setters by frames in the same origin.
- if (!thisObject->allowsAccessFrom(exec))
- return;
- Base::defineSetter(thisObject, exec, propertyName, setterFunction, attributes);
-}
-
bool JSDOMWindow::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
// Only allow defining properties in this way by frames in the same origin, as it allows setters to be introduced.
if (!thisObject->allowsAccessFrom(exec))
return false;
+
+ // Don't allow shadowing location using accessor properties.
+ if (descriptor.isAccessorDescriptor() && propertyName == "location")
+ return false;
+
return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
}
diff --git a/Source/WebCore/bindings/js/JSDOMWindowShell.cpp b/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
index 03bcd4292..45506e6e4 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
@@ -139,18 +139,6 @@ void JSDOMWindowShell::getOwnPropertyNames(JSObject* object, ExecState* exec, Pr
thisObject->window()->methodTable()->getOwnPropertyNames(thisObject->window(), exec, propertyNames, mode);
}
-void JSDOMWindowShell::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
-{
- JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
- thisObject->window()->methodTable()->defineGetter(thisObject->window(), exec, propertyName, getterFunction, attributes);
-}
-
-void JSDOMWindowShell::defineSetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
-{
- JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
- thisObject->window()->methodTable()->defineSetter(thisObject->window(), exec, propertyName, setterFunction, attributes);
-}
-
// ----
// JSDOMWindow methods
diff --git a/Source/WebCore/bindings/js/JSDOMWindowShell.h b/Source/WebCore/bindings/js/JSDOMWindowShell.h
index 1e179edf4..e111cb84d 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowShell.h
+++ b/Source/WebCore/bindings/js/JSDOMWindowShell.h
@@ -86,8 +86,6 @@ namespace WebCore {
static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName);
static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
- static void defineGetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);
- static void defineSetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);
static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);
RefPtr<DOMWrapperWorld> m_world;
diff --git a/Source/WebCore/bindings/js/JSDictionary.cpp b/Source/WebCore/bindings/js/JSDictionary.cpp
index da24d82fe..bd06216cf 100644
--- a/Source/WebCore/bindings/js/JSDictionary.cpp
+++ b/Source/WebCore/bindings/js/JSDictionary.cpp
@@ -34,7 +34,9 @@
#include "JSTrackCustom.h"
#include "SerializedScriptValue.h"
#include "ScriptValue.h"
+#include <wtf/HashMap.h>
#include <wtf/MathExtras.h>
+#include <wtf/text/AtomicString.h>
using namespace JSC;
@@ -136,4 +138,26 @@ void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<TrackBase>& re
}
#endif
+#if ENABLE(MUTATION_OBSERVERS)
+void JSDictionary::convertValue(ExecState* exec, JSValue value, HashSet<AtomicString>& result)
+{
+ result.clear();
+
+ if (value.isUndefinedOrNull())
+ return;
+
+ unsigned length;
+ JSObject* object = toJSSequence(exec, value, length);
+ if (exec->hadException())
+ return;
+
+ for (unsigned i = 0 ; i < length; ++i) {
+ JSValue itemValue = object->get(exec, i);
+ if (exec->hadException())
+ return;
+ result.add(ustringToAtomicString(itemValue.toString(exec)->value(exec)));
+ }
+}
+#endif
+
} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDictionary.h b/Source/WebCore/bindings/js/JSDictionary.h
index c5a48a259..fb8ea003a 100644
--- a/Source/WebCore/bindings/js/JSDictionary.h
+++ b/Source/WebCore/bindings/js/JSDictionary.h
@@ -87,6 +87,9 @@ private:
#if ENABLE(VIDEO_TRACK)
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result);
#endif
+#if ENABLE(MUTATION_OBSERVERS)
+ static void convertValue(JSC::ExecState*, JSC::JSValue, HashSet<AtomicString>& result);
+#endif
JSC::ExecState* m_exec;
JSC::JSObject* m_initializerObject;
diff --git a/Source/WebCore/bindings/js/JSEntryCustom.cpp b/Source/WebCore/bindings/js/JSEntryCustom.cpp
index 59d7e3c1a..2552e05db 100644
--- a/Source/WebCore/bindings/js/JSEntryCustom.cpp
+++ b/Source/WebCore/bindings/js/JSEntryCustom.cpp
@@ -50,10 +50,10 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Entry* entry)
return jsNull();
if (entry->isFile())
- return getDOMObjectWrapper<JSFileEntry>(exec, globalObject, static_cast<FileEntry*>(entry));
+ return wrap<JSFileEntry>(exec, globalObject, static_cast<FileEntry*>(entry));
ASSERT(entry->isDirectory());
- return getDOMObjectWrapper<JSDirectoryEntry>(exec, globalObject, static_cast<DirectoryEntry*>(entry));
+ return wrap<JSDirectoryEntry>(exec, globalObject, static_cast<DirectoryEntry*>(entry));
}
} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSEntrySyncCustom.cpp b/Source/WebCore/bindings/js/JSEntrySyncCustom.cpp
index 22f96ad87..7ad57c4e6 100644
--- a/Source/WebCore/bindings/js/JSEntrySyncCustom.cpp
+++ b/Source/WebCore/bindings/js/JSEntrySyncCustom.cpp
@@ -50,10 +50,10 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EntrySync* entry)
return jsNull();
if (entry->isFile())
- return getDOMObjectWrapper<JSFileEntrySync>(exec, globalObject, static_cast<FileEntrySync*>(entry));
+ return wrap<JSFileEntrySync>(exec, globalObject, static_cast<FileEntrySync*>(entry));
ASSERT(entry->isDirectory());
- return getDOMObjectWrapper<JSDirectoryEntrySync>(exec, globalObject, static_cast<DirectoryEntrySync*>(entry));
+ return wrap<JSDirectoryEntrySync>(exec, globalObject, static_cast<DirectoryEntrySync*>(entry));
}
} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSErrorHandler.cpp b/Source/WebCore/bindings/js/JSErrorHandler.cpp
index 59b3ff37c..e292d2930 100644
--- a/Source/WebCore/bindings/js/JSErrorHandler.cpp
+++ b/Source/WebCore/bindings/js/JSErrorHandler.cpp
@@ -36,6 +36,7 @@
#include "Event.h"
#include "EventNames.h"
#include "JSEvent.h"
+#include "JSMainThreadExecState.h"
#include <runtime/JSLock.h>
using namespace JSC;
@@ -94,7 +95,9 @@ void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext,
JSValue thisValue = globalObject->methodTable()->toThisObject(globalObject, exec);
globalData.timeoutChecker.start();
- JSValue returnValue = JSC::call(exec, jsFunction, callType, callData, thisValue, args);
+ JSValue returnValue = scriptExecutionContext->isDocument()
+ ? JSMainThreadExecState::call(exec, jsFunction, callType, callData, thisValue, args)
+ : JSC::call(exec, jsFunction, callType, callData, thisValue, args);
globalData.timeoutChecker.stop();
globalObject->setCurrentEvent(savedEvent);
diff --git a/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
index 623973a7f..e64e24381 100644
--- a/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
+++ b/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
@@ -38,6 +38,7 @@
#include "JSDOMWindowCustom.h"
#include "JSDOMWindowShell.h"
#include "JSHTMLCollection.h"
+#include "JSMainThreadExecState.h"
#include "SegmentedString.h"
#include "DocumentParser.h"
#include <runtime/Error.h>
@@ -113,7 +114,7 @@ JSValue JSHTMLDocument::open(ExecState* exec)
CallType callType = ::getCallData(function, callData);
if (callType == CallTypeNone)
return throwTypeError(exec);
- return JSC::call(exec, function, callType, callData, wrapper, ArgList(exec));
+ return JSMainThreadExecState::call(exec, function, callType, callData, wrapper, ArgList(exec));
}
}
return jsUndefined();
diff --git a/Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
index c6cc2488b..7f00ebcde 100644
--- a/Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
+++ b/Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
@@ -45,7 +45,7 @@ static inline bool allowSettingJavascriptURL(ExecState* exec, HTMLFrameElement*
{
if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value))) {
Document* contentDocument = imp->contentDocument();
- if (contentDocument && !allowAccessToNode(exec, contentDocument))
+ if (contentDocument && !shouldAllowAccessToNode(exec, contentDocument))
return false;
}
return true;
diff --git a/Source/WebCore/bindings/js/JSHistoryCustom.cpp b/Source/WebCore/bindings/js/JSHistoryCustom.cpp
index 72ea5424c..480658b51 100644
--- a/Source/WebCore/bindings/js/JSHistoryCustom.cpp
+++ b/Source/WebCore/bindings/js/JSHistoryCustom.cpp
@@ -61,7 +61,7 @@ bool JSHistory::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& pr
// Our custom code is only needed to implement the Window cross-domain scheme, so if access is
// allowed, return false so the normal lookup will take place.
String message;
- if (allowAccessToFrame(exec, impl()->frame(), message))
+ if (shouldAllowAccessToFrame(exec, impl()->frame(), message))
return false;
// Check for the few functions that we allow, even when called cross-domain.
@@ -101,7 +101,7 @@ bool JSHistory::getOwnPropertyDescriptorDelegate(ExecState* exec, const Identifi
}
// Throw out all cross domain access
- if (!allowAccessToFrame(exec, impl()->frame()))
+ if (!shouldAllowAccessToFrame(exec, impl()->frame()))
return true;
// Check for the few functions that we allow, even when called cross-domain.
@@ -141,7 +141,7 @@ bool JSHistory::getOwnPropertyDescriptorDelegate(ExecState* exec, const Identifi
bool JSHistory::putDelegate(ExecState* exec, const Identifier&, JSValue, PutPropertySlot&)
{
// Only allow putting by frames in the same origin.
- if (!allowAccessToFrame(exec, impl()->frame()))
+ if (!shouldAllowAccessToFrame(exec, impl()->frame()))
return true;
return false;
}
@@ -150,7 +150,7 @@ bool JSHistory::deleteProperty(JSCell* cell, ExecState* exec, const Identifier&
{
JSHistory* thisObject = jsCast<JSHistory*>(cell);
// Only allow deleting by frames in the same origin.
- if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
return false;
return Base::deleteProperty(thisObject, exec, propertyName);
}
@@ -159,11 +159,25 @@ void JSHistory::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyN
{
JSHistory* thisObject = jsCast<JSHistory*>(object);
// Only allow the history object to enumerated by frames in the same origin.
- if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
return;
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
+JSValue JSHistory::state(ExecState *exec) const
+{
+ History* history = static_cast<History*>(impl());
+
+ JSValue cachedValue = m_state.get();
+ if (!cachedValue.isEmpty() && !history->stateChanged())
+ return cachedValue;
+
+ SerializedScriptValue* serialized = history->state();
+ JSValue result = serialized ? serialized->deserialize(exec, globalObject(), 0) : jsNull();
+ const_cast<JSHistory*>(this)->m_state.set(exec->globalData(), this, result);
+ return result;
+}
+
JSValue JSHistory::pushState(ExecState* exec)
{
RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(exec, exec->argument(0), 0);
@@ -185,6 +199,8 @@ JSValue JSHistory::pushState(ExecState* exec)
impl()->stateObjectAdded(historyState.release(), title, url, History::StateObjectPush, ec);
setDOMException(exec, ec);
+ m_state.clear();
+
return jsUndefined();
}
@@ -209,6 +225,8 @@ JSValue JSHistory::replaceState(ExecState* exec)
impl()->stateObjectAdded(historyState.release(), title, url, History::StateObjectReplace, ec);
setDOMException(exec, ec);
+ m_state.clear();
+
return jsUndefined();
}
diff --git a/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index 0320c1834..73cb2fa7e 100644
--- a/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -76,28 +76,6 @@ ScriptValue InjectedScriptHost::nodeAsScriptValue(ScriptState* state, Node* node
return ScriptValue(state->globalData(), toJS(state, deprecatedGlobalObjectForPrototype(state), node));
}
-JSValue JSInjectedScriptHost::evaluate(ExecState* exec)
-{
- JSValue expression = exec->argument(0);
- if (!expression.isString())
- return throwError(exec, createError(exec, "String argument expected."));
- JSGlobalObject* globalObject = exec->lexicalGlobalObject();
- JSFunction* evalFunction = globalObject->evalFunction();
- CallData callData;
- CallType callType = evalFunction->methodTable()->getCallData(evalFunction, callData);
- if (callType == CallTypeNone)
- return jsUndefined();
- MarkedArgumentBuffer args;
- args.append(expression);
-
- bool wasEvalEnabled = globalObject->evalEnabled();
- globalObject->setEvalEnabled(true);
- JSValue result = JSC::call(exec, evalFunction, callType, callData, exec->globalThisValue(), args);
- globalObject->setEvalEnabled(wasEvalEnabled);
-
- return result;
-}
-
JSValue JSInjectedScriptHost::inspectedNode(ExecState* exec)
{
if (exec->argumentCount() < 1)
diff --git a/Source/WebCore/bindings/js/JSLocationCustom.cpp b/Source/WebCore/bindings/js/JSLocationCustom.cpp
index 4bbd56e1a..7786a988d 100644
--- a/Source/WebCore/bindings/js/JSLocationCustom.cpp
+++ b/Source/WebCore/bindings/js/JSLocationCustom.cpp
@@ -59,7 +59,7 @@ bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& p
// Our custom code is only needed to implement the Window cross-domain scheme, so if access is
// allowed, return false so the normal lookup will take place.
String message;
- if (allowAccessToFrame(exec, frame, message))
+ if (shouldAllowAccessToFrame(exec, frame, message))
return false;
// Check for the few functions that we allow, even when called cross-domain.
@@ -95,7 +95,7 @@ bool JSLocation::getOwnPropertyDescriptorDelegate(ExecState* exec, const Identif
}
// throw out all cross domain access
- if (!allowAccessToFrame(exec, frame))
+ if (!shouldAllowAccessToFrame(exec, frame))
return true;
// Check for the few functions that we allow, even when called cross-domain.
@@ -134,7 +134,7 @@ bool JSLocation::putDelegate(ExecState* exec, const Identifier& propertyName, JS
if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
return true;
- bool sameDomainAccess = allowAccessToFrame(exec, frame);
+ bool sameDomainAccess = shouldAllowAccessToFrame(exec, frame);
const HashEntry* entry = JSLocation::s_info.propHashTable(exec)->entry(exec, propertyName);
if (!entry) {
@@ -156,7 +156,7 @@ bool JSLocation::deleteProperty(JSCell* cell, ExecState* exec, const Identifier&
{
JSLocation* thisObject = jsCast<JSLocation*>(cell);
// Only allow deleting by frames in the same origin.
- if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
return false;
return Base::deleteProperty(thisObject, exec, propertyName);
}
@@ -165,16 +165,16 @@ void JSLocation::getOwnPropertyNames(JSObject* object, ExecState* exec, Property
{
JSLocation* thisObject = jsCast<JSLocation*>(object);
// Only allow the location object to enumerated by frames in the same origin.
- if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
return;
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
-void JSLocation::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
+bool JSLocation::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
{
- if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
- return;
- Base::defineGetter(object, exec, propertyName, getterFunction, attributes);
+ if (descriptor.isAccessorDescriptor() && (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf))
+ return false;
+ return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
void JSLocation::setHref(ExecState* exec, JSValue value)
@@ -270,7 +270,7 @@ JSValue JSLocation::assign(ExecState* exec)
JSValue JSLocation::toStringFunction(ExecState* exec)
{
Frame* frame = impl()->frame();
- if (!frame || !allowAccessToFrame(exec, frame))
+ if (!frame || !shouldAllowAccessToFrame(exec, frame))
return jsUndefined();
return jsString(exec, impl()->toString());
@@ -281,11 +281,11 @@ bool JSLocationPrototype::putDelegate(ExecState* exec, const Identifier& propert
return (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf);
}
-void JSLocationPrototype::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
+bool JSLocationPrototype::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
{
- if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
- return;
- Base::defineGetter(object, exec, propertyName, getterFunction, attributes);
+ if (descriptor.isAccessorDescriptor() && (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf))
+ return false;
+ return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSMainThreadExecState.cpp b/Source/WebCore/bindings/js/JSMainThreadExecState.cpp
index d679a5899..9177a4b10 100644
--- a/Source/WebCore/bindings/js/JSMainThreadExecState.cpp
+++ b/Source/WebCore/bindings/js/JSMainThreadExecState.cpp
@@ -25,9 +25,17 @@
#include "config.h"
#include "JSMainThreadExecState.h"
+#include "WebKitMutationObserver.h"
namespace WebCore {
JSC::ExecState* JSMainThreadExecState::s_mainThreadState = 0;
+#if ENABLE(MUTATION_OBSERVERS)
+void JSMainThreadExecState::didLeaveScriptContext()
+{
+ WebKitMutationObserver::deliverAllMutations();
+}
+#endif
+
} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSMainThreadExecState.h b/Source/WebCore/bindings/js/JSMainThreadExecState.h
index 55b820324..5e4c4e2dc 100644
--- a/Source/WebCore/bindings/js/JSMainThreadExecState.h
+++ b/Source/WebCore/bindings/js/JSMainThreadExecState.h
@@ -92,19 +92,34 @@ protected:
ASSERT(isMainThread());
s_mainThreadState = exec;
};
-
+
~JSMainThreadExecState()
{
ASSERT(isMainThread());
+
+#if ENABLE(MUTATION_OBSERVERS)
+ bool didExitJavaScript = s_mainThreadState && !m_previousState;
+#endif
+
s_mainThreadState = m_previousState;
+
+#if ENABLE(MUTATION_OBSERVERS)
+ if (didExitJavaScript)
+ didLeaveScriptContext();
+#endif
}
private:
static JSC::ExecState* s_mainThreadState;
JSC::ExecState* m_previousState;
+
+#if ENABLE(MUTATION_OBSERVERS)
+ static void didLeaveScriptContext();
+#endif
};
// Null state prevents origin security checks.
+// Used by non-JavaScript bindings (ObjC, GObject).
class JSMainThreadNullState : private JSMainThreadExecState {
public:
explicit JSMainThreadNullState() : JSMainThreadExecState(0) {};
diff --git a/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp b/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp
index 9d5df0421..91b9156a4 100644
--- a/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp
+++ b/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp
@@ -20,6 +20,7 @@
#include "config.h"
#include "JSNodeFilterCondition.h"
+#include "JSMainThreadExecState.h"
#include "JSNode.h"
#include "JSNodeFilter.h"
#include "NodeFilter.h"
@@ -72,7 +73,7 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode)
if (exec->hadException())
return NodeFilter::FILTER_REJECT;
- JSValue result = JSC::call(exec, function, callType, callData, m_filter.get(), args);
+ JSValue result = JSMainThreadExecState::call(exec, function, callType, callData, m_filter.get(), args);
if (exec->hadException())
return NodeFilter::FILTER_REJECT;
diff --git a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
index b4f566239..0bfa63afb 100644
--- a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
+++ b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
@@ -40,8 +40,10 @@
#include "JSOESStandardDerivatives.h"
#include "JSOESTextureFloat.h"
#include "JSOESVertexArrayObject.h"
+#include "JSUint32Array.h"
#include "JSUint8Array.h"
#include "JSWebGLBuffer.h"
+#include "JSWebGLCompressedTextureS3TC.h"
#include "JSWebGLFramebuffer.h"
#include "JSWebGLLoseContext.h"
#include "JSWebGLProgram.h"
@@ -56,7 +58,7 @@
#include "OESTextureFloat.h"
#include "OESVertexArrayObject.h"
#include "WebGLBuffer.h"
-#include "WebGLCompressedTextures.h"
+#include "WebGLCompressedTextureS3TC.h"
#include "WebGLDebugRendererInfo.h"
#include "WebGLDebugShaders.h"
#include "WebGLExtension.h"
@@ -71,6 +73,7 @@
#include <wtf/FastMalloc.h>
#include <wtf/Float32Array.h>
#include <wtf/Int32Array.h>
+#include <wtf/Uint32Array.h>
#if ENABLE(VIDEO)
#include "HTMLVideoElement.h"
@@ -121,6 +124,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebG
return toJS(exec, globalObject, info.getWebGLTexture());
case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
return toJS(exec, globalObject, info.getWebGLUnsignedByteArray());
+ case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
+ return toJS(exec, globalObject, info.getWebGLUnsignedIntArray());
case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
default:
@@ -193,8 +198,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten
return toJS(exec, globalObject, static_cast<WebGLDebugRendererInfo*>(extension));
case WebGLExtension::WebGLDebugShadersName:
return toJS(exec, globalObject, static_cast<WebGLDebugShaders*>(extension));
- case WebGLExtension::WebKitWebGLCompressedTexturesName:
- return toJS(exec, globalObject, static_cast<WebGLCompressedTextures*>(extension));
+ case WebGLExtension::WebKitWebGLCompressedTextureS3TCName:
+ return toJS(exec, globalObject, static_cast<WebGLCompressedTextureS3TC*>(extension));
}
ASSERT_NOT_REACHED();
return jsNull();
diff --git a/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp b/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp
index 38c39e422..455f4d4e0 100644
--- a/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp
+++ b/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp
@@ -41,6 +41,8 @@
#include "Node.h"
#include "WebKitMutationObserver.h"
#include <runtime/Error.h>
+#include <wtf/HashSet.h>
+#include <wtf/text/AtomicString.h>
using namespace JSC;
@@ -62,6 +64,22 @@ EncodedJSValue JSC_HOST_CALL JSWebKitMutationObserverConstructor::constructJSWeb
return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), WebKitMutationObserver::create(callback.release()))));
}
+struct BooleanOption {
+ const char* name;
+ MutationObserverOptions value;
+};
+
+static const BooleanOption booleanOptions[] = {
+ { "childList", WebKitMutationObserver::ChildList },
+ { "attributes", WebKitMutationObserver::Attributes },
+ { "characterData", WebKitMutationObserver::CharacterData },
+ { "subtree", WebKitMutationObserver::Subtree },
+ { "attributeOldValue", WebKitMutationObserver::AttributeOldValue },
+ { "characterDataOldValue", WebKitMutationObserver::CharacterDataOldValue }
+};
+
+static const size_t numBooleanOptions = sizeof(booleanOptions) / sizeof(BooleanOption);
+
JSValue JSWebKitMutationObserver::observe(ExecState* exec)
{
if (exec->argumentCount() < 2)
@@ -78,24 +96,22 @@ JSValue JSWebKitMutationObserver::observe(ExecState* exec)
JSDictionary dictionary(exec, optionsObject);
MutationObserverOptions options = 0;
- // FIXME: Add support for parsing of the attributeFilter option.
- bool option;
- if (dictionary.tryGetProperty("childList", option) && option)
- options |= WebKitMutationObserver::ChildList;
- if (dictionary.tryGetProperty("attributes", option) && option)
- options |= WebKitMutationObserver::Attributes;
- if (dictionary.tryGetProperty("subtree", option) && option)
- options |= WebKitMutationObserver::Subtree;
- if (dictionary.tryGetProperty("attributeOldValue", option) && option)
- options |= WebKitMutationObserver::AttributeOldValue;
- if (dictionary.tryGetProperty("characterDataOldValue", option) && option)
- options |= WebKitMutationObserver::CharacterDataOldValue;
+ for (unsigned i = 0; i < numBooleanOptions; ++i) {
+ bool option = false;
+ if (!dictionary.tryGetProperty(booleanOptions[i].name, option))
+ return jsUndefined();
+ if (option)
+ options |= booleanOptions[i].value;
+ }
- if (exec->hadException())
+ HashSet<AtomicString> attributeFilter;
+ if (!dictionary.tryGetProperty("attributeFilter", attributeFilter))
return jsUndefined();
+ if (!attributeFilter.isEmpty())
+ options |= WebKitMutationObserver::AttributeFilter;
ExceptionCode ec = 0;
- impl()->observe(target, options, ec);
+ impl()->observe(target, options, attributeFilter, ec);
if (ec)
setDOMException(exec, ec);
return jsUndefined();
diff --git a/Source/WebCore/bindings/js/ScriptController.cpp b/Source/WebCore/bindings/js/ScriptController.cpp
index c1072f861..4143f44b5 100644
--- a/Source/WebCore/bindings/js/ScriptController.cpp
+++ b/Source/WebCore/bindings/js/ScriptController.cpp
@@ -247,7 +247,7 @@ bool ScriptController::canAccessFromCurrentOrigin(Frame *frame)
{
ExecState* exec = JSMainThreadExecState::currentState();
if (exec)
- return allowAccessToFrame(exec, frame);
+ return shouldAllowAccessToFrame(exec, frame);
// If the current state is 0 we're in a call path where the DOM security
// check doesn't apply (eg. parser).
return true;
diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.h b/Source/WebCore/bindings/js/ScriptDebugServer.h
index 2494c2075..3f7bd4f64 100644
--- a/Source/WebCore/bindings/js/ScriptDebugServer.h
+++ b/Source/WebCore/bindings/js/ScriptDebugServer.h
@@ -90,6 +90,8 @@ public:
void recompileAllJSFunctionsSoon();
virtual void recompileAllJSFunctions(Timer<ScriptDebugServer>* = 0) = 0;
+ bool isPaused() { return m_paused; }
+
protected:
typedef HashSet<ScriptDebugListener*> ListenerSet;
typedef void (ScriptDebugServer::*JavaScriptExecutionCallback)(ScriptDebugListener*);
diff --git a/Source/WebCore/bindings/js/ScriptProfiler.cpp b/Source/WebCore/bindings/js/ScriptProfiler.cpp
index 4c84fb971..a63fe4d9e 100644
--- a/Source/WebCore/bindings/js/ScriptProfiler.cpp
+++ b/Source/WebCore/bindings/js/ScriptProfiler.cpp
@@ -31,8 +31,8 @@
#include "ScriptProfiler.h"
#include "GCController.h"
-#include "InspectorValues.h"
#include "JSDOMBinding.h"
+#include "ScriptObject.h"
#include <profiler/Profiler.h>
namespace WebCore {
@@ -42,9 +42,9 @@ void ScriptProfiler::collectGarbage()
gcController().garbageCollectNow();
}
-PassRefPtr<InspectorValue> ScriptProfiler::objectByHeapObjectId(unsigned, InjectedScriptManager*)
+ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned)
{
- return InspectorValue::null();
+ return ScriptObject();
}
void ScriptProfiler::start(ScriptState* state, const String& title)
diff --git a/Source/WebCore/bindings/js/ScriptProfiler.h b/Source/WebCore/bindings/js/ScriptProfiler.h
index 2211971a8..a21eada4c 100644
--- a/Source/WebCore/bindings/js/ScriptProfiler.h
+++ b/Source/WebCore/bindings/js/ScriptProfiler.h
@@ -28,7 +28,6 @@
#define ScriptProfiler_h
#if ENABLE(JAVASCRIPT_DEBUGGER)
-#include "InspectorValues.h"
#include "ScriptHeapSnapshot.h"
#include "ScriptProfile.h"
#include "ScriptState.h"
@@ -38,7 +37,7 @@
namespace WebCore {
class DOMWrapperVisitor;
-class InjectedScriptManager;
+class ScriptObject;
class ScriptProfiler {
WTF_MAKE_NONCOPYABLE(ScriptProfiler);
@@ -53,7 +52,7 @@ public:
};
static void collectGarbage();
- static PassRefPtr<InspectorValue> objectByHeapObjectId(unsigned id, InjectedScriptManager*);
+ static ScriptObject objectByHeapObjectId(unsigned id);
static void start(ScriptState* state, const String& title);
static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String&, HeapSnapshotProgress*) { return 0; }
diff --git a/Source/WebCore/bindings/js/ScriptState.cpp b/Source/WebCore/bindings/js/ScriptState.cpp
index c7cd9299a..e823c6e3a 100644
--- a/Source/WebCore/bindings/js/ScriptState.cpp
+++ b/Source/WebCore/bindings/js/ScriptState.cpp
@@ -71,6 +71,18 @@ DOMWindow* domWindowFromScriptState(ScriptState* scriptState)
return static_cast<JSDOMWindowBase*>(globalObject)->impl();
}
+bool evalEnabled(ScriptState* scriptState)
+{
+ JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
+ return globalObject->evalEnabled();
+}
+
+void setEvalEnabled(ScriptState* scriptState, bool enabled)
+{
+ JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
+ return globalObject->setEvalEnabled(enabled);
+}
+
ScriptState* mainWorldScriptState(Frame* frame)
{
JSDOMWindowShell* shell = frame->script()->windowShell(mainThreadNormalWorld());
diff --git a/Source/WebCore/bindings/js/ScriptState.h b/Source/WebCore/bindings/js/ScriptState.h
index 4311c7460..58f36f599 100644
--- a/Source/WebCore/bindings/js/ScriptState.h
+++ b/Source/WebCore/bindings/js/ScriptState.h
@@ -66,6 +66,9 @@ private:
DOMWindow* domWindowFromScriptState(ScriptState*);
+bool evalEnabled(ScriptState*);
+void setEvalEnabled(ScriptState*, bool);
+
ScriptState* mainWorldScriptState(Frame*);
ScriptState* scriptStateFromNode(DOMWrapperWorld*, Node*);