Bug 574430: In nsTextEditorState.cpp, move helper-class declaration outside of function-bodies to fix GCC warnings. r=jst

This commit is contained in:
Daniel Holbert 2010-07-18 15:07:53 -07:00
Родитель 7bc0610614
Коммит d4dc6fed41
2 изменённых файлов: 54 добавлений и 50 удалений

Просмотреть файл

@ -969,6 +969,36 @@ nsTextEditorState::GetSelectionController() const
return mSelCon;
}
// Helper class, used below in BindToFrame().
class PrepareEditorEvent : public nsRunnable {
public:
PrepareEditorEvent(nsTextEditorState &aState,
nsIContent *aOwnerContent,
const nsAString &aCurrentValue)
: mState(aState)
, mOwnerContent(aOwnerContent)
, mCurrentValue(aCurrentValue)
{
}
NS_IMETHOD Run() {
// Transfer the saved value to the editor if we have one
const nsAString *value = nsnull;
if (!mCurrentValue.IsEmpty()) {
value = &mCurrentValue;
}
mState.PrepareEditor(value);
return NS_OK;
}
private:
nsTextEditorState &mState;
nsCOMPtr<nsIContent> mOwnerContent; // strong reference
nsAutoString mCurrentValue;
};
nsresult
nsTextEditorState::BindToFrame(nsTextControlFrame* aFrame)
{
@ -1029,35 +1059,6 @@ nsTextEditorState::BindToFrame(nsTextControlFrame* aFrame)
// If an editor exists from before, prepare it for usage
if (mEditor) {
class PrepareEditorEvent : public nsRunnable {
public:
PrepareEditorEvent(nsTextEditorState &aState,
nsIContent *aOwnerContent,
const nsAString &aCurrentValue)
: mState(aState)
, mOwnerContent(aOwnerContent)
, mCurrentValue(aCurrentValue)
{
}
NS_IMETHOD Run() {
// Transfer the saved value to the editor if we have one
const nsAString *value = nsnull;
if (!mCurrentValue.IsEmpty()) {
value = &mCurrentValue;
}
mState.PrepareEditor(value);
return NS_OK;
}
private:
nsTextEditorState &mState;
nsCOMPtr<nsIContent> mOwnerContent; // strong reference
nsAutoString mCurrentValue;
};
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);

Просмотреть файл

@ -3005,6 +3005,30 @@ nsHTMLDocument::EndUpdate(nsUpdateType aUpdateType)
MaybeEditingStateChanged();
}
// Helper class, used below in ChangeContentEditableCount().
class DeferredContentEditableCountChangeEvent : public nsRunnable
{
public:
DeferredContentEditableCountChangeEvent(nsHTMLDocument *aDoc,
nsIContent *aElement)
: mDoc(aDoc)
, mElement(aElement)
{
}
NS_IMETHOD Run() {
if (mElement->GetOwnerDoc() == mDoc) {
mDoc->DeferredContentEditableCountChange(mElement);
}
return NS_OK;
}
private:
nsRefPtr<nsHTMLDocument> mDoc;
nsCOMPtr<nsIContent> mElement;
};
nsresult
nsHTMLDocument::ChangeContentEditableCount(nsIContent *aElement,
PRInt32 aChange)
@ -3014,27 +3038,6 @@ nsHTMLDocument::ChangeContentEditableCount(nsIContent *aElement,
mContentEditableCount += aChange;
class DeferredContentEditableCountChangeEvent : public nsRunnable
{
public:
DeferredContentEditableCountChangeEvent(nsHTMLDocument *aDoc, nsIContent *aElement)
: mDoc(aDoc)
, mElement(aElement)
{
}
NS_IMETHOD Run() {
if (mElement->GetOwnerDoc() == mDoc) {
mDoc->DeferredContentEditableCountChange(mElement);
}
return NS_OK;
}
private:
nsRefPtr<nsHTMLDocument> mDoc;
nsCOMPtr<nsIContent> mElement;
};
nsContentUtils::AddScriptRunner(
new DeferredContentEditableCountChangeEvent(this, aElement));