Bug 1416310 - 1. Remove getMatrixForLayerRectToViewRect; r=rbarker

Patch gets rid of `LayerView.getMatrixForLayerRectToViewRect`, and just
uses `LayerView.getZoomFactor` directly when calculating the matrix in
GeckoInputConnection. This also lets us avoid the `isCompositorReady`
call on a non-UI thread. To get the correct offset, we need the screen
bounds from Gecko, so it's passed to Java as the first element in the
rect array. Using bounds from Gecko lets us avoid having to deal with
things like the dynamic toolbar animator ourselves.

MozReview-Commit-ID: 6I61SZGyQyO

--HG--
extra : rebase_source : d576fb7ef9a42de10b14db662e5c4833f16f6312
This commit is contained in:
Jim Chen 2017-11-20 17:17:00 -05:00
Родитель e760c78ddc
Коммит bbe7b4e34c
4 изменённых файлов: 20 добавлений и 33 удалений

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

@ -365,13 +365,11 @@ class GeckoInputConnection
return;
}
Matrix matrix = view.getMatrixForLayerRectToViewRect();
if (matrix == null) {
if (DEBUG) {
Log.d(LOGTAG, "Cannot get Matrix to convert from Gecko coords to layer view coords");
}
return;
}
// First aRects element is the widget bounds in device units.
final float zoom = view.getZoomFactor();
final Matrix matrix = new Matrix();
matrix.postScale(zoom, zoom);
matrix.postTranslate(aRects[0].left, aRects[0].top);
mCursorAnchorInfoBuilder.setMatrix(matrix);
final Editable content = getEditable();
@ -387,8 +385,9 @@ class GeckoInputConnection
return;
}
for (int i = 0; i < aRects.length; i++) {
mCursorAnchorInfoBuilder.addCharacterBounds(i,
// Subsequent aRects elements are character bounds in CSS units.
for (int i = 1; i < aRects.length; i++) {
mCursorAnchorInfoBuilder.addCharacterBounds(i - 1,
aRects[i].left,
aRects[i].top,
aRects[i].right,

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

@ -387,19 +387,4 @@ class GeckoLayerClient implements LayerView.Listener
ImmutableViewportMetrics getViewportMetrics() {
return mViewportMetrics;
}
Matrix getMatrixForLayerRectToViewRect() {
ImmutableViewportMetrics viewportMetrics = mViewportMetrics;
PointF origin = viewportMetrics.getOrigin();
float zoom = viewportMetrics.zoomFactor;
ImmutableViewportMetrics geckoViewport = mViewportMetrics;
PointF geckoOrigin = geckoViewport.getOrigin();
float geckoZoom = geckoViewport.zoomFactor;
Matrix matrix = new Matrix();
matrix.postTranslate(geckoOrigin.x / geckoZoom, geckoOrigin.y / geckoZoom);
matrix.postScale(zoom, zoom);
matrix.postTranslate(-origin.x, -origin.y);
return matrix;
}
}

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

@ -283,10 +283,6 @@ public class LayerView extends FrameLayout {
return mLayerClient.getViewportMetrics();
}
public Matrix getMatrixForLayerRectToViewRect() {
return mLayerClient.getMatrixForLayerRectToViewRect();
}
public void setSurfaceBackgroundColor(int newColor) {
}

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

@ -536,19 +536,26 @@ ConvertAndroidColor(uint32_t aArgb)
static jni::ObjectArray::LocalRef
ConvertRectArrayToJavaRectFArray(const nsTArray<LayoutDeviceIntRect>& aRects,
const LayoutDeviceIntPoint& aOffset,
const LayoutDeviceIntRect& aWidgetBounds,
const CSSToLayoutDeviceScale aScale)
{
const size_t length = aRects.Length();
auto rects = jni::ObjectArray::New<sdk::RectF>(length);
auto rects = jni::ObjectArray::New<sdk::RectF>(length + 1);
// First element is the widget bounds in device units.
auto widgetRect = sdk::RectF::New(aWidgetBounds.x, aWidgetBounds.y,
aWidgetBounds.x + aWidgetBounds.width,
aWidgetBounds.y + aWidgetBounds.height);
rects->SetElement(0, widgetRect);
for (size_t i = 0; i < length; i++) {
LayoutDeviceIntRect tmp = aRects[i] + aOffset;
LayoutDeviceIntRect tmp = aRects[i];
// Subsequent elements are character bounds in CSS units.
auto rect = sdk::RectF::New(tmp.x / aScale.scale, tmp.y / aScale.scale,
(tmp.x + tmp.width) / aScale.scale,
(tmp.y + tmp.height) / aScale.scale);
rects->SetElement(i, rect);
rects->SetElement(i + 1, rect);
}
return rects;
}
@ -915,7 +922,7 @@ GeckoEditableSupport::UpdateCompositionRects()
auto rects = ConvertRectArrayToJavaRectFArray(
textRects.mReply.mRectArray,
widget->WidgetToScreenOffset(),
widget->GetScreenBounds(),
widget->GetDefaultScale());
mEditable->UpdateCompositionRects(rects);