зеркало из https://github.com/mozilla/pjs.git
Oog. Green and open not enough. jkeiser back self out, keep drivers from hitting with big rock.
This commit is contained in:
Родитель
cdf00824db
Коммит
928715aac0
|
@ -60,7 +60,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Set the control's value without security checks
|
* Set the control's value without security checks
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD TakeTextFrameValue(const nsAString& aValue) = 0;
|
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsITextControlFrame* aFrame) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell the control that value has been deliberately changed (or not).
|
* Tell the control that value has been deliberately changed (or not).
|
||||||
|
|
|
@ -219,7 +219,7 @@ public:
|
||||||
NS_IMETHOD DoneCreatingElement();
|
NS_IMETHOD DoneCreatingElement();
|
||||||
|
|
||||||
// nsITextControlElement
|
// nsITextControlElement
|
||||||
NS_IMETHOD TakeTextFrameValue(const nsAString& aValue);
|
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsITextControlFrame* aFrame);
|
||||||
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
|
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
|
||||||
|
|
||||||
// nsIRadioControlElement
|
// nsIRadioControlElement
|
||||||
|
@ -232,8 +232,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Helper method
|
// Helper method
|
||||||
nsresult SetValueInternal(const nsAString& aValue,
|
NS_IMETHOD SetValueSecure(const nsAString& aValue,
|
||||||
nsITextControlFrame* aFrame);
|
nsITextControlFrame* aFrame,
|
||||||
|
PRBool aCheckSecurity);
|
||||||
|
|
||||||
nsresult GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
|
nsresult GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
|
||||||
//Helper method
|
//Helper method
|
||||||
|
@ -504,21 +505,6 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||||
SetCheckedChanged(PR_FALSE);
|
SetCheckedChanged(PR_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// If we are changing type from File/Text/Passwd to other input types
|
|
||||||
// we need save the mValue into value attribute
|
|
||||||
//
|
|
||||||
if (aName == nsHTMLAtoms::type && mValue &&
|
|
||||||
mType != NS_FORM_INPUT_TEXT &&
|
|
||||||
mType != NS_FORM_INPUT_PASSWORD &&
|
|
||||||
mType != NS_FORM_INPUT_FILE) {
|
|
||||||
SetAttr(kNameSpaceID_None, nsHTMLAtoms::value,
|
|
||||||
NS_ConvertUTF8toUCS2(mValue), PR_FALSE);
|
|
||||||
if (mValue) {
|
|
||||||
nsMemory::Free(mValue);
|
|
||||||
mValue = nsnull;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIDOMHTMLInputElement
|
// nsIDOMHTMLInputElement
|
||||||
|
@ -661,42 +647,46 @@ nsHTMLInputElement::GetValue(nsAString& aValue)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLInputElement::SetValue(const nsAString& aValue)
|
nsHTMLInputElement::SetValue(const nsAString& aValue)
|
||||||
{
|
{
|
||||||
//check secuity
|
return SetValueSecure(aValue, nsnull, PR_TRUE);
|
||||||
if (mType == NS_FORM_INPUT_FILE) {
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
|
||||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
PRBool enabled;
|
|
||||||
rv = securityManager->IsCapabilityEnabled("UniversalFileRead", &enabled);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (!enabled) {
|
|
||||||
// setting the value of a "FILE" input widget requires the
|
|
||||||
// UniversalFileRead privilege
|
|
||||||
return NS_ERROR_DOM_SECURITY_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SetValueInternal(aValue, nsnull);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLInputElement::TakeTextFrameValue(const nsAString& aValue)
|
nsHTMLInputElement::SetValueGuaranteed(const nsAString& aValue,
|
||||||
|
nsITextControlFrame* aFrame)
|
||||||
{
|
{
|
||||||
if (mValue) {
|
return SetValueSecure(aValue, aFrame, PR_FALSE);
|
||||||
nsMemory::Free(mValue);
|
|
||||||
}
|
|
||||||
mValue = ToNewUTF8String(aValue);
|
|
||||||
return SetValueChanged(PR_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
NS_IMETHODIMP
|
||||||
nsHTMLInputElement::SetValueInternal(const nsAString& aValue,
|
nsHTMLInputElement::SetValueSecure(const nsAString& aValue,
|
||||||
nsITextControlFrame* aFrame)
|
nsITextControlFrame* aFrame,
|
||||||
|
PRBool aCheckSecurity)
|
||||||
{
|
{
|
||||||
if (mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_PASSWORD ||
|
PRInt32 type;
|
||||||
mType == NS_FORM_INPUT_FILE) {
|
GetType(&type);
|
||||||
|
if (type == NS_FORM_INPUT_TEXT || type == NS_FORM_INPUT_PASSWORD ||
|
||||||
|
type == NS_FORM_INPUT_FILE) {
|
||||||
|
|
||||||
|
if (aCheckSecurity && type == NS_FORM_INPUT_FILE) {
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
||||||
|
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRBool enabled;
|
||||||
|
rv = securityManager->IsCapabilityEnabled("UniversalFileRead", &enabled);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled) {
|
||||||
|
// setting the value of a "FILE" input widget requires the
|
||||||
|
// UniversalFileRead privilege
|
||||||
|
return NS_ERROR_DOM_SECURITY_ERR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsITextControlFrame* textControlFrame = aFrame;
|
nsITextControlFrame* textControlFrame = aFrame;
|
||||||
nsIFormControlFrame* formControlFrame = textControlFrame;
|
nsIFormControlFrame* formControlFrame = textControlFrame;
|
||||||
|
@ -714,7 +704,7 @@ nsHTMLInputElement::SetValueInternal(const nsAString& aValue,
|
||||||
// File frames always own the value (if the frame is there).
|
// File frames always own the value (if the frame is there).
|
||||||
// Text frames have a bit that says whether they own the value.
|
// Text frames have a bit that says whether they own the value.
|
||||||
PRBool frameOwnsValue = PR_FALSE;
|
PRBool frameOwnsValue = PR_FALSE;
|
||||||
if (mType == NS_FORM_INPUT_FILE && formControlFrame) {
|
if (type == NS_FORM_INPUT_FILE && formControlFrame) {
|
||||||
frameOwnsValue = PR_TRUE;
|
frameOwnsValue = PR_TRUE;
|
||||||
}
|
}
|
||||||
if (textControlFrame) {
|
if (textControlFrame) {
|
||||||
|
@ -744,7 +734,7 @@ nsHTMLInputElement::SetValueInternal(const nsAString& aValue,
|
||||||
// the meaning of ValueChanged just a teensy bit to save a measly byte of
|
// the meaning of ValueChanged just a teensy bit to save a measly byte of
|
||||||
// storage space in nsHTMLInputElement. Yes, you are free to make a new flag,
|
// storage space in nsHTMLInputElement. Yes, you are free to make a new flag,
|
||||||
// NEED_TO_SAVE_VALUE, at such time as mBitField becomes a 16-bit value.
|
// NEED_TO_SAVE_VALUE, at such time as mBitField becomes a 16-bit value.
|
||||||
if (mType == NS_FORM_INPUT_HIDDEN) {
|
if (type == NS_FORM_INPUT_HIDDEN) {
|
||||||
SetValueChanged(PR_TRUE);
|
SetValueChanged(PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2233,7 +2223,7 @@ nsHTMLInputElement::Reset()
|
||||||
case NS_FORM_INPUT_FILE:
|
case NS_FORM_INPUT_FILE:
|
||||||
{
|
{
|
||||||
// Resetting it to blank should not perform security check
|
// Resetting it to blank should not perform security check
|
||||||
rv = SetValueInternal(NS_LITERAL_STRING(""), nsnull);
|
rv = SetValueGuaranteed(NS_LITERAL_STRING(""), nsnull);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Value is the same as defaultValue for hidden inputs
|
// Value is the same as defaultValue for hidden inputs
|
||||||
|
@ -2616,7 +2606,7 @@ nsHTMLInputElement::RestoreState(nsIPresState* aState)
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
rv = aState->GetStateProperty(NS_LITERAL_STRING("v"), value);
|
rv = aState->GetStateProperty(NS_LITERAL_STRING("v"), value);
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
|
||||||
SetValueInternal(value, nsnull);
|
SetValueGuaranteed(value, nsnull);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1876,11 +1876,11 @@ nsHTMLSelectElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||||
PRInt32 aModType,
|
PRInt32 aModType,
|
||||||
nsChangeHint& aHint) const
|
nsChangeHint& aHint) const
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::multiple ||
|
if (aAttribute == nsHTMLAtoms::multiple) {
|
||||||
aAttribute == nsHTMLAtoms::size) {
|
|
||||||
aHint = NS_STYLE_HINT_FRAMECHANGE;
|
aHint = NS_STYLE_HINT_FRAMECHANGE;
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::align) {
|
else if ((aAttribute == nsHTMLAtoms::align) ||
|
||||||
|
(aAttribute == nsHTMLAtoms::size)) {
|
||||||
aHint = NS_STYLE_HINT_REFLOW;
|
aHint = NS_STYLE_HINT_REFLOW;
|
||||||
}
|
}
|
||||||
else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||||
|
|
|
@ -115,8 +115,8 @@ public:
|
||||||
NS_IMETHOD SaveState();
|
NS_IMETHOD SaveState();
|
||||||
NS_IMETHOD RestoreState(nsIPresState* aState);
|
NS_IMETHOD RestoreState(nsIPresState* aState);
|
||||||
|
|
||||||
// nsITextControlElemet
|
// nsITextControlElement
|
||||||
NS_IMETHOD TakeTextFrameValue(const nsAString& aValue);
|
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsITextControlFrame* aFrame);
|
||||||
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
|
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
|
||||||
|
|
||||||
// nsIContent
|
// nsIContent
|
||||||
|
@ -162,9 +162,6 @@ protected:
|
||||||
* wrap=hard.
|
* wrap=hard.
|
||||||
*/
|
*/
|
||||||
void GetValueInternal(nsAString& aValue, PRBool aIgnoreWrap);
|
void GetValueInternal(nsAString& aValue, PRBool aIgnoreWrap);
|
||||||
|
|
||||||
nsresult SetValueInternal(const nsAString& aValue,
|
|
||||||
nsITextControlFrame* aFrame);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -456,19 +453,10 @@ nsHTMLTextAreaElement::GetValueInternal(nsAString& aValue, PRBool aIgnoreWrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsHTMLTextAreaElement::TakeTextFrameValue(const nsAString& aValue)
|
|
||||||
{
|
|
||||||
if (mValue) {
|
|
||||||
nsMemory::Free(mValue);
|
|
||||||
}
|
|
||||||
mValue = ToNewUTF8String(aValue);
|
|
||||||
return SetValueChanged(PR_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
NS_IMETHODIMP
|
||||||
nsHTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
|
nsHTMLTextAreaElement::SetValueGuaranteed(const nsAString& aValue,
|
||||||
nsITextControlFrame* aFrame)
|
nsITextControlFrame* aFrame)
|
||||||
{
|
{
|
||||||
nsITextControlFrame* textControlFrame = aFrame;
|
nsITextControlFrame* textControlFrame = aFrame;
|
||||||
nsIFormControlFrame* formControlFrame = textControlFrame;
|
nsIFormControlFrame* formControlFrame = textControlFrame;
|
||||||
|
@ -508,7 +496,7 @@ nsHTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLTextAreaElement::SetValue(const nsAString& aValue)
|
nsHTMLTextAreaElement::SetValue(const nsAString& aValue)
|
||||||
{
|
{
|
||||||
return SetValueInternal(aValue, nsnull);
|
return SetValueGuaranteed(aValue, nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2940,7 +2940,7 @@ nsTextControlFrame::SetValue(const nsAString& aValue)
|
||||||
nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(mContent);
|
nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(mContent);
|
||||||
if (textControl)
|
if (textControl)
|
||||||
{
|
{
|
||||||
textControl->TakeTextFrameValue(aValue);
|
textControl->SetValueGuaranteed(aValue, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2940,7 +2940,7 @@ nsTextControlFrame::SetValue(const nsAString& aValue)
|
||||||
nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(mContent);
|
nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(mContent);
|
||||||
if (textControl)
|
if (textControl)
|
||||||
{
|
{
|
||||||
textControl->TakeTextFrameValue(aValue);
|
textControl->SetValueGuaranteed(aValue, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче