FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
ScriptingCore/DOM/Document.cpp
1 /**********************************************************\
2 Original Author: Richard Bateman (taxilian)
3 
4 Created: Dec 9, 2009
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 2009 PacketPass, Inc and the Firebreath development team
13 \**********************************************************/
14 
15 #include "variant.h"
16 #include "variant_list.h"
17 #include "Window.h"
18 #include "../precompiled_headers.h" // On windows, everything above this line in PCH
19 
20 #include "Document.h"
21 
22 using namespace FB::DOM;
23 
24 Document::Document(const FB::JSObjectPtr& element) : Node(element), Element(element)
25 {
26 }
27 
28 Document::~Document()
29 {
30 }
31 
32 WindowPtr Document::getWindow() const
33 {
34  JSObjectPtr api = getProperty<FB::JSObjectPtr>("window");
35  return Window::create(api);
36 }
37 
38 ElementPtr Document::getHead() const
39 {
40  JSObjectPtr api = getProperty<FB::JSObjectPtr>("head");
41  return Element::create(api);
42 }
43 
44 ElementPtr Document::getBody() const
45 {
46  JSObjectPtr api = getProperty<FB::JSObjectPtr>("body");
47  return Element::create(api);
48 }
49 
50 FB::DOM::ElementPtr Document::createElement(const std::string &name) const
51 {
52  JSObjectPtr api = callMethod<FB::JSObjectPtr>("createElement", FB::variant_list_of(name));
53  return Element::create(api);
54 }
DOM Node wrapper.
boost::shared_ptr< FB::JSObject > JSObjectPtr
Defines an alias representing a JSObject shared_ptr (you should never use a JSObject* directly) ...
Definition: APITypes.h:109
FB::detail::VariantListInserter variant_list_of(FB::variant v)
Allows convenient creation of an FB::VariantList.
Definition: variant_list.h:122
boost::shared_ptr< Window > WindowPtr
shared_ptr for a FB::DOM::Window
DOM Element wrapper.
boost::shared_ptr< Element > ElementPtr
shared_ptr for a FB::DOM::Element