Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2011-12-07 09:39:26 +00:00
Родитель 9f13075404 606f874333
Коммит df7e8d0963
14 изменённых файлов: 353 добавлений и 111 удалений

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

@ -263,6 +263,9 @@
#ifdef XP_MACOSX
@BINPATH@/components/widget_cocoa.xpt
#endif
#ifdef ANDROID
@BINPATH@/components/widget_android.xpt
#endif
@BINPATH@/components/windowds.xpt
@BINPATH@/components/windowwatcher.xpt
@BINPATH@/components/xpcom_base.xpt

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

@ -125,5 +125,13 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="org.mozilla.gecko.VideoPlayer"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

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

@ -73,6 +73,9 @@ import android.net.NetworkInfo;
import android.graphics.drawable.*;
import android.graphics.Bitmap;
import org.json.JSONArray;
import org.json.JSONObject;
public class GeckoAppShell
{
private static final String LOG_FILE_NAME = "GeckoAppShell";
@ -808,6 +811,18 @@ public class GeckoAppShell
intent.setDataAndType(Uri.parse(aUriSpec), aMimeType);
} else {
Uri uri = Uri.parse(aUriSpec);
if ("vnd.youtube".equals(uri.getScheme())) {
// Special case youtube to fallback to our own player
String[] handlers = getHandlersForURL(aUriSpec, aAction);
if (handlers.length == 0) {
intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(GeckoApp.mAppContext.getPackageName(),
"org.mozilla.gecko.VideoPlayer");
intent.setData(uri);
GeckoApp.mAppContext.startActivity(intent);
return true;
}
}
if ("sms".equals(uri.getScheme())) {
// Have a apecial handling for the SMS, as the message body
// is not extracted from the URI automatically
@ -1629,10 +1644,6 @@ public class GeckoAppShell
}
}
// unused
public static String handleGeckoMessage(String message) {
return "";
}
// unused
static void checkUriVisited(String uri) {}
// unused
@ -1645,6 +1656,27 @@ public class GeckoAppShell
GeckoBatteryManager.enableNotifications();
}
public static String handleGeckoMessage(String message) {
//
// {"gecko": {
// "type": "value",
// "event_specific": "value",
// ....
try {
JSONObject json = new JSONObject(message);
final JSONObject geckoObject = json.getJSONObject("gecko");
String type = geckoObject.getString("type");
if (type.equals("Gecko:Ready")) {
onAppShellReady();
}
} catch (Exception e) {
Log.i(LOG_FILE_NAME, "handleGeckoMessage throws " + e);
}
return "";
}
public static void disableBatteryNotifications() {
GeckoBatteryManager.disableNotifications();
}

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

@ -56,6 +56,7 @@ JAVAFILES = \
SurfaceInfo.java \
GeckoBatteryManager.java \
GeckoSmsManager.java \
VideoPlayer.java \
$(NULL)
PROCESSEDJAVAFILES = \
@ -127,6 +128,7 @@ RES_LAYOUT = \
res/layout/notification_icon_text.xml \
res/layout/launch_app_list.xml \
res/layout/launch_app_listitem.xml \
res/layout/videoplayer.xml \
$(NULL)
RES_VALUES = res/values/colors.xml res/values/themes.xml

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

@ -0,0 +1,113 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Android code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brad Lassey <blassey@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
package org.mozilla.gecko;
import android.app.Activity;
import android.os.Bundle;
import java.net.*;
import java.io.*;
import java.util.*;
import android.util.*;
import android.widget.*;
import android.net.*;
import android.content.Intent;
public class VideoPlayer extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.videoplayer);
mVideoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(mVideoView);
Intent intent = getIntent();
Uri data = intent.getData();
String spec = null;
if ("vnd.youtube".equals(data.getScheme())) {
String ssp = data.getSchemeSpecificPart();
String id = ssp.substring(0, ssp.indexOf('?'));
spec = getSpecFromYouTubeVideoID(id);
}
if (spec == null)
return;
Uri video = Uri.parse(spec);
mVideoView.setMediaController(mediaController);
mVideoView.setVideoURI(video);
mVideoView.start();
}
VideoView mVideoView;
String getSpecFromYouTubeVideoID(String id) {
String spec = null;
try {
String info_uri = "http://www.youtube.com/get_video_info?&video_id=" + id;
URL info_url = new URL(info_uri);
URLConnection urlConnection = info_url.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
try {
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
sb.append(line);
android.net.Uri fakeUri = android.net.Uri.parse("fake:/fake?" + sb);
String stream_map = fakeUri.getQueryParameter("url_encoded_fmt_stream_map");
if (stream_map == null)
return null;
String[] streams = stream_map.split(",");
for (int i = 0; i < streams.length; i++) {
fakeUri = android.net.Uri.parse("fake:/fake?" + streams[i]);
String url = fakeUri.getQueryParameter("url");
String type = fakeUri.getQueryParameter("type");
if (type != null && url != null &&
(type.startsWith("video/mp4") || type.startsWith("video/webm"))) {
spec = url;
}
}
} finally {
br.close();
}
} catch (Exception e) {
Log.e("VideoPlayer", "exception", e);
}
return spec;
}
}

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

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:id="@+id/VideoView" />
</LinearLayout>

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

@ -0,0 +1,44 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Tiny ugly fonts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
margin: 50px;
}
p, div {
margin: 0;
}
#test {
font-size: 1px;
}
#test p {
font-size: 8.3%;
}
#f1 { font-family: Terminal; }
#f2 { font-family: FixedSys; }
#f3 { font-family: Script; }
#f4 { font-family: Roman; }
</style>
</head>
<body>
<h4>No text should show below this line</h4>
<div id="test">
<p id="f1">ugly font</p>
<p id="f2">ugly font</p>
<p id="f3">ugly font</p>
<p id="f4">ugly font</p>
</div>
</body>
</html>

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

@ -85,3 +85,5 @@ load 595727-1.html
load 633453-1.html
load 633322-1.html
load 686190-1.html
load 693143-1.html

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

@ -1832,7 +1832,7 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, bool aIsBadUnderlineFont)
{
// Even if this font size is zero, this font is created with non-zero size.
// However, for layout and others, we should return the metrics of zero size font.
if (mStyle.size == 0) {
if (mStyle.size == 0.0) {
memset(aMetrics, 0, sizeof(gfxFont::Metrics));
return;
}

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

@ -327,6 +327,7 @@ gfxGDIFont::Initialize()
}
}
// this may end up being zero
mAdjustedSize = ROUND(mAdjustedSize);
FillLogFont(logFont, mAdjustedSize);
mFont = ::CreateFontIndirectW(&logFont);
@ -338,7 +339,9 @@ gfxGDIFont::Initialize()
SetGraphicsMode(dc.GetDC(), GM_ADVANCED);
AutoSelectFont selectFont(dc.GetDC(), mFont);
// Get font metrics
// Get font metrics if size > 0
if (mAdjustedSize > 0.0) {
OUTLINETEXTMETRIC oMetrics;
TEXTMETRIC& metrics = oMetrics.otmTextMetrics;
@ -434,6 +437,7 @@ gfxGDIFont::Initialize()
}
SanitizeMetrics(mMetrics, GetFontEntry()->mIsBadUnderlineFont);
}
mFontFace = cairo_win32_font_face_create_for_logfontw_hfont(&logFont,
mFont);
@ -460,20 +464,21 @@ gfxGDIFont::Initialize()
mScaledFont ? cairo_scaled_font_status(mScaledFont) : 0);
NS_WARNING(warnBuf);
#endif
mIsValid = false;
} else {
mIsValid = true;
}
mIsValid = true;
#if 0
printf("Font: %p (%s) size: %f\n", this,
NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size);
printf(" emHeight: %f emAscent: %f emDescent: %f\n", mMetrics.emHeight, mMetrics.emAscent, mMetrics.emDescent);
printf(" maxAscent: %f maxDescent: %f maxAdvance: %f\n", mMetrics.maxAscent, mMetrics.maxDescent, mMetrics.maxAdvance);
printf(" internalLeading: %f externalLeading: %f\n", mMetrics.internalLeading, mMetrics.externalLeading);
printf(" spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics.spaceWidth, mMetrics.aveCharWidth, mMetrics.xHeight);
printf("Font: %p (%s) size: %f adjusted size: %f valid: %s\n", this,
NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size, mAdjustedSize, (mIsValid ? "yes" : "no"));
printf(" emHeight: %f emAscent: %f emDescent: %f\n", mMetrics->emHeight, mMetrics->emAscent, mMetrics->emDescent);
printf(" maxAscent: %f maxDescent: %f maxAdvance: %f\n", mMetrics->maxAscent, mMetrics->maxDescent, mMetrics->maxAdvance);
printf(" internalLeading: %f externalLeading: %f\n", mMetrics->internalLeading, mMetrics->externalLeading);
printf(" spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics->spaceWidth, mMetrics->aveCharWidth, mMetrics->xHeight);
printf(" uOff: %f uSize: %f stOff: %f stSize: %f supOff: %f subOff: %f\n",
mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize,
mMetrics.superscriptOffset, mMetrics.subscriptOffset);
mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize,
mMetrics->superscriptOffset, mMetrics->subscriptOffset);
#endif
}

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

@ -53,6 +53,16 @@ let Ci = Components.interfaces;
let Cu = Components.utils;
let Cr = Components.results;
function getBridge() {
return Cc["@mozilla.org/android/bridge;1"].getService(Ci.nsIAndroidBridge);
}
function sendMessageToJava(aMessage) {
return getBridge().handleGeckoMessage(JSON.stringify(aMessage));
}
function getBrowser() {
return Browser.selectedBrowser;
}
@ -167,6 +177,12 @@ var Browser = {
startup: function startup() {
var self = this;
sendMessageToJava({
gecko: {
type: "Gecko:Ready"
}
});
try {
messageManager.loadFrameScript("chrome://browser/content/Util.js", true);
messageManager.loadFrameScript("chrome://browser/content/forms.js", true);

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

@ -267,6 +267,9 @@
#ifdef XP_MACOSX
@BINPATH@/components/widget_cocoa.xpt
#endif
#ifdef ANDROID
@BINPATH@/components/widget_android.xpt
#endif
@BINPATH@/components/windowds.xpt
@BINPATH@/components/windowwatcher.xpt
@BINPATH@/components/xpcom_base.xpt

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

@ -63,7 +63,7 @@ nsFastStartup::symbolsLoadingFinished(bool preloaded)
{
mSymbolsLoaded = preloaded;
if (mWidgetPainted && mSymbolsLoaded) {
qApp->quit();
mLoop.quit();
}
}
@ -71,7 +71,7 @@ void nsFastStartup::painted()
{
mWidgetPainted = true;
if (mWidgetPainted && mSymbolsLoaded) {
qApp->quit();
mLoop.quit();
}
}
@ -159,7 +159,7 @@ nsFastStartup::CreateFastStartup(int& argc, char ** argv,
// Start native loop in order to get view opened and painted once
// Will block CreateFastStartup function and
// exit when symbols are loaded and Static UI shown
qApp->exec();
mLoop.exec();
return true;
}

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

@ -42,6 +42,7 @@
#include <QObject>
#include "nscore.h"
#include <QThread>
#include <QEventLoop>
#include <sys/time.h>
class QGraphicsView;
@ -106,6 +107,7 @@ private:
bool mSymbolsLoaded;
bool mWidgetPainted;
GeckoThread* mThread;
QEventLoop mLoop;
};
#endif