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
Родитель 3034734290
Коммит 62347a8f7b
6 изменённых файлов: 48 добавлений и 1 удалений

Просмотреть файл

@ -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());
}

Просмотреть файл

@ -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
*

Просмотреть файл

@ -1453,6 +1453,13 @@ TabParent::RecvNotifyIMEMouseButtonEvent(
return true;
}
bool
TabParent::RecvNotifyIMEEditorRect(const nsIntRect& aRect)
{
mIMEEditorRect = aRect;
return true;
}
bool
TabParent::RecvRequestFocus(const bool& aCanRaise)
{
@ -1598,6 +1605,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)
@ -1682,6 +1691,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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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()
{

Просмотреть файл

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