gecko-dev/dom/base/AnonymousContent.h
Emilio Cobos Álvarez bd1b363ff9 Bug 1824886 - Rewrite AnonymousContent to use a shadow tree. r=smaug,TYLin,sfoster,devtools-reviewers,nchevobbe
Subtle things:

 * We now have shadow trees in NAC, inception! Only a couple lines of
   code in the style system had to be changed to match :host rules and
   so properly.

 * Had to make highlighters.css contentaccessible, because otherwise we
   can't load it from the shadow tree. I don't think it's a big deal.

 * I removed some of the code from highlighters.css that claimed that
   stuff inherited from the html element. That's just no longer true.

 * Had to switch from `setAttribute("style", ...)` to `.style = ...;`.
   This is needed because CSSOM from chrome code bypasses CSP (as
   AnonymousContent did), but setAttribute() doesn't, see bug 1424474.

Differential Revision: https://phabricator.services.mozilla.com/D173998
2023-07-09 11:34:05 +00:00

46 lines
1.4 KiB
C++

/* -*- 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_AnonymousContent_h
#define mozilla_dom_AnonymousContent_h
#include "mozilla/AlreadyAddRefed.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupportsImpl.h"
namespace mozilla::dom {
class Element;
class Document;
class ShadowRoot;
class AnonymousContent final {
public:
// Ref counting and cycle collection
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnonymousContent)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AnonymousContent)
static already_AddRefed<AnonymousContent> Create(Document&);
Element* Host() const { return mHost.get(); }
ShadowRoot* Root() const { return mRoot.get(); }
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
JS::MutableHandle<JSObject*> aReflector);
private:
~AnonymousContent();
explicit AnonymousContent(already_AddRefed<Element> aHost,
already_AddRefed<ShadowRoot> aRoot);
RefPtr<Element> mHost;
RefPtr<ShadowRoot> mRoot;
};
} // namespace mozilla::dom
#endif // mozilla_dom_AnonymousContent_h