mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1835578 - Fix warnings of clang-tidy in XP IME handling code r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D179325
This commit is contained in:
parent
72e30bb189
commit
218033f32b
@ -616,7 +616,7 @@ nsresult IMEContentObserver::HandleQueryContentEvent(
|
||||
aEvent->mReply->mContentsRoot = mRootElement;
|
||||
aEvent->mReply->mWritingMode = mSelectionData.GetWritingMode();
|
||||
// The selection cache in IMEContentObserver must always have been in
|
||||
// an editing host (or an editable annoymous <div> element). Therefore,
|
||||
// an editing host (or an editable anonymous <div> element). Therefore,
|
||||
// we set mIsEditableContent to true here even though it's already been
|
||||
// blurred or changed its editable state but the selection cache has not
|
||||
// been invalidated yet.
|
||||
@ -1073,10 +1073,7 @@ bool IMEContentObserver::IsNextNodeOfLastAddedNode(nsINode* aParent,
|
||||
// If the parent node isn't changed, we can check that mLastAddedContent has
|
||||
// aChild as its next sibling.
|
||||
if (aParent == mLastAddedContainer) {
|
||||
if (NS_WARN_IF(mLastAddedContent->GetNextSibling() != aChild)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !NS_WARN_IF(mLastAddedContent->GetNextSibling() != aChild);
|
||||
}
|
||||
|
||||
// If the parent node is changed, that means that the recorded last added node
|
||||
@ -1088,10 +1085,7 @@ bool IMEContentObserver::IsNextNodeOfLastAddedNode(nsINode* aParent,
|
||||
// If the node is aParent is a descendant of mLastAddedContainer,
|
||||
// aChild should be the first child in the new container.
|
||||
if (mLastAddedContainer == aParent->GetParent()) {
|
||||
if (NS_WARN_IF(aChild->GetPreviousSibling())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !NS_WARN_IF(aChild->GetPreviousSibling());
|
||||
}
|
||||
|
||||
// Otherwise, we need to check it even with slow path.
|
||||
@ -1499,7 +1493,7 @@ void IMEContentObserver::FlushMergeableNotifications() {
|
||||
|
||||
// If contents in selection range is modified, the selection range still
|
||||
// has removed node from the tree. In such case, ContentIterator won't
|
||||
// work well. Therefore, we shouldn't use AddScriptRunnder() here since
|
||||
// work well. Therefore, we shouldn't use AddScriptRunner() here since
|
||||
// it may kick runnable event immediately after DOM tree is changed but
|
||||
// the selection range isn't modified yet.
|
||||
mQueuedSender = new IMENotificationSender(this);
|
||||
|
@ -403,6 +403,7 @@ class IMEContentObserver final : public nsStubMutationObserver,
|
||||
*/
|
||||
class DocumentObserver final : public nsStubDocumentObserver {
|
||||
public:
|
||||
DocumentObserver() = delete;
|
||||
explicit DocumentObserver(IMEContentObserver& aIMEContentObserver)
|
||||
: mIMEContentObserver(&aIMEContentObserver), mDocumentUpdating(0) {
|
||||
SetEnabledCallbacks(nsIMutationObserver::kBeginUpdate |
|
||||
@ -423,7 +424,6 @@ class IMEContentObserver final : public nsStubMutationObserver,
|
||||
bool IsUpdating() const { return mDocumentUpdating != 0; }
|
||||
|
||||
private:
|
||||
DocumentObserver() = delete;
|
||||
virtual ~DocumentObserver() { Destroy(); }
|
||||
|
||||
RefPtr<IMEContentObserver> mIMEContentObserver;
|
||||
|
@ -37,12 +37,12 @@ class Selection;
|
||||
*/
|
||||
|
||||
class IMEStateManager {
|
||||
typedef dom::BrowserParent BrowserParent;
|
||||
typedef widget::IMEMessage IMEMessage;
|
||||
typedef widget::IMENotification IMENotification;
|
||||
typedef widget::IMEState IMEState;
|
||||
typedef widget::InputContext InputContext;
|
||||
typedef widget::InputContextAction InputContextAction;
|
||||
using BrowserParent = dom::BrowserParent;
|
||||
using IMEMessage = widget::IMEMessage;
|
||||
using IMENotification = widget::IMENotification;
|
||||
using IMEState = widget::IMEState;
|
||||
using InputContext = widget::InputContext;
|
||||
using InputContextAction = widget::InputContextAction;
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
|
@ -909,11 +909,11 @@ RawRangeBoundary TextComposition::LastIMESelectionEndRef() const {
|
||||
******************************************************************************/
|
||||
|
||||
TextComposition::CompositionEventDispatcher::CompositionEventDispatcher(
|
||||
TextComposition* aComposition, nsINode* aEventTarget,
|
||||
TextComposition* aTextComposition, nsINode* aEventTarget,
|
||||
EventMessage aEventMessage, const nsAString& aData,
|
||||
bool aIsSynthesizedEvent)
|
||||
: Runnable("TextComposition::CompositionEventDispatcher"),
|
||||
mTextComposition(aComposition),
|
||||
mTextComposition(aTextComposition),
|
||||
mEventTarget(aEventTarget),
|
||||
mData(aData),
|
||||
mEventMessage(aEventMessage),
|
||||
|
@ -216,17 +216,17 @@ bool ContentCacheInChild::CacheCaret(nsIWidget* aWidget,
|
||||
const uint32_t offset = mSelection->StartOffset();
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
WidgetQueryContentEvent queryCaretRectEvet(true, eQueryCaretRect, aWidget);
|
||||
queryCaretRectEvet.InitForQueryCaretRect(offset);
|
||||
aWidget->DispatchEvent(&queryCaretRectEvet, status);
|
||||
if (NS_WARN_IF(queryCaretRectEvet.Failed())) {
|
||||
WidgetQueryContentEvent queryCaretRectEvent(true, eQueryCaretRect, aWidget);
|
||||
queryCaretRectEvent.InitForQueryCaretRect(offset);
|
||||
aWidget->DispatchEvent(&queryCaretRectEvent, status);
|
||||
if (NS_WARN_IF(queryCaretRectEvent.Failed())) {
|
||||
MOZ_LOG(sContentCacheLog, LogLevel::Error,
|
||||
("0x%p CacheCaret(), FAILED, couldn't retrieve the caret rect "
|
||||
"at offset=%u",
|
||||
this, offset));
|
||||
return false;
|
||||
}
|
||||
mCaret.emplace(offset, queryCaretRectEvet.mReply->mRect);
|
||||
mCaret.emplace(offset, queryCaretRectEvent.mReply->mRect);
|
||||
}
|
||||
MOZ_LOG(sContentCacheLog, LogLevel::Info,
|
||||
("0x%p CacheCaret(), Succeeded, mSelection=%s, mCaret=%s", this,
|
||||
@ -1273,25 +1273,25 @@ bool ContentCacheInParent::GetCaretRect(uint32_t aOffset,
|
||||
}
|
||||
|
||||
bool ContentCacheInParent::OnCompositionEvent(
|
||||
const WidgetCompositionEvent& aEvent) {
|
||||
const WidgetCompositionEvent& aCompositionEvent) {
|
||||
MOZ_LOG(
|
||||
sContentCacheLog, LogLevel::Info,
|
||||
("0x%p OnCompositionEvent(aEvent={ "
|
||||
("0x%p OnCompositionEvent(aCompositionEvent={ "
|
||||
"mMessage=%s, mData=\"%s\", mRanges->Length()=%zu }), "
|
||||
"PendingEventsNeedingAck()=%u, WidgetHasComposition()=%s, "
|
||||
"mHandlingCompositions.Length()=%zu, HasPendingCommit()=%s, "
|
||||
"mIsChildIgnoringCompositionEvents=%s, mCommitStringByRequest=0x%p",
|
||||
this, ToChar(aEvent.mMessage),
|
||||
PrintStringDetail(aEvent.mData,
|
||||
this, ToChar(aCompositionEvent.mMessage),
|
||||
PrintStringDetail(aCompositionEvent.mData,
|
||||
PrintStringDetail::kMaxLengthForCompositionString)
|
||||
.get(),
|
||||
aEvent.mRanges ? aEvent.mRanges->Length() : 0, PendingEventsNeedingAck(),
|
||||
GetBoolName(WidgetHasComposition()), mHandlingCompositions.Length(),
|
||||
GetBoolName(HasPendingCommit()),
|
||||
aCompositionEvent.mRanges ? aCompositionEvent.mRanges->Length() : 0,
|
||||
PendingEventsNeedingAck(), GetBoolName(WidgetHasComposition()),
|
||||
mHandlingCompositions.Length(), GetBoolName(HasPendingCommit()),
|
||||
GetBoolName(mIsChildIgnoringCompositionEvents), mCommitStringByRequest));
|
||||
|
||||
#if MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
mDispatchedEventMessages.AppendElement(aEvent.mMessage);
|
||||
mDispatchedEventMessages.AppendElement(aCompositionEvent.mMessage);
|
||||
#endif // #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
|
||||
// We must be able to simulate the selection because
|
||||
@ -1308,25 +1308,26 @@ bool ContentCacheInParent::OnCompositionEvent(
|
||||
? mSelection->StartOffset()
|
||||
: 0u);
|
||||
}
|
||||
MOZ_ASSERT(aEvent.mMessage == eCompositionStart);
|
||||
MOZ_ASSERT(aCompositionEvent.mMessage == eCompositionStart);
|
||||
mHandlingCompositions.AppendElement(
|
||||
HandlingCompositionData(aEvent.mCompositionId));
|
||||
HandlingCompositionData(aCompositionEvent.mCompositionId));
|
||||
}
|
||||
|
||||
mHandlingCompositions.LastElement().mSentCommitEvent =
|
||||
aEvent.CausesDOMCompositionEndEvent();
|
||||
aCompositionEvent.CausesDOMCompositionEndEvent();
|
||||
MOZ_ASSERT(mHandlingCompositions.LastElement().mCompositionId ==
|
||||
aEvent.mCompositionId);
|
||||
aCompositionEvent.mCompositionId);
|
||||
|
||||
if (!WidgetHasComposition()) {
|
||||
// mCompositionStart will be reset when commit event is completely handled
|
||||
// in the remote process.
|
||||
if (mHandlingCompositions.Length() == 1u) {
|
||||
mPendingCommitLength = aEvent.mData.Length();
|
||||
mPendingCommitLength = aCompositionEvent.mData.Length();
|
||||
}
|
||||
MOZ_ASSERT(HasPendingCommit());
|
||||
} else if (aEvent.mMessage != eCompositionStart) {
|
||||
mHandlingCompositions.LastElement().mCompositionString = aEvent.mData;
|
||||
} else if (aCompositionEvent.mMessage != eCompositionStart) {
|
||||
mHandlingCompositions.LastElement().mCompositionString =
|
||||
aCompositionEvent.mData;
|
||||
}
|
||||
|
||||
// During REQUEST_TO_COMMIT_COMPOSITION or REQUEST_TO_CANCEL_COMPOSITION,
|
||||
@ -1337,13 +1338,13 @@ bool ContentCacheInParent::OnCompositionEvent(
|
||||
// RequestIMEToCommitComposition(). Then, eCommitComposition event will
|
||||
// be dispatched with the committed string in the remote process internally.
|
||||
if (mCommitStringByRequest) {
|
||||
if (aEvent.mMessage == eCompositionCommitAsIs) {
|
||||
if (aCompositionEvent.mMessage == eCompositionCommitAsIs) {
|
||||
*mCommitStringByRequest =
|
||||
mHandlingCompositions.LastElement().mCompositionString;
|
||||
} else {
|
||||
MOZ_ASSERT(aEvent.mMessage == eCompositionChange ||
|
||||
aEvent.mMessage == eCompositionCommit);
|
||||
*mCommitStringByRequest = aEvent.mData;
|
||||
MOZ_ASSERT(aCompositionEvent.mMessage == eCompositionChange ||
|
||||
aCompositionEvent.mMessage == eCompositionCommit);
|
||||
*mCommitStringByRequest = aCompositionEvent.mData;
|
||||
}
|
||||
// We need to wait eCompositionCommitRequestHandled from the remote process
|
||||
// in this case. Therefore, mPendingEventsNeedingAck needs to be
|
||||
|
@ -40,8 +40,8 @@ class BrowserParent;
|
||||
|
||||
class ContentCache {
|
||||
public:
|
||||
typedef CopyableTArray<LayoutDeviceIntRect> RectArray;
|
||||
typedef widget::IMENotification IMENotification;
|
||||
using RectArray = CopyableTArray<LayoutDeviceIntRect>;
|
||||
using IMENotification = widget::IMENotification;
|
||||
|
||||
ContentCache() = default;
|
||||
|
||||
@ -109,12 +109,12 @@ class ContentCache {
|
||||
mRect.SetEmpty();
|
||||
}
|
||||
bool HasRects() const {
|
||||
for (auto& rect : mAnchorCharRects) {
|
||||
for (const auto& rect : mAnchorCharRects) {
|
||||
if (!rect.IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (auto& rect : mFocusCharRects) {
|
||||
for (const auto& rect : mFocusCharRects) {
|
||||
if (!rect.IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
@ -192,7 +192,7 @@ class ContentCache {
|
||||
LayoutDeviceIntRect mFirstCharRect;
|
||||
|
||||
struct Caret final {
|
||||
uint32_t mOffset;
|
||||
uint32_t mOffset = 0u;
|
||||
LayoutDeviceIntRect mRect;
|
||||
|
||||
explicit Caret(uint32_t aOffset, LayoutDeviceIntRect aCaretRect)
|
||||
@ -215,6 +215,7 @@ class ContentCache {
|
||||
}
|
||||
|
||||
private:
|
||||
// For ParamTraits<Caret>
|
||||
Caret() = default;
|
||||
|
||||
friend struct IPC::ParamTraits<ContentCache::Caret>;
|
||||
@ -223,7 +224,7 @@ class ContentCache {
|
||||
Maybe<Caret> mCaret;
|
||||
|
||||
struct TextRectArray final {
|
||||
uint32_t mStart;
|
||||
uint32_t mStart = 0u;
|
||||
RectArray mRects;
|
||||
|
||||
explicit TextRectArray(uint32_t aStartOffset) : mStart(aStartOffset) {}
|
||||
@ -288,6 +289,7 @@ class ContentCache {
|
||||
}
|
||||
|
||||
private:
|
||||
// For ParamTraits<TextRectArray>
|
||||
TextRectArray() = default;
|
||||
|
||||
friend struct IPC::ParamTraits<ContentCache::TextRectArray>;
|
||||
@ -373,6 +375,7 @@ class ContentCacheInChild final : public ContentCache {
|
||||
|
||||
class ContentCacheInParent final : public ContentCache {
|
||||
public:
|
||||
ContentCacheInParent() = delete;
|
||||
explicit ContentCacheInParent(dom::BrowserParent& aBrowserParent);
|
||||
|
||||
/**
|
||||
@ -606,8 +609,6 @@ class ContentCacheInParent final : public ContentCache {
|
||||
// Then, set to false when the child process ignores the commit event.
|
||||
bool mIsChildIgnoringCompositionEvents;
|
||||
|
||||
ContentCacheInParent() = delete;
|
||||
|
||||
/**
|
||||
* When following methods' aRoundToExistingOffset is true, even if specified
|
||||
* offset or range is out of bounds, the result is computed with the existing
|
||||
|
Loading…
Reference in New Issue
Block a user