| Differences between
and this patch
- Source/WebKit2/ChangeLog +47 lines
Lines 1-3 Source/WebKit2/ChangeLog_sec1
1
2011-03-31  Chang Shu  <cshu@webkit.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        [Mac] [WK2] Implement KeyDown function for WebKit2 EventSender.
6
        https://bugs.webkit.org/show_bug.cgi?id=57515
7
8
        The following code change builds up the infrastructure for
9
        WebKitTestRunner EventSender to send messages from the InjectedBundle
10
        in WebProcess to UIProcess of WebKitTestRunner.
11
12
        The basic KeyDown functionality is implemented except the local implementation.
13
14
        * Shared/API/c/WKArgumentDecoder.cpp: Added.
15
        (WKCreateArgumentDecoder):
16
        (WKDecodeUInt32):
17
        (WKDecodeString):
18
        * Shared/API/c/WKArgumentDecoder.h: Added.
19
        * Shared/API/c/WKBase.h:
20
        * Shared/API/c/WKMessageID.h: Added.
21
        * Shared/API/c/WKSharedAPICast.h:
22
        * Shared/EventSenderProxyMessages.h: Added.
23
        (Messages::EventSenderProxy::KeyDown::KeyDown):
24
        (Messages::EventSenderProxy::KeyDown::encode):
25
        * UIProcess/WebContextUserMessageCoders.h:
26
        (WebKit::WebContextUserMessageDecoder::decode):
27
        * WebKit2.xcodeproj/project.pbxproj:
28
        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
29
        (WKBundleGetEventSender):
30
        * WebProcess/InjectedBundle/API/c/WKBundle.h:
31
        * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
32
        * WebProcess/InjectedBundle/API/c/WKBundleEventSender.cpp: Added.
33
        (WKBundleEventSenderKeyDown):
34
        * WebProcess/InjectedBundle/API/c/WKBundleEventSender.h: Added.
35
        * WebProcess/InjectedBundle/InjectedBundle.cpp:
36
        (WebKit::InjectedBundle::InjectedBundle):
37
        * WebProcess/InjectedBundle/InjectedBundle.h:
38
        (WebKit::InjectedBundle::eventSender):
39
        * WebProcess/InjectedBundle/InjectedBundleEventSender.cpp: Added.
40
        (WebKit::InjectedBundleEventSender::create):
41
        (WebKit::InjectedBundleEventSender::InjectedBundleEventSender):
42
        (WebKit::InjectedBundleEventSender::~InjectedBundleEventSender):
43
        (WebKit::InjectedBundleEventSender::keyDown):
44
        * WebProcess/InjectedBundle/InjectedBundleEventSender.h: Added.
45
        * WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h:
46
        (WebKit::InjectedBundleUserMessageEncoder::encode):
47
1
2011-03-31  John Sullivan  <sullivan@apple.com>
48
2011-03-31  John Sullivan  <sullivan@apple.com>
2
49
3
        Reviewed by Darin Adler and Adam Roben.
50
        Reviewed by Darin Adler and Adam Roben.
- Source/WebKit2/Shared/EventSenderProxyMessages.h +64 lines
Line 0 Source/WebKit2/Shared/EventSenderProxyMessages.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
18
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef EventSenderProxyMessages_h
27
#define EventSenderProxyMessages_h
28
29
#include "Arguments.h"
30
#include "MessageID.h"
31
#include "WKMessageID.h"
32
#include <wtf/text/WTFString.h>
33
34
namespace Messages {
35
36
namespace EventSenderProxy {
37
38
struct KeyDown : CoreIPC::Arguments3<const String&, uint32_t, uint32_t> {
39
    static const Kind messageID = KeyDownID;
40
    typedef CoreIPC::Arguments3<const String&, uint32_t, uint32_t> DecodeType;
41
    KeyDown(const String& key, uint32_t modifiers, uint32_t location)
42
        : CoreIPC::Arguments3<const String&, uint32_t, uint32_t>(key, modifiers, location)
43
    {
44
    }
45
    void encode(CoreIPC::ArgumentEncoder* encoder) const
46
    {
47
        encoder->encode(static_cast<uint32_t>(messageID));
48
        DecodeType::encode(encoder);
49
    }
50
};
51
52
} // namespace EventSenderProxy
53
54
} // namespace Messages
55
56
namespace CoreIPC {
57
58
template<> struct MessageKindTraits<Messages::EventSenderProxy::Kind> {
59
    static const MessageClass messageClass = MessageClassWebContextLegacy;
60
};
61
62
} // namespace CoreIPC
63
64
#endif // EventSenderProxyMessages_h
- Source/WebKit2/Shared/API/c/WKArgumentDecoder.cpp +59 lines
Line 0 Source/WebKit2/Shared/API/c/WKArgumentDecoder.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "WKArgumentDecoder.h"
29
30
#include "APIObject.h"
31
#include "ArgumentCoders.h"
32
#include "Connection.h"
33
#include "EventSenderProxyMessages.h"
34
#include "HandleMessage.h"
35
#include "WKAPICast.h"
36
#include "WKString.h"
37
38
using namespace WebKit;
39
40
WKArgumentDecoderRef WKCreateArgumentDecoder(const unsigned char* data, size_t length)
41
{
42
    CoreIPC::ArgumentDecoder* argumentDecoder = new CoreIPC::ArgumentDecoder(data, length);
43
    return toAPI(argumentDecoder);
44
}
45
46
bool WKDecodeUInt32(WKArgumentDecoderRef argumentDecoderRef, uint32_t& value)
47
{
48
    return toImpl(argumentDecoderRef)->decode(value);
49
}
50
51
bool WKDecodeString(WKArgumentDecoderRef argumentDecoderRef, WKStringRef& strRef)
52
{
53
    String str;
54
    if (toImpl(argumentDecoderRef)->decode(str)) {
55
        strRef = WKStringCreateWithUTF8CString(str.utf8().data());
56
        return true;
57
    }
58
    return false;
59
}
- Source/WebKit2/Shared/API/c/WKArgumentDecoder.h +47 lines
Line 0 Source/WebKit2/Shared/API/c/WKArgumentDecoder.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#ifndef WKArgumentDecoder_h
28
#define WKArgumentDecoder_h
29
30
#include <WebKit2/WKBase.h>
31
#include <WebKit2/WKMessageID.h>
32
33
#ifdef __cplusplus
34
extern "C" {
35
#endif
36
37
WK_EXPORT WKArgumentDecoderRef WKCreateArgumentDecoder(const unsigned char*, size_t);
38
WK_EXPORT bool WKDecodeUInt32(WKArgumentDecoderRef, uint32_t&);
39
40
WK_EXPORT bool WKDecodeString(WKArgumentDecoderRef, WKStringRef&);
41
42
#ifdef __cplusplus
43
}
44
#endif
45
46
47
#endif /* WKArgumentDecoder_h */
- Source/WebKit2/Shared/API/c/WKBase.h +3 lines
Lines 65-70 typedef const struct OpaqueWKURLRequest* Source/WebKit2/Shared/API/c/WKBase.h_sec1
65
typedef const struct OpaqueWKURLResponse* WKURLResponseRef;
65
typedef const struct OpaqueWKURLResponse* WKURLResponseRef;
66
typedef const struct OpaqueWKUserContentURLPattern* WKUserContentURLPatternRef;
66
typedef const struct OpaqueWKUserContentURLPattern* WKUserContentURLPatternRef;
67
67
68
typedef const struct OpaqueWKArgumentDecoder* WKArgumentDecoderRef;
69
68
/* WebKit2 main API types */
70
/* WebKit2 main API types */
69
71
70
typedef const struct OpaqueWKApplicationCacheManager* WKApplicationCacheManagerRef;
72
typedef const struct OpaqueWKApplicationCacheManager* WKApplicationCacheManagerRef;
Lines 103-108 typedef const struct OpaqueWKBundle* WKB Source/WebKit2/Shared/API/c/WKBase.h_sec2
103
typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef;
105
typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef;
104
typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef;
106
typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef;
105
typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
107
typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
108
typedef const struct OpaqueWKBundleEventSender* WKBundleEventSenderRef;
106
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
109
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
107
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
110
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
108
typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
111
typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
- Source/WebKit2/Shared/API/c/WKMessageID.h +41 lines
Line 0 Source/WebKit2/Shared/API/c/WKMessageID.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
18
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef WKMessageID_h
27
#define WKMessageID_h
28
29
namespace Messages {
30
31
namespace EventSenderProxy {
32
33
enum Kind {
34
    KeyDownID,
35
};
36
37
} // namespace EventSenderProxy
38
39
} // namespace Messages
40
41
#endif // WKMessageID_h
- Source/WebKit2/Shared/API/c/WKSharedAPICast.h +6 lines
Lines 49-54 Source/WebKit2/Shared/API/c/WKSharedAPICast.h_sec1
49
#include <WebCore/IntRect.h>
49
#include <WebCore/IntRect.h>
50
#include <wtf/TypeTraits.h>
50
#include <wtf/TypeTraits.h>
51
51
52
namespace CoreIPC {
53
class ArgumentDecoder;
54
}
55
52
namespace WebKit {
56
namespace WebKit {
53
57
54
class ImmutableArray;
58
class ImmutableArray;
Lines 95-100 WK_ADD_API_MAPPING(WKURLRequestRef, WebU Source/WebKit2/Shared/API/c/WKSharedAPICast.h_sec2
95
WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse)
99
WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse)
96
WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern)
100
WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern)
97
101
102
WK_ADD_API_MAPPING(WKArgumentDecoderRef, CoreIPC::ArgumentDecoder)
103
98
template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
104
template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
99
class ProxyingRefPtr {
105
class ProxyingRefPtr {
100
public:
106
public:
- Source/WebKit2/UIProcess/WebContextUserMessageCoders.h +9 lines
Lines 25-30 Source/WebKit2/UIProcess/WebContextUserMessageCoders.h_sec1
25
25
26
#include "UserMessageCoders.h"
26
#include "UserMessageCoders.h"
27
#include "WebContext.h"
27
#include "WebContext.h"
28
#include "WebData.h"
28
#include "WebFrameProxy.h"
29
#include "WebFrameProxy.h"
29
#include "WebPageGroup.h"
30
#include "WebPageGroup.h"
30
#include "WebPageGroupData.h"
31
#include "WebPageGroupData.h"
Lines 127-132 public: Source/WebKit2/UIProcess/WebContextUserMessageCoders.h_sec2
127
            coder.m_root = WebPageGroup::get(pageGroupID);
128
            coder.m_root = WebPageGroup::get(pageGroupID);
128
            break;
129
            break;
129
        }
130
        }
131
        case APIObject::TypeData: {
132
            Vector<uint8_t> bytes;
133
            if (!decoder->decodeBytes(bytes))
134
                return false;
135
            RefPtr<WebData> webData = WebData::create(bytes.releaseBuffer(), bytes.size());
136
            coder.m_root = webData.release();
137
            break;
138
        }
130
        default:
139
        default:
131
            return false;
140
            return false;
132
        }
141
        }
- Source/WebKit2/WebKit2.xcodeproj/project.pbxproj +34 lines
Lines 356-361 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec1
356
		51D02F6A132EC73700BEAA96 /* WebIconDatabaseMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D02F67132EC73700BEAA96 /* WebIconDatabaseMessages.h */; };
356
		51D02F6A132EC73700BEAA96 /* WebIconDatabaseMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D02F67132EC73700BEAA96 /* WebIconDatabaseMessages.h */; };
357
		51D02F6B132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D02F68132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp */; };
357
		51D02F6B132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D02F68132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp */; };
358
		51D02F6C132EC73700BEAA96 /* WebIconDatabaseProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D02F69132EC73700BEAA96 /* WebIconDatabaseProxyMessages.h */; };
358
		51D02F6C132EC73700BEAA96 /* WebIconDatabaseProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D02F69132EC73700BEAA96 /* WebIconDatabaseProxyMessages.h */; };
359
		56BC6D7613439C9C006BD7A3 /* WKArgumentDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56BC6D7513439C9C006BD7A3 /* WKArgumentDecoder.cpp */; };
360
		56BC6D7813439F04006BD7A3 /* WKArgumentDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 56BC6D7713439F04006BD7A3 /* WKArgumentDecoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
361
		56BC6D7C1343B92E006BD7A3 /* WKMessageID.h in Headers */ = {isa = PBXBuildFile; fileRef = 56BC6D7B1343B92E006BD7A3 /* WKMessageID.h */; settings = {ATTRIBUTES = (Public, ); }; };
362
		56CE714B1333BAB10049D89E /* InjectedBundleEventSender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56CE714A1333BAB10049D89E /* InjectedBundleEventSender.cpp */; };
363
		56CE714D1333BAED0049D89E /* InjectedBundleEventSender.h in Headers */ = {isa = PBXBuildFile; fileRef = 56CE714C1333BAED0049D89E /* InjectedBundleEventSender.h */; };
364
		56CE714F1333BB2A0049D89E /* EventSenderProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 56CE714E1333BB2A0049D89E /* EventSenderProxyMessages.h */; };
365
		56CE715A1333BBC10049D89E /* WKBundleEventSender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56CE71581333BBC10049D89E /* WKBundleEventSender.cpp */; };
366
		56CE715B1333BBC10049D89E /* WKBundleEventSender.h in Headers */ = {isa = PBXBuildFile; fileRef = 56CE71591333BBC10049D89E /* WKBundleEventSender.h */; settings = {ATTRIBUTES = (Public, ); }; };
367
		56D01DC81343BC440098DE06 /* WKArray.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BC4075D8124FF0270068F20A /* WKArray.h */; };
359
		6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
368
		6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
360
		659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
369
		659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
361
		65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Public, ); }; };
370
		65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Public, ); }; };
Lines 868-873 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec2
868
				1A50DB66110A3D57000D3FE5 /* WebProcess.app in CopyFiles */,
877
				1A50DB66110A3D57000D3FE5 /* WebProcess.app in CopyFiles */,
869
				BCDE0ABF13272708001259FB /* PluginProcess.app in CopyFiles */,
878
				BCDE0ABF13272708001259FB /* PluginProcess.app in CopyFiles */,
870
				F6389550133BEF38008941D5 /* HTTPCookieAcceptPolicy.h in CopyFiles */,
879
				F6389550133BEF38008941D5 /* HTTPCookieAcceptPolicy.h in CopyFiles */,
880
				56D01DC81343BC440098DE06 /* WKArray.h in CopyFiles */,
871
			);
881
			);
872
			runOnlyForDeploymentPostprocessing = 0;
882
			runOnlyForDeploymentPostprocessing = 0;
873
		};
883
		};
Lines 1241-1246 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec3
1241
		51D02F67132EC73700BEAA96 /* WebIconDatabaseMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseMessages.h; sourceTree = "<group>"; };
1251
		51D02F67132EC73700BEAA96 /* WebIconDatabaseMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseMessages.h; sourceTree = "<group>"; };
1242
		51D02F68132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebIconDatabaseProxyMessageReceiver.cpp; sourceTree = "<group>"; };
1252
		51D02F68132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebIconDatabaseProxyMessageReceiver.cpp; sourceTree = "<group>"; };
1243
		51D02F69132EC73700BEAA96 /* WebIconDatabaseProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseProxyMessages.h; sourceTree = "<group>"; };
1253
		51D02F69132EC73700BEAA96 /* WebIconDatabaseProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseProxyMessages.h; sourceTree = "<group>"; };
1254
		56BC6D7513439C9C006BD7A3 /* WKArgumentDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKArgumentDecoder.cpp; sourceTree = "<group>"; };
1255
		56BC6D7713439F04006BD7A3 /* WKArgumentDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKArgumentDecoder.h; sourceTree = "<group>"; };
1256
		56BC6D7B1343B92E006BD7A3 /* WKMessageID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKMessageID.h; sourceTree = "<group>"; };
1257
		56CE714A1333BAB10049D89E /* InjectedBundleEventSender.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleEventSender.cpp; sourceTree = "<group>"; };
1258
		56CE714C1333BAED0049D89E /* InjectedBundleEventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleEventSender.h; sourceTree = "<group>"; };
1259
		56CE714E1333BB2A0049D89E /* EventSenderProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSenderProxyMessages.h; sourceTree = "<group>"; };
1260
		56CE71581333BBC10049D89E /* WKBundleEventSender.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleEventSender.cpp; sourceTree = "<group>"; };
1261
		56CE71591333BBC10049D89E /* WKBundleEventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleEventSender.h; sourceTree = "<group>"; };
1244
		5DAD7294116FF70B00EE5396 /* WebProcess.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcess.xcconfig; sourceTree = "<group>"; };
1262
		5DAD7294116FF70B00EE5396 /* WebProcess.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcess.xcconfig; sourceTree = "<group>"; };
1245
		5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
1263
		5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
1246
		6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = "<group>"; };
1264
		6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = "<group>"; };
Lines 2040-2045 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec4
2040
				BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */,
2058
				BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */,
2041
				C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
2059
				C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
2042
				0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
2060
				0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
2061
				56CE714E1333BB2A0049D89E /* EventSenderProxyMessages.h */,
2043
				762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
2062
				762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
2044
				F638954F133BEF38008941D5 /* HTTPCookieAcceptPolicy.h */,
2063
				F638954F133BEF38008941D5 /* HTTPCookieAcceptPolicy.h */,
2045
				BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
2064
				BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
Lines 2808-2813 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec5
2808
				935EEB921277615D003322B8 /* InjectedBundleBackForwardListItem.h */,
2827
				935EEB921277615D003322B8 /* InjectedBundleBackForwardListItem.h */,
2809
				BCEE7DC4128B645D009827DA /* InjectedBundleClient.cpp */,
2828
				BCEE7DC4128B645D009827DA /* InjectedBundleClient.cpp */,
2810
				BCEE7DC3128B645D009827DA /* InjectedBundleClient.h */,
2829
				BCEE7DC3128B645D009827DA /* InjectedBundleClient.h */,
2830
				56CE714A1333BAB10049D89E /* InjectedBundleEventSender.cpp */,
2831
				56CE714C1333BAED0049D89E /* InjectedBundleEventSender.h */,
2811
				BC498617124D10E200D834E1 /* InjectedBundleHitTestResult.cpp */,
2832
				BC498617124D10E200D834E1 /* InjectedBundleHitTestResult.cpp */,
2812
				BC498616124D10E200D834E1 /* InjectedBundleHitTestResult.h */,
2833
				BC498616124D10E200D834E1 /* InjectedBundleHitTestResult.h */,
2813
				BC8147D412F66D31007B2C32 /* InjectedBundleNavigationAction.cpp */,
2834
				BC8147D412F66D31007B2C32 /* InjectedBundleNavigationAction.cpp */,
Lines 2859-2864 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec6
2859
				935EEB961277616D003322B8 /* WKBundleBackForwardList.h */,
2880
				935EEB961277616D003322B8 /* WKBundleBackForwardList.h */,
2860
				935EEB971277616D003322B8 /* WKBundleBackForwardListItem.cpp */,
2881
				935EEB971277616D003322B8 /* WKBundleBackForwardListItem.cpp */,
2861
				935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */,
2882
				935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */,
2883
				56CE71581333BBC10049D89E /* WKBundleEventSender.cpp */,
2884
				56CE71591333BBC10049D89E /* WKBundleEventSender.h */,
2862
				BCD25F1611D6BDE100169B0E /* WKBundleFrame.cpp */,
2885
				BCD25F1611D6BDE100169B0E /* WKBundleFrame.cpp */,
2863
				BCD25F1511D6BDE100169B0E /* WKBundleFrame.h */,
2886
				BCD25F1511D6BDE100169B0E /* WKBundleFrame.h */,
2864
				BCF049E411FE20F600F86A58 /* WKBundleFramePrivate.h */,
2887
				BCF049E411FE20F600F86A58 /* WKBundleFramePrivate.h */,
Lines 3044-3049 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec7
3044
				BC4075D5124FEFFA0068F20A /* cf */,
3067
				BC4075D5124FEFFA0068F20A /* cf */,
3045
				BCCF6AC412C91F3B008F9C35 /* cg */,
3068
				BCCF6AC412C91F3B008F9C35 /* cg */,
3046
				BC4075D6124FF0000068F20A /* mac */,
3069
				BC4075D6124FF0000068F20A /* mac */,
3070
				56BC6D7513439C9C006BD7A3 /* WKArgumentDecoder.cpp */,
3071
				56BC6D7713439F04006BD7A3 /* WKArgumentDecoder.h */,
3047
				BC4075D7124FF0270068F20A /* WKArray.cpp */,
3072
				BC4075D7124FF0270068F20A /* WKArray.cpp */,
3048
				BC4075D8124FF0270068F20A /* WKArray.h */,
3073
				BC4075D8124FF0270068F20A /* WKArray.h */,
3049
				BCDDB316124EBD130048D13C /* WKBase.h */,
3074
				BCDDB316124EBD130048D13C /* WKBase.h */,
Lines 3065-3070 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec8
3065
				BCA56A6312F9C8F900C566C7 /* WKGraphicsContext.h */,
3090
				BCA56A6312F9C8F900C566C7 /* WKGraphicsContext.h */,
3066
				BCCF6AC012C91F34008F9C35 /* WKImage.cpp */,
3091
				BCCF6AC012C91F34008F9C35 /* WKImage.cpp */,
3067
				BCCF6AC112C91F34008F9C35 /* WKImage.h */,
3092
				BCCF6AC112C91F34008F9C35 /* WKImage.h */,
3093
				56BC6D7B1343B92E006BD7A3 /* WKMessageID.h */,
3068
				BC4075E1124FF0270068F20A /* WKMutableArray.cpp */,
3094
				BC4075E1124FF0270068F20A /* WKMutableArray.cpp */,
3069
				BC4075E2124FF0270068F20A /* WKMutableArray.h */,
3095
				BC4075E2124FF0270068F20A /* WKMutableArray.h */,
3070
				BC4075E3124FF0270068F20A /* WKMutableDictionary.cpp */,
3096
				BC4075E3124FF0270068F20A /* WKMutableDictionary.cpp */,
Lines 3651-3656 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec9
3651
				C064504A133BE709003470E2 /* LayerTreeHostCA.h in Headers */,
3677
				C064504A133BE709003470E2 /* LayerTreeHostCA.h in Headers */,
3652
				5110AE0D133C16CB0072717A /* WKIconDatabase.h in Headers */,
3678
				5110AE0D133C16CB0072717A /* WKIconDatabase.h in Headers */,
3653
				5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */,
3679
				5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */,
3680
				56CE714D1333BAED0049D89E /* InjectedBundleEventSender.h in Headers */,
3681
				56CE714F1333BB2A0049D89E /* EventSenderProxyMessages.h in Headers */,
3682
				56CE715B1333BBC10049D89E /* WKBundleEventSender.h in Headers */,
3683
				56BC6D7813439F04006BD7A3 /* WKArgumentDecoder.h in Headers */,
3684
				56BC6D7C1343B92E006BD7A3 /* WKMessageID.h in Headers */,
3654
			);
3685
			);
3655
			runOnlyForDeploymentPostprocessing = 0;
3686
			runOnlyForDeploymentPostprocessing = 0;
3656
		};
3687
		};
Lines 4275-4280 Source/WebKit2/WebKit2.xcodeproj/project.pbxproj_sec10
4275
				5123CF1B133D260A0056F800 /* WKIconDatabaseCG.cpp in Sources */,
4306
				5123CF1B133D260A0056F800 /* WKIconDatabaseCG.cpp in Sources */,
4276
				F6A90813133C20510082C3F4 /* WebCookieManagerMac.mm in Sources */,
4307
				F6A90813133C20510082C3F4 /* WebCookieManagerMac.mm in Sources */,
4277
				F6D632BC133D198200743D77 /* WebCookieManagerProxyMac.mm in Sources */,
4308
				F6D632BC133D198200743D77 /* WebCookieManagerProxyMac.mm in Sources */,
4309
				56CE714B1333BAB10049D89E /* InjectedBundleEventSender.cpp in Sources */,
4310
				56CE715A1333BBC10049D89E /* WKBundleEventSender.cpp in Sources */,
4311
				56BC6D7613439C9C006BD7A3 /* WKArgumentDecoder.cpp in Sources */,
4278
			);
4312
			);
4279
			runOnlyForDeploymentPostprocessing = 0;
4313
			runOnlyForDeploymentPostprocessing = 0;
4280
		};
4314
		};
- Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +4 lines
Lines 28-33 Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp_sec1
28
28
29
#include "Arguments.h"
29
#include "Arguments.h"
30
#include "ImmutableArray.h"
30
#include "ImmutableArray.h"
31
#include "InjectedBundleEventSender.h"
31
#include "InjectedBundleMessageKinds.h"
32
#include "InjectedBundleMessageKinds.h"
32
#include "InjectedBundleScriptWorld.h"
33
#include "InjectedBundleScriptWorld.h"
33
#include "InjectedBundleUserMessageCoders.h"
34
#include "InjectedBundleUserMessageCoders.h"
Lines 57-62 InjectedBundle::InjectedBundle(const Str Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp_sec2
57
    : m_path(path)
58
    : m_path(path)
58
    , m_platformBundle(0)
59
    , m_platformBundle(0)
59
{
60
{
61
#if PLATFORM(MAC)
62
    m_eventSender = toAPI(InjectedBundleEventSender::create());
63
#endif
60
    initializeClient(0);
64
    initializeClient(0);
61
}
65
}
62
66
- Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h -1 / +4 lines
Lines 28-33 Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h_sec1
28
28
29
#include "APIObject.h"
29
#include "APIObject.h"
30
#include "InjectedBundleClient.h"
30
#include "InjectedBundleClient.h"
31
#include "InjectedBundleEventSender.h"
31
#include "SandboxExtension.h"
32
#include "SandboxExtension.h"
32
#include "WKBundle.h"
33
#include "WKBundle.h"
33
#include <WebCore/UserContentTypes.h>
34
#include <WebCore/UserContentTypes.h>
Lines 78-85 public: Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h_sec2
78
79
79
    // API
80
    // API
80
    void initializeClient(WKBundleClient*);
81
    void initializeClient(WKBundleClient*);
81
    void postMessage(const String&, APIObject*);
82
    static void postMessage(const String&, APIObject*);
82
    void postSynchronousMessage(const String&, APIObject*, RefPtr<APIObject>& returnData);
83
    void postSynchronousMessage(const String&, APIObject*, RefPtr<APIObject>& returnData);
84
    WKBundleEventSenderRef eventSender() const { return m_eventSender; }
83
#if PLATFORM(WIN)
85
#if PLATFORM(WIN)
84
    void setHostAllowsAnyHTTPSCertificate(const String&);
86
    void setHostAllowsAnyHTTPSCertificate(const String&);
85
    void setClientCertificate(const String&, const WebCertificateInfo*);
87
    void setClientCertificate(const String&, const WebCertificateInfo*);
Lines 124-129 private: Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h_sec3
124
    String m_path;
126
    String m_path;
125
    PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module.
127
    PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module.
126
128
129
    WKBundleEventSenderRef m_eventSender;
127
    RefPtr<SandboxExtension> m_sandboxExtension;
130
    RefPtr<SandboxExtension> m_sandboxExtension;
128
131
129
    InjectedBundleClient m_client;
132
    InjectedBundleClient m_client;
- Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleEventSender.cpp +69 lines
Line 0 Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleEventSender.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "InjectedBundleEventSender.h"
29
30
#include "APIObject.h"
31
#include "ArgumentCoders.h"
32
#include "EventSenderProxyMessages.h"
33
#include <InjectedBundle.h>
34
#include <MessageID.h>
35
#include <WKString.h>
36
#include <WebContextMessageKinds.h>
37
#include <WebCore/UserContentTypes.h>
38
#include <WebCore/UserScriptTypes.h>
39
#include <WebData.h>
40
#include <WebKit2/WKRetainPtr.h>
41
#include <WebProcess.h>
42
#include <wtf/PassRefPtr.h>
43
#include <wtf/text/WTFString.h>
44
45
namespace WebKit {
46
47
InjectedBundleEventSender* InjectedBundleEventSender::create()
48
{
49
    return new InjectedBundleEventSender();
50
}
51
52
InjectedBundleEventSender::InjectedBundleEventSender()
53
{
54
}
55
56
InjectedBundleEventSender::~InjectedBundleEventSender()
57
{
58
}
59
60
void InjectedBundleEventSender::keyDown(const String& key, unsigned int modif, unsigned int location)
61
{
62
    OwnPtr<CoreIPC::ArgumentEncoder> argumentEncoder = CoreIPC::ArgumentEncoder::create(0);
63
    argumentEncoder->encode(Messages::EventSenderProxy::KeyDown(key, modif, location));
64
    RefPtr<WebData> webData = WebData::create(argumentEncoder->buffer(), argumentEncoder->bufferSize());
65
    InjectedBundle::postMessage("EventSender", webData.release().get());
66
}
67
68
} // namespace WebKit
69
- Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleEventSender.h +49 lines
Line 0 Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleEventSender.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#ifndef InjectedBundleEventSender_h
28
#define InjectedBundleEventSender_h
29
30
#include "APIObject.h"
31
#include <wtf/PassRefPtr.h>
32
#include <wtf/text/WTFString.h>
33
34
namespace WebKit {
35
36
class InjectedBundleEventSender {
37
public:
38
    static InjectedBundleEventSender* create();
39
    ~InjectedBundleEventSender();
40
41
    void keyDown(const String& key, unsigned int modif, unsigned int location);
42
43
private:
44
    InjectedBundleEventSender();
45
};
46
47
} // namespace WebKit
48
49
#endif // InjectedBundleEventSender_h
- Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h +6 lines
Lines 27-32 Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h_sec1
27
#define InjectedBundleUserMessageCoders_h
27
#define InjectedBundleUserMessageCoders_h
28
28
29
#include "UserMessageCoders.h"
29
#include "UserMessageCoders.h"
30
#include "WebData.h"
30
#include "WebFrame.h"
31
#include "WebFrame.h"
31
#include "WebPage.h"
32
#include "WebPage.h"
32
#include "WebPageGroupData.h"
33
#include "WebPageGroupData.h"
Lines 71-76 public: Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h_sec2
71
            encoder->encode(pageGroup->pageGroupID());
72
            encoder->encode(pageGroup->pageGroupID());
72
            break;
73
            break;
73
        }
74
        }
75
        case APIObject::TypeData: {
76
            WebData* webData = static_cast<WebData*>(m_root);
77
            encoder->encodeBytes(webData->bytes(), webData->size());
78
            break;
79
        }
74
        default:
80
        default:
75
            ASSERT_NOT_REACHED();
81
            ASSERT_NOT_REACHED();
76
            break;
82
            break;
- Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +5 lines
Lines 45-50 void WKBundleSetClient(WKBundleRef bundl Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp_sec1
45
    toImpl(bundleRef)->initializeClient(wkClient);
45
    toImpl(bundleRef)->initializeClient(wkClient);
46
}
46
}
47
47
48
WKBundleEventSenderRef WKBundleGetEventSender(WKBundleRef bundleRef)
49
{
50
    return toImpl(bundleRef)->eventSender();
51
}
52
48
void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
53
void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
49
{
54
{
50
    toImpl(bundleRef)->postMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
55
    toImpl(bundleRef)->postMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
- Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h +2 lines
Lines 51-56 typedef struct WKBundleClient WKBundleCl Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h_sec1
51
51
52
WK_EXPORT WKTypeID WKBundleGetTypeID();
52
WK_EXPORT WKTypeID WKBundleGetTypeID();
53
53
54
WK_EXPORT WKBundleEventSenderRef WKBundleGetEventSender(WKBundleRef bundleRef);
55
54
WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient * client);
56
WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient * client);
55
57
56
WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody);
58
WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody);
- Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h +2 lines
Lines 44-49 namespace WebKit { Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h_sec1
44
class InjectedBundle;
44
class InjectedBundle;
45
class InjectedBundleBackForwardList;
45
class InjectedBundleBackForwardList;
46
class InjectedBundleBackForwardListItem;
46
class InjectedBundleBackForwardListItem;
47
class InjectedBundleEventSender;
47
class InjectedBundleHitTestResult;
48
class InjectedBundleHitTestResult;
48
class InjectedBundleNavigationAction;
49
class InjectedBundleNavigationAction;
49
class InjectedBundleNodeHandle;
50
class InjectedBundleNodeHandle;
Lines 58-63 class WebPageGroupProxy; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h_sec2
58
WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem)
59
WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem)
59
WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
60
WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
60
WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration)
61
WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration)
62
WK_ADD_API_MAPPING(WKBundleEventSenderRef, InjectedBundleEventSender)
61
WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
63
WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
62
WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
64
WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
63
WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
65
WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
- Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleEventSender.cpp +39 lines
Line 0 Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleEventSender.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "WKBundleEventSender.h"
29
30
#include "InjectedBundleEventSender.h"
31
#include "WKBundleAPICast.h"
32
33
using namespace WebKit;
34
35
void WKBundleEventSenderKeyDown(WKBundleEventSenderRef eventSenderRef, WKStringRef keyRef, uint32_t modif, uint32_t location)
36
{
37
    toImpl(eventSenderRef)->keyDown(toImpl(keyRef)->string(), static_cast<unsigned int>(toImpl(modif)), toImpl(location));
38
}
39
- Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleEventSender.h +44 lines
Line 0 Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleEventSender.h_sec1
1
/*
2
 * Copyright (C) 2010 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#ifndef WKBundleEventSender_h
28
#define WKBundleEventSender_h
29
30
#include <WebKit2/WKBase.h>
31
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
36
WK_EXPORT WKTypeID WKBundleEventSenderGetTypeID();
37
38
WK_EXPORT void WKBundleEventSenderKeyDown(WKBundleEventSenderRef eventSenderRef, WKStringRef keyRef, uint32_t modif, uint32_t location);
39
40
#ifdef __cplusplus
41
}
42
#endif
43
44
#endif // WKBundleEventSender_h
- Tools/ChangeLog +30 lines
Lines 1-3 Tools/ChangeLog_sec1
1
2011-03-31  Chang Shu  <cshu@webkit.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        [Mac] [WK2] Implement KeyDown function for WebKit2 EventSender.
6
        https://bugs.webkit.org/show_bug.cgi?id=57515
7
8
        The following code change builds up the infrastructure for
9
        WebKitTestRunner EventSender to send messages from the InjectedBundle
10
        in WebProcess to UIProcess of WebKitTestRunner.
11
12
        The basic KeyDown functionality is implemented except the local implementation.
13
14
        * WebKitTestRunner/EventSenderProxy.cpp: Added.
15
        (WTR::EventSenderProxy::create):
16
        (WTR::EventSenderProxy::EventSenderProxy):
17
        (WTR::EventSenderProxy::didReceiveEventSenderProxyMessage):
18
        * WebKitTestRunner/EventSenderProxy.h: Added.
19
        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
20
        (WTR::EventSendingController::keyDown):
21
        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
22
        (WTR::InjectedBundle::eventSender):
23
        * WebKitTestRunner/TestController.cpp:
24
        (WTR::TestController::TestController):
25
        (WTR::TestController::didReceiveMessageFromInjectedBundle):
26
        * WebKitTestRunner/TestController.h:
27
        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
28
        * WebKitTestRunner/mac/EventSender.h: Added.
29
        * WebKitTestRunner/mac/EventSenderMac.mm: Added.
30
1
2011-03-31  Sergio Villar Senin  <svillar@igalia.com>
31
2011-03-31  Sergio Villar Senin  <svillar@igalia.com>
2
32
3
        Reviewed by Martin Robinson.
33
        Reviewed by Martin Robinson.
- Tools/Scripts/build-webkit +1 lines
Lines 505-510 if (isGtk()) { Tools/Scripts/build-webkit_sec1
505
    push @options, "--install-headers=" . $installHeaders if defined($installHeaders);
505
    push @options, "--install-headers=" . $installHeaders if defined($installHeaders);
506
    push @options, "--install-libs=" . $installLibs if defined($installLibs);
506
    push @options, "--install-libs=" . $installLibs if defined($installLibs);
507
    push @options, "--makeargs=" . $makeArgs if $makeArgs;
507
    push @options, "--makeargs=" . $makeArgs if $makeArgs;
508
    push @options, "--qmakearg=CONFIG+=webkit2" if !$noWebKit2;
508
509
509
    foreach (@features) {
510
    foreach (@features) {
510
        push @options, "DEFINES+=$_->{define}=${$_->{value}}" if ${$_->{value}} != $_->{default};
511
        push @options, "DEFINES+=$_->{define}=${$_->{value}}" if ${$_->{value}} != $_->{default};
- Tools/WebKitTestRunner/EventSenderProxy.cpp +66 lines
Line 0 Tools/WebKitTestRunner/EventSenderProxy.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "EventSenderProxy.h"
29
30
#include <WebKit2/WKArgumentDecoder.h>
31
#include <WebKit2/WKArray.h>
32
#include <WebKit2/WKMessageID.h>
33
34
namespace WTR {
35
36
EventSenderProxy* EventSenderProxy::create(TestController* testController)
37
{
38
    return new EventSenderProxy(testController);
39
}
40
41
EventSenderProxy::EventSenderProxy(TestController* testController)
42
    : m_testController(testController)
43
{
44
// TODO    m_eventSender = new EventSender();
45
};
46
47
void EventSenderProxy::didReceiveEventSenderProxyMessage(WKDataRef webData)
48
{
49
    WKArgumentDecoderRef argumentDecoderRef = WKCreateArgumentDecoder(WKDataGetBytes(webData), WKDataGetSize(webData));
50
    uint32_t messageIDUint32;
51
    if (!WKDecodeUInt32(argumentDecoderRef, messageIDUint32))
52
        return;
53
    switch (static_cast<Messages::EventSenderProxy::Kind>(messageIDUint32)) {
54
    case Messages::EventSenderProxy::KeyDownID:
55
        WKStringRef key;
56
        uint32_t modifiers;
57
        uint32_t location;
58
        if (WKDecodeString(argumentDecoderRef, key) && WKDecodeUInt32(argumentDecoderRef, modifiers) && WKDecodeUInt32(argumentDecoderRef, location))
59
            fputs("Implement keyDown in WTR.\n", stderr); // TODO m_eventSender->keyDown(key, modifiers, location);
60
        break;
61
    default:
62
        ASSERT_NOT_REACHED();
63
    }
64
}
65
66
} // namespace WebKit
- Tools/WebKitTestRunner/EventSenderProxy.h +54 lines
Line 0 Tools/WebKitTestRunner/EventSenderProxy.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24
 * THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#ifndef EventSenderProxy_h
28
#define EventSenderProxy_h
29
30
//TODO #include "EventSender.h"
31
#include "TestController.h"
32
#include "WebKit2/WKString.h"
33
34
using namespace WebKit;
35
36
namespace WTR {
37
38
class EventSenderProxy {
39
public:
40
41
    static EventSenderProxy* create(TestController*);
42
43
    void didReceiveEventSenderProxyMessage(WKDataRef);
44
45
private:
46
    EventSenderProxy(TestController*);
47
48
    TestController* m_testController;
49
// TODO    EventSender* m_eventSender;
50
};
51
52
} // namespace WebKit
53
54
#endif // WebPageProxy_h
- Tools/WebKitTestRunner/TestController.cpp +13 lines
Lines 26-31 Tools/WebKitTestRunner/TestController.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "TestController.h"
27
#include "TestController.h"
28
28
29
#if PLATFORM(MAC)
30
#include <EventSenderProxy.h>
31
#endif
29
#include "PlatformWebView.h"
32
#include "PlatformWebView.h"
30
#include "StringFunctions.h"
33
#include "StringFunctions.h"
31
#include "TestInvocation.h"
34
#include "TestInvocation.h"
Lines 66-71 TestController::TestController(int argc, Tools/WebKitTestRunner/TestController.cpp_sec2
66
    , m_shortTimeout(defaultShortTimeout)
69
    , m_shortTimeout(defaultShortTimeout)
67
    , m_didPrintWebProcessCrashedMessage(false)
70
    , m_didPrintWebProcessCrashedMessage(false)
68
    , m_shouldExitWhenWebProcessCrashes(true)
71
    , m_shouldExitWhenWebProcessCrashes(true)
72
#if PLATFORM(MAC)
73
    , m_eventSenderProxy(EventSenderProxy::create(this))
74
#endif
69
{
75
{
70
    initialize(argc, argv);
76
    initialize(argc, argv);
71
    controller = this;
77
    controller = this;
Lines 458-463 void TestController::didReceiveSynchrono Tools/WebKitTestRunner/TestController.cpp_sec3
458
464
459
void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
465
void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
460
{
466
{
467
#if PLATFORM(MAC)
468
    if (WKStringIsEqualToUTF8CString(messageName, "EventSender")) {
469
        ASSERT(WKGetTypeID(messageBody) == WKDataGetTypeID());
470
        m_eventSenderProxy->didReceiveEventSenderProxyMessage(static_cast<WKDataRef>(messageBody));
471
        return;
472
    }
473
#endif
461
    if (!m_currentInvocation)
474
    if (!m_currentInvocation)
462
        return;
475
        return;
463
    m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody);
476
    m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody);
- Tools/WebKitTestRunner/TestController.h +3 lines
Lines 35-40 namespace WTR { Tools/WebKitTestRunner/TestController.h_sec1
35
35
36
class TestInvocation;
36
class TestInvocation;
37
class PlatformWebView;
37
class PlatformWebView;
38
class EventSenderProxy;
38
39
39
// FIXME: Rename this TestRunner?
40
// FIXME: Rename this TestRunner?
40
class TestController {
41
class TestController {
Lines 120-125 private: Tools/WebKitTestRunner/TestController.h_sec2
120
121
121
    bool m_didPrintWebProcessCrashedMessage;
122
    bool m_didPrintWebProcessCrashedMessage;
122
    bool m_shouldExitWhenWebProcessCrashes;
123
    bool m_shouldExitWhenWebProcessCrashes;
124
125
    EventSenderProxy* m_eventSenderProxy;
123
};
126
};
124
127
125
} // namespace WTR
128
} // namespace WTR
- Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp +34 lines
Lines 29-34 Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp_sec1
29
#include "InjectedBundle.h"
29
#include "InjectedBundle.h"
30
#include "InjectedBundlePage.h"
30
#include "InjectedBundlePage.h"
31
#include "JSEventSendingController.h"
31
#include "JSEventSendingController.h"
32
#include "StringFunctions.h"
33
#if PLATFORM(MAC)
34
#include <WebKit2/WKBundleEventSender.h>
35
#endif
32
#include <WebKit2/WKBundlePage.h>
36
#include <WebKit2/WKBundlePage.h>
33
#include <WebKit2/WKBundlePagePrivate.h>
37
#include <WebKit2/WKBundlePagePrivate.h>
34
#include <WebKit2/WKBundlePrivate.h>
38
#include <WebKit2/WKBundlePrivate.h>
Lines 78-84 void EventSendingController::mouseMoveTo Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp_sec2
78
82
79
void EventSendingController::keyDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
83
void EventSendingController::keyDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
80
{
84
{
85
#if PLATFORM(MAC)
86
    if (!JSValueIsString(context, arguments[0]))
87
        return;
88
    JSRetainPtr<JSStringRef> jsKeyStrRef = JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, arguments[0], 0));
89
    
90
    unsigned int modif = 0;
91
    if (JSValueIsObject(context, arguments[1])) {
92
        JSObjectRef modifObjRef = JSValueToObject(context, arguments[1], exception);
93
        for (int i = 0; i < 4; i++) {
94
            JSValueRef modifValueRef = JSObjectGetPropertyAtIndex(context, modifObjRef, i, exception);
95
            if (JSValueIsString(context, modifValueRef)) {
96
                JSRetainPtr<JSStringRef> jsModifStrRef = JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, modifValueRef, 0));
97
                if (JSStringIsEqualToUTF8CString(jsModifStrRef.get(), "ctrlKey"))
98
                    modif |= kWKEventModifiersControlKey;
99
                else if (JSStringIsEqualToUTF8CString(jsModifStrRef.get(), "shiftKey"))
100
                    modif |= kWKEventModifiersShiftKey;
101
                else if (JSStringIsEqualToUTF8CString(jsModifStrRef.get(), "altKey"))
102
                    modif |= kWKEventModifiersAltKey;
103
                else if (JSStringIsEqualToUTF8CString(jsModifStrRef.get(), "metaKey"))
104
                    modif |= kWKEventModifiersMetaKey;
105
            }
106
        }
107
    }
108
    unsigned int location = 0;
109
    if (JSValueIsNumber(context, arguments[2]))
110
        location = static_cast<unsigned int>(JSValueToNumber(context, arguments[2], exception));
111
112
    WKBundleEventSenderKeyDown(InjectedBundle::shared().eventSender(), toWK(jsKeyStrRef).get(), modif, location);
113
#else
81
    setExceptionForString(context, exception, "EventSender.keyDown is not yet supported.");
114
    setExceptionForString(context, exception, "EventSender.keyDown is not yet supported.");
115
#endif
82
}
116
}
83
117
84
void EventSendingController::contextClick(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
118
void EventSendingController::contextClick(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
- Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h +3 lines
Lines 30-35 Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h_sec1
30
#include "GCController.h"
30
#include "GCController.h"
31
#include "LayoutTestController.h"
31
#include "LayoutTestController.h"
32
#include <WebKit2/WKBase.h>
32
#include <WebKit2/WKBase.h>
33
#include <WebKit2/WKBundle.h>
33
#include <WebKit2/WKRetainPtr.h>
34
#include <WebKit2/WKRetainPtr.h>
34
#include <wtf/OwnPtr.h>
35
#include <wtf/OwnPtr.h>
35
#include <wtf/RefPtr.h>
36
#include <wtf/RefPtr.h>
Lines 51-56 public: Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h_sec2
51
    WKBundleRef bundle() const { return m_bundle; }
52
    WKBundleRef bundle() const { return m_bundle; }
52
    WKBundlePageGroupRef pageGroup() const { return m_pageGroup; }
53
    WKBundlePageGroupRef pageGroup() const { return m_pageGroup; }
53
54
55
    WKBundleEventSenderRef eventSender() const { return WKBundleGetEventSender(m_bundle); }
56
54
    LayoutTestController* layoutTestController() { return m_layoutTestController.get(); }
57
    LayoutTestController* layoutTestController() { return m_layoutTestController.get(); }
55
    GCController* gcController() { return m_gcController.get(); }
58
    GCController* gcController() { return m_gcController.get(); }
56
    EventSendingController* eventSendingController() { return m_eventSendingController.get(); }
59
    EventSendingController* eventSendingController() { return m_eventSendingController.get(); }
- Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj +12 lines
Lines 21-26 Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj_sec1
21
/* End PBXAggregateTarget section */
21
/* End PBXAggregateTarget section */
22
22
23
/* Begin PBXBuildFile section */
23
/* Begin PBXBuildFile section */
24
		561781761344CC3B007A90A8 /* EventSenderMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 561781751344CC3B007A90A8 /* EventSenderMac.mm */; };
25
		56CE71801333C7140049D89E /* EventSenderProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56CE717E1333C7140049D89E /* EventSenderProxy.cpp */; };
24
		6510A78211EC643800410867 /* AHEM____.TTF in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77711EC643800410867 /* AHEM____.TTF */; };
26
		6510A78211EC643800410867 /* AHEM____.TTF in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77711EC643800410867 /* AHEM____.TTF */; };
25
		6510A78311EC643800410867 /* ColorBits.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77811EC643800410867 /* ColorBits.ttf */; };
27
		6510A78311EC643800410867 /* ColorBits.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77811EC643800410867 /* ColorBits.ttf */; };
26
		6510A78411EC643800410867 /* WebKitWeightWatcher100.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */; };
28
		6510A78411EC643800410867 /* WebKitWeightWatcher100.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */; };
Lines 78-83 Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj_sec2
78
80
79
/* Begin PBXFileReference section */
81
/* Begin PBXFileReference section */
80
		378D442213346D00006A777B /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
82
		378D442213346D00006A777B /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
83
		561781741344CC28007A90A8 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
84
		561781751344CC3B007A90A8 /* EventSenderMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventSenderMac.mm; sourceTree = "<group>"; };
85
		56CE717E1333C7140049D89E /* EventSenderProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventSenderProxy.cpp; sourceTree = "<group>"; };
86
		56CE717F1333C7140049D89E /* EventSenderProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSenderProxy.h; sourceTree = "<group>"; };
81
		6510A77711EC643800410867 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
87
		6510A77711EC643800410867 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
82
		6510A77811EC643800410867 /* ColorBits.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ColorBits.ttf; path = fonts/ColorBits.ttf; sourceTree = "<group>"; };
88
		6510A77811EC643800410867 /* ColorBits.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ColorBits.ttf; path = fonts/ColorBits.ttf; sourceTree = "<group>"; };
83
		6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher100.ttf; path = fonts/WebKitWeightWatcher100.ttf; sourceTree = "<group>"; };
89
		6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher100.ttf; path = fonts/WebKitWeightWatcher100.ttf; sourceTree = "<group>"; };
Lines 185-190 Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj_sec3
185
			children = (
191
			children = (
186
				BC9192021333E4CD003011DC /* cg */,
192
				BC9192021333E4CD003011DC /* cg */,
187
				BC7933FE118F7C74005EA8E2 /* mac */,
193
				BC7933FE118F7C74005EA8E2 /* mac */,
194
				56CE717E1333C7140049D89E /* EventSenderProxy.cpp */,
195
				56CE717F1333C7140049D89E /* EventSenderProxy.h */,
188
				BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
196
				BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */,
189
				BC7934DD119066EC005EA8E2 /* PlatformWebView.h */,
197
				BC7934DD119066EC005EA8E2 /* PlatformWebView.h */,
190
				BC79342F118F7F19005EA8E2 /* TestController.h */,
198
				BC79342F118F7F19005EA8E2 /* TestController.h */,
Lines 276-281 Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj_sec4
276
		BC7933FE118F7C74005EA8E2 /* mac */ = {
284
		BC7933FE118F7C74005EA8E2 /* mac */ = {
277
			isa = PBXGroup;
285
			isa = PBXGroup;
278
			children = (
286
			children = (
287
				561781751344CC3B007A90A8 /* EventSenderMac.mm */,
288
				561781741344CC28007A90A8 /* EventSender.h */,
279
				BC7933FF118F7C84005EA8E2 /* main.mm */,
289
				BC7933FF118F7C84005EA8E2 /* main.mm */,
280
				BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
290
				BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
281
				BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
291
				BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
Lines 452-457 Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj_sec5
452
				BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
462
				BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
453
				BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
463
				BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
454
				BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
464
				BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
465
				56CE71801333C7140049D89E /* EventSenderProxy.cpp in Sources */,
466
				561781761344CC3B007A90A8 /* EventSenderMac.mm in Sources */,
455
			);
467
			);
456
			runOnlyForDeploymentPostprocessing = 0;
468
			runOnlyForDeploymentPostprocessing = 0;
457
		};
469
		};
- Tools/WebKitTestRunner/mac/EventSender.h +56 lines
Line 0 Tools/WebKitTestRunner/mac/EventSender.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer. 
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution. 
13
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission. 
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
29
#if 0 // TODO
30
#import <Cocoa/Cocoa.h>
31
#import <WebKit/WebKit.h>
32
33
@interface EventSender : NSObject <DOMEventListener> {
34
    BOOL leftMouseButtonDown;
35
    BOOL dragMode;
36
    int clickCount;
37
    NSTimeInterval lastClick;
38
    int eventNumber;
39
    double timeOffset;
40
}
41
42
+ (void)saveEvent:(NSInvocation *)event;
43
+ (void)replaySavedEvents;
44
+ (void)clearSavedEvents;
45
46
- (void)scheduleAsynchronousClick;
47
48
- (void)enableDOMUIEventLogging:(WebScriptObject *)node;
49
50
- (void)handleEvent:(DOMEvent *)event;
51
52
@end
53
54
extern NSPoint lastMousePosition;
55
extern NSPoint lastClickPosition;
56
#endif
- Tools/WebKitTestRunner/mac/EventSenderMac.mm +867 lines
Line 0 Tools/WebKitTestRunner/mac/EventSenderMac.mm_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer. 
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution. 
13
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission. 
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
29
#if 0
30
#import "config.h"
31
#import "EventSender.h"
32
33
#import "DumpRenderTree.h"
34
#import "DumpRenderTreeDraggingInfo.h"
35
#import "DumpRenderTreeFileDraggingSource.h"
36
37
#import <Carbon/Carbon.h>                           // for GetCurrentEventTime()
38
#import <WebKit/DOMPrivate.h>
39
#import <WebKit/WebKit.h>
40
#import <WebKit/WebViewPrivate.h>
41
42
extern "C" void _NSNewKillRingSequence();
43
44
enum MouseAction {
45
    MouseDown,
46
    MouseUp,
47
    MouseDragged
48
};
49
50
// Match the DOM spec (sadly the DOM spec does not provide an enum)
51
enum MouseButton {
52
    LeftMouseButton = 0,
53
    MiddleMouseButton = 1,
54
    RightMouseButton = 2,
55
    NoMouseButton = -1
56
};
57
58
NSPoint lastMousePosition;
59
NSPoint lastClickPosition;
60
int lastClickButton = NoMouseButton;
61
NSArray *webkitDomEventNames;
62
NSMutableArray *savedMouseEvents; // mouse events sent between mouseDown and mouseUp are stored here, and then executed at once.
63
BOOL replayingSavedEvents;
64
65
@implementation EventSender
66
67
+ (void)initialize
68
{
69
    webkitDomEventNames = [[NSArray alloc] initWithObjects:
70
        @"abort",
71
        @"beforecopy",
72
        @"beforecut",
73
        @"beforepaste",
74
        @"blur",
75
        @"change",
76
        @"click",
77
        @"contextmenu",
78
        @"copy",
79
        @"cut",
80
        @"dblclick",
81
        @"drag",
82
        @"dragend",
83
        @"dragenter",
84
        @"dragleave",
85
        @"dragover",
86
        @"dragstart",
87
        @"drop",
88
        @"error",
89
        @"focus",
90
        @"input",
91
        @"keydown",
92
        @"keypress",
93
        @"keyup",
94
        @"load",
95
        @"mousedown",
96
        @"mousemove",
97
        @"mouseout",
98
        @"mouseover",
99
        @"mouseup",
100
        @"mousewheel",
101
        @"beforeunload",
102
        @"paste",
103
        @"readystatechange",
104
        @"reset",
105
        @"resize", 
106
        @"scroll", 
107
        @"search",
108
        @"select",
109
        @"selectstart",
110
        @"submit", 
111
        @"textInput", 
112
        @"textzoomin",
113
        @"textzoomout",
114
        @"unload",
115
        @"zoom",
116
        nil];
117
}
118
119
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
120
{
121
    if (aSelector == @selector(beginDragWithFiles:)
122
            || aSelector == @selector(clearKillRing)
123
            || aSelector == @selector(contextClick)
124
            || aSelector == @selector(enableDOMUIEventLogging:)
125
            || aSelector == @selector(fireKeyboardEventsToElement:)
126
            || aSelector == @selector(keyDown:withModifiers:withLocation:)
127
            || aSelector == @selector(leapForward:)
128
            || aSelector == @selector(mouseDown:withModifiers:)
129
            || aSelector == @selector(mouseMoveToX:Y:)
130
            || aSelector == @selector(mouseUp:withModifiers:)
131
            || aSelector == @selector(scheduleAsynchronousClick)
132
            || aSelector == @selector(textZoomIn)
133
            || aSelector == @selector(textZoomOut)
134
            || aSelector == @selector(zoomPageIn)
135
            || aSelector == @selector(zoomPageOut)
136
            || aSelector == @selector(mouseScrollByX:andY:)
137
            || aSelector == @selector(continuousMouseScrollByX:andY:))
138
        return NO;
139
    return YES;
140
}
141
142
+ (BOOL)isKeyExcludedFromWebScript:(const char*)name
143
{
144
    if (strcmp(name, "dragMode") == 0)
145
        return NO;
146
    return YES;
147
}
148
149
+ (NSString *)webScriptNameForSelector:(SEL)aSelector
150
{
151
    if (aSelector == @selector(beginDragWithFiles:))
152
        return @"beginDragWithFiles";
153
    if (aSelector == @selector(contextClick))
154
        return @"contextClick";
155
    if (aSelector == @selector(enableDOMUIEventLogging:))
156
        return @"enableDOMUIEventLogging";
157
    if (aSelector == @selector(fireKeyboardEventsToElement:))
158
        return @"fireKeyboardEventsToElement";
159
    if (aSelector == @selector(keyDown:withModifiers:withLocation:))
160
        return @"keyDown";
161
    if (aSelector == @selector(leapForward:))
162
        return @"leapForward";
163
    if (aSelector == @selector(mouseDown:withModifiers:))
164
        return @"mouseDown";
165
    if (aSelector == @selector(mouseUp:withModifiers:))
166
        return @"mouseUp";
167
    if (aSelector == @selector(mouseMoveToX:Y:))
168
        return @"mouseMoveTo";
169
    if (aSelector == @selector(setDragMode:))
170
        return @"setDragMode";
171
    if (aSelector == @selector(mouseScrollByX:andY:))
172
        return @"mouseScrollBy";
173
    if (aSelector == @selector(continuousMouseScrollByX:andY:))
174
        return @"continuousMouseScrollBy";
175
    return nil;
176
}
177
178
- (id)init
179
{
180
    self = [super init];
181
    if (self)
182
        dragMode = YES;
183
    return self;
184
}
185
186
- (void)dealloc
187
{
188
    [super dealloc];
189
}
190
191
- (double)currentEventTime
192
{
193
    return GetCurrentEventTime() + timeOffset;
194
}
195
196
- (void)leapForward:(int)milliseconds
197
{
198
    if (dragMode && leftMouseButtonDown && !replayingSavedEvents) {
199
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[EventSender instanceMethodSignatureForSelector:@selector(leapForward:)]];
200
        [invocation setTarget:self];
201
        [invocation setSelector:@selector(leapForward:)];
202
        [invocation setArgument:&milliseconds atIndex:2];
203
        
204
        [EventSender saveEvent:invocation];
205
        
206
        return;
207
    }
208
209
    timeOffset += milliseconds / 1000.0;
210
}
211
212
- (void)clearKillRing
213
{
214
    _NSNewKillRingSequence();
215
}
216
217
static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction action)
218
{
219
    switch (button) {
220
        case LeftMouseButton:
221
            switch (action) {
222
                case MouseDown:
223
                    return NSLeftMouseDown;
224
                case MouseUp:
225
                    return NSLeftMouseUp;
226
                case MouseDragged:
227
                    return NSLeftMouseDragged;
228
            }
229
        case RightMouseButton:
230
            switch (action) {
231
                case MouseDown:
232
                    return NSRightMouseDown;
233
                case MouseUp:
234
                    return NSRightMouseUp;
235
                case MouseDragged:
236
                    return NSRightMouseDragged;
237
            }
238
        default:
239
            switch (action) {
240
                case MouseDown:
241
                    return NSOtherMouseDown;
242
                case MouseUp:
243
                    return NSOtherMouseUp;
244
                case MouseDragged:
245
                    return NSOtherMouseDragged;
246
            }
247
    }
248
    assert(0);
249
    return static_cast<NSEventType>(0);
250
}
251
252
- (void)beginDragWithFiles:(WebScriptObject*)jsFilePaths
253
{
254
    assert(!draggingInfo);
255
    assert([jsFilePaths isKindOfClass:[WebScriptObject class]]);
256
257
    NSPasteboard *pboard = [NSPasteboard pasteboardWithUniqueName];
258
    [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
259
260
    NSURL *currentTestURL = [NSURL URLWithString:[[mainFrame webView] mainFrameURL]];
261
262
    NSMutableArray *filePaths = [NSMutableArray array];
263
    for (unsigned i = 0; [[jsFilePaths webScriptValueAtIndex:i] isKindOfClass:[NSString class]]; i++) {
264
        NSString *filePath = (NSString *)[jsFilePaths webScriptValueAtIndex:i];
265
        // Have NSURL encode the name so that we handle '?' in file names correctly.
266
        NSURL *fileURL = [NSURL fileURLWithPath:filePath];
267
        NSURL *absoluteFileURL = [NSURL URLWithString:[fileURL relativeString]  relativeToURL:currentTestURL];
268
        [filePaths addObject:[absoluteFileURL path]];
269
    }
270
271
    [pboard setPropertyList:filePaths forType:NSFilenamesPboardType];
272
    assert([pboard propertyListForType:NSFilenamesPboardType]); // setPropertyList will silently fail on error, assert that it didn't fail
273
274
    // Provide a source, otherwise [DumpRenderTreeDraggingInfo draggingSourceOperationMask] defaults to NSDragOperationNone
275
    DumpRenderTreeFileDraggingSource *source = [[[DumpRenderTreeFileDraggingSource alloc] init] autorelease];
276
    draggingInfo = [[DumpRenderTreeDraggingInfo alloc] initWithImage:nil offset:NSZeroSize pasteboard:pboard source:source];
277
    [[mainFrame webView] draggingEntered:draggingInfo];
278
279
    dragMode = NO; // dragMode saves events and then replays them later.  We don't need/want that.
280
    leftMouseButtonDown = YES; // Make the rest of eventSender think a drag is in progress
281
}
282
283
- (void)updateClickCountForButton:(int)buttonNumber
284
{
285
    if (([self currentEventTime] - lastClick >= 1) ||
286
        !NSEqualPoints(lastMousePosition, lastClickPosition) ||
287
        lastClickButton != buttonNumber) {
288
        clickCount = 1;
289
        lastClickButton = buttonNumber;
290
    } else
291
        clickCount++;
292
}
293
294
static int buildModifierFlags(const WebScriptObject* modifiers)
295
{
296
    int flags = 0;
297
    if (![modifiers isKindOfClass:[WebScriptObject class]])
298
        return flags;
299
    for (unsigned i = 0; [[modifiers webScriptValueAtIndex:i] isKindOfClass:[NSString class]]; i++) {
300
        NSString* modifierName = (NSString*)[modifiers webScriptValueAtIndex:i];
301
        if ([modifierName isEqual:@"ctrlKey"])
302
            flags |= NSControlKeyMask;
303
        else if ([modifierName isEqual:@"shiftKey"] || [modifierName isEqual:@"rangeSelectionKey"])
304
            flags |= NSShiftKeyMask;
305
        else if ([modifierName isEqual:@"altKey"])
306
            flags |= NSAlternateKeyMask;
307
        else if ([modifierName isEqual:@"metaKey"] || [modifierName isEqual:@"addSelectionKey"])
308
            flags |= NSCommandKeyMask;
309
    }
310
    return flags;
311
}
312
313
- (void)mouseDown:(int)buttonNumber withModifiers:(WebScriptObject*)modifiers
314
{
315
    [[[mainFrame frameView] documentView] layout];
316
    [self updateClickCountForButton:buttonNumber];
317
    
318
    NSEventType eventType = eventTypeForMouseButtonAndAction(buttonNumber, MouseDown);
319
    NSEvent *event = [NSEvent mouseEventWithType:eventType
320
                                        location:lastMousePosition 
321
                                   modifierFlags:buildModifierFlags(modifiers)
322
                                       timestamp:[self currentEventTime]
323
                                    windowNumber:[[[mainFrame webView] window] windowNumber] 
324
                                         context:[NSGraphicsContext currentContext] 
325
                                     eventNumber:++eventNumber 
326
                                      clickCount:clickCount 
327
                                        pressure:0.0];
328
329
    NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
330
    if (subView) {
331
        [subView mouseDown:event];
332
        if (buttonNumber == LeftMouseButton)
333
            leftMouseButtonDown = YES;
334
    }
335
}
336
337
- (void)mouseDown:(int)buttonNumber
338
{
339
    [self mouseDown:buttonNumber withModifiers:nil];
340
}
341
342
- (void)textZoomIn
343
{
344
    [[mainFrame webView] makeTextLarger:self];
345
}
346
347
- (void)textZoomOut
348
{
349
    [[mainFrame webView] makeTextSmaller:self];
350
}
351
352
- (void)zoomPageIn
353
{
354
    [[mainFrame webView] zoomPageIn:self];
355
}
356
357
- (void)zoomPageOut
358
{
359
    [[mainFrame webView] zoomPageOut:self];
360
}
361
362
- (void)mouseUp:(int)buttonNumber withModifiers:(WebScriptObject*)modifiers
363
{
364
    if (dragMode && !replayingSavedEvents) {
365
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[EventSender instanceMethodSignatureForSelector:@selector(mouseUp:withModifiers:)]];
366
        [invocation setTarget:self];
367
        [invocation setSelector:@selector(mouseUp:withModifiers:)];
368
        [invocation setArgument:&buttonNumber atIndex:2];
369
        [invocation setArgument:&modifiers atIndex:3];
370
        
371
        [EventSender saveEvent:invocation];
372
        [EventSender replaySavedEvents];
373
374
        return;
375
    }
376
377
    [[[mainFrame frameView] documentView] layout];
378
    NSEventType eventType = eventTypeForMouseButtonAndAction(buttonNumber, MouseUp);
379
    NSEvent *event = [NSEvent mouseEventWithType:eventType
380
                                        location:lastMousePosition 
381
                                   modifierFlags:buildModifierFlags(modifiers)
382
                                       timestamp:[self currentEventTime]
383
                                    windowNumber:[[[mainFrame webView] window] windowNumber] 
384
                                         context:[NSGraphicsContext currentContext] 
385
                                     eventNumber:++eventNumber 
386
                                      clickCount:clickCount 
387
                                        pressure:0.0];
388
389
    NSView *targetView = [[mainFrame webView] hitTest:[event locationInWindow]];
390
    // FIXME: Silly hack to teach DRT to respect capturing mouse events outside the WebView.
391
    // The right solution is just to use NSApplication's built-in event sending methods, 
392
    // instead of rolling our own algorithm for selecting an event target.
393
    targetView = targetView ? targetView : [[mainFrame frameView] documentView];
394
    assert(targetView);
395
    [targetView mouseUp:event];
396
    if (buttonNumber == LeftMouseButton)
397
        leftMouseButtonDown = NO;
398
    lastClick = [event timestamp];
399
    lastClickPosition = lastMousePosition;
400
    if (draggingInfo) {
401
        WebView *webView = [mainFrame webView];
402
        
403
        NSDragOperation dragOperation = [webView draggingUpdated:draggingInfo];
404
        
405
        if (dragOperation != NSDragOperationNone)
406
            [webView performDragOperation:draggingInfo];
407
        else
408
            [webView draggingExited:draggingInfo];
409
        // Per NSDragging.h: draggingSources may not implement draggedImage:endedAt:operation:
410
        if ([[draggingInfo draggingSource] respondsToSelector:@selector(draggedImage:endedAt:operation:)])
411
            [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] endedAt:lastMousePosition operation:dragOperation];
412
        [draggingInfo release];
413
        draggingInfo = nil;
414
    }
415
}
416
417
- (void)mouseUp:(int)buttonNumber
418
{
419
    [self mouseUp:buttonNumber withModifiers:nil];
420
}
421
422
- (void)mouseMoveToX:(int)x Y:(int)y
423
{
424
    if (dragMode && leftMouseButtonDown && !replayingSavedEvents) {
425
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[EventSender instanceMethodSignatureForSelector:@selector(mouseMoveToX:Y:)]];
426
        [invocation setTarget:self];
427
        [invocation setSelector:@selector(mouseMoveToX:Y:)];
428
        [invocation setArgument:&x atIndex:2];
429
        [invocation setArgument:&y atIndex:3];
430
        
431
        [EventSender saveEvent:invocation];
432
        return;
433
    }
434
435
    NSView *view = [mainFrame webView];
436
    lastMousePosition = [view convertPoint:NSMakePoint(x, [view frame].size.height - y) toView:nil];
437
    NSEvent *event = [NSEvent mouseEventWithType:(leftMouseButtonDown ? NSLeftMouseDragged : NSMouseMoved)
438
                                        location:lastMousePosition 
439
                                   modifierFlags:0 
440
                                       timestamp:[self currentEventTime]
441
                                    windowNumber:[[view window] windowNumber] 
442
                                         context:[NSGraphicsContext currentContext] 
443
                                     eventNumber:++eventNumber 
444
                                      clickCount:(leftMouseButtonDown ? clickCount : 0) 
445
                                        pressure:0.0];
446
447
    NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
448
    if (subView) {
449
        if (leftMouseButtonDown) {
450
            if (draggingInfo) {
451
                // Per NSDragging.h: draggingSources may not implement draggedImage:movedTo:
452
                if ([[draggingInfo draggingSource] respondsToSelector:@selector(draggedImage:movedTo:)])
453
                    [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition];
454
                [[mainFrame webView] draggingUpdated:draggingInfo];
455
            } else
456
                [subView mouseDragged:event];
457
        } else
458
            [subView mouseMoved:event];
459
    }
460
}
461
462
- (void)mouseScrollByX:(int)x andY:(int)y continuously:(BOOL)c
463
{
464
    // CGEventCreateScrollWheelEvent() was introduced in 10.5
465
#if !defined(BUILDING_ON_TIGER)
466
    CGScrollEventUnit unit = c?kCGScrollEventUnitPixel:kCGScrollEventUnitLine;
467
    CGEventRef cgScrollEvent = CGEventCreateScrollWheelEvent(NULL, unit, 2, y, x);
468
    
469
    // CGEvent locations are in global display coordinates.
470
    CGPoint lastGlobalMousePosition = {
471
        lastMousePosition.x,
472
        [[NSScreen mainScreen] frame].size.height - lastMousePosition.y
473
    };
474
    CGEventSetLocation(cgScrollEvent, lastGlobalMousePosition);
475
476
    NSEvent *scrollEvent = [NSEvent eventWithCGEvent:cgScrollEvent];
477
    CFRelease(cgScrollEvent);
478
479
    NSView *subView = [[mainFrame webView] hitTest:[scrollEvent locationInWindow]];
480
    if (subView)
481
        [subView scrollWheel:scrollEvent];
482
#endif
483
}
484
485
- (void)continuousMouseScrollByX:(int)x andY:(int)y
486
{
487
    [self mouseScrollByX:x andY:y continuously:YES];
488
}
489
490
- (void)mouseScrollByX:(int)x andY:(int)y
491
{
492
    [self mouseScrollByX:x andY:y continuously:NO];
493
}
494
495
- (NSArray *)contextClick
496
{
497
    [[[mainFrame frameView] documentView] layout];
498
    [self updateClickCountForButton:RightMouseButton];
499
500
    NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseDown
501
                                        location:lastMousePosition 
502
                                   modifierFlags:0 
503
                                       timestamp:[self currentEventTime]
504
                                    windowNumber:[[[mainFrame webView] window] windowNumber] 
505
                                         context:[NSGraphicsContext currentContext] 
506
                                     eventNumber:++eventNumber 
507
                                      clickCount:clickCount 
508
                                        pressure:0.0];
509
510
    NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
511
    NSMutableArray *menuItemStrings = [NSMutableArray array];
512
    
513
    if (subView) {
514
        NSMenu* menu = [subView menuForEvent:event];
515
516
        for (int i = 0; i < [menu numberOfItems]; ++i) {
517
            NSMenuItem* menuItem = [menu itemAtIndex:i];
518
            if (!strcmp("Inspect Element", [[menuItem title] UTF8String]))
519
                continue;
520
521
            if ([menuItem isSeparatorItem])
522
                [menuItemStrings addObject:@"<separator>"];
523
            else
524
                [menuItemStrings addObject:[menuItem title]];
525
        }
526
    }
527
    
528
    return menuItemStrings;
529
}
530
531
- (void)scheduleAsynchronousClick
532
{
533
    [self performSelector:@selector(mouseDown:) withObject:nil afterDelay:0];
534
    [self performSelector:@selector(mouseUp:) withObject:nil afterDelay:0];
535
}
536
537
+ (void)saveEvent:(NSInvocation *)event
538
{
539
    if (!savedMouseEvents)
540
        savedMouseEvents = [[NSMutableArray alloc] init];
541
    [savedMouseEvents addObject:event];
542
}
543
544
+ (void)replaySavedEvents
545
{
546
    replayingSavedEvents = YES;
547
    while ([savedMouseEvents count]) {
548
        // if a drag is initiated, the remaining saved events will be dispatched from our dragging delegate
549
        NSInvocation *invocation = [[[savedMouseEvents objectAtIndex:0] retain] autorelease];
550
        [savedMouseEvents removeObjectAtIndex:0];
551
        [invocation invoke];
552
    }
553
    replayingSavedEvents = NO;
554
}
555
556
+ (void)clearSavedEvents
557
{
558
    [savedMouseEvents release];
559
    savedMouseEvents = nil;
560
}
561
562
- (void)keyDown:(NSString *)character withModifiers:(WebScriptObject *)modifiers withLocation:(unsigned long)keyLocation
563
{
564
    NSString *eventCharacter = character;
565
    unsigned short keyCode = 0;
566
    if ([character isEqualToString:@"leftArrow"]) {
567
        const unichar ch = NSLeftArrowFunctionKey;
568
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
569
        keyCode = 0x7B;
570
    } else if ([character isEqualToString:@"rightArrow"]) {
571
        const unichar ch = NSRightArrowFunctionKey;
572
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
573
        keyCode = 0x7C;
574
    } else if ([character isEqualToString:@"upArrow"]) {
575
        const unichar ch = NSUpArrowFunctionKey;
576
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
577
        keyCode = 0x7E;
578
    } else if ([character isEqualToString:@"downArrow"]) {
579
        const unichar ch = NSDownArrowFunctionKey;
580
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
581
        keyCode = 0x7D;
582
    } else if ([character isEqualToString:@"pageUp"]) {
583
        const unichar ch = NSPageUpFunctionKey;
584
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
585
        keyCode = 0x74;
586
    } else if ([character isEqualToString:@"pageDown"]) {
587
        const unichar ch = NSPageDownFunctionKey;
588
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
589
        keyCode = 0x79;
590
    } else if ([character isEqualToString:@"home"]) {
591
        const unichar ch = NSHomeFunctionKey;
592
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
593
        keyCode = 0x73;
594
    } else if ([character isEqualToString:@"end"]) {
595
        const unichar ch = NSEndFunctionKey;
596
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
597
        keyCode = 0x77;
598
    } else if ([character isEqualToString:@"insert"]) {
599
        const unichar ch = NSInsertFunctionKey;
600
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
601
        keyCode = 0x72;
602
    } else if ([character isEqualToString:@"delete"]) {
603
        const unichar ch = NSDeleteFunctionKey;
604
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
605
        keyCode = 0x75;
606
    } else if ([character isEqualToString:@"printScreen"]) {
607
        const unichar ch = NSPrintScreenFunctionKey;
608
        eventCharacter = [NSString stringWithCharacters:&ch length:1];
609
        keyCode = 0x0; // There is no known virtual key code for PrintScreen.
610
    }
611
612
    // Compare the input string with the function-key names defined by the DOM spec (i.e. "F1",...,"F24").
613
    // If the input string is a function-key name, set its key code.
614
    for (unsigned i = 1; i <= 24; i++) {
615
        if ([character isEqualToString:[NSString stringWithFormat:@"F%u", i]]) {
616
            const unichar ch = NSF1FunctionKey + (i - 1);
617
            eventCharacter = [NSString stringWithCharacters:&ch length:1];
618
            switch (i) {
619
                case 1: keyCode = 0x7A; break;
620
                case 2: keyCode = 0x78; break;
621
                case 3: keyCode = 0x63; break;
622
                case 4: keyCode = 0x76; break;
623
                case 5: keyCode = 0x60; break;
624
                case 6: keyCode = 0x61; break;
625
                case 7: keyCode = 0x62; break;
626
                case 8: keyCode = 0x64; break;
627
                case 9: keyCode = 0x65; break;
628
                case 10: keyCode = 0x6D; break;
629
                case 11: keyCode = 0x67; break;
630
                case 12: keyCode = 0x6F; break;
631
                case 13: keyCode = 0x69; break;
632
                case 14: keyCode = 0x6B; break;
633
                case 15: keyCode = 0x71; break;
634
                case 16: keyCode = 0x6A; break;
635
                case 17: keyCode = 0x40; break;
636
                case 18: keyCode = 0x4F; break;
637
                case 19: keyCode = 0x50; break;
638
                case 20: keyCode = 0x5A; break;
639
            }
640
        }
641
    }
642
643
    // FIXME: No keyCode is set for most keys.
644
    if ([character isEqualToString:@"\t"])
645
        keyCode = 0x30;
646
    else if ([character isEqualToString:@" "])
647
        keyCode = 0x31;
648
    else if ([character isEqualToString:@"\r"])
649
        keyCode = 0x24;
650
    else if ([character isEqualToString:@"\n"])
651
        keyCode = 0x4C;
652
    else if ([character isEqualToString:@"\x8"])
653
        keyCode = 0x33;
654
    else if ([character isEqualToString:@"7"])
655
        keyCode = 0x1A;
656
    else if ([character isEqualToString:@"5"])
657
        keyCode = 0x17;
658
    else if ([character isEqualToString:@"9"])
659
        keyCode = 0x19;
660
    else if ([character isEqualToString:@"0"])
661
        keyCode = 0x1D;
662
    else if ([character isEqualToString:@"a"])
663
        keyCode = 0x00;
664
    else if ([character isEqualToString:@"b"])
665
        keyCode = 0x0B;
666
    else if ([character isEqualToString:@"d"])
667
        keyCode = 0x02;
668
    else if ([character isEqualToString:@"e"])
669
        keyCode = 0x0E;
670
671
    NSString *charactersIgnoringModifiers = eventCharacter;
672
673
    int modifierFlags = 0;
674
675
    if ([character length] == 1 && [character characterAtIndex:0] >= 'A' && [character characterAtIndex:0] <= 'Z') {
676
        modifierFlags |= NSShiftKeyMask;
677
        charactersIgnoringModifiers = [character lowercaseString];
678
    }
679
680
    modifierFlags |= buildModifierFlags(modifiers);
681
682
    if (keyLocation == DOM_KEY_LOCATION_NUMPAD)
683
        modifierFlags |= NSNumericPadKeyMask;
684
685
    [[[mainFrame frameView] documentView] layout];
686
687
    NSEvent *event = [NSEvent keyEventWithType:NSKeyDown
688
                        location:NSMakePoint(5, 5)
689
                        modifierFlags:modifierFlags
690
                        timestamp:[self currentEventTime]
691
                        windowNumber:[[[mainFrame webView] window] windowNumber]
692
                        context:[NSGraphicsContext currentContext]
693
                        characters:eventCharacter
694
                        charactersIgnoringModifiers:charactersIgnoringModifiers
695
                        isARepeat:NO
696
                        keyCode:keyCode];
697
698
    [[[[mainFrame webView] window] firstResponder] keyDown:event];
699
700
    event = [NSEvent keyEventWithType:NSKeyUp
701
                        location:NSMakePoint(5, 5)
702
                        modifierFlags:modifierFlags
703
                        timestamp:[self currentEventTime]
704
                        windowNumber:[[[mainFrame webView] window] windowNumber]
705
                        context:[NSGraphicsContext currentContext]
706
                        characters:eventCharacter
707
                        charactersIgnoringModifiers:charactersIgnoringModifiers
708
                        isARepeat:NO
709
                        keyCode:keyCode];
710
711
    [[[[mainFrame webView] window] firstResponder] keyUp:event];
712
}
713
714
- (void)enableDOMUIEventLogging:(WebScriptObject *)node
715
{
716
    NSEnumerator *eventEnumerator = [webkitDomEventNames objectEnumerator];
717
    id eventName;
718
    while ((eventName = [eventEnumerator nextObject])) {
719
        [(id<DOMEventTarget>)node addEventListener:eventName listener:self useCapture:NO];
720
    }
721
}
722
723
- (void)handleEvent:(DOMEvent *)event
724
{
725
    DOMNode *target = [event target];
726
727
    printf("event type:      %s\n", [[event type] UTF8String]);
728
    printf("  target:        <%s>\n", [[[target nodeName] lowercaseString] UTF8String]);
729
    
730
    if ([event isKindOfClass:[DOMEvent class]]) {
731
        printf("  eventPhase:    %d\n", [event eventPhase]);
732
        printf("  bubbles:       %d\n", [event bubbles] ? 1 : 0);
733
        printf("  cancelable:    %d\n", [event cancelable] ? 1 : 0);
734
    }
735
    
736
    if ([event isKindOfClass:[DOMUIEvent class]]) {
737
        printf("  detail:        %d\n", [(DOMUIEvent*)event detail]);
738
        
739
        DOMAbstractView *view = [(DOMUIEvent*)event view];
740
        if (view) {
741
            printf("  view:          OK");            
742
            if ([view document])
743
                printf(" (document: OK)");
744
            printf("\n");
745
        }
746
    }
747
    
748
    if ([event isKindOfClass:[DOMKeyboardEvent class]]) {
749
        printf("  keyIdentifier: %s\n", [[(DOMKeyboardEvent*)event keyIdentifier] UTF8String]);
750
        printf("  keyLocation:   %d\n", [(DOMKeyboardEvent*)event keyLocation]);
751
        printf("  modifier keys: c:%d s:%d a:%d m:%d\n", 
752
               [(DOMKeyboardEvent*)event ctrlKey] ? 1 : 0, 
753
               [(DOMKeyboardEvent*)event shiftKey] ? 1 : 0, 
754
               [(DOMKeyboardEvent*)event altKey] ? 1 : 0, 
755
               [(DOMKeyboardEvent*)event metaKey] ? 1 : 0);
756
        printf("  keyCode:       %d\n", [(DOMKeyboardEvent*)event keyCode]);
757
        printf("  charCode:      %d\n", [(DOMKeyboardEvent*)event charCode]);
758
    }
759
    
760
    if ([event isKindOfClass:[DOMMouseEvent class]]) {
761
        printf("  button:        %d\n", [(DOMMouseEvent*)event button]);
762
        printf("  clientX:       %d\n", [(DOMMouseEvent*)event clientX]);
763
        printf("  clientY:       %d\n", [(DOMMouseEvent*)event clientY]);
764
        printf("  screenX:       %d\n", [(DOMMouseEvent*)event screenX]);
765
        printf("  screenY:       %d\n", [(DOMMouseEvent*)event screenY]);
766
        printf("  modifier keys: c:%d s:%d a:%d m:%d\n", 
767
               [(DOMMouseEvent*)event ctrlKey] ? 1 : 0, 
768
               [(DOMMouseEvent*)event shiftKey] ? 1 : 0, 
769
               [(DOMMouseEvent*)event altKey] ? 1 : 0, 
770
               [(DOMMouseEvent*)event metaKey] ? 1 : 0);
771
        id relatedTarget = [(DOMMouseEvent*)event relatedTarget];
772
        if (relatedTarget) {
773
            printf("  relatedTarget: %s", [[[relatedTarget class] description] UTF8String]);
774
            if ([relatedTarget isKindOfClass:[DOMNode class]])
775
                printf(" (nodeName: %s)", [[(DOMNode*)relatedTarget nodeName] UTF8String]);
776
            printf("\n");
777
        }
778
    }
779
    
780
    if ([event isKindOfClass:[DOMMutationEvent class]]) {
781
        printf("  prevValue:     %s\n", [[(DOMMutationEvent*)event prevValue] UTF8String]);
782
        printf("  newValue:      %s\n", [[(DOMMutationEvent*)event newValue] UTF8String]);
783
        printf("  attrName:      %s\n", [[(DOMMutationEvent*)event attrName] UTF8String]);
784
        printf("  attrChange:    %d\n", [(DOMMutationEvent*)event attrChange]);
785
        DOMNode *relatedNode = [(DOMMutationEvent*)event relatedNode];
786
        if (relatedNode) {
787
            printf("  relatedNode:   %s (nodeName: %s)\n", 
788
                   [[[relatedNode class] description] UTF8String],
789
                   [[relatedNode nodeName] UTF8String]);
790
        }
791
    }
792
    
793
    if ([event isKindOfClass:[DOMWheelEvent class]]) {
794
        printf("  clientX:       %d\n", [(DOMWheelEvent*)event clientX]);
795
        printf("  clientY:       %d\n", [(DOMWheelEvent*)event clientY]);
796
        printf("  screenX:       %d\n", [(DOMWheelEvent*)event screenX]);
797
        printf("  screenY:       %d\n", [(DOMWheelEvent*)event screenY]);
798
        printf("  modifier keys: c:%d s:%d a:%d m:%d\n", 
799
               [(DOMWheelEvent*)event ctrlKey] ? 1 : 0, 
800
               [(DOMWheelEvent*)event shiftKey] ? 1 : 0, 
801
               [(DOMWheelEvent*)event altKey] ? 1 : 0, 
802
               [(DOMWheelEvent*)event metaKey] ? 1 : 0);
803
        printf("  isHorizontal:  %d\n", [(DOMWheelEvent*)event isHorizontal] ? 1 : 0);
804
        printf("  wheelDelta:    %d\n", [(DOMWheelEvent*)event wheelDelta]);
805
    }
806
}
807
808
// FIXME: It's not good to have a test hard-wired into this controller like this.
809
// Instead we need to get testing framework based on the Objective-C bindings
810
// to work well enough that we can test that way instead.
811
- (void)fireKeyboardEventsToElement:(WebScriptObject *)element {
812
    
813
    if (![element isKindOfClass:[DOMHTMLElement class]])
814
        return;
815
    
816
    DOMHTMLElement *target = (DOMHTMLElement*)element;
817
    DOMDocument *document = [target ownerDocument];
818
    
819
    // Keyboard Event 1
820
    
821
    DOMEvent *domEvent = [document createEvent:@"KeyboardEvent"];
822
    [(DOMKeyboardEvent*)domEvent initKeyboardEvent:@"keydown" 
823
                                         canBubble:YES
824
                                        cancelable:YES
825
                                              view:[document defaultView]
826
                                     keyIdentifier:@"U+000041" 
827
                                       keyLocation:0
828
                                           ctrlKey:YES
829
                                            altKey:NO
830
                                          shiftKey:NO
831
                                           metaKey:NO];
832
    [target dispatchEvent:domEvent];  
833
        
834
    // Keyboard Event 2
835
    
836
    domEvent = [document createEvent:@"KeyboardEvent"];
837
    [(DOMKeyboardEvent*)domEvent initKeyboardEvent:@"keypress" 
838
                                         canBubble:YES
839
                                        cancelable:YES
840
                                              view:[document defaultView]
841
                                     keyIdentifier:@"U+000045" 
842
                                       keyLocation:1
843
                                           ctrlKey:NO
844
                                            altKey:YES
845
                                          shiftKey:NO
846
                                           metaKey:NO];
847
    [target dispatchEvent:domEvent];    
848
    
849
    // Keyboard Event 3
850
    
851
    domEvent = [document createEvent:@"KeyboardEvent"];
852
    [(DOMKeyboardEvent*)domEvent initKeyboardEvent:@"keyup" 
853
                                         canBubble:YES
854
                                        cancelable:YES
855
                                              view:[document defaultView]
856
                                     keyIdentifier:@"U+000056" 
857
                                       keyLocation:0
858
                                           ctrlKey:NO
859
                                            altKey:NO
860
                                          shiftKey:NO
861
                                           metaKey:NO];
862
    [target dispatchEvent:domEvent];   
863
    
864
}
865
866
@end
867
#endif

Return to Bug 57515