Commit 7e131b6d authored by darin@apple.com's avatar darin@apple.com

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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47313 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fa9b19d6
2009-08-14 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
Make DOM classes start with a reference count of 1, like all other RefCounted
https://bugs.webkit.org/show_bug.cgi?id=28068
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.
2009-08-13 Jon Honeycutt <jhoneycutt@apple.com>
Part of <rdar://problem/6218721> No MSAA focus events fired for Webkit
......@@ -659,7 +659,6 @@ webcore_sources += \
WebCore/dom/DOMCoreException.h \
WebCore/dom/DOMImplementation.cpp \
WebCore/dom/DOMImplementation.h \
WebCore/dom/DocPtr.h \
WebCore/dom/Document.cpp \
WebCore/dom/Document.h \
WebCore/dom/DocumentFragment.cpp \
......
......@@ -949,7 +949,6 @@
'dom/DOMCoreException.h',
'dom/DOMImplementation.cpp',
'dom/DOMImplementation.h',
'dom/DocPtr.h',
'dom/Document.cpp',
'dom/Document.h',
'dom/DocumentFragment.cpp',
......
......@@ -23727,10 +23727,6 @@
RelativePath="..\dom\CSSMappedAttributeDeclaration.h"
>
</File>
<File
RelativePath="..\dom\DocPtr.h"
>
</File>
<File
RelativePath="..\dom\Document.cpp"
>
......
......@@ -2149,7 +2149,6 @@
93EB169509F880B00091F8FF /* WebCoreSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */; };
93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */; };
93EEC1FA09C2877700C515D1 /* DocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1E709C2877700C515D1 /* DocPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F198E608245E59001E9ABC /* HTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23F02DE4396018635CA /* HTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F198EF08245E59001E9ABC /* HTMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D25102DE4396018635CA /* HTMLParser.h */; };
......@@ -7188,7 +7187,6 @@
93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; };
93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
93EEC1E609C2877700C515D1 /* CharacterData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CharacterData.idl; sourceTree = "<group>"; };
93EEC1E709C2877700C515D1 /* DocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocPtr.h; sourceTree = "<group>"; };
93EEC1E809C2877700C515D1 /* DocumentType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentType.idl; sourceTree = "<group>"; };
93EEC1E909C2877700C515D1 /* DOMImplementation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMImplementation.idl; sourceTree = "<group>"; };
93EEC1EA09C2877700C515D1 /* Element.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Element.idl; sourceTree = "<group>"; };
......@@ -14772,7 +14770,6 @@
A81872110977D3C0005826D9 /* ContainerNode.h */,
A8C4A7F809D563270003AC8D /* CSSMappedAttributeDeclaration.cpp */,
A8C4A7F709D563270003AC8D /* CSSMappedAttributeDeclaration.h */,
93EEC1E709C2877700C515D1 /* DocPtr.h */,
A8185F3409765765005826D9 /* Document.cpp */,
A8185F3809765765005826D9 /* Document.h */,
6548E24809E1E04D00AF8020 /* Document.idl */,
......@@ -15173,7 +15170,6 @@
93F1996D08245E59001E9ABC /* DeprecatedPtrListImpl.h in Headers */,
B2F34FE60E82F81400F627CD /* DNS.h in Headers */,
BCB16C2A0979C3BD00467741 /* DocLoader.h in Headers */,
93EEC1FA09C2877700C515D1 /* DocPtr.h in Headers */,
A8185F4009765766005826D9 /* Document.h in Headers */,
A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */,
656D37360ADBA5DE00A4554D /* DocumentLoader.h in Headers */,
......@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -30,10 +30,10 @@
namespace WebCore {
Attr::Attr(Element* element, Document* docPtr, PassRefPtr<Attribute> a)
: ContainerNode(docPtr)
inline Attr::Attr(Element* element, Document* document, PassRefPtr<Attribute> attribute)
: ContainerNode(document)
, m_element(element)
, m_attribute(a)
, m_attribute(attribute)
, m_ignoreChildrenChanged(0)
, m_specified(true)
{
......@@ -41,6 +41,13 @@ Attr::Attr(Element* element, Document* docPtr, PassRefPtr<Attribute> a)
m_attribute->m_impl = this;
}
PassRefPtr<Attr> Attr::create(Element* element, Document* document, PassRefPtr<Attribute> attribute)
{
RefPtr<Attr> attr = adoptRef(new Attr(element, document, attribute));
attr->createTextChild();
return attr.release();
}
Attr::~Attr()
{
ASSERT(m_attribute->attr() == this);
......@@ -86,14 +93,14 @@ const AtomicString& Attr::prefix() const
return m_attribute->prefix();
}
void Attr::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
void Attr::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
{
ec = 0;
checkSetPrefix(_prefix, ec);
checkSetPrefix(prefix, ec);
if (ec)
return;
m_attribute->setPrefix(_prefix);
m_attribute->setPrefix(prefix);
}
String Attr::nodeValue() const
......@@ -101,11 +108,11 @@ String Attr::nodeValue() const
return value();
}
void Attr::setValue(const String& v, ExceptionCode&)
void Attr::setValue(const AtomicString& value, ExceptionCode&)
{
m_ignoreChildrenChanged++;
removeChildren();
m_attribute->setValue(v.impl());
m_attribute->setValue(value);
createTextChild();
m_ignoreChildrenChanged--;
......@@ -120,7 +127,7 @@ void Attr::setNodeValue(const String& v, ExceptionCode& ec)
PassRefPtr<Node> Attr::cloneNode(bool /*deep*/)
{
RefPtr<Attr> clone = new Attr(0, document(), m_attribute->clone());
RefPtr<Attr> clone = adoptRef(new Attr(0, document(), m_attribute->clone()));
cloneChildNodes(clone.get());
return clone.release();
}
......
......@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -39,48 +39,47 @@ namespace WebCore {
class Attr : public ContainerNode {
friend class NamedNodeMap;
public:
Attr(Element*, Document*, PassRefPtr<Attribute>);
~Attr();
static PassRefPtr<Attr> create(Element*, Document*, PassRefPtr<Attribute>);
virtual ~Attr();
// Call this after calling the constructor so the
// Attr node isn't floating when we append the text node.
void createTextChild();
// DOM methods & attributes for Attr
String name() const { return qualifiedName().toString(); }
bool specified() const { return m_specified; }
Element* ownerElement() const { return m_element; }
String value() const { return m_attribute->value(); }
void setValue(const String&, ExceptionCode&);
const AtomicString& value() const { return m_attribute->value(); }
void setValue(const AtomicString&, ExceptionCode&);
Attribute* attr() const { return m_attribute.get(); }
const QualifiedName& qualifiedName() const { return m_attribute->name(); }
// An extension to get presentational information for attributes.
CSSStyleDeclaration* style() { return m_attribute->style(); }
void setSpecified(bool specified) { m_specified = specified; }
private:
Attr(Element*, Document*, PassRefPtr<Attribute>);
void createTextChild();
// DOM methods overridden from parent classes
virtual String nodeName() const;
virtual NodeType nodeType() const;
const AtomicString& localName() const;
const AtomicString& namespaceURI() const;
const AtomicString& prefix() const;
virtual void setPrefix(const AtomicString&, ExceptionCode&);
virtual String nodeValue() const;
virtual void setNodeValue(const String&, ExceptionCode&);
virtual PassRefPtr<Node> cloneNode(bool deep);
// Other methods (not part of DOM)
virtual bool isAttributeNode() const { return true; }
virtual bool childTypeAllowed(NodeType);
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
Attribute* attr() const { return m_attribute.get(); }
const QualifiedName& qualifiedName() const { return m_attribute->name(); }
// An extension to get presentational information for attributes.
CSSStyleDeclaration* style() { return m_attribute->style(); }
void setSpecified(bool specified) { m_specified = specified; }
private:
virtual const AtomicString& virtualPrefix() const { return prefix(); }
virtual const AtomicString& virtualLocalName() const { return localName(); }
virtual const AtomicString& virtualNamespaceURI() const { return namespaceURI(); }
......
......@@ -37,10 +37,8 @@ PassRefPtr<Attribute> Attribute::clone() const
PassRefPtr<Attr> Attribute::createAttrIfNeeded(Element* e)
{
RefPtr<Attr> r = m_impl;
if (!r) {
r = new Attr(e, e->document(), this);
r->createTextChild();
}
if (!r)
r = Attr::create(e, e->document(), this);
return r.release();
}
......
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -26,13 +26,14 @@
namespace WebCore {
CDATASection::CDATASection(Document* document, const String& text)
: Text(document, text)
inline CDATASection::CDATASection(Document* document, const String& data)
: Text(document, data)
{
}
CDATASection::~CDATASection()
PassRefPtr<CDATASection> CDATASection::create(Document* document, const String& data)
{
return adoptRef(new CDATASection(document, data));
}
String CDATASection::nodeName() const
......@@ -47,19 +48,17 @@ Node::NodeType CDATASection::nodeType() const
PassRefPtr<Node> CDATASection::cloneNode(bool /*deep*/)
{
return new CDATASection(document(), m_data);
return create(document(), data());
}
// DOM Section 1.1.1
bool CDATASection::childTypeAllowed(NodeType)
{
return false;
}
PassRefPtr<Text> CDATASection::createNew(PassRefPtr<StringImpl> string)
PassRefPtr<Text> CDATASection::virtualCreate(const String& data)
{
return new CDATASection(document(), string);
return create(document(), data);
}
} // namespace WebCore
/*
* This file is part of the DOM implementation for KDE.
*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003 Apple Computer, Inc.
* Copyright (C) 2003, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -31,16 +29,16 @@ namespace WebCore {
class CDATASection : public Text {
public:
static PassRefPtr<CDATASection> create(Document*, const String&);
private:
CDATASection(Document*, const String&);
virtual ~CDATASection();
virtual String nodeName() const;
virtual NodeType nodeType() const;
virtual PassRefPtr<Node> cloneNode(bool deep);
virtual bool childTypeAllowed(NodeType);
protected:
virtual PassRefPtr<Text> createNew(PassRefPtr<StringImpl>);
virtual PassRefPtr<Text> virtualCreate(const String&);
};
} // namespace WebCore
......
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -30,20 +30,11 @@
namespace WebCore {
CharacterData::CharacterData(Document *doc, bool isText)
: Node(doc, false, false, isText)
, m_data(StringImpl::empty())
{
}
CharacterData::CharacterData(Document* document, const String& text, bool isText)
: Node(document, false, false, isText)
{
m_data = text.impl() ? text.impl() : StringImpl::empty();
}
CharacterData::~CharacterData()
CharacterData::CharacterData(Document* document, const String& text, ConstructionType type)
: Node(document, type)
, m_data(text.impl() ? text.impl() : StringImpl::empty())
{
ASSERT(type == CreateOther || type == CreateText);
}
void CharacterData::setData(const String& data, ExceptionCode&)
......
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -29,12 +29,6 @@ namespace WebCore {
class CharacterData : public Node {
public:
CharacterData(Document*, const String& text, bool isText = false);
CharacterData(Document*, bool isText = false);
virtual ~CharacterData();
// DOM methods & attributes for CharacterData
String data() const { return m_data; }
void setData(const String&, ExceptionCode&);
unsigned length() const { return m_data->length(); }
......@@ -42,31 +36,30 @@ public:
void appendData(const String&, ExceptionCode&);
void insertData(unsigned offset, const String&, ExceptionCode&);
void deleteData(unsigned offset, unsigned count, ExceptionCode&);
void replaceData(unsigned offset, unsigned count, const String &arg, ExceptionCode&);
void replaceData(unsigned offset, unsigned count, const String&, ExceptionCode&);
bool containsOnlyWhitespace() const;
// DOM methods overridden from parent classes