Bug 1130936 - Support vertical writing mode in nsTextStore for Windows TSF. r=masayuki

This commit is contained in:
Jonathan Kew 2015-02-10 14:00:02 +00:00
Родитель 3becdb3805
Коммит 1733a1d87b
2 изменённых файлов: 37 добавлений и 6 удалений

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

@ -1895,7 +1895,8 @@ nsTextStore::CurrentSelection()
mSelection.SetSelection(querySelection.mReply.mOffset,
querySelection.mReply.mString.Length(),
querySelection.mReply.mReversed);
querySelection.mReply.mReversed,
querySelection.GetWritingMode());
}
PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
@ -2801,6 +2802,9 @@ nsTextStore::GetRequestedAttrIndex(const TS_ATTRID& aAttrID)
if (IsEqualGUID(aAttrID, TSATTRID_Text_VerticalWriting)) {
return eTextVerticalWriting;
}
if (IsEqualGUID(aAttrID, TSATTRID_Text_Orientation)) {
return eTextOrientation;
}
return eNotSupported;
}
@ -2812,6 +2816,8 @@ nsTextStore::GetAttrID(int32_t aIndex)
return GUID_PROP_INPUTSCOPE;
case eTextVerticalWriting:
return TSATTRID_Text_VerticalWriting;
case eTextOrientation:
return TSATTRID_Text_Orientation;
default:
MOZ_CRASH("Invalid index? Or not implemented yet?");
return GUID_NULL;
@ -2980,11 +2986,21 @@ nsTextStore::RetrieveRequestedAttrs(ULONG ulCount,
paAttrVals[count].varValue.punkVal = inputScope.forget().take();
break;
}
case eTextVerticalWriting:
// Currently, we don't support vertical writing mode.
case eTextVerticalWriting: {
Selection& currentSelection = CurrentSelection();
paAttrVals[count].varValue.vt = VT_BOOL;
paAttrVals[count].varValue.boolVal = VARIANT_FALSE;
paAttrVals[count].varValue.boolVal =
currentSelection.GetWritingMode().IsVertical()
? VARIANT_TRUE : VARIANT_FALSE;
break;
}
case eTextOrientation: {
Selection& currentSelection = CurrentSelection();
paAttrVals[count].varValue.vt = VT_I4;
paAttrVals[count].varValue.lVal =
currentSelection.GetWritingMode().IsVertical() ? 2700 : 0;
break;
}
default:
MOZ_CRASH("Invalid index? Or not implemented yet?");
break;
@ -4893,8 +4909,10 @@ nsTextStore::Content::StartComposition(ITfCompositionView* aCompositionView,
GetSubstring(static_cast<uint32_t>(aCompStart.mSelectionStart),
static_cast<uint32_t>(aCompStart.mSelectionLength)));
if (!aPreserveSelection) {
// XXX Do we need to set a new writing-mode here when setting a new
// selection? Currently, we just preserve the existing value.
mSelection.SetSelection(mComposition.mStart, mComposition.mString.Length(),
false);
false, mSelection.GetWritingMode());
}
}

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

@ -384,13 +384,15 @@ protected:
mACP.style.fInterimChar = FALSE;
}
void SetSelection(uint32_t aStart, uint32_t aLength, bool aReversed)
void SetSelection(uint32_t aStart, uint32_t aLength, bool aReversed,
mozilla::WritingMode aWritingMode)
{
mDirty = false;
mACP.acpStart = static_cast<LONG>(aStart);
mACP.acpEnd = static_cast<LONG>(aStart + aLength);
mACP.style.ase = aReversed ? TS_AE_START : TS_AE_END;
mACP.style.fInterimChar = FALSE;
mWritingMode = aWritingMode;
}
bool IsCollapsed() const
@ -401,6 +403,9 @@ protected:
void CollapseAt(uint32_t aOffset)
{
// XXX This does not update the selection's mWritingMode.
// If it is ever used to "collapse" to an entirely new location,
// we may need to fix that.
mDirty = false;
mACP.acpStart = mACP.acpEnd = static_cast<LONG>(aOffset);
mACP.style.ase = TS_AE_END;
@ -462,8 +467,15 @@ protected:
return (mACP.style.fInterimChar != FALSE);
}
mozilla::WritingMode GetWritingMode() const
{
MOZ_ASSERT(!mDirty);
return mWritingMode;
}
private:
TS_SELECTION_ACP mACP;
mozilla::WritingMode mWritingMode;
bool mDirty;
};
// Don't access mSelection directly except at calling MarkDirty().
@ -706,6 +718,7 @@ protected:
// Supported attributes
eInputScope = 0,
eTextVerticalWriting,
eTextOrientation,
// Count of the supported attributes
NUM_OF_SUPPORTED_ATTRS