+2012-02-08 Adam Klein <adamk@chromium.org>
+
+ Simplify and correct mutation delivery timing for JSC
+ https://bugs.webkit.org/show_bug.cgi?id=78172
+
+ Reviewed by Adam Barth.
+
+ Instead of keeping a static recursion counter in JSMainThreadExecState,
+ simply wait for a state change from non-null ExecState to null ExecState.
+ Because s_mainThreadState is initially null, this equivalent to
+ waiting for s_recursionLevel to rewind to zero.
+
+ This also properly handles the usage of JSMainThreadNullState (and
+ does not do mutation delivery), since that class is only used by
+ non-JS bindings. Now fast/mutation/end-of-task-delivery.html properly
+ fails, whereas it was passing before due to usage of the ObjC DOM API
+ from DumpRenderTree.
+
+ * bindings/js/JSMainThreadExecState.cpp:
+ (WebCore):
+ * bindings/js/JSMainThreadExecState.h: Added a comment explaining the purpose of JSMainThreadNullState.
+ (WebCore::JSMainThreadExecState::JSMainThreadExecState):
+ (WebCore::JSMainThreadExecState::~JSMainThreadExecState):
+ (JSMainThreadExecState):
+ (WebCore):
+
2012-02-08 Kentaro Hara <haraken@chromium.org>
Remove [ConvertToString] from CodeGeneratorCPP.pm and rename
JSC::ExecState* JSMainThreadExecState::s_mainThreadState = 0;
#if ENABLE(MUTATION_OBSERVERS)
-int JSMainThreadExecState::s_recursionLevel = 0;
-
void JSMainThreadExecState::didLeaveScriptContext()
{
WebKitMutationObserver::deliverAllMutations();
{
ASSERT(isMainThread());
s_mainThreadState = exec;
-
-#if ENABLE(MUTATION_OBSERVERS)
- ASSERT(s_recursionLevel >= 0);
- ++s_recursionLevel;
-#endif
};
~JSMainThreadExecState()
{
ASSERT(isMainThread());
+
+#if ENABLE(MUTATION_OBSERVERS)
+ bool didExitJavaScript = s_mainThreadState && !m_previousState;
+#endif
+
s_mainThreadState = m_previousState;
#if ENABLE(MUTATION_OBSERVERS)
- ASSERT(s_recursionLevel > 0);
- if (!--s_recursionLevel)
+ if (didExitJavaScript)
didLeaveScriptContext();
#endif
}
#if ENABLE(MUTATION_OBSERVERS)
static void didLeaveScriptContext();
- static int s_recursionLevel;
#endif
};
// Null state prevents origin security checks.
+// Used by non-JavaScript bindings (ObjC, GObject).
class JSMainThreadNullState : private JSMainThreadExecState {
public:
explicit JSMainThreadNullState() : JSMainThreadExecState(0) {};