Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwViewAndroidDelegate.java

Issue 2536223003: Refactor ContentViewClient (3/6) (Closed)
Patch Set: removed getDesiredMeasureSpec Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.view.View; 7 import android.view.View;
8 import android.view.ViewGroup; 8 import android.view.ViewGroup;
9 import android.widget.FrameLayout; 9 import android.widget.FrameLayout;
10 10
(...skipping 15 matching lines...) Expand all
26 * {@link #updateCurrentContainerView()}. 26 * {@link #updateCurrentContainerView()}.
27 */ 27 */
28 private ViewGroup mContainerView; 28 private ViewGroup mContainerView;
29 29
30 /** 30 /**
31 * List of anchor views stored in the order in which they were acquired mapp ed 31 * List of anchor views stored in the order in which they were acquired mapp ed
32 * to their position. 32 * to their position.
33 */ 33 */
34 private final Map<View, Position> mAnchorViews = new LinkedHashMap<>(); 34 private final Map<View, Position> mAnchorViews = new LinkedHashMap<>();
35 35
36 private final AwContentsClient mContentsClient;
37
36 private final RenderCoordinates mRenderCoordinates; 38 private final RenderCoordinates mRenderCoordinates;
37 39
38 /** 40 /**
39 * Represents the position of an anchor view. 41 * Represents the position of an anchor view.
40 */ 42 */
41 @VisibleForTesting 43 @VisibleForTesting
42 private static class Position { 44 private static class Position {
43 public final float mX; 45 public final float mX;
44 public final float mY; 46 public final float mY;
45 public final float mWidth; 47 public final float mWidth;
46 public final float mHeight; 48 public final float mHeight;
47 public final int mLeftMargin; 49 public final int mLeftMargin;
48 public final int mTopMargin; 50 public final int mTopMargin;
49 51
50 public Position(float x, float y, float width, float height, int leftMar gin, 52 public Position(float x, float y, float width, float height, int leftMar gin,
51 int topMargin) { 53 int topMargin) {
52 mX = x; 54 mX = x;
53 mY = y; 55 mY = y;
54 mWidth = width; 56 mWidth = width;
55 mHeight = height; 57 mHeight = height;
56 mLeftMargin = leftMargin; 58 mLeftMargin = leftMargin;
57 mTopMargin = topMargin; 59 mTopMargin = topMargin;
58 } 60 }
59 } 61 }
60 62
61 @VisibleForTesting 63 @VisibleForTesting
62 public AwViewAndroidDelegate(ViewGroup containerView, RenderCoordinates rend erCoordinates) { 64 public AwViewAndroidDelegate(ViewGroup containerView, AwContentsClient conte ntsClient,
65 RenderCoordinates renderCoordinates) {
63 mContainerView = containerView; 66 mContainerView = containerView;
67 mContentsClient = contentsClient;
64 mRenderCoordinates = renderCoordinates; 68 mRenderCoordinates = renderCoordinates;
65 } 69 }
66 70
67 @Override 71 @Override
68 public View acquireView() { 72 public View acquireView() {
69 ViewGroup containerView = getContainerView(); 73 ViewGroup containerView = getContainerView();
70 if (containerView == null) return null; 74 if (containerView == null) return null;
71 View anchorView = new View(containerView.getContext()); 75 View anchorView = new View(containerView.getContext());
72 containerView.addView(anchorView); 76 containerView.addView(anchorView);
73 // |mAnchorViews| will be updated with the right view position in |setVi ewPosition|. 77 // |mAnchorViews| will be updated with the right view position in |setVi ewPosition|.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 android.widget.AbsoluteLayout.LayoutParams lp = 137 android.widget.AbsoluteLayout.LayoutParams lp =
134 new android.widget.AbsoluteLayout.LayoutParams( 138 new android.widget.AbsoluteLayout.LayoutParams(
135 scaledWidth, scaledHeight, leftMargin, topMargin); 139 scaledWidth, scaledHeight, leftMargin, topMargin);
136 anchorView.setLayoutParams(lp); 140 anchorView.setLayoutParams(lp);
137 } 141 }
138 142
139 @Override 143 @Override
140 public ViewGroup getContainerView() { 144 public ViewGroup getContainerView() {
141 return mContainerView; 145 return mContainerView;
142 } 146 }
147
148 @Override
149 public void onBackgroundColorChanged(int color) {
150 mContentsClient.onBackgroundColorChanged(color);
151 }
143 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698