Bug 744439 - Reset the checkerboard colour when we start loading a new page. r=kats a=blocker

--HG--
extra : rebase_source : ca294fc3dd36a0d0a299c8247aa72673e115d372
This commit is contained in:
Joe Drew 2012-04-23 10:29:14 -07:00
Родитель c66d61426b
Коммит 99ec51f8f8
4 изменённых файлов: 53 добавлений и 36 удалений

Просмотреть файл

@ -670,6 +670,7 @@ abstract public class GeckoApp
tab.updateSecurityMode("unknown");
tab.removeTransientDoorHangers();
tab.setHasTouchListeners(false);
tab.setCheckerboardColor(Color.WHITE);
maybeCancelFaviconLoad(tab);
@ -829,14 +830,20 @@ abstract public class GeckoApp
final String title = message.getString("title");
final String backgroundColor = message.getString("bgColor");
handleContentLoaded(tabId, uri, title);
if (getLayerController() != null) {
Tab tab = Tabs.getInstance().getTab(tabId);
if (backgroundColor != null) {
getLayerController().setCheckerboardColor(backgroundColor);
tab.setCheckerboardColor(backgroundColor);
} else {
// Default to white if no color is given
getLayerController().setCheckerboardColor(Color.WHITE);
tab.setCheckerboardColor(Color.WHITE);
}
// Sync up the LayerController and the tab if the tab's
// currently displayed.
if (getLayerController() != null && Tabs.getInstance().isSelectedTab(tab)) {
getLayerController().setCheckerboardColor(tab.getCheckerboardColor());
}
Log.i(LOGTAG, "URI - " + uri + ", title - " + title);
} else if (event.equals("DOMTitleChanged")) {
final int tabId = message.getInt("tabID");

Просмотреть файл

@ -40,6 +40,7 @@ package org.mozilla.gecko;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@ -58,6 +59,8 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public final class Tab {
private static final String LOGTAG = "GeckoTab";
@ -68,6 +71,7 @@ public final class Tab {
private static float sDensity = 1;
private static int sMinScreenshotWidth = 0;
private static int sMinScreenshotHeight = 0;
private static Pattern sColorPattern;
private int mId;
private String mUrl;
private String mTitle;
@ -89,6 +93,7 @@ public final class Tab {
private HashMap<Surface, Layer> mPluginLayers;
private ContentResolver mContentResolver;
private ContentObserver mContentObserver;
private int mCheckerboardColor = Color.WHITE;
private int mState;
public static final int STATE_DELAYED = 0;
@ -561,4 +566,36 @@ public final class Tab {
public Layer removePluginLayer(Surface surface) {
return mPluginLayers.remove(surface);
}
public int getCheckerboardColor() {
return mCheckerboardColor;
}
/** Sets a new color for the checkerboard. */
public void setCheckerboardColor(int color) {
mCheckerboardColor = color;
}
/** Parses and sets a new color for the checkerboard. */
public void setCheckerboardColor(String newColor) {
setCheckerboardColor(parseColorFromGecko(newColor));
}
// Parses a color from an RGB triple of the form "rgb([0-9]+, [0-9]+, [0-9]+)". If the color
// cannot be parsed, returns white.
private static int parseColorFromGecko(String string) {
if (sColorPattern == null) {
sColorPattern = Pattern.compile("rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)");
}
Matcher matcher = sColorPattern.matcher(string);
if (!matcher.matches()) {
return Color.WHITE;
}
int r = Integer.parseInt(matcher.group(1));
int g = Integer.parseInt(matcher.group(2));
int b = Integer.parseInt(matcher.group(3));
return Color.rgb(r, g, b);
}
}

Просмотреть файл

@ -58,6 +58,7 @@ import android.util.Log;
import android.view.View;
import java.util.Map;
import java.util.HashMap;
import org.mozilla.gecko.Tabs;
public class GeckoLayerClient implements GeckoEventResponder,
LayerView.Listener {
@ -329,6 +330,7 @@ public class GeckoLayerClient implements GeckoEventResponder,
currentMetrics.setZoomFactor(zoom);
currentMetrics.setPageSize(new FloatSize(pageWidth, pageHeight), new FloatSize(cssPageWidth, cssPageHeight));
mLayerController.setViewportMetrics(currentMetrics);
mLayerController.setCheckerboardColor(Tabs.getInstance().getSelectedTab().getCheckerboardColor());
// At this point, we have just switched to displaying a different document than we
// we previously displaying. This means we need to abort any panning/zooming animations
// that are in progress and send an updated display port request to browser.js as soon

Просмотреть файл

@ -52,8 +52,6 @@ import android.graphics.RectF;
import android.util.Log;
import android.view.GestureDetector;
import android.view.View.OnTouchListener;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* The layer controller manages a tile that represents the visible page. It does panning and
@ -96,8 +94,6 @@ public class LayerController {
private boolean mForceRedraw;
private static Pattern sColorPattern;
public LayerController(Context context) {
mContext = context;
@ -359,29 +355,4 @@ public class LayerController {
mCheckerboardColor = newColor;
mView.requestRender();
}
/** Parses and sets a new color for the checkerboard. */
public void setCheckerboardColor(String newColor) {
setCheckerboardColor(parseColorFromGecko(newColor));
}
// Parses a color from an RGB triple of the form "rgb([0-9]+, [0-9]+, [0-9]+)". If the color
// cannot be parsed, returns white.
private static int parseColorFromGecko(String string) {
if (sColorPattern == null) {
sColorPattern = Pattern.compile("rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)");
}
Matcher matcher = sColorPattern.matcher(string);
if (!matcher.matches()) {
return Color.WHITE;
}
int r = Integer.parseInt(matcher.group(1));
int g = Integer.parseInt(matcher.group(2));
int b = Integer.parseInt(matcher.group(3));
return Color.rgb(r, g, b);
}
}