| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 #include "web/LinkHighlightImpl.h" | 166 #include "web/LinkHighlightImpl.h" |
| 167 #include "web/PageOverlay.h" | 167 #include "web/PageOverlay.h" |
| 168 #include "web/PrerendererClientImpl.h" | 168 #include "web/PrerendererClientImpl.h" |
| 169 #include "web/ResizeViewportAnchor.h" | 169 #include "web/ResizeViewportAnchor.h" |
| 170 #include "web/RotationViewportAnchor.h" | 170 #include "web/RotationViewportAnchor.h" |
| 171 #include "web/SpeechRecognitionClientProxy.h" | 171 #include "web/SpeechRecognitionClientProxy.h" |
| 172 #include "web/StorageQuotaClientImpl.h" | 172 #include "web/StorageQuotaClientImpl.h" |
| 173 #include "web/ValidationMessageClientImpl.h" | 173 #include "web/ValidationMessageClientImpl.h" |
| 174 #include "web/WebDevToolsAgentImpl.h" | 174 #include "web/WebDevToolsAgentImpl.h" |
| 175 #include "web/WebInputEventConversion.h" | 175 #include "web/WebInputEventConversion.h" |
| 176 #include "web/WebInputMethodControllerImpl.h" |
| 176 #include "web/WebLocalFrameImpl.h" | 177 #include "web/WebLocalFrameImpl.h" |
| 177 #include "web/WebPagePopupImpl.h" | 178 #include "web/WebPagePopupImpl.h" |
| 178 #include "web/WebPluginContainerImpl.h" | 179 #include "web/WebPluginContainerImpl.h" |
| 179 #include "web/WebRemoteFrameImpl.h" | 180 #include "web/WebRemoteFrameImpl.h" |
| 180 #include "web/WebSettingsImpl.h" | 181 #include "web/WebSettingsImpl.h" |
| 181 #include "wtf/AutoReset.h" | 182 #include "wtf/AutoReset.h" |
| 182 #include "wtf/CurrentTime.h" | 183 #include "wtf/CurrentTime.h" |
| 183 #include "wtf/PtrUtil.h" | 184 #include "wtf/PtrUtil.h" |
| 184 #include "wtf/RefPtr.h" | 185 #include "wtf/RefPtr.h" |
| 185 #include <memory> | 186 #include <memory> |
| (...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2303 focusedFrame->inputMethodController().finishComposingText(InputM
ethodController::KeepSelection); | 2304 focusedFrame->inputMethodController().finishComposingText(InputM
ethodController::KeepSelection); |
| 2304 | 2305 |
| 2305 if (autofillClient) | 2306 if (autofillClient) |
| 2306 autofillClient->setIgnoreTextChanges(false); | 2307 autofillClient->setIgnoreTextChanges(false); |
| 2307 } | 2308 } |
| 2308 m_imeAcceptEvents = false; | 2309 m_imeAcceptEvents = false; |
| 2309 } | 2310 } |
| 2310 } | 2311 } |
| 2311 } | 2312 } |
| 2312 | 2313 |
| 2313 | |
| 2314 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as | |
| 2315 // well. This code needs to be refactored (http://crbug.com/629721). | |
| 2316 bool WebViewImpl::setComposition( | |
| 2317 const WebString& text, | |
| 2318 const WebVector<WebCompositionUnderline>& underlines, | |
| 2319 int selectionStart, | |
| 2320 int selectionEnd) | |
| 2321 { | |
| 2322 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | |
| 2323 if (!focused) | |
| 2324 return false; | |
| 2325 | |
| 2326 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | |
| 2327 return plugin->setComposition(text, underlines, selectionStart, selectio
nEnd); | |
| 2328 | |
| 2329 // The input focus has been moved to another WebWidget object. | |
| 2330 // We should use this |editor| object only to complete the ongoing | |
| 2331 // composition. | |
| 2332 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); | |
| 2333 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) | |
| 2334 return false; | |
| 2335 | |
| 2336 // We should verify the parent node of this IME composition node are | |
| 2337 // editable because JavaScript may delete a parent node of the composition | |
| 2338 // node. In this case, WebKit crashes while deleting texts from the parent | |
| 2339 // node, which doesn't exist any longer. | |
| 2340 const EphemeralRange range = inputMethodController.compositionEphemeralRange
(); | |
| 2341 if (range.isNotNull()) { | |
| 2342 Node* node = range.startPosition().computeContainerNode(); | |
| 2343 focused->document()->updateStyleAndLayoutTree(); | |
| 2344 if (!node || !hasEditableStyle(*node)) | |
| 2345 return false; | |
| 2346 } | |
| 2347 | |
| 2348 // A keypress event is canceled. If an ongoing composition exists, then the | |
| 2349 // keydown event should have arisen from a handled key (e.g., backspace). | |
| 2350 // In this case we ignore the cancellation and continue; otherwise (no | |
| 2351 // ongoing composition) we exit and signal success only for attempts to | |
| 2352 // clear the composition. | |
| 2353 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) | |
| 2354 return text.isEmpty(); | |
| 2355 | |
| 2356 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
| 2357 | |
| 2358 // When the range of composition underlines overlap with the range between | |
| 2359 // selectionStart and selectionEnd, WebKit somehow won't paint the selection | |
| 2360 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). | |
| 2361 // But the selection range actually takes effect. | |
| 2362 inputMethodController.setComposition(String(text), | |
| 2363 CompositionUnderlineVectorBuilder(underlines), | |
| 2364 selectionStart, selectionEnd); | |
| 2365 | |
| 2366 return text.isEmpty() || inputMethodController.hasComposition(); | |
| 2367 } | |
| 2368 | |
| 2369 // TODO(ekaramad):These methods are almost duplicated in WebFrameWidgetImpl as | |
| 2370 // well. This code needs to be refactored (http://crbug.com/629721). | |
| 2371 bool WebViewImpl::finishComposingText(ConfirmCompositionBehavior selectionBehavi
or) | |
| 2372 { | |
| 2373 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | |
| 2374 if (!focused) | |
| 2375 return false; | |
| 2376 | |
| 2377 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | |
| 2378 return plugin->finishComposingText(selectionBehavior); | |
| 2379 | |
| 2380 return focused->inputMethodController().finishComposingText(selectionBehavio
r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle
r::DoNotKeepSelection); | |
| 2381 } | |
| 2382 | |
| 2383 bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition) | |
| 2384 { | |
| 2385 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
| 2386 | |
| 2387 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | |
| 2388 if (!focused) | |
| 2389 return false; | |
| 2390 | |
| 2391 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | |
| 2392 return plugin->commitText(text, relativeCaretPosition); | |
| 2393 | |
| 2394 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 2395 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 2396 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 2397 | |
| 2398 return focused->inputMethodController().commitText(text, relativeCaretPositi
on); | |
| 2399 } | |
| 2400 | |
| 2401 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as | 2314 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as |
| 2402 // well. This code needs to be refactored (http://crbug.com/629721). | 2315 // well. This code needs to be refactored (http://crbug.com/629721). |
| 2403 WebRange WebViewImpl::compositionRange() | 2316 WebRange WebViewImpl::compositionRange() |
| 2404 { | 2317 { |
| 2405 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2318 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2406 if (!focused) | 2319 if (!focused) |
| 2407 return WebRange(); | 2320 return WebRange(); |
| 2408 | 2321 |
| 2409 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 2322 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
| 2410 if (range.isNull()) | 2323 if (range.isNull()) |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 | 3874 |
| 3962 if (m_layerTreeView) | 3875 if (m_layerTreeView) |
| 3963 m_layerTreeView->setHasTransparentBackground(this->isTransparent()); | 3876 m_layerTreeView->setHasTransparentBackground(this->isTransparent()); |
| 3964 } | 3877 } |
| 3965 | 3878 |
| 3966 bool WebViewImpl::isTransparent() const | 3879 bool WebViewImpl::isTransparent() const |
| 3967 { | 3880 { |
| 3968 return m_isTransparent; | 3881 return m_isTransparent; |
| 3969 } | 3882 } |
| 3970 | 3883 |
| 3884 WebInputMethodControllerImpl* WebViewImpl::getActiveWebInputMethodController() c
onst |
| 3885 { |
| 3886 return WebInputMethodControllerImpl::fromFrame(focusedLocalFrameAvailableFor
Ime()); |
| 3887 } |
| 3888 |
| 3971 void WebViewImpl::setBaseBackgroundColor(WebColor color) | 3889 void WebViewImpl::setBaseBackgroundColor(WebColor color) |
| 3972 { | 3890 { |
| 3973 if (m_baseBackgroundColor == color) | 3891 if (m_baseBackgroundColor == color) |
| 3974 return; | 3892 return; |
| 3975 | 3893 |
| 3976 m_baseBackgroundColor = color; | 3894 m_baseBackgroundColor = color; |
| 3977 | 3895 |
| 3978 if (m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()) | 3896 if (m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()) |
| 3979 m_page->deprecatedLocalMainFrame()->view()->setBaseBackgroundColor(color
); | 3897 m_page->deprecatedLocalMainFrame()->view()->setBaseBackgroundColor(color
); |
| 3980 } | 3898 } |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4605 return nullptr; | 4523 return nullptr; |
| 4606 return focusedFrame; | 4524 return focusedFrame; |
| 4607 } | 4525 } |
| 4608 | 4526 |
| 4609 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const | 4527 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const |
| 4610 { | 4528 { |
| 4611 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4529 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4612 } | 4530 } |
| 4613 | 4531 |
| 4614 } // namespace blink | 4532 } // namespace blink |
| OLD | NEW |