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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarControlContainer.java

Issue 2752693003: chrome/android: Update toolbar drawing in native. (Closed)
Patch Set: .. Created 3 years, 9 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.chrome.browser.toolbar; 5 package org.chromium.chrome.browser.toolbar;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Canvas; 8 import android.graphics.Canvas;
9 import android.graphics.PorterDuff; 9 import android.graphics.PorterDuff;
10 import android.graphics.Rect; 10 import android.graphics.Rect;
11 import android.graphics.Region; 11 import android.graphics.Region;
12 import android.util.AttributeSet; 12 import android.util.AttributeSet;
13 import android.view.MotionEvent; 13 import android.view.MotionEvent;
14 import android.view.View; 14 import android.view.View;
15 import android.view.ViewStub; 15 import android.view.ViewStub;
16 import android.widget.FrameLayout; 16 import android.widget.FrameLayout;
17 17
18 import org.chromium.chrome.R; 18 import org.chromium.chrome.R;
19 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl er; 19 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl er;
20 import org.chromium.chrome.browser.compositor.resources.ResourceFactory;
20 import org.chromium.chrome.browser.contextualsearch.SwipeRecognizer; 21 import org.chromium.chrome.browser.contextualsearch.SwipeRecognizer;
21 import org.chromium.chrome.browser.util.ViewUtils; 22 import org.chromium.chrome.browser.util.ViewUtils;
22 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo; 23 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo;
23 import org.chromium.chrome.browser.widget.ControlContainer; 24 import org.chromium.chrome.browser.widget.ControlContainer;
24 import org.chromium.chrome.browser.widget.ToolbarProgressBar; 25 import org.chromium.chrome.browser.widget.ToolbarProgressBar;
25 import org.chromium.chrome.browser.widget.ViewResourceFrameLayout; 26 import org.chromium.chrome.browser.widget.ViewResourceFrameLayout;
26 import org.chromium.ui.UiUtils; 27 import org.chromium.ui.UiUtils;
27 import org.chromium.ui.resources.dynamics.ViewResourceAdapter; 28 import org.chromium.ui.resources.dynamics.ViewResourceAdapter;
28 29
29 /** 30 /**
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 154 }
154 155
155 @Override 156 @Override
156 protected boolean isReadyForCapture() { 157 protected boolean isReadyForCapture() {
157 return mReadyForBitmapCapture; 158 return mReadyForBitmapCapture;
158 } 159 }
159 } 160 }
160 161
161 private static class ToolbarViewResourceAdapter extends ViewResourceAdapter { 162 private static class ToolbarViewResourceAdapter extends ViewResourceAdapter {
162 private final int[] mTempPosition = new int[2]; 163 private final int[] mTempPosition = new int[2];
164 private final Rect mLocationBarRect = new Rect();
165 private final Rect mToolbarRect = new Rect();
163 private final View mToolbarContainer; 166 private final View mToolbarContainer;
164 167
165 private Toolbar mToolbar; 168 private Toolbar mToolbar;
166 private int mTabStripHeightPx; 169 private int mTabStripHeightPx;
167 170
168 /** Builds the resource adapter for the toolbar. */ 171 /** Builds the resource adapter for the toolbar. */
169 public ToolbarViewResourceAdapter(View toolbarContainer) { 172 public ToolbarViewResourceAdapter(View toolbarContainer) {
170 super(toolbarContainer); 173 super(toolbarContainer);
171 mToolbarContainer = toolbarContainer; 174 mToolbarContainer = toolbarContainer;
172 } 175 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 216
214 @Override 217 @Override
215 protected void onCaptureEnd() { 218 protected void onCaptureEnd() {
216 mToolbar.setTextureCaptureMode(false); 219 mToolbar.setTextureCaptureMode(false);
217 // Forcing a texture capture should only be done for one draw. Turn off forced 220 // Forcing a texture capture should only be done for one draw. Turn off forced
218 // texture capture. 221 // texture capture.
219 mToolbar.setForceTextureCapture(false); 222 mToolbar.setForceTextureCapture(false);
220 } 223 }
221 224
222 @Override 225 @Override
223 protected void computeContentPadding(Rect outContentPadding) { 226 public long createNativeResource() {
224 outContentPadding.set( 227 mToolbar.getPositionRelativeToContainer(mToolbarContainer, mTempPosi tion);
225 0, mTabStripHeightPx, mToolbarContainer.getWidth(), mToolbar .getHeight()); 228 mToolbarRect.set(mTempPosition[0], mTempPosition[1], mToolbarContain er.getWidth(),
226 } 229 mTempPosition[1] + mToolbar.getHeight());
227 230
228 @Override 231 mToolbar.getLocationBarContentRect(mLocationBarRect);
229 protected void computeContentAperture(Rect outContentAperture) { 232 mLocationBarRect.offset(mTempPosition[0], mTempPosition[1]);
230 mToolbar.getLocationBarContentRect(outContentAperture); 233
231 mToolbar.getPositionRelativeToContainer(mToolbarContainer, mTempPosi tion); 234 int shadowHeight =
232 outContentAperture.offset(mTempPosition[0], mTempPosition[1]); 235 mToolbarContainer.getHeight() - mToolbar.getHeight() - mTabS tripHeightPx;
236 return ResourceFactory.createToolbarContainerResource(
237 mToolbarRect, mLocationBarRect, shadowHeight);
233 } 238 }
234 } 239 }
235 240
236 @Override 241 @Override
237 public boolean onTouchEvent(MotionEvent event) { 242 public boolean onTouchEvent(MotionEvent event) {
238 // Don't eat the event if we don't have a handler. 243 // Don't eat the event if we don't have a handler.
239 if (mSwipeHandler == null) return false; 244 if (mSwipeHandler == null) return false;
240 245
241 // If we have ACTION_DOWN in this context, that means either no child co nsumed the event or 246 // If we have ACTION_DOWN in this context, that means either no child co nsumed the event or
242 // this class is the top UI at the event position. Then, we don't need t o feed the event to 247 // this class is the top UI at the event position. Then, we don't need t o feed the event to
(...skipping 25 matching lines...) Expand all
268 273
269 @Override 274 @Override
270 public boolean shouldRecognizeSwipe(MotionEvent e1, MotionEvent e2) { 275 public boolean shouldRecognizeSwipe(MotionEvent e1, MotionEvent e2) {
271 if (isOnTabStrip(e1)) return false; 276 if (isOnTabStrip(e1)) return false;
272 if (mToolbar.shouldIgnoreSwipeGesture()) return false; 277 if (mToolbar.shouldIgnoreSwipeGesture()) return false;
273 if (UiUtils.isKeyboardShowing(getContext(), ToolbarControlContainer. this)) return false; 278 if (UiUtils.isKeyboardShowing(getContext(), ToolbarControlContainer. this)) return false;
274 return true; 279 return true;
275 } 280 }
276 } 281 }
277 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698