Add JSC support for delivering mutations when the outermost script context exits
authoradamk@chromium.org <adamk@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 00:40:31 +0000 (00:40 +0000)
committeradamk@chromium.org <adamk@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 00:40:31 +0000 (00:40 +0000)
commit82abc774b5f1a39909e8f9e97ff262967e83cf5a
tree2f4be54c759c50e46add50ab384925dbb49ddf19
parente1df2ad748d733d79436de41ff3e5e1bab4335fd
Add JSC support for delivering mutations when the outermost script context exits
https://bugs.webkit.org/show_bug.cgi?id=70289

Reviewed by Eric Seidel.

Source/WebCore:

The meat of this change is in JSMainThreadExecState, where a counter
is incremented every time WebCore calls into JSC and decremented every
time it returns. When the counter reaches zero, any pending mutations
are delivered (this mirrors very similar code in V8Proxy and V8RecursionScope).

The rest of the changes are of two sorts: compilation/logic fixes for
JSC code when ENABLE(MUTATION_OBSERVERS) is true, and additional
usages of JSMainThreadExecState so as to trigger the above
increment/decrements at the appropriate times.

* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
Use JSMainThreadExecState instead of JSC::call.
* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue): Add support
for tryGetProperty with a HashMap<AtomicString>.
* bindings/js/JSDictionary.h:
* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
Use JSMainThreadExecState instead of JSC::call.
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::open):
Use JSMainThreadExecState instead of JSC::call.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::JSMainThreadExecState):
Increment a static recursion level counter.
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
Decrement a static recursion level counter and, if we are
at zero (the outermost script invocation), deliver any
outstanding mutation records.
* bindings/js/JSNodeFilterCondition.cpp:
(WebCore::JSNodeFilterCondition::acceptNode):
Use JSMainThreadExecState instead of JSC::call.
* bindings/js/JSWebKitMutationObserverCustom.cpp:
(WebCore::JSWebKitMutationObserver::observe):
Fix JSDictionary logic, add support for attributeFilter.

Tools:

* DumpRenderTree/mac/EventSendingController.mm: Add support for
eventSender.scheduleAsynchronousKeyDown.
(+[EventSendingController isSelectorExcludedFromWebScript:]):
(+[EventSendingController webScriptNameForSelector:]):
(-[EventSendingController keyDownWrapper:withModifiers:withLocation:]):
(-[EventSendingController scheduleAsynchronousKeyDown:withModifiers:withLocation:]):
* Scripts/build-webkit: Properly alphabetize --mutation-observers in the --help output.

LayoutTests:

With the various fixes in this change, 8/10 tests in fast/mutation
pass under WebKit/Mac. Of the failing tests, only one is due to
a deficiency in the Mac port's code (end-of-task-delivery.html);
the other is due to lack of support for a feature (FILE_SYSTEM)
exercised by the test (non-event-delivery.html).

* fast/mutation/non-event-delivery.html: Made it fail fast if FileSystem support isn't available.
* fast/mutation/observe-attributes.html: Fixed calls to removeEventListener.
* fast/mutation/observe-characterdata.html: ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mutation/non-event-delivery.html
LayoutTests/fast/mutation/observe-attributes.html
LayoutTests/fast/mutation/observe-characterdata.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSDictionary.cpp
Source/WebCore/bindings/js/JSDictionary.h
Source/WebCore/bindings/js/JSErrorHandler.cpp
Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
Source/WebCore/bindings/js/JSMainThreadExecState.cpp
Source/WebCore/bindings/js/JSMainThreadExecState.h
Source/WebCore/bindings/js/JSNodeFilterCondition.cpp
Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/EventSendingController.mm
Tools/Scripts/build-webkit