зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1345767 - Part 5: Factor HasPatternMismatch() out of HTMLInputElement. r=smaug
MozReview-Commit-ID: 2JWhbfEJhTm --HG-- extra : rebase_source : 0f3a0a58ebc4148ef591cb3aea970b060957dbef
This commit is contained in:
Родитель
ea4dea7a00
Коммит
75671019e8
|
@ -7379,17 +7379,6 @@ HTMLInputElement::PlaceholderApplies() const
|
|||
return IsSingleLineTextControl(false);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLInputElement::DoesPatternApply() const
|
||||
{
|
||||
// TODO: temporary until bug 773205 is fixed.
|
||||
if (IsExperimentalMobileType(mType) || IsDateTimeInputType(mType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsSingleLineTextControl(false);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLInputElement::DoesMinMaxApply() const
|
||||
{
|
||||
|
@ -7553,24 +7542,7 @@ HTMLInputElement::HasTypeMismatch() const
|
|||
bool
|
||||
HTMLInputElement::HasPatternMismatch() const
|
||||
{
|
||||
if (!DoesPatternApply() ||
|
||||
!HasAttr(kNameSpaceID_None, nsGkAtoms::pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString pattern;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::pattern, pattern);
|
||||
|
||||
nsAutoString value;
|
||||
GetNonFileValueInternal(value);
|
||||
|
||||
if (value.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIDocument* doc = OwnerDoc();
|
||||
|
||||
return !nsContentUtils::IsPatternMatching(value, pattern, doc);
|
||||
return mInputType->HasPatternMismatch();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -1081,11 +1081,6 @@ protected:
|
|||
*/
|
||||
bool DoesRequiredApply() const;
|
||||
|
||||
/**
|
||||
* Returns if the pattern attribute applies for the current type.
|
||||
*/
|
||||
bool DoesPatternApply() const;
|
||||
|
||||
/**
|
||||
* Returns if the min and max attributes apply for the current type.
|
||||
*/
|
||||
|
|
|
@ -150,3 +150,9 @@ InputType::HasTypeMismatch() const
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
InputType::HasPatternMismatch() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
virtual bool IsTooShort() const;
|
||||
virtual bool IsValueMissing() const;
|
||||
virtual bool HasTypeMismatch() const;
|
||||
virtual bool HasPatternMismatch() const;
|
||||
|
||||
protected:
|
||||
explicit InputType(mozilla::dom::HTMLInputElement* aInputElement)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "HTMLSplitOnSpacesTokenizer.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsIIDNService.h"
|
||||
#include "nsIIOService.h"
|
||||
|
@ -68,6 +69,26 @@ SingleLineTextInputTypeBase::IsValueMissing() const
|
|||
return IsValueEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
SingleLineTextInputTypeBase::HasPatternMismatch() const
|
||||
{
|
||||
nsAutoString pattern;
|
||||
if (!mInputElement->GetAttr(kNameSpaceID_None, nsGkAtoms::pattern, pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
GetNonFileValueInternal(value);
|
||||
|
||||
if (value.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIDocument* doc = mInputElement->OwnerDoc();
|
||||
|
||||
return !nsContentUtils::IsPatternMatching(value, pattern, doc);
|
||||
}
|
||||
|
||||
/* input type=url */
|
||||
|
||||
bool
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
bool IsTooLong() const override;
|
||||
bool IsTooShort() const override;
|
||||
bool IsValueMissing() const override;
|
||||
bool HasPatternMismatch() const override;
|
||||
|
||||
protected:
|
||||
explicit SingleLineTextInputTypeBase(
|
||||
|
|
Загрузка…
Ссылка в новой задаче