Title: [122821] trunk/Tools
Revision
122821
Author
[email protected]
Date
2012-07-17 01:10:50 -0700 (Tue, 17 Jul 2012)

Log Message

[Chromium] TextInputController shouldn't know about TestShell
https://bugs.webkit.org/show_bug.cgi?id=91455

Reviewed by Kent Tamura.

This patch uses the same pattern we used for the
AccessibilityController to remove the dependency on TestShell.

* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::initialize):
(TestShell::createMainWindow):
(TestShell::~TestShell):
* DumpRenderTree/chromium/TextInputController.cpp:
(TextInputController::TextInputController):
(TextInputController::insertText):
(TextInputController::doCommand):
(TextInputController::setMarkedText):
(TextInputController::unmarkText):
(TextInputController::hasMarkedText):
(TextInputController::markedRange):
(TextInputController::selectedRange):
(TextInputController::firstRectForCharacterRange):
(TextInputController::validAttributesForMarkedText):
(TextInputController::setComposition):
* DumpRenderTree/chromium/TextInputController.h:
(WebKit):
(TextInputController):
(TextInputController::setWebView):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (122820 => 122821)


--- trunk/Tools/ChangeLog	2012-07-17 08:02:39 UTC (rev 122820)
+++ trunk/Tools/ChangeLog	2012-07-17 08:10:50 UTC (rev 122821)
@@ -1,3 +1,34 @@
+2012-07-17  Adam Barth  <[email protected]>
+
+        [Chromium] TextInputController shouldn't know about TestShell
+        https://bugs.webkit.org/show_bug.cgi?id=91455
+
+        Reviewed by Kent Tamura.
+
+        This patch uses the same pattern we used for the
+        AccessibilityController to remove the dependency on TestShell.
+
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::initialize):
+        (TestShell::createMainWindow):
+        (TestShell::~TestShell):
+        * DumpRenderTree/chromium/TextInputController.cpp:
+        (TextInputController::TextInputController):
+        (TextInputController::insertText):
+        (TextInputController::doCommand):
+        (TextInputController::setMarkedText):
+        (TextInputController::unmarkText):
+        (TextInputController::hasMarkedText):
+        (TextInputController::markedRange):
+        (TextInputController::selectedRange):
+        (TextInputController::firstRectForCharacterRange):
+        (TextInputController::validAttributesForMarkedText):
+        (TextInputController::setComposition):
+        * DumpRenderTree/chromium/TextInputController.h:
+        (WebKit):
+        (TextInputController):
+        (TextInputController::setWebView):
+
 2012-07-17  David Barr  <[email protected]>
 
         Introduce ENABLE_CSS_IMAGE_ORIENTATION compile flag

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (122820 => 122821)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2012-07-17 08:02:39 UTC (rev 122820)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2012-07-17 08:10:50 UTC (rev 122821)
@@ -150,7 +150,7 @@
     m_testInterfaces = adoptPtr(new TestInterfaces());
     m_layoutTestController = adoptPtr(new LayoutTestController(this));
     m_eventSender = adoptPtr(new EventSender(this));
-    m_textInputController = adoptPtr(new TextInputController(this));
+    m_textInputController = adoptPtr(new TextInputController());
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     m_notificationPresenter = adoptPtr(new NotificationPresenter(this));
 #endif
@@ -176,12 +176,14 @@
     m_webViewHost = adoptPtr(createNewWindow(WebURL(), m_drtDevToolsAgent.get()));
     m_webView = m_webViewHost->webView();
     m_accessibilityController->setWebView(m_webView);
+    m_textInputController->setWebView(m_webView);
     m_drtDevToolsAgent->setWebView(m_webView);
 }
 
 TestShell::~TestShell()
 {
     m_accessibilityController->setWebView(0);
+    m_textInputController->setWebView(0);
     m_drtDevToolsAgent->setWebView(0);
 }
 

Modified: trunk/Tools/DumpRenderTree/chromium/TextInputController.cpp (122820 => 122821)


--- trunk/Tools/DumpRenderTree/chromium/TextInputController.cpp	2012-07-17 08:02:39 UTC (rev 122820)
+++ trunk/Tools/DumpRenderTree/chromium/TextInputController.cpp	2012-07-17 08:10:50 UTC (rev 122821)
@@ -31,28 +31,21 @@
 #include "config.h"
 #include "TextInputController.h"
 
-#include "TestShell.h"
 #include "WebBindings.h"
 #include "WebCompositionUnderline.h"
 #include "WebFrame.h"
+#include "WebInputEvent.h"
 #include "WebRange.h"
+#include "WebView.h"
 #include "platform/WebString.h"
 #include "platform/WebVector.h"
-#include "WebView.h"
 #include <string>
 #include <wtf/StringExtras.h>
 
 using namespace WebKit;
 
-TestShell* TextInputController::testShell = 0;
-
-TextInputController::TextInputController(TestShell* shell)
+TextInputController::TextInputController()
 {
-    // Set static testShell variable. Be careful not to assign testShell to new
-    // windows which are temporary.
-    if (!testShell)
-        testShell = shell;
-
     bindMethod("attributedSubstringFromRange", &TextInputController::attributedSubstringFromRange);
     bindMethod("characterIndexForPoint", &TextInputController::characterIndexForPoint);
     bindMethod("conversationIdentifier", &TextInputController::conversationIdentifier);
@@ -70,11 +63,6 @@
     bindMethod("setComposition", &TextInputController::setComposition);
 }
 
-WebFrame* TextInputController::getMainFrame()
-{
-    return testShell->webView()->mainFrame();
-}
-
 void TextInputController::insertText(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
@@ -82,14 +70,14 @@
     if (arguments.size() < 1 || !arguments[0].isString())
         return;
 
-    testShell->webView()->confirmComposition(WebString::fromUTF8(arguments[0].toString()));
+    m_webView->confirmComposition(WebString::fromUTF8(arguments[0].toString()));
 }
 
 void TextInputController::doCommand(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
 
-    WebFrame* mainFrame = getMainFrame();
+    WebFrame* mainFrame = m_webView->mainFrame();
     if (!mainFrame)
         return;
 
@@ -104,10 +92,10 @@
     if (arguments.size() >= 3 && arguments[0].isString()
         && arguments[1].isNumber() && arguments[2].isNumber()) {
         WebVector<WebCompositionUnderline> underlines;
-        testShell->webView()->setComposition(WebString::fromUTF8(arguments[0].toString()),
-                                             underlines,
-                                             arguments[1].toInt32(),
-                                             arguments[1].toInt32() + arguments[2].toInt32());
+        m_webView->setComposition(WebString::fromUTF8(arguments[0].toString()),
+                                  underlines,
+                                  arguments[1].toInt32(),
+                                  arguments[1].toInt32() + arguments[2].toInt32());
     }
 }
 
@@ -115,14 +103,14 @@
 {
     result->setNull();
 
-    testShell->webView()->confirmComposition();
+    m_webView->confirmComposition();
 }
 
 void TextInputController::hasMarkedText(const CppArgumentList&, CppVariant* result)
 {
     result->setNull();
 
-    WebFrame* mainFrame = getMainFrame();
+    WebFrame* mainFrame = m_webView->mainFrame();
     if (!mainFrame)
         return;
 
@@ -151,7 +139,7 @@
 {
     result->setNull();
 
-    WebFrame* mainFrame = getMainFrame();
+    WebFrame* mainFrame = m_webView->mainFrame();
     if (!mainFrame)
         return;
 
@@ -166,7 +154,7 @@
 {
     result->setNull();
 
-    WebFrame* mainFrame = getMainFrame();
+    WebFrame* mainFrame = m_webView->mainFrame();
     if (!mainFrame)
         return;
 
@@ -181,7 +169,7 @@
 {
     result->setNull();
 
-    WebFrame* frame = testShell->webView()->focusedFrame();
+    WebFrame* frame = m_webView->focusedFrame();
     if (!frame)
         return;
 
@@ -210,7 +198,7 @@
 {
     result->setNull();
 
-    WebFrame* mainFrame = getMainFrame();
+    WebFrame* mainFrame = m_webView->mainFrame();
     if (!mainFrame)
         return;
 
@@ -228,10 +216,6 @@
 {
     result->setNull();
 
-    WebView* view = getMainFrame() ? getMainFrame()->view() : 0;
-    if (!view)
-        return;
-
     if (arguments.size() < 1)
         return;
 
@@ -241,9 +225,9 @@
     keyDown.modifiers = 0;
     keyDown.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY
     keyDown.setKeyIdentifierFromWindowsKeyCode();
-    view->handleInputEvent(keyDown);
+    m_webView->handleInputEvent(keyDown);
 
     WebVector<WebCompositionUnderline> underlines;
     WebString text(WebString::fromUTF8(arguments[0].toString()));
-    view->setComposition(text, underlines, 0, text.length());
+    m_webView->setComposition(text, underlines, 0, text.length());
 }

Modified: trunk/Tools/DumpRenderTree/chromium/TextInputController.h (122820 => 122821)


--- trunk/Tools/DumpRenderTree/chromium/TextInputController.h	2012-07-17 08:02:39 UTC (rev 122820)
+++ trunk/Tools/DumpRenderTree/chromium/TextInputController.h	2012-07-17 08:10:50 UTC (rev 122821)
@@ -37,16 +37,16 @@
 
 #include "CppBoundClass.h"
 
-class TestShell;
-
 namespace WebKit {
-class WebFrame;
+class WebView;
 }
 
 class TextInputController : public CppBoundClass {
 public:
-    TextInputController(TestShell*);
+    TextInputController();
 
+    void setWebView(WebKit::WebView* webView) { m_webView = webView; }
+
     void insertText(const CppArgumentList&, CppVariant*);
     void doCommand(const CppArgumentList&, CppVariant*);
     void setMarkedText(const CppArgumentList&, CppVariant*);
@@ -64,11 +64,7 @@
     void setComposition(const CppArgumentList&, CppVariant*);
 
 private:
-    // Returns the test shell's main WebFrame.
-    static WebKit::WebFrame* getMainFrame();
-
-    // Non-owning pointer. The TextInputController is owned by the TestShell.
-    static TestShell* testShell;
+    WebKit::WebView* m_webView;
 };
 
 #endif // TextInputController_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to