From b1225d076ec386506e31cbbf0f875f8ac892dcfc Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 28 Jan 2015 15:27:32 +0900 Subject: [PATCH] Bug 917322 part.14 Remove sendCompositionEvent() and createCompositionStringSynthesizer() of nsIDOMWindowUtils and nsICompositionStringSynthesizer r=smaug, sr=smaug --- CLOBBER | 2 +- dom/base/CompositionStringSynthesizer.cpp | 66 ----------- dom/base/CompositionStringSynthesizer.h | 36 ------ dom/base/moz.build | 1 - dom/base/nsDOMWindowUtils.cpp | 104 ------------------ dom/base/nsDOMWindowUtils.h | 11 -- dom/interfaces/base/moz.build | 1 - .../base/nsICompositionStringSynthesizer.idl | 53 --------- dom/interfaces/base/nsIDOMWindowUtils.idl | 30 +---- 9 files changed, 2 insertions(+), 302 deletions(-) delete mode 100644 dom/base/CompositionStringSynthesizer.cpp delete mode 100644 dom/base/CompositionStringSynthesizer.h delete mode 100644 dom/interfaces/base/nsICompositionStringSynthesizer.idl diff --git a/CLOBBER b/CLOBBER index e5e034becacf..c591cfb00791 100644 --- a/CLOBBER +++ b/CLOBBER @@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -bug 1114669 removes nsIStreamCipher.idl, which requires a clobber according to bug 1114669 +Bug 917322 - Due to removing nsICompositionStringSynthesizer.idl diff --git a/dom/base/CompositionStringSynthesizer.cpp b/dom/base/CompositionStringSynthesizer.cpp deleted file mode 100644 index 1e82243ac08e..000000000000 --- a/dom/base/CompositionStringSynthesizer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "CompositionStringSynthesizer.h" -#include "nsContentUtils.h" -#include "nsIDocShell.h" -#include "nsIFrame.h" -#include "nsIPresShell.h" -#include "nsIWidget.h" -#include "nsPIDOMWindow.h" -#include "nsView.h" -#include "mozilla/TextEvents.h" - -namespace mozilla { -namespace dom { - -NS_IMPL_ISUPPORTS(CompositionStringSynthesizer, - nsICompositionStringSynthesizer) - -CompositionStringSynthesizer::CompositionStringSynthesizer( - TextEventDispatcher* aDispatcher) - : mDispatcher(aDispatcher) -{ -} - -CompositionStringSynthesizer::~CompositionStringSynthesizer() -{ -} - -NS_IMETHODIMP -CompositionStringSynthesizer::SetString(const nsAString& aString) -{ - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - return mDispatcher->SetPendingCompositionString(aString); -} - -NS_IMETHODIMP -CompositionStringSynthesizer::AppendClause(uint32_t aLength, - uint32_t aAttribute) -{ - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - return mDispatcher->AppendClauseToPendingComposition(aLength, aAttribute); -} - -NS_IMETHODIMP -CompositionStringSynthesizer::SetCaret(uint32_t aOffset, uint32_t aLength) -{ - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - return mDispatcher->SetCaretInPendingComposition(aOffset, aLength); -} - -NS_IMETHODIMP -CompositionStringSynthesizer::DispatchEvent(bool* aDefaultPrevented) -{ - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - NS_ENSURE_ARG_POINTER(aDefaultPrevented); - nsEventStatus status = nsEventStatus_eIgnore; - nsresult rv = mDispatcher->FlushPendingComposition(status); - *aDefaultPrevented = (status == nsEventStatus_eConsumeNoDefault); - return rv; -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/base/CompositionStringSynthesizer.h b/dom/base/CompositionStringSynthesizer.h deleted file mode 100644 index bf77b85f1ecd..000000000000 --- a/dom/base/CompositionStringSynthesizer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_compositionstringsynthesizer_h__ -#define mozilla_dom_compositionstringsynthesizer_h__ - -#include "nsICompositionStringSynthesizer.h" - -#include "mozilla/TextEventDispatcher.h" - -namespace mozilla { -namespace dom { - -class CompositionStringSynthesizer MOZ_FINAL : - public nsICompositionStringSynthesizer -{ - typedef mozilla::widget::TextEventDispatcher TextEventDispatcher; - -public: - explicit CompositionStringSynthesizer(TextEventDispatcher* aDispatcher); - - NS_DECL_ISUPPORTS - NS_DECL_NSICOMPOSITIONSTRINGSYNTHESIZER - -private: - ~CompositionStringSynthesizer(); - - nsRefPtr mDispatcher; -}; - -} // namespace dom -} // namespace mozilla - -#endif // #ifndef mozilla_dom_compositionstringsynthesizer_h__ diff --git a/dom/base/moz.build b/dom/base/moz.build index f50cccb3d359..7c22caf00117 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -202,7 +202,6 @@ UNIFIED_SOURCES += [ 'BarProps.cpp', 'ChildIterator.cpp', 'Comment.cpp', - 'CompositionStringSynthesizer.cpp', 'Console.cpp', 'Crypto.cpp', 'DirectionalityUtils.cpp', diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 236185662b07..95f7d88e5504 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -13,7 +13,6 @@ #include "nsError.h" #include "nsIDOMEvent.h" #include "nsQueryContentEventResult.h" -#include "CompositionStringSynthesizer.h" #include "nsGlobalWindow.h" #include "nsIDocument.h" #include "nsFocusManager.h" @@ -2134,109 +2133,6 @@ InitEvent(WidgetGUIEvent& aEvent, LayoutDeviceIntPoint* aPt = nullptr) aEvent.time = PR_IntervalNow(); } -nsresult -nsDOMWindowUtils::GetTextEventDispatcher(TextEventDispatcher** aDispatcher) -{ - if (!aDispatcher) { - return NS_ERROR_INVALID_ARG; - } - *aDispatcher = nullptr; - - nsCOMPtr widget(GetWidget()); - if (NS_WARN_IF(!widget)) { - return NS_ERROR_FAILURE; - } - - TextEventDispatcher* dispatcher = widget->GetTextEventDispatcher(); - nsresult rv = dispatcher->GetState(); - if (NS_SUCCEEDED(rv)) { - NS_ADDREF(*aDispatcher = dispatcher); - return NS_OK; - } - if (rv == NS_ERROR_NOT_INITIALIZED) { - rv = dispatcher->InitForTests(); - } - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - NS_ADDREF(*aDispatcher = dispatcher); - return NS_OK; -} - -NS_IMETHODIMP -nsDOMWindowUtils::SendCompositionEvent(const nsAString& aType, - const nsAString& aData, - const nsAString& aLocale) -{ - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - - // get the widget to send the event to - nsCOMPtr widget = GetWidget(); - if (!widget) { - return NS_ERROR_FAILURE; - } - - if (aType.EqualsLiteral("compositionend")) { - // Now we don't support manually dispatching composition end with this - // API. A compositionend is dispatched when this is called with - // compositioncommitasis or compositioncommit automatically. For backward - // compatibility, this shouldn't return error in this case. - NS_WARNING("Don't call nsIDOMWindowUtils.sendCompositionEvent() for " - "compositionend. Instead, use it with compositioncommitasis or " - "compositioncommit. Then, compositionend will be automatically " - "dispatched."); - return NS_OK; - } else if (aType.EqualsLiteral("compositionupdate")) { - // Now we don't support manually dispatching composition update with this - // API. A compositionupdate is dispatched when a DOM text event modifies - // composition string automatically. For backward compatibility, this - // shouldn't return error in this case. - NS_WARNING("Don't call nsIDOMWindowUtils.sendCompositionEvent() for " - "compositionupdate since it's ignored and the event is " - "fired automatically when it's necessary"); - return NS_OK; - } - - nsRefPtr dispatcher; - nsresult rv = GetTextEventDispatcher(getter_AddRefs(dispatcher)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - nsEventStatus status = nsEventStatus_eIgnore; - if (aType.EqualsLiteral("compositionstart")) { - return dispatcher->StartComposition(status); - } - if (aType.EqualsLiteral("compositioncommitasis")) { - return dispatcher->CommitComposition(status); - } - if (aType.EqualsLiteral("compositioncommit")) { - return dispatcher->CommitComposition(status, &aData); - } - return NS_ERROR_INVALID_ARG; -} - -NS_IMETHODIMP -nsDOMWindowUtils::CreateCompositionStringSynthesizer( - nsICompositionStringSynthesizer** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - *aResult = nullptr; - - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); - - nsCOMPtr widget = GetWidget(); - if (NS_WARN_IF(!widget)) { - return NS_ERROR_FAILURE; - } - nsRefPtr dispatcher; - nsresult rv = GetTextEventDispatcher(getter_AddRefs(dispatcher)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - NS_ADDREF(*aResult = new CompositionStringSynthesizer(dispatcher)); - return NS_OK; -} - NS_IMETHODIMP nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType, uint32_t aOffset, uint32_t aLength, diff --git a/dom/base/nsDOMWindowUtils.h b/dom/base/nsDOMWindowUtils.h index ba3dd3057919..3bb656c5ed98 100644 --- a/dom/base/nsDOMWindowUtils.h +++ b/dom/base/nsDOMWindowUtils.h @@ -80,17 +80,6 @@ protected: nsPresContext* GetPresContext(); nsIDocument* GetDocument(); mozilla::layers::LayerTransactionChild* GetLayerTransaction(); - /** - * GetTextEventDispatcher() retrieves a TextEventDispatcher - * belonging to the widget (result of GetWidget()) and initializes it. - * - * @param [out] aDispatcher The TextEventDispatcher belonging to - * the widget which has already been - * initialized and addrefed. - * @return The result of TextEventDispatcher::InitForTest(). - */ - nsresult GetTextEventDispatcher( - TextEventDispatcher** aDispatcher); nsView* GetViewToDispatchEvent(nsPresContext* presContext, nsIPresShell** presShell); diff --git a/dom/interfaces/base/moz.build b/dom/interfaces/base/moz.build index f48f75623537..286562ef768f 100644 --- a/dom/interfaces/base/moz.build +++ b/dom/interfaces/base/moz.build @@ -7,7 +7,6 @@ XPIDL_SOURCES += [ 'domstubs.idl', 'nsIBrowserDOMWindow.idl', - 'nsICompositionStringSynthesizer.idl', 'nsIContentPermissionPrompt.idl', 'nsIContentPrefService.idl', 'nsIContentPrefService2.idl', diff --git a/dom/interfaces/base/nsICompositionStringSynthesizer.idl b/dom/interfaces/base/nsICompositionStringSynthesizer.idl deleted file mode 100644 index a7d2770b4712..000000000000 --- a/dom/interfaces/base/nsICompositionStringSynthesizer.idl +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -/** - * Stores composition clauses information and caret information for synthesizing - * composition string. - */ - -[scriptable, uuid(9a7d7851-8c0a-4061-9edc-60d6693f86c9)] -interface nsICompositionStringSynthesizer : nsISupports -{ - /** - * Set composition string or committed string. - */ - void setString(in AString aString); - - // NOTE: These values must be same to NS_TEXTRANGE_* in TextEvents.h - const unsigned long ATTR_RAWINPUT = 0x02; - const unsigned long ATTR_SELECTEDRAWTEXT = 0x03; - const unsigned long ATTR_CONVERTEDTEXT = 0x04; - const unsigned long ATTR_SELECTEDCONVERTEDTEXT = 0x05; - - /** - * Append a clause. - * - * TODO: Should be able to specify custom clause style. - */ - void appendClause(in unsigned long aLength, - in unsigned long aAttribute); - - /** - * Set caret information. - */ - void setCaret(in unsigned long aOffset, - in unsigned long aLength); - - /** - * Synthesize composition string with given information by dispatching - * a proper event. - * - * If clauses have never been set, this dispatches a commit event. - * If clauses are not filled all over the composition string, this throw an - * error. - * - * After dispatching event, this clears all the information about the - * composition string. So, you can reuse this instance. - */ - bool dispatchEvent(); -}; diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 11c86b480567..1c4d7e76d816 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -46,12 +46,11 @@ interface nsIDOMClientRect; interface nsIURI; interface nsIDOMEventTarget; interface nsIRunnable; -interface nsICompositionStringSynthesizer; interface nsITranslationNodeList; interface nsIJSRAIIHelper; interface nsIContentPermissionRequest; -[scriptable, uuid(0281e107-394d-4c96-830b-2f830b07c6c0)] +[scriptable, uuid(04db2684-f9ed-4d70-827d-3d5b87825238)] interface nsIDOMWindowUtils : nsISupports { /** @@ -1035,33 +1034,6 @@ interface nsIDOMWindowUtils : nsISupports { void sendContentCommandEvent(in AString aType, [optional] in nsITransferable aTransferable); - /** - * Synthesize a composition event to the window. - * - * Cannot be accessed from unprivileged context (not content-accessible) - * Will throw a DOM security error if called without chrome privileges. - * - * @param aType The event type: "compositionstart", - * "compositioncommitasis", or "compositioncommit". - * @param aData The data property value. Note that this isn't applied - * for compositionstart event because its value is the - * selected text which is automatically computed. And also - * this isn't applied for compositioncommitasis because - * the last data will be set automatically. - * @param aLocale The locale property value. - */ - void sendCompositionEvent(in AString aType, - in AString aData, - in AString aLocale); - - /** - * Creating synthesizer of composition string on the window. - * - * Cannot be accessed from unprivileged context (not content-accessible) - * Will throw a DOM security error if called without chrome privileges. - */ - nsICompositionStringSynthesizer createCompositionStringSynthesizer(); - /** * If sendQueryContentEvent()'s aAdditionalFlags argument is * QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK, plain text generated from content