Fix for 128110
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Feb 2014 01:02:23 +0000 (01:02 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Feb 2014 01:02:23 +0000 (01:02 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163346 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/replay/EmptyInputCursor.h [new file with mode: 0644]
Source/JavaScriptCore/replay/InputCursor.h [new file with mode: 0644]
Source/JavaScriptCore/replay/NondeterministicInput.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/replay/EmptyInputCursor.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/replay/InputCursor.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/replay/NondeterministicInput.h [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/replay/EventLoopInput.h [new file with mode: 0644]

index c04220e..2c2b2c8 100644 (file)
@@ -1,3 +1,43 @@
+2014-02-03  Brian Burg  <bburg@apple.com>
+
+        Web Replay: upstream base input classes and the input cursor interface
+        https://bugs.webkit.org/show_bug.cgi?id=128110
+
+        Reviewed by Joseph Pecoraro.
+
+        Add the base class for all replay inputs. Add InputTraits, a trait that
+        provides an input's queue, type, and encode/decode methods statically so
+        that they can be used within templated helper functions in InputCursor and
+        EncodedValue.
+
+        Add the InputCursor base class which mediates the saving and fetching of
+        replay inputs from a replay recording by instrumented nondeterministic code.
+
+        Add a dummy cursor implementation. This allows us to return a cursor reference
+        to clients even if no capturing or replaying is happening.
+
+        Add the ability to set an InputCursor instance on a JSGlobalObject. This
+        is the means for connecting a replay recording to a script context.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * replay/EmptyInputCursor.h: Added.
+        (JSC::EmptyInputCursor::~EmptyInputCursor):
+        (JSC::EmptyInputCursor::create):
+        (JSC::EmptyInputCursor::EmptyInputCursor):
+        * replay/InputCursor.h: Added.
+        (JSC::InputCursor::InputCursor):
+        (JSC::InputCursor::~InputCursor):
+        (JSC::InputCursor::appendInput):
+        (JSC::InputCursor::fetchInput):
+        * replay/NondeterministicInput.h: Added.
+        (JSC::NondeterministicInputBase::NondeterministicInputBase):
+        (JSC::NondeterministicInputBase::~NondeterministicInputBase):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::JSGlobalObject):
+        (JSC::JSGlobalObject::setInputCursor):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::inputCursor):
+
 2014-02-03  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Fix the cloop due to GenGC
index 81bd32f..d996308 100644 (file)
                969A079B0ED1D3AE00F1F681 /* Opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 969A07950ED1D3AE00F1F681 /* Opcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                978801401471AD920041B016 /* JSDateMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9788FC221471AD0C0068CE2D /* JSDateMath.cpp */; };
                978801411471AD920041B016 /* JSDateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9788FC231471AD0C0068CE2D /* JSDateMath.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               99E45A1018A01F350026D88F /* EmptyInputCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E45A0D18A01F350026D88F /* EmptyInputCursor.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               99E45A1118A01F350026D88F /* InputCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E45A0E18A01F350026D88F /* InputCursor.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               99E45A1218A01F350026D88F /* NondeterministicInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E45A0F18A01F350026D88F /* NondeterministicInput.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1712B3B11C7B212007A5315 /* RegExpCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1712B3A11C7B212007A5315 /* RegExpCache.cpp */; };
                A1712B3F11C7B228007A5315 /* RegExpCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B3E11C7B228007A5315 /* RegExpCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B4011C7B235007A5315 /* RegExpKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
                969A09220ED1E09C00F1F681 /* Completion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Completion.cpp; sourceTree = "<group>"; };
                9788FC221471AD0C0068CE2D /* JSDateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDateMath.cpp; sourceTree = "<group>"; };
                9788FC231471AD0C0068CE2D /* JSDateMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDateMath.h; sourceTree = "<group>"; };
+               99E45A0D18A01F350026D88F /* EmptyInputCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmptyInputCursor.h; path = replay/EmptyInputCursor.h; sourceTree = "<group>"; };
+               99E45A0E18A01F350026D88F /* InputCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputCursor.h; path = replay/InputCursor.h; sourceTree = "<group>"; };
+               99E45A0F18A01F350026D88F /* NondeterministicInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NondeterministicInput.h; path = replay/NondeterministicInput.h; sourceTree = "<group>"; };
                A1712B3A11C7B212007A5315 /* RegExpCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpCache.cpp; sourceTree = "<group>"; };
                A1712B3E11C7B228007A5315 /* RegExpCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCache.h; sourceTree = "<group>"; };
                A1712B4011C7B235007A5315 /* RegExpKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpKey.h; sourceTree = "<group>"; };
                                7E39D8370EC3A388003AF11A /* parser */,
                                034768DFFF38A50411DB9C8B /* Products */,
                                95AB831A0DA42C6900BC83F3 /* profiler */,
+                               99E45A0C18A01E930026D88F /* replay */,
                                932FC3C20824BB70005B3C75 /* Resources */,
                                7EF6E0BB0EB7A1EC0079AFAF /* runtime */,
                                141211000A48772600480255 /* tests */,
                        path = bytecode;
                        sourceTree = "<group>";
                };
+               99E45A0C18A01E930026D88F /* replay */ = {
+                       isa = PBXGroup;
+                       children = (
+                               99E45A0D18A01F350026D88F /* EmptyInputCursor.h */,
+                               99E45A0E18A01F350026D88F /* InputCursor.h */,
+                               99E45A0F18A01F350026D88F /* NondeterministicInput.h */,
+                       );
+                       name = replay;
+                       sourceTree = "<group>";
+               };
                A513E5CC185FB992007E95AD /* agents */ = {
                        isa = PBXGroup;
                        children = (
                                0FEA0A10170513DB00BB722C /* FTLLowerDFGToLLVM.h in Headers */,
                                A7D89D0217A0B90400773AD8 /* FTLLoweredNodeValue.h in Headers */,
                                0FD8A31C17D51F2200CA2C40 /* FTLOSREntry.h in Headers */,
+                               99E45A1118A01F350026D88F /* InputCursor.h in Headers */,
                                0F235BDD17178E1C00690C7F /* FTLOSRExit.h in Headers */,
                                0F235BDE17178E1C00690C7F /* FTLOSRExitCompilationInfo.h in Headers */,
                                0F235BE017178E1C00690C7F /* FTLOSRExitCompiler.h in Headers */,
                                BC18C45E0E16F5CD00B34460 /* JSStack.h in Headers */,
                                A7C1EAF017987AB600299DB2 /* JSStackInlines.h in Headers */,
                                BC18C4270E16F5CD00B34460 /* JSString.h in Headers */,
+                               99E45A1218A01F350026D88F /* NondeterministicInput.h in Headers */,
                                86E85539111B9968001AF51E /* JSStringBuilder.h in Headers */,
                                2600B5A7152BAAA70091EE5F /* JSStringJoiner.h in Headers */,
                                BC18C4280E16F5CD00B34460 /* JSStringRef.h in Headers */,
                                E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */,
                                0FB7F39E15ED8E4600F167B2 /* SparseArrayValueMap.h in Headers */,
                                A7386554118697B400540279 /* SpecializedThunkJIT.h in Headers */,
+                               99E45A1018A01F350026D88F /* EmptyInputCursor.h in Headers */,
                                0F5541B21613C1FB00CE3E25 /* SpecialPointer.h in Headers */,
                                0FD82E54141DAEEE00179C94 /* SpeculatedType.h in Headers */,
                                A7C1EAF217987AB600299DB2 /* StackVisitor.h in Headers */,
diff --git a/Source/JavaScriptCore/replay/EmptyInputCursor.h b/Source/JavaScriptCore/replay/EmptyInputCursor.h
new file mode 100644 (file)
index 0000000..f2a9a40
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2014 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 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
+ * HOLDER 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 EmptyInputCursor_h
+#define EmptyInputCursor_h
+
+#if ENABLE(WEB_REPLAY)
+
+#include "InputCursor.h"
+#include <wtf/Assertions.h>
+#include <wtf/Noncopyable.h>
+
+namespace JSC {
+
+class EmptyInputCursor final : public InputCursor {
+    WTF_MAKE_NONCOPYABLE(EmptyInputCursor);
+public:
+    virtual ~EmptyInputCursor() { }
+
+    static PassRefPtr<EmptyInputCursor> create()
+    {
+        return adoptRef(new EmptyInputCursor());
+    }
+
+    virtual bool isCapturing() const override { return false; }
+    virtual bool isReplaying() const override { return false; }
+
+    virtual NondeterministicInputBase* uncheckedLoadInput(InputQueue) override
+    {
+        ASSERT_NOT_REACHED();
+        return nullptr;
+    }
+
+    virtual void storeInput(std::unique_ptr<NondeterministicInputBase>) override
+    {
+        ASSERT_NOT_REACHED();
+    }
+
+protected:
+    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString&) override
+    {
+        ASSERT_NOT_REACHED();
+        return nullptr;
+    }
+
+private:
+    EmptyInputCursor() { }
+};
+
+} // namespace JSC
+
+using JSC::EmptyInputCursor;
+
+#endif // ENABLE(WEB_REPLAY)
+
+#endif // EmptyInputCursor_h
diff --git a/Source/JavaScriptCore/replay/InputCursor.h b/Source/JavaScriptCore/replay/InputCursor.h
new file mode 100644 (file)
index 0000000..6102a7f
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011, 2012 University of Washington. All rights reserved.
+ * Copyright (C) 2014 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 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
+ * HOLDER 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 InputCursor_h
+#define InputCursor_h
+
+#if ENABLE(WEB_REPLAY)
+
+#include "NondeterministicInput.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/AtomicString.h>
+
+namespace JSC {
+
+class InputCursor : public RefCounted<InputCursor> {
+    WTF_MAKE_NONCOPYABLE(InputCursor);
+public:
+    InputCursor() { }
+
+    virtual ~InputCursor() { }
+
+    virtual bool isCapturing() const = 0;
+    virtual bool isReplaying() const = 0;
+
+    template <class InputType, class... Args> inline
+    void appendInput(Args&&... args)
+    {
+        InputType* rawInput = WTF::safeCast<InputType*>(new InputType(std::forward<Args>(args)...));
+        return storeInput(std::unique_ptr<NondeterministicInputBase>(rawInput));
+    }
+
+    template <class InputType> inline
+    InputType* fetchInput()
+    {
+        return static_cast<InputType*>(loadInput(InputTraits<InputType>::queue(), InputTraits<InputType>::type()));
+    }
+
+    virtual void storeInput(std::unique_ptr<NondeterministicInputBase>) = 0;
+    virtual NondeterministicInputBase* uncheckedLoadInput(InputQueue) = 0;
+protected:
+    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString&) = 0;
+};
+
+} // namespace JSC
+
+using JSC::InputCursor;
+
+#endif // ENABLE(WEB_REPLAY)
+
+#endif // InputCursor_h
diff --git a/Source/JavaScriptCore/replay/NondeterministicInput.h b/Source/JavaScriptCore/replay/NondeterministicInput.h
new file mode 100644 (file)
index 0000000..fb3bca0
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2011, 2012 University of Washington. All rights reserved.
+ * Copyright (C) 2014 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 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
+ * HOLDER 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 NondeterministicInput_h
+#define NondeterministicInput_h
+
+#if ENABLE(WEB_REPLAY)
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+
+namespace JSC {
+
+class EncodedValue;
+
+enum class InputQueue {
+    ScriptMemoizedData = 0,
+    LoaderMemoizedData = 1,
+    EventLoopInput = 2,
+    Count = 3
+};
+
+template<typename InputType>
+struct JS_EXPORT_PRIVATE InputTraits {
+    static InputQueue queue();
+    static AtomicString& type();
+
+    static void encode(EncodedValue& encodedInput, InputType& decodedInput);
+    static bool decode(EncodedValue& encodedInput, std::unique_ptr<InputType>& decodedInput);
+};
+
+class NondeterministicInputBase {
+    WTF_MAKE_NONCOPYABLE(NondeterministicInputBase);
+public:
+    NondeterministicInputBase() { }
+    virtual ~NondeterministicInputBase() { }
+
+    virtual const AtomicString& type() const = 0;
+    virtual InputQueue queue() const = 0;
+};
+
+template<typename InputType>
+class NondeterministicInput final : public NondeterministicInputBase {
+    virtual const AtomicString& type() const override
+    {
+        return InputTraits<InputType>::type();
+    }
+
+    virtual InputQueue queue() const override
+    {
+        return InputTraits<InputType>::queue();
+    }
+};
+
+} // namespace JSC
+
+using JSC::InputQueue;
+using JSC::InputTraits;
+using JSC::NondeterministicInput;
+using JSC::NondeterministicInputBase;
+
+#endif // ENABLE(WEB_REPLAY)
+
+#endif // NondeterministicInput_h
index 2c274c1..66dfd29 100644 (file)
 #include "RemoteInspector.h"
 #endif
 
+#if ENABLE(WEB_REPLAY)
+#include "EmptyInputCursor.h"
+#endif
+
 #include "JSGlobalObject.lut.h"
 
 namespace JSC {
@@ -152,6 +156,9 @@ const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &all
 
 JSGlobalObject::JSGlobalObject(VM& vm, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
     : Base(vm, structure, 0)
+#if ENABLE(WEB_REPLAY)
+    , m_inputCursor(EmptyInputCursor::create())
+#endif
     , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
     , m_havingABadTimeWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
     , m_varInjectionWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
@@ -770,6 +777,13 @@ bool JSGlobalObject::remoteDebuggingEnabled() const
 #endif
 }
 
+#if ENABLE(WEB_REPLAY)
+void JSGlobalObject::setInputCursor(PassRefPtr<InputCursor> prpCursor)
+{
+    m_inputCursor = prpCursor;
+}
+#endif
+
 void JSGlobalObject::setName(const String& name)
 {
     m_name = name;
index b0cad3d..f987e4a 100644 (file)
@@ -60,6 +60,7 @@ class FunctionExecutable;
 class FunctionPrototype;
 class GetterSetter;
 class GlobalCodeBlock;
+class InputCursor;
 class JSGlobalObjectDebuggable;
 class JSPromiseConstructor;
 class JSPromisePrototype;
@@ -225,6 +226,10 @@ protected:
 
     Debugger* m_debugger;
 
+#if ENABLE(WEB_REPLAY)
+    RefPtr<InputCursor> m_inputCursor;
+#endif
+
 #if ENABLE(REMOTE_INSPECTOR)
     std::unique_ptr<JSGlobalObjectDebuggable> m_inspectorDebuggable;
 #endif
@@ -417,6 +422,11 @@ public:
     JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool);
     JS_EXPORT_PRIVATE bool remoteDebuggingEnabled() const;
 
+#if ENABLE(WEB_REPLAY)
+    JS_EXPORT_PRIVATE void setInputCursor(PassRefPtr<InputCursor>);
+    InputCursor& inputCursor() const { return *m_inputCursor; }
+#endif
+
     void setName(const String&);
     const String& name() const { return m_name; }
 
index f5c0035..2441f4a 100644 (file)
@@ -1,3 +1,40 @@
+2014-02-03  Brian Burg  <bburg@apple.com>
+
+        Web Replay: upstream base input classes and the input cursor interface
+        https://bugs.webkit.org/show_bug.cgi?id=128110
+
+        Reviewed by Joseph Pecoraro.
+
+        Add EventLoopInput, a base class for replay inputs that are handled
+        as if they begin a new run loop. For example, navigations, user input,
+        network callbacks, and asynchronous timers are modeled by inputs which
+        derive from this base class.
+
+        Add the ability to set an InputCursor instance on a Document. This
+        is the means for connecting a replay recording to a document context.
+
+        Add forwarding headers for some fundamental replay classes.
+
+        No new tests; no new functionality is exposed.
+
+        * ForwardingHeaders/replay/EmptyInputCursor.h: Added.
+        * ForwardingHeaders/replay/InputCursor.h: Added.
+        * ForwardingHeaders/replay/NondeterministicInput.h: Added.
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        * dom/Document.h:
+        (WebCore::Document::inputCursor):
+        (WebCore::Document::setInputCursor):
+        * replay/EventLoopInput.h: Added.
+        (WebCore::ReplayPosition::ReplayPosition):
+        (WebCore::ReplayPosition::index):
+        (WebCore::ReplayPosition::time):
+        (WebCore::EventLoopInputBase::EventLoopInputBase):
+        (WebCore::EventLoopInputBase::~EventLoopInputBase):
+        (WebCore::EventLoopInputBase::setPosition):
+        (WebCore::EventLoopInputBase::position):
+
 2014-02-03  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         Remove unused code in CSSParser.cpp
diff --git a/Source/WebCore/ForwardingHeaders/replay/EmptyInputCursor.h b/Source/WebCore/ForwardingHeaders/replay/EmptyInputCursor.h
new file mode 100644 (file)
index 0000000..d8a794f
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_EmptyInputCursor_h
+#define WebCore_FWD_EmptyInputCursor_h
+#include <JavaScriptCore/EmptyInputCursor.h>
+#endif
diff --git a/Source/WebCore/ForwardingHeaders/replay/InputCursor.h b/Source/WebCore/ForwardingHeaders/replay/InputCursor.h
new file mode 100644 (file)
index 0000000..8c68c34
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_InputCursor_h
+#define WebCore_FWD_InputCursor_h
+#include <JavaScriptCore/InputCursor.h>
+#endif
diff --git a/Source/WebCore/ForwardingHeaders/replay/NondeterministicInput.h b/Source/WebCore/ForwardingHeaders/replay/NondeterministicInput.h
new file mode 100644 (file)
index 0000000..7becdb7
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_NondeterministicInput_h
+#define WebCore_FWD_NondeterministicInput_h
+#include <JavaScriptCore/NondeterministicInput.h>
+#endif
index 04ffa47..ed6acf7 100644 (file)
                98CE4326129E00BD005821DC /* LinkLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98CE4325129E00BD005821DC /* LinkLoader.cpp */; };
                98CE432A129E00E5005821DC /* LinkLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 98CE4329129E00E5005821DC /* LinkLoader.h */; };
                98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               99E45A1718A063BE0026D88F /* EventLoopInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E45A1618A063BE0026D88F /* EventLoopInput.h */; };
                9A1142041832D135000BB8AD /* ValueToString.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A1142031832D134000BB8AD /* ValueToString.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9A1B6F97158869C80011A8C4 /* JSDOMStringListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1B6F96158869C80011A8C4 /* JSDOMStringListCustom.cpp */; };
                9A528E8317D7F52F00AA9518 /* FloatingObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */; };
                98CE4325129E00BD005821DC /* LinkLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinkLoader.cpp; sourceTree = "<group>"; };
                98CE4329129E00E5005821DC /* LinkLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkLoader.h; sourceTree = "<group>"; };
                98EB1F941313FE0500D0E1EA /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
+               99E45A1618A063BE0026D88F /* EventLoopInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventLoopInput.h; sourceTree = "<group>"; };
                9A1142031832D134000BB8AD /* ValueToString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueToString.h; sourceTree = "<group>"; };
                9A1B6F96158869C80011A8C4 /* JSDOMStringListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMStringListCustom.cpp; sourceTree = "<group>"; };
                9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatingObjects.cpp; sourceTree = "<group>"; };
                                BCF1A5BA097832090061A123 /* platform */,
                                5DCF83690D59157800953BC6 /* plugins */,
                                F523D2F302DE443B018635CA /* rendering */,
+                               99E45A1318A021760026D88F /* replay */,
                                1AE82EC90CAAE177002237AE /* storage */,
                                E4763D4A17B2704900D35206 /* style */,
                                B22277CA0D00BF1E0071B782 /* svg */,
                        name = parser;
                        sourceTree = "<group>";
                };
+               99E45A1318A021760026D88F /* replay */ = {
+                       isa = PBXGroup;
+                       children = (
+                               99E45A1618A063BE0026D88F /* EventLoopInput.h */,
+                       );
+                       path = replay;
+                       sourceTree = "<group>";
+               };
                A148328B187F506800DA63A6 /* wak */ = {
                        isa = PBXGroup;
                        children = (
                                FBDB61A116D6037E00BB3394 /* PageRuleCollector.h in Headers */,
                                F3820895147D35F90010BC06 /* PageRuntimeAgent.h in Headers */,
                                F34742E51343633C00531BC2 /* PageScriptDebugServer.h in Headers */,
+                               99E45A1718A063BE0026D88F /* EventLoopInput.h in Headers */,
                                371E65CC13661EDC00BEEDB0 /* PageSerializer.h in Headers */,
                                A7197F24175689C4007B9442 /* PageThrottler.h in Headers */,
                                E1284AE110447D4500EAEB52 /* PageTransitionEvent.h in Headers */,
index 2ae165f..a96f970 100644 (file)
 #include "CaptionUserPreferences.h"
 #endif
 
+#if ENABLE(WEB_REPLAY)
+#include <replay/EmptyInputCursor.h>
+#endif
+
 using namespace WTF;
 using namespace Unicode;
 
@@ -496,6 +500,9 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
 #if ENABLE(TEMPLATE_ELEMENT)
     , m_templateDocumentHost(nullptr)
 #endif
+#if ENABLE(WEB_REPLAY)
+    , m_inputCursor(EmptyInputCursor::create())
+#endif
     , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsTimerFired)
     , m_hasInjectedPlugInsScript(false)
     , m_renderTreeBeingDestroyed(false)
index 31b0679..01cc314 100644 (file)
 #include <wtf/PassRefPtr.h>
 #include <wtf/WeakPtr.h>
 
+#if ENABLE(WEB_REPLAY)
+#include <replay/InputCursor.h>
+#endif
+
 namespace WebCore {
 
 class AXObjectCache;
@@ -442,6 +446,11 @@ public:
 
     virtual URL baseURI() const override;
 
+#if ENABLE(WEB_REPLAY)
+    InputCursor& inputCursor() const { return *m_inputCursor; }
+    void setInputCursor(PassRefPtr<InputCursor> cursor) { m_inputCursor = cursor; }
+#endif
+
 #if ENABLE(PAGE_VISIBILITY_API)
     void visibilityStateChanged();
     String visibilityState() const;
@@ -1645,6 +1654,10 @@ private:
     RefPtr<FontLoader> m_fontloader;
 #endif
 
+#if ENABLE(WEB_REPLAY)
+    RefPtr<InputCursor> m_inputCursor;
+#endif
+
     Timer<Document> m_didAssociateFormControlsTimer;
     HashSet<RefPtr<Element>> m_associatedFormControls;
 
diff --git a/Source/WebCore/replay/EventLoopInput.h b/Source/WebCore/replay/EventLoopInput.h
new file mode 100644 (file)
index 0000000..abb7d44
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2011-2013 University of Washington. All rights reserved.
+ * Copyright (C) 2014 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 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
+ * HOLDER 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 EventLoopInput_h
+#define EventLoopInput_h
+
+#if ENABLE(WEB_REPLAY)
+
+#include <replay/NondeterministicInput.h>
+#include <wtf/CurrentTime.h>
+
+namespace WebCore {
+
+class ReplayController;
+
+struct ReplayPosition {
+public:
+    ReplayPosition()
+        : m_index(0)
+        , m_time(0.0) { }
+
+    explicit ReplayPosition(unsigned index)
+        : m_index(index)
+        , m_time(monotonicallyIncreasingTime()) { }
+
+    unsigned index() const { return m_index; }
+    double time() const { return m_time; }
+private:
+    unsigned m_index;
+    double m_time;
+};
+
+class EventLoopInputBase : public NondeterministicInputBase {
+public:
+    EventLoopInputBase()
+        : m_position(ReplayPosition()) { }
+
+    virtual ~EventLoopInputBase() { }
+    virtual InputQueue queue() const override final { return InputQueue::EventLoopInput; }
+
+    virtual void dispatch(ReplayController&) = 0;
+
+    // During capture, the position is set when the following event loop input is captured.
+    void setPosition(const ReplayPosition& position) { m_position = position; }
+    ReplayPosition position() const { return m_position; }
+protected:
+    ReplayPosition m_position;
+};
+
+template <typename InputType>
+class EventLoopInput : public EventLoopInputBase {
+    virtual const AtomicString& type() const override final
+    {
+        return InputTraits<InputType>::type();
+    }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_REPLAY)
+
+#endif // EventLoopInput_h