Skip to content

Commit

Permalink
Merge m-c to autoland
Browse files Browse the repository at this point in the history
  • Loading branch information
philor committed Jan 20, 2017
2 parents f10b4dc + 6f55fab commit d0690ad
Show file tree
Hide file tree
Showing 71 changed files with 16,930 additions and 358 deletions.
8 changes: 7 additions & 1 deletion accessible/generic/Accessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// Accessible: nsISupports and cycle collection

NS_IMPL_CYCLE_COLLECTION(Accessible, mContent)
NS_IMPL_CYCLE_COLLECTION_CLASS(Accessible)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Accessible)
tmp->Shutdown();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Accessible)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent, mDoc)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Accessible)
if (aIID.Equals(NS_GET_IID(Accessible)))
Expand Down
2 changes: 1 addition & 1 deletion accessible/generic/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ class Accessible : public nsISupports

// Data Members
nsCOMPtr<nsIContent> mContent;
DocAccessible* mDoc;
RefPtr<DocAccessible> mDoc;

Accessible* mParent;
nsTArray<Accessible*> mChildren;
Expand Down
8 changes: 7 additions & 1 deletion accessible/generic/DocAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ static const uint32_t kRelationAttrsLen = ArrayLength(kRelationAttrs);

DocAccessible::
DocAccessible(nsIDocument* aDocument, nsIPresShell* aPresShell) :
HyperTextAccessibleWrap(nullptr, this),
// XXX don't pass a document to the Accessible constructor so that we don't
// set mDoc until our vtable is fully setup. If we set mDoc before setting
// up the vtable we will call Accessible::AddRef() but not the overrides of
// it for subclasses. It is important to call those overrides to avoid
// confusing leak checking machinary.
HyperTextAccessibleWrap(nullptr, nullptr),
// XXX aaronl should we use an algorithm for the initial cache size?
mAccessibleCache(kDefaultCacheLength),
mNodeToAccessibleMap(kDefaultCacheLength),
Expand All @@ -92,6 +97,7 @@ DocAccessible::
{
mGenericTypes |= eDocument;
mStateFlags |= eNotNodeMapEntry;
mDoc = this;

MOZ_ASSERT(mPresShell, "should have been given a pres shell");
mPresShell->SetDocAccessible(this);
Expand Down
3 changes: 2 additions & 1 deletion accessible/windows/msaa/AccessibleWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ void
AccessibleWrap::Shutdown()
{
if (mID != kNoID) {
auto doc = static_cast<DocAccessibleWrap*>(mDoc);
auto doc = static_cast<DocAccessibleWrap*>(mDoc.get());
MOZ_ASSERT(doc);
if (doc) {
doc->RemoveID(mID);
mID = kNoID;
}
}

Expand Down
42 changes: 17 additions & 25 deletions build/clang-plugin/NoAddRefReleaseOnReturnChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,27 @@
#include "CustomMatchers.h"

void NoAddRefReleaseOnReturnChecker::registerMatchers(MatchFinder* AstMatcher) {
// First, look for direct parents of the MemberExpr.
AstMatcher->addMatcher(
callExpr(
callee(functionDecl(hasNoAddRefReleaseOnReturnAttr()).bind("func")),
hasParent(memberExpr(isAddRefOrRelease(), hasParent(callExpr()))
.bind("member")))
.bind("node"),
this);
// Then, look for MemberExpr that need to be casted to the right type using
// an intermediary CastExpr before we get to the CallExpr.
AstMatcher->addMatcher(
callExpr(
callee(functionDecl(hasNoAddRefReleaseOnReturnAttr()).bind("func")),
hasParent(castExpr(
hasParent(memberExpr(isAddRefOrRelease(), hasParent(callExpr()))
.bind("member")))))
.bind("node"),
this);
// Look for all of the calls to AddRef() or Release()
AstMatcher->addMatcher(memberExpr(isAddRefOrRelease(), hasParent(callExpr())).bind("member"),
this);
}

void NoAddRefReleaseOnReturnChecker::check(
const MatchFinder::MatchResult &Result) {
const Stmt *Node = Result.Nodes.getNodeAs<Stmt>("node");
const FunctionDecl *Func = Result.Nodes.getNodeAs<FunctionDecl>("func");
const MemberExpr *Member = Result.Nodes.getNodeAs<MemberExpr>("member");
const CXXMethodDecl *Method =
dyn_cast<CXXMethodDecl>(Member->getMemberDecl());
const Expr *Base = IgnoreTrivials(Member->getBase());

diag(Node->getLocStart(),
"%1 cannot be called on the return value of %0",
DiagnosticIDs::Error) << Func << Method;
// Check if the call to AddRef() or Release() was made on the result of a call
// to a MOZ_NO_ADDREF_RELEASE_ON_RETURN function or method.
if (auto *Call = dyn_cast<CallExpr>(Base)) {
if (auto *Callee = Call->getDirectCallee()) {
if (hasCustomAnnotation(Callee, "moz_no_addref_release_on_return")) {
diag(Call->getLocStart(),
"%1 cannot be called on the return value of %0",
DiagnosticIDs::Error)
<< Callee
<< dyn_cast<CXXMethodDecl>(Member->getMemberDecl());
}
}
}
}
6 changes: 5 additions & 1 deletion build/clang-plugin/OverrideBaseCallChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ void OverrideBaseCallChecker::check(

// If list is not empty pop up errors
for (auto BaseMethod : MethodsList) {
std::string QualName;
raw_string_ostream OS(QualName);
BaseMethod->printQualifiedName(OS);

diag(Method->getLocation(), Error, DiagnosticIDs::Error)
<< BaseMethod->getQualifiedNameAsString()
<< OS.str()
<< Decl->getName();
}
}
Expand Down
6 changes: 5 additions & 1 deletion build/clang-plugin/SprintfLiteralChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ void SprintfLiteralChecker::check(
Literal = Result.Nodes.getNodeAs<IntegerLiteral>("constant");
}

if (Type->getSize().ule(Literal->getValue())) {
// We're going to assume here that the bitwidth of both of these values fits within 64 bits.
// and zero-extend both values to 64-bits before comparing them.
uint64_t Size = Type->getSize().getZExtValue();
uint64_t Lit = Literal->getValue().getZExtValue();
if (Size <= Lit) {
diag(D->getLocStart(), Error, DiagnosticIDs::Error) << Name << Replacement;
diag(D->getLocStart(), Note, DiagnosticIDs::Note) << Name;
}
Expand Down
4 changes: 3 additions & 1 deletion build/clang-plugin/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ inline bool typeIsRefPtr(QualType Q) {
// IgnoreTrivials.
inline const Stmt *IgnoreTrivials(const Stmt *s) {
while (true) {
if (auto *ewc = dyn_cast<ExprWithCleanups>(s)) {
if (!s) {
return nullptr;
} else if (auto *ewc = dyn_cast<ExprWithCleanups>(s)) {
s = ewc->getSubExpr();
} else if (auto *mte = dyn_cast<MaterializeTemporaryExpr>(s)) {
s = mte->GetTemporaryExpr();
Expand Down
3 changes: 3 additions & 0 deletions build/moz.configure/init.configure
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ def split_triplet(triplet):
elif cpu.startswith('aarch64'):
canonical_cpu = 'aarch64'
endianness = 'little'
elif cpu == 'sh4':
canonical_cpu = 'sh4'
endianness = 'little'
else:
die('Unknown CPU type: %s' % cpu)

Expand Down
75 changes: 75 additions & 0 deletions docshell/base/PendingGlobalHistoryEntry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "mozilla/dom/PendingGlobalHistoryEntry.h"

namespace mozilla {

namespace dom {

void
PendingGlobalHistoryEntry::VisitURI(nsIURI* aURI,
nsIURI* aLastVisitedURI,
nsIURI* aReferrerURI,
uint32_t aFlags)
{
URIVisit visit;
visit.mURI = aURI;
visit.mLastVisitedURI = aLastVisitedURI;
visit.mReferrerURI = aReferrerURI;
visit.mFlags = aFlags;
mVisits.AppendElement(Move(visit));
}

void
PendingGlobalHistoryEntry::SetURITitle(nsIURI* aURI,
const nsAString& aTitle)
{
URITitle title;
title.mURI = aURI;
title.mTitle.Assign(aTitle);
mTitles.AppendElement(title);
}

nsresult
PendingGlobalHistoryEntry::ApplyChanges(IHistory* aHistory)
{
nsresult rv;
for (const URIVisit& visit : mVisits) {
rv = aHistory->VisitURI(visit.mURI, visit.mLastVisitedURI, visit.mFlags);
NS_ENSURE_SUCCESS(rv, rv);
}
mVisits.Clear();

for (const URITitle& title : mTitles) {
aHistory->SetURITitle(title.mURI, title.mTitle);
NS_ENSURE_SUCCESS(rv, rv);
}
mTitles.Clear();

return NS_OK;
}

nsresult
PendingGlobalHistoryEntry::ApplyChanges(nsIGlobalHistory2* aHistory)
{
nsresult rv;
for (const URIVisit& visit : mVisits) {
bool redirect = (visit.mFlags & IHistory::REDIRECT_TEMPORARY) ||
(visit.mFlags & IHistory::REDIRECT_PERMANENT);
bool toplevel = (visit.mFlags & IHistory::TOP_LEVEL);

rv = aHistory->AddURI(visit.mURI, redirect, toplevel, visit.mReferrerURI);
NS_ENSURE_SUCCESS(rv, rv);
}
mVisits.Clear();

for (const URITitle& title : mTitles) {
rv = aHistory->SetPageTitle(title.mURI, title.mTitle);
NS_ENSURE_SUCCESS(rv, rv);
}
mTitles.Clear();

return NS_OK;
}

} // namespace dom

} // namespace mozilla
65 changes: 65 additions & 0 deletions docshell/base/PendingGlobalHistoryEntry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_dom_PendingGlobalHistoryEntry_h_
#define mozilla_dom_PendingGlobalHistoryEntry_h_

#include "mozilla/IHistory.h"
#include "nsIGlobalHistory2.h"
#include "nsIURI.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsTArray.h"

namespace mozilla {

namespace dom {

// This class acts as a wrapper around a IHistory, in that it can be used to
// record a series of operations on the IHistory, and then play them back at a
// later time. This is used in Prerendering in order to record the Global
// History changes being made by the prerendering docshell and then play them
// back when the docshell is finished rendering.
//
// This class also handles applying the changes to nsIGlobalHistory2.
class PendingGlobalHistoryEntry
{
public:
void VisitURI(nsIURI* aURI,
nsIURI* aLastVisitedURI,
nsIURI* aReferrerURI,
uint32_t aFlags);

void SetURITitle(nsIURI* aURI,
const nsAString& aTitle);

nsresult ApplyChanges(IHistory* aHistory);

nsresult ApplyChanges(nsIGlobalHistory2* aHistory);

private:
struct URIVisit
{
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mLastVisitedURI;
nsCOMPtr<nsIURI> mReferrerURI;
uint32_t mFlags = 0;
};
struct URITitle
{
nsCOMPtr<nsIURI> mURI;
nsString mTitle;
};
nsTArray<URIVisit> mVisits;
nsTArray<URITitle> mTitles;
};

} // namespace dom

} // namespace mozilla

#endif // mozilla_dom_PendingGlobalHistoryEntry_h_

5 changes: 5 additions & 0 deletions docshell/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ EXPORTS.mozilla += [
'LoadContext.h',
]

EXPORTS.mozilla.dom += [
'PendingGlobalHistoryEntry.h',
]

UNIFIED_SOURCES += [
'LoadContext.cpp',
'nsAboutRedirector.cpp',
Expand All @@ -70,6 +74,7 @@ UNIFIED_SOURCES += [
'nsDownloadHistory.cpp',
'nsDSURIContentListener.cpp',
'nsWebNavigationInfo.cpp',
'PendingGlobalHistoryEntry.cpp',
'SerializedLoadContext.cpp',
]

Expand Down
Loading

0 comments on commit d0690ad

Please sign in to comment.