mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
f96be1a4d9
- Bug 895274 part.145 Rename NS_SELECTION_SET to eSetSelection r=smaug (5a576f3fc7) - Bug 895274 part.146 Rename NS_MOUSE_SCROLL_START to eLegacyMouseScrollEventFirst r=smaug (a03038ca81) - Bug 895274 part.147 Rename NS_MOUSE_SCROLL to eLegacyMouseLineOrPageScroll r=smaug (a16fa072ad) - Bug 895274 part.148 Rename NS_MOUSE_PIXEL_SCROLL to eLegacyMousePixelScroll r=smaug (85810aa54b) - Bug 895274 part.150 Rename NS_QUERY_CONTENT_EVENT_START to eQueryContentEventFirst r=smaug (36b4be4c20) - Bug 895274 part.151 Rename NS_QUERY_SELECTION_AS_TRANSFERABLE to eQuerySelectionAsTransferable r=smaug (7b50da594a) - Bug 895274 part.152 Rename NS_QUERY_SELECTED_TEXT to eQuerySelectedText r=smaug (3dbd79293f) - Bug 1199224 TSFTextStore should clear mLockedContent unless it needs to wait the content to be modified asynchronously r=emk (70aed5d4c5) - Bug 895274 part.153 Rename NS_QUERY_TEXT_CONTENT to eQueryTextContent r=smaug (9d3a8acf96) - Bug 299603 part.1 IMContextWrapper should have a method to initialize a TextRange r=m_kato (cf04d9b788) - Bug 299603 part.2 IMContextWrapper::SetTextRange() should initialize the range offsets and fail if the range is collapsed r=m_kato (4c64f3f7e7) - Bug 299603 part.3 IMContextWrapper::SetTextRange() shold set the style of the range which is specified by the IME r=m_kato (02b09d3df4) - Bug 1057921 - Don't propagate text decorations through outer <svg> elements. r=dholbert (e1e489eb2b) - Bug 1186721 - Suppress line break due to soft hyphen inside ruby. r=jfkthame (15bdd20955) - Bug 1175789 Draw underline as overline when it's in vertical writing mode and the language is Japanese or Korean r=dbaron (ffdb9f3e5b) - Bug 834830 - Add nsISelectionController.SELECTION_URLSTRIKEOUT to enable striking out parts of the URL in the URL bar r=roc (73d2871c77) - Bug 1155261 - Fix computation of glyph extents and text-frame visual overflow for vertical text frames. r=smontagu (5e94c117c3) - Bug 1140486 patch 1 - Pass block frame instead of block reflow state to nsTextFrame::RecomputeOverflow. r=jfkthame (2ecd788bd1) - Bug 1140486 patch 2 - Make nsTextFrame::UpdateOverflow include the visual overflow from the text metrics by calling existing RecomputeOverflow. r=jfkthame (3452b7edfd) - Bug 299603 part.4 Some global methods in nsTextFrame.cpp should be members of nsTextFrame class r=roc (9ca79dab6f) - Bug 299603 part.5 nsTextFrame should use system foreground or background color when painting IME selections if whose style defines only one of foreground color or background color r=roc (c4843a6c98) - Bug 299603 part.6 Guess the meaning of each clause in the composition string with caret position r=m_kato (364dfcc3b2) - Bug 299603 part.7 IMContextWrapper::CreateTextRange() should convert the caret offset from offset in characters to offset in UTF-16 r=m_kato (d67b116232) - Bug 895274 part.154 Rename NS_QUERY_CARET_RECT to eQueryCaretRect r=smaug (da09b897d9) - Bug 1153634 - Weaken the assertion condition to make it match the condition before. r=roc (02ce185f35) - Bug 299603 part.8 Rename aLastDispatchedData with aCompositionString in IMContextWrapper::CreateTextRangeArray() r=m_kato (998af878dc)
184 lines
5.0 KiB
C++
184 lines
5.0 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsQueryContentEventResult.h"
|
|
#include "nsIWidget.h"
|
|
#include "nsPoint.h"
|
|
#include "mozilla/TextEvents.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsQueryContentEventResult)
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIQueryContentEventResult)
|
|
NS_INTERFACE_MAP_ENTRY(nsIQueryContentEventResult)
|
|
NS_INTERFACE_MAP_END
|
|
|
|
NS_IMPL_ADDREF(nsQueryContentEventResult)
|
|
NS_IMPL_RELEASE(nsQueryContentEventResult)
|
|
|
|
nsQueryContentEventResult::nsQueryContentEventResult()
|
|
: mEventMessage(eVoidEvent)
|
|
, mSucceeded(false)
|
|
{
|
|
}
|
|
|
|
nsQueryContentEventResult::~nsQueryContentEventResult()
|
|
{
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetOffset(uint32_t *aOffset)
|
|
{
|
|
bool notFound;
|
|
nsresult rv = GetNotFound(¬Found);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
NS_ENSURE_TRUE(!notFound, NS_ERROR_NOT_AVAILABLE);
|
|
*aOffset = mOffset;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetTentativeCaretOffset(uint32_t* aOffset)
|
|
{
|
|
bool notFound;
|
|
nsresult rv = GetTentativeCaretOffsetNotFound(¬Found);
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
return rv;
|
|
}
|
|
if (NS_WARN_IF(notFound)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
*aOffset = mTentativeCaretOffset;
|
|
return NS_OK;
|
|
}
|
|
|
|
static bool IsRectEnabled(EventMessage aEventMessage)
|
|
{
|
|
return aEventMessage == eQueryCaretRect ||
|
|
aEventMessage == NS_QUERY_TEXT_RECT ||
|
|
aEventMessage == NS_QUERY_EDITOR_RECT ||
|
|
aEventMessage == NS_QUERY_CHARACTER_AT_POINT;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetReversed(bool *aReversed)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(mEventMessage == eQuerySelectedText, NS_ERROR_NOT_AVAILABLE);
|
|
*aReversed = mReversed;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetLeft(int32_t *aLeft)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
|
|
NS_ERROR_NOT_AVAILABLE);
|
|
*aLeft = mRect.x;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetWidth(int32_t *aWidth)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
|
|
NS_ERROR_NOT_AVAILABLE);
|
|
*aWidth = mRect.width;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetTop(int32_t *aTop)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
|
|
NS_ERROR_NOT_AVAILABLE);
|
|
*aTop = mRect.y;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetHeight(int32_t *aHeight)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
|
|
NS_ERROR_NOT_AVAILABLE);
|
|
*aHeight = mRect.height;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetText(nsAString &aText)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(mEventMessage == eQuerySelectedText ||
|
|
mEventMessage == eQueryTextContent,
|
|
NS_ERROR_NOT_AVAILABLE);
|
|
aText = mString;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetSucceeded(bool *aSucceeded)
|
|
{
|
|
NS_ENSURE_TRUE(mEventMessage != eVoidEvent, NS_ERROR_NOT_INITIALIZED);
|
|
*aSucceeded = mSucceeded;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetNotFound(bool *aNotFound)
|
|
{
|
|
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
|
|
NS_ENSURE_TRUE(mEventMessage == eQuerySelectedText ||
|
|
mEventMessage == NS_QUERY_CHARACTER_AT_POINT,
|
|
NS_ERROR_NOT_AVAILABLE);
|
|
*aNotFound = (mOffset == WidgetQueryContentEvent::NOT_FOUND);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsQueryContentEventResult::GetTentativeCaretOffsetNotFound(bool* aNotFound)
|
|
{
|
|
if (NS_WARN_IF(!mSucceeded)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
if (NS_WARN_IF(mEventMessage != NS_QUERY_CHARACTER_AT_POINT)) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
*aNotFound = (mTentativeCaretOffset == WidgetQueryContentEvent::NOT_FOUND);
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget,
|
|
const WidgetQueryContentEvent &aEvent)
|
|
{
|
|
mEventMessage = aEvent.mMessage;
|
|
mSucceeded = aEvent.mSucceeded;
|
|
mReversed = aEvent.mReply.mReversed;
|
|
mRect = aEvent.mReply.mRect;
|
|
mOffset = aEvent.mReply.mOffset;
|
|
mTentativeCaretOffset = aEvent.mReply.mTentativeCaretOffset;
|
|
mString = aEvent.mReply.mString;
|
|
|
|
if (!IsRectEnabled(mEventMessage) || !aWidget || !mSucceeded) {
|
|
return;
|
|
}
|
|
|
|
nsIWidget* topWidget = aWidget->GetTopLevelWidget();
|
|
if (!topWidget || topWidget == aWidget) {
|
|
return;
|
|
}
|
|
|
|
// Convert the top widget related coordinates to the given widget's.
|
|
LayoutDeviceIntPoint offset =
|
|
aWidget->WidgetToScreenOffset() - topWidget->WidgetToScreenOffset();
|
|
mRect.MoveBy(-offset);
|
|
}
|