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> 2006-01-03 Anders Carlsson <andersca@mac.com>
Reviewed by Darin. Reviewed by Darin.
......
...@@ -601,10 +601,10 @@ void SelectionController::setNeedsLayout(bool flag) ...@@ -601,10 +601,10 @@ void SelectionController::setNeedsLayout(bool flag)
m_needsLayout = flag; m_needsLayout = flag;
} }
RefPtr<RangeImpl> SelectionController::toRange() const PassRefPtr<RangeImpl> SelectionController::toRange() const
{ {
if (isNone()) if (isNone())
return RefPtr<RangeImpl>(); return 0;
// Make sure we have an updated layout since this function is called // Make sure we have an updated layout since this function is called
// in the course of running edit commands which modify the DOM. // in the course of running edit commands which modify the DOM.
...@@ -647,16 +647,16 @@ RefPtr<RangeImpl> SelectionController::toRange() const ...@@ -647,16 +647,16 @@ RefPtr<RangeImpl> SelectionController::toRange() const
} }
int exceptionCode = 0; 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); result->setStart(s.node(), s.offset(), exceptionCode);
if (exceptionCode) { if (exceptionCode) {
ERROR("Exception setting Range start from SelectionController: %d", exceptionCode); ERROR("Exception setting Range start from SelectionController: %d", exceptionCode);
return RefPtr<RangeImpl>(); return 0;
} }
result->setEnd(e.node(), e.offset(), exceptionCode); result->setEnd(e.node(), e.offset(), exceptionCode);
if (exceptionCode) { if (exceptionCode) {
ERROR("Exception setting Range end from SelectionController: %d", exceptionCode); ERROR("Exception setting Range end from SelectionController: %d", exceptionCode);
return RefPtr<RangeImpl>(); return 0;
} }
return result; return result;
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define KHTML_EDITING_SELECTION_H #define KHTML_EDITING_SELECTION_H
#include <qrect.h> #include <qrect.h>
#include <kxmlcore/PassRefPtr.h>
#include "xml/dom_position.h" #include "xml/dom_position.h"
#include "text_granularity.h" #include "text_granularity.h"
#include "misc/shared.h" #include "misc/shared.h"
...@@ -105,7 +106,7 @@ public: ...@@ -105,7 +106,7 @@ public:
bool isRange() const { return state() == RANGE; } bool isRange() const { return state() == RANGE; }
bool isCaretOrRange() const { return state() != NONE; } bool isCaretOrRange() const { return state() != NONE; }
RefPtr<DOM::RangeImpl> toRange() const; PassRefPtr<DOM::RangeImpl> toRange() const;
void debugPosition() const; void debugPosition() const;
void debugRenderer(khtml::RenderObject *r, bool selected) const; void debugRenderer(khtml::RenderObject *r, bool selected) const;
......
...@@ -39,19 +39,7 @@ AppendNodeCommand::AppendNodeCommand(DocumentImpl *document, NodeImpl *appendChi ...@@ -39,19 +39,7 @@ AppendNodeCommand::AppendNodeCommand(DocumentImpl *document, NodeImpl *appendChi
: EditCommand(document), m_appendChild(appendChild), m_parentNode(parentNode) : EditCommand(document), m_appendChild(appendChild), m_parentNode(parentNode)
{ {
ASSERT(m_appendChild); ASSERT(m_appendChild);
m_appendChild->ref();
ASSERT(m_parentNode);
m_parentNode->ref();
}
AppendNodeCommand::~AppendNodeCommand()
{
ASSERT(m_appendChild);
m_appendChild->deref();
ASSERT(m_parentNode); ASSERT(m_parentNode);
m_parentNode->deref();
} }
void AppendNodeCommand::doApply() void AppendNodeCommand::doApply()
...@@ -60,7 +48,7 @@ void AppendNodeCommand::doApply() ...@@ -60,7 +48,7 @@ void AppendNodeCommand::doApply()
ASSERT(m_parentNode); ASSERT(m_parentNode);
int exceptionCode = 0; int exceptionCode = 0;
m_parentNode->appendChild(m_appendChild, exceptionCode); m_parentNode->appendChild(m_appendChild.get(), exceptionCode);
ASSERT(exceptionCode == 0); ASSERT(exceptionCode == 0);
} }
...@@ -71,7 +59,7 @@ void AppendNodeCommand::doUnapply() ...@@ -71,7 +59,7 @@ void AppendNodeCommand::doUnapply()
ASSERT(state() == Applied); ASSERT(state() == Applied);
int exceptionCode = 0; int exceptionCode = 0;
m_parentNode->removeChild(m_appendChild, exceptionCode); m_parentNode->removeChild(m_appendChild.get(), exceptionCode);
ASSERT(exceptionCode == 0); ASSERT(exceptionCode == 0);
} }
......
...@@ -38,17 +38,17 @@ class AppendNodeCommand : public EditCommand ...@@ -38,17 +38,17 @@ class AppendNodeCommand : public EditCommand
{ {
public: public:
AppendNodeCommand(DOM::DocumentImpl *, DOM::NodeImpl *appendChild, DOM::NodeImpl *parentNode); AppendNodeCommand(DOM::DocumentImpl *, DOM::NodeImpl *appendChild, DOM::NodeImpl *parentNode);
virtual ~AppendNodeCommand(); virtual ~AppendNodeCommand() { }
virtual void doApply(); virtual void doApply();
virtual void doUnapply(); virtual void doUnapply();
DOM::NodeImpl *appendChild() const { return m_appendChild; } DOM::NodeImpl *appendChild() const { return m_appendChild.get(); }
DOM::NodeImpl *parentNode() const { return m_parentNode; } DOM::NodeImpl *parentNode() const { return m_parentNode.get(); }
private: private:
DOM::NodeImpl *m_appendChild; RefPtr<DOM::NodeImpl> m_appendChild;
DOM::NodeImpl *m_parentNode; RefPtr<DOM::NodeImpl> m_parentNode;
}; };
} // namespace khtml } // namespace khtml
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
bool usesLegacyStyles() const { return m_usesLegacyStyles; } bool usesLegacyStyles() const { return m_usesLegacyStyles; }
private: private:
void init(CSSStyleDeclarationImpl *, const Position &); void init(PassRefPtr<CSSStyleDeclarationImpl>, const Position &);
bool checkForLegacyHTMLStyleChange(const CSSProperty *); bool checkForLegacyHTMLStyleChange(const CSSProperty *);
static bool currentlyHasStyle(const Position &, const CSSProperty *); static bool currentlyHasStyle(const Position &, const CSSProperty *);
...@@ -117,13 +117,11 @@ StyleChange::StyleChange(CSSStyleDeclarationImpl *style, const Position &positio ...@@ -117,13 +117,11 @@ StyleChange::StyleChange(CSSStyleDeclarationImpl *style, const Position &positio
init(style, position); 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(); RefPtr<CSSMutableStyleDeclarationImpl> mutableStyle = style->makeMutable();
style->deref();
QString styleText(""); DOMString styleText("");
QValueListConstIterator<CSSProperty> end; QValueListConstIterator<CSSProperty> end;
for (QValueListConstIterator<CSSProperty> it = mutableStyle->valuesIterator(); it != end; ++it) { for (QValueListConstIterator<CSSProperty> it = mutableStyle->valuesIterator(); it != end; ++it) {
...@@ -143,14 +141,13 @@ void StyleChange::init(CSSStyleDeclarationImpl *style, const Position &position) ...@@ -143,14 +141,13 @@ void StyleChange::init(CSSStyleDeclarationImpl *style, const Position &position)
if (property->id() == CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT) { if (property->id() == CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT) {
// we have to special-case text decorations // we have to special-case text decorations
CSSProperty alteredProperty = CSSProperty(CSS_PROP_TEXT_DECORATION, property->value(), property->isImportant()); CSSProperty alteredProperty = CSSProperty(CSS_PROP_TEXT_DECORATION, property->value(), property->isImportant());
styleText += alteredProperty.cssText().qstring(); styleText += alteredProperty.cssText();
} else { } else
styleText += property->cssText().qstring(); styleText += property->cssText();
}
} }
// Save the result for later // Save the result for later
m_cssStyle = styleText.stripWhiteSpace(); m_cssStyle = styleText.qstring().stripWhiteSpace();
} }
StyleChange::ELegacyHTMLStyles StyleChange::styleModeForParseMode(bool isQuirksMode) StyleChange::ELegacyHTMLStyles StyleChange::styleModeForParseMode(bool isQuirksMode)
...@@ -876,7 +873,7 @@ static int maxRangeOffset(NodeImpl *n) ...@@ -876,7 +873,7 @@ static int maxRangeOffset(NodeImpl *n)
return 1; 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(start.isNotNull());
ASSERT(end.isNotNull()); ASSERT(end.isNotNull());
...@@ -905,12 +902,12 @@ void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style, ...@@ -905,12 +902,12 @@ void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style,
HTMLElementImpl *elem = static_cast<HTMLElementImpl *>(node); HTMLElementImpl *elem = static_cast<HTMLElementImpl *>(node);
NodeImpl *prev = elem->traversePreviousNodePostOrder(); NodeImpl *prev = elem->traversePreviousNodePostOrder();
NodeImpl *next = elem->traverseNextNode(); NodeImpl *next = elem->traverseNextNode();
if (isHTMLStyleNode(style, elem)) { if (isHTMLStyleNode(style.get(), elem)) {
removeHTMLStyleNode(elem); removeHTMLStyleNode(elem);
} }
else { else {
removeHTMLFontStyle(style, elem); removeHTMLFontStyle(style.get(), elem);
removeCSSStyle(style, elem); removeCSSStyle(style.get(), elem);
} }
if (!elem->inDocument()) { if (!elem->inDocument()) {
if (s.node() == elem) { if (s.node() == elem) {
...@@ -932,11 +929,6 @@ void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style, ...@@ -932,11 +929,6 @@ void ApplyStyleCommand::removeInlineStyle(CSSMutableStyleDeclarationImpl *style,
break; break;
node = next; node = next;
} }
if (textDecorationSpecialProperty) {
style->deref();
}
ASSERT(s.node()->inDocument()); ASSERT(s.node()->inDocument());
ASSERT(e.node()->inDocument()); ASSERT(e.node()->inDocument());
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define __apply_style_command_h__ #define __apply_style_command_h__
#include "composite_edit_command.h" #include "composite_edit_command.h"
#include <kxmlcore/PassRefPtr.h>
namespace DOM { namespace DOM {
class HTMLElementImpl; class HTMLElementImpl;
...@@ -55,7 +56,7 @@ private: ...@@ -55,7 +56,7 @@ private:
void removeHTMLFontStyle(DOM::CSSMutableStyleDeclarationImpl *, DOM::HTMLElementImpl *); void removeHTMLFontStyle(DOM::CSSMutableStyleDeclarationImpl *, DOM::HTMLElementImpl *);
void removeCSSStyle(DOM::CSSMutableStyleDeclarationImpl *, DOM::HTMLElementImpl *); void removeCSSStyle(DOM::CSSMutableStyleDeclarationImpl *, DOM::HTMLElementImpl *);
void removeBlockStyle(DOM::CSSMutableStyleDeclarationImpl *, const DOM::Position &start, const DOM::Position &end); 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 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; bool nodeFullyUnselected(DOM::NodeImpl *node, const DOM::Position &start, const DOM::Position &end) const;
DOM::CSSMutableStyleDeclarationImpl *extractTextDecorationStyle(DOM::NodeImpl *node); DOM::CSSMutableStyleDeclarationImpl *extractTextDecorationStyle(DOM::NodeImpl *node);
......
...@@ -380,7 +380,7 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start ...@@ -380,7 +380,7 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
int removed = 0; int removed = 0;
InlineTextBox *prevBox = 0; InlineTextBox *prevBox = 0;
DOMStringImpl *str = 0; RefPtr<DOMStringImpl> str;
// This loop structure works to process all gaps preceding a box, // This loop structure works to process all gaps preceding a box,
// and also will look at the gap after the last box. // and also will look at the gap after the last box.
...@@ -396,10 +396,8 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start ...@@ -396,10 +396,8 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
if (indicesIntersect && gapLen > 0) { if (indicesIntersect && gapLen > 0) {
gapStart = kMax(gapStart, start); gapStart = kMax(gapStart, start);
gapEnd = kMin(gapEnd, end); gapEnd = kMin(gapEnd, end);
if (!str) { if (!str)
str = textNode->string()->substring(start, end - start); str = textNode->string()->substring(start, end - start);
str->ref();
}
// remove text in the gap // remove text in the gap
str->remove(gapStart - start - removed, gapLen); str->remove(gapStart - start - removed, gapLen);
removed += gapLen; removed += gapLen;
...@@ -413,7 +411,7 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start ...@@ -413,7 +411,7 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
if (str) { if (str) {
// Replace the text between start and end with our pruned version. // Replace the text between start and end with our pruned version.
if (str->l > 0) { if (str->l > 0) {
replaceTextInNode(textNode, start, end - start, str); replaceTextInNode(textNode, start, end - start, str.get());
} }
else { else {
// Assert that we are not going to delete all of the text in the node. // 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 ...@@ -422,7 +420,6 @@ void CompositeEditCommand::deleteInsignificantText(TextImpl *textNode, int start
ASSERT(start > 0 || (unsigned)end - start < textNode->length()); ASSERT(start > 0 || (unsigned)end - start < textNode->length());
deleteTextFromNode(textNode, start, end - start); deleteTextFromNode(textNode, start, end - start);
} }
str->deref();
} }
} }
......
...@@ -42,14 +42,6 @@ DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(DocumentImpl *document, Tex ...@@ -42,14 +42,6 @@ DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(DocumentImpl *document, Tex
ASSERT(m_offset >= 0); ASSERT(m_offset >= 0);
ASSERT(m_offset < (int)m_node->length()); ASSERT(m_offset < (int)m_node->length());
ASSERT(m_count >= 0); ASSERT(m_count >= 0);
m_node->ref();
}
DeleteFromTextNodeCommand::~DeleteFromTextNodeCommand()
{
ASSERT(m_node);
m_node->deref();
} }
void DeleteFromTextNodeCommand::doApply() void DeleteFromTextNodeCommand::doApply()
......
...@@ -40,17 +40,17 @@ class DeleteFromTextNodeCommand : public EditCommand ...@@ -40,17 +40,17 @@ class DeleteFromTextNodeCommand : public EditCommand
{ {
public: public:
DeleteFromTextNodeCommand(DOM::DocumentImpl *document, DOM::TextImpl *node, int offset, int count); DeleteFromTextNodeCommand(DOM::DocumentImpl *document, DOM::TextImpl *node, int offset, int count);
virtual ~DeleteFromTextNodeCommand(); virtual ~DeleteFromTextNodeCommand() { }
virtual void doApply(); virtual void doApply();
virtual void doUnapply(); 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 offset() const { return m_offset; }
int count() const { return m_count; } int count() const { return m_count; }
private: private:
DOM::TextImpl *m_node; RefPtr<DOM::TextImpl> m_node;
int m_offset; int m_offset;
int m_count; int m_count;
DOM::DOMString m_text;