@Override
 public void setDisabled(boolean disabled) {
   this.disabled = disabled;
   CSSStyleSheet sheet = this.styleSheet;
   if (sheet != null) {
     sheet.setDisabled(disabled);
   }
 }
  /** If the LINK refers to a stylesheet document, this method loads and parses it. */
  protected void processLink() {
    this.styleSheet = null;
    String rel = this.getAttribute(HtmlAttributeProperties.REL);
    if (rel != null) {
      String cleanRel = rel.trim().toLowerCase();
      boolean isStyleSheet = cleanRel.equals("stylesheet");
      boolean isAltStyleSheet = cleanRel.equals("alternate stylesheet");
      boolean isAppendixStyleSheet = cleanRel.equals("appendix stylesheet");
      if (isStyleSheet || isAltStyleSheet || isAppendixStyleSheet) {
        UserAgentContext uacontext = this.getUserAgentContext();
        if (uacontext.isExternalCSSEnabled()) {
          String media = this.getMedia();
          if (CSSUtilities.matchesMedia(media, uacontext)) {
            HTMLDocumentImpl doc = (HTMLDocumentImpl) this.getOwnerDocument();
            try {

              CSSStyleSheet sheet = CSSUtilities.parse(this.getHref(), doc);
              CSSStyleSheetImpl sheetImpl = null;
              if (sheet != null) {
                doc.addStyleSheet(sheet);
                this.styleSheet = sheet;
                if (sheet instanceof CSSStyleSheetImpl) {
                  sheetImpl = (CSSStyleSheetImpl) sheet;
                  if (isAltStyleSheet) {
                    sheetImpl.setDisabled(true);
                  } else {
                    sheetImpl.setDisabled(disabled);
                  }

                  URL baseURL = new URL(doc.getBaseURI());
                  URL scriptURL = Urls.createURL(baseURL, getHref());
                  if (scriptURL != null) sheetImpl.setHref(scriptURL.toString());
                  doc.addStyleSheet(sheetImpl);
                } else {
                  if (isAltStyleSheet) {
                    sheet.setDisabled(true);
                  } else {
                    sheet.setDisabled(this.disabled);
                  }
                  doc.addStyleSheet(sheet);
                }
              }

            } catch (MalformedURLException mfe) {
              this.warn(
                  "Will not parse CSS. URI=["
                      + this.getHref()
                      + "] with BaseURI=["
                      + doc.getBaseURI()
                      + "] does not appear to be a valid URI.");
            } catch (Throwable err) {
              this.warn("Unable to parse CSS. URI=[" + this.getHref() + "].", err);
            }
          }
        }
      }
    }
  }
  public void _testInsertText1() throws IOException {
    ICSSModel model = getModel();
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    structuredDocument.set(
        FileUtil.createString(
            "src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFaceRuleTest.css"));

    CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
    CSSRuleList ruleList = sheet.getCssRules();
    assertEquals(3, ruleList.getLength());

    CSSRule rule;
    CSSStyleDeclaration declaration;
    CSSValue value;
    CSSValueList valueList;

    // rule 1

    rule = ruleList.item(0);
    assertEquals(CSSRule.FONT_FACE_RULE, rule.getType());
    assertTrue(rule instanceof CSSFontFaceRule);

    declaration = ((CSSFontFaceRule) rule).getStyle();
    assertEquals(4, declaration.getLength());

    value = declaration.getPropertyCSSValue("font-family");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_STRING, "Swiss 721"));

    value = declaration.getPropertyCSSValue("src");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_URI, "swiss721blk.pfr"));

    value = declaration.getPropertyCSSValue("font-style");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(3, valueList.getLength());

    checkPrimitiveString(
        valueList.item(0), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "normal"));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "italic"));

    value = declaration.getPropertyCSSValue("font-weight");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(3, valueList.getLength());

    checkPrimitiveNumber(
        valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 800));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 900));
  }
  /**
   * Parse CSS and create completion informations.
   *
   * @param css CSS
   */
  private void processStylesheet(String css) {
    try {
      CSSOMParser parser = new CSSOMParser();
      InputSource is = new InputSource(new StringReader(css));
      CSSStyleSheet stylesheet = parser.parseStyleSheet(is);
      CSSRuleList list = stylesheet.getCssRules();
      //			ArrayList assists = new ArrayList();
      for (int i = 0; i < list.getLength(); i++) {
        CSSRule rule = list.item(i);
        if (rule instanceof CSSStyleRule) {
          CSSStyleRule styleRule = (CSSStyleRule) rule;
          String selector = styleRule.getSelectorText();
          SelectorList selectors =
              parser.parseSelectors(new InputSource(new StringReader(selector)));
          for (int j = 0; j < selectors.getLength(); j++) {
            Selector sel = selectors.item(j);
            if (sel instanceof ConditionalSelector) {
              Condition cond = ((ConditionalSelector) sel).getCondition();
              SimpleSelector simple = ((ConditionalSelector) sel).getSimpleSelector();

              if (simple instanceof ElementSelector) {
                String tagName = ((ElementSelector) simple).getLocalName();
                if (tagName == null) {
                  tagName = "*";
                } else {
                  tagName = tagName.toLowerCase();
                }
                if (cond instanceof AttributeCondition) {
                  AttributeCondition attrCond = (AttributeCondition) cond;
                  if (rules.get(tagName) == null) {
                    List<String> classes = new ArrayList<String>();
                    classes.add(attrCond.getValue());
                    rules.put(tagName, classes);
                    //									} else {
                    //										ArrayList classes = (ArrayList)rules.get(tagName);
                    ////										classes.add(new AssistInfo(attrCond.getValue()));
                    //										classes.add(attrCond.getValue());
                  }
                }
              }
            }
          }
        }
      }
    } catch (Throwable ex) {
      // java.lang.Error: Missing return statement in function
    }
  }
Exemplo n.º 5
0
 /**
  * Show style sheet.
  *
  * @param styleSheet the style sheet
  */
 private void showStyleSheet(CSSStyleSheet styleSheet) {
   StringWriter stringWriter = new StringWriter();
   PrintWriter writer = new PrintWriter(stringWriter);
   writer.println("<DL>");
   CSSRuleList ruleList = styleSheet.getCssRules();
   int length = ruleList.getLength();
   for (int i = 0; i < length; i++) {
     CSSRule rule = ruleList.item(i);
     writer.println(
         "<DT><strong>Rule: type="
             + rule.getType()
             + ",class="
             + rule.getClass().getName()
             + "</strong></DT>");
     writer.println("<DD>");
     this.writeRuleInfo(writer, rule);
     writer.println("</DD>");
   }
   writer.println("</DL>");
   writer.flush();
   String html = stringWriter.toString();
   HtmlRendererContext rcontext =
       new SimpleHtmlRendererContext(this.cssOutput, (UserAgentContext) null);
   this.cssOutput.setHtml(html, "about:css", rcontext);
 }
 /**
  * Adds the style sheet.
  *
  * @param styleSheet the style sheet
  * @throws MalformedURLException the malformed url exception
  * @throws UnsupportedEncodingException
  */
 private final void addStyleSheet(CSSStyleSheet styleSheet)
     throws MalformedURLException, UnsupportedEncodingException {
   CSSRuleList ruleList = styleSheet.getCssRules();
   int length = ruleList.getLength();
   for (int i = 0; i < length; i++) {
     CSSRule rule = ruleList.item(i);
     this.addRule(styleSheet, rule);
   }
 }
Exemplo n.º 7
0
 private void parseFile(String filename) throws IOException {
   Reader r = new FileReader(filename);
   InputSource is = new InputSource(r);
   CSSOMParser parser = new CSSOMParser();
   CSSStyleSheet styleSheet = parser.parseStyleSheet(is);
   CSSRuleList list = styleSheet.getCssRules();
   for (int i = 0; i < list.getLength(); i++) {
     CSSRule rule = list.item(i);
     switch (rule.getType()) {
       case CSSRule.UNKNOWN_RULE:
         throw new IOException("Unknown rule in css file");
       case CSSRule.STYLE_RULE:
         //				CSSStyleRule srule = (CSSStyleRule) rule;
         //				System.out.println(srule.getSelectorText());
         break;
       default:
         System.out.println(rule);
         break;
     }
   }
 }
  public void testInsertRule() {
    final String RULE =
        "@font-face { font-family: \"Swiss 721\"; src: url(swiss721.pfr); /* The expanded Swiss 721 */ font-stretch: expanded; }";
    CSSStyleSheet sheet = getStyleSheet();
    assertEquals(0, sheet.insertRule(RULE, 0));

    CSSRuleList ruleList = sheet.getCssRules();
    CSSRule rule = ruleList.item(0);
    assertTrue(rule instanceof CSSFontFaceRule);

    CSSStyleDeclaration declaration = ((CSSFontFaceRule) rule).getStyle();
    assertEquals(3, declaration.getLength());

    CSSValue value;
    CSSPrimitiveValue primitiveValue;

    value = declaration.getPropertyCSSValue("font-family");
    assertTrue(value instanceof CSSPrimitiveValue);

    primitiveValue = (CSSPrimitiveValue) value;
    assertEquals(CSSPrimitiveValue.CSS_STRING, primitiveValue.getPrimitiveType());
    assertEquals("Swiss 721", primitiveValue.getStringValue());

    value = declaration.getPropertyCSSValue("src");
    assertTrue(value instanceof CSSPrimitiveValue);

    primitiveValue = (CSSPrimitiveValue) value;
    assertEquals(CSSPrimitiveValue.CSS_URI, primitiveValue.getPrimitiveType());
    assertEquals("swiss721.pfr", primitiveValue.getStringValue());

    value = declaration.getPropertyCSSValue("font-stretch");
    assertTrue(value instanceof CSSPrimitiveValue);

    primitiveValue = (CSSPrimitiveValue) value;
    assertEquals(CSSPrimitiveValue.CSS_IDENT, primitiveValue.getPrimitiveType());
    assertEquals("expanded", primitiveValue.getStringValue());
  }
  public void _testInsertText3() throws IOException {
    ICSSModel model = getModel();
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    structuredDocument.set(
        FileUtil.createString(
            "src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFaceRuleTest.css"));

    CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
    CSSRuleList ruleList = sheet.getCssRules();
    assertEquals(3, ruleList.getLength());

    CSSRule rule;
    CSSStyleDeclaration declaration;
    CSSValue value;
    CSSValueList valueList;

    // rule 3

    rule = ruleList.item(2);
    assertEquals(CSSRule.FONT_FACE_RULE, rule.getType());
    assertTrue(rule instanceof CSSFontFaceRule);

    declaration = ((CSSFontFaceRule) rule).getStyle();
    assertEquals(5, declaration.getLength());

    value = declaration.getPropertyCSSValue("src");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(4, valueList.getLength());

    checkPrimitiveString(
        valueList.item(0), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Alabama Italic"));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(2),
        new PrimitiveString(CSSPrimitiveValue.CSS_URI, "http://www.fonts.org/A/alabama-italic"));
    checkPrimitiveString(
        valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_FORMAT, "truetype"));

    value = declaration.getPropertyCSSValue("panose-1");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(10, valueList.getLength());

    checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 2));
    checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 4));
    checkPrimitiveNumber(valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 5));
    checkPrimitiveNumber(valueList.item(3), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 2));
    checkPrimitiveNumber(valueList.item(4), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 5));
    checkPrimitiveNumber(valueList.item(5), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 4));
    checkPrimitiveNumber(valueList.item(6), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 5));
    checkPrimitiveNumber(valueList.item(7), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 9));
    checkPrimitiveNumber(valueList.item(8), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 3));
    checkPrimitiveNumber(valueList.item(9), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 3));

    value = declaration.getPropertyCSSValue("font-family");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(3, valueList.getLength());

    checkPrimitiveString(
        valueList.item(0), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Alabama"));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "serif"));

    value = declaration.getPropertyCSSValue("font-weight");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(5, valueList.getLength());

    checkPrimitiveNumber(
        valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 300));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 400));
    checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(4), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 500));

    value = declaration.getPropertyCSSValue("font-style");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(3, valueList.getLength());

    checkPrimitiveString(
        valueList.item(0), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "italic"));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "oblique"));
  }
  public void _testInsertText2() throws IOException {
    ICSSModel model = getModel();
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    structuredDocument.set(
        FileUtil.createString(
            "src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFaceRuleTest.css"));

    CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
    CSSRuleList ruleList = sheet.getCssRules();
    assertEquals(3, ruleList.getLength());

    CSSRule rule;
    CSSStyleDeclaration declaration;
    CSSValue value;
    CSSValueList valueList;

    // rule 2

    rule = ruleList.item(1);
    assertEquals(CSSRule.FONT_FACE_RULE, rule.getType());
    assertTrue(rule instanceof CSSFontFaceRule);

    declaration = ((CSSFontFaceRule) rule).getStyle();
    assertEquals(6, declaration.getLength());

    value = declaration.getPropertyCSSValue("src");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(9, valueList.getLength());

    checkPrimitiveString(
        valueList.item(0), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Palatino"));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(2), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Times New Roman"));
    checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(4), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "New York"));
    checkPrimitiveString(valueList.item(5), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(6), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Utopia"));
    checkPrimitiveString(valueList.item(7), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveString(
        valueList.item(8),
        new PrimitiveString(CSSPrimitiveValue.CSS_URI, "http://somewhere/free/font"));

    value = declaration.getPropertyCSSValue("font-family");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "serif"));

    value = declaration.getPropertyCSSValue("font-weight");
    assertTrue(value instanceof CSSValueList);

    valueList = (CSSValueList) value;
    assertEquals(9, valueList.getLength());

    checkPrimitiveNumber(
        valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 100));
    checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 200));
    checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(4), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 300));
    checkPrimitiveString(valueList.item(5), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(6), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 400));
    checkPrimitiveString(valueList.item(7), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
    checkPrimitiveNumber(
        valueList.item(8), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 500));

    value = declaration.getPropertyCSSValue("font-style");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "normal"));

    value = declaration.getPropertyCSSValue("font-variant");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "normal"));

    value = declaration.getPropertyCSSValue("font-size");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "all"));
  }
 /**
  * Affected by pseudo name in ancestor.
  *
  * @param element the element
  * @param ancestor the ancestor
  * @param elementName the element name
  * @param elementId the element id
  * @param classArray the class array
  * @param pseudoName the pseudo name
  * @return true, if successful
  */
 public final boolean affectedByPseudoNameInAncestor(
     HTMLElementImpl element,
     HTMLElementImpl ancestor,
     String elementName,
     String elementId,
     String[] classArray,
     String pseudoName) {
   String elementTL = elementName.toLowerCase();
   Collection elementRules = this.rulesByElement.get(elementTL);
   if (elementRules != null) {
     Iterator i = elementRules.iterator();
     while (i.hasNext()) {
       StyleRuleInfo styleRuleInfo = (StyleRuleInfo) i.next();
       CSSStyleSheet styleSheet = styleRuleInfo.getStyleRule().getParentStyleSheet();
       if ((styleSheet != null) && styleSheet.getDisabled()) {
         continue;
       }
       if (styleRuleInfo.affectedByPseudoNameInAncestor(element, ancestor, pseudoName)) {
         return true;
       }
     }
   }
   elementRules = this.rulesByElement.get("*");
   if (elementRules != null) {
     Iterator i = elementRules.iterator();
     while (i.hasNext()) {
       StyleRuleInfo styleRuleInfo = (StyleRuleInfo) i.next();
       CSSStyleSheet styleSheet = styleRuleInfo.getStyleRule().getParentStyleSheet();
       if ((styleSheet != null) && styleSheet.getDisabled()) {
         continue;
       }
       if (styleRuleInfo.affectedByPseudoNameInAncestor(element, ancestor, pseudoName)) {
         return true;
       }
     }
   }
   if (classArray != null) {
     for (int cidx = 0; cidx < classArray.length; cidx++) {
       String className = classArray[cidx];
       String classNameTL = className.toLowerCase();
       Map<?, ?> classMaps = this.classMapsByElement.get(elementTL);
       if (classMaps != null) {
         Collection classRules = (Collection) classMaps.get(classNameTL);
         if (classRules != null) {
           Iterator i = classRules.iterator();
           while (i.hasNext()) {
             StyleRuleInfo styleRuleInfo = (StyleRuleInfo) i.next();
             CSSStyleSheet styleSheet = styleRuleInfo.getStyleRule().getParentStyleSheet();
             if ((styleSheet != null) && styleSheet.getDisabled()) {
               continue;
             }
             if (styleRuleInfo.affectedByPseudoNameInAncestor(element, ancestor, pseudoName)) {
               return true;
             }
           }
         }
       }
       classMaps = this.classMapsByElement.get("*");
       if (classMaps != null) {
         Collection classRules = (Collection) classMaps.get(classNameTL);
         if (classRules != null) {
           Iterator i = classRules.iterator();
           while (i.hasNext()) {
             StyleRuleInfo styleRuleInfo = (StyleRuleInfo) i.next();
             CSSStyleSheet styleSheet = styleRuleInfo.getStyleRule().getParentStyleSheet();
             if ((styleSheet != null) && styleSheet.getDisabled()) {
               continue;
             }
             if (styleRuleInfo.affectedByPseudoNameInAncestor(element, ancestor, pseudoName)) {
               return true;
             }
           }
         }
       }
     }
   }
   if (elementId != null) {
     Map<?, ?> idMaps = this.idMapsByElement.get(elementTL);
     if (idMaps != null) {
       String elementIdTL = elementId.toLowerCase();
       Collection idRules = (Collection) idMaps.get(elementIdTL);
       if (idRules != null) {
         Iterator i = idRules.iterator();
         while (i.hasNext()) {
           StyleRuleInfo styleRuleInfo = (StyleRuleInfo) i.next();
           CSSStyleSheet styleSheet = styleRuleInfo.getStyleRule().getParentStyleSheet();
           if ((styleSheet != null) && styleSheet.getDisabled()) {
             continue;
           }
           if (styleRuleInfo.affectedByPseudoNameInAncestor(element, ancestor, pseudoName)) {
             return true;
           }
         }
       }
     }
     idMaps = this.idMapsByElement.get("*");
     if (idMaps != null) {
       String elementIdTL = elementId.toLowerCase();
       Collection idRules = (Collection) idMaps.get(elementIdTL);
       if (idRules != null) {
         Iterator i = idRules.iterator();
         while (i.hasNext()) {
           StyleRuleInfo styleRuleInfo = (StyleRuleInfo) i.next();
           CSSStyleSheet styleSheet = styleRuleInfo.getStyleRule().getParentStyleSheet();
           if ((styleSheet != null) && styleSheet.getDisabled()) {
             continue;
           }
           if (styleRuleInfo.affectedByPseudoNameInAncestor(element, ancestor, pseudoName)) {
             return true;
           }
         }
       }
     }
   }
   return false;
 }
 /**
  * Gets the active style declarations.
  *
  * @param element the element
  * @param elementName the element name
  * @param elementId the element id
  * @param className the class name
  * @param pseudoNames the pseudo names
  * @return the active style declarations
  */
 public final Collection<CSSStyleDeclaration> getActiveStyleDeclarations(
     HTMLElementImpl element,
     String elementName,
     String elementId,
     String className,
     Set pseudoNames) {
   Collection<CSSStyleDeclaration> styleDeclarations = null;
   String elementTL = elementName.toLowerCase();
   Collection elementRules = this.rulesByElement.get(elementTL);
   if (elementRules != null) {
     Iterator i = elementRules.iterator();
     while (i.hasNext()) {
       StyleRuleInfo 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());
       } else {
       }
     }
   }
   elementRules = this.rulesByElement.get("*");
   if (elementRules != null) {
     Iterator i = elementRules.iterator();
     while (i.hasNext()) {
       StyleRuleInfo 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());
       }
     }
   }
   if (className != null) {
     String classNameTL = className.toLowerCase();
     Map<?, ?> classMaps = this.classMapsByElement.get(elementTL);
     if (classMaps != null) {
       Collection classRules = (Collection) classMaps.get(classNameTL);
       if (classRules != null) {
         Iterator i = classRules.iterator();
         while (i.hasNext()) {
           StyleRuleInfo 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());
           }
         }
       }
     }
     classMaps = this.classMapsByElement.get("*");
     if (classMaps != null) {
       Collection classRules = (Collection) classMaps.get(classNameTL);
       if (classRules != null) {
         Iterator i = classRules.iterator();
         while (i.hasNext()) {
           StyleRuleInfo 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());
           }
         }
       }
     }
   }
   if (elementId != null) {
     Map<?, ?> idMaps = this.idMapsByElement.get(elementTL);
     if (idMaps != null) {
       String elementIdTL = elementId.toLowerCase();
       Collection idRules = (Collection) idMaps.get(elementIdTL);
       if (idRules != null) {
         Iterator i = idRules.iterator();
         while (i.hasNext()) {
           StyleRuleInfo 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());
           }
         }
       }
     }
     idMaps = this.idMapsByElement.get("*");
     if (idMaps != null) {
       String elementIdTL = elementId.toLowerCase();
       Collection idRules = (Collection) idMaps.get(elementIdTL);
       if (idRules != null) {
         Iterator i = idRules.iterator();
         while (i.hasNext()) {
           StyleRuleInfo 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;
 }