diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
commit | 49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch) | |
tree | 5410cb9a8fd53168bb60d62c54b654d86f03c38d /Tools/DumpRenderTree/chromium | |
parent | b211c645d8ab690f713515dfdc84d80b11c27d2c (diff) | |
download | qtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz |
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Tools/DumpRenderTree/chromium')
17 files changed, 417 insertions, 41 deletions
diff --git a/Tools/DumpRenderTree/chromium/EventSender.cpp b/Tools/DumpRenderTree/chromium/EventSender.cpp index 05e4eb83f..47bec2a71 100644 --- a/Tools/DumpRenderTree/chromium/EventSender.cpp +++ b/Tools/DumpRenderTree/chromium/EventSender.cpp @@ -287,6 +287,7 @@ EventSender::EventSender(TestShell* shell) bindMethod("gestureScrollUpdate", &EventSender::gestureScrollUpdate); bindMethod("gestureTap", &EventSender::gestureTap); bindMethod("gestureLongPress", &EventSender::gestureLongPress); + bindMethod("gestureTwoFingerTap", &EventSender::gestureTwoFingerTap); bindMethod("zoomPageIn", &EventSender::zoomPageIn); bindMethod("zoomPageOut", &EventSender::zoomPageOut); bindMethod("scalePageBy", &EventSender::scalePageBy); @@ -1117,6 +1118,12 @@ void EventSender::gestureLongPress(const CppArgumentList& arguments, CppVariant* gestureEvent(WebInputEvent::GestureLongPress, arguments); } +void EventSender::gestureTwoFingerTap(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + gestureEvent(WebInputEvent::GestureTwoFingerTap, arguments); +} + void EventSender::gestureScrollFirstPoint(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); @@ -1170,6 +1177,10 @@ void EventSender::gestureEvent(WebInputEvent::Type type, const CppArgumentList& event.x = point.x; event.y = point.y; break; + case WebInputEvent::GestureTwoFingerTap: + event.x = point.x; + event.y = point.y; + break; default: ASSERT_NOT_REACHED(); } diff --git a/Tools/DumpRenderTree/chromium/EventSender.h b/Tools/DumpRenderTree/chromium/EventSender.h index bc8a6baa0..9de2f760b 100644 --- a/Tools/DumpRenderTree/chromium/EventSender.h +++ b/Tools/DumpRenderTree/chromium/EventSender.h @@ -105,6 +105,7 @@ public: void gestureScrollUpdate(const CppArgumentList&, CppVariant*); void gestureTap(const CppArgumentList&, CppVariant*); void gestureLongPress(const CppArgumentList&, CppVariant*); + void gestureTwoFingerTap(const CppArgumentList&, CppVariant*); void gestureEvent(WebKit::WebInputEvent::Type, const CppArgumentList&); // Unimplemented stubs diff --git a/Tools/DumpRenderTree/chromium/ImageDiff.cpp b/Tools/DumpRenderTree/chromium/ImageDiff.cpp index 966554bab..906813d9c 100644 --- a/Tools/DumpRenderTree/chromium/ImageDiff.cpp +++ b/Tools/DumpRenderTree/chromium/ImageDiff.cpp @@ -34,8 +34,6 @@ // The exact format of this tool's output to stdout is important, to match // what the run-webkit-tests script expects. -#include "config.h" - #include "webkit/support/webkit_support_gfx.h" #include <algorithm> #include <iterator> @@ -44,12 +42,13 @@ #include <string.h> #include <vector> -#if OS(WINDOWS) +#if defined(_WIN32) #include <windows.h> #define PATH_MAX MAX_PATH +#define strtok_r strtok_s #endif -// Define macro here to make ImageDiff independent of JavaScriptCore. +// Define macro here to make ImageDiff independent of WTF. #ifdef NDEBUG #define ASSERT(assertion) do { } while (0) #else @@ -342,13 +341,8 @@ int untestedCompareImages(ImageComparisonProc comparator) while (fgets(buffer, sizeof(buffer), stdin)) { if (!strncmp("Content-length: ", buffer, 16)) { char* context; -#if OS(WINDOWS) - strtok_s(buffer, " ", &context); - int imageSize = strtol(strtok_s(0, " ", &context), 0, 10); -#else strtok_r(buffer, " ", &context); int imageSize = strtol(strtok_r(0, " ", &context), 0, 10); -#endif bool success = false; if (imageSize > 0 && !actualImage.hasImage()) { diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp index c739143e0..120197e25 100644 --- a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -34,6 +34,7 @@ #include "DRTDevToolsAgent.h" #include "MockWebSpeechInputController.h" +#include "MockWebSpeechRecognizer.h" #include "TestShell.h" #include "WebAnimationController.h" #include "WebBindings.h" @@ -77,6 +78,10 @@ #include <wtf/OwnArrayPtr.h> #endif +#if OS(LINUX) || OS(ANDROID) +#include "linux/WebFontRendering.h" +#endif + using namespace WebCore; using namespace WebKit; using namespace std; @@ -110,12 +115,15 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult); bindMethod("setMockSpeechInputDumpRect", &LayoutTestController::setMockSpeechInputDumpRect); #endif +#if ENABLE(SCRIPTED_SPEECH) + bindMethod("addMockSpeechRecognitionResult", &LayoutTestController::addMockSpeechRecognitionResult); + bindMethod("setMockSpeechRecognitionError", &LayoutTestController::setMockSpeechRecognitionError); +#endif bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry); bindMethod("addUserScript", &LayoutTestController::addUserScript); bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet); bindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases); bindMethod("closeWebInspector", &LayoutTestController::closeWebInspector); - bindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById); #if ENABLE(POINTER_LOCK) bindMethod("didLosePointerLock", &LayoutTestController::didLosePointerLock); #endif @@ -211,6 +219,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("setPrinting", &LayoutTestController::setPrinting); bindMethod("setScrollbarPolicy", &LayoutTestController::setScrollbarPolicy); bindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSelectTrailingWhitespaceEnabled); + bindMethod("setTextSubpixelPositioning", &LayoutTestController::setTextSubpixelPositioning); bindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInsertDeleteEnabled); bindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvisionalFrameLoads); bindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements); @@ -692,6 +701,9 @@ void LayoutTestController::reset() m_taskList.revokeAll(); m_shouldStayOnPageAfterHandlingBeforeUnload = false; m_hasCustomFullScreenBehavior = false; +#if OS(LINUX) || OS(ANDROID) + WebFontRendering::setSubpixelPositioning(false); +#endif } void LayoutTestController::locationChangeDone() @@ -1644,20 +1656,6 @@ void LayoutTestController::setPOSIXLocale(const CppArgumentList& arguments, CppV setlocale(LC_ALL, arguments[0].toString().c_str()); } -void LayoutTestController::counterValueForElementById(const CppArgumentList& arguments, CppVariant* result) -{ - result->setNull(); - if (arguments.size() < 1 || !arguments[0].isString()) - return; - WebFrame* frame = m_shell->webView()->mainFrame(); - if (!frame) - return; - WebString counterValue = frame->counterValueForElementById(cppVariantToWebString(arguments[0])); - if (counterValue.isNull()) - return; - result->set(counterValue.utf8()); -} - // Parse a single argument. The method returns true if there is an argument that // is a number or if there is no argument at all. It returns false only if there // is some argument that is not a number. The value parameter is filled with the @@ -1874,7 +1872,15 @@ void LayoutTestController::setMockDeviceOrientation(const CppArgumentList& argum if (arguments.size() < 6 || !arguments[0].isBool() || !arguments[1].isNumber() || !arguments[2].isBool() || !arguments[3].isNumber() || !arguments[4].isBool() || !arguments[5].isNumber()) return; - WebDeviceOrientation orientation(arguments[0].toBoolean(), arguments[1].toDouble(), arguments[2].toBoolean(), arguments[3].toDouble(), arguments[4].toBoolean(), arguments[5].toDouble()); + WebDeviceOrientation orientation; + orientation.setNull(false); + if (arguments[0].toBoolean()) + orientation.setAlpha(arguments[1].toDouble()); + if (arguments[2].toBoolean()) + orientation.setBeta(arguments[3].toDouble()); + if (arguments[4].toBoolean()) + orientation.setGamma(arguments[5].toDouble()); + // Note that we only call setOrientation on the main page's mock since this is all that the // tests require. If necessary, we could get a list of WebViewHosts from the TestShell and // call setOrientation on each DeviceOrientationClientMock. @@ -1940,6 +1946,28 @@ void LayoutTestController::setMockSpeechInputDumpRect(const CppArgumentList& arg } #endif +#if ENABLE(SCRIPTED_SPEECH) +void LayoutTestController::addMockSpeechRecognitionResult(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isNumber()) + return; + + if (MockWebSpeechRecognizer* recognizer = m_shell->webViewHost()->mockSpeechRecognizer()) + recognizer->addMockResult(cppVariantToWebString(arguments[0]), arguments[1].toDouble()); +} + +void LayoutTestController::setMockSpeechRecognitionError(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isString()) + return; + + if (MockWebSpeechRecognizer* recognizer = m_shell->webViewHost()->mockSpeechRecognizer()) + recognizer->setError(arguments[0].toInt32(), cppVariantToWebString(arguments[1])); +} +#endif + void LayoutTestController::startSpeechInput(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); @@ -2159,9 +2187,20 @@ void LayoutTestController::deliverWebIntent(const CppArgumentList& arguments, Cp WebSerializedScriptValue serializedData = WebSerializedScriptValue::serialize( v8::String::New(data.data(), data.length())); - WebIntent intent(action, type, serializedData.toString()); + WebIntent intent = WebIntent::create(action, type, serializedData.toString(), WebVector<WebString>(), WebVector<WebString>()); + + m_shell->webView()->mainFrame()->deliverIntent(intent, 0, m_intentClient.get()); +} - m_shell->webView()->mainFrame()->deliverIntent(intent, m_intentClient.get()); +void LayoutTestController::setTextSubpixelPositioning(const CppArgumentList& arguments, CppVariant* result) +{ +#if OS(LINUX) || OS(ANDROID) + // Since FontConfig doesn't provide a variable to control subpixel positioning, we'll fall back + // to setting it globally for all fonts. + if (arguments.size() > 0 && arguments[0].isBool()) + WebFontRendering::setSubpixelPositioning(arguments[0].value.boolValue); +#endif + result->setNull(); } void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result) diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.h b/Tools/DumpRenderTree/chromium/LayoutTestController.h index 37978657e..5a8729388 100644 --- a/Tools/DumpRenderTree/chromium/LayoutTestController.h +++ b/Tools/DumpRenderTree/chromium/LayoutTestController.h @@ -324,9 +324,6 @@ public: // Resets between tests. void setPOSIXLocale(const CppArgumentList&, CppVariant*); - // Gets the value of the counter in the element specified by its ID. - void counterValueForElementById(const CppArgumentList&, CppVariant*); - // Causes layout to happen as if targetted to printed pages. void setPrinting(const CppArgumentList&, CppVariant*); @@ -375,6 +372,10 @@ public: void addMockSpeechInputResult(const CppArgumentList&, CppVariant*); void setMockSpeechInputDumpRect(const CppArgumentList&, CppVariant*); #endif +#if ENABLE(SCRIPTED_SPEECH) + void addMockSpeechRecognitionResult(const CppArgumentList&, CppVariant*); + void setMockSpeechRecognitionError(const CppArgumentList&, CppVariant*); +#endif void startSpeechInput(const CppArgumentList&, CppVariant*); void layerTreeAsText(const CppArgumentList& args, CppVariant* result); @@ -444,6 +445,13 @@ public: // Cause the web intent to be delivered to this context. void deliverWebIntent(const CppArgumentList&, CppVariant*); + // Enables or disables subpixel positioning (i.e. fractional X positions for + // glyphs) in text rendering on Linux. Since this method changes global + // settings, tests that call it must use their own custom font family for + // all text that they render. If not, an already-cached style will be used, + // resulting in the changed setting being ignored. + void setTextSubpixelPositioning(const CppArgumentList&, CppVariant*); + public: // The following methods are not exposed to JavaScript. void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); } diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp new file mode 100644 index 000000000..b53e1701f --- /dev/null +++ b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "MockWebSpeechRecognizer.h" + +#if ENABLE(SCRIPTED_SPEECH) + +#include "WebSpeechRecognitionResult.h" +#include "WebSpeechRecognizerClient.h" + +using namespace WebKit; + +namespace { + +// Task class for calling a client function that does not take any parameters. +typedef void (WebSpeechRecognizerClient::*ClientFunctionPointer)(const WebSpeechRecognitionHandle&); +class ClientCallTask : public MethodTask<MockWebSpeechRecognizer> { +public: + ClientCallTask(MockWebSpeechRecognizer* mock, ClientFunctionPointer function) + : MethodTask<MockWebSpeechRecognizer>(mock) + , m_function(function) + { + } + + virtual void runIfValid() OVERRIDE { (m_object->client()->*m_function)(m_object->handle()); } + +private: + ClientFunctionPointer m_function; +}; + +// Task for delivering a result event. +class ResultTask : public MethodTask<MockWebSpeechRecognizer> { +public: + ResultTask(MockWebSpeechRecognizer* mock, const WebString transcript, float confidence) + : MethodTask<MockWebSpeechRecognizer>(mock) + , m_transcript(transcript) + , m_confidence(confidence) + { + } + + virtual void runIfValid() OVERRIDE + { + WebVector<WebString> transcripts(static_cast<size_t>(1)); + WebVector<float> confidences(static_cast<size_t>(1)); + transcripts[0] = m_transcript; + confidences[0] = m_confidence; + WebSpeechRecognitionResult res; + res.assign(transcripts, confidences, true); + + m_object->client()->didReceiveResult(m_object->handle(), res, 0, WebVector<WebSpeechRecognitionResult>()); + } + +private: + WebString m_transcript; + float m_confidence; +}; + +// Task for delivering a nomatch event. +class NoMatchTask : public MethodTask<MockWebSpeechRecognizer> { +public: + NoMatchTask(MockWebSpeechRecognizer* mock) : MethodTask<MockWebSpeechRecognizer>(mock) { } + virtual void runIfValid() OVERRIDE { m_object->client()->didReceiveNoMatch(m_object->handle(), WebSpeechRecognitionResult()); } +}; + +// Task for delivering an error event. +class ErrorTask : public MethodTask<MockWebSpeechRecognizer> { +public: + ErrorTask(MockWebSpeechRecognizer* mock, int code, const WebString& message) + : MethodTask<MockWebSpeechRecognizer>(mock) + , m_code(code) + , m_message(message) + { + } + + virtual void runIfValid() OVERRIDE { m_object->client()->didReceiveError(m_object->handle(), m_message, static_cast<WebSpeechRecognizerClient::ErrorCode>(m_code)); } + +private: + int m_code; + WebString m_message; +}; + +} // namespace + +PassOwnPtr<MockWebSpeechRecognizer> MockWebSpeechRecognizer::create() +{ + return adoptPtr(new MockWebSpeechRecognizer()); +} + +void MockWebSpeechRecognizer::start(const WebSpeechRecognitionHandle& handle, const WebSpeechRecognitionParams& params, WebSpeechRecognizerClient* client) +{ + m_handle = handle; + m_client = client; + + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didStart)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didStartAudio)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didStartSound)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didStartSpeech)); + + if (!m_mockTranscripts.isEmpty()) { + ASSERT(m_mockTranscripts.size() == m_mockConfidences.size()); + + for (size_t i = 0; i < m_mockTranscripts.size(); ++i) + postTask(new ResultTask(this, m_mockTranscripts[i], m_mockConfidences[i])); + + m_mockTranscripts.clear(); + m_mockConfidences.clear(); + } else + postTask(new NoMatchTask(this)); + + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didEndSpeech)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didEndSound)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didEndAudio)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didEnd)); +} + +void MockWebSpeechRecognizer::stop(const WebSpeechRecognitionHandle& handle, WebSpeechRecognizerClient* client) +{ + m_handle = handle; + m_client = client; + + // FIXME: Implement. + ASSERT_NOT_REACHED(); +} + +void MockWebSpeechRecognizer::abort(const WebSpeechRecognitionHandle& handle, WebSpeechRecognizerClient* client) +{ + m_handle = handle; + m_client = client; + + // FIXME: Implement. + ASSERT_NOT_REACHED(); +} + +void MockWebSpeechRecognizer::addMockResult(const WebString& transcript, float confidence) +{ + m_mockTranscripts.append(transcript); + m_mockConfidences.append(confidence); +} + +void MockWebSpeechRecognizer::setError(int code, const WebString& message) +{ + m_taskList.revokeAll(); + postTask(new ErrorTask(this, code, message)); + postTask(new ClientCallTask(this, &WebSpeechRecognizerClient::didEnd)); +} + +MockWebSpeechRecognizer::MockWebSpeechRecognizer() +{ +} + +MockWebSpeechRecognizer::~MockWebSpeechRecognizer() +{ +} + + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h new file mode 100644 index 000000000..939497686 --- /dev/null +++ b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MockWebSpeechRecognizer_h +#define MockWebSpeechRecognizer_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "Task.h" +#include "WebSpeechRecognizer.h" +#include <wtf/Compiler.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/Vector.h> + +namespace WebKit { +class WebSpeechRecognitionHandle; +class WebSpeechRecognitionParams; +class WebSpeechRecognizerClient; +} + +class MockWebSpeechRecognizer : public WebKit::WebSpeechRecognizer { +public: + static PassOwnPtr<MockWebSpeechRecognizer> create(); + ~MockWebSpeechRecognizer(); + + // WebSpeechRecognizer implementation: + virtual void start(const WebKit::WebSpeechRecognitionHandle&, const WebKit::WebSpeechRecognitionParams&, WebKit::WebSpeechRecognizerClient*) OVERRIDE; + virtual void stop(const WebKit::WebSpeechRecognitionHandle&, WebKit::WebSpeechRecognizerClient*) OVERRIDE; + virtual void abort(const WebKit::WebSpeechRecognitionHandle&, WebKit::WebSpeechRecognizerClient*) OVERRIDE; + + // Methods accessed by layout tests: + void addMockResult(const WebKit::WebString& transcript, float confidence); + void setError(int code, const WebKit::WebString& message); + + TaskList* taskList() { return &m_taskList; } + WebKit::WebSpeechRecognizerClient* client() { return m_client; } + WebKit::WebSpeechRecognitionHandle& handle() { return m_handle; } + +private: + MockWebSpeechRecognizer(); + + TaskList m_taskList; + WebKit::WebSpeechRecognitionHandle m_handle; + WebKit::WebSpeechRecognizerClient* m_client; + Vector<WebKit::WebString> m_mockTranscripts; + Vector<float> m_mockConfidences; +}; + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // MockWebSpeechRecognizer_h diff --git a/Tools/DumpRenderTree/chromium/TestShell.cpp b/Tools/DumpRenderTree/chromium/TestShell.cpp index 9b9ca4a5b..b8323a39b 100644 --- a/Tools/DumpRenderTree/chromium/TestShell.cpp +++ b/Tools/DumpRenderTree/chromium/TestShell.cpp @@ -114,7 +114,6 @@ TestShell::TestShell() , m_accelerated2dCanvasEnabled(false) , m_deferred2dCanvasEnabled(false) , m_acceleratedPaintingEnabled(false) - , m_perTilePaintingEnabled(false) , m_stressOpt(false) , m_stressDeopt(false) , m_dumpWhenFinished(true) @@ -231,7 +230,6 @@ void TestShell::resetWebSettings(WebView& webView) m_prefs.accelerated2dCanvasEnabled = m_accelerated2dCanvasEnabled; m_prefs.deferred2dCanvasEnabled = m_deferred2dCanvasEnabled; m_prefs.acceleratedPaintingEnabled = m_acceleratedPaintingEnabled; - m_prefs.perTilePaintingEnabled = m_perTilePaintingEnabled; m_prefs.applyTo(&webView); } @@ -377,6 +375,11 @@ void TestShell::testTimedOut() testFinished(); } +void TestShell::setPerTilePaintingEnabled(bool enabled) +{ + WebCompositor::setPerTilePaintingEnabled(enabled); +} + static string dumpDocumentText(WebFrame* frame) { // We use the document element's text instead of the body text here because @@ -726,6 +729,7 @@ void TestShell::bindJSObjectsToWindow(WebFrame* frame) m_accessibilityController->bindToJavascript(frame, WebString::fromUTF8("accessibilityController")); m_gamepadController->bindToJavascript(frame, WebString::fromUTF8("gamepadController")); m_layoutTestController->bindToJavascript(frame, WebString::fromUTF8("layoutTestController")); + m_layoutTestController->bindToJavascript(frame, WebString::fromUTF8("testRunner")); m_eventSender->bindToJavascript(frame, WebString::fromUTF8("eventSender")); m_textInputController->bindToJavascript(frame, WebString::fromUTF8("textInputController")); } diff --git a/Tools/DumpRenderTree/chromium/TestShell.h b/Tools/DumpRenderTree/chromium/TestShell.h index ae9d8d8a1..8ae0c2421 100644 --- a/Tools/DumpRenderTree/chromium/TestShell.h +++ b/Tools/DumpRenderTree/chromium/TestShell.h @@ -142,7 +142,7 @@ public: void setAccelerated2dCanvasEnabled(bool enabled) { m_accelerated2dCanvasEnabled = enabled; } void setDeferred2dCanvasEnabled(bool enabled) { m_deferred2dCanvasEnabled = enabled; } void setAcceleratedPaintingEnabled(bool enabled) { m_acceleratedPaintingEnabled = enabled; } - void setPerTilePaintingEnabled(bool enabled) { m_perTilePaintingEnabled = enabled; } + void setPerTilePaintingEnabled(bool); #if defined(OS_WIN) // Access to the finished event. Used by the static WatchDog thread. HANDLE finishedEvent() { return m_finishedEvent; } diff --git a/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp b/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp index e77d80d48..ba182bbbb 100644 --- a/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp +++ b/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "TestShell.h" +#include "linux/WebFontRendering.h" #include <android/log.h> #include <errno.h> #include <fcntl.h> @@ -127,4 +128,8 @@ void platformInit(int* argc, char*** argv) // Redirect stderr to stdout. dup2(1, 2); } + + // Disable auto hint and use normal hinting in layout test mode to produce the same font metrics as chromium-linux. + WebKit::WebFontRendering::setAutoHint(false); + WebKit::WebFontRendering::setHinting(SkPaint::kNormal_Hinting); } diff --git a/Tools/DumpRenderTree/chromium/TestWebPlugin.h b/Tools/DumpRenderTree/chromium/TestWebPlugin.h index 8581288ac..4c9f2f4d2 100644 --- a/Tools/DumpRenderTree/chromium/TestWebPlugin.h +++ b/Tools/DumpRenderTree/chromium/TestWebPlugin.h @@ -68,6 +68,7 @@ public: virtual void didFailLoading(const WebKit::WebURLError&) { } virtual void didFinishLoadingFrameRequest(const WebKit::WebURL&, void* notifyData) { } virtual void didFailLoadingFrameRequest(const WebKit::WebURL&, void* notifyData, const WebKit::WebURLError&) { } + virtual bool isPlaceholder() { return false; } private: enum Primitive { diff --git a/Tools/DumpRenderTree/chromium/WebPreferences.cpp b/Tools/DumpRenderTree/chromium/WebPreferences.cpp index 3227c0231..751dfeeb5 100644 --- a/Tools/DumpRenderTree/chromium/WebPreferences.cpp +++ b/Tools/DumpRenderTree/chromium/WebPreferences.cpp @@ -117,7 +117,6 @@ void WebPreferences::reset() acceleratedPaintingEnabled = false; forceCompositingMode = false; hixie76WebSocketProtocolEnabled = true; - perTilePaintingEnabled = false; mockScrollbarsEnabled = false; cssCustomFilterEnabled = false; } @@ -226,7 +225,6 @@ void WebPreferences::applyTo(WebView* webView) settings->setDeferred2dCanvasEnabled(deferred2dCanvasEnabled); settings->setAcceleratedPaintingEnabled(acceleratedPaintingEnabled); settings->setHixie76WebSocketProtocolEnabled(hixie76WebSocketProtocolEnabled); - settings->setPerTilePaintingEnabled(perTilePaintingEnabled); settings->setMockScrollbarsEnabled(mockScrollbarsEnabled); // Fixed values. diff --git a/Tools/DumpRenderTree/chromium/WebPreferences.h b/Tools/DumpRenderTree/chromium/WebPreferences.h index 31de331ed..6e951feb3 100644 --- a/Tools/DumpRenderTree/chromium/WebPreferences.h +++ b/Tools/DumpRenderTree/chromium/WebPreferences.h @@ -110,7 +110,6 @@ struct WebPreferences { bool deferred2dCanvasEnabled; bool acceleratedPaintingEnabled; bool hixie76WebSocketProtocolEnabled; - bool perTilePaintingEnabled; bool mockScrollbarsEnabled; bool cssCustomFilterEnabled; diff --git a/Tools/DumpRenderTree/chromium/WebThemeEngineDRTWin.cpp b/Tools/DumpRenderTree/chromium/WebThemeEngineDRTWin.cpp index 789b1c816..831c354fa 100755 --- a/Tools/DumpRenderTree/chromium/WebThemeEngineDRTWin.cpp +++ b/Tools/DumpRenderTree/chromium/WebThemeEngineDRTWin.cpp @@ -51,7 +51,7 @@ static const int dfcsNormal = 0x0000; static SkIRect webRectToSkIRect(const WebRect& webRect) { SkIRect irect; - irect.set(webRect.x, webRect.y, webRect.x + webRect.width, webRect.y + webRect.height); + irect.set(webRect.x, webRect.y, webRect.x + webRect.width - 1, webRect.y + webRect.height - 1); return irect; } diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp index 6c48bc1e1..88e07378f 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp @@ -34,6 +34,7 @@ #include "LayoutTestController.h" #include "MockGrammarCheck.h" #include "MockWebSpeechInputController.h" +#include "MockWebSpeechRecognizer.h" #include "TestNavigationController.h" #include "TestShell.h" #include "TestWebPlugin.h" @@ -261,6 +262,7 @@ WebWidget* WebViewHost::createPopupMenu(WebPopupType type) switch (type) { case WebKit::WebPopupTypeNone: case WebKit::WebPopupTypePage: + case WebKit::WebPopupTypeHelperPlugin: break; case WebKit::WebPopupTypeSelect: case WebKit::WebPopupTypeSuggestion: @@ -286,7 +288,7 @@ WebKit::WebGraphicsContext3D* WebViewHost::createGraphicsContext3D(const WebKit: { if (!webView()) return 0; - return webkit_support::CreateGraphicsContext3D(attributes, webView(), true); + return webkit_support::CreateGraphicsContext3D(attributes, webView()); } void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine) @@ -465,6 +467,32 @@ void WebViewHost::spellCheck(const WebString& text, int& misspelledOffset, int& m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength); } +void WebViewHost::checkTextOfParagraph(const WebString& text, WebTextCheckingTypeMask mask, WebVector<WebTextCheckingResult>* webResults) +{ + Vector<WebTextCheckingResult> results; + if (mask & WebTextCheckingTypeSpelling) { + size_t offset = 0; + size_t length = text.length(); + const WebUChar* data = text.data(); + while (offset < length) { + int misspelledPosition = 0; + int misspelledLength = 0; + m_spellcheck.spellCheckWord(WebString(&data[offset], length - offset), &misspelledPosition, &misspelledLength); + if (!misspelledLength) + break; + WebTextCheckingResult result; + result.type = WebTextCheckingTypeSpelling; + result.location = offset + misspelledPosition; + result.length = misspelledLength; + results.append(result); + offset += misspelledPosition + misspelledLength; + } + } + if (mask & WebTextCheckingTypeGrammar) + MockGrammarCheck::checkGrammarOfString(text, &results); + webResults->assign(results); +} + void WebViewHost::requestCheckingOfText(const WebString& text, WebTextCheckingCompletion* completion) { if (text.isEmpty()) { @@ -714,6 +742,15 @@ WebSpeechInputController* WebViewHost::speechInputController(WebKit::WebSpeechIn } #endif +#if ENABLE(SCRIPTED_SPEECH) +WebSpeechRecognizer* WebViewHost::speechRecognizer() +{ + if (!m_mockSpeechRecognizer) + m_mockSpeechRecognizer = MockWebSpeechRecognizer::create(); + return m_mockSpeechRecognizer.get(); +} +#endif + WebDeviceOrientationClientMock* WebViewHost::deviceOrientationClientMock() { if (!m_deviceOrientationClientMock.get()) @@ -857,9 +894,10 @@ void WebViewHost::didNotAcquirePointerLock() void WebViewHost::didLosePointerLock() { - ASSERT(m_pointerLocked); + bool wasLocked = m_pointerLocked; m_pointerLocked = false; - webWidget()->didLosePointerLock(); + if (wasLocked) + webWidget()->didLosePointerLock(); } #endif diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h index 21dbb4c8d..ce189d915 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.h +++ b/Tools/DumpRenderTree/chromium/WebViewHost.h @@ -48,6 +48,7 @@ class LayoutTestController; class MockWebSpeechInputController; +class MockWebSpeechRecognizer; class SkCanvas; class TestShell; @@ -117,6 +118,10 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, MockWebSpeechInputController* speechInputControllerMock() { return m_speechInputControllerMock.get(); } #endif +#if ENABLE(SCRIPTED_SPEECH) + MockWebSpeechRecognizer* mockSpeechRecognizer() { return m_mockSpeechRecognizer.get(); } +#endif + #if ENABLE(POINTER_LOCK) void didLosePointerLock(); void setPointerLockWillFailAsynchronously() { m_pointerLockPlannedResult = PointerLockWillFailAsync; } @@ -131,6 +136,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, // WebKit::WebSpellCheckClient virtual void spellCheck(const WebKit::WebString&, int& offset, int& length, WebKit::WebVector<WebKit::WebString>* optionalSuggestions); + virtual void checkTextOfParagraph(const WebKit::WebString&, WebKit::WebTextCheckingTypeMask, WebKit::WebVector<WebKit::WebTextCheckingResult>*); virtual void requestCheckingOfText(const WebKit::WebString&, WebKit::WebTextCheckingCompletion*); virtual WebKit::WebString autoCorrectWord(const WebKit::WebString&); @@ -176,7 +182,10 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, #if ENABLE(INPUT_SPEECH) virtual WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*); #endif - virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient(); +#if ENABLE(SCRIPTED_SPEECH) + virtual WebKit::WebSpeechRecognizer* speechRecognizer() OVERRIDE; +#endif + virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient() OVERRIDE; #if ENABLE(MEDIA_STREAM) virtual WebKit::WebUserMediaClient* userMediaClient(); #endif @@ -412,6 +421,10 @@ private: OwnPtr<MockWebSpeechInputController> m_speechInputControllerMock; #endif +#if ENABLE(SCRIPTED_SPEECH) + OwnPtr<MockWebSpeechRecognizer> m_mockSpeechRecognizer; +#endif + #if ENABLE(MEDIA_STREAM) OwnPtr<WebKit::WebUserMediaClientMock> m_userMediaClientMock; OwnPtr<webkit_support::TestMediaStreamClient> m_testMediaStreamClient; diff --git a/Tools/DumpRenderTree/chromium/fonts.conf b/Tools/DumpRenderTree/chromium/fonts.conf index b75a9322e..8e4f8d712 100644 --- a/Tools/DumpRenderTree/chromium/fonts.conf +++ b/Tools/DumpRenderTree/chromium/fonts.conf @@ -226,4 +226,17 @@ </edit> </match> + <match target="pattern"> + <!-- FontConfig doesn't currently provide a well-defined way to turn on + subpixel positioning. This is just an arbitrary pattern to use after + turning subpixel positioning on globally to ensure that we don't have + issues with our style getting cached for other tests. --> + <test name="family" compare="eq"> + <string>SubpixelPositioning</string> + </test> + <edit name="family" mode="assign"> + <string>Times New Roman</string> + </edit> + </match> + </fontconfig> |