From d6f1c6f7dd1a82e1cafb2b49a08f8571b042c624 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 6 Feb 2018 14:45:22 +0900 Subject: [PATCH] Bug 1435730 - part 1: Make TSFTextStore::GetTextExt() not return TS_E_NOLAYOUT error to Japanist 10 when the range is in composition string r=m_kato Similar to ATOK, Japanist 10 requests all or part of composition string. If we return TS_E_NOLAYOUT in this case, you'll see candidate window at top-left of the screen. For avoiding this issue, we should not return TS_E_NOLAYOUT to Japanist 10 when the query range is in composition string. MozReview-Commit-ID: 2OPafUO5PQC --HG-- extra : rebase_source : bd7a594d8d3540374d61860651b69528aa6e3793 --- modules/libpref/init/all.js | 7 +++++- widget/windows/TSFTextStore.cpp | 43 ++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index bddd36af74b3..ff2dc62adb41 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -3965,11 +3965,16 @@ pref("intl.tsf.associate_imc_only_when_imm_ime_is_active", false); // Whether creates native caret for ATOK or not. pref("intl.tsf.hack.atok.create_native_caret", true); // Whether use available composition string rect for result of -// ITfContextView::GetTextExt() even if the specified range is same as the +// ITextStoreACP::GetTextExt() even if the specified range is same as the // range of composition string but some character rects of them are not // available. Note that this is ignored if active ATOK is or older than 2016 // and create_native_caret is true. pref("intl.tsf.hack.atok.do_not_return_no_layout_error_of_composition_string", true); +// Whether use available composition string rect for result of +// ITextStoreACP::GetTextExt() even if the specified range is same as or is in +// the range of composition string but some character rects of them are not +// available. +pref("intl.tsf.hack.japanist10.do_not_return_no_layout_error_of_composition_string", true); // Whether use composition start position for the result of // ITfContextView::GetTextExt() if the specified range is larger than // composition start offset. diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp index d3643ab00943..0f6d31fd50fc 100644 --- a/widget/windows/TSFTextStore.cpp +++ b/widget/windows/TSFTextStore.cpp @@ -1096,6 +1096,7 @@ public: DECL_AND_IMPL_IS_TIP_ACTIVE(IsATOK2014Active) DECL_AND_IMPL_IS_TIP_ACTIVE(IsATOK2015Active) DECL_AND_IMPL_IS_TIP_ACTIVE(IsATOK2016Active) + DECL_AND_IMPL_IS_TIP_ACTIVE(IsJapanist10Active) DECL_AND_IMPL_IS_TIP_ACTIVE(IsMSBopomofoActive) DECL_AND_IMPL_IS_TIP_ACTIVE(IsMSChangJieActive) @@ -1247,8 +1248,15 @@ private: // * ATOK Passport (confirmed with version 31.1.2) // - {A38F2FD9-7199-45E1-841C-BE0313D8052F} - // * Japanist 10 - // - {E6D66705-1EDA-4373-8D01-1D0CB2D054C7} + bool IsJapanist10ActiveInternal() const + { + // {E6D66705-1EDA-4373-8D01-1D0CB2D054C7} + static const GUID kGUID = { + 0xE6D66705, 0x1EDA, 0x4373, + { 0x8D, 0x01, 0x1D, 0x0C, 0xB2, 0xD0, 0x54, 0xC7 } + }; + return mActiveTIPGUID == kGUID; + } /**************************************************************************** * Traditional Chinese TIP @@ -1705,6 +1713,10 @@ public: DECL_AND_IMPL_BOOL_PREF( "intl.tsf.hack.atok.do_not_return_no_layout_error_of_composition_string", DoNotReturnNoLayoutErrorToATOKOfCompositionString, true) + DECL_AND_IMPL_BOOL_PREF( + "intl.tsf.hack.japanist10." + "do_not_return_no_layout_error_of_composition_string", + DoNotReturnNoLayoutErrorToJapanist10OfCompositionString, true) DECL_AND_IMPL_BOOL_PREF( "intl.tsf.hack.ms_simplified_chinese.do_not_return_no_layout_error", DoNotReturnNoLayoutErrorToMSSimplifiedTIP, true) @@ -3360,7 +3372,7 @@ TSFTextStore::SetSelectionInternal(const TS_SELECTION_ACP* pSelection, // Perhaps, we can ignore the difference change because it must not be // important for following edit. if (selectionForTSF.EqualsExceptDirection(*pSelection)) { - MOZ_LOG(sTextStoreLog, LogLevel::Error, + MOZ_LOG(sTextStoreLog, LogLevel::Warning, ("0x%p TSFTextStore::SetSelectionInternal() Succeeded but " "did nothing because the selection range isn't changing", this)); selectionForTSF.SetSelection(*pSelection); @@ -4253,8 +4265,20 @@ TSFTextStore::GetTextExt(TsViewCookie vcView, MOZ_LOG(sTextStoreLog, LogLevel::Info, ("0x%p TSFTextStore::GetTextExt(vcView=%ld, " "acpStart=%ld, acpEnd=%ld, prc=0x%p, pfClipped=0x%p), " + "IsHandlingComposition()=%s, " + "mContentForTSF={ MinOffsetOfLayoutChanged()=%u, " + "LatestCompositionStartOffset()=%d, LatestCompositionEndOffset()=%d }, " + "mComposition= { IsComposing()=%s, mStart=%d, EndOffset()=%d }, " "mDeferNotifyingTSF=%s, mWaitingQueryLayout=%s", this, vcView, acpStart, acpEnd, prc, pfClipped, + GetBoolName(IsHandlingComposition()), + mContentForTSF.MinOffsetOfLayoutChanged(), + mContentForTSF.HasOrHadComposition() ? + mContentForTSF.LatestCompositionStartOffset() : -1, + mContentForTSF.HasOrHadComposition() ? + mContentForTSF.LatestCompositionEndOffset() : -1, + GetBoolName(mComposition.IsComposing()), + mComposition.mStart, mComposition.EndOffset(), GetBoolName(mDeferNotifyingTSF), GetBoolName(mWaitingQueryLayout))); if (!IsReadLocked()) { @@ -4378,6 +4402,19 @@ TSFTextStore::GetTextExt(TsViewCookie vcView, mContentForTSF.LatestCompositionEndOffset() == acpEnd) { dontReturnNoLayoutError = true; } + // Japanist 10 fails to handle TS_E_NOLAYOUT when it decides the position of + // candidate window. In such case, Japanist shows candidate window at + // top-left of the screen. So, we should return the nearest caret rect + // where we know. + else if ( + TSFPrefs::DoNotReturnNoLayoutErrorToJapanist10OfCompositionString() && + TSFStaticSink::IsJapanist10Active() && + acpStart >= mContentForTSF.LatestCompositionStartOffset() && + acpStart <= mContentForTSF.LatestCompositionEndOffset() && + acpEnd >= mContentForTSF.LatestCompositionStartOffset() && + acpEnd <= mContentForTSF.LatestCompositionEndOffset()) { + dontReturnNoLayoutError = true; + } // Free ChangJie 2010 doesn't handle ITfContextView::GetTextExt() properly. // Prehaps, it's due to the bug of TSF. We need to check if this is // necessary on Windows 10 before disabling this on Windows 10.