Merge fx-team to m-c.

This commit is contained in:
Ryan VanderMeulen 2013-09-06 20:49:55 -04:00
commit 9fe836923d
15 changed files with 207 additions and 197 deletions

View File

@ -15,6 +15,7 @@ let Cr = Components.results;
*/
var APZCObserver = {
_debugEvents: false,
init: function() {
this._enabled = Services.prefs.getBoolPref(kAsyncPanZoomEnabled);
if (!this._enabled) {
@ -95,25 +96,23 @@ var APZCObserver = {
id: scrollId
});
Util.dumpLn("APZC scrollId: " + scrollId);
Util.dumpLn("APZC scrollTo.x: " + scrollTo.x + ", scrollTo.y: " + scrollTo.y);
Util.dumpLn("APZC setResolution: " + resolution);
Util.dumpLn("APZC setDisplayPortForElement: displayPort.x: " +
displayPort.x + ", displayPort.y: " + displayPort.y +
", displayPort.width: " + displayPort.width +
", displayort.height: " + displayPort.height);
if (this._debugEvents) {
Util.dumpLn("APZC scrollId: " + scrollId);
Util.dumpLn("APZC scrollTo.x: " + scrollTo.x + ", scrollTo.y: " + scrollTo.y);
Util.dumpLn("APZC setResolution: " + resolution);
Util.dumpLn("APZC setDisplayPortForElement: displayPort.x: " +
displayPort.x + ", displayPort.y: " + displayPort.y +
", displayPort.width: " + displayPort.width +
", displayort.height: " + displayPort.height);
}
} else if (aTopic == "apzc-handle-pan-begin") {
// When we're panning, hide the main scrollbars by setting imprecise
// input (which sets a property on the browser which hides the scrollbar
// via CSS). This reduces jittering from left to right. We may be able
// to get rid of this once we implement axis locking in /gfx APZC.
Util.dumpLn("APZC pan-begin");
if (InputSourceHelper.isPrecise) {
InputSourceHelper._imprecise();
}
} else if (aTopic == "apzc-handle-pan-end") {
Util.dumpLn("APZC pan-end");
}
},

View File

@ -34,7 +34,7 @@ pref("prompts.tab_modal.enabled", true);
// Enable off main thread compositing
pref("layers.offmainthreadcomposition.enabled", true);
pref("layers.async-pan-zoom.enabled", false);
pref("layers.async-pan-zoom.enabled", true);
pref("layers.componentalpha.enabled", false);
pref("gfx.azpc.touch_start_tolerance", "0.1"); // dpi * tolerance = pixel threshold
pref("gfx.axis.fling_friction", "0.002");

View File

@ -13,6 +13,7 @@ import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.gfx.PanZoomController;
import org.mozilla.gecko.health.BrowserHealthRecorder;
import org.mozilla.gecko.health.BrowserHealthReporter;
import org.mozilla.gecko.home.BrowserSearch;
import org.mozilla.gecko.home.HomePager;
@ -1464,6 +1465,8 @@ abstract public class BrowserApp extends GeckoApp
return;
}
recordSearch(null, "barkeyword");
// Otherwise, construct a search query from the bookmark keyword.
final String searchUrl = keywordUrl.replace("%s", URLEncoder.encode(keywordSearch));
Tabs.getInstance().loadUrl(searchUrl, Tabs.LOADURL_USER_ENTERED);
@ -1471,6 +1474,28 @@ abstract public class BrowserApp extends GeckoApp
});
}
/**
* Record in Health Report that a search has occurred.
*
* @param identifier
* a search identifier, such as "partnername". Can be null.
* @param where
* where the search was initialized; one of the values in
* {@link BrowserHealthRecorder#SEARCH_LOCATIONS}.
*/
private static void recordSearch(String identifier, String where) {
Log.i(LOGTAG, "Recording search: " + identifier + ", " + where);
try {
JSONObject message = new JSONObject();
message.put("type", BrowserHealthRecorder.EVENT_SEARCH);
message.put("location", where);
message.put("identifier", identifier);
GeckoAppShell.getEventDispatcher().dispatchEvent(message);
} catch (Exception e) {
Log.w(LOGTAG, "Error recording search.", e);
}
}
boolean dismissEditingMode() {
if (!mBrowserToolbar.isEditing()) {
return false;
@ -2209,6 +2234,7 @@ abstract public class BrowserApp extends GeckoApp
// BrowserSearch.OnSearchListener
@Override
public void onSearch(String engineId, String text) {
recordSearch(engineId, "barsuggest");
openUrl(text, engineId);
}

View File

@ -861,11 +861,11 @@ public class BrowserToolbar extends GeckoRelativeLayout
return;
}
// If toolbar is in edit mode, this means the entry is expanded and the
// tabs button is translated offscreen. Don't trigger tabs counter
// If toolbar is in edit mode on a phone, this means the entry is expanded
// and the tabs button is translated offscreen. Don't trigger tabs counter
// updates until the tabs button is back on screen.
// See stopEditing()
if (!isEditing()) {
if (!isEditing() || HardwareUtils.isTablet()) {
mTabsCounter.setCount(count);
mTabs.setContentDescription((count > 1) ?
@ -875,11 +875,11 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
public void updateTabCount(int count) {
// If toolbar is in edit mode, this means the entry is expanded and the
// tabs button is translated offscreen. Don't trigger tabs counter
// If toolbar is in edit mode on a phone, this means the entry is expanded
// and the tabs button is translated offscreen. Don't trigger tabs counter
// updates until the tabs button is back on screen.
// See stopEditing()
if (isEditing()) {
if (isEditing() && !HardwareUtils.isTablet()) {
return;
}
@ -1378,9 +1378,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
if (HardwareUtils.isTablet() || Build.VERSION.SDK_INT < 11) {
hideUrlEditContainer();
updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
if (!HardwareUtils.isTablet()) {
updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
if (mUrlBarRightEdge != null) {
ViewHelper.setTranslationX(mUrlBarRightEdge, 0);
}

View File

@ -334,7 +334,6 @@ var BrowserApp = {
Reader.init();
UserAgentOverrides.init();
DesktopUserAgent.init();
ExternalApps.init();
Distribution.init();
Tabs.init();
#ifdef ACCESSIBILITY
@ -368,6 +367,9 @@ var BrowserApp = {
SearchEngines.init();
this.initContextMenu();
}
// The order that context menu items are added is important
// Make sure the "Open in App" context menu item appears at the bottom of the list
ExternalApps.init();
// XXX maybe we don't do this if the launch was kicked off from external
Services.io.offline = false;

View File

@ -0,0 +1,107 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "APZController.h"
#include "base/message_loop.h"
#include "mozilla/layers/GeckoContentController.h"
#include "nsThreadUtils.h"
#include "MetroUtils.h"
#include "nsPrintfCString.h"
namespace mozilla {
namespace widget {
namespace winrt {
class RequestContentRepaintEvent : public nsRunnable
{
typedef mozilla::layers::FrameMetrics FrameMetrics;
public:
RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) : mFrameMetrics(aFrameMetrics)
{
}
NS_IMETHOD Run() {
// This event shuts down the worker thread and so must be main thread.
MOZ_ASSERT(NS_IsMainThread());
CSSToScreenScale resolution = mFrameMetrics.mZoom;
CSSRect compositedRect = mFrameMetrics.CalculateCompositedRectInCssPixels();
NS_ConvertASCIItoUTF16 data(nsPrintfCString("{ " \
" \"resolution\": %.2f, " \
" \"scrollId\": %d, " \
" \"compositedRect\": { \"width\": %d, \"height\": %d }, " \
" \"displayPort\": { \"x\": %d, \"y\": %d, \"width\": %d, \"height\": %d }, " \
" \"scrollTo\": { \"x\": %d, \"y\": %d }" \
"}",
(float)(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel.scale),
(int)mFrameMetrics.mScrollId,
(int)compositedRect.width,
(int)compositedRect.height,
(int)mFrameMetrics.mDisplayPort.x,
(int)mFrameMetrics.mDisplayPort.y,
(int)mFrameMetrics.mDisplayPort.width,
(int)mFrameMetrics.mDisplayPort.height,
(int)mFrameMetrics.mScrollOffset.x,
(int)mFrameMetrics.mScrollOffset.y));
MetroUtils::FireObserver("apzc-request-content-repaint", data.get());
return NS_OK;
}
protected:
const FrameMetrics mFrameMetrics;
};
void
APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
// Send the result back to the main thread so that it can shutdown
nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics);
if (!NS_IsMainThread()) {
NS_DispatchToMainThread(r1);
} else {
r1->Run();
}
}
void
APZController::HandleDoubleTap(const CSSIntPoint& aPoint)
{
}
void
APZController::HandleSingleTap(const CSSIntPoint& aPoint)
{
}
void
APZController::HandleLongTap(const CSSIntPoint& aPoint)
{
}
void
APZController::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize)
{
}
void
APZController::PostDelayedTask(Task* aTask, int aDelayMs)
{
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
}
void
APZController::HandlePanBegin()
{
MetroUtils::FireObserver("apzc-handle-pan-begin", L"");
}
void
APZController::HandlePanEnd()
{
MetroUtils::FireObserver("apzc-handle-pan-end", L"");
}
} } }

View File

@ -0,0 +1,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#pragma once
#include "mozwrlbase.h"
#include "mozilla/layers/GeckoContentController.h"
#include "FrameMetrics.h"
#include "Units.h"
namespace mozilla {
namespace widget {
namespace winrt {
class APZController : public mozilla::layers::GeckoContentController
{
typedef mozilla::layers::FrameMetrics FrameMetrics;
public:
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
virtual void PostDelayedTask(Task* aTask, int aDelayMs);
virtual void HandlePanBegin();
virtual void HandlePanEnd();
};
} } }

View File

@ -197,7 +197,6 @@ FrameworkView::ShutdownXPCOM()
mAutomationProvider = nullptr;
mMetroInput = nullptr;
mD2DWindowSurface = nullptr;
delete sSettingsArray;
sSettingsArray = nullptr;
mWidget = nullptr;

View File

@ -7,6 +7,7 @@
#include "nsGUIEvent.h"
#include "MetroWidget.h"
#include "MetroInput.h"
#include "gfxWindowsPlatform.h"
#include "gfxD2DSurface.h"
#include "nsDataHashtable.h"
@ -176,7 +177,6 @@ private:
EventRegistrationToken mPrintManager;
private:
nsRefPtr<gfxD2DSurface> mD2DWindowSurface;
nsIntRect mWindowBounds; // in device-pixel coordinates
float mDPI;
bool mShuttingDown;

View File

@ -107,6 +107,7 @@ MetroApp::ShutdownXPCOM()
void
MetroApp::CoreExit()
{
LogFunction();
HRESULT hr;
ComPtr<ICoreApplicationExit> coreExit;
HStringReference className(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication);

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Moz headers (alphabetical)
#include "MetroInput.h"
#include "MetroUtils.h" // Logging, POINT_CEIL_*, ActivateGenericInstance, etc
#include "MetroWidget.h" // MetroInput::mWidget
#include "mozilla/dom/Touch.h" // Touch
@ -161,8 +162,6 @@ MetroInput::MetroInput(MetroWidget* aWidget,
NS_ASSERTION(aWidget, "Attempted to create MetroInput for null widget!");
NS_ASSERTION(aWindow, "Attempted to create MetroInput for null window!");
mWidget->SetMetroInput(this);
mTokenPointerPressed.value = 0;
mTokenPointerReleased.value = 0;
mTokenPointerMoved.value = 0;
@ -928,27 +927,6 @@ MetroInput::OnRightTapped(UI::Input::IGestureRecognizer* aSender,
return S_OK;
}
// Used by MetroWidget GeckoContentController callbacks
void
MetroInput::HandleDoubleTap(const LayoutDeviceIntPoint& aPoint)
{
#ifdef DEBUG_INPUT
LogFunction();
#endif
nsSimpleGestureEvent* tapEvent =
new nsSimpleGestureEvent(true,
NS_SIMPLE_GESTURE_TAP,
mWidget.Get(),
0,
0.0);
tapEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
tapEvent->refPoint = aPoint;
tapEvent->clickCount = 2;
tapEvent->pressure = 1;
DispatchAsyncEventIgnoreStatus(tapEvent);
}
void
MetroInput::HandleSingleTap(const LayoutDeviceIntPoint& aPoint)
{

View File

@ -147,8 +147,6 @@ public:
HRESULT OnRightTapped(IGestureRecognizer* aSender,
IRightTappedEventArgs* aArgs);
// Used by MetroWidget GeckoContentController callbacks
void HandleDoubleTap(const mozilla::LayoutDeviceIntPoint& aPoint);
void HandleSingleTap(const mozilla::LayoutDeviceIntPoint& aPoint);
void HandleLongTap(const mozilla::LayoutDeviceIntPoint& aPoint);

View File

@ -962,7 +962,8 @@ CompositorParent* MetroWidget::NewCompositorParent(int aSurfaceWidth, int aSurfa
if (ShouldUseAPZC()) {
mRootLayerTreeId = compositor->RootLayerTreeId();
CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, this);
mController = new APZController();
CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, mController);
MetroWidget::sAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId());
MetroWidget::sAPZC->SetDPI(GetDPI());
@ -1474,124 +1475,6 @@ MetroWidget::HasPendingInputEvent()
return false;
}
// GeckoContentController interface impl
class RequestContentRepaintEvent : public nsRunnable
{
public:
RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) : mFrameMetrics(aFrameMetrics)
{
}
NS_IMETHOD Run() {
// This event shuts down the worker thread and so must be main thread.
MOZ_ASSERT(NS_IsMainThread());
CSSToScreenScale resolution = mFrameMetrics.mZoom;
CSSRect compositedRect = mFrameMetrics.CalculateCompositedRectInCssPixels();
NS_ConvertASCIItoUTF16 data(nsPrintfCString("{ " \
" \"resolution\": %.2f, " \
" \"scrollId\": %d, " \
" \"compositedRect\": { \"width\": %d, \"height\": %d }, " \
" \"displayPort\": { \"x\": %d, \"y\": %d, \"width\": %d, \"height\": %d }, " \
" \"scrollTo\": { \"x\": %d, \"y\": %d }" \
"}",
(float)(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel.scale),
(int)mFrameMetrics.mScrollId,
(int)compositedRect.width,
(int)compositedRect.height,
(int)mFrameMetrics.mDisplayPort.x,
(int)mFrameMetrics.mDisplayPort.y,
(int)mFrameMetrics.mDisplayPort.width,
(int)mFrameMetrics.mDisplayPort.height,
(int)mFrameMetrics.mScrollOffset.x,
(int)mFrameMetrics.mScrollOffset.y));
MetroUtils::FireObserver("apzc-request-content-repaint", data.get());
return NS_OK;
}
protected:
const FrameMetrics mFrameMetrics;
};
void
MetroWidget::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
LogFunction();
// Send the result back to the main thread so that it can shutdown
nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics);
if (!NS_IsMainThread()) {
NS_DispatchToMainThread(r1);
} else {
r1->Run();
}
}
void
MetroWidget::HandleDoubleTap(const CSSIntPoint& aPoint)
{
LogFunction();
if (!mMetroInput) {
return;
}
mMetroInput->HandleDoubleTap(CSSIntPointToLayoutDeviceIntPoint(aPoint));
}
void
MetroWidget::HandleSingleTap(const CSSIntPoint& aPoint)
{
LogFunction();
if (!mMetroInput) {
return;
}
mMetroInput->HandleSingleTap(CSSIntPointToLayoutDeviceIntPoint(aPoint));
}
void
MetroWidget::HandleLongTap(const CSSIntPoint& aPoint)
{
LogFunction();
if (!mMetroInput) {
return;
}
mMetroInput->HandleLongTap(CSSIntPointToLayoutDeviceIntPoint(aPoint));
}
void
MetroWidget::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize)
{
LogFunction();
}
void
MetroWidget::PostDelayedTask(Task* aTask, int aDelayMs)
{
LogFunction();
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
}
void
MetroWidget::HandlePanBegin()
{
LogFunction();
MetroUtils::FireObserver("apzc-handle-pan-begin", L"");
}
void
MetroWidget::HandlePanEnd()
{
LogFunction();
MetroUtils::FireObserver("apzc-handle-pan-end", L"");
}
NS_IMETHODIMP
MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *data)
{

View File

@ -22,11 +22,11 @@
#include "mozilla/a11y/Accessible.h"
#endif
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/GeckoContentController.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "Units.h"
#include "MetroInput.h"
#include "nsDeque.h"
#include "APZController.h"
#include "mozwrlbase.h"
@ -48,7 +48,6 @@ class FrameworkView;
class DispatchMsg;
class MetroWidget : public nsWindowBase,
public mozilla::layers::GeckoContentController,
public nsIObserver
{
typedef mozilla::widget::WindowHook WindowHook;
@ -58,7 +57,7 @@ class MetroWidget : public nsWindowBase,
typedef ABI::Windows::UI::Core::IKeyEventArgs IKeyEventArgs;
typedef ABI::Windows::UI::Core::ICharacterReceivedEventArgs ICharacterReceivedEventArgs;
typedef mozilla::widget::winrt::FrameworkView FrameworkView;
typedef mozilla::layers::FrameMetrics FrameMetrics;
typedef mozilla::widget::winrt::APZController APZController;
static LRESULT CALLBACK
StaticWindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam);
@ -200,21 +199,6 @@ public:
nsresult RequestContentScroll();
void RequestContentRepaintImplMainThread();
// GeckoContentController interface impl
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
virtual void PostDelayedTask(Task* aTask, int aDelayMs);
virtual void HandlePanBegin();
virtual void HandlePanEnd();
void SetMetroInput(mozilla::widget::winrt::MetroInput* aMetroInput)
{
mMetroInput = aMetroInput;
}
protected:
friend class FrameworkView;
@ -238,6 +222,16 @@ protected:
void RemoveSubclass();
nsIWidgetListener* GetPaintListener();
// Async event dispatching
void DispatchAsyncScrollEvent(DispatchMsg* aEvent);
void DeliverNextScrollEvent();
void DeliverNextKeyboardEvent();
DispatchMsg* CreateDispatchMsg(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
public:
static nsRefPtr<mozilla::layers::APZCTreeManager> sAPZC;
protected:
OleInitializeWrapper mOleInitializeWrapper;
WindowHook mWindowHook;
Microsoft::WRL::ComPtr<FrameworkView> mView;
@ -248,19 +242,8 @@ protected:
static HWND sICoreHwnd;
WNDPROC mMetroWndProc;
bool mTempBasicLayerInUse;
Microsoft::WRL::ComPtr<mozilla::widget::winrt::MetroInput> mMetroInput;
mozilla::layers::FrameMetrics mFrameMetrics;
uint64_t mRootLayerTreeId;
// Async event dispatching
void DispatchAsyncScrollEvent(DispatchMsg* aEvent);
void DeliverNextScrollEvent();
void DeliverNextKeyboardEvent();
DispatchMsg* CreateDispatchMsg(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
nsDeque mMsgEventQueue;
nsDeque mKeyEventQueue;
public:
static nsRefPtr<mozilla::layers::APZCTreeManager> sAPZC;
nsRefPtr<APZController> mController;
};

View File

@ -19,6 +19,7 @@ CPP_SOURCES += [
'UIABridge.cpp',
'nsMetroFilePicker.cpp',
'nsWinMetroUtils.cpp',
'APZController.cpp',
]
EXTRA_COMPONENTS += [