From b54174e54a7f55cb6e11b6fb20f6615b37f5b65a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 4 Nov 2015 16:15:00 +0000 Subject: [PATCH] Add CSS object model and DOM parsing IDL ready for implementation --- Docs/UnimplementedJavascript.txt | 102 ++++++++++++++++--- javascript/WebIDL/Makefile | 10 +- javascript/WebIDL/cssom.idl | 157 ++++++++++++++++++++++++++++++ javascript/WebIDL/dom-parsing.idl | 35 +++++++ javascript/duktape/netsurf.bnd | 2 + 5 files changed, 291 insertions(+), 15 deletions(-) create mode 100644 javascript/WebIDL/cssom.idl create mode 100644 javascript/WebIDL/dom-parsing.idl diff --git a/Docs/UnimplementedJavascript.txt b/Docs/UnimplementedJavascript.txt index c99c5804e..d81c34f0b 100644 --- a/Docs/UnimplementedJavascript.txt +++ b/Docs/UnimplementedJavascript.txt @@ -168,6 +168,50 @@ getter CloseEvent::reason(string);\n getter CloseEvent::wasClean(boolean);\n getter CompositionEvent::data(string);\n method CompositionEvent::initCompositionEvent();\n +method CSS::escape();\n +getter CSSGroupingRule::cssRules(user);\n +method CSSGroupingRule::deleteRule();\n +method CSSGroupingRule::insertRule();\n +getter CSSImportRule::href(string);\n +getter CSSImportRule::media(user);\n +getter CSSImportRule::styleSheet(user);\n +getter CSSMarginRule::name(string);\n +getter CSSMarginRule::style(user);\n +getter CSSMediaRule::media(user);\n +getter CSSNamespaceRule::namespaceURI(string);\n +getter CSSNamespaceRule::prefix(string);\n +getter CSSPageRule::selectorText(string);\n +setter CSSPageRule::selectorText(string);\n +getter CSSPageRule::style(user);\n +getter CSSRule::cssText(string);\n +setter CSSRule::cssText(string);\n +method CSSRuleList::item();\n +getter CSSRuleList::length(unsigned long);\n +getter CSSRule::parentRule(user);\n +getter CSSRule::parentStyleSheet(user);\n +getter CSSRule::type(unsigned short);\n +getter CSSStyleDeclaration::cssFloat(string);\n +setter CSSStyleDeclaration::cssFloat(string);\n +getter CSSStyleDeclaration::cssText(string);\n +setter CSSStyleDeclaration::cssText(string);\n +getter CSSStyleDeclaration::dashed_attribute(string);\n +setter CSSStyleDeclaration::dashed_attribute(string);\n +method CSSStyleDeclaration::getPropertyPriority();\n +method CSSStyleDeclaration::getPropertyValue();\n +method CSSStyleDeclaration::item();\n +getter CSSStyleDeclaration::length(unsigned long);\n +getter CSSStyleDeclaration::parentRule(user);\n +method CSSStyleDeclaration::removeProperty();\n +method CSSStyleDeclaration::setProperty();\n +method CSSStyleDeclaration::setPropertyPriority();\n +method CSSStyleDeclaration::setPropertyValue();\n +getter CSSStyleRule::selectorText(string);\n +setter CSSStyleRule::selectorText(string);\n +getter CSSStyleRule::style(user);\n +getter CSSStyleSheet::cssRules(user);\n +method CSSStyleSheet::deleteRule();\n +method CSSStyleSheet::insertRule();\n +getter CSSStyleSheet::ownerRule(user);\n getter CustomEvent::detail(any);\n method CustomEvent::initCustomEvent();\n method DataTransfer::clearData();\n @@ -235,6 +279,7 @@ getter Document::documentURI(string);\n getter Document::domain(string);\n setter Document::domain(string);\n getter Document::embeds(user);\n +method Document::enableStyleSheetsForSet();\n method Document::execCommand();\n getter Document::fgColor(string);\n setter Document::fgColor(string);\n @@ -261,6 +306,7 @@ method Document::importNode();\n getter Document::inputEncoding(string);\n getter Document::lastElementChild(user);\n getter Document::lastModified(string);\n +getter Document::lastStyleSheetSet(string);\n getter Document::linkColor(string);\n setter Document::linkColor(string);\n getter Document::links(user);\n @@ -395,6 +441,7 @@ setter Document::onwheel(user);\n method Document::open();\n getter Document::origin(string);\n getter Document::plugins(user);\n +getter Document::preferredStyleSheetSet(string);\n method Document::prepend();\n method Document::query();\n method Document::queryAll();\n @@ -409,6 +456,10 @@ getter Document::readyState(user);\n getter Document::referrer(string);\n method Document::releaseEvents();\n getter Document::scripts(user);\n +getter Document::selectedStyleSheetSet(string);\n +setter Document::selectedStyleSheetSet(string);\n +getter Document::styleSheetSets(string);\n +getter Document::styleSheets(user);\n getter Document::title(string);\n setter Document::title(string);\n method DocumentType::after();\n @@ -425,6 +476,7 @@ method DOMImplementation::createDocument();\n method DOMImplementation::createDocumentType();\n method DOMImplementation::createHTMLDocument();\n method DOMImplementation::hasFeature();\n +method DOMParser::parseFromString();\n getter DOMSettableTokenList::value(string);\n setter DOMSettableTokenList::value(string);\n method DOMTokenList::add();\n @@ -458,9 +510,11 @@ method Element::after();\n method Element::append();\n getter Element::attributes(user);\n method Element::before();\n +getter Element::cascadedStyle(user);\n getter Element::children(user);\n getter Element::classList(user);\n method Element::closest();\n +getter Element::defaultStyle(user);\n method Element::getAttributeNode();\n method Element::getAttributeNodeNS();\n method Element::getAttributeNS();\n @@ -468,15 +522,22 @@ method Element::getElementsByClassName();\n method Element::getElementsByTagNameNS();\n method Element::hasAttributeNS();\n method Element::hasAttributes();\n +getter Element::innerHTML(string);\n +setter Element::innerHTML(string);\n +method Element::insertAdjacentHTML();\n getter Element::localName(string);\n method Element::matches();\n getter Element::namespaceURI(string);\n +getter Element::outerHTML(string);\n +setter Element::outerHTML(string);\n getter Element::prefix(string);\n method Element::prepend();\n +method Element::pseudo();\n method Element::query();\n method Element::queryAll();\n method Element::querySelector();\n method Element::querySelectorAll();\n +getter Element::rawComputedStyle(user);\n method Element::remove();\n method Element::removeAttributeNode();\n method Element::removeAttributeNS();\n @@ -485,20 +546,15 @@ method Element::setAttributeNode();\n method Element::setAttributeNodeNS();\n method Element::setAttributeNS();\n getter Element::tagName(string);\n +getter Element::usedStyle(user);\n getter ErrorEvent::colno(unsigned long);\n getter ErrorEvent::error(any);\n getter ErrorEvent::filename(string);\n getter ErrorEvent::lineno(unsigned long);\n getter ErrorEvent::message(string);\n -getter Event::bubbles(boolean);\n -getter Event::cancelable(boolean);\n -getter Event::currentTarget(user);\n -getter Event::defaultPrevented(boolean);\n -getter Event::eventPhase(unsigned short);\n method Event::initEvent();\n getter Event::isTrusted(boolean);\n method EventListener::handleEvent();\n -method Event::preventDefault();\n method EventSource::close();\n getter EventSource::onerror(user);\n setter EventSource::onerror(user);\n @@ -509,14 +565,10 @@ setter EventSource::onopen(user);\n getter EventSource::readyState(unsigned short);\n getter EventSource::url(string);\n getter EventSource::withCredentials(boolean);\n -method Event::stopImmediatePropagation();\n -method Event::stopPropagation();\n method EventTarget::addEventListener();\n method EventTarget::dispatchEvent();\n method EventTarget::removeEventListener();\n -getter Event::target(user);\n getter Event::timeStamp(user);\n -getter Event::type(string);\n method External::AddSearchProvider();\n method External::IsSearchProviderInstalled();\n method FocusEvent::initFocusEvent();\n @@ -716,8 +768,6 @@ getter HTMLElement::oncanplay(user);\n setter HTMLElement::oncanplay(user);\n getter HTMLElement::onchange(user);\n setter HTMLElement::onchange(user);\n -getter HTMLElement::onclick(user);\n -setter HTMLElement::onclick(user);\n getter HTMLElement::onclose(user);\n setter HTMLElement::onclose(user);\n getter HTMLElement::oncontextmenu(user);\n @@ -828,6 +878,7 @@ getter HTMLElement::onwheel(user);\n setter HTMLElement::onwheel(user);\n getter HTMLElement::spellcheck(boolean);\n setter HTMLElement::spellcheck(boolean);\n +getter HTMLElement::style(user);\n getter HTMLElement::tabIndex(long);\n setter HTMLElement::tabIndex(long);\n getter HTMLElement::translate(boolean);\n @@ -1021,6 +1072,7 @@ getter HTMLLegendElement::form(user);\n getter HTMLLinkElement::crossOrigin(string);\n setter HTMLLinkElement::crossOrigin(string);\n getter HTMLLinkElement::relList(user);\n +getter HTMLLinkElement::sheet(user);\n getter HTMLLinkElement::sizes(user);\n getter HTMLMapElement::areas(user);\n getter HTMLMarqueeElement::behavior(string);\n @@ -1239,6 +1291,7 @@ getter HTMLStyleElement::nonce(string);\n setter HTMLStyleElement::nonce(string);\n getter HTMLStyleElement::scoped(boolean);\n setter HTMLStyleElement::scoped(boolean);\n +getter HTMLStyleElement::sheet(user);\n getter HTMLTableCellElement::headers(user);\n getter HTMLTableColElement::span(unsigned long);\n setter HTMLTableColElement::span(unsigned long);\n @@ -1422,6 +1475,12 @@ method MediaController::unpause();\n getter MediaController::volume(double);\n setter MediaController::volume(double);\n getter MediaError::code(unsigned short);\n +method MediaList::appendMedium();\n +method MediaList::deleteMedium();\n +method MediaList::item();\n +getter MediaList::length(unsigned long);\n +getter MediaList::mediaText(string);\n +setter MediaList::mediaText(string);\n getter MessageChannel::port1(user);\n getter MessageChannel::port2(user);\n getter MessageEvent::data(any);\n @@ -1528,7 +1587,12 @@ getter Plugin::length(unsigned long);\n method Plugin::namedItem();\n getter Plugin::name(string);\n getter PopStateEvent::state(any);\n +getter ProcessingInstruction::sheet(user);\n getter ProcessingInstruction::target(string);\n +getter PseudoElement::cascadedStyle(user);\n +getter PseudoElement::defaultStyle(user);\n +getter PseudoElement::rawComputedStyle(user);\n +getter PseudoElement::usedStyle(user);\n getter RadioNodeList::value(string);\n setter RadioNodeList::value(string);\n method Range::cloneContents();\n @@ -1538,6 +1602,7 @@ getter Range::collapsed(boolean);\n getter Range::commonAncestorContainer(user);\n method Range::compareBoundaryPoints();\n method Range::comparePoint();\n +method Range::createContextualFragment();\n method Range::deleteContents();\n method Range::detach();\n getter Range::endContainer(user);\n @@ -1576,6 +1641,17 @@ method Storage::key();\n getter Storage::length(unsigned long);\n method Storage::removeItem();\n method Storage::setItem();\n +getter StyleSheet::disabled(boolean);\n +setter StyleSheet::disabled(boolean);\n +getter StyleSheet::href(string);\n +method StyleSheetList::item();\n +getter StyleSheetList::length(unsigned long);\n +getter StyleSheet::media(user);\n +getter StyleSheet::ownerNode(user);\n +getter StyleSheet::parentStyleSheet(user);\n +getter StyleSheet::title(string);\n +getter StyleSheet::type(string);\n +getter SVGElement::style(user);\n getter TextMetrics::actualBoundingBoxAscent(double);\n getter TextMetrics::actualBoundingBoxDescent(double);\n getter TextMetrics::actualBoundingBoxLeft(double);\n @@ -1741,6 +1817,7 @@ getter Window::external(user);\n method Window::focus();\n getter Window::frameElement(user);\n getter Window::frames(user);\n +method Window::getComputedStyle();\n getter Window::history(user);\n getter Window::length(unsigned long);\n getter Window::localStorage(user);\n @@ -1969,4 +2046,5 @@ setter Worker::onmessage(user);\n method Worker::postMessage();\n method Worker::terminate();\n method XMLDocument::load();\n +method XMLSerializer::serializeToString();\n */ diff --git a/javascript/WebIDL/Makefile b/javascript/WebIDL/Makefile index 6319bbddd..7d901cee1 100644 --- a/javascript/WebIDL/Makefile +++ b/javascript/WebIDL/Makefile @@ -16,12 +16,13 @@ .PHONY:all clean -all: dom.idl html.idl uievents.idl +all: dom.idl html.idl uievents.idl cssom.idl -.INTERMEDIATE:dom-spec.html dom-spec.xml dom-idl.html +.INTERMEDIATE:dom-spec.html dom-spec.xml dom-idl.html .INTERMEDIATE:html-spec.html html-spec.xml html-idl.html .INTERMEDIATE:uievents-spec.html uievents-spec.xml uievents-idl.html .INTERMEDIATE:urlutils-spec.html urlutils-spec.xml urlutils-idl.html +.INTERMEDIATE:cssom-spec.html cssom-spec.xml cssom-idl.html dom-spec.html: curl -s https://dom.spec.whatwg.org/ -o $@ @@ -35,8 +36,11 @@ uievents-spec.html: urlutils-spec.html: curl -s https://url.spec.whatwg.org/ -o $@ +cssom-spec.html: + curl -s https://drafts.csswg.org/cssom-1/ -o $@ + %-spec.xml: %-spec.html - -tidy -q -f $@.errors --new-blocklevel-tags header,hgroup,figure,time,main,nav,svg,rect,text,image,mark,figcaption,section -o $@ -asxml $< + -tidy -q -f $@.errors --new-blocklevel-tags header,hgroup,figure,time,main,nav,svg,rect,text,image,mark,figcaption,section,g,path,circle -o $@ -asxml $< %-idl.html: %-spec.xml hxselect 'pre[class="idl"]' < $< > $@ diff --git a/javascript/WebIDL/cssom.idl b/javascript/WebIDL/cssom.idl new file mode 100644 index 000000000..95c97e42a --- /dev/null +++ b/javascript/WebIDL/cssom.idl @@ -0,0 +1,157 @@ +// Retrived from https://drafts.csswg.org/cssom-1/ +// Wed Nov 4 15:39:43 GMT 2015 +// Removed duplicate IDL from appendix + + +[ArrayClass]interface MediaList { + [TreatNullAs=EmptyString] stringifier attribute DOMString mediaText; + readonly attribute unsigned long length; + getter DOMString? item(unsigned long index ); + void appendMedium(DOMString medium ); + void deleteMedium(DOMString medium ); +}; + +interface StyleSheet { + readonly attribute DOMString type; + readonly attribute DOMString? href; + readonly attribute (Element or ProcessingInstruction)? ownerNode; + readonly attribute StyleSheet? parentStyleSheet; + readonly attribute DOMString? title; + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; + attribute boolean disabled; +}; + +interface CSSStyleSheet : StyleSheet { + readonly attribute CSSRule? ownerRule; + [SameObject] readonly attribute CSSRuleList cssRules; + unsigned long insertRule(DOMString rule , unsigned long index ); + void deleteRule(unsigned long index ); +}; + +[ArrayClass]interface StyleSheetList { + getter StyleSheet? item(unsigned long index ); + readonly attribute unsigned long length; +}; + +partial interface Document { + [SameObject] readonly attribute StyleSheetList styleSheets; + attribute DOMString? selectedStyleSheetSet; + readonly attribute DOMString? lastStyleSheetSet; + readonly attribute DOMString? preferredStyleSheetSet; + readonly attribute DOMString[] styleSheetSets; + void enableStyleSheetsForSet(DOMString? name ); +}; + +[NoInterfaceObject]interface LinkStyle { + readonly attribute StyleSheet? sheet; +}; + +ProcessingInstruction implements LinkStyle; + +[ArrayClass]interface CSSRuleList { + getter CSSRule? item(unsigned long index ); + readonly attribute unsigned long length; +}; + +interface CSSRule { + const unsigned short STYLE_RULE = 1; + const unsigned short CHARSET_RULE = 2; // historical + const unsigned short IMPORT_RULE = 3; + const unsigned short MEDIA_RULE = 4; + const unsigned short FONT_FACE_RULE = 5; + const unsigned short PAGE_RULE = 6; + const unsigned short MARGIN_RULE = 9; + const unsigned short NAMESPACE_RULE = 10; + readonly attribute unsigned short type; + attribute DOMString cssText; + readonly attribute CSSRule? parentRule; + readonly attribute CSSStyleSheet? parentStyleSheet; +}; + +interface CSSStyleRule : CSSRule { + attribute DOMString selectorText; + [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; +}; + +interface CSSImportRule : CSSRule { + readonly attribute DOMString href; + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; + [SameObject] readonly attribute CSSStyleSheet styleSheet; +}; + +interface CSSGroupingRule : CSSRule { + [SameObject] readonly attribute CSSRuleList cssRules; + unsigned long insertRule(DOMString rule , unsigned long index ); + void deleteRule(unsigned long index ); +}; + +interface CSSMediaRule : CSSGroupingRule { + [SameObject, PutForwards=mediaText] readonly attribute MediaList media ; +}; + +interface CSSPageRule : CSSGroupingRule { + attribute DOMString selectorText ; + [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style ; +}; + +interface CSSMarginRule : CSSRule { + readonly attribute DOMString name; + [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; +}; + +interface CSSNamespaceRule : CSSRule { + readonly attribute DOMString namespaceURI; + readonly attribute DOMString prefix; +}; + +interface CSSStyleDeclaration { + attribute DOMString cssText; + readonly attribute unsigned long length; + getter DOMString item(unsigned long index ); + DOMString getPropertyValue(DOMString property ); + DOMString getPropertyPriority(DOMString property ); + void setProperty(DOMString property , [TreatNullAs=EmptyString] DOMString value , [TreatNullAs=EmptyString] optional DOMString priority = ""); + void setPropertyValue(DOMString property , [TreatNullAs=EmptyString] DOMString value ); + void setPropertyPriority(DOMString property , [TreatNullAs=EmptyString] DOMString priority ); + DOMString removeProperty(DOMString property ); + readonly attribute CSSRule? parentRule; + [TreatNullAs=EmptyString] attribute DOMString cssFloat; +}; + +partial interface CSSStyleDeclaration { + [TreatNullAs=EmptyString] attribute DOMString _dashed_attribute ; +}; + +[NoInterfaceObject]interface ElementCSSInlineStyle { + [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; +}; + +HTMLElement implements ElementCSSInlineStyle; + +SVGElement implements ElementCSSInlineStyle; + +partial interface Window { + [NewObject] CSSStyleDeclaration getComputedStyle(Element elt , optional DOMString? pseudoElt ); +}; + +[NoInterfaceObject]interface GetStyleUtils { + [SameObject] readonly attribute CSSStyleDeclaration cascadedStyle; + [SameObject] readonly attribute CSSStyleDeclaration defaultStyle; + [SameObject] readonly attribute CSSStyleDeclaration rawComputedStyle; + [SameObject] readonly attribute CSSStyleDeclaration usedStyle; +}; + +partial interface Element { + PseudoElement? pseudo(DOMString pseudoElt ); +}; + +Element implements GetStyleUtils; + +interface PseudoElement { +}; + +PseudoElement implements GetStyleUtils; + +interface CSS { + static DOMString escape(DOMString ident ); +}; diff --git a/javascript/WebIDL/dom-parsing.idl b/javascript/WebIDL/dom-parsing.idl new file mode 100644 index 000000000..d2581328e --- /dev/null +++ b/javascript/WebIDL/dom-parsing.idl @@ -0,0 +1,35 @@ +// Retrived from http://www.w3.org/TR/DOM-Parsing/ +// Wed Nov 4 15:39:43 GMT 2015 +// Manually extracted IDL + +enum SupportedType { + "text/html", + "text/xml", + "application/xml", + "application/xhtml+xml", + "image/svg+xml" +}; + +[Constructor] +interface DOMParser { + [NewObject] + Document parseFromString (DOMString str, SupportedType type); +}; + +[Constructor] +interface XMLSerializer { + DOMString serializeToString (Node root); +}; + +partial interface Element { + [TreatNullAs=EmptyString] + attribute DOMString innerHTML; + [TreatNullAs=EmptyString] + attribute DOMString outerHTML; + void insertAdjacentHTML (DOMString position, DOMString text); +}; + +partial interface Range { + [NewObject] + DocumentFragment createContextualFragment (DOMString fragment); +}; diff --git a/javascript/duktape/netsurf.bnd b/javascript/duktape/netsurf.bnd index 1f3938627..4aca4752f 100644 --- a/javascript/duktape/netsurf.bnd +++ b/javascript/duktape/netsurf.bnd @@ -10,7 +10,9 @@ binding duk_libdom { webidl "dom.idl"; + webidl "dom-parsing.idl"; webidl "html.idl"; + webidl "cssom.idl"; webidl "uievents.idl"; webidl "urlutils.idl"; webidl "console.idl";