| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +14 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2018-03-06  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        HTML `pattern` attribute should set `u` flag for regular expressions
4
        https://bugs.webkit.org/show_bug.cgi?id=151598
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * yarr/RegularExpression.cpp:
9
        (JSC::Yarr::RegularExpression::Private::create):
10
        (JSC::Yarr::RegularExpression::Private::Private):
11
        (JSC::Yarr::RegularExpression::Private::compile):
12
        (JSC::Yarr::RegularExpression::RegularExpression):
13
        * yarr/RegularExpression.h:
14
1
2018-03-05  Yusuke Suzuki  <utatane.tea@gmail.com>
15
2018-03-05  Yusuke Suzuki  <utatane.tea@gmail.com>
2
16
3
        Fix std::make_unique / new[] using system malloc
17
        Fix std::make_unique / new[] using system malloc
- a/Source/WebCore/ChangeLog +10 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2018-03-06  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        HTML `pattern` attribute should set `u` flag for regular expressions
4
        https://bugs.webkit.org/show_bug.cgi?id=151598
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * html/BaseTextInputType.cpp:
9
        (WebCore::BaseTextInputType::patternMismatch const):
10
1
2018-03-06  Nan Wang  <n_wang@apple.com>
11
2018-03-06  Nan Wang  <n_wang@apple.com>
2
12
3
        AX: AOM: More accessibility events support
13
        AX: AOM: More accessibility events support
- a/Source/JavaScriptCore/yarr/RegularExpression.cpp -7 / +10 lines
Lines 37-45 namespace JSC { namespace Yarr { a/Source/JavaScriptCore/yarr/RegularExpression.cpp_sec1
37
37
38
class RegularExpression::Private : public RefCounted<RegularExpression::Private> {
38
class RegularExpression::Private : public RefCounted<RegularExpression::Private> {
39
public:
39
public:
40
    static Ref<Private> create(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
40
    static Ref<Private> create(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode, UnicodeCodePointMode unicodeCodePointMode)
41
    {
41
    {
42
        return adoptRef(*new Private(pattern, caseSensitivity, multilineMode));
42
        return adoptRef(*new Private(pattern, caseSensitivity, multilineMode, unicodeCodePointMode));
43
    }
43
    }
44
44
45
    int lastMatchLength { -1 };
45
    int lastMatchLength { -1 };
Lines 48-59 class RegularExpression::Private : public RefCounted<RegularExpression::Private> a/Source/JavaScriptCore/yarr/RegularExpression.cpp_sec2
48
    std::unique_ptr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
48
    std::unique_ptr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
49
49
50
private:
50
private:
51
    Private(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
51
    Private(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode, UnicodeCodePointMode unicodeCodePointMode)
52
        : m_regExpByteCode(compile(pattern, caseSensitivity, multilineMode))
52
        : m_regExpByteCode(compile(pattern, caseSensitivity, multilineMode, unicodeCodePointMode))
53
    {
53
    {
54
    }
54
    }
55
55
56
    std::unique_ptr<JSC::Yarr::BytecodePattern> compile(const String& patternString, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
56
    std::unique_ptr<JSC::Yarr::BytecodePattern> compile(const String& patternString, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode, UnicodeCodePointMode unicodeCodePointMode)
57
    {
57
    {
58
        RegExpFlags flags = NoFlags;
58
        RegExpFlags flags = NoFlags;
59
59
Lines 63-68 class RegularExpression::Private : public RefCounted<RegularExpression::Private> a/Source/JavaScriptCore/yarr/RegularExpression.cpp_sec3
63
        if (multilineMode == MultilineEnabled)
63
        if (multilineMode == MultilineEnabled)
64
            flags = static_cast<RegExpFlags>(flags | FlagMultiline);
64
            flags = static_cast<RegExpFlags>(flags | FlagMultiline);
65
65
66
        if (unicodeCodePointMode == UnicodeCodePointAware)
67
            flags = static_cast<RegExpFlags>(flags | FlagUnicode);
68
66
        JSC::Yarr::YarrPattern pattern(patternString, flags, m_constructionErrorCode);
69
        JSC::Yarr::YarrPattern pattern(patternString, flags, m_constructionErrorCode);
67
        if (JSC::Yarr::hasError(m_constructionErrorCode)) {
70
        if (JSC::Yarr::hasError(m_constructionErrorCode)) {
68
            LOG_ERROR("RegularExpression: YARR compile failed with '%s'", JSC::Yarr::errorMessage(m_constructionErrorCode));
71
            LOG_ERROR("RegularExpression: YARR compile failed with '%s'", JSC::Yarr::errorMessage(m_constructionErrorCode));
Lines 78-85 class RegularExpression::Private : public RefCounted<RegularExpression::Private> a/Source/JavaScriptCore/yarr/RegularExpression.cpp_sec4
78
    JSC::Yarr::ErrorCode m_constructionErrorCode { Yarr::ErrorCode::NoError };
81
    JSC::Yarr::ErrorCode m_constructionErrorCode { Yarr::ErrorCode::NoError };
79
};
82
};
80
83
81
RegularExpression::RegularExpression(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode)
84
RegularExpression::RegularExpression(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode, UnicodeCodePointMode unicodeCodePointMode)
82
    : d(Private::create(pattern, caseSensitivity, multilineMode))
85
    : d(Private::create(pattern, caseSensitivity, multilineMode, unicodeCodePointMode))
83
{
86
{
84
}
87
}
85
88
- a/Source/JavaScriptCore/yarr/RegularExpression.h -1 / +2 lines
Lines 31-41 namespace JSC { namespace Yarr { a/Source/JavaScriptCore/yarr/RegularExpression.h_sec1
31
31
32
enum MultilineMode { MultilineDisabled, MultilineEnabled };
32
enum MultilineMode { MultilineDisabled, MultilineEnabled };
33
enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
33
enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
34
enum UnicodeCodePointMode { UnicodeCodePointUnaware, UnicodeCodePointAware };
34
35
35
class JS_EXPORT_PRIVATE RegularExpression {
36
class JS_EXPORT_PRIVATE RegularExpression {
36
    WTF_MAKE_FAST_ALLOCATED;
37
    WTF_MAKE_FAST_ALLOCATED;
37
public:
38
public:
38
    explicit RegularExpression(const String&, TextCaseSensitivity = TextCaseSensitive, MultilineMode = MultilineDisabled);
39
    explicit RegularExpression(const String&, TextCaseSensitivity = TextCaseSensitive, MultilineMode = MultilineDisabled, UnicodeCodePointMode = UnicodeCodePointUnaware);
39
    ~RegularExpression();
40
    ~RegularExpression();
40
41
41
    RegularExpression(const RegularExpression&);
42
    RegularExpression(const RegularExpression&);
- a/Source/WebCore/html/BaseTextInputType.cpp -2 / +4 lines
Lines 39-51 bool BaseTextInputType::isTextType() const a/Source/WebCore/html/BaseTextInputType.cpp_sec1
39
39
40
bool BaseTextInputType::patternMismatch(const String& value) const
40
bool BaseTextInputType::patternMismatch(const String& value) const
41
{
41
{
42
    // FIXME: We should execute RegExp parser first to check validity instead of creating an actual RegularExpression.
43
    // https://bugs.webkit.org/show_bug.cgi?id=183361
42
    const AtomicString& rawPattern = element().attributeWithoutSynchronization(patternAttr);
44
    const AtomicString& rawPattern = element().attributeWithoutSynchronization(patternAttr);
43
    if (rawPattern.isNull() || value.isEmpty() || !JSC::Yarr::RegularExpression(rawPattern).isValid())
45
    if (rawPattern.isNull() || value.isEmpty() || !JSC::Yarr::RegularExpression(rawPattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeCodePointAware).isValid())
44
        return false;
46
        return false;
45
    String pattern = "^(?:" + rawPattern + ")$";
47
    String pattern = "^(?:" + rawPattern + ")$";
46
    int matchLength = 0;
48
    int matchLength = 0;
47
    int valueLength = value.length();
49
    int valueLength = value.length();
48
    int matchOffset = JSC::Yarr::RegularExpression(pattern).match(value, 0, &matchLength);
50
    int matchOffset = JSC::Yarr::RegularExpression(pattern, JSC::Yarr::TextCaseSensitive, JSC::Yarr::MultilineDisabled, JSC::Yarr::UnicodeCodePointAware).match(value, 0, &matchLength);
49
    return matchOffset || matchLength != valueLength;
51
    return matchOffset || matchLength != valueLength;
50
}
52
}
51
53

Return to Bug 151598