Program: 60136
Project: 60136
Buggy source:
/** 
 * 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,NamedNodeMap attributes){
  Collection<CSSStyleDeclaration> styleDeclarations=null;
  String elementTL=elementName.toLowerCase();
  Collection<StyleRuleInfo> elementRules=this.rulesByElement.get(elementTL);
  if (elementRules != null) {
    SelectorMatcher sm=new SelectorMatcher();
    if (sm.matchesPseudoClassSelector(pseudoElement,element) && element.getPseudoNames().contains(pseudoElement)) {
      styleDeclarations=putStyleDeclarations(elementRules,styleDeclarations,element,pseudoNames);
    }
 else     if (!sm.matchesPseudoClassSelector(pseudoElement,element) && !element.getPseudoNames().contains(pseudoElement)) {
      styleDeclarations=putStyleDeclarations(elementRules,styleDeclarations,element,pseudoNames);
    }
  }
  elementRules=this.rulesByElement.get("String_Node_Str");
  if (elementRules != null) {
    styleDeclarations=putStyleDeclarations(elementRules,styleDeclarations,element,pseudoNames);
  }
  if (className != null) {
    String classNameTL=className.toLowerCase();
    Map<String,Collection<StyleRuleInfo>> classMaps=this.classMapsByElement.get(elementTL);
    if (classMaps != null) {
      Collection<StyleRuleInfo> classRules=classMaps.get(classNameTL);
      if (classRules != null) {
        styleDeclarations=putStyleDeclarations(classRules,styleDeclarations,element,pseudoNames);
      }
    }
    classMaps=this.classMapsByElement.get("String_Node_Str");
    if (classMaps != null) {
      Collection<StyleRuleInfo> classRules=classMaps.get(classNameTL);
      if (classRules != null) {
        styleDeclarations=putStyleDeclarations(classRules,styleDeclarations,element,pseudoNames);
      }
    }
  }
  if (elementId != null) {
    Map<String,Collection<StyleRuleInfo>> idMaps=this.idMapsByElement.get(elementTL);
    if (idMaps != null) {
      String elementIdTL=elementId.toLowerCase();
      Collection<StyleRuleInfo> idRules=idMaps.get(elementIdTL);
      if (idRules != null) {
        styleDeclarations=putStyleDeclarations(idRules,styleDeclarations,element,pseudoNames);
      }
    }
    idMaps=this.idMapsByElement.get("String_Node_Str");
    if (idMaps != null) {
      String elementIdTL=elementId.toLowerCase();
      Collection<StyleRuleInfo> idRules=idMaps.get(elementIdTL);
      if (idRules != null) {
        styleDeclarations=putStyleDeclarations(idRules,styleDeclarations,element,pseudoNames);
      }
    }
  }
  if (attributes != null && attributes.getLength() > 0) {
    for (int i=0; i < attributes.getLength(); i++) {
      Attr attr=(Attr)attributes.item(i);
      if (isAttributeOperator(attr,element)) {
        Map<String,Collection<StyleRuleInfo>> classMaps=this.attrMapsByElement.get(htmlElement);
        if (classMaps != null) {
          Collection<StyleRuleInfo> attrRules=classMaps.get(attributeValue);
          if (attrRules != null) {
            styleDeclarations=putStyleDeclarations(attrRules,styleDeclarations,element,pseudoNames);
          }
        }
      }
    }
  }
  return styleDeclarations;
}

Fixed version (ground truth):
/** 
 * 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,NamedNodeMap attributes){
  Collection<CSSStyleDeclaration> styleDeclarations=null;
  String elementTL=elementName.toLowerCase();
  Collection<StyleRuleInfo> elementRules=this.rulesByElement.get(elementTL);
  if (elementRules != null) {
    SelectorMatcher sm=new SelectorMatcher();
    String psElement=pseudoElement;
    if (psElement != null && psElement.contains("String_Node_Str")) {
      psElement=psElement.substring(0,psElement.indexOf("String_Node_Str"));
    }
    if (sm.matchesPseudoClassSelector(pseudoElement,element) && element.getPseudoNames().contains(psElement)) {
      styleDeclarations=putStyleDeclarations(elementRules,styleDeclarations,element,pseudoNames);
    }
 else     if (!sm.matchesPseudoClassSelector(pseudoElement,element) && !element.getPseudoNames().contains(psElement)) {
      styleDeclarations=putStyleDeclarations(elementRules,styleDeclarations,element,pseudoNames);
    }
  }
  elementRules=this.rulesByElement.get("String_Node_Str");
  if (elementRules != null) {
    styleDeclarations=putStyleDeclarations(elementRules,styleDeclarations,element,pseudoNames);
  }
  if (className != null) {
    String classNameTL=className.toLowerCase();
    Map<String,Collection<StyleRuleInfo>> classMaps=this.classMapsByElement.get(elementTL);
    if (classMaps != null) {
      Collection<StyleRuleInfo> classRules=classMaps.get(classNameTL);
      if (classRules != null) {
        styleDeclarations=putStyleDeclarations(classRules,styleDeclarations,element,pseudoNames);
      }
    }
    classMaps=this.classMapsByElement.get("String_Node_Str");
    if (classMaps != null) {
      Collection<StyleRuleInfo> classRules=classMaps.get(classNameTL);
      if (classRules != null) {
        styleDeclarations=putStyleDeclarations(classRules,styleDeclarations,element,pseudoNames);
      }
    }
  }
  if (elementId != null) {
    Map<String,Collection<StyleRuleInfo>> idMaps=this.idMapsByElement.get(elementTL);
    if (idMaps != null) {
      String elementIdTL=elementId.toLowerCase();
      Collection<StyleRuleInfo> idRules=idMaps.get(elementIdTL);
      if (idRules != null) {
        styleDeclarations=putStyleDeclarations(idRules,styleDeclarations,element,pseudoNames);
      }
    }
    idMaps=this.idMapsByElement.get("String_Node_Str");
    if (idMaps != null) {
      String elementIdTL=elementId.toLowerCase();
      Collection<StyleRuleInfo> idRules=idMaps.get(elementIdTL);
      if (idRules != null) {
        styleDeclarations=putStyleDeclarations(idRules,styleDeclarations,element,pseudoNames);
      }
    }
  }
  if (attributes != null && attributes.getLength() > 0) {
    for (int i=0; i < attributes.getLength(); i++) {
      Attr attr=(Attr)attributes.item(i);
      if (isAttributeOperator(attr,element)) {
        Map<String,Collection<StyleRuleInfo>> classMaps=this.attrMapsByElement.get(htmlElement);
        if (classMaps != null) {
          Collection<StyleRuleInfo> attrRules=classMaps.get(attributeValue);
          if (attrRules != null) {
            styleDeclarations=putStyleDeclarations(attrRules,styleDeclarations,element,pseudoNames);
          }
        }
      }
    }
  }
  return styleDeclarations;
}