Bug 480111 - [TSF]mCompositionStart and mCompositionLength is not updated on WinXP; r=masayuki sr=roc

This commit is contained in:
Masatoshi Kimura 2009-03-08 10:39:03 +01:00
Родитель 369f8525dd
Коммит fb31b54efc
2 изменённых файлов: 46 добавлений и 22 удалений

Просмотреть файл

@ -601,6 +601,46 @@ IsSameTextEvent(const nsTextEvent* aEvent1, const nsTextEvent* aEvent2)
sizeof(nsTextRange) * aEvent1->rangeCount)));
}
HRESULT
nsTextStore::UpdateCompositionExtent(ITfRange* aRangeNew)
{
NS_ENSURE_TRUE(mCompositionView, E_FAIL);
HRESULT hr;
nsRefPtr<ITfCompositionView> pComposition(mCompositionView);
nsRefPtr<ITfRange> composingRange(aRangeNew);
if (!composingRange) {
hr = pComposition->GetRange(getter_AddRefs(composingRange));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
}
// Get starting offset of the composition
LONG compStart = 0, compLength = 0;
hr = GetRangeExtent(composingRange, &compStart, &compLength);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
if (mCompositionStart != compStart ||
mCompositionString.Length() != compLength) {
// If the queried composition length is different from the length
// of our composition string, OnUpdateComposition is being called
// because a part of the original composition was committed.
// Reflect that by committing existing composition and starting
// a new one. OnEndComposition followed by OnStartComposition
// will accomplish this automagically.
OnEndComposition(pComposition);
OnStartCompositionInternal(pComposition, composingRange, PR_TRUE);
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: UpdateCompositionExtent, (reset) range=%ld-%ld\n",
compStart, compStart + compLength));
} else {
mCompositionLength = compLength;
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: UpdateCompositionExtent, range=%ld-%ld\n",
compStart, compStart + compLength));
}
return S_OK;
}
HRESULT
nsTextStore::SendTextEventForCompositionString()
{
@ -704,6 +744,10 @@ nsTextStore::SetSelectionInternal(const TS_SELECTION_ACP* pSelection,
("TSF: SetSelection, sel=%ld-%ld\n",
pSelection->acpStart, pSelection->acpEnd));
if (mCompositionView) {
if (aDispatchTextEvent) {
HRESULT hr = UpdateCompositionExtent(nsnull);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
}
// Emulate selection during compositions
NS_ENSURE_TRUE(pSelection->acpStart >= mCompositionStart &&
pSelection->acpEnd <= mCompositionStart +
@ -1270,29 +1314,8 @@ nsTextStore::OnUpdateComposition(ITfCompositionView* pComposition,
if (!pRangeNew) // pRangeNew is null when the update is not complete
return S_OK;
// Get starting offset of the composition
LONG compStart = 0, compLength = 0;
HRESULT hr = GetRangeExtent(pRangeNew, &compStart, &compLength);
HRESULT hr = UpdateCompositionExtent(pRangeNew);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
if (mCompositionStart != compStart ||
mCompositionString.Length() != compLength) {
// If the queried composition length is different from the length
// of our composition string, OnUpdateComposition is being called
// because a part of the original composition was committed.
// Reflect that by committing existing composition and starting
// a new one. OnEndComposition followed by OnStartComposition
// will accomplish this automagically.
OnEndComposition(pComposition);
OnStartCompositionInternal(pComposition, pRangeNew, PR_TRUE);
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: OnUpdateComposition, (reset) range=%ld-%ld\n",
compStart, compStart + compLength));
} else {
mCompositionLength = compLength;
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: OnUpdateComposition, range=%ld-%ld\n",
compStart, compStart + compLength));
}
return SendTextEventForCompositionString();
}

Просмотреть файл

@ -199,6 +199,7 @@ protected:
HRESULT GetDisplayAttribute(ITfProperty* aProperty,
ITfRange* aRange,
TF_DISPLAYATTRIBUTE* aResult);
HRESULT UpdateCompositionExtent(ITfRange* pRangeNew);
HRESULT SendTextEventForCompositionString();
HRESULT SaveTextEvent(const nsTextEvent* aEvent);
nsresult OnCompositionTimer();