mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-29 10:32:23 +00:00
b91a6a24cc
- Bug 1001637 - Make math tables implement the nsIAccessibleTable interface. r=surkov (ebbb4325d6) - Bug 1149118 - Expose radio group with the correct role on OS X, r=surkov (4d4a95735c) - Bug 1113153 - use 'paragraph' role for paragraphs only, introduce 'text' role for small text containers, r=marcoz (14c4fa5881) - Bug 1175164 - Do not expose MathML semantics element in the accessibility tree. r=surkov (3945ae0367) - Bug 930843 part.1 Add test for checking isTrust attribute value of DOMActivate event r=smaug (14a49dd447) - Bug 930843 part.2 NS_UI_ACTIVATE event should be trusted event even if it's caused by an untrusted event r=smaug (e0af6165b5) - Bug 1156315 - Call DispatchInputEvent in more places on OS X. r=dvander (e24f42c09f) - Bug 1186015 part.1 Rename nsIMEContext to mozilla::widget::IMEContext r=jimm (077bf6e772) - Bug 1186015 part.2 Rename nsIMM32Handler to mozilla::widget::IMMHandler r=jimm+m_kato (a2098e33b5) - Bug 1184533 Rewrite range check in aOffset of nsIMM32Handler::GetCharacterRectOfSelectedTextAt() r=emk (fb68bc3c56) - Bug 555642 part.1 nsCaret should have a way to override the caret visible state for hiding caret temporarily and nsEditor should hide caret if composition string doesn't have caret information r=roc (9de4aa366c) - Bug 1171847 Remove unnecessary ',' in logging code in nsTextStore::Initialize() r=m_kato (78d0d43625) - Bug 1181714 nsTextStore should store previous focused document manager until new document manager actually gets focus r=m_kato (fd7e820af2) - Bug 1176950 nsTextStore should keep storing locked content until NOTIFY_IME_OF_COMPOSITION_UPDATE is notified r=emk (0a12349575) - Bug 1137539 part.1 Implement TSFStaticSink::IsGoogleJapaneseInputActive() r=emk (68d1f9a0ec) - Bug 1137539 part.2 Implement TSFStaticSink::IsATOKActive() r=emk (51a4208bfa) - Bug 1137539 part.3 Implement TSFStaticSink::IsFreeChangJieActive() r=emk (affbb81b96) - Bug 1137539 part.4 Implement TSFStaticSink::IsEasyChangjeiActive() r=emk (abd3e674b6) - Bug 1186014 Rename nsTextStore to mozilla::widget::TSFTextStore r=jimm+m_kato (ca63351f94) - Bug 1187351 TSFTextStore should forget modified range at notifying TSF of layout change since GetTextExt() shouldn't return TS_E_NOLAYOUT after that r=emk (48878793e0) - Bg 1187367 TSFTextStore shouldn't destroy native caret for ATOK until notifying TSF of layout change r=emk (a2a4022d15) - Bug 1187566 TSFTextStore::Content should compute mMinTextModified Offset only with the latest composition string and original composition string, and also the hack should be enabled on Win10 r=emk (1368885efe) - Bug 1050644 part.1 Add methods to check whether the active TIP is Chinese TIP which deosn't show candidate window in e10s mode r=emk (1b783e682e) - Bug 1050644 part.2 Hack ITextStoreACP::GetTextExt()'s offset for some Chinese TIPs of MS r=emk (c05cec10ce) - Bug 1187579 Enable TSF in e10s mode r=m_kato (1ae106231a) - Bug 555642 part.2 IME handlers on Windows shouldn't append caret range if the caret is in the target clause which doesn't have specific style r=m_kato (88bae2c8da) - Bug 1196124 Fix mismatch of printf style string and following arguments of MOZ_LOG() in IMMHandler::GetCharacterRectOfSelectedTextAt() r=m_kato (0f6debd0d3) - Bug 90712 Cancel composition when Enter key message isn't consumed by IME r=m_kato (0febdb1fd9) - pointer style (6c984274cd) - Bug 1177268 - implement aria-rowcount/index and aria-colcount/index, r=marcoz (92ac300374) - Bug 1153135 - Return possibility PEN working while APZC is enabled. r=jimm (8bc77ff84f) - Bug 1171073 - Suppress content scrolling issue on 64-bit platforms. r=kats (62db0dead3) - Bug 1121946, Implement e10 cursor drag feedback on Windows, r=jmathies (6e8218d202) - Bug 1144650 - Don't dispatch touch-based mouse events when APZ is handling touch. r=jimm (53ebea0d90) - Bug 1163056 - InkCollector activation at first PEN event. r=jimm (b28e0ee58b) - Bug 895274 part.3 Make the enum of event messages a named enum IGNORE IDL r=smaug (32e04a4e90) - spacing (b9249221dc) - Bug 1182966 - Part 3: Add some final annotations to DomainSet. r=mrbkap (3455822e89) - Bug 1050122 - Part 1: Enable Nuwa on debug builds, and kill it if the preference is false. r=khuey (46685a7bf3) - Bug 1146229: Remove calling convention modifier from local variable. r=surkov (e5f4b6e5d5) - bug 1168932 - Implement ProxyCreated and ProxyDestroyed to update mozAccessibles r=tbsaunde (77a007fa21) - Bug 1169701 - Fire native OS X accessibility events for proxied accessibles r=tbsaunde (c4847135a8) - bug 1172523 - fire useful text change events for proxies r=lsock (85b7f995b8) - remove spurious file (229c787360) - bug 1171117 - Fix cairo to build on iOS. r=jrmuizel (45709c8fe3) - Bug 963738 - Annotate XPCNativeMember, r=terrence (d1afdde52b) - Bug 1148383 - Add testcase for previously fixed object metadata issue r=terrence (2c1b762cba) - Bug 1149797 - Update browser jstests to treat ecma_6/extensions tests as 1.8, so that let is interpreted as a statement and not as an expression. r=bustage in a CLOSED TREE (ac6127d6bc) - Bug 1150858 - Unwrap the correct object in ArrayBuffer.transfer (r=sfink) (cf67906802) - Bug 1150380 - IonMonkey: MIPS: Fix JitRuntime::generateProfilerExitFrameTailStub. r=rankov (eeac49ddce) - use RootedValue for POW as in 1135708 (34c1c3d191) - Bug 1196648: IonMonkey - Don't run the lazy link stub for asmjs to jit fastpath, r=nbp (686d495371) - Bug 1121947, Implement e10 cursor drag feedback on Mac, r=smaug (f48df2d1) - and sync widget/TextEvents.h and TextRange.h with AF.
387 lines
12 KiB
C++
387 lines
12 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: sw=2 ts=8 et :
|
|
*/
|
|
/* 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/. */
|
|
|
|
#ifndef mozilla_ContentCache_h
|
|
#define mozilla_ContentCache_h
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "mozilla/Assertions.h"
|
|
#include "mozilla/CheckedInt.h"
|
|
#include "mozilla/EventForwards.h"
|
|
#include "mozilla/WritingModes.h"
|
|
#include "nsIWidget.h"
|
|
#include "nsString.h"
|
|
#include "nsTArray.h"
|
|
#include "Units.h"
|
|
|
|
namespace mozilla {
|
|
|
|
class ContentCacheInParent;
|
|
|
|
/**
|
|
* ContentCache stores various information of the child content.
|
|
* This class has members which are necessary both in parent process and
|
|
* content process.
|
|
*/
|
|
|
|
class ContentCache
|
|
{
|
|
public:
|
|
typedef InfallibleTArray<LayoutDeviceIntRect> RectArray;
|
|
typedef widget::IMENotification IMENotification;
|
|
|
|
ContentCache();
|
|
|
|
protected:
|
|
// Whole text in the target
|
|
nsString mText;
|
|
|
|
struct Selection final
|
|
{
|
|
// Following values are offset in "flat text".
|
|
uint32_t mAnchor;
|
|
uint32_t mFocus;
|
|
|
|
WritingMode mWritingMode;
|
|
|
|
// Character rects at next character of mAnchor and mFocus.
|
|
LayoutDeviceIntRect mAnchorCharRect;
|
|
LayoutDeviceIntRect mFocusCharRect;
|
|
|
|
// Whole rect of selected text. This is empty if the selection is collapsed.
|
|
LayoutDeviceIntRect mRect;
|
|
|
|
Selection()
|
|
: mAnchor(UINT32_MAX)
|
|
, mFocus(UINT32_MAX)
|
|
{
|
|
}
|
|
|
|
void Clear()
|
|
{
|
|
mAnchor = mFocus = UINT32_MAX;
|
|
mWritingMode = WritingMode();
|
|
mAnchorCharRect.SetEmpty();
|
|
mFocusCharRect.SetEmpty();
|
|
mRect.SetEmpty();
|
|
}
|
|
|
|
bool IsValid() const
|
|
{
|
|
return mAnchor != UINT32_MAX && mFocus != UINT32_MAX;
|
|
}
|
|
bool Collapsed() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the selection is valid");
|
|
return mFocus == mAnchor;
|
|
}
|
|
bool Reversed() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the selection is valid");
|
|
return mFocus < mAnchor;
|
|
}
|
|
uint32_t StartOffset() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the selection is valid");
|
|
return Reversed() ? mFocus : mAnchor;
|
|
}
|
|
uint32_t EndOffset() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the selection is valid");
|
|
return Reversed() ? mAnchor : mFocus;
|
|
}
|
|
uint32_t Length() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the selection is valid");
|
|
return Reversed() ? mAnchor - mFocus : mFocus - mAnchor;
|
|
}
|
|
} mSelection;
|
|
|
|
bool IsSelectionValid() const
|
|
{
|
|
return mSelection.IsValid() && mSelection.EndOffset() <= mText.Length();
|
|
}
|
|
|
|
// Stores first char rect because Yosemite's Japanese IME sometimes tries
|
|
// to query it. If there is no text, this is caret rect.
|
|
LayoutDeviceIntRect mFirstCharRect;
|
|
|
|
struct Caret final
|
|
{
|
|
uint32_t mOffset;
|
|
LayoutDeviceIntRect mRect;
|
|
|
|
Caret()
|
|
: mOffset(UINT32_MAX)
|
|
{
|
|
}
|
|
|
|
void Clear()
|
|
{
|
|
mOffset = UINT32_MAX;
|
|
mRect.SetEmpty();
|
|
}
|
|
|
|
bool IsValid() const { return mOffset != UINT32_MAX; }
|
|
|
|
uint32_t Offset() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the caret is valid");
|
|
return mOffset;
|
|
}
|
|
} mCaret;
|
|
|
|
struct TextRectArray final
|
|
{
|
|
uint32_t mStart;
|
|
RectArray mRects;
|
|
|
|
TextRectArray()
|
|
: mStart(UINT32_MAX)
|
|
{
|
|
}
|
|
|
|
void Clear()
|
|
{
|
|
mStart = UINT32_MAX;
|
|
mRects.Clear();
|
|
}
|
|
|
|
bool IsValid() const
|
|
{
|
|
if (mStart == UINT32_MAX) {
|
|
return false;
|
|
}
|
|
CheckedInt<uint32_t> endOffset =
|
|
CheckedInt<uint32_t>(mStart) + mRects.Length();
|
|
return endOffset.isValid();
|
|
}
|
|
uint32_t StartOffset() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the caret is valid");
|
|
return mStart;
|
|
}
|
|
uint32_t EndOffset() const
|
|
{
|
|
NS_ASSERTION(IsValid(),
|
|
"The caller should check if the caret is valid");
|
|
if (!IsValid()) {
|
|
return UINT32_MAX;
|
|
}
|
|
return mStart + mRects.Length();
|
|
}
|
|
bool InRange(uint32_t aOffset) const
|
|
{
|
|
return IsValid() &&
|
|
StartOffset() <= aOffset && aOffset < EndOffset();
|
|
}
|
|
bool InRange(uint32_t aOffset, uint32_t aLength) const
|
|
{
|
|
CheckedInt<uint32_t> endOffset =
|
|
CheckedInt<uint32_t>(aOffset) + aLength;
|
|
if (NS_WARN_IF(!endOffset.isValid())) {
|
|
return false;
|
|
}
|
|
return InRange(aOffset) && aOffset + aLength <= EndOffset();
|
|
}
|
|
bool IsOverlappingWith(uint32_t aOffset, uint32_t aLength) const
|
|
{
|
|
if (!IsValid() || aOffset == UINT32_MAX) {
|
|
return false;
|
|
}
|
|
CheckedInt<uint32_t> endOffset =
|
|
CheckedInt<uint32_t>(aOffset) + aLength;
|
|
if (NS_WARN_IF(!endOffset.isValid())) {
|
|
return false;
|
|
}
|
|
return aOffset <= EndOffset() && endOffset.value() >= mStart;
|
|
}
|
|
LayoutDeviceIntRect GetRect(uint32_t aOffset) const;
|
|
LayoutDeviceIntRect GetUnionRect(uint32_t aOffset, uint32_t aLength) const;
|
|
LayoutDeviceIntRect GetUnionRectAsFarAsPossible(uint32_t aOffset,
|
|
uint32_t aLength) const;
|
|
} mTextRectArray;
|
|
|
|
LayoutDeviceIntRect mEditorRect;
|
|
|
|
friend class ContentCacheInParent;
|
|
friend struct IPC::ParamTraits<ContentCache>;
|
|
};
|
|
|
|
class ContentCacheInChild final : public ContentCache
|
|
{
|
|
public:
|
|
ContentCacheInChild();
|
|
|
|
/**
|
|
* When IME loses focus, this should be called and making this forget the
|
|
* content for reducing footprint.
|
|
*/
|
|
void Clear();
|
|
|
|
/**
|
|
* Cache*() retrieves the latest content information and store them.
|
|
* Be aware, CacheSelection() calls CacheTextRects(), and also CacheText()
|
|
* calls CacheSelection(). So, related data is also retrieved automatically.
|
|
*/
|
|
bool CacheEditorRect(nsIWidget* aWidget,
|
|
const IMENotification* aNotification = nullptr);
|
|
bool CacheSelection(nsIWidget* aWidget,
|
|
const IMENotification* aNotification = nullptr);
|
|
bool CacheText(nsIWidget* aWidget,
|
|
const IMENotification* aNotification = nullptr);
|
|
|
|
bool CacheAll(nsIWidget* aWidget,
|
|
const IMENotification* aNotification = nullptr);
|
|
|
|
/**
|
|
* SetSelection() modifies selection with specified raw data. And also this
|
|
* tries to retrieve text rects too.
|
|
*/
|
|
void SetSelection(nsIWidget* aWidget,
|
|
uint32_t aStartOffset,
|
|
uint32_t aLength,
|
|
bool aReversed,
|
|
const WritingMode& aWritingMode);
|
|
|
|
private:
|
|
bool QueryCharRect(nsIWidget* aWidget,
|
|
uint32_t aOffset,
|
|
LayoutDeviceIntRect& aCharRect) const;
|
|
bool CacheCaret(nsIWidget* aWidget,
|
|
const IMENotification* aNotification = nullptr);
|
|
bool CacheTextRects(nsIWidget* aWidget,
|
|
const IMENotification* aNotification = nullptr);
|
|
};
|
|
|
|
class ContentCacheInParent final : public ContentCache
|
|
{
|
|
public:
|
|
ContentCacheInParent();
|
|
|
|
/**
|
|
* AssignContent() is called when TabParent receives ContentCache from
|
|
* the content process. This doesn't copy composition information because
|
|
* it's managed by TabParent itself.
|
|
*/
|
|
void AssignContent(const ContentCache& aOther,
|
|
const IMENotification* aNotification = nullptr);
|
|
|
|
/**
|
|
* HandleQueryContentEvent() sets content data to aEvent.mReply.
|
|
*
|
|
* For NS_QUERY_SELECTED_TEXT, fail if the cache doesn't contain the whole
|
|
* selected range. (This shouldn't happen because PuppetWidget should have
|
|
* already sent the whole selection.)
|
|
*
|
|
* For NS_QUERY_TEXT_CONTENT, fail only if the cache doesn't overlap with
|
|
* the queried range. Note the difference from above. We use
|
|
* this behavior because a normal NS_QUERY_TEXT_CONTENT event is allowed to
|
|
* have out-of-bounds offsets, so that widget can request content without
|
|
* knowing the exact length of text. It's up to widget to handle cases when
|
|
* the returned offset/length are different from the queried offset/length.
|
|
*
|
|
* 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
|
|
*
|
|
* For NS_QUERY_EDITOR_RECT, always success
|
|
*/
|
|
bool HandleQueryContentEvent(WidgetQueryContentEvent& aEvent,
|
|
nsIWidget* aWidget) const;
|
|
|
|
/**
|
|
* OnCompositionEvent() should be called before sending composition string.
|
|
* This returns true if the event should be sent. Otherwise, false.
|
|
*/
|
|
bool OnCompositionEvent(const WidgetCompositionEvent& aCompositionEvent);
|
|
|
|
/**
|
|
* OnSelectionEvent() should be called before sending selection event.
|
|
*/
|
|
void OnSelectionEvent(const WidgetSelectionEvent& aSelectionEvent);
|
|
|
|
/**
|
|
* OnEventNeedingAckHandled() should be called after the child process
|
|
* handles a sent event which needs acknowledging.
|
|
*
|
|
* WARNING: This may send notifications to IME. That might cause destroying
|
|
* TabParent or aWidget. Therefore, the caller must not destroy
|
|
* this instance during a call of this method.
|
|
*/
|
|
void OnEventNeedingAckHandled(nsIWidget* aWidget, EventMessage aMessage);
|
|
|
|
/**
|
|
* RequestToCommitComposition() requests to commit or cancel composition to
|
|
* the widget. If it's handled synchronously, this returns the number of
|
|
* composition events after that.
|
|
*
|
|
* @param aWidget The widget to be requested to commit or cancel
|
|
* the composition.
|
|
* @param aCancel When the caller tries to cancel the composition, true.
|
|
* Otherwise, i.e., tries to commit the composition, false.
|
|
* @param aLastString The last composition string before requesting to
|
|
* commit or cancel composition.
|
|
* @return The count of composition events ignored after a call of
|
|
* WillRequestToCommitOrCancelComposition().
|
|
*/
|
|
uint32_t RequestToCommitComposition(nsIWidget* aWidget,
|
|
bool aCancel,
|
|
nsAString& aLastString);
|
|
|
|
/**
|
|
* MaybeNotifyIME() may notify IME of the notification. If child process
|
|
* hasn't been handled all sending events yet, this stores the notification
|
|
* and flush it later.
|
|
*/
|
|
void MaybeNotifyIME(nsIWidget* aWidget,
|
|
const IMENotification& aNotification);
|
|
|
|
private:
|
|
IMENotification mPendingSelectionChange;
|
|
IMENotification mPendingTextChange;
|
|
IMENotification mPendingLayoutChange;
|
|
IMENotification mPendingCompositionUpdate;
|
|
|
|
// This is commit string which is caused by our request.
|
|
nsString mCommitStringByRequest;
|
|
// Start offset of the composition string.
|
|
uint32_t mCompositionStart;
|
|
// Count of composition events during requesting commit or cancel the
|
|
// composition.
|
|
uint32_t mCompositionEventsDuringRequest;
|
|
// mPendingEventsNeedingAck is increased before sending a composition event or
|
|
// a selection event and decreased after they are received in the child
|
|
// process.
|
|
uint32_t mPendingEventsNeedingAck;
|
|
|
|
bool mIsComposing;
|
|
bool mRequestedToCommitOrCancelComposition;
|
|
|
|
bool GetCaretRect(uint32_t aOffset, LayoutDeviceIntRect& aCaretRect) const;
|
|
bool GetTextRect(uint32_t aOffset,
|
|
LayoutDeviceIntRect& aTextRect) const;
|
|
bool GetUnionTextRects(uint32_t aOffset,
|
|
uint32_t aLength,
|
|
LayoutDeviceIntRect& aUnionTextRect) const;
|
|
|
|
void FlushPendingNotifications(nsIWidget* aWidget);
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_ContentCache_h
|