From c7c5328338c18e12e30f53d1663ab70a36a2f221 Mon Sep 17 00:00:00 2001 From: Elliott Sprehn Date: Mon, 26 Jan 2015 13:12:08 -0800 Subject: [PATCH] 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 --- engine/core/core.gni | 3 - engine/core/dom/Element.cpp | 10 -- engine/core/dom/Element.h | 4 - engine/core/dom/Element.idl | 2 - engine/core/dom/ElementRareData.cpp | 2 +- engine/core/dom/ElementRareData.h | 10 -- engine/core/events/EventTargetFactory.in | 1 - engine/core/html/ime/InputMethodContext.cpp | 180 -------------------- engine/core/html/ime/InputMethodContext.h | 93 ---------- engine/core/html/ime/InputMethodContext.idl | 39 ----- engine/public/web/WebWidget.h | 7 - engine/web/ChromeClientImpl.cpp | 1 + engine/web/SpellCheckerClientImpl.cpp | 1 + engine/web/WebViewImpl.cpp | 35 ---- engine/web/WebViewImpl.h | 7 - 15 files changed, 3 insertions(+), 392 deletions(-) delete mode 100644 engine/core/html/ime/InputMethodContext.cpp delete mode 100644 engine/core/html/ime/InputMethodContext.h delete mode 100644 engine/core/html/ime/InputMethodContext.idl diff --git a/engine/core/core.gni b/engine/core/core.gni index d5b36e2e9ca..d0f34954cc7 100644 --- a/engine/core/core.gni +++ b/engine/core/core.gni @@ -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", diff --git a/engine/core/dom/Element.cpp b/engine/core/dom/Element.cpp index bf7fc003347..70c4676387b 100644 --- a/engine/core/dom/Element.cpp +++ b/engine/core/dom/Element.cpp @@ -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()); diff --git a/engine/core/dom/Element.h b/engine/core/dom/Element.h index e2169b1907f..649094ab95a 100644 --- a/engine/core/dom/Element.h +++ b/engine/core/dom/Element.h @@ -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(); diff --git a/engine/core/dom/Element.idl b/engine/core/dom/Element.idl index 4419646aa52..e33cc64544a 100644 --- a/engine/core/dom/Element.idl +++ b/engine/core/dom/Element.idl @@ -74,8 +74,6 @@ [CustomElementCallbacks] attribute long tabIndex; - [RuntimeEnabled=IMEAPI] readonly attribute InputMethodContext inputMethodContext; - [CustomElementCallbacks, RaisesException=Setter] attribute DOMString contentEditable; readonly attribute boolean isContentEditable; diff --git a/engine/core/dom/ElementRareData.cpp b/engine/core/dom/ElementRareData.cpp index 76974cc8ffd..4dffcc00e29 100644 --- a/engine/core/dom/ElementRareData.cpp +++ b/engine/core/dom/ElementRareData.cpp @@ -38,7 +38,7 @@ namespace blink { struct SameSizeAsElementRareData : NodeRareData { short index; IntSize scrollOffset; - void* pointers[7]; + void* pointers[6]; }; CSSStyleDeclaration& ElementRareData::ensureInlineCSSStyleDeclaration(Element* ownerElement) diff --git a/engine/core/dom/ElementRareData.h b/engine/core/dom/ElementRareData.h index b592d1f3313..fd1661e4d39 100644 --- a/engine/core/dom/ElementRareData.h +++ b/engine/core/dom/ElementRareData.h @@ -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 definition) { m_customElementDefinition = definition; } CustomElementDefinition* customElementDefinition() const { return m_customElementDefinition.get(); } @@ -103,7 +94,6 @@ private: OwnPtr m_classList; OwnPtr m_shadow; - OwnPtr m_inputMethodContext; OwnPtr m_activeAnimations; OwnPtr m_cssomWrapper; diff --git a/engine/core/events/EventTargetFactory.in b/engine/core/events/EventTargetFactory.in index 4602cc1ad2e..5efeaf48f4c 100644 --- a/engine/core/events/EventTargetFactory.in +++ b/engine/core/events/EventTargetFactory.in @@ -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 diff --git a/engine/core/html/ime/InputMethodContext.cpp b/engine/core/html/ime/InputMethodContext.cpp deleted file mode 100644 index c7836b8646f..00000000000 --- a/engine/core/html/ime/InputMethodContext.cpp +++ /dev/null @@ -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::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 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& InputMethodContext::segments() -{ - m_segments.clear(); - if (!hasFocus()) - return m_segments; - const InputMethodController& controller = inputMethodController(); - if (!controller.hasComposition()) - return m_segments; - - Vector 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 diff --git a/engine/core/html/ime/InputMethodContext.h b/engine/core/html/ime/InputMethodContext.h deleted file mode 100644 index 047210386f5..00000000000 --- a/engine/core/html/ime/InputMethodContext.h +++ /dev/null @@ -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 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& 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 m_element; - Vector m_segments; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_HTML_IME_INPUTMETHODCONTEXT_H_ diff --git a/engine/core/html/ime/InputMethodContext.idl b/engine/core/html/ime/InputMethodContext.idl deleted file mode 100644 index d42f1593968..00000000000 --- a/engine/core/html/ime/InputMethodContext.idl +++ /dev/null @@ -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(); -}; diff --git a/engine/public/web/WebWidget.h b/engine/public/web/WebWidget.h index 491e4f2fec9..4a394aa61b9 100644 --- a/engine/public/web/WebWidget.h +++ b/engine/public/web/WebWidget.h @@ -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; diff --git a/engine/web/ChromeClientImpl.cpp b/engine/web/ChromeClientImpl.cpp index 92d024b6901..40ce3386ca5 100644 --- a/engine/web/ChromeClientImpl.cpp +++ b/engine/web/ChromeClientImpl.cpp @@ -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" diff --git a/engine/web/SpellCheckerClientImpl.cpp b/engine/web/SpellCheckerClientImpl.cpp index 9d8fa22f411..cd45d2eba3e 100644 --- a/engine/web/SpellCheckerClientImpl.cpp +++ b/engine/web/SpellCheckerClientImpl.cpp @@ -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" diff --git a/engine/web/WebViewImpl.cpp b/engine/web/WebViewImpl.cpp index 239a54874d7..68392427ce8 100644 --- a/engine/web/WebViewImpl.cpp +++ b/engine/web/WebViewImpl.cpp @@ -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 WebViewImpl::compositionUnderlines() const { const LocalFrame* focused = focusedCoreFrame(); diff --git a/engine/web/WebViewImpl.h b/engine/web/WebViewImpl.h index ba627f6307e..07fe0fe4da9 100644 --- a/engine/web/WebViewImpl.h +++ b/engine/web/WebViewImpl.h @@ -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;