Web Replay: AtomicString replay input names should be stored in a thread-local table
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Feb 2014 00:54:36 +0000 (00:54 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Feb 2014 00:54:36 +0000 (00:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128829

Reviewed by Andreas Kling.

Similar to how DOM event names are frequently-used AtomicStrings, replay input
names are also checked in many places as a "type tag". This patch puts all known
input names into a class held by ThreadGlobalData and adds the shortcut `inputTypes()`
so that replay input types can be referenced with `inputTypes.InputName()`.

* WebCore.xcodeproj/project.pbxproj:
* platform/ThreadGlobalData.cpp: Add inputTypes() shortcut.
(WebCore::ThreadGlobalData::ThreadGlobalData):
* platform/ThreadGlobalData.h: Add inputTypes() shortcut.
(WebCore::ThreadGlobalData::inputTypes):
* replay/ReplayInputTypes.cpp: Added.
(WebCore::ReplayInputTypes::ReplayInputTypes):
* replay/ReplayInputTypes.h: Added.
(WebCore::inputTypes): The input names are provided by per-framework macros that
are generated by the replay inputs code generator.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164144 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/ThreadGlobalData.cpp
Source/WebCore/platform/ThreadGlobalData.h
Source/WebCore/replay/ReplayInputTypes.cpp [new file with mode: 0644]
Source/WebCore/replay/ReplayInputTypes.h [new file with mode: 0644]

index c0f8df0..9bdc910 100644 (file)
                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, ); }; };
                9928FF3B18AC4AEC00B8CF12 /* JSReplayInputs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9928FF3918AC4AEC00B8CF12 /* JSReplayInputs.cpp */; };
-               9928FF3C18AC4AEC00B8CF12 /* JSReplayInputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 9928FF3A18AC4AEC00B8CF12 /* JSReplayInputs.h */; };
+               9928FF3C18AC4AEC00B8CF12 /* JSReplayInputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 9928FF3A18AC4AEC00B8CF12 /* JSReplayInputs.h */; settings = {ATTRIBUTES = (Private, ); }; };
                99E45A2418A1B2590026D88F /* EmptyInputCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E45A1F18A1B2590026D88F /* EmptyInputCursor.h */; settings = {ATTRIBUTES = (Private, ); }; };
                99E45A2518A1B2590026D88F /* EncodedValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99E45A2018A1B2590026D88F /* EncodedValue.cpp */; };
                99E45A2618A1B2590026D88F /* EncodedValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E45A2118A1B2590026D88F /* EncodedValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
index 4b160b9..58acc35 100644 (file)
@@ -1,3 +1,26 @@
+2014-02-14  Brian Burg  <bburg@apple.com>
+
+        Web Replay: AtomicString replay input names should be stored in a thread-local table
+        https://bugs.webkit.org/show_bug.cgi?id=128829
+
+        Reviewed by Andreas Kling.
+
+        Similar to how DOM event names are frequently-used AtomicStrings, replay input
+        names are also checked in many places as a "type tag". This patch puts all known
+        input names into a class held by ThreadGlobalData and adds the shortcut `inputTypes()`
+        so that replay input types can be referenced with `inputTypes.InputName()`.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/ThreadGlobalData.cpp: Add inputTypes() shortcut.
+        (WebCore::ThreadGlobalData::ThreadGlobalData):
+        * platform/ThreadGlobalData.h: Add inputTypes() shortcut.
+        (WebCore::ThreadGlobalData::inputTypes):
+        * replay/ReplayInputTypes.cpp: Added.
+        (WebCore::ReplayInputTypes::ReplayInputTypes):
+        * replay/ReplayInputTypes.h: Added.
+        (WebCore::inputTypes): The input names are provided by per-framework macros that
+        are generated by the replay inputs code generator.
+
 2014-02-14  Jer Noble  <jer.noble@apple.com>
 
         Add support for specced event handlers to HTMLMediaElement
index 892e345..50f5752 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, ); }; };
+               990A1A0418ADA48400183FD1 /* ReplayInputTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 990A19F418ADA48400183FD1 /* ReplayInputTypes.cpp */; };
+               990A1A0518ADA48400183FD1 /* ReplayInputTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 990A19F518ADA48400183FD1 /* ReplayInputTypes.h */; };
                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 */; };
                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>"; };
+               990A19F418ADA48400183FD1 /* ReplayInputTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReplayInputTypes.cpp; sourceTree = "<group>"; };
+               990A19F518ADA48400183FD1 /* ReplayInputTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReplayInputTypes.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>"; };
                        isa = PBXGroup;
                        children = (
                                99E45A1618A063BE0026D88F /* EventLoopInput.h */,
+                               990A19F418ADA48400183FD1 /* ReplayInputTypes.cpp */,
+                               990A19F518ADA48400183FD1 /* ReplayInputTypes.h */,
                        );
                        path = replay;
                        sourceTree = "<group>";
                                B22279DD0D00BF220071B782 /* SVGFEFloodElement.h in Headers */,
                                B22279E00D00BF220071B782 /* SVGFEFuncAElement.h in Headers */,
                                B22279E30D00BF220071B782 /* SVGFEFuncBElement.h in Headers */,
+                               990A1A0518ADA48400183FD1 /* ReplayInputTypes.h in Headers */,
                                B22279E60D00BF220071B782 /* SVGFEFuncGElement.h in Headers */,
                                B22279E90D00BF220071B782 /* SVGFEFuncRElement.h in Headers */,
                                B22279EC0D00BF220071B782 /* SVGFEGaussianBlurElement.h in Headers */,
                                078E090917D14CEE00420AA1 /* RTCIceCandidate.cpp in Sources */,
                                CDA98E0B1603CD6000FEA3B1 /* CDM.cpp in Sources */,
                                CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */,
+                               990A1A0418ADA48400183FD1 /* ReplayInputTypes.cpp in Sources */,
                                E1A8E56617552B2A007488E7 /* CFURLExtras.cpp in Sources */,
                                97BC69DC1505F076001B74AC /* ChangeVersionWrapper.cpp in Sources */,
                                FD315FFE12B0267600C1A359 /* ChannelMergerNode.cpp in Sources */,
index 8e7e6e2..0f8a8db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 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
 #include "TextCodeCMac.h"
 #endif
 
+#if ENABLE(WEB_REPLAY)
+#include "ReplayInputTypes.h"
+#endif
+
 namespace WebCore {
 
 ThreadSpecific<ThreadGlobalData>* ThreadGlobalData::staticData;
@@ -53,6 +57,9 @@ ThreadGlobalData::ThreadGlobalData()
     : m_cachedResourceRequestInitiators(adoptPtr(new CachedResourceRequestInitiators))
     , m_eventNames(adoptPtr(new EventNames))
     , m_threadTimers(adoptPtr(new ThreadTimers))
+#if ENABLE(WEB_REPLAY)
+    , m_inputTypes(std::make_unique<ReplayInputTypes>())
+#endif
 #ifndef NDEBUG
     , m_isMainThread(isMainThread())
 #endif
@@ -88,6 +95,10 @@ void ThreadGlobalData::destroy()
     m_inspectorCounters.clear();
 #endif
 
+#if ENABLE(WEB_REPLAY)
+    m_inputTypes = nullptr;
+#endif
+
     m_eventNames.clear();
     m_threadTimers.clear();
 }
index e386be2..4a7163e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 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
@@ -40,6 +40,7 @@ using WTF::ThreadSpecific;
 namespace WebCore {
 
     class EventNames;
+    class ReplayInputTypes;
     class ThreadLocalInspectorCounters;
     class ThreadTimers;
 
@@ -57,6 +58,9 @@ namespace WebCore {
         const CachedResourceRequestInitiators& cachedResourceRequestInitiators() { return *m_cachedResourceRequestInitiators; }
         EventNames& eventNames() { return *m_eventNames; }
         ThreadTimers& threadTimers() { return *m_threadTimers; }
+#if ENABLE(WEB_REPLAY)
+        ReplayInputTypes& inputTypes() { return *m_inputTypes; }
+#endif
 
         ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
 
@@ -77,6 +81,10 @@ namespace WebCore {
         OwnPtr<EventNames> m_eventNames;
         OwnPtr<ThreadTimers> m_threadTimers;
 
+#if ENABLE(WEB_REPLAY)
+        std::unique_ptr<ReplayInputTypes> m_inputTypes;
+#endif
+
 #ifndef NDEBUG
         bool m_isMainThread;
 #endif
diff --git a/Source/WebCore/replay/ReplayInputTypes.cpp b/Source/WebCore/replay/ReplayInputTypes.cpp
new file mode 100644 (file)
index 0000000..8e8919e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 University of Washington. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights resernved.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "ReplayInputTypes.h"
+
+#if ENABLE(WEB_REPLAY)
+
+namespace WebCore {
+
+#define INITIALIZE_INPUT_TYPE(name) \
+    , name(#name, AtomicString::ConstructFromLiteral)
+
+ReplayInputTypes::ReplayInputTypes()
+    : dummy(0)
+JS_REPLAY_INPUT_NAMES_FOR_EACH(INITIALIZE_INPUT_TYPE)
+{
+    UNUSED_PARAM(dummy);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_REPLAY)
diff --git a/Source/WebCore/replay/ReplayInputTypes.h b/Source/WebCore/replay/ReplayInputTypes.h
new file mode 100644 (file)
index 0000000..df16ca0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 University of Washington. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights resernved.
+ *
+ * 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 ReplayInputTypes_h
+#define ReplayInputTypes_h
+
+#if ENABLE(WEB_REPLAY)
+
+#include "ThreadGlobalData.h"
+#include <JavaScriptCore/JSReplayInputs.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class ReplayInputTypes {
+    WTF_MAKE_NONCOPYABLE(ReplayInputTypes); WTF_MAKE_FAST_ALLOCATED;
+    int dummy; // Needed to make initialization macro work.
+public:
+    ReplayInputTypes();
+
+#define DECLARE_REPLAY_INPUT_TYPES(name) AtomicString name;
+    JS_REPLAY_INPUT_NAMES_FOR_EACH(DECLARE_REPLAY_INPUT_TYPES)
+#undef DECLARE_REPLAY_INPUT_TYPES
+};
+
+inline ReplayInputTypes& inputTypes()
+{
+    return threadGlobalData().inputTypes();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_REPLAY)
+
+#endif // ReplayInputTypes_h