Ignore invalid regular expressions for input[pattern].
https://bugs.webkit.org/show_bug.cgi?id=115204

Reviewed by Darin Adler.

Source/WebCore:

According to the specification, we should not proceed regular expression
matching if a pattern attribute value is an invalid regular
expression. We had a bug that invalid expressions such as
pattern=")foo(" made RegularExpression objects successfully.

http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-pattern-attribute
> If an input element has a pattern attribute specified, and the
> attribute's value, when compiled as a JavaScript regular expression with
> the global, ignoreCase, and multiline flags disabled (see ECMA262
> Edition 5, sections 15.10.7.2 through 15.10.7.4), compiles successfully,
> then the resulting regular expression is the element's compiled pattern
> regular expression. If the element has no such attribute, or if the
> value doesn't compile successfully, then the element has no compiled
> pattern regular expression.

This imports a part of Blink r148951.

Tests: Update fast/forms/ValidityState-patternMismatch.html

* html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch):
Check correctness of pattern attribute value before wrapping with parentheses.
* platform/text/RegularExpression.cpp:
(WebCore::RegularExpression::isValid): Added.
* platform/text/RegularExpression.h:
(RegularExpression): Declare isValid.

LayoutTests:

* fast/forms/ValidityState-patternMismatch-expected.txt:
* fast/forms/ValidityState-patternMismatch.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
7 files changed