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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java

Issue 2774423003: Removing invalidateActionMode (Closed)
Patch Set: fixing unhiding on showActionMode Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.SearchManager; 9 import android.app.SearchManager;
10 import android.content.ClipboardManager; 10 import android.content.ClipboardManager;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 * 189 *
190 * <p>Action mode in floating mode is tried first, and then falls back to 190 * <p>Action mode in floating mode is tried first, and then falls back to
191 * a normal one. 191 * a normal one.
192 * @return {@code true} if the action mode started successfully or is alread y on. 192 * @return {@code true} if the action mode started successfully or is alread y on.
193 */ 193 */
194 public boolean showActionMode() { 194 public boolean showActionMode() {
195 if (isEmpty()) return false; 195 if (isEmpty()) return false;
196 196
197 // Just refreshes the view if it is already showing. 197 // Just refreshes the view if it is already showing.
198 if (isActionModeValid()) { 198 if (isActionModeValid()) {
199 invalidateActionMode(); 199 // Try/catch necessary for framework bug, crbug.com/446717.
200 return true; 200 try {
201 } 201 mActionMode.invalidate();
202 202 } catch (NullPointerException e) {
203 if (mView.getParent() != null) { 203 Log.w(TAG, "Ignoring NPE from ActionMode.invalidate() as workaro und for L", e);
204 // On ICS, startActionMode throws an NPE when getParent() is null. 204 }
205 } else {
205 assert mWebContents != null; 206 assert mWebContents != null;
206 ActionMode actionMode = supportsFloatingActionMode() 207 ActionMode actionMode = supportsFloatingActionMode()
207 ? startFloatingActionMode() 208 ? startFloatingActionMode()
208 : mView.startActionMode(mCallback); 209 : mView.startActionMode(mCallback);
209 if (actionMode != null) { 210 if (actionMode != null) {
210 // This is to work around an LGE email issue. See crbug.com/6517 06 for more details. 211 // This is to work around an LGE email issue. See crbug.com/6517 06 for more details.
211 LGEmailActionModeWorkaround.runIfNecessary(mContext, actionMode) ; 212 LGEmailActionModeWorkaround.runIfNecessary(mContext, actionMode) ;
212 } 213 }
213 mActionMode = actionMode; 214 mActionMode = actionMode;
214 } 215 }
216 hideActionMode(false);
Tima Vaisburd 2017/03/28 02:54:42 Can the action mode be hidden (i.e. mHidden == tru
boliu 2017/03/28 17:09:19 So only SELECTION_HANDLES_SHOWN can fall into inva
Tima Vaisburd 2017/03/28 17:39:52 Action mode can be hidden, but it should exist. I
boliu 2017/03/28 17:44:12 Oh, ok. Yeah I got confused, old code in invalidat
amaralp 2017/03/28 18:15:08 The only times mHidden is set to true is when a sc
215 mUnselectAllOnDismiss = true; 217 mUnselectAllOnDismiss = true;
Jinsuk Kim 2017/03/28 02:19:59 |mUnselectAllOnDismiss| gets turned on but didn't
boliu 2017/03/28 17:09:19 Looks ok, it would have already been false in the
amaralp 2017/03/28 18:15:08 It would have been already false. Also I've change
216 return isActionModeValid(); 218 return isActionModeValid();
217 } 219 }
218 220
219 @TargetApi(Build.VERSION_CODES.M) 221 @TargetApi(Build.VERSION_CODES.M)
220 private ActionMode startFloatingActionMode() { 222 private ActionMode startFloatingActionMode() {
221 ActionMode actionMode = mView.startActionMode( 223 ActionMode actionMode = mView.startActionMode(
222 new FloatingActionModeCallback(this, mCallback), ActionMode.TYPE _FLOATING); 224 new FloatingActionModeCallback(this, mCallback), ActionMode.TYPE _FLOATING);
223 return actionMode; 225 return actionMode;
224 } 226 }
225 227
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 public void finishActionMode() { 292 public void finishActionMode() {
291 if (isActionModeValid()) { 293 if (isActionModeValid()) {
292 mActionMode.finish(); 294 mActionMode.finish();
293 295
294 // Should be nulled out in case #onDestroyActionMode() is not invoke d in response. 296 // Should be nulled out in case #onDestroyActionMode() is not invoke d in response.
295 mActionMode = null; 297 mActionMode = null;
296 } 298 }
297 } 299 }
298 300
299 /** 301 /**
300 * @see ActionMode#invalidate()
301 * Note that invalidation will also reset visibility state. The caller
302 * should account for this when making subsequent visibility updates.
303 */
304 private void invalidateActionMode() {
305 if (!isActionModeValid()) return;
306 if (mHidden) {
307 assert canHideActionMode();
308 mHidden = false;
309 mView.removeCallbacks(mRepeatingHideRunnable);
310 mPendingInvalidateContentRect = false;
311 }
312
313 // Try/catch necessary for framework bug, crbug.com/446717.
314 try {
315 mActionMode.invalidate();
316 } catch (NullPointerException e) {
317 Log.w(TAG, "Ignoring NPE from ActionMode.invalidate() as workaround for L", e);
318 }
319 }
320
321 /**
322 * @see ActionMode#invalidateContentRect() 302 * @see ActionMode#invalidateContentRect()
323 */ 303 */
324 public void invalidateContentRect() { 304 public void invalidateContentRect() {
325 if (supportsFloatingActionMode()) { 305 if (supportsFloatingActionMode()) {
326 if (mHidden) { 306 if (mHidden) {
327 mPendingInvalidateContentRect = true; 307 mPendingInvalidateContentRect = true;
328 } else { 308 } else {
329 mPendingInvalidateContentRect = false; 309 mPendingInvalidateContentRect = false;
330 if (isActionModeValid()) mActionMode.invalidateContentRect(); 310 if (isActionModeValid()) mActionMode.invalidateContentRect();
331 } 311 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 mIsInsertion = insertion; 883 mIsInsertion = insertion;
904 } 884 }
905 885
906 private boolean isShareAvailable() { 886 private boolean isShareAvailable() {
907 Intent intent = new Intent(Intent.ACTION_SEND); 887 Intent intent = new Intent(Intent.ACTION_SEND);
908 intent.setType("text/plain"); 888 intent.setType("text/plain");
909 return mContext.getPackageManager().queryIntentActivities(intent, 889 return mContext.getPackageManager().queryIntentActivities(intent,
910 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; 890 PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
911 } 891 }
912 } 892 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698