mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1077515 - part 4 - Add writing-mode to the reply to the NS_QUERY_SELECTED_TEXT event. r=roc
This commit is contained in:
parent
8faf68508f
commit
d0f9e25a27
@ -604,6 +604,23 @@ ContentEventHandler::GetLineBreakType(bool aUseNativeLineBreak)
|
||||
LINE_BREAK_TYPE_NATIVE : LINE_BREAK_TYPE_XP;
|
||||
}
|
||||
|
||||
// Similar to nsFrameSelection::GetFrameForNodeOffset,
|
||||
// but this is more flexible for OnQueryTextRect to use
|
||||
static nsresult GetFrameForTextRect(nsINode* aNode,
|
||||
int32_t aNodeOffset,
|
||||
bool aHint,
|
||||
nsIFrame** aReturnFrame)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode && aNode->IsNodeOfType(nsINode::eCONTENT),
|
||||
NS_ERROR_UNEXPECTED);
|
||||
nsIContent* content = static_cast<nsIContent*>(aNode);
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
int32_t childNodeOffset = 0;
|
||||
return frame->GetChildFrameContainingOffset(aNodeOffset, aHint,
|
||||
&childNodeOffset, aReturnFrame);
|
||||
}
|
||||
|
||||
nsresult
|
||||
ContentEventHandler::OnQuerySelectedText(WidgetQueryContentEvent* aEvent)
|
||||
{
|
||||
@ -646,6 +663,14 @@ ContentEventHandler::OnQuerySelectedText(WidgetQueryContentEvent* aEvent)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsIFrame* frame = nullptr;
|
||||
rv = GetFrameForTextRect(focusNode, focusOffset, true, &frame);
|
||||
if (NS_SUCCEEDED(rv) && frame) {
|
||||
aEvent->mReply.mWritingMode = frame->GetWritingMode();
|
||||
} else {
|
||||
aEvent->mReply.mWritingMode = WritingMode();
|
||||
}
|
||||
|
||||
aEvent->mSucceeded = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -697,23 +722,6 @@ static nsINode* AdjustTextRectNode(nsINode* aNode,
|
||||
return node;
|
||||
}
|
||||
|
||||
// Similar to nsFrameSelection::GetFrameForNodeOffset,
|
||||
// but this is more flexible for OnQueryTextRect to use
|
||||
static nsresult GetFrameForTextRect(nsINode* aNode,
|
||||
int32_t aNodeOffset,
|
||||
bool aHint,
|
||||
nsIFrame** aReturnFrame)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode && aNode->IsNodeOfType(nsINode::eCONTENT),
|
||||
NS_ERROR_UNEXPECTED);
|
||||
nsIContent* content = static_cast<nsIContent*>(aNode);
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
int32_t childNodeOffset = 0;
|
||||
return frame->GetChildFrameContainingOffset(aNodeOffset, aHint,
|
||||
&childNodeOffset, aReturnFrame);
|
||||
}
|
||||
|
||||
nsresult
|
||||
ContentEventHandler::OnQueryTextRect(WidgetQueryContentEvent* aEvent)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "nsRect.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsTArray.h"
|
||||
#include "WritingModes.h"
|
||||
|
||||
/******************************************************************************
|
||||
* virtual keycode values
|
||||
@ -455,6 +456,8 @@ public:
|
||||
bool mHasSelection;
|
||||
// true if DOM element under mouse belongs to widget
|
||||
bool mWidgetIsHit;
|
||||
// mozilla::WritingMode value at the end (focus) of the selection
|
||||
mozilla::WritingMode mWritingMode;
|
||||
// used by NS_QUERY_SELECTION_AS_TRANSFERABLE
|
||||
nsCOMPtr<nsITransferable> mTransferable;
|
||||
} mReply;
|
||||
|
Loading…
Reference in New Issue
Block a user