Bug 935821 - Part 3. Support remote NS_QUERY_CARET_RECT. r=masayuki

This commit is contained in:
Makoto Kato 2014-01-16 19:04:39 +09:00
parent 40ae85bb49
commit c9fb41d576
5 changed files with 32 additions and 5 deletions

View File

@ -1214,7 +1214,9 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
break;
case NS_QUERY_CARET_RECT:
{
// XXX remote event
if (RemoteQueryContentEvent(aEvent)) {
break;
}
nsContentEventHandler handler(mPresContext);
handler.OnQueryCaretRect(aEvent->AsQueryContentEvent());
}

View File

@ -136,8 +136,9 @@ parent:
*
* offset The starting offset of this rect
* rect The rect of first character of selected IME composition
* caretRect The rect of IME caret
*/
NotifyIMESelectedCompositionRect(uint32_t offset, nsIntRect rect);
NotifyIMESelectedCompositionRect(uint32_t offset, nsIntRect rect, nsIntRect caretRect);
/**
* Notifies chrome that there has been a change in selection

View File

@ -995,11 +995,13 @@ TabParent::RecvNotifyIMETextChange(const uint32_t& aStart,
bool
TabParent::RecvNotifyIMESelectedCompositionRect(const uint32_t& aOffset,
const nsIntRect& aRect)
const nsIntRect& aRect,
const nsIntRect& aCaretRect)
{
// add rect to cache for another query
mIMECompositionRectOffset = aOffset;
mIMECompositionRect = aRect;
mIMECaretRect = aCaretRect;
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
@ -1101,6 +1103,8 @@ TabParent::GetChildProcessOffset()
*
* For NS_QUERY_TEXT_RECT, fail if cached offset/length aren't equals to input.
* 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
*/
bool
TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
@ -1163,6 +1167,17 @@ TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
aEvent.mSucceeded = true;
}
break;
case NS_QUERY_CARET_RECT:
{
if (aEvent.mInput.mOffset != mIMECompositionRectOffset) {
break;
}
aEvent.mReply.mOffset = mIMECompositionRectOffset;
aEvent.mReply.mRect = mIMECaretRect - GetChildProcessOffset();
aEvent.mSucceeded = true;
}
break;
}
return true;
}

View File

@ -145,7 +145,8 @@ public:
const uint32_t& aEnd,
const uint32_t& aNewEnd);
virtual bool RecvNotifyIMESelectedCompositionRect(const uint32_t& aOffset,
const nsIntRect& aRect);
const nsIntRect& aRect,
const nsIntRect& aCaretRect) MOZ_OVERRIDE;
virtual bool RecvNotifyIMESelection(const uint32_t& aSeqno,
const uint32_t& aAnchor,
const uint32_t& aFocus);
@ -335,6 +336,7 @@ protected:
uint32_t mIMECompositionRectOffset;
nsIntRect mIMECompositionRect;
nsIntRect mIMECaretRect;
// The number of event series we're currently capturing.
int32_t mEventCaptureDepth;

View File

@ -502,8 +502,15 @@ PuppetWidget::NotifyIMEOfUpdateComposition()
DispatchEvent(&textRect, status);
NS_ENSURE_TRUE(textRect.mSucceeded, NS_ERROR_FAILURE);
WidgetQueryContentEvent caretRect(true, NS_QUERY_CARET_RECT, this);
InitEvent(caretRect, nullptr);
caretRect.InitForQueryCaretRect(offset);
DispatchEvent(&caretRect, status);
NS_ENSURE_TRUE(caretRect.mSucceeded, NS_ERROR_FAILURE);
mTabChild->SendNotifyIMESelectedCompositionRect(offset,
textRect.mReply.mRect);
textRect.mReply.mRect,
caretRect.mReply.mRect);
return NS_OK;
}