| Index: webkit/support/test_webkit_platform_support.cc
|
| ===================================================================
|
| --- webkit/support/test_webkit_platform_support.cc (revision 121358)
|
| +++ webkit/support/test_webkit_platform_support.cc (working copy)
|
| @@ -406,6 +406,76 @@
|
| return new WebAudioDeviceMock(sampleRate);
|
| }
|
|
|
| +bool TestWebKitPlatformSupport::canHyphenate(const WebKit::WebString& locale) {
|
| + // As of February 2012, DumpRenderTree needs to support English only.
|
| + return locale.isEmpty() || locale.equals("en") || locale.equals("en_US") ||
|
| + locale.equals("en_GB");
|
| +}
|
| +
|
| +size_t TestWebKitPlatformSupport::lastHyphenLocation(
|
| + const char16* characters,
|
| + size_t length,
|
| + size_t index,
|
| + const WebKit::WebString& locale) {
|
| + // A list of hyphenation queries and their results used by DumpRenderTree. To
|
| + // emulate Mac Safari, this list is created with the following steps:
|
| + // 1. Run LayoutTests of Mac Safari;
|
| + // 2. collect its hyphenation queries, and;
|
| + // 3. Pack the results for the same text.
|
| + // (When a query always returns 0, its indices becomes an empty string.)
|
| + // Therefore, these results do not always represent gramatically-correct
|
| + // locations. For example, we can insert two hyphens to a word "ev-i-dence"
|
| + // even though this list does not allow inserting them.
|
| + static const struct {
|
| + const char* query;
|
| + const char* results;
|
| + } kQueries[] = {
|
| + { " and", "" },
|
| + { " concupiscent,", "" },
|
| + { " evidence.", "" },
|
| + { " first", "" },
|
| + { " getting", "\x04" },
|
| + { " hedgehog", "\x06" },
|
| + { " remarkable", "\x03\x07" },
|
| + { " straightened", "\x09" },
|
| + { " undid", "\x03" },
|
| + { " were", "" },
|
| + { "Simply", "\x03" },
|
| + { "Undone.", "" },
|
| + { "comfortably", "\x03" },
|
| + { "declination", "\x03" },
|
| + { "flamingo:", "" },
|
| + { "lination", "\x04" },
|
| + { "reciprocity", "\x04" },
|
| + { "throughout", "\x07" },
|
| + { "undid", "\x02" },
|
| + { "undone.", "" },
|
| + { "unnecessary", "\x02" },
|
| + };
|
| +
|
| + // Find a matching query. If we have a matching query, we return the largest
|
| + // index in the indices less than the given index.
|
| + WebKit::WebString word(characters, length);
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kQueries); ++i) {
|
| + if (word != WebKit::WebString::fromUTF8(kQueries[i].query))
|
| + continue;
|
| + const char* results = kQueries[i].results;
|
| + size_t previous = 0;
|
| + size_t next = 0;
|
| + while ((next = *results++) != '\0') {
|
| + if (next >= index)
|
| + break;
|
| + previous = next;
|
| + }
|
| + return previous;
|
| + }
|
| +
|
| + // DumpRenderTree sends a query not supported by this function. This case
|
| + // happens probably when WebKit adds new layout tests that needs hyphenation.
|
| + NOTIMPLEMENTED();
|
| + return 0;
|
| +}
|
| +
|
| void TestWebKitPlatformSupport::sampleGamepads(WebKit::WebGamepads& data) {
|
| data = gamepad_data_;
|
| }
|
|
|