[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

darin at apple.com darin at apple.com
Wed Dec 22 14:40:44 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 601d44bde182e672877a2d6f5434b88c2972231e
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 15 18:30:37 2010 +0000

    2010-10-14  Darin Adler  <darin at apple.com>
    
            Reviewed by Alexey Proskuryakov.
    
            Use more specific types for node pointers, especially when calling node insertion and removal functions
            https://bugs.webkit.org/show_bug.cgi?id=47702
    
            Refactoring. No new tests.
    
            While developing this patch I temporarily removed the node insertion and
            removal member functions from the Node class and fixed almost all call sites
            so they call it directly on the ContainerNode class, which will be important
            once we make the functions non-virtual.
    
            * css/CSSStyleSelector.cpp:
            (WebCore::CSSStyleSelector::SelectorChecker::checkSelector):
            * dom/ContainerNode.cpp:
            (WebCore::ContainerNode::insertBefore):
            (WebCore::ContainerNode::replaceChild):
            (WebCore::ContainerNode::appendChild):
            * dom/Document.cpp:
            (WebCore::Document::caretRangeFromPoint):
            * dom/DynamicNodeList.cpp:
            (WebCore::DynamicNodeList::itemWithName):
            * dom/Position.cpp:
            (WebCore::Position::previous):
            (WebCore::Position::next):
            * dom/Text.cpp:
            (WebCore::Text::replaceWholeText):
            * dom/TreeWalker.cpp:
            (WebCore::TreeWalker::firstChild):
            (WebCore::TreeWalker::lastChild):
            (WebCore::TreeWalker::previousNode):
            * dom/XMLDocumentParserLibxml2.cpp:
            (WebCore::XMLDocumentParser::XMLDocumentParser):
            * editing/BreakBlockquoteCommand.cpp:
            (WebCore::BreakBlockquoteCommand::doApply):
            * editing/CompositeEditCommand.h:
            * editing/DeleteButtonController.cpp:
            (WebCore::isDeletableElement):
            * editing/IndentOutdentCommand.cpp:
            (WebCore::IndentOutdentCommand::outdentParagraph):
            * editing/InsertNodeBeforeCommand.cpp:
            (WebCore::InsertNodeBeforeCommand::doApply):
            * editing/JoinTextNodesCommand.cpp:
            (WebCore::JoinTextNodesCommand::doApply):
            (WebCore::JoinTextNodesCommand::doUnapply):
            * editing/MergeIdenticalElementsCommand.cpp:
            (WebCore::MergeIdenticalElementsCommand::doUnapply):
            * editing/RemoveNodeCommand.cpp:
            (WebCore::RemoveNodeCommand::doApply):
            (WebCore::RemoveNodeCommand::doUnapply):
            * editing/RemoveNodeCommand.h:
            * editing/SplitElementCommand.cpp:
            (WebCore::SplitElementCommand::executeApply):
            * editing/SplitTextNodeCommand.cpp:
            (WebCore::SplitTextNodeCommand::doApply):
            (WebCore::SplitTextNodeCommand::doReapply):
            * editing/TextIterator.cpp:
            (WebCore::parentCrossingShadowBoundaries):
            * editing/htmlediting.cpp:
            (WebCore::enclosingList):
            * editing/markup.cpp:
            (WebCore::serializeNodes):
            (WebCore::ancestorToRetainStructureAndAppearance):
            (WebCore::createMarkup):
            * html/HTMLAreaElement.cpp:
            (WebCore::HTMLAreaElement::updateFocusAppearance):
            * html/HTMLEmbedElement.cpp:
            (WebCore::HTMLEmbedElement::rendererIsNeeded):
            * html/HTMLFormElement.cpp:
            (WebCore::HTMLFormElement::rendererIsNeeded):
            * html/HTMLFrameSetElement.cpp:
            (WebCore::HTMLFrameSetElement::attach):
            * html/HTMLImageElement.cpp:
            (WebCore::HTMLImageElement::insertedIntoTree):
            * html/HTMLLegendElement.cpp:
            (WebCore::HTMLLegendElement::associatedControl):
            * html/HTMLOptGroupElement.cpp:
            (WebCore::HTMLOptGroupElement::recalcSelectOptions):
            (WebCore::HTMLOptGroupElement::ownerSelectElement):
            * html/HTMLOptionElement.cpp:
            (WebCore::HTMLOptionElement::ownerSelectElement):
            * html/HTMLTableCellElement.cpp:
            (WebCore::HTMLTableCellElement::additionalAttributeStyleDecls):
            * html/HTMLTableColElement.cpp:
            (WebCore::HTMLTableColElement::additionalAttributeStyleDecls):
            * html/HTMLTableElement.cpp:
            (WebCore::HTMLTableElement::insertRow):
            * html/HTMLTableRowElement.cpp:
            (WebCore::HTMLTableRowElement::rowIndex):
            * html/HTMLTableSectionElement.cpp:
            (WebCore::HTMLTableSectionElement::additionalAttributeStyleDecls):
            * page/DOMSelection.cpp:
            (WebCore::DOMSelection::getRangeAt):
            (WebCore::DOMSelection::containsNode):
            * rendering/RenderSVGGradientStop.cpp:
            (WebCore::RenderSVGGradientStop::gradientElement):
            * svg/SVGElement.cpp:
            (WebCore::SVGElement::ownerSVGElement):
            (WebCore::SVGElement::viewportElement):
            * svg/SVGFELightElement.cpp:
            (WebCore::SVGFELightElement::svgAttributeChanged):
            (WebCore::SVGFELightElement::childrenChanged):
            * svg/SVGFEMergeNodeElement.cpp:
            (WebCore::SVGFEMergeNodeElement::svgAttributeChanged):
            * svg/SVGFontFaceFormatElement.cpp:
            (WebCore::SVGFontFaceFormatElement::childrenChanged):
            * svg/SVGFontFaceUriElement.cpp:
            (WebCore::SVGFontFaceUriElement::childrenChanged):
            * svg/SVGGlyphElement.cpp:
            (WebCore::SVGGlyphElement::invalidateGlyphCache):
            * svg/SVGHKernElement.cpp:
            (WebCore::SVGHKernElement::insertedIntoDocument):
            (WebCore::SVGHKernElement::removedFromDocument):
            * svg/SVGLocatable.cpp:
            (WebCore::SVGLocatable::nearestViewportElement):
            (WebCore::SVGLocatable::farthestViewportElement):
            * svg/SVGUseElement.cpp:
            (WebCore::SVGUseElement::updateContainerOffsets):
            * svg/SVGVKernElement.cpp:
            (WebCore::SVGVKernElement::insertedIntoDocument):
            (WebCore::SVGVKernElement::removedFromDocument):
            * svg/animation/SVGSMILElement.cpp:
            (WebCore::SVGSMILElement::targetElement):
            * wml/WMLDoElement.cpp:
            (WebCore::WMLDoElement::insertedIntoDocument):
            (WebCore::WMLDoElement::removedFromDocument):
            * wml/WMLNoopElement.cpp:
            (WebCore::WMLNoopElement::insertedIntoDocument):
            * wml/WMLOptionElement.cpp:
            (WebCore::ownerSelectElement):
            * wml/WMLPostfieldElement.cpp:
            (WebCore::WMLPostfieldElement::insertedIntoDocument):
            (WebCore::WMLPostfieldElement::removedFromDocument):
            * wml/WMLSetvarElement.cpp:
            (WebCore::WMLSetvarElement::insertedIntoDocument):
            (WebCore::WMLSetvarElement::removedFromDocument):
            * wml/WMLTaskElement.cpp:
            (WebCore::WMLTaskElement::insertedIntoDocument):
            (WebCore::WMLTaskElement::removedFromDocument):
            * wml/WMLTimerElement.cpp:
            (WebCore::WMLTimerElement::insertedIntoDocument):
            (WebCore::WMLTimerElement::removedFromDocument):
            * xml/XPathStep.cpp:
            (WebCore::XPath::Step::nodesInAxis):
            Use ContainerNode* for the result of the parentNode function now that
            it returns a ContainerNode*. In the past it used to return just Node*.
    
            * dom/ContainerNode.h: Added toContainerNode.
    
            * dom/Element.h: Use ContainerNode*. Added toElement.
    
            * dom/Element.cpp:
            (WebCore::Element::deprecatedCreateContextualFragment): Explcitly
            cast to HTMLElement* in the case that handles <html> and <body>
            elements.
            (WebCore::Element::baseURI): Use ContainerNode*.
    
            * dom/Node.cpp:
            (WebCore::Node::markAncestorsWithChildNeedsStyleRecalc): Use ContainerNode*.
            (WebCore::Node::isDescendantOf): Ditto.
            (WebCore::Node::createRendererIfNeeded): Ditto.
            (WebCore::Node::setTextContent): Use already-typecast pointer in a call to
            appendChild.
            (WebCore::Node::ancestorElement): Use ContainerNode*.
    
            * dom/Range.cpp:
            (WebCore::Range::compareNode): Use ContainerNode*.
            (WebCore::Range::intersectsNode): Ditto.
            (WebCore::Range::processContents): Cast to ContainerNode* in a couple cases
            where we previously checked that the node in question has a child. Any node
            that returns a non-zero value for firstChild is a ContainerNode.
            (WebCore::Range::checkNodeBA): Ditto.
            (WebCore::Range::selectNode): Ditto.
            (WebCore::Range::surroundContents): Ditto.
    
            * dom/XMLDocumentParser.cpp:
            (WebCore::XMLDocumentParser::insertErrorMessageBlock): Rewrote code to use
            more specific types, document instead of doc, and paragraph instead of par.
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::ApplyStyleCommand::removeStyleFromRunBeforeApplyingStyle):
            Use ContainerNode*.
            (WebCore::ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes):
            Use replaceElementWithSpanPreservingChildrenAndAttributes; the old function
            took a Node argument and had Node in its name.
    
            * editing/CompositeEditCommand.cpp:
            (WebCore::CompositeEditCommand::removeNodeAndPruneAncestors): Use ContainerNode.
            (WebCore::CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes):
            Renamed and changed to take HTMLElement. Also use ContainerNode.
            (WebCore::CompositeEditCommand::prune): Ditto.
            (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): Ditto.
            (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): Ditto.
    
            * editing/ReplaceNodeWithSpanCommand.cpp:
            (WebCore::ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand): Take an
            HTMLElement instead of a Node. Call it m_elementToReplace instead of m_node.
            (WebCore::swapInNodePreservingAttributesAndChildren): Take HTMLElement.
            (WebCore::ReplaceNodeWithSpanCommand::doApply): Updated for name changes.
            (WebCore::ReplaceNodeWithSpanCommand::doUnapply): Ditto.
            * editing/ReplaceNodeWithSpanCommand.h: Ditto.
    
            * editing/ReplaceSelectionCommand.cpp:
            (WebCore::ReplacementFragment::ReplacementFragment): Use StyledElement for result
            of insertFragmentForTestRendering since that's what it returns.
            (WebCore::ReplacementFragment::removeNode): Use ContainerNode.
            (WebCore::ReplacementFragment::insertNodeBefore): Ditto.
            (WebCore::ReplacementFragment::insertFragmentForTestRendering): Return StyledElement.
            Use HTMLElement for body.
            (WebCore::ReplacementFragment::restoreTestRenderingNodesToFragment): Take
            StyledElement.
            (WebCore::ReplaceSelectionCommand::handleStyleSpans): Use ContainerNode.
            (WebCore::ReplaceSelectionCommand::copyStyleToChildren): Use HTMLElement for
            the cloned span, since the clone will be a sspan too.
            (WebCore::ReplaceSelectionCommand::insertAsListItems): Use ContainerNode since
            the list item has a child, and that proves it is a ContainerNode.
    
            * editing/SelectionController.cpp:
            (WebCore::SelectionController::selectFrameElementInParentIfFullySelected):
            Use ContainerNode and also removed an unnneded local variable.
    
            * html/HTMLElement.cpp:
            (WebCore::HTMLElement::setOuterText): Use ContainerNode.
            (WebCore::HTMLElement::insertAdjacent): Use ContainerNode and also use && to make
            the logic a little simpler.
            (WebCore::contextElementForInsertion): Use ContainerNode.
            (WebCore::HTMLElement::findFormAncestor): Ditto.
    
            * inspector/InspectorDOMAgent.cpp:
            (WebCore::InspectorDOMAgent::removeNode): Use ContainerNode.
            (WebCore::InspectorDOMAgent::changeTagName): Ditto.
            (WebCore::InspectorDOMAgent::setOuterHTML): Ditto.
            (WebCore::InspectorDOMAgent::innerParentNode): Use isDocumentNode instead of
            nodeType. We should almost never use nodeType inside the engine.
            (WebCore::InspectorDOMAgent::didInsertDOMNode): Use ContainerNode.
            (WebCore::InspectorDOMAgent::didRemoveDOMNode): Ditto.
    
            * wml/WMLOptGroupElement.cpp: Removed unneeded overrides of insertBefore,
            replaceChild, removeChild, appendChild, and removeChildren functions.
            Ths already overrides childrenChanged, that is called by all of the above,
            and it does the same thing these functions did.
            (WebCore::ownerSelectElement): Use ContainerNode.
            * wml/WMLOptGroupElement.h: Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69868 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f8070fc..d3d3099 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,249 @@
+2010-10-14  Darin Adler  <darin at apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Use more specific types for node pointers, especially when calling node insertion and removal functions
+        https://bugs.webkit.org/show_bug.cgi?id=47702
+
+        Refactoring. No new tests.
+
+        While developing this patch I temporarily removed the node insertion and
+        removal member functions from the Node class and fixed almost all call sites
+        so they call it directly on the ContainerNode class, which will be important
+        once we make the functions non-virtual.
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::SelectorChecker::checkSelector):
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::insertBefore):
+        (WebCore::ContainerNode::replaceChild):
+        (WebCore::ContainerNode::appendChild):
+        * dom/Document.cpp:
+        (WebCore::Document::caretRangeFromPoint):
+        * dom/DynamicNodeList.cpp:
+        (WebCore::DynamicNodeList::itemWithName):
+        * dom/Position.cpp:
+        (WebCore::Position::previous):
+        (WebCore::Position::next):
+        * dom/Text.cpp:
+        (WebCore::Text::replaceWholeText):
+        * dom/TreeWalker.cpp:
+        (WebCore::TreeWalker::firstChild):
+        (WebCore::TreeWalker::lastChild):
+        (WebCore::TreeWalker::previousNode):
+        * dom/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::XMLDocumentParser):
+        * editing/BreakBlockquoteCommand.cpp:
+        (WebCore::BreakBlockquoteCommand::doApply):
+        * editing/CompositeEditCommand.h:
+        * editing/DeleteButtonController.cpp:
+        (WebCore::isDeletableElement):
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::outdentParagraph):
+        * editing/InsertNodeBeforeCommand.cpp:
+        (WebCore::InsertNodeBeforeCommand::doApply):
+        * editing/JoinTextNodesCommand.cpp:
+        (WebCore::JoinTextNodesCommand::doApply):
+        (WebCore::JoinTextNodesCommand::doUnapply):
+        * editing/MergeIdenticalElementsCommand.cpp:
+        (WebCore::MergeIdenticalElementsCommand::doUnapply):
+        * editing/RemoveNodeCommand.cpp:
+        (WebCore::RemoveNodeCommand::doApply):
+        (WebCore::RemoveNodeCommand::doUnapply):
+        * editing/RemoveNodeCommand.h:
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::executeApply):
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::doApply):
+        (WebCore::SplitTextNodeCommand::doReapply):
+        * editing/TextIterator.cpp:
+        (WebCore::parentCrossingShadowBoundaries):
+        * editing/htmlediting.cpp:
+        (WebCore::enclosingList):
+        * editing/markup.cpp:
+        (WebCore::serializeNodes):
+        (WebCore::ancestorToRetainStructureAndAppearance):
+        (WebCore::createMarkup):
+        * html/HTMLAreaElement.cpp:
+        (WebCore::HTMLAreaElement::updateFocusAppearance):
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::rendererIsNeeded):
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::rendererIsNeeded):
+        * html/HTMLFrameSetElement.cpp:
+        (WebCore::HTMLFrameSetElement::attach):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::insertedIntoTree):
+        * html/HTMLLegendElement.cpp:
+        (WebCore::HTMLLegendElement::associatedControl):
+        * html/HTMLOptGroupElement.cpp:
+        (WebCore::HTMLOptGroupElement::recalcSelectOptions):
+        (WebCore::HTMLOptGroupElement::ownerSelectElement):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::ownerSelectElement):
+        * html/HTMLTableCellElement.cpp:
+        (WebCore::HTMLTableCellElement::additionalAttributeStyleDecls):
+        * html/HTMLTableColElement.cpp:
+        (WebCore::HTMLTableColElement::additionalAttributeStyleDecls):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::insertRow):
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::HTMLTableRowElement::rowIndex):
+        * html/HTMLTableSectionElement.cpp:
+        (WebCore::HTMLTableSectionElement::additionalAttributeStyleDecls):
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::getRangeAt):
+        (WebCore::DOMSelection::containsNode):
+        * rendering/RenderSVGGradientStop.cpp:
+        (WebCore::RenderSVGGradientStop::gradientElement):
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::ownerSVGElement):
+        (WebCore::SVGElement::viewportElement):
+        * svg/SVGFELightElement.cpp:
+        (WebCore::SVGFELightElement::svgAttributeChanged):
+        (WebCore::SVGFELightElement::childrenChanged):
+        * svg/SVGFEMergeNodeElement.cpp:
+        (WebCore::SVGFEMergeNodeElement::svgAttributeChanged):
+        * svg/SVGFontFaceFormatElement.cpp:
+        (WebCore::SVGFontFaceFormatElement::childrenChanged):
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::SVGFontFaceUriElement::childrenChanged):
+        * svg/SVGGlyphElement.cpp:
+        (WebCore::SVGGlyphElement::invalidateGlyphCache):
+        * svg/SVGHKernElement.cpp:
+        (WebCore::SVGHKernElement::insertedIntoDocument):
+        (WebCore::SVGHKernElement::removedFromDocument):
+        * svg/SVGLocatable.cpp:
+        (WebCore::SVGLocatable::nearestViewportElement):
+        (WebCore::SVGLocatable::farthestViewportElement):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::updateContainerOffsets):
+        * svg/SVGVKernElement.cpp:
+        (WebCore::SVGVKernElement::insertedIntoDocument):
+        (WebCore::SVGVKernElement::removedFromDocument):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::targetElement):
+        * wml/WMLDoElement.cpp:
+        (WebCore::WMLDoElement::insertedIntoDocument):
+        (WebCore::WMLDoElement::removedFromDocument):
+        * wml/WMLNoopElement.cpp:
+        (WebCore::WMLNoopElement::insertedIntoDocument):
+        * wml/WMLOptionElement.cpp:
+        (WebCore::ownerSelectElement):
+        * wml/WMLPostfieldElement.cpp:
+        (WebCore::WMLPostfieldElement::insertedIntoDocument):
+        (WebCore::WMLPostfieldElement::removedFromDocument):
+        * wml/WMLSetvarElement.cpp:
+        (WebCore::WMLSetvarElement::insertedIntoDocument):
+        (WebCore::WMLSetvarElement::removedFromDocument):
+        * wml/WMLTaskElement.cpp:
+        (WebCore::WMLTaskElement::insertedIntoDocument):
+        (WebCore::WMLTaskElement::removedFromDocument):
+        * wml/WMLTimerElement.cpp:
+        (WebCore::WMLTimerElement::insertedIntoDocument):
+        (WebCore::WMLTimerElement::removedFromDocument):
+        * xml/XPathStep.cpp:
+        (WebCore::XPath::Step::nodesInAxis):
+        Use ContainerNode* for the result of the parentNode function now that
+        it returns a ContainerNode*. In the past it used to return just Node*.
+
+        * dom/ContainerNode.h: Added toContainerNode.
+
+        * dom/Element.h: Use ContainerNode*. Added toElement.
+
+        * dom/Element.cpp:
+        (WebCore::Element::deprecatedCreateContextualFragment): Explcitly
+        cast to HTMLElement* in the case that handles <html> and <body>
+        elements.
+        (WebCore::Element::baseURI): Use ContainerNode*.
+
+        * dom/Node.cpp:
+        (WebCore::Node::markAncestorsWithChildNeedsStyleRecalc): Use ContainerNode*.
+        (WebCore::Node::isDescendantOf): Ditto.
+        (WebCore::Node::createRendererIfNeeded): Ditto.
+        (WebCore::Node::setTextContent): Use already-typecast pointer in a call to
+        appendChild.
+        (WebCore::Node::ancestorElement): Use ContainerNode*.
+
+        * dom/Range.cpp:
+        (WebCore::Range::compareNode): Use ContainerNode*.
+        (WebCore::Range::intersectsNode): Ditto.
+        (WebCore::Range::processContents): Cast to ContainerNode* in a couple cases
+        where we previously checked that the node in question has a child. Any node
+        that returns a non-zero value for firstChild is a ContainerNode.
+        (WebCore::Range::checkNodeBA): Ditto.
+        (WebCore::Range::selectNode): Ditto.
+        (WebCore::Range::surroundContents): Ditto.
+
+        * dom/XMLDocumentParser.cpp:
+        (WebCore::XMLDocumentParser::insertErrorMessageBlock): Rewrote code to use
+        more specific types, document instead of doc, and paragraph instead of par.
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::removeStyleFromRunBeforeApplyingStyle):
+        Use ContainerNode*.
+        (WebCore::ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes):
+        Use replaceElementWithSpanPreservingChildrenAndAttributes; the old function
+        took a Node argument and had Node in its name.
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::removeNodeAndPruneAncestors): Use ContainerNode.
+        (WebCore::CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes):
+        Renamed and changed to take HTMLElement. Also use ContainerNode.
+        (WebCore::CompositeEditCommand::prune): Ditto.
+        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): Ditto.
+        (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): Ditto.
+
+        * editing/ReplaceNodeWithSpanCommand.cpp:
+        (WebCore::ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand): Take an
+        HTMLElement instead of a Node. Call it m_elementToReplace instead of m_node.
+        (WebCore::swapInNodePreservingAttributesAndChildren): Take HTMLElement.
+        (WebCore::ReplaceNodeWithSpanCommand::doApply): Updated for name changes.
+        (WebCore::ReplaceNodeWithSpanCommand::doUnapply): Ditto.
+        * editing/ReplaceNodeWithSpanCommand.h: Ditto.
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::ReplacementFragment): Use StyledElement for result
+        of insertFragmentForTestRendering since that's what it returns.
+        (WebCore::ReplacementFragment::removeNode): Use ContainerNode.
+        (WebCore::ReplacementFragment::insertNodeBefore): Ditto.
+        (WebCore::ReplacementFragment::insertFragmentForTestRendering): Return StyledElement.
+        Use HTMLElement for body.
+        (WebCore::ReplacementFragment::restoreTestRenderingNodesToFragment): Take
+        StyledElement.
+        (WebCore::ReplaceSelectionCommand::handleStyleSpans): Use ContainerNode.
+        (WebCore::ReplaceSelectionCommand::copyStyleToChildren): Use HTMLElement for
+        the cloned span, since the clone will be a sspan too.
+        (WebCore::ReplaceSelectionCommand::insertAsListItems): Use ContainerNode since
+        the list item has a child, and that proves it is a ContainerNode.
+
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::selectFrameElementInParentIfFullySelected):
+        Use ContainerNode and also removed an unnneded local variable.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::setOuterText): Use ContainerNode.
+        (WebCore::HTMLElement::insertAdjacent): Use ContainerNode and also use && to make
+        the logic a little simpler.
+        (WebCore::contextElementForInsertion): Use ContainerNode.
+        (WebCore::HTMLElement::findFormAncestor): Ditto.
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::removeNode): Use ContainerNode.
+        (WebCore::InspectorDOMAgent::changeTagName): Ditto.
+        (WebCore::InspectorDOMAgent::setOuterHTML): Ditto.
+        (WebCore::InspectorDOMAgent::innerParentNode): Use isDocumentNode instead of
+        nodeType. We should almost never use nodeType inside the engine.
+        (WebCore::InspectorDOMAgent::didInsertDOMNode): Use ContainerNode.
+        (WebCore::InspectorDOMAgent::didRemoveDOMNode): Ditto.
+
+        * wml/WMLOptGroupElement.cpp: Removed unneeded overrides of insertBefore,
+        replaceChild, removeChild, appendChild, and removeChildren functions.
+        Ths already overrides childrenChanged, that is called by all of the above,
+        and it does the same thing these functions did.
+        (WebCore::ownerSelectElement): Use ContainerNode.
+        * wml/WMLOptGroupElement.h: Ditto.
+
 2010-10-15  Ryosuke Niwa  <rniwa at webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index 909d91c..9a089af 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -1964,7 +1964,7 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::SelectorChecker::checkSelector
     switch (relation) {
         case CSSSelector::Descendant:
             while (true) {
-                Node* n = e->parentNode();
+                ContainerNode* n = e->parentNode();
                 if (!n || !n->isElementNode())
                     return SelectorFailsCompletely;
                 e = static_cast<Element*>(n);
@@ -1975,7 +1975,7 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::SelectorChecker::checkSelector
             break;
         case CSSSelector::Child:
         {
-            Node* n = e->parentNode();
+            ContainerNode* n = e->parentNode();
             if (!n || !n->isElementNode())
                 return SelectorFailsCompletely;
             e = static_cast<Element*>(n);
diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp
index 89ea7b5..092ce74 100644
--- a/WebCore/dom/ContainerNode.cpp
+++ b/WebCore/dom/ContainerNode.cpp
@@ -135,7 +135,7 @@ bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
         Node* child = it->get();
 
         // If child is already present in the tree, first remove it from the old location.
-        if (Node* oldParent = child->parentNode())
+        if (ContainerNode* oldParent = child->parentNode())
             oldParent->removeChild(child, ec);
         if (ec)
             return false;
@@ -285,7 +285,7 @@ bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
         RefPtr<Node> nextChild = isFragment ? child->nextSibling() : 0;
 
         // Remove child from its old position.
-        if (Node* oldParent = child->parentNode())
+        if (ContainerNode* oldParent = child->parentNode())
             oldParent->removeChild(child.get(), ec);
         if (ec)
             return false;
@@ -571,7 +571,7 @@ bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
     for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); ++it) {
         Node* child = it->get();
         // If child is already present in the tree, first remove it
-        if (Node* oldParent = child->parentNode()) {
+        if (ContainerNode* oldParent = child->parentNode()) {
             oldParent->removeChild(child, ec);
             if (ec)
                 return false;
diff --git a/WebCore/dom/ContainerNode.h b/WebCore/dom/ContainerNode.h
index ab90783..c8583d2 100644
--- a/WebCore/dom/ContainerNode.h
+++ b/WebCore/dom/ContainerNode.h
@@ -118,6 +118,21 @@ private:
     Node* m_lastChild;
 };
 
+inline ContainerNode* toContainerNode(Node* node)
+{
+    ASSERT(!node || node->isContainerNode());
+    return static_cast<ContainerNode*>(node);
+}
+
+inline const ContainerNode* toContainerNode(const Node* node)
+{
+    ASSERT(!node || node->isContainerNode());
+    return static_cast<const ContainerNode*>(node);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toContainerNode(const ContainerNode*);
+
 inline ContainerNode::ContainerNode(Document* document, ConstructionType type)
     : Node(document, type)
     , m_firstChild(0)
@@ -127,26 +142,22 @@ inline ContainerNode::ContainerNode(Document* document, ConstructionType type)
 
 inline unsigned Node::containerChildNodeCount() const
 {
-    ASSERT(isContainerNode());
-    return static_cast<const ContainerNode*>(this)->childNodeCount();
+    return toContainerNode(this)->childNodeCount();
 }
 
 inline Node* Node::containerChildNode(unsigned index) const
 {
-    ASSERT(isContainerNode());
-    return static_cast<const ContainerNode*>(this)->childNode(index);
+    return toContainerNode(this)->childNode(index);
 }
 
 inline Node* Node::containerFirstChild() const
 {
-    ASSERT(isContainerNode());
-    return static_cast<const ContainerNode*>(this)->firstChild();
+    return toContainerNode(this)->firstChild();
 }
 
 inline Node* Node::containerLastChild() const
 {
-    ASSERT(isContainerNode());
-    return static_cast<const ContainerNode*>(this)->lastChild();
+    return toContainerNode(this)->lastChild();
 }
 
 } // namespace WebCore
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index da6a1f8..99984b3 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1162,7 +1162,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y)
     Node* shadowAncestorNode = node->shadowAncestorNode();
     if (shadowAncestorNode != node) {
         unsigned offset = shadowAncestorNode->nodeIndex();
-        Node* container = shadowAncestorNode->parentNode();
+        ContainerNode* container = shadowAncestorNode->parentNode();
         return Range::create(this, container, offset, container, offset);
     }
 
diff --git a/WebCore/dom/DynamicNodeList.cpp b/WebCore/dom/DynamicNodeList.cpp
index c7609a1..3538b60 100644
--- a/WebCore/dom/DynamicNodeList.cpp
+++ b/WebCore/dom/DynamicNodeList.cpp
@@ -124,7 +124,7 @@ Node* DynamicNodeList::itemWithName(const AtomicString& elementId) const
     if (m_rootNode->isDocumentNode() || m_rootNode->inDocument()) {
         Element* node = m_rootNode->document()->getElementById(elementId);
         if (node && nodeMatches(node)) {
-            for (Node* p = node->parentNode(); p; p = p->parentNode()) {
+            for (ContainerNode* p = node->parentNode(); p; p = p->parentNode()) {
                 if (p == m_rootNode)
                     return node;
             }
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index 67e0fd0..83e129e 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -122,18 +122,19 @@ PassRefPtr<DocumentFragment> Element::deprecatedCreateContextualFragment(const S
     for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) {
         nextNode = node->nextSibling();
         if (node->hasTagName(htmlTag) || node->hasTagName(bodyTag)) {
-            Node* firstChild = node->firstChild();
+            HTMLElement* element = static_cast<HTMLElement*>(node.get());
+            Node* firstChild = element->firstChild();
             if (firstChild)
                 nextNode = firstChild;
             RefPtr<Node> nextChild;
             for (RefPtr<Node> child = firstChild; child; child = nextChild) {
                 nextChild = child->nextSibling();
-                node->removeChild(child.get(), ignoredExceptionCode);
+                element->removeChild(child.get(), ignoredExceptionCode);
                 ASSERT(!ignoredExceptionCode);
-                fragment->insertBefore(child, node.get(), ignoredExceptionCode);
+                fragment->insertBefore(child, element, ignoredExceptionCode);
                 ASSERT(!ignoredExceptionCode);
             }
-            fragment->removeChild(node.get(), ignoredExceptionCode);
+            fragment->removeChild(element, ignoredExceptionCode);
             ASSERT(!ignoredExceptionCode);
         } else if (node->hasTagName(headTag)) {
             fragment->removeChild(node.get(), ignoredExceptionCode);
@@ -775,7 +776,7 @@ KURL Element::baseURI() const
     if (!base.protocol().isEmpty())
         return base;
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent)
         return base;
 
diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h
index aa29729..6362b02 100644
--- a/WebCore/dom/Element.h
+++ b/WebCore/dom/Element.h
@@ -372,25 +372,40 @@ private:
     mutable RefPtr<NamedNodeMap> m_attributeMap;
 };
     
+inline Element* toElement(Node* node)
+{
+    ASSERT(!node || node->isElementNode());
+    return static_cast<Element*>(node);
+}
+
+inline const Element* toElement(const Node* node)
+{
+    ASSERT(!node || node->isElementNode());
+    return static_cast<const Element*>(node);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toElement(const Element*);
+
 inline bool Node::hasTagName(const QualifiedName& name) const
 {
-    return isElementNode() && static_cast<const Element*>(this)->hasTagName(name);
+    return isElementNode() && toElement(this)->hasTagName(name);
 }
 
 inline bool Node::hasAttributes() const
 {
-    return isElementNode() && static_cast<const Element*>(this)->hasAttributes();
+    return isElementNode() && toElement(this)->hasAttributes();
 }
 
 inline NamedNodeMap* Node::attributes() const
 {
-    return isElementNode() ? static_cast<const Element*>(this)->attributes() : 0;
+    return isElementNode() ? toElement(this)->attributes() : 0;
 }
 
 inline Element* Node::parentElement() const
 {
-    Node* parent = parentNode();
-    return parent && parent->isElementNode() ? static_cast<Element*>(parent) : 0;
+    ContainerNode* parent = parentNode();
+    return parent && parent->isElementNode() ? toElement(parent) : 0;
 }
 
 inline NamedNodeMap* Element::attributes(bool readonly) const
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 873a2f3..ac0afc9 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -724,7 +724,7 @@ inline void Node::setStyleChange(StyleChangeType changeType)
 
 inline void Node::markAncestorsWithChildNeedsStyleRecalc()
 {
-    for (Node* p = parentNode(); p && !p->childNeedsStyleRecalc(); p = p->parentNode())
+    for (ContainerNode* p = parentNode(); p && !p->childNeedsStyleRecalc(); p = p->parentNode())
         p->setChildNeedsStyleRecalc();
     
     if (document()->childNeedsStyleRecalc())
@@ -1166,7 +1166,7 @@ bool Node::isDescendantOf(const Node *other) const
     // Return true if other is an ancestor of this, otherwise false
     if (!other)
         return false;
-    for (const Node *n = parentNode(); n; n = n->parentNode()) {
+    for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) {
         if (n == other)
             return true;
     }
@@ -1333,7 +1333,7 @@ void Node::createRendererIfNeeded()
 
     ASSERT(!renderer());
     
-    Node* parent = parentNode();    
+    ContainerNode* parent = parentNode();    
     ASSERT(parent);
     
     RenderObject* parentRenderer = parent->renderer();
@@ -1973,7 +1973,7 @@ String Node::textContent(bool convertBRsToNewlines) const
     return isNullString ? String() : content.toString();
 }
 
-void Node::setTextContent(const String &text, ExceptionCode& ec)
+void Node::setTextContent(const String& text, ExceptionCode& ec)
 {           
     switch (nodeType()) {
         case TEXT_NODE:
@@ -1981,33 +1981,32 @@ void Node::setTextContent(const String &text, ExceptionCode& ec)
         case COMMENT_NODE:
         case PROCESSING_INSTRUCTION_NODE:
             setNodeValue(text, ec);
-            break;
+            return;
         case ELEMENT_NODE:
         case ATTRIBUTE_NODE:
         case ENTITY_NODE:
         case ENTITY_REFERENCE_NODE:
         case DOCUMENT_FRAGMENT_NODE: {
-            ContainerNode *container = static_cast<ContainerNode *>(this);
-            
+            ContainerNode* container = toContainerNode(this);
             container->removeChildren();
-            
             if (!text.isEmpty())
-                appendChild(document()->createTextNode(text), ec);
-            break;
+                container->appendChild(document()->createTextNode(text), ec);
+            return;
         }
         case DOCUMENT_NODE:
         case DOCUMENT_TYPE_NODE:
         case NOTATION_NODE:
-        default:
-            // Do nothing
-            break;
+        case XPATH_NAMESPACE_NODE:
+            // Do nothing.
+            return;
     }
+    ASSERT_NOT_REACHED();
 }
 
 Element* Node::ancestorElement() const
 {
     // In theory, there can be EntityReference nodes between elements, but this is currently not supported.
-    for (Node* n = parentNode(); n; n = n->parentNode()) {
+    for (ContainerNode* n = parentNode(); n; n = n->parentNode()) {
         if (n->isElementNode())
             return static_cast<Element*>(n);
     }
diff --git a/WebCore/dom/Position.cpp b/WebCore/dom/Position.cpp
index 4758bd9..f1834d8 100644
--- a/WebCore/dom/Position.cpp
+++ b/WebCore/dom/Position.cpp
@@ -239,7 +239,7 @@ Position Position::previous(PositionMoveType moveType) const
         }
     }
 
-    Node* parent = n->parentNode();
+    ContainerNode* parent = n->parentNode();
     if (!parent)
         return *this;
 
@@ -271,7 +271,7 @@ Position Position::next(PositionMoveType moveType) const
         return Position(n, (moveType == Character) ? uncheckedNextOffset(n, o) : o + 1);
     }
 
-    Node* parent = n->parentNode();
+    ContainerNode* parent = n->parentNode();
     if (!parent)
         return *this;
 
diff --git a/WebCore/dom/Range.cpp b/WebCore/dom/Range.cpp
index 95502df..5507b83 100644
--- a/WebCore/dom/Range.cpp
+++ b/WebCore/dom/Range.cpp
@@ -373,7 +373,7 @@ Range::CompareResults Range::compareNode(Node* refNode, ExceptionCode& ec) const
         return NODE_BEFORE;
     }
 
-    Node* parentNode = refNode->parentNode();
+    ContainerNode* parentNode = refNode->parentNode();
     int nodeIndex = refNode->nodeIndex();
     
     if (!parentNode) {
@@ -572,7 +572,7 @@ bool Range::intersectsNode(Node* refNode, ExceptionCode& ec)
         return false;
     }
 
-    Node* parentNode = refNode->parentNode();
+    ContainerNode* parentNode = refNode->parentNode();
     int nodeIndex = refNode->nodeIndex();
     
     if (!parentNode) {
@@ -667,7 +667,7 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception
                 else if (action == CLONE_CONTENTS)
                     fragment->appendChild(n->cloneNode(true), ec);
                 else
-                    m_start.container()->removeChild(n, ec);
+                    toContainerNode(m_start.container())->removeChild(n, ec);
                 n = next;
                 i++;
             }
@@ -730,12 +730,12 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception
                 else if (action == CLONE_CONTENTS)
                     leftContents->appendChild(n->cloneNode(true), ec);
                 else
-                    m_start.container()->removeChild(n, ec);
+                    toContainerNode(m_start.container())->removeChild(n, ec);
                 n = next;
             }
         }
 
-        Node* leftParent = m_start.container()->parentNode();
+        ContainerNode* leftParent = m_start.container()->parentNode();
         Node* n = m_start.container()->nextSibling();
         for (; leftParent != commonRoot; leftParent = leftParent->parentNode()) {
             if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) {
@@ -800,12 +800,12 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception
                     else if (action == CLONE_CONTENTS)
                         rightContents->insertBefore(n->cloneNode(true), rightContents->firstChild(), ec);
                     else
-                        m_end.container()->removeChild(n, ec);
+                        toContainerNode(m_end.container())->removeChild(n, ec);
                 }
             }
         }
 
-        Node* rightParent = m_end.container()->parentNode();
+        ContainerNode* rightParent = m_end.container()->parentNode();
         Node* n = m_end.container()->previousSibling();
         for (; rightParent != commonRoot; rightParent = rightParent->parentNode()) {
             if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) {
@@ -1161,7 +1161,7 @@ void Range::checkNodeBA(Node* n, ExceptionCode& ec) const
     }
 
     Node* root = n;
-    while (Node* parent = root->parentNode())
+    while (ContainerNode* parent = root->parentNode())
         root = parent;
 
     switch (root->nodeType()) {
@@ -1287,7 +1287,7 @@ void Range::selectNode(Node* refNode, ExceptionCode& ec)
     // INVALID_NODE_TYPE_ERR: Raised if an ancestor of refNode is an Entity, Notation or
     // DocumentType node or if refNode is a Document, DocumentFragment, Attr, Entity, or Notation
     // node.
-    for (Node* anc = refNode->parentNode(); anc; anc = anc->parentNode()) {
+    for (ContainerNode* anc = refNode->parentNode(); anc; anc = anc->parentNode()) {
         switch (anc->nodeType()) {
             case Node::ATTRIBUTE_NODE:
             case Node::CDATA_SECTION_NODE:
@@ -1463,7 +1463,7 @@ void Range::surroundContents(PassRefPtr<Node> passNewParent, ExceptionCode& ec)
 
     ec = 0;
     while (Node* n = newParent->firstChild()) {
-        newParent->removeChild(n, ec);
+        toContainerNode(newParent.get())->removeChild(n, ec);
         if (ec)
             return;
     }
diff --git a/WebCore/dom/Text.cpp b/WebCore/dom/Text.cpp
index cc216d8..6271f11 100644
--- a/WebCore/dom/Text.cpp
+++ b/WebCore/dom/Text.cpp
@@ -153,7 +153,7 @@ PassRefPtr<Text> Text::replaceWholeText(const String& newText, ExceptionCode&)
     RefPtr<Text> endText = const_cast<Text*>(latestLogicallyAdjacentTextNode(this));
 
     RefPtr<Text> protectedThis(this); // Mutation event handlers could cause our last ref to go away
-    Node* parent = parentNode(); // Protect against mutation handlers moving this node during traversal
+    ContainerNode* parent = parentNode(); // Protect against mutation handlers moving this node during traversal
     ExceptionCode ignored = 0;
     for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) {
         RefPtr<Node> nodeToRemove(n.release());
diff --git a/WebCore/dom/TreeWalker.cpp b/WebCore/dom/TreeWalker.cpp
index 6a8ca87..d28603f 100644
--- a/WebCore/dom/TreeWalker.cpp
+++ b/WebCore/dom/TreeWalker.cpp
@@ -94,7 +94,7 @@ Node* TreeWalker::firstChild(ScriptState* state)
                 node = node->nextSibling();
                 break;
             }
-            Node* parent = node->parentNode();
+            ContainerNode* parent = node->parentNode();
             if (!parent || parent == root() || parent == m_current)
                 return 0;
             node = parent;
@@ -127,7 +127,7 @@ Node* TreeWalker::lastChild(ScriptState* state)
                 node = node->previousSibling();
                 break;
             }
-            Node* parent = node->parentNode();
+            ContainerNode* parent = node->parentNode();
             if (!parent || parent == root() || parent == m_current)
                 return 0;
             node = parent;
@@ -236,7 +236,7 @@ Node* TreeWalker::previousNode(ScriptState* state)
         }
         if (node == root())
             return 0;
-        Node* parent = node->parentNode();
+        ContainerNode* parent = node->parentNode();
         if (!parent)
             return 0;
         node = parent;
diff --git a/WebCore/dom/XMLDocumentParser.cpp b/WebCore/dom/XMLDocumentParser.cpp
index 0b002f1..b790217 100644
--- a/WebCore/dom/XMLDocumentParser.cpp
+++ b/WebCore/dom/XMLDocumentParser.cpp
@@ -293,47 +293,47 @@ void XMLDocumentParser::insertErrorMessageBlock()
 
     // Create elements for display
     ExceptionCode ec = 0;
-    Document* doc = document();
-    Node* documentElement = doc->documentElement();
+    Document* document = this->document();
+    Element* documentElement = document->documentElement();
     if (!documentElement) {
-        RefPtr<Node> rootElement = doc->createElement(htmlTag, false);
-        doc->appendChild(rootElement, ec);
-        RefPtr<Node> body = doc->createElement(bodyTag, false);
+        RefPtr<Element> rootElement = document->createElement(htmlTag, false);
+        document->appendChild(rootElement, ec);
+        RefPtr<Element> body = document->createElement(bodyTag, false);
         rootElement->appendChild(body, ec);
         documentElement = body.get();
     }
 #if ENABLE(SVG)
     else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) {
-        RefPtr<Node> rootElement = doc->createElement(htmlTag, false);
-        RefPtr<Node> body = doc->createElement(bodyTag, false);
+        RefPtr<Element> rootElement = document->createElement(htmlTag, false);
+        RefPtr<Element> body = document->createElement(bodyTag, false);
         rootElement->appendChild(body, ec);
         body->appendChild(documentElement, ec);
-        doc->appendChild(rootElement.get(), ec);
+        document->appendChild(rootElement.get(), ec);
         documentElement = body.get();
     }
 #endif
 #if ENABLE(WML)
     else if (isWMLDocument()) {
-        RefPtr<Node> rootElement = doc->createElement(htmlTag, false);
-        RefPtr<Node> body = doc->createElement(bodyTag, false);
+        RefPtr<Element> rootElement = document->createElement(htmlTag, false);
+        RefPtr<Element> body = document->createElement(bodyTag, false);
         rootElement->appendChild(body, ec);
         body->appendChild(documentElement, ec);
-        doc->appendChild(rootElement.get(), ec);
+        document->appendChild(rootElement.get(), ec);
         documentElement = body.get();
     }
 #endif
 
-    RefPtr<Element> reportElement = createXHTMLParserErrorHeader(doc, m_errorMessages);
+    RefPtr<Element> reportElement = createXHTMLParserErrorHeader(document, m_errorMessages);
     documentElement->insertBefore(reportElement, documentElement->firstChild(), ec);
 #if ENABLE(XSLT)
-    if (doc->transformSourceDocument()) {
-        RefPtr<Element> par = doc->createElement(pTag, false);
-        reportElement->appendChild(par, ec);
-        par->setAttribute(styleAttr, "white-space: normal");
-        par->appendChild(doc->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."), ec);
+    if (document->transformSourceDocument()) {
+        RefPtr<Element> paragraph = document->createElement(pTag, false);
+        paragraph->setAttribute(styleAttr, "white-space: normal");
+        paragraph->appendChild(document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."), ec);
+        reportElement->appendChild(paragraph.release(), ec);
     }
 #endif
-    doc->updateStyleIfNeeded();
+    document->updateStyleIfNeeded();
 }
 
 void XMLDocumentParser::notifyFinished(CachedResource* unusedResource)
diff --git a/WebCore/dom/XMLDocumentParserLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp
index c01a57e..5b5ac89 100644
--- a/WebCore/dom/XMLDocumentParserLibxml2.cpp
+++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp
@@ -598,7 +598,7 @@ XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent
     while (parentElement) {
         elemStack.append(parentElement);
 
-        Node* n = parentElement->parentNode();
+        ContainerNode* n = parentElement->parentNode();
         if (!n || !n->isElementNode())
             break;
         parentElement = static_cast<Element*>(n);
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 605c1a6..d041f74 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -1200,7 +1200,7 @@ bool ApplyStyleCommand::removeStyleFromRunBeforeApplyingStyle(CSSMutableStyleDec
         
         Node* previousSibling = node->previousSibling();
         Node* nextSibling = node->nextSibling();
-        Node* parent = node->parentNode();
+        ContainerNode* parent = node->parentNode();
         removeInlineStyleFromElement(style, static_cast<HTMLElement*>(node), RemoveAlways);
         if (!node->inDocument()) {
             // FIXME: We might need to update the start and the end of current selection here but need a test.
@@ -1366,7 +1366,7 @@ void ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*&
     if (removeNode)
         removeNodePreservingChildren(elem);
     else {
-        HTMLElement* newSpanElement = replaceNodeWithSpanPreservingChildrenAndAttributes(elem);
+        HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(elem);
         ASSERT(newSpanElement && newSpanElement->inDocument());
         elem = newSpanElement;
     }
diff --git a/WebCore/editing/BreakBlockquoteCommand.cpp b/WebCore/editing/BreakBlockquoteCommand.cpp
index 2da6047..63956e5 100644
--- a/WebCore/editing/BreakBlockquoteCommand.cpp
+++ b/WebCore/editing/BreakBlockquoteCommand.cpp
@@ -67,7 +67,7 @@ void BreakBlockquoteCommand::doApply()
     
     // Find the top-most blockquote from the start.
     Element* topBlockquote = 0;
-    for (Node *node = pos.node()->parentNode(); node; node = node->parentNode()) {
+    for (ContainerNode* node = pos.node()->parentNode(); node; node = node->parentNode()) {
         if (isMailBlockquote(node))
             topBlockquote = static_cast<Element*>(node);
     }
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp
index 4cb3005..a00db36 100644
--- a/WebCore/editing/CompositeEditCommand.cpp
+++ b/WebCore/editing/CompositeEditCommand.cpp
@@ -216,12 +216,12 @@ void CompositeEditCommand::removeNodePreservingChildren(PassRefPtr<Node> node)
 
 void CompositeEditCommand::removeNodeAndPruneAncestors(PassRefPtr<Node> node)
 {
-    RefPtr<Node> parent = node->parentNode();
+    RefPtr<ContainerNode> parent = node->parentNode();
     removeNode(node);
     prune(parent.release());
 }
 
-HTMLElement* CompositeEditCommand::replaceNodeWithSpanPreservingChildrenAndAttributes(PassRefPtr<Node> node)
+HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtr<HTMLElement> node)
 {
     // It would also be possible to implement all of ReplaceNodeWithSpanCommand
     // as a series of existing smaller edit commands.  Someone who wanted to
@@ -254,7 +254,7 @@ void CompositeEditCommand::prune(PassRefPtr<Node> node)
         if (renderer && (!renderer->canHaveChildren() || hasARenderedDescendant(node.get()) || node->rootEditableElement() == node))
             return;
             
-        RefPtr<Node> next = node->parentNode();
+        RefPtr<ContainerNode> next = node->parentNode();
         removeNode(node);
         node = next;
     }
@@ -1005,7 +1005,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
 
     RefPtr<CSSMutableStyleDeclaration> style = ApplyStyleCommand::editingStyleAtPosition(endingSelection().start(), IncludeTypingStyle);
 
-    Node* listNode = emptyListItem->parentNode();
+    ContainerNode* listNode = emptyListItem->parentNode();
     // FIXME: Can't we do something better when the immediate parent wasn't a list node?
     if (!listNode
         || (!listNode->hasTagName(ulTag) && !listNode->hasTagName(olTag))
@@ -1014,7 +1014,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
         return false;
 
     RefPtr<Element> newBlock = 0;
-    if (Node* blockEnclosingList = listNode->parentNode()) {
+    if (ContainerNode* blockEnclosingList = listNode->parentNode()) {
         if (blockEnclosingList->hasTagName(liTag)) { // listNode is inside another list item
             if (visiblePositionAfterNode(blockEnclosingList) == visiblePositionAfterNode(listNode)) {
                 // If listNode appears at the end of the outer list item, then move listNode outside of this list item
@@ -1105,7 +1105,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph()
     } else {
         ASSERT(caretPos.deprecatedEditingOffset() == 0);
         Text* textNode = static_cast<Text*>(caretPos.node());
-        Node* parentNode = textNode->parentNode();
+        ContainerNode* parentNode = textNode->parentNode();
         // The preserved newline must be the first thing in the node, since otherwise the previous
         // paragraph would be quoted, and we verified that it wasn't above.
         deleteTextFromNode(textNode, 0, 1);
diff --git a/WebCore/editing/CompositeEditCommand.h b/WebCore/editing/CompositeEditCommand.h
index 4397464..b4c3b2d 100644
--- a/WebCore/editing/CompositeEditCommand.h
+++ b/WebCore/editing/CompositeEditCommand.h
@@ -75,7 +75,7 @@ protected:
     void removeNodeAttribute(PassRefPtr<Element>, const QualifiedName& attribute);
     void removeChildrenInRange(PassRefPtr<Node>, unsigned from, unsigned to);
     virtual void removeNode(PassRefPtr<Node>);
-    HTMLElement* replaceNodeWithSpanPreservingChildrenAndAttributes(PassRefPtr<Node>);
+    HTMLElement* replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtr<HTMLElement>);
     void removeNodePreservingChildren(PassRefPtr<Node>);
     void removeNodeAndPruneAncestors(PassRefPtr<Node>);
     void prune(PassRefPtr<Node>);
diff --git a/WebCore/editing/DeleteButtonController.cpp b/WebCore/editing/DeleteButtonController.cpp
index 8b23eaa..028edc8 100644
--- a/WebCore/editing/DeleteButtonController.cpp
+++ b/WebCore/editing/DeleteButtonController.cpp
@@ -121,7 +121,7 @@ static bool isDeletableElement(const Node* node)
             return true;
 
         // Allow blocks that have a different background from it's parent
-        Node* parentNode = node->parentNode();
+        ContainerNode* parentNode = node->parentNode();
         if (!parentNode)
             return false;
 
diff --git a/WebCore/editing/IndentOutdentCommand.cpp b/WebCore/editing/IndentOutdentCommand.cpp
index c7ba744..9642afa 100644
--- a/WebCore/editing/IndentOutdentCommand.cpp
+++ b/WebCore/editing/IndentOutdentCommand.cpp
@@ -143,7 +143,7 @@ void IndentOutdentCommand::outdentParagraph()
         // outdentRegion() assumes it is operating on the first paragraph of an enclosing blockquote, but if there are multiply nested blockquotes and we've
         // just removed one, then this assumption isn't true. By splitting the next containing blockquote after this node, we keep this assumption true
         if (splitPoint) {
-            if (Node* splitPointParent = splitPoint->parentNode()) {
+            if (ContainerNode* splitPointParent = splitPoint->parentNode()) {
                 if (splitPointParent->hasTagName(blockquoteTag)
                     && !splitPoint->hasTagName(blockquoteTag)
                     && splitPointParent->parentNode()->isContentEditable()) // We can't outdent if there is no place to go!
diff --git a/WebCore/editing/InsertNodeBeforeCommand.cpp b/WebCore/editing/InsertNodeBeforeCommand.cpp
index fb72312..5fae45e 100644
--- a/WebCore/editing/InsertNodeBeforeCommand.cpp
+++ b/WebCore/editing/InsertNodeBeforeCommand.cpp
@@ -46,7 +46,7 @@ InsertNodeBeforeCommand::InsertNodeBeforeCommand(PassRefPtr<Node> insertChild, P
 
 void InsertNodeBeforeCommand::doApply()
 {
-    Node* parent = m_refChild->parentNode();
+    ContainerNode* parent = m_refChild->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
 
diff --git a/WebCore/editing/JoinTextNodesCommand.cpp b/WebCore/editing/JoinTextNodesCommand.cpp
index fa0987d..2766b84 100644
--- a/WebCore/editing/JoinTextNodesCommand.cpp
+++ b/WebCore/editing/JoinTextNodesCommand.cpp
@@ -45,7 +45,7 @@ void JoinTextNodesCommand::doApply()
     if (m_text1->nextSibling() != m_text2)
         return;
 
-    Node* parent = m_text2->parentNode();
+    ContainerNode* parent = m_text2->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
     
@@ -62,7 +62,7 @@ void JoinTextNodesCommand::doUnapply()
     if (m_text1->parentNode())
         return;
 
-    Node* parent = m_text2->parentNode();
+    ContainerNode* parent = m_text2->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
 
diff --git a/WebCore/editing/MergeIdenticalElementsCommand.cpp b/WebCore/editing/MergeIdenticalElementsCommand.cpp
index f56f726..a1cb79f 100644
--- a/WebCore/editing/MergeIdenticalElementsCommand.cpp
+++ b/WebCore/editing/MergeIdenticalElementsCommand.cpp
@@ -67,7 +67,7 @@ void MergeIdenticalElementsCommand::doUnapply()
 
     RefPtr<Node> atChild = m_atChild.release();
 
-    Node* parent = m_element2->parent();
+    ContainerNode* parent = m_element2->parent();
     if (!parent || !parent->isContentEditable())
         return;
 
diff --git a/WebCore/editing/RemoveNodeCommand.cpp b/WebCore/editing/RemoveNodeCommand.cpp
index f6d6a4b..94e3e62 100644
--- a/WebCore/editing/RemoveNodeCommand.cpp
+++ b/WebCore/editing/RemoveNodeCommand.cpp
@@ -41,7 +41,7 @@ RemoveNodeCommand::RemoveNodeCommand(PassRefPtr<Node> node)
 
 void RemoveNodeCommand::doApply()
 {
-    Node* parent = m_node->parentNode();
+    ContainerNode* parent = m_node->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
 
@@ -54,7 +54,7 @@ void RemoveNodeCommand::doApply()
 
 void RemoveNodeCommand::doUnapply()
 {
-    RefPtr<Node> parent = m_parent.release();
+    RefPtr<ContainerNode> parent = m_parent.release();
     RefPtr<Node> refChild = m_refChild.release();
     if (!parent || !parent->isContentEditable())
         return;
diff --git a/WebCore/editing/RemoveNodeCommand.h b/WebCore/editing/RemoveNodeCommand.h
index 14a798c..b803964 100644
--- a/WebCore/editing/RemoveNodeCommand.h
+++ b/WebCore/editing/RemoveNodeCommand.h
@@ -44,7 +44,7 @@ private:
     virtual void doUnapply();
 
     RefPtr<Node> m_node;
-    RefPtr<Node> m_parent;
+    RefPtr<ContainerNode> m_parent;
     RefPtr<Node> m_refChild;    
 };
 
diff --git a/WebCore/editing/ReplaceNodeWithSpanCommand.cpp b/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
index ae181a2..7ab3aba 100644
--- a/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
+++ b/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
@@ -41,18 +41,18 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(PassRefPtr<Node> node)
-    : SimpleEditCommand(node->document())
-    , m_node(node)
+ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(PassRefPtr<HTMLElement> element)
+    : SimpleEditCommand(element->document())
+    , m_elementToReplace(element)
 {
-    ASSERT(m_node);
+    ASSERT(m_elementToReplace);
 }
 
-static void swapInNodePreservingAttributesAndChildren(Node* newNode, Node* nodeToReplace)
+static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement* nodeToReplace)
 {
     ASSERT(nodeToReplace->inDocument());
     ExceptionCode ec = 0;
-    Node* parentNode = nodeToReplace->parentNode();
+    ContainerNode* parentNode = nodeToReplace->parentNode();
     parentNode->insertBefore(newNode, nodeToReplace, ec);
     ASSERT(!ec);
 
@@ -71,18 +71,18 @@ static void swapInNodePreservingAttributesAndChildren(Node* newNode, Node* nodeT
 
 void ReplaceNodeWithSpanCommand::doApply()
 {
-    if (!m_node->inDocument())
+    if (!m_elementToReplace->inDocument())
         return;
     if (!m_spanElement)
-        m_spanElement = createHTMLElement(m_node->document(), spanTag);
-    swapInNodePreservingAttributesAndChildren(m_spanElement.get(), m_node.get());
+        m_spanElement = createHTMLElement(m_elementToReplace->document(), spanTag);
+    swapInNodePreservingAttributesAndChildren(m_spanElement.get(), m_elementToReplace.get());
 }
 
 void ReplaceNodeWithSpanCommand::doUnapply()
 {
     if (!m_spanElement->inDocument())
         return;
-    swapInNodePreservingAttributesAndChildren(m_node.get(), m_spanElement.get());
+    swapInNodePreservingAttributesAndChildren(m_elementToReplace.get(), m_spanElement.get());
 }
 
 } // namespace WebCore
diff --git a/WebCore/editing/ReplaceNodeWithSpanCommand.h b/WebCore/editing/ReplaceNodeWithSpanCommand.h
index 6c02fc6..0154f29 100644
--- a/WebCore/editing/ReplaceNodeWithSpanCommand.h
+++ b/WebCore/editing/ReplaceNodeWithSpanCommand.h
@@ -37,23 +37,23 @@ namespace WebCore {
 
 class HTMLElement;
 
-// More accurately, this is ReplaceNodeWithSpanPreservingChildrenAndAttributesCommand
+// More accurately, this is ReplaceElementWithSpanPreservingChildrenAndAttributesCommand
 class ReplaceNodeWithSpanCommand : public SimpleEditCommand {
 public:
-    static PassRefPtr<ReplaceNodeWithSpanCommand> create(PassRefPtr<Node> node)
+    static PassRefPtr<ReplaceNodeWithSpanCommand> create(PassRefPtr<HTMLElement> element)
     {
-        return adoptRef(new ReplaceNodeWithSpanCommand(node));
+        return adoptRef(new ReplaceNodeWithSpanCommand(element));
     }
 
     HTMLElement* spanElement() { return m_spanElement.get(); }
 
 private:
-    ReplaceNodeWithSpanCommand(PassRefPtr<Node>);
+    ReplaceNodeWithSpanCommand(PassRefPtr<HTMLElement>);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    RefPtr<Node> m_node;
+    RefPtr<HTMLElement> m_elementToReplace;
     RefPtr<HTMLElement> m_spanElement;
 };
 
diff --git a/WebCore/editing/ReplaceSelectionCommand.cpp b/WebCore/editing/ReplaceSelectionCommand.cpp
index 49bdaca..51234e3 100644
--- a/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -76,9 +76,9 @@ public:
     void removeNodePreservingChildren(Node*);
 
 private:
-    PassRefPtr<Node> insertFragmentForTestRendering(Node* context);
+    PassRefPtr<StyledElement> insertFragmentForTestRendering(Node* context);
     void removeUnrenderedNodes(Node*);
-    void restoreTestRenderingNodesToFragment(Node*);
+    void restoreTestRenderingNodesToFragment(StyledElement*);
     void removeInterchangeNodes(Node*);
     
     void insertNodeBefore(PassRefPtr<Node> node, Node* refNode);
@@ -150,7 +150,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
     }
 
     Node* styleNode = selection.base().node();
-    RefPtr<Node> holder = insertFragmentForTestRendering(styleNode);
+    RefPtr<StyledElement> holder = insertFragmentForTestRendering(styleNode);
     
     RefPtr<Range> range = VisibleSelection::selectionFromContentsOfNode(holder.get()).toNormalizedRange();
     String text = plainText(range.get());
@@ -208,7 +208,7 @@ void ReplacementFragment::removeNode(PassRefPtr<Node> node)
     if (!node)
         return;
     
-    Node *parent = node->parentNode();
+    ContainerNode* parent = node->parentNode();
     if (!parent)
         return;
     
@@ -222,7 +222,7 @@ void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
     if (!node || !refNode)
         return;
         
-    Node* parent = refNode->parentNode();
+    ContainerNode* parent = refNode->parentNode();
     if (!parent)
         return;
         
@@ -231,9 +231,9 @@ void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
     ASSERT(ec == 0);
 }
 
-PassRefPtr<Node> ReplacementFragment::insertFragmentForTestRendering(Node* context)
+PassRefPtr<StyledElement> ReplacementFragment::insertFragmentForTestRendering(Node* context)
 {
-    Node* body = m_document->body();
+    HTMLElement* body = m_document->body();
     if (!body)
         return 0;
 
@@ -266,7 +266,7 @@ PassRefPtr<Node> ReplacementFragment::insertFragmentForTestRendering(Node* conte
     return holder.release();
 }
 
-void ReplacementFragment::restoreTestRenderingNodesToFragment(Node *holder)
+void ReplacementFragment::restoreTestRenderingNodesToFragment(StyledElement* holder)
 {
     if (!holder)
         return;
@@ -628,7 +628,7 @@ void ReplaceSelectionCommand::handleStyleSpans()
         return;
         
     RefPtr<CSSMutableStyleDeclaration> sourceDocumentStyle = static_cast<HTMLElement*>(sourceDocumentStyleSpan)->getInlineStyleDecl()->copy();
-    Node* context = sourceDocumentStyleSpan->parentNode();
+    ContainerNode* context = sourceDocumentStyleSpan->parentNode();
     
     // If Mail wraps the fragment with a Paste as Quotation blockquote, or if you're pasting into a quoted region,
     // styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
@@ -710,13 +710,15 @@ void ReplaceSelectionCommand::copyStyleToChildren(Node* parentNode, const CSSMut
     for (Node* childNode = parentNode->firstChild(); childNode; childNode = childNode->nextSibling()) {
         if (childNode->isTextNode() || !isBlock(childNode) || childNode->hasTagName(preTag)) {
             // In this case, put a span tag around the child node.
-            RefPtr<Node> newSpan = parentNode->cloneNode(false);
-            setNodeAttribute(static_cast<Element*>(newSpan.get()), styleAttr, parentStyle->cssText());
+            RefPtr<Node> newNode = parentNode->cloneNode(false);
+            ASSERT(newNode->hasTagName(spanTag));
+            HTMLElement* newSpan = static_cast<HTMLElement*>(newNode.get());
+            setNodeAttribute(newSpan, styleAttr, parentStyle->cssText());
             insertNodeAfter(newSpan, childNode);
             ExceptionCode ec = 0;
             newSpan->appendChild(childNode, ec);
             ASSERT(!ec);
-            childNode = newSpan.get();
+            childNode = newSpan;
         } else if (childNode->isHTMLElement()) {
             // Copy the style attribute and merge them into the child node.  We don't want to override
             // existing styles, so don't clobber on merge.
@@ -1211,7 +1213,7 @@ Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<Node> listElement, N
 
     while (RefPtr<Node> listItem = listElement->firstChild()) {
         ExceptionCode ec = 0;
-        listElement->removeChild(listItem.get(), ec);
+        toContainerNode(listElement.get())->removeChild(listItem.get(), ec);
         ASSERT(!ec);
         if (isStart || isMiddle)
             insertNodeBefore(listItem, lastNode);
diff --git a/WebCore/editing/SelectionController.cpp b/WebCore/editing/SelectionController.cpp
index c9295d3..cbcf306 100644
--- a/WebCore/editing/SelectionController.cpp
+++ b/WebCore/editing/SelectionController.cpp
@@ -1222,11 +1222,10 @@ void SelectionController::selectFrameElementInParentIfFullySelected()
         return;
 
     // Get to the <iframe> or <frame> (or even <object>) element in the parent frame.
-    Document* doc = m_frame->document();
-    Element* ownerElement = doc->ownerElement();
+    Element* ownerElement = m_frame->document()->ownerElement();
     if (!ownerElement)
         return;
-    Node* ownerElementParent = ownerElement->parentNode();
+    ContainerNode* ownerElementParent = ownerElement->parentNode();
     if (!ownerElementParent)
         return;
         
diff --git a/WebCore/editing/SplitElementCommand.cpp b/WebCore/editing/SplitElementCommand.cpp
index 5047205..888c45f 100644
--- a/WebCore/editing/SplitElementCommand.cpp
+++ b/WebCore/editing/SplitElementCommand.cpp
@@ -53,7 +53,7 @@ void SplitElementCommand::executeApply()
     
     ExceptionCode ec = 0;
     
-    Node* parent = m_element2->parentNode();
+    ContainerNode* parent = m_element2->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
     parent->insertBefore(m_element1.get(), m_element2.get(), ec);
diff --git a/WebCore/editing/SplitTextNodeCommand.cpp b/WebCore/editing/SplitTextNodeCommand.cpp
index 1f38902..6c414f9 100644
--- a/WebCore/editing/SplitTextNodeCommand.cpp
+++ b/WebCore/editing/SplitTextNodeCommand.cpp
@@ -49,7 +49,7 @@ SplitTextNodeCommand::SplitTextNodeCommand(PassRefPtr<Text> text, int offset)
 
 void SplitTextNodeCommand::doApply()
 {
-    Node* parent = m_text2->parentNode();
+    ContainerNode* parent = m_text2->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
 
@@ -87,7 +87,7 @@ void SplitTextNodeCommand::doReapply()
     if (!m_text1 || !m_text2)
         return;
 
-    Node* parent = m_text2->parentNode();
+    ContainerNode* parent = m_text2->parentNode();
     if (!parent || !parent->isContentEditable())
         return;
 
diff --git a/WebCore/editing/TextIterator.cpp b/WebCore/editing/TextIterator.cpp
index da30d8f..a96268d 100644
--- a/WebCore/editing/TextIterator.cpp
+++ b/WebCore/editing/TextIterator.cpp
@@ -154,9 +154,9 @@ unsigned BitStack::size() const
 
 // --------
 
-static inline Node* parentCrossingShadowBoundaries(Node* node)
+static inline ContainerNode* parentCrossingShadowBoundaries(Node* node)
 {
-    if (Node* parent = node->parentNode())
+    if (ContainerNode* parent = node->parentNode())
         return parent;
     return node->shadowParentNode();
 }
diff --git a/WebCore/editing/htmlediting.cpp b/WebCore/editing/htmlediting.cpp
index 7927900..f8f02b9 100644
--- a/WebCore/editing/htmlediting.cpp
+++ b/WebCore/editing/htmlediting.cpp
@@ -706,7 +706,7 @@ HTMLElement* enclosingList(Node* node)
         
     Node* root = highestEditableRoot(Position(node, 0));
     
-    for (Node* n = node->parentNode(); n; n = n->parentNode()) {
+    for (ContainerNode* n = node->parentNode(); n; n = n->parentNode()) {
         if (n->hasTagName(ulTag) || n->hasTagName(olTag))
             return static_cast<HTMLElement*>(n);
         if (n == root)
diff --git a/WebCore/editing/markup.cpp b/WebCore/editing/markup.cpp
index 82499bf..308fded 100644
--- a/WebCore/editing/markup.cpp
+++ b/WebCore/editing/markup.cpp
@@ -834,10 +834,10 @@ static Node* serializeNodes(StyledMarkupAccumulator& accumulator, Node* startNod
             }
 
             // Surround the currently accumulated markup with markup for ancestors we never opened as we leave the subtree(s) rooted at those ancestors.
-            Node* nextParent = next ? next->parentNode() : 0;
+            ContainerNode* nextParent = next ? next->parentNode() : 0;
             if (next != pastEnd && n != nextParent) {
                 Node* lastAncestorClosedOrSelf = n->isDescendantOf(lastClosed) ? lastClosed : n;
-                for (Node *parent = lastAncestorClosedOrSelf->parent(); parent && parent != nextParent; parent = parent->parentNode()) {
+                for (ContainerNode* parent = lastAncestorClosedOrSelf->parent(); parent && parent != nextParent; parent = parent->parentNode()) {
                     // All ancestors that aren't in the ancestorsToClose list should either be a) unrendered:
                     if (!parent->renderer())
                         continue;
@@ -861,7 +861,7 @@ static Node* ancestorToRetainStructureAndAppearance(Node* commonAncestor)
         return 0;
 
     if (commonAncestorBlock->hasTagName(tbodyTag) || commonAncestorBlock->hasTagName(trTag)) {
-        Node* table = commonAncestorBlock->parentNode();
+        ContainerNode* table = commonAncestorBlock->parentNode();
         while (table && !table->hasTagName(tableTag))
             table = table->parentNode();
 
@@ -1071,7 +1071,7 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
 
     if (specialCommonAncestor && lastClosed) {
         // Also include all of the ancestors of lastClosed up to this special ancestor.
-        for (Node* ancestor = lastClosed->parentNode(); ancestor; ancestor = ancestor->parentNode()) {
+        for (ContainerNode* ancestor = lastClosed->parentNode(); ancestor; ancestor = ancestor->parentNode()) {
             if (ancestor == fullySelectedRoot && !convertBlocksToInlines) {
                 RefPtr<CSSMutableStyleDeclaration> fullySelectedRootStyle = styleFromMatchedRulesAndInlineDecl(fullySelectedRoot);
 
@@ -1106,7 +1106,7 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
     }
 
     // Add a wrapper span with the styles that all of the nodes in the markup inherit.
-    Node* parentOfLastClosed = lastClosed ? lastClosed->parentNode() : 0;
+    ContainerNode* parentOfLastClosed = lastClosed ? lastClosed->parentNode() : 0;
     if (parentOfLastClosed && parentOfLastClosed->renderer()) {
         RefPtr<CSSMutableStyleDeclaration> style = ApplyStyleCommand::editingStyleAtPosition(Position(parentOfLastClosed, 0));
 
diff --git a/WebCore/html/HTMLAreaElement.cpp b/WebCore/html/HTMLAreaElement.cpp
index d808fb1..0155bce 100644
--- a/WebCore/html/HTMLAreaElement.cpp
+++ b/WebCore/html/HTMLAreaElement.cpp
@@ -200,7 +200,7 @@ void HTMLAreaElement::updateFocusAppearance(bool restorePreviousSelection)
     if (!isFocusable())
         return;
     
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent || !parent->hasTagName(mapTag))
         return;
     
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index a56efdc..1483fbc 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -456,7 +456,7 @@ void HTMLElement::setOuterText(const String &text, ExceptionCode& ec)
         return;
     }
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent) {
         ec = NO_MODIFICATION_ALLOWED_ERR;
         return;
@@ -507,9 +507,8 @@ Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, Exception
     // Opera also appears to disallow such usage.
 
     if (equalIgnoringCase(where, "beforeBegin")) {
-        if (Node* p = parent())
-            return p->insertBefore(newChild, this, ec) ? newChild : 0;
-        return 0;
+        ContainerNode* parent = this->parent();
+        return (parent && parent->insertBefore(newChild, this, ec)) ? newChild : 0;
     }
 
     if (equalIgnoringCase(where, "afterBegin"))
@@ -519,9 +518,8 @@ Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, Exception
         return appendChild(newChild, ec) ? newChild : 0;
 
     if (equalIgnoringCase(where, "afterEnd")) {
-        if (Node* p = parent())
-            return p->insertBefore(newChild, nextSibling(), ec) ? newChild : 0;
-        return 0;
+        ContainerNode* parent = this->parent();
+        return (parent && parent->insertBefore(newChild, nextSibling(), ec)) ? newChild : 0;
     }
     
     // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative.
@@ -546,7 +544,7 @@ Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChi
 static Element* contextElementForInsertion(const String& where, Element* element, ExceptionCode& ec)
 {
     if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "afterEnd")) {
-        Node* parent = element->parentNode();
+        ContainerNode* parent = element->parentNode();
         if (parent && parent->isDocumentNode()) {
             ec = NO_MODIFICATION_ALLOWED_ERR;
             return 0;
@@ -793,9 +791,10 @@ RenderObject* HTMLElement::createRenderer(RenderArena* arena, RenderStyle* style
 
 HTMLFormElement* HTMLElement::findFormAncestor() const
 {
-    for (Node* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode())
+    for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
         if (ancestor->hasTagName(formTag))
             return static_cast<HTMLFormElement*>(ancestor);
+    }
     return 0;
 }
 
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index 4f5729a..c4f007c 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -192,7 +192,7 @@ bool HTMLEmbedElement::rendererIsNeeded(RenderStyle* style)
 
     // If my parent is an <object> and is not set to use fallback content, I
     // should be ignored and not get a renderer.
-    Node* p = parentNode();
+    ContainerNode* p = parentNode();
     if (p && p->hasTagName(objectTag)) {
         ASSERT(p->renderer());
         if (!static_cast<HTMLObjectElement*>(p)->useFallbackContent()) {
diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp
index db5da66..31a72bd 100644
--- a/WebCore/html/HTMLFormElement.cpp
+++ b/WebCore/html/HTMLFormElement.cpp
@@ -107,7 +107,7 @@ bool HTMLFormElement::rendererIsNeeded(RenderStyle* style)
     if (!isDemoted())
         return HTMLElement::rendererIsNeeded(style);
 
-    Node* node = parentNode();
+    ContainerNode* node = parentNode();
     RenderObject* parentRenderer = node->renderer();
     bool parentIsTableElementPart = (parentRenderer->isTable() && node->hasTagName(tableTag))
         || (parentRenderer->isTableRow() && node->hasTagName(trTag))
diff --git a/WebCore/html/HTMLFrameSetElement.cpp b/WebCore/html/HTMLFrameSetElement.cpp
index a2a3930..bd68c14 100644
--- a/WebCore/html/HTMLFrameSetElement.cpp
+++ b/WebCore/html/HTMLFrameSetElement.cpp
@@ -164,7 +164,7 @@ void HTMLFrameSetElement::attach()
 {
     // Inherit default settings from parent frameset
     // FIXME: This is not dynamic.
-    for (Node* node = parentNode(); node; node = node->parentNode()) {
+    for (ContainerNode* node = parentNode(); node; node = node->parentNode()) {
         if (node->hasTagName(framesetTag)) {
             HTMLFrameSetElement* frameset = static_cast<HTMLFrameSetElement*>(node);
             if (!frameBorderSet)
diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp
index ad08ae9..d66075e 100644
--- a/WebCore/html/HTMLImageElement.cpp
+++ b/WebCore/html/HTMLImageElement.cpp
@@ -237,7 +237,7 @@ void HTMLImageElement::insertedIntoTree(bool deep)
 {
     if (!m_form) {
         // m_form can be non-null if it was set in constructor.
-        for (Node* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
+        for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
             if (ancestor->hasTagName(formTag)) {
                 m_form = static_cast<HTMLFormElement*>(ancestor);
                 m_form->registerImgElement(this);
diff --git a/WebCore/html/HTMLLegendElement.cpp b/WebCore/html/HTMLLegendElement.cpp
index acc4a59..f998118 100644
--- a/WebCore/html/HTMLLegendElement.cpp
+++ b/WebCore/html/HTMLLegendElement.cpp
@@ -57,7 +57,7 @@ const AtomicString& HTMLLegendElement::formControlType() const
 HTMLFormControlElement* HTMLLegendElement::associatedControl()
 {
     // Check if there's a fieldset belonging to this legend.
-    Node* fieldset = parentNode();
+    ContainerNode* fieldset = parentNode();
     while (fieldset && !fieldset->hasTagName(fieldsetTag))
         fieldset = fieldset->parentNode();
     if (!fieldset)
diff --git a/WebCore/html/HTMLOptGroupElement.cpp b/WebCore/html/HTMLOptGroupElement.cpp
index 091e0f2..987eb51 100644
--- a/WebCore/html/HTMLOptGroupElement.cpp
+++ b/WebCore/html/HTMLOptGroupElement.cpp
@@ -79,7 +79,7 @@ void HTMLOptGroupElement::parseMappedAttribute(Attribute* attr)
 
 void HTMLOptGroupElement::recalcSelectOptions()
 {
-    Node* select = parentNode();
+    ContainerNode* select = parentNode();
     while (select && !select->hasTagName(selectTag))
         select = select->parentNode();
     if (select)
@@ -123,7 +123,7 @@ String HTMLOptGroupElement::groupLabelText() const
     
 HTMLSelectElement* HTMLOptGroupElement::ownerSelectElement() const
 {
-    Node* select = parentNode();
+    ContainerNode* select = parentNode();
     while (select && !select->hasTagName(selectTag))
         select = select->parentNode();
     
diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp
index 3bf522c..67c3567 100644
--- a/WebCore/html/HTMLOptionElement.cpp
+++ b/WebCore/html/HTMLOptionElement.cpp
@@ -193,7 +193,7 @@ void HTMLOptionElement::childrenChanged(bool changedByParser, Node* beforeChange
 
 HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const
 {
-    Node* select = parentNode();
+    ContainerNode* select = parentNode();
     while (select && !(select->hasTagName(selectTag) || select->hasTagName(keygenTag)))
         select = select->parentNode();
 
diff --git a/WebCore/html/HTMLTableCellElement.cpp b/WebCore/html/HTMLTableCellElement.cpp
index f14a45b..9123115 100644
--- a/WebCore/html/HTMLTableCellElement.cpp
+++ b/WebCore/html/HTMLTableCellElement.cpp
@@ -115,7 +115,7 @@ void HTMLTableCellElement::parseMappedAttribute(Attribute* attr)
 // used by table cells to share style decls created by the enclosing table.
 void HTMLTableCellElement::additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>& results)
 {
-    Node* p = parentNode();
+    ContainerNode* p = parentNode();
     while (p && !p->hasTagName(tableTag))
         p = p->parentNode();
     if (!p)
diff --git a/WebCore/html/HTMLTableColElement.cpp b/WebCore/html/HTMLTableColElement.cpp
index 20b0f36..96af708 100644
--- a/WebCore/html/HTMLTableColElement.cpp
+++ b/WebCore/html/HTMLTableColElement.cpp
@@ -82,7 +82,7 @@ void HTMLTableColElement::additionalAttributeStyleDecls(Vector<CSSMutableStyleDe
 {
     if (!hasLocalName(colgroupTag))
         return;
-    Node* p = parentNode();
+    ContainerNode* p = parentNode();
     while (p && !p->hasTagName(tableTag))
         p = p->parentNode();
     if (!p)
diff --git a/WebCore/html/HTMLTableElement.cpp b/WebCore/html/HTMLTableElement.cpp
index 74e06d1..fe823ea 100644
--- a/WebCore/html/HTMLTableElement.cpp
+++ b/WebCore/html/HTMLTableElement.cpp
@@ -203,7 +203,7 @@ PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec
         }
     }
 
-    Node* parent;
+    ContainerNode* parent;
     if (lastRow)
         parent = row ? row->parent() : lastRow->parent();
     else {
diff --git a/WebCore/html/HTMLTableRowElement.cpp b/WebCore/html/HTMLTableRowElement.cpp
index e9b5cec..fbc253d 100644
--- a/WebCore/html/HTMLTableRowElement.cpp
+++ b/WebCore/html/HTMLTableRowElement.cpp
@@ -56,7 +56,7 @@ PassRefPtr<HTMLTableRowElement> HTMLTableRowElement::create(const QualifiedName&
 
 int HTMLTableRowElement::rowIndex() const
 {
-    Node *table = parentNode();
+    ContainerNode* table = parentNode();
     if (!table)
         return -1;
     table = table->parentNode();
diff --git a/WebCore/html/HTMLTableSectionElement.cpp b/WebCore/html/HTMLTableSectionElement.cpp
index 982e035..5ef25f1 100644
--- a/WebCore/html/HTMLTableSectionElement.cpp
+++ b/WebCore/html/HTMLTableSectionElement.cpp
@@ -50,7 +50,7 @@ PassRefPtr<HTMLTableSectionElement> HTMLTableSectionElement::create(const Qualif
 // used by table row groups to share style decls created by the enclosing table.
 void HTMLTableSectionElement::additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>& results)
 {
-    Node* p = parentNode();
+    ContainerNode* p = parentNode();
     while (p && !p->hasTagName(tableTag))
         p = p->parentNode();
     if (!p)
diff --git a/WebCore/inspector/InspectorDOMAgent.cpp b/WebCore/inspector/InspectorDOMAgent.cpp
index 2739191..30bc3dc 100644
--- a/WebCore/inspector/InspectorDOMAgent.cpp
+++ b/WebCore/inspector/InspectorDOMAgent.cpp
@@ -485,7 +485,7 @@ void InspectorDOMAgent::removeNode(long nodeId, long* outNodeId)
     if (!node)
         return;
 
-    Node* parentNode = node->parentNode();
+    ContainerNode* parentNode = node->parentNode();
     if (!parentNode)
         return;
 
@@ -520,7 +520,7 @@ void InspectorDOMAgent::changeTagName(long nodeId, const String& tagName, long*
         newElem->appendChild(child, ec);
 
     // Replace the old node with the new node
-    Node* parent = oldNode->parentNode();
+    ContainerNode* parent = oldNode->parentNode();
     parent->insertBefore(newElem, oldNode->nextSibling(), ec);
     parent->removeChild(oldNode, ec);
 
@@ -551,7 +551,7 @@ void InspectorDOMAgent::setOuterHTML(long nodeId, const String& outerHTML, long*
 
     bool childrenRequested = m_childrenRequested.contains(nodeId);
     Node* previousSibling = node->previousSibling();
-    Node* parentNode = node->parentNode();
+    ContainerNode* parentNode = node->parentNode();
 
     HTMLElement* htmlElement = static_cast<HTMLElement*>(node);
     ExceptionCode ec = 0;
@@ -1034,8 +1034,8 @@ unsigned InspectorDOMAgent::innerChildNodeCount(Node* node)
 
 Node* InspectorDOMAgent::innerParentNode(Node* node)
 {
-    Node* parent = node->parentNode();
-    if (parent && parent->nodeType() == Node::DOCUMENT_NODE)
+    ContainerNode* parent = node->parentNode();
+    if (parent && parent->isDocumentNode())
         return static_cast<Document*>(parent)->ownerElement();
     return parent;
 }
@@ -1076,7 +1076,7 @@ void InspectorDOMAgent::didInsertDOMNode(Node* node)
     // We could be attaching existing subtree. Forget the bindings.
     unbind(node, &m_documentNodeToIdMap);
 
-    Node* parent = node->parentNode();
+    ContainerNode* parent = node->parentNode();
     long parentId = m_documentNodeToIdMap.get(parent);
     // Return if parent is not mapped yet.
     if (!parentId)
@@ -1114,7 +1114,7 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node)
         } while (!stack.isEmpty());
     }
 
-    Node* parent = node->parentNode();
+    ContainerNode* parent = node->parentNode();
     long parentId = m_documentNodeToIdMap.get(parent);
     // If parent is not mapped yet -> ignore the event.
     if (!parentId)
diff --git a/WebCore/page/DOMSelection.cpp b/WebCore/page/DOMSelection.cpp
index 6c25103..03172b5 100644
--- a/WebCore/page/DOMSelection.cpp
+++ b/WebCore/page/DOMSelection.cpp
@@ -370,7 +370,7 @@ PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionCode& ec)
     ASSERT(rangeCount() == 1);
 
     if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) {
-        Node* container = shadowAncestor->parentNode();
+        ContainerNode* container = shadowAncestor->parentNode();
         int offset = shadowAncestor->nodeIndex();
         return Range::create(shadowAncestor->document(), container, offset, container, offset);
     }
@@ -460,7 +460,7 @@ bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
     if (!n || m_frame->document() != n->document() || selection->isNone())
         return false;
 
-    Node* parentNode = n->parentNode();
+    ContainerNode* parentNode = n->parentNode();
     unsigned nodeIndex = n->nodeIndex();
     RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
 
diff --git a/WebCore/rendering/RenderSVGGradientStop.cpp b/WebCore/rendering/RenderSVGGradientStop.cpp
index ebf7385..a5e5808 100644
--- a/WebCore/rendering/RenderSVGGradientStop.cpp
+++ b/WebCore/rendering/RenderSVGGradientStop.cpp
@@ -72,7 +72,7 @@ void RenderSVGGradientStop::layout()
 
 SVGGradientElement* RenderSVGGradientStop::gradientElement() const
 {
-    Node* parentNode = node()->parent();
+    ContainerNode* parentNode = node()->parent();
     if (parentNode->hasTagName(linearGradientTag) || parentNode->hasTagName(radialGradientTag))
         return static_cast<SVGGradientElement*>(parentNode);
     return 0;
diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp
index 1b19f25..ea79e78 100644
--- a/WebCore/svg/SVGElement.cpp
+++ b/WebCore/svg/SVGElement.cpp
@@ -116,7 +116,7 @@ void SVGElement::setXmlbase(const String& value, ExceptionCode&)
 
 SVGSVGElement* SVGElement::ownerSVGElement() const
 {
-    Node* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode();
+    ContainerNode* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode();
     while (n) {
         if (n->hasTagName(SVGNames::svgTag))
             return static_cast<SVGSVGElement*>(n);
@@ -131,7 +131,7 @@ SVGElement* SVGElement::viewportElement() const
 {
     // This function needs shadow tree support - as RenderSVGContainer uses this function
     // to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise.
-    Node* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode();
+    ContainerNode* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode();
     while (n) {
         if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::imageTag) || n->hasTagName(SVGNames::symbolTag))
             return static_cast<SVGElement*>(n);
diff --git a/WebCore/svg/SVGFELightElement.cpp b/WebCore/svg/SVGFELightElement.cpp
index 61d7df0..315aa29 100644
--- a/WebCore/svg/SVGFELightElement.cpp
+++ b/WebCore/svg/SVGFELightElement.cpp
@@ -78,7 +78,7 @@ void SVGFELightElement::svgAttributeChanged(const QualifiedName& attrName)
         || attrName == SVGNames::pointsAtZAttr
         || attrName == SVGNames::specularExponentAttr
         || attrName == SVGNames::limitingConeAngleAttr) {
-        if (Node* parentNode = parent()) {
+        if (ContainerNode* parentNode = parent()) {
             RenderObject* renderer = parentNode->renderer();
             if (renderer && renderer->isSVGResourceFilterPrimitive())
                 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
@@ -131,7 +131,7 @@ void SVGFELightElement::childrenChanged(bool changedByParser, Node* beforeChange
     SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
 
     if (!changedByParser) {
-        if (Node* parentNode = parent()) {
+        if (ContainerNode* parentNode = parent()) {
             RenderObject* renderer = parentNode->renderer();
             if (renderer && renderer->isSVGResourceFilterPrimitive())
                 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
diff --git a/WebCore/svg/SVGFEMergeNodeElement.cpp b/WebCore/svg/SVGFEMergeNodeElement.cpp
index aeb05f4..ee1ac3a 100644
--- a/WebCore/svg/SVGFEMergeNodeElement.cpp
+++ b/WebCore/svg/SVGFEMergeNodeElement.cpp
@@ -55,7 +55,7 @@ void SVGFEMergeNodeElement::svgAttributeChanged(const QualifiedName& attrName)
     if (attrName != SVGNames::inAttr)
         return;
 
-    Node* parentNode = parent();
+    ContainerNode* parentNode = parent();
     if (!parentNode)
         return;
 
diff --git a/WebCore/svg/SVGFontFaceFormatElement.cpp b/WebCore/svg/SVGFontFaceFormatElement.cpp
index e3182c4..939b062 100644
--- a/WebCore/svg/SVGFontFaceFormatElement.cpp
+++ b/WebCore/svg/SVGFontFaceFormatElement.cpp
@@ -46,7 +46,7 @@ void SVGFontFaceFormatElement::childrenChanged(bool changedByParser, Node* befor
     if (!parentNode() || !parentNode()->hasTagName(font_face_uriTag))
         return;
     
-    Node* ancestor = parentNode()->parentNode();
+    ContainerNode* ancestor = parentNode()->parentNode();
     if (!ancestor || !ancestor->hasTagName(font_face_srcTag))
         return;
     
diff --git a/WebCore/svg/SVGFontFaceUriElement.cpp b/WebCore/svg/SVGFontFaceUriElement.cpp
index 3ecba16..58a22c7 100644
--- a/WebCore/svg/SVGFontFaceUriElement.cpp
+++ b/WebCore/svg/SVGFontFaceUriElement.cpp
@@ -76,9 +76,9 @@ void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeCh
     if (!parentNode() || !parentNode()->hasTagName(font_face_srcTag))
         return;
     
-    Node* grandParent = parentNode()->parentNode();
-    if (grandParent && grandParent->hasTagName(font_faceTag))
-        static_cast<SVGFontFaceElement*>(grandParent)->rebuildFontFace();
+    ContainerNode* grandparent = parentNode()->parentNode();
+    if (grandparent && grandparent->hasTagName(font_faceTag))
+        static_cast<SVGFontFaceElement*>(grandparent)->rebuildFontFace();
 }
 
 void SVGFontFaceUriElement::insertedIntoDocument()
diff --git a/WebCore/svg/SVGGlyphElement.cpp b/WebCore/svg/SVGGlyphElement.cpp
index 8ded0fc..baa9966 100644
--- a/WebCore/svg/SVGGlyphElement.cpp
+++ b/WebCore/svg/SVGGlyphElement.cpp
@@ -49,7 +49,7 @@ PassRefPtr<SVGGlyphElement> SVGGlyphElement::create(const QualifiedName& tagName
 
 void SVGGlyphElement::invalidateGlyphCache()
 {
-    Node* fontNode = parentNode();
+    ContainerNode* fontNode = parentNode();
     if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) {
         if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
             element->invalidateGlyphCache();
diff --git a/WebCore/svg/SVGHKernElement.cpp b/WebCore/svg/SVGHKernElement.cpp
index a432daa..7f83241 100644
--- a/WebCore/svg/SVGHKernElement.cpp
+++ b/WebCore/svg/SVGHKernElement.cpp
@@ -47,7 +47,7 @@ PassRefPtr<SVGHKernElement> SVGHKernElement::create(const QualifiedName& tagName
 
 void SVGHKernElement::insertedIntoDocument()
 {
-    Node* fontNode = parentNode();
+    ContainerNode* fontNode = parentNode();
     if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) {
         if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
             element->invalidateGlyphCache();
@@ -56,7 +56,7 @@ void SVGHKernElement::insertedIntoDocument()
 
 void SVGHKernElement::removedFromDocument()
 {
-    Node* fontNode = parentNode();
+    ContainerNode* fontNode = parentNode();
     if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) {
         if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
             element->invalidateGlyphCache();
diff --git a/WebCore/svg/SVGLocatable.cpp b/WebCore/svg/SVGLocatable.cpp
index 3311a5a..9a823ff 100644
--- a/WebCore/svg/SVGLocatable.cpp
+++ b/WebCore/svg/SVGLocatable.cpp
@@ -44,7 +44,7 @@ static bool isViewportElement(Node* node)
 SVGElement* SVGLocatable::nearestViewportElement(const SVGElement* element)
 {
     ASSERT(element);
-    for (Node* n = element->parentNode(); n && !n->isDocumentNode(); n = n->parentNode()) {
+    for (ContainerNode* n = element->parentNode(); n; n = n->parentNode()) {
         if (isViewportElement(n))
             return static_cast<SVGElement*>(n);
     }
@@ -56,7 +56,7 @@ SVGElement* SVGLocatable::farthestViewportElement(const SVGElement* element)
 {
     ASSERT(element);
     SVGElement* farthest = 0;
-    for (Node* n = element->parentNode(); n && !n->isDocumentNode(); n = n->parentNode()) {
+    for (ContainerNode* n = element->parentNode(); n; n = n->parentNode()) {
         if (isViewportElement(n))
             farthest = static_cast<SVGElement*>(n);
     }
diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp
index d4452ec..6edc216 100644
--- a/WebCore/svg/SVGUseElement.cpp
+++ b/WebCore/svg/SVGUseElement.cpp
@@ -298,7 +298,7 @@ void SVGUseElement::updateContainerOffsets()
     SVGElement* shadowRoot = m_targetElementInstance->shadowTreeElement();
     ASSERT(shadowRoot);
 
-    Node* parentNode = shadowRoot->parentNode();
+    ContainerNode* parentNode = shadowRoot->parentNode();
     ASSERT(parentNode);
     ASSERT(parentNode->isSVGElement());
     ASSERT(parentNode->hasTagName(SVGNames::gTag));
@@ -479,7 +479,7 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR
 
     // Do not build the shadow/instance tree for <use> elements living in a shadow tree.
     // The will be expanded soon anyway - see expandUseElementsInShadowTree().
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     while (parent) {
         if (parent->isShadowNode())
             return;
diff --git a/WebCore/svg/SVGVKernElement.cpp b/WebCore/svg/SVGVKernElement.cpp
index b9f3c17..eed13d2 100644
--- a/WebCore/svg/SVGVKernElement.cpp
+++ b/WebCore/svg/SVGVKernElement.cpp
@@ -45,7 +45,7 @@ PassRefPtr<SVGVKernElement> SVGVKernElement::create(const QualifiedName& tagName
 
 void SVGVKernElement::insertedIntoDocument()
 {
-    Node* fontNode = parentNode();
+    ContainerNode* fontNode = parentNode();
     if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) {
         if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
             element->invalidateGlyphCache();
@@ -54,7 +54,7 @@ void SVGVKernElement::insertedIntoDocument()
 
 void SVGVKernElement::removedFromDocument()
 {
-    Node* fontNode = parentNode();
+    ContainerNode* fontNode = parentNode();
     if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) {
         if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
             element->invalidateGlyphCache();
diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp
index 99a5189..a90b444 100644
--- a/WebCore/svg/animation/SVGSMILElement.cpp
+++ b/WebCore/svg/animation/SVGSMILElement.cpp
@@ -463,7 +463,7 @@ void SVGSMILElement::reschedule()
 SVGElement* SVGSMILElement::targetElement() const
 {
     String href = xlinkHref();
-    Node* target = href.isEmpty() ? parentNode() : document()->getElementById(SVGURIReference::getTarget(href));
+    ContainerNode* target = href.isEmpty() ? parentNode() : document()->getElementById(SVGURIReference::getTarget(href));
     if (target && target->isSVGElement())
         return static_cast<SVGElement*>(target);
     return 0;
diff --git a/WebCore/wml/WMLDoElement.cpp b/WebCore/wml/WMLDoElement.cpp
index 9398aa0..17a6d10 100644
--- a/WebCore/wml/WMLDoElement.cpp
+++ b/WebCore/wml/WMLDoElement.cpp
@@ -120,7 +120,7 @@ void WMLDoElement::insertedIntoDocument()
     if (!hasAttribute(HTMLNames::nameAttr))
         m_name = m_type;
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent || !parent->isWMLElement())
         return;
 
@@ -130,7 +130,7 @@ void WMLDoElement::insertedIntoDocument()
 
 void WMLDoElement::removedFromDocument()
 {
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
 
     if (parent  && parent->isWMLElement()) {
         if (WMLEventHandlingElement* eventHandlingElement = toWMLEventHandlingElement(static_cast<WMLElement*>(parent)))
diff --git a/WebCore/wml/WMLNoopElement.cpp b/WebCore/wml/WMLNoopElement.cpp
index 3afddeb..fbd3788 100644
--- a/WebCore/wml/WMLNoopElement.cpp
+++ b/WebCore/wml/WMLNoopElement.cpp
@@ -49,7 +49,7 @@ void WMLNoopElement::insertedIntoDocument()
 {
     WMLElement::insertedIntoDocument();
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent || !parent->isWMLElement())
         return;
 
diff --git a/WebCore/wml/WMLOptGroupElement.cpp b/WebCore/wml/WMLOptGroupElement.cpp
index 7c59a7e..3e15c7b 100644
--- a/WebCore/wml/WMLOptGroupElement.cpp
+++ b/WebCore/wml/WMLOptGroupElement.cpp
@@ -55,49 +55,9 @@ const AtomicString& WMLOptGroupElement::formControlType() const
     return optgroup;
 }
 
-bool WMLOptGroupElement::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& ec, bool shouldLazyAttach)
-{
-    bool result = WMLFormControlElement::insertBefore(newChild, refChild, ec, shouldLazyAttach);
-    if (result)
-        recalcSelectOptions();
-    return result;
-}
-
-bool WMLOptGroupElement::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& ec, bool shouldLazyAttach)
-{
-    bool result = WMLFormControlElement::replaceChild(newChild, oldChild, ec, shouldLazyAttach);
-    if (result)
-        recalcSelectOptions();
-    return result;
-}
-
-bool WMLOptGroupElement::removeChild(Node* oldChild, ExceptionCode& ec)
-{
-    bool result = WMLFormControlElement::removeChild(oldChild, ec);
-    if (result)
-        recalcSelectOptions();
-    return result;
-}
-
-bool WMLOptGroupElement::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bool shouldLazyAttach)
-{
-    bool result = WMLFormControlElement::appendChild(newChild, ec, shouldLazyAttach);
-    if (result)
-        recalcSelectOptions();
-    return result;
-}
-
-bool WMLOptGroupElement::removeChildren()
-{
-    bool result = WMLFormControlElement::removeChildren();
-    if (result)
-        recalcSelectOptions();
-    return result;
-}
-
 static inline WMLSelectElement* ownerSelectElement(Element* element)
 {
-    Node* select = element->parentNode();
+    ContainerNode* select = element->parentNode();
     while (select && !select->hasTagName(selectTag))
         select = select->parentNode();
 
diff --git a/WebCore/wml/WMLOptGroupElement.h b/WebCore/wml/WMLOptGroupElement.h
index 3cfa47d..c49749e 100644
--- a/WebCore/wml/WMLOptGroupElement.h
+++ b/WebCore/wml/WMLOptGroupElement.h
@@ -38,12 +38,6 @@ public:
 
     virtual bool rendererIsNeeded(RenderStyle*) { return false; }
 
-    virtual bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&, bool shouldLazyAttach = false);
-    virtual bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&, bool shouldLazyAttach = false);
-    virtual bool removeChild(Node* child, ExceptionCode&);
-    virtual bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&, bool shouldLazyAttach = false);
-    virtual bool removeChildren();
-
     virtual void accessKeyAction(bool sendToAnyElement);
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/wml/WMLOptionElement.cpp b/WebCore/wml/WMLOptionElement.cpp
index bc97215..6c8aa74 100644
--- a/WebCore/wml/WMLOptionElement.cpp
+++ b/WebCore/wml/WMLOptionElement.cpp
@@ -56,7 +56,7 @@ const AtomicString& WMLOptionElement::formControlType() const
 
 static inline WMLSelectElement* ownerSelectElement(Element* element)
 {
-    Node* select = element->parentNode();
+    ContainerNode* select = element->parentNode();
     while (select && !select->hasTagName(selectTag))
         select = select->parentNode();
 
diff --git a/WebCore/wml/WMLPostfieldElement.cpp b/WebCore/wml/WMLPostfieldElement.cpp
index b168dbb..25ce05a 100644
--- a/WebCore/wml/WMLPostfieldElement.cpp
+++ b/WebCore/wml/WMLPostfieldElement.cpp
@@ -48,14 +48,14 @@ void WMLPostfieldElement::insertedIntoDocument()
 {
     WMLElement::insertedIntoDocument();
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (parent && parent->hasTagName(goTag))
         static_cast<WMLGoElement*>(parent)->registerPostfieldElement(this);
 }
 
 void WMLPostfieldElement::removedFromDocument()
 {
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (parent && parent->hasTagName(goTag))
         static_cast<WMLGoElement*>(parent)->deregisterPostfieldElement(this);
 
diff --git a/WebCore/wml/WMLSetvarElement.cpp b/WebCore/wml/WMLSetvarElement.cpp
index a0fc3e8..0514602 100644
--- a/WebCore/wml/WMLSetvarElement.cpp
+++ b/WebCore/wml/WMLSetvarElement.cpp
@@ -60,7 +60,7 @@ void WMLSetvarElement::insertedIntoDocument()
 {
     WMLElement::insertedIntoDocument();
  
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent || !parent->isWMLElement())
         return;
 
@@ -70,7 +70,7 @@ void WMLSetvarElement::insertedIntoDocument()
 
 void WMLSetvarElement::removedFromDocument()
 {
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (parent && parent->isWMLElement()) {
         if (static_cast<WMLElement*>(parent)->isWMLTaskElement())
             static_cast<WMLTaskElement*>(parent)->deregisterVariableSetter(this);
diff --git a/WebCore/wml/WMLTaskElement.cpp b/WebCore/wml/WMLTaskElement.cpp
index d49a03e..3d1d636 100644
--- a/WebCore/wml/WMLTaskElement.cpp
+++ b/WebCore/wml/WMLTaskElement.cpp
@@ -47,7 +47,7 @@ void WMLTaskElement::insertedIntoDocument()
 {
     WMLElement::insertedIntoDocument();
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent || !parent->isWMLElement())
         return;
 
@@ -61,7 +61,7 @@ void WMLTaskElement::insertedIntoDocument()
 
 void WMLTaskElement::removedFromDocument()
 {
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (parent && parent->isWMLElement()) {
         if (parent->hasTagName(anchorTag))
             static_cast<WMLAnchorElement*>(parent)->deregisterTask(this);
diff --git a/WebCore/wml/WMLTimerElement.cpp b/WebCore/wml/WMLTimerElement.cpp
index feac38b..dd6c4aa 100644
--- a/WebCore/wml/WMLTimerElement.cpp
+++ b/WebCore/wml/WMLTimerElement.cpp
@@ -63,7 +63,7 @@ void WMLTimerElement::insertedIntoDocument()
     if (value().toInt() <= 0)
         return;
 
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (!parent || !parent->isWMLElement())
         return;
 
@@ -75,7 +75,7 @@ void WMLTimerElement::insertedIntoDocument()
 
 void WMLTimerElement::removedFromDocument()
 {
-    Node* parent = parentNode();
+    ContainerNode* parent = parentNode();
     if (parent && parent->isWMLElement() && parent->hasTagName(cardTag)) {
         m_card->setIntrinsicEventTimer(0);
         m_card = 0;
diff --git a/WebCore/xml/XPathStep.cpp b/WebCore/xml/XPathStep.cpp
index 6e60952..ddd8c3c 100644
--- a/WebCore/xml/XPathStep.cpp
+++ b/WebCore/xml/XPathStep.cpp
@@ -255,11 +255,11 @@ void Step::nodesInAxis(Node* context, NodeSet& nodes) const
             return;
         case ParentAxis:
             if (context->isAttributeNode()) {
-                Node* n = static_cast<Attr*>(context)->ownerElement();
+                Element* n = static_cast<Attr*>(context)->ownerElement();
                 if (nodeMatches(n, ParentAxis, m_nodeTest))
                     nodes.append(n);
             } else {
-                Node* n = context->parentNode();
+                ContainerNode* n = context->parentNode();
                 if (n && nodeMatches(n, ParentAxis, m_nodeTest))
                     nodes.append(n);
             }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list