Bug 1166436 part.11 Remove unnecessary public methods of mozilla::ContentCache r=m_kato

This commit is contained in:
Masayuki Nakano 2015-06-05 18:28:20 +09:00
parent dcfea181de
commit 0f0df4d078
3 changed files with 45 additions and 95 deletions

View File

@ -1962,16 +1962,7 @@ TabParent::RecvNotifyIMESelection(const ContentCache& aContentCache,
if (updatePreference.WantSelectionChange() &&
(updatePreference.WantChangesCausedByComposition() ||
!aCausedByComposition)) {
IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE);
notification.mSelectionChangeData.mOffset = mContentCache.SelectionStart();
notification.mSelectionChangeData.mLength = mContentCache.SelectionLength();
notification.mSelectionChangeData.mReversed =
mContentCache.SelectionReversed();
notification.mSelectionChangeData.SetWritingMode(
mContentCache.SelectionWritingMode());
notification.mSelectionChangeData.mCausedByComposition =
aCausedByComposition;
widget->NotifyIME(notification);
mContentCache.NotifyIMEOfSelectionChange(widget, aCausedByComposition);
}
return true;
}
@ -2212,10 +2203,7 @@ TabParent::SendSelectionEvent(WidgetSelectionEvent& event)
// XXX The writing mode is wrong, but this should cause a call of
// RecvNotifyIMESelection(). If so, why do we need to modify the range
// here??
mContentCache.SetSelection(
event.mOffset + (event.mReversed ? event.mLength : 0),
event.mOffset + (!event.mReversed ? event.mLength : 0),
mContentCache.SelectionWritingMode());
mContentCache.SetSelection(event.mOffset, event.mLength, event.mReversed);
return PBrowserParent::SendSelectionEvent(event);
}

View File

@ -55,7 +55,7 @@ ContentCache::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent,
if (mSelection.Collapsed()) {
aEvent.mReply.mString.Truncate(0);
} else {
if (NS_WARN_IF(SelectionEndIsGraterThanTextLength())) {
if (NS_WARN_IF(mSelection.EndOffset() > mText.Length())) {
return false;
}
aEvent.mReply.mString =
@ -209,10 +209,10 @@ ContentCache::CacheText(nsIWidget* aWidget)
queryText.InitForQueryTextContent(0, UINT32_MAX);
aWidget->DispatchEvent(&queryText, status);
if (NS_WARN_IF(!queryText.mSucceeded)) {
SetText(EmptyString());
mText.Truncate();
return false;
}
SetText(queryText.mReply.mString);
mText = queryText.mReply.mString;
return true;
}
@ -250,12 +250,6 @@ ContentCache::CacheTextRects(nsIWidget* aWidget)
return true;
}
void
ContentCache::SetText(const nsAString& aText)
{
mText = aText;
}
void
ContentCache::SetSelection(uint32_t aStartOffset,
uint32_t aLength,
@ -282,19 +276,6 @@ ContentCache::SetSelection(uint32_t aAnchorOffset,
mSelection.mWritingMode = aWritingMode;
}
bool
ContentCache::InitTextRectArray(uint32_t aOffset,
const RectArray& aTextRectArray)
{
if (NS_WARN_IF(aOffset >= TextLength()) ||
NS_WARN_IF(aOffset + aTextRectArray.Length() > TextLength())) {
return false;
}
mTextRectArray.mStart = aOffset;
mTextRectArray.mRects = aTextRectArray;
return true;
}
bool
ContentCache::GetTextRect(uint32_t aOffset,
LayoutDeviceIntRect& aTextRect) const
@ -320,18 +301,6 @@ ContentCache::GetUnionTextRects(uint32_t aOffset,
return true;
}
bool
ContentCache::InitCaretRect(uint32_t aOffset,
const LayoutDeviceIntRect& aCaretRect)
{
if (NS_WARN_IF(aOffset > TextLength())) {
return false;
}
mCaret.mOffset = aOffset;
mCaret.mRect = aCaretRect;
return true;
}
bool
ContentCache::GetCaretRect(uint32_t aOffset,
LayoutDeviceIntRect& aCaretRect) const
@ -350,7 +319,7 @@ ContentCache::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
if (!aEvent.CausesDOMTextEvent()) {
MOZ_ASSERT(aEvent.message == NS_COMPOSITION_START);
mIsComposing = !aEvent.CausesDOMCompositionEndEvent();
mCompositionStart = SelectionStart();
mCompositionStart = mSelection.StartOffset();
// XXX What's this case??
if (mRequestedToCommitOrCancelComposition) {
mCommitStringByRequest = aEvent.mData;
@ -378,7 +347,7 @@ ContentCache::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
// We must be able to simulate the selection because
// we might not receive selection updates in time
if (!mIsComposing) {
mCompositionStart = SelectionStart();
mCompositionStart = mSelection.StartOffset();
}
// XXX This causes different behavior from non-e10s mode.
// Selection range should represent caret position in the composition
@ -406,6 +375,20 @@ ContentCache::RequestToCommitComposition(nsIWidget* aWidget,
return mCompositionEventsDuringRequest;
}
void
ContentCache::NotifyIMEOfSelectionChange(nsIWidget* aWidget,
bool aCausedByComposition) const
{
IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE);
notification.mSelectionChangeData.mOffset = mSelection.StartOffset();
notification.mSelectionChangeData.mLength = mSelection.Length();
notification.mSelectionChangeData.mReversed = mSelection.Reversed();
notification.mSelectionChangeData.SetWritingMode(mSelection.mWritingMode);
notification.mSelectionChangeData.mCausedByComposition =
aCausedByComposition;
aWidget->NotifyIME(notification);
}
/*****************************************************************************
* mozilla::ContentCache::TextRectArray
*****************************************************************************/

View File

@ -84,10 +84,6 @@ public:
bool CacheAll(nsIWidget* aWidget);
void SetText(const nsAString& aText);
const nsString& Text() const { return mText; }
uint32_t TextLength() const { return mText.Length(); }
/**
* OnCompositionEvent() should be called before sending composition string.
* This returns true if the event should be sent. Otherwise, false.
@ -111,10 +107,27 @@ public:
bool aCancel,
nsAString& aLastString);
/**
* NotifyIMEOfSelectionChange() notifies IME of selection change with
* storing selection range.
*
* @param aWidget A widget to notify IME of the notification.
* @param aCausedByComposition true if the change is caused by composition.
* Otherwise, false.
*/
void NotifyIMEOfSelectionChange(nsIWidget* aWidget,
bool aCausedByComposition) const;
void SetSelection(uint32_t aCaretOffset, const WritingMode& aWritingMode)
{
SetSelection(aCaretOffset, aCaretOffset, aWritingMode);
}
void SetSelection(uint32_t aStartOffset,
uint32_t aLength,
bool aReversed)
{
SetSelection(aStartOffset, aLength, aReversed, mSelection.mWritingMode);
}
void SetSelection(uint32_t aStartOffset,
uint32_t aLength,
bool aReversed,
@ -122,47 +135,6 @@ public:
void SetSelection(uint32_t aAnchorOffset,
uint32_t aFocusOffset,
const WritingMode& aWritingMode);
bool SelectionCollapsed() const { return mSelection.Collapsed(); }
bool SelectionReversed() const { return mSelection.Reversed(); }
bool SelectionEndIsGraterThanTextLength() const
{
return SelectionEnd() > TextLength();
}
uint32_t SelectionAnchor() const { return mSelection.mAnchor; }
uint32_t SelectionFocus() const { return mSelection.mFocus; }
uint32_t SelectionStart() const { return mSelection.StartOffset(); }
uint32_t SelectionEnd() const { return mSelection.EndOffset(); }
uint32_t SelectionLength() const { return mSelection.Length(); }
const WritingMode& SelectionWritingMode() const
{
return mSelection.mWritingMode;
}
bool UpdateTextRectArray(const RectArray& aTextRectArray)
{
return InitTextRectArray(mTextRectArray.mStart, aTextRectArray);
}
bool InitTextRectArray(uint32_t aOffset, const RectArray& aTextRectArray);
bool GetTextRect(uint32_t aOffset,
LayoutDeviceIntRect& aTextRect) const;
bool GetUnionTextRects(uint32_t aOffset,
uint32_t aLength,
LayoutDeviceIntRect& aUnionTextRect) const;
bool UpdateCaretRect(const LayoutDeviceIntRect& aCaretRect)
{
return InitCaretRect(mCaret.mOffset, aCaretRect);
}
bool InitCaretRect(uint32_t aOffset, const LayoutDeviceIntRect& aCaretRect);
uint32_t CaretOffset() const { return mCaret.mOffset; }
bool GetCaretRect(uint32_t aOffset, LayoutDeviceIntRect& aCaretRect) const;
void SetEditorRect(const LayoutDeviceIntRect& aEditorRect)
{
mEditorRect = aEditorRect;
}
const LayoutDeviceIntRect& GetEditorRect() const { return mEditorRect; }
private:
// Whole text in the target
@ -280,6 +252,13 @@ private:
bool mRequestedToCommitOrCancelComposition;
bool mIsChrome;
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;
friend struct IPC::ParamTraits<ContentCache>;
};