Java Code Examples for cz.vutbr.web.css.CSSFactory#registerDefaultMatchCondition()
The following examples show how to use
cz.vutbr.web.css.CSSFactory#registerDefaultMatchCondition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void pseudoClassMap() throws SAXException, IOException { DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html")); Document doc = ds.parse(); ElementMap elements = new ElementMap(doc); MatchConditionOnElements cond = new MatchConditionOnElements("a", PseudoClassType.LINK); cond.addMatch(elements.getElementById("l2"), PseudoClassType.HOVER); cond.addMatch(elements.getElementById("l3"), PseudoClassType.VISITED); cond.addMatch(elements.getElementById("l3"), PseudoClassType.HOVER); cond.removeMatch(elements.getElementById("l3"), PseudoClassType.HOVER); CSSFactory.registerDefaultMatchCondition(cond); StyleMap decl = CSSFactory.assignDOM(doc, null, createBaseFromFilename("data/simple/pseudo.html"),"screen", true); NodeData l1 = getStyleById(elements, decl, "l1"); NodeData l2 = getStyleById(elements, decl, "l2"); NodeData l3 = getStyleById(elements, decl, "l3"); assertThat(l1.getValue(TermColor.class, "color"), is(tf.createColor(0,255,0))); assertThat(l2.getValue(TermColor.class, "color"), is(tf.createColor(0,255,255))); assertThat(l3.getValue(TermColor.class, "color"), is(tf.createColor(0,0,170))); }
Example 2
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void pseudoClassDirect() throws SAXException, IOException { DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html")); Document doc = ds.parse(); ElementMap elements = new ElementMap(doc); MatchConditionOnElements cond = new MatchConditionOnElements("a", PseudoClassType.LINK); cond.addMatch(elements.getElementById("l2"), PseudoClassType.HOVER); cond.addMatch(elements.getElementById("l3"), PseudoClassType.VISITED); CSSFactory.registerDefaultMatchCondition(cond); StyleSheet style = CSSFactory.getUsedStyles(doc, null, createBaseFromFilename("data/simple/selectors.html"),"screen"); DirectAnalyzer da = new DirectAnalyzer(style); NodeData l1 = getStyleById(elements, da, "l1"); NodeData l2 = getStyleById(elements, da, "l2"); NodeData l3 = getStyleById(elements, da, "l3"); assertThat(l1.getValue(TermColor.class, "color"), is(tf.createColor(0,255,0))); assertThat(l2.getValue(TermColor.class, "color"), is(tf.createColor(0,255,255))); assertThat(l3.getValue(TermColor.class, "color"), is(tf.createColor(0,0,170))); }