mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
Fix for bug #45002: Password displayed in clear text.
layout/html/forms/src/nsGfxTextControlFrame2.cpp - Modified CreateAnonymousContent() to disable forced refreshes and reflows in the editor, and call SetTextControlFrameState() to set the intial value of the text widget. - Fixed leak in SetTextControlFrameState(). editor/public/nsIHTMLEditor.h - Added DisableForcedUpdates and DisableForcedRefreshes flags. editor/base/nsEditor.cpp - Modified EndUpdateViewBatch() so that it uses the new DisableForcedUpdates and DisableForcedRefreshes flags. - We now also close the reflow batch before we close the update batch. r=brade@netscape.com
This commit is contained in:
parent
7df6a29f8a
commit
baa1e3d567
@ -5039,9 +5039,7 @@ nsresult nsEditor::BeginUpdateViewBatch()
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv) && presShell)
|
||||
{
|
||||
presShell->BeginReflowBatching();
|
||||
}
|
||||
}
|
||||
mUpdateCount++;
|
||||
}
|
||||
@ -5078,16 +5076,40 @@ nsresult nsEditor::EndUpdateViewBatch()
|
||||
mUpdateCount--;
|
||||
if (0==mUpdateCount)
|
||||
{
|
||||
#ifdef HACK_FORCE_REDRAW
|
||||
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
HACKForceRedraw();
|
||||
#else
|
||||
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
|
||||
#endif
|
||||
PRUint32 flags = 0;
|
||||
|
||||
rv = GetFlags(&flags);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Make sure we enable reflowing before we call
|
||||
// mViewManager->EndUpdateViewBatch(). This will make sure that any
|
||||
// new updates caused by a reflow, that may happen during the
|
||||
// EndReflowBatching(), get included if we force a refresh during
|
||||
// the mViewManager->EndUpdateViewBatch() call.
|
||||
|
||||
PRBool forceReflow = PR_TRUE;
|
||||
|
||||
if (flags & nsIHTMLEditor::eEditorDisableForcedReflowsMask)
|
||||
forceReflow = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv) && presShell)
|
||||
presShell->EndReflowBatching(PR_TRUE);
|
||||
presShell->EndReflowBatching(forceReflow);
|
||||
|
||||
PRUint32 updateFlag = NS_VMREFRESH_IMMEDIATE;
|
||||
|
||||
if (flags & nsIHTMLEditor::eEditorDisableForcedUpdatesMask)
|
||||
updateFlag = NS_VMREFRESH_NO_SYNC;
|
||||
|
||||
#ifdef HACK_FORCE_REDRAW
|
||||
mViewManager->EnableRefresh(updateFlag);
|
||||
HACKForceRedraw();
|
||||
#else
|
||||
mViewManager->EndUpdateViewBatch(updateFlag);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5039,9 +5039,7 @@ nsresult nsEditor::BeginUpdateViewBatch()
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv) && presShell)
|
||||
{
|
||||
presShell->BeginReflowBatching();
|
||||
}
|
||||
}
|
||||
mUpdateCount++;
|
||||
}
|
||||
@ -5078,16 +5076,40 @@ nsresult nsEditor::EndUpdateViewBatch()
|
||||
mUpdateCount--;
|
||||
if (0==mUpdateCount)
|
||||
{
|
||||
#ifdef HACK_FORCE_REDRAW
|
||||
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
HACKForceRedraw();
|
||||
#else
|
||||
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
|
||||
#endif
|
||||
PRUint32 flags = 0;
|
||||
|
||||
rv = GetFlags(&flags);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Make sure we enable reflowing before we call
|
||||
// mViewManager->EndUpdateViewBatch(). This will make sure that any
|
||||
// new updates caused by a reflow, that may happen during the
|
||||
// EndReflowBatching(), get included if we force a refresh during
|
||||
// the mViewManager->EndUpdateViewBatch() call.
|
||||
|
||||
PRBool forceReflow = PR_TRUE;
|
||||
|
||||
if (flags & nsIHTMLEditor::eEditorDisableForcedReflowsMask)
|
||||
forceReflow = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv) && presShell)
|
||||
presShell->EndReflowBatching(PR_TRUE);
|
||||
presShell->EndReflowBatching(forceReflow);
|
||||
|
||||
PRUint32 updateFlag = NS_VMREFRESH_IMMEDIATE;
|
||||
|
||||
if (flags & nsIHTMLEditor::eEditorDisableForcedUpdatesMask)
|
||||
updateFlag = NS_VMREFRESH_NO_SYNC;
|
||||
|
||||
#ifdef HACK_FORCE_REDRAW
|
||||
mViewManager->EnableRefresh(updateFlag);
|
||||
HACKForceRedraw();
|
||||
#else
|
||||
mViewManager->EndUpdateViewBatch(updateFlag);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,19 +57,23 @@ public:
|
||||
eEditorReadonlyBit, // editing events are disabled. Editor may still accept focus.
|
||||
eEditorDisabledBit, // all events are disabled (like scrolling). Editor will not accept focus.
|
||||
eEditorFilterInputBit, // text input is limited to certain character types, use mFilter
|
||||
eEditorMailBit // use mail-compose editting rules
|
||||
eEditorMailBit, // use mail-compose editting rules
|
||||
eEditorDisableForcedUpdatesBit, // prevent immediate view refreshes
|
||||
eEditorDisableForcedReflowsBit // prevent immediate reflows
|
||||
|
||||
// max 32 bits
|
||||
};
|
||||
|
||||
enum {
|
||||
eEditorPlaintextMask = (1 << eEditorPlaintextBit),
|
||||
eEditorSingleLineMask = (1 << eEditorSingleLineBit),
|
||||
eEditorPasswordMask = (1 << eEditorPasswordBit),
|
||||
eEditorReadonlyMask = (1 << eEditorReadonlyBit),
|
||||
eEditorDisabledMask = (1 << eEditorDisabledBit),
|
||||
eEditorFilterInputMask = (1 << eEditorFilterInputBit),
|
||||
eEditorMailMask = (1 << eEditorMailBit)
|
||||
eEditorPlaintextMask = (1 << eEditorPlaintextBit),
|
||||
eEditorSingleLineMask = (1 << eEditorSingleLineBit),
|
||||
eEditorPasswordMask = (1 << eEditorPasswordBit),
|
||||
eEditorReadonlyMask = (1 << eEditorReadonlyBit),
|
||||
eEditorDisabledMask = (1 << eEditorDisabledBit),
|
||||
eEditorFilterInputMask = (1 << eEditorFilterInputBit),
|
||||
eEditorMailMask = (1 << eEditorMailBit),
|
||||
eEditorDisableForcedUpdatesMask = (1 << eEditorDisableForcedUpdatesBit),
|
||||
eEditorDisableForcedReflowsMask = (1 << eEditorDisableForcedReflowsBit)
|
||||
};
|
||||
|
||||
// below used by TypedText()
|
||||
|
@ -1457,48 +1457,6 @@ nsGfxTextControlFrame2::CreateAnonymousContent(nsIPresContext* aPresContext,
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Get the default value for the textfield.
|
||||
|
||||
nsAutoString defaultValue;
|
||||
|
||||
if (mCachedState)
|
||||
defaultValue = mCachedState->GetUnicode();
|
||||
else
|
||||
rv = GetText(&defaultValue, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// If we have a default value, create a textnode for it
|
||||
// and insert it under the DIV we created.
|
||||
|
||||
if (defaultValue.Length() > 0)
|
||||
{
|
||||
nsCOMPtr<nsIContent> textContent;
|
||||
rv = NS_NewTextNode(getter_AddRefs(textContent));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (! textContent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> charData = do_QueryInterface(textContent);
|
||||
|
||||
if (!charData)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
rv = charData->SetData(defaultValue);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = divContent->AppendChildTo(textContent, PR_FALSE);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create an editor
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kHTMLEditorCID,
|
||||
@ -1665,6 +1623,55 @@ nsGfxTextControlFrame2::CreateAnonymousContent(nsIPresContext* aPresContext,
|
||||
domSelection->AddSelectionListener(listener);
|
||||
}
|
||||
|
||||
// Get the default value for the textfield.
|
||||
|
||||
nsAutoString defaultValue;
|
||||
|
||||
if (mCachedState)
|
||||
defaultValue = mCachedState->GetUnicode();
|
||||
else
|
||||
rv = GetText(&defaultValue, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// If we have a default value, insert it under the div we created
|
||||
// above, but be sure to use the editor so that '*' characters get
|
||||
// displayed for password fields, etc. SetTextControlFrameState()
|
||||
// will call the editor for us.
|
||||
|
||||
if (defaultValue.Length() > 0)
|
||||
{
|
||||
rv = mEditor->GetFlags(&editorFlags);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Avoid causing reentrant painting and reflowing by telling the editor
|
||||
// that we don't want it to force immediate view refreshes or force
|
||||
// immediate reflows during any editor calls.
|
||||
|
||||
rv = mEditor->SetFlags(editorFlags |
|
||||
nsIHTMLEditor::eEditorDisableForcedUpdatesMask |
|
||||
nsIHTMLEditor::eEditorDisableForcedReflowsMask);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Now call SetTextControlFrameState() which will make the
|
||||
// neccessary editor calls to set the default value.
|
||||
|
||||
SetTextControlFrameState(defaultValue);
|
||||
|
||||
// Now restore the original editor flags.
|
||||
|
||||
rv = mEditor->SetFlags(editorFlags);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
if (mContent)
|
||||
{
|
||||
rv = mEditor->GetFlags(&editorFlags);
|
||||
@ -2686,9 +2693,12 @@ nsGfxTextControlFrame2::SetTextControlFrameState(const nsString& aValue)
|
||||
}
|
||||
else
|
||||
{
|
||||
mCachedState = new nsString;
|
||||
if (!mCachedState)
|
||||
return;
|
||||
{
|
||||
mCachedState = new nsString;
|
||||
if (!mCachedState)
|
||||
return;
|
||||
}
|
||||
*mCachedState = aValue; //store value for later initialization;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user