Commit a0fe4047 authored by mjs's avatar mjs

Reviewed by Dave.

	- more splitting up of htmlediting.cpp

        * WebCore.pbproj/project.pbxproj:
        * khtml/editing/composite_edit_command.cpp:
        * khtml/editing/delete_from_text_node_command.cpp: Added.
        * khtml/editing/delete_from_text_node_command.h: Added.
        * khtml/editing/delete_selection_command.cpp: Added.
        * khtml/editing/delete_selection_command.h: Added.
        * khtml/editing/htmlediting.cpp:
        * khtml/editing/htmlediting.h:
        * khtml/editing/insert_into_text_node_command.cpp: Added.
        * khtml/editing/insert_into_text_node_command.h: Added.
        * khtml/editing/insert_node_before_command.cpp: Added.
        * khtml/editing/insert_node_before_command.h: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@9168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e5a72c77
2005-05-13 Maciej Stachowiak <mjs@apple.com>
Reviewed by Dave.
- more splitting up of htmlediting.cpp
* WebCore.pbproj/project.pbxproj:
* khtml/editing/composite_edit_command.cpp:
* khtml/editing/delete_from_text_node_command.cpp: Added.
* khtml/editing/delete_from_text_node_command.h: Added.
* khtml/editing/delete_selection_command.cpp: Added.
* khtml/editing/delete_selection_command.h: Added.
* khtml/editing/htmlediting.cpp:
* khtml/editing/htmlediting.h:
* khtml/editing/insert_into_text_node_command.cpp: Added.
* khtml/editing/insert_into_text_node_command.h: Added.
* khtml/editing/insert_node_before_command.cpp: Added.
* khtml/editing/insert_node_before_command.h: Added.
2005-05-12 Adele Peterson <adele@apple.com>
Reviewed by Maciej.
......@@ -326,6 +326,126 @@
//652
//653
//654
652C6E9708331AE400714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.cpp.cpp;
name = delete_from_text_node_command.cpp;
path = editing/delete_from_text_node_command.cpp;
refType = 4;
sourceTree = "<group>";
};
652C6E9808331AE400714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = delete_from_text_node_command.h;
path = editing/delete_from_text_node_command.h;
refType = 4;
sourceTree = "<group>";
};
652C6E9908331AE400714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.cpp.cpp;
name = delete_selection_command.cpp;
path = editing/delete_selection_command.cpp;
refType = 4;
sourceTree = "<group>";
};
652C6E9A08331AE400714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = delete_selection_command.h;
path = editing/delete_selection_command.h;
refType = 4;
sourceTree = "<group>";
};
652C6E9B08331AE400714969 = {
fileRef = 652C6E9708331AE400714969;
isa = PBXBuildFile;
settings = {
};
};
652C6E9C08331AE400714969 = {
fileRef = 652C6E9808331AE400714969;
isa = PBXBuildFile;
settings = {
};
};
652C6E9D08331AE400714969 = {
fileRef = 652C6E9908331AE400714969;
isa = PBXBuildFile;
settings = {
};
};
652C6E9E08331AE400714969 = {
fileRef = 652C6E9A08331AE400714969;
isa = PBXBuildFile;
settings = {
};
};
652C6E9F083328A700714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.cpp.cpp;
name = insert_into_text_node_command.cpp;
path = editing/insert_into_text_node_command.cpp;
refType = 4;
sourceTree = "<group>";
};
652C6EA0083328A700714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = insert_into_text_node_command.h;
path = editing/insert_into_text_node_command.h;
refType = 4;
sourceTree = "<group>";
};
652C6EA1083328A700714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.cpp.cpp;
name = insert_node_before_command.cpp;
path = editing/insert_node_before_command.cpp;
refType = 4;
sourceTree = "<group>";
};
652C6EA2083328A700714969 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = insert_node_before_command.h;
path = editing/insert_node_before_command.h;
refType = 4;
sourceTree = "<group>";
};
652C6EA3083328A700714969 = {
fileRef = 652C6E9F083328A700714969;
isa = PBXBuildFile;
settings = {
};
};
652C6EA4083328A700714969 = {
fileRef = 652C6EA0083328A700714969;
isa = PBXBuildFile;
settings = {
};
};
652C6EA5083328A700714969 = {
fileRef = 652C6EA1083328A700714969;
isa = PBXBuildFile;
settings = {
};
};
652C6EA6083328A700714969 = {
fileRef = 652C6EA2083328A700714969;
isa = PBXBuildFile;
settings = {
};
};
654D87B50831973B0082DCA1 = {
fileEncoding = 30;
isa = PBXFileReference;
......@@ -1933,6 +2053,10 @@
65DC16C50831DD6F0022744E,
65AC79A20831ED6D009385CE,
65AC79AA0831F006009385CE,
652C6E9C08331AE400714969,
652C6E9E08331AE400714969,
652C6EA4083328A700714969,
652C6EA6083328A700714969,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -4361,6 +4485,10 @@
65DC16C40831DD6F0022744E,
65AC79A10831ED6D009385CE,
65AC79A90831F006009385CE,
652C6E9B08331AE400714969,
652C6E9D08331AE400714969,
652C6EA3083328A700714969,
652C6EA5083328A700714969,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -6657,13 +6785,21 @@
65AC79A70831F006009385CE,
65DC16C30831DD6F0022744E,
65DC16C20831DD6F0022744E,
652C6E9808331AE400714969,
652C6E9708331AE400714969,
652C6E9A08331AE400714969,
652C6E9908331AE400714969,
EDA4AC97076FB89100DD23EC,
654D87B60831973B0082DCA1,
654D87B50831973B0082DCA1,
BE9185DD05EE59B80081354D,
BE9185E005EE59B80081354D,
BEA5DBDA075CEDA00098A432,
BEA5E01D075CEDAC0098A432,
BEA5DBDA075CEDA00098A432,
652C6EA0083328A700714969,
652C6E9F083328A700714969,
652C6EA2083328A700714969,
652C6EA1083328A700714969,
BE02D4E6066F908A0076809F,
BE02D4E7066F908A0076809F,
9378D9FA07640A46004B97BF,
......
......@@ -26,6 +26,9 @@
#include "composite_edit_command.h"
#include "append_node_command.h"
#include "delete_from_text_node_command.h"
#include "insert_into_text_node_command.h"
#include "insert_node_before_command.h"
#include "htmlediting.h"
#include "visible_units.h"
......@@ -245,7 +248,7 @@ void CompositeEditCommand::inputText(const DOMString &text, bool selectInsertedT
void CompositeEditCommand::insertTextIntoNode(TextImpl *node, long offset, const DOMString &text)
{
EditCommandPtr cmd(new InsertIntoTextNode(document(), node, offset, text));
EditCommandPtr cmd(new InsertIntoTextNodeCommand(document(), node, offset, text));
applyCommandToComposite(cmd);
}
......@@ -259,7 +262,7 @@ void CompositeEditCommand::replaceTextInNode(TextImpl *node, long offset, long c
{
EditCommandPtr deleteCommand(new DeleteFromTextNodeCommand(document(), node, offset, count));
applyCommandToComposite(deleteCommand);
EditCommandPtr insertCommand(new InsertIntoTextNode(document(), node, offset, replacementText));
EditCommandPtr insertCommand(new InsertIntoTextNodeCommand(document(), node, offset, replacementText));
applyCommandToComposite(insertCommand);
}
......
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "delete_from_text_node_command.h"
#include "xml/dom_textimpl.h"
#if APPLE_CHANGES
#include "KWQAssertions.h"
#else
#define ASSERT(assertion) assert(assertion)
#endif
using DOM::DocumentImpl;
using DOM::TextImpl;
namespace khtml {
DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(DocumentImpl *document, TextImpl *node, long offset, long count)
: EditCommand(document), m_node(node), m_offset(offset), m_count(count)
{
ASSERT(m_node);
ASSERT(m_offset >= 0);
ASSERT(m_offset < (long)m_node->length());
ASSERT(m_count >= 0);
m_node->ref();
}
DeleteFromTextNodeCommand::~DeleteFromTextNodeCommand()
{
ASSERT(m_node);
m_node->deref();
}
void DeleteFromTextNodeCommand::doApply()
{
ASSERT(m_node);
int exceptionCode = 0;
m_text = m_node->substringData(m_offset, m_count, exceptionCode);
ASSERT(exceptionCode == 0);
m_node->deleteData(m_offset, m_count, exceptionCode);
ASSERT(exceptionCode == 0);
}
void DeleteFromTextNodeCommand::doUnapply()
{
ASSERT(m_node);
ASSERT(!m_text.isEmpty());
int exceptionCode = 0;
m_node->insertData(m_offset, m_text, exceptionCode);
ASSERT(exceptionCode == 0);
}
} // namespace khtml
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __delete_from_text_node_command_h__
#define __delete_from_text_node_command_h__
#include "edit_command.h"
#include "dom/dom_string.h"
namespace DOM {
class TextImpl;
}
namespace khtml {
class DeleteFromTextNodeCommand : public EditCommand
{
public:
DeleteFromTextNodeCommand(DOM::DocumentImpl *document, DOM::TextImpl *node, long offset, long count);
virtual ~DeleteFromTextNodeCommand();
virtual void doApply();
virtual void doUnapply();
DOM::TextImpl *node() const { return m_node; }
long offset() const { return m_offset; }
long count() const { return m_count; }
private:
DOM::TextImpl *m_node;
long m_offset;
long m_count;
DOM::DOMString m_text;
};
} // namespace khtml
#endif // __delete_from_text_node_command_h__
This diff is collapsed.
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __delete_selection_command_h__
#define __delete_selection_command_h__
#include "composite_edit_command.h"
namespace khtml {
class DeleteSelectionCommand : public CompositeEditCommand
{
public:
DeleteSelectionCommand(DOM::DocumentImpl *document, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
DeleteSelectionCommand(DOM::DocumentImpl *document, const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
virtual void doApply();
virtual EditAction editingAction() const;
private:
virtual bool preservesTypingStyle() const;
void initializePositionData();
void saveTypingStyleState();
void insertPlaceholderForAncestorBlockContent();
bool handleSpecialCaseBRDelete();
void handleGeneralDelete();
void fixupWhitespace();
void moveNodesAfterNode();
void calculateEndingPosition();
void calculateTypingStyleAfterDelete(DOM::NodeImpl *insertedPlaceholder);
void clearTransientState();
void setStartNode(DOM::NodeImpl *);
bool m_hasSelectionToDelete;
bool m_smartDelete;
bool m_mergeBlocksAfterDelete;
bool m_trailingWhitespaceValid;
// This data is transient and should be cleared at the end of the doApply function.
Selection m_selectionToDelete;
DOM::Position m_upstreamStart;
DOM::Position m_downstreamStart;
DOM::Position m_upstreamEnd;
DOM::Position m_downstreamEnd;
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;
};
} // namespace khtml
#endif // __delete_selection_command_h__
This diff is collapsed.
......@@ -29,6 +29,7 @@
#include "edit_command.h"
#include "composite_edit_command.h"
#include "apply_style_command.h"
#include "delete_selection_command.h"
#include "dom_nodeimpl.h"
#include "editing/edit_actions.h"
......@@ -52,119 +53,6 @@ namespace khtml {
class Selection;
class VisiblePosition;
//------------------------------------------------------------------------------------------
// DeleteFromTextNodeCommand
class DeleteFromTextNodeCommand : public EditCommand
{
public:
DeleteFromTextNodeCommand(DOM::DocumentImpl *document, DOM::TextImpl *node, long offset, long count);
virtual ~DeleteFromTextNodeCommand();
virtual void doApply();
virtual void doUnapply();
DOM::TextImpl *node() const { return m_node; }
long offset() const { return m_offset; }
long count() const { return m_count; }
private:
DOM::TextImpl *m_node;
long m_offset;
long m_count;
DOM::DOMString m_text;
};
//------------------------------------------------------------------------------------------
// DeleteSelectionCommand
class DeleteSelectionCommand : public CompositeEditCommand
{
public:
DeleteSelectionCommand(DOM::DocumentImpl *document, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
DeleteSelectionCommand(DOM::DocumentImpl *document, const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
virtual void doApply();
virtual EditAction editingAction() const;
private:
virtual bool preservesTypingStyle() const;
void initializePositionData();
void saveTypingStyleState();
void insertPlaceholderForAncestorBlockContent();
bool handleSpecialCaseBRDelete();
void handleGeneralDelete();
void fixupWhitespace();
void moveNodesAfterNode();
void calculateEndingPosition();
void calculateTypingStyleAfterDelete(DOM::NodeImpl *insertedPlaceholder);
void clearTransientState();
void setStartNode(DOM::NodeImpl *);
bool m_hasSelectionToDelete;
bool m_smartDelete;
bool m_mergeBlocksAfterDelete;
bool m_trailingWhitespaceValid;
// This data is transient and should be cleared at the end of the doApply function.
Selection m_selectionToDelete;
DOM::Position m_upstreamStart;
DOM::Position m_downstreamStart;
DOM::Position m_upstreamEnd;
DOM::Position m_downstreamEnd;
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;
};
//------------------------------------------------------------------------------------------
// InsertIntoTextNode
class InsertIntoTextNode : public EditCommand
{
public:
InsertIntoTextNode(DOM::DocumentImpl *document, DOM::TextImpl *, long, const DOM::DOMString &);
virtual ~InsertIntoTextNode();
virtual void doApply();
virtual void doUnapply();
DOM::TextImpl *node() const { return m_node; }
long offset() const { return m_offset; }
DOM::DOMString text() const { return m_text; }
private:
DOM::TextImpl *m_node;
long m_offset;
DOM::DOMString m_text;
};
//------------------------------------------------------------------------------------------
// InsertNodeBeforeCommand
class InsertNodeBeforeCommand : public EditCommand
{
public:
InsertNodeBeforeCommand(DOM::DocumentImpl *, DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
virtual ~InsertNodeBeforeCommand();
virtual void doApply();
virtual void doUnapply();
DOM::NodeImpl *insertChild() const { return m_insertChild; }
DOM::NodeImpl *refChild() const { return m_refChild; }
private:
DOM::NodeImpl *m_insertChild;
DOM::NodeImpl *m_refChild;
};
//------------------------------------------------------------------------------------------
// InsertLineBreakCommand
......@@ -691,6 +579,12 @@ bool isMailPasteAsQuotationNode(const DOM::NodeImpl *node);
bool isTableStructureNode(const DOM::NodeImpl *node);
DOM::ElementImpl *createBlockPlaceholderElement(DOM::DocumentImpl *document);
bool isFirstVisiblePositionInSpecialElement(const DOM::Position& pos);
DOM::Position positionBeforeContainingSpecialElement(const DOM::Position& pos);
bool isLastVisiblePositionInSpecialElement(const DOM::Position& pos);
DOM::Position positionAfterContainingSpecialElement(const DOM::Position& pos);
DOM::Position positionOutsideContainingSpecialElement(const DOM::Position &pos);
} // end namespace khtml
#endif
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "insert_into_text_node_command.h"
#include "xml/dom_textimpl.h"
#if APPLE_CHANGES
#include "KWQAssertions.h"
#else
#define ASSERT(assertion) assert(assertion)
#endif
using DOM::DocumentImpl;
using DOM::TextImpl;