File indexing completed on 2024-04-28 15:22:56
0001 /** 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright 2001 Peter Kelly (pmk@post.com) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 */ 0022 0023 #include "dom/dom2_views.h" 0024 #include "dom/dom_exception.h" 0025 #include "dom/dom_doc.h" 0026 #include "xml/dom_elementimpl.h" 0027 #include "xml/dom2_viewsimpl.h" 0028 0029 using namespace DOM; 0030 0031 AbstractView::AbstractView() 0032 { 0033 impl = nullptr; 0034 } 0035 0036 AbstractView::AbstractView(const AbstractView &other) 0037 { 0038 impl = other.impl; 0039 if (impl) { 0040 impl->ref(); 0041 } 0042 } 0043 0044 AbstractView::AbstractView(AbstractViewImpl *i) 0045 { 0046 impl = i; 0047 if (impl) { 0048 impl->ref(); 0049 } 0050 } 0051 0052 AbstractView::~AbstractView() 0053 { 0054 if (impl) { 0055 impl->deref(); 0056 } 0057 } 0058 0059 AbstractView &AbstractView::operator = (const AbstractView &other) 0060 { 0061 if (impl != other.impl) { 0062 if (impl) { 0063 impl->deref(); 0064 } 0065 impl = other.impl; 0066 if (impl) { 0067 impl->ref(); 0068 } 0069 } 0070 return *this; 0071 } 0072 0073 Document AbstractView::document() const 0074 { 0075 if (!impl) { 0076 throw DOMException(DOMException::INVALID_STATE_ERR); 0077 } 0078 0079 return impl->document(); 0080 } 0081 0082 CSSStyleDeclaration AbstractView::getComputedStyle(const Element &elt, const DOMString &pseudoElt) 0083 { 0084 if (!impl) { 0085 throw DOMException(DOMException::INVALID_STATE_ERR); 0086 } 0087 0088 return impl->getComputedStyle(static_cast<ElementImpl *>(elt.handle()), pseudoElt.implementation()); 0089 } 0090 0091 AbstractViewImpl *AbstractView::handle() const 0092 { 0093 return impl; 0094 } 0095 0096 bool AbstractView::isNull() const 0097 { 0098 return (impl == nullptr); 0099 } 0100