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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebViewImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index 3e92e32a2f867341300bb60c550f5729a13a1c55..a6f470bcfa657e745247569a866a9dc01ce1a6ec 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -2424,6 +2424,11 @@ WebTextInputInfo WebViewImpl::textInputInfo()
{
WebTextInputInfo info;
+ // When mainFrameImpl() is nullptr/remote, IME is handled at the Widget
+ // belonging to the local root.
+ if (!mainFrameImpl())
+ return info;
+
Frame* focusedFrame = focusedCoreFrame();
if (!focusedFrame->isLocalFrame())
return info;
@@ -2432,6 +2437,11 @@ WebTextInputInfo WebViewImpl::textInputInfo()
if (!focused)
return info;
+ // We can only have a text input type when focused frame belongs to this
+ // WebViewImpl, i.e., its local root is the main frame.
+ if (focused->localFrameRoot() != mainFrameImpl()->frame())
+ return info;
+
FrameSelection& selection = focused->selection();
if (!selection.isAvailable()) {
// plugins/mouse-capture-inside-shadow.html reaches here.
@@ -2481,10 +2491,21 @@ WebTextInputInfo WebViewImpl::textInputInfo()
WebTextInputType WebViewImpl::textInputType()
{
+ // When mainFrameImpl() is nullptr/remote, IME is handled at the Widget
+ // belonging to the local root.
+ if (!mainFrameImpl())
+ return WebTextInputTypeNone;
+
LocalFrame* focusedFrame = m_page->focusController().focusedFrame();
if (!focusedFrame)
return WebTextInputTypeNone;
+ if (focusedFrame != mainFrameImpl()->frame()) {
+ // We can only report a text input type when the focused frame belongs
+ // to this WebViewImpl, i.e., its local root is the main frame.
+ return WebTextInputTypeNone;
+ }
+
if (!focusedFrame->selection().isAvailable()) {
// "mouse-capture-inside-shadow.html" reaches here.
return WebTextInputTypeNone;
@@ -2824,6 +2845,48 @@ void WebViewImpl::didChangeWindowResizerRect()
mainFrameImpl()->frameView()->windowResizerRectChanged();
}
+bool WebViewImpl::getCompositionCharacterBounds(WebVector<WebRect>& bounds)
+{
+ size_t offset = 0;
+ size_t characterCount = 0;
+ if (!compositionRange(&offset, &characterCount))
+ return false;
+
+ if (characterCount == 0)
+ return false;
+
+ WebLocalFrame* frame = focusedFrame()->toWebLocalFrame();
+ if (!frame)
+ return false;
+
+ // Only consider frames whose local root is the main frame. For other
+ // local frames which have different local roots, the corresponding
+ // WebFrameWidget will handle this task.
+ if (frame->localRoot() != mainFrameImpl())
+ return false;
+
+ WebVector<WebRect> result(characterCount);
+ WebRect webrect;
+ for (size_t i = 0; i < characterCount; ++i) {
+ if (!frame->firstRectForCharacterRange(offset + i, 1, webrect)) {
+ DLOG(ERROR) << "Could not retrieve character rectangle at " << i;
+ return false;
+ }
+ result[i] = webrect;
+ }
+ bounds.swap(result);
+ return true;
+}
+
+void WebViewImpl::applyReplacementRange(int start, int length)
+{
+ if (WebLocalFrame* frame = focusedFrame()->toWebLocalFrame()) {
+ WebRange webrange = WebRange::fromDocumentRange(frame, start, length);
+ if (!webrange.isNull())
+ frame->selectRange(webrange);
+ }
+}
+
// WebView --------------------------------------------------------------------
WebSettingsImpl* WebViewImpl::settingsImpl()

Powered by Google App Engine
This is Rietveld 408576698