Bug 910237 - Get rid of the nsIEditor.h #include in nsTextControlFrame.h; r=mats,ehsan

This commit is contained in:
Ehsan Akhgari 2013-08-28 19:06:00 +00:00
parent a899450297
commit b1b1f64807
3 changed files with 30 additions and 37 deletions

View File

@ -50,6 +50,33 @@ static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID);
static nsINativeKeyBindings *sNativeInputBindings = nullptr;
static nsINativeKeyBindings *sNativeTextAreaBindings = nullptr;
class MOZ_STACK_CLASS ValueSetter
{
public:
ValueSetter(nsIEditor* aEditor)
: mEditor(aEditor)
{
MOZ_ASSERT(aEditor);
// To protect against a reentrant call to SetValue, we check whether
// another SetValue is already happening for this editor. If it is,
// we must wait until we unwind to re-enable oninput events.
mEditor->GetSuppressDispatchingInputEvent(&mOuterTransaction);
}
~ValueSetter()
{
mEditor->SetSuppressDispatchingInputEvent(mOuterTransaction);
}
void Init()
{
mEditor->SetSuppressDispatchingInputEvent(true);
}
private:
nsCOMPtr<nsIEditor> mEditor;
bool mOuterTransaction;
};
class RestoreSelectionState : public nsRunnable {
public:
RestoreSelectionState(nsTextEditorState *aState, nsTextControlFrame *aFrame)
@ -1808,7 +1835,7 @@ nsTextEditorState::SetValue(const nsAString& aValue, bool aUserInput,
// this is necessary to avoid infinite recursion
if (!currentValue.Equals(aValue))
{
nsTextControlFrame::ValueSetter valueSetter(mEditor);
ValueSetter valueSetter(mEditor);
// \r is an illegal character in the dom, but people use them,
// so convert windows and mac platform linebreaks to \n:
@ -1902,7 +1929,6 @@ nsTextEditorState::SetValue(const nsAString& aValue, bool aUserInput,
if (!mBoundFrame) {
SetValue(newValue, false, aSetValueChanged);
}
valueSetter.Cancel();
return;
}

View File

@ -10,6 +10,7 @@
#include "nsIPlaintextEditor.h"
#include "nsCaret.h"
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsIPhonetic.h"
#include "nsTextFragment.h"

View File

@ -12,11 +12,11 @@
#include "nsITextControlFrame.h"
#include "nsITextControlElement.h"
#include "nsIStatefulFrame.h"
#include "nsIEditor.h"
class nsISelectionController;
class EditorInitializerEntryTracker;
class nsTextEditorState;
class nsIEditor;
namespace mozilla {
namespace dom {
class Element;
@ -169,40 +169,6 @@ public: //for methods who access nsTextControlFrame directly
nsresult MaybeBeginSecureKeyboardInput();
void MaybeEndSecureKeyboardInput();
class MOZ_STACK_CLASS ValueSetter {
public:
ValueSetter(nsIEditor* aEditor)
: mEditor(aEditor)
, mCanceled(false)
{
MOZ_ASSERT(aEditor);
// To protect against a reentrant call to SetValue, we check whether
// another SetValue is already happening for this frame. If it is,
// we must wait until we unwind to re-enable oninput events.
mEditor->GetSuppressDispatchingInputEvent(&mOuterTransaction);
}
void Cancel() {
mCanceled = true;
}
void Init() {
mEditor->SetSuppressDispatchingInputEvent(true);
}
~ValueSetter() {
mEditor->SetSuppressDispatchingInputEvent(mOuterTransaction);
if (mCanceled) {
return;
}
}
private:
nsCOMPtr<nsIEditor> mEditor;
bool mOuterTransaction;
bool mCanceled;
};
friend class ValueSetter;
#define DEFINE_TEXTCTRL_FORWARDER(type, name) \
type name() { \
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); \