Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 102963005: Add supportsInputMethod() interface for WebPlugin. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: setComposition/confirmComposition Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "core/dom/Text.h" 81 #include "core/dom/Text.h"
82 #include "core/dom/WheelController.h" 82 #include "core/dom/WheelController.h"
83 #include "core/editing/Editor.h" 83 #include "core/editing/Editor.h"
84 #include "core/editing/FrameSelection.h" 84 #include "core/editing/FrameSelection.h"
85 #include "core/editing/InputMethodController.h" 85 #include "core/editing/InputMethodController.h"
86 #include "core/editing/TextIterator.h" 86 #include "core/editing/TextIterator.h"
87 #include "core/events/KeyboardEvent.h" 87 #include "core/events/KeyboardEvent.h"
88 #include "core/events/WheelEvent.h" 88 #include "core/events/WheelEvent.h"
89 #include "core/html/HTMLInputElement.h" 89 #include "core/html/HTMLInputElement.h"
90 #include "core/html/HTMLMediaElement.h" 90 #include "core/html/HTMLMediaElement.h"
91 #include "core/html/HTMLPlugInElement.h"
91 #include "core/html/HTMLTextAreaElement.h" 92 #include "core/html/HTMLTextAreaElement.h"
92 #include "core/html/HTMLVideoElement.h" 93 #include "core/html/HTMLVideoElement.h"
93 #include "core/html/ime/InputMethodContext.h" 94 #include "core/html/ime/InputMethodContext.h"
94 #include "core/inspector/InspectorController.h" 95 #include "core/inspector/InspectorController.h"
95 #include "core/loader/DocumentLoader.h" 96 #include "core/loader/DocumentLoader.h"
96 #include "core/loader/FrameLoader.h" 97 #include "core/loader/FrameLoader.h"
97 #include "core/loader/UniqueIdentifier.h" 98 #include "core/loader/UniqueIdentifier.h"
98 #include "core/page/Chrome.h" 99 #include "core/page/Chrome.h"
99 #include "core/page/ContextMenuController.h" 100 #include "core/page/ContextMenuController.h"
100 #include "core/page/DragController.h" 101 #include "core/page/DragController.h"
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 bool WebViewImpl::setComposition( 2057 bool WebViewImpl::setComposition(
2057 const WebString& text, 2058 const WebString& text,
2058 const WebVector<WebCompositionUnderline>& underlines, 2059 const WebVector<WebCompositionUnderline>& underlines,
2059 int selectionStart, 2060 int selectionStart,
2060 int selectionEnd) 2061 int selectionEnd)
2061 { 2062 {
2062 Frame* focused = focusedWebCoreFrame(); 2063 Frame* focused = focusedWebCoreFrame();
2063 if (!focused || !m_imeAcceptEvents) 2064 if (!focused || !m_imeAcceptEvents)
2064 return false; 2065 return false;
2065 2066
2067 WebPlugin* plugin = getFocusedPluginIfInputMethodSupported();
tkent 2013/12/10 07:22:57 nit: We can simplify the code like: if (WebPlugin
kochi 2013/12/10 08:20:56 Done.
2068 if (plugin)
2069 return plugin->setComposition(text, underlines, selectionStart, selectio nEnd);
2070
2066 // The input focus has been moved to another WebWidget object. 2071 // The input focus has been moved to another WebWidget object.
2067 // We should use this |editor| object only to complete the ongoing 2072 // We should use this |editor| object only to complete the ongoing
2068 // composition. 2073 // composition.
2069 InputMethodController& inputMethodController = focused->inputMethodControlle r(); 2074 InputMethodController& inputMethodController = focused->inputMethodControlle r();
2070 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) 2075 if (!focused->editor().canEdit() && !inputMethodController.hasComposition())
2071 return false; 2076 return false;
2072 2077
2073 // We should verify the parent node of this IME composition node are 2078 // We should verify the parent node of this IME composition node are
2074 // editable because JavaScript may delete a parent node of the composition 2079 // editable because JavaScript may delete a parent node of the composition
2075 // node. In this case, WebKit crashes while deleting texts from the parent 2080 // node. In this case, WebKit crashes while deleting texts from the parent
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 bool WebViewImpl::confirmComposition(const WebString& text) 2123 bool WebViewImpl::confirmComposition(const WebString& text)
2119 { 2124 {
2120 return confirmComposition(text, DoNotKeepSelection); 2125 return confirmComposition(text, DoNotKeepSelection);
2121 } 2126 }
2122 2127
2123 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior) 2128 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior)
2124 { 2129 {
2125 Frame* focused = focusedWebCoreFrame(); 2130 Frame* focused = focusedWebCoreFrame();
2126 if (!focused || !m_imeAcceptEvents) 2131 if (!focused || !m_imeAcceptEvents)
2127 return false; 2132 return false;
2133
2134 WebPlugin* plugin = getFocusedPluginIfInputMethodSupported();
2135 if (plugin)
2136 return plugin->confirmComposition(text, selectionBehavior);
2137
2128 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 2138 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection);
2129 } 2139 }
2130 2140
2131 bool WebViewImpl::compositionRange(size_t* location, size_t* length) 2141 bool WebViewImpl::compositionRange(size_t* location, size_t* length)
2132 { 2142 {
2133 Frame* focused = focusedWebCoreFrame(); 2143 Frame* focused = focusedWebCoreFrame();
2134 if (!focused || !m_imeAcceptEvents) 2144 if (!focused || !m_imeAcceptEvents)
2135 return false; 2145 return false;
2136 2146
2137 RefPtr<Range> range = focused->inputMethodController().compositionRange(); 2147 RefPtr<Range> range = focused->inputMethodController().compositionRange();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 if (!focusedFrame) 2336 if (!focusedFrame)
2327 return 0; 2337 return 0;
2328 2338
2329 Element* target = focusedFrame->document()->focusedElement(); 2339 Element* target = focusedFrame->document()->focusedElement();
2330 if (target && target->hasInputMethodContext()) 2340 if (target && target->hasInputMethodContext())
2331 return target->inputMethodContext(); 2341 return target->inputMethodContext();
2332 2342
2333 return 0; 2343 return 0;
2334 } 2344 }
2335 2345
2346 WebPlugin* WebViewImpl::getFocusedPluginIfInputMethodSupported()
tkent 2013/12/10 07:22:57 We usually prepend no 'get' to such function. Thi
kochi 2013/12/10 08:20:56 Removed 'get' prefix. I think I need to support P
2347 {
2348 Element* element = focusedElement();
2349 if (element && element->isPluginElement()) {
2350 WebPluginContainerImpl* container = toPluginContainerImpl(toHTMLPlugInEl ement(element)->pluginWidget());
2351 if (container && container->supportsInputMethod())
2352 return container->plugin();
2353 }
2354 return 0;
2355 }
2356
2336 void WebViewImpl::didShowCandidateWindow() 2357 void WebViewImpl::didShowCandidateWindow()
2337 { 2358 {
2338 if (InputMethodContext* context = inputMethodContext()) 2359 if (InputMethodContext* context = inputMethodContext())
2339 context->dispatchCandidateWindowShowEvent(); 2360 context->dispatchCandidateWindowShowEvent();
2340 } 2361 }
2341 2362
2342 void WebViewImpl::didUpdateCandidateWindow() 2363 void WebViewImpl::didUpdateCandidateWindow()
2343 { 2364 {
2344 if (InputMethodContext* context = inputMethodContext()) 2365 if (InputMethodContext* context = inputMethodContext())
2345 context->dispatchCandidateWindowUpdateEvent(); 2366 context->dispatchCandidateWindowUpdateEvent();
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4175 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4196 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4176 4197
4177 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4198 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4178 return false; 4199 return false;
4179 4200
4180 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4201 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4181 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4202 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4182 } 4203 }
4183 4204
4184 } // namespace blink 4205 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698