root/trunk/WebCore/html/HTMLDocument.h

Revision 47313, 3.1 KB (checked in by darin@apple.com, 3 months ago)

Make DOM classes start with a reference count of 1, like all other RefCounted
 https://bugs.webkit.org/show_bug.cgi?id=28068

Patch by Darin Adler < darin@apple.com> on 2009-08-14
Reviewed by Sam Weinig.

First half, everything except for element classes.

* GNUmakefile.am: Removed DocPtr.h.
* WebCore.gypi: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* dom/Attr.cpp:
(WebCore::Attr::Attr): Added a call to createTextChild here so callers don't
have to call it explicitly.
(WebCore::Attr::create): Added.
(WebCore::Attr::setValue): Changed to take AtomicString.
(WebCore::Attr::cloneNode): Use create.

* dom/Attr.h: Added a create function. Made the constructor private,
and a lot of other functions private as well.

* dom/Attribute.cpp:
(WebCore::Attribute::createAttrIfNeeded): Use Attr::create.

* dom/CDATASection.cpp:
(WebCore::CDATASection::create): Added.
(WebCore::CDATASection::cloneNode): Use create.
(WebCore::CDATASection::virtualCreate): Ditto.

* dom/CDATASection.h: Added a create function. Made everything private.
Removed unneeded destructor declaration.

* dom/CharacterData.cpp:
(WebCore::CharacterData::CharacterData): Replaced the multiple constructors
with a single one that takes ConstructionType.

* dom/CharacterData.h: Made more functions be protected and private.
Made m_data be private.

* dom/Comment.cpp:
(WebCore::Comment::Comment): Got rid of an extra constructor.
(WebCore::Comment::create): Added.
(WebCore::Comment::cloneNode): Call create.

* dom/Comment.h: Added a create function. Made everything private.

* dom/ContainerNode.cpp:
(WebCore::dispatchChildInsertionEvents): Use RefPtr instead of DocPtr.
(WebCore::dispatchChildRemovalEvents): Ditto.

* dom/ContainerNode.h: Made the constructor protected and passed
ConstructionType instead of an isElement boolean.

* dom/DocPtr.h: Removed.

* dom/Document.cpp:
(WebCore::Document::Document): Simplified the code that sets m_document
since it's no longer a smart pointer.
(WebCore::Document::removedLastRef): Use explicit calls to selfOnlyRef
and selfOnlyDeref instead of a DocPtr in here.
(WebCore::Document::~Document): Simplified the code that sets m_document
since it's no longer a smart pointer.
(WebCore::Document::createDocumentFragment): Call create.
(WebCore::Document::createTextNode): Ditto.
(WebCore::Document::createComment): Ditto.
(WebCore::Document::createCDATASection): Ditto.
(WebCore::Document::createProcessingInstruction): Ditto.
(WebCore::Document::createEntityReference): Ditto.
(WebCore::Document::createEditingTextNode): Ditto.
(WebCore::Document::importNode): Call Attr::create.
(WebCore::Document::createAttributeNS): Ditto.

* dom/Document.h: Call adoptRef. Made a lot of functions private and
protected and sorted them so public functions come first.

* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::create): Added.
(WebCore::DocumentFragment::cloneNode): Call create.
* dom/DocumentFragment.h: Added create.

* dom/DocumentType.cpp:
(WebCore::DocumentType::DocumentType): Pass type to Node constructor.
(WebCore::DocumentType::cloneNode): Use create.
* dom/DocumentType.h:
(WebCore::DocumentType::create): Call adoptRef.

* dom/EditingText.cpp:
(WebCore::EditingText::create): Added.
* dom/EditingText.h: Added a create function. Made everything private.

* dom/Element.cpp:
(WebCore::Element::Element): Pass CreateElementZeroRefCount to preserve
the zero reference count behavior for classes derived from Element.

* dom/EntityReference.cpp:
(WebCore::EntityReference::create): Added.
(WebCore::EntityReference::cloneNode): Call create.
* dom/EntityReference.h: Added create. Made everything private.

* dom/Node.cpp:
(WebCore::Node::initialRefCount): Added. Inline helper function for
the constructor.
(WebCore::Node::isContainer): Ditto.
(WebCore::Node::isElement): Ditto.
(WebCore::Node::isText): Ditto.
(WebCore::Node::Node): Changed to take a construction type argument.
Since m_document is now a normal pointer, added a call to selfOnlyRef.
(WebCore::Node::~Node): Ditto, but selfOnlyDeref.
(WebCore::Node::setDocument): Added selfOnlyRef/Deref calls.
(WebCore::Node::appendTextContent): Use the data function instead of
calling nodeValue functions, which do the same thing in a roundabout way.

* dom/Node.h: Made the constructor protected and replaced the multiple
arguments iwth a single ConstructionType argument. Sorted the public
things first.

* dom/Notation.h: Made most things private.
* dom/Notation.cpp: Removed extra constructor.

* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::create): Added.
(WebCore::ProcessingInstruction::cloneNode): Call create.
* dom/ProcessingInstruction.h: Added create function. Made many other
members private.

* dom/Range.cpp:
(WebCore::Range::processContents): Use DocumentFragment::create.

* dom/Text.cpp:
(WebCore::Text::Text): Updated for base class change.
(WebCore::Text::create): Added.
(WebCore::Text::splitText): Changed to not require access to m_data.
(WebCore::Text::cloneNode): Call create.
(WebCore::Text::createRenderer): Call dataImpl.
(WebCore::Text::attach): Call data.
(WebCore::Text::recalcStyle): Call dataImpl.
(WebCore::Text::virtualCreate): Call create.
(WebCore::Text::createWithLengthLimit): Call create.
(WebCore::Text::formatForDebugger): Call data.

* dom/Text.h: Added a create function. Made many other members private.
Renamed createNew to virtualCreate.

* dom/XMLTokenizer.cpp:
(WebCore::XMLTokenizer::enterText): Call Text::create.

* dom/XMLTokenizerLibxml2.cpp:
(WebCore::XMLTokenizer::cdataBlock): Call CDATASection::create.
(WebCore::XMLTokenizer::comment): Call Comment::create.

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::deleteInsignificantText):
Call data instead of string.

* editing/CreateLinkCommand.cpp:
(WebCore::CreateLinkCommand::doApply): Call Text::create.

* editing/EditorCommand.cpp:
(WebCore::executeInsertNode): Call DocumentFragment::create.

* editing/SplitTextNodeCommand.cpp:
(WebCore::SplitTextNodeCommand::doApply): Call Text::create.

* editing/markup.cpp:
(WebCore::appendStartMarkup): Call data instead of nodeValue.

* html/HTMLDocument.h:
(WebCore::HTMLDocument::create): Call adoptRef.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::createContextualFragment): Call DocumentFragment::create.
(WebCore::replaceChildrenWithFragment): Call data instead of string.
(WebCore::replaceChildrenWithText): Call Text::create.
(WebCore::HTMLElement::setInnerText): Call DocumentFragment::create and
Text::create.
(WebCore::HTMLElement::setOuterText): Call Text::create.

* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::HTMLKeygenElement): Call Text::create.

* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::setText): Call Text::create.

* html/HTMLParser.cpp:
(WebCore::HTMLParser::textCreateErrorCheck): Call Text::create.
(WebCore::HTMLParser::commentCreateErrorCheck): Call Comment::create.
(WebCore::HTMLParser::handleIsindex): Call Text::create.

* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::addText): Call Text::create.

* html/HTMLViewSourceDocument.h:
(WebCore::HTMLViewSourceDocument::create): Call adoptRef.

* loader/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryTokenizer::appendEntry): Call Text::create.
(WebCore::FTPDirectoryTokenizer::createTDForFilename): Call Text::create.

* loader/FTPDirectoryDocument.h:
(WebCore::FTPDirectoryDocument::create): Call adoptRef.
* loader/ImageDocument.h:
(WebCore::ImageDocument::create): Ditto.
* loader/MediaDocument.h:
(WebCore::MediaDocument::create): Ditto.
* loader/PlaceholderDocument.h:
(WebCore::PlaceholderDocument::create): Ditto.
* loader/PluginDocument.h:
(WebCore::PluginDocument::create): Ditto.
* loader/TextDocument.h:
(WebCore::TextDocument::create): Ditto.

* loader/loader.cpp:
(WebCore::Loader::Host::didFinishLoading): Use RefPtr instead of DocPtr.
(WebCore::Loader::Host::didFail): Ditto.

* platform/TreeShared.h:
(WebCore::TreeShared::TreeShared): Added an initialRefCount argument,
defaulting to 1. Node still sometimes initializes it to 0 instead for now.

* rendering/RenderText.cpp:
(WebCore::RenderText::originalText): Use dataImpl instead of string.

* rendering/RenderTextFragment.cpp:
(WebCore::RenderTextFragment::originalText): Use dataImpl instead of string.
(WebCore::RenderTextFragment::previousCharacter): Ditto.

* svg/SVGDocument.h:
(WebCore::SVGDocument::create): Use adoptRef.

* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::SVGElementInstance): Updated to take a
PassRefPtr.

* svg/SVGElementInstance.h: Made everything private.

* wml/WMLDocument.h:
(WebCore::WMLDocument::create): Called adoptRef.

* xml/XPathNamespace.cpp:
(WebCore::XPathNamespace::XPathNamespace): Take AtomicString arguments.
* xml/XPathNamespace.h: Made everything private.

* xml/XSLTProcessor.cpp:
(WebCore::createFragmentFromSource): Use DocumentFragment::create and
Text::create.

  • Property svn:eol-style set to native
Line 
1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
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#ifndef HTMLDocument_h
24#define HTMLDocument_h
25
26#include "AtomicStringHash.h"
27#include "CachedResourceClient.h"
28#include "Document.h"
29#include <wtf/HashCountedSet.h>
30
31namespace WebCore {
32
33class FrameView;
34class HTMLElement;
35
36class HTMLDocument : public Document, public CachedResourceClient {
37public:
38    static PassRefPtr<HTMLDocument> create(Frame* frame)
39    {
40        return adoptRef(new HTMLDocument(frame));
41    }
42    virtual ~HTMLDocument();
43
44    int width();
45    int height();
46
47    String dir();
48    void setDir(const String&);
49
50    String designMode() const;
51    void setDesignMode(const String&);
52
53    String compatMode() const;
54
55    Element* activeElement();
56    bool hasFocus();
57
58    String bgColor();
59    void setBgColor(const String&);
60    String fgColor();
61    void setFgColor(const String&);
62    String alinkColor();
63    void setAlinkColor(const String&);
64    String linkColor();
65    void setLinkColor(const String&);
66    String vlinkColor();
67    void setVlinkColor(const String&);
68
69    void clear();
70
71    void captureEvents();
72    void releaseEvents();
73
74    void addNamedItem(const AtomicString& name);
75    void removeNamedItem(const AtomicString& name);
76    bool hasNamedItem(AtomicStringImpl* name);
77
78    void addExtraNamedItem(const AtomicString& name);
79    void removeExtraNamedItem(const AtomicString& name);
80    bool hasExtraNamedItem(AtomicStringImpl* name);
81
82protected:
83    HTMLDocument(Frame*);
84
85private:
86    virtual bool childAllowed(Node*);
87
88    virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
89
90    virtual bool isHTMLDocument() const { return true; }
91    virtual bool isFrameSet() const;
92    virtual Tokenizer* createTokenizer();
93    virtual void determineParseMode();
94
95    HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
96    HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
97};
98
99inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name)
100{
101    ASSERT(name);
102    return m_namedItemCounts.contains(name);
103}
104
105inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name)
106{
107    ASSERT(name);
108    return m_extraNamedItemCounts.contains(name);
109}
110
111} // namespace WebCore
112
113#endif // HTMLDocument_h
Note: See TracBrowser for help on using the browser.