Skip to content

Truly independent web browser

6.8 KB
Raw Blame
// https://drafts.csswg.org/cssom-1/#namespacedef-css
[Exposed=Window, ImplementedIn=Rust]
namespace CSS {
    CSSOMString escape(CSSOMString ident);
};

// https://drafts.csswg.org/css-conditional-3/#dom-css-supports
partial namespace CSS {
    [ImplementedAs=supports_property] boolean supports(CSSOMString property, CSSOMString value);
    [ImplementedAs=supports_condition] boolean supports(CSSOMString conditionText);
};

// https://drafts.css-houdini.org/css-properties-values-api-1/#registering-custom-properties
dictionary PropertyDefinition {
    required DOMString name;
    DOMString syntax = "*";
    // FIXME: The spec has made this optional, but web reality does not yet match that change.
    //        https://github.com/w3c/css-houdini-drafts/commit/e1f11c5e6fffef319bcdc0f0fe25034d1a6a4b3f
    required boolean inherits;
    DOMString initialValue;
};

partial namespace CSS {
    undefined registerProperty(PropertyDefinition definition);
};

// https://drafts.csswg.org/css-highlight-api-1/#registration
partial namespace CSS {
    readonly attribute HighlightRegistry highlights;
};

// https://drafts.css-houdini.org/css-typed-om-1/#numeric-factory
// NB: Extensions to the CSS namepace are generated by generate_libweb_css_numeric_factory_methods.py.

// https://drafts.csswg.org/cssom/#extensions-to-the-window-interface
partial interface Window {
    [NewObject] CSSStyleProperties getComputedStyle(Element elt, optional CSSOMString? pseudoElt);
};

// https://w3c.github.io/csswg-drafts/cssom-view/#extensions-to-the-window-interface
enum ScrollBehavior { "auto", "instant", "smooth" };

dictionary ScrollOptions {
    ScrollBehavior behavior = "auto";
};

dictionary ScrollToOptions : ScrollOptions {
    unrestricted double left;
    unrestricted double top;
};

partial interface Window {
    [NewObject] MediaQueryList matchMedia(CSSOMString query);
    [SameObject, Replaceable] readonly attribute Screen screen;
    [SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;

    // browsing context
    undefined moveTo(long x, long y);
    undefined moveBy(long x, long y);
    undefined resizeTo(long width, long height);
    undefined resizeBy(long x, long y);

    // viewport
    [Replaceable] readonly attribute long innerWidth;
    [Replaceable] readonly attribute long innerHeight;

    // viewport scrolling
    [Replaceable] readonly attribute double scrollX;
    [Replaceable, ImplementedAs=scroll_x] readonly attribute double pageXOffset;
    [Replaceable] readonly attribute double scrollY;
    [Replaceable, ImplementedAs=scroll_y] readonly attribute double pageYOffset;
    [CreatesPromise] Promise<undefined> scroll(optional ScrollToOptions options = {});
    [CreatesPromise] Promise<undefined> scroll(unrestricted double x, unrestricted double y);
    [ImplementedAs=scroll, CreatesPromise] Promise<undefined> scrollTo(optional ScrollToOptions options = {});
    [ImplementedAs=scroll, CreatesPromise] Promise<undefined> scrollTo(unrestricted double x, unrestricted double y);
    [CreatesPromise] Promise<undefined> scrollBy(optional ScrollToOptions options = {});
    [CreatesPromise] Promise<undefined> scrollBy(unrestricted double x, unrestricted double y);

    // client
    [Replaceable] readonly attribute long screenX;
    [Replaceable, ImplementedAs=screen_x] readonly attribute long screenLeft;
    [Replaceable] readonly attribute long screenY;
    [Replaceable, ImplementedAs=screen_y] readonly attribute long screenTop;
    [Replaceable] readonly attribute long outerWidth;
    [Replaceable] readonly attribute long outerHeight;
    [Replaceable] readonly attribute double devicePixelRatio;
};

// https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
partial interface Document {
    Element? elementFromPoint(double x, double y);
    sequence<Element> elementsFromPoint(double x, double y);
    CaretPosition? caretPositionFromPoint(double x, double y, optional CaretPositionFromPointOptions options = {});
    readonly attribute Element? scrollingElement;
};

// INTEROP: Chrome and Safari also expose these hit-testing methods on ShadowRoot.
// https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
partial interface ShadowRoot {
    Element? elementFromPoint(double x, double y);
    sequence<Element> elementsFromPoint(double x, double y);
};

dictionary CaretPositionFromPointOptions {
    sequence<ShadowRoot> shadowRoots = [];
};

// https://drafts.csswg.org/cssom/#extensions-to-the-document-or-shadow-root-interface
partial interface mixin DocumentOrShadowRoot {
    [SameObject, ImplementedInBindings] readonly attribute StyleSheetList styleSheets;
    // FIXME: adoptedStyleSheets should be ObservableArray<CSSStyleSheet>.
    [ImplementedInBindings] attribute any adoptedStyleSheets;
};

// https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
dictionary ScrollIntoViewOptions : ScrollOptions {
    ScrollLogicalPosition block = "start";
    ScrollLogicalPosition inline = "nearest";
    ScrollIntoViewContainer container = "all";
};

enum ScrollIntoViewContainer { "all", "nearest" };

dictionary CheckVisibilityOptions {
    boolean checkOpacity = false;
    boolean checkVisibilityCSS = false;
    boolean contentVisibilityAuto = false;
    boolean opacityProperty = false;
    boolean visibilityProperty = false;
};

partial interface Element {
    [ImplementedInBindings] DOMRectList getClientRects();
    [NewObject, ImplementedInBindings] DOMRect getBoundingClientRect();

    boolean checkVisibility(optional CheckVisibilityOptions options = {});

    [CreatesPromise] Promise<undefined> scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
    [CreatesPromise] Promise<undefined> scroll(optional ScrollToOptions options = {});
    [CreatesPromise] Promise<undefined> scroll(unrestricted double x, unrestricted double y);
    [CreatesPromise, ImplementedAs=scroll] Promise<undefined> scrollTo(optional ScrollToOptions options = {});
    [CreatesPromise, ImplementedAs=scroll] Promise<undefined> scrollTo(unrestricted double x, unrestricted double y);
    [CreatesPromise] Promise<undefined> scrollBy(optional ScrollToOptions options = {});
    [CreatesPromise] Promise<undefined> scrollBy(unrestricted double x, unrestricted double y);
    attribute unrestricted double scrollTop;
    attribute unrestricted double scrollLeft;
    readonly attribute long scrollWidth;
    readonly attribute long scrollHeight;
    readonly attribute long clientTop;
    readonly attribute long clientLeft;
    readonly attribute long clientWidth;
    readonly attribute long clientHeight;
    readonly attribute double currentCSSZoom;
};

// https://drafts.csswg.org/css-shadow-1/#idl
partial interface Element {
    [SameObject, PutForwards=value, ImplementedAs=part_list] readonly attribute DOMTokenList part;
};