Skip to content

Commit 99015a2

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "Remove unnecessary memory allocations" into ics-mr1
2 parents f3a892a + aefc28a commit 99015a2

File tree

5 files changed

+25
-94
lines changed

5 files changed

+25
-94
lines changed

core/java/android/webkit/BrowserFrame.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,6 @@ private LoadListener startLoadingResource(int loaderHandle,
813813
boolean synchronous,
814814
String username,
815815
String password) {
816-
PerfChecker checker = new PerfChecker();
817-
818816
if (mSettings.getCacheMode() != WebSettings.LOAD_DEFAULT) {
819817
cacheMode = mSettings.getCacheMode();
820818
}
@@ -872,11 +870,6 @@ private LoadListener startLoadingResource(int loaderHandle,
872870
|| headers.containsKey("If-None-Match") ?
873871
WebSettings.LOAD_NO_CACHE : cacheMode);
874872
// Set referrer to current URL?
875-
if (!loader.executeLoad()) {
876-
checker.responseAlert("startLoadingResource fail");
877-
}
878-
checker.responseAlert("startLoadingResource succeed");
879-
880873
return !synchronous ? loadListener : null;
881874
}
882875

core/java/android/webkit/JWebCoreJavaBridge.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ static synchronized void removeActiveWebView(WebView webview) {
8787
* Call native timer callbacks.
8888
*/
8989
private void fireSharedTimer() {
90-
PerfChecker checker = new PerfChecker();
9190
// clear the flag so that sharedTimerFired() can set a new timer
9291
mHasInstantTimer = false;
9392
sharedTimerFired();
94-
checker.responseAlert("sharedTimer");
9593
}
9694

9795
/**

core/java/android/webkit/LoadListener.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,6 @@ private void commitLoad() {
11361136
// Give the data to WebKit now. We don't have to synchronize on
11371137
// mDataBuilder here because pulling each chunk removes it from the
11381138
// internal list so it cannot be modified.
1139-
PerfChecker checker = new PerfChecker();
11401139
ByteArrayBuilder.Chunk c;
11411140
while (true) {
11421141
c = mDataBuilder.getFirstChunk();
@@ -1152,7 +1151,6 @@ private void commitLoad() {
11521151
} else {
11531152
c.release();
11541153
}
1155-
checker.responseAlert("res nativeAddData");
11561154
}
11571155
}
11581156

@@ -1173,13 +1171,11 @@ void tearDown() {
11731171
WebViewWorker.MSG_REMOVE_CACHE, this).sendToTarget();
11741172
}
11751173
if (mNativeLoader != 0) {
1176-
PerfChecker checker = new PerfChecker();
11771174
if (!mSetNativeResponse) {
11781175
setNativeResponse();
11791176
}
11801177

11811178
nativeFinished();
1182-
checker.responseAlert("res nativeFinished");
11831179
clearNativeLoader();
11841180
}
11851181
}

core/java/android/webkit/PerfChecker.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

core/java/android/webkit/WebView.java

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,6 @@ public void onTrimMemory(int level) {
683683
private static final int SWITCH_TO_LONGPRESS = 4;
684684
private static final int RELEASE_SINGLE_TAP = 5;
685685
private static final int REQUEST_FORM_DATA = 6;
686-
private static final int RESUME_WEBCORE_PRIORITY = 7;
687686
private static final int DRAG_HELD_MOTIONLESS = 8;
688687
private static final int AWAKEN_SCROLL_BARS = 9;
689688
private static final int PREVENT_DEFAULT_TIMEOUT = 10;
@@ -2850,46 +2849,47 @@ private void recordNewContentSize(int w, int h, boolean updateLayout) {
28502849
// Used to avoid sending many visible rect messages.
28512850
private Rect mLastVisibleRectSent;
28522851
private Rect mLastGlobalRect;
2852+
private Rect mVisibleRect = new Rect();
2853+
private Rect mGlobalVisibleRect = new Rect();
2854+
private Point mScrollOffset = new Point();
28532855

28542856
Rect sendOurVisibleRect() {
28552857
if (mZoomManager.isPreventingWebkitUpdates()) return mLastVisibleRectSent;
2856-
Rect rect = new Rect();
2857-
calcOurContentVisibleRect(rect);
2858+
calcOurContentVisibleRect(mVisibleRect);
28582859
// Rect.equals() checks for null input.
2859-
if (!rect.equals(mLastVisibleRectSent)) {
2860+
if (!mVisibleRect.equals(mLastVisibleRectSent)) {
28602861
if (!mBlockWebkitViewMessages) {
2861-
Point pos = new Point(rect.left, rect.top);
2862+
mScrollOffset.set(mVisibleRect.left, mVisibleRect.top);
28622863
mWebViewCore.removeMessages(EventHub.SET_SCROLL_OFFSET);
28632864
mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,
2864-
nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, pos);
2865+
nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, mScrollOffset);
28652866
}
2866-
mLastVisibleRectSent = rect;
2867+
mLastVisibleRectSent = mVisibleRect;
28672868
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
28682869
}
2869-
Rect globalRect = new Rect();
2870-
if (getGlobalVisibleRect(globalRect)
2871-
&& !globalRect.equals(mLastGlobalRect)) {
2870+
if (getGlobalVisibleRect(mGlobalVisibleRect)
2871+
&& !mGlobalVisibleRect.equals(mLastGlobalRect)) {
28722872
if (DebugFlags.WEB_VIEW) {
2873-
Log.v(LOGTAG, "sendOurVisibleRect=(" + globalRect.left + ","
2874-
+ globalRect.top + ",r=" + globalRect.right + ",b="
2875-
+ globalRect.bottom);
2873+
Log.v(LOGTAG, "sendOurVisibleRect=(" + mGlobalVisibleRect.left + ","
2874+
+ mGlobalVisibleRect.top + ",r=" + mGlobalVisibleRect.right + ",b="
2875+
+ mGlobalVisibleRect.bottom);
28762876
}
28772877
// TODO: the global offset is only used by windowRect()
28782878
// in ChromeClientAndroid ; other clients such as touch
28792879
// and mouse events could return view + screen relative points.
28802880
if (!mBlockWebkitViewMessages) {
2881-
mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, globalRect);
2881+
mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, mGlobalVisibleRect);
28822882
}
2883-
mLastGlobalRect = globalRect;
2883+
mLastGlobalRect = mGlobalVisibleRect;
28842884
}
2885-
return rect;
2885+
return mVisibleRect;
28862886
}
28872887

2888+
private Point mGlobalVisibleOffset = new Point();
28882889
// Sets r to be the visible rectangle of our webview in view coordinates
28892890
private void calcOurVisibleRect(Rect r) {
2890-
Point p = new Point();
2891-
getGlobalVisibleRect(r, p);
2892-
r.offset(-p.x, -p.y);
2891+
getGlobalVisibleRect(r, mGlobalVisibleOffset);
2892+
r.offset(-mGlobalVisibleOffset.x, -mGlobalVisibleOffset.y);
28932893
}
28942894

28952895
// Sets r to be our visible rectangle in content coordinates
@@ -2905,21 +2905,21 @@ private void calcOurContentVisibleRect(Rect r) {
29052905
r.bottom = viewToContentY(r.bottom);
29062906
}
29072907

2908+
private Rect mContentVisibleRect = new Rect();
29082909
// Sets r to be our visible rectangle in content coordinates. We use this
29092910
// method on the native side to compute the position of the fixed layers.
29102911
// Uses floating coordinates (necessary to correctly place elements when
29112912
// the scale factor is not 1)
29122913
private void calcOurContentVisibleRectF(RectF r) {
2913-
Rect ri = new Rect(0,0,0,0);
2914-
calcOurVisibleRect(ri);
2915-
r.left = viewToContentXf(ri.left);
2914+
calcOurVisibleRect(mContentVisibleRect);
2915+
r.left = viewToContentXf(mContentVisibleRect.left);
29162916
// viewToContentY will remove the total height of the title bar. Add
29172917
// the visible height back in to account for the fact that if the title
29182918
// bar is partially visible, the part of the visible rect which is
29192919
// displaying our content is displaced by that amount.
2920-
r.top = viewToContentYf(ri.top + getVisibleTitleHeightImpl());
2921-
r.right = viewToContentXf(ri.right);
2922-
r.bottom = viewToContentYf(ri.bottom);
2920+
r.top = viewToContentYf(mContentVisibleRect.top + getVisibleTitleHeightImpl());
2921+
r.right = viewToContentXf(mContentVisibleRect.right);
2922+
r.bottom = viewToContentYf(mContentVisibleRect.bottom);
29232923
}
29242924

29252925
static class ViewSizeData {
@@ -3569,7 +3569,6 @@ public void computeScroll() {
35693569
mScrollingLayerRect.top = y;
35703570
}
35713571
abortAnimation();
3572-
mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
35733572
nativeSetIsScrolling(false);
35743573
if (!mBlockWebkitViewMessages) {
35753574
WebViewCore.resumePriority();
@@ -5992,7 +5991,6 @@ private boolean handleTouchEventCommon(MotionEvent ev, int action, int x, int y)
59925991
mScroller.abortAnimation();
59935992
mTouchMode = TOUCH_DRAG_START_MODE;
59945993
mConfirmMove = true;
5995-
mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
59965994
nativeSetIsScrolling(false);
59975995
} else if (mPrivateHandler.hasMessages(RELEASE_SINGLE_TAP)) {
59985996
mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
@@ -7329,7 +7327,6 @@ private void updateSelection() {
73297327
mLastTouchTime = eventTime;
73307328
if (!mScroller.isFinished()) {
73317329
abortAnimation();
7332-
mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
73337330
}
73347331
mSnapScrollMode = SNAP_NONE;
73357332
mVelocityTracker = VelocityTracker.obtain();
@@ -8461,10 +8458,6 @@ public void handleMessage(Message msg) {
84618458
mWebTextView.setAdapterCustom(adapter);
84628459
}
84638460
break;
8464-
case RESUME_WEBCORE_PRIORITY:
8465-
WebViewCore.resumePriority();
8466-
WebViewCore.resumeUpdatePicture(mWebViewCore);
8467-
break;
84688461

84698462
case LONG_PRESS_CENTER:
84708463
// as this is shared by keydown and trackballdown, reset all

0 commit comments

Comments
 (0)