2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-08 22:16:22 +00:00
|
|
|
|
|
|
|
#include "SplitElementTxn.h"
|
1999-05-05 04:05:19 +00:00
|
|
|
#include "nsEditor.h"
|
1999-01-08 22:16:22 +00:00
|
|
|
#include "nsIDOMNode.h"
|
2000-09-14 11:45:01 +00:00
|
|
|
#include "nsISelection.h"
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
#include "nsIDOMCharacterData.h"
|
1999-02-17 19:42:29 +00:00
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gNoisy = false;
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-08 22:16:22 +00:00
|
|
|
|
|
|
|
// note that aEditor is not refcounted
|
1999-01-21 01:51:09 +00:00
|
|
|
SplitElementTxn::SplitElementTxn()
|
|
|
|
: EditTxn()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-05-09 04:59:25 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(SplitElementTxn)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SplitElementTxn, EditTxn)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNewLeftNode)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SplitElementTxn, EditTxn)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNewLeftNode)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2011-02-19 22:18:37 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(SplitElementTxn, EditTxn)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(SplitElementTxn, EditTxn)
|
2009-05-09 04:59:25 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SplitElementTxn)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
|
|
|
|
|
2000-01-04 03:09:41 +00:00
|
|
|
NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor,
|
1999-03-17 20:56:10 +00:00
|
|
|
nsIDOMNode *aNode,
|
|
|
|
PRInt32 aOffset)
|
1999-01-08 22:16:22 +00:00
|
|
|
{
|
2000-01-04 03:09:41 +00:00
|
|
|
NS_ASSERTION(aEditor && aNode, "bad args");
|
|
|
|
if (!aEditor || !aNode) { return NS_ERROR_NOT_INITIALIZED; }
|
1999-08-19 13:30:48 +00:00
|
|
|
|
1999-05-28 00:16:55 +00:00
|
|
|
mEditor = aEditor;
|
1999-02-19 11:30:31 +00:00
|
|
|
mExistingRightNode = do_QueryInterface(aNode);
|
1999-01-08 22:16:22 +00:00
|
|
|
mOffset = aOffset;
|
1999-01-21 01:51:09 +00:00
|
|
|
return NS_OK;
|
1999-01-08 22:16:22 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
1999-01-08 22:16:22 +00:00
|
|
|
{
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2010-01-17 23:11:04 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
|
|
|
printf("%p Do Split of node %p offset %d\n",
|
|
|
|
static_cast<void*>(this),
|
|
|
|
static_cast<void*>(mExistingRightNode.get()),
|
|
|
|
mOffset);
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-19 13:30:48 +00:00
|
|
|
NS_ASSERTION(mExistingRightNode && mEditor, "bad state");
|
|
|
|
if (!mExistingRightNode || !mEditor) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
|
1999-01-08 22:16:22 +00:00
|
|
|
// create a new node
|
2012-02-23 13:23:30 +00:00
|
|
|
nsresult result = mExistingRightNode->CloneNode(false, 1, getter_AddRefs(mNewLeftNode));
|
1999-01-21 01:51:09 +00:00
|
|
|
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewLeftNode)), "could not create element.");
|
2010-06-17 19:27:24 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
2010-06-17 19:41:16 +00:00
|
|
|
NS_ENSURE_TRUE(mNewLeftNode, NS_ERROR_NULL_POINTER);
|
2000-03-24 00:26:47 +00:00
|
|
|
mEditor->MarkNodeDirty(mExistingRightNode);
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2010-01-17 23:11:04 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
|
|
|
printf(" created left node = %p\n",
|
|
|
|
static_cast<void*>(mNewLeftNode.get()));
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-19 13:30:48 +00:00
|
|
|
// get the parent node
|
|
|
|
result = mExistingRightNode->GetParentNode(getter_AddRefs(mParent));
|
2010-06-17 19:27:24 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
2010-06-17 19:41:16 +00:00
|
|
|
NS_ENSURE_TRUE(mParent, NS_ERROR_NULL_POINTER);
|
1999-01-08 22:16:22 +00:00
|
|
|
|
1999-08-19 13:30:48 +00:00
|
|
|
// insert the new node
|
2000-01-04 03:09:41 +00:00
|
|
|
result = mEditor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent);
|
2010-12-01 05:24:09 +00:00
|
|
|
if (mNewLeftNode) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool bAdjustSelection;
|
2010-12-01 05:24:09 +00:00
|
|
|
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
|
|
|
|
if (bAdjustSelection)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISelection> selection;
|
|
|
|
result = mEditor->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
|
|
|
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
|
|
|
result = selection->Collapse(mNewLeftNode, mOffset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// do nothing - dom range gravity will adjust selection
|
|
|
|
}
|
1999-01-08 22:16:22 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
NS_IMETHODIMP SplitElementTxn::UndoTransaction(void)
|
1999-01-08 22:16:22 +00:00
|
|
|
{
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy) {
|
2010-01-17 23:11:04 +00:00
|
|
|
printf("%p Undo Split of existing node %p and new node %p offset %d\n",
|
|
|
|
static_cast<void*>(this),
|
|
|
|
static_cast<void*>(mExistingRightNode.get()),
|
|
|
|
static_cast<void*>(mNewLeftNode.get()),
|
|
|
|
mOffset);
|
2000-10-28 22:17:53 +00:00
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-19 13:30:48 +00:00
|
|
|
NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
|
|
|
|
if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) {
|
1999-03-17 20:56:10 +00:00
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
|
1999-01-09 00:24:48 +00:00
|
|
|
// this assumes Do inserted the new node in front of the prior existing node
|
2011-10-17 14:59:28 +00:00
|
|
|
nsresult result = mEditor->JoinNodesImpl(mExistingRightNode, mNewLeftNode, mParent, false);
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
2010-01-17 23:11:04 +00:00
|
|
|
printf("** after join left child node %p into right node %p\n",
|
|
|
|
static_cast<void*>(mNewLeftNode.get()),
|
|
|
|
static_cast<void*>(mExistingRightNode.get()));
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy) {mEditor->DebugDumpContent(); } // DEBUG
|
|
|
|
}
|
1999-05-05 04:05:19 +00:00
|
|
|
if (NS_SUCCEEDED(result))
|
1999-03-17 20:56:10 +00:00
|
|
|
{
|
2010-01-17 23:11:04 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
|
|
|
printf(" left node = %p removed\n",
|
|
|
|
static_cast<void*>(mNewLeftNode.get()));
|
|
|
|
}
|
1999-02-17 19:42:29 +00:00
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-09 00:24:48 +00:00
|
|
|
return result;
|
1999-01-08 22:16:22 +00:00
|
|
|
}
|
|
|
|
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
/* redo cannot simply resplit the right node, because subsequent transactions
|
|
|
|
* on the redo stack may depend on the left node existing in its previous state.
|
|
|
|
*/
|
2001-03-09 14:23:59 +00:00
|
|
|
NS_IMETHODIMP SplitElementTxn::RedoTransaction(void)
|
1999-01-08 22:16:22 +00:00
|
|
|
{
|
1999-08-19 13:30:48 +00:00
|
|
|
NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
|
|
|
|
if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) {
|
1999-03-17 20:56:10 +00:00
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy) {
|
2010-01-17 23:11:04 +00:00
|
|
|
printf("%p Redo Split of existing node %p and new node %p offset %d\n",
|
|
|
|
static_cast<void*>(this),
|
|
|
|
static_cast<void*>(mExistingRightNode.get()),
|
|
|
|
static_cast<void*>(mNewLeftNode.get()),
|
|
|
|
mOffset);
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy) {mEditor->DebugDumpContent(); } // DEBUG
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
|
|
|
|
1999-02-17 19:42:29 +00:00
|
|
|
nsresult result;
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
nsCOMPtr<nsIDOMNode>resultNode;
|
|
|
|
// first, massage the existing node so it is in its post-split state
|
2003-06-30 14:57:59 +00:00
|
|
|
nsCOMPtr<nsIDOMCharacterData>rightNodeAsText = do_QueryInterface(mExistingRightNode);
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
if (rightNodeAsText)
|
|
|
|
{
|
|
|
|
result = rightNodeAsText->DeleteData(0, mOffset);
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
2010-01-17 23:11:04 +00:00
|
|
|
printf("** after delete of text in right text node %p offset %d\n",
|
|
|
|
static_cast<void*>(rightNodeAsText.get()),
|
|
|
|
mOffset);
|
2000-10-28 22:17:53 +00:00
|
|
|
mEditor->DebugDumpContent(); // DEBUG
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
1999-02-17 19:42:29 +00:00
|
|
|
}
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMNode>child;
|
|
|
|
nsCOMPtr<nsIDOMNode>nextSibling;
|
|
|
|
result = mExistingRightNode->GetFirstChild(getter_AddRefs(child));
|
|
|
|
PRInt32 i;
|
|
|
|
for (i=0; i<mOffset; i++)
|
|
|
|
{
|
|
|
|
if (NS_FAILED(result)) {return result;}
|
|
|
|
if (!child) {return NS_ERROR_NULL_POINTER;}
|
|
|
|
child->GetNextSibling(getter_AddRefs(nextSibling));
|
|
|
|
result = mExistingRightNode->RemoveChild(child, getter_AddRefs(resultNode));
|
1999-04-04 18:01:35 +00:00
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
{
|
|
|
|
result = mNewLeftNode->AppendChild(child, getter_AddRefs(resultNode));
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
2010-01-17 23:11:04 +00:00
|
|
|
printf("** move child node %p from right node %p to left node %p\n",
|
|
|
|
static_cast<void*>(child.get()),
|
|
|
|
static_cast<void*>(mExistingRightNode.get()),
|
|
|
|
static_cast<void*>(mNewLeftNode.get()));
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy) {mEditor->DebugDumpContent(); } // DEBUG
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
1999-04-04 18:01:35 +00:00
|
|
|
}
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
child = do_QueryInterface(nextSibling);
|
|
|
|
}
|
1999-02-17 19:42:29 +00:00
|
|
|
}
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
// second, re-insert the left node into the tree
|
|
|
|
result = mParent->InsertBefore(mNewLeftNode, mExistingRightNode, getter_AddRefs(resultNode));
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy)
|
|
|
|
{
|
2010-01-17 23:11:04 +00:00
|
|
|
printf("** reinsert left child node %p before right node %p\n",
|
|
|
|
static_cast<void*>(mNewLeftNode.get()),
|
|
|
|
static_cast<void*>(mExistingRightNode.get()));
|
2000-10-28 22:17:53 +00:00
|
|
|
if (gNoisy) {mEditor->DebugDumpContent(); } // DEBUG
|
|
|
|
}
|
2003-05-23 21:43:10 +00:00
|
|
|
#endif
|
1999-01-09 00:24:48 +00:00
|
|
|
return result;
|
1999-01-08 22:16:22 +00:00
|
|
|
}
|
As a reminder, we decided to do this based strictly content. Some support for style-based text properties is written, but not used
anywhere any more.
* Cleaned up split and join undo/redo.
* Added TypeInState, a data struct that remembers things about text properties for collapsed selections, so you can type
* Ctrl-B with an insertion point and the next character will be bold.
* Added all the logic to handle inline vs. block elements when setting text properties.
* Added some support for italic and underline as well. Adding these things is pretty easy now. Ctrl-B, Ctrl-I, Ctrl-U for testing bold, italic, underline.
* Added all the logic to make sure we only add style tags where they're needed, so you should never get the same style tag nested within itself, except as needed for block elements.
* Added methods for testing a node to see if a particular style is set. This isn't 100% done yet, but with very little work we could have toolbar buttons that respond to selection changed notification that show the state of bold, italic, underline, etc. in real time. Supports tri-state: whole selection is bold, some of selection is bold, none of selection is bold, ...
* Fully undoable and redoable.
* Added some debug printfs to transactions and editors. all controlled by a gNoisy static in each module. helps me track down undo/redo problems. if the output bugs people enough, I'll shut it off and re-enable it in my local tree.
Noticably missing: make un-bold, make un-italic, etc. This is coming soon.
1999-04-01 17:58:07 +00:00
|
|
|
|
1999-01-08 22:16:22 +00:00
|
|
|
|
2002-03-23 22:16:54 +00:00
|
|
|
NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAString& aString)
|
1999-01-08 22:16:22 +00:00
|
|
|
{
|
2004-06-17 00:13:25 +00:00
|
|
|
aString.AssignLiteral("SplitElementTxn");
|
1999-01-08 22:16:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-02-24 17:24:37 +00:00
|
|
|
|
1999-03-02 05:30:53 +00:00
|
|
|
NS_IMETHODIMP SplitElementTxn::GetNewNode(nsIDOMNode **aNewNode)
|
1999-02-24 17:24:37 +00:00
|
|
|
{
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aNewNode, NS_ERROR_NULL_POINTER);
|
|
|
|
NS_ENSURE_TRUE(mNewLeftNode, NS_ERROR_NOT_INITIALIZED);
|
1999-02-24 17:24:37 +00:00
|
|
|
*aNewNode = mNewLeftNode;
|
|
|
|
NS_ADDREF(*aNewNode);
|
|
|
|
return NS_OK;
|
|
|
|
}
|