1999-03-10 19:53:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsTextEditRules_h__
|
|
|
|
#define nsTextEditRules_h__
|
|
|
|
|
|
|
|
#include "nsIEditor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
1999-03-15 00:57:32 +00:00
|
|
|
#include "nsIDOMNode.h"
|
1999-03-10 19:53:26 +00:00
|
|
|
|
1999-03-12 02:28:24 +00:00
|
|
|
class nsTextEditor;
|
1999-03-15 00:57:32 +00:00
|
|
|
class PlaceholderTxn;
|
1999-03-10 19:53:26 +00:00
|
|
|
|
|
|
|
/** Object that encapsulates HTML text-specific editing rules.
|
|
|
|
*
|
|
|
|
* To be a good citizen, edit rules must live by these restrictions:
|
|
|
|
* 1. All data manipulation is through the editor.
|
|
|
|
* Content nodes in the document tree must <B>not</B> be manipulated directly.
|
|
|
|
* Content nodes in document fragments that are not part of the document itself
|
|
|
|
* may be manipulated at will. Operations on document fragments must <B>not</B>
|
|
|
|
* go through the editor.
|
|
|
|
* 2. Selection must not be explicitly set by the rule method.
|
|
|
|
* Any manipulation of Selection must be done by the editor.
|
|
|
|
*/
|
1999-03-12 02:28:24 +00:00
|
|
|
class nsTextEditRules
|
1999-03-10 19:53:26 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsTextEditRules();
|
|
|
|
virtual ~nsTextEditRules();
|
|
|
|
|
1999-03-12 02:28:24 +00:00
|
|
|
NS_IMETHOD Init(nsTextEditor *aEditor);
|
1999-03-10 19:53:26 +00:00
|
|
|
|
|
|
|
NS_IMETHOD WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
NS_IMETHOD DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult);
|
|
|
|
NS_IMETHOD GetInsertBreakTag(nsIAtom **aTag);
|
|
|
|
|
1999-03-13 04:53:21 +00:00
|
|
|
NS_IMETHOD WillInsertText(nsIDOMSelection *aSelection,
|
|
|
|
const nsString& aInputString,
|
|
|
|
PRBool *aCancel,
|
1999-03-15 00:57:32 +00:00
|
|
|
nsString& aOutputString,
|
|
|
|
PlaceholderTxn ** aTxn);
|
1999-03-13 04:53:21 +00:00
|
|
|
NS_IMETHOD DidInsertText(nsIDOMSelection *aSelection, const nsString& aStringToInsert, nsresult aResult);
|
|
|
|
|
|
|
|
NS_IMETHOD WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
NS_IMETHOD DidInsert(nsIDOMSelection *aSelection, nsresult aResult);
|
|
|
|
|
1999-03-12 02:28:24 +00:00
|
|
|
NS_IMETHOD WillDeleteSelection(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
NS_IMETHOD DidDeleteSelection(nsIDOMSelection *aSelection, nsresult aResult);
|
|
|
|
|
1999-03-10 19:53:26 +00:00
|
|
|
protected:
|
|
|
|
|
1999-03-12 02:28:24 +00:00
|
|
|
nsTextEditor *mEditor; // note that we do not refcount the editor
|
1999-03-15 00:57:32 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> mBogusNode; // magic node acts as placeholder in empty doc
|
1999-03-10 19:53:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //nsTextEditRules_h__
|
|
|
|
|