| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 focusedFrame->inputMethodController().confirmComposition(); | 485 focusedFrame->inputMethodController().confirmComposition(); |
| 486 | 486 |
| 487 if (autofillClient) | 487 if (autofillClient) |
| 488 autofillClient->setIgnoreTextChanges(false); | 488 autofillClient->setIgnoreTextChanges(false); |
| 489 } | 489 } |
| 490 m_imeAcceptEvents = false; | 490 m_imeAcceptEvents = false; |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 | 494 |
| 495 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 496 // code needs to be refactored (http://crbug.com/629721). |
| 495 bool WebFrameWidgetImpl::setComposition( | 497 bool WebFrameWidgetImpl::setComposition( |
| 496 const WebString& text, | 498 const WebString& text, |
| 497 const WebVector<WebCompositionUnderline>& underlines, | 499 const WebVector<WebCompositionUnderline>& underlines, |
| 498 int selectionStart, | 500 int selectionStart, |
| 499 int selectionEnd) | 501 int selectionEnd) |
| 500 { | 502 { |
| 501 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 503 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 502 if (!focused) | 504 if (!focused) |
| 503 return false; | 505 return false; |
| 504 | 506 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // selectionStart and selectionEnd, WebKit somehow won't paint the selection | 540 // selectionStart and selectionEnd, WebKit somehow won't paint the selection |
| 539 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). | 541 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). |
| 540 // But the selection range actually takes effect. | 542 // But the selection range actually takes effect. |
| 541 inputMethodController.setComposition(String(text), | 543 inputMethodController.setComposition(String(text), |
| 542 CompositionUnderlineVectorBuilder(underlines), | 544 CompositionUnderlineVectorBuilder(underlines), |
| 543 selectionStart, selectionEnd); | 545 selectionStart, selectionEnd); |
| 544 | 546 |
| 545 return text.isEmpty() || inputMethodController.hasComposition(); | 547 return text.isEmpty() || inputMethodController.hasComposition(); |
| 546 } | 548 } |
| 547 | 549 |
| 550 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well. |
| 551 // This code needs to be refactored (http://crbug.com/629721). |
| 548 bool WebFrameWidgetImpl::confirmComposition() | 552 bool WebFrameWidgetImpl::confirmComposition() |
| 549 { | 553 { |
| 550 return confirmComposition(DoNotKeepSelection); | 554 return confirmComposition(DoNotKeepSelection); |
| 551 } | 555 } |
| 552 | 556 |
| 553 bool WebFrameWidgetImpl::confirmComposition(ConfirmCompositionBehavior selection
Behavior) | 557 bool WebFrameWidgetImpl::confirmComposition(ConfirmCompositionBehavior selection
Behavior) |
| 554 { | 558 { |
| 555 return confirmComposition(WebString(), selectionBehavior); | 559 return confirmComposition(WebString(), selectionBehavior); |
| 556 } | 560 } |
| 557 | 561 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 570 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 574 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 571 return plugin->confirmComposition(text, selectionBehavior); | 575 return plugin->confirmComposition(text, selectionBehavior); |
| 572 | 576 |
| 573 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 577 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 574 // needs to be audited. See http://crbug.com/590369 for more details. | 578 // needs to be audited. See http://crbug.com/590369 for more details. |
| 575 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 579 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 576 | 580 |
| 577 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 581 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); |
| 578 } | 582 } |
| 579 | 583 |
| 584 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 585 // code needs to be refactored (http://crbug.com/629721). |
| 580 WebRange WebFrameWidgetImpl::compositionRange() | 586 WebRange WebFrameWidgetImpl::compositionRange() |
| 581 { | 587 { |
| 582 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 588 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 583 if (!focused) | 589 if (!focused) |
| 584 return WebRange(); | 590 return WebRange(); |
| 585 | 591 |
| 586 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 592 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
| 587 if (range.isNull()) | 593 if (range.isNull()) |
| 588 return WebRange(); | 594 return WebRange(); |
| 589 | 595 |
| 590 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); | 596 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); |
| 591 DCHECK(editable); | 597 DCHECK(editable); |
| 592 | 598 |
| 593 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 599 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 594 // needs to be audited. See http://crbug.com/590369 for more details. | 600 // needs to be audited. See http://crbug.com/590369 for more details. |
| 595 editable->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 601 editable->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 596 | 602 |
| 597 return PlainTextRange::create(*editable, range); | 603 return PlainTextRange::create(*editable, range); |
| 598 } | 604 } |
| 599 | 605 |
| 606 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 607 // code needs to be refactored (http://crbug.com/629721). |
| 600 WebTextInputInfo WebFrameWidgetImpl::textInputInfo() | 608 WebTextInputInfo WebFrameWidgetImpl::textInputInfo() |
| 601 { | 609 { |
| 602 WebTextInputInfo info; | 610 WebTextInputInfo info; |
| 603 | 611 |
| 604 LocalFrame* focused = focusedLocalFrameInWidget(); | 612 LocalFrame* focused = focusedLocalFrameInWidget(); |
| 605 if (!focused) | 613 if (!focused) |
| 606 return info; | 614 return info; |
| 607 | 615 |
| 608 FrameSelection& selection = focused->selection(); | 616 FrameSelection& selection = focused->selection(); |
| 609 if (!selection.isAvailable()) { | 617 if (!selection.isAvailable()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 PlainTextRange plainTextRange(PlainTextRange::create(*element, range)); | 659 PlainTextRange plainTextRange(PlainTextRange::create(*element, range)); |
| 652 if (plainTextRange.isNotNull()) { | 660 if (plainTextRange.isNotNull()) { |
| 653 info.compositionStart = plainTextRange.start(); | 661 info.compositionStart = plainTextRange.start(); |
| 654 info.compositionEnd = plainTextRange.end(); | 662 info.compositionEnd = plainTextRange.end(); |
| 655 } | 663 } |
| 656 } | 664 } |
| 657 | 665 |
| 658 return info; | 666 return info; |
| 659 } | 667 } |
| 660 | 668 |
| 669 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 670 // code needs to be refactored (http://crbug.com/629721). |
| 661 WebTextInputType WebFrameWidgetImpl::textInputType() | 671 WebTextInputType WebFrameWidgetImpl::textInputType() |
| 662 { | 672 { |
| 663 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); | 673 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); |
| 664 if (!focusedFrame) | 674 if (!focusedFrame) |
| 665 return WebTextInputTypeNone; | 675 return WebTextInputTypeNone; |
| 666 | 676 |
| 667 if (!focusedFrame->selection().isAvailable()) { | 677 if (!focusedFrame->selection().isAvailable()) { |
| 668 // "mouse-capture-inside-shadow.html" reaches here. | 678 // "mouse-capture-inside-shadow.html" reaches here. |
| 669 return WebTextInputTypeNone; | 679 return WebTextInputTypeNone; |
| 670 } | 680 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 WebColor WebFrameWidgetImpl::backgroundColor() const | 738 WebColor WebFrameWidgetImpl::backgroundColor() const |
| 729 { | 739 { |
| 730 if (isTransparent()) | 740 if (isTransparent()) |
| 731 return Color::transparent; | 741 return Color::transparent; |
| 732 if (!m_localRoot->frameView()) | 742 if (!m_localRoot->frameView()) |
| 733 return m_baseBackgroundColor; | 743 return m_baseBackgroundColor; |
| 734 FrameView* view = m_localRoot->frameView(); | 744 FrameView* view = m_localRoot->frameView(); |
| 735 return view->documentBackgroundColor().rgb(); | 745 return view->documentBackgroundColor().rgb(); |
| 736 } | 746 } |
| 737 | 747 |
| 748 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 749 // code needs to be refactored (http://crbug.com/629721). |
| 738 bool WebFrameWidgetImpl::selectionBounds(WebRect& anchor, WebRect& focus) const | 750 bool WebFrameWidgetImpl::selectionBounds(WebRect& anchor, WebRect& focus) const |
| 739 { | 751 { |
| 740 const LocalFrame* localFrame = focusedLocalFrameInWidget(); | 752 const LocalFrame* localFrame = focusedLocalFrameInWidget(); |
| 741 if (!localFrame) | 753 if (!localFrame) |
| 742 return false; | 754 return false; |
| 743 | 755 |
| 744 FrameSelection& selection = localFrame->selection(); | 756 FrameSelection& selection = localFrame->selection(); |
| 745 | 757 |
| 746 if (selection.isCaret()) { | 758 if (selection.isCaret()) { |
| 747 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesh
eets | 759 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesh
eets |
| (...skipping 14 matching lines...) Expand all Loading... |
| 762 IntRect scaledFocus(localFrame->view()->contentsToRootFrame(focus)); | 774 IntRect scaledFocus(localFrame->view()->contentsToRootFrame(focus)); |
| 763 | 775 |
| 764 anchor = scaledAnchor; | 776 anchor = scaledAnchor; |
| 765 focus = scaledFocus; | 777 focus = scaledFocus; |
| 766 | 778 |
| 767 if (!selection.selection().isBaseFirst()) | 779 if (!selection.selection().isBaseFirst()) |
| 768 std::swap(anchor, focus); | 780 std::swap(anchor, focus); |
| 769 return true; | 781 return true; |
| 770 } | 782 } |
| 771 | 783 |
| 784 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 785 // code needs to be refactored (http://crbug.com/629721). |
| 772 bool WebFrameWidgetImpl::selectionTextDirection(WebTextDirection& start, WebText
Direction& end) const | 786 bool WebFrameWidgetImpl::selectionTextDirection(WebTextDirection& start, WebText
Direction& end) const |
| 773 { | 787 { |
| 774 const LocalFrame* frame = focusedLocalFrameInWidget(); | 788 const LocalFrame* frame = focusedLocalFrameInWidget(); |
| 775 if (!frame) | 789 if (!frame) |
| 776 return false; | 790 return false; |
| 777 | 791 |
| 778 FrameSelection& selection = frame->selection(); | 792 FrameSelection& selection = frame->selection(); |
| 779 if (selection.selection().toNormalizedEphemeralRange().isNull()) | 793 if (selection.selection().toNormalizedEphemeralRange().isNull()) |
| 780 return false; | 794 return false; |
| 781 start = toWebTextDirection(primaryDirectionOf(*selection.start().anchorNode(
))); | 795 start = toWebTextDirection(primaryDirectionOf(*selection.start().anchorNode(
))); |
| 782 end = toWebTextDirection(primaryDirectionOf(*selection.end().anchorNode())); | 796 end = toWebTextDirection(primaryDirectionOf(*selection.end().anchorNode())); |
| 783 return true; | 797 return true; |
| 784 } | 798 } |
| 785 | 799 |
| 800 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 801 // code needs to be refactored (http://crbug.com/629721). |
| 786 bool WebFrameWidgetImpl::isSelectionAnchorFirst() const | 802 bool WebFrameWidgetImpl::isSelectionAnchorFirst() const |
| 787 { | 803 { |
| 788 if (const LocalFrame* frame = focusedLocalFrameInWidget()) | 804 if (const LocalFrame* frame = focusedLocalFrameInWidget()) |
| 789 return frame->selection().selection().isBaseFirst(); | 805 return frame->selection().selection().isBaseFirst(); |
| 790 return false; | 806 return false; |
| 791 } | 807 } |
| 792 | 808 |
| 809 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 810 // code needs to be refactored (http://crbug.com/629721). |
| 793 WebRange WebFrameWidgetImpl::caretOrSelectionRange() | 811 WebRange WebFrameWidgetImpl::caretOrSelectionRange() |
| 794 { | 812 { |
| 795 LocalFrame* focused = focusedLocalFrameInWidget(); | 813 LocalFrame* focused = focusedLocalFrameInWidget(); |
| 796 if (!focused) | 814 if (!focused) |
| 797 return WebRange(); | 815 return WebRange(); |
| 798 | 816 |
| 799 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 817 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 800 // needs to be audited. See http://crbug.com/590369 for more details. | 818 // needs to be audited. See http://crbug.com/590369 for more details. |
| 801 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 819 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 802 | 820 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 void WebFrameWidgetImpl::didNotAcquirePointerLock() | 884 void WebFrameWidgetImpl::didNotAcquirePointerLock() |
| 867 { | 885 { |
| 868 page()->pointerLockController().didNotAcquirePointerLock(); | 886 page()->pointerLockController().didNotAcquirePointerLock(); |
| 869 } | 887 } |
| 870 | 888 |
| 871 void WebFrameWidgetImpl::didLosePointerLock() | 889 void WebFrameWidgetImpl::didLosePointerLock() |
| 872 { | 890 { |
| 873 page()->pointerLockController().didLosePointerLock(); | 891 page()->pointerLockController().didLosePointerLock(); |
| 874 } | 892 } |
| 875 | 893 |
| 894 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 895 // code needs to be refactored (http://crbug.com/629721). |
| 876 bool WebFrameWidgetImpl::getCompositionCharacterBounds(WebVector<WebRect>& bound
s) | 896 bool WebFrameWidgetImpl::getCompositionCharacterBounds(WebVector<WebRect>& bound
s) |
| 877 { | 897 { |
| 878 WebRange range = compositionRange(); | 898 WebRange range = compositionRange(); |
| 879 if (range.isEmpty()) | 899 if (range.isEmpty()) |
| 880 return false; | 900 return false; |
| 881 | 901 |
| 882 LocalFrame* frame = focusedLocalFrameInWidget(); | 902 LocalFrame* frame = focusedLocalFrameInWidget(); |
| 883 if (!frame) | 903 if (!frame) |
| 884 return false; | 904 return false; |
| 885 | 905 |
| 886 WebLocalFrameImpl* webLocalFrame = WebLocalFrameImpl::fromFrame(frame); | 906 WebLocalFrameImpl* webLocalFrame = WebLocalFrameImpl::fromFrame(frame); |
| 887 size_t characterCount = range.length(); | 907 size_t characterCount = range.length(); |
| 888 size_t offset = range.startOffset(); | 908 size_t offset = range.startOffset(); |
| 889 WebVector<WebRect> result(characterCount); | 909 WebVector<WebRect> result(characterCount); |
| 890 WebRect webrect; | 910 WebRect webrect; |
| 891 for (size_t i = 0; i < characterCount; ++i) { | 911 for (size_t i = 0; i < characterCount; ++i) { |
| 892 if (!webLocalFrame->firstRectForCharacterRange(offset + i, 1, webrect))
{ | 912 if (!webLocalFrame->firstRectForCharacterRange(offset + i, 1, webrect))
{ |
| 893 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; | 913 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; |
| 894 return false; | 914 return false; |
| 895 } | 915 } |
| 896 result[i] = webrect; | 916 result[i] = webrect; |
| 897 } | 917 } |
| 898 | 918 |
| 899 bounds.swap(result); | 919 bounds.swap(result); |
| 900 return true; | 920 return true; |
| 901 } | 921 } |
| 902 | 922 |
| 923 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This |
| 924 // code needs to be refactored (http://crbug.com/629721). |
| 903 void WebFrameWidgetImpl::applyReplacementRange(const WebRange& range) | 925 void WebFrameWidgetImpl::applyReplacementRange(const WebRange& range) |
| 904 { | 926 { |
| 905 if (LocalFrame* frame = focusedLocalFrameInWidget()) { | 927 if (LocalFrame* frame = focusedLocalFrameInWidget()) { |
| 906 // TODO(dglazkov): Going from LocalFrame to WebLocalFrameImpl seems | 928 // TODO(dglazkov): Going from LocalFrame to WebLocalFrameImpl seems |
| 907 // silly. What is going on here? | 929 // silly. What is going on here? |
| 908 WebLocalFrameImpl::fromFrame(frame)->selectRange(range); | 930 WebLocalFrameImpl::fromFrame(frame)->selectRange(range); |
| 909 } | 931 } |
| 910 } | 932 } |
| 911 | 933 |
| 912 void WebFrameWidgetImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseE
vent& event) | 934 void WebFrameWidgetImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseE
vent& event) |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 } | 1481 } |
| 1460 | 1482 |
| 1461 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const | 1483 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const |
| 1462 { | 1484 { |
| 1463 if (!m_imeAcceptEvents) | 1485 if (!m_imeAcceptEvents) |
| 1464 return nullptr; | 1486 return nullptr; |
| 1465 return focusedLocalFrameInWidget(); | 1487 return focusedLocalFrameInWidget(); |
| 1466 } | 1488 } |
| 1467 | 1489 |
| 1468 } // namespace blink | 1490 } // namespace blink |
| OLD | NEW |