зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347640 part 2. Move a few more things from AfterSetAttr to HandleTypeChange. r=smaug
We also stop doing some unnecessary work (e.g. canceling image requests if our old type wasn't image). MozReview-Commit-ID: GLPl1McLL9N
This commit is contained in:
Родитель
a1462692fb
Коммит
85fd027b51
|
@ -1460,32 +1460,7 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|||
newType = aValue->GetEnumValue();
|
||||
}
|
||||
if (newType != mType) {
|
||||
HandleTypeChange(newType);
|
||||
}
|
||||
|
||||
UpdateBarredFromConstraintValidation();
|
||||
|
||||
if (mType != NS_FORM_INPUT_IMAGE) {
|
||||
// We're no longer an image input. Cancel our image requests, if we have
|
||||
// any. Note that doing this when we already weren't an image is ok --
|
||||
// just does nothing.
|
||||
CancelImageRequests(aNotify);
|
||||
} else if (aNotify) {
|
||||
// We just got switched to be an image input; we should see
|
||||
// whether we have an image to load;
|
||||
nsAutoString src;
|
||||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
LoadImage(src, false, aNotify, eImageLoadType_Normal);
|
||||
}
|
||||
}
|
||||
|
||||
if (mType == NS_FORM_INPUT_PASSWORD && IsInComposedDoc()) {
|
||||
AsyncEventDispatcher* dispatcher =
|
||||
new AsyncEventDispatcher(this,
|
||||
NS_LITERAL_STRING("DOMInputPasswordAdded"),
|
||||
true,
|
||||
true);
|
||||
dispatcher->PostDOMEvent();
|
||||
HandleTypeChange(newType, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5126,9 +5101,11 @@ HTMLInputElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
}
|
||||
|
||||
void
|
||||
HTMLInputElement::HandleTypeChange(uint8_t aNewType)
|
||||
HTMLInputElement::HandleTypeChange(uint8_t aNewType, bool aNotify)
|
||||
{
|
||||
uint8_t oldType = mType;
|
||||
MOZ_ASSERT(oldType != aNewType);
|
||||
|
||||
if (aNewType == NS_FORM_INPUT_FILE || oldType == NS_FORM_INPUT_FILE) {
|
||||
// Strictly speaking, we only need to clear files on going _to_ or _from_
|
||||
// the NS_FORM_INPUT_FILE type, not both, since we'll never confuse values
|
||||
|
@ -5224,6 +5201,30 @@ HTMLInputElement::HandleTypeChange(uint8_t aNewType)
|
|||
UpdateAllValidityStates(false);
|
||||
|
||||
UpdateApzAwareFlag();
|
||||
|
||||
UpdateBarredFromConstraintValidation();
|
||||
|
||||
if (oldType == NS_FORM_INPUT_IMAGE) {
|
||||
// We're no longer an image input. Cancel our image requests, if we have
|
||||
// any.
|
||||
CancelImageRequests(aNotify);
|
||||
} else if (aNotify && mType == NS_FORM_INPUT_IMAGE) {
|
||||
// We just got switched to be an image input; we should see
|
||||
// whether we have an image to load;
|
||||
nsAutoString src;
|
||||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
LoadImage(src, false, aNotify, eImageLoadType_Normal);
|
||||
}
|
||||
}
|
||||
|
||||
if (mType == NS_FORM_INPUT_PASSWORD && IsInComposedDoc()) {
|
||||
AsyncEventDispatcher* dispatcher =
|
||||
new AsyncEventDispatcher(this,
|
||||
NS_LITERAL_STRING("DOMInputPasswordAdded"),
|
||||
true,
|
||||
true);
|
||||
dispatcher->PostDOMEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1107,7 +1107,7 @@ protected:
|
|||
/**
|
||||
* Manages the internal data storage across type changes.
|
||||
*/
|
||||
void HandleTypeChange(uint8_t aNewType);
|
||||
void HandleTypeChange(uint8_t aNewType, bool aNotify);
|
||||
|
||||
/**
|
||||
* Sanitize the value of the element depending of its current type.
|
||||
|
|
Загрузка…
Ссылка в новой задаче