Commit 079bebf2 authored by eric@webkit.org's avatar eric@webkit.org

2010-06-19 Zhe Su <suzhe@chromium.org>

        Reviewed by Darin Fisher.

        [chromium]Refactor input method related APIs.
        https://bugs.webkit.org/show_bug.cgi?id=40608

        No new tests are needed, because there is no new functionality.

        * page/FocusController.cpp:
        (WebCore::FocusController::setFocusedNode):
2010-06-19  Zhe Su  <suzhe@chromium.org>

        Reviewed by Darin Fisher.

        [chromium]Refactor input method related APIs.
        https://bugs.webkit.org/show_bug.cgi?id=40608

        * WebKit.gyp:
        * public/WebCompositionCommand.h:
        * public/WebCompositionUnderline.h: Added.
        (WebKit::WebCompositionUnderline::WebCompositionUnderline):
        * public/WebTextInputType.h: Added.
        (WebKit::):
        * public/WebViewClient.h:
        * public/WebWidget.h:
        * public/WebWidgetClient.h:
        (WebKit::WebWidgetClient::resetInputMethod):
        * src/CompositionUnderlineBuilder.h: Added.
        (WebKit::CompositionUnderlineBuilder::CompositionUnderlineBuilder):
        * src/CompositionUnderlineVectorBuilder.cpp: Added.
        (WebKit::CompositionUnderlineVectorBuilder::CompositionUnderlineVectorBuilder):
        * src/CompositionUnderlineVectorBuilder.h: Added.
        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::setInputMethodState):
        * src/WebPopupMenuImpl.cpp:
        (WebKit::WebPopupMenuImpl::setComposition):
        (WebKit::WebPopupMenuImpl::confirmComposition):
        (WebKit::WebPopupMenuImpl::textInputType):
        (WebKit::WebPopupMenuImpl::caretOrSelectionBounds):
        * src/WebPopupMenuImpl.h:
        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::handleCompositionEvent):
        (WebKit::WebViewImpl::setComposition):
        (WebKit::WebViewImpl::confirmComposition):
        (WebKit::WebViewImpl::textInputType):
        (WebKit::WebViewImpl::caretOrSelectionBounds):
        * src/WebViewImpl.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@61484 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c8ccc31b
2010-06-19 Zhe Su <suzhe@chromium.org>
Reviewed by Darin Fisher.
[chromium]Refactor input method related APIs.
https://bugs.webkit.org/show_bug.cgi?id=40608
No new tests are needed, because there is no new functionality.
* page/FocusController.cpp:
(WebCore::FocusController::setFocusedNode):
2010-06-19 George Wright <gwright@rim.com>
Reviewed by George Staikos.
......
......@@ -594,20 +594,23 @@ bool FocusController::setFocusedNode(Node* node, PassRefPtr<Frame> newFocusedFra
// FIXME: Might want to disable this check for caretBrowsing
if (oldFocusedNode && oldFocusedNode->rootEditableElement() == oldFocusedNode && !relinquishesEditingFocus(oldFocusedNode))
return false;
// Set input method state before changing the focused node, so that the
// input method can still have a chance to finish the ongoing composition
// session.
m_page->editorClient()->setInputMethodState(node ? node->shouldUseInputMethod() : false);
clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), node);
if (!node) {
if (oldDocument)
oldDocument->setFocusedNode(0);
m_page->editorClient()->setInputMethodState(false);
return true;
}
RefPtr<Document> newDocument = node->document();
if (newDocument && newDocument->focusedNode() == node) {
m_page->editorClient()->setInputMethodState(node->shouldUseInputMethod());
return true;
}
......@@ -619,8 +622,6 @@ bool FocusController::setFocusedNode(Node* node, PassRefPtr<Frame> newFocusedFra
if (newDocument)
newDocument->setFocusedNode(node);
m_page->editorClient()->setInputMethodState(node->shouldUseInputMethod());
return true;
}
......
2010-06-19 Zhe Su <suzhe@chromium.org>
Reviewed by Darin Fisher.
[chromium]Refactor input method related APIs.
https://bugs.webkit.org/show_bug.cgi?id=40608
* WebKit.gyp:
* public/WebCompositionCommand.h:
* public/WebCompositionUnderline.h: Added.
(WebKit::WebCompositionUnderline::WebCompositionUnderline):
* public/WebTextInputType.h: Added.
(WebKit::):
* public/WebViewClient.h:
* public/WebWidget.h:
* public/WebWidgetClient.h:
(WebKit::WebWidgetClient::resetInputMethod):
* src/CompositionUnderlineBuilder.h: Added.
(WebKit::CompositionUnderlineBuilder::CompositionUnderlineBuilder):
* src/CompositionUnderlineVectorBuilder.cpp: Added.
(WebKit::CompositionUnderlineVectorBuilder::CompositionUnderlineVectorBuilder):
* src/CompositionUnderlineVectorBuilder.h: Added.
* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::setInputMethodState):
* src/WebPopupMenuImpl.cpp:
(WebKit::WebPopupMenuImpl::setComposition):
(WebKit::WebPopupMenuImpl::confirmComposition):
(WebKit::WebPopupMenuImpl::textInputType):
(WebKit::WebPopupMenuImpl::caretOrSelectionBounds):
* src/WebPopupMenuImpl.h:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleCompositionEvent):
(WebKit::WebViewImpl::setComposition):
(WebKit::WebViewImpl::confirmComposition):
(WebKit::WebViewImpl::textInputType):
(WebKit::WebViewImpl::caretOrSelectionBounds):
* src/WebViewImpl.h:
2010-06-19 Victoria Kirst <vrk@google.com>
Reviewed by David Levin.
......
......@@ -94,6 +94,7 @@
'public/WebCommon.h',
'public/WebCommonWorkerClient.h',
'public/WebCompositionCommand.h',
'public/WebCompositionUnderline.h',
'public/WebConsoleMessage.h',
'public/WebContextMenuData.h',
'public/WebCookie.h',
......@@ -206,6 +207,7 @@
'public/WebTextAffinity.h',
'public/WebTextCaseSensitivity.h',
'public/WebTextDirection.h',
'public/WebTextInputType.h',
'public/WebThemeEngine.h',
'public/WebURL.h',
'public/WebURLError.h',
......@@ -241,6 +243,9 @@
'src/ChromiumBridge.cpp',
'src/ChromiumCurrentTime.cpp',
'src/ChromiumThreading.cpp',
'src/CompositionUnderlineBuilder.h',
'src/CompositionUnderlineVectorBuilder.cpp',
'src/CompositionUnderlineVectorBuilder.h',
'src/ContextMenuClientImpl.cpp',
'src/ContextMenuClientImpl.h',
'src/DatabaseObserver.cpp',
......
......@@ -33,6 +33,7 @@
namespace WebKit {
// DEPRECATED.
enum WebCompositionCommand {
WebCompositionCommandDiscard,
WebCompositionCommandSet,
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebCompositionUnderline_h
#define WebCompositionUnderline_h
#include "WebColor.h"
namespace WebKit {
// Class WebCompositionUnderline is intended to be used with WebWidget's
// setComposition() method.
struct WebCompositionUnderline {
WebCompositionUnderline()
: startOffset(0)
, endOffset(0)
, color(0)
, thick(false) { }
WebCompositionUnderline(unsigned s, unsigned e, WebColor c, bool t)
: startOffset(s)
, endOffset(e)
, color(c)
, thick(t) { }
unsigned startOffset;
unsigned endOffset;
WebColor color;
bool thick;
};
} // namespace WebKit
#endif
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebTextInputType_h
#define WebTextInputType_h
namespace WebKit {
enum WebTextInputType {
// Input caret is not in an editable node, no input method shall be used.
WebTextInputTypeNone,
// Input caret is in a normal editable node, any input method can be used.
WebTextInputTypeText,
// Input caret is in a password box, an input method may be used only if
// it's suitable for password input.
WebTextInputTypePassword,
// FIXME: Add more text input types when necessary, eg. Number,
// Date, Email, URL, etc.
};
} // namespace WebKit
#endif
......@@ -125,6 +125,8 @@ public:
virtual bool isSmartInsertDeleteEnabled() { return true; }
virtual bool isSelectTrailingWhitespaceEnabled() { return true; }
// DEPRECATED: replaced by WebWidgetClient::resetInputMethod().
virtual void setInputMethodEnabled(bool enabled) { }
virtual void didBeginEditing() { }
......
......@@ -34,6 +34,8 @@
#include "WebCanvas.h"
#include "WebCommon.h"
#include "WebCompositionCommand.h"
#include "WebCompositionUnderline.h"
#include "WebTextInputType.h"
#include "WebTextDirection.h"
namespace WebKit {
......@@ -42,6 +44,7 @@ class WebInputEvent;
class WebString;
struct WebRect;
struct WebSize;
template <typename T> class WebVector;
class WebWidget {
public:
......@@ -76,17 +79,39 @@ public:
// Called to inform the WebWidget that it has gained or lost keyboard focus.
virtual void setFocus(bool) = 0;
// Called to inform the WebWidget of a composition event.
// DEPRECATED. It's replaced by setComposition() and confirmComposition().
virtual bool handleCompositionEvent(WebCompositionCommand command,
int cursorPosition,
int targetStart,
int targetEnd,
const WebString& text) = 0;
// Retrieve the status of this WebWidget required by IME APIs. Upon
// success enabled and caretBounds are set.
// Called to inform the WebWidget of a new composition text.
// If selectionStart and selectionEnd has the same value, then it indicates
// the input caret position. If the text is empty, then the existing
// composition text will be cancelled.
// Returns true if the composition text was set successfully.
virtual bool setComposition(
const WebString& text,
const WebVector<WebCompositionUnderline>& underlines,
int selectionStart,
int selectionEnd) = 0;
// Called to inform the WebWidget to confirm an ongoing composition.
// Returns true if there is an ongoing composition.
virtual bool confirmComposition() = 0;
// DEPRECATED. It's replaced by textInputType() and
// caretOrSelectionBounds().
virtual bool queryCompositionStatus(bool* enabled, WebRect* caretBounds) = 0;
// Returns the current text input type of this WebWidget.
virtual WebTextInputType textInputType() = 0;
// Returns the current caret bounds of this WebWidget. The selection bounds
// will be returned if a selection range is available.
virtual WebRect caretOrSelectionBounds() = 0;
// Changes the text direction of the selected input node.
virtual void setTextDirection(WebTextDirection) = 0;
......
......@@ -83,6 +83,10 @@ public:
// displayed.
virtual WebScreenInfo screenInfo() { return WebScreenInfo(); }
// When this method gets called, WebWidgetClient implementation should
// reset the input method by cancelling any ongoing composition.
virtual void resetInputMethod() { }
protected:
~WebWidgetClient() { }
};
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CompositionUnderlineBuilder_h
#define CompositionUnderlineBuilder_h
#include "Editor.h"
#include "Vector.h"
#include "WebCompositionUnderline.h"
#include "WebVector.h"
namespace WebKit {
// This class is used for converting from WebCompositionUnderline to
// WebCore::CompositionUnderline.
class CompositionUnderlineBuilder : public WebCore::CompositionUnderline {
public:
CompositionUnderlineBuilder(const WebCompositionUnderline& u)
: WebCore::CompositionUnderline(u.startOffset, u.endOffset,
WebCore::Color(u.color), u.thick) { }
};
} // namespace WebKit
#endif
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "CompositionUnderlineVectorBuilder.h"
#include "CompositionUnderlineBuilder.h"
using namespace WebCore;
namespace WebKit {
CompositionUnderlineVectorBuilder::CompositionUnderlineVectorBuilder(
const WebVector<WebCompositionUnderline>& underlines)
{
size_t size = underlines.size();
reserveCapacity(size);
for (size_t i = 0; i < size; ++i)
append(CompositionUnderlineBuilder(underlines[i]));
}
} // namespace WebKit
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CompositionUnderlineVectorBuilder_h
#define CompositionUnderlineVectorBuilder_h
#include "Editor.h"
#include "Vector.h"
#include "WebCompositionUnderline.h"
#include "WebVector.h"
namespace WebKit {
// This classes are used for converting from std::vector<WebCompositionUnderline>
// to Vector<WebCore::CompositionUnderline>.
class CompositionUnderlineVectorBuilder :
public Vector<WebCore::CompositionUnderline> {
public:
CompositionUnderlineVectorBuilder(
const WebVector<WebCompositionUnderline>&);
};
} // namespace WebKit
#endif
......@@ -921,8 +921,13 @@ void EditorClientImpl::getGuessesForWord(const String&,
void EditorClientImpl::setInputMethodState(bool enabled)
{
if (m_webView->client())
if (m_webView->client()) {
m_webView->client()->resetInputMethod();
// Remove this line when WebViewClient::setInputMethodEnabled() gets
// removed.
m_webView->client()->setInputMethodEnabled(enabled);
}
}
} // namesace WebKit
......@@ -230,6 +230,7 @@ void WebPopupMenuImpl::setFocus(bool enable)
{
}
// DEPRECATED, will be removed later.
bool WebPopupMenuImpl::handleCompositionEvent(
WebCompositionCommand command, int cursorPosition, int targetStart,
int targetEnd, const WebString& imeString)
......@@ -237,11 +238,34 @@ bool WebPopupMenuImpl::handleCompositionEvent(
return false;
}
bool WebPopupMenuImpl::setComposition(
const WebString& text, const WebVector<WebCompositionUnderline>& underlines,
int selectionStart, int selectionEnd)
{
return false;
}
bool WebPopupMenuImpl::confirmComposition()
{
return false;
}
// DEPRECATED, will be removed later.
bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled, WebRect* caretRect)
{
return false;
}
WebTextInputType WebPopupMenuImpl::textInputType()
{
return WebTextInputTypeNone;
}
WebRect WebPopupMenuImpl::caretOrSelectionBounds()
{
return WebRect();
}
void WebPopupMenuImpl::setTextDirection(WebTextDirection direction)
{
}
......
......@@ -66,10 +66,21 @@ public:
virtual bool handleInputEvent(const WebInputEvent&);
virtual void mouseCaptureLost();
virtual void setFocus(bool enable);
// DEPRECATED, will be removed later.
virtual bool handleCompositionEvent(
WebCompositionCommand command, int cursorPosition,
int targetStart, int targetEnd, const WebString& text);
virtual bool setComposition(
const WebString& text,
const WebVector<WebCompositionUnderline>& underlines,
int selectionStart, int selectionEnd);
virtual bool confirmComposition();
// DEPRECATED, will be removed later.
virtual bool queryCompositionStatus(bool* enabled, WebRect* caretRect);
virtual WebTextInputType textInputType();
virtual WebRect caretOrSelectionBounds();
virtual void setTextDirection(WebTextDirection direction);
virtual bool isAcceleratedCompositingActive() const { return false; }
......
......@@ -35,6 +35,7 @@
#include "AutocompletePopupMenuClient.h"
#include "AXObjectCache.h"
#include "Chrome.h"
#include "CompositionUnderlineVectorBuilder.h"
#include "ContextMenu.h"
#include "ContextMenuController.h"
#include "ContextMenuItem.h"
......@@ -1191,11 +1192,53 @@ void WebViewImpl::setFocus(bool enable)
}
}
// DEPRECATED, will be removed later.
bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
int cursorPosition,
int targetStart,
int targetEnd,
const WebString& imeString)
{
if (command == WebKit::WebCompositionCommandSet) {
if (targetStart < 0)
targetStart = 0;
if (targetEnd < 0)
targetEnd = static_cast<int>(imeString.length());
// Create custom underlines.
// To emphasize the selection, the selected region uses a solid black
// for its underline while other regions uses a pale gray for theirs.
WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(3));
underlines[0].startOffset = 0;
underlines[0].endOffset = targetStart;
underlines[0].thick = true;
underlines[0].color = 0xffd3d3d3;
underlines[1].startOffset = targetStart;
underlines[1].endOffset = targetEnd;
underlines[1].thick = true;
underlines[1].color = 0xff000000;
underlines[2].startOffset = targetEnd;
underlines[2].endOffset = static_cast<unsigned>(imeString.length());
underlines[2].thick = true;
underlines[2].color = 0xffd3d3d3;
return setComposition(imeString, underlines, cursorPosition, cursorPosition);
}
if (command == WebKit::WebCompositionCommandDiscard)
setComposition(WebString(), WebVector<WebCompositionUnderline>(), 0, 0);
else if (command == WebKit::WebCompositionCommandConfirm) {
setComposition(imeString, WebVector<WebCompositionUnderline>(), 0, 0);
confirmComposition();
}
return true;
}
bool WebViewImpl::setComposition(
const WebString& text,
const WebVector<WebCompositionUnderline>& underlines,
int selectionStart,
int selectionEnd)
{
Frame* focused = focusedWebCoreFrame();
if (!focused || !m_imeAcceptEvents)
......@@ -1203,13 +1246,12 @@ bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
Editor* editor = focused->editor();
if (!editor)
return false;
if (!editor->canEdit()) {
// The input focus has been moved to another WebWidget object.
// We should use this |editor| object only to complete the ongoing
// composition.
if (!editor->hasComposition())
return false;