This commit is contained in:
Wes Kocher 2013-10-09 20:42:24 -07:00
Родитель 1eea17f696 c430ecd99d
Коммит dfa1f8d566
74 изменённых файлов: 1183 добавлений и 590 удалений

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

@ -18,4 +18,4 @@
# Modifying this file will now automatically clobber the buildbot machines \o/
#
Bug 899574 needed a clobber, at least on Windows.
Bug 817194 needs a clobber on Windows due to bug 924992.

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

@ -41,11 +41,11 @@ TESTFLAGS := -fsyntax-only -Xclang -verify \
$(TESTS): test-%: tests/%.cpp $(PLUGIN)
$(CXX) $(TESTFLAGS) $<
compile libs export tools: all
compile binaries libs export tools: all
distclean clean:
rm -f $(OBJS) $(TESTS) $(PLUGIN)
check:
.PHONY: compile libs export tools distclean clean check
.PHONY: compile binaries libs export tools distclean clean check

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

@ -1,97 +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/.
package mozLock;
use strict;
use IO::File;
use Cwd;
BEGIN {
use Exporter ();
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(&mozLock &mozUnlock);
%EXPORT_TAGS = ( );
@EXPORT_OK = qw();
}
my $lockcounter = 0;
my $locklimit = 100;
my $locksleep = 0.1;
my %lockhash;
# File::Spec->rel2abs appears to be broken in ActiveState Perl 5.22
# so roll our own
sub priv_abspath($) {
my ($file) = @_;
my ($dir, $out);
my (@inlist, @outlist);
# Force files to have unix paths.
$file =~ s/\\/\//g;
# Check if file is already absolute
if ($file =~ m/^\// || substr($file, 1, 1) eq ':') {
return $file;
}
$out = cwd . "/$file";
# Do what File::Spec->canonpath should do
@inlist = split(/\//, $out);
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$out = join '/',@outlist;
return $out;
}
sub mozLock($) {
my ($inlockfile) = @_;
my ($lockhandle, $lockfile);
$lockfile = priv_abspath($inlockfile);
#print "LOCK: $lockfile\n";
$lockcounter = 0;
$lockhandle = new IO::File || die "Could not create filehandle for $lockfile: $!\n";
while ($lockcounter < $locklimit) {
if (! -e $lockfile) {
open($lockhandle, ">$lockfile") || die "$lockfile: $!\n";
$lockhash{$lockfile} = $lockhandle;
last;
}
$lockcounter++;
select(undef,undef,undef, $locksleep);
}
if ($lockcounter >= $locklimit) {
undef $lockhandle;
die "$0: Could not get lockfile $lockfile.\nRemove $lockfile to clear up\n";
}
}
sub mozUnlock($) {
my ($inlockfile) = @_;
my ($lockhandle, $lockfile);
#$lockfile = File::Spec->rel2abs($inlockfile);
$lockfile = priv_abspath($inlockfile);
#print "UNLOCK: $lockfile\n";
$lockhandle = $lockhash{$lockfile};
if (defined($lockhandle)) {
close($lockhandle);
$lockhash{$lockfile} = undef;
unlink($lockfile);
} else {
print "WARNING: $0: lockhandle for $lockfile not defined. Lock may not be removed.\n";
}
}
END {};
1;

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

@ -27,6 +27,8 @@
#include "nsTHashtable.h" // for member
#include "mozilla/dom/DocumentBinding.h"
#include "Units.h"
#include "nsExpirationTracker.h"
#include "nsClassHashtable.h"
class imgIRequest;
class nsAString;
@ -80,6 +82,7 @@ class nsDOMCaretPosition;
class nsViewportInfo;
class nsDOMEvent;
class nsIGlobalObject;
class nsCSSSelectorList;
namespace mozilla {
class ErrorResult;
@ -660,7 +663,61 @@ public:
protected:
virtual Element *GetRootElementInternal() const = 0;
private:
class SelectorCacheKey
{
public:
SelectorCacheKey(const nsAString& aString) : mKey(aString)
{
MOZ_COUNT_CTOR(SelectorCacheKey);
}
nsString mKey;
nsExpirationState mState;
nsExpirationState* GetExpirationState() { return &mState; }
~SelectorCacheKey()
{
MOZ_COUNT_DTOR(SelectorCacheKey);
}
};
class SelectorCacheKeyDeleter;
public:
class SelectorCache MOZ_FINAL
: public nsExpirationTracker<SelectorCacheKey, 4>
{
public:
SelectorCache();
// CacheList takes ownership of aSelectorList.
void CacheList(const nsAString& aSelector, nsCSSSelectorList* aSelectorList);
virtual void NotifyExpired(SelectorCacheKey* aSelector) MOZ_OVERRIDE;
// We do not call MarkUsed because it would just slow down lookups and
// because we're OK expiring things after a few seconds even if they're
// being used.
nsCSSSelectorList* GetList(const nsAString& aSelector)
{
return mTable.Get(aSelector);
}
~SelectorCache()
{
AgeAllGenerations();
}
private:
nsClassHashtable<nsStringHashKey, nsCSSSelectorList> mTable;
};
SelectorCache& GetSelectorCache()
{
return mSelectorCache;
}
// Get the root <html> element, or return null if there isn't one (e.g.
// if the root isn't <html>)
Element* GetHtmlElement() const;
@ -2133,6 +2190,7 @@ public:
private:
uint64_t mWarnedAbout;
SelectorCache mSelectorCache;
protected:
~nsIDocument();

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

@ -163,7 +163,10 @@ nsDOMFileBase::GetMozFullPath(nsAString &aFileName)
NS_IMETHODIMP
nsDOMFileBase::GetMozFullPathInternal(nsAString &aFileName)
{
NS_ASSERTION(mIsFile, "Should only be called on files");
if (!mIsFile) {
return NS_ERROR_FAILURE;
}
aFileName.Truncate();
return NS_OK;
}

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

@ -526,11 +526,11 @@ nsDOMMutationObserver::TakeRecords(
}
void
nsDOMMutationObserver::GetObservingInfo(nsTArray<Nullable<MutationObservingInfoInitializer> >& aResult)
nsDOMMutationObserver::GetObservingInfo(nsTArray<Nullable<MutationObservingInfo> >& aResult)
{
aResult.SetCapacity(mReceivers.Count());
for (int32_t i = 0; i < mReceivers.Count(); ++i) {
MutationObservingInfoInitializer& info = aResult.AppendElement()->SetValue();
MutationObservingInfo& info = aResult.AppendElement()->SetValue();
nsMutationReceiver* mr = mReceivers[i];
info.mChildList = mr->ChildList();
info.mAttributes = mr->Attributes();

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

@ -26,7 +26,7 @@
#include "nsIDocument.h"
class nsDOMMutationObserver;
using mozilla::dom::MutationObservingInfoInitializer;
using mozilla::dom::MutationObservingInfo;
class nsDOMMutationRecord : public nsISupports,
public nsWrapperCache
@ -379,7 +379,7 @@ public:
void HandleMutation();
void GetObservingInfo(nsTArray<Nullable<MutationObservingInfoInitializer> >& aResult);
void GetObservingInfo(nsTArray<Nullable<MutationObservingInfo> >& aResult);
mozilla::dom::MutationCallback* MutationCallback() { return mCallback; }

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

@ -1315,6 +1315,49 @@ nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
}
// ==================================================================
nsIDocument::SelectorCache::SelectorCache()
: nsExpirationTracker<SelectorCacheKey, 4>(1000) { }
// CacheList takes ownership of aSelectorList.
void nsIDocument::SelectorCache::CacheList(const nsAString& aSelector,
nsCSSSelectorList* aSelectorList)
{
SelectorCacheKey* key = new SelectorCacheKey(aSelector);
mTable.Put(key->mKey, aSelectorList);
AddObject(key);
}
class nsIDocument::SelectorCacheKeyDeleter MOZ_FINAL : public nsRunnable
{
public:
explicit SelectorCacheKeyDeleter(SelectorCacheKey* aToDelete)
: mSelector(aToDelete)
{
MOZ_COUNT_CTOR(SelectorCacheKeyDeleter);
}
~SelectorCacheKeyDeleter()
{
MOZ_COUNT_DTOR(SelectorCacheKeyDeleter);
}
NS_IMETHOD Run()
{
return NS_OK;
}
private:
nsAutoPtr<SelectorCacheKey> mSelector;
};
void nsIDocument::SelectorCache::NotifyExpired(SelectorCacheKey* aSelector)
{
RemoveObject(aSelector);
mTable.Remove(aSelector->mKey);
nsCOMPtr<nsIRunnable> runnable = new SelectorCacheKeyDeleter(aSelector);
NS_DispatchToCurrentThread(runnable);
}
struct nsIDocument::FrameRequest
{

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

@ -2337,21 +2337,30 @@ template<bool onlyFirstMatch, class T>
inline static nsresult
FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList)
{
nsAutoPtr<nsCSSSelectorList> selectorList;
nsresult rv = ParseSelectorList(aRoot, aSelector,
getter_Transfers(selectorList));
if (NS_FAILED(rv)) {
// We hit this for syntax errors, which are quite common, so don't
// use NS_ENSURE_SUCCESS. (For example, jQuery has an extended set
// of selectors, but it sees if we can parse them first.)
return rv;
nsIDocument* doc = aRoot->OwnerDoc();
nsIDocument::SelectorCache& cache = doc->GetSelectorCache();
nsCSSSelectorList* selectorList = cache.GetList(aSelector);
if (!selectorList) {
nsresult rv = ParseSelectorList(aRoot, aSelector,
&selectorList);
if (NS_FAILED(rv)) {
delete selectorList;
// We hit this for syntax errors, which are quite common, so don't
// use NS_ENSURE_SUCCESS. (For example, jQuery has an extended set
// of selectors, but it sees if we can parse them first.)
return rv;
}
NS_ENSURE_TRUE(selectorList, NS_OK);
cache.CacheList(aSelector, selectorList);
}
NS_ENSURE_TRUE(selectorList, NS_OK);
NS_ASSERTION(selectorList->mSelectors,
"How can we not have any selectors?");
nsIDocument* doc = aRoot->OwnerDoc();
TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited,
doc, TreeMatchContext::eNeverMatchVisited);
doc->FlushPendingLinkUpdates();

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

@ -911,7 +911,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
}
void
WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializer> &retval)
WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributes> &retval)
{
retval.SetNull();
if (IsContextLost())

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

@ -76,7 +76,6 @@ namespace dom {
class ImageData;
struct WebGLContextAttributes;
struct WebGLContextAttributesInitializer;
template<typename> struct Nullable;
}
@ -258,7 +257,7 @@ public:
GLsizei DrawingBufferWidth() const { return IsContextLost() ? 0 : mWidth; }
GLsizei DrawingBufferHeight() const { return IsContextLost() ? 0 : mHeight; }
void GetContextAttributes(dom::Nullable<dom::WebGLContextAttributesInitializer>& retval);
void GetContextAttributes(dom::Nullable<dom::WebGLContextAttributes>& retval);
bool IsContextLost() const { return mContextStatus != ContextNotLost; }
void GetSupportedExtensions(JSContext *cx, dom::Nullable< nsTArray<nsString> > &retval);
JSObject* GetExtension(JSContext* cx, const nsAString& aName, ErrorResult& rv);

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

@ -234,11 +234,6 @@ WebGLProgram::GetUniformInfoForMappedIdentifier(const nsACString& name) {
mUniformInfoMap->Get(mutableName, &info);
// we don't check if that Get failed, as if it did, it left info with default values
// if there is a bracket and it's not [0], then we're not an array, we're just an entry in an array
if (hadBracketPart && !bracketPart.EqualsLiteral("[0]")) {
info.isArray = false;
info.arraySize = 1;
}
return info;
}

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

@ -269,6 +269,56 @@ struct DeltaValues
double deltaY;
};
/******************************************************************/
/* nsScrollbarsForWheel */
/******************************************************************/
class nsScrollbarsForWheel {
public:
static void PrepareToScrollText(nsEventStateManager* aESM,
nsIFrame* aTargetFrame,
WheelEvent* aEvent);
static void SetActiveScrollTarget(nsIScrollableFrame* aScrollTarget);
// Hide all scrollbars (both mActiveOwner's and mActivatedScrollTargets')
static void MayInactivate();
static void Inactivate();
static bool IsActive();
static void OwnWheelTransaction(bool aOwn);
protected:
static const size_t kNumberOfTargets = 4;
static const DeltaValues directions[kNumberOfTargets];
static nsWeakFrame sActiveOwner;
static nsWeakFrame sActivatedScrollTargets[kNumberOfTargets];
static bool sHadWheelStart;
static bool sOwnWheelTransaction;
/**
* These two methods are called upon NS_WHEEL_START/NS_WHEEL_STOP events
* to show/hide the right scrollbars.
*/
static void TemporarilyActivateAllPossibleScrollTargets(
nsEventStateManager* aESM,
nsIFrame* aTargetFrame,
WheelEvent* aEvent);
static void DeactivateAllTemporarilyActivatedScrollTargets();
};
const DeltaValues nsScrollbarsForWheel::directions[kNumberOfTargets] = {
DeltaValues(-1, 0), DeltaValues(+1, 0), DeltaValues(0, -1), DeltaValues(0, +1)
};
nsWeakFrame nsScrollbarsForWheel::sActiveOwner = nullptr;
nsWeakFrame nsScrollbarsForWheel::sActivatedScrollTargets[kNumberOfTargets] = {
nullptr, nullptr, nullptr, nullptr
};
bool nsScrollbarsForWheel::sHadWheelStart = false;
bool nsScrollbarsForWheel::sOwnWheelTransaction = false;
/******************************************************************/
/* nsMouseWheelTransaction */
/******************************************************************/
class nsMouseWheelTransaction {
public:
static nsIFrame* GetTargetFrame() { return sTargetFrame; }
@ -277,11 +327,13 @@ public:
// Be careful, UpdateTransaction may fire a DOM event, therefore, the target
// frame might be destroyed in the event handler.
static bool UpdateTransaction(WheelEvent* aEvent);
static void MayEndTransaction();
static void EndTransaction();
static void OnEvent(WidgetEvent* aEvent);
static void Shutdown();
static uint32_t GetTimeoutTime();
static void OwnScrollbars(bool aOwn);
static DeltaValues AccelerateWheelDelta(WheelEvent* aEvent,
bool aAllowScrollSpeedOverride);
@ -299,12 +351,14 @@ protected:
static int32_t GetAccelerationFactor();
static DeltaValues OverrideSystemScrollSpeed(WheelEvent* aEvent);
static double ComputeAcceleratedWheelDelta(double aDelta, int32_t aFactor);
static bool OutOfTime(uint32_t aBaseTime, uint32_t aThreshold);
static nsWeakFrame sTargetFrame;
static uint32_t sTime; // in milliseconds
static uint32_t sMouseMoved; // in milliseconds
static nsITimer* sTimer;
static int32_t sScrollSeriesCounter;
static bool sOwnScrollbars;
};
nsWeakFrame nsMouseWheelTransaction::sTargetFrame(nullptr);
@ -312,13 +366,7 @@ uint32_t nsMouseWheelTransaction::sTime = 0;
uint32_t nsMouseWheelTransaction::sMouseMoved = 0;
nsITimer* nsMouseWheelTransaction::sTimer = nullptr;
int32_t nsMouseWheelTransaction::sScrollSeriesCounter = 0;
static bool
OutOfTime(uint32_t aBaseTime, uint32_t aThreshold)
{
uint32_t now = PR_IntervalToMilliseconds(PR_IntervalNow());
return (now - aBaseTime > aThreshold);
}
bool nsMouseWheelTransaction::sOwnScrollbars = false;
static bool
CanScrollInRange(nscoord aMin, nscoord aValue, nscoord aMax, double aDirection)
@ -328,20 +376,33 @@ CanScrollInRange(nscoord aMin, nscoord aValue, nscoord aMax, double aDirection)
}
static bool
CanScrollOn(nsIScrollableFrame* aScrollFrame, double aDeltaX, double aDeltaY)
CanScrollOn(nsIScrollableFrame* aScrollFrame, double aDirectionX, double aDirectionY)
{
MOZ_ASSERT(aScrollFrame);
NS_ASSERTION(aDeltaX || aDeltaY,
NS_ASSERTION(aDirectionX || aDirectionY,
"One of the delta values must be non-zero at least");
nsPoint scrollPt = aScrollFrame->GetScrollPosition();
nsRect scrollRange = aScrollFrame->GetScrollRange();
uint32_t directions = aScrollFrame->GetPerceivedScrollingDirections();
return (aDeltaX && (directions & nsIScrollableFrame::HORIZONTAL) &&
CanScrollInRange(scrollRange.x, scrollPt.x, scrollRange.XMost(), aDeltaX)) ||
(aDeltaY && (directions & nsIScrollableFrame::VERTICAL) &&
CanScrollInRange(scrollRange.y, scrollPt.y, scrollRange.YMost(), aDeltaY));
return (aDirectionX && (directions & nsIScrollableFrame::HORIZONTAL) &&
CanScrollInRange(scrollRange.x, scrollPt.x, scrollRange.XMost(), aDirectionX)) ||
(aDirectionY && (directions & nsIScrollableFrame::VERTICAL) &&
CanScrollInRange(scrollRange.y, scrollPt.y, scrollRange.YMost(), aDirectionY));
}
bool
nsMouseWheelTransaction::OutOfTime(uint32_t aBaseTime, uint32_t aThreshold)
{
uint32_t now = PR_IntervalToMilliseconds(PR_IntervalNow());
return (now - aBaseTime > aThreshold);
}
void
nsMouseWheelTransaction::OwnScrollbars(bool aOwn)
{
sOwnScrollbars = aOwn;
}
void
@ -349,6 +410,9 @@ nsMouseWheelTransaction::BeginTransaction(nsIFrame* aTargetFrame,
WheelEvent* aEvent)
{
NS_ASSERTION(!sTargetFrame, "previous transaction is not finished!");
MOZ_ASSERT(aEvent->message == NS_WHEEL_WHEEL,
"Transaction must be started with a wheel event");
nsScrollbarsForWheel::OwnWheelTransaction(false);
sTargetFrame = aTargetFrame;
sScrollSeriesCounter = 0;
if (!UpdateTransaction(aEvent)) {
@ -385,6 +449,16 @@ nsMouseWheelTransaction::UpdateTransaction(WheelEvent* aEvent)
return true;
}
void
nsMouseWheelTransaction::MayEndTransaction()
{
if (!sOwnScrollbars && nsScrollbarsForWheel::IsActive()) {
nsScrollbarsForWheel::OwnWheelTransaction(true);
} else {
EndTransaction();
}
}
void
nsMouseWheelTransaction::EndTransaction()
{
@ -392,6 +466,11 @@ nsMouseWheelTransaction::EndTransaction()
sTimer->Cancel();
sTargetFrame = nullptr;
sScrollSeriesCounter = 0;
if (sOwnScrollbars) {
sOwnScrollbars = false;
nsScrollbarsForWheel::OwnWheelTransaction(false);
nsScrollbarsForWheel::Inactivate();
}
}
void
@ -415,7 +494,7 @@ nsMouseWheelTransaction::OnEvent(WidgetEvent* aEvent)
OutOfTime(sMouseMoved, GetIgnoreMoveDelayTime())) {
// Terminate the current mousewheel transaction if the mouse moved more
// than ignoremovedelay milliseconds ago
EndTransaction();
MayEndTransaction();
}
return;
case NS_MOUSE_MOVE:
@ -426,7 +505,7 @@ nsMouseWheelTransaction::OnEvent(WidgetEvent* aEvent)
nsIntPoint pt = GetScreenPoint(static_cast<WidgetGUIEvent*>(aEvent));
nsIntRect r = sTargetFrame->GetScreenRectExternal();
if (!r.Contains(pt)) {
EndTransaction();
MayEndTransaction();
return;
}
@ -475,8 +554,9 @@ nsMouseWheelTransaction::OnFailToScrollTarget()
}
// The target frame might be destroyed in the event handler, at that time,
// we need to finish the current transaction
if (!sTargetFrame)
if (!sTargetFrame) {
EndTransaction();
}
}
void
@ -491,7 +571,7 @@ nsMouseWheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure)
nsIFrame* frame = sTargetFrame;
// We need to finish current transaction before DOM event firing. Because
// the next DOM event might create strange situation for us.
EndTransaction();
MayEndTransaction();
if (Preferences::GetBool("test.mousescroll", false)) {
// This event is used for automated tests, see bug 442774.
@ -625,6 +705,127 @@ nsMouseWheelTransaction::OverrideSystemScrollSpeed(WheelEvent* aEvent)
return NS_FAILED(rv) ? DeltaValues(aEvent) : overriddenDeltaValues;
}
/******************************************************************/
/* nsScrollbarsForWheel */
/******************************************************************/
void
nsScrollbarsForWheel::PrepareToScrollText(
nsEventStateManager* aESM,
nsIFrame* aTargetFrame,
WheelEvent* aEvent)
{
if (aEvent->message == NS_WHEEL_START) {
nsMouseWheelTransaction::OwnScrollbars(false);
if (!IsActive()) {
TemporarilyActivateAllPossibleScrollTargets(aESM, aTargetFrame, aEvent);
sHadWheelStart = true;
}
} else {
DeactivateAllTemporarilyActivatedScrollTargets();
}
}
void
nsScrollbarsForWheel::SetActiveScrollTarget(nsIScrollableFrame* aScrollTarget)
{
if (!sHadWheelStart) {
return;
}
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(aScrollTarget);
if (!scrollbarOwner) {
return;
}
sHadWheelStart = false;
sActiveOwner = do_QueryFrame(aScrollTarget);
scrollbarOwner->ScrollbarActivityStarted();
}
void
nsScrollbarsForWheel::MayInactivate()
{
if (!sOwnWheelTransaction && nsMouseWheelTransaction::GetTargetFrame()) {
nsMouseWheelTransaction::OwnScrollbars(true);
} else {
Inactivate();
}
}
void
nsScrollbarsForWheel::Inactivate()
{
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sActiveOwner);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
}
sActiveOwner = nullptr;
DeactivateAllTemporarilyActivatedScrollTargets();
if (sOwnWheelTransaction) {
sOwnWheelTransaction = false;
nsMouseWheelTransaction::OwnScrollbars(false);
nsMouseWheelTransaction::EndTransaction();
}
}
bool
nsScrollbarsForWheel::IsActive()
{
if (sActiveOwner) {
return true;
}
for (size_t i = 0; i < kNumberOfTargets; ++i) {
if (sActivatedScrollTargets[i]) {
return true;
}
}
return false;
}
void
nsScrollbarsForWheel::OwnWheelTransaction(bool aOwn)
{
sOwnWheelTransaction = aOwn;
}
void
nsScrollbarsForWheel::TemporarilyActivateAllPossibleScrollTargets(
nsEventStateManager* aESM,
nsIFrame* aTargetFrame,
WheelEvent* aEvent)
{
for (size_t i = 0; i < kNumberOfTargets; i++) {
const DeltaValues *dir = &directions[i];
nsWeakFrame* scrollTarget = &sActivatedScrollTargets[i];
MOZ_ASSERT(!*scrollTarget, "scroll target still temporarily activated!");
nsIScrollableFrame* target =
aESM->ComputeScrollTarget(aTargetFrame, dir->deltaX, dir->deltaY, aEvent,
nsEventStateManager::COMPUTE_DEFAULT_ACTION_TARGET);
if (target) {
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(target);
if (scrollbarOwner) {
nsIFrame* targetFrame = do_QueryFrame(target);
*scrollTarget = targetFrame;
scrollbarOwner->ScrollbarActivityStarted();
}
}
}
}
void
nsScrollbarsForWheel::DeactivateAllTemporarilyActivatedScrollTargets()
{
for (size_t i = 0; i < kNumberOfTargets; i++) {
nsWeakFrame* scrollTarget = &sActivatedScrollTargets[i];
if (*scrollTarget) {
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(*scrollTarget);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
}
*scrollTarget = nullptr;
}
}
}
/******************************************************************/
/* nsEventStateManager */
/******************************************************************/
@ -977,13 +1178,20 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
}
break;
case NS_WHEEL_WHEEL:
case NS_WHEEL_START:
case NS_WHEEL_STOP:
{
NS_ASSERTION(aEvent->mFlags.mIsTrusted,
"Untrusted wheel event shouldn't be here");
nsIContent* content = GetFocusedContent();
if (content)
if (content) {
mCurrentTargetContent = content;
}
if (aEvent->message != NS_WHEEL_WHEEL) {
break;
}
WheelEvent* wheelEvent = static_cast<WheelEvent*>(aEvent);
WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(wheelEvent);
@ -2545,6 +2753,20 @@ nsIScrollableFrame*
nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
WheelEvent* aEvent,
ComputeScrollTargetOptions aOptions)
{
return ComputeScrollTarget(aTargetFrame, aEvent->deltaX, aEvent->deltaY,
aEvent, aOptions);
}
// Overload ComputeScrollTarget method to allow passing "test" dx and dy when looking
// for which scrollbarowners to activate when two finger down on trackpad
// and before any actual motion
nsIScrollableFrame*
nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
double aDirectionX,
double aDirectionY,
WheelEvent* aEvent,
ComputeScrollTargetOptions aOptions)
{
if (aOptions & PREFER_MOUSE_WHEEL_TRANSACTION) {
// If the user recently scrolled with the mousewheel, then they probably
@ -2569,14 +2791,14 @@ nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
// If the event doesn't cause scroll actually, we cannot find scroll target
// because we check if the event can cause scroll actually on each found
// scrollable frame.
if (!aEvent->deltaX && !aEvent->deltaY) {
if (!aDirectionX && !aDirectionY) {
return nullptr;
}
bool checkIfScrollableX =
aEvent->deltaX && (aOptions & PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS);
aDirectionX && (aOptions & PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS);
bool checkIfScrollableY =
aEvent->deltaY && (aOptions & PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS);
aDirectionY && (aOptions & PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS);
nsIScrollableFrame* frameToScroll = nullptr;
nsIFrame* scrollFrame =
@ -2604,8 +2826,7 @@ nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
// For default action, we should climb up the tree if cannot scroll it
// by the event actually.
bool canScroll = CanScrollOn(frameToScroll,
aEvent->deltaX, aEvent->deltaY);
bool canScroll = CanScrollOn(frameToScroll, aDirectionX, aDirectionY);
// Comboboxes need special care.
nsIComboboxControlFrame* comboBox = do_QueryFrame(scrollFrame);
if (comboBox) {
@ -3170,33 +3391,51 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
}
break;
case NS_WHEEL_STOP:
{
MOZ_ASSERT(aEvent->mFlags.mIsTrusted);
nsScrollbarsForWheel::MayInactivate();
}
break;
case NS_WHEEL_WHEEL:
case NS_WHEEL_START:
{
MOZ_ASSERT(aEvent->mFlags.mIsTrusted);
if (*aStatus == nsEventStatus_eConsumeNoDefault) {
nsScrollbarsForWheel::Inactivate();
break;
}
WheelEvent* wheelEvent = static_cast<WheelEvent*>(aEvent);
switch (WheelPrefs::GetInstance()->ComputeActionFor(wheelEvent)) {
case WheelPrefs::ACTION_SCROLL: {
if (!wheelEvent->deltaX && !wheelEvent->deltaY) {
break;
}
// For scrolling of default action, we should honor the mouse wheel
// transaction.
nsScrollbarsForWheel::PrepareToScrollText(this, aTargetFrame, wheelEvent);
if (aEvent->message != NS_WHEEL_WHEEL ||
(!wheelEvent->deltaX && !wheelEvent->deltaY)) {
break;
}
nsIScrollableFrame* scrollTarget =
ComputeScrollTarget(aTargetFrame, wheelEvent,
COMPUTE_DEFAULT_ACTION_TARGET);
nsScrollbarsForWheel::SetActiveScrollTarget(scrollTarget);
wheelEvent->overflowDeltaX = wheelEvent->deltaX;
wheelEvent->overflowDeltaY = wheelEvent->deltaY;
WheelPrefs::GetInstance()->
CancelApplyingUserPrefsFromOverflowDelta(wheelEvent);
if (scrollTarget) {
DoScrollText(scrollTarget, wheelEvent);
} else {
nsMouseWheelTransaction::EndTransaction();
nsScrollbarsForWheel::Inactivate();
}
break;
}

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

@ -46,6 +46,7 @@ class nsEventStateManager : public nsSupportsWeakReference,
public nsIObserver
{
friend class nsMouseWheelTransaction;
friend class nsScrollbarsForWheel;
public:
typedef mozilla::TimeStamp TimeStamp;
@ -557,6 +558,12 @@ protected:
mozilla::WheelEvent* aEvent,
ComputeScrollTargetOptions aOptions);
nsIScrollableFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
double aDirectionX,
double aDirectionY,
mozilla::WheelEvent* aEvent,
ComputeScrollTargetOptions aOptions);
/**
* GetScrollAmount() returns the scroll amount in app uints of one line or
* one page. If the wheel event scrolls a page, returns the page width and

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

@ -529,6 +529,12 @@ private:
nsTArray<nsCOMPtr<nsIDOMFile> > mFileList;
};
/**
* This may return nullptr if aDomFile's implementation of
* nsIDOMFile::mozFullPathInternal does not successfully return a non-empty
* string that is a valid path. This can happen on Firefox OS, for example,
* where the file picker can create Blobs.
*/
static already_AddRefed<nsIFile>
DOMFileToLocalFile(nsIDOMFile* aDomFile)
{
@ -630,10 +636,12 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
// Store the last used directory using the content pref service:
nsCOMPtr<nsIFile> file = DOMFileToLocalFile(newFiles[0]);
nsCOMPtr<nsIFile> lastUsedDir;
file->GetParent(getter_AddRefs(lastUsedDir));
HTMLInputElement::gUploadLastDir->StoreLastUsedDirectory(
mInput->OwnerDoc(), lastUsedDir);
if (file) {
nsCOMPtr<nsIFile> lastUsedDir;
file->GetParent(getter_AddRefs(lastUsedDir));
HTMLInputElement::gUploadLastDir->StoreLastUsedDirectory(
mInput->OwnerDoc(), lastUsedDir);
}
// The text control frame (if there is one) isn't going to send a change
// event because it will think this is done by a script.

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

@ -386,3 +386,4 @@ support-files =
[test_ul_attributes_reflection.html]
[test_undoManager.html]
[test_video_wakelock.html]
[test_input_files_not_nsIFile.html]

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

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for &lt;input type='file'&gt; handling when its "files" do not implement nsIFile</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="content">
<input id='a' type='file'>
</div>
<button id='b' onclick="document.getElementById('a').click();">Show Filepicker</button>
<input type="file" id="file" />
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init(window);
SimpleTest.waitForFocus(function() {
MockFilePicker.useBlobFile();
MockFilePicker.returnValue = MockFilePicker.returnOK;
var b = document.getElementById('b');
b.focus(); // Be sure the element is visible.
document.getElementById('a').addEventListener("change", function(aEvent) {
ok(true, "change event correctly sent");
SimpleTest.executeSoon(function() {
MockFilePicker.cleanup();
SimpleTest.finish();
});
}, false);
b.click();
});
</script>
</pre>
</body>
</html>

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

@ -492,7 +492,7 @@ MediaRecorder::CreateAndDispatchBlobEvent(Session *aSession)
return NS_ERROR_DOM_SECURITY_ERR;
}
BlobEventInitInitializer init;
BlobEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mData = aSession->GetEncodedData();

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

@ -120,7 +120,7 @@ void
TextTrackList::CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
const nsAString& aEventName)
{
TrackEventInitInitializer eventInit;
TrackEventInit eventInit;
eventInit.mBubbles = false;
eventInit.mCancelable = false;
eventInit.mTrack = aTrack;

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

@ -713,7 +713,7 @@ SpeechRecognition::Start(ErrorResult& aRv)
NS_ENSURE_SUCCESS_VOID(rv);
AutoSafeJSContext cx;
MediaStreamConstraintsInitializer constraints;
MediaStreamConstraints constraints;
constraints.mAudio.SetAsBoolean() = true;
if (!mTestConfig.mFakeFSMEvents) {

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

@ -4999,7 +4999,7 @@ nsGlobalWindow::DispatchResizeEvent(const nsIntSize& aSize)
AutoSafeJSContext cx;
JSAutoCompartment ac(cx, mJSObject);
DOMWindowResizeEventDetailInitializer detail;
DOMWindowResizeEventDetail detail;
detail.mWidth = aSize.width;
detail.mHeight = aSize.height;
JS::Rooted<JS::Value> detailValue(cx);

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

@ -3544,9 +3544,13 @@ for (uint32_t i = 0; i < length; ++i) {
assert not isOptional
typeName = CGDictionary.makeDictionaryName(type.inner)
actualTypeName = typeName
if not isMember:
# Since we're not a member and not nullable or optional, no one will
# see our real type, so we can do the fast version of the dictionary
# that doesn't pre-initialize members.
typeName = "dictionary_detail::Fast" + typeName
declType = CGGeneric(actualTypeName)
declType = CGGeneric(typeName)
# We do manual default value handling here, because we
# actually do want a jsval, and we only handle null anyway
@ -4424,8 +4428,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
return result, True, rooter, None
if returnType.isDictionary():
nullable = returnType.nullable()
dictName = (CGDictionary.makeDictionaryName(returnType.unroll().inner) +
"Initializer")
dictName = CGDictionary.makeDictionaryName(returnType.unroll().inner)
result = CGGeneric(dictName)
if not isMember and typeNeedsRooting(returnType):
if nullable:
@ -8379,7 +8382,20 @@ if (""",
visibility="public",
body=self.getMemberInitializer(m))
for m in self.memberInfo]
ctors = [ClassConstructor([], bodyInHeader=True, visibility="public")]
ctors = [
ClassConstructor(
[],
visibility="public",
body=(
"// Safe to pass a null context if we pass a null value\n"
"Init(nullptr, JS::NullHandleValue);")),
ClassConstructor(
[Argument("int", "")],
visibility="protected",
explicit=True,
bodyInHeader=True,
body='// Do nothing here; this is used by our "Fast" subclass')
]
methods = []
if self.needToInitIds:
@ -8413,17 +8429,23 @@ if (""",
disallowCopyConstruction=disallowCopyConstruction)
initializerCtor = ClassConstructor([],
fastDictionaryCtor = ClassConstructor(
[],
visibility="public",
body=(
"// Safe to pass a null context if we pass a null value\n"
"Init(nullptr, JS::NullHandleValue);"))
initializerStruct = CGClass(selfName + "Initializer",
bodyInHeader=True,
baseConstructors=["%s(42)" % selfName],
body="// Doesn't matter what int we pass to the parent constructor"
)
fastStruct = CGClass("Fast" + selfName,
bases=[ClassBase(selfName)],
constructors=[initializerCtor],
constructors=[fastDictionaryCtor],
isStruct=True)
return CGList([struct, initializerStruct])
return CGList([struct,
CGNamespace.build(['dictionary_detail'],
fastStruct)],
"\n")
def deps(self):
return self.dictionary.getDeps()

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

@ -587,7 +587,7 @@ public:
// Dictionary tests
void PassDictionary(JSContext*, const Dict&);
void ReceiveDictionary(JSContext*, Dict&);
void ReceiveNullableDictionary(JSContext*, Nullable<DictInitializer>&);
void ReceiveNullableDictionary(JSContext*, Nullable<Dict>&);
void PassOtherDictionary(const GrandparentDict&);
void PassSequenceOfDictionaries(JSContext*, const Sequence<Dict>&);
void PassDictionaryOrLong(JSContext*, const Dict&);

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

@ -134,7 +134,7 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
// aFeatures.
// Create the event's detail object.
OpenWindowEventDetailInitializer detail;
OpenWindowEventDetail detail;
detail.mUrl = aURL;
detail.mName = aName;
detail.mFeatures = aFeatures;
@ -307,7 +307,7 @@ NS_IMETHODIMP DispatchAsyncScrollEventRunnable::Run()
NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED);
// Create the event's detail object.
AsyncScrollEventDetailInitializer detail;
AsyncScrollEventDetail detail;
detail.mLeft = mContentRect.x;
detail.mTop = mContentRect.y;
detail.mWidth = mContentRect.width;

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

@ -244,7 +244,7 @@ GamepadService::FireButtonEvent(EventTarget* aTarget,
{
nsString name = aValue == 1.0L ? NS_LITERAL_STRING("gamepadbuttondown") :
NS_LITERAL_STRING("gamepadbuttonup");
GamepadButtonEventInitInitializer init;
GamepadButtonEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mGamepad = aGamepad;
@ -307,7 +307,7 @@ GamepadService::FireAxisMoveEvent(EventTarget* aTarget,
uint32_t aAxis,
double aValue)
{
GamepadAxisMoveEventInitInitializer init;
GamepadAxisMoveEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mGamepad = aGamepad;
@ -388,7 +388,7 @@ GamepadService::FireConnectionEvent(EventTarget* aTarget,
{
nsString name = aConnected ? NS_LITERAL_STRING("gamepadconnected") :
NS_LITERAL_STRING("gamepaddisconnected");
GamepadEventInitInitializer init;
GamepadEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mGamepad = aGamepad;

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

@ -943,7 +943,7 @@ PeerConnectionObserver.prototype = {
{
candidate: candidate,
sdpMid: mid,
sdpMLineIndex: level
sdpMLineIndex: level - 1
}
));
},

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

@ -34,8 +34,6 @@ this.EXPORTED_SYMBOLS = ["PermissionPromptHelper"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PermissionsInstaller.jsm");
Cu.import("resource://gre/modules/PermissionsTable.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",

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

@ -916,6 +916,25 @@ NetworkManager.prototype = {
}
},
// Enable/Disable DHCP server.
setDhcpServer: function setDhcpServer(enabled, config, callback) {
if (null === config) {
config = {};
}
config.cmd = "setDhcpServer";
config.isAsync = true;
config.enabled = enabled;
this.controlMessage(config, function setDhcpServerResult(response) {
if (!response.success) {
callback.dhcpServerResult('Set DHCP server error');
return;
}
callback.dhcpServerResult(null);
});
},
// Enable/disable WiFi tethering by sending commands to netd.
setWifiTethering: function setWifiTethering(enable, network, config, callback) {
if (!network) {

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

@ -213,6 +213,40 @@ self.onmessage = function onmessage(event) {
}
};
/**
* Start/Stop DHCP server.
*/
function setDhcpServer(config) {
function onSuccess() {
postMessage({ id: config.id, success: true });
return true;
}
function onError() {
postMessage({ id: config.id, success: false });
}
let startDhcpServerChain = [setInterfaceUp,
startTethering,
onSuccess];
let stopDhcpServerChain = [stopTethering,
onSuccess];
if (config.enabled) {
let params = { wifiStartIp: config.startIp,
wifiEndIp: config.endIp,
ip: config.serverIp,
prefix: config.maskLength,
ifname: config.ifname,
link: "up" };
chain(params, startDhcpServerChain, onError);
} else {
chain({}, stopDhcpServerChain, onError);
}
}
/**
* Set DNS servers for given network interface.
*/
@ -455,8 +489,14 @@ function startTethering(params, callback) {
if (params.resultReason.indexOf("started") !== -1) {
command = DUMMY_COMMAND;
} else {
command = "tether start " + params.wifiStartIp + " " + params.wifiEndIp +
" " + params.usbStartIp + " " + params.usbEndIp;
command = "tether start " + params.wifiStartIp + " " + params.wifiEndIp;
// If usbStartIp/usbEndIp is not valid, don't append them since
// the trailing white spaces will be parsed to extra empty args
// See: http://androidxref.com/4.3_r2.1/xref/system/core/libsysutils/src/FrameworkListener.cpp#78
if (params.usbStartIp && params.usbEndIp) {
command += " " + params.usbStartIp + " " + params.usbEndIp;
}
}
return doCommand(command, callback);
}

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

@ -117,10 +117,23 @@ interface nsIWifiOperationModeCallback : nsISupports
void wifiOperationModeResult(in jsval error);
};
[scriptable, function, uuid(097878b0-19fc-11e3-8ffd-0800200c9a66)]
interface nsISetDhcpServerCallback : nsISupports
{
/**
* Callback function used to report DHCP server result
*
* @param error
* An error message if the operation wasn't successful,
* or `null` if it was.
*/
void dhcpServerResult(in jsval error);
};
/**
* Manage network interfaces.
*/
[scriptable, uuid(fad3fb08-664f-48e3-bba3-423186988c61)]
[scriptable, uuid(f658c740-26bb-11e3-8224-0800200c9a66)]
interface nsINetworkManager : nsISupports
{
/**
@ -205,6 +218,30 @@ interface nsINetworkManager : nsISupports
in jsval config,
in nsIWifiTetheringCallback callback);
/**
* Enable or disable DHCP server
*
* @param enabled
* Boolean that indicates enabling or disabling DHCP server.
*
* @param config
* Config used to enable the DHCP server. It contains
* .startIp start of the ip lease range (string)
* .endIp end of the ip lease range (string)
* .serverIp ip of the DHCP server (string)
* .maskLength the length of the subnet mask
* .ifname the interface name
*
* As for disabling the DHCP server, put this value |null|.
*
* @param callback
* Callback function used to report status.
*/
void setDhcpServer(in boolean enabled,
in jsval config,
in nsISetDhcpServerCallback callback);
/**
* Retrieve network interface stats.
*

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

@ -239,7 +239,7 @@ void
nsDeviceSensors::FireDOMLightEvent(mozilla::dom::EventTarget* aTarget,
double aValue)
{
DeviceLightEventInitInitializer init;
DeviceLightEventInit init;
init.mBubbles = true;
init.mCancelable = false;
init.mValue = aValue;
@ -258,7 +258,7 @@ nsDeviceSensors::FireDOMProximityEvent(mozilla::dom::EventTarget* aTarget,
double aMin,
double aMax)
{
DeviceProximityEventInitInitializer init;
DeviceProximityEventInit init;
init.mBubbles = true;
init.mCancelable = false;
init.mValue = aValue;
@ -289,7 +289,7 @@ void
nsDeviceSensors::FireDOMUserProximityEvent(mozilla::dom::EventTarget* aTarget,
bool aNear)
{
UserProximityEventInitInitializer init;
UserProximityEventInit init;
init.mBubbles = true;
init.mCancelable = false;
init.mNear = aNear;

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

@ -87,8 +87,8 @@ private:
mozilla::RefPtr<MacIOSurface> mIOSurface;
uint32_t mFBO;
uint32_t mIOTexture;
uint32_t mUnsupportedWidth;
uint32_t mUnsupportedHeight;
int mUnsupportedWidth;
int mUnsupportedHeight;
AllowOfflineRendererEnum mAllowOfflineRenderer;
double mContentsScaleFactor;
};

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

@ -807,7 +807,8 @@ void nsCARenderer::AttachIOSurface(RefPtr<MacIOSurface> aSurface) {
// Rebind the FBO to make it live
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
if (mIOSurface->GetWidth() != width || mIOSurface->GetHeight() != height) {
if (static_cast<int>(mIOSurface->GetWidth()) != width ||
static_cast<int>(mIOSurface->GetHeight()) != height) {
width = mIOSurface->GetWidth();
height = mIOSurface->GetHeight();
SetBounds(width, height);

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

@ -440,81 +440,25 @@ gfxPlatformMac::SupportsOffMainThreadCompositing()
qcms_profile *
gfxPlatformMac::GetPlatformCMSOutputProfile()
{
qcms_profile *profile = nullptr;
CMProfileRef cmProfile;
CMProfileLocation *location;
UInt32 locationSize;
/* There a number of different ways that we could try to get a color
profile to use. On 10.5 all of these methods seem to give the same
results. On 10.6, the results are different and the following method,
using CGMainDisplayID() seems to best match what we are looking for.
Currently, both Google Chrome and Qt4 use a similar method.
CMTypes.h describes CMDisplayIDType:
"Data type for ColorSync DisplayID reference
On 8 & 9 this is a AVIDType
On X this is a CGSDisplayID"
CGMainDisplayID gives us a CGDirectDisplayID which presumeably
corresponds directly to a CGSDisplayID */
CGDirectDisplayID displayID = CGMainDisplayID();
CMError err = CMGetProfileByAVID(static_cast<CMDisplayIDType>(displayID), &cmProfile);
if (err != noErr)
return nullptr;
// get the size of location
err = NCMGetProfileLocation(cmProfile, nullptr, &locationSize);
if (err != noErr)
return nullptr;
// allocate enough room for location
location = static_cast<CMProfileLocation*>(malloc(locationSize));
if (!location)
goto fail_close;
err = NCMGetProfileLocation(cmProfile, location, &locationSize);
if (err != noErr)
goto fail_location;
switch (location->locType) {
#ifndef __LP64__
case cmFileBasedProfile: {
FSRef fsRef;
if (!FSpMakeFSRef(&location->u.fileLoc.spec, &fsRef)) {
char path[512];
if (!FSRefMakePath(&fsRef, reinterpret_cast<UInt8*>(path), sizeof(path))) {
profile = qcms_profile_from_path(path);
#ifdef DEBUG_tor
if (profile)
fprintf(stderr,
"ICM profile read from %s fileLoc successfully\n", path);
#endif
}
}
break;
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
if (!cspace) {
cspace = ::CGColorSpaceCreateDeviceRGB();
}
#endif
case cmPathBasedProfile:
profile = qcms_profile_from_path(location->u.pathLoc.path);
#ifdef DEBUG_tor
if (profile)
fprintf(stderr,
"ICM profile read from %s pathLoc successfully\n",
device.u.pathLoc.path);
#endif
break;
default:
#ifdef DEBUG_tor
fprintf(stderr, "Unhandled ColorSync profile location\n");
#endif
break;
if (!cspace) {
return nullptr;
}
fail_location:
free(location);
fail_close:
CMCloseProfile(cmProfile);
CFDataRef iccp = ::CGColorSpaceCopyICCProfile(cspace);
::CFRelease(cspace);
if (!iccp) {
return nullptr;
}
qcms_profile* profile = qcms_profile_from_memory(::CFDataGetBytePtr(iccp), static_cast<size_t>(::CFDataGetLength(iccp)));
::CFRelease(iccp);
return profile;
}

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

@ -1566,18 +1566,17 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
ns.addstmts([ tfDecl, Whitespace.NL ])
self.funcDefns.append(tfDefn)
typedefs = self.protocol.decl.cxxtypedefs
for md in p.messageDecls:
ns.addstmts([
_generateMessageClass(md.msgClass(), md.msgId(),
typedefs, md.prettyMsgName(p.name+'::'),
md.prettyMsgName(p.name+'::'),
md.decl.type.compress),
Whitespace.NL ])
if md.hasReply():
ns.addstmts([
_generateMessageClass(
md.replyClass(), md.replyId(),
typedefs, md.prettyReplyName(p.name+'::'),
md.prettyReplyName(p.name+'::'),
md.decl.type.compress),
Whitespace.NL ])
@ -1768,12 +1767,8 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
##--------------------------------------------------
def _generateMessageClass(clsname, msgid, typedefs, prettyName, compress):
def _generateMessageClass(clsname, msgid, prettyName, compress):
cls = Class(name=clsname, inherits=[ Inherit(Type('IPC::Message')) ])
cls.addstmt(Label.PRIVATE)
cls.addstmts(typedefs)
cls.addstmt(Whitespace.NL)
cls.addstmt(Label.PUBLIC)
idenum = TypeEnum()

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

@ -7,6 +7,8 @@
#ifndef js_HeapAPI_h
#define js_HeapAPI_h
#include <limits.h>
#include "jspubtd.h"
#include "js/Utility.h"
@ -134,8 +136,9 @@ GetGCThingMarkWordAndMask(const void *thing, uint32_t color,
size_t bit = (addr & js::gc::ChunkMask) / js::gc::CellSize + color;
JS_ASSERT(bit < js::gc::ChunkMarkBitmapBits);
uintptr_t *bitmap = GetGCThingMarkBitmap(thing);
*maskp = uintptr_t(1) << (bit % JS_BITS_PER_WORD);
*wordp = &bitmap[bit / JS_BITS_PER_WORD];
const uintptr_t nbits = sizeof(*bitmap) * CHAR_BIT;
*maskp = uintptr_t(1) << (bit % nbits);
*wordp = &bitmap[bit / nbits];
}
static JS_ALWAYS_INLINE JS::shadow::ArenaHeader *

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

@ -9,6 +9,8 @@
#include "mozilla/TemplateLib.h"
#include <limits.h>
#include "jstypes.h"
namespace js {
@ -16,8 +18,9 @@ namespace js {
template <size_t nbits>
class BitArray {
private:
static const size_t bitsPerElement = sizeof(uintptr_t) * CHAR_BIT;
static const size_t numSlots =
nbits / JS_BITS_PER_WORD + (nbits % JS_BITS_PER_WORD == 0 ? 0 : 1);
nbits / bitsPerElement + (nbits % bitsPerElement == 0 ? 0 : 1);
uintptr_t map[numSlots];
public:
@ -54,8 +57,10 @@ class BitArray {
private:
inline void getMarkWordAndMask(size_t offset,
uintptr_t *indexp, uintptr_t *maskp) const {
*indexp = offset >> mozilla::tl::FloorLog2<JS_BITS_PER_WORD>::value;
*maskp = uintptr_t(1) << (offset & (JS_BITS_PER_WORD - 1));
static_assert(bitsPerElement == 32 || bitsPerElement == 64,
"unexpected bitsPerElement value");
*indexp = offset / bitsPerElement;
*maskp = uintptr_t(1) << (offset % bitsPerElement);
}
};

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

@ -2766,7 +2766,12 @@ CodeGenerator::generateBody()
#endif
for (; iter != current->end(); iter++) {
IonSpew(IonSpew_Codegen, "instruction %s", iter->opName());
IonSpewStart(IonSpew_Codegen, "instruction %s", iter->opName());
#ifdef DEBUG
if (const char *extra = iter->extraName())
IonSpewCont(IonSpew_Codegen, ":%s", extra);
#endif
IonSpewFin(IonSpew_Codegen);
if (counts)
blockCounts.ref().visitInstruction(*iter);

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

@ -168,6 +168,9 @@ class LPointer : public LInstructionHelper<1, 0, 0>
Kind kind() const {
return kind_;
}
const char *extraName() const {
return kind_ == GC_THING ? "GC_THING" : "NON_GC_THING";
}
gc::Cell *gcptr() const {
JS_ASSERT(kind() == GC_THING);
@ -1542,6 +1545,9 @@ class LCompare : public LInstructionHelper<1, 2, 0>
MCompare *mir() {
return mir_->toCompare();
}
const char *extraName() const {
return js_CodeName[jsop_];
}
};
// Compares two integral values of the same JS type, either integer or object.
@ -1580,6 +1586,9 @@ class LCompareAndBranch : public LControlInstructionHelper<2, 2, 0>
MCompare *mir() {
return mir_->toCompare();
}
const char *extraName() const {
return js_CodeName[jsop_];
}
};
class LCompareD : public LInstructionHelper<1, 2, 0>
@ -2020,7 +2029,7 @@ class LBitOpI : public LInstructionHelper<1, 2, 0>
const char *extraName() const {
if (bitop() == JSOP_URSH && mir_->toUrsh()->canOverflow())
return "UrshCanOverflow";
return nullptr;
return js_CodeName[op_];
}
JSOp bitop() const {
@ -2044,6 +2053,10 @@ class LBitOpV : public LCallInstructionHelper<1, 2 * BOX_PIECES, 0>
return jsop_;
}
const char *extraName() const {
return js_CodeName[jsop_];
}
static const size_t LhsInput = 0;
static const size_t RhsInput = BOX_PIECES;
};
@ -2068,6 +2081,10 @@ class LShiftI : public LBinaryMath<0>
MInstruction *mir() {
return mir_->toInstruction();
}
const char *extraName() const {
return js_CodeName[op_];
}
};
class LUrshD : public LBinaryMath<1>
@ -2123,6 +2140,9 @@ class LMinMaxI : public LInstructionHelper<1, 2, 0>
MMinMax *mir() const {
return mir_->toMinMax();
}
const char *extraName() const {
return mir()->isMax() ? "Max" : "Min";
}
};
class LMinMaxD : public LInstructionHelper<1, 2, 0>
@ -2147,6 +2167,9 @@ class LMinMaxD : public LInstructionHelper<1, 2, 0>
MMinMax *mir() const {
return mir_->toMinMax();
}
const char *extraName() const {
return mir()->isMax() ? "Max" : "Min";
}
};
// Negative of an integer
@ -2312,6 +2335,9 @@ class LMathFunctionD : public LCallInstructionHelper<1, 1, 1>
MMathFunction *mir() const {
return mir_->toMathFunction();
}
const char *extraName() const {
return MMathFunction::FunctionName(mir()->function());
}
};
// Adds two integers, returning an integer value.
@ -2377,6 +2403,10 @@ class LMathD : public LBinaryMath<0>
JSOp jsop() const {
return jsop_;
}
const char *extraName() const {
return js_CodeName[jsop_];
}
};
// Performs an add, sub, mul, or div on two double values.
@ -2394,6 +2424,10 @@ class LMathF: public LBinaryMath<0>
JSOp jsop() const {
return jsop_;
}
const char *extraName() const {
return js_CodeName[jsop_];
}
};
class LModD : public LBinaryMath<1>
@ -2431,6 +2465,10 @@ class LBinaryV : public LCallInstructionHelper<BOX_PIECES, 2 * BOX_PIECES, 0>
return jsop_;
}
const char *extraName() const {
return js_CodeName[jsop_];
}
static const size_t LhsInput = 0;
static const size_t RhsInput = BOX_PIECES;
};
@ -4001,6 +4039,9 @@ class LSetPropertyPolymorphicT : public LInstructionHelper<0, 2, 1>
const MSetPropertyPolymorphic *mir() const {
return mir_->toSetPropertyPolymorphic();
}
const char *extraName() const {
return StringFromMIRType(valueType_);
}
};
class LGetElementCacheV : public LInstructionHelper<BOX_PIECES, 1 + BOX_PIECES, 0>
@ -4356,6 +4397,9 @@ class LSetPropertyCacheT : public LInstructionHelper<0, 2, 1>
MIRType valueType() {
return valueType_;
}
const char *extraName() const {
return StringFromMIRType(valueType_);
}
};
class LSetElementCacheV : public LInstructionHelper<0, 1 + 2 * BOX_PIECES, 3>

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

@ -554,6 +554,45 @@ MAssertRange::printOpcode(FILE *fp) const
fprintf(fp, " %s", sp.string());
}
const char *
MMathFunction::FunctionName(Function function)
{
switch (function) {
case Log: return "Log";
case Sin: return "Sin";
case Cos: return "Cos";
case Exp: return "Exp";
case Tan: return "Tan";
case ACos: return "ACos";
case ASin: return "ASin";
case ATan: return "ATan";
case Log10: return "Log10";
case Log2: return "Log2";
case Log1P: return "Log1P";
case ExpM1: return "ExpM1";
case CosH: return "CosH";
case SinH: return "SinH";
case TanH: return "TanH";
case ACosH: return "ACosH";
case ASinH: return "ASinH";
case ATanH: return "ATanH";
case Sign: return "Sign";
case Trunc: return "Trunc";
case Cbrt: return "Cbrt";
case Floor: return "Floor";
case Round: return "Round";
default:
MOZ_ASSUME_UNREACHABLE("Unknown math function");
}
}
void
MMathFunction::printOpcode(FILE *fp) const
{
MDefinition::printOpcode(fp);
fprintf(fp, " %s", FunctionName(function()));
}
MParameter *
MParameter::New(int32_t index, types::TemporaryTypeSet *types)
{

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

@ -3658,6 +3658,10 @@ class MMathFunction
bool possiblyCalls() const {
return true;
}
void printOpcode(FILE *fp) const;
static const char *FunctionName(Function function);
};
class MAdd : public MBinaryArithInstruction

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

@ -26,6 +26,9 @@ class LBox : public LInstructionHelper<2, 1, 0>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
class LBoxFloatingPoint : public LInstructionHelper<2, 1, 1>
@ -45,6 +48,9 @@ class LBoxFloatingPoint : public LInstructionHelper<2, 1, 1>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
class LUnbox : public LInstructionHelper<1, 2, 0>
@ -83,6 +89,9 @@ class LUnboxFloatingPoint : public LInstructionHelper<1, 2, 0>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
// Convert a 32-bit unsigned integer to a double.

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

@ -27,6 +27,9 @@ class LBox : public LInstructionHelper<1, 1, 0>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
// Given an untyped input, guards on whether it's a specific type and returns
@ -68,6 +71,9 @@ class LUnboxFloatingPoint : public LUnboxBase {
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
// Convert a 32-bit unsigned integer to a double.

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

@ -26,6 +26,9 @@ class LBox : public LInstructionHelper<2, 1, 0>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
class LBoxFloatingPoint : public LInstructionHelper<2, 1, 1>
@ -46,6 +49,9 @@ class LBoxFloatingPoint : public LInstructionHelper<2, 1, 1>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
class LUnbox : public LInstructionHelper<1, 2, 0>
@ -84,6 +90,9 @@ class LUnboxFloatingPoint : public LInstructionHelper<1, 2, 0>
MIRType type() const {
return type_;
}
const char *extraName() const {
return StringFromMIRType(type_);
}
};
// Convert a 32-bit unsigned integer to a double.

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

@ -14,6 +14,8 @@
#include "mozilla/Compiler.h"
#include "mozilla/GuardObjects.h"
#include <limits.h>
#ifdef USE_ZLIB
#include <zlib.h>
#endif
@ -204,16 +206,18 @@ UnsignedPtrDiff(const void *bigger, const void *smaller)
/* A bit array is an array of bits represented by an array of words (size_t). */
static const size_t BitArrayElementBits = sizeof(size_t) * CHAR_BIT;
static inline unsigned
NumWordsForBitArrayOfLength(size_t length)
{
return (length + (JS_BITS_PER_WORD - 1)) / JS_BITS_PER_WORD;
return (length + (BitArrayElementBits - 1)) / BitArrayElementBits;
}
static inline unsigned
BitArrayIndexToWordIndex(size_t length, size_t bitIndex)
{
unsigned wordIndex = bitIndex / JS_BITS_PER_WORD;
unsigned wordIndex = bitIndex / BitArrayElementBits;
JS_ASSERT(wordIndex < length);
return wordIndex;
}
@ -221,7 +225,7 @@ BitArrayIndexToWordIndex(size_t length, size_t bitIndex)
static inline size_t
BitArrayIndexToWordMask(size_t i)
{
return size_t(1) << (i % JS_BITS_PER_WORD);
return size_t(1) << (i % BitArrayElementBits);
}
static inline bool
@ -341,12 +345,13 @@ JS_DumpHistogram(JSBasicStats *bs, FILE *fp);
/* A jsbitmap_t is a long integer that can be used for bitmaps. */
typedef size_t jsbitmap;
#define JS_TEST_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] & \
((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1))))
#define JS_SET_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] |= \
((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1))))
#define JS_CLEAR_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] &= \
~((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1))))
#define JS_BITMAP_NBITS (sizeof(jsbitmap) * CHAR_BIT)
#define JS_TEST_BIT(_map,_bit) ((_map)[(_bit)/JS_BITMAP_NBITS] & \
(jsbitmap(1)<<((_bit)%JS_BITMAP_NBITS)))
#define JS_SET_BIT(_map,_bit) ((_map)[(_bit)/JS_BITMAP_NBITS] |= \
(jsbitmap(1)<<((_bit)%JS_BITMAP_NBITS)))
#define JS_CLEAR_BIT(_map,_bit) ((_map)[(_bit)/JS_BITMAP_NBITS] &= \
~(jsbitmap(1)<<((_bit)%JS_BITMAP_NBITS)))
/* Wrapper for various macros to stop warnings coming from their expansions. */
#if defined(__clang__)

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

@ -77,8 +77,8 @@ class Test:
# Path relative to the top mozilla/ directory.
self.relpath_top = os.path.relpath(path, TOP_SRC_DIR)
# Path relative to mozilla/js/src/.
self.relpath_js = os.path.relpath(path, JS_DIR)
# Path relative to mozilla/js/src/jit-test/tests/.
self.relpath_tests = os.path.relpath(path, TEST_DIR)
self.jitflags = [] # jit flags to enable
self.slow = False # True means the test is slow-running
@ -558,14 +558,14 @@ def process_test_results(results, num_tests, options):
sys.stdout.write(res.err)
ok = check_output(res.out, res.err, res.rc, res.test)
doing = 'after %s' % res.test.relpath_js
doing = 'after %s' % res.test.relpath_tests
if not ok:
failures.append(res)
if res.timed_out:
pb.message("TIMEOUT - %s" % res.test.relpath_js)
pb.message("TIMEOUT - %s" % res.test.relpath_tests)
timeouts += 1
else:
pb.message("FAIL - %s" % res.test.relpath_js)
pb.message("FAIL - %s" % res.test.relpath_tests)
if options.tinderbox:
print_tinderbox(ok, res)

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

@ -766,7 +766,10 @@ public:
if (term.type == PatternTerm::TypeParenthesesSubpattern) {
PatternDisjunction* nestedDisjunction = term.parentheses.disjunction;
for (unsigned alt = 0; alt < nestedDisjunction->m_alternatives.size(); ++alt) {
if (containsCapturingTerms(nestedDisjunction->m_alternatives[alt], 0, nestedDisjunction->m_alternatives[alt]->m_terms.size() - 1))
PatternAlternative *pattern = nestedDisjunction->m_alternatives[alt];
if (pattern->m_terms.size() == 0)
continue;
if (containsCapturingTerms(pattern, 0, pattern->m_terms.size() - 1))
return true;
}
}

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

@ -77,6 +77,22 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, nsStyleContext* aCont
{
}
void
nsHTMLScrollFrame::ScrollbarActivityStarted() const
{
if (mInner.mScrollbarActivity) {
mInner.mScrollbarActivity->ActivityStarted();
}
}
void
nsHTMLScrollFrame::ScrollbarActivityStopped() const
{
if (mInner.mScrollbarActivity) {
mInner.mScrollbarActivity->ActivityStopped();
}
}
nsresult
nsHTMLScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
@ -902,6 +918,22 @@ nsXULScrollFrame::nsXULScrollFrame(nsIPresShell* aShell, nsStyleContext* aContex
mInner.mClipAllDescendants = aClipAllDescendants;
}
void
nsXULScrollFrame::ScrollbarActivityStarted() const
{
if (mInner.mScrollbarActivity) {
mInner.mScrollbarActivity->ActivityStarted();
}
}
void
nsXULScrollFrame::ScrollbarActivityStopped() const
{
if (mInner.mScrollbarActivity) {
mInner.mScrollbarActivity->ActivityStopped();
}
}
nsMargin
nsGfxScrollFrameInner::GetDesiredScrollbarSizes(nsBoxLayoutState* aState)
{

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

@ -520,6 +520,9 @@ public:
return mInner.GetScrollbarBox(aVertical);
}
virtual void ScrollbarActivityStarted() const MOZ_OVERRIDE;
virtual void ScrollbarActivityStopped() const MOZ_OVERRIDE;
// nsIScrollableFrame
virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE {
return mInner.GetScrolledFrame();
@ -810,6 +813,9 @@ public:
return mInner.GetScrollbarBox(aVertical);
}
virtual void ScrollbarActivityStarted() const MOZ_OVERRIDE;
virtual void ScrollbarActivityStopped() const MOZ_OVERRIDE;
// nsIScrollableFrame
virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE {
return mInner.GetScrolledFrame();

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

@ -23,6 +23,13 @@ public:
* if there is no such box.
*/
virtual nsIFrame* GetScrollbarBox(bool aVertical) = 0;
/**
* Show or hide scrollbars on 2 fingers touch.
* Subclasses should call their ScrollbarActivity's corresponding methods.
*/
virtual void ScrollbarActivityStarted() const = 0;
virtual void ScrollbarActivityStopped() const = 0;
};
#endif

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

@ -4495,6 +4495,22 @@ nsTreeBodyFrame::PostScrollEvent()
}
}
void
nsTreeBodyFrame::ScrollbarActivityStarted() const
{
if (mScrollbarActivity) {
mScrollbarActivity->ActivityStarted();
}
}
void
nsTreeBodyFrame::ScrollbarActivityStopped() const
{
if (mScrollbarActivity) {
mScrollbarActivity->ActivityStopped();
}
}
void
nsTreeBodyFrame::DetachImageListeners()
{

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

@ -464,6 +464,9 @@ protected:
void PostScrollEvent();
void FireScrollEvent();
virtual void ScrollbarActivityStarted() const MOZ_OVERRIDE;
virtual void ScrollbarActivityStopped() const MOZ_OVERRIDE;
/**
* Clear the pointer to this frame for all nsTreeImageListeners that were

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

@ -223,6 +223,11 @@ nsIThread* VcmSIPCCBinding::getMainThread()
return gMainThread;
}
nsIEventTarget* VcmSIPCCBinding::getSTSThread()
{
return gSTSThread;
}
void VcmSIPCCBinding::connectCandidateSignal(
NrIceMediaStream *stream)
{
@ -475,38 +480,27 @@ void vcmRxAllocPort(cc_mcapid_t mcap_id,
/**
* Gets the ICE parameters for a stream. Called "alloc" for style consistency
* Gets the ICE objects for a stream.
*
* @param[in] mcap_id - Media Capability ID
* @param[in] group_id - group identifier to which stream belongs.
* @param[in] stream_id - stream identifier
* @param[in] call_handle - call identifier
* @param[in] peerconnection - the peerconnection in use
* @param[out] default_addrp - the ICE default addr
* @param[out] port_allocatedp - the ICE default port
* @param[out] candidatesp - the ICE candidate array
* @param[out] candidate_ctp length of the array
*
* @return 0 for success; VCM_ERROR for failure
*
* @param[in] level - the m-line index (1-based)
* @param[out] ctx - the NrIceCtx
* @param[out] stream - the NrIceStream
*/
static short vcmRxAllocICE_m(cc_mcapid_t mcap_id,
cc_groupid_t group_id,
cc_streamid_t stream_id,
cc_call_handle_t call_handle,
const char *peerconnection,
uint16_t level,
char **default_addrp, /* Out */
int *default_portp, /* Out */
char ***candidatesp, /* Out */
int *candidate_ctp /* Out */
)
{
*default_addrp = NULL;
*default_portp = -1;
*candidatesp = NULL;
*candidate_ctp = 0;
static short vcmGetIceStream_m(cc_mcapid_t mcap_id,
cc_groupid_t group_id,
cc_streamid_t stream_id,
cc_call_handle_t call_handle,
const char *peerconnection,
uint16_t level,
mozilla::RefPtr<NrIceCtx> *ctx,
mozilla::RefPtr<NrIceMediaStream> *stream)
{
CSFLogDebug( logTag, "%s: group_id=%d stream_id=%d call_handle=%d PC = %s",
__FUNCTION__, group_id, stream_id, call_handle, peerconnection);
@ -516,14 +510,57 @@ static short vcmRxAllocICE_m(cc_mcapid_t mcap_id,
sipcc::PeerConnectionWrapper pc(peerconnection);
ENSURE_PC(pc, VCM_ERROR);
*ctx = pc.impl()->media()->ice_ctx();
MOZ_ASSERT(*ctx);
if (!*ctx)
return VCM_ERROR;
CSFLogDebug( logTag, "%s: Getting stream %d", __FUNCTION__, level);
mozilla::RefPtr<NrIceMediaStream> stream = pc.impl()->media()->
ice_media_stream(level-1);
MOZ_ASSERT(stream);
if (!stream) {
*stream = pc.impl()->media()->ice_media_stream(level-1);
MOZ_ASSERT(*stream);
if (!*stream) {
return VCM_ERROR;
}
return 0;
}
/**
* Gets the ICE parameters for a stream. Called "alloc" for style consistency
* @param[in] ctx_in - the ICE ctx
* @param[in] stream_in - the ICE stream
* @param[in] call_handle - call identifier
* @param[in] stream_id - stream identifier
* @param[in] level - the m-line index (1-based)
* @param[out] default_addrp - the ICE default addr
* @param[out] port_allocatedp - the ICE default port
* @param[out] candidatesp - the ICE candidate array
* @param[out] candidate_ctp length of the array
*
* @return 0 for success; VCM_ERROR for failure
*
*/
static short vcmRxAllocICE_s(TemporaryRef<NrIceCtx> ctx_in,
TemporaryRef<NrIceMediaStream> stream_in,
cc_call_handle_t call_handle,
cc_streamid_t stream_id,
uint16_t level,
char **default_addrp, /* Out */
int *default_portp, /* Out */
char ***candidatesp, /* Out */
int *candidate_ctp /* Out */
)
{
// Make a concrete reference to ctx_in and stream_in so we
// can use the pointers (TemporaryRef is not dereferencable).
RefPtr<NrIceCtx> ctx(ctx_in);
RefPtr<NrIceMediaStream> stream(stream_in);
*default_addrp = NULL;
*default_portp = -1;
*candidatesp = NULL;
*candidate_ctp = 0;
// Set the opaque so we can correlate events.
stream->SetOpaque(new VcmIceOpaque(stream_id, call_handle, level));
@ -569,12 +606,12 @@ static short vcmRxAllocICE_m(cc_mcapid_t mcap_id,
/**
* Gets the ICE parameters for a stream. Called "alloc" for style consistency
*
* This is a thunk to vcmRxAllocICE_m
*
* @param[in] mcap_id - media cap id
* @param[in] group_id - group identifier to which stream belongs.
* @param[in] stream_id - stream identifier
* @param[in] call_handle - call identifier
* @param[in] peerconnection - the peerconnection in use
* @param[in] level - the m-line index (1-based)
* @param[out] default_addrp - the ICE default addr
* @param[out] port_allocatedp - the ICE default port
* @param[out] candidatesp - the ICE candidate array
@ -596,19 +633,44 @@ short vcmRxAllocICE(cc_mcapid_t mcap_id,
)
{
int ret;
mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(),
WrapRunnableNMRet(&vcmRxAllocICE_m,
mozilla::RefPtr<NrIceCtx> ctx;
mozilla::RefPtr<NrIceMediaStream> stream;
// First, get a strong ref to the ICE context and stream from the
// main thread.
mozilla::SyncRunnable::DispatchToThread(
VcmSIPCCBinding::getMainThread(),
WrapRunnableNMRet(&vcmGetIceStream_m,
mcap_id,
group_id,
stream_id,
call_handle,
peerconnection,
level,
&ctx,
&stream,
&ret));
if (ret)
return ret;
// Now get the ICE parameters from the STS thread.
// We .forget() the strong refs so that they can be
// released on the STS thread.
mozilla::SyncRunnable::DispatchToThread(
VcmSIPCCBinding::getSTSThread(),
WrapRunnableNMRet(&vcmRxAllocICE_s,
ctx.forget(),
stream.forget(),
call_handle,
stream_id,
level,
default_addrp,
default_portp,
candidatesp,
candidate_ctp,
&ret));
return ret;
}

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

@ -63,6 +63,7 @@ namespace CSF
static void setMainThread(nsIThread *thread);
static nsIThread *getMainThread();
static nsIEventTarget *getSTSThread();
static void setSTSThread(nsIEventTarget *thread);

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

@ -139,7 +139,12 @@ IsNegativeZero(double d)
return bits == DoubleSignBit;
}
/** Returns the exponent portion of the double. */
/**
* Returns the exponent portion of the double.
*
* Zero is not special-cased, so ExponentComponent(0.0) is
* -int_fast16_t(DoubleExponentBias).
*/
static MOZ_ALWAYS_INLINE int_fast16_t
ExponentComponent(double d)
{

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

@ -8,6 +8,8 @@
#include <math.h>
using mozilla::DoublesAreIdentical;
using mozilla::DoubleExponentBias;
using mozilla::ExponentComponent;
using mozilla::IsFinite;
using mozilla::IsInfinite;
using mozilla::IsNaN;
@ -102,6 +104,22 @@ TestDoublesAreIdentical()
ShouldNotBeIdentical(UnspecifiedNaN(), NegativeInfinity());
}
static void
TestExponentComponent()
{
MOZ_ASSERT(ExponentComponent(0.0) == -int_fast16_t(DoubleExponentBias));
MOZ_ASSERT(ExponentComponent(-0.0) == -int_fast16_t(DoubleExponentBias));
MOZ_ASSERT(ExponentComponent(0.125) == -3);
MOZ_ASSERT(ExponentComponent(0.5) == -1);
MOZ_ASSERT(ExponentComponent(1.0) == 0);
MOZ_ASSERT(ExponentComponent(1.5) == 0);
MOZ_ASSERT(ExponentComponent(2.0) == 1);
MOZ_ASSERT(ExponentComponent(7) == 2);
MOZ_ASSERT(ExponentComponent(PositiveInfinity()) == DoubleExponentBias + 1);
MOZ_ASSERT(ExponentComponent(NegativeInfinity()) == DoubleExponentBias + 1);
MOZ_ASSERT(ExponentComponent(UnspecifiedNaN()) == DoubleExponentBias + 1);
}
static void
TestPredicates()
{
@ -152,5 +170,6 @@ int
main()
{
TestDoublesAreIdentical();
TestExponentComponent();
TestPredicates();
}

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

@ -704,6 +704,11 @@ NS_IMETHODIMP _OldStorage::AsyncOpenURI(nsIURI *aURI,
if (!mAppCache && (mLookupAppCache || mOfflineStorage)) {
rv = ChooseApplicationCache(cacheKey, getter_AddRefs(mAppCache));
NS_ENSURE_SUCCESS(rv, rv);
if (mAppCache) {
// From a chosen appcache open only as readonly
aFlags &= ~nsICacheStorage::OPEN_TRUNCATE;
}
}
nsRefPtr<_OldCacheLoad> cacheLoad =

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

@ -2532,7 +2532,7 @@ nsHttpChannel::OpenCacheEntry(bool usingSSL)
NS_ENSURE_SUCCESS(rv, rv);
uint32_t cacheEntryOpenFlags;
if (BYPASS_LOCAL_CACHE(mLoadFlags))
if (BYPASS_LOCAL_CACHE(mLoadFlags) && !mApplicationCache)
cacheEntryOpenFlags = nsICacheStorage::OPEN_TRUNCATE;
else
cacheEntryOpenFlags = nsICacheStorage::OPEN_NORMALLY;

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

@ -1186,14 +1186,6 @@ class Marionette(object):
js = f.read()
return self._send_message('importScript', 'ok', script=js)
def clear_imported_scripts(self):
'''
Clears all imported scripts in this context, ie: calling clear_imported_scripts in chrome
context will clear only scripts you imported in chrome, and will leave the scripts
you imported in content context.
'''
return self._send_message('clearImportedScripts', 'ok')
def add_cookie(self, cookie):
"""
Adds a cookie to your current session.

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

@ -1,105 +1,18 @@
# 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/.
import os
from marionette_test import MarionetteTestCase
from errors import JavascriptException
class TestImportScript(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
def clear_other_context(self):
self.marionette.set_context("chrome")
self.marionette.clear_imported_scripts()
self.marionette.set_context("content")
def check_file_exists(self):
return self.marionette.execute_script("""
let FileUtils = SpecialPowers.Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils;
let importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
return importedScripts.exists();
""", special_powers=True)
def get_file_size(self):
return self.marionette.execute_script("""
let FileUtils = SpecialPowers.Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils;
let importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
return importedScripts.fileSize;
""", special_powers=True)
def test_import_script(self):
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js"))
self.marionette.import_script(js)
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
def test_import_script_twice(self):
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js"))
self.marionette.import_script(js)
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
self.assertTrue(self.check_file_exists())
file_size = self.get_file_size()
self.assertNotEqual(file_size, None)
self.marionette.import_script(js)
file_size = self.get_file_size()
self.assertEqual(file_size, self.get_file_size())
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
def test_import_two_scripts_twice(self):
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js"))
self.marionette.import_script(js)
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
self.assertTrue(self.check_file_exists())
file_size = self.get_file_size()
self.assertNotEqual(file_size, None)
self.marionette.import_script(js)
# same script should not append to file
self.assertEqual(file_size, self.get_file_size())
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importanotherscript.js"))
self.marionette.import_script(js)
new_size = self.get_file_size()
# new script should append to file
self.assertNotEqual(file_size, new_size)
file_size = new_size
self.assertEqual("i'm yet another test function!",
self.marionette.execute_script("return testAnotherFunc();"))
self.assertEqual("i'm yet another test function!",
self.marionette.execute_async_script("marionetteScriptFinished(testAnotherFunc());"))
self.marionette.import_script(js)
# same script should not append to file
self.assertEqual(file_size, self.get_file_size())
def test_import_script_and_clear(self):
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js"))
self.marionette.import_script(js)
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
self.marionette.clear_imported_scripts()
self.assertFalse(self.check_file_exists())
self.assertRaises(JavascriptException, self.marionette.execute_script, "return testFunc();")
self.assertRaises(JavascriptException, self.marionette.execute_async_script, "marionetteScriptFinished(testFunc());")
def test_import_script_and_clear_in_chrome(self):
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js"))
self.marionette.import_script(js)
self.assertTrue(self.check_file_exists())
file_size = self.get_file_size()
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
self.clear_other_context()
# clearing other context's script file should not affect ours
self.assertTrue(self.check_file_exists())
self.assertEqual(file_size, self.get_file_size())
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))
self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());"))
def test_importing_another_script_and_check_they_append(self):
firstjs = os.path.abspath(
os.path.join(__file__, os.path.pardir, "importscript.js"))
@ -118,41 +31,4 @@ class TestImportScript(MarionetteTestCase):
class TestImportScriptChrome(TestImportScript):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_script_timeout(30000)
self.marionette.set_context("chrome")
def clear_other_context(self):
self.marionette.set_context("content")
self.marionette.clear_imported_scripts()
self.marionette.set_context("chrome")
def check_file_exists(self):
return self.marionette.execute_async_script("""
Components.utils.import("resource://gre/modules/FileUtils.jsm");
let checkTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
let f = function() {
if (typeof FileUtils === 'undefined') {
checkTimer.initWithCallback(f, 100, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
return;
}
let importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
marionetteScriptFinished(importedScripts.exists());
};
checkTimer.initWithCallback(f, 100, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
""")
def get_file_size(self):
return self.marionette.execute_async_script("""
Components.utils.import("resource://gre/modules/FileUtils.jsm");
let checkTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
let f = function() {
if (typeof FileUtils === 'undefined') {
checkTimer.initWithCallback(f, 100, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
return;
}
let importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
marionetteScriptFinished(importedScripts.fileSize);
};
checkTimer.initWithCallback(f, 100, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
""")

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

@ -96,7 +96,7 @@ function registerSelf() {
if (register[0]) {
listenerId = register[0].id;
importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
importedScripts = FileUtils.File(register[0].importedScripts);
startListeners();
}
}

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

@ -134,8 +134,7 @@ function MarionetteServerConnection(aPrefix, aTransport, aServer)
this.command_id = null;
this.mainFrame = null; //topmost chrome frame
this.curFrame = null; // chrome iframe that currently has focus
this.importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
this.importedScriptHashes = {"chrome" : [], "content": []};
this.importedScripts = FileUtils.getFile('TmpD', ['marionettescriptchrome']);
this.currentFrameElement = null;
this.testName = null;
this.mozBrowserClose = null;
@ -466,16 +465,6 @@ MarionetteServerConnection.prototype = {
return this.uuidGen.generateUUID().toString();
},
/**
* Given a file name, this will delete the file from the temp directory if it exists
*/
deleteFile: function(filename) {
let file = FileUtils.getFile('TmpD', [filename.toString()]);
if (file.exists()) {
file.remove(true);
}
},
/**
* Marionette API:
*
@ -1944,13 +1933,7 @@ MarionetteServerConnection.prototype = {
// if there is only 1 window left, delete the session
if (numOpenWindows === 1){
try {
this.sessionTearDown();
}
catch (e) {
this.sendError("Could not clear session", 500, e.name + ": " + e.message, command_id);
return;
}
this.sessionTearDown();
this.sendOk(command_id);
return;
}
@ -2007,23 +1990,20 @@ MarionetteServerConnection.prototype = {
if (this.mainFrame) {
this.mainFrame.focus();
}
this.deleteFile('marionetteChromeScripts');
this.deleteFile('marionetteContentScripts');
try {
this.importedScripts.remove(false);
}
catch (e) {
}
},
/**
* Processes the 'deleteSession' request from the client by tearing down
* the session and responding 'ok'.
*/
deleteSession: function MDA_deleteSession() {
deleteSession: function MDA_sessionTearDown() {
let command_id = this.command_id = this.getCommandId();
try {
this.sessionTearDown();
}
catch (e) {
this.sendError("Could not delete session", 500, e.name + ": " + e.message, command_id);
return;
}
this.sessionTearDown();
this.sendOk(command_id);
},
@ -2074,23 +2054,6 @@ MarionetteServerConnection.prototype = {
importScript: function MDA_importScript(aRequest) {
let command_id = this.command_id = this.getCommandId();
let converter =
Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8";
let result = {};
let data = converter.convertToByteArray(aRequest.script, result);
let ch = Components.classes["@mozilla.org/security/hash;1"]
.createInstance(Components.interfaces.nsICryptoHash);
ch.init(ch.MD5);
ch.update(data, data.length);
let hash = ch.finish(true);
if (this.importedScriptHashes[this.context].indexOf(hash) > -1) {
//we have already imported this script
this.sendOk(command_id);
return;
}
this.importedScriptHashes[this.context].push(hash);
if (this.context == "chrome") {
let file;
if (this.importedScripts.exists()) {
@ -2116,23 +2079,6 @@ MarionetteServerConnection.prototype = {
}
},
clearImportedScripts: function MDA_clearImportedScripts(aRequest) {
let command_id = this.command_id = this.getCommandId();
try {
if (this.context == "chrome") {
this.deleteFile('marionetteChromeScripts');
}
else {
this.deleteFile('marionetteContentScripts');
}
}
catch (e) {
this.sendError("Could not clear imported scripts", 500, e.name + ": " + e.message, command_id);
return;
}
this.sendOk(command_id);
},
/**
* Takes a screenshot of a DOM node. If there is no node given a screenshot
* of the window will be taken.
@ -2250,6 +2196,7 @@ MarionetteServerConnection.prototype = {
listenerWindow);
}
this.curBrowser.elementManager.seenItems[reg.id] = Cu.getWeakReference(listenerWindow);
reg.importedScripts = this.importedScripts.path;
if (nullPrevious && (this.curBrowser.curFrameId != null)) {
if (!this.sendAsync("newSession",
{ B2G: (appName == "B2G") },
@ -2314,7 +2261,6 @@ MarionetteServerConnection.prototype.requestTypes = {
"deleteSession": MarionetteServerConnection.prototype.deleteSession,
"emulatorCmdResult": MarionetteServerConnection.prototype.emulatorCmdResult,
"importScript": MarionetteServerConnection.prototype.importScript,
"clearImportedScripts": MarionetteServerConnection.prototype.clearImportedScripts,
"getAppCacheStatus": MarionetteServerConnection.prototype.getAppCacheStatus,
"closeWindow": MarionetteServerConnection.prototype.closeWindow,
"setTestName": MarionetteServerConnection.prototype.setTestName,

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

@ -48,7 +48,11 @@ this.MockFilePicker = {
filterAudio: Ci.nsIFilePicker.filterAudio,
filterVideo: Ci.nsIFilePicker.filterVideo,
window: null,
init: function(window) {
this.window = window;
this.reset();
this.factory = newFactory(window);
if (!registrar.isCIDRegistered(newClassID)) {
@ -86,6 +90,22 @@ this.MockFilePicker = {
var file = FileUtils.getFile("TmpD", ["testfile"]);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
this.returnFiles = [file];
},
useBlobFile: function() {
var blob = new this.window.Blob([]);
var file = new this.window.File(blob, { name: 'helloworld.txt', type: 'plain/text' });
this.returnFiles = [file];
},
isNsIFile: function(aFile) {
let ret = false;
try {
if (aFile.QueryInterface(Ci.nsIFile))
ret = true;
} catch(e) {}
return ret;
}
};
@ -113,12 +133,21 @@ MockFilePickerInstance.prototype = {
filterIndex: 0,
displayDirectory: null,
get file() {
if (MockFilePicker.returnFiles.length >= 1)
if (MockFilePicker.returnFiles.length >= 1 &&
// window.File does not implement nsIFile
MockFilePicker.isNsIFile(MockFilePicker.returnFiles[0])) {
return MockFilePicker.returnFiles[0];
}
return null;
},
get domfile() {
if (MockFilePicker.returnFiles.length >= 1) {
// window.File does not implement nsIFile
if (!MockFilePicker.isNsIFile(MockFilePicker.returnFiles[0])) {
return MockFilePicker.returnFiles[0];
}
let utils = this.parent.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
return utils.wrapDOMFile(MockFilePicker.returnFiles[0]);
@ -126,8 +155,12 @@ MockFilePickerInstance.prototype = {
return null;
},
get fileURL() {
if (MockFilePicker.returnFiles.length >= 1)
if (MockFilePicker.returnFiles.length >= 1 &&
// window.File does not implement nsIFile
MockFilePicker.isNsIFile(MockFilePicker.returnFiles[0])) {
return Services.io.newFileURI(MockFilePicker.returnFiles[0]);
}
return null;
},
get files() {
@ -138,13 +171,17 @@ MockFilePickerInstance.prototype = {
return this.index < MockFilePicker.returnFiles.length;
},
getNext: function() {
// window.File does not implement nsIFile
if (!MockFilePicker.isNsIFile(MockFilePicker.returnFiles[this.index])) {
return null;
}
return MockFilePicker.returnFiles[this.index++];
}
};
},
get domfiles() {
let utils = this.parent.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
.getInterface(Ci.nsIDOMWindowUtils);
return {
index: 0,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]),
@ -152,6 +189,10 @@ MockFilePickerInstance.prototype = {
return this.index < MockFilePicker.returnFiles.length;
},
getNext: function() {
// window.File does not implement nsIFile
if (!MockFilePicker.isNsIFile(MockFilePicker.returnFiles[this.index])) {
return MockFilePicker.returnFiles[this.index++];
}
return utils.wrapDOMFile(MockFilePicker.returnFiles[this.index++]);
}
};

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

@ -50,10 +50,8 @@ let gMgr = Cc["@mozilla.org/memory-reporter-manager;1"]
// We need to know about "child-memory-reporter-update" events from child
// processes.
let gOs = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
gOs.addObserver(updateAboutMemoryFromReporters,
"child-memory-reporter-update", false);
Services.obs.addObserver(updateAboutMemoryFromReporters,
"child-memory-reporter-update", false);
let gUnnamedProcessStr = "Main Process";
@ -122,8 +120,8 @@ function debug(x)
function onUnload()
{
gOs.removeObserver(updateAboutMemoryFromReporters,
"child-memory-reporter-update");
Services.obs.removeObserver(updateAboutMemoryFromReporters,
"child-memory-reporter-update");
}
//---------------------------------------------------------------------------
@ -411,9 +409,7 @@ function onLoad()
function doGC()
{
Cu.forceGC();
let os = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "child-gc-request", null);
Services.obs.notifyObservers(null, "child-gc-request", null);
updateMainAndFooter("Garbage collection completed", HIDE_FOOTER);
}
@ -422,9 +418,7 @@ function doCC()
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.cycleCollect();
let os = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "child-cc-request", null);
Services.obs.notifyObservers(null, "child-cc-request", null);
updateMainAndFooter("Cycle collection completed", HIDE_FOOTER);
}
@ -440,7 +434,7 @@ function doMeasure()
// update the page. If any reports come back from children,
// updateAboutMemoryFromReporters() will be called again and the page will
// regenerate.
gOs.notifyObservers(null, "child-memory-reporter-request", null);
Services.obs.notifyObservers(null, "child-memory-reporter-request", null);
updateAboutMemoryFromReporters();
}
@ -616,8 +610,6 @@ function updateAboutMemoryFromTwoFiles(aFilename1, aFilename2)
function updateAboutMemoryFromClipboard()
{
// Get the clipboard's contents.
let cb = Cc["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
let transferable = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);
let loadContext = window.QueryInterface(Ci.nsIInterfaceRequestor)
@ -625,7 +617,7 @@ function updateAboutMemoryFromClipboard()
.QueryInterface(Ci.nsILoadContext);
transferable.init(loadContext);
transferable.addDataFlavor('text/unicode');
cb.getData(transferable, Ci.nsIClipboard.kGlobalClipboard);
Services.clipboard.getData(transferable, Ci.nsIClipboard.kGlobalClipboard);
var cbData = {};
try {

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

@ -6,6 +6,8 @@
mozilla_StartupTimeline_Event(PROCESS_CREATION, "process")
mozilla_StartupTimeline_Event(START, "start")
mozilla_StartupTimeline_Event(MAIN, "main")
mozilla_StartupTimeline_Event(SELECT_PROFILE, "selectProfile")
mozilla_StartupTimeline_Event(AFTER_PROFILE_LOCKED, "afterProfileLocked")
// Record the beginning and end of startup crash detection to compare with crash stats to know whether
// detection should be improved to start or end sooner.
mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_BEGIN, "startupCrashDetectionBegin")

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

@ -2037,6 +2037,8 @@ static nsresult
SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, nsINativeAppSupport* aNative,
bool* aStartOffline, nsACString* aProfileName)
{
StartupTimeline::Record(StartupTimeline::SELECT_PROFILE);
nsresult rv;
ArgResult ar;
const char* arg;
@ -2311,17 +2313,31 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
else
gDoProfileReset = false;
}
// If you close Firefox and very quickly reopen it, the old Firefox may
// still be closing down. Rather than immediately showing the
// "Firefox is running but is not responding" message, we spend a few
// seconds retrying first.
static const int kLockRetrySeconds = 5;
static const int kLockRetrySleepMS = 100;
nsCOMPtr<nsIProfileUnlocker> unlocker;
rv = profile->Lock(getter_AddRefs(unlocker), aResult);
if (NS_SUCCEEDED(rv)) {
// Try to grab the profile name.
if (aProfileName) {
rv = profile->GetName(*aProfileName);
if (NS_FAILED(rv))
aProfileName->Truncate(0);
const TimeStamp start = TimeStamp::Now();
do {
rv = profile->Lock(getter_AddRefs(unlocker), aResult);
if (NS_SUCCEEDED(rv)) {
StartupTimeline::Record(StartupTimeline::AFTER_PROFILE_LOCKED);
// Try to grab the profile name.
if (aProfileName) {
rv = profile->GetName(*aProfileName);
if (NS_FAILED(rv))
aProfileName->Truncate(0);
}
return NS_OK;
}
return NS_OK;
}
PR_Sleep(kLockRetrySleepMS);
} while (TimeStamp::Now() - start < TimeDuration::FromSeconds(kLockRetrySeconds));
return ProfileLockedDialog(profile, unlocker, aNative, aResult);
}

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

@ -429,6 +429,8 @@ enum nsEventStructType
#define NS_WHEEL_EVENT_START 5400
#define NS_WHEEL_WHEEL (NS_WHEEL_EVENT_START)
#define NS_WHEEL_START (NS_WHEEL_EVENT_START + 1)
#define NS_WHEEL_STOP (NS_WHEEL_EVENT_START + 2)
//System time is changed
#define NS_MOZ_TIME_CHANGE_EVENT 5500

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

@ -205,6 +205,12 @@ typedef NSInteger NSEventGestureAxis;
#endif // #ifdef __LP64__
#endif // #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
#if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
enum {
NSEventPhaseMayBegin = 0x1 << 5
};
#endif // #if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
// Undocumented scrollPhase flag that lets us discern between real scrolls and
// automatically firing momentum scroll events.
@interface NSEvent (ScrollPhase)
@ -251,6 +257,11 @@ typedef NSInteger NSEventGestureAxis;
NSMutableArray* mPendingDirtyRects;
BOOL mPendingFullDisplay;
BOOL mPendingDisplay;
// WheelStart/Stop events should always come in pairs. This BOOL records the
// last received event so that, when we receive one of the events, we make sure
// to send its pair event first, in case we didn't yet for any reason.
BOOL mExpectingWheelStop;
// Holds our drag service across multiple drag calls. The reference to the
// service is obtained when the mouse enters the view and is released when
@ -354,6 +365,8 @@ typedef NSInteger NSEventGestureAxis;
- (void)rotateWithEvent:(NSEvent *)anEvent;
- (void)endGestureWithEvent:(NSEvent *)anEvent;
- (void)scrollWheel:(NSEvent *)anEvent;
// Helper function for Lion smart magnify events
+ (BOOL)isLionSmartMagnifyEvent:(NSEvent*)anEvent;

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

@ -140,8 +140,10 @@ uint32_t nsChildView::sLastInputEventCount = 0;
- (void)forceRefreshOpenGL;
// set up a gecko mouse event based on a cocoa mouse event
- (void) convertCocoaMouseWheelEvent:(NSEvent*)aMouseEvent
toGeckoEvent:(WidgetWheelEvent*)outWheelEvent;
- (void) convertCocoaMouseEvent:(NSEvent*)aMouseEvent
toGeckoEvent:(WidgetInputEvent*)outGeckoEvent;
toGeckoEvent:(WidgetInputEvent*)outWheelEvent;
- (NSMenu*)contextMenu;
@ -2776,6 +2778,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
#endif
mPendingDisplay = NO;
mBlockedLastMouseDown = NO;
mExpectingWheelStop = NO;
mLastMouseDownEvent = nil;
mClickThroughMouseDownEvent = nil;
@ -4705,6 +4708,22 @@ static int32_t RoundUp(double aDouble)
static_cast<int32_t>(ceil(aDouble));
}
- (void)sendWheelStartOrStop:(uint32_t)msg forEvent:(NSEvent *)theEvent
{
WidgetWheelEvent wheelEvent(true, msg, mGeckoChild);
[self convertCocoaMouseWheelEvent:theEvent toGeckoEvent:&wheelEvent];
mExpectingWheelStop = (msg == NS_WHEEL_START);
mGeckoChild->DispatchWindowEvent(wheelEvent);
}
- (void)sendWheelCondition:(BOOL)condition first:(uint32_t)first second:(uint32_t)second forEvent:(NSEvent *)theEvent
{
if (mExpectingWheelStop == condition) {
[self sendWheelStartOrStop:first forEvent:theEvent];
}
[self sendWheelStartOrStop:second forEvent:theEvent];
}
- (void)scrollWheel:(NSEvent*)theEvent
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@ -4721,24 +4740,21 @@ static int32_t RoundUp(double aDouble)
return;
}
WheelEvent wheelEvent(true, NS_WHEEL_WHEEL, mGeckoChild);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&wheelEvent];
wheelEvent.deltaMode =
Preferences::GetBool("mousewheel.enable_pixel_scrolling", true) ?
nsIDOMWheelEvent::DOM_DELTA_PIXEL : nsIDOMWheelEvent::DOM_DELTA_LINE;
NSEventPhase phase = [theEvent phase];
// Calling deviceDeltaX or deviceDeltaY on theEvent will trigger a Cocoa
// assertion and an Objective-C NSInternalInconsistencyException if the
// underlying "Carbon" event doesn't contain pixel scrolling information.
// For these events, carbonEventKind is kEventMouseWheelMoved instead of
// kEventMouseScroll.
if (wheelEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL) {
EventRef theCarbonEvent = [theEvent _eventRef];
UInt32 carbonEventKind = theCarbonEvent ? ::GetEventKind(theCarbonEvent) : 0;
if (carbonEventKind != kEventMouseScroll) {
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
}
// Fire NS_WHEEL_START/STOP events when 2 fingers touch/release the touchpad.
if (phase & NSEventPhaseMayBegin) {
[self sendWheelCondition:YES first:NS_WHEEL_STOP second:NS_WHEEL_START forEvent:theEvent];
return;
}
if (phase & (NSEventPhaseEnded | NSEventPhaseCancelled)) {
[self sendWheelCondition:NO first:NS_WHEEL_START second:NS_WHEEL_STOP forEvent:theEvent];
return;
}
WidgetWheelEvent wheelEvent(true, NS_WHEEL_WHEEL, mGeckoChild);
[self convertCocoaMouseWheelEvent:theEvent toGeckoEvent:&wheelEvent];
wheelEvent.lineOrPageDeltaX = RoundUp(-[theEvent deltaX]);
wheelEvent.lineOrPageDeltaY = RoundUp(-[theEvent deltaY]);
@ -4770,8 +4786,6 @@ static int32_t RoundUp(double aDouble)
return;
}
wheelEvent.isMomentum = nsCocoaUtils::IsMomentumScrollEvent(theEvent);
NPCocoaEvent cocoaEvent;
ChildViewMouseTracker::AttachPluginEvent(wheelEvent, self, theEvent,
NPCocoaEventScrollWheel,
@ -4847,6 +4861,29 @@ static int32_t RoundUp(double aDouble)
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (void) convertCocoaMouseWheelEvent:(NSEvent*)aMouseEvent
toGeckoEvent:(WidgetWheelEvent*)outWheelEvent
{
[self convertCocoaMouseEvent:aMouseEvent toGeckoEvent:outWheelEvent];
outWheelEvent->deltaMode =
Preferences::GetBool("mousewheel.enable_pixel_scrolling", true) ?
nsIDOMWheelEvent::DOM_DELTA_PIXEL : nsIDOMWheelEvent::DOM_DELTA_LINE;
// Calling deviceDeltaX or deviceDeltaY on theEvent will trigger a Cocoa
// assertion and an Objective-C NSInternalInconsistencyException if the
// underlying "Carbon" event doesn't contain pixel scrolling information.
// For these events, carbonEventKind is kEventMouseWheelMoved instead of
// kEventMouseScroll.
if (outWheelEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL) {
EventRef theCarbonEvent = [aMouseEvent _eventRef];
UInt32 carbonEventKind = theCarbonEvent ? ::GetEventKind(theCarbonEvent) : 0;
if (carbonEventKind != kEventMouseScroll) {
outWheelEvent->deltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
}
}
outWheelEvent->isMomentum = nsCocoaUtils::IsMomentumScrollEvent(aMouseEvent);
}
- (void) convertCocoaMouseEvent:(NSEvent*)aMouseEvent
toGeckoEvent:(WidgetInputEvent*)outGeckoEvent
{

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

@ -493,7 +493,7 @@ nsComponentManagerImpl::RegisterCIDEntryLocked(
existing = f->mModule->Description();
else
existing = "<unknown module>";
SafeMutexAutoUnlock unlock(mLock);
LogMessage("While registering XPCOM module %s, trying to re-register CID '%s' already registered by %s.",
aModule->Description().get(),
idstr,

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

@ -296,6 +296,7 @@ template <class T, uint32_t K> class nsExpirationTracker {
}
}
void Destroy() {
mOwner = nullptr;
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs)
obs->RemoveObserver(this, "memory-pressure");
@ -334,7 +335,7 @@ nsExpirationTracker<T, K>::ExpirationTrackerObserver::Observe(nsISupports *a
const char *aTopic,
const PRUnichar *aData)
{
if (!strcmp(aTopic, "memory-pressure"))
if (!strcmp(aTopic, "memory-pressure") && mOwner)
mOwner->AgeAllGenerations();
return NS_OK;
}

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CocoaFileUtils.h"
#include "nsCocoaUtils.h"
#include <Cocoa/Cocoa.h>
#include "nsObjCExceptions.h"
#include "nsDebug.h"
@ -48,18 +49,25 @@ nsresult GetFileCreatorCode(CFURLRef url, OSType *creatorCode)
NS_ENSURE_ARG_POINTER(url);
NS_ENSURE_ARG_POINTER(creatorCode);
nsresult rv = NS_ERROR_FAILURE;
nsAutoreleasePool localPool;
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
NSDictionary* dict = [[NSFileManager defaultManager] fileAttributesAtPath:[(NSURL*)url path] traverseLink:YES];
NSNumber* creatorNum = (NSNumber*)[dict objectForKey:NSFileHFSCreatorCode];
if (creatorNum) {
*creatorCode = [creatorNum unsignedLongValue];
rv = NS_OK;
NSString *resolvedPath = [[(NSURL*)url path] stringByResolvingSymlinksInPath];
if (!resolvedPath) {
return NS_ERROR_FAILURE;
}
[ap release];
return rv;
NSDictionary* dict = [[NSFileManager defaultManager] attributesOfItemAtPath:resolvedPath error:nil];
if (!dict) {
return NS_ERROR_FAILURE;
}
NSNumber* creatorNum = (NSNumber*)[dict objectForKey:NSFileHFSCreatorCode];
if (!creatorNum) {
return NS_ERROR_FAILURE;
}
*creatorCode = [creatorNum unsignedLongValue];
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
@ -86,18 +94,25 @@ nsresult GetFileTypeCode(CFURLRef url, OSType *typeCode)
NS_ENSURE_ARG_POINTER(url);
NS_ENSURE_ARG_POINTER(typeCode);
nsresult rv = NS_ERROR_FAILURE;
nsAutoreleasePool localPool;
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
NSDictionary* dict = [[NSFileManager defaultManager] fileAttributesAtPath:[(NSURL*)url path] traverseLink:YES];
NSNumber* typeNum = (NSNumber*)[dict objectForKey:NSFileHFSTypeCode];
if (typeNum) {
*typeCode = [typeNum unsignedLongValue];
rv = NS_OK;
NSString *resolvedPath = [[(NSURL*)url path] stringByResolvingSymlinksInPath];
if (!resolvedPath) {
return NS_ERROR_FAILURE;
}
[ap release];
return rv;
NSDictionary* dict = [[NSFileManager defaultManager] attributesOfItemAtPath:resolvedPath error:nil];
if (!dict) {
return NS_ERROR_FAILURE;
}
NSNumber* typeNum = (NSNumber*)[dict objectForKey:NSFileHFSTypeCode];
if (!typeNum) {
return NS_ERROR_FAILURE;
}
*typeCode = [typeNum unsignedLongValue];
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}

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

@ -61,7 +61,9 @@
#define F_BSIZE f_bsize
#endif
#if defined(HAVE_STAT64) && defined(HAVE_LSTAT64)
// stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are
// 64-bit by default on OS X 10.6+.
#if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_MACOSX)
#if defined (AIX)
#if defined STAT
#undef STAT

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

@ -18,6 +18,7 @@ DummyConstructorFunc(nsISupports* aOuter, const nsIID& aIID, void** aResult)
}
static const mozilla::Module::CIDEntry kTestCIDs[] = {
{ &kNS_TESTING_CID, false, NULL, DummyConstructorFunc },
{ &kNS_TESTING_CID, false, NULL, DummyConstructorFunc },
{ NULL }
};