Commit ef508986 authored by eseidel's avatar eseidel

Bug #: 6109

Submitted by: eseidel
Reviewed by: darin
        No functionality changes, no tests possible.

        khtml/editing should use RefPtr instead of manual ref/deref
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6109

        Results in a slight performance gain < 1% on the PLT.

        * khtml/editing/SelectionController.cpp:
        (khtml::SelectionController::toRange):
        * khtml/editing/SelectionController.h:
        * khtml/editing/append_node_command.cpp:
        (khtml::AppendNodeCommand::AppendNodeCommand):
        (khtml::AppendNodeCommand::doApply):
        (khtml::AppendNodeCommand::doUnapply):
        * khtml/editing/append_node_command.h:
        (khtml::AppendNodeCommand::~AppendNodeCommand):
        (khtml::AppendNodeCommand::appendChild):
        (khtml::AppendNodeCommand::parentNode):
        * khtml/editing/apply_style_command.cpp:
        (khtml::StyleChange::init):
        (khtml::ApplyStyleCommand::removeInlineStyle):
        * khtml/editing/apply_style_command.h:
        * khtml/editing/composite_edit_command.cpp:
        (khtml::CompositeEditCommand::deleteInsignificantText):
        * khtml/editing/delete_from_text_node_command.cpp:
        (khtml::DeleteFromTextNodeCommand::DeleteFromTextNodeCommand):
        * khtml/editing/delete_from_text_node_command.h:
        (khtml::DeleteFromTextNodeCommand::~DeleteFromTextNodeCommand):
        (khtml::DeleteFromTextNodeCommand::node):
        * khtml/editing/delete_selection_command.cpp:
        (khtml::DeleteSelectionCommand::initializePositionData):
        (khtml::DeleteSelectionCommand::saveTypingStyleState):
        (khtml::DeleteSelectionCommand::handleGeneralDelete):
        (khtml::DeleteSelectionCommand::calculateEndingPosition):
        (khtml::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
        (khtml::DeleteSelectionCommand::clearTransientState):
        * khtml/editing/delete_selection_command.h:
        * khtml/editing/edit_command.cpp:
        (khtml::EditCommand::EditCommand):
        (khtml::EditCommand::~EditCommand):
        (khtml::EditCommand::setTypingStyle):
        (khtml::EditCommand::styleAtPosition):
        * khtml/editing/edit_command.h:
        (khtml::EditCommand::document):
        (khtml::EditCommand::typingStyle):
        * khtml/editing/insert_into_text_node_command.cpp:
        (khtml::InsertIntoTextNodeCommand::InsertIntoTextNodeCommand):
        * khtml/editing/insert_into_text_node_command.h:
        (khtml::InsertIntoTextNodeCommand::~InsertIntoTextNodeCommand):
        (khtml::InsertIntoTextNodeCommand::node):
        * khtml/editing/insert_node_before_command.cpp:
        (khtml::InsertNodeBeforeCommand::InsertNodeBeforeCommand):
        (khtml::InsertNodeBeforeCommand::doApply):
        (khtml::InsertNodeBeforeCommand::doUnapply):
        * khtml/editing/insert_node_before_command.h:
        (khtml::InsertNodeBeforeCommand::~InsertNodeBeforeCommand):
        (khtml::InsertNodeBeforeCommand::insertChild):
        (khtml::InsertNodeBeforeCommand::refChild):
        * khtml/editing/insert_paragraph_separator_command.cpp:
        (khtml::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand):
        (khtml::InsertParagraphSeparatorCommand::~InsertParagraphSeparatorCommand):
        (khtml::InsertParagraphSeparatorCommand::calculateStyleBeforeInsertion):
        (khtml::InsertParagraphSeparatorCommand::applyStyleAfterInsertion):
        * khtml/editing/insert_paragraph_separator_command.h:
        * khtml/editing/join_text_nodes_command.cpp:
        (khtml::JoinTextNodesCommand::JoinTextNodesCommand):
        (khtml::JoinTextNodesCommand::doApply):
        (khtml::JoinTextNodesCommand::doUnapply):
        * khtml/editing/join_text_nodes_command.h:
        (khtml::JoinTextNodesCommand::~JoinTextNodesCommand):
        (khtml::JoinTextNodesCommand::firstNode):
        (khtml::JoinTextNodesCommand::secondNode):
        * khtml/editing/jsediting.cpp:
        * khtml/editing/markup.cpp:
        (khtml::createMarkup):
        (khtml::createFragmentFromMarkup):
        (khtml::createFragmentFromText):
        (khtml::createFragmentFromNodeList):
        * khtml/editing/markup.h:
        * khtml/editing/merge_identical_elements_command.cpp:
        (khtml::MergeIdenticalElementsCommand::MergeIdenticalElementsCommand):
        (khtml::MergeIdenticalElementsCommand::doApply):
        (khtml::MergeIdenticalElementsCommand::doUnapply):
        * khtml/editing/merge_identical_elements_command.h:
        (khtml::MergeIdenticalElementsCommand::~MergeIdenticalElementsCommand):
        * khtml/editing/move_selection_command.cpp:
        (khtml::MoveSelectionCommand::MoveSelectionCommand):
        (khtml::MoveSelectionCommand::~MoveSelectionCommand):
        (khtml::MoveSelectionCommand::doApply):
        * khtml/editing/move_selection_command.h:
        * khtml/editing/rebalance_whitespace_command.cpp:
        * khtml/editing/rebalance_whitespace_command.h:
        (khtml::RebalanceWhitespaceCommand::~RebalanceWhitespaceCommand):
        * khtml/editing/remove_css_property_command.cpp:
        (khtml::RemoveCSSPropertyCommand::RemoveCSSPropertyCommand):
        * khtml/editing/remove_css_property_command.h:
        (khtml::RemoveCSSPropertyCommand::~RemoveCSSPropertyCommand):
        (khtml::RemoveCSSPropertyCommand::styleDeclaration):
        * khtml/editing/remove_node_attribute_command.cpp:
        (khtml::RemoveNodeAttributeCommand::RemoveNodeAttributeCommand):
        * khtml/editing/remove_node_attribute_command.h:
        (khtml::RemoveNodeAttributeCommand::~RemoveNodeAttributeCommand):
        (khtml::RemoveNodeAttributeCommand::element):
        * khtml/editing/remove_node_command.cpp:
        (khtml::RemoveNodeCommand::RemoveNodeCommand):
        (khtml::RemoveNodeCommand::doApply):
        (khtml::RemoveNodeCommand::doUnapply):
        * khtml/editing/remove_node_command.h:
        (khtml::RemoveNodeCommand::~RemoveNodeCommand):
        (khtml::RemoveNodeCommand::node):
        * khtml/editing/remove_node_preserving_children_command.cpp:
        (khtml::RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand):
        * khtml/editing/remove_node_preserving_children_command.h:
        (khtml::RemoveNodePreservingChildrenCommand::~RemoveNodePreservingChildrenCommand):
        (khtml::RemoveNodePreservingChildrenCommand::node):
        * khtml/editing/replace_selection_command.cpp:
        (khtml::ReplacementFragment::ReplacementFragment):
        (khtml::ReplacementFragment::~ReplacementFragment):
        (khtml::ReplacementFragment::enclosingBlock):
        (khtml::ReplacementFragment::removeNodePreservingChildren):
        (khtml::ReplacementFragment::removeNode):
        (khtml::ReplacementFragment::insertFragmentForTestRendering):
        (khtml::ReplacementFragment::restoreTestRenderingNodesToFragment):
        (khtml::ReplaceSelectionCommand::fixupNodeStyles):
        (khtml::computeAndStoreNodeDesiredStyle):
        (khtml::NodeDesiredStyle::NodeDesiredStyle):
        (khtml::ReplaceSelectionCommand::ReplaceSelectionCommand):
        (khtml::ReplaceSelectionCommand::~ReplaceSelectionCommand):
        (khtml::ReplaceSelectionCommand::doApply):
        (khtml::ReplaceSelectionCommand::completeHTMLReplacement):
        (khtml::ReplaceSelectionCommand::updateNodesInserted):
        * khtml/editing/replace_selection_command.h:
        (khtml::NodeDesiredStyle::node):
        (khtml::NodeDesiredStyle::style):
        (khtml::ReplacementFragment::root):
        * khtml/editing/set_node_attribute_command.cpp:
        (khtml::SetNodeAttributeCommand::SetNodeAttributeCommand):
        * khtml/editing/set_node_attribute_command.h:
        (khtml::SetNodeAttributeCommand::~SetNodeAttributeCommand):
        (khtml::SetNodeAttributeCommand::element):
        * khtml/editing/split_element_command.cpp:
        (khtml::SplitElementCommand::SplitElementCommand):
        (khtml::SplitElementCommand::doApply):
        (khtml::SplitElementCommand::doUnapply):
        * khtml/editing/split_element_command.h:
        (khtml::SplitElementCommand::~SplitElementCommand):
        * khtml/editing/split_text_node_command.cpp:
        (khtml::SplitTextNodeCommand::SplitTextNodeCommand):
        (khtml::SplitTextNodeCommand::doApply):
        (khtml::SplitTextNodeCommand::doUnapply):
        * khtml/editing/split_text_node_command.h:
        (khtml::SplitTextNodeCommand::~SplitTextNodeCommand):
        (khtml::SplitTextNodeCommand::node):
        * khtml/editing/split_text_node_containing_element.cpp:
        (khtml::SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand):
        (khtml::SplitTextNodeContainingElementCommand::doApply):
        * khtml/editing/split_text_node_containing_element_command.h:
        (khtml::SplitTextNodeContainingElementCommand::~SplitTextNodeContainingElementCommand):
        * khtml/editing/visible_position.cpp:
        (khtml::makeRange):
        * khtml/editing/visible_position.h:
        * khtml/editing/visible_text.cpp:
        (khtml::TextIterator::range):
        (khtml::SimplifiedBackwardsTextIterator::range):
        (khtml::CharacterIterator::range):
        (khtml::findPlainText):
        * khtml/editing/visible_text.h:
        (khtml::WordAwareIterator::range):
        * khtml/editing/wrap_contents_in_dummy_span_command.cpp:
        (khtml::WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand):
        (khtml::WrapContentsInDummySpanCommand::doApply):
        (khtml::WrapContentsInDummySpanCommand::doUnapply):
        * khtml/editing/wrap_contents_in_dummy_span_command.h:
        (khtml::WrapContentsInDummySpanCommand::~WrapContentsInDummySpanCommand):
        * kwq/DOMHTML.mm:
        (-[DOMHTMLDocument _createDocumentFragmentWithMarkupString:baseURLString:]):
        (-[DOMHTMLDocument _createDocumentFragmentWithText:]):
        * kwq/WebCoreBridge.mm:
        (-[WebCoreBridge documentFragmentWithMarkupString:baseURLString:]):
        (-[WebCoreBridge documentFragmentWithText:]):
        (-[WebCoreBridge documentFragmentWithNodesAsParagraphs:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1fb63eff
2006-01-03 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
No functionality changes, no tests possible.
khtml/editing should use RefPtr instead of manual ref/deref
http://bugzilla.opendarwin.org/show_bug.cgi?id=6109
Results in a slight performance gain < 1% on the PLT.
* khtml/editing/SelectionController.cpp:
(khtml::SelectionController::toRange):
* khtml/editing/SelectionController.h:
* khtml/editing/append_node_command.cpp:
(khtml::AppendNodeCommand::AppendNodeCommand):
(khtml::AppendNodeCommand::doApply):
(khtml::AppendNodeCommand::doUnapply):
* khtml/editing/append_node_command.h:
(khtml::AppendNodeCommand::~AppendNodeCommand):
(khtml::AppendNodeCommand::appendChild):
(khtml::AppendNodeCommand::parentNode):
* khtml/editing/apply_style_command.cpp:
(khtml::StyleChange::init):
(khtml::ApplyStyleCommand::removeInlineStyle):
* khtml/editing/apply_style_command.h:
* khtml/editing/composite_edit_command.cpp:
(khtml::CompositeEditCommand::deleteInsignificantText):
* khtml/editing/delete_from_text_node_command.cpp:
(khtml::DeleteFromTextNodeCommand::DeleteFromTextNodeCommand):
* khtml/editing/delete_from_text_node_command.h:
(khtml::DeleteFromTextNodeCommand::~DeleteFromTextNodeCommand):
(khtml::DeleteFromTextNodeCommand::node):
* khtml/editing/delete_selection_command.cpp:
(khtml::DeleteSelectionCommand::initializePositionData):
(khtml::DeleteSelectionCommand::saveTypingStyleState):
(khtml::DeleteSelectionCommand::handleGeneralDelete):
(khtml::DeleteSelectionCommand::calculateEndingPosition):
(khtml::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
(khtml::DeleteSelectionCommand::clearTransientState):
* khtml/editing/delete_selection_command.h:
* khtml/editing/edit_command.cpp:
(khtml::EditCommand::EditCommand):
(khtml::EditCommand::~EditCommand):
(khtml::EditCommand::setTypingStyle):
(khtml::EditCommand::styleAtPosition):
* khtml/editing/edit_command.h:
(khtml::EditCommand::document):
(khtml::EditCommand::typingStyle):
* khtml/editing/insert_into_text_node_command.cpp:
(khtml::InsertIntoTextNodeCommand::InsertIntoTextNodeCommand):
* khtml/editing/insert_into_text_node_command.h:
(khtml::InsertIntoTextNodeCommand::~InsertIntoTextNodeCommand):
(khtml::InsertIntoTextNodeCommand::node):
* khtml/editing/insert_node_before_command.cpp:
(khtml::InsertNodeBeforeCommand::InsertNodeBeforeCommand):
(khtml::InsertNodeBeforeCommand::doApply):
(khtml::InsertNodeBeforeCommand::doUnapply):
* khtml/editing/insert_node_before_command.h:
(khtml::InsertNodeBeforeCommand::~InsertNodeBeforeCommand):
(khtml::InsertNodeBeforeCommand::insertChild):
(khtml::InsertNodeBeforeCommand::refChild):
* khtml/editing/insert_paragraph_separator_command.cpp:
(khtml::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand):
(khtml::InsertParagraphSeparatorCommand::~InsertParagraphSeparatorCommand):
(khtml::InsertParagraphSeparatorCommand::calculateStyleBeforeInsertion):
(khtml::InsertParagraphSeparatorCommand::applyStyleAfterInsertion):
* khtml/editing/insert_paragraph_separator_command.h:
* khtml/editing/join_text_nodes_command.cpp:
(khtml::JoinTextNodesCommand::JoinTextNodesCommand):
(khtml::JoinTextNodesCommand::doApply):
(khtml::JoinTextNodesCommand::doUnapply):
* khtml/editing/join_text_nodes_command.h:
(khtml::JoinTextNodesCommand::~JoinTextNodesCommand):
(khtml::JoinTextNodesCommand::firstNode):
(khtml::JoinTextNodesCommand::secondNode):
* khtml/editing/jsediting.cpp:
* khtml/editing/markup.cpp:
(khtml::createMarkup):
(khtml::createFragmentFromMarkup):
(khtml::createFragmentFromText):
(khtml::createFragmentFromNodeList):
* khtml/editing/markup.h:
* khtml/editing/merge_identical_elements_command.cpp:
(khtml::MergeIdenticalElementsCommand::MergeIdenticalElementsCommand):
(khtml::MergeIdenticalElementsCommand::doApply):
(khtml::MergeIdenticalElementsCommand::doUnapply):
* khtml/editing/merge_identical_elements_command.h:
(khtml::MergeIdenticalElementsCommand::~MergeIdenticalElementsCommand):
* khtml/editing/move_selection_command.cpp:
(khtml::MoveSelectionCommand::MoveSelectionCommand):
(khtml::MoveSelectionCommand::~MoveSelectionCommand):
(khtml::MoveSelectionCommand::doApply):
* khtml/editing/move_selection_command.h:
* khtml/editing/rebalance_whitespace_command.cpp:
* khtml/editing/rebalance_whitespace_command.h:
(khtml::RebalanceWhitespaceCommand::~RebalanceWhitespaceCommand):
* khtml/editing/remove_css_property_command.cpp:
(khtml::RemoveCSSPropertyCommand::RemoveCSSPropertyCommand):
* khtml/editing/remove_css_property_command.h:
(khtml::RemoveCSSPropertyCommand::~RemoveCSSPropertyCommand):
(khtml::RemoveCSSPropertyCommand::styleDeclaration):
* khtml/editing/remove_node_attribute_command.cpp:
(khtml::RemoveNodeAttributeCommand::RemoveNodeAttributeCommand):
* khtml/editing/remove_node_attribute_command.h:
(khtml::RemoveNodeAttributeCommand::~RemoveNodeAttributeCommand):
(khtml::RemoveNodeAttributeCommand::element):
* khtml/editing/remove_node_command.cpp:
(khtml::RemoveNodeCommand::RemoveNodeCommand):
(khtml::RemoveNodeCommand::doApply):
(khtml::RemoveNodeCommand::doUnapply):
* khtml/editing/remove_node_command.h:
(khtml::RemoveNodeCommand::~RemoveNodeCommand):
(khtml::RemoveNodeCommand::node):
* khtml/editing/remove_node_preserving_children_command.cpp:
(khtml::RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand):
* khtml/editing/remove_node_preserving_children_command.h:
(khtml::RemoveNodePreservingChildrenCommand::~RemoveNodePreservingChildrenCommand):
(khtml::RemoveNodePreservingChildrenCommand::node):
* khtml/editing/replace_selection_command.cpp:
(khtml::ReplacementFragment::ReplacementFragment):
(khtml::ReplacementFragment::~ReplacementFragment):
(khtml::ReplacementFragment::enclosingBlock):
(khtml::ReplacementFragment::removeNodePreservingChildren):
(khtml::ReplacementFragment::removeNode):
(khtml::ReplacementFragment::insertFragmentForTestRendering):
(khtml::ReplacementFragment::restoreTestRenderingNodesToFragment):
(khtml::ReplaceSelectionCommand::fixupNodeStyles):
(khtml::computeAndStoreNodeDesiredStyle):
(khtml::NodeDesiredStyle::NodeDesiredStyle):
(khtml::ReplaceSelectionCommand::ReplaceSelectionCommand):
(khtml::ReplaceSelectionCommand::~ReplaceSelectionCommand):
(khtml::ReplaceSelectionCommand::doApply):
(khtml::ReplaceSelectionCommand::completeHTMLReplacement):
(khtml::ReplaceSelectionCommand::updateNodesInserted):
* khtml/editing/replace_selection_command.h:
(khtml::NodeDesiredStyle::node):
(khtml::NodeDesiredStyle::style):
(khtml::ReplacementFragment::root):
* khtml/editing/set_node_attribute_command.cpp:
(khtml::SetNodeAttributeCommand::SetNodeAttributeCommand):
* khtml/editing/set_node_attribute_command.h:
(khtml::SetNodeAttributeCommand::~SetNodeAttributeCommand):
(khtml::SetNodeAttributeCommand::element):
* khtml/editing/split_element_command.cpp:
(khtml::SplitElementCommand::SplitElementCommand):
(khtml::SplitElementCommand::doApply):
(khtml::SplitElementCommand::doUnapply):
* khtml/editing/split_element_command.h:
(khtml::SplitElementCommand::~SplitElementCommand):
* khtml/editing/split_text_node_command.cpp:
(khtml::SplitTextNodeCommand::SplitTextNodeCommand):
(khtml::SplitTextNodeCommand::doApply):
(khtml::SplitTextNodeCommand::doUnapply):
* khtml/editing/split_text_node_command.h:
(khtml::SplitTextNodeCommand::~SplitTextNodeCommand):
(khtml::SplitTextNodeCommand::node):
* khtml/editing/split_text_node_containing_element.cpp:
(khtml::SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand):
(khtml::SplitTextNodeContainingElementCommand::doApply):
* khtml/editing/split_text_node_containing_element_command.h:
(khtml::SplitTextNodeContainingElementCommand::~SplitTextNodeContainingElementCommand):
* khtml/editing/visible_position.cpp:
(khtml::makeRange):
* khtml/editing/visible_position.h:
* khtml/editing/visible_text.cpp:
(khtml::TextIterator::range):
(khtml::SimplifiedBackwardsTextIterator::range):
(khtml::CharacterIterator::range):
(khtml::findPlainText):
* khtml/editing/visible_text.h:
(khtml::WordAwareIterator::range):
* khtml/editing/wrap_contents_in_dummy_span_command.cpp:
(khtml::WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand):
(khtml::WrapContentsInDummySpanCommand::doApply):
(khtml::WrapContentsInDummySpanCommand::doUnapply):
* khtml/editing/wrap_contents_in_dummy_span_command.h:
(khtml::WrapContentsInDummySpanCommand::~WrapContentsInDummySpanCommand):
* kwq/DOMHTML.mm:
(-[DOMHTMLDocument _createDocumentFragmentWithMarkupString:baseURLString:]):
(-[DOMHTMLDocument _createDocumentFragmentWithText:]):
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge documentFragmentWithMarkupString:baseURLString:]):
(-[WebCoreBridge documentFragmentWithText:]):
(-[WebCoreBridge documentFragmentWithNodesAsParagraphs:]):
2006-01-03 Anders Carlsson <andersca@mac.com>
Reviewed by Darin.
......
......@@ -601,10 +601,10 @@ void SelectionController::setNeedsLayout(bool flag)
m_needsLayout = flag;
}
RefPtr<RangeImpl> SelectionController::toRange() const
PassRefPtr<RangeImpl> SelectionController::toRange() const
{
if (isNone())
return RefPtr<RangeImpl>();
return 0;
// Make sure we have an updated layout since this function is called
// in the course of running edit commands which modify the DOM.
......@@ -647,16 +647,16 @@ RefPtr<RangeImpl> SelectionController::toRange() const
}
int exceptionCode = 0;
RefPtr<RangeImpl> result(new RangeImpl(s.node()->getDocument()));
PassRefPtr<RangeImpl> result(new RangeImpl(s.node()->getDocument()));
result->setStart(s.node(), s.offset(), exceptionCode);
if (exceptionCode) {
ERROR("Exception setting Range start from SelectionController: %d", exceptionCode);
return RefPtr<RangeImpl>();
return 0;
}
result->setEnd(e.node(), e.offset(), exceptionCode);
if (exceptionCode) {
ERROR("Exception setting Range end from SelectionController: %d", exceptionCode);
return RefPtr<RangeImpl>();
return 0;
}
return result;
}
......
......@@ -27,6 +27,7 @@
#define KHTML_EDITING_SELECTION_H
#include <qrect.h>
#include <kxmlcore/PassRefPtr.h>
#include "xml/dom_position.h"
#include "text_granularity.h"
#include "misc/shared.h"
......@@ -105,7 +106,7 @@ public:
bool isRange() const { return state() == RANGE; }
bool isCaretOrRange() const { return state() != NONE; }
RefPtr<DOM::RangeImpl> toRange() const;
PassRefPtr<DOM::RangeImpl> toRange() const;
void debugPosition() const;
void debugRenderer(khtml::RenderObject *r, bool selected) const;
......
......@@ -39,19 +39,7 @@ AppendNodeCommand::AppendNodeCommand(DocumentImpl *document, NodeImpl *appendChi
: EditCommand(document), m_appendChild(appendChild), m_parentNode(parentNode)
{
ASSERT(m_appendChild);
m_appendChild->ref();
ASSERT(m_parentNode);
m_parentNode->ref();
}
AppendNodeCommand::~AppendNodeCommand()
{
ASSERT(m_appendChild);
m_appendChild->deref();
ASSERT(m_parentNode);
m_parentNode->deref();
}
void AppendNodeCommand::doApply()
......@@ -60,7 +48,7 @@ void AppendNodeCommand::doApply()
ASSERT(m_parentNode);
int exceptionCode = 0;
m_parentNode->appendChild(m_appendChild, exceptionCode);
m_parentNode->appendChild(m_appendChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
......@@ -71,7 +59,7 @@ void AppendNodeCommand::doUnapply()
ASSERT(state() == Applied);
int exceptionCode = 0;
m_parentNode->removeChild(m_appendChild, exceptionCode);
m_parentNode->removeChild(m_appendChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
......
......@@ -38,17 +38,17 @@ class AppendNodeCommand : public EditCommand
{
public:
AppendNodeCommand(DOM::DocumentImpl *, DOM::NodeImpl *appendChild, DOM::NodeImpl *parentNode);
virtual ~AppendNodeCommand();
virtual ~AppendNodeCommand() { }
virtual void doApply();
virtual void doUnapply();
DOM::NodeImpl *appendChild() const { return m_appendChild; }
DOM::NodeImpl *parentNode() const { return m_parentNode; }
DOM::NodeImpl *appendChild() const { return m_appendChild.get(); }
DOM::NodeImpl *parentNode() const { return m_parentNode.get(); }
private:
DOM::NodeImpl *m_appendChild;
DOM::NodeImpl *m_parentNode;
RefPtr<DOM::NodeImpl> m_appendChild;
RefPtr<DOM::NodeImpl> m_parentNode;
};
} // namespace khtml
......
......@@ -90,7 +90,7 @@ public:
bool usesLegacyStyles() const { return m_usesLegacyStyles; }
private:
void init(CSSStyleDeclarationImpl *, const Position &);
void init(PassRefPtr<CSSStyleDeclarationImpl>, const Position &);
bool checkForLegacyHTMLStyleChange(const CSSProperty *);
static bool currentlyHasStyle(const Position &, const CSSProperty *);
......@@ -117,13 +117,11 @@ StyleChange::StyleChange(CSSStyleDeclarationImpl *style, const Position &positio
init(style, position);
}
void StyleChange::init(CSSStyleDeclarationImpl *style, const Position &position)
void StyleChange::init(PassRefPtr<CSSStyleDeclarationImpl> style, const Position &position)
{
style->ref();
RefPtr<CSSMutableStyleDeclarationImpl> mutableStyle = style->makeMutable();
style->deref();
QString styleText("");
DOMString styleText("");
QValueListConstIterator<CSSProperty> end;
for (QValueListConstIterator<CSSProperty> it = mutableStyle->valuesIterator(); it != end; ++it) {
......@@ -143,14 +141,13 @@ void StyleChange::init(CSSStyleDeclarationImpl *style, const Position &position)
if (property->id() == CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT) {
// we have to special-case text decorations
CSSProperty alteredProperty = CSSProperty(CSS_PROP_TEXT_DECORATION, property->value(), property->isImportant());
styleText += alteredProperty.cssText().qstring();
} else {
styleText += property->cssText().qstring();
}
styleText += alteredProperty.cssText();
} else
styleText += property->cssText();
}
// Save the result for later
m_cssStyle = styleText.stripWhiteSpace();
m_cssStyle = styleText.qstring().stripWhiteSpace();
}
StyleChange::ELegacyHTMLStyles StyleChange::styleModeForParseMode(bool isQuirksMode)
......@@ -876,7 +873,7 @@ static int maxRangeOffset(NodeImpl *n)
return 1;
}
void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style, const Position &start, const Position &end)
void ApplyStyleCommand::removeInlineStyle(PassRefPtr<CSSMutableStyleDeclarationImpl> style, const Position &start, const Position &end)
{
ASSERT(start.isNotNull());
ASSERT(end.isNotNull());
......@@ -905,12 +902,12 @@ void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style,
HTMLElementImpl *elem = static_cast<HTMLElementImpl *>(node);
NodeImpl *prev = elem->traversePreviousNodePostOrder();
NodeImpl *next = elem->traverseNextNode();
if (isHTMLStyleNode(style, elem)) {
if (isHTMLStyleNode(style.get(), elem)) {
removeHTMLStyleNode(elem);
}
else {
removeHTMLFontStyle(style, elem);
removeCSSStyle(style, elem);
removeHTMLFontStyle(style.get(), elem);
removeCSSStyle(style.get(), elem);
}
if (!elem->inDocument()) {
if (s.node() == elem) {
......@@ -932,11 +929,6 @@ void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style,
break;
node = next;
}
if (textDecorationSpecialProperty) {
style->deref();
}
ASSERT(s.node()->inDocument());
ASSERT(e.node()->inDocument());
......
......@@ -27,6 +27,7 @@
#define __apply_style_command_h__
#include "composite_edit_command.h"
#include <kxmlcore/PassRefPtr.h>
namespace DOM {
class HTMLElementImpl;
......@@ -55,7 +56,7 @@ private:
void removeHTMLFontStyle(DOM::CSSMutableStyleDeclarationImpl *, DOM::HTMLElementImpl *);
void removeCSSStyle(DOM::CSSMutableStyleDeclarationImpl *, DOM::HTMLElementImpl *);
void removeBlockStyle(DOM::CSSMutableStyleDeclarationImpl *, const DOM::Position &start, const DOM::Position &end);
void removeInlineStyle(DOM::CSSMutableStyleDeclarationImpl *, const DOM::Position &start, const DOM::Position &end);
void removeInlineStyle(PassRefPtr<DOM::CSSMutableStyleDeclarationImpl>, const DOM::Position &start, const DOM::Position &end);
bool nodeFullySelected(DOM::NodeImpl *, const DOM::Position &start, const DOM::Position &end) const;
bool nodeFullyUnselected(DOM::NodeImpl *node, const DOM::Position &start, const DOM::Position &end) const;
DOM::CSSMutableStyleDeclarationImpl *extractTextDecorationStyle(DOM::NodeImpl *node);
......
......@@ -380,7 +380,7 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
int removed = 0;
InlineTextBox *prevBox = 0;
DOMStringImpl *str = 0;
RefPtr<DOMStringImpl> str;
// This loop structure works to process all gaps preceding a box,
// and also will look at the gap after the last box.
......@@ -396,10 +396,8 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
if (indicesIntersect && gapLen > 0) {
gapStart = kMax(gapStart, start);
gapEnd = kMin(gapEnd, end);
if (!str) {
if (!str)
str = textNode->string()->substring(start, end - start);
str->ref();
}
// remove text in the gap
str->remove(gapStart - start - removed, gapLen);
removed += gapLen;
......@@ -413,7 +411,7 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
if (str) {
// Replace the text between start and end with our pruned version.
if (str->l > 0) {
replaceTextInNode(textNode, start, end - start, str);
replaceTextInNode(textNode, start, end - start, str.get());
}
else {
// Assert that we are not going to delete all of the text in the node.
......@@ -422,7 +420,6 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
ASSERT(start > 0 || (unsigned)end - start < textNode->length());
deleteTextFromNode(textNode, start, end - start);
}
str->deref();
}
}
......
......@@ -42,14 +42,6 @@ DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(DocumentImpl *document, Tex
ASSERT(m_offset >= 0);
ASSERT(m_offset < (int)m_node->length());
ASSERT(m_count >= 0);
m_node->ref();
}
DeleteFromTextNodeCommand::~DeleteFromTextNodeCommand()
{
ASSERT(m_node);
m_node->deref();
}
void DeleteFromTextNodeCommand::doApply()
......
......@@ -40,17 +40,17 @@ class DeleteFromTextNodeCommand : public EditCommand
{
public:
DeleteFromTextNodeCommand(DOM::DocumentImpl *document, DOM::TextImpl *node, int offset, int count);
virtual ~DeleteFromTextNodeCommand();
virtual ~DeleteFromTextNodeCommand() { }
virtual void doApply();
virtual void doUnapply();
DOM::TextImpl *node() const { return m_node; }
DOM::TextImpl *node() const { return m_node.get(); }
int offset() const { return m_offset; }
int count() const { return m_count; }
private:
DOM::TextImpl *m_node;
RefPtr<DOM::TextImpl> m_node;
int m_offset;
int m_count;
DOM::DOMString m_text;
......
......@@ -204,11 +204,8 @@ void DeleteSelectionCommand::initializePositionData()
// Handle setting start and end blocks and the start node.
//
m_startBlock = m_downstreamStart.node()->enclosingBlockFlowElement();
m_startBlock->ref();
m_endBlock = m_upstreamEnd.node()->enclosingBlockFlowElement();
m_endBlock->ref();
m_startNode = m_upstreamStart.node();
m_startNode->ref();
//
// Handle detecting if the line containing the selection end is itself fully selected.
......@@ -227,9 +224,9 @@ void DeleteSelectionCommand::initializePositionData()
debugPosition("m_downstreamEnd ", m_downstreamEnd);
debugPosition("m_leadingWhitespace ", m_leadingWhitespace);
debugPosition("m_trailingWhitespace ", m_trailingWhitespace);
debugNode( "m_startBlock ", m_startBlock);
debugNode( "m_endBlock ", m_endBlock);
debugNode( "m_startNode ", m_startNode);
debugNode( "m_startBlock ", m_startBlock.get());
debugNode( "m_endBlock ", m_endBlock.get());
debugNode( "m_startNode ", m_startNode.get());
}
void DeleteSelectionCommand::insertPlaceholderForAncestorBlockContent()
......@@ -272,20 +269,14 @@ void DeleteSelectionCommand::saveTypingStyleState()
// Figure out the typing style in effect before the delete is done.
// FIXME: Improve typing style.
// See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
CSSComputedStyleDeclarationImpl *computedStyle = positionBeforeTabSpan(m_selectionToDelete.start()).computedStyle();
computedStyle->ref();
RefPtr<CSSComputedStyleDeclarationImpl> computedStyle = positionBeforeTabSpan(m_selectionToDelete.start()).computedStyle();
m_typingStyle = computedStyle->copyInheritableProperties();
m_typingStyle->ref();
computedStyle->deref();
// If we're deleting into a Mail blockquote, save the style at end() instead of start()
// We'll use this later in computeTypingStyleAfterDelete if we end up outside of a Mail blockquote
if (nearestMailBlockquote(m_selectionToDelete.start().node())) {
computedStyle = m_selectionToDelete.end().computedStyle();
computedStyle->ref();
m_deleteIntoBlockquoteStyle = computedStyle->copyInheritableProperties();
m_deleteIntoBlockquoteStyle->ref();
computedStyle->deref();
} else
m_deleteIntoBlockquoteStyle = 0;
}
......@@ -312,16 +303,6 @@ bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
return false;
}
void DeleteSelectionCommand::setStartNode(NodeImpl *node)
{
NodeImpl *old = m_startNode;
m_startNode = node;
if (m_startNode)
m_startNode->ref();
if (old)
old->deref();
}
void DeleteSelectionCommand::handleGeneralDelete()
{
int startOffset = m_upstreamStart.offset();
......@@ -343,13 +324,13 @@ void DeleteSelectionCommand::handleGeneralDelete()
// end of a block other than the block containing the selection start, then do not delete the
// start block, otherwise delete the start block.
if (startOffset == 1 && m_startNode && m_startNode->hasTagName(brTag)) {
setStartNode(m_startNode->traverseNextNode());
m_startNode = m_startNode->traverseNextNode();
startOffset = 0;
}
if (m_startBlock != m_endBlock && isStartOfBlock(VisiblePosition(m_upstreamStart, m_selectionToDelete.startAffinity()))) {
if (!m_startBlock->isAncestor(m_endBlock) && !isStartOfBlock(visibleEnd) && endAtEndOfBlock) {
if (!m_startBlock->isAncestor(m_endBlock.get()) && !isStartOfBlock(visibleEnd) && endAtEndOfBlock) {
// Delete all the children of the block, but not the block itself.
setStartNode(m_startBlock->firstChild());
m_startNode = m_startBlock->firstChild();
startOffset = 0;
}
}
......@@ -362,13 +343,13 @@ void DeleteSelectionCommand::handleGeneralDelete()
// Also, before moving on, delete any insignificant text that may be present in a text node.
if (m_startNode->isTextNode()) {
// Delete any insignificant text from this node.
TextImpl *text = static_cast<TextImpl *>(m_startNode);
TextImpl *text = static_cast<TextImpl *>(m_startNode.get());
if (text->length() > (unsigned)m_startNode->caretMaxOffset())
deleteTextFromNode(text, m_startNode->caretMaxOffset(), text->length() - m_startNode->caretMaxOffset());
}
// shift the start node to the next
setStartNode(m_startNode->traverseNextNode());
m_startNode = m_startNode->traverseNextNode();
startOffset = 0;
}
......@@ -379,24 +360,24 @@ void DeleteSelectionCommand::handleGeneralDelete()
if (m_startNode == m_downstreamEnd.node()) {
// The selection to delete is all in one node.
if (!m_startNode->renderer() ||
(startOffset == 0 && m_downstreamEnd.offset() >= maxDeepOffset(m_startNode))) {
(startOffset == 0 && m_downstreamEnd.offset() >= maxDeepOffset(m_startNode.get()))) {
// just delete
removeFullySelectedNode(m_startNode);
removeFullySelectedNode(m_startNode.get());
} else if (m_downstreamEnd.offset() - startOffset > 0) {
if (m_startNode->isTextNode()) {
// in a text node that needs to be trimmed
TextImpl *text = static_cast<TextImpl *>(m_startNode);
TextImpl *text = static_cast<TextImpl *>(m_startNode.get());
deleteTextFromNode(text, startOffset, m_downstreamEnd.offset() - startOffset);
m_trailingWhitespaceValid = false;
} else {
removeChildrenInRange(m_startNode, startOffset, m_downstreamEnd.offset());
removeChildrenInRange(m_startNode.get(), startOffset, m_downstreamEnd.offset());
m_endingPosition = m_upstreamStart;
}
}
}
else {
// The selection to delete spans more than one node.
NodeImpl *node = m_startNode;
NodeImpl *node = m_startNode.get();
if (startOffset > 0) {
if (m_startNode->isTextNode()) {
......@@ -614,11 +595,11 @@ void DeleteSelectionCommand::calculateEndingPosition()
if (m_endingPosition.node()->inDocument())
return;
m_endingPosition = Position(m_startBlock, 0);
m_endingPosition = Position(m_startBlock.get(), 0);
if (m_endingPosition.node()->inDocument())
return;