Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.input; | 5 package org.chromium.content.browser.input; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.res.TypedArray; | 8 import android.content.res.TypedArray; |
| 9 import android.util.TypedValue; | 9 import android.util.TypedValue; |
| 10 import android.view.Gravity; | 10 import android.view.Gravity; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 coords[0] += handleHalfWidth + width / 2; | 151 coords[0] += handleHalfWidth + width / 2; |
| 152 } else { | 152 } else { |
| 153 coords[0] -= handleHalfWidth + width / 2; | 153 coords[0] -= handleHalfWidth + width / 2; |
| 154 } | 154 } |
| 155 } else { | 155 } else { |
| 156 // Horizontal clipping | 156 // Horizontal clipping |
| 157 coords[0] = Math.max(0, coords[0]); | 157 coords[0] = Math.max(0, coords[0]); |
| 158 coords[0] = Math.min(screenWidth - width, coords[0]); | 158 coords[0] = Math.min(screenWidth - width, coords[0]); |
| 159 } | 159 } |
| 160 | 160 |
| 161 mContainer.showAtLocation(mParent, Gravity.NO_GRAVITY, coords[0], coords [1]); | 161 if (!isShowing()) { |
| 162 // Popup is showing first time | |
|
jdduke (slow)
2014/08/01 15:10:51
Nit: No need for this comment, I think it's pretty
AKVT
2014/08/01 15:23:25
Done.
| |
| 163 mContainer.showAtLocation(mParent, Gravity.NO_GRAVITY, coords[0], co ords[1]); | |
| 164 } else { | |
| 165 // Repositioning already showing popup. | |
| 166 mContainer.update(coords[0], coords[1], -1, -1); | |
| 167 } | |
| 162 } | 168 } |
| 163 | 169 |
| 164 private int viewIndex(boolean onTop) { | 170 private int viewIndex(boolean onTop) { |
| 165 return (onTop ? 0 : 1 << 1) + (canPaste() ? 0 : 1 << 0); | 171 return (onTop ? 0 : 1 << 1) + (canPaste() ? 0 : 1 << 0); |
| 166 } | 172 } |
| 167 | 173 |
| 168 private void updateContent(boolean onTop) { | 174 private void updateContent(boolean onTop) { |
| 169 final int viewIndex = viewIndex(onTop); | 175 final int viewIndex = viewIndex(onTop); |
| 170 View view = mPasteViews[viewIndex]; | 176 View view = mPasteViews[viewIndex]; |
| 171 | 177 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 195 } | 201 } |
| 196 | 202 |
| 197 private boolean canPaste() { | 203 private boolean canPaste() { |
| 198 return mDelegate.canPaste(); | 204 return mDelegate.canPaste(); |
| 199 } | 205 } |
| 200 | 206 |
| 201 private void paste() { | 207 private void paste() { |
| 202 mDelegate.paste(); | 208 mDelegate.paste(); |
| 203 } | 209 } |
| 204 } | 210 } |
| OLD | NEW |