зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1597897 - Use LayoutDeviceIntRect directly for IME composition rect. r=geckoview-reviewers,agi
Actually `nsIWidget::GetDefaultScale()` will always return 1.0 on GeckoView ([*1] and [*2]). When calculating CSS rect, although we have to consider zoom factor too, but `ConvertRectArrayToJavaRectFArray` doesn't yet. So then, GeckoView will notify IME of incorrect rect. Now we already know the layout device rect, so we should use it directly instead of converting to CSS unit. Also, there is no way to add tests since we cannot have the physical keyboard tests on geckoview-junit. *1 https://searchfox.org/mozilla-central/rev/4646b826a25d3825cf209db890862b45fa09ffc3/widget/android/nsWindow.cpp#1919-1928 *2 https://searchfox.org/mozilla-central/rev/4646b826a25d3825cf209db890862b45fa09ffc3/widget/android/ScreenHelperAndroid.cpp#39-41 Differential Revision: https://phabricator.services.mozilla.com/D133710
This commit is contained in:
Родитель
c3603037db
Коммит
eb7e6786b8
|
@ -421,7 +421,7 @@ import org.mozilla.gecko.util.ThreadUtils;
|
|||
mCursorAnchorInfoBuilder.reset();
|
||||
|
||||
final Matrix matrix = new Matrix();
|
||||
mSession.getClientToScreenMatrix(matrix);
|
||||
mSession.getClientToScreenOffsetMatrix(matrix);
|
||||
mCursorAnchorInfoBuilder.setMatrix(matrix);
|
||||
|
||||
for (int i = 0; i < rects.length; i++) {
|
||||
|
|
|
@ -5051,6 +5051,20 @@ public class GeckoSession {
|
|||
matrix.postTranslate(-mViewportLeft, -mViewportTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a matrix for transforming from layout device client coordinates to screen coordinates.
|
||||
*
|
||||
* @param matrix Matrix to be replaced by the transformation matrix.
|
||||
* @see #getClientToScreenMatrix(Matrix)
|
||||
* @see #getPageToSurfaceMatrix(Matrix)
|
||||
*/
|
||||
@UiThread
|
||||
/* package */ void getClientToScreenOffsetMatrix(@NonNull final Matrix matrix) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
matrix.postTranslate(mLeft, mTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bounds of the client area in client coordinates. The returned top-left coordinates are
|
||||
* always (0, 0). Use the matrix from {@link #getClientToSurfaceMatrix(Matrix)} or {@link
|
||||
|
|
|
@ -410,19 +410,14 @@ static nscolor ConvertAndroidColor(uint32_t aArgb) {
|
|||
}
|
||||
|
||||
static jni::ObjectArray::LocalRef ConvertRectArrayToJavaRectFArray(
|
||||
const nsTArray<LayoutDeviceIntRect>& aRects,
|
||||
const CSSToLayoutDeviceScale aScale) {
|
||||
const nsTArray<LayoutDeviceIntRect>& aRects) {
|
||||
const size_t length = aRects.Length();
|
||||
auto rects = jni::ObjectArray::New<java::sdk::RectF>(length);
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
const LayoutDeviceIntRect& tmp = aRects[i];
|
||||
|
||||
// Character bounds in CSS units.
|
||||
auto rect =
|
||||
java::sdk::RectF::New(tmp.x / aScale.scale, tmp.y / aScale.scale,
|
||||
(tmp.x + tmp.width) / aScale.scale,
|
||||
(tmp.y + tmp.height) / aScale.scale);
|
||||
auto rect = java::sdk::RectF::New(tmp.x, tmp.y, tmp.XMost(), tmp.YMost());
|
||||
rects->SetElement(i, rect);
|
||||
}
|
||||
return rects;
|
||||
|
@ -815,8 +810,7 @@ void GeckoEditableSupport::UpdateCompositionRects() {
|
|||
auto rects = ConvertRectArrayToJavaRectFArray(
|
||||
queryTextRectsEvent.Succeeded()
|
||||
? queryTextRectsEvent.mReply->mRectArray
|
||||
: CopyableTArray<mozilla::LayoutDeviceIntRect>(),
|
||||
widget->GetDefaultScale());
|
||||
: CopyableTArray<mozilla::LayoutDeviceIntRect>());
|
||||
|
||||
mEditable->UpdateCompositionRects(rects);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче