FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
JSEvent.cpp
1 /**********************************************************\
2 Original Author: Richard Bateman (taxilian)
3 
4 Created: Dec 17, 2010
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2010 Richard Bateman, Firebreath development team
13 \**********************************************************/
14 
15 #include "variant.h"
16 #include "precompiled_headers.h" // On windows, everything above this line in PCH
17 
18 #include "JSEvent.h"
19 
20 FB::VariantMap FB::CreateEvent( const FB::JSAPIPtr& api, const std::string& name, const FB::VariantMap &members, const FB::VariantList &arguments )
21 {
22  FB::VariantMap event;
23  event["type"] = name;
24  event["target"] = api;
25  event["currentTarget"] = api;
26  event["eventPhase"] = 2; // we're always AT_TARGET
27  event["bubbles"] = false;
28  event["cancelable"] = false; // Events in firebreath are async; not cancelable
29  event["namespaceURI"] = name;
30  //event["timeStamp"] = FB::FBDateString();
31 
32  // Add the custom members
33  event.insert(members.begin(), members.end());
34  event["arguments"] = arguments;
35  return event;
36 }
37 
38 FB::VariantMap FB::CreateEvent( const FB::JSAPIPtr& api, const std::string& name, const FB::VariantMap &members )
39 {
40  return FB::CreateEvent(api, name, members, FB::VariantList());
41 }
42 
43 FB::VariantMap FB::CreateEvent( const FB::JSAPIPtr& api, const std::string& name, const VariantList &arguments )
44 {
45  return FB::CreateEvent(api, name, FB::VariantMap(), arguments);
46 }
47 
std::vector< variant > VariantList
Defines an alias representing list of variants.
Definition: APITypes.h:64
boost::shared_ptr< FB::JSAPI > JSAPIPtr
Defines an alias for a JSAPI shared_ptr (you should never use a JSAPI* directly)
Definition: APITypes.h:94
std::map< std::string, variant > VariantMap
Defines an alias representing a string -> variant map.
Definition: APITypes.h:72