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

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

Issue 2029423003: OOPIF IME: Renderer Side Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing lfg@'s comments. Created 4 years, 5 months 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
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 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 return false; 2417 return false;
2418 *location = plainTextRange.start(); 2418 *location = plainTextRange.start();
2419 *length = plainTextRange.length(); 2419 *length = plainTextRange.length();
2420 return true; 2420 return true;
2421 } 2421 }
2422 2422
2423 WebTextInputInfo WebViewImpl::textInputInfo() 2423 WebTextInputInfo WebViewImpl::textInputInfo()
2424 { 2424 {
2425 WebTextInputInfo info; 2425 WebTextInputInfo info;
2426 2426
2427 // When mainFrameImpl() is nullptr/remote, IME is handled at the Widget
2428 // belonging to the local root.
2429 if (!mainFrameImpl())
2430 return info;
2431
2427 Frame* focusedFrame = focusedCoreFrame(); 2432 Frame* focusedFrame = focusedCoreFrame();
2428 if (!focusedFrame->isLocalFrame()) 2433 if (!focusedFrame->isLocalFrame())
2429 return info; 2434 return info;
2430 2435
2431 LocalFrame* focused = toLocalFrame(focusedFrame); 2436 LocalFrame* focused = toLocalFrame(focusedFrame);
2432 if (!focused) 2437 if (!focused)
2433 return info; 2438 return info;
2434 2439
2440 // We can only have a text input type when focused frame belongs to this
2441 // WebViewImpl, i.e., its local root is the main frame.
2442 if (focused->localFrameRoot() != mainFrameImpl()->frame())
2443 return info;
2444
2435 FrameSelection& selection = focused->selection(); 2445 FrameSelection& selection = focused->selection();
2436 if (!selection.isAvailable()) { 2446 if (!selection.isAvailable()) {
2437 // plugins/mouse-capture-inside-shadow.html reaches here. 2447 // plugins/mouse-capture-inside-shadow.html reaches here.
2438 return info; 2448 return info;
2439 } 2449 }
2440 Element* element = selection.selection().rootEditableElement(); 2450 Element* element = selection.selection().rootEditableElement();
2441 if (!element) 2451 if (!element)
2442 return info; 2452 return info;
2443 2453
2444 info.inputMode = inputModeOfFocusedElement(); 2454 info.inputMode = inputModeOfFocusedElement();
(...skipping 29 matching lines...) Expand all
2474 info.compositionStart = plainTextRange.start(); 2484 info.compositionStart = plainTextRange.start();
2475 info.compositionEnd = plainTextRange.end(); 2485 info.compositionEnd = plainTextRange.end();
2476 } 2486 }
2477 } 2487 }
2478 2488
2479 return info; 2489 return info;
2480 } 2490 }
2481 2491
2482 WebTextInputType WebViewImpl::textInputType() 2492 WebTextInputType WebViewImpl::textInputType()
2483 { 2493 {
2494 // When mainFrameImpl() is nullptr/remote, IME is handled at the Widget
2495 // belonging to the local root.
2496 if (!mainFrameImpl())
2497 return WebTextInputTypeNone;
2498
2484 LocalFrame* focusedFrame = m_page->focusController().focusedFrame(); 2499 LocalFrame* focusedFrame = m_page->focusController().focusedFrame();
2485 if (!focusedFrame) 2500 if (!focusedFrame)
2486 return WebTextInputTypeNone; 2501 return WebTextInputTypeNone;
2487 2502
2503 if (focusedFrame != mainFrameImpl()->frame()) {
2504 // We can only report a text input type when the focused frame belongs
2505 // to this WebViewImpl, i.e., its local root is the main frame.
2506 return WebTextInputTypeNone;
2507 }
2508
2488 if (!focusedFrame->selection().isAvailable()) { 2509 if (!focusedFrame->selection().isAvailable()) {
2489 // "mouse-capture-inside-shadow.html" reaches here. 2510 // "mouse-capture-inside-shadow.html" reaches here.
2490 return WebTextInputTypeNone; 2511 return WebTextInputTypeNone;
2491 } 2512 }
2492 2513
2493 // It's important to preserve the equivalence of textInputInfo().type and te xtInputType(), 2514 // It's important to preserve the equivalence of textInputInfo().type and te xtInputType(),
2494 // so perform the same rootEditableElement() existence check here for consis tency. 2515 // so perform the same rootEditableElement() existence check here for consis tency.
2495 if (!focusedFrame->selection().selection().rootEditableElement()) 2516 if (!focusedFrame->selection().selection().rootEditableElement())
2496 return WebTextInputTypeNone; 2517 return WebTextInputTypeNone;
2497 2518
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2817 if (page()) 2838 if (page())
2818 page()->pointerLockController().didLosePointerLock(); 2839 page()->pointerLockController().didLosePointerLock();
2819 } 2840 }
2820 2841
2821 void WebViewImpl::didChangeWindowResizerRect() 2842 void WebViewImpl::didChangeWindowResizerRect()
2822 { 2843 {
2823 if (mainFrameImpl()->frameView()) 2844 if (mainFrameImpl()->frameView())
2824 mainFrameImpl()->frameView()->windowResizerRectChanged(); 2845 mainFrameImpl()->frameView()->windowResizerRectChanged();
2825 } 2846 }
2826 2847
2848 bool WebViewImpl::getCompositionCharacterBounds(WebVector<WebRect>& bounds)
2849 {
2850 size_t offset = 0;
2851 size_t characterCount = 0;
2852 if (!compositionRange(&offset, &characterCount))
2853 return false;
2854
2855 if (characterCount == 0)
2856 return false;
2857
2858 WebLocalFrame* frame = focusedFrame()->toWebLocalFrame();
2859 if (!frame)
2860 return false;
2861
2862 // Only consider frames whose local root is the main frame. For other
2863 // local frames which have different local roots, the corresponding
2864 // WebFrameWidget will handle this task.
2865 if (frame->localRoot() != mainFrameImpl())
2866 return false;
2867
2868 WebVector<WebRect> result(characterCount);
2869 WebRect webrect;
2870 for (size_t i = 0; i < characterCount; ++i) {
2871 if (!frame->firstRectForCharacterRange(offset + i, 1, webrect)) {
2872 DLOG(ERROR) << "Could not retrieve character rectangle at " << i;
2873 return false;
2874 }
2875 result[i] = webrect;
2876 }
2877 bounds.swap(result);
2878 return true;
2879 }
2880
2881 void WebViewImpl::applyReplacementRange(int start, int length)
2882 {
2883 if (WebLocalFrame* frame = focusedFrame()->toWebLocalFrame()) {
2884 WebRange webrange = WebRange::fromDocumentRange(frame, start, length);
2885 if (!webrange.isNull())
2886 frame->selectRange(webrange);
2887 }
2888 }
2889
2827 // WebView -------------------------------------------------------------------- 2890 // WebView --------------------------------------------------------------------
2828 2891
2829 WebSettingsImpl* WebViewImpl::settingsImpl() 2892 WebSettingsImpl* WebViewImpl::settingsImpl()
2830 { 2893 {
2831 if (!m_webSettings) 2894 if (!m_webSettings)
2832 m_webSettings = wrapUnique(new WebSettingsImpl(&m_page->settings(), m_de vToolsEmulator.get())); 2895 m_webSettings = wrapUnique(new WebSettingsImpl(&m_page->settings(), m_de vToolsEmulator.get()));
2833 DCHECK(m_webSettings); 2896 DCHECK(m_webSettings);
2834 return m_webSettings.get(); 2897 return m_webSettings.get();
2835 } 2898 }
2836 2899
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
4533 { 4596 {
4534 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4597 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4535 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4598 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4536 if (!page()) 4599 if (!page())
4537 return 1; 4600 return 1;
4538 4601
4539 return page()->deviceScaleFactor(); 4602 return page()->deviceScaleFactor();
4540 } 4603 }
4541 4604
4542 } // namespace blink 4605 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698