Commit 9b57d020 authored by Sean Feng's avatar Sean Feng
Browse files

Bug 1413836 - Add delegatesFocus attribute to shadow dom r=smaug

parent a27769ef
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1180,11 +1180,13 @@ already_AddRefed<ShadowRoot> Element::AttachShadow(const ShadowRootInit& aInit,
    OwnerDoc()->ReportShadowDOMUsage();
  }

  return AttachShadowWithoutNameChecks(aInit.mMode, aInit.mSlotAssignment);
  return AttachShadowWithoutNameChecks(aInit.mMode, aInit.mDelegatesFocus,
                                       aInit.mSlotAssignment);
}

already_AddRefed<ShadowRoot> Element::AttachShadowWithoutNameChecks(
    ShadowRootMode aMode, SlotAssignmentMode aSlotAssignment) {
    ShadowRootMode aMode, bool aDelegatesFocus,
    SlotAssignmentMode aSlotAssignment) {
  nsAutoScriptBlocker scriptBlocker;

  RefPtr<mozilla::dom::NodeInfo> nodeInfo =
@@ -1212,8 +1214,8 @@ already_AddRefed<ShadowRoot> Element::AttachShadowWithoutNameChecks(
   *    and mode is init's mode.
   */
  auto* nim = nodeInfo->NodeInfoManager();
  RefPtr<ShadowRoot> shadowRoot =
      new (nim) ShadowRoot(this, aMode, aSlotAssignment, nodeInfo.forget());
  RefPtr<ShadowRoot> shadowRoot = new (nim) ShadowRoot(
      this, aMode, aDelegatesFocus, aSlotAssignment, nodeInfo.forget());

  if (NodeOrAncestorHasDirAuto()) {
    shadowRoot->SetAncestorHasDirAuto();
+1 −1
Original line number Diff line number Diff line
@@ -1269,7 +1269,7 @@ class Element : public FragmentOrElement {
  bool CanAttachShadowDOM() const;

  already_AddRefed<ShadowRoot> AttachShadowWithoutNameChecks(
      ShadowRootMode aMode,
      ShadowRootMode aMode, bool aDelegatesFocus = false,
      SlotAssignmentMode aSlotAssignmentMode = SlotAssignmentMode::Named);

  // Attach UA Shadow Root if it is not attached.
+2 −1
Original line number Diff line number Diff line
@@ -48,11 +48,12 @@ NS_IMPL_ADDREF_INHERITED(ShadowRoot, DocumentFragment)
NS_IMPL_RELEASE_INHERITED(ShadowRoot, DocumentFragment)

ShadowRoot::ShadowRoot(Element* aElement, ShadowRootMode aMode,
                       SlotAssignmentMode aSlotAssignment,
                       bool aDelegatesFocus, SlotAssignmentMode aSlotAssignment,
                       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
    : DocumentFragment(std::move(aNodeInfo)),
      DocumentOrShadowRoot(this),
      mMode(aMode),
      mDelegatesFocus(aDelegatesFocus),
      mSlotAssignment(aSlotAssignment),
      mIsUAWidget(false),
      mIsAvailableToElementInternals(false) {
+4 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class ShadowRoot final : public DocumentFragment,
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRoot, DocumentFragment)
  NS_DECL_ISUPPORTS_INHERITED

  ShadowRoot(Element* aElement, ShadowRootMode aMode,
  ShadowRoot(Element* aElement, ShadowRootMode aMode, bool aDelegatesFocus,
             SlotAssignmentMode aSlotAssignment,
             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);

@@ -76,6 +76,7 @@ class ShadowRoot final : public DocumentFragment,
  }

  ShadowRootMode Mode() const { return mMode; }
  bool DelegatesFocus() const { return mDelegatesFocus; }
  SlotAssignmentMode SlotAssignment() const { return mSlotAssignment; }
  bool IsClosed() const { return mMode == ShadowRootMode::Closed; }

@@ -273,6 +274,8 @@ class ShadowRoot final : public DocumentFragment,

  const ShadowRootMode mMode;

  bool mDelegatesFocus;

  const SlotAssignmentMode mSlotAssignment;

  // The computed data from the style sheets.
+2 −0
Original line number Diff line number Diff line
@@ -260,6 +260,8 @@ partial interface Element {
// https://dom.spec.whatwg.org/#dictdef-shadowrootinit
dictionary ShadowRootInit {
  required ShadowRootMode mode;
  [Pref="dom.shadowdom.delegatesFocus.enabled"]
  boolean delegatesFocus = false;
  [Pref="dom.shadowdom.slot.assign.enabled"]
  SlotAssignmentMode slotAssignment = "named";
};
Loading