зеркало из https://github.com/mozilla/gecko-dev.git
Bug 327003 Don't commit the IME composition string when Mozilla is deactivated r=roc+masaki.katakai+timeless sr=roc
This commit is contained in:
Родитель
152c9dd6c3
Коммит
6fb048961a
|
@ -52,10 +52,10 @@ class imgIContainer;
|
|||
/*
|
||||
* Event state manager interface.
|
||||
*/
|
||||
// {1dbe2518-06a1-461c-a1fd-dfbfb0ac0635}
|
||||
// {14E5E066-E60A-446b-965F-A9ECAA7098F3}
|
||||
#define NS_IEVENTSTATEMANAGER_IID \
|
||||
{ 0x1dbe2518, 0x6a1, 0x461c, \
|
||||
{ 0xa1, 0xfd, 0xdf, 0xbf, 0xb0, 0xac, 0x6, 0x35 } }
|
||||
{ 0x14e5e066, 0xe60a, 0x446b, \
|
||||
{ 0x96, 0x5f, 0xa9, 0xec, 0xaa, 0x70, 0x98, 0xf3 } }
|
||||
|
||||
|
||||
#define NS_EVENT_NEEDS_FRAME(event) (!NS_IS_FOCUS_EVENT(event))
|
||||
|
@ -143,6 +143,8 @@ public:
|
|||
|
||||
// Method for moving the focus forward/back.
|
||||
NS_IMETHOD ShiftFocus(PRBool aDirection, nsIContent* aStart)=0;
|
||||
|
||||
NS_IMETHOD NotifyDestroyPresContext(nsPresContext* aPresContext) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIEventStateManager, NS_IEVENTSTATEMANAGER_IID)
|
||||
|
|
|
@ -82,6 +82,7 @@ CPPSRCS = \
|
|||
nsXMLEventsElement.cpp \
|
||||
nsPLDOMEvent.cpp \
|
||||
nsEventDispatcher.cpp \
|
||||
nsIMEStateManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -626,7 +627,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
// "leak" this reference, but we take it back later
|
||||
SetFocusedContent(nsnull);
|
||||
|
||||
UpdateIMEState(aPresContext, currentFocus);
|
||||
nsIMEStateManager::OnChangeFocus(mPresContext, currentFocus);
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent focusevent(PR_TRUE, NS_FOCUS_CONTENT);
|
||||
|
@ -814,10 +815,13 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
nsCOMPtr<nsIPresShell> shell = document->GetShellAt(0);
|
||||
NS_ASSERTION(shell, "Focus events should not be getting thru when this is null!");
|
||||
if (shell) {
|
||||
nsPresContext* context = shell->GetPresContext();
|
||||
nsIMEStateManager::OnActivate(context);
|
||||
if (focusedElement) {
|
||||
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(focusedElement);
|
||||
nsCOMPtr<nsPresContext> context = shell->GetPresContext();
|
||||
focusContent->SetFocus(context);
|
||||
} else {
|
||||
nsIMEStateManager::OnChangeFocus(context, nsnull);
|
||||
}
|
||||
|
||||
// disable selection mousedown state on activation
|
||||
|
@ -853,6 +857,8 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
{
|
||||
EnsureDocument(aPresContext);
|
||||
|
||||
nsIMEStateManager::OnDeactivate(aPresContext);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow(mDocument->GetWindow());
|
||||
|
||||
// Suppress the focus controller for the duration of the
|
||||
|
@ -2276,10 +2282,18 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
return ret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::NotifyDestroyPresContext(nsPresContext* aPresContext)
|
||||
{
|
||||
nsIMEStateManager::OnDestroyPresContext(aPresContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetPresContext(nsPresContext* aPresContext)
|
||||
{
|
||||
if (aPresContext == nsnull) {
|
||||
// XXX should we move this block to |NotifyDestroyPresContext|?
|
||||
// A pres context is going away. Make sure we do cleanup.
|
||||
if (mPresContext == gLastFocusedPresContext) {
|
||||
gLastFocusedPresContext = nsnull;
|
||||
|
@ -3836,6 +3850,7 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
|||
|
||||
if ((aState & NS_EVENT_STATE_FOCUS)) {
|
||||
EnsureDocument(mPresContext);
|
||||
nsIMEStateManager::OnChangeFocus(mPresContext, aContent);
|
||||
if (aContent && (aContent == mCurrentFocus) && gLastFocusedDocument == mDocument) {
|
||||
// gLastFocusedDocument appears to always be correct, that is why
|
||||
// I'm not setting it here. This is to catch an edge case.
|
||||
|
@ -3857,7 +3872,6 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
|||
}
|
||||
notifyContent[2] = gLastFocusedContent;
|
||||
NS_IF_ADDREF(gLastFocusedContent);
|
||||
UpdateIMEState(mPresContext, aContent);
|
||||
// only raise window if the the focus controller is active
|
||||
SendFocusBlur(mPresContext, aContent, fcActive);
|
||||
if (mCurrentFocus != aContent) {
|
||||
|
@ -4406,7 +4420,7 @@ nsEventStateManager::ContentRemoved(nsIContent* aContent)
|
|||
// Note that we don't use SetContentState() here because
|
||||
// we don't want to fire a blur. Blurs should only be fired
|
||||
// in response to clicks or tabbing.
|
||||
UpdateIMEState(mPresContext, nsnull);
|
||||
nsIMEStateManager::OnRemoveContent(mPresContext, mCurrentFocus);
|
||||
SetFocusedContent(nsnull);
|
||||
}
|
||||
|
||||
|
@ -5391,80 +5405,3 @@ nsEventStateManager::GetFocusControllerForDocument(nsIDocument* aDocument)
|
|||
return windowPrivate ? windowPrivate->GetRootFocusController() : nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::UpdateIMEState(nsPresContext* aPresContext,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
if (!aPresContext)
|
||||
return;
|
||||
|
||||
// On Printing or Print Preview, we don't need IME.
|
||||
if (aPresContext->Type() == nsPresContext::eContext_PrintPreview ||
|
||||
aPresContext->Type() == nsPresContext::eContext_Print) {
|
||||
SetIMEState(aPresContext, nsIContent::IME_STATUS_DISABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
PRUint32 state = nsIContent::IME_STATUS_DISABLE;
|
||||
|
||||
PRBool isEditable = PR_FALSE;
|
||||
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
|
||||
nsCOMPtr<nsIEditorDocShell> editorDocShell(do_QueryInterface(container));
|
||||
if (editorDocShell)
|
||||
editorDocShell->GetEditable(&isEditable);
|
||||
|
||||
if (isEditable)
|
||||
state = nsIContent::IME_STATUS_ENABLE;
|
||||
else if (aContent)
|
||||
state = aContent->GetDesiredIMEState();
|
||||
|
||||
if (state == nsIContent::IME_STATUS_NONE)
|
||||
return;
|
||||
SetIMEState(aPresContext, state);
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::SetIMEState(nsPresContext* aPresContext,
|
||||
PRUint32 aState)
|
||||
{
|
||||
if (!aPresContext)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIKBStateControl> kb;
|
||||
nsresult rv = GetKBStateControl(aPresContext, getter_AddRefs(kb));
|
||||
if (NS_FAILED(rv) || !kb)
|
||||
return;
|
||||
|
||||
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
|
||||
PRBool enable = (aState & nsIContent::IME_STATUS_ENABLE);
|
||||
kb->SetIMEEnabled(enable);
|
||||
}
|
||||
if (aState & nsIContent::IME_STATUS_MASK_OPENED) {
|
||||
PRBool open = (aState & nsIContent::IME_STATUS_OPEN);
|
||||
kb->SetIMEOpenState(open);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEventStateManager::GetKBStateControl(nsPresContext* aPresContext,
|
||||
nsIKBStateControl** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = nsnull;
|
||||
nsIViewManager* vm = aPresContext->GetViewManager();
|
||||
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIWidget> widget = nsnull;
|
||||
nsresult rv = vm->GetWidget(getter_AddRefs(widget));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIKBStateControl> kb = do_QueryInterface(widget);
|
||||
// Don't use NS_ENSURE_TRUE. Because nsIWidget is not having
|
||||
// nsIKBStateControl always. e.g., GTK2, OS/2, BeOS...
|
||||
if (!kb)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ADDREF(*aResult = kb);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ class nsIDocShell;
|
|||
class nsIDocShellTreeNode;
|
||||
class nsIDocShellTreeItem;
|
||||
class nsIFocusController;
|
||||
class nsIKBStateControl;
|
||||
class imgIContainer;
|
||||
|
||||
// mac uses click-hold context menus, a holdover from 4.x
|
||||
|
@ -108,6 +107,7 @@ public:
|
|||
nsEventStatus* aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
NS_IMETHOD NotifyDestroyPresContext(nsPresContext* aPresContext);
|
||||
NS_IMETHOD SetPresContext(nsPresContext* aPresContext);
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
|
||||
|
||||
|
@ -219,11 +219,6 @@ protected:
|
|||
} ProcessingAccessKeyState;
|
||||
void HandleAccessKey(nsPresContext* aPresContext, nsKeyEvent* aEvent, nsEventStatus* aStatus, PRInt32 aChildOffset, ProcessingAccessKeyState aAccessKeyState);
|
||||
|
||||
void UpdateIMEState(nsPresContext* aPresContext, nsIContent* aContent);
|
||||
void SetIMEState(nsPresContext* aPresContext, PRUint32 aState);
|
||||
nsresult GetKBStateControl(nsPresContext* aPresContext,
|
||||
nsIKBStateControl** aResult);
|
||||
|
||||
//---------------------------------------------
|
||||
// DocShell Focus Traversal Methods
|
||||
//---------------------------------------------
|
||||
|
|
|
@ -0,0 +1,266 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 et tw=80: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Japan.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIViewObserver.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIEditorDocShell.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIKBStateControl.h"
|
||||
#include "nsIFocusController.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
/******************************************************************/
|
||||
/* nsIMEStateManager */
|
||||
/******************************************************************/
|
||||
|
||||
nsIContent* nsIMEStateManager::sContent = nsnull;
|
||||
nsPresContext* nsIMEStateManager::sPresContext = nsnull;
|
||||
nsPIDOMWindow* nsIMEStateManager::sActiveWindow = nsnull;
|
||||
|
||||
nsresult
|
||||
nsIMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
if (aPresContext != sPresContext)
|
||||
return NS_OK;
|
||||
sContent = nsnull;
|
||||
sPresContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
if (!sPresContext || !sContent ||
|
||||
aPresContext != sPresContext ||
|
||||
aContent != sContent)
|
||||
return NS_OK;
|
||||
|
||||
// Current IME transaction should commit
|
||||
nsIKBStateControl* kb = GetKBStateControl(sPresContext);
|
||||
if (kb) {
|
||||
nsresult rv = kb->CancelIMEComposition();
|
||||
if (NS_FAILED(rv))
|
||||
kb->ResetInputState();
|
||||
}
|
||||
|
||||
sContent = nsnull;
|
||||
sPresContext = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
|
||||
if (!IsActive(aPresContext)) {
|
||||
// The actual focus isn't changing, because this presContext isn't active.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIKBStateControl* kb = GetKBStateControl(aPresContext);
|
||||
if (!kb) {
|
||||
// This platform doesn't support IME controlling
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 newState = GetNewIMEState(aPresContext, aContent);
|
||||
if (aPresContext == sPresContext && aContent == sContent) {
|
||||
// actual focus isn't changing, but if IME enabled state is changing,
|
||||
// we should do it.
|
||||
PRUint32 newEnabledState = newState & nsIContent::IME_STATUS_MASK_ENABLED;
|
||||
if (newEnabledState == 0) {
|
||||
// the enabled state isn't changing, we should do nothing.
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool enabled;
|
||||
if (NS_FAILED(kb->GetIMEEnabled(&enabled))) {
|
||||
// this platform doesn't support IME controlling
|
||||
return NS_OK;
|
||||
}
|
||||
if ((enabled && newEnabledState == nsIContent::IME_STATUS_ENABLE) ||
|
||||
(!enabled && newEnabledState == nsIContent::IME_STATUS_DISABLE)) {
|
||||
// the enabled state isn't changing.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Current IME transaction should commit
|
||||
if (sPresContext) {
|
||||
nsIKBStateControl* oldKB;
|
||||
if (sPresContext == aPresContext)
|
||||
oldKB = kb;
|
||||
else
|
||||
oldKB = GetKBStateControl(sPresContext);
|
||||
if (oldKB)
|
||||
oldKB->ResetInputState();
|
||||
}
|
||||
|
||||
if (newState != nsIContent::IME_STATUS_NONE) {
|
||||
// Update IME state for new focus widget
|
||||
SetIMEState(aPresContext, newState, kb);
|
||||
}
|
||||
|
||||
sPresContext = aPresContext;
|
||||
sContent = aContent;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIMEStateManager::OnActivate(nsPresContext* aPresContext)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
NS_ENSURE_TRUE(aPresContext->GetDocument(), NS_ERROR_FAILURE);
|
||||
sActiveWindow = aPresContext->GetDocument()->GetWindow();
|
||||
NS_ENSURE_TRUE(sActiveWindow, NS_ERROR_FAILURE);
|
||||
sActiveWindow = sActiveWindow->GetPrivateRoot();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIMEStateManager::OnDeactivate(nsPresContext* aPresContext)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
NS_ENSURE_TRUE(aPresContext->GetDocument(), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(aPresContext->GetDocument()->GetWindow(), NS_ERROR_FAILURE);
|
||||
if (sActiveWindow ==
|
||||
aPresContext->GetDocument()->GetWindow()->GetPrivateRoot())
|
||||
sActiveWindow = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsIMEStateManager::IsActive(nsPresContext* aPresContext)
|
||||
{
|
||||
NS_ENSURE_TRUE(aPresContext->GetDocument(), PR_FALSE);
|
||||
nsPIDOMWindow* window = aPresContext->GetDocument()->GetWindow();
|
||||
NS_ENSURE_TRUE(window, PR_FALSE);
|
||||
if (!sActiveWindow || sActiveWindow != window->GetPrivateRoot()) {
|
||||
// This root window is not active.
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsIViewManager* vm = aPresContext->GetViewManager();
|
||||
NS_ENSURE_TRUE(vm, PR_FALSE);
|
||||
nsCOMPtr<nsIViewObserver> observer;
|
||||
vm->GetViewObserver(*getter_AddRefs(observer));
|
||||
NS_ENSURE_TRUE(observer, PR_FALSE);
|
||||
return observer->IsVisible();
|
||||
}
|
||||
|
||||
nsIFocusController*
|
||||
nsIMEStateManager::GetFocusController(nsPresContext* aPresContext)
|
||||
{
|
||||
if (!aPresContext->GetDocument())
|
||||
return nsnull;
|
||||
nsCOMPtr<nsISupports> container =
|
||||
aPresContext->GetDocument()->GetContainer();
|
||||
nsCOMPtr<nsPIDOMWindow> windowPrivate = do_GetInterface(container);
|
||||
|
||||
return windowPrivate ? windowPrivate->GetRootFocusController() : nsnull;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsIMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
// On Printing or Print Preview, we don't need IME.
|
||||
if (aPresContext->Type() == nsPresContext::eContext_PrintPreview ||
|
||||
aPresContext->Type() == nsPresContext::eContext_Print) {
|
||||
return nsIContent::IME_STATUS_DISABLE;
|
||||
}
|
||||
|
||||
PRBool isEditable = PR_FALSE;
|
||||
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
|
||||
nsCOMPtr<nsIEditorDocShell> editorDocShell(do_QueryInterface(container));
|
||||
if (editorDocShell)
|
||||
editorDocShell->GetEditable(&isEditable);
|
||||
|
||||
if (isEditable)
|
||||
return nsIContent::IME_STATUS_ENABLE;
|
||||
|
||||
if (aContent)
|
||||
return aContent->GetDesiredIMEState();
|
||||
|
||||
return nsIContent::IME_STATUS_DISABLE;
|
||||
}
|
||||
|
||||
void
|
||||
nsIMEStateManager::SetIMEState(nsPresContext* aPresContext,
|
||||
PRUint32 aState,
|
||||
nsIKBStateControl* aKB)
|
||||
{
|
||||
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
|
||||
PRBool enable = (aState & nsIContent::IME_STATUS_ENABLE);
|
||||
aKB->SetIMEEnabled(enable);
|
||||
}
|
||||
if (aState & nsIContent::IME_STATUS_MASK_OPENED) {
|
||||
PRBool open = (aState & nsIContent::IME_STATUS_OPEN);
|
||||
aKB->SetIMEOpenState(open);
|
||||
}
|
||||
}
|
||||
|
||||
nsIKBStateControl*
|
||||
nsIMEStateManager::GetKBStateControl(nsPresContext* aPresContext)
|
||||
{
|
||||
nsIViewManager* vm = aPresContext->GetViewManager();
|
||||
if (!vm)
|
||||
return nsnull;
|
||||
nsCOMPtr<nsIWidget> widget = nsnull;
|
||||
nsresult rv = vm->GetWidget(getter_AddRefs(widget));
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
NS_ENSURE_TRUE(widget, nsnull);
|
||||
nsCOMPtr<nsIKBStateControl> kb = do_QueryInterface(widget);
|
||||
return kb;
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Japan.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIMEStateManager_h__
|
||||
#define nsIMEStateManager_h__
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsPIDOMWindow;
|
||||
class nsPresContext;
|
||||
class nsIKBStateControl;
|
||||
class nsIFocusController;
|
||||
|
||||
/*
|
||||
* IME state manager
|
||||
*/
|
||||
|
||||
class nsIMEStateManager
|
||||
{
|
||||
public:
|
||||
static nsresult OnDestroyPresContext(nsPresContext* aPresContext);
|
||||
static nsresult OnRemoveContent(nsPresContext* aPresContext,
|
||||
nsIContent* aContent);
|
||||
static nsresult OnChangeFocus(nsPresContext* aPresContext,
|
||||
nsIContent* aContent);
|
||||
static nsresult OnActivate(nsPresContext* aPresContext);
|
||||
static nsresult OnDeactivate(nsPresContext* aPresContext);
|
||||
protected:
|
||||
static void SetIMEState(nsPresContext* aPresContext,
|
||||
PRUint32 aState,
|
||||
nsIKBStateControl* aKB);
|
||||
static PRUint32 GetNewIMEState(nsPresContext* aPresContext,
|
||||
nsIContent* aContent);
|
||||
|
||||
static PRBool IsActive(nsPresContext* aPresContext);
|
||||
|
||||
static nsIFocusController* GetFocusController(nsPresContext* aPresContext);
|
||||
static nsIKBStateControl* GetKBStateControl(nsPresContext* aPresContext);
|
||||
|
||||
static nsIContent* sContent;
|
||||
static nsPresContext* sPresContext;
|
||||
static nsPIDOMWindow* sActiveWindow;
|
||||
};
|
||||
|
||||
#endif // nsIMEStateManager_h__
|
|
@ -336,9 +336,6 @@ nsEditor::PostCreate()
|
|||
NotifyDocumentListeners(eDocumentCreated);
|
||||
NotifyDocumentListeners(eDocumentStateChanged);
|
||||
|
||||
// Call ResetInputState() for initialization
|
||||
ForceCompositionEnd();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2235,18 +2232,6 @@ nsEditor::ForceCompositionEnd()
|
|||
NS_IMETHODIMP
|
||||
nsEditor::NotifyIMEOnFocus()
|
||||
{
|
||||
nsCOMPtr<nsIKBStateControl> kb;
|
||||
nsresult res = GetKBStateControl(getter_AddRefs(kb));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
if (!kb)
|
||||
return NS_OK;
|
||||
|
||||
res = kb->CancelIMEComposition();
|
||||
if (NS_FAILED(res))
|
||||
kb->ResetInputState();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -372,6 +372,10 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
nsresult
|
||||
nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
|
||||
if (!imeEditor)
|
||||
return NS_OK;
|
||||
imeEditor->ForceCompositionEnd();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1081,7 +1085,6 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
|
|||
// the input focus is leaving first
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
|
||||
if (imeEditor) {
|
||||
imeEditor->ForceCompositionEnd();
|
||||
imeEditor->NotifyIMEOnBlur();
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,10 @@ nsPresContext::~nsPresContext()
|
|||
SetShell(nsnull);
|
||||
|
||||
if (mEventManager) {
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
// unclear if these are needed, but can't hurt
|
||||
mEventManager->NotifyDestroyPresContext(this);
|
||||
mEventManager->SetPresContext(nsnull);
|
||||
|
||||
NS_RELEASE(mEventManager);
|
||||
}
|
||||
|
||||
|
|
|
@ -1836,6 +1836,12 @@ PresShell::Destroy()
|
|||
if (mHaveShutDown)
|
||||
return NS_OK;
|
||||
|
||||
if (mPresContext) {
|
||||
// We need to notify the destroying the nsPresContext to ESM for
|
||||
// suppressing to use from ESM.
|
||||
mPresContext->EventStateManager()->NotifyDestroyPresContext(mPresContext);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
|
|
|
@ -1701,11 +1701,6 @@ nsWindow::OnButtonPressEvent(GtkWidget *aWidget, GdkEventButton *aEvent)
|
|||
PRUint32 eventType;
|
||||
nsEventStatus status;
|
||||
|
||||
#ifdef USE_XIM
|
||||
if (gIMEFocusWindow)
|
||||
gIMEFocusWindow->ResetInputStateInternal();
|
||||
#endif
|
||||
|
||||
// If you double click in GDK, it will actually generate a single
|
||||
// click event before sending the double click event, and this is
|
||||
// different than the DOM spec. GDK puts this in the queue
|
||||
|
@ -4641,7 +4636,7 @@ nsWindow::IMEDestroyContext(void)
|
|||
if (!mIMEData) {
|
||||
// Clear reference to this.
|
||||
if (IMEComposingWindow() == this)
|
||||
CancelIMECompositionInternal();
|
||||
CancelIMEComposition();
|
||||
if (gIMEFocusWindow == this)
|
||||
gIMEFocusWindow = nsnull;
|
||||
return;
|
||||
|
@ -4901,13 +4896,6 @@ nsWindow::IMEFilterEvent(GdkEventKey *aEvent)
|
|||
/* nsIKBStateControl */
|
||||
NS_IMETHODIMP
|
||||
nsWindow::ResetInputState()
|
||||
{
|
||||
// We should not implement this until bug 327003 is fixed.
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWindow::ResetInputStateInternal()
|
||||
{
|
||||
nsWindow *win = IMEComposingWindow();
|
||||
if (win) {
|
||||
|
@ -4928,7 +4916,7 @@ nsWindow::ResetInputStateInternal()
|
|||
pango_attr_list_unref(feedback_list);
|
||||
}
|
||||
|
||||
CancelIMECompositionInternal();
|
||||
CancelIMEComposition();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -4963,8 +4951,10 @@ nsWindow::SetIMEEnabled(PRBool aState)
|
|||
|
||||
if (focusedIm && focusedIm == window->mIMEData->mContext) {
|
||||
// Release current IME focus if IME is enabled.
|
||||
if (window->mIMEData->mEnabled)
|
||||
if (window->mIMEData->mEnabled) {
|
||||
focusedWin->ResetInputState();
|
||||
focusedWin->IMELoseFocus();
|
||||
}
|
||||
|
||||
window->mIMEData->mEnabled = aState;
|
||||
|
||||
|
@ -4973,7 +4963,7 @@ nsWindow::SetIMEEnabled(PRBool aState)
|
|||
focusedWin->IMESetFocus();
|
||||
} else {
|
||||
if (window->mIMEData->mEnabled)
|
||||
ResetInputStateInternal();
|
||||
ResetInputState();
|
||||
window->mIMEData->mEnabled = aState;
|
||||
}
|
||||
|
||||
|
@ -4990,20 +4980,13 @@ nsWindow::GetIMEEnabled(PRBool* aState)
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::CancelIMEComposition()
|
||||
{
|
||||
// We should not implement this until bug 327003 is fixed.
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWindow::CancelIMECompositionInternal()
|
||||
{
|
||||
GtkIMContext *im = IMEGetContext();
|
||||
if (!im)
|
||||
return NS_OK;
|
||||
|
||||
NS_ASSERTION(!gIMESuppressCommit,
|
||||
"CancelIMECompositionInternal is already called!");
|
||||
"CancelIMEComposition is already called!");
|
||||
gIMESuppressCommit = PR_TRUE;
|
||||
gtk_im_context_reset(im);
|
||||
gIMESuppressCommit = PR_FALSE;
|
||||
|
|
|
@ -326,9 +326,6 @@ public:
|
|||
NS_IMETHOD GetIMEEnabled(PRBool* aState);
|
||||
NS_IMETHOD CancelIMEComposition();
|
||||
|
||||
nsresult ResetInputStateInternal();
|
||||
nsresult CancelIMECompositionInternal();
|
||||
|
||||
#endif
|
||||
|
||||
void ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight);
|
||||
|
|
Загрузка…
Ссылка в новой задаче