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 Adler> 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.
(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.
(WebCore::Attribute::createAttrIfNeeded): Use Attr::create.
(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.
(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.
(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.
(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.
(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.
(WebCore::DocumentType::DocumentType): Pass type to Node constructor.
(WebCore::DocumentType::cloneNode): Use create.
(WebCore::DocumentType::create): Call adoptRef.
(WebCore::EditingText::create): Added.
- dom/EditingText.h: Added a create function. Made everything private.
(WebCore::Element::Element): Pass CreateElementZeroRefCount to preserve
the zero reference count behavior for classes derived from Element.
(WebCore::EntityReference::create): Added.
(WebCore::EntityReference::cloneNode): Call create.
- dom/EntityReference.h: Added create. Made everything private.
(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.
(WebCore::Range::processContents): Use DocumentFragment::create.
(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.
(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.
(WebCore::appendStartMarkup): Call data instead of nodeValue.
(WebCore::HTMLDocument::create): Call adoptRef.
(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.
(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.
(WebCore::ImageDocument::create): Ditto.
(WebCore::MediaDocument::create): Ditto.
- loader/PlaceholderDocument.h:
(WebCore::PlaceholderDocument::create): Ditto.
(WebCore::PluginDocument::create): Ditto.
(WebCore::TextDocument::create): Ditto.
(WebCore::Loader::Host::didFinishLoading): Use RefPtr instead of DocPtr.
(WebCore::Loader::Host::didFail): Ditto.
(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.
(WebCore::SVGDocument::create): Use adoptRef.
- svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::SVGElementInstance): Updated to take a
PassRefPtr.
- svg/SVGElementInstance.h: Made everything private.
(WebCore::WMLDocument::create): Called adoptRef.
(WebCore::XPathNamespace::XPathNamespace): Take AtomicString arguments.
- xml/XPathNamespace.h: Made everything private.
(WebCore::createFragmentFromSource): Use DocumentFragment::create and
Text::create.