Merge m-c to fx-team.

This commit is contained in:
Ryan VanderMeulen 2014-01-15 14:36:54 -05:00
commit 628b3a7cbc
207 changed files with 4830 additions and 1233 deletions

View File

@ -307,12 +307,10 @@ pref("image.onload.decode.limit", 24); /* don't decode more than 24 images eager
// XXX this isn't a good check for "are touch events supported", but
// we don't really have a better one at the moment.
#ifdef MOZ_WIDGET_GONK
// enable touch events interfaces
pref("dom.w3c_touch_events.enabled", 1);
pref("dom.w3c_touch_events.safetyX", 0); // escape borders in units of 1/240"
pref("dom.w3c_touch_events.safetyY", 120); // escape borders in units of 1/240"
#endif
#ifdef MOZ_SAFE_BROWSING
// Safe browsing does nothing unless this pref is set

View File

@ -0,0 +1,10 @@
window.addEventListener("ContentStart", function(evt) {
// Enable touch event shim on desktop that translates mouse events
// into touch ones
let require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {})
.devtools.require;
let { TouchEventHandler } = require("devtools/touch-events");
let touchEventHandler = new TouchEventHandler(shell.contentBrowser);
touchEventHandler.start();
});

View File

@ -19,7 +19,9 @@
src="chrome://browser/content/shell.js"> </script>
#ifndef MOZ_WIDGET_GONK
<!-- various task that has to happen only on desktop -->
<script type="application/javascript;version=1.8"
src="chrome://browser/content/desktop.js"> </script>
<!-- this script handles the screen argument for desktop builds -->
<script type="application/javascript;version=1.8"
src="chrome://browser/content/screen.js"> </script>

View File

@ -14,6 +14,7 @@ chrome.jar:
* content/shell.html (content/shell.html)
* content/shell.js (content/shell.js)
#ifndef ANDROID
content/desktop.js (content/desktop.js)
content/screen.js (content/screen.js)
content/runapp.js (content/runapp.js)
#endif

View File

@ -1,4 +1,4 @@
{
"revision": "25a3b96e9c5ff89b69b29007462bfd056ad5bf53",
"revision": "35ba072bcabf79e9c32776e9322c41e0020c9264",
"repo_path": "/integration/gaia-central"
}

View File

@ -144,3 +144,6 @@ let healthReportWrapper = {
healthReportWrapper.reportFailure(healthReportWrapper.ERROR_PAYLOAD_FAILED);
},
}
window.addEventListener("load", function () { healthReportWrapper.init(); });
window.addEventListener("unload", function () { healthReportWrapper.uninit(); });

View File

@ -24,8 +24,7 @@
<script type="text/javascript;version=1.8"
src="chrome://browser/content/abouthealthreport/abouthealth.js" />
</head>
<body onload="healthReportWrapper.init();"
onunload="healthReportWrapper.uninit();">
<body>
<iframe id="remote-report"/>
</body>
</html>

View File

@ -25,11 +25,11 @@ function test() {
function testWithNoTouch() {
let div = content.document.querySelector("div");
let x = 2, y = 2;
EventUtils.synthesizeMouse(div, x, y, {type: "mousedown"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content);
x += 20; y += 10;
EventUtils.synthesizeMouse(div, x, y, {type: "mousemove"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content);
is(div.style.transform, "", "touch didn't work");
EventUtils.synthesizeMouse(div, x, y, {type: "mouseup"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content);
testWithTouch();
}
@ -37,11 +37,11 @@ function test() {
gBrowser.selectedTab.__responsiveUI.enableTouch();
let div = content.document.querySelector("div");
let x = 2, y = 2;
EventUtils.synthesizeMouse(div, x, y, {type: "mousedown"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content);
x += 20; y += 10;
EventUtils.synthesizeMouse(div, x, y, {type: "mousemove"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content);
is(div.style.transform, "translate(20px, 10px)", "touch worked");
EventUtils.synthesizeMouse(div, x, y, {type: "mouseup"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content);
is(div.style.transform, "none", "end event worked");
mgr.toggle(window, gBrowser.selectedTab);
}
@ -50,11 +50,11 @@ function test() {
gBrowser.selectedTab.__responsiveUI.disableTouch();
let div = content.document.querySelector("div");
let x = 2, y = 2;
EventUtils.synthesizeMouse(div, x, y, {type: "mousedown"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content);
x += 20; y += 10;
EventUtils.synthesizeMouse(div, x, y, {type: "mousemove"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content);
is(div.style.transform, "", "touch didn't work");
EventUtils.synthesizeMouse(div, x, y, {type: "mouseup"}, content);
EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content);
finishUp();
}

View File

@ -18,7 +18,6 @@
#include "nsEventStates.h" // for member
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocumentFragment.h"
#include "nsILinkHandler.h"
#include "nsNodeUtils.h"
#include "nsAttrAndChildArray.h"

View File

@ -18,7 +18,6 @@
#include "nsDOMString.h"
#include "nsIContentInlines.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMUserDataHandler.h"
#include "nsEventDispatcher.h"
#include "nsGkAtoms.h"

View File

@ -24,7 +24,6 @@
#include "nsIDocumentInlines.h"
#include "nsIDocumentEncoder.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIContentIterator.h"
#include "nsEventListenerManager.h"
#include "nsFocusManager.h"
@ -87,7 +86,6 @@
#include "nsNodeInfoManager.h"
#include "nsICategoryManager.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMUserDataHandler.h"
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
@ -2704,18 +2702,15 @@ FragmentOrElement::SetInnerHTMLInternal(const nsAString& aInnerHTML, ErrorResult
nsContentUtils::FireMutationEventsForDirectParsing(doc, target,
oldChildCount);
} else {
nsCOMPtr<nsIDOMDocumentFragment> df;
aError = nsContentUtils::CreateContextualFragment(target, aInnerHTML,
true,
getter_AddRefs(df));
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
nsRefPtr<DocumentFragment> df =
nsContentUtils::CreateContextualFragment(target, aInnerHTML, true, aError);
if (!aError.Failed()) {
// Suppress assertion about node removal mutation events that can't have
// listeners anyway, because no one has had the chance to register mutation
// listeners on the fragment that comes from the parser.
nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
static_cast<nsINode*>(target)->AppendChild(*fragment, aError);
static_cast<nsINode*>(target)->AppendChild(*df, aError);
mb.NodesAdded();
}
}

View File

@ -21,7 +21,6 @@
#include "nsIDOMEvent.h"
#include "nsIDOMDragEvent.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIDOMRange.h"
#include "nsIFormControl.h"
#include "nsIDOMHTMLAreaElement.h"
@ -52,6 +51,7 @@
#include "imgIRequest.h"
#include "nsDOMDataTransfer.h"
#include "nsIMIMEInfo.h"
#include "nsRange.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLAreaElement.h"
@ -339,20 +339,17 @@ void
DragDataProducer::GetNodeString(nsIContent* inNode,
nsAString & outNodeString)
{
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(inNode);
nsCOMPtr<nsINode> node = inNode;
outNodeString.Truncate();
// use a range to get the text-equivalent of the node
nsCOMPtr<nsIDOMDocument> doc;
node->GetOwnerDocument(getter_AddRefs(doc));
if (doc) {
nsCOMPtr<nsIDOMRange> range;
doc->CreateRange(getter_AddRefs(range));
if (range) {
range->SelectNode(node);
range->ToString(outNodeString);
}
nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
mozilla::ErrorResult rv;
nsRefPtr<nsRange> range = doc->CreateRange(rv);
if (range) {
range->SelectNode(*node, rv);
range->ToString(outNodeString);
}
}

View File

@ -67,7 +67,7 @@ static nsresult AppendString(nsITransferable *aTransferable,
// copy HTML node data
static nsresult AppendDOMNode(nsITransferable *aTransferable,
nsIDOMNode *aDOMNode);
nsINode* aDOMNode);
// Helper used for HTMLCopy and GetTransferableForSelection since both routines
// share common code.
@ -421,7 +421,7 @@ nsCopySupport::ImageCopy(nsIImageLoadingContent* aImageElement,
if (aCopyFlags & nsIContentViewerEdit::COPY_IMAGE_HTML) {
// append HTML data to the transferable
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aImageElement, &rv));
nsCOMPtr<nsINode> node(do_QueryInterface(aImageElement, &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = AppendDOMNode(trans, node);
@ -486,37 +486,33 @@ static nsresult AppendString(nsITransferable *aTransferable,
}
static nsresult AppendDOMNode(nsITransferable *aTransferable,
nsIDOMNode *aDOMNode)
nsINode *aDOMNode)
{
nsresult rv;
// selializer
nsCOMPtr<nsIDocumentEncoder>
docEncoder(do_CreateInstance(NS_HTMLCOPY_ENCODER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
// get document for the encoder
nsCOMPtr<nsIDOMDocument> domDocument;
rv = aDOMNode->GetOwnerDocument(getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = aDOMNode->OwnerDoc();
// Note that XHTML is not counted as HTML here, because we can't copy it
// properly (all the copy code for non-plaintext assumes using HTML
// serializers and parsers is OK, and those mess up XHTML).
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDocument, &rv);
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
NS_ENSURE_TRUE(document->IsHTML(), NS_OK);
// init encoder with document and node
rv = docEncoder->Init(domDocument, NS_LITERAL_STRING(kHTMLMime),
nsIDocumentEncoder::OutputAbsoluteLinks |
nsIDocumentEncoder::OutputEncodeW3CEntities);
rv = docEncoder->NativeInit(document, NS_LITERAL_STRING(kHTMLMime),
nsIDocumentEncoder::OutputAbsoluteLinks |
nsIDocumentEncoder::OutputEncodeW3CEntities);
NS_ENSURE_SUCCESS(rv, rv);
rv = docEncoder->SetNode(aDOMNode);
rv = docEncoder->SetNativeNode(aDOMNode);
NS_ENSURE_SUCCESS(rv, rv);
// serialize to string

View File

@ -18,7 +18,6 @@
#include "nsError.h"
#include "nsIContentInlines.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsINameSpaceManager.h"
#include "nsNodeInfoManager.h"
#include "nsUnicharUtils.h"

View File

@ -15,7 +15,6 @@
#include "nsIDocument.h"
#include "nsINode.h"
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
NS_IMPL_ISUPPORTS1(nsDataDocumentContentPolicy, nsIContentPolicy)
@ -50,11 +49,9 @@ nsDataDocumentContentPolicy::ShouldLoad(uint32_t aContentType,
if (node) {
doc = node->OwnerDoc();
} else {
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(aRequestingContext);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aRequestingContext);
if (window) {
nsCOMPtr<nsIDOMDocument> domDoc;
window->GetDocument(getter_AddRefs(domDoc));
doc = do_QueryInterface(domDoc);
doc = window->GetDoc();
}
}

View File

@ -627,8 +627,7 @@ static void
FirePageHideEvent(nsIDocShellTreeItem* aItem,
EventTarget* aChromeEventHandler)
{
nsCOMPtr<nsIDOMDocument> doc = do_GetInterface(aItem);
nsCOMPtr<nsIDocument> internalDoc = do_QueryInterface(doc);
nsCOMPtr<nsIDocument> internalDoc = do_GetInterface(aItem);
NS_ASSERTION(internalDoc, "What happened here?");
internalDoc->OnPageHide(true, aChromeEventHandler);
@ -670,8 +669,7 @@ FirePageShowEvent(nsIDocShellTreeItem* aItem,
}
}
nsCOMPtr<nsIDOMDocument> doc = do_GetInterface(aItem);
nsCOMPtr<nsIDocument> internalDoc = do_QueryInterface(doc);
nsCOMPtr<nsIDocument> internalDoc = do_GetInterface(aItem);
NS_ASSERTION(internalDoc, "What happened here?");
if (internalDoc->IsShowing() == aFireIfShowing) {
internalDoc->OnPageShow(true, aChromeEventHandler);
@ -2195,16 +2193,14 @@ nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
dest->MaybeCreateDocShell();
NS_ENSURE_STATE(dest->mDocShell);
nsCOMPtr<nsIDOMDocument> dummy = do_GetInterface(dest->mDocShell);
nsCOMPtr<nsIDocument> dummy = do_GetInterface(dest->mDocShell);
nsCOMPtr<nsIContentViewer> viewer;
dest->mDocShell->GetContentViewer(getter_AddRefs(viewer));
NS_ENSURE_STATE(viewer);
nsCOMPtr<nsIDocShell> origDocShell;
GetDocShell(getter_AddRefs(origDocShell));
nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(origDocShell);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCOMPtr<nsIDocument> doc = do_GetInterface(origDocShell);
NS_ENSURE_STATE(doc);
nsCOMPtr<nsIDocument> clonedDoc = doc->CreateStaticClone(dest->mDocShell);
nsCOMPtr<nsIDOMDocument> clonedDOMDoc = do_QueryInterface(clonedDoc);

View File

@ -75,6 +75,7 @@
#include "nsDOMClassInfo.h"
#include "nsWrapperCacheInlines.h"
#include "nsDOMJSUtils.h"
#include "nsDOMEvent.h"
#include "nsWidgetsCID.h"
#include "nsContentCID.h"
@ -297,17 +298,16 @@ nsPluginCrashedEvent::Run()
LOG(("OBJLC [%p]: Firing plugin crashed event\n",
mContent.get()));
nsCOMPtr<nsIDOMDocument> domDoc =
do_QueryInterface(mContent->GetDocument());
if (!domDoc) {
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (!doc) {
NS_WARNING("Couldn't get document for PluginCrashed event!");
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
domDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"),
getter_AddRefs(event));
nsCOMPtr<nsIDOMDataContainerEvent> containerEvent(do_QueryInterface(event));
ErrorResult rv;
nsRefPtr<nsDOMEvent> event =
doc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"), rv);
nsCOMPtr<nsIDOMDataContainerEvent> containerEvent(do_QueryObject(event));
if (!containerEvent) {
NS_WARNING("Couldn't QI event for PluginCrashed event!");
return NS_OK;

View File

@ -82,6 +82,7 @@ tests.push(function test_redirect_to_file_uri() {
function runNextTest() {
if (!tests.length) {
SimpleTest.finish();
return;
}
tests.shift()();
@ -89,14 +90,8 @@ function runNextTest() {
function runTests() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.addPermission("systemXHR", true, document);
tests.push(function tearDown() {
SpecialPowers.removePermission("systemXHR", document);
SimpleTest.finish();
});
runNextTest();
SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], runNextTest);
}
</script>

View File

@ -1,37 +0,0 @@
/* 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/. */
#ifndef mozilla_dom_DocumentRendererNativeIDChild
#define mozilla_dom_DocumentRendererNativeIDChild
#include "mozilla/ipc/PDocumentRendererNativeIDChild.h"
class nsIDOMWindow;
struct gfxMatrix;
namespace mozilla {
namespace ipc {
class DocumentRendererNativeIDChild : public PDocumentRendererNativeIDChild
{
public:
DocumentRendererNativeIDChild();
virtual ~DocumentRendererNativeIDChild();
bool RenderDocument(nsIDOMWindow* window, const int32_t& x,
const int32_t& y, const int32_t& w,
const int32_t& h, const nsString& aBGColor,
const uint32_t& flags, const bool& flush,
const gfxMatrix& aMatrix,
const int32_t& nativeID);
private:
DISALLOW_EVIL_CONSTRUCTORS(DocumentRendererNativeIDChild);
};
}
}
#endif

View File

@ -1,35 +0,0 @@
/* 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/. */
#ifndef mozilla_dom_DocumentRendererNativeIDParent
#define mozilla_dom_DocumentRendererNativeIDParent
#include "mozilla/ipc/PDocumentRendererNativeIDParent.h"
#include "nsICanvasRenderingContextInternal.h"
#include "nsCOMPtr.h"
namespace mozilla {
namespace ipc {
class DocumentRendererNativeIDParent : public PDocumentRendererNativeIDParent
{
public:
DocumentRendererNativeIDParent();
virtual ~DocumentRendererNativeIDParent();
void SetCanvas(nsICanvasRenderingContextInternal* aCanvas);
virtual bool Recv__delete__(const int32_t& x, const int32_t& y,
const int32_t& w, const int32_t& h,
const uint32_t& nativeID);
private:
nsCOMPtr<nsICanvasRenderingContextInternal> mCanvas;
DISALLOW_EVIL_CONSTRUCTORS(DocumentRendererNativeIDParent);
};
}
}
#endif

View File

@ -1,37 +0,0 @@
/* 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/. */
#ifndef mozilla_dom_DocumentRendererShmemChild
#define mozilla_dom_DocumentRendererShmemChild
#include "mozilla/ipc/PDocumentRendererShmemChild.h"
class nsIDOMWindow;
struct gfxMatrix;
namespace mozilla {
namespace ipc {
class DocumentRendererShmemChild : public PDocumentRendererShmemChild
{
public:
DocumentRendererShmemChild();
virtual ~DocumentRendererShmemChild();
bool RenderDocument(nsIDOMWindow *window, const int32_t& x,
const int32_t& y, const int32_t& w,
const int32_t& h, const nsString& aBGColor,
const uint32_t& flags, const bool& flush,
const gfxMatrix& aMatrix,
Shmem& data);
private:
DISALLOW_EVIL_CONSTRUCTORS(DocumentRendererShmemChild);
};
}
}
#endif

View File

@ -1,35 +0,0 @@
/* 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/. */
#ifndef mozilla_dom_DocumentRendererShmemParent
#define mozilla_dom_DocumentRendererShmemParent
#include "mozilla/ipc/PDocumentRendererShmemParent.h"
#include "nsICanvasRenderingContextInternal.h"
#include "nsCOMPtr.h"
namespace mozilla {
namespace ipc {
class DocumentRendererShmemParent : public PDocumentRendererShmemParent
{
public:
DocumentRendererShmemParent();
virtual ~DocumentRendererShmemParent();
void SetCanvas(nsICanvasRenderingContextInternal* aCanvas);
virtual bool Recv__delete__(const int32_t& x, const int32_t& y,
const int32_t& w, const int32_t& h,
Shmem& data);
private:
nsCOMPtr<nsICanvasRenderingContextInternal> mCanvas;
DISALLOW_EVIL_CONSTRUCTORS(DocumentRendererShmemParent);
};
}
}
#endif

View File

@ -17,10 +17,6 @@ EXPORTS += [
EXPORTS.mozilla.ipc += [
'DocumentRendererChild.h',
'DocumentRendererNativeIDChild.h',
'DocumentRendererNativeIDParent.h',
'DocumentRendererParent.h',
'DocumentRendererShmemChild.h',
'DocumentRendererShmemParent.h',
]

View File

@ -1735,7 +1735,7 @@ CanvasRenderingContext2D::Stroke()
Redraw();
}
void CanvasRenderingContext2D::DrawSystemFocusRing(mozilla::dom::Element& aElement)
void CanvasRenderingContext2D::DrawFocusIfNeeded(mozilla::dom::Element& aElement)
{
EnsureUserSpacePath();

View File

@ -172,7 +172,7 @@ public:
void BeginPath();
void Fill(const CanvasWindingRule& winding);
void Stroke();
void DrawSystemFocusRing(mozilla::dom::Element& element);
void DrawFocusIfNeeded(mozilla::dom::Element& element);
bool DrawCustomFocusRing(mozilla::dom::Element& element);
void Clip(const CanvasWindingRule& winding);
bool IsPointInPath(double x, double y, const CanvasWindingRule& winding);

View File

@ -10,10 +10,10 @@ var in2=document.getElementById("in2");
in1.onfocus=function(){
c.beginPath();
c.rect(10, 10, 200, 200);
c.drawSystemFocusRing(in1);
c.drawFocusIfNeeded(in1);
c.beginPath();
c.rect(10, 220, 200, 200);
c.drawSystemFocusRing(in2);
c.drawFocusIfNeeded(in2);
}
in1.focus();
}

View File

@ -190,5 +190,5 @@ skip-if(!winWidget) pref(webgl.prefer-native-gl,true) pref(webgl.prefer-16bpp,tr
== stroketext-shadow.html stroketext-shadow-ref.html
# focus rings
pref(canvas.focusring.enabled,true) skip-if(B2G) skip-if(Android&&AndroidVersion<15,8,500) skip-if(winWidget) needs-focus == drawSystemFocusRing.html drawSystemFocusRing-ref.html
pref(canvas.focusring.enabled,true) skip-if(B2G) skip-if(Android&&AndroidVersion<15,8,500) skip-if(winWidget) needs-focus == drawFocusIfNeeded.html drawFocusIfNeeded-ref.html
pref(canvas.focusring.enabled,true) skip-if(B2G) skip-if(Android&&AndroidVersion<15,8,500) skip-if(winWidget) needs-focus == drawCustomFocusRing.html drawCustomFocusRing-ref.html

View File

@ -30,7 +30,7 @@ function test_drawCustomFocusRing_canvas() {
}
</script>
<p>Canvas test: drawSystemFocusRing</p>
<p>Canvas test: drawFocusIfNeeded</p>
<canvas id="c689" class="output" width="50" height="25">
<input id="button3" type="range" min="1" max="12"></input>
<input id="button4" type="range" min="1" max="12"></input>
@ -44,7 +44,7 @@ function isEmptyCanvas(ctx, w, h) {
return true;
}
function test_drawSystemFocusRing_canvas() {
function test_drawFocusIfNeeded_canvas() {
var c = document.getElementById("c689");
var ctx = c.getContext("2d");
var b1 = document.getElementById('button3');
@ -52,22 +52,22 @@ function test_drawSystemFocusRing_canvas() {
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.beginPath();
ctx.rect(10, 10, 30, 30);
ctx.drawSystemFocusRing(b1);
ctx.drawFocusIfNeeded(b1);
ok(isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height), "focus of button 1 is drawn");
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.beginPath();
ctx.rect(50, 10, 30, 30);
ctx.drawSystemFocusRing(b2);
ctx.drawFocusIfNeeded(b2);
ctx.rect(50, 10, 30, 30);
ctx.drawSystemFocusRing(b2);
ctx.drawFocusIfNeeded(b2);
ok(isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height), "focus of button 2 is drawn");
b1.focus();
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.beginPath();
ctx.rect(10, 10, 30, 30);
ctx.drawSystemFocusRing(b1);
ctx.drawFocusIfNeeded(b1);
ok(!isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height) , "focus of button 1 is not drawn");
}
</script>
@ -83,10 +83,10 @@ function runTests() {
ok(false, "unexpected exception thrown in: test_drawCustomFocusRing_canvas");
}
try {
test_drawSystemFocusRing_canvas();
test_drawFocusIfNeeded_canvas();
} catch(e) {
throw e;
ok(false, "unexpected exception thrown in: test_drawSystemFocusRing_canvas");
ok(false, "unexpected exception thrown in: test_drawFocusIfNeeded_canvas");
}
SpecialPowers.setBoolPref("canvas.focusring.enabled", false);

View File

@ -7,6 +7,7 @@
#include "nsIPrincipal.h"
#include "nsMimeTypes.h"
#include "prlog.h"
#include "mozilla/Preferences.h"
#ifdef MOZ_OGG
#include "OggWriter.h"
@ -92,7 +93,7 @@ MediaEncoder::CreateEncoder(const nsAString& aMIMEType, uint8_t aTrackTypes)
return nullptr;
}
#ifdef MOZ_WEBM_ENCODER
else if (MediaDecoder::IsWebMEnabled() &&
else if (MediaEncoder::IsWebMEncoderEnabled() &&
(aMIMEType.EqualsLiteral(VIDEO_WEBM) ||
(aTrackTypes & ContainerWriter::HAS_VIDEO))) {
if (aTrackTypes & ContainerWriter::HAS_AUDIO) {
@ -107,8 +108,9 @@ MediaEncoder::CreateEncoder(const nsAString& aMIMEType, uint8_t aTrackTypes)
}
#endif //MOZ_WEBM_ENCODER
#ifdef MOZ_OMX_ENCODER
else if (aMIMEType.EqualsLiteral(VIDEO_MP4) ||
(aTrackTypes & ContainerWriter::HAS_VIDEO)) {
else if (MediaEncoder::IsOMXEncoderEnabled() &&
(aMIMEType.EqualsLiteral(VIDEO_MP4) ||
(aTrackTypes & ContainerWriter::HAS_VIDEO))) {
if (aTrackTypes & ContainerWriter::HAS_AUDIO) {
audioEncoder = new OmxAudioTrackEncoder();
NS_ENSURE_TRUE(audioEncoder, nullptr);
@ -296,4 +298,20 @@ MediaEncoder::CopyMetadataToMuxer(TrackEncoder *aTrackEncoder)
return rv;
}
#ifdef MOZ_WEBM_ENCODER
bool
MediaEncoder::IsWebMEncoderEnabled()
{
return Preferences::GetBool("media.encoder.webm.enabled");
}
#endif
#ifdef MOZ_OMX_ENCODER
bool
MediaEncoder::IsOMXEncoderEnabled()
{
return Preferences::GetBool("media.encoder.omx.enabled");
}
#endif
}

View File

@ -128,6 +128,14 @@ public :
return mState == ENCODE_ERROR;
}
#ifdef MOZ_WEBM_ENCODER
static bool IsWebMEncoderEnabled();
#endif
#ifdef MOZ_OMX_ENCODER
static bool IsOMXEncoderEnabled();
#endif
private:
// Get encoded data from trackEncoder and write to muxer
nsresult WriteEncodedDataToMuxer(TrackEncoder *aTrackEncoder);

View File

@ -301,13 +301,6 @@ URLSearchParams::Delete(const nsAString& aName)
NotifyObserver();
}
uint32_t
URLSearchParams::Size()
{
Validate();
return mSearchParams.Count();
}
void
URLSearchParams::DeleteAll()
{
@ -348,7 +341,7 @@ public:
};
void
URLSearchParams::Serialize(nsAString& aValue)
URLSearchParams::Serialize(nsAString& aValue) const
{
MOZ_ASSERT(mValid);

View File

@ -71,7 +71,7 @@ public:
return mValid;
}
void Serialize(nsAString& aValue);
void Serialize(nsAString& aValue) const;
void Get(const nsAString& aName, nsString& aRetval);
@ -85,7 +85,11 @@ public:
void Delete(const nsAString& aName);
uint32_t Size();
void Stringify(nsString& aRetval)
{
Validate();
Serialize(aRetval);
}
private:
void AppendInternal(const nsAString& aName, const nsAString& aValue);

View File

@ -604,11 +604,14 @@ nsDOMWindowUtils::SendMouseEvent(const nsAString& aType,
bool aIgnoreRootScrollFrame,
float aPressure,
unsigned short aInputSourceArg,
bool aIsSynthesized,
uint8_t aOptionalArgCount,
bool *aPreventDefault)
{
return SendMouseEventCommon(aType, aX, aY, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, aPressure,
aInputSourceArg, false, aPreventDefault);
aInputSourceArg, false, aPreventDefault,
aOptionalArgCount >= 4 ? aIsSynthesized : true);
}
NS_IMETHODIMP
@ -620,12 +623,15 @@ nsDOMWindowUtils::SendMouseEventToWindow(const nsAString& aType,
int32_t aModifiers,
bool aIgnoreRootScrollFrame,
float aPressure,
unsigned short aInputSourceArg)
unsigned short aInputSourceArg,
bool aIsSynthesized,
uint8_t aOptionalArgCount)
{
PROFILER_LABEL("nsDOMWindowUtils", "SendMouseEventToWindow");
return SendMouseEventCommon(aType, aX, aY, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, aPressure,
aInputSourceArg, true, nullptr);
aInputSourceArg, true, nullptr,
aOptionalArgCount >= 4 ? aIsSynthesized : true);
}
static LayoutDeviceIntPoint
@ -668,7 +674,8 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
float aPressure,
unsigned short aInputSourceArg,
bool aToWindow,
bool *aPreventDefault)
bool *aPreventDefault,
bool aIsSynthesized)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
@ -715,7 +722,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
event.inputSource = aInputSourceArg;
event.clickCount = aClickCount;
event.time = PR_IntervalNow();
event.mFlags.mIsSynthesizedForTests = true;
event.mFlags.mIsSynthesizedForTests = aIsSynthesized;
nsPresContext* presContext = GetPresContext();
if (!presContext)

View File

@ -46,7 +46,8 @@ protected:
float aPressure,
unsigned short aInputSourceArg,
bool aToWindow,
bool *aPreventDefault);
bool *aPreventDefault,
bool aIsSynthesized);
NS_IMETHOD SendTouchEventCommon(const nsAString& aType,
uint32_t* aIdentifiers,

View File

@ -49,3 +49,4 @@ support-files =
[test_window_extensible.html]
[test_window_indexing.html]
[test_writable-replaceable.html]
[test_domwindowutils.html]

View File

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test for DOMWindowUtils</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var utils = SpecialPowers.getDOMWindowUtils(window);
function test_sendMouseEventDefaults() {
var x = 1, y = 2, button = 1, clickCount = 2,
modifiers = SpecialPowers.Ci.nsIDOMNSEvent.SHIFT_MASK;
window.addEventListener("mousedown", function listener(evt) {
window.removeEventListener("mousedown", listener);
// Mandatory args
is(evt.clientX, x, "check x");
is(evt.clientY, y, "check y");
is(evt.button, button, "check button");
is(evt.detail, clickCount, "check click count");
is(evt.getModifierState("Shift"), true, "check modifiers");
// Default value for optionals
is(evt.mozPressure, 0, "check pressure");
is(evt.mozInputSource, SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE, "check input source");
is(evt.isSynthesized, undefined, "check isSynthesized is undefined in content");
is(SpecialPowers.wrap(evt).isSynthesized, true, "check isSynthesized is true from chrome");
next();
});
// Only pass mandatory arguments and check default values
utils.sendMouseEvent("mousedown", x, y, button, clickCount, modifiers);
}
function test_sendMouseEventOptionals() {
var x = 1, y = 2, button = 1, clickCount = 3,
modifiers = SpecialPowers.Ci.nsIDOMNSEvent.SHIFT_MASK,
pressure = 0.5,
source = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
window.addEventListener("mouseup", function listener(evt) {
window.removeEventListener("mouseup", listener);
is(evt.mozInputSource, source, "explicit input source is valid");
is(SpecialPowers.wrap(evt).isSynthesized, false, "we can dispatch event that don't look synthesized");
next();
});
// Check explicit value for optional args
utils.sendMouseEvent("mouseup", x, y, button, clickCount, modifiers,
false, pressure, source, false);
}
var tests = [
test_sendMouseEventDefaults,
test_sendMouseEventOptionals
];
function next() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
function start() {
SimpleTest.waitForExplicitFinish();
SimpleTest.executeSoon(next);
}
window.addEventListener("load", start);
</script>
</pre>
</body>
</html>

View File

@ -32,21 +32,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
is(u.has('foo'), false, 'URLSearchParams.has(foo)');
is(u.get('foo'), '', 'URLSearchParams.get(foo)');
is(u.getAll('foo').length, 0, 'URLSearchParams.getAll(foo)');
is(u.size, 0, 'URLSearchParams.size()');
u.append('foo', 'bar');
is(u.has('foo'), true, 'URLSearchParams.has(foo)');
is(u.get('foo'), 'bar', 'URLSearchParams.get(foo)');
is(u.getAll('foo').length, 1, 'URLSearchParams.getAll(foo)');
is(u.size, 1, 'URLSearchParams.size()');
u.set('foo', 'bar2');
is(u.get('foo'), 'bar2', 'URLSearchParams.get(foo)');
is(u.getAll('foo').length, 1, 'URLSearchParams.getAll(foo)');
is(u.size, 1, 'URLSearchParams.size()');
is(u + "", "foo=bar2", "stringifier");
u.delete('foo');
is(u.size, 0, 'URLSearchParams.size()');
runTest();
}
@ -55,10 +53,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
var u = new URLSearchParams();
ok(u, "URLSearchParams created");
u.append('foo', 'bar');
is(u.size, 1, "u.size()");
var uu = new URLSearchParams(u);
is(uu.size, 1, "uu.size()");
is(uu.get('foo'), 'bar', 'uu.get()');
u.append('foo', 'bar2');
@ -112,8 +108,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
is(all[k], checks[i].data[key][k], "value matches");
}
}
is(u.size, count, "size matches");
}
runTest();

View File

@ -179,6 +179,11 @@ public:
return mEvent->mFlags.mIsTrusted;
}
bool IsSynthesized() const
{
return mEvent->mFlags.mIsSynthesizedForTests;
}
uint64_t TimeStamp() const
{
return mEvent->time;

View File

@ -118,11 +118,8 @@ function test_setComposition() {
function test_endComposition() {
gContext.endComposition('2013').then(function() {
if (gContext.textBeforeCursor + gContext.textAfterCursor == 'Xulei2013') {
ok(true, 'endComposition changed the input field correctly.');
} else {
todo(false, 'endComposition changed the input field incorrectly.');
}
is(gContext.textBeforeCursor + gContext.textAfterCursor, 'Xulei2013',
'endComposition changed the input field correctly.');
test_onSelectionChange();
}, function (e) {
ok(false, 'endComposition failed: ' + e.name);

View File

@ -43,7 +43,7 @@ interface nsIDOMEventTarget;
interface nsIRunnable;
interface nsICompositionStringSynthesizer;
[scriptable, uuid(c6efd629-7282-4f0d-9db8-0fa59c191dd5)]
[scriptable, uuid(fa0fe174-7c07-11e3-a5ba-000c290c393e)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -249,9 +249,13 @@ interface nsIDOMWindowUtils : nsISupports {
* @param aPressure touch input pressure: 0.0 -> 1.0
* @param aInputSourceArg input source, see nsIDOMMouseEvent for values,
* defaults to mouse input.
* @param aIsSynthesized controls nsIDOMEvent.isSynthesized value
* that helps identifying test related events,
* defaults to true
*
* returns true if the page called prevent default on this event
*/
[optional_argc]
boolean sendMouseEvent(in AString aType,
in float aX,
in float aY,
@ -260,7 +264,8 @@ interface nsIDOMWindowUtils : nsISupports {
in long aModifiers,
[optional] in boolean aIgnoreRootScrollFrame,
[optional] in float aPressure,
[optional] in unsigned short aInputSourceArg);
[optional] in unsigned short aInputSourceArg,
[optional] in boolean aIsSynthesized);
/** Synthesize a touch event. The event types supported are:
* touchstart, touchend, touchmove, and touchcancel
@ -303,6 +308,7 @@ interface nsIDOMWindowUtils : nsISupports {
/** The same as sendMouseEvent but ensures that the event is dispatched to
* this DOM window or one of its children.
*/
[optional_argc]
void sendMouseEventToWindow(in AString aType,
in float aX,
in float aY,
@ -311,7 +317,8 @@ interface nsIDOMWindowUtils : nsISupports {
in long aModifiers,
[optional] in boolean aIgnoreRootScrollFrame,
[optional] in float aPressure,
[optional] in unsigned short aInputSourceArg);
[optional] in unsigned short aInputSourceArg,
[optional] in boolean aIsSynthesized);
/** The same as sendTouchEvent but ensures that the event is dispatched to
* this DOM window or one of its children.

View File

@ -2387,7 +2387,7 @@ TabChild::DispatchMouseEvent(const nsString& aType,
bool defaultPrevented = false;
utils->SendMouseEvent(aType, aPoint.x, aPoint.y, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, 0, aInputSourceArg, &defaultPrevented);
aIgnoreRootScrollFrame, 0, aInputSourceArg, false, 4, &defaultPrevented);
return defaultPrevented;
}

View File

@ -1116,7 +1116,7 @@ TabParent::SendCompositionEvent(WidgetCompositionEvent& event)
mIMECompositionStart = std::min(mIMESelectionAnchor, mIMESelectionFocus);
if (mIMECompositionEnding)
return true;
event.seqno = ++mIMESeqno;
event.mSeqno = ++mIMESeqno;
return PBrowserParent::SendCompositionEvent(event);
}
@ -1147,7 +1147,7 @@ TabParent::SendTextEvent(WidgetTextEvent& event)
mIMESelectionAnchor = mIMESelectionFocus =
mIMECompositionStart + event.theText.Length();
event.seqno = ++mIMESeqno;
event.mSeqno = ++mIMESeqno;
return PBrowserParent::SendTextEvent(event);
}
@ -1159,7 +1159,7 @@ TabParent::SendSelectionEvent(WidgetSelectionEvent& event)
}
mIMESelectionAnchor = event.mOffset + (event.mReversed ? event.mLength : 0);
mIMESelectionFocus = event.mOffset + (!event.mReversed ? event.mLength : 0);
event.seqno = ++mIMESeqno;
event.mSeqno = ++mIMESeqno;
return PBrowserParent::SendSelectionEvent(event);
}

View File

@ -119,18 +119,26 @@ GlobalPCList.prototype = {
},
getStatsForEachPC: function(callback, errorCallback) {
function getStatsFromPC(pcref) {
try {
pcref.get().getStatsInternal(null, callback, errorCallback);
} catch (e) {
errorCallback("Some error getting stats from PC: " + e.toString());
}
}
for (let winId in this._list) {
if (this._list.hasOwnProperty(winId)) {
this.removeNullRefs(winId);
if (this._list[winId]) {
this._list[winId].forEach(function(pcref) {
pcref.get().getStatsInternal(null, callback, errorCallback);
});
this._list[winId].forEach(getStatsFromPC);
}
}
}
},
// TODO(bcampen@mozilla.com): Handle this with a global object in c++
// (Bug 958221)
getLoggingFromFirstPC: function(pattern, callback, errorCallback) {
for (let winId in this._list) {
this.removeNullRefs(winId);
@ -154,6 +162,8 @@ WebrtcGlobalInformation.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
getAllStats: function(successCallback, failureCallback) {
// TODO(bcampen@mozilla.com): Move the work of fanout into c++, and
// only callback once. (Bug 958221)
if (_globalPCList) {
_globalPCList.getStatsForEachPC(successCallback, failureCallback);
} else {

View File

@ -1488,8 +1488,17 @@ PeerConnectionWrapper.prototype = {
ok(toNum(counters["inboundrtp"]) >= nin, "Have at least " + nin + " inboundrtp stat(s) *");
is(toNum(counters["outboundrtp"]), nout, "Have " + nout + " outboundrtp stat(s)");
ok(toNum(counters["localcandidate"]), "Have localcandidate stat(s)");
ok(toNum(counters["remotecandidate"]), "Have remotecandidate stat(s)");
var numLocalCandidates = toNum(counters["localcandidate"]);
var numRemoteCandidates = toNum(counters["remotecandidate"]);
// If there are no tracks, there will be no stats either.
if (nin + nout > 0) {
ok(numLocalCandidates, "Have localcandidate stat(s)");
ok(numRemoteCandidates, "Have remotecandidate stat(s)");
} else {
is(numLocalCandidates, 0, "Have no localcandidate stats");
is(numRemoteCandidates, 0, "Have no remotecandidate stats");
}
},
/**

View File

@ -2633,6 +2633,8 @@ nsPluginHost::ReadPluginInfo()
mCachedPlugins = tag;
}
// On Android we always want to try to load a plugin again (Flash). Bug 935676.
#ifndef MOZ_WIDGET_ANDROID
if (hasInvalidPlugins) {
if (!ReadSectionHeader(reader, "INVALID")) {
return rv;
@ -2656,6 +2658,7 @@ nsPluginHost::ReadPluginInfo()
mInvalidPlugins = invalidTag;
}
}
#endif
// flip the pref so we don't import the legacy flags again
Preferences::SetBool("plugin.importedState", true);

View File

@ -168,6 +168,14 @@ nsPluginInstanceOwner::GetImageContainer()
// for what we do on other versions.
if (AndroidBridge::Bridge()->GetAPIVersion() < 11)
return nullptr;
LayoutDeviceRect r = GetPluginRect();
// NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render
// into, set y-flip flags, etc, so we do this at the beginning.
gfxSize resolution = mObjectFrame->PresContext()->PresShell()->GetCumulativeResolution();
ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution.width, resolution.height)).Size();
mInstance->NotifySize(nsIntSize(screenSize.width, screenSize.height));
container = LayerManager::CreateImageContainer();
@ -175,23 +183,16 @@ nsPluginInstanceOwner::GetImageContainer()
nsRefPtr<Image> img = container->CreateImage(&format, 1);
SharedTextureImage::Data data;
data.mSize = gfx::IntSize(r.width, r.height);
data.mHandle = mInstance->CreateSharedHandle();
data.mShareType = mozilla::gl::SharedTextureShareType::SameProcess;
data.mInverted = mInstance->Inverted();
LayoutDeviceRect r = GetPluginRect();
data.mSize = gfx::IntSize(r.width, r.height);
SharedTextureImage* pluginImage = static_cast<SharedTextureImage*>(img.get());
pluginImage->SetData(data);
container->SetCurrentImageInTransaction(img);
float xResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetXResolution();
float yResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetYResolution();
ScreenSize screenSize = (r * LayoutDeviceToScreenScale(xResolution, yResolution)).Size();
mInstance->NotifySize(nsIntSize(screenSize.width, screenSize.height));
return container.forget();
#endif

View File

@ -46,6 +46,11 @@ function debug(s) {
let RILQUIRKS_DATA_REGISTRATION_ON_DEMAND =
libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") == "true";
// Ril quirk to always turn the radio off for the client without SIM card
// except hw default client.
let RILQUIRKS_RADIO_OFF_WO_CARD =
libcutils.property_get("ro.moz.ril.radio_off_wo_card", "false") == "true";
const RADIOINTERFACELAYER_CID =
Components.ID("{2d831c8d-6017-435b-a80c-e5d422810cea}");
const RADIOINTERFACE_CID =
@ -90,6 +95,7 @@ const DOM_MOBILE_MESSAGE_DELIVERY_ERROR = "error";
const RADIO_POWER_OFF_TIMEOUT = 30000;
const SMS_HANDLED_WAKELOCK_TIMEOUT = 5000;
const HW_DEFAULT_CLIENT_ID = 0;
const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:GetRilContext",
@ -502,6 +508,8 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function() {
XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
return {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
ril: null,
pendingMessages: [], // For queueing "RIL:SetRadioEnabled" messages.
timer: null,
@ -510,6 +518,7 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
init: function(ril) {
this.ril = ril;
Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
},
receiveMessage: function(msg) {
@ -541,9 +550,47 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
this._handleMessage(msg);
},
_getNumCards: function() {
let numCards = 0;
for (let i = 0, N = this.ril.numRadioInterfaces; i < N; ++i) {
if (this._isCardPresentAtClient(i)) {
numCards++;
}
}
return numCards;
},
_isCardPresentAtClient: function(clientId) {
let cardState = this.ril.getRadioInterface(clientId).rilContext.cardState;
return cardState !== RIL.GECKO_CARDSTATE_UNDETECTED &&
cardState !== RIL.GECKO_CARDSTATE_UNKNOWN;
},
_isRadioAbleToEnableAtClient: function(clientId, numCards) {
if (!RILQUIRKS_RADIO_OFF_WO_CARD) {
return true;
}
// We could only turn on the radio for clientId if
// 1. a SIM card is presented or
// 2. it is the default clientId and there is no any SIM card at any client.
if (this._isCardPresentAtClient(clientId)) {
return true;
}
numCards = numCards == null ? this._getNumCards() : numCards;
if (clientId === HW_DEFAULT_CLIENT_ID && numCards === 0) {
return true;
}
return false;
},
_handleMessage: function(msg) {
if (DEBUG) debug("setRadioEnabled: handleMessage: " + JSON.stringify(msg));
let radioInterface = this.ril.getRadioInterface(msg.json.clientId || 0);
let clientId = msg.json.clientId || 0;
let radioInterface = this.ril.getRadioInterface(clientId);
if (!radioInterface.isValidStateForSetRadioEnabled()) {
radioInterface.setRadioEnabledResponse(msg.target, msg.json.data,
@ -559,7 +606,13 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
}
if (msg.json.data.enabled) {
radioInterface.receiveMessage(msg);
if (this._isRadioAbleToEnableAtClient(clientId)) {
radioInterface.receiveMessage(msg);
} else {
// Not really do it but respond success.
radioInterface.setRadioEnabledResponse(msg.target, msg.json.data);
}
this._processNextMessage();
} else {
this.request = (function() {
@ -620,6 +673,27 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
this.request = null;
}
this._processNextMessage();
},
/**
* nsIObserver interface methods.
*/
observe: function observe(subject, topic, data) {
switch (topic) {
case kSysMsgListenerReadyObserverTopic:
Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic);
let numCards = this._getNumCards();
for (let i = 0, N = this.ril.numRadioInterfaces; i < N; ++i) {
if (this._isRadioAbleToEnableAtClient(i, numCards)) {
let radioInterface = this.ril.getRadioInterface(i);
radioInterface.setRadioEnabledInternal({enabled: true}, null);
}
}
break;
default:
break;
}
}
};
});
@ -1181,7 +1255,6 @@ function RadioInterface(options) {
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
Services.obs.addObserver(this, kSysClockChangeObserverTopic, false);
Services.obs.addObserver(this, kScreenStateChangedTopic, false);
@ -2659,9 +2732,6 @@ RadioInterface.prototype = {
observe: function(subject, topic, data) {
switch (topic) {
case kSysMsgListenerReadyObserverTopic:
this.setRadioEnabledInternal({enabled: true}, null);
break;
case kMozSettingsChangedObserverTopic:
let setting = JSON.parse(data);
this.handleSettingsChange(setting.key, setting.value, setting.message);

View File

@ -697,11 +697,11 @@ Telephony::NotifyError(uint32_t aServiceId,
NS_IMETHODIMP
Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber)
{
MOZ_ASSERT(mActiveCall &&
mActiveCall->ServiceId() == aServiceId &&
mActiveCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED);
MOZ_ASSERT(mCalls.Length() == 1);
nsRefPtr<TelephonyCall> callToNotify = mCalls[0];
MOZ_ASSERT(callToNotify && callToNotify->ServiceId() == aServiceId);
nsRefPtr<TelephonyCall> callToNotify = mActiveCall;
callToNotify->UpdateSecondNumber(aNumber);
DispatchCallEvent(NS_LITERAL_STRING("callschanged"), callToNotify);
return NS_OK;

View File

@ -82,7 +82,7 @@ interface CanvasRenderingContext2D {
// NOT IMPLEMENTED void fill(Path path);
void stroke();
// NOT IMPLEMENTED void stroke(Path path);
[Pref="canvas.focusring.enabled"] void drawSystemFocusRing(Element element);
[Pref="canvas.focusring.enabled"] void drawFocusIfNeeded(Element element);
// NOT IMPLEMENTED void drawSystemFocusRing(Path path, HTMLElement element);
[Pref="canvas.focusring.enabled"] boolean drawCustomFocusRing(Element element);
// NOT IMPLEMENTED boolean drawCustomFocusRing(Path path, HTMLElement element);

View File

@ -56,6 +56,7 @@ partial interface Event {
readonly attribute EventTarget? originalTarget;
readonly attribute EventTarget? explicitOriginalTarget;
[ChromeOnly] readonly attribute boolean multipleActionsPrevented;
[ChromeOnly] readonly attribute boolean isSynthesized;
boolean getPreventDefault();
};

View File

@ -104,6 +104,7 @@ enum RTCStatsIceCandidateType {
};
dictionary RTCIceCandidateStats : RTCStats {
DOMString componentId;
DOMString candidateId;
DOMString ipAddress;
long portNumber;

View File

@ -16,11 +16,11 @@
[Constructor(optional DOMString init = ""),
Constructor(URLSearchParams init)]
interface URLSearchParams {
void append(DOMString name, DOMString value);
void delete(DOMString name);
DOMString? get(DOMString name);
sequence<DOMString> getAll(DOMString name);
void set(DOMString name, DOMString value);
void append(DOMString name, DOMString value);
boolean has(DOMString name);
void delete(DOMString name);
readonly attribute unsigned long size;
void set(DOMString name, DOMString value);
stringifier;
};

View File

@ -29,21 +29,19 @@ onmessage = function() {
is(u.has('foo'), false, 'URLSearchParams.has(foo)');
is(u.get('foo'), '', 'URLSearchParams.get(foo)');
is(u.getAll('foo').length, 0, 'URLSearchParams.getAll(foo)');
is(u.size, 0, 'URLSearchParams.size()');
u.append('foo', 'bar');
is(u.has('foo'), true, 'URLSearchParams.has(foo)');
is(u.get('foo'), 'bar', 'URLSearchParams.get(foo)');
is(u.getAll('foo').length, 1, 'URLSearchParams.getAll(foo)');
is(u.size, 1, 'URLSearchParams.size()');
u.set('foo', 'bar2');
is(u.get('foo'), 'bar2', 'URLSearchParams.get(foo)');
is(u.getAll('foo').length, 1, 'URLSearchParams.getAll(foo)');
is(u.size, 1, 'URLSearchParams.size()');
is(u + "", "foo=bar2", "stringify");
u.delete('foo');
is(u.size, 0, 'URLSearchParams.size()');
runTest();
}
@ -52,10 +50,8 @@ onmessage = function() {
var u = new URLSearchParams();
ok(u, "URLSearchParams created");
u.append('foo', 'bar');
is(u.size, 1, "u.size()");
var uu = new URLSearchParams(u);
is(uu.size, 1, "uu.size()");
is(uu.get('foo'), 'bar', 'uu.get()');
u.append('foo', 'bar2');
@ -109,8 +105,6 @@ onmessage = function() {
is(all[k], checks[i].data[key][k], "value matches");
}
}
is(u.size, count, "size matches");
}
runTest();

View File

@ -117,7 +117,7 @@ D3D9SurfaceImage::GetSize()
}
already_AddRefed<gfxASurface>
D3D9SurfaceImage::GetAsSurface()
D3D9SurfaceImage::DeprecatedGetAsSurface()
{
NS_ENSURE_TRUE(mTexture, nullptr);

View File

@ -46,7 +46,7 @@ public:
gfx::IntSize GetSize() MOZ_OVERRIDE;
already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
private:

View File

@ -197,7 +197,7 @@ ConvertYVU420SPToRGB565(void *aYData, uint32_t aYStride,
}
already_AddRefed<gfxASurface>
GrallocImage::GetAsSurface()
GrallocImage::DeprecatedGetAsSurface()
{
android::sp<GraphicBuffer> graphicBuffer =
GrallocBufferActor::GetFrom(GetSurfaceDescriptor());

View File

@ -109,7 +109,7 @@ public:
HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS = 0x7FA30C04,
};
virtual already_AddRefed<gfxASurface> GetAsSurface();
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
void* GetNativeBuffer()
{

View File

@ -21,6 +21,7 @@
#ifdef MOZ_WIDGET_GONK
#include "GrallocImages.h"
#endif
#include "gfx2DGlue.h"
#ifdef XP_MACOSX
#include "mozilla/gfx/QuartzSupport.h"
@ -49,6 +50,13 @@ class SourceSurface;
Atomic<int32_t> Image::sSerialCounter(0);
TemporaryRef<gfx::SourceSurface>
Image::GetAsSourceSurface()
{
nsRefPtr<gfxASurface> surface = DeprecatedGetAsSurface();
return gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
}
already_AddRefed<Image>
ImageFactory::CreateImage(const ImageFormat *aFormats,
uint32_t aNumFormats,
@ -289,7 +297,7 @@ ImageContainer::LockCurrentImage()
}
already_AddRefed<gfxASurface>
ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
ImageContainer::DeprecatedLockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
@ -323,7 +331,7 @@ ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
}
*aSize = mActiveImage->GetSize();
return mActiveImage->GetAsSurface();
return mActiveImage->DeprecatedGetAsSurface();
}
if (aCurrentImage) {
@ -336,7 +344,59 @@ ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
}
*aSize = mActiveImage->GetSize();
return mActiveImage->GetAsSurface();
return mActiveImage->DeprecatedGetAsSurface();
}
TemporaryRef<gfx::SourceSurface>
ImageContainer::LockCurrentAsSourceSurface(gfx::IntSize *aSize, Image** aCurrentImage)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mRemoteData) {
NS_ASSERTION(mRemoteDataMutex, "Should have remote data mutex when having remote data!");
mRemoteDataMutex->Lock();
EnsureActiveImage();
if (aCurrentImage) {
NS_IF_ADDREF(mActiveImage);
*aCurrentImage = mActiveImage.get();
}
if (!mActiveImage) {
return nullptr;
}
if (mActiveImage->GetFormat() == REMOTE_IMAGE_BITMAP) {
gfxImageFormat fmt = mRemoteData->mFormat == RemoteImageData::BGRX32
? gfxImageFormatARGB32
: gfxImageFormatRGB24;
RefPtr<gfx::DataSourceSurface> newSurf
= gfx::Factory::CreateWrappingDataSourceSurface(mRemoteData->mBitmap.mData,
mRemoteData->mBitmap.mStride,
mRemoteData->mSize,
gfx::ImageFormatToSurfaceFormat(fmt));
*aSize = newSurf->GetSize();
return newSurf;
}
*aSize = mActiveImage->GetSize();
return mActiveImage->GetAsSourceSurface();
}
if (aCurrentImage) {
NS_IF_ADDREF(mActiveImage);
*aCurrentImage = mActiveImage.get();
}
if (!mActiveImage) {
return nullptr;
}
*aSize = mActiveImage->GetSize();
return mActiveImage->GetAsSourceSurface();
}
void
@ -349,7 +409,7 @@ ImageContainer::UnlockCurrentImage()
}
already_AddRefed<gfxASurface>
ImageContainer::GetCurrentAsSurface(gfx::IntSize *aSize)
ImageContainer::DeprecatedGetCurrentAsSurface(gfx::IntSize *aSize)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
@ -365,7 +425,27 @@ ImageContainer::GetCurrentAsSurface(gfx::IntSize *aSize)
return nullptr;
*aSize = mActiveImage->GetSize();
}
return mActiveImage->GetAsSurface();
return mActiveImage->DeprecatedGetAsSurface();
}
TemporaryRef<gfx::SourceSurface>
ImageContainer::GetCurrentAsSourceSurface(gfx::IntSize *aSize)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mRemoteData) {
CrossProcessMutexAutoLock autoLock(*mRemoteDataMutex);
EnsureActiveImage();
if (!mActiveImage)
return nullptr;
*aSize = mRemoteData->mSize;
} else {
if (!mActiveImage)
return nullptr;
*aSize = mActiveImage->GetSize();
}
return mActiveImage->GetAsSourceSurface();
}
gfx::IntSize
@ -553,7 +633,7 @@ PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
}
already_AddRefed<gfxASurface>
PlanarYCbCrImage::GetAsSurface()
PlanarYCbCrImage::DeprecatedGetAsSurface()
{
if (mSurface) {
nsRefPtr<gfxASurface> result = mSurface.get();
@ -580,7 +660,7 @@ PlanarYCbCrImage::GetAsSurface()
}
already_AddRefed<gfxASurface>
RemoteBitmapImage::GetAsSurface()
RemoteBitmapImage::DeprecatedGetAsSurface()
{
nsRefPtr<gfxImageSurface> newSurf =
new gfxImageSurface(ThebesIntSize(mSize),

View File

@ -27,6 +27,7 @@
#include "nsTArray.h" // for nsTArray
#include "mozilla/Atomics.h"
#include "nsThreadUtils.h"
#include "mozilla/gfx/2D.h"
#ifndef XPCOM_GLUE_AVOID_NSPR
/**
@ -146,7 +147,7 @@ public:
ImageFormat GetFormat() { return mFormat; }
void* GetImplData() { return mImplData; }
virtual already_AddRefed<gfxASurface> GetAsSurface() = 0;
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() = 0;
virtual gfx::IntSize GetSize() = 0;
virtual nsIntRect GetPictureRect()
{
@ -163,6 +164,8 @@ public:
void MarkSent() { mSent = true; }
bool IsSentToCompositor() { return mSent; }
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
protected:
Image(void* aImplData, ImageFormat aFormat) :
mImplData(aImplData),
@ -483,7 +486,7 @@ public:
* the lock methods should be used to avoid the copy, however this should be
* avoided if the surface is required for a long period of time.
*/
already_AddRefed<gfxASurface> GetCurrentAsSurface(gfx::IntSize* aSizeResult);
already_AddRefed<gfxASurface> DeprecatedGetCurrentAsSurface(gfx::IntSize* aSizeResult);
/**
* This is similar to GetCurrentAsSurface, however this does not make a copy
@ -493,8 +496,19 @@ public:
* type of image. Optionally a pointer can be passed to receive the current
* image.
*/
already_AddRefed<gfxASurface> LockCurrentAsSurface(gfx::IntSize* aSizeResult,
Image** aCurrentImage = nullptr);
already_AddRefed<gfxASurface> DeprecatedLockCurrentAsSurface(gfx::IntSize* aSizeResult,
Image** aCurrentImage = nullptr);
/**
* Same as GetCurrentAsSurface but for Moz2D
*/
TemporaryRef<gfx::SourceSurface> GetCurrentAsSourceSurface(gfx::IntSize* aSizeResult);
/**
* Same as LockCurrentAsSurface but for Moz2D
*/
TemporaryRef<gfx::SourceSurface> LockCurrentAsSourceSurface(gfx::IntSize* aSizeResult,
Image** aCurrentImage = nullptr);
/**
* Returns the size of the image in pixels.
@ -668,7 +682,7 @@ class AutoLockImage
public:
AutoLockImage(ImageContainer *aContainer) : mContainer(aContainer) { mImage = mContainer->LockCurrentImage(); }
AutoLockImage(ImageContainer *aContainer, gfxASurface **aSurface) : mContainer(aContainer) {
*aSurface = mContainer->LockCurrentAsSurface(&mSize, getter_AddRefs(mImage)).get();
*aSurface = mContainer->DeprecatedLockCurrentAsSurface(&mSize, getter_AddRefs(mImage)).get();
}
~AutoLockImage() { if (mContainer) { mContainer->UnlockCurrentImage(); } }
@ -841,7 +855,7 @@ protected:
*/
virtual uint8_t* AllocateBuffer(uint32_t aSize);
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
gfxImageFormat GetOffscreenFormat();
@ -879,7 +893,7 @@ public:
}
virtual already_AddRefed<gfxASurface> GetAsSurface()
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface()
{
nsRefPtr<gfxASurface> surface = mSurface.get();
return surface.forget();
@ -897,7 +911,7 @@ class RemoteBitmapImage : public Image {
public:
RemoteBitmapImage() : Image(nullptr, REMOTE_IMAGE_BITMAP) {}
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
gfx::IntSize GetSize() { return mSize; }

View File

@ -28,7 +28,7 @@ public:
virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
virtual already_AddRefed<gfxASurface> GetAsSurface() {
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() {
mSurface->Lock();
size_t bytesPerRow = mSurface->GetBytesPerRow();
size_t ioWidth = mSurface->GetDevicePixelWidth();

View File

@ -35,7 +35,7 @@ public:
gfx::IntSize GetSize() { return mData.mSize; }
virtual already_AddRefed<gfxASurface> GetAsSurface() {
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() {
return nullptr;
}

View File

@ -167,7 +167,7 @@ BasicImageLayer::GetAsSurface(gfxASurface** aSurface,
}
gfx::IntSize dontCare;
nsRefPtr<gfxASurface> surface = mContainer->GetCurrentAsSurface(&dontCare);
nsRefPtr<gfxASurface> surface = mContainer->DeprecatedGetCurrentAsSurface(&dontCare);
*aSurface = surface.forget().get();
return true;
}

View File

@ -52,7 +52,7 @@ public:
virtual void SetData(const Data& aData);
virtual void SetDelayedConversion(bool aDelayed) { mDelayedConversion = aDelayed; }
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
private:
nsAutoArrayPtr<uint8_t> mDecodedBuffer;
@ -133,7 +133,7 @@ DestroyBuffer(void* aBuffer)
}
already_AddRefed<gfxASurface>
BasicPlanarYCbCrImage::GetAsSurface()
BasicPlanarYCbCrImage::DeprecatedGetAsSurface()
{
NS_ASSERTION(NS_IsMainThread(), "Must be main thread");
@ -143,7 +143,7 @@ BasicPlanarYCbCrImage::GetAsSurface()
}
if (!mDecodedBuffer) {
return PlanarYCbCrImage::GetAsSurface();
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
gfxImageFormat format = GetOffscreenFormat();

View File

@ -221,7 +221,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
GetForwarder()->UseTexture(this, mFrontBuffer);
} else {
nsRefPtr<gfxASurface> surface = image->GetAsSurface();
nsRefPtr<gfxASurface> surface = image->DeprecatedGetAsSurface();
MOZ_ASSERT(surface);
gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
@ -435,7 +435,7 @@ DeprecatedImageClientSingle::UpdateImage(ImageContainer* aContainer,
mDeprecatedTextureClient->SetDescriptor(desc);
#endif
} else {
nsRefPtr<gfxASurface> surface = image->GetAsSurface();
nsRefPtr<gfxASurface> surface = image->DeprecatedGetAsSurface();
MOZ_ASSERT(surface);
EnsureDeprecatedTextureClient(TEXTURE_SHMEM);

View File

@ -18,7 +18,6 @@
#include "mozilla/TouchEvents.h"
#include "nsDebug.h" // for NS_WARNING
#include "nsPoint.h" // for nsIntPoint
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
#include "nsThreadUtils.h" // for NS_IsMainThread
#include <algorithm> // for std::stable_sort
@ -43,6 +42,38 @@ APZCTreeManager::~APZCTreeManager()
{
}
void
APZCTreeManager::GetAllowedTouchBehavior(WidgetInputEvent* aEvent,
nsTArray<TouchBehaviorFlags>& aOutValues)
{
WidgetTouchEvent *touchEvent = aEvent->AsTouchEvent();
aOutValues.Clear();
for (size_t i = 0; i < touchEvent->touches.Length(); i++) {
// If aEvent wasn't transformed previously we might need to
// add transforming of the spt here.
mozilla::ScreenIntPoint spt;
spt.x = touchEvent->touches[i]->mRefPoint.x;
spt.y = touchEvent->touches[i]->mRefPoint.y;
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(spt);
aOutValues.AppendElement(apzc
? apzc->GetAllowedTouchBehavior(spt)
: AllowedTouchBehavior::UNKNOWN);
}
}
void
APZCTreeManager::SetAllowedTouchBehavior(const ScrollableLayerGuid& aGuid,
const nsTArray<TouchBehaviorFlags> &aValues)
{
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
if (apzc) {
apzc->SetAllowedTouchBehavior(aValues);
}
}
void
APZCTreeManager::AssertOnCompositorThread()
{

View File

@ -19,6 +19,7 @@
#include "nsISupportsImpl.h"
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
#include "mozilla/Vector.h" // for mozilla::Vector
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
class gfx3DMatrix;
template <class E> class nsTArray;
@ -28,6 +29,14 @@ class InputData;
namespace layers {
enum AllowedTouchBehavior {
NONE = 0,
VERTICAL_PAN = 1 << 0,
HORIZONTAL_PAN = 1 << 1,
ZOOM = 1 << 2,
UNKNOWN = 1 << 3
};
class Layer;
class AsyncPanZoomController;
class CompositorParent;
@ -57,6 +66,9 @@ class CompositorParent;
class APZCTreeManager {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZCTreeManager)
typedef mozilla::layers::AllowedTouchBehavior AllowedTouchBehavior;
typedef uint32_t TouchBehaviorFlags;
public:
APZCTreeManager();
virtual ~APZCTreeManager();
@ -189,6 +201,22 @@ public:
*/
static float GetDPI() { return sDPI; }
/**
* Returns values of allowed touch-behavior for the touches of aEvent via out parameter.
* Internally performs asks appropriate AsyncPanZoomController to perform
* hit testing on its own.
*/
void GetAllowedTouchBehavior(WidgetInputEvent* aEvent,
nsTArray<TouchBehaviorFlags>& aOutValues);
/**
* Sets allowed touch behavior values for current touch-session for specific apzc (determined by guid).
* Should be invoked by the widget. Each value of the aValues arrays corresponds to the different
* touch point that is currently active.
*/
void SetAllowedTouchBehavior(const ScrollableLayerGuid& aGuid,
const nsTArray<TouchBehaviorFlags>& aValues);
/**
* This is a callback for AsyncPanZoomController to call when it wants to
* scroll in response to a touch-move event, or when it needs to hand off

View File

@ -326,6 +326,16 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer,
return;
}
// Fixed layers are relative to their nearest scrollable layer, so when we
// encounter a scrollable layer, reset the transform to that layer and remove
// the fixed margins.
if (aLayer->AsContainerLayer() &&
aLayer->AsContainerLayer()->GetFrameMetrics().IsScrollable() &&
aLayer != aTransformedSubtreeRoot) {
AlignFixedAndStickyLayers(aLayer, aLayer, aLayer->GetTransform(), LayerMargin(0, 0, 0, 0));
return;
}
for (Layer* child = aLayer->GetFirstChild();
child; child = child->GetNextSibling()) {
AlignFixedAndStickyLayers(child, aTransformedSubtreeRoot,

View File

@ -38,12 +38,6 @@ ImageHost::~ImageHost() {}
void
ImageHost::UseTextureHost(TextureHost* aTexture)
{
if (mFrontBuffer) {
// XXX - When we implement sharing textures between several compositables
// we will need to not remove the compositor if there is another compositable
// using the texture.
mFrontBuffer->SetCompositor(nullptr);
}
CompositableHost::UseTextureHost(aTexture);
mFrontBuffer = aTexture;
}

View File

@ -421,7 +421,7 @@ ImageLayerD3D10::GetAsTexture(gfx::IntSize* aSize)
}
already_AddRefed<gfxASurface>
RemoteDXGITextureImage::GetAsSurface()
RemoteDXGITextureImage::DeprecatedGetAsSurface()
{
nsRefPtr<ID3D10Device1> device =
gfxWindowsPlatform::GetPlatform()->GetD3D10Device();

View File

@ -60,7 +60,7 @@ class RemoteDXGITextureImage : public Image {
public:
RemoteDXGITextureImage() : Image(nullptr, REMOTE_IMAGE_DXGI_TEXTURE) {}
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
IntSize GetSize() { return mSize; }

View File

@ -127,6 +127,13 @@ using namespace mozilla::css;
namespace mozilla {
namespace layers {
typedef mozilla::layers::AllowedTouchBehavior AllowedTouchBehavior;
/**
* Specifies whether touch-action property is in force.
*/
static bool gTouchActionPropertyEnabled = false;
/**
* Constant describing the tolerance in distance we use, multiplied by the
* device DPI, before we start panning the screen. This is to prevent us from
@ -135,6 +142,13 @@ namespace layers {
*/
static float gTouchStartTolerance = 1.0f/2.0f;
/**
* Default touch behavior (is used when not touch behavior is set).
*/
static const uint32_t DefaultTouchBehavior = AllowedTouchBehavior::VERTICAL_PAN |
AllowedTouchBehavior::HORIZONTAL_PAN |
AllowedTouchBehavior::ZOOM;
/**
* Angle from axis within which we stay axis-locked
*/
@ -150,6 +164,15 @@ static const float AXIS_BREAKOUT_THRESHOLD = 1.0f/32.0f;
*/
static const double AXIS_BREAKOUT_ANGLE = M_PI / 8.0; // 22.5 degrees
/**
* Angle from axis to the line drawn by pan move.
* If angle is less than this value we can assume that panning
* can be done in allowed direction (horizontal or vertical).
* Currently used only for touch-action css property stuff and was
* added to keep behavior consistent with IE.
*/
static const double ALLOWED_DIRECT_PAN_ANGLE = M_PI / 3.0; // 60 degrees
/**
* The preferred axis locking style. See AxisLockMode for possible values.
*/
@ -194,12 +217,12 @@ static const CSSToScreenScale MAX_ZOOM(8.0f);
static const CSSToScreenScale MIN_ZOOM(0.125f);
/**
* Amount of time before we timeout touch event listeners. For example, if
* Amount of time before we timeout response from content. For example, if
* content is being unruly/slow and we don't get a response back within this
* time, we will just pretend that content did not preventDefault any touch
* events we dispatched to it.
*/
static int gTouchListenerTimeout = 300;
static int gContentResponseTimeout = 300;
/**
* Number of samples to store of how long it took to paint after the previous
@ -358,10 +381,11 @@ AsyncPanZoomController::InitializeGlobalState()
return;
sInitialized = true;
Preferences::AddBoolVarCache(&gTouchActionPropertyEnabled, "layout.css.touch_action.enabled", gTouchActionPropertyEnabled);
Preferences::AddIntVarCache(&gPanRepaintInterval, "apz.pan_repaint_interval", gPanRepaintInterval);
Preferences::AddIntVarCache(&gFlingRepaintInterval, "apz.fling_repaint_interval", gFlingRepaintInterval);
Preferences::AddFloatVarCache(&gMinSkateSpeed, "apz.min_skate_speed", gMinSkateSpeed);
Preferences::AddIntVarCache(&gTouchListenerTimeout, "apz.touch_listener_timeout", gTouchListenerTimeout);
Preferences::AddIntVarCache(&gContentResponseTimeout, "apz.content_response_timeout", gContentResponseTimeout);
Preferences::AddIntVarCache(&gNumPaintDurationSamples, "apz.num_paint_duration_samples", gNumPaintDurationSamples);
Preferences::AddFloatVarCache(&gTouchStartTolerance, "apz.touch_start_tolerance", gTouchStartTolerance);
Preferences::AddFloatVarCache(&gXSkateSizeMultiplier, "apz.x_skate_size_multiplier", gXSkateSizeMultiplier);
@ -390,9 +414,11 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
mGeckoContentController(aGeckoContentController),
mRefPtrMonitor("RefPtrMonitor"),
mMonitor("AsyncPanZoomController"),
mTouchListenerTimeoutTask(nullptr),
mTouchActionPropertyEnabled(gTouchActionPropertyEnabled),
mContentResponseTimeoutTask(nullptr),
mX(MOZ_THIS_IN_INITIALIZER_LIST()),
mY(MOZ_THIS_IN_INITIALIZER_LIST()),
mPanDirRestricted(false),
mZoomConstraints(false, MIN_ZOOM, MAX_ZOOM),
mLastSampleTime(GetFrameTime()),
mState(NOTHING),
@ -401,6 +427,9 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
mCurrentAsyncScrollOffset(0, 0),
mAsyncScrollTimeoutTask(nullptr),
mHandlingTouchQueue(false),
mAllowedTouchBehaviorSet(false),
mPreventDefault(false),
mPreventDefaultSet(false),
mTreeManager(aTreeManager),
mAPZCId(sAsyncPanZoomControllerCount++),
mSharedFrameMetricsBuffer(nullptr),
@ -475,30 +504,35 @@ AsyncPanZoomController::GetTouchStartTolerance()
}
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
// If we may have touch listeners, we enable the machinery that allows touch
// listeners to preventDefault any touch inputs. This should not happen unless
// there are actually touch listeners as it introduces potentially unbounded
// lag because it causes a round-trip through content. Usually, if content is
// responding in a timely fashion, this only introduces a nearly constant few
// hundred ms of lag.
// If we may have touch listeners and touch action property is enabled, we
// enable the machinery that allows touch listeners to preventDefault any touch inputs
// and also waits for the allowed touch behavior values to be received from the outside.
// This should not happen unless there are actually touch listeners and touch-action property
// enable as it introduces potentially unbounded lag because it causes a round-trip through
// content. Usually, if content is responding in a timely fashion, this only introduces a
// nearly constant few hundred ms of lag.
if (mFrameMetrics.mMayHaveTouchListeners && aEvent.mInputType == MULTITOUCH_INPUT &&
(mState == NOTHING || mState == TOUCHING || IsPanningState(mState))) {
const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_START) {
SetState(WAITING_LISTENERS);
mAllowedTouchBehaviors.Clear();
mAllowedTouchBehaviorSet = false;
mPreventDefault = false;
mPreventDefaultSet = false;
SetState(WAITING_CONTENT_RESPONSE);
}
}
if (mState == WAITING_LISTENERS || mHandlingTouchQueue) {
if (mState == WAITING_CONTENT_RESPONSE || mHandlingTouchQueue) {
if (aEvent.mInputType == MULTITOUCH_INPUT) {
const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
mTouchQueue.AppendElement(multiTouchInput);
if (!mTouchListenerTimeoutTask) {
mTouchListenerTimeoutTask =
NewRunnableMethod(this, &AsyncPanZoomController::TimeoutTouchListeners);
if (!mContentResponseTimeoutTask) {
mContentResponseTimeoutTask =
NewRunnableMethod(this, &AsyncPanZoomController::TimeoutContentResponse);
PostDelayedTask(mTouchListenerTimeoutTask, gTouchListenerTimeout);
PostDelayedTask(mContentResponseTimeoutTask, gContentResponseTimeout);
}
}
return nsEventStatus_eIgnore;
@ -561,6 +595,7 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent)
nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent) {
APZC_LOG("%p got a touch-start in state %d\n", this, mState);
mPanDirRestricted = false;
ScreenIntPoint point = GetFirstTouchScreenPoint(aEvent);
switch (mState) {
@ -589,7 +624,7 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent
case CROSS_SLIDING_X:
case CROSS_SLIDING_Y:
case PINCHING:
case WAITING_LISTENERS:
case WAITING_CONTENT_RESPONSE:
NS_WARNING("Received impossible touch in OnTouchStart");
break;
default:
@ -624,6 +659,17 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent)
return nsEventStatus_eIgnore;
}
if (mTouchActionPropertyEnabled &&
(GetTouchBehavior(0) & AllowedTouchBehavior::VERTICAL_PAN) &&
(GetTouchBehavior(0) & AllowedTouchBehavior::HORIZONTAL_PAN)) {
// User tries to trigger a touch behavior. If allowed touch behavior is vertical pan
// + horizontal pan (touch-action value is equal to AUTO) we can return ConsumeNoDefault
// status immediately to trigger cancel event further. It should happen independent of
// the parent type (whether it is scrolling or not).
StartPanning(aEvent);
return nsEventStatus_eConsumeNoDefault;
}
return StartPanning(aEvent);
}
@ -638,7 +684,7 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent)
NS_WARNING("Gesture listener should have handled pinching in OnTouchMove.");
return nsEventStatus_eIgnore;
case WAITING_LISTENERS:
case WAITING_CONTENT_RESPONSE:
NS_WARNING("Received impossible touch in OnTouchMove");
break;
}
@ -648,7 +694,13 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent)
nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent) {
APZC_LOG("%p got a touch-end in state %d\n", this, mState);
{
// In case no touch behavior triggered previously we can avoid sending
// scroll events or requesting content repaint. This condition is added
// to make tests consistent - in case touch-action is NONE (and therefore
// no pans/zooms can be performed) we expected neither scroll or repaint
// events.
if (mState != NOTHING) {
ReentrantMonitorAutoEnter lock(mMonitor);
SendAsyncScrollEvent();
}
@ -690,7 +742,7 @@ nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent)
NS_WARNING("Gesture listener should have handled pinching in OnTouchEnd.");
return nsEventStatus_eIgnore;
case WAITING_LISTENERS:
case WAITING_CONTENT_RESPONSE:
NS_WARNING("Received impossible touch in OnTouchEnd");
break;
}
@ -706,6 +758,11 @@ nsEventStatus AsyncPanZoomController::OnTouchCancel(const MultiTouchInput& aEven
nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEvent) {
APZC_LOG("%p got a scale-begin in state %d\n", this, mState);
if (!TouchActionAllowZoom()) {
return nsEventStatus_eIgnore;
}
if (!mZoomConstraints.mAllowZoom) {
return nsEventStatus_eConsumeNoDefault;
}
@ -934,6 +991,74 @@ const gfx::Point AsyncPanZoomController::GetAccelerationVector() {
return gfx::Point(mX.GetAccelerationFactor(), mY.GetAccelerationFactor());
}
void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle, TouchBehaviorFlags aBehavior) {
// Handling of cross sliding will need to be added in this method after touch-action released
// enabled by default.
if ((aBehavior & AllowedTouchBehavior::VERTICAL_PAN) && (aBehavior & AllowedTouchBehavior::HORIZONTAL_PAN)) {
if (mX.Scrollable() && mY.Scrollable()) {
if (IsCloseToHorizontal(aAngle, AXIS_LOCK_ANGLE)) {
mY.SetScrollingDisabled(true);
SetState(PANNING_LOCKED_X);
} else if (IsCloseToVertical(aAngle, AXIS_LOCK_ANGLE)) {
mX.SetScrollingDisabled(true);
SetState(PANNING_LOCKED_Y);
} else {
SetState(PANNING);
}
} else if (mX.Scrollable() || mY.Scrollable()) {
SetState(PANNING);
} else {
SetState(NOTHING);
}
} else if (aBehavior & AllowedTouchBehavior::HORIZONTAL_PAN) {
// Using bigger angle for panning to keep behavior consistent
// with IE.
if (IsCloseToHorizontal(aAngle, ALLOWED_DIRECT_PAN_ANGLE)) {
mY.SetScrollingDisabled(true);
SetState(PANNING_LOCKED_X);
mPanDirRestricted = true;
} else {
// Don't treat these touches as pan/zoom movements since 'touch-action' value
// requires it.
SetState(NOTHING);
}
} else if (aBehavior & AllowedTouchBehavior::VERTICAL_PAN) {
if (IsCloseToVertical(aAngle, ALLOWED_DIRECT_PAN_ANGLE)) {
mX.SetScrollingDisabled(true);
SetState(PANNING_LOCKED_Y);
mPanDirRestricted = true;
} else {
SetState(NOTHING);
}
} else {
SetState(NOTHING);
}
}
void AsyncPanZoomController::HandlePanning(double aAngle) {
if (!gCrossSlideEnabled && (!mX.Scrollable() || !mY.Scrollable())) {
SetState(PANNING);
} else if (IsCloseToHorizontal(aAngle, AXIS_LOCK_ANGLE)) {
mY.SetScrollingDisabled(true);
if (mX.Scrollable()) {
SetState(PANNING_LOCKED_X);
} else {
SetState(CROSS_SLIDING_X);
mX.SetScrollingDisabled(true);
}
} else if (IsCloseToVertical(aAngle, AXIS_LOCK_ANGLE)) {
mX.SetScrollingDisabled(true);
if (mY.Scrollable()) {
SetState(PANNING_LOCKED_Y);
} else {
SetState(CROSS_SLIDING_Y);
mY.SetScrollingDisabled(true);
}
} else {
SetState(PANNING);
}
}
nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent) {
ReentrantMonitorAutoEnter lock(mMonitor);
@ -947,37 +1072,21 @@ nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent
mY.StartTouch(point.y);
mLastEventTime = aEvent.mTime;
if (GetAxisLockMode() == FREE) {
SetState(PANNING);
return nsEventStatus_eConsumeNoDefault;
}
double angle = atan2(dy, dx); // range [-pi, pi]
angle = fabs(angle); // range [0, pi]
if (!gCrossSlideEnabled && (!mX.Scrollable() || !mY.Scrollable())) {
SetState(PANNING);
} else if (IsCloseToHorizontal(angle, AXIS_LOCK_ANGLE)) {
mY.SetScrollingDisabled(true);
if (mX.Scrollable()) {
SetState(PANNING_LOCKED_X);
} else {
SetState(CROSS_SLIDING_X);
mX.SetScrollingDisabled(true);
}
} else if (IsCloseToVertical(angle, AXIS_LOCK_ANGLE)) {
mX.SetScrollingDisabled(true);
if (mY.Scrollable()) {
SetState(PANNING_LOCKED_Y);
} else {
SetState(CROSS_SLIDING_Y);
mY.SetScrollingDisabled(true);
}
if (mTouchActionPropertyEnabled) {
HandlePanningWithTouchAction(angle, GetTouchBehavior(0));
} else {
SetState(PANNING);
if (GetAxisLockMode() == FREE) {
SetState(PANNING);
return nsEventStatus_eConsumeNoDefault;
}
HandlePanning(angle);
}
// Don't consume an event that starts a cross-slide.
// Don't consume an event that didn't trigger a panning.
return IsPanningState(mState) ? nsEventStatus_eConsumeNoDefault
: nsEventStatus_eIgnore;
}
@ -1060,7 +1169,7 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
}
// If we're axis-locked, check if the user is trying to break the lock
if (GetAxisLockMode() == STICKY) {
if (GetAxisLockMode() == STICKY && !mPanDirRestricted) {
ScreenIntPoint point = GetFirstTouchScreenPoint(aEvent);
float dx = mX.PanDistance(point.x);
float dy = mY.PanDistance(point.y);
@ -1583,25 +1692,40 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
}
void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) {
if (!mFrameMetrics.mMayHaveTouchListeners) {
mTouchQueue.Clear();
mPreventDefaultSet = true;
mPreventDefault = aPreventDefault;
CheckContentResponse();
}
void AsyncPanZoomController::CheckContentResponse() {
bool canProceedToTouchState = true;
if (mFrameMetrics.mMayHaveTouchListeners) {
canProceedToTouchState &= mPreventDefaultSet;
}
if (mTouchActionPropertyEnabled) {
canProceedToTouchState &= mAllowedTouchBehaviorSet;
}
if (!canProceedToTouchState) {
return;
}
if (mTouchListenerTimeoutTask) {
mTouchListenerTimeoutTask->Cancel();
mTouchListenerTimeoutTask = nullptr;
if (mContentResponseTimeoutTask) {
mContentResponseTimeoutTask->Cancel();
mContentResponseTimeoutTask = nullptr;
}
if (mState == WAITING_LISTENERS) {
if (!aPreventDefault) {
if (mState == WAITING_CONTENT_RESPONSE) {
if (!mPreventDefault) {
SetState(NOTHING);
}
mHandlingTouchQueue = true;
while (!mTouchQueue.IsEmpty()) {
if (!aPreventDefault) {
if (!mPreventDefault) {
HandleInputEvent(mTouchQueue[0]);
}
@ -1618,6 +1742,45 @@ void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) {
}
}
bool AsyncPanZoomController::TouchActionAllowZoom() {
if (!mTouchActionPropertyEnabled) {
return true;
}
// Pointer events specification implies all touch points to allow zoom
// to perform it.
for (size_t i = 0; i < mAllowedTouchBehaviors.Length(); i++) {
if (!(mAllowedTouchBehaviors[i] & AllowedTouchBehavior::ZOOM)) {
return false;
}
}
return true;
}
AsyncPanZoomController::TouchBehaviorFlags
AsyncPanZoomController::GetTouchBehavior(uint32_t touchIndex) {
if (touchIndex < mAllowedTouchBehaviors.Length()) {
return mAllowedTouchBehaviors[touchIndex];
}
return DefaultTouchBehavior;
}
AsyncPanZoomController::TouchBehaviorFlags
AsyncPanZoomController::GetAllowedTouchBehavior(ScreenIntPoint& aPoint) {
// Here we need to perform a hit testing over the touch-action regions attached to the
// layer associated with current apzc.
// Currently they are in progress, for more info see bug 928833.
return AllowedTouchBehavior::UNKNOWN;
}
void AsyncPanZoomController::SetAllowedTouchBehavior(const nsTArray<TouchBehaviorFlags>& aBehaviors) {
mAllowedTouchBehaviors.Clear();
mAllowedTouchBehaviors.AppendElements(aBehaviors);
mAllowedTouchBehaviorSet = true;
CheckContentResponse();
}
void AsyncPanZoomController::SetState(PanZoomState aNewState) {
PanZoomState oldState;
@ -1641,15 +1804,15 @@ void AsyncPanZoomController::SetState(PanZoomState aNewState) {
}
bool AsyncPanZoomController::IsTransformingState(PanZoomState aState) {
return !(aState == NOTHING || aState == TOUCHING || aState == WAITING_LISTENERS);
return !(aState == NOTHING || aState == TOUCHING || aState == WAITING_CONTENT_RESPONSE);
}
bool AsyncPanZoomController::IsPanningState(PanZoomState aState) {
return (aState == PANNING || aState == PANNING_LOCKED_X || aState == PANNING_LOCKED_Y);
}
void AsyncPanZoomController::TimeoutTouchListeners() {
mTouchListenerTimeoutTask = nullptr;
void AsyncPanZoomController::TimeoutContentResponse() {
mContentResponseTimeoutTask = nullptr;
ContentReceivedTouch(false);
}

View File

@ -65,6 +65,7 @@ class AsyncPanZoomController {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncPanZoomController)
typedef mozilla::MonitorAutoLock MonitorAutoLock;
typedef uint32_t TouchBehaviorFlags;
public:
enum GestureBehavior {
@ -292,6 +293,24 @@ public:
void AttemptScroll(const ScreenPoint& aStartPoint, const ScreenPoint& aEndPoint,
uint32_t aOverscrollHandoffChainIndex = 0);
/**
* Returns allowed touch behavior for the given point on the scrollable layer.
* Internally performs a kind of hit testing based on the regions constructed
* on the main thread and attached to the current scrollable layer. Each of such regions
* contains info about allowed touch behavior. If regions info isn't enough it returns
* UNKNOWN value and we should switch to the fallback approach - asking content.
* TODO: for now it's only a stub and returns hardcoded magic value. As soon as bug 928833
* is done we should integrate its logic here.
*/
TouchBehaviorFlags GetAllowedTouchBehavior(ScreenIntPoint& aPoint);
/**
* Sets allowed touch behavior for current touch session.
* This method is invoked by the APZCTreeManager which in its turn invoked by
* the widget after performing touch-action values retrieving.
*/
void SetAllowedTouchBehavior(const nsTArray<TouchBehaviorFlags>& aBehaviors);
/**
* A helper function for calling APZCTreeManager::DispatchScroll().
* Guards against the case where the APZC is being concurrently destroyed
@ -422,6 +441,16 @@ protected:
*/
ScreenIntPoint& GetFirstTouchScreenPoint(const MultiTouchInput& aEvent);
/**
* Sets the panning state basing on the pan direction angle and current touch-action value.
*/
void HandlePanningWithTouchAction(double angle, TouchBehaviorFlags value);
/**
* Sets the panning state ignoring the touch action value.
*/
void HandlePanning(double angle);
/**
* Sets up anything needed for panning. This takes us out of the "TOUCHING"
* state and starts actually panning us.
@ -470,13 +499,13 @@ protected:
const FrameMetrics& GetFrameMetrics();
/**
* Timeout function for touch listeners. This should be called on a timer
* Timeout function for content response. This should be called on a timer
* after we get our first touch event in a batch, under the condition that we
* have touch listeners. If a notification comes indicating whether or not
* content preventDefaulted a series of touch events before the timeout, the
* timeout should be cancelled.
* waiting for response from content. If a notification comes indicating whether or not
* content preventDefaulted a series of touch events and touch behavior values are
* set before the timeout, the timeout should be cancelled.
*/
void TimeoutTouchListeners();
void TimeoutContentResponse();
/**
* Timeout function for mozbrowserasyncscroll event. Because we throttle
@ -488,26 +517,48 @@ protected:
private:
enum PanZoomState {
NOTHING, /* no touch-start events received */
FLING, /* all touches removed, but we're still scrolling page */
TOUCHING, /* one touch-start event received */
NOTHING, /* no touch-start events received */
FLING, /* all touches removed, but we're still scrolling page */
TOUCHING, /* one touch-start event received */
PANNING, /* panning the frame */
PANNING_LOCKED_X, /* touch-start followed by move (i.e. panning with axis lock) X axis */
PANNING_LOCKED_Y, /* as above for Y axis */
PANNING, /* panning the frame */
PANNING_LOCKED_X, /* touch-start followed by move (i.e. panning with axis lock) X axis */
PANNING_LOCKED_Y, /* as above for Y axis */
CROSS_SLIDING_X, /* Panning disabled while user does a horizontal gesture
on a vertically-scrollable view. This used for the
Windows Metro "cross-slide" gesture. */
CROSS_SLIDING_Y, /* as above for Y axis */
CROSS_SLIDING_X, /* Panning disabled while user does a horizontal gesture
on a vertically-scrollable view. This used for the
Windows Metro "cross-slide" gesture. */
CROSS_SLIDING_Y, /* as above for Y axis */
PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */
ANIMATING_ZOOM, /* animated zoom to a new rect */
WAITING_LISTENERS, /* a state halfway between NOTHING and TOUCHING - the user has
put a finger down, but we don't yet know if a touch listener has
prevented the default actions yet. we still need to abort animations. */
PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */
ANIMATING_ZOOM, /* animated zoom to a new rect */
WAITING_CONTENT_RESPONSE, /* a state halfway between NOTHING and TOUCHING - the user has
put a finger down, but we don't yet know if a touch listener has
prevented the default actions yet and the allowed touch behavior
was not set yet. we still need to abort animations. */
};
/*
* Returns whether current touch behavior values allow zooming.
*/
bool TouchActionAllowZoom();
/*
* Returns allowed touch behavior from the mAllowedTouchBehavior array.
* In case apzc didn't receive touch behavior values within the timeout
* it returns default value.
*/
TouchBehaviorFlags GetTouchBehavior(uint32_t touchIndex);
/**
* To move from the WAITING_CONTENT_RESPONSE state to TOUCHING one we need two
* conditions set: get content listeners response (whether they called preventDefault)
* and get allowed touch behaviors.
* This method checks both conditions and changes (or not changes) state
* appropriately.
*/
void CheckContentResponse();
/**
* Helper to set the current state. Holds the monitor before actually setting
* it and fires content controller events based on state changes. Always set
@ -564,6 +615,12 @@ protected:
// function can be used, or the monitor can be held and then |mState| updated.
ReentrantMonitor mMonitor;
// Specifies whether we should use touch-action css property. Initialized from
// the preferences. This property (in comparison with the global one) simplifies
// testing apzc with (and without) touch-action property enabled concurrently
// (e.g. with the gtest framework).
bool mTouchActionPropertyEnabled;
private:
// Metrics of the container layer corresponding to this APZC. This is
// stored here so that it is accessible from the UI/controller thread.
@ -579,11 +636,15 @@ private:
nsTArray<MultiTouchInput> mTouchQueue;
CancelableTask* mTouchListenerTimeoutTask;
CancelableTask* mContentResponseTimeoutTask;
AxisX mX;
AxisY mY;
// This flag is set to true when we are in a axis-locked pan as a result of
// the touch-action CSS property.
bool mPanDirRestricted;
// Most up-to-date constraints on zooming. These should always be reasonable
// values; for example, allowing a min zoom of 0.0 can cause very bad things
// to happen.
@ -622,6 +683,22 @@ private:
// and we don't want to queue the events back up again.
bool mHandlingTouchQueue;
// Values of allowed touch behavior for current touch points.
// Since there are maybe a few current active touch points per time (multitouch case)
// and each touch point should have its own value of allowed touch behavior- we're
// keeping an array of allowed touch behavior values, not the single value.
nsTArray<TouchBehaviorFlags> mAllowedTouchBehaviors;
// Specifies whether mAllowedTouchBehaviors is set for current touch events block.
bool mAllowedTouchBehaviorSet;
// Flag used to specify that content prevented the default behavior of the current
// touch events block.
bool mPreventDefault;
// Specifies whether mPreventDefault property is set for current touch events block.
bool mPreventDefaultSet;
RefPtr<AsyncPanZoomAnimation> mAnimation;
friend class Axis;

View File

@ -75,13 +75,13 @@ SharedPlanarYCbCrImage::GetBuffer()
}
already_AddRefed<gfxASurface>
SharedPlanarYCbCrImage::GetAsSurface()
SharedPlanarYCbCrImage::DeprecatedGetAsSurface()
{
if (!mTextureClient->IsAllocated()) {
NS_WARNING("Can't get as surface");
return nullptr;
}
return PlanarYCbCrImage::GetAsSurface();
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
void

View File

@ -39,13 +39,13 @@ public:
return this;
}
virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE
{
if (!mAllocated) {
NS_WARNING("Can't get as surface");
return nullptr;
}
return PlanarYCbCrImage::GetAsSurface();
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
@ -100,7 +100,7 @@ public:
virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
virtual void SetDataNoCopy(const Data &aData) MOZ_OVERRIDE;

View File

@ -131,7 +131,7 @@ DeprecatedSharedRGBImage::AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageF
}
already_AddRefed<gfxASurface>
DeprecatedSharedRGBImage::GetAsSurface()
DeprecatedSharedRGBImage::DeprecatedGetAsSurface()
{
return nullptr;
}
@ -235,7 +235,7 @@ SharedRGBImage::GetTextureClient()
}
already_AddRefed<gfxASurface>
SharedRGBImage::GetAsSurface()
SharedRGBImage::DeprecatedGetAsSurface()
{
return nullptr;
}

View File

@ -60,7 +60,7 @@ public:
size_t GetBufferSize();
static uint8_t BytesPerPixel(gfxImageFormat aImageFormat);
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
/**
* Setup the Surface descriptor to contain this image's shmem, while keeping
@ -117,7 +117,7 @@ public:
size_t GetBufferSize();
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
private:

View File

@ -21,8 +21,9 @@ using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::layers;
using ::testing::_;
using ::testing::NiceMock;
using ::testing::NiceMock;
using ::testing::AtLeast;
using ::testing::AtMost;
class Task;
@ -72,6 +73,15 @@ public:
: AsyncPanZoomController(aLayersId, aTreeManager, aMcc, aBehavior)
{}
// Since touch-action-enabled property is global - setting it for each test
// separately isn't safe from the concurrency point of view. To make tests
// run concurrent and independent from each other we have a member variable
// mTouchActionEnabled for each apzc and setter defined here.
void SetTouchActionEnabled(const bool touchActionEnabled) {
ReentrantMonitorAutoEnter lock(mMonitor);
mTouchActionPropertyEnabled = touchActionEnabled;
}
void SetFrameMetrics(const FrameMetrics& metrics) {
ReentrantMonitorAutoEnter lock(mMonitor);
mFrameMetrics = metrics;
@ -107,8 +117,12 @@ FrameMetrics TestFrameMetrics() {
return fm;
}
/*
* Dispatches mock touch events to the apzc and checks whether apzc properly
* consumed them and triggered scrolling behavior.
*/
static
void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, int& aTime, int aTouchStartY, int aTouchEndY) {
void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, int& aTime, int aTouchStartY, int aTouchEndY, bool expectIgnoredPan = false) {
const int TIME_BETWEEN_TOUCH_EVENT = 100;
const int OVERCOME_TOUCH_TOLERANCE = 100;
@ -128,18 +142,27 @@ void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, in
EXPECT_EQ(status, nsEventStatus_eConsumeNoDefault);
// APZC should be in TOUCHING state
nsEventStatus touchMoveStatus;
if (expectIgnoredPan) {
// APZC should ignore panning, be in TOUCHING state and therefore return eIgnore.
// The same applies to all consequent touch move events.
touchMoveStatus = nsEventStatus_eIgnore;
} else {
// APZC should go into the panning state and therefore consume the event.
touchMoveStatus = nsEventStatus_eConsumeNoDefault;
}
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime, 0);
aTime += TIME_BETWEEN_TOUCH_EVENT;
mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(10, aTouchStartY), ScreenSize(0, 0), 0, 0));
status = apzc->HandleInputEvent(mti);
EXPECT_EQ(status, nsEventStatus_eConsumeNoDefault);
// APZC should be in PANNING, otherwise status != ConsumeNoDefault
EXPECT_EQ(status, touchMoveStatus);
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime, 0);
aTime += TIME_BETWEEN_TOUCH_EVENT;
mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(10, aTouchEndY), ScreenSize(0, 0), 0, 0));
status = apzc->HandleInputEvent(mti);
EXPECT_EQ(status, nsEventStatus_eConsumeNoDefault);
EXPECT_EQ(status, touchMoveStatus);
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime, 0);
aTime += TIME_BETWEEN_TOUCH_EVENT;
@ -147,6 +170,59 @@ void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, in
status = apzc->HandleInputEvent(mti);
}
static
void DoPanTest(bool aShouldTriggerScroll, bool aShouldUseTouchAction, uint32_t aBehavior)
{
TimeStamp testStartTime = TimeStamp::Now();
AsyncPanZoomController::SetFrameTime(testStartTime);
nsRefPtr<MockContentController> mcc = new NiceMock<MockContentController>();
nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc, tm);
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
apzc->SetFrameMetrics(TestFrameMetrics());
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
if (aShouldTriggerScroll) {
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(AtLeast(1));
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
} else {
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(0);
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
}
int time = 0;
int touchStart = 50;
int touchEnd = 10;
ScreenPoint pointOut;
ViewTransform viewTransformOut;
nsTArray<uint32_t> values;
values.AppendElement(aBehavior);
// Pan down
apzc->SetAllowedTouchBehavior(values);
ApzcPan(apzc, tm, time, touchStart, touchEnd, !aShouldTriggerScroll);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
if (aShouldTriggerScroll) {
EXPECT_EQ(pointOut, ScreenPoint(0, -(touchEnd-touchStart)));
EXPECT_NE(viewTransformOut, ViewTransform());
} else {
EXPECT_EQ(pointOut, ScreenPoint());
EXPECT_EQ(viewTransformOut, ViewTransform());
}
// Pan back
apzc->SetAllowedTouchBehavior(values);
ApzcPan(apzc, tm, time, touchEnd, touchStart, !aShouldTriggerScroll);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
EXPECT_EQ(pointOut, ScreenPoint());
EXPECT_EQ(viewTransformOut, ViewTransform());
}
static void
ApzcPinch(AsyncPanZoomController* aApzc, int aFocusX, int aFocusY, float aScale) {
aApzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_START,
@ -241,6 +317,40 @@ TEST(AsyncPanZoomController, Pinch) {
EXPECT_EQ(fm.mScrollOffset.y, 0);
}
TEST(AsyncPanZoomController, PinchWithTouchActionNone) {
nsRefPtr<MockContentController> mcc = new NiceMock<MockContentController>();
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc);
FrameMetrics fm;
fm.mViewport = CSSRect(0, 0, 980, 480);
fm.mCompositionBounds = ScreenIntRect(200, 200, 100, 200);
fm.mScrollableRect = CSSRect(0, 0, 980, 1000);
fm.mScrollOffset = CSSPoint(300, 300);
fm.mZoom = CSSToScreenScale(2.0);
apzc->SetFrameMetrics(fm);
// the visible area of the document in CSS pixels is x=300 y=300 w=50 h=100
// Apzc's OnScaleEnd method calls once SendAsyncScrollDOMEvent and RequestContentRepaint methods,
// therefore we're setting these specific values.
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(AtMost(1));
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtMost(1));
nsTArray<uint32_t> values;
values.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
values.AppendElement(mozilla::layers::AllowedTouchBehavior::ZOOM);
apzc->SetTouchActionEnabled(true);
apzc->SetAllowedTouchBehavior(values);
ApzcPinch(apzc, 250, 300, 1.25);
// The frame metrics should stay the same since touch-action:none makes
// apzc ignore pinch gestures.
fm = apzc->GetFrameMetrics();
EXPECT_EQ(fm.mZoom.scale, 2.0f);
EXPECT_EQ(fm.mScrollOffset.x, 300);
EXPECT_EQ(fm.mScrollOffset.y, 300);
}
TEST(AsyncPanZoomController, Overzoom) {
nsRefPtr<MockContentController> mcc = new NiceMock<MockContentController>();
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc);
@ -389,36 +499,29 @@ TEST(AsyncPanZoomController, ComplexTransform) {
}
TEST(AsyncPanZoomController, Pan) {
TimeStamp testStartTime = TimeStamp::Now();
AsyncPanZoomController::SetFrameTime(testStartTime);
DoPanTest(true, false, mozilla::layers::AllowedTouchBehavior::NONE);
}
nsRefPtr<MockContentController> mcc = new NiceMock<MockContentController>();
nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc, tm);
// In the each of the following 4 pan tests we are performing two pan gestures: vertical pan from top
// to bottom and back - from bottom to top.
// According to the pointer-events/touch-action spec AUTO and PAN_Y touch-action values allow vertical
// scrolling while NONE and PAN_X forbid it. The first parameter of DoPanTest method specifies this
// behavior.
TEST(AsyncPanZoomController, PanWithTouchActionAuto) {
DoPanTest(true, true,
mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN | mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
}
apzc->SetFrameMetrics(TestFrameMetrics());
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
TEST(AsyncPanZoomController, PanWithTouchActionNone) {
DoPanTest(false, true, 0);
}
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(AtLeast(1));
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
TEST(AsyncPanZoomController, PanWithTouchActionPanX) {
DoPanTest(false, true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN);
}
int time = 0;
int touchStart = 50;
int touchEnd = 10;
ScreenPoint pointOut;
ViewTransform viewTransformOut;
// Pan down
ApzcPan(apzc, tm, time, touchStart, touchEnd);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
EXPECT_EQ(pointOut, ScreenPoint(0, -(touchEnd-touchStart)));
EXPECT_NE(viewTransformOut, ViewTransform());
// Pan back
ApzcPan(apzc, tm, time, touchEnd, touchStart);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
EXPECT_EQ(pointOut, ScreenPoint());
EXPECT_EQ(viewTransformOut, ViewTransform());
TEST(AsyncPanZoomController, PanWithTouchActionPanY) {
DoPanTest(true, true, mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
}
TEST(AsyncPanZoomController, Fling) {

View File

@ -815,7 +815,7 @@ static char *
QuoteString(Sprinter *sp, JSString *str, uint32_t quote);
static bool
ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
ToDisassemblySource(JSContext *cx, HandleValue v, JSAutoByteString *bytes)
{
if (JSVAL_IS_STRING(v)) {
Sprinter sprinter(cx);
@ -941,7 +941,8 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
}
case JOF_SCOPECOORD: {
Value v = StringValue(ScopeCoordinateName(cx->runtime()->scopeCoordinateNameCache, script, pc));
RootedValue v(cx,
StringValue(ScopeCoordinateName(cx->runtime()->scopeCoordinateNameCache, script, pc)));
JSAutoByteString bytes;
if (!ToDisassemblySource(cx, v, &bytes))
return 0;
@ -951,7 +952,7 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
}
case JOF_ATOM: {
Value v = StringValue(script->getAtom(GET_UINT32_INDEX(pc)));
RootedValue v(cx, StringValue(script->getAtom(GET_UINT32_INDEX(pc))));
JSAutoByteString bytes;
if (!ToDisassemblySource(cx, v, &bytes))
return 0;
@ -960,7 +961,7 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
}
case JOF_DOUBLE: {
Value v = script->getConst(GET_UINT32_INDEX(pc));
RootedValue v(cx, script->getConst(GET_UINT32_INDEX(pc)));
JSAutoByteString bytes;
if (!ToDisassemblySource(cx, v, &bytes))
return 0;
@ -978,7 +979,8 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
JSObject *obj = script->getObject(GET_UINT32_INDEX(pc));
{
JSAutoByteString bytes;
if (!ToDisassemblySource(cx, ObjectValue(*obj), &bytes))
RootedValue v(cx, ObjectValue(*obj));
if (!ToDisassemblySource(cx, v, &bytes))
return 0;
Sprint(sp, " %s", bytes.ptr());
}
@ -988,7 +990,8 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
case JOF_REGEXP: {
JSObject *obj = script->getRegExp(GET_UINT32_INDEX(pc));
JSAutoByteString bytes;
if (!ToDisassemblySource(cx, ObjectValue(*obj), &bytes))
RootedValue v(cx, ObjectValue(*obj));
if (!ToDisassemblySource(cx, v, &bytes))
return 0;
Sprint(sp, " %s", bytes.ptr());
break;
@ -1026,7 +1029,8 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
Sprint(sp, " %u", GET_SLOTNO(pc));
JSObject *obj = script->getObject(GET_UINT32_INDEX(pc + SLOTNO_LEN));
JSAutoByteString bytes;
if (!ToDisassemblySource(cx, ObjectValue(*obj), &bytes))
RootedValue v(cx, ObjectValue(*obj));
if (!ToDisassemblySource(cx, v, &bytes))
return 0;
Sprint(sp, " %s", bytes.ptr());
break;

View File

@ -347,11 +347,15 @@ else:
]
if CONFIG['ENABLE_ION'] or CONFIG['ENABLE_YARR_JIT']:
SOURCES += [
'assembler/assembler/ARMAssembler.cpp',
'assembler/assembler/MacroAssemblerARM.cpp',
'assembler/assembler/MacroAssemblerX86Common.cpp',
]
if '86' in CONFIG['TARGET_CPU']:
SOURCES += [
'assembler/assembler/MacroAssemblerX86Common.cpp',
]
elif CONFIG['CPU_ARCH'] == 'arm':
SOURCES += [
'assembler/assembler/ARMAssembler.cpp',
'assembler/assembler/MacroAssemblerARM.cpp',
]
if CONFIG['ENABLE_YARR_JIT']:
SOURCES += [

View File

@ -84,8 +84,8 @@ static bool
#endif
LooseEqualityOp(JSContext *cx, FrameRegs &regs)
{
Value rval = regs.sp[-1];
Value lval = regs.sp[-2];
HandleValue rval = regs.stackHandleAt(-1);
HandleValue lval = regs.stackHandleAt(-2);
bool cond;
if (!LooselyEqual(cx, lval, rval, &cond))
return false;

View File

@ -779,14 +779,14 @@ JSRuntime::initSelfHosting(JSContext *cx)
* and we don't want errors in self-hosted code to be silently swallowed.
*/
JSErrorReporter oldReporter = JS_SetErrorReporter(cx, selfHosting_ErrorReporter);
Value rv;
RootedValue rv(cx);
bool ok = false;
char *filename = getenv("MOZ_SELFHOSTEDJS");
if (filename) {
RootedScript script(cx, Compile(cx, shg, options, filename));
if (script)
ok = Execute(cx, script, *shg.get(), &rv);
ok = Execute(cx, script, *shg.get(), rv.address());
} else {
uint32_t srcLen = GetRawScriptsSize();
@ -803,7 +803,7 @@ JSRuntime::initSelfHosting(JSContext *cx)
const char *src = rawSources;
#endif
ok = Evaluate(cx, shg, options, src, srcLen, &rv);
ok = Evaluate(cx, shg, options, src, srcLen, rv.address());
}
JS_SetErrorReporter(cx, oldReporter);
if (receivesDefaultObject)

View File

@ -809,7 +809,8 @@ JSStructuredCloneWriter::writeTypedArray(HandleObject obj)
return false;
// Write out the ArrayBuffer tag and contents
if (!startWrite(TypedArrayObject::bufferValue(tarr)))
RootedValue val(context(), TypedArrayObject::bufferValue(tarr));
if (!startWrite(val))
return false;
return out.write(tarr->byteOffset());

View File

@ -4672,7 +4672,7 @@ nsCSSFrameConstructor::FindMathMLData(Element* aElement,
SIMPLE_MATHML_CREATE(mprescripts_, NS_NewMathMLmspaceFrame),
SIMPLE_MATHML_CREATE(mfenced_, NS_NewMathMLmfencedFrame),
SIMPLE_MATHML_CREATE(mmultiscripts_, NS_NewMathMLmmultiscriptsFrame),
SIMPLE_MATHML_CREATE(mstyle_, NS_NewMathMLmstyleFrame),
SIMPLE_MATHML_CREATE(mstyle_, NS_NewMathMLmrowFrame),
SIMPLE_MATHML_CREATE(msqrt_, NS_NewMathMLmsqrtFrame),
SIMPLE_MATHML_CREATE(mroot_, NS_NewMathMLmrootFrame),
SIMPLE_MATHML_CREATE(maction_, NS_NewMathMLmactionFrame),

View File

@ -129,10 +129,10 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
// 0e4f2b36-7ab8-43c5-b912-5c311566297c
// db8d5e1e-6392-4ec1-9a29-18ee2ec0889b
#define NS_IPRESSHELL_IID \
{ 0xde498c49, 0xf83f, 0x47bf, \
{0x8c, 0xc6, 0x8f, 0xf8, 0x74, 0x62, 0x22, 0x23 } }
{ 0xdb8d5e1e, 0x6392, 0x4ec1, \
{0x9a, 0x29, 0x18, 0xee, 0x2e, 0xc0, 0x88, 0x9b}}
// debug VerifyReflow flags
#define VERIFY_REFLOW_ON 0x01
@ -1255,6 +1255,7 @@ public:
gfxSize GetResolution() { return gfxSize(mXResolution, mYResolution); }
float GetXResolution() { return mXResolution; }
float GetYResolution() { return mYResolution; }
virtual gfxSize GetCumulativeResolution() = 0;
/**
* Returns whether we are in a DrawWindow() call that used the

View File

@ -4995,7 +4995,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement,
return result;
mozilla::gfx::IntSize size;
nsRefPtr<gfxASurface> surf = container->GetCurrentAsSurface(&size);
nsRefPtr<gfxASurface> surf = container->DeprecatedGetCurrentAsSurface(&size);
if (!surf)
return result;

View File

@ -5205,7 +5205,17 @@ nsresult PresShell::SetResolution(float aXResolution, float aYResolution)
state.mYResolution = aYResolution;
SetRenderingState(state);
return NS_OK;
}
}
gfxSize PresShell::GetCumulativeResolution()
{
gfxSize resolution = GetResolution();
nsCOMPtr<nsIPresShell> parent = GetParentPresShell();
if (parent) {
resolution = resolution * parent->GetCumulativeResolution();
}
return resolution;
}
void PresShell::SetRenderingState(const RenderingState& aState)
{

View File

@ -180,6 +180,7 @@ public:
virtual void SetDisplayPort(const nsRect& aDisplayPort);
virtual nsresult SetResolution(float aXResolution, float aYResolution) MOZ_OVERRIDE;
virtual gfxSize GetCumulativeResolution() MOZ_OVERRIDE;
//nsIViewObserver interface

View File

@ -3,7 +3,7 @@
* 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 "MathVariantTextRunFactory.h"
#include "MathMLTextRunFactory.h"
#include "mozilla/ArrayUtils.h"
@ -517,8 +517,8 @@ MathVariant(uint32_t aCh, uint8_t aMathVar)
}
void
nsMathVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext)
MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext)
{
gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
gfxFontStyle fontStyle = *fontGroup->GetStyle();
@ -537,6 +537,56 @@ nsMathVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
const char16_t* str = aTextRun->mString.BeginReading();
nsRefPtr<nsStyleContext>* styles = aTextRun->mStyles.Elements();
if (mSSTYScriptLevel && length) {
bool found = false;
// We respect ssty settings explicitly set by the user
for (uint32_t i = 0; i < fontStyle.featureSettings.Length(); i++) {
if (fontStyle.featureSettings[i].mTag == TRUETYPE_TAG('s','s','t','y')) {
found = true;
break;
}
}
if (!found) {
uint8_t sstyLevel = 0;
float scriptScaling = pow(styles[0]->StyleFont()->mScriptSizeMultiplier,
mSSTYScriptLevel);
static_assert(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER < 1,
"Shouldn't it make things smaller?");
/*
An SSTY level of 2 is set if the scaling factor is less than or equal
to halfway between that for a scriptlevel of 1 (0.71) and that of a
scriptlevel of 2 (0.71^2), assuming the default script size multiplier.
An SSTY level of 1 is set if the script scaling factor is less than
or equal that for a scriptlevel of 1 assuming the default script size
multiplier.
User specified values of script size multiplier will change the scaling
factor which mSSTYScriptLevel values correspond to.
In the event that the script size multiplier actually makes things
larger, no change is made.
If the user doesn't want this to happen, all they need to do is set
style="-moz-font-feature-settings: 'ssty' 0"
*/
if (scriptScaling <= (NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER +
(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER*
NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER))/2) {
// Currently only the first two ssty settings are used, so two is large
// as we go
sstyLevel = 2;
} else if (scriptScaling <= NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER) {
sstyLevel = 1;
}
if (sstyLevel) {
gfxFontFeature settingSSTY;
settingSSTY.mTag = TRUETYPE_TAG('s','s','t','y');
settingSSTY.mValue = sstyLevel;
fontStyle.featureSettings.AppendElement(settingSSTY);
}
}
}
uint8_t mathVar;
bool doMathvariantStyling = true;
@ -613,8 +663,10 @@ nsMathVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
doMathvariantStyling) {
fontStyle.style = NS_FONT_STYLE_ITALIC;
fontStyle.weight = NS_FONT_WEIGHT_BOLD;
} else {
} else if (mathVar != NS_MATHML_MATHVARIANT_NONE) {
// Mathvariant overrides fontstyle and fontweight
// Need to check to see if mathvariant is actually applied as this function
// is used for other purposes.
fontStyle.style = NS_FONT_STYLE_NORMAL;
fontStyle.weight = NS_FONT_WEIGHT_NORMAL;
}

View File

@ -3,23 +3,26 @@
* 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/. */
#ifndef MATHVARIANTTEXTRUNFACTORY_H_
#define MATHVARIANTTEXTRUNFACTORY_H_
#ifndef MATHMLTEXTRUNFACTORY_H_
#define MATHMLTEXTRUNFACTORY_H_
#include "nsTextRunTransformations.h"
/**
* Builds textruns that render their text using a mathvariant
* Builds textruns that render their text with MathML specific renderings.
*/
class nsMathVariantTextRunFactory : public nsTransformingTextRunFactory {
class MathMLTextRunFactory : public nsTransformingTextRunFactory {
public:
nsMathVariantTextRunFactory(nsTransformingTextRunFactory* aInnerTransformingTextRunFactory)
: mInnerTransformingTextRunFactory(aInnerTransformingTextRunFactory) {}
MathMLTextRunFactory(nsTransformingTextRunFactory* aInnerTransformingTextRunFactory,
uint8_t aSSTYScriptLevel)
: mInnerTransformingTextRunFactory(aInnerTransformingTextRunFactory),
mSSTYScriptLevel(aSSTYScriptLevel) {}
virtual void RebuildTextRun(nsTransformedTextRun* aTextRun,
gfxContext* aRefContext) MOZ_OVERRIDE;
protected:
nsAutoPtr<nsTransformingTextRunFactory> mInnerTransformingTextRunFactory;
uint8_t mSSTYScriptLevel;
};
#endif /*MATHVARIANTTEXTRUNFACTORY_H_*/
#endif /*MATHMLTEXTRUNFACTORY_H_*/

View File

@ -44,7 +44,7 @@ EXPORTS.mozilla.layout += [
UNIFIED_SOURCES += [
'FrameChildList.cpp',
'MathVariantTextRunFactory.cpp',
'MathMLTextRunFactory.cpp',
'nsAbsoluteContainingBlock.cpp',
'nsBlockFrame.cpp',
'nsBlockReflowContext.cpp',

View File

@ -338,6 +338,10 @@ typedef uint64_t nsFrameState;
// Frame has a LayerActivityProperty property
#define NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY NS_FRAME_STATE_BIT(54)
// Set for all descendants of MathML sub/supscript elements (other than the
// base frame) to indicate that the SSTY font feature should be used.
#define NS_FRAME_MATHML_SCRIPT_DESCENDANT NS_FRAME_STATE_BIT(58)
// Box layout bits
#define NS_STATE_IS_HORIZONTAL NS_FRAME_STATE_BIT(22)
#define NS_STATE_IS_DIRECTION_NORMAL NS_FRAME_STATE_BIT(31)

View File

@ -38,10 +38,11 @@
#include "nsLayoutUtils.h"
#include "nsDisplayList.h"
#include "nsFrame.h"
#include "nsIMathMLFrame.h"
#include "nsPlaceholderFrame.h"
#include "nsTextFrameUtils.h"
#include "nsTextRunTransformations.h"
#include "MathVariantTextRunFactory.h"
#include "MathMLTextRunFactory.h"
#include "nsExpirationTracker.h"
#include "nsUnicodeProperties.h"
@ -1329,6 +1330,9 @@ BuildTextRuns(gfxContext* aContext, nsTextFrame* aForFrame,
if (aForFrame && aForFrame->HasAnyStateBits(TEXT_IS_IN_SINGLE_CHAR_MI)) {
aLineContainer->AddStateBits(TEXT_IS_IN_SINGLE_CHAR_MI);
}
if (aForFrame && aForFrame->HasAnyStateBits(NS_FRAME_MATHML_SCRIPT_DESCENDANT)) {
aLineContainer->AddStateBits(NS_FRAME_MATHML_SCRIPT_DESCENDANT);
}
nsPresContext* presContext = aLineContainer->PresContext();
BuildTextRunsScanner scanner(presContext, aContext, aLineContainer,
@ -1893,7 +1897,8 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
const void* textPtr = aTextBuffer;
bool anySmallcapsStyle = false;
bool anyTextTransformStyle = false;
bool anyMathVariantStyle = false;
bool anyMathMLStyling = false;
uint8_t sstyScriptLevel = 0;
uint32_t textFlags = nsTextFrameUtils::TEXT_NO_BREAKS;
if (mCurrentRunContextInfo & nsTextFrameUtils::INCOMING_WHITESPACE) {
@ -1972,10 +1977,35 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
anySmallcapsStyle = true;
}
if (NS_MATHML_MATHVARIANT_NONE != fontStyle->mMathVariant) {
anyMathVariantStyle = true;
anyMathMLStyling = true;
} else if (mLineContainer->GetStateBits() & TEXT_IS_IN_SINGLE_CHAR_MI) {
textFlags |= nsTextFrameUtils::TEXT_IS_SINGLE_CHAR_MI;
anyMathVariantStyle = true;
anyMathMLStyling = true;
}
nsIFrame* parent = mLineContainer->GetParent();
nsIFrame* child = mLineContainer;
uint8_t oldScriptLevel = 0;
while (parent &&
child->HasAnyStateBits(NS_FRAME_MATHML_SCRIPT_DESCENDANT)) {
// Reconstruct the script level ignoring any user overrides. It is
// calculated this way instead of using scriptlevel to ensure the
// correct ssty font feature setting is used even if the user sets a
// different (especially negative) scriptlevel.
nsIMathMLFrame* mathFrame= do_QueryFrame(parent);
if (mathFrame) {
sstyScriptLevel += mathFrame->ScriptIncrement(child);
}
if (sstyScriptLevel < oldScriptLevel) {
// overflow
sstyScriptLevel = UINT8_MAX;
break;
}
child = parent;
parent = parent->GetParent();
oldScriptLevel = sstyScriptLevel;
}
if (sstyScriptLevel) {
anyMathMLStyling = true;
}
// Figure out what content is included in this flow.
@ -2110,9 +2140,9 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
transformingFactory =
new nsCaseTransformTextRunFactory(transformingFactory.forget());
}
if (anyMathVariantStyle) {
if (anyMathMLStyling) {
transformingFactory =
new nsMathVariantTextRunFactory(transformingFactory.forget());
new MathMLTextRunFactory(transformingFactory.forget(), sstyScriptLevel);
}
nsTArray<nsStyleContext*> styles;
if (transformingFactory) {

View File

@ -20,7 +20,6 @@ UNIFIED_SOURCES += [
'nsMathMLmrowFrame.cpp',
'nsMathMLmspaceFrame.cpp',
'nsMathMLmsqrtFrame.cpp',
'nsMathMLmstyleFrame.cpp',
'nsMathMLmtableFrame.cpp',
'nsMathMLmunderoverFrame.cpp',
'nsMathMLOperators.cpp',
@ -29,6 +28,11 @@ UNIFIED_SOURCES += [
'nsMathMLTokenFrame.cpp',
]
EXPORTS += [
'nsIMathMLFrame.h',
'nsMathMLOperators.h'
]
FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'gklayout'

View File

@ -7,6 +7,7 @@
#define nsIMathMLFrame_h___
#include "nsQueryFrame.h"
#include "nsMathMLOperators.h"
struct nsPresentationData;
struct nsEmbellishData;
@ -192,6 +193,13 @@ public:
int32_t aLastIndex,
uint32_t aFlagsValues,
uint32_t aWhichFlags) = 0;
// If aFrame is a child frame, returns the script increment which this frame
// imposes on the specified frame, ignoring any artificial adjustments to
// scriptlevel.
// Returns 0 if the specified frame isn't a child frame.
virtual uint8_t
ScriptIncrement(nsIFrame* aFrame) = 0;
};
// struct used by a container frame to keep track of its embellishments.
@ -242,13 +250,9 @@ struct nsPresentationData {
// pick a particular child in their child list to be the base)
nsIFrame* baseFrame;
// up-pointer on the mstyle frame, if any, that defines the scope
nsIFrame* mstyle;
nsPresentationData() {
flags = 0;
baseFrame = nullptr;
mstyle = nullptr;
}
};

View File

@ -1530,6 +1530,21 @@ nsMathMLContainerFrame::TransmitAutomaticDataForMrowLikeElement()
return NS_OK;
}
/*static*/ void
nsMathMLContainerFrame::PropagateFrameFlagFor(nsIFrame* aFrame,
uint64_t aFlags)
{
if (!aFrame || !aFlags)
return;
aFrame->AddStateBits(aFlags);
nsIFrame* childFrame = aFrame->GetFirstPrincipalChild();
while (childFrame) {
PropagateFrameFlagFor(childFrame, aFlags);
childFrame = childFrame->GetNextSibling();
}
}
nsresult
nsMathMLContainerFrame::ReportErrorToConsole(const char* errorMsgId,
const char16_t** aParams,

View File

@ -151,7 +151,7 @@ public:
// 2b. If the automatic data to update affects us in some way, we ask our parent
// to re-layout its children using ReLayoutChildren(mParent);
// Therefore, there is an overhead here in that our siblings are re-laid
// too (e.g., this happens with <mstyle>, <munder>, <mover>, <munderover>).
// too (e.g., this happens with <munder>, <mover>, <munderover>).
NS_IMETHOD
AttributeChanged(int32_t aNameSpaceID,
nsIAtom* aAttribute,
@ -339,6 +339,11 @@ public:
uint32_t aFlagsValues,
uint32_t aFlagsToUpdate);
// Sets flags on aFrame and all descendant frames
static void
PropagateFrameFlagFor(nsIFrame* aFrame,
uint64_t aFlags);
// helper to let the rebuild of automatic data (presentation data
// and embellishement data) walk through a subtree that may contain
// non-MathML container frames. Note that this method re-builds the

View File

@ -41,12 +41,10 @@ nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent)
mPresentationData.flags = 0;
mPresentationData.baseFrame = nullptr;
mPresentationData.mstyle = nullptr;
// by default, just inherit the display of our parent
nsPresentationData parentData;
GetPresentationDataFrom(aParent, parentData);
mPresentationData.mstyle = parentData.mstyle;
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS;
@ -124,7 +122,6 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
// initialize OUT params
aPresentationData.flags = 0;
aPresentationData.baseFrame = nullptr;
aPresentationData.mstyle = nullptr;
nsIFrame* frame = aFrame;
while (frame) {
@ -147,7 +144,6 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
break;
if (content->Tag() == nsGkAtoms::math) {
aPresentationData.mstyle = frame->FirstContinuation();
break;
}
frame = frame->GetParent();
@ -156,41 +152,6 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
"bad MathML markup - could not find the top <math> element");
}
// helper to get an attribute from the content or the surrounding <mstyle> hierarchy
/* static */ bool
nsMathMLFrame::GetAttribute(nsIContent* aContent,
nsIFrame* aMathMLmstyleFrame,
nsIAtom* aAttributeAtom,
nsString& aValue)
{
// see if we can get the attribute from the content
if (aContent && aContent->GetAttr(kNameSpaceID_None, aAttributeAtom,
aValue)) {
return true;
}
// see if we can get the attribute from the mstyle frame
if (!aMathMLmstyleFrame) {
return false;
}
nsIFrame* mstyleParent = aMathMLmstyleFrame->GetParent();
nsPresentationData mstyleParentData;
mstyleParentData.mstyle = nullptr;
if (mstyleParent) {
nsIMathMLFrame* mathMLFrame = do_QueryFrame(mstyleParent);
if (mathMLFrame) {
mathMLFrame->GetPresentationData(mstyleParentData);
}
}
// recurse all the way up into the <mstyle> hierarchy
return GetAttribute(aMathMLmstyleFrame->GetContent(),
mstyleParentData.mstyle, aAttributeAtom, aValue);
}
/* static */ void
nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,

View File

@ -92,6 +92,12 @@ public:
return NS_OK;
}
uint8_t
ScriptIncrement(nsIFrame* aFrame) MOZ_OVERRIDE
{
return 0;
}
// helper to give a style context suitable for doing the stretching to the
// MathMLChar. Frame classes that use this should make the extra style contexts
// accessible to the Style System via Get/Set AdditionalStyleContext.
@ -128,16 +134,6 @@ public:
nsPresentationData& aPresentationData,
bool aClimbTree = true);
// helper to check if a content has an attribute. If content is nullptr or if
// the attribute is not there, check if the attribute is on the mstyle hierarchy
// @return true --if attribute exists
// false --if attribute doesn't exist
static bool
GetAttribute(nsIContent* aContent,
nsIFrame* aMathMLmstyleFrame,
nsIAtom* aAttributeAtom,
nsString& aValue);
// utilities to parse and retrieve numeric values in CSS units
// All values are stored in twips.
// @pre aLengthValue is the default length value of the attribute.

View File

@ -24,7 +24,6 @@ nsIFrame* NS_NewMathMLmsupFrame(nsIPresShell* aPresShell, nsStyleContext* aConte
nsIFrame* NS_NewMathMLmsubsupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmunderoverFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmmultiscriptsFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmstyleFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);

Some files were not shown because too many files have changed in this diff Show More