Highlight.webidl (2099B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://drafts.csswg.org/css-highlight-api-1/ 8 * 9 * Copyright © 2021 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 10 * liability, trademark and document use rules apply. 11 */ 12 13 /** 14 * Enum defining the available highlight types. 15 * See https://drafts.csswg.org/css-highlight-api-1/#enumdef-highlighttype 16 */ 17 enum HighlightType { 18 "highlight", 19 "spelling-error", 20 "grammar-error" 21 }; 22 23 /** 24 * Definition of a highlight object, consisting of a set of ranges, 25 * a priority and a highlight type. 26 * 27 * See https://drafts.csswg.org/css-highlight-api-1/#highlight 28 */ 29 [Pref="dom.customHighlightAPI.enabled", Exposed=Window] 30 interface Highlight { 31 32 [Throws] 33 constructor(AbstractRange... initialRanges); 34 setlike<AbstractRange>; 35 attribute long priority; 36 attribute HighlightType type; 37 }; 38 39 partial interface Highlight { 40 // Setlike methods need to be overridden. 41 // Iterating a setlike is not possible from C++ yet. 42 // Therefore a separate data structure must be held and kept in sync. 43 [Throws] 44 Highlight add(AbstractRange range); 45 [Throws] 46 undefined clear(); 47 [Throws] 48 boolean delete(AbstractRange range); 49 }; 50 51 /** 52 * Registry object that contains all Highlights associated with a Document. 53 * 54 * See https://drafts.csswg.org/css-highlight-api-1/#highlightregistry 55 */ 56 [Pref="dom.customHighlightAPI.enabled", Exposed=Window] 57 interface HighlightRegistry { 58 maplike<DOMString, Highlight>; 59 }; 60 61 partial interface HighlightRegistry { 62 // Maplike interface methods need to be overridden. 63 // Iterating a maplike is not possible from C++ yet. 64 // Therefore, a separate data structure must be held and kept in sync. 65 [Throws] 66 HighlightRegistry set(DOMString key, Highlight value); 67 [Throws] 68 undefined clear(); 69 [Throws] 70 boolean delete(DOMString key); 71 };