Method and device for cascading style sheet (CSS) selector matching
AssigneeOpera Software AS
InventorRune Lillesveen
Life of this patent
Estimating the term…
Abstract
The present invention relates to a computer-implemented method for Cascading Style Sheet (CSS) selector matching. The method comprises: generating machine code based on text which includes at least one CSS selector; and executing the machine code to perform the CSS selector matching. The present invention also relates to a corresponding computer device and a computer readable storage medium.
Claims18
A method for Cascading Style Sheet (CSS) selector matching, which method comprises:
- receiving content including markup language text and text which includes at least one CSS selector;
- parsing the markup language into a Document Object Model (DOM) tree;
- parsing the text which includes at least one CSS selector into a data structure representing the at least one CSS selector;
- compiling the data structure into machine code;
- and
- executing the machine code to perform the CSS selector matching,
- wherein the executing of the machine code comprises:
- for each DOM node from said DOM tree,
- invoking the machine code for the at least one CSS selector to determine whether each of the at least one CSS selector matches the DOM node, and
- for each of the at least one CSS selector determined to match the DOM node, apply a corresponding CSS property to the DOM node.
A computer device for Cascading Style Sheet (CSS) selector matching, which device comprises:
- a CSS parser adapted to parse text which includes at least one CSS selector into a data structure representing the at least one CSS selector;
- a compiler adapted to compile the data structure into machine code for the particular architecture of the computer device;
- and
- an execution engine adapted to execute the machine code to perform the CSS selector matching,
- wherein the execution engine is adapted to perform the following when executing the machine code:
- for each DOM node from said DOM tree,
- invoke the machine code for the at least one CSS selector to determine whether each of the at least one CSS selector matches the DOM node, and
- for each of the at least one CSS selector determined to match the DOM node, apply a corresponding CSS property to the DOM node.
A non-transitory computer readable storage medium having code or instructions, which code or instructions when executed on a computer cause(s) a process for Cascading Style Sheet (CSS) selector matching that includes:
- receiving content including markup language text and text which includes at least one CSS selector;
- parsing the markup language into a Document Object Model (DOM) tree;
- parsing the text which includes at least one CSS selector into a data structure representing the at least one CSS selector;
- generating machine code by compiling the data structure based on the parsing of the text which includes at least one CSS selector;
- and
- executing the machine code to perform the CSS selector matching,
- wherein the executing of the machine code comprises:
- for each DOM node from said DOM tree,
- invoking the machine code for the at least one CSS selector to determine whether each of the at least one CSS selector matches the DOM node, and
- for each of the at least one CSS selector determined to match the DOM node, apply a corresponding CSS property to the DOM node.
Dependencies are inferred from the claim text.