Merge inbound to mozilla-central. a=merge

This commit is contained in:
arthur.iakab 2018-04-03 12:31:23 +03:00
Родитель 94289ab246 54337513b3
Коммит b310d9523e
31 изменённых файлов: 390 добавлений и 348 удалений

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

@ -62,6 +62,11 @@ class ToolboxTab extends Component {
tabIndex: focusedButton === id ? "0" : "-1",
onFocus: () => focusButton(id),
onMouseDown: () => selectTool(id),
onKeyDown: (evt) => {
if (evt.key === "Enter" || evt.key === " ") {
selectTool(id);
}
},
},
span(
{

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

@ -81,3 +81,44 @@ add_task(async function () {
EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
is(doc.activeElement.id, expectedFocusedControl.id, "New control is focused");
});
// Test that moving the focus of tab button and selecting it.
add_task(async function () {
info("Create a test tab and open the toolbox");
let toolbox = await openNewTabAndToolbox(TEST_URL, "inspector");
let doc = toolbox.doc;
let toolbar = doc.querySelector(".toolbox-tabs");
let tabButtons = toolbar.querySelectorAll(".devtools-tab, button");
let win = tabButtons[0].ownerDocument.defaultView;
// Put the keyboard focus onto the first tab button.
tabButtons[0].focus();
ok(containsFocus(doc, toolbar), "Focus is within the toolbox");
is(doc.activeElement.id, tabButtons[0].id, "First tab button is focused.");
// Move the focused tab and select it by using enter key.
let onKeyEvent = once(win, "keydown");
EventUtils.synthesizeKey("KEY_ArrowRight");
await onKeyEvent;
let onceSelected = toolbox.once("webconsole-selected");
EventUtils.synthesizeKey("Enter");
await onceSelected;
ok(doc.activeElement.id, tabButtons[1].id, "Changed tab button is focused.");
// Webconsole steal the focus from button after sending "webconsole-selected"
// event.
tabButtons[1].focus();
// Return the focused tab with space key.
onKeyEvent = once(win, "keydown");
EventUtils.synthesizeKey("KEY_ArrowLeft");
await onKeyEvent;
onceSelected = toolbox.once("inspector-selected");
EventUtils.synthesizeKey(" ");
await onceSelected;
ok(doc.activeElement.id, tabButtons[0].id, "Changed tab button is focused.");
});

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

@ -2332,15 +2332,6 @@ nsGlobalWindowInner::GetScreen(ErrorResult& aError)
return mScreen;
}
nsIDOMScreen*
nsGlobalWindowInner::GetScreen()
{
ErrorResult dummy;
nsIDOMScreen* screen = GetScreen(dummy);
dummy.SuppressException();
return screen;
}
nsHistory*
nsGlobalWindowInner::GetHistory(ErrorResult& aError)
{

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

@ -779,7 +779,6 @@ public:
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
nsScreen* GetScreen(mozilla::ErrorResult& aError);
nsIDOMScreen* GetScreen() override;
void MoveTo(int32_t aXPos, int32_t aYPos,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);

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

@ -2596,10 +2596,10 @@ nsGlobalWindowOuter::GetNavigator()
FORWARD_TO_INNER(Navigator, (), nullptr);
}
nsIDOMScreen*
nsScreen*
nsGlobalWindowOuter::GetScreen()
{
FORWARD_TO_INNER(GetScreen, (), nullptr);
FORWARD_TO_INNER(GetScreen, (IgnoreErrors()), nullptr);
}
void
@ -3708,10 +3708,9 @@ nsGlobalWindowOuter::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
nsCOMPtr<nsIBaseWindow> treeOwner = GetTreeOwnerWindow();
nsCOMPtr<nsIDOMScreen> screen = GetScreen();
RefPtr<nsScreen> screen = GetScreen();
if (treeOwner && screen) {
int32_t screenLeft, screenTop, screenWidth, screenHeight;
int32_t winLeft, winTop, winWidth, winHeight;
// Get the window size
@ -3726,9 +3725,9 @@ nsGlobalWindowOuter::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
// Get the screen dimensions
// XXX This should use nsIScreenManager once it's fully fleshed out.
screen->GetAvailLeft(&screenLeft);
screen->GetAvailWidth(&screenWidth);
screen->GetAvailHeight(&screenHeight);
int32_t screenLeft = screen->GetAvailLeft(IgnoreErrors());
int32_t screenWidth = screen->GetAvailWidth(IgnoreErrors());
int32_t screenHeight = screen->GetAvailHeight(IgnoreErrors());
#if defined(XP_MACOSX)
/* The mac's coordinate system is different from the assumed Windows'
system. It offsets by the height of the menubar so that a window
@ -3737,9 +3736,9 @@ nsGlobalWindowOuter::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
the Avail... coordinates is overloaded. Here we allow a window
to be placed at (0,0) because it does make sense to do so.
*/
screen->GetTop(&screenTop);
int32_t screenTop = screen->GetTop(IgnoreErrors());
#else
screen->GetAvailTop(&screenTop);
int32_t screenTop = screen->GetAvailTop(IgnoreErrors());
#endif
if (aLeft) {

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

@ -636,7 +636,7 @@ public:
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(
const nsAString& aQuery,
mozilla::dom::CallerType aCallerType);
nsIDOMScreen* GetScreen() override;
nsScreen* GetScreen();
void MoveToOuter(int32_t aXPos, int32_t aYPos,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);

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

@ -590,7 +590,6 @@ public:
return mMarkedCCGeneration;
}
virtual nsIDOMScreen* GetScreen() = 0;
mozilla::dom::Navigator* Navigator();
virtual mozilla::dom::Location* GetLocation() = 0;
@ -1094,7 +1093,6 @@ public:
// XXX(nika): These feel like they should be inner window only, but they're
// called on the outer window.
virtual nsIDOMScreen* GetScreen() = 0;
virtual mozilla::dom::Navigator* GetNavigator() = 0;
virtual mozilla::dom::Location* GetLocation() = 0;

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

@ -50,7 +50,6 @@ nsScreen::~nsScreen()
// QueryInterface implementation for nsScreen
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScreen)
NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(nsScreen, DOMEventTargetHelper)
@ -80,22 +79,6 @@ nsScreen::GetPixelDepth(ErrorResult& aRv)
return depth;
}
#define FORWARD_LONG_GETTER(_name) \
NS_IMETHODIMP \
nsScreen::Get ## _name(int32_t* aOut) \
{ \
ErrorResult rv; \
*aOut = Get ## _name(rv); \
return rv.StealNSResult(); \
}
FORWARD_LONG_GETTER(AvailWidth)
FORWARD_LONG_GETTER(AvailHeight)
FORWARD_LONG_GETTER(Top)
FORWARD_LONG_GETTER(AvailTop)
FORWARD_LONG_GETTER(AvailLeft)
nsPIDOMWindowOuter*
nsScreen::GetOuter() const
{

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

@ -10,7 +10,6 @@
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/ErrorResult.h"
#include "nsIDOMScreen.h"
#include "nsCOMPtr.h"
#include "nsRect.h"
@ -18,14 +17,12 @@ class nsDeviceContext;
// Script "screen" object
class nsScreen : public mozilla::DOMEventTargetHelper
, public nsIDOMScreen
{
typedef mozilla::ErrorResult ErrorResult;
public:
static already_AddRefed<nsScreen> Create(nsPIDOMWindowInner* aWindow);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSCREEN
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen, mozilla::DOMEventTargetHelper)
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)

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

@ -2189,6 +2189,7 @@ class PropertyDefiner:
disablersTemplate = dedent(
"""
// Can't be const because the pref-enabled boolean needs to be writable
static PrefableDisablers %s_disablers%d = {
true, %s, %s, %s
};
@ -2257,8 +2258,7 @@ class PropertyDefiner:
#endif
${disablers}
// Can't be const because the pref-enabled boolean needs to be writable
static Prefable<${specType}> ${name}[] = {
static const Prefable<${specType}> ${name}[] = {
${prefableSpecs}
};

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

@ -34,7 +34,6 @@ class DOMException;
// Base
interface nsIDOMWindow;
interface nsIDOMWindowCollection;
interface nsIDOMScreen;
// Events
interface nsIDOMEvent;

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

@ -17,7 +17,6 @@ XPIDL_SOURCES += [
'nsIContentURIGrouper.idl',
'nsIDOMChromeWindow.idl',
'nsIDOMGlobalPropertyInitializer.idl',
'nsIDOMScreen.idl',
'nsIDOMWindow.idl',
'nsIDOMWindowCollection.idl',
'nsIDOMWindowUtils.idl',

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

@ -1,16 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMEventTarget.idl"
[builtinclass, uuid(82c7924b-4b46-4e5a-a8d2-6edb5fc0a60d)]
interface nsIDOMScreen : nsIDOMEventTarget
{
readonly attribute long top;
readonly attribute long availWidth;
readonly attribute long availHeight;
readonly attribute long availLeft;
readonly attribute long availTop;
};

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

@ -31,7 +31,6 @@
#include "nsITextServicesFilter.h" // for nsITextServicesFilter
#include "mozilla/intl/WordBreaker.h" // for WordRange, WordBreaker
#include "nsRange.h" // for nsRange
#include "nsStaticAtom.h" // for NS_STATIC_ATOM_SETUP, etc
#include "nsString.h" // for nsString, nsAutoString
#include "nscore.h" // for nsresult, NS_IMETHODIMP, etc

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

@ -9,7 +9,6 @@
#include "mozilla/ArrayUtils.h"
#include "nsCSSAnonBoxes.h"
#include "nsStaticAtom.h"
using namespace mozilla;
@ -22,40 +21,39 @@ extern constexpr CSSAnonBoxAtoms gCSSAnonBoxAtoms = {
NS_STATIC_ATOM_INIT_STRING(value_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_INIT_ATOM(CSSAnonBoxAtoms, name_, value_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
{
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_INIT_ATOM( \
nsICSSAnonBoxPseudo, CSSAnonBoxAtoms, name_, value_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
}
};
MOZ_POP_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
} // namespace detail
} // namespace mozilla
// Non-inheriting boxes must come first in nsCSSAnonBoxList.h so that
// `NonInheriting` values can index into this array and other similar arrays.
const nsStaticAtom* const nsCSSAnonBoxes::sAtoms =
mozilla::detail::gCSSAnonBoxAtoms.mAtoms;
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_SUBCLASS_DEFN_PTR(nsICSSAnonBoxPseudo, nsCSSAnonBoxes, name_)
NS_STATIC_ATOM_DEFN_PTR( \
nsICSSAnonBoxPseudo, mozilla::detail::CSSAnonBoxAtoms, \
mozilla::detail::gCSSAnonBoxAtoms, nsCSSAnonBoxes, name_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
static const nsStaticAtomSetup sCSSAnonBoxAtomSetup[] = {
// Non-inheriting boxes must come first in nsCSSAnonBoxList.h so that
// `NonInheriting` values can index into this array and other similar arrays.
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_SUBCLASS_SETUP( \
mozilla::detail::gCSSAnonBoxAtoms, nsCSSAnonBoxes, name_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
};
void nsCSSAnonBoxes::RegisterStaticAtoms()
{
NS_RegisterStaticAtoms(sCSSAnonBoxAtomSetup);
NS_RegisterStaticAtoms(sAtoms, sAtomsLen);
}
bool nsCSSAnonBoxes::IsAnonBox(nsAtom *aAtom)
{
return nsStaticAtomUtils::IsMember(aAtom, sCSSAnonBoxAtomSetup);
return nsStaticAtomUtils::IsMember(aAtom, sAtoms, sAtomsLen);
}
#ifdef MOZ_XUL
@ -72,8 +70,7 @@ nsCSSAnonBoxes::IsTreePseudoElement(nsAtom* aPseudo)
nsCSSAnonBoxes::NonInheritingTypeForPseudoTag(nsAtom* aPseudo)
{
MOZ_ASSERT(IsNonInheritingAnonBox(aPseudo));
Maybe<uint32_t> index =
nsStaticAtomUtils::Lookup(aPseudo, sCSSAnonBoxAtomSetup);
Maybe<uint32_t> index = nsStaticAtomUtils::Lookup(aPseudo, sAtoms, sAtomsLen);
MOZ_RELEASE_ASSERT(index.isSome());
return static_cast<NonInheriting>(*index);
}

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

@ -12,9 +12,16 @@
#include "nsAtom.h"
#include "nsStaticAtom.h"
// Empty class derived from nsAtom so that function signatures can
// require an atom from this atom list.
class nsICSSAnonBoxPseudo : public nsAtom {};
// Trivial subclass of nsStaticAtom so that function signatures can require an
// atom from this atom list.
class nsICSSAnonBoxPseudo : public nsStaticAtom
{
public:
constexpr nsICSSAnonBoxPseudo(const char16_t* aStr, uint32_t aLength,
uint32_t aStringOffset)
: nsStaticAtom(aStr, aLength, aStringOffset)
{}
};
namespace mozilla {
namespace detail {
@ -25,9 +32,15 @@ struct CSSAnonBoxAtoms
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
#define CSS_ANON_BOX(name_, value_) NS_STATIC_ATOM_DECL_ATOM(name_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
enum class Atoms {
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_ENUM(name_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
AtomsCount
};
const nsICSSAnonBoxPseudo mAtoms[static_cast<size_t>(Atoms::AtomsCount)];
};
extern const CSSAnonBoxAtoms gCSSAnonBoxAtoms;
@ -50,10 +63,16 @@ public:
aPseudo == firstLetterContinuation;
}
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_SUBCLASS_DECL_PTR(nsICSSAnonBoxPseudo, name_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
private:
static const nsStaticAtom* const sAtoms;
static constexpr size_t sAtomsLen =
mozilla::ArrayLength(mozilla::detail::gCSSAnonBoxAtoms.mAtoms);
public:
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM_DECL_PTR(nsICSSAnonBoxPseudo, name_)
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
typedef uint8_t NonInheritingBase;
enum class NonInheriting : NonInheritingBase {

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

@ -10,7 +10,6 @@
#include "mozilla/ArrayUtils.h"
#include "nsStaticAtom.h"
#include "nsCSSAnonBoxes.h"
#include "nsDOMString.h"
@ -25,35 +24,30 @@ extern constexpr CSSPseudoElementAtoms gCSSPseudoElementAtoms = {
NS_STATIC_ATOM_INIT_STRING(value_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_INIT_ATOM(CSSPseudoElementAtoms, name_, value_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
{
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_INIT_ATOM( \
nsICSSPseudoElement, CSSPseudoElementAtoms, name_, value_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
}
};
MOZ_POP_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
} // namespace detail
} // namespace mozilla
const nsStaticAtom* const nsCSSPseudoElements::sAtoms =
mozilla::detail::gCSSPseudoElementAtoms.mAtoms;
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_SUBCLASS_DEFN_PTR( \
nsICSSPseudoElement, nsCSSPseudoElements, name_)
NS_STATIC_ATOM_DEFN_PTR( \
nsICSSPseudoElement, mozilla::detail::CSSPseudoElementAtoms, \
mozilla::detail::gCSSPseudoElementAtoms, nsCSSPseudoElements, name_);
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
// Array of nsStaticAtomSetup for each of the pseudo-elements.
static const nsStaticAtomSetup sCSSPseudoElementAtomSetup[] = {
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_SUBCLASS_SETUP( \
detail::gCSSPseudoElementAtoms, nsCSSPseudoElements, name_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
};
// Flags data for each of the pseudo-elements, which must be separate
// from the previous array since there's no place for it in
// nsStaticAtomSetup.
// Flags data for each of the pseudo-elements.
/* static */ const uint32_t
nsCSSPseudoElements::kPseudoElementFlags[] = {
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
@ -64,12 +58,12 @@ nsCSSPseudoElements::kPseudoElementFlags[] = {
void nsCSSPseudoElements::RegisterStaticAtoms()
{
NS_RegisterStaticAtoms(sCSSPseudoElementAtomSetup);
NS_RegisterStaticAtoms(sAtoms, sAtomsLen);
}
bool nsCSSPseudoElements::IsPseudoElement(nsAtom *aAtom)
{
return nsStaticAtomUtils::IsMember(aAtom, sCSSPseudoElementAtomSetup);
return nsStaticAtomUtils::IsMember(aAtom, sAtoms, sAtomsLen);
}
/* static */ bool
@ -95,8 +89,7 @@ nsCSSPseudoElements::IsCSS2PseudoElement(nsAtom *aAtom)
/* static */ CSSPseudoElementType
nsCSSPseudoElements::GetPseudoType(nsAtom *aAtom, EnabledState aEnabledState)
{
Maybe<uint32_t> index =
nsStaticAtomUtils::Lookup(aAtom, sCSSPseudoElementAtomSetup);
Maybe<uint32_t> index = nsStaticAtomUtils::Lookup(aAtom, sAtoms, sAtomsLen);
if (index.isSome()) {
auto type = static_cast<Type>(*index);
// ::moz-placeholder is an alias for ::placeholder
@ -126,9 +119,9 @@ nsCSSPseudoElements::GetPseudoType(nsAtom *aAtom, EnabledState aEnabledState)
/* static */ nsAtom*
nsCSSPseudoElements::GetPseudoAtom(Type aType)
{
NS_ASSERTION(aType < Type::Count, "Unexpected type");
return *sCSSPseudoElementAtomSetup[
static_cast<CSSPseudoElementTypeBase>(aType)].mAtomp;
MOZ_ASSERT(aType < Type::Count, "Unexpected type");
return const_cast<nsStaticAtom*>(
&sAtoms[static_cast<CSSPseudoElementTypeBase>(aType)]);
}
/* static */ already_AddRefed<nsAtom>

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

@ -56,6 +56,17 @@
// grid containers) and thus needs parent display-based style fixup?
#define CSS_PSEUDO_ELEMENT_IS_FLEX_OR_GRID_ITEM (1<<7)
// Trivial subclass of nsStaticAtom so that function signatures can require an
// atom from this atom list.
class nsICSSPseudoElement : public nsStaticAtom
{
public:
constexpr nsICSSPseudoElement(const char16_t* aStr, uint32_t aLength,
uint32_t aStringOffset)
: nsStaticAtom(aStr, aLength, aStringOffset)
{}
};
namespace mozilla {
// The total count of CSSPseudoElement is less than 256,
@ -88,10 +99,15 @@ struct CSSPseudoElementAtoms
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_DECL_ATOM(name_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
enum class Atoms {
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_ENUM(name_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
AtomsCount
};
const nsICSSPseudoElement mAtoms[static_cast<size_t>(Atoms::AtomsCount)];
};
extern const CSSPseudoElementAtoms gCSSPseudoElementAtoms;
@ -100,10 +116,6 @@ extern const CSSPseudoElementAtoms gCSSPseudoElementAtoms;
} // namespace mozilla
// Empty class derived from nsAtom so that function signatures can
// require an atom from this atom list.
class nsICSSPseudoElement : public nsAtom {};
class nsCSSPseudoElements
{
typedef mozilla::CSSPseudoElementType Type;
@ -124,10 +136,16 @@ public:
return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_IS_CSS2);
}
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_SUBCLASS_DECL_PTR(nsICSSPseudoElement, name_)
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
private:
static const nsStaticAtom* const sAtoms;
static constexpr size_t sAtomsLen =
mozilla::ArrayLength(mozilla::detail::gCSSPseudoElementAtoms.mAtoms);
public:
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
NS_STATIC_ATOM_DECL_PTR(nsICSSPseudoElement, name_);
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
static Type GetPseudoType(nsAtom* aAtom, EnabledState aEnabledState);

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

@ -19,7 +19,6 @@
#include "nsPopupSetFrame.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMEvent.h"
#include "nsIDOMScreen.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsIPresShell.h"
#include "nsFrameManager.h"

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

@ -8,7 +8,6 @@
#include "nsDataHashtable.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsStaticAtom.h"
#include "nsUnicharUtils.h"
#include "mozilla/HashFunctions.h"
#include <algorithm>

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

@ -6,7 +6,6 @@
#ifndef nsHTMLTags_h___
#define nsHTMLTags_h___
#include "nsStaticAtom.h"
#include "nsString.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"

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

@ -279,7 +279,7 @@ public:
already_AddRefed<nsAtom> Atomize(const nsACString& aUTF8String);
already_AddRefed<nsAtom> AtomizeMainThread(const nsAString& aUTF16String);
nsStaticAtom* GetStaticAtom(const nsAString& aUTF16String);
void RegisterStaticAtoms(const nsStaticAtomSetup* aSetup, uint32_t aCount);
void RegisterStaticAtoms(const nsStaticAtom* aAtoms, size_t aAtomsLen);
// The result of this function may be imprecise if other threads are operating
// on atoms concurrently. It's also slow, since it triggers a GC before
@ -647,16 +647,13 @@ nsAtomSubTable::AddSizeOfExcludingThisLocked(MallocSizeOf aMallocSizeOf,
}
void
nsAtomTable::RegisterStaticAtoms(const nsStaticAtomSetup* aSetup,
uint32_t aCount)
nsAtomTable::RegisterStaticAtoms(const nsStaticAtom* aAtoms, size_t aAtomsLen)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(!gStaticAtomsDone, "Static atom insertion is finished!");
for (uint32_t i = 0; i < aCount; ++i) {
const nsStaticAtom* atom = aSetup[i].mAtom;
nsStaticAtom** atomp = aSetup[i].mAtomp;
for (uint32_t i = 0; i < aAtomsLen; ++i) {
const nsStaticAtom* atom = &aAtoms[i];
MOZ_ASSERT(nsCRT::IsAscii(atom->String()));
MOZ_ASSERT(NS_strlen(atom->String()) == atom->GetLength());
@ -676,15 +673,15 @@ nsAtomTable::RegisterStaticAtoms(const nsStaticAtomSetup* aSetup,
he->mAtom->ToUTF8String(name);
MOZ_CRASH_UNSAFE_PRINTF("Atom for '%s' already exists", name.get());
}
he->mAtom = *atomp = const_cast<nsStaticAtom*>(atom);
he->mAtom = const_cast<nsStaticAtom*>(atom);
}
}
void
RegisterStaticAtoms(const nsStaticAtomSetup* aSetup, uint32_t aCount)
NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, size_t aAtomsLen)
{
MOZ_ASSERT(gAtomTable);
gAtomTable->RegisterStaticAtoms(aSetup, aCount);
gAtomTable->RegisterStaticAtoms(aAtoms, aAtomsLen);
}
already_AddRefed<nsAtom>

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

@ -14,30 +14,29 @@ extern constexpr GkAtoms gGkAtoms = {
#define GK_ATOM(name_, value_) NS_STATIC_ATOM_INIT_STRING(value_)
#include "nsGkAtomList.h"
#undef GK_ATOM
#define GK_ATOM(name_, value_) \
NS_STATIC_ATOM_INIT_ATOM(GkAtoms, name_, value_)
#include "nsGkAtomList.h"
#undef GK_ATOM
{
#define GK_ATOM(name_, value_) \
NS_STATIC_ATOM_INIT_ATOM(nsStaticAtom, GkAtoms, name_, value_)
#include "nsGkAtomList.h"
#undef GK_ATOM
}
};
MOZ_POP_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
} // namespace detail
} // namespace mozilla
#define GK_ATOM(name_, value_) NS_STATIC_ATOM_DEFN_PTR(nsGkAtoms, name_)
const nsStaticAtom* const nsGkAtoms::sAtoms = mozilla::detail::gGkAtoms.mAtoms;
#define GK_ATOM(name_, value_) \
NS_STATIC_ATOM_DEFN_PTR( \
nsStaticAtom, mozilla::detail::GkAtoms, mozilla::detail::gGkAtoms, \
nsGkAtoms, name_)
#include "nsGkAtomList.h"
#undef GK_ATOM
static const nsStaticAtomSetup sGkAtomSetup[] = {
#define GK_ATOM(name_, value_) \
NS_STATIC_ATOM_SETUP(mozilla::detail::gGkAtoms, nsGkAtoms, name_)
#include "nsGkAtomList.h"
#undef GK_ATOM
};
void nsGkAtoms::RegisterStaticAtoms()
{
NS_RegisterStaticAtoms(sGkAtomSetup);
NS_RegisterStaticAtoms(sAtoms, sAtomsLen);
}

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

@ -19,9 +19,14 @@ struct GkAtoms
#include "nsGkAtomList.h"
#undef GK_ATOM
#define GK_ATOM(name_, value_) NS_STATIC_ATOM_DECL_ATOM(name_)
#include "nsGkAtomList.h"
#undef GK_ATOM
enum class Atoms {
#define GK_ATOM(name_, value_) NS_STATIC_ATOM_ENUM(name_)
#include "nsGkAtomList.h"
#undef GK_ATOM
AtomsCount
};
const nsStaticAtom mAtoms[static_cast<size_t>(Atoms::AtomsCount)];
};
extern const GkAtoms gGkAtoms;
@ -31,10 +36,15 @@ extern const GkAtoms gGkAtoms;
class nsGkAtoms
{
private:
static const nsStaticAtom* const sAtoms;
static constexpr size_t sAtomsLen =
mozilla::ArrayLength(mozilla::detail::gGkAtoms.mAtoms);
public:
static void RegisterStaticAtoms();
#define GK_ATOM(name_, value_) NS_STATIC_ATOM_DECL_PTR(name_)
#define GK_ATOM(name_, value_) NS_STATIC_ATOM_DECL_PTR(nsStaticAtom, name_)
#include "nsGkAtomList.h"
#undef GK_ATOM
};

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

@ -9,10 +9,45 @@
#include <stdint.h>
#include "nsAtom.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Maybe.h"
// The following macros are used to define static atoms, typically in
// conjunction with a .h file that defines the names and values of the atoms.
// Static atoms are structured carefully to satisfy a lot of constraints.
//
// - We have ~2700 static atoms. They are divided across ~4 classes, with the
// majority in nsGkAtoms.
//
// - We want them to be constexpr so they end up in .rodata, and thus shared
// between processes, minimizing memory usage.
//
// - We need them to be in an array, so we can iterate over them (for
// registration and lookups).
//
// - Each static atom has a string literal associated with it. We can't use a
// pointer to the string literal because then the atoms won't end up in
// .rodata. Therefore the string literals and the atoms must be arranged in a
// way such that a numeric index can be used instead. This numeric index
// (nsStaticAtom::mStringOffset) must be computable at compile-time to keep
// the static atom constexpr. It should also not be too large (a uint32_t is
// reasonable).
//
// - Each static atom stores the hash value of its associated string literal;
// it's used in various ways. The hash value must be computed at
// compile-time, to keep the static atom constexpr.
//
// - As well as accessing each static atom via array indexing, we need an
// individual pointer, e.g. nsGkAtoms::foo. Ideally this would be constexpr
// so it doesn't take up any space in memory. Unfortunately MSVC's constexpr
// support is buggy and so this isn't possible yet. See bug 1449787.
//
// - The array of static atoms can't be in a .h file, because it's a huge
// constexpr expression, which would blow out compile times. But the
// individual pointers for the static atoms must be in a .h file so they are
// public.
//
// The macros below are used to define static atoms in a way that satisfies
// these constraints. They are used in conjunction with a .h file that defines
// the names and values of the atoms.
//
// For example, the .h file might be called MyAtomList.h and look like this:
//
@ -20,60 +55,9 @@
// MY_ATOM(two, "two")
// MY_ATOM(three, "three")
//
// The code defining the static atoms should look something like this:
//
// ====> MyAtoms.h <====
//
// namespace detail {
//
// struct MyAtoms
// {
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DECL_STRING(name_, value_)
// #include "MyAtomList.h"
// #undef MY_ATOM
//
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DECL_ATOM(name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// };
//
// extern const MyAtoms gMyAtoms;
//
// } // namespace detail
//
// class nsMyAtoms
// {
// public:
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DECL_PTR(name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// };
//
// ====> MyAtoms.cpp <====
//
// MOZ_PUSH_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
// static constexpr MyAtoms gMyAtoms = {
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_INIT_STRING(value_)
// #include "MyAtomList.h"
// #undef MY_ATOM
//
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_INIT_ATOM(MyAtoms, name_, value_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// };
// MOZ_POP_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
//
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DEFN_PTR(nsMyAtoms, name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
//
// static const nsStaticAtomSetup sMyAtomSetup[] = {
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_SETUP(mozilla::detail::gMyAtoms, nsMyAtoms, name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// };
//
// The macros expand to the following:
// The code defining the static atoms should look something like the following.
// ("<<<"/"---"/">>>" markers are used below to indicate what the macros look
// like before and after expansion.)
//
// ====> MyAtoms.h <====
//
@ -86,15 +70,34 @@
// // atoms will be small and can be initialized at compile time.
// struct MyAtoms
// {
// <<<
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DECL_STRING(name_, value_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// ---
// const char16_t one_string[4];
// const char16_t two_string[4];
// const char16_t three_string[6];
// >>>
//
// const nsStaticAtom one_atom;
// const nsStaticAtom two_atom;
// const nsStaticAtom three_atom;
// enum class Atoms {
// <<<
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_ENUM(name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// ---
// one,
// two,
// three,
// >>>
// AtomsCount
// };
//
// const nsStaticAtom mAtoms[static_cast<size_t>(Atoms::AtomsCount)];
// };
//
// // The MyAtoms instance is `extern const` so it can be defined in a .cpp
// // file.
// extern const MyAtoms gMyAtoms;
//
// } // namespace detail
@ -102,147 +105,158 @@
// // This class holds the pointers to the individual atoms.
// class nsMyAtoms
// {
// private:
// // This is a useful handle to the array of atoms, used below and also
// // possibly by Rust code.
// static const nsStaticAtom* const sAtoms;
//
// // The number of atoms, used below.
// static constexpr size_t sAtomsLen =
// mozilla::ArrayLength(detail::gMyAtoms.mAtoms);
//
// public:
// // The type is not `nsStaticAtom* const` -- even though these atoms are
// // immutable -- because they are often passed to functions with
// // `nsAtom*` parameters, i.e. that can be passed both dynamic and
// // static.
// <<<
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DECL_PTR(nsStaticAtom, name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// ---
// static nsStaticAtom* one;
// static nsStaticAtom* two;
// static nsStaticAtom* three;
// >>>
// };
//
// ====> MyAtoms.cpp <====
//
// namespace detail {
//
// // Need to suppress some MSVC warning weirdness with WrappingMultiply().
// MOZ_PUSH_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
// // Because this is `constexpr` it ends up in read-only memory where it can
// // be shared between processes.
// extern constexpr MyAtoms gMyAtoms = {
// static constexpr MyAtoms gMyAtoms = {
// <<<
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_INIT_STRING(value_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// ---
// u"one",
// u"two",
// u"three",
//
// nsStaticAtom(u"one", 3, offsetof(MyAtoms, one_atom) -
// offsetof(MyAtoms, one_string)),
// nsStaticAtom(u"two", 3, offsetof(MyAtoms, two_atom) -
// offsetof(MyAtoms, two_string)),
// nsStaticAtom(u"three", 3, offsetof(MyAtoms, three_atom) -
// offsetof(MyAtoms, three_string)),
// >>>
// {
// <<<
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_INIT_ATOM(nsStaticAtom, MyAtoms, name_, value_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// ---
// nsStaticAtom(
// u"one", 3,
// offsetof(MyAtoms, mAtoms[static_cast<size_t>(MyAtoms::Atoms::one)]) -
// offsetof(MyAtoms, one_string)),
// nsStaticAtom(
// u"two", 3,
// offsetof(MyAtoms, mAtoms[static_cast<size_t>(MyAtoms::Atoms::two)]) -
// offsetof(MyAtoms, two_string)),
// nsStaticAtom(
// u"three", 3,
// offsetof(MyAtoms, mAtoms[static_cast<size_t>(MyAtoms::Atoms::three)]) -
// offsetof(MyAtoms, three_string)),
// >>>
// }
// };
// MOZ_POP_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
//
// nsStaticAtom* MyAtoms::one;
// nsStaticAtom* MyAtoms::two;
// nsStaticAtom* MyAtoms::three;
// } // namespace detail
//
// static const nsStaticAtomSetup sMyAtomSetup[] = {
// { &detail::gMyAtoms.one_atom, &nsMyAtoms::one },
// { &detail::gMyAtoms.two_atom, &nsMyAtoms::two },
// { &detail::gMyAtoms.three_atom, &nsMyAtoms::three },
// };
// const nsStaticAtom* const nsMyAtoms::sAtoms =
// mozilla::detail::gMyAtoms.mAtoms;
//
// When RegisterStaticAtoms(sMyAtomSetup) is called it iterates over
// sMyAtomSetup[]. E.g. for the first atom it does roughly the following:
// - MyAtoms::one = one_atom
// - inserts one_atom into the atom table
// <<<
// #define MY_ATOM(name_, value_) NS_STATIC_ATOM_DEFN_PTR(nsStaticAtom, detail::MyAtoms, detail::gMyAtoms, nsMyAtoms, name_)
// #include "MyAtomList.h"
// #undef MY_ATOM
// ---
// nsStaticAtom* nsMyAtoms::one =
// const_cast<nsStaticAtom*>(&detail::gMyAtoms.mAtoms[
// static_cast<size_t>(detail::MyAtoms::Atoms::one)]);
// nsStaticAtom* nsMyAtoms::two =
// const_cast<nsStaticAtom*>(&detail::gMyAtoms.mAtoms[
// static_cast<size_t>(detail::MyAtoms::Atoms::two)]);
// nsStaticAtom* nsMyAtoms::three =
// const_cast<nsStaticAtom*>(&detail::gMyAtoms.mAtoms[
// static_cast<size_t>(detail::MyAtoms::Atoms::three)]);
// >>>
//
// When NS_RegisterStaticAtoms(sAtoms, sAtomsLen) is called it iterates
// over the atoms, inserting them into the atom table.
// The declaration of the atom's string, which must be within the same `detail`
// class as NS_STATIC_ATOM_DECL_ATOM.
// The declaration of the atom's string.
#define NS_STATIC_ATOM_DECL_STRING(name_, value_) \
const char16_t name_##_string[sizeof(value_)];
// The declaration of the static atom itself, which must be within the same
// `detail` class as NS_STATIC_ATOM_DECL_STRING.
#define NS_STATIC_ATOM_DECL_ATOM(name_) \
const nsStaticAtom name_##_atom;
// The enum value for the atom.
#define NS_STATIC_ATOM_ENUM(name_) \
name_,
// The declaration of the pointer to the static atom, which must be within
// a class.
#define NS_STATIC_ATOM_DECL_PTR(name_) \
static nsStaticAtom* name_;
// Like NS_STATIC_ATOM_DECL, but for sub-classes of nsStaticAtom.
#define NS_STATIC_ATOM_SUBCLASS_DECL_PTR(type_, name_) \
// The declaration of the pointer to the static atom. `type_` must be
// `nsStaticAtom` or a subclass thereof.
// XXX: Eventually this should be combined with NS_STATIC_ATOM_DEFN_PTR and the
// pointer should be made `constexpr`. See bug 1449787.
#define NS_STATIC_ATOM_DECL_PTR(type_, name_) \
static type_* name_;
// The initialization of the atom's string, which must be within a `constexpr`
// instance of the `detail` class.
// The initialization of the atom's string.
#define NS_STATIC_ATOM_INIT_STRING(value_) \
u"" value_,
// The initialization of the static atom itself, which must be within a
// `constexpr` instance of the `detail` class.
// The initialization of the atom itself. `type_` must be `nsStaticAtom` or a
// subclass thereof.
//
// Note that |value_| is an 8-bit string, and so |sizeof(value_)| is equal
// to the number of chars (including the terminating '\0'). The |u""| prefix
// converts |value_| to a 16-bit string.
#define NS_STATIC_ATOM_INIT_ATOM(class_, name_, value_) \
nsStaticAtom(u"" value_, \
sizeof(value_) - 1, \
offsetof(class_, name_##_atom) - \
offsetof(class_, name_##_string)),
#define NS_STATIC_ATOM_INIT_ATOM(type_, detailClass_, name_, value_) \
type_(u"" value_, \
sizeof(value_) - 1, \
offsetof(detailClass_, \
mAtoms[static_cast<size_t>(detailClass_::Atoms::name_)]) - \
offsetof(detailClass_, name_##_string)),
// The definition of the pointer to the static atom. Initially null, it is
// set by RegisterStaticAtoms() to point to a heap-allocated nsStaticAtom.
#define NS_STATIC_ATOM_DEFN_PTR(class_, name_) \
nsStaticAtom* class_::name_;
// Like NS_STATIC_ATOM_DEFN, but for sub-classes of nsStaticAtom.
#define NS_STATIC_ATOM_SUBCLASS_DEFN_PTR(type_, class_, name_) \
type_* class_::name_;
// The StaticAtomSetup. Used during start-up, and in some cases afterwards.
#define NS_STATIC_ATOM_SETUP(detailObj_, class_, name_) \
{ &detailObj_.name_##_atom, &class_::name_ },
// Like NS_STATIC_ATOM_SUBCLASS, but for sub-classes of nsStaticAtom.
#define NS_STATIC_ATOM_SUBCLASS_SETUP(detailObj_, class_, name_) \
{ &detailObj_.name_##_atom, \
reinterpret_cast<nsStaticAtom**>(&class_::name_) },
// Holds data used to initialize large number of atoms during startup. Use
// NS_STATIC_ATOM_SETUP to initialize these structs.
struct nsStaticAtomSetup
{
const nsStaticAtom* const mAtom;
nsStaticAtom** const mAtomp;
};
// Definition of the pointer to the static atom. `type_` must be `nsStaticAtom`
// or a subclass thereof.
#define NS_STATIC_ATOM_DEFN_PTR(type_, detailClass_, detailObj_, class_, name_) \
type_* class_::name_ = const_cast<type_*>( \
&detailObj_.mAtoms[static_cast<size_t>(detailClass_::Atoms::name_)]);
// Register an array of static atoms with the atom table.
template<uint32_t N>
void
NS_RegisterStaticAtoms(const nsStaticAtomSetup (&aSetup)[N])
{
extern void RegisterStaticAtoms(const nsStaticAtomSetup* aSetup,
uint32_t aCount);
RegisterStaticAtoms(aSetup, N);
}
NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, size_t aAtomsLen);
// This class holds basic operations on arrays of static atoms.
class nsStaticAtomUtils {
public:
template<uint32_t N>
static mozilla::Maybe<uint32_t> Lookup(nsAtom *aAtom,
const nsStaticAtomSetup (&aSetup)[N])
{
return Lookup(aAtom, aSetup, N);
}
template<uint32_t N>
static bool IsMember(nsAtom *aAtom, const nsStaticAtomSetup (&aSetup)[N])
{
return Lookup(aAtom, aSetup, N).isSome();
}
private:
static mozilla::Maybe<uint32_t> Lookup(nsAtom* aAtom,
const nsStaticAtomSetup* aSetup,
const nsStaticAtom* aAtoms,
uint32_t aCount)
{
for (uint32_t i = 0; i < aCount; i++) {
if (aAtom == *(aSetup[i].mAtomp)) {
if (aAtom == &aAtoms[i]) {
return mozilla::Some(i);
}
}
return mozilla::Nothing();
}
static bool IsMember(nsAtom* aAtom, const nsStaticAtom* aAtoms,
uint32_t aCount)
{
return Lookup(aAtom, aAtoms, aCount).isSome();
}
};
#endif

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

@ -12,7 +12,6 @@
#include "nsLocalFile.h"
#include "nsDebug.h"
#include "nsGkAtoms.h"
#include "nsStaticAtom.h"
#include "nsEnumeratorUtils.h"
#include "nsICategoryManager.h"
@ -103,30 +102,28 @@ extern constexpr DirectoryAtoms gDirectoryAtoms = {
#define DIR_ATOM(name_, value_) NS_STATIC_ATOM_INIT_STRING(value_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
#define DIR_ATOM(name_, value_) \
NS_STATIC_ATOM_INIT_ATOM(DirectoryAtoms, name_, value_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
{
#define DIR_ATOM(name_, value_) \
NS_STATIC_ATOM_INIT_ATOM(nsStaticAtom, DirectoryAtoms, name_, value_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
}
};
MOZ_POP_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING
} // namespace detail
} // namespace mozilla
const nsStaticAtom* const nsDirectoryService::sAtoms =
mozilla::detail::gDirectoryAtoms.mAtoms;
#define DIR_ATOM(name_, value_) \
NS_STATIC_ATOM_DEFN_PTR(nsDirectoryService, name_)
NS_STATIC_ATOM_DEFN_PTR( \
nsStaticAtom, mozilla::detail::DirectoryAtoms, \
mozilla::detail::gDirectoryAtoms, nsDirectoryService, name_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
static const nsStaticAtomSetup sDirectoryServiceAtomSetup[] = {
#define DIR_ATOM(name_, value_) \
NS_STATIC_ATOM_SETUP( \
mozilla::detail::gDirectoryAtoms, nsDirectoryService, name_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
};
NS_IMETHODIMP
nsDirectoryService::Init()
{
@ -142,7 +139,7 @@ nsDirectoryService::RealInit()
gService = new nsDirectoryService();
NS_RegisterStaticAtoms(sDirectoryServiceAtomSetup);
NS_RegisterStaticAtoms(sAtoms, sAtomsLen);
// Let the list hold the only reference to the provider.
nsAppFileLocationProvider* defaultProvider = new nsAppFileLocationProvider;

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

@ -30,9 +30,14 @@ struct DirectoryAtoms
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
#define DIR_ATOM(name_, value_) NS_STATIC_ATOM_DECL_ATOM(name_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
enum class Atoms {
#define DIR_ATOM(name_, value_) NS_STATIC_ATOM_ENUM(name_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
AtomsCount
};
const nsStaticAtom mAtoms[static_cast<size_t>(Atoms::AtomsCount)];
};
extern const DirectoryAtoms gDirectoryAtoms;
@ -74,8 +79,12 @@ private:
nsInterfaceHashtable<nsCStringHashKey, nsIFile> mHashtable;
nsTArray<nsCOMPtr<nsIDirectoryServiceProvider>> mProviders;
static const nsStaticAtom* const sAtoms;
static constexpr size_t sAtomsLen =
mozilla::ArrayLength(mozilla::detail::gDirectoryAtoms.mAtoms);
public:
#define DIR_ATOM(name_, value_) NS_STATIC_ATOM_DECL_PTR(name_)
#define DIR_ATOM(name_, value_) NS_STATIC_ATOM_DECL_PTR(nsStaticAtom, name_)
#include "nsDirectoryServiceAtomList.h"
#undef DIR_ATOM
};

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

@ -25,7 +25,6 @@
#include "nsIDOMOfflineResourceList.h"
#include "nsIDOMParser.h"
#include "nsIDOMRange.h"
#include "nsIDOMScreen.h"
#include "nsIDOMSerializer.h"
#include "nsIDOMXMLDocument.h"
#include "nsIDOMXULElement.h"
@ -69,7 +68,6 @@
#ifdef MOZ_WEBRTC
#include "mozilla/dom/RTCDataChannelBinding.h"
#endif
#include "mozilla/dom/ScreenBinding.h"
#include "mozilla/dom/SelectionBinding.h"
#include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/StyleSheetBinding.h"
@ -158,7 +156,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
#ifdef MOZ_WEBRTC
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMDataChannel, RTCDataChannel),
#endif
DEFINE_SHIM(Screen),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsITreeBoxObject, TreeBoxObject),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIWebBrowserPersistable, FrameLoader),

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

@ -23,7 +23,6 @@
#include "nsPrintfCString.h"
#include "nsMemory.h"
#include "prprf.h"
#include "nsStaticAtom.h"
#include "nsCOMPtr.h"
#include "mozilla/IntegerPrintfMacros.h"

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

@ -10,7 +10,6 @@
#include "nsString.h"
#include "UTFStrings.h"
#include "nsIServiceManager.h"
#include "nsStaticAtom.h"
#include "nsThreadUtils.h"
#include "gtest/gtest.h"

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

@ -20,6 +20,7 @@
#include "mozilla/Sprintf.h"
//Interfaces needed to be included
#include "nsGlobalWindowOuter.h"
#include "nsIAppShell.h"
#include "nsIAppShellService.h"
#include "nsIServiceManager.h"
@ -29,7 +30,7 @@
#include "nsIDOMElement.h"
#include "nsIDOMXULElement.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMScreen.h"
#include "nsScreen.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
@ -1028,23 +1029,25 @@ NS_IMETHODIMP nsXULWindow::EnsureAuthPrompter()
NS_IMETHODIMP nsXULWindow::GetAvailScreenSize(int32_t* aAvailWidth, int32_t* aAvailHeight)
{
nsresult rv;
nsCOMPtr<mozIDOMWindowProxy> domWindow;
GetWindowDOMWindow(getter_AddRefs(domWindow));
NS_ENSURE_STATE(domWindow);
auto* window = nsPIDOMWindowOuter::From(domWindow);
NS_ENSURE_STATE(window);
auto* window = nsGlobalWindowOuter::Cast(domWindow);
nsCOMPtr<nsIDOMScreen> screen = window->GetScreen();
RefPtr<nsScreen> screen = window->GetScreen();
NS_ENSURE_STATE(screen);
rv = screen->GetAvailWidth(aAvailWidth);
NS_ENSURE_SUCCESS(rv, rv);
ErrorResult rv;
*aAvailWidth = screen->GetAvailWidth(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
rv = screen->GetAvailHeight(aAvailHeight);
NS_ENSURE_SUCCESS(rv, rv);
*aAvailHeight = screen->GetAvailHeight(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
return NS_OK;
}