| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 2068 return plugin->setComposition(text, underlines, selectionStart, selectio
nEnd); |
| 2069 |
| 2066 // The input focus has been moved to another WebWidget object. | 2070 // The input focus has been moved to another WebWidget object. |
| 2067 // We should use this |editor| object only to complete the ongoing | 2071 // We should use this |editor| object only to complete the ongoing |
| 2068 // composition. | 2072 // composition. |
| 2069 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); | 2073 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); |
| 2070 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) | 2074 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) |
| 2071 return false; | 2075 return false; |
| 2072 | 2076 |
| 2073 // We should verify the parent node of this IME composition node are | 2077 // We should verify the parent node of this IME composition node are |
| 2074 // editable because JavaScript may delete a parent node of the composition | 2078 // editable because JavaScript may delete a parent node of the composition |
| 2075 // node. In this case, WebKit crashes while deleting texts from the parent | 2079 // node. In this case, WebKit crashes while deleting texts from the parent |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 bool WebViewImpl::confirmComposition(const WebString& text) | 2122 bool WebViewImpl::confirmComposition(const WebString& text) |
| 2119 { | 2123 { |
| 2120 return confirmComposition(text, DoNotKeepSelection); | 2124 return confirmComposition(text, DoNotKeepSelection); |
| 2121 } | 2125 } |
| 2122 | 2126 |
| 2123 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) | 2127 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) |
| 2124 { | 2128 { |
| 2125 Frame* focused = focusedWebCoreFrame(); | 2129 Frame* focused = focusedWebCoreFrame(); |
| 2126 if (!focused || !m_imeAcceptEvents) | 2130 if (!focused || !m_imeAcceptEvents) |
| 2127 return false; | 2131 return false; |
| 2132 |
| 2133 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 2134 return plugin->confirmComposition(text, selectionBehavior); |
| 2135 |
| 2128 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 2136 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); |
| 2129 } | 2137 } |
| 2130 | 2138 |
| 2131 bool WebViewImpl::compositionRange(size_t* location, size_t* length) | 2139 bool WebViewImpl::compositionRange(size_t* location, size_t* length) |
| 2132 { | 2140 { |
| 2133 Frame* focused = focusedWebCoreFrame(); | 2141 Frame* focused = focusedWebCoreFrame(); |
| 2134 if (!focused || !m_imeAcceptEvents) | 2142 if (!focused || !m_imeAcceptEvents) |
| 2135 return false; | 2143 return false; |
| 2136 | 2144 |
| 2137 RefPtr<Range> range = focused->inputMethodController().compositionRange(); | 2145 RefPtr<Range> range = focused->inputMethodController().compositionRange(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 if (!focusedFrame) | 2334 if (!focusedFrame) |
| 2327 return 0; | 2335 return 0; |
| 2328 | 2336 |
| 2329 Element* target = focusedFrame->document()->focusedElement(); | 2337 Element* target = focusedFrame->document()->focusedElement(); |
| 2330 if (target && target->hasInputMethodContext()) | 2338 if (target && target->hasInputMethodContext()) |
| 2331 return target->inputMethodContext(); | 2339 return target->inputMethodContext(); |
| 2332 | 2340 |
| 2333 return 0; | 2341 return 0; |
| 2334 } | 2342 } |
| 2335 | 2343 |
| 2344 WebPlugin* WebViewImpl::focusedPluginIfInputMethodSupported(Frame* frame) |
| 2345 { |
| 2346 WebPluginContainerImpl* container = WebFrameImpl::pluginContainerFromNode(fr
ame, WebNode(focusedElement())); |
| 2347 if (container && container->supportsInputMethod()) |
| 2348 return container->plugin(); |
| 2349 return 0; |
| 2350 } |
| 2351 |
| 2336 void WebViewImpl::didShowCandidateWindow() | 2352 void WebViewImpl::didShowCandidateWindow() |
| 2337 { | 2353 { |
| 2338 if (InputMethodContext* context = inputMethodContext()) | 2354 if (InputMethodContext* context = inputMethodContext()) |
| 2339 context->dispatchCandidateWindowShowEvent(); | 2355 context->dispatchCandidateWindowShowEvent(); |
| 2340 } | 2356 } |
| 2341 | 2357 |
| 2342 void WebViewImpl::didUpdateCandidateWindow() | 2358 void WebViewImpl::didUpdateCandidateWindow() |
| 2343 { | 2359 { |
| 2344 if (InputMethodContext* context = inputMethodContext()) | 2360 if (InputMethodContext* context = inputMethodContext()) |
| 2345 context->dispatchCandidateWindowUpdateEvent(); | 2361 context->dispatchCandidateWindowUpdateEvent(); |
| (...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4175 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4191 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
| 4176 | 4192 |
| 4177 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4193 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4178 return false; | 4194 return false; |
| 4179 | 4195 |
| 4180 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4196 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4181 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4197 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
| 4182 } | 4198 } |
| 4183 | 4199 |
| 4184 } // namespace blink | 4200 } // namespace blink |
| OLD | NEW |