Skip to content

Commit

Permalink
#432: M1390342
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Sep 1, 2017
1 parent 8a6fd1e commit 6aee6c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dom/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
, mNumberControlSpinnerSpinsUp(false)
, mPickerRunning(false)
, mSelectionCached(true)
, mHasPatternAttribute(false)
{
// We are in a type=text so we now we currenty need a nsTextEditorState.
mInputData.mState = new nsTextEditorState(this);
Expand Down Expand Up @@ -1150,6 +1151,10 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
} else if (MaxLengthApplies() && aName == nsGkAtoms::maxlength) {
UpdateTooLongValidityState();
} else if (aName == nsGkAtoms::pattern) {
// Although pattern attribute only applies to single line text controls,
// we set this flag for all input types to save having to check the type
// here.
mHasPatternAttribute = !!aValue;
UpdatePatternMismatchValidityState();
} else if (aName == nsGkAtoms::multiple) {
UpdateTypeMismatchValidityState();
Expand Down Expand Up @@ -6426,8 +6431,7 @@ HTMLInputElement::HasTypeMismatch() const
bool
HTMLInputElement::HasPatternMismatch() const
{
if (!DoesPatternApply() ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::pattern)) {
if (!mHasPatternAttribute || !DoesPatternApply()) {
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions dom/html/HTMLInputElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
return mSelectionProperties;
}

bool HasPatternAttribute() const
{
return mHasPatternAttribute;
}

// nsIConstraintValidation
bool IsTooLong();
bool IsValueMissing() const;
Expand Down Expand Up @@ -1357,6 +1362,7 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
bool mNumberControlSpinnerSpinsUp : 1;
bool mPickerRunning : 1;
bool mSelectionCached : 1;
bool mHasPatternAttribute : 1;

private:
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
Expand Down

0 comments on commit 6aee6c0

Please sign in to comment.