Java 类org.w3c.dom.css.CSSStyleRule 实例源码
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void idTagClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".idtag");
assertThat(rule).hasPropertyWithValue("background-image", "url(images/Token-IDTag_Light.png)")
.hasPropertyWithValue("background-size", "30px 30px")
.hasPropertyWithValue("background-repeat", "no-repeat")
.hasPropertyWithValue("height", "30px")
.hasPropertyWithValue("width", "30px")
.hasPropertyWithValue("display", "inline-block")
.hasPropertyWithValue("text-align", "center")
.hasPropertyWithValue("text-shadow", "0px 0px rgb(0, 0, 0)")
.hasPropertyWithValue("color", "black")
.hasPropertyWithValue("padding-top", "5px")
.hasPropertyWithValue("vertical-align", "middle")
.hasPropertyWithValue("font-size", "0.95em");
}
项目:LoboEvolution
文件:StyleSheetAggregator.java
/**
* Adds the class rule.
*
* @param elemtl
* the elemtl
* @param classtl
* the classtl
* @param styleRule
* the style rule
* @param ancestorSelectors
* the ancestor selectors
*/
private final void addClassRule(String elemtl, String classtl, CSSStyleRule styleRule,
ArrayList<SelectorMatcher> ancestorSelectors) {
if (elemtl == null || "".equals(elemtl)) {
elemtl = "*";
}
Map<String, Collection<StyleRuleInfo>> classMap = this.classMapsByElement.get(elemtl);
if (classMap == null) {
classMap = new HashMap<String, Collection<StyleRuleInfo>>();
this.classMapsByElement.put(elemtl, classMap);
}
Collection<StyleRuleInfo> rules = classMap.get(classtl);
if (rules == null) {
rules = new LinkedList<StyleRuleInfo>();
classMap.put(classtl, rules);
}
rules.add(new StyleRuleInfo(ancestorSelectors, styleRule));
}
项目:LoboEvolution
文件:StyleSheetAggregator.java
/**
* Adds the attribute rule.
*
* @param elemtl
* the elemtl
* @param classtl
* the classtl
* @param styleRule
* the style rule
* @param ancestorSelectors
* the ancestor selectors
*/
private final void addAttributeRule(String elemtl, String attrtl, CSSStyleRule styleRule,
ArrayList<SelectorMatcher> ancestorSelectors) {
if (elemtl == null || "".equals(elemtl)) {
elemtl = "*";
}
Map<String, Collection<StyleRuleInfo>> attrMap = this.attrMapsByElement.get(elemtl);
if (attrMap == null) {
attrMap = new HashMap<String, Collection<StyleRuleInfo>>();
this.attrMapsByElement.put(elemtl, attrMap);
}
Collection<StyleRuleInfo> rules = attrMap.get(attrtl);
if (rules == null) {
rules = new LinkedList<StyleRuleInfo>();
attrMap.put(attrtl, rules);
}
rules.add(new StyleRuleInfo(ancestorSelectors, styleRule));
}
项目:LoboEvolution
文件:StyleSheetAggregator.java
/**
* Adds the id rule.
*
* @param elemtl
* the elemtl
* @param idtl
* the idtl
* @param styleRule
* the style rule
* @param ancestorSelectors
* the ancestor selectors
*/
private final void addIdRule(String elemtl, String idtl, CSSStyleRule styleRule,
ArrayList<SelectorMatcher> ancestorSelectors) {
if (elemtl == null || "".equals(elemtl)) {
elemtl = "*";
}
Map<String, Collection<StyleRuleInfo>> idsMap = this.idMapsByElement.get(elemtl);
if (idsMap == null) {
idsMap = new HashMap<String, Collection<StyleRuleInfo>>();
this.idMapsByElement.put(elemtl, idsMap);
}
Collection<StyleRuleInfo> rules = idsMap.get(idtl);
if (rules == null) {
rules = new LinkedList<StyleRuleInfo>();
idsMap.put(idtl, rules);
}
rules.add(new StyleRuleInfo(ancestorSelectors, styleRule));
}
项目:LoboEvolution
文件:StyleSheetAggregator.java
/**
* put style declarations
*
* @param elementRules
* @param styleDeclarations
* @param element
* @param pseudoNames
* @return
*/
private Collection<CSSStyleDeclaration> putStyleDeclarations(Collection<StyleRuleInfo> elementRules,
Collection<CSSStyleDeclaration> styleDeclarations, HTMLElementImpl element, Set pseudoNames) {
Iterator<StyleRuleInfo> i = elementRules.iterator();
while (i.hasNext()) {
StyleRuleInfo styleRuleInfo = i.next();
if (styleRuleInfo.isSelectorMatch(element, pseudoNames)) {
CSSStyleRule styleRule = styleRuleInfo.getStyleRule();
CSSStyleSheet styleSheet = styleRule.getParentStyleSheet();
if (styleSheet != null && styleSheet.getDisabled()) {
continue;
}
if (styleDeclarations == null) {
styleDeclarations = new LinkedList<CSSStyleDeclaration>();
}
styleDeclarations.add(styleRule.getStyle());
}
}
return styleDeclarations;
}
项目:thymesheet
文件:ThymesheetPreprocessor.java
private ElementRuleList extractDOMModifications(List<CSSStyleRule> ruleList) {
ElementRuleList modifierRules = new ElementRuleList();
Iterator<CSSStyleRule> it = ruleList.iterator();
while(it.hasNext()) {
CSSStyleRule rule = it.next();
PseudoClass pseudoModifier = getDOMModifier(rule.getSelectorText());
if(pseudoModifier!=null) {
ElementRule modifierRule = ElementRuleFactory.createElementRule(pseudoModifier, CSSUtil.asMap(rule.getStyle()));
modifierRules.add(modifierRule);
it.remove();
}
}
return modifierRules;
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void pilotClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".pilot");
assertThat(rule).hasPropertyWithValue("font-size", "1.1em")
.hasPropertyWithValue("margin-top", "5px")
.hasPropertyWithValue("font-weight", "bold");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void shieldsSymbolClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".shields-symbol");
assertThat(rule).hasPropertyWithValue("font-family", "\"x-wing-symbols\"")
.hasPropertyWithValue("font-size", "1.75em")
.hasPropertyWithValue("color", "cyan")
.hasPropertyWithValue("font-weight", "normal")
.hasPropertyWithValue("font-style", "normal")
.hasPropertyWithValue("text-shadow", "0px 0px rgb(0, 0, 0)")
.hasPropertyWithValue("-webkit-font-smoothing", "always");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void hullSymbolClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".hull-symbol");
assertThat(rule).hasPropertyWithValue("font-family", "\"x-wing-symbols\"")
.hasPropertyWithValue("font-size", "1.7em")
.hasPropertyWithValue("font-style", "normal")
.hasPropertyWithValue("color", "yellow")
.hasPropertyWithValue("font-weight", "normal")
.hasPropertyWithValue("font-style", "normal")
.hasPropertyWithValue("text-shadow", "0px 0px rgb(0, 0, 0)")
.hasPropertyWithValue("-webkit-font-smoothing", "always");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void agilitySymbolClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".agility-symbol");
assertThat(rule).hasPropertyWithValue("font-family", "\"x-wing-symbols\"")
.hasPropertyWithValue("font-size", "1.75em")
.hasPropertyWithValue("color", "rgb(86, 244, 66)")
.hasPropertyWithValue("font-weight", "normal")
.hasPropertyWithValue("font-style", "normal")
.hasPropertyWithValue("text-shadow", "0px 0px rgb(0, 0, 0)")
.hasPropertyWithValue("-webkit-font-smoothing", "always");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void attackSymbolClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".attack-symbol");
assertThat(rule).hasPropertyWithValue("font-family", "\"x-wing-symbols\"")
.hasPropertyWithValue("font-size", "1.75em")
.hasPropertyWithValue("color", "rgb(242, 14, 56)")
.hasPropertyWithValue("font-weight", "normal")
.hasPropertyWithValue("font-style", "normal")
.hasPropertyWithValue("text-shadow", "0px 0px rgb(0, 0, 0)")
.hasPropertyWithValue("-webkit-font-smoothing", "always");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void upgradeTypeSymbolClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".upgrade-type-symbol");
assertThat(rule).hasPropertyWithValue("font-family", "\"x-wing-symbols\"")
.hasPropertyWithValue("font-size", "16pt")
.hasPropertyWithValue("color", "rgb(255, 255, 255)")
.hasPropertyWithValue("font-weight", "normal")
.hasPropertyWithValue("font-style", "normal")
.hasPropertyWithValue("text-shadow", "0px 0px rgb(0, 0, 0)")
.hasPropertyWithValue("-webkit-font-smoothing", "always");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void squadClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".squad");
assertThat(rule).hasPropertyWithValue("padding", "10px")
.hasPropertyWithValue("height", "100%")
.hasPropertyWithValue("background-image", "linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void pilotClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".pilot");
assertThat(rule).hasPropertyWithValue("font-size", "1.1em")
.hasPropertyWithValue("margin-top", "5px")
.hasPropertyWithValue("font-weight", "bold");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void upgradesClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".upgrades");
assertThat(rule).hasPropertyWithValue("font-size", "0.9em")
.hasPropertyWithValue("margin-bottom", "5px")
.hasPropertyWithValue("font-weight", "bold");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
protected CSSStyleRule findRule(CSSRuleList rules, String ruleName) throws Exception {
for (int i = 0; i < rules.getLength(); i++) {
CSSStyleRuleImpl rule = (CSSStyleRuleImpl) rules.item(i);
SelectorList selectorList = rule.getSelectors();
for (int s = 0; s < selectorList.getLength(); s++ ) {
Selector selector = selectorList.item(s);
if (selector.toString().equals(ruleName)) {
return rule;
}
}
}
return null;
}
项目:LoboEvolution
文件:CSSStyleRuleImpl.java
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CSSStyleRule)) {
return false;
}
final CSSStyleRule csr = (CSSStyleRule) obj;
return super.equals(obj) && LangUtils.equals(getSelectorText(), csr.getSelectorText())
&& LangUtils.equals(getStyle(), csr.getStyle());
}
项目:LoboEvolution
文件:StyleSheetAggregator.java
/**
* Adds the element rule.
*
* @param elemtl
* the elemtl
* @param styleRule
* the style rule
* @param ancestorSelectors
* the ancestor selectors
*/
private final void addElementRule(String elemtl, CSSStyleRule styleRule,
ArrayList<SelectorMatcher> ancestorSelectors) {
if (elemtl == null || "".equals(elemtl)) {
elemtl = "*";
}
Collection<StyleRuleInfo> rules = this.rulesByElement.get(elemtl);
if (rules == null) {
rules = new LinkedList<StyleRuleInfo>();
this.rulesByElement.put(elemtl, rules);
}
rules.add(new StyleRuleInfo(ancestorSelectors, styleRule));
}
项目:SimpleFunctionalTest
文件:CssParser.java
public HashMap<String, CSSStyleRule> extractCssStyleRules(String cssFile) throws IOException {
TEST_FILE_SYSTEM.filesExists(cssFile);
CSSOMParser cssParser = new CSSOMParser();
CSSStyleSheet css = cssParser.parseStyleSheet(new InputSource(new FileReader(TEST_FILE_SYSTEM.file(cssFile))), null, null);
CSSRuleList cssRules = css.getCssRules();
HashMap<String, CSSStyleRule> rules = new HashMap<String, CSSStyleRule>();
for (int i = 0; i < cssRules.getLength(); i++) {
CSSRule rule = cssRules.item(i);
if (rule instanceof CSSStyleRule) {
rules.put(((CSSStyleRule) rule).getSelectorText(), (CSSStyleRule) rule);
}
}
return rules;
}
项目:SimpleFunctionalTest
文件:CssParser.java
@Override
public String toString(){
String css= "";
for (Map.Entry<String, CSSStyleRule> ruleEntry : rules.entrySet()) {
css += ruleEntry.toString() +"\n";
}
return css;
}
项目:thymesheet
文件:AttributeRuleList.java
public AttributeRuleList(CSSRuleList ruleList) {
super(ruleList.getLength());
for (int i = 0; i < ruleList.getLength(); i++) {
CSSRule rule = ruleList.item(i);
if(rule instanceof CSSStyleRule) {
this.add((CSSStyleRule)rule);
}
}
}
项目:thymesheet
文件:ThymesheetPreprocessorTests.java
private List<SingleRule> getSingleRules(AttributeRuleList ruleList) {
ArrayList<SingleRule> result = new ArrayList<SingleRule>();
for (CSSStyleRule styleRule : ruleList) {
String selectorText = styleRule.getSelectorText();
CSSStyleDeclaration styles = styleRule.getStyle();
for (int j = 0; j < styles.getLength(); j++) {
String property = styles.item(j);
result.add(new SingleRule(selectorText, property, styles.getPropertyCSSValue(property).getCssText()));
}
}
return result;
}
项目:xstreamer
文件:CSSStyleRuleAssert.java
protected CSSStyleRuleAssert(CSSStyleRule actual) {
super(actual, CSSStyleRuleAssert.class);
}
项目:xstreamer
文件:CSSStyleRuleAssert.java
public static CSSStyleRuleAssert assertThat(CSSStyleRule actual) {
return new CSSStyleRuleAssert(actual);
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void hullClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".hull");
assertThat(rule).hasPropertyWithValue("font-size", "0.95em")
.hasPropertyWithValue("color", "yellow");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void redClassHasExpectedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".red");
assertThat(rule).hasPropertyWithValue("color", "red");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void shieldsClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".shields");
assertThat(rule).hasPropertyWithValue("font-size", "0.95em")
.hasPropertyWithValue("color", "cyan");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void hullClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".hull");
assertThat(rule).hasPropertyWithValue("font-size", "0.95em")
.hasPropertyWithValue("color", "yellow");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void agilityClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".agility");
assertThat(rule).hasPropertyWithValue("font-size", "0.95em")
.hasPropertyWithValue("color", "rgb(86, 244, 66)");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void attackClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".attack");
assertThat(rule).hasPropertyWithValue("font-size", "0.95em")
.hasPropertyWithValue("color", "rgb(242, 14, 56)");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void upgradeDiscardedClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".upgradeDiscarded");
assertThat(rule).hasPropertyWithValue("color", "red");
}
项目:xstreamer
文件:XWIngCommonCssTest.java
@Test
public void upgradeDiscardedBeforeClassHasExpecedValues() throws Exception {
CSSStyleRule rule = findRule(styleSheet.getCssRules(), ".upgradeDiscarded:before");
assertThat(rule).hasPropertyWithValue("content", "\"\u2718\"");
}
项目:SimpleFunctionalTest
文件:CssParser.java
public CSSStyleRule get(String ruleName) {
return rules.get(ruleName);
}
项目:thymesheet
文件:AttributeRuleList.java
public AttributeRuleList(Collection<? extends CSSStyleRule> c) {
super(c);
}
项目:thymesheet
文件:AttributeRuleList.java
public void applyTo(Document document) throws NodeSelectorException {
for (CSSStyleRule styleRule : this) {
handleRule(document, styleRule.getSelectorText(), CSSUtil.asMap(styleRule.getStyle()));
}
}
项目:LoboEvolution
文件:StyleRuleInfo.java
/**
* Instantiates a new style rule info.
*
* @param SelectorMatchers
* A collection of SelectorMatcher's.
* @param rule
* A CSS rule.
*/
public StyleRuleInfo(ArrayList<SelectorMatcher> SelectorMatchers, CSSStyleRule rule) {
super();
ancestorSelectors = SelectorMatchers;
setStyleRule(rule);
}
项目:LoboEvolution
文件:StyleRuleInfo.java
/**
* Gets the style rule.
*
* @return the style rule
*/
public CSSStyleRule getStyleRule() {
return styleRule;
}
项目:LoboEvolution
文件:StyleRuleInfo.java
/**
* Sets the style rule.
*
* @param styleRule
* the new style rule
*/
public void setStyleRule(CSSStyleRule styleRule) {
this.styleRule = styleRule;
}