merge mozilla-inbound to mozilla-central. r=merge a=merge

MozReview-Commit-ID: 2iKvbnEUJsY
This commit is contained in:
Sebastian Hengst 2017-05-25 10:32:22 +02:00
commit 011ef9ea3e
20 changed files with 244 additions and 100 deletions

View File

@ -1347,7 +1347,7 @@ public:
sContentUnbinder = next;
next->mLast = mLast;
mLast = nullptr;
NS_DispatchToMainThread(next);
NS_IdleDispatchToCurrentThread(next.forget());
}
}
return NS_OK;
@ -1368,7 +1368,7 @@ public:
if (!sContentUnbinder) {
sContentUnbinder = new ContentUnbinder();
nsCOMPtr<nsIRunnable> e = sContentUnbinder;
NS_DispatchToMainThread(e);
NS_IdleDispatchToCurrentThread(e.forget());
}
if (sContentUnbinder->mLast->mSubtreeRoots.Length() >=

View File

@ -166,7 +166,6 @@ WebGLContext::WebGLContext()
mDitherEnabled = 1;
mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244
mScissorTestEnabled = 0;
mDepthTestEnabled = 0;
mStencilTestEnabled = 0;
if (NS_IsMainThread()) {

View File

@ -453,6 +453,7 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
mDitherEnabled = true;
mRasterizerDiscardEnabled = false;
mScissorTestEnabled = false;
mDepthTestEnabled = 0;
mGenerateMipmapHint = LOCAL_GL_DONT_CARE;
// Bindings, etc.

View File

@ -331,6 +331,7 @@ EventStateManager::EventStateManager()
"dom.w3c_pointer_events.enabled", false);
sAddedPointerEventEnabled = true;
}
WheelTransaction::InitializeStatics();
}
nsresult

View File

@ -281,7 +281,7 @@ WheelTransaction::OnFailToScrollTarget()
{
NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction");
if (Preferences::GetBool("test.mousescroll", false)) {
if (Prefs::sTestMouseScroll) {
// This event is used for automated tests, see bug 442774.
nsContentUtils::DispatchTrustedEvent(
sTargetFrame->GetContent()->OwnerDoc(),
@ -310,7 +310,7 @@ WheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure)
// the next DOM event might create strange situation for us.
MayEndTransaction();
if (Preferences::GetBool("test.mousescroll", false)) {
if (Prefs::sTestMouseScroll) {
// This event is used for automated tests, see bug 442774.
nsContentUtils::DispatchTrustedEvent(
frame->GetContent()->OwnerDoc(),
@ -346,18 +346,6 @@ WheelTransaction::GetScreenPoint(WidgetGUIEvent* aEvent)
return aEvent->mRefPoint + aEvent->mWidget->WidgetToScreenOffset();
}
/* static */ uint32_t
WheelTransaction::GetTimeoutTime()
{
return Preferences::GetUint("mousewheel.transaction.timeout", 1500);
}
/* static */ uint32_t
WheelTransaction::GetIgnoreMoveDelayTime()
{
return Preferences::GetUint("mousewheel.transaction.ignoremovedelay", 100);
}
/* static */ DeltaValues
WheelTransaction::AccelerateWheelDelta(WidgetWheelEvent* aEvent,
bool aAllowScrollSpeedOverride)
@ -392,18 +380,6 @@ WheelTransaction::ComputeAcceleratedWheelDelta(double aDelta, int32_t aFactor)
return mozilla::ComputeAcceleratedWheelDelta(aDelta, sScrollSeriesCounter, aFactor);
}
/* static */ int32_t
WheelTransaction::GetAccelerationStart()
{
return Preferences::GetInt("mousewheel.acceleration.start", -1);
}
/* static */ int32_t
WheelTransaction::GetAccelerationFactor()
{
return Preferences::GetInt("mousewheel.acceleration.factor", -1);
}
/* static */ DeltaValues
WheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
{
@ -550,4 +526,31 @@ ScrollbarsForWheel::DeactivateAllTemporarilyActivatedScrollTargets()
}
}
/******************************************************************/
/* mozilla::WheelTransaction */
/******************************************************************/
int32_t WheelTransaction::Prefs::sMouseWheelAccelerationStart = -1;
int32_t WheelTransaction::Prefs::sMouseWheelAccelerationFactor = -1;
uint32_t WheelTransaction::Prefs::sMouseWheelTransactionTimeout = 1500;
uint32_t WheelTransaction::Prefs::sMouseWheelTransactionIgnoreMoveDelay = 100;
bool WheelTransaction::Prefs::sTestMouseScroll = false;
/* static */ void
WheelTransaction::Prefs::InitializeStatics()
{
static bool sIsInitialized = false;
if (!sIsInitialized) {
Preferences::AddIntVarCache(&sMouseWheelAccelerationStart,
"mousewheel.acceleration.start", -1);
Preferences::AddIntVarCache(&sMouseWheelAccelerationFactor,
"mousewheel.acceleration.factor", -1);
Preferences::AddUintVarCache(&sMouseWheelTransactionTimeout,
"mousewheel.transaction.timeout", 1500);
Preferences::AddUintVarCache(&sMouseWheelTransactionIgnoreMoveDelay,
"mousewheel.transaction.ignoremovedelay", 100);
Preferences::AddBoolVarCache(&sTestMouseScroll, "test.mousescroll", false);
sIsInitialized = true;
}
}
} // namespace mozilla

View File

@ -143,12 +143,19 @@ public:
}
static void OnEvent(WidgetEvent* aEvent);
static void Shutdown();
static uint32_t GetTimeoutTime();
static uint32_t GetTimeoutTime()
{
return Prefs::sMouseWheelTransactionTimeout;
}
static void OwnScrollbars(bool aOwn);
static DeltaValues AccelerateWheelDelta(WidgetWheelEvent* aEvent,
bool aAllowScrollSpeedOverride);
static void InitializeStatics()
{
Prefs::InitializeStatics();
}
protected:
static void BeginTransaction(nsIFrame* aTargetFrame,
@ -162,9 +169,18 @@ protected:
static void OnFailToScrollTarget();
static void OnTimeout(nsITimer* aTimer, void* aClosure);
static void SetTimeout();
static uint32_t GetIgnoreMoveDelayTime();
static int32_t GetAccelerationStart();
static int32_t GetAccelerationFactor();
static uint32_t GetIgnoreMoveDelayTime()
{
return Prefs::sMouseWheelTransactionIgnoreMoveDelay;
}
static int32_t GetAccelerationStart()
{
return Prefs::sMouseWheelAccelerationStart;
}
static int32_t GetAccelerationFactor()
{
return Prefs::sMouseWheelAccelerationFactor;
}
static DeltaValues OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent);
static double ComputeAcceleratedWheelDelta(double aDelta, int32_t aFactor);
static bool OutOfTime(uint32_t aBaseTime, uint32_t aThreshold);
@ -175,6 +191,17 @@ protected:
static nsITimer* sTimer;
static int32_t sScrollSeriesCounter;
static bool sOwnScrollbars;
class Prefs
{
public:
static void InitializeStatics();
static int32_t sMouseWheelAccelerationStart;
static int32_t sMouseWheelAccelerationFactor;
static uint32_t sMouseWheelTransactionTimeout;
static uint32_t sMouseWheelTransactionIgnoreMoveDelay;
static bool sTestMouseScroll;
};
};
} // namespace mozilla

View File

@ -169,6 +169,8 @@ parent:
// Used to broker the GetOpenFileName/GetSaveFileName file pickers on Windows.
intr GetFileName(GetFileNameFunc aFunc, OpenFileNameIPC aOfnIn)
returns (OpenFileNameRetIPC aOfnOut, bool aResult);
intr SetCursorPos(int x, int y) returns (bool aResult);
};
} // namespace plugins

View File

@ -107,6 +107,10 @@ typedef BOOL (WINAPI *GetOpenFileNameWPtr)(LPOPENFILENAMEW lpofn);
static GetOpenFileNameWPtr sGetOpenFileNameWPtrStub = nullptr;
typedef BOOL (WINAPI *GetSaveFileNameWPtr)(LPOPENFILENAMEW lpofn);
static GetSaveFileNameWPtr sGetSaveFileNameWPtrStub = nullptr;
typedef BOOL (WINAPI *SetCursorPosPtr)(int x, int y);
static SetCursorPosPtr sSetCursorPosPtrStub = nullptr;
#endif
/* static */
@ -2097,52 +2101,45 @@ PMCGetKeyState(int aVirtKey)
return sGetKeyStatePtrStub(aVirtKey);
}
BOOL WINAPI PMCGetSaveFileNameW(LPOPENFILENAMEW lpofn);
BOOL WINAPI PMCGetOpenFileNameW(LPOPENFILENAMEW lpofn);
class PluginThreadTaskData
{
public:
virtual bool RunTask() = 0;
};
// Runnable that performs GetOpenFileNameW and GetSaveFileNameW
// on the main thread so that the call can be
// Runnable that performs a task on the main thread so that the call can be
// synchronously run on the PluginModuleParent via IPC.
// The task alerts the given semaphore when it is finished.
class GetFileNameTask : public Runnable
class PluginThreadTask : public Runnable
{
BOOL* mReturnValue;
void* mLpOpenFileName;
bool mSuccess;
PluginThreadTaskData* mTaskData;
HANDLE mSemaphore;
GetFileNameFunc mFunc;
public:
explicit GetFileNameTask(GetFileNameFunc func, void* aLpOpenFileName,
HANDLE aSemaphore, BOOL* aReturnValue) :
Runnable("GetFileNameTask"), mLpOpenFileName(aLpOpenFileName),
mSemaphore(aSemaphore), mReturnValue(aReturnValue),
mFunc(func)
explicit PluginThreadTask(PluginThreadTaskData* aTaskData,
HANDLE aSemaphore) :
Runnable("PluginThreadTask"), mTaskData(aTaskData),
mSemaphore(aSemaphore), mSuccess(false)
{}
NS_IMETHOD Run() override
{
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
switch (mFunc) {
case OPEN_FUNC:
*mReturnValue =
PMCGetOpenFileNameW(static_cast<LPOPENFILENAMEW>(mLpOpenFileName));
break;
case SAVE_FUNC:
*mReturnValue =
PMCGetSaveFileNameW(static_cast<LPOPENFILENAMEW>(mLpOpenFileName));
break;
}
mSuccess = mTaskData->RunTask();
if (!ReleaseSemaphore(mSemaphore, 1, nullptr)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
bool Success() { return mSuccess; }
};
// static
BOOL
PostToPluginThread(GetFileNameFunc aFunc, void* aLpofn)
PostToPluginThread(PluginThreadTaskData* aTaskData)
{
MOZ_ASSERT(!IsPluginThread());
@ -2155,13 +2152,11 @@ PostToPluginThread(GetFileNameFunc aFunc, void* aLpofn)
return FALSE;
}
BOOL returnValue = FALSE;
RefPtr<GetFileNameTask> task =
new GetFileNameTask(aFunc, aLpofn, semaphore, &returnValue);
RefPtr<PluginThreadTask> task = new PluginThreadTask(aTaskData, semaphore);
ProcessChild::message_loop()->PostTask(task.forget());
DWORD err = WaitForSingleObject(semaphore, INFINITE);
if (err != WAIT_FAILED) {
return returnValue;
return task->Success();
}
PLUGIN_LOG_DEBUG(("Error while waiting for semaphore: %d",
GetLastError()));
@ -2169,12 +2164,39 @@ PostToPluginThread(GetFileNameFunc aFunc, void* aLpofn)
return FALSE;
}
BOOL WINAPI PMCGetSaveFileNameW(LPOPENFILENAMEW lpofn);
BOOL WINAPI PMCGetOpenFileNameW(LPOPENFILENAMEW lpofn);
class GetFileNameTaskData : public PluginThreadTaskData
{
public:
GetFileNameTaskData(GetFileNameFunc aFunc, void* aLpOpenFileName) :
mFunc(aFunc), mLpOpenFileName(aLpOpenFileName)
{}
bool RunTask()
{
switch (mFunc) {
case OPEN_FUNC:
return PMCGetOpenFileNameW(static_cast<LPOPENFILENAMEW>(mLpOpenFileName));
case SAVE_FUNC:
return PMCGetSaveFileNameW(static_cast<LPOPENFILENAMEW>(mLpOpenFileName));
}
return false;
}
private:
GetFileNameFunc mFunc;
void* mLpOpenFileName;
};
// static
BOOL WINAPI
PMCGetFileNameW(GetFileNameFunc aFunc, LPOPENFILENAMEW aLpofn)
{
if (!IsPluginThread()) {
return PostToPluginThread(aFunc, aLpofn);
GetFileNameTaskData gfnData(aFunc, aLpofn);
return PostToPluginThread(&gfnData);
}
PluginModuleChild* chromeInstance = PluginModuleChild::GetChrome();
@ -2215,6 +2237,38 @@ PMCGetOpenFileNameW(LPOPENFILENAMEW aLpofn)
{
return PMCGetFileNameW(OPEN_FUNC, aLpofn);
}
BOOL WINAPI PMCSetCursorPos(int x, int y);
class SetCursorPosTaskData : public PluginThreadTaskData
{
public:
SetCursorPosTaskData(int x, int y) : mX(x), mY(y) {}
bool RunTask() { return PMCSetCursorPos(mX, mY); }
private:
int mX, mY;
};
// static
BOOL WINAPI
PMCSetCursorPos(int x, int y)
{
if (!IsPluginThread()) {
SetCursorPosTaskData scpData(x, y);
return PostToPluginThread(&scpData);
}
PluginModuleChild* chromeInstance = PluginModuleChild::GetChrome();
if (chromeInstance) {
bool ret = FALSE;
chromeInstance->CallSetCursorPos(x, y, &ret);
return ret;
}
return sSetCursorPosPtrStub(x, y);
}
#endif
PPluginInstanceChild*
@ -2247,6 +2301,11 @@ PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
(void**) &sGetKeyStatePtrStub);
}
if (!sSetCursorPosPtrStub) {
sUser32Intercept.AddHook("SetCursorPos", reinterpret_cast<intptr_t>(PMCSetCursorPos),
(void**) &sSetCursorPosPtrStub);
}
sComDlg32Intercept.Init("comdlg32.dll");
if (!sGetSaveFileNameWPtrStub) {
sComDlg32Intercept.AddHook("GetSaveFileNameW", reinterpret_cast<intptr_t>(PMCGetSaveFileNameW),

View File

@ -3358,3 +3358,15 @@ PluginModuleChromeParent::AnswerGetFileName(const GetFileNameFunc& aFunc,
return IPC_FAIL_NO_REASON(this);
#endif
}
mozilla::ipc::IPCResult
PluginModuleChromeParent::AnswerSetCursorPos(const int &x, const int &y,
bool* aResult)
{
#if defined(XP_WIN)
*aResult = ::SetCursorPos(x, y);
return IPC_OK();
#else
return PluginModuleParent::AnswerSetCursorPos(x, y, aResult);
#endif
}

View File

@ -225,6 +225,12 @@ protected:
return IPC_FAIL_NO_REASON(this);
}
virtual mozilla::ipc::IPCResult
AnswerSetCursorPos(const int &x, const int &y, bool* aResult) override
{
return IPC_FAIL_NO_REASON(this);
}
protected:
void SetChildTimeout(const int32_t aChildTimeout);
static void TimeoutChanged(const char* aPref, void* aModule);
@ -538,6 +544,10 @@ class PluginModuleChromeParent
const OpenFileNameIPC& aOfnIn,
OpenFileNameRetIPC* aOfnOut, bool* aResult) override;
// Proxy SetCursorPos on Windows.
virtual mozilla::ipc::IPCResult
AnswerSetCursorPos(const int &x, const int &y, bool* aResult) override;
private:
virtual void
EnteredCxxStack() override;

View File

@ -3149,7 +3149,8 @@ XMLHttpRequestMainThread::SetRequestHeader(const nsACString& aName,
bool isPrivilegedCaller = IsSystemXHR();
bool isForbiddenHeader = nsContentUtils::IsForbiddenRequestHeader(aName);
if (!isPrivilegedCaller && isForbiddenHeader) {
const char16_t* params[] = { NS_ConvertUTF8toUTF16(aName).get() };
NS_ConvertUTF8toUTF16 name(aName);
const char16_t* params[] = { name.get() };
LogMessage("ForbiddenHeaderWarning", GetOwner(), params, ArrayLength(params));
return NS_OK;
}

View File

@ -775,6 +775,8 @@ description =
description =
[PPluginModule::GetFileName]
description =
[PPluginModule::SetCursorPos]
description =
[PPluginScriptableObject::NPN_Evaluate]
description =
[PPluginScriptableObject::Invalidate]

View File

@ -1,5 +0,0 @@
[event-readystatechange-loaded.htm]
type: testharness
[XMLHttpRequest: the LOADING state change should only happen once]
expected: FAIL

View File

@ -1,5 +0,0 @@
[overridemimetype-invalid-mime-type.htm]
type: testharness
[XMLHttpRequest: overrideMimeType() in unsent state, invalid MIME types]
expected: FAIL

View File

@ -1,5 +0,0 @@
[send-entity-body-document-bogus.htm]
type: testharness
[XMLHttpRequest: send() - unserializable Document]
expected: FAIL

View File

@ -1,3 +0,0 @@
[send-redirect-post-upload.htm]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1290916

View File

@ -43,6 +43,8 @@ this.SelectContentHelper = function(aElement, aOptions, aGlobal) {
this._uaSelectBackgroundColor = null;
this._uaSelectColor = null;
this._closeAfterBlur = true;
this._pseudoStylesSetup = false;
this._lockedDescendants = null;
this.init();
this.showDropDown();
this._updateTimer = new DeferredTask(this._update.bind(this), 0);
@ -100,13 +102,12 @@ this.SelectContentHelper.prototype = {
showDropDown() {
this.element.openInParentProcess = true;
this._setupPseudoClassStyles();
let rect = this._getBoundingContentRect();
DOMUtils.addPseudoClassLock(this.element, ":focus");
let computedStyles = getComputedStyles(this.element);
this._selectBackgroundColor = computedStyles.backgroundColor;
this._selectColor = computedStyles.color;
this._selectTextShadow = computedStyles.textShadow;
DOMUtils.clearPseudoClassLocks(this.element);
this.global.sendAsyncMessage("Forms:ShowDropDown", {
direction: computedStyles.direction,
isOpenedViaTouch: this.isOpenedViaTouch,
@ -121,18 +122,52 @@ this.SelectContentHelper.prototype = {
uaSelectBackgroundColor: this.uaSelectBackgroundColor,
uaSelectColor: this.uaSelectColor
});
this._clearPseudoClassStyles();
gOpen = true;
},
_setupPseudoClassStyles() {
if (this._pseudoStylesSetup) {
throw new Error("pseudo styles must not be set up yet");
}
// Do all of the things that change style at once, before we read
// any styles.
this._pseudoStylesSetup = true;
DOMUtils.addPseudoClassLock(this.element, ":focus");
let lockedDescendants = this._lockedDescendants = this.element.querySelectorAll(":checked");
for (let child of lockedDescendants) {
// Selected options have the :checked pseudo-class, which
// we want to disable before calculating the computed
// styles since the user agent styles alter the styling
// based on :checked.
DOMUtils.addPseudoClassLock(child, ":checked", false);
}
},
_clearPseudoClassStyles() {
if (!this._pseudoStylesSetup) {
throw new Error("pseudo styles must be set up already");
}
// Undo all of the things that change style at once, after we're
// done reading styles.
DOMUtils.clearPseudoClassLocks(this.element);
let lockedDescendants = this._lockedDescendants;
for (let child of lockedDescendants) {
DOMUtils.clearPseudoClassLocks(child);
}
this._lockedDescendants = null;
this._pseudoStylesSetup = false;
},
_getBoundingContentRect() {
return BrowserUtils.getElementBoundingScreenRect(this.element);
},
_buildOptionList() {
DOMUtils.addPseudoClassLock(this.element, ":focus");
let result = buildOptionListForChildren(this.element);
DOMUtils.clearPseudoClassLocks(this.element);
return result;
if (!this._pseudoStylesSetup) {
throw new Error("pseudo styles must be set up");
}
return buildOptionListForChildren(this.element);
},
_update() {
@ -141,12 +176,11 @@ this.SelectContentHelper.prototype = {
// Technically we might not need to set this pseudo-class
// during _update() since the element should organically
// have :focus, though it is here for belt-and-suspenders.
DOMUtils.addPseudoClassLock(this.element, ":focus");
this._setupPseudoClassStyles();
let computedStyles = getComputedStyles(this.element);
this._selectBackgroundColor = computedStyles.backgroundColor;
this._selectColor = computedStyles.color;
this._selectTextShadow = computedStyles.textShadow;
DOMUtils.clearPseudoClassLocks(this.element);
this.global.sendAsyncMessage("Forms:UpdateDropDown", {
options: this._buildOptionList(),
selectedIndex: this.element.selectedIndex,
@ -158,6 +192,7 @@ this.SelectContentHelper.prototype = {
uaSelectBackgroundColor: this.uaSelectBackgroundColor,
uaSelectColor: this.uaSelectColor
});
this._clearPseudoClassStyles();
},
// Determine user agent background-color and color.
@ -344,11 +379,6 @@ function buildOptionListForChildren(node) {
textContent = "";
}
// Selected options have the :checked pseudo-class, which
// we want to disable before calculating the computed
// styles since the user agent styles alter the styling
// based on :checked.
DOMUtils.addPseudoClassLock(child, ":checked", false);
let cs = getComputedStyles(child);
let info = {
@ -370,10 +400,6 @@ function buildOptionListForChildren(node) {
info.textShadow = cs.textShadow;
}
// We must wait until all computedStyles have been
// read before we clear the locks.
DOMUtils.clearPseudoClassLocks(child);
result.push(info);
}
}

View File

@ -397,6 +397,20 @@ bool TestProcessCaretEvents(void* aFunc)
return true;
}
bool TestSetCursorPos(void* aFunc)
{
auto patchedSetCursorPos =
reinterpret_cast<decltype(&SetCursorPos)>(aFunc);
POINT cursorPos;
BOOL ok = GetCursorPos(&cursorPos);
if (ok) {
ok = patchedSetCursorPos(cursorPos.x, cursorPos.y);
} else {
ok = patchedSetCursorPos(512, 512);
}
return ok;
}
static DWORD sTlsIndex = 0;
bool TestTlsAlloc(void* aFunc)
@ -517,6 +531,7 @@ int main()
#ifdef _M_IX86
TestHook(TestSendMessageTimeoutW, "user32.dll", "SendMessageTimeoutW") &&
#endif
TestHook(TestSetCursorPos, "user32.dll", "SetCursorPos") &&
TestHook(TestTlsAlloc, "kernel32.dll", "TlsAlloc") &&
TestHook(TestTlsFree, "kernel32.dll", "TlsFree") &&
#ifdef _M_IX86

View File

@ -1008,6 +1008,10 @@ protected:
MOZ_ASSERT_UNREACHABLE("Unrecognized opcode sequence");
return;
}
} else if (origBytes[nOrigBytes] == 0x63 &&
(origBytes[nOrigBytes + 1] & kMaskMod) == kModReg) {
// movsxd r64, r32 (move + sign extend)
COPY_CODES(2);
} else {
// not support yet!
MOZ_ASSERT_UNREACHABLE("Unrecognized opcode sequence");
@ -1106,8 +1110,8 @@ protected:
} else if (origBytes[nOrigBytes] == 0x90) {
// nop
COPY_CODES(1);
} else if (origBytes[nOrigBytes] == 0xb8) {
// MOV 0xB8: http://ref.x86asm.net/coder32.html#xB8
} else if ((origBytes[nOrigBytes] & 0xf8) == 0xb8) {
// MOV r32, imm32
COPY_CODES(5);
} else if (origBytes[nOrigBytes] == 0x33) {
// xor r32, r/m32