| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "public/web/WebAutofillClient.h" | 57 #include "public/web/WebAutofillClient.h" |
| 58 #include "public/web/WebPlugin.h" | 58 #include "public/web/WebPlugin.h" |
| 59 #include "public/web/WebRange.h" | 59 #include "public/web/WebRange.h" |
| 60 #include "public/web/WebWidgetClient.h" | 60 #include "public/web/WebWidgetClient.h" |
| 61 #include "web/CompositionUnderlineVectorBuilder.h" | 61 #include "web/CompositionUnderlineVectorBuilder.h" |
| 62 #include "web/CompositorMutatorImpl.h" | 62 #include "web/CompositorMutatorImpl.h" |
| 63 #include "web/CompositorProxyClientImpl.h" | 63 #include "web/CompositorProxyClientImpl.h" |
| 64 #include "web/ContextMenuAllowedScope.h" | 64 #include "web/ContextMenuAllowedScope.h" |
| 65 #include "web/WebDevToolsAgentImpl.h" | 65 #include "web/WebDevToolsAgentImpl.h" |
| 66 #include "web/WebInputEventConversion.h" | 66 #include "web/WebInputEventConversion.h" |
| 67 #include "web/WebInputMethodControllerImpl.h" |
| 67 #include "web/WebLocalFrameImpl.h" | 68 #include "web/WebLocalFrameImpl.h" |
| 68 #include "web/WebPluginContainerImpl.h" | 69 #include "web/WebPluginContainerImpl.h" |
| 69 #include "web/WebRemoteFrameImpl.h" | 70 #include "web/WebRemoteFrameImpl.h" |
| 70 #include "web/WebViewFrameWidget.h" | 71 #include "web/WebViewFrameWidget.h" |
| 71 #include "wtf/AutoReset.h" | 72 #include "wtf/AutoReset.h" |
| 72 #include "wtf/PtrUtil.h" | 73 #include "wtf/PtrUtil.h" |
| 73 #include <memory> | 74 #include <memory> |
| 74 | 75 |
| 75 namespace blink { | 76 namespace blink { |
| 76 | 77 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 void WebFrameWidgetImpl::setBaseBackgroundColor(WebColor color) | 401 void WebFrameWidgetImpl::setBaseBackgroundColor(WebColor color) |
| 401 { | 402 { |
| 402 if (m_baseBackgroundColor == color) | 403 if (m_baseBackgroundColor == color) |
| 403 return; | 404 return; |
| 404 | 405 |
| 405 m_baseBackgroundColor = color; | 406 m_baseBackgroundColor = color; |
| 406 | 407 |
| 407 m_localRoot->frameView()->setBaseBackgroundColor(color); | 408 m_localRoot->frameView()->setBaseBackgroundColor(color); |
| 408 } | 409 } |
| 409 | 410 |
| 411 WebInputMethodControllerImpl* WebFrameWidgetImpl::getActiveWebInputMethodControl
ler() const |
| 412 { |
| 413 return WebInputMethodControllerImpl::fromFrame(focusedLocalFrameAvailableFor
Ime()); |
| 414 } |
| 415 |
| 410 void WebFrameWidgetImpl::scheduleAnimation() | 416 void WebFrameWidgetImpl::scheduleAnimation() |
| 411 { | 417 { |
| 412 if (m_layerTreeView) { | 418 if (m_layerTreeView) { |
| 413 m_layerTreeView->setNeedsBeginFrame(); | 419 m_layerTreeView->setNeedsBeginFrame(); |
| 414 return; | 420 return; |
| 415 } | 421 } |
| 416 if (m_client) | 422 if (m_client) |
| 417 m_client->scheduleAnimation(); | 423 m_client->scheduleAnimation(); |
| 418 } | 424 } |
| 419 | 425 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 if (autofillClient) | 493 if (autofillClient) |
| 488 autofillClient->setIgnoreTextChanges(false); | 494 autofillClient->setIgnoreTextChanges(false); |
| 489 } | 495 } |
| 490 m_imeAcceptEvents = false; | 496 m_imeAcceptEvents = false; |
| 491 } | 497 } |
| 492 } | 498 } |
| 493 } | 499 } |
| 494 | 500 |
| 495 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This | 501 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 496 // code needs to be refactored (http://crbug.com/629721). | 502 // code needs to be refactored (http://crbug.com/629721). |
| 497 bool WebFrameWidgetImpl::setComposition( | |
| 498 const WebString& text, | |
| 499 const WebVector<WebCompositionUnderline>& underlines, | |
| 500 int selectionStart, | |
| 501 int selectionEnd) | |
| 502 { | |
| 503 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | |
| 504 if (!focused) | |
| 505 return false; | |
| 506 | |
| 507 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | |
| 508 return plugin->setComposition(text, underlines, selectionStart, selectio
nEnd); | |
| 509 | |
| 510 // The input focus has been moved to another WebWidget object. | |
| 511 // We should use this |editor| object only to complete the ongoing | |
| 512 // composition. | |
| 513 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); | |
| 514 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) | |
| 515 return false; | |
| 516 | |
| 517 // We should verify the parent node of this IME composition node are | |
| 518 // editable because JavaScript may delete a parent node of the composition | |
| 519 // node. In this case, WebKit crashes while deleting texts from the parent | |
| 520 // node, which doesn't exist any longer. | |
| 521 const EphemeralRange range = inputMethodController.compositionEphemeralRange
(); | |
| 522 if (range.isNotNull()) { | |
| 523 Node* node = range.startPosition().computeContainerNode(); | |
| 524 focused->document()->updateStyleAndLayoutTree(); | |
| 525 if (!node || !hasEditableStyle(*node)) | |
| 526 return false; | |
| 527 } | |
| 528 | |
| 529 // A keypress event is canceled. If an ongoing composition exists, then the | |
| 530 // keydown event should have arisen from a handled key (e.g., backspace). | |
| 531 // In this case we ignore the cancellation and continue; otherwise (no | |
| 532 // ongoing composition) we exit and signal success only for attempts to | |
| 533 // clear the composition. | |
| 534 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) | |
| 535 return text.isEmpty(); | |
| 536 | |
| 537 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
| 538 | |
| 539 // When the range of composition underlines overlap with the range between | |
| 540 // selectionStart and selectionEnd, WebKit somehow won't paint the selection | |
| 541 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). | |
| 542 // But the selection range actually takes effect. | |
| 543 inputMethodController.setComposition(String(text), | |
| 544 CompositionUnderlineVectorBuilder(underlines), | |
| 545 selectionStart, selectionEnd); | |
| 546 | |
| 547 return text.isEmpty() || inputMethodController.hasComposition(); | |
| 548 } | |
| 549 | |
| 550 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well. | |
| 551 // This code needs to be refactored (http://crbug.com/629721). | |
| 552 bool WebFrameWidgetImpl::commitText(const WebString& text, int relativeCaretPosi
tion) | |
| 553 { | |
| 554 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
| 555 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | |
| 556 if (!focused) | |
| 557 return false; | |
| 558 | |
| 559 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | |
| 560 return plugin->commitText(text, relativeCaretPosition); | |
| 561 | |
| 562 return focused->inputMethodController().commitText(text, relativeCaretPositi
on); | |
| 563 } | |
| 564 | |
| 565 bool WebFrameWidgetImpl::finishComposingText(ConfirmCompositionBehavior selectio
nBehavior) | |
| 566 { | |
| 567 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | |
| 568 if (!focused) | |
| 569 return false; | |
| 570 | |
| 571 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | |
| 572 return plugin->finishComposingText(selectionBehavior); | |
| 573 | |
| 574 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 575 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 576 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 577 | |
| 578 return focused->inputMethodController().finishComposingText(selectionBehavio
r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle
r::DoNotKeepSelection); | |
| 579 } | |
| 580 | |
| 581 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This | |
| 582 // code needs to be refactored (http://crbug.com/629721). | |
| 583 WebRange WebFrameWidgetImpl::compositionRange() | 503 WebRange WebFrameWidgetImpl::compositionRange() |
| 584 { | 504 { |
| 585 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 505 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 586 if (!focused) | 506 if (!focused) |
| 587 return WebRange(); | 507 return WebRange(); |
| 588 | 508 |
| 589 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 509 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
| 590 if (range.isNull()) | 510 if (range.isNull()) |
| 591 return WebRange(); | 511 return WebRange(); |
| 592 | 512 |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 } | 1425 } |
| 1506 | 1426 |
| 1507 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const | 1427 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const |
| 1508 { | 1428 { |
| 1509 if (!m_imeAcceptEvents) | 1429 if (!m_imeAcceptEvents) |
| 1510 return nullptr; | 1430 return nullptr; |
| 1511 return focusedLocalFrameInWidget(); | 1431 return focusedLocalFrameInWidget(); |
| 1512 } | 1432 } |
| 1513 | 1433 |
| 1514 } // namespace blink | 1434 } // namespace blink |
| OLD | NEW |