forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
CSSOM student project
Sagar Muchhal edited this page Mar 13, 2016
·
4 revisions
Background information: One of many standards defined by the CSS Working Group is the CSS Object Model. This provides a JS API that allows webpages to query and modify the CSS rules and properties that affect individual elements as well as whole pages. This project is intended to implement the most commonly-used portions of this specification to increase Servo's compatibility with existing webpages.
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 your progress
- create the StyleSheet interface. See the documentation for how to go about this. Comment out any method in the WebIDL that cannot be trivially implemented according to the specification.
- create the StyleSheetList interface. Leave
[ArrayClass]
commented out, since it is not yet supported by Servo. Store aJS<Document>
member to allow accessing a document's stylesheets. - add the
styleSheets
attribute from the Document extension toDocument.webidl
, and make it return a new instance ofStyleSheetList
referencing the current document. - run
./mach test-wpt /tests/wpt/html/dom/interfaces.html
and update the test result expectations according to the documentation - update
tests/wpt/mozilla/tests/mozilla/interfaces.html
to add the new interface names and allow the test to pass.
Subsequent steps:
- make the
stylesheets
member ofDocument
store the associatedElement
along with the actualStylesheet
. Add a member toStyleSheet
for the associated element, and implement theownerNode
attribute ofStyleSheet
using this. - create the CSSStyleSheet interface, containing an
Arc<Stylesheet>
member. Add a method toDocument
that returns a newCSSStyleSheet
instance for a particular index in thestylesheets
member. - create the CSSRule interface.
- create the CSSRuleList interface and implement
CSSStyleSheet.cssRules
. - implement the
insertRule
anddeleteRule
methods ofCSSStyleSheet
by making therules
member of theStylesheet
type contain a RefCell, and using this to mutate the contents of the vector. - create the CSSStyleRule interface and make
cssRules
returnCSSStyleRule
values for appropriate rules.