gecko-dev/editor/libeditor/InsertNodeTransaction.h

59 строки
1.7 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2012-05-21 15:12:37 +04: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/. */
#ifndef InsertNodeTransaction_h
#define InsertNodeTransaction_h
#include "mozilla/EditTransactionBase.h" // for EditTransactionBase, etc.
#include "nsCOMPtr.h" // for nsCOMPtr
#include "nsCycleCollectionParticipant.h"
#include "nsIContent.h" // for nsIContent
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
namespace mozilla {
class EditorBase;
/**
1999-05-07 23:23:17 +04:00
* A transaction that inserts a single element
*/
class InsertNodeTransaction final : public EditTransactionBase
{
public:
/**
* Initialize the transaction.
* @param aNode The node to insert.
* @param aParent The node to insert into.
* @param aOffset The offset in aParent to insert aNode.
*/
InsertNodeTransaction(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
EditorBase& aEditorBase);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTransaction,
EditTransactionBase)
NS_DECL_EDITTRANSACTIONBASE
protected:
virtual ~InsertNodeTransaction();
// The element to insert.
nsCOMPtr<nsIContent> mNode;
// The node into which the new node will be inserted.
nsCOMPtr<nsINode> mParent;
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 21:58:07 +04:00
// The index in mParent for the new node.
int32_t mOffset;
// The editor for this transaction.
RefPtr<EditorBase> mEditorBase;
};
} // namespace mozilla
#endif // #ifndef InsertNodeTransaction_h