[webkit-changes] cvs commit: WebCore/kwq DOMHTML.mm WebCoreBridge.mm
Eric
eseidel at opensource.apple.com
Tue Jan 3 01:19:20 PST 2006
eseidel 06/01/03 01:19:19
Modified: . ChangeLog
khtml/editing SelectionController.cpp SelectionController.h
append_node_command.cpp append_node_command.h
apply_style_command.cpp apply_style_command.h
composite_edit_command.cpp
delete_from_text_node_command.cpp
delete_from_text_node_command.h
delete_selection_command.cpp
delete_selection_command.h edit_command.cpp
edit_command.h insert_into_text_node_command.cpp
insert_into_text_node_command.h
insert_node_before_command.cpp
insert_node_before_command.h
insert_paragraph_separator_command.cpp
insert_paragraph_separator_command.h
join_text_nodes_command.cpp
join_text_nodes_command.h jsediting.cpp markup.cpp
markup.h merge_identical_elements_command.cpp
merge_identical_elements_command.h
move_selection_command.cpp move_selection_command.h
rebalance_whitespace_command.cpp
rebalance_whitespace_command.h
remove_css_property_command.cpp
remove_css_property_command.h
remove_node_attribute_command.cpp
remove_node_attribute_command.h
remove_node_command.cpp remove_node_command.h
remove_node_preserving_children_command.cpp
remove_node_preserving_children_command.h
replace_selection_command.cpp
replace_selection_command.h
set_node_attribute_command.cpp
set_node_attribute_command.h
split_element_command.cpp split_element_command.h
split_text_node_command.cpp
split_text_node_command.h
split_text_node_containing_element.cpp
split_text_node_containing_element_command.h
visible_position.cpp visible_position.h
visible_text.cpp visible_text.h
wrap_contents_in_dummy_span_command.cpp
wrap_contents_in_dummy_span_command.h
kwq DOMHTML.mm WebCoreBridge.mm
Log:
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:]):
Revision Changes Path
1.76 +186 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- ChangeLog 3 Jan 2006 08:12:26 -0000 1.75
+++ ChangeLog 3 Jan 2006 09:19:02 -0000 1.76
@@ -1,3 +1,189 @@
+2006-01-03 Eric Seidel <eseidel at 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 at mac.com>
Reviewed by Darin.
1.107 +5 -5 WebCore/khtml/editing/SelectionController.cpp
Index: SelectionController.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/SelectionController.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- SelectionController.cpp 10 Dec 2005 02:59:30 -0000 1.106
+++ SelectionController.cpp 3 Jan 2006 09:19:02 -0000 1.107
@@ -601,10 +601,10 @@
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 @@
}
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;
}
1.48 +2 -1 WebCore/khtml/editing/SelectionController.h
Index: SelectionController.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/SelectionController.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- SelectionController.h 6 Dec 2005 04:29:24 -0000 1.47
+++ SelectionController.h 3 Jan 2006 09:19:02 -0000 1.48
@@ -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 @@
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;
1.5 +2 -14 WebCore/khtml/editing/append_node_command.cpp
Index: append_node_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/append_node_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- append_node_command.cpp 21 Nov 2005 01:20:01 -0000 1.4
+++ append_node_command.cpp 3 Jan 2006 09:19:03 -0000 1.5
@@ -39,19 +39,7 @@
: 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 @@
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 @@
ASSERT(state() == Applied);
int exceptionCode = 0;
- m_parentNode->removeChild(m_appendChild, exceptionCode);
+ m_parentNode->removeChild(m_appendChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
1.2 +5 -5 WebCore/khtml/editing/append_node_command.h
Index: append_node_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/append_node_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- append_node_command.h 12 May 2005 04:00:19 -0000 1.1
+++ append_node_command.h 3 Jan 2006 09:19:03 -0000 1.2
@@ -38,17 +38,17 @@
{
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
1.24 +11 -19 WebCore/khtml/editing/apply_style_command.cpp
Index: apply_style_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/apply_style_command.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- apply_style_command.cpp 31 Dec 2005 00:14:23 -0000 1.23
+++ apply_style_command.cpp 3 Jan 2006 09:19:03 -0000 1.24
@@ -90,7 +90,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
break;
node = next;
}
-
-
- if (textDecorationSpecialProperty) {
- style->deref();
- }
ASSERT(s.node()->inDocument());
ASSERT(e.node()->inDocument());
1.5 +2 -1 WebCore/khtml/editing/apply_style_command.h
Index: apply_style_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/apply_style_command.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apply_style_command.h 21 Dec 2005 22:51:10 -0000 1.4
+++ apply_style_command.h 3 Jan 2006 09:19:03 -0000 1.5
@@ -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 @@
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);
1.23 +3 -6 WebCore/khtml/editing/composite_edit_command.cpp
Index: composite_edit_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/composite_edit_command.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- composite_edit_command.cpp 22 Dec 2005 04:11:36 -0000 1.22
+++ composite_edit_command.cpp 3 Jan 2006 09:19:03 -0000 1.23
@@ -380,7 +380,7 @@
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 @@
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 @@
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 @@
ASSERT(start > 0 || (unsigned)end - start < textNode->length());
deleteTextFromNode(textNode, start, end - start);
}
- str->deref();
}
}
1.6 +0 -8 WebCore/khtml/editing/delete_from_text_node_command.cpp
Index: delete_from_text_node_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/delete_from_text_node_command.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- delete_from_text_node_command.cpp 21 Nov 2005 01:20:02 -0000 1.5
+++ delete_from_text_node_command.cpp 3 Jan 2006 09:19:03 -0000 1.6
@@ -42,14 +42,6 @@
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()
1.3 +3 -3 WebCore/khtml/editing/delete_from_text_node_command.h
Index: delete_from_text_node_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/delete_from_text_node_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- delete_from_text_node_command.h 16 Sep 2005 22:42:06 -0000 1.2
+++ delete_from_text_node_command.h 3 Jan 2006 09:19:03 -0000 1.3
@@ -40,17 +40,17 @@
{
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;
1.25 +27 -79 WebCore/khtml/editing/delete_selection_command.cpp
Index: delete_selection_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/delete_selection_command.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- delete_selection_command.cpp 22 Dec 2005 04:11:36 -0000 1.24
+++ delete_selection_command.cpp 3 Jan 2006 09:19:03 -0000 1.25
@@ -204,11 +204,8 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
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 @@
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;
- m_endingPosition = Position(m_endBlock, 0);
+ m_endingPosition = Position(m_endBlock.get(), 0);
if (m_endingPosition.node()->inDocument())
return;
@@ -635,25 +616,15 @@
// FIXME: Improve typing style.
// See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
- if (m_deleteIntoBlockquoteStyle) {
- // If we deleted into a blockquote, but are now no longer in a blockquote, use the alternate typing style
- if (!nearestMailBlockquote(m_endingPosition.node())) {
- CSSMutableStyleDeclarationImpl *oldStyle = m_typingStyle;
- m_typingStyle = m_deleteIntoBlockquoteStyle;
- m_deleteIntoBlockquoteStyle = 0;
- oldStyle->deref();
- } else {
- m_deleteIntoBlockquoteStyle->deref();
- m_deleteIntoBlockquoteStyle = 0;
- }
- }
-
- CSSComputedStyleDeclarationImpl endingStyle(m_endingPosition.node());
- endingStyle.diff(m_typingStyle);
- if (!m_typingStyle->length()) {
- m_typingStyle->deref();
+ // If we deleted into a blockquote, but are now no longer in a blockquote, use the alternate typing style
+ if (m_deleteIntoBlockquoteStyle && !nearestMailBlockquote(m_endingPosition.node()))
+ m_typingStyle = m_deleteIntoBlockquoteStyle;
+ m_deleteIntoBlockquoteStyle = 0;
+
+ RefPtr<CSSComputedStyleDeclarationImpl> endingStyle = new CSSComputedStyleDeclarationImpl(m_endingPosition.node());
+ endingStyle->diff(m_typingStyle.get());
+ if (!m_typingStyle->length())
m_typingStyle = 0;
- }
if (insertedPlaceholder && m_typingStyle) {
// Apply style to the placeholder. This makes sure that the single line in the
// paragraph has the right height, and that the paragraph takes on the style
@@ -662,15 +633,13 @@
// is not retained until the next typing action.
setEndingSelection(SelectionController(Position(insertedPlaceholder, 0), DOWNSTREAM));
- applyStyle(m_typingStyle, EditActionUnspecified);
-
- m_typingStyle->deref();
+ applyStyle(m_typingStyle.get(), EditActionUnspecified);
m_typingStyle = 0;
}
// Set m_typingStyle as the typing style.
// It's perfectly OK for m_typingStyle to be null.
- document()->part()->setTypingStyle(m_typingStyle);
- setTypingStyle(m_typingStyle);
+ document()->part()->setTypingStyle(m_typingStyle.get());
+ setTypingStyle(m_typingStyle.get());
}
void DeleteSelectionCommand::clearTransientState()
@@ -683,27 +652,6 @@
m_endingPosition.clear();
m_leadingWhitespace.clear();
m_trailingWhitespace.clear();
-
- if (m_startBlock) {
- m_startBlock->deref();
- m_startBlock = 0;
- }
- if (m_endBlock) {
- m_endBlock->deref();
- m_endBlock = 0;
- }
- if (m_startNode) {
- m_startNode->deref();
- m_startNode = 0;
- }
- if (m_typingStyle) {
- m_typingStyle->deref();
- m_typingStyle = 0;
- }
- if (m_deleteIntoBlockquoteStyle) {
- m_deleteIntoBlockquoteStyle->deref();
- m_deleteIntoBlockquoteStyle = 0;
- }
}
void DeleteSelectionCommand::doApply()
1.6 +5 -7 WebCore/khtml/editing/delete_selection_command.h
Index: delete_selection_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/delete_selection_command.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- delete_selection_command.h 24 Sep 2005 01:18:55 -0000 1.5
+++ delete_selection_command.h 3 Jan 2006 09:19:03 -0000 1.6
@@ -53,8 +53,6 @@
void calculateTypingStyleAfterDelete(DOM::NodeImpl *insertedPlaceholder);
void clearTransientState();
- void setStartNode(DOM::NodeImpl *);
-
bool m_hasSelectionToDelete;
bool m_smartDelete;
bool m_mergeBlocksAfterDelete;
@@ -69,11 +67,11 @@
DOM::Position m_endingPosition;
DOM::Position m_leadingWhitespace;
DOM::Position m_trailingWhitespace;
- DOM::NodeImpl *m_startBlock;
- DOM::NodeImpl *m_endBlock;
- DOM::NodeImpl *m_startNode;
- DOM::CSSMutableStyleDeclarationImpl *m_typingStyle;
- DOM::CSSMutableStyleDeclarationImpl *m_deleteIntoBlockquoteStyle;
+ RefPtr<DOM::NodeImpl> m_startBlock;
+ RefPtr<DOM::NodeImpl> m_endBlock;
+ RefPtr<DOM::NodeImpl> m_startNode;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_typingStyle;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_deleteIntoBlockquoteStyle;
};
} // namespace khtml
1.15 +3 -37 WebCore/khtml/editing/edit_command.cpp
Index: edit_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/edit_command.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- edit_command.cpp 22 Dec 2005 04:11:36 -0000 1.14
+++ edit_command.cpp 3 Jan 2006 09:19:04 -0000 1.15
@@ -59,20 +59,6 @@
{
}
-EditCommandPtr::EditCommandPtr(const EditCommandPtr &o) : RefPtr<EditCommand>(o)
-{
-}
-
-EditCommandPtr::~EditCommandPtr()
-{
-}
-
-EditCommandPtr &EditCommandPtr::operator=(const EditCommandPtr &c)
-{
- static_cast<RefPtr<EditCommand> &>(*this) = c;
- return *this;
-}
-
bool EditCommandPtr::isCompositeStep() const
{
IF_IMPL_NULL_RETURN_ARG(false);
@@ -202,21 +188,16 @@
}
EditCommand::EditCommand(DocumentImpl *document)
- : m_document(document), m_state(NotApplied), m_typingStyle(0), m_parent(0)
+ : m_document(document), m_state(NotApplied), m_parent(0)
{
ASSERT(m_document);
ASSERT(m_document->part());
- m_document->ref();
m_startingSelection = m_document->part()->selection();
m_endingSelection = m_startingSelection;
}
EditCommand::~EditCommand()
{
- ASSERT(m_document);
- m_document->deref();
- if (m_typingStyle)
- m_typingStyle->deref();
}
void EditCommand::apply()
@@ -335,25 +316,12 @@
cmd->m_endingSelection = s;
}
-void EditCommand::assignTypingStyle(CSSMutableStyleDeclarationImpl *style)
-{
- if (m_typingStyle == style)
- return;
-
- CSSMutableStyleDeclarationImpl *old = m_typingStyle;
- m_typingStyle = style;
- if (m_typingStyle)
- m_typingStyle->ref();
- if (old)
- old->deref();
-}
-
void EditCommand::setTypingStyle(CSSMutableStyleDeclarationImpl *style)
{
// FIXME: Improve typing style.
// See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
- cmd->assignTypingStyle(style);
+ cmd->m_typingStyle = style;
}
bool EditCommand::preservesTypingStyle() const
@@ -373,10 +341,8 @@
CSSMutableStyleDeclarationImpl *EditCommand::styleAtPosition(const Position &pos)
{
- CSSComputedStyleDeclarationImpl *computedStyle = positionBeforeTabSpan(pos).computedStyle();
- computedStyle->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> computedStyle = positionBeforeTabSpan(pos).computedStyle();
CSSMutableStyleDeclarationImpl *style = computedStyle->copyInheritableProperties();
- computedStyle->deref();
// FIXME: Improve typing style.
// See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
1.6 +4 -10 WebCore/khtml/editing/edit_command.h
Index: edit_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/edit_command.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- edit_command.h 22 Dec 2005 04:11:36 -0000 1.5
+++ edit_command.h 3 Jan 2006 09:19:04 -0000 1.6
@@ -62,7 +62,7 @@
virtual EditAction editingAction() const;
- virtual DOM::DocumentImpl * const document() const { return m_document; }
+ virtual DOM::DocumentImpl * const document() const { return m_document.get(); }
SelectionController startingSelection() const { return m_startingSelection; }
SelectionController endingSelection() const { return m_endingSelection; }
@@ -79,7 +79,7 @@
void setEndingSelection(const VisiblePosition &p);
void setEndingSelection(const DOM::Position &p, EAffinity affinity);
- DOM::CSSMutableStyleDeclarationImpl *typingStyle() const { return m_typingStyle; };
+ DOM::CSSMutableStyleDeclarationImpl *typingStyle() const { return m_typingStyle.get(); };
void setTypingStyle(DOM::CSSMutableStyleDeclarationImpl *);
DOM::CSSMutableStyleDeclarationImpl *styleAtPosition(const DOM::Position &pos);
@@ -90,15 +90,13 @@
void updateLayout() const;
private:
- void assignTypingStyle(DOM::CSSMutableStyleDeclarationImpl *);
-
virtual bool preservesTypingStyle() const;
- DOM::DocumentImpl *m_document;
+ RefPtr<DOM::DocumentImpl> m_document;
ECommandState m_state;
SelectionController m_startingSelection;
SelectionController m_endingSelection;
- DOM::CSSMutableStyleDeclarationImpl *m_typingStyle;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_typingStyle;
EditCommand *m_parent;
};
@@ -107,10 +105,6 @@
public:
EditCommandPtr();
EditCommandPtr(EditCommand *);
- EditCommandPtr(const EditCommandPtr &);
- ~EditCommandPtr();
-
- EditCommandPtr &operator=(const EditCommandPtr &);
bool isCompositeStep() const;
1.6 +0 -7 WebCore/khtml/editing/insert_into_text_node_command.cpp
Index: insert_into_text_node_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_into_text_node_command.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- insert_into_text_node_command.cpp 21 Nov 2005 01:20:03 -0000 1.5
+++ insert_into_text_node_command.cpp 3 Jan 2006 09:19:04 -0000 1.6
@@ -43,16 +43,9 @@
ASSERT(m_offset >= 0);
ASSERT(!text.isEmpty());
- m_node->ref();
m_text = text.copy(); // make a copy to ensure that the string never changes
}
-InsertIntoTextNodeCommand::~InsertIntoTextNodeCommand()
-{
- if (m_node)
- m_node->deref();
-}
-
void InsertIntoTextNodeCommand::doApply()
{
ASSERT(m_node);
1.3 +3 -3 WebCore/khtml/editing/insert_into_text_node_command.h
Index: insert_into_text_node_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_into_text_node_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- insert_into_text_node_command.h 16 Sep 2005 22:42:06 -0000 1.2
+++ insert_into_text_node_command.h 3 Jan 2006 09:19:04 -0000 1.3
@@ -41,17 +41,17 @@
{
public:
InsertIntoTextNodeCommand(DOM::DocumentImpl *document, DOM::TextImpl *, int, const DOM::DOMString &);
- virtual ~InsertIntoTextNodeCommand();
+ virtual ~InsertIntoTextNodeCommand() { }
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; }
DOM::DOMString text() const { return m_text; }
private:
- DOM::TextImpl *m_node;
+ RefPtr<DOM::TextImpl> m_node;
int m_offset;
DOM::DOMString m_text;
};
1.5 +2 -14 WebCore/khtml/editing/insert_node_before_command.cpp
Index: insert_node_before_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_node_before_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- insert_node_before_command.cpp 21 Nov 2005 01:20:03 -0000 1.4
+++ insert_node_before_command.cpp 3 Jan 2006 09:19:04 -0000 1.5
@@ -39,19 +39,7 @@
: EditCommand(document), m_insertChild(insertChild), m_refChild(refChild)
{
ASSERT(m_insertChild);
- m_insertChild->ref();
-
- ASSERT(m_refChild);
- m_refChild->ref();
-}
-
-InsertNodeBeforeCommand::~InsertNodeBeforeCommand()
-{
- ASSERT(m_insertChild);
- m_insertChild->deref();
-
ASSERT(m_refChild);
- m_refChild->deref();
}
void InsertNodeBeforeCommand::doApply()
@@ -61,7 +49,7 @@
ASSERT(m_refChild->parentNode());
int exceptionCode = 0;
- m_refChild->parentNode()->insertBefore(m_insertChild, m_refChild, exceptionCode);
+ m_refChild->parentNode()->insertBefore(m_insertChild.get(), m_refChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
@@ -72,7 +60,7 @@
ASSERT(m_refChild->parentNode());
int exceptionCode = 0;
- m_refChild->parentNode()->removeChild(m_insertChild, exceptionCode);
+ m_refChild->parentNode()->removeChild(m_insertChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
1.2 +5 -5 WebCore/khtml/editing/insert_node_before_command.h
Index: insert_node_before_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_node_before_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- insert_node_before_command.h 13 May 2005 08:37:15 -0000 1.1
+++ insert_node_before_command.h 3 Jan 2006 09:19:04 -0000 1.2
@@ -34,17 +34,17 @@
{
public:
InsertNodeBeforeCommand(DOM::DocumentImpl *, DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
- virtual ~InsertNodeBeforeCommand();
+ virtual ~InsertNodeBeforeCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::NodeImpl *insertChild() const { return m_insertChild; }
- DOM::NodeImpl *refChild() const { return m_refChild; }
+ DOM::NodeImpl *insertChild() const { return m_insertChild.get(); }
+ DOM::NodeImpl *refChild() const { return m_refChild.get(); }
private:
- DOM::NodeImpl *m_insertChild;
- DOM::NodeImpl *m_refChild;
+ RefPtr<DOM::NodeImpl> m_insertChild;
+ RefPtr<DOM::NodeImpl> m_refChild;
};
} // namespace khtml
1.12 +4 -10 WebCore/khtml/editing/insert_paragraph_separator_command.cpp
Index: insert_paragraph_separator_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_paragraph_separator_command.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- insert_paragraph_separator_command.cpp 22 Dec 2005 04:11:36 -0000 1.11
+++ insert_paragraph_separator_command.cpp 3 Jan 2006 09:19:04 -0000 1.12
@@ -52,15 +52,13 @@
namespace khtml {
InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(DocumentImpl *document)
- : CompositeEditCommand(document), m_style(0)
+ : CompositeEditCommand(document)
{
}
InsertParagraphSeparatorCommand::~InsertParagraphSeparatorCommand()
{
derefNodesInList(clonedNodes);
- if (m_style)
- m_style->deref();
}
bool InsertParagraphSeparatorCommand::preservesTypingStyle() const
@@ -85,10 +83,7 @@
if (!isStartOfParagraph(visiblePos) && !isEndOfParagraph(visiblePos))
return;
- if (m_style)
- m_style->deref();
m_style = styleAtPosition(pos);
- m_style->ref();
}
void InsertParagraphSeparatorCommand::applyStyleAfterInsertion()
@@ -99,10 +94,9 @@
return;
CSSComputedStyleDeclarationImpl endingStyle(endingSelection().start().node());
- endingStyle.diff(m_style);
- if (m_style->length() > 0) {
- applyStyle(m_style);
- }
+ endingStyle.diff(m_style.get());
+ if (m_style->length() > 0)
+ applyStyle(m_style.get());
}
void InsertParagraphSeparatorCommand::doApply()
1.2 +1 -1 WebCore/khtml/editing/insert_paragraph_separator_command.h
Index: insert_paragraph_separator_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_paragraph_separator_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- insert_paragraph_separator_command.h 24 May 2005 07:21:47 -0000 1.1
+++ insert_paragraph_separator_command.h 3 Jan 2006 09:19:04 -0000 1.2
@@ -48,7 +48,7 @@
QPtrList<DOM::NodeImpl> ancestors;
QPtrList<DOM::NodeImpl> clonedNodes;
- DOM::CSSMutableStyleDeclarationImpl *m_style;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_style;
};
} // namespace khtml
1.5 +2 -13 WebCore/khtml/editing/join_text_nodes_command.cpp
Index: join_text_nodes_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/join_text_nodes_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- join_text_nodes_command.cpp 21 Nov 2005 01:20:03 -0000 1.4
+++ join_text_nodes_command.cpp 3 Jan 2006 09:19:04 -0000 1.5
@@ -44,17 +44,6 @@
ASSERT(m_text1->nextSibling() == m_text2);
ASSERT(m_text1->length() > 0);
ASSERT(m_text2->length() > 0);
-
- m_text1->ref();
- m_text2->ref();
-}
-
-JoinTextNodesCommand::~JoinTextNodesCommand()
-{
- ASSERT(m_text1);
- m_text1->deref();
- ASSERT(m_text2);
- m_text2->deref();
}
void JoinTextNodesCommand::doApply()
@@ -67,7 +56,7 @@
m_text2->insertData(0, m_text1->data(), exceptionCode);
ASSERT(exceptionCode == 0);
- m_text2->parentNode()->removeChild(m_text1, exceptionCode);
+ m_text2->parentNode()->removeChild(m_text1.get(), exceptionCode);
ASSERT(exceptionCode == 0);
m_offset = m_text1->length();
@@ -83,7 +72,7 @@
m_text2->deleteData(0, m_offset, exceptionCode);
ASSERT(exceptionCode == 0);
- m_text2->parentNode()->insertBefore(m_text1, m_text2, exceptionCode);
+ m_text2->parentNode()->insertBefore(m_text1.get(), m_text2.get(), exceptionCode);
ASSERT(exceptionCode == 0);
ASSERT(m_text2->previousSibling()->isTextNode());
1.3 +5 -5 WebCore/khtml/editing/join_text_nodes_command.h
Index: join_text_nodes_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/join_text_nodes_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- join_text_nodes_command.h 16 Sep 2005 22:42:07 -0000 1.2
+++ join_text_nodes_command.h 3 Jan 2006 09:19:04 -0000 1.3
@@ -38,17 +38,17 @@
{
public:
JoinTextNodesCommand(DOM::DocumentImpl *, DOM::TextImpl *, DOM::TextImpl *);
- virtual ~JoinTextNodesCommand();
+ virtual ~JoinTextNodesCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::TextImpl *firstNode() const { return m_text1; }
- DOM::TextImpl *secondNode() const { return m_text2; }
+ DOM::TextImpl *firstNode() const { return m_text1.get(); }
+ DOM::TextImpl *secondNode() const { return m_text2.get(); }
private:
- DOM::TextImpl *m_text1;
- DOM::TextImpl *m_text2;
+ RefPtr<DOM::TextImpl> m_text1;
+ RefPtr<DOM::TextImpl> m_text2;
unsigned m_offset;
};
1.38 +6 -14 WebCore/khtml/editing/jsediting.cpp
Index: jsediting.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/jsediting.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- jsediting.cpp 23 Dec 2005 18:44:14 -0000 1.37
+++ jsediting.cpp 3 Jan 2006 09:19:04 -0000 1.38
@@ -145,11 +145,9 @@
bool execStyleChange(KHTMLPart *part, int propertyID, const DOMString &propertyValue)
{
- CSSMutableStyleDeclarationImpl *style = new CSSMutableStyleDeclarationImpl;
+ RefPtr<CSSMutableStyleDeclarationImpl> style = new CSSMutableStyleDeclarationImpl;
style->setProperty(propertyID, propertyValue);
- style->ref();
- part->applyStyle(style);
- style->deref();
+ part->applyStyle(style.get());
return true;
}
@@ -160,22 +158,16 @@
KHTMLPart::TriState stateStyle(KHTMLPart *part, int propertyID, const char *desiredValue)
{
- CSSMutableStyleDeclarationImpl *style = new CSSMutableStyleDeclarationImpl;
+ RefPtr<CSSMutableStyleDeclarationImpl> style = new CSSMutableStyleDeclarationImpl;
style->setProperty(propertyID, desiredValue);
- style->ref();
- KHTMLPart::TriState state = part->selectionHasStyle(style);
- style->deref();
- return state;
+ return part->selectionHasStyle(style.get());
}
bool selectionStartHasStyle(KHTMLPart *part, int propertyID, const char *desiredValue)
{
- CSSMutableStyleDeclarationImpl *style = new CSSMutableStyleDeclarationImpl;
+ RefPtr<CSSMutableStyleDeclarationImpl> style = new CSSMutableStyleDeclarationImpl;
style->setProperty(propertyID, desiredValue);
- style->ref();
- bool hasStyle = part->selectionStartHasStyle(style);
- style->deref();
- return hasStyle;
+ return part->selectionStartHasStyle(style.get());
}
DOMString valueStyle(KHTMLPart *part, int propertyID)
1.46 +19 -46 WebCore/khtml/editing/markup.cpp
Index: markup.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/markup.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- markup.cpp 30 Dec 2005 14:51:31 -0000 1.45
+++ markup.cpp 3 Jan 2006 09:19:04 -0000 1.46
@@ -353,20 +353,15 @@
// calculate the "default style" for this markup
Position pos(doc->documentElement(), 0);
- CSSComputedStyleDeclarationImpl *computedStyle = pos.computedStyle();
- computedStyle->ref();
- CSSMutableStyleDeclarationImpl *defaultStyle = computedStyle->copyInheritableProperties();
- computedStyle->deref();
- defaultStyle->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> computedStyle = pos.computedStyle();
+ RefPtr<CSSMutableStyleDeclarationImpl> defaultStyle = computedStyle->copyInheritableProperties();
NodeImpl *startNode = range->startNode();
VisiblePosition visibleStart(range->startPosition(), VP_DEFAULT_AFFINITY);
VisiblePosition visibleEnd(range->endPosition(), VP_DEFAULT_AFFINITY);
if (!inSameBlock(visibleStart, visibleStart.next())) {
- if (visibleStart == visibleEnd.previous()) {
- defaultStyle->deref();
+ if (visibleStart == visibleEnd.previous())
return interchangeNewlineString;
- }
markups.append(interchangeNewlineString);
startNode = startNode->traverseNextNode();
}
@@ -383,7 +378,7 @@
// Add the node to the markup.
if (n->renderer()) {
- markups.append(startMarkup(n, range, annotate, defaultStyle));
+ markups.append(startMarkup(n, range, annotate, defaultStyle.get()));
if (nodes) {
nodes->append(n);
}
@@ -415,7 +410,7 @@
NodeImpl *nextParent = next->parentNode();
if (n != nextParent) {
for (NodeImpl *parent = n->parent(); parent != 0 && parent != nextParent; parent = parent->parentNode()) {
- markups.prepend(startMarkup(parent, range, annotate, defaultStyle));
+ markups.prepend(startMarkup(parent, range, annotate, defaultStyle.get()));
markups.append(endMarkup(parent));
if (nodes) {
nodes->append(parent);
@@ -453,7 +448,7 @@
break;
}
}
- markups.prepend(startMarkup(ancestor, range, annotate, defaultStyle));
+ markups.prepend(startMarkup(ancestor, range, annotate, defaultStyle.get()));
markups.append(endMarkup(ancestor));
if (nodes) {
nodes->append(ancestor);
@@ -472,7 +467,7 @@
// Retain the Mail quote level by including all ancestor mail block quotes.
for (NodeImpl *ancestor = commonAncestorBlock; ancestor; ancestor = ancestor->parentNode()) {
if (isMailBlockquote(ancestor)) {
- markups.prepend(startMarkup(ancestor, range, annotate, defaultStyle));
+ markups.prepend(startMarkup(ancestor, range, annotate, defaultStyle.get()));
markups.append(endMarkup(ancestor));
}
}
@@ -482,22 +477,21 @@
QString openTag = QString("<span class=\"") + AppleStyleSpanClass + "\" style=\"" + defaultStyle->cssText().qstring() + "\">";
markups.prepend(openTag);
markups.append("</span>");
- defaultStyle->deref();
return markups.join("");
}
-DocumentFragmentImpl *createFragmentFromMarkup(DocumentImpl *document, const QString &markup, const QString &baseURL)
+PassRefPtr<DocumentFragmentImpl> createFragmentFromMarkup(DocumentImpl *document, const QString &markup, const QString &baseURL)
{
ASSERT(document->documentElement()->isHTMLElement());
// FIXME: What if the document element is not an HTML element?
HTMLElementImpl *element = static_cast<HTMLElementImpl *>(document->documentElement());
- DocumentFragmentImpl *fragment = element->createContextualFragment(markup);
+ PassRefPtr<DocumentFragmentImpl> fragment = element->createContextualFragment(markup);
ASSERT(fragment);
if (!baseURL.isEmpty() && baseURL != document->baseURL())
- completeURLs(fragment, baseURL);
+ completeURLs(fragment.get(), baseURL);
return fragment;
}
@@ -552,13 +546,12 @@
}
}
-DOM::DocumentFragmentImpl *createFragmentFromText(DOM::DocumentImpl *document, const QString &text)
+PassRefPtr<DocumentFragmentImpl> createFragmentFromText(DocumentImpl *document, const QString &text)
{
if (!document)
return 0;
- DocumentFragmentImpl *fragment = document->createDocumentFragment();
- fragment->ref();
+ PassRefPtr<DocumentFragmentImpl> fragment = document->createDocumentFragment();
if (!text.isEmpty()) {
QString string = text;
@@ -572,59 +565,39 @@
list.pop_front();
int exceptionCode = 0;
- ElementImpl *element;
+ RefPtr<ElementImpl> element;
if (s.isEmpty() && list.isEmpty()) {
// For last line, use the "magic BR" rather than a P.
element = document->createElementNS(xhtmlNamespaceURI, "br", exceptionCode);
ASSERT(exceptionCode == 0);
- element->ref();
element->setAttribute(classAttr, AppleInterchangeNewline);
} else {
element = createDefaultParagraphElement(document);
- element->ref();
- createParagraphContentsFromString(document, element, s);
+ createParagraphContentsFromString(document, element.get(), s);
}
- fragment->appendChild(element, exceptionCode);
+ fragment->appendChild(element.get(), exceptionCode);
ASSERT(exceptionCode == 0);
- element->deref();
}
}
-
- // Trick to get the fragment back to the floating state, with 0
- // refs but not destroyed.
- fragment->setParent(document);
- fragment->deref();
- fragment->setParent(0);
-
return fragment;
}
-DOM::DocumentFragmentImpl *createFragmentFromNodeList(DOM::DocumentImpl *document, const QPtrList<DOM::NodeImpl> &nodeList)
+PassRefPtr<DocumentFragmentImpl> createFragmentFromNodeList(DocumentImpl *document, const QPtrList<NodeImpl> &nodeList)
{
if (!document)
return 0;
- DocumentFragmentImpl *fragment = document->createDocumentFragment();
- fragment->ref();
+ PassRefPtr<DocumentFragmentImpl> fragment = document->createDocumentFragment();
- ElementImpl *element;
+ RefPtr<ElementImpl> element;
int exceptionCode = 0;
for (QPtrListIterator<NodeImpl> i(nodeList); i.current(); ++i) {
element = createDefaultParagraphElement(document);
- element->ref();
element->appendChild(i.current(), exceptionCode);
ASSERT(exceptionCode == 0);
- fragment->appendChild(element, exceptionCode);
+ fragment->appendChild(element.get(), exceptionCode);
ASSERT(exceptionCode == 0);
- element->deref();
}
-
- // Trick to get the fragment back to the floating state, with 0
- // refs but not destroyed.
- fragment->setParent(document);
- fragment->deref();
- fragment->setParent(0);
-
return fragment;
}
1.3 +4 -3 WebCore/khtml/editing/markup.h
Index: markup.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/markup.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- markup.h 30 Nov 2005 02:06:33 -0000 1.2
+++ markup.h 3 Jan 2006 09:19:05 -0000 1.3
@@ -28,14 +28,15 @@
#include <xml/dom_docimpl.h>
#include "html_interchange.h"
+#include <kxmlcore/PassRefPtr.h>
namespace khtml {
enum EChildrenOnly { IncludeNode, ChildrenOnly };
-DOM::DocumentFragmentImpl *createFragmentFromText(DOM::DocumentImpl *document, const QString &text);
-DOM::DocumentFragmentImpl *createFragmentFromMarkup(DOM::DocumentImpl *document, const QString &markup, const QString &baseURL);
-DOM::DocumentFragmentImpl *createFragmentFromNodeList(DOM::DocumentImpl *document, const QPtrList<DOM::NodeImpl> &nodeList);
+PassRefPtr<DOM::DocumentFragmentImpl> createFragmentFromText(DOM::DocumentImpl *document, const QString &text);
+PassRefPtr<DOM::DocumentFragmentImpl> createFragmentFromMarkup(DOM::DocumentImpl *document, const QString &markup, const QString &baseURL);
+PassRefPtr<DOM::DocumentFragmentImpl> createFragmentFromNodeList(DOM::DocumentImpl *document, const QPtrList<DOM::NodeImpl> &nodeList);
QString createMarkup(const DOM::RangeImpl *range,
QPtrList<DOM::NodeImpl> *nodes = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange);
1.5 +4 -20 WebCore/khtml/editing/merge_identical_elements_command.cpp
Index: merge_identical_elements_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/merge_identical_elements_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- merge_identical_elements_command.cpp 21 Nov 2005 01:20:04 -0000 1.4
+++ merge_identical_elements_command.cpp 3 Jan 2006 09:19:05 -0000 1.5
@@ -37,24 +37,10 @@
namespace khtml {
MergeIdenticalElementsCommand::MergeIdenticalElementsCommand(DOM::DocumentImpl *document, DOM::ElementImpl *first, DOM::ElementImpl *second)
- : EditCommand(document), m_element1(first), m_element2(second), m_atChild(0)
+ : EditCommand(document), m_element1(first), m_element2(second)
{
ASSERT(m_element1);
ASSERT(m_element2);
-
- m_element1->ref();
- m_element2->ref();
-}
-
-MergeIdenticalElementsCommand::~MergeIdenticalElementsCommand()
-{
- if (m_atChild)
- m_atChild->deref();
-
- ASSERT(m_element1);
- m_element1->deref();
- ASSERT(m_element2);
- m_element2->deref();
}
void MergeIdenticalElementsCommand::doApply()
@@ -65,17 +51,15 @@
int exceptionCode = 0;
- if (!m_atChild) {
+ if (!m_atChild)
m_atChild = m_element2->firstChild();
- m_atChild->ref();
- }
while (m_element1->lastChild()) {
m_element2->insertBefore(m_element1->lastChild(), m_element2->firstChild(), exceptionCode);
ASSERT(exceptionCode == 0);
}
- m_element2->parentNode()->removeChild(m_element1, exceptionCode);
+ m_element2->parentNode()->removeChild(m_element1.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
@@ -86,7 +70,7 @@
int exceptionCode = 0;
- m_element2->parent()->insertBefore(m_element1, m_element2, exceptionCode);
+ m_element2->parent()->insertBefore(m_element1.get(), m_element2.get(), exceptionCode);
ASSERT(exceptionCode == 0);
while (m_element2->firstChild() != m_atChild) {
1.2 +4 -4 WebCore/khtml/editing/merge_identical_elements_command.h
Index: merge_identical_elements_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/merge_identical_elements_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- merge_identical_elements_command.h 24 May 2005 07:21:47 -0000 1.1
+++ merge_identical_elements_command.h 3 Jan 2006 09:19:05 -0000 1.2
@@ -34,15 +34,15 @@
{
public:
MergeIdenticalElementsCommand(DOM::DocumentImpl *, DOM::ElementImpl *first, DOM::ElementImpl *second);
- virtual ~MergeIdenticalElementsCommand();
+ virtual ~MergeIdenticalElementsCommand() { }
virtual void doApply();
virtual void doUnapply();
private:
- DOM::ElementImpl *m_element1;
- DOM::ElementImpl *m_element2;
- DOM::NodeImpl *m_atChild;
+ RefPtr<DOM::ElementImpl> m_element1;
+ RefPtr<DOM::ElementImpl> m_element2;
+ RefPtr<DOM::NodeImpl> m_atChild;
};
} // namespace khtml
1.7 +1 -4 WebCore/khtml/editing/move_selection_command.cpp
Index: move_selection_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/move_selection_command.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- move_selection_command.cpp 21 Nov 2005 01:20:04 -0000 1.6
+++ move_selection_command.cpp 3 Jan 2006 09:19:05 -0000 1.7
@@ -42,13 +42,10 @@
: CompositeEditCommand(document), m_fragment(fragment), m_position(position), m_smartMove(smartMove)
{
ASSERT(m_fragment);
- m_fragment->ref();
}
MoveSelectionCommand::~MoveSelectionCommand()
{
- ASSERT(m_fragment);
- m_fragment->deref();
}
void MoveSelectionCommand::doApply()
@@ -84,7 +81,7 @@
pos = endingSelection().start();
setEndingSelection(pos, endingSelection().startAffinity());
- EditCommandPtr cmd(new ReplaceSelectionCommand(document(), m_fragment, true, m_smartMove));
+ EditCommandPtr cmd(new ReplaceSelectionCommand(document(), m_fragment.get(), true, m_smartMove));
applyCommandToComposite(cmd);
}
1.2 +1 -1 WebCore/khtml/editing/move_selection_command.h
Index: move_selection_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/move_selection_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- move_selection_command.h 24 May 2005 07:21:47 -0000 1.1
+++ move_selection_command.h 3 Jan 2006 09:19:05 -0000 1.2
@@ -44,7 +44,7 @@
virtual EditAction editingAction() const;
private:
- DOM::DocumentFragmentImpl *m_fragment;
+ RefPtr<DOM::DocumentFragmentImpl> m_fragment;
DOM::Position m_position;
bool m_smartMove;
};
1.7 +0 -4 WebCore/khtml/editing/rebalance_whitespace_command.cpp
Index: rebalance_whitespace_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/rebalance_whitespace_command.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- rebalance_whitespace_command.cpp 21 Nov 2005 01:20:04 -0000 1.6
+++ rebalance_whitespace_command.cpp 3 Jan 2006 09:19:05 -0000 1.7
@@ -45,10 +45,6 @@
{
}
-RebalanceWhitespaceCommand::~RebalanceWhitespaceCommand()
-{
-}
-
static inline bool isWhitespace(const QChar &c)
{
return c.unicode() == 0xa0 || isCollapsibleWhitespace(c);
1.3 +1 -1 WebCore/khtml/editing/rebalance_whitespace_command.h
Index: rebalance_whitespace_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/rebalance_whitespace_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- rebalance_whitespace_command.h 16 Sep 2005 22:42:07 -0000 1.2
+++ rebalance_whitespace_command.h 3 Jan 2006 09:19:05 -0000 1.3
@@ -35,7 +35,7 @@
{
public:
RebalanceWhitespaceCommand(DOM::DocumentImpl *, const DOM::Position &);
- virtual ~RebalanceWhitespaceCommand();
+ virtual ~RebalanceWhitespaceCommand() { }
virtual void doApply();
virtual void doUnapply();
1.5 +0 -7 WebCore/khtml/editing/remove_css_property_command.cpp
Index: remove_css_property_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_css_property_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- remove_css_property_command.cpp 21 Nov 2005 01:20:04 -0000 1.4
+++ remove_css_property_command.cpp 3 Jan 2006 09:19:05 -0000 1.5
@@ -40,13 +40,6 @@
: EditCommand(document), m_decl(decl->makeMutable()), m_property(property), m_important(false)
{
ASSERT(m_decl);
- m_decl->ref();
-}
-
-RemoveCSSPropertyCommand::~RemoveCSSPropertyCommand()
-{
- ASSERT(m_decl);
- m_decl->deref();
}
void RemoveCSSPropertyCommand::doApply()
1.2 +3 -3 WebCore/khtml/editing/remove_css_property_command.h
Index: remove_css_property_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_css_property_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- remove_css_property_command.h 24 May 2005 07:21:47 -0000 1.1
+++ remove_css_property_command.h 3 Jan 2006 09:19:05 -0000 1.2
@@ -40,16 +40,16 @@
{
public:
RemoveCSSPropertyCommand(DOM::DocumentImpl *, DOM::CSSStyleDeclarationImpl *, int property);
- virtual ~RemoveCSSPropertyCommand();
+ virtual ~RemoveCSSPropertyCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::CSSMutableStyleDeclarationImpl *styleDeclaration() const { return m_decl; }
+ DOM::CSSMutableStyleDeclarationImpl *styleDeclaration() const { return m_decl.get(); }
int property() const { return m_property; }
private:
- DOM::CSSMutableStyleDeclarationImpl *m_decl;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_decl;
int m_property;
DOM::DOMString m_oldValue;
bool m_important;
1.7 +0 -7 WebCore/khtml/editing/remove_node_attribute_command.cpp
Index: remove_node_attribute_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_node_attribute_command.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- remove_node_attribute_command.cpp 21 Nov 2005 01:20:04 -0000 1.6
+++ remove_node_attribute_command.cpp 3 Jan 2006 09:19:06 -0000 1.7
@@ -41,13 +41,6 @@
: EditCommand(document), m_element(element), m_attribute(attribute)
{
ASSERT(m_element);
- m_element->ref();
-}
-
-RemoveNodeAttributeCommand::~RemoveNodeAttributeCommand()
-{
- ASSERT(m_element);
- m_element->deref();
}
void RemoveNodeAttributeCommand::doApply()
1.3 +3 -3 WebCore/khtml/editing/remove_node_attribute_command.h
Index: remove_node_attribute_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_node_attribute_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- remove_node_attribute_command.h 18 Jul 2005 21:44:18 -0000 1.2
+++ remove_node_attribute_command.h 3 Jan 2006 09:19:06 -0000 1.3
@@ -37,16 +37,16 @@
{
public:
RemoveNodeAttributeCommand(DOM::DocumentImpl *, DOM::ElementImpl *, const DOM::QualifiedName& attribute);
- virtual ~RemoveNodeAttributeCommand();
+ virtual ~RemoveNodeAttributeCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::ElementImpl *element() const { return m_element; }
+ DOM::ElementImpl *element() const { return m_element.get(); }
const DOM::QualifiedName& attribute() const { return m_attribute; }
private:
- DOM::ElementImpl *m_element;
+ RefPtr<DOM::ElementImpl> m_element;
DOM::QualifiedName m_attribute;
DOM::DOMString m_oldValue;
};
1.5 +3 -24 WebCore/khtml/editing/remove_node_command.cpp
Index: remove_node_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_node_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- remove_node_command.cpp 21 Nov 2005 01:20:05 -0000 1.4
+++ remove_node_command.cpp 3 Jan 2006 09:19:06 -0000 1.5
@@ -36,30 +36,9 @@
namespace khtml {
RemoveNodeCommand::RemoveNodeCommand(DocumentImpl *document, NodeImpl *removeChild)
- : EditCommand(document), m_parent(0), m_removeChild(removeChild), m_refChild(0)
+ : EditCommand(document), m_removeChild(removeChild), m_parent(m_removeChild->parentNode()), m_refChild(m_removeChild->nextSibling())
{
- ASSERT(m_removeChild);
- m_removeChild->ref();
-
- m_parent = m_removeChild->parentNode();
ASSERT(m_parent);
- m_parent->ref();
-
- m_refChild = m_removeChild->nextSibling();
- if (m_refChild)
- m_refChild->ref();
-}
-
-RemoveNodeCommand::~RemoveNodeCommand()
-{
- ASSERT(m_parent);
- m_parent->deref();
-
- ASSERT(m_removeChild);
- m_removeChild->deref();
-
- if (m_refChild)
- m_refChild->deref();
}
void RemoveNodeCommand::doApply()
@@ -68,7 +47,7 @@
ASSERT(m_removeChild);
int exceptionCode = 0;
- m_parent->removeChild(m_removeChild, exceptionCode);
+ m_parent->removeChild(m_removeChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
@@ -78,7 +57,7 @@
ASSERT(m_removeChild);
int exceptionCode = 0;
- m_parent->insertBefore(m_removeChild, m_refChild, exceptionCode);
+ m_parent->insertBefore(m_removeChild.get(), m_refChild.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
1.2 +5 -5 WebCore/khtml/editing/remove_node_command.h
Index: remove_node_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_node_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- remove_node_command.h 24 May 2005 07:21:47 -0000 1.1
+++ remove_node_command.h 3 Jan 2006 09:19:06 -0000 1.2
@@ -34,17 +34,17 @@
{
public:
RemoveNodeCommand(DOM::DocumentImpl *, DOM::NodeImpl *);
- virtual ~RemoveNodeCommand();
+ virtual ~RemoveNodeCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::NodeImpl *node() const { return m_removeChild; }
+ DOM::NodeImpl *node() const { return m_removeChild.get(); }
private:
- DOM::NodeImpl *m_parent;
- DOM::NodeImpl *m_removeChild;
- DOM::NodeImpl *m_refChild;
+ RefPtr<DOM::NodeImpl> m_removeChild;
+ RefPtr<DOM::NodeImpl> m_parent;
+ RefPtr<DOM::NodeImpl> m_refChild;
};
} // namespace khtml
1.5 +0 -7 WebCore/khtml/editing/remove_node_preserving_children_command.cpp
Index: remove_node_preserving_children_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_node_preserving_children_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- remove_node_preserving_children_command.cpp 21 Nov 2005 01:20:05 -0000 1.4
+++ remove_node_preserving_children_command.cpp 3 Jan 2006 09:19:06 -0000 1.5
@@ -39,13 +39,6 @@
: CompositeEditCommand(document), m_node(node)
{
ASSERT(m_node);
- m_node->ref();
-}
-
-RemoveNodePreservingChildrenCommand::~RemoveNodePreservingChildrenCommand()
-{
- ASSERT(m_node);
- m_node->deref();
}
void RemoveNodePreservingChildrenCommand::doApply()
1.2 +3 -3 WebCore/khtml/editing/remove_node_preserving_children_command.h
Index: remove_node_preserving_children_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/remove_node_preserving_children_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- remove_node_preserving_children_command.h 24 May 2005 07:21:47 -0000 1.1
+++ remove_node_preserving_children_command.h 3 Jan 2006 09:19:06 -0000 1.2
@@ -34,14 +34,14 @@
{
public:
RemoveNodePreservingChildrenCommand(DOM::DocumentImpl *, DOM::NodeImpl *);
- virtual ~RemoveNodePreservingChildrenCommand();
+ virtual ~RemoveNodePreservingChildrenCommand() { }
virtual void doApply();
- DOM::NodeImpl *node() const { return m_node; }
+ DOM::NodeImpl *node() const { return m_node.get(); }
private:
- DOM::NodeImpl *m_node;
+ RefPtr<DOM::NodeImpl> m_node;
};
} // namespace khtml
1.23 +50 -154 WebCore/khtml/editing/replace_selection_command.cpp
Index: replace_selection_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/replace_selection_command.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- replace_selection_command.cpp 22 Dec 2005 04:11:37 -0000 1.22
+++ replace_selection_command.cpp 3 Jan 2006 09:19:06 -0000 1.23
@@ -74,10 +74,7 @@
m_type = EmptyFragment;
return;
}
-
- m_document->ref();
- m_fragment->ref();
-
+
NodeImpl *firstChild = m_fragment->firstChild();
NodeImpl *lastChild = m_fragment->lastChild();
@@ -109,12 +106,10 @@
}
}
else if (isInterchangeConvertedSpaceSpan(node)) {
- NodeImpl *n = 0;
+ RefPtr<NodeImpl> n = 0;
while ((n = node->firstChild())) {
- n->ref();
removeNode(n);
- insertNodeBefore(n, node);
- n->deref();
+ insertNodeBefore(n.get(), node);
}
removeNode(node);
if (n)
@@ -128,26 +123,18 @@
if (newlineAtEndNode)
removeNode(newlineAtEndNode);
- NodeImpl *holder = insertFragmentForTestRendering();
- if (holder)
- holder->ref();
- if (!m_matchStyle) {
- computeStylesUsingTestRendering(holder);
- }
- removeUnrenderedNodesUsingTestRendering(holder);
- m_hasMoreThanOneBlock = countRenderedBlocks(holder) > 1;
- restoreTestRenderingNodesToFragment(holder);
+ PassRefPtr<NodeImpl> holder = insertFragmentForTestRendering();
+ if (!m_matchStyle)
+ computeStylesUsingTestRendering(holder.get());
+ removeUnrenderedNodesUsingTestRendering(holder.get());
+ m_hasMoreThanOneBlock = countRenderedBlocks(holder.get()) > 1;
+ restoreTestRenderingNodesToFragment(holder.get());
removeNode(holder);
- holder->deref();
removeStyleNodes();
}
ReplacementFragment::~ReplacementFragment()
{
- if (m_document)
- m_document->deref();
- if (m_fragment)
- m_fragment->deref();
}
NodeImpl *ReplacementFragment::firstChild() const
@@ -209,7 +196,7 @@
{
while (node && !isProbablyBlock(node))
node = node->parentNode();
- return node ? node : m_fragment;
+ return node ? node : m_fragment.get();
}
void ReplacementFragment::removeNodePreservingChildren(NodeImpl *node)
@@ -217,28 +204,24 @@
if (!node)
return;
- while (NodeImpl *n = node->firstChild()) {
- n->ref();
+ while (RefPtr<NodeImpl> n = node->firstChild()) {
removeNode(n);
- insertNodeBefore(n, node);
- n->deref();
+ insertNodeBefore(n.get(), node);
}
removeNode(node);
}
-void ReplacementFragment::removeNode(NodeImpl *node)
+void ReplacementFragment::removeNode(PassRefPtr<NodeImpl> node)
{
if (!node)
return;
-
+
NodeImpl *parent = node->parentNode();
if (!parent)
return;
-
+
int exceptionCode = 0;
- node->ref();
- parent->removeChild(node, exceptionCode);
- node->deref();
+ parent->removeChild(node.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
@@ -256,22 +239,20 @@
ASSERT(exceptionCode == 0);
}
-NodeImpl *ReplacementFragment::insertFragmentForTestRendering()
+PassRefPtr<NodeImpl> ReplacementFragment::insertFragmentForTestRendering()
{
NodeImpl *body = m_document->body();
if (!body)
return 0;
- ElementImpl *holder = createDefaultParagraphElement(m_document);
- holder->ref();
+ PassRefPtr<ElementImpl> holder = createDefaultParagraphElement(m_document.get());
int exceptionCode = 0;
- holder->appendChild(m_fragment, exceptionCode);
+ holder->appendChild(m_fragment.get(), exceptionCode);
ASSERT(exceptionCode == 0);
- body->appendChild(holder, exceptionCode);
+ body->appendChild(holder.get(), exceptionCode);
ASSERT(exceptionCode == 0);
- holder->deref();
m_document->updateLayoutIgnorePendingStylesheets();
@@ -284,13 +265,11 @@
return;
int exceptionCode = 0;
- while (NodeImpl *node = holder->firstChild()) {
- node->ref();
- holder->removeChild(node, exceptionCode);
+ while (RefPtr<NodeImpl> node = holder->firstChild()) {
+ holder->removeChild(node.get(), exceptionCode);
ASSERT(exceptionCode == 0);
- m_fragment->appendChild(node, exceptionCode);
+ m_fragment->appendChild(node.get(), exceptionCode);
ASSERT(exceptionCode == 0);
- node->deref();
}
}
@@ -319,8 +298,7 @@
// The desiredStyle declaration tells what style this node wants to be.
// Compare that to the style that it is right now in the document.
Position pos(node, 0);
- CSSComputedStyleDeclarationImpl *currentStyle = pos.computedStyle();
- currentStyle->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> currentStyle = pos.computedStyle();
// Check for the special "match nearest blockquote color" property and resolve to the correct
// color if necessary.
@@ -328,11 +306,9 @@
if (matchColorCheck == matchNearestBlockquoteColorString()) {
NodeImpl *blockquote = nearestMailBlockquote(node);
Position pos(blockquote ? blockquote : node->getDocument()->documentElement(), 0);
- CSSComputedStyleDeclarationImpl *style = pos.computedStyle();
- style->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> style = pos.computedStyle();
DOMString desiredColor = desiredStyle->getPropertyValue(CSS_PROP_COLOR);
DOMString nearestColor = style->getPropertyValue(CSS_PROP_COLOR);
- style->deref();
if (desiredColor != nearestColor)
desiredStyle->setProperty(CSS_PROP_COLOR, nearestColor);
}
@@ -349,8 +325,6 @@
// from the desired by the styles remaining in the desiredStyle declaration.
if (desiredStyle->length() > 0)
applyStyle(desiredStyle, Position(node, 0), Position(node, node->maxDeepOffset()));
-
- currentStyle->deref();
}
}
@@ -359,20 +333,16 @@
if (!node || !node->inDocument())
return;
- CSSComputedStyleDeclarationImpl *computedStyle = Position(node, 0).computedStyle();
- computedStyle->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> computedStyle = Position(node, 0).computedStyle();
CSSMutableStyleDeclarationImpl *style = computedStyle->copyInheritableProperties();
list.append(NodeDesiredStyle(node, style));
- computedStyle->deref();
// In either of the color-matching tests below, set the color to a pseudo-color that will
// make the content take on the color of the nearest-enclosing blockquote (if any) after
// being pasted in.
if (NodeImpl *blockquote = nearestMailBlockquote(node)) {
- CSSComputedStyleDeclarationImpl *blockquoteStyle = Position(blockquote, 0).computedStyle();
- blockquoteStyle->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> blockquoteStyle = Position(blockquote, 0).computedStyle();
bool match = (blockquoteStyle->getPropertyValue(CSS_PROP_COLOR) == style->getPropertyValue(CSS_PROP_COLOR));
- blockquoteStyle->deref();
if (match) {
style->setProperty(CSS_PROP__KHTML_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR, matchNearestBlockquoteColorString());
return;
@@ -380,13 +350,10 @@
}
NodeImpl *documentElement = node->getDocument() ? node->getDocument()->documentElement() : 0;
if (documentElement) {
- CSSComputedStyleDeclarationImpl *documentStyle = Position(documentElement, 0).computedStyle();
- documentStyle->ref();
+ RefPtr<CSSComputedStyleDeclarationImpl> documentStyle = Position(documentElement, 0).computedStyle();
bool match = (documentStyle->getPropertyValue(CSS_PROP_COLOR) == style->getPropertyValue(CSS_PROP_COLOR));
- documentStyle->deref();
- if (match) {
+ if (match)
style->setProperty(CSS_PROP__KHTML_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR, matchNearestBlockquoteColorString());
- }
}
}
@@ -486,57 +453,11 @@
NodeDesiredStyle::NodeDesiredStyle(NodeImpl *node, CSSMutableStyleDeclarationImpl *style)
: m_node(node), m_style(style)
{
- if (m_node)
- m_node->ref();
- if (m_style)
- m_style->ref();
-}
-
-NodeDesiredStyle::NodeDesiredStyle(const NodeDesiredStyle &other)
- : m_node(other.node()), m_style(other.style())
-{
- if (m_node)
- m_node->ref();
- if (m_style)
- m_style->ref();
-}
-
-NodeDesiredStyle::~NodeDesiredStyle()
-{
- if (m_node)
- m_node->deref();
- if (m_style)
- m_style->deref();
-}
-
-NodeDesiredStyle &NodeDesiredStyle::operator=(const NodeDesiredStyle &other)
-{
- NodeImpl *oldNode = m_node;
- CSSMutableStyleDeclarationImpl *oldStyle = m_style;
-
- m_node = other.node();
- m_style = other.style();
-
- if (m_node)
- m_node->ref();
- if (m_style)
- m_style->ref();
-
- if (oldNode)
- oldNode->deref();
- if (oldStyle)
- oldStyle->deref();
-
- return *this;
}
ReplaceSelectionCommand::ReplaceSelectionCommand(DocumentImpl *document, DocumentFragmentImpl *fragment, bool selectReplacement, bool smartReplace, bool matchStyle)
: CompositeEditCommand(document),
m_fragment(document, fragment, matchStyle),
- m_firstNodeInserted(0),
- m_lastNodeInserted(0),
- m_lastTopNodeInserted(0),
- m_insertionStyle(0),
m_selectReplacement(selectReplacement),
m_smartReplace(smartReplace),
m_matchStyle(matchStyle)
@@ -545,14 +466,6 @@
ReplaceSelectionCommand::~ReplaceSelectionCommand()
{
- if (m_firstNodeInserted)
- m_firstNodeInserted->deref();
- if (m_lastNodeInserted)
- m_lastNodeInserted->deref();
- if (m_lastTopNodeInserted)
- m_lastTopNodeInserted->deref();
- if (m_insertionStyle)
- m_insertionStyle->deref();
}
static int maxRangeOffset(NodeImpl *n)
@@ -589,10 +502,8 @@
SelectionController selection = endingSelection();
ASSERT(selection.isCaretOrRange());
- if (m_matchStyle) {
+ if (m_matchStyle)
m_insertionStyle = styleAtPosition(selection.start());
- m_insertionStyle->ref();
- }
VisiblePosition visibleStart(selection.start(), selection.startAffinity());
VisiblePosition visibleEnd(selection.end(), selection.endAffinity());
@@ -759,7 +670,7 @@
// update insertion point to be at the end of the last block inserted
if (m_lastNodeInserted) {
updateLayout();
- insertionPos = Position(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset());
+ insertionPos = Position(m_lastNodeInserted.get(), m_lastNodeInserted->caretMaxOffset());
}
}
@@ -789,23 +700,23 @@
node = next;
}
updateLayout();
- insertionPos = Position(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset());
+ insertionPos = Position(m_lastNodeInserted.get(), m_lastNodeInserted->caretMaxOffset());
}
// step 3 : handle "smart replace" whitespace
if (addTrailingSpace && m_lastNodeInserted) {
updateLayout();
- Position pos(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset());
+ Position pos(m_lastNodeInserted.get(), m_lastNodeInserted->caretMaxOffset());
bool needsTrailingSpace = pos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull();
if (needsTrailingSpace) {
if (m_lastNodeInserted->isTextNode()) {
- TextImpl *text = static_cast<TextImpl *>(m_lastNodeInserted);
+ TextImpl *text = static_cast<TextImpl *>(m_lastNodeInserted.get());
insertTextIntoNode(text, text->length(), nonBreakingSpaceString());
insertionPos = Position(text, text->length());
}
else {
NodeImpl *node = document()->createEditingTextNode(nonBreakingSpaceString());
- insertNodeAfterAndUpdateNodesInserted(node, m_lastNodeInserted);
+ insertNodeAfterAndUpdateNodesInserted(node, m_lastNodeInserted.get());
insertionPos = Position(node, 1);
}
}
@@ -813,15 +724,15 @@
if (addLeadingSpace && m_firstNodeInserted) {
updateLayout();
- Position pos(m_firstNodeInserted, 0);
+ Position pos(m_firstNodeInserted.get(), 0);
bool needsLeadingSpace = pos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull();
if (needsLeadingSpace) {
if (m_firstNodeInserted->isTextNode()) {
- TextImpl *text = static_cast<TextImpl *>(m_firstNodeInserted);
+ TextImpl *text = static_cast<TextImpl *>(m_firstNodeInserted.get());
insertTextIntoNode(text, 0, nonBreakingSpaceString());
} else {
NodeImpl *node = document()->createEditingTextNode(nonBreakingSpaceString());
- insertNodeBeforeAndUpdateNodesInserted(node, m_firstNodeInserted);
+ insertNodeBeforeAndUpdateNodesInserted(node, m_firstNodeInserted.get());
}
}
}
@@ -839,7 +750,7 @@
bool insertParagraph = false;
VisiblePosition pos(insertionPos, VP_DEFAULT_AFFINITY);
- if (startBlock == endBlock && !isProbablyBlock(m_lastTopNodeInserted)) {
+ if (startBlock == endBlock && !isProbablyBlock(m_lastTopNodeInserted.get())) {
insertParagraph = true;
} else {
// Handle end-of-document case.
@@ -865,23 +776,23 @@
else {
if (m_lastNodeInserted && m_lastNodeInserted->hasTagName(brTag) && !document()->inStrictMode()) {
updateLayout();
- VisiblePosition pos(Position(m_lastNodeInserted, 1), DOWNSTREAM);
+ VisiblePosition pos(Position(m_lastNodeInserted.get(), 1), DOWNSTREAM);
if (isEndOfBlock(pos)) {
NodeImpl *next = m_lastNodeInserted->traverseNextNode();
bool hasTrailingBR = next && next->hasTagName(brTag) && m_lastNodeInserted->enclosingBlockFlowElement() == next->enclosingBlockFlowElement();
if (!hasTrailingBR) {
// Insert an "extra" BR at the end of the block.
- insertNodeBefore(createBreakElement(document()), m_lastNodeInserted);
+ insertNodeBefore(createBreakElement(document()), m_lastNodeInserted.get());
}
}
}
- if (moveNodesAfterEnd && !isLastVisiblePositionInSpecialElement(Position(m_lastNodeInserted, maxRangeOffset(m_lastNodeInserted)))) {
+ if (moveNodesAfterEnd && !isLastVisiblePositionInSpecialElement(Position(m_lastNodeInserted.get(), maxRangeOffset(m_lastNodeInserted.get())))) {
updateLayout();
QValueList<NodeDesiredStyle> styles;
QPtrList<NodeImpl> blocks;
NodeImpl *node = beyondEndNode;
- NodeImpl *refNode = m_lastNodeInserted;
+ NodeImpl *refNode = m_lastNodeInserted.get();
while (node) {
RenderObject *renderer = node->renderer();
// Stop at the first table or block.
@@ -948,11 +859,9 @@
Position start;
Position end;
- if (m_firstNodeInserted && m_firstNodeInserted->inDocument() &&
- m_lastNodeInserted && m_lastNodeInserted->inDocument()) {
-
+ if (m_firstNodeInserted && m_firstNodeInserted->inDocument() && m_lastNodeInserted && m_lastNodeInserted->inDocument()) {
// Find the last leaf.
- NodeImpl *lastLeaf = m_lastNodeInserted;
+ NodeImpl *lastLeaf = m_lastNodeInserted.get();
while (1) {
NodeImpl *nextChild = lastLeaf->lastChild();
if (!nextChild)
@@ -961,7 +870,7 @@
}
// Find the first leaf.
- NodeImpl *firstLeaf = m_firstNodeInserted;
+ NodeImpl *firstLeaf = m_firstNodeInserted.get();
while (1) {
NodeImpl *nextChild = firstLeaf->firstChild();
if (!nextChild)
@@ -976,14 +885,14 @@
if (m_matchStyle) {
assert(m_insertionStyle);
- applyStyle(m_insertionStyle, start, end);
+ applyStyle(m_insertionStyle.get(), start, end);
}
if (lastPositionToSelect.isNotNull())
end = lastPositionToSelect;
- } else if (lastPositionToSelect.isNotNull()) {
+ } else if (lastPositionToSelect.isNotNull())
start = end = lastPositionToSelect;
- } else
+ else
return;
if (m_selectReplacement)
@@ -1022,27 +931,14 @@
if (!node)
return;
- // update m_lastTopNodeInserted
- node->ref();
- if (m_lastTopNodeInserted)
- m_lastTopNodeInserted->deref();
m_lastTopNodeInserted = node;
-
- // update m_firstNodeInserted
- if (!m_firstNodeInserted) {
+ if (!m_firstNodeInserted)
m_firstNodeInserted = node;
- m_firstNodeInserted->ref();
- }
if (node == m_lastNodeInserted)
return;
- // update m_lastNodeInserted
- NodeImpl *old = m_lastNodeInserted;
m_lastNodeInserted = node->lastDescendant();
- m_lastNodeInserted->ref();
- if (old)
- old->deref();
}
} // namespace khtml
1.4 +14 -17 WebCore/khtml/editing/replace_selection_command.h
Index: replace_selection_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/replace_selection_command.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- replace_selection_command.h 13 Dec 2005 01:28:59 -0000 1.3
+++ replace_selection_command.h 3 Jan 2006 09:19:06 -0000 1.4
@@ -27,6 +27,7 @@
#define __replace_selection_command_h__
#include "composite_edit_command.h"
+#include <kxmlcore/PassRefPtr.h>
namespace DOM {
class DocumentFragmentImpl;
@@ -38,17 +39,13 @@
{
public:
NodeDesiredStyle(DOM::NodeImpl *, DOM::CSSMutableStyleDeclarationImpl *);
- NodeDesiredStyle(const NodeDesiredStyle &);
- ~NodeDesiredStyle();
- DOM::NodeImpl *node() const { return m_node; }
- DOM::CSSMutableStyleDeclarationImpl *style() const { return m_style; }
-
- NodeDesiredStyle &operator=(const NodeDesiredStyle &);
+ DOM::NodeImpl *node() const { return m_node.get(); }
+ DOM::CSSMutableStyleDeclarationImpl *style() const { return m_style.get(); }
private:
- DOM::NodeImpl *m_node;
- DOM::CSSMutableStyleDeclarationImpl *m_style;
+ RefPtr<DOM::NodeImpl> m_node;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_style;
};
// --- ReplacementFragment helper class
@@ -61,7 +58,7 @@
enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment };
- DOM::DocumentFragmentImpl *root() const { return m_fragment; }
+ DOM::DocumentFragmentImpl *root() const { return m_fragment.get(); }
DOM::NodeImpl *firstChild() const;
DOM::NodeImpl *lastChild() const;
@@ -86,7 +83,7 @@
static bool isInterchangeNewlineNode(const DOM::NodeImpl *);
static bool isInterchangeConvertedSpaceSpan(const DOM::NodeImpl *);
- DOM::NodeImpl *insertFragmentForTestRendering();
+ PassRefPtr<DOM::NodeImpl> insertFragmentForTestRendering();
void restoreTestRenderingNodesToFragment(DOM::NodeImpl *);
void computeStylesUsingTestRendering(DOM::NodeImpl *);
void removeUnrenderedNodesUsingTestRendering(DOM::NodeImpl *);
@@ -95,13 +92,13 @@
// A couple simple DOM helpers
DOM::NodeImpl *enclosingBlock(DOM::NodeImpl *) const;
- void removeNode(DOM::NodeImpl *);
+ void removeNode(PassRefPtr<DOM::NodeImpl>);
void removeNodePreservingChildren(DOM::NodeImpl *);
void insertNodeBefore(DOM::NodeImpl *node, DOM::NodeImpl *refNode);
EFragmentType m_type;
- DOM::DocumentImpl *m_document;
- DOM::DocumentFragmentImpl *m_fragment;
+ RefPtr<DOM::DocumentImpl> m_document;
+ RefPtr<DOM::DocumentFragmentImpl> m_fragment;
QValueList<NodeDesiredStyle> m_styles;
bool m_matchStyle;
bool m_hasInterchangeNewlineAtStart;
@@ -130,10 +127,10 @@
void removeLinePlaceholderIfNeeded(DOM::NodeImpl *);
ReplacementFragment m_fragment;
- DOM::NodeImpl *m_firstNodeInserted;
- DOM::NodeImpl *m_lastNodeInserted;
- DOM::NodeImpl *m_lastTopNodeInserted;
- DOM::CSSMutableStyleDeclarationImpl *m_insertionStyle;
+ RefPtr<DOM::NodeImpl> m_firstNodeInserted;
+ RefPtr<DOM::NodeImpl> m_lastNodeInserted;
+ RefPtr<DOM::NodeImpl> m_lastTopNodeInserted;
+ RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_insertionStyle;
bool m_selectReplacement;
bool m_smartReplace;
bool m_matchStyle;
1.7 +0 -7 WebCore/khtml/editing/set_node_attribute_command.cpp
Index: set_node_attribute_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/set_node_attribute_command.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- set_node_attribute_command.cpp 21 Nov 2005 01:20:05 -0000 1.6
+++ set_node_attribute_command.cpp 3 Jan 2006 09:19:06 -0000 1.7
@@ -43,16 +43,9 @@
: EditCommand(document), m_element(element), m_attribute(attribute), m_value(value)
{
ASSERT(m_element);
- m_element->ref();
ASSERT(!m_value.isNull());
}
-SetNodeAttributeCommand::~SetNodeAttributeCommand()
-{
- ASSERT(m_element);
- m_element->deref();
-}
-
void SetNodeAttributeCommand::doApply()
{
ASSERT(m_element);
1.3 +3 -3 WebCore/khtml/editing/set_node_attribute_command.h
Index: set_node_attribute_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/set_node_attribute_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- set_node_attribute_command.h 18 Jul 2005 21:44:18 -0000 1.2
+++ set_node_attribute_command.h 3 Jan 2006 09:19:06 -0000 1.3
@@ -37,17 +37,17 @@
{
public:
SetNodeAttributeCommand(DOM::DocumentImpl *, DOM::ElementImpl *, const DOM::QualifiedName& attribute, const DOM::DOMString &value);
- virtual ~SetNodeAttributeCommand();
+ virtual ~SetNodeAttributeCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::ElementImpl *element() const { return m_element; }
+ DOM::ElementImpl *element() const { return m_element.get(); }
const DOM::QualifiedName& attribute() const { return m_attribute; }
DOM::DOMString value() const { return m_value; }
private:
- DOM::ElementImpl *m_element;
+ RefPtr<DOM::ElementImpl> m_element;
DOM::QualifiedName m_attribute;
DOM::DOMString m_value;
DOM::DOMString m_oldValue;
1.5 +3 -18 WebCore/khtml/editing/split_element_command.cpp
Index: split_element_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/split_element_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- split_element_command.cpp 21 Nov 2005 01:20:05 -0000 1.4
+++ split_element_command.cpp 3 Jan 2006 09:19:06 -0000 1.5
@@ -37,24 +37,10 @@
namespace khtml {
SplitElementCommand::SplitElementCommand(DOM::DocumentImpl *document, DOM::ElementImpl *element, DOM::NodeImpl *atChild)
- : EditCommand(document), m_element1(0), m_element2(element), m_atChild(atChild)
+ : EditCommand(document), m_element2(element), m_atChild(atChild)
{
ASSERT(m_element2);
ASSERT(m_atChild);
-
- m_element2->ref();
- m_atChild->ref();
-}
-
-SplitElementCommand::~SplitElementCommand()
-{
- if (m_element1)
- m_element1->deref();
-
- ASSERT(m_element2);
- m_element2->deref();
- ASSERT(m_atChild);
- m_atChild->deref();
}
void SplitElementCommand::doApply()
@@ -69,10 +55,9 @@
// if reapplying, this object will already exist.
m_element1 = static_cast<ElementImpl *>(m_element2->cloneNode(false));
ASSERT(m_element1);
- m_element1->ref();
}
- m_element2->parent()->insertBefore(m_element1, m_element2, exceptionCode);
+ m_element2->parent()->insertBefore(m_element1.get(), m_element2.get(), exceptionCode);
ASSERT(exceptionCode == 0);
while (m_element2->firstChild() != m_atChild) {
@@ -98,7 +83,7 @@
ASSERT(exceptionCode == 0);
}
- m_element2->parentNode()->removeChild(m_element1, exceptionCode);
+ m_element2->parentNode()->removeChild(m_element1.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
1.2 +4 -4 WebCore/khtml/editing/split_element_command.h
Index: split_element_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/split_element_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- split_element_command.h 24 May 2005 07:21:47 -0000 1.1
+++ split_element_command.h 3 Jan 2006 09:19:06 -0000 1.2
@@ -34,15 +34,15 @@
{
public:
SplitElementCommand(DOM::DocumentImpl *, DOM::ElementImpl *element, DOM::NodeImpl *atChild);
- virtual ~SplitElementCommand();
+ virtual ~SplitElementCommand() { }
virtual void doApply();
virtual void doUnapply();
private:
- DOM::ElementImpl *m_element1;
- DOM::ElementImpl *m_element2;
- DOM::NodeImpl *m_atChild;
+ RefPtr<DOM::ElementImpl> m_element1;
+ RefPtr<DOM::ElementImpl> m_element2;
+ RefPtr<DOM::NodeImpl> m_atChild;
};
} // namespace khtml
1.7 +5 -17 WebCore/khtml/editing/split_text_node_command.cpp
Index: split_text_node_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/split_text_node_command.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- split_text_node_command.cpp 21 Nov 2005 01:20:05 -0000 1.6
+++ split_text_node_command.cpp 3 Jan 2006 09:19:07 -0000 1.7
@@ -38,21 +38,10 @@
namespace khtml {
SplitTextNodeCommand::SplitTextNodeCommand(DocumentImpl *document, TextImpl *text, int offset)
- : EditCommand(document), m_text1(0), m_text2(text), m_offset(offset)
+ : EditCommand(document), m_text2(text), m_offset(offset)
{
ASSERT(m_text2);
ASSERT(m_text2->length() > 0);
-
- m_text2->ref();
-}
-
-SplitTextNodeCommand::~SplitTextNodeCommand()
-{
- if (m_text1)
- m_text1->deref();
-
- ASSERT(m_text2);
- m_text2->deref();
}
void SplitTextNodeCommand::doApply()
@@ -72,14 +61,13 @@
m_text1 = document()->createTextNode(m_text2->substringData(0, m_offset, exceptionCode));
ASSERT(exceptionCode == 0);
ASSERT(m_text1);
- m_text1->ref();
}
- document()->copyMarkers(m_text2, 0, m_offset, m_text1, 0);
+ document()->copyMarkers(m_text2.get(), 0, m_offset, m_text1.get(), 0);
m_text2->deleteData(0, m_offset, exceptionCode);
ASSERT(exceptionCode == 0);
- m_text2->parentNode()->insertBefore(m_text1, m_text2, exceptionCode);
+ m_text2->parentNode()->insertBefore(m_text1.get(), m_text2.get(), exceptionCode);
ASSERT(exceptionCode == 0);
ASSERT(m_text2->previousSibling()->isTextNode());
@@ -96,9 +84,9 @@
m_text2->insertData(0, m_text1->data(), exceptionCode);
ASSERT(exceptionCode == 0);
- document()->copyMarkers(m_text1, 0, m_offset, m_text2, 0);
+ document()->copyMarkers(m_text1.get(), 0, m_offset, m_text2.get(), 0);
- m_text2->parentNode()->removeChild(m_text1, exceptionCode);
+ m_text2->parentNode()->removeChild(m_text1.get(), exceptionCode);
ASSERT(exceptionCode == 0);
m_offset = m_text1->length();
1.3 +4 -4 WebCore/khtml/editing/split_text_node_command.h
Index: split_text_node_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/split_text_node_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- split_text_node_command.h 16 Sep 2005 22:42:07 -0000 1.2
+++ split_text_node_command.h 3 Jan 2006 09:19:07 -0000 1.3
@@ -38,17 +38,17 @@
{
public:
SplitTextNodeCommand(DOM::DocumentImpl *, DOM::TextImpl *, int);
- virtual ~SplitTextNodeCommand();
+ virtual ~SplitTextNodeCommand() { }
virtual void doApply();
virtual void doUnapply();
- DOM::TextImpl *node() const { return m_text2; }
+ DOM::TextImpl *node() const { return m_text2.get(); }
int offset() const { return m_offset; }
private:
- DOM::TextImpl *m_text1;
- DOM::TextImpl *m_text2;
+ RefPtr<DOM::TextImpl> m_text1;
+ RefPtr<DOM::TextImpl> m_text2;
unsigned m_offset;
};
1.6 +2 -10 WebCore/khtml/editing/split_text_node_containing_element.cpp
Index: split_text_node_containing_element.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/split_text_node_containing_element.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- split_text_node_containing_element.cpp 21 Nov 2005 01:20:05 -0000 1.5
+++ split_text_node_containing_element.cpp 3 Jan 2006 09:19:07 -0000 1.6
@@ -44,14 +44,6 @@
{
ASSERT(m_text);
ASSERT(m_text->length() > 0);
-
- m_text->ref();
-}
-
-SplitTextNodeContainingElementCommand::~SplitTextNodeContainingElementCommand()
-{
- ASSERT(m_text);
- m_text->deref();
}
void SplitTextNodeContainingElementCommand::doApply()
@@ -59,7 +51,7 @@
ASSERT(m_text);
ASSERT(m_offset > 0);
- splitTextNode(m_text, m_offset);
+ splitTextNode(m_text.get(), m_offset);
NodeImpl *parentNode = m_text->parentNode();
if (!parentNode->renderer() || !parentNode->renderer()->isInline()) {
@@ -67,7 +59,7 @@
parentNode = parentNode->firstChild();
}
- splitElement(static_cast<ElementImpl *>(parentNode), m_text);
+ splitElement(static_cast<ElementImpl *>(parentNode), m_text.get());
}
} // namespace khtml
1.3 +2 -2 WebCore/khtml/editing/split_text_node_containing_element_command.h
Index: split_text_node_containing_element_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/split_text_node_containing_element_command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- split_text_node_containing_element_command.h 16 Sep 2005 22:42:07 -0000 1.2
+++ split_text_node_containing_element_command.h 3 Jan 2006 09:19:07 -0000 1.3
@@ -34,12 +34,12 @@
{
public:
SplitTextNodeContainingElementCommand(DOM::DocumentImpl *, DOM::TextImpl *, int);
- virtual ~SplitTextNodeContainingElementCommand();
+ virtual ~SplitTextNodeContainingElementCommand() { }
virtual void doApply();
private:
- DOM::TextImpl *m_text;
+ RefPtr<DOM::TextImpl> m_text;
int m_offset;
};
1.67 +2 -2 WebCore/khtml/editing/visible_position.cpp
Index: visible_position.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_position.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- visible_position.cpp 2 Dec 2005 09:00:29 -0000 1.66
+++ visible_position.cpp 3 Jan 2006 09:19:07 -0000 1.67
@@ -387,11 +387,11 @@
}
#endif
-RefPtr<RangeImpl> makeRange(const VisiblePosition &start, const VisiblePosition &end)
+PassRefPtr<RangeImpl> makeRange(const VisiblePosition &start, const VisiblePosition &end)
{
Position s = start.position();
Position e = end.position();
- return RefPtr<RangeImpl>(new RangeImpl(s.node()->getDocument(), s.node(), s.offset(), e.node(), e.offset()));
+ return new RangeImpl(s.node()->getDocument(), s.node(), s.offset(), e.node(), e.offset());
}
VisiblePosition startVisiblePosition(const RangeImpl *r, EAffinity affinity)
1.35 +3 -2 WebCore/khtml/editing/visible_position.h
Index: visible_position.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_position.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- visible_position.h 1 Dec 2005 10:32:14 -0000 1.34
+++ visible_position.h 3 Jan 2006 09:19:07 -0000 1.35
@@ -26,7 +26,8 @@
#ifndef KHTML_EDITING_VISIBLE_POSITION_H
#define KHTML_EDITING_VISIBLE_POSITION_H
-#include <qstring.h>
+#include <qstring.h> // for QChar
+#include <kxmlcore/PassRefPtr.h>
#include "xml/dom_position.h"
#include "text_affinity.h"
@@ -128,7 +129,7 @@
return !(a == b);
}
-RefPtr<DOM::RangeImpl> makeRange(const VisiblePosition &start, const VisiblePosition &end);
+PassRefPtr<DOM::RangeImpl> makeRange(const VisiblePosition &start, const VisiblePosition &end);
bool setStart(DOM::RangeImpl *, const VisiblePosition &start);
bool setEnd(DOM::RangeImpl *, const VisiblePosition &start);
VisiblePosition startVisiblePosition(const DOM::RangeImpl *, EAffinity);
1.47 +14 -17 WebCore/khtml/editing/visible_text.cpp
Index: visible_text.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_text.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- visible_text.cpp 30 Dec 2005 21:23:32 -0000 1.46
+++ visible_text.cpp 3 Jan 2006 09:19:07 -0000 1.47
@@ -459,7 +459,7 @@
m_lastCharacter = c;
}
-RefPtr<RangeImpl> TextIterator::range() const
+PassRefPtr<RangeImpl> TextIterator::range() const
{
// use the current run information, if we have it
if (m_positionNode) {
@@ -469,16 +469,14 @@
m_positionEndOffset += index;
m_positionOffsetBaseNode = 0;
}
- return RefPtr<RangeImpl>(new RangeImpl(m_positionNode->getDocument(),
- m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset));
+ return new RangeImpl(m_positionNode->getDocument(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset);
}
// otherwise, return the end of the overall range we were given
if (m_endContainer)
- return RefPtr<RangeImpl>(new RangeImpl(m_endContainer->getDocument(),
- m_endContainer, m_endOffset, m_endContainer, m_endOffset));
+ return new RangeImpl(m_endContainer->getDocument(), m_endContainer, m_endOffset, m_endContainer, m_endOffset);
- return RefPtr<RangeImpl>();
+ return 0;
}
SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator() : m_positionNode(0)
@@ -712,13 +710,12 @@
}
}
-RefPtr<RangeImpl> SimplifiedBackwardsTextIterator::range() const
+PassRefPtr<RangeImpl> SimplifiedBackwardsTextIterator::range() const
{
- if (m_positionNode) {
- return RefPtr<RangeImpl>(new RangeImpl(m_positionNode->getDocument(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset));
- } else {
- return RefPtr<RangeImpl>(new RangeImpl(m_startNode->getDocument(), m_startNode, m_startOffset, m_startNode, m_startOffset));
- }
+ if (m_positionNode)
+ return new RangeImpl(m_positionNode->getDocument(), m_positionNode, m_positionStartOffset, m_positionNode, m_positionEndOffset);
+
+ return new RangeImpl(m_startNode->getDocument(), m_startNode, m_startOffset, m_startNode, m_startOffset);
}
CharacterIterator::CharacterIterator()
@@ -734,9 +731,9 @@
}
}
-RefPtr<RangeImpl> CharacterIterator::range() const
+PassRefPtr<RangeImpl> CharacterIterator::range() const
{
- RefPtr<RangeImpl> r = m_textIterator.range();
+ PassRefPtr<RangeImpl> r = m_textIterator.range();
if (!m_textIterator.atEnd()) {
if (m_textIterator.length() <= 1) {
assert(m_runOffset == 0);
@@ -1071,7 +1068,7 @@
return result;
}
-RefPtr<RangeImpl> findPlainText(const RangeImpl *r, const QString &s, bool forward, bool caseSensitive)
+PassRefPtr<RangeImpl> findPlainText(const RangeImpl *r, const QString &s, bool forward, bool caseSensitive)
{
// FIXME: Can we do Boyer-Moore or equivalent instead for speed?
@@ -1081,7 +1078,7 @@
int exception = 0;
RangeImpl *result = r->cloneRange(exception);
result->collapse(forward, exception);
- return RefPtr<RangeImpl>(result);
+ return result;
}
CircularSearchBuffer buffer(s, caseSensitive);
@@ -1139,7 +1136,7 @@
it.advance(buffer.length() - 1);
result->setEnd(it.range()->endContainer(exception), it.range()->endOffset(exception), exception);
}
- return RefPtr<RangeImpl>(result);
+ return result;
}
}
1.19 +6 -6 WebCore/khtml/editing/visible_text.h
Index: visible_text.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_text.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- visible_text.h 1 Dec 2005 10:32:15 -0000 1.18
+++ visible_text.h 3 Jan 2006 09:19:07 -0000 1.19
@@ -51,7 +51,7 @@
}
QString plainText(const DOM::RangeImpl *);
-RefPtr<DOM::RangeImpl> findPlainText(const DOM::RangeImpl *, const QString &, bool forward, bool caseSensitive);
+PassRefPtr<DOM::RangeImpl> findPlainText(const DOM::RangeImpl *, const QString &, bool forward, bool caseSensitive);
// Iterates through the DOM range, returning all the text, and 0-length boundaries
// at points where replaced elements break up the text flow. The text comes back in
@@ -71,7 +71,7 @@
int length() const { return m_textLength; }
const QChar *characters() const { return m_textCharacters; }
- RefPtr<DOM::RangeImpl> range() const;
+ PassRefPtr<DOM::RangeImpl> range() const;
static int TextIterator::rangeLength(const DOM::RangeImpl *r);
static DOM::RangeImpl *TextIterator::rangeFromLocationAndLength(DOM::DocumentImpl *doc, int rangeLocation, int rangeLength);
@@ -136,7 +136,7 @@
int length() const { return m_textLength; }
const QChar *characters() const { return m_textCharacters; }
- RefPtr<DOM::RangeImpl> range() const;
+ PassRefPtr<DOM::RangeImpl> range() const;
private:
void exitNode();
@@ -189,7 +189,7 @@
QString string(int numChars);
int characterOffset() const { return m_offset; }
- RefPtr<DOM::RangeImpl> range() const;
+ PassRefPtr<DOM::RangeImpl> range() const;
private:
int m_offset;
@@ -213,7 +213,7 @@
const QChar *characters() const;
// Range of the text we're currently returning
- RefPtr<DOM::RangeImpl> range() const { return m_range; }
+ PassRefPtr<DOM::RangeImpl> range() const { return m_range; }
private:
// text from the previous chunk from the textIterator
@@ -226,7 +226,7 @@
// Did we have to look ahead in the textIterator to confirm the current chunk?
bool m_didLookAhead;
- RefPtr<DOM::RangeImpl> m_range;
+ PassRefPtr<DOM::RangeImpl> m_range;
TextIterator m_textIterator;
};
1.5 +5 -18 WebCore/khtml/editing/wrap_contents_in_dummy_span_command.cpp
Index: wrap_contents_in_dummy_span_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/wrap_contents_in_dummy_span_command.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wrap_contents_in_dummy_span_command.cpp 21 Nov 2005 01:20:06 -0000 1.4
+++ wrap_contents_in_dummy_span_command.cpp 3 Jan 2006 09:19:07 -0000 1.5
@@ -37,20 +37,9 @@
namespace khtml {
WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(DOM::DocumentImpl *document, DOM::ElementImpl *element)
- : EditCommand(document), m_element(element), m_dummySpan(0)
+ : EditCommand(document), m_element(element)
{
ASSERT(m_element);
-
- m_element->ref();
-}
-
-WrapContentsInDummySpanCommand::~WrapContentsInDummySpanCommand()
-{
- if (m_dummySpan)
- m_dummySpan->deref();
-
- ASSERT(m_element);
- m_element->deref();
}
void WrapContentsInDummySpanCommand::doApply()
@@ -59,17 +48,15 @@
int exceptionCode = 0;
- if (!m_dummySpan) {
+ if (!m_dummySpan)
m_dummySpan = createStyleSpanElement(document());
- m_dummySpan->ref();
- }
-
+
while (m_element->firstChild()) {
m_dummySpan->appendChild(m_element->firstChild(), exceptionCode);
ASSERT(exceptionCode == 0);
}
- m_element->appendChild(m_dummySpan, exceptionCode);
+ m_element->appendChild(m_dummySpan.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
@@ -88,7 +75,7 @@
ASSERT(exceptionCode == 0);
}
- m_element->removeChild(m_dummySpan, exceptionCode);
+ m_element->removeChild(m_dummySpan.get(), exceptionCode);
ASSERT(exceptionCode == 0);
}
1.2 +3 -3 WebCore/khtml/editing/wrap_contents_in_dummy_span_command.h
Index: wrap_contents_in_dummy_span_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/wrap_contents_in_dummy_span_command.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- wrap_contents_in_dummy_span_command.h 24 May 2005 07:21:47 -0000 1.1
+++ wrap_contents_in_dummy_span_command.h 3 Jan 2006 09:19:07 -0000 1.2
@@ -34,14 +34,14 @@
{
public:
WrapContentsInDummySpanCommand(DOM::DocumentImpl *, DOM::ElementImpl *);
- virtual ~WrapContentsInDummySpanCommand();
+ virtual ~WrapContentsInDummySpanCommand() { }
virtual void doApply();
virtual void doUnapply();
private:
- DOM::ElementImpl *m_element;
- DOM::ElementImpl *m_dummySpan;
+ RefPtr<DOM::ElementImpl> m_element;
+ RefPtr<DOM::ElementImpl> m_dummySpan;
};
} // namespace khtml
1.33 +3 -3 WebCore/kwq/DOMHTML.mm
Index: DOMHTML.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/DOMHTML.mm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- DOMHTML.mm 22 Dec 2005 01:25:13 -0000 1.32
+++ DOMHTML.mm 3 Jan 2006 09:19:17 -0000 1.33
@@ -552,13 +552,13 @@
- (DOMDocumentFragment *)_createDocumentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString
{
- DocumentFragmentImpl *fragment = createFragmentFromMarkup([self _documentImpl], QString::fromNSString(markupString), QString::fromNSString(baseURLString));
- return [DOMDocumentFragment _documentFragmentWithImpl:fragment];
+ RefPtr<DocumentFragmentImpl> fragment = createFragmentFromMarkup([self _documentImpl], QString::fromNSString(markupString), QString::fromNSString(baseURLString));
+ return [DOMDocumentFragment _documentFragmentWithImpl:fragment.get()];
}
- (DOMDocumentFragment *)_createDocumentFragmentWithText:(NSString *)text
{
- return [DOMDocumentFragment _documentFragmentWithImpl:createFragmentFromText([self _documentImpl], QString::fromNSString(text))];
+ return [DOMDocumentFragment _documentFragmentWithImpl:createFragmentFromText([self _documentImpl], QString::fromNSString(text)).get()];
}
@end
1.447 +4 -4 WebCore/kwq/WebCoreBridge.mm
Index: WebCoreBridge.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
retrieving revision 1.446
retrieving revision 1.447
diff -u -r1.446 -r1.447
--- WebCoreBridge.mm 26 Dec 2005 21:46:17 -0000 1.446
+++ WebCoreBridge.mm 3 Jan 2006 09:19:17 -0000 1.447
@@ -1881,8 +1881,8 @@
if (!_part || !_part->xmlDocImpl())
return 0;
- DocumentFragmentImpl *fragment = createFragmentFromMarkup(_part->xmlDocImpl(), QString::fromNSString(markupString), QString::fromNSString(baseURLString));
- return [DOMDocumentFragment _documentFragmentWithImpl:fragment];
+ PassRefPtr<DocumentFragmentImpl> fragment = createFragmentFromMarkup(_part->xmlDocImpl(), QString::fromNSString(markupString), QString::fromNSString(baseURLString));
+ return [DOMDocumentFragment _documentFragmentWithImpl:fragment.get()];
}
- (DOMDocumentFragment *)documentFragmentWithText:(NSString *)text
@@ -1890,7 +1890,7 @@
if (!partHasSelection(self) || !text)
return 0;
- return [DOMDocumentFragment _documentFragmentWithImpl:createFragmentFromText(_part->xmlDocImpl(), QString::fromNSString(text))];
+ return [DOMDocumentFragment _documentFragmentWithImpl:createFragmentFromText(_part->xmlDocImpl(), QString::fromNSString(text)).get()];
}
- (DOMDocumentFragment *)documentFragmentWithNodesAsParagraphs:(NSArray *)nodes
@@ -1906,7 +1906,7 @@
nodeList.append([node _nodeImpl]);
}
- return [DOMDocumentFragment _documentFragmentWithImpl:createFragmentFromNodeList(_part->xmlDocImpl(), nodeList)];
+ return [DOMDocumentFragment _documentFragmentWithImpl:createFragmentFromNodeList(_part->xmlDocImpl(), nodeList).get()];
}
- (void)replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle
More information about the webkit-changes
mailing list