CSC/ECE 517 Fall 2017/M1752 Implement the Microdata API: Difference between revisions
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
This specification consists of the following HTML attributes. Out of which ‘itemtype’ and ‘itemprop’ are currently in scope. | This specification consists of the following HTML attributes. Out of which ‘itemtype’ and ‘itemprop’ are currently in scope. | ||
{{<div itemscope itemtype="http://data-vocabulary.org/Person"> | |||
<img src="avatar.jpg" itemprop="photo"> | |||
My name is <span itemprop="name">John Cox</span>, and I am a <span itemprop="title">writer</span> for | |||
<a href="http://net.tutsplus.com" itemprop="affliation">Nettuts+</a>. | |||
I live in | |||
<span itemprop="address" itemscope | |||
itemtype="http://data-vocabulary.org/Address"> | |||
<span itemprop="locality">Louisville</span>, | |||
<span itemprop="region">KY</span> | |||
</span> | |||
</div>}} | |||
More information about the Microdata specification is available [https://html.spec.whatwg.org/multipage/microdata.html here] | More information about the Microdata specification is available [https://html.spec.whatwg.org/multipage/microdata.html here] |
Revision as of 10:42, 27 October 2017
M1752 : Implement the Microdata API
Introduction
Scope
The scope of this project is to implement initial support for Microdata API specification by allowing the Servo engine to read Microdata API tags from web pages and interpret them in the DOM. This should lay a groundwork for future improvements to implement features to created vCard and JSON data from Microdata on the ServoShell. Additional project information is available here
Specification
The WHATWG Microdata HTML specification allows web data to be enriched in that it allows machines to learn more about the data in a web page. A typical example of an HTML file with Microdata is shown below -
This specification consists of the following HTML attributes. Out of which ‘itemtype’ and ‘itemprop’ are currently in scope.
{{
<img src="avatar.jpg" itemprop="photo"> My name is John Cox, and I am a writer for <a href="http://net.tutsplus.com" itemprop="affliation">Nettuts+</a>. I live in Louisville, KY
}}
More information about the Microdata specification is available here
Some popular websites like Google, Skype and Microsoft use the Microdata. The number of websites that use Microdata is growing; currently about 13% of websites use Microdata (statistics courtesy Alexa)
Design
As for the initial stage of this project, the scope did not require any major changes to the engine design. We implemented a DOM method to handle appropriate attributes in the Microdata API. The below diagram shows an overview of components involved in the design. The highlighted blocks have been modified.
Implementation
The implementation involved updates to the Web Interface Definition Language (webidl) files and its Rust implementation.
HTMLElement.WebIDL
Method Name | Return Type | Description |
---|---|---|
propertyNames() | String | Method definition only. The implementation is done in htmlelement.rs |
htmlelement.rs
Method Name | Return Type | Description | Location |
---|---|---|---|
parse_plain_attributes() | AttrValue | This method returns a value of an attribute associated to an the HTML Element. | traits Virtual_Methods |
propertyNames() | Option<Vec<DOMString>> | This method parses the space-separated values of the 'item-type' attributes' | struct HTMLElement |
Configuration
The preference [Pref="dom.microdata.testing.enabled"] was added to toggle the experimental microdata methods during development.
Testing
testharness is used as the testing framework.
Dependencies
html5ever - HTML attribute names are fetched in Servo from a lookup file in the html5ever module. The html5ever module was augmented with the 'itemprop' and 'itemtype' attributes for use in Servo.
Pull Request
The pull request used to incorporate our changes upstream is available here