BaseTextInputType.cpp [plain text]
#include "config.h"
#include "BaseTextInputType.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include <JavaScriptCore/RegularExpression.h>
namespace WebCore {
using namespace HTMLNames;
bool BaseTextInputType::isTextType() const
{
return true;
}
bool BaseTextInputType::patternMismatch(const String& value) const
{
ASSERT(element());
const AtomString& rawPattern = element()->attributeWithoutSynchronization(patternAttr);
if (rawPattern.isNull() || value.isEmpty() || !JSC::Yarr::RegularExpression(rawPattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeAwareMode).isValid())
return false;
String pattern = "^(?:" + rawPattern + ")$";
int matchLength = 0;
int valueLength = value.length();
int matchOffset = JSC::Yarr::RegularExpression(pattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeAwareMode).match(value, 0, &matchLength);
return matchOffset || matchLength != valueLength;
}
bool BaseTextInputType::supportsPlaceholder() const
{
return true;
}
bool BaseTextInputType::supportsSelectionAPI() const
{
return true;
}
}