Bug 966157 - Part 1. Implement remote NS_QUERY_EDITOR_RECT. r=masayuki

This commit is contained in:
Makoto Kato 2014-12-15 18:21:20 +09:00
parent 424eea2aaf
commit 327fa03357
6 changed files with 48 additions and 1 deletions

View File

@ -742,7 +742,9 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
break;
case NS_QUERY_EDITOR_RECT:
{
// XXX remote event
if (RemoteQueryContentEvent(aEvent)) {
break;
}
ContentEventHandler handler(mPresContext);
handler.OnQueryEditorRect(aEvent->AsQueryContentEvent());
}

View File

@ -227,6 +227,13 @@ parent:
prio(urgent) sync NotifyIMEMouseButtonEvent(IMENotification notification)
returns (bool consumedByIME);
/**
* Notifies chrome to currect editor rect
*
* rect Rect of current focused editor
*/
prio(urgent) async NotifyIMEEditorRect(nsIntRect rect);
/**
* Instructs chrome to end any pending composition
*

View File

@ -1488,6 +1488,13 @@ TabParent::RecvNotifyIMEMouseButtonEvent(
return true;
}
bool
TabParent::RecvNotifyIMEEditorRect(const nsIntRect& aRect)
{
mIMEEditorRect = aRect;
return true;
}
bool
TabParent::RecvRequestFocus(const bool& aCanRaise)
{
@ -1633,6 +1640,8 @@ TabParent::RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& aEvent)
* Cocoa widget always queries selected offset, so it works on it.
*
* For NS_QUERY_CARET_RECT, fail if cached offset isn't equals to input
*
* For NS_QUERY_EDITOR_RECT, always success
*/
bool
TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
@ -1717,6 +1726,12 @@ TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
aEvent.mSucceeded = true;
}
break;
case NS_QUERY_EDITOR_RECT:
{
aEvent.mReply.mRect = mIMEEditorRect - GetChildProcessOffset();
aEvent.mSucceeded = true;
}
break;
}
return true;
}

View File

@ -178,6 +178,7 @@ public:
virtual bool RecvNotifyIMETextHint(const nsString& aText) MOZ_OVERRIDE;
virtual bool RecvNotifyIMEMouseButtonEvent(const widget::IMENotification& aEventMessage,
bool* aConsumedByIME) MOZ_OVERRIDE;
virtual bool RecvNotifyIMEEditorRect(const nsIntRect& aRect) MOZ_OVERRIDE;
virtual bool RecvEndIMEComposition(const bool& aCancel,
nsString* aComposition) MOZ_OVERRIDE;
virtual bool RecvGetInputContext(int32_t* aIMEEnabled,
@ -398,6 +399,7 @@ protected:
InfallibleTArray<nsIntRect> mIMECompositionRects;
uint32_t mIMECaretOffset;
nsIntRect mIMECaretRect;
nsIntRect mIMEEditorRect;
// The number of event series we're currently capturing.
int32_t mEventCaptureDepth;

View File

@ -530,6 +530,7 @@ PuppetWidget::NotifyIMEOfFocusChange(bool aFocus)
IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE);
notification.mSelectionChangeData.mCausedByComposition = false;
NotifyIMEOfSelectionChange(notification); // Update selection
NotifyIMEOfEditorRect();
} else {
mIMELastBlurSeqno = chromeSeqno;
}
@ -577,6 +578,25 @@ PuppetWidget::NotifyIMEOfUpdateComposition()
return NS_OK;
}
nsresult
PuppetWidget::NotifyIMEOfEditorRect()
{
#ifndef MOZ_CROSS_PROCESS_IME
return NS_OK;
#endif
nsEventStatus status;
WidgetQueryContentEvent editorRectEvent(true, NS_QUERY_EDITOR_RECT, this);
InitEvent(editorRectEvent);
DispatchEvent(&editorRectEvent, status);
if (editorRectEvent.mSucceeded) {
mTabChild->SendNotifyIMEEditorRect(editorRectEvent.mReply.mRect);
}
return NS_OK;
}
nsIMEUpdatePreference
PuppetWidget::GetIMEUpdatePreference()
{

View File

@ -216,6 +216,7 @@ private:
nsresult NotifyIMEOfUpdateComposition();
nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
nsresult NotifyIMEOfMouseButtonEvent(const IMENotification& aIMENotification);
nsresult NotifyIMEOfEditorRect();
class PaintTask : public nsRunnable {
public: