Remove InputMethodContext.

We'll probably want a really different API in sky, and this just makes
ElementRareData bigger for now and isn't hooked up to anything.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/880663002
This commit is contained in:
Elliott Sprehn 2015-01-26 13:12:08 -08:00
parent 86f47baf88
commit c7c5328338
15 changed files with 3 additions and 392 deletions

View File

@ -890,8 +890,6 @@ sky_core_files = [
"html/HTMLTitleElement.h",
"html/ImageData.cpp",
"html/ImageData.h",
"html/ime/InputMethodContext.cpp",
"html/ime/InputMethodContext.h",
"html/imports/HTMLImport.cpp",
"html/imports/HTMLImport.h",
"html/imports/HTMLImportChild.cpp",
@ -1313,7 +1311,6 @@ core_idl_files = get_path_info([
"html/HTMLTitleElement.idl",
"html/HTMLTElement.idl",
"html/ImageData.idl",
"html/ime/InputMethodContext.idl",
"html/TextMetrics.idl",
"html/VoidCallback.idl",
"inspector/JavaScriptCallFrame.idl",

View File

@ -1559,16 +1559,6 @@ void Element::createUniqueElementData()
}
}
InputMethodContext& Element::inputMethodContext()
{
return ensureElementRareData().ensureInputMethodContext(toHTMLElement(this));
}
bool Element::hasInputMethodContext() const
{
return hasRareData() && elementRareData()->hasInputMethodContext();
}
void Element::synchronizeStyleAttributeInternal() const
{
ASSERT(isStyledElement());

View File

@ -50,7 +50,6 @@ class ElementRareData;
class ElementShadow;
class ExceptionState;
class Image;
class InputMethodContext;
class IntSize;
class MutableStylePropertySet;
class PropertySetCSSStyleDeclaration;
@ -272,9 +271,6 @@ public:
ActiveAnimations& ensureActiveAnimations();
bool hasActiveAnimations() const;
InputMethodContext& inputMethodContext();
bool hasInputMethodContext() const;
void synchronizeAttribute(const AtomicString& localName) const;
MutableStylePropertySet& ensureMutableInlineStyle();

View File

@ -74,8 +74,6 @@
[CustomElementCallbacks] attribute long tabIndex;
[RuntimeEnabled=IMEAPI] readonly attribute InputMethodContext inputMethodContext;
[CustomElementCallbacks, RaisesException=Setter] attribute DOMString contentEditable;
readonly attribute boolean isContentEditable;

View File

@ -38,7 +38,7 @@ namespace blink {
struct SameSizeAsElementRareData : NodeRareData {
short index;
IntSize scrollOffset;
void* pointers[7];
void* pointers[6];
};
CSSStyleDeclaration& ElementRareData::ensureInlineCSSStyleDeclaration(Element* ownerElement)

View File

@ -27,7 +27,6 @@
#include "sky/engine/core/dom/NodeRareData.h"
#include "sky/engine/core/dom/custom/CustomElementDefinition.h"
#include "sky/engine/core/dom/shadow/ElementShadow.h"
#include "sky/engine/core/html/ime/InputMethodContext.h"
#include "sky/engine/core/rendering/style/StyleInheritedData.h"
#include "sky/engine/wtf/OwnPtr.h"
@ -85,14 +84,6 @@ public:
m_activeAnimations = activeAnimations;
}
bool hasInputMethodContext() const { return m_inputMethodContext; }
InputMethodContext& ensureInputMethodContext(HTMLElement* element)
{
if (!m_inputMethodContext)
m_inputMethodContext = InputMethodContext::create(element);
return *m_inputMethodContext;
}
void setCustomElementDefinition(PassRefPtr<CustomElementDefinition> definition) { m_customElementDefinition = definition; }
CustomElementDefinition* customElementDefinition() const { return m_customElementDefinition.get(); }
@ -103,7 +94,6 @@ private:
OwnPtr<DOMTokenList> m_classList;
OwnPtr<ElementShadow> m_shadow;
OwnPtr<InputMethodContext> m_inputMethodContext;
OwnPtr<ActiveAnimations> m_activeAnimations;
OwnPtr<InlineCSSStyleDeclaration> m_cssomWrapper;

View File

@ -6,5 +6,4 @@ core/app/Module
core/css/FontFaceSet
core/css/MediaQueryList
core/dom/Node
core/html/ime/InputMethodContext
core/frame/Window ImplementedAs=LocalDOMWindow

View File

@ -1,180 +0,0 @@
/*
* Copyright (C) 2013 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 "sky/engine/config.h"
#include "sky/engine/core/html/ime/InputMethodContext.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/Text.h"
#include "sky/engine/core/editing/InputMethodController.h"
#include "sky/engine/core/events/Event.h"
#include "sky/engine/core/frame/LocalFrame.h"
namespace blink {
PassOwnPtr<InputMethodContext> InputMethodContext::create(HTMLElement* element)
{
return adoptPtr(new InputMethodContext(element));
}
InputMethodContext::InputMethodContext(HTMLElement* element)
: m_element(element)
{
}
InputMethodContext::~InputMethodContext()
{
}
String InputMethodContext::locale() const
{
// FIXME: Implement this.
return emptyString();
}
HTMLElement* InputMethodContext::target() const
{
return m_element;
}
unsigned InputMethodContext::compositionStartOffset()
{
if (hasFocus())
return inputMethodController().compositionStart();
return 0;
}
unsigned InputMethodContext::compositionEndOffset()
{
if (hasFocus())
return inputMethodController().compositionEnd();
return 0;
}
void InputMethodContext::confirmComposition()
{
if (hasFocus())
inputMethodController().confirmCompositionAndResetState();
}
bool InputMethodContext::hasFocus() const
{
LocalFrame* frame = m_element->document().frame();
if (!frame)
return false;
const Element* element = frame->document()->focusedElement();
return element && element->isHTMLElement() && m_element == toHTMLElement(element);
}
CompositionUnderline InputMethodContext::selectedSegment() const
{
CompositionUnderline underline;
if (!hasFocus())
return underline;
const InputMethodController& controller = inputMethodController();
if (!controller.hasComposition())
return underline;
Vector<CompositionUnderline> underlines = controller.customCompositionUnderlines();
for (size_t i = 0; i < underlines.size(); ++i) {
if (underlines[i].thick)
return underlines[i];
}
// When no underline information is available while composition exists,
// build a CompositionUnderline whose element is the whole composition.
underline.endOffset = controller.compositionEnd() - controller.compositionStart();
return underline;
}
int InputMethodContext::selectionStart() const
{
return selectedSegment().startOffset;
}
int InputMethodContext::selectionEnd() const
{
return selectedSegment().endOffset;
}
const Vector<unsigned>& InputMethodContext::segments()
{
m_segments.clear();
if (!hasFocus())
return m_segments;
const InputMethodController& controller = inputMethodController();
if (!controller.hasComposition())
return m_segments;
Vector<CompositionUnderline> underlines = controller.customCompositionUnderlines();
if (!underlines.size()) {
m_segments.append(0);
} else {
for (size_t i = 0; i < underlines.size(); ++i)
m_segments.append(underlines[i].startOffset);
}
return m_segments;
}
InputMethodController& InputMethodContext::inputMethodController() const
{
return m_element->document().frame()->inputMethodController();
}
const AtomicString& InputMethodContext::interfaceName() const
{
return EventTargetNames::InputMethodContext;
}
ExecutionContext* InputMethodContext::executionContext() const
{
return &m_element->document();
}
void InputMethodContext::dispatchCandidateWindowShowEvent()
{
dispatchEvent(Event::create(EventTypeNames::candidatewindowshow));
}
void InputMethodContext::dispatchCandidateWindowUpdateEvent()
{
dispatchEvent(Event::create(EventTypeNames::candidatewindowupdate));
}
void InputMethodContext::dispatchCandidateWindowHideEvent()
{
dispatchEvent(Event::create(EventTypeNames::candidatewindowhide));
}
} // namespace blink

View File

@ -1,93 +0,0 @@
/*
* Copyright (C) 2013 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 SKY_ENGINE_CORE_HTML_IME_INPUTMETHODCONTEXT_H_
#define SKY_ENGINE_CORE_HTML_IME_INPUTMETHODCONTEXT_H_
#include "sky/engine/core/editing/CompositionUnderline.h"
#include "sky/engine/core/events/EventTarget.h"
#include "sky/engine/core/html/HTMLElement.h"
#include "sky/engine/wtf/PassOwnPtr.h"
#include "sky/engine/wtf/RefPtr.h"
#include "sky/engine/wtf/text/AtomicString.h"
#include "sky/engine/wtf/text/WTFString.h"
namespace blink {
class ExecutionContext;
class InputMethodController;
class Node;
class InputMethodContext final : public EventTargetWithInlineData {
DEFINE_WRAPPERTYPEINFO();
public:
static PassOwnPtr<InputMethodContext> create(HTMLElement*);
virtual ~InputMethodContext();
#if !ENABLE(OILPAN)
void ref() { m_element->ref(); }
void deref() { m_element->deref(); }
#endif
String locale() const;
HTMLElement* target() const;
unsigned compositionStartOffset();
unsigned compositionEndOffset();
void confirmComposition();
int selectionStart() const;
int selectionEnd() const;
const Vector<unsigned>& segments();
virtual const AtomicString& interfaceName() const override;
virtual ExecutionContext* executionContext() const override;
void dispatchCandidateWindowShowEvent();
void dispatchCandidateWindowUpdateEvent();
void dispatchCandidateWindowHideEvent();
private:
InputMethodContext(HTMLElement*);
bool hasFocus() const;
CompositionUnderline selectedSegment() const;
InputMethodController& inputMethodController() const;
#if !ENABLE(OILPAN)
virtual void refEventTarget() override { ref(); }
virtual void derefEventTarget() override { deref(); }
#endif
RawPtr<HTMLElement> m_element;
Vector<unsigned> m_segments;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_HTML_IME_INPUTMETHODCONTEXT_H_

View File

@ -1,39 +0,0 @@
/*
* Copyright (C) 2013 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.
*/
// http://www.w3.org/TR/ime-api/
interface InputMethodContext : EventTarget {
readonly attribute DOMString locale;
readonly attribute HTMLElement target;
readonly attribute unsigned long compositionStartOffset;
readonly attribute unsigned long compositionEndOffset;
void confirmComposition();
};

View File

@ -119,13 +119,6 @@ public:
// Returns information about the current text input of this WebWidget.
virtual WebTextInputInfo textInputInfo() = 0;
// Called to notify that IME candidate window has changed its visibility or
// its appearance. These calls correspond to trigger
// candidatewindow{show,update,hide} events defined in W3C IME API.
virtual void didShowCandidateWindow() = 0;
virtual void didUpdateCandidateWindow() = 0;
virtual void didHideCandidateWindow() = 0;
// The page background color. Can be used for filling in areas without
// content.
virtual WebColor backgroundColor() const = 0;

View File

@ -35,6 +35,7 @@
#include "gen/sky/platform/RuntimeEnabledFeatures.h"
#include "sky/engine/bindings/core/v8/ScriptController.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/Element.h"
#include "sky/engine/core/dom/Node.h"
#include "sky/engine/core/events/KeyboardEvent.h"
#include "sky/engine/core/frame/Console.h"

View File

@ -28,6 +28,7 @@
#include "sky/engine/web/SpellCheckerClientImpl.h"
#include "sky/engine/core/dom/DocumentMarkerController.h"
#include "sky/engine/core/dom/Element.h"
#include "sky/engine/core/editing/Editor.h"
#include "sky/engine/core/editing/SpellChecker.h"
#include "sky/engine/core/frame/LocalFrame.h"

View File

@ -50,7 +50,6 @@
#include "sky/engine/core/frame/NewEventHandler.h"
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/html/HTMLImportElement.h"
#include "sky/engine/core/html/ime/InputMethodContext.h"
#include "sky/engine/core/loader/FrameLoader.h"
#include "sky/engine/core/loader/UniqueIdentifier.h"
#include "sky/engine/core/page/AutoscrollController.h"
@ -575,40 +574,6 @@ WebString WebViewImpl::inputModeOfFocusedElement()
return WebString();
}
InputMethodContext* WebViewImpl::inputMethodContext()
{
if (!m_imeAcceptEvents)
return 0;
LocalFrame* focusedFrame = focusedCoreFrame();
if (!focusedFrame)
return 0;
Element* target = focusedFrame->document()->focusedElement();
if (target && target->hasInputMethodContext())
return &target->inputMethodContext();
return 0;
}
void WebViewImpl::didShowCandidateWindow()
{
if (InputMethodContext* context = inputMethodContext())
context->dispatchCandidateWindowShowEvent();
}
void WebViewImpl::didUpdateCandidateWindow()
{
if (InputMethodContext* context = inputMethodContext())
context->dispatchCandidateWindowUpdateEvent();
}
void WebViewImpl::didHideCandidateWindow()
{
if (InputMethodContext* context = inputMethodContext())
context->dispatchCandidateWindowHideEvent();
}
WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const
{
const LocalFrame* focused = focusedCoreFrame();

View File

@ -31,7 +31,6 @@
#ifndef SKY_ENGINE_WEB_WEBVIEWIMPL_H_
#define SKY_ENGINE_WEB_WEBVIEWIMPL_H_
#include "sky/engine/core/html/ime/InputMethodContext.h"
#include "sky/engine/platform/geometry/IntPoint.h"
#include "sky/engine/platform/geometry/IntRect.h"
#include "sky/engine/public/platform/WebInputEvent.h"
@ -84,10 +83,6 @@ public:
virtual WebTextInputInfo textInputInfo() override;
virtual WebColor backgroundColor() const override;
virtual void didShowCandidateWindow() override;
virtual void didUpdateCandidateWindow() override;
virtual void didHideCandidateWindow() override;
// WebView methods:
virtual void setMainFrame(WebFrame*) override;
virtual void injectModule(const WebString&) override;
@ -217,8 +212,6 @@ private:
void doComposite();
void reallocateRenderer();
InputMethodContext* inputMethodContext();
WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
WebSpellCheckClient* m_spellCheckClient;