KHtml

dom2_views.cpp
1 /**
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 2001 Peter Kelly ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "dom/dom2_views.h"
24 #include "dom/dom_exception.h"
25 #include "dom/dom_doc.h"
26 #include "xml/dom_elementimpl.h"
27 #include "xml/dom2_viewsimpl.h"
28 
29 using namespace DOM;
30 
31 AbstractView::AbstractView()
32 {
33  impl = nullptr;
34 }
35 
36 AbstractView::AbstractView(const AbstractView &other)
37 {
38  impl = other.impl;
39  if (impl) {
40  impl->ref();
41  }
42 }
43 
44 AbstractView::AbstractView(AbstractViewImpl *i)
45 {
46  impl = i;
47  if (impl) {
48  impl->ref();
49  }
50 }
51 
52 AbstractView::~AbstractView()
53 {
54  if (impl) {
55  impl->deref();
56  }
57 }
58 
59 AbstractView &AbstractView::operator = (const AbstractView &other)
60 {
61  if (impl != other.impl) {
62  if (impl) {
63  impl->deref();
64  }
65  impl = other.impl;
66  if (impl) {
67  impl->ref();
68  }
69  }
70  return *this;
71 }
72 
74 {
75  if (!impl) {
76  throw DOMException(DOMException::INVALID_STATE_ERR);
77  }
78 
79  return impl->document();
80 }
81 
83 {
84  if (!impl) {
85  throw DOMException(DOMException::INVALID_STATE_ERR);
86  }
87 
88  return impl->getComputedStyle(static_cast<ElementImpl *>(elt.handle()), pseudoElt.implementation());
89 }
90 
91 AbstractViewImpl *AbstractView::handle() const
92 {
93  return impl;
94 }
95 
96 bool AbstractView::isNull() const
97 {
98  return (impl == nullptr);
99 }
100 
The CSSStyleDeclaration interface represents a single CSS declaration block .
Definition: css_value.h:59
Introduced in DOM Level 2.
Definition: dom2_views.h:42
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:58
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
Definition: dom_element.h:212
CSSStyleDeclaration getComputedStyle(const Element &elt, const DOMString &pseudoElt)
Introduced in DOM Level 2 This method is from the ViewCSS interface.
Definition: dom2_views.cpp:82
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
Document document() const
The source DocumentView of which this is an AbstractView.
Definition: dom2_views.cpp:73
This library provides a full-featured HTML parser and widget.
DOMStringImpl * implementation() const
Definition: dom_string.h:145
AbstractViewImpl * handle() const
Definition: dom2_views.cpp:91
NodeImpl * handle() const
Definition: dom_node.h:936
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 01:00:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.