Skip to content

Image load conformance student project

Josh Matthews edited this page Feb 8, 2016 · 5 revisions

Implement specification-conforming image loads

Background information: The HTML5 specification defines a surprisingly complex model for loading images in a web page. Servo's current implementation is straightforward, but non-compliant in a number of important ways. The goal of this project is to implement image loading behaviour that is both more correct and easy to verify against the text of the specification.

Initial steps:

  • compile Servo and ensure that it runs on tests/html/about-mozilla.html
  • email the mozilla.dev.servo mailing list introducing your group and describing your progress
  • define data types to represent the image request concept, and add pending and current requests to the HTMLImageElement type in htmlimageelement.rs. These should subsume the existing fields in HTMLImageElement that are used for storing the image's properties, and the fields of the current request should be used instead.
  • implement the crossOrigin attribute using the make_enumerated_getter/make_setter macros and uncommenting the attribute in HTMLImageElement.webidl
  • implement the currentSrc attribute by adding the appropriate attribute to HTMLImageElement.webidl
  • run ./mach test-wpt tests/wpt/web-platform-tests/html/dom/interfaces.html and adjust the test result expectations according to the documenatation.
  • add a command for the image cache task that accepts a URL and a vector of bytes. This command should instruct the cache to store this data as a newly-complete network request and continue decoding the result into pixel data.

Subsequent steps:

  • replace the code in htmlimageelement.rs that instructs the image cache to fetch a URL with code that directly performs a network request (see HTMLScriptElement::prepare for an example that uses the NetworkListener helper and Document::load_async). The result should be sent to the image cache using the newly-added command.
  • implement the parse a srcset attribute algorithm by defining a parse_a_srcset_attribute function in htmlimageelement.rs. Write unit tests demonstrating correctness in tests/unit/script/htmlimageelement.rs (./mach test-unit -p script/dom/htmlimageelement).
  • implement the parse a sizes attribute algorithm by defining a parse_a_sizes_attribute function in htmlimageelement.rs. Write unit tests demonstrating correctness in tests/unit/script/htmlimageelement.rs.
  • implement the normalize the source densities algorithm - create data types for source set and image source
  • implement the update the source set algorithm by defining a update_the_source_set function in htmlimageelement.rs
  • implement the select an image source algorithm by defining a select_an_image_source function in htmlimageelement.rs
Clone this wiki locally