FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
ScriptingCore/DOM/Document.h
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 #pragma once
16 #ifndef H_FB_DOM_DOCUMENT
17 #define H_FB_DOM_DOCUMENT
18 
19 #include <string>
20 #include "JSObject.h"
21 #include "Element.h"
22 
23 namespace FB { namespace DOM {
24 
25  class Document;
26  typedef boost::shared_ptr<Document> DocumentPtr;
27 
38  class Document : public virtual Element
39  {
40  public:
42  virtual ~Document();
43 
51  DocumentPtr document() { return boost::dynamic_pointer_cast<Document>(node()); }
52 
64  static DocumentPtr create(const FB::JSObjectPtr &api) {
65  if (!api) { return DocumentPtr(); }
66  return api->getHost()->_createDocument(api);
67  }
68 
69  public:
70 
78  virtual WindowPtr getWindow() const;
79 
87  virtual ElementPtr getHead() const;
88 
96  virtual ElementPtr getBody() const;
97 
105  virtual ElementPtr createElement(const std::string &name) const;
106 
107  };
108 
109 }; };
110 
111 #endif // H_FB_DOM_DOCUMENT
112 
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
boost::shared_ptr< Window > WindowPtr
shared_ptr for a FB::DOM::Window
boost::shared_ptr< Document > DocumentPtr
shared_ptr for a FB::DOM::Document
virtual WindowPtr getWindow() const
Gets a DOM::WindowPtr for the window the document is contained in.
static DocumentPtr create(const FB::JSObjectPtr &api)
Creates a FB::DOM::Document object from a JSObjectPtr representing a DOM object. This will probably t...
virtual ElementPtr getHead() const
Gets a DOM::ElementPtr for the document's head.
DocumentPtr document()
Gets a FB::DOM::DocumentPtr for the current object.
DOM Element wrapper.
virtual ElementPtr getBody() const
Gets a DOM::ElementPtr for the document's body.
NodePtr node()
Gets the NodePtr for the current node.
boost::shared_ptr< Element > ElementPtr
shared_ptr for a FB::DOM::Element
virtual ElementPtr createElement(const std::string &name) const
roughly equivalent to calling document.createElement(name) from javascript
ElementPtr element()
Gets a FB::DOM::ElementPtr pointing to the current object.
Abstraction for accessing and manipulating a DOM Document.