FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
ActiveXCore/AXDOM/Node.cpp
1 /**********************************************************\
2 Original Author: Roee Shenberg
3 
4 Created: Feb 21, 2012
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 \**********************************************************/
13 
14 #include "precompiled_headers.h" // On windows, everything above this line in PCH
15 #include "Node.h"
16 
17 using namespace FB::ActiveX::AXDOM;
18 
19 Node::Node(const FB::JSObjectPtr& element, IWebBrowser *web)
20  : m_axNode(FB::ptr_cast<IDispatchAPI>(element)->getIDispatch()),
21  m_webBrowser(web), FB::DOM::Node(element)
22 {
23 }
24 
25 Node::~Node()
26 {
27 }
28 
29 FB::DOM::NodePtr Node::appendChild(FB::DOM::NodePtr node) {
30  CComPtr<IHTMLDOMNode> newNode;
31  NodePtr actualNode = FB::ptr_cast<Node>(node);
32  if (SUCCEEDED(m_axNode->appendChild(actualNode->m_axNode, &newNode))) {
33  actualNode->m_axNode = newNode; // set the node to point to the real IHTMLDOMNode
34  } else {
35  throw std::runtime_error("failed to appendChild!");
36  }
37  return node;
38 }
39 
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< Node > NodePtr
shared_ptr for a FB::DOM::Node
boost::shared_ptr< T > ptr_cast(boost::shared_ptr< U > const &r)
Convenience function for doing a dynamic cast of one boost::shared_ptr to another.
Definition: APITypes.h:339
Provides an ActiveX specific implementation of DOM::Node.
NodePtr node()
Gets the NodePtr for the current node.