Auto merge of #22743 - ferjm:shadowdom, r=emilio

Partial ShadowDOM support

This is just an early WIP, not to take it very seriously yet.

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22719
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22743)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-04-29 08:38:50 -04:00 committed by GitHub
commit 799490a02e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 2081 additions and 702 deletions

View file

@ -132,7 +132,6 @@ partial /*sealed*/ interface Document {
// user interaction
readonly attribute Window?/*Proxy?*/ defaultView;
readonly attribute Element? activeElement;
boolean hasFocus();
// [CEReactions]
// attribute DOMString designMode;
@ -199,17 +198,6 @@ partial interface Document {
TouchList createTouchList(Touch... touches);
};
// https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint
partial interface Document {
Element? elementFromPoint(double x, double y);
sequence<Element> elementsFromPoint(double x, double y);
};
// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface
partial interface Document {
[SameObject] readonly attribute StyleSheetList styleSheets;
};
// https://fullscreen.spec.whatwg.org/#api
partial interface Document {
[LenientSetter] readonly attribute boolean fullscreenEnabled;
@ -221,3 +209,5 @@ partial interface Document {
attribute EventHandler onfullscreenchange;
attribute EventHandler onfullscreenerror;
};
Document implements DocumentOrShadowRoot;

View file

@ -0,0 +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 https://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://dom.spec.whatwg.org/#documentorshadowroot
* https://w3c.github.io/webcomponents/spec/shadow/#extensions-to-the-documentorshadowroot-mixin
*/
[NoInterfaceObject]
interface DocumentOrShadowRoot {
// Selection? getSelection();
Element? elementFromPoint (double x, double y);
sequence<Element> elementsFromPoint (double x, double y);
// CaretPosition? caretPositionFromPoint (double x, double y);
readonly attribute Element? activeElement;
readonly attribute StyleSheetList styleSheets;
};

View file

@ -81,6 +81,8 @@ interface Element : Node {
void insertAdjacentText(DOMString where_, DOMString data);
[CEReactions, Throws]
void insertAdjacentHTML(DOMString position, DOMString html);
[Throws, Pref="dom.shadowdom.enabled"] ShadowRoot attachShadow();
};
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-element-interface

View file

@ -32,7 +32,7 @@ interface Node : EventTarget {
readonly attribute Document? ownerDocument;
[Pure]
Node getRootNode();
Node getRootNode(optional GetRootNodeOptions options);
[Pure]
readonly attribute Node? parentNode;
@ -58,7 +58,7 @@ interface Node : EventTarget {
[CEReactions]
void normalize();
[CEReactions]
[CEReactions, Throws]
Node cloneNode(optional boolean deep = false);
[Pure]
boolean isEqualNode(Node? node);
@ -92,3 +92,7 @@ interface Node : EventTarget {
[CEReactions, Throws]
Node removeChild(Node child);
};
dictionary GetRootNodeOptions {
boolean composed = false;
};

View file

@ -0,0 +1,17 @@
/* 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 https://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is:
* https://dom.spec.whatwg.org/#interface-shadowroot
*/
[Exposed=Window]
interface ShadowRoot : DocumentFragment {
readonly attribute ShadowRootMode mode;
readonly attribute Element host;
};
enum ShadowRootMode { "open", "closed"};
ShadowRoot implements DocumentOrShadowRoot;