Program: 39461
Project: 39461
Buggy source:
@Override public Map<String,String> resolveStyles(INode element,CssContext context){
  List<CssDeclaration> nodeCssDeclarations=UserAgentCss.getStyles(element);
  if (element instanceof IElementNode) {
    nodeCssDeclarations.addAll(HtmlStylesToCssConverter.convert((IElementNode)element));
  }
  nodeCssDeclarations.addAll(cssStyleSheet.getCssDeclarations(element,deviceDescription));
  if (element instanceof IElementNode) {
    String styleAttribute=((IElementNode)element).getAttribute(AttributeConstants.STYLE);
    if (styleAttribute != null) {
      nodeCssDeclarations.addAll(CssRuleSetParser.parsePropertyDeclarations(styleAttribute));
    }
  }
  Map<String,String> elementStyles=cssDeclarationsToMap(nodeCssDeclarations);
  String parentFontSizeStr=null;
  if (element.parentNode() instanceof IStylesContainer) {
    IStylesContainer parentNode=(IStylesContainer)element.parentNode();
    Map<String,String> parentStyles=parentNode.getStyles();
    if (parentStyles == null && !(element.parentNode() instanceof IDocumentNode)) {
      Logger logger=LoggerFactory.getLogger(DefaultCssResolver.class);
      logger.error(LogMessageConstant.ERROR_RESOLVING_PARENT_STYLES);
    }
    if (parentStyles != null) {
      for (      Map.Entry<String,String> entry : parentStyles.entrySet()) {
        mergeParentCssDeclaration(elementStyles,entry.getKey(),entry.getValue(),parentStyles.get(CssConstants.FONT_SIZE));
      }
      parentFontSizeStr=parentStyles.get(CssConstants.FONT_SIZE);
    }
  }
  String elementFontSize=elementStyles.get(CssConstants.FONT_SIZE);
  if (CssUtils.isRelativeValue(elementFontSize) || CssConstants.LARGER.equals(elementFontSize) || CssConstants.SMALLER.equals(elementFontSize)) {
    float baseFontSize;
    if (CssUtils.isRemValue(elementFontSize)) {
      baseFontSize=context.getRootFontSize();
    }
 else {
      if (parentFontSizeStr == null) {
        baseFontSize=FontStyleApplierUtil.parseAbsoluteFontSize(CssDefaults.getDefaultValue(CssConstants.FONT_SIZE));
      }
 else {
        baseFontSize=CssUtils.parseAbsoluteLength(parentFontSizeStr);
      }
    }
    float absoluteFontSize=FontStyleApplierUtil.parseRelativeFontSize(elementFontSize,baseFontSize);
    elementStyles.put(CssConstants.FONT_SIZE,DecimalFormatUtil.formatNumber(absoluteFontSize,"String_Node_Str") + CssConstants.PT);
  }
 else {
    elementStyles.put(CssConstants.FONT_SIZE,Float.toString(FontStyleApplierUtil.parseAbsoluteFontSize(elementFontSize)) + CssConstants.PT);
  }
  if (element instanceof IElementNode && TagConstants.HTML.equals(((IElementNode)element).name())) {
    context.setRootFontSize(elementStyles.get(CssConstants.FONT_SIZE));
  }
  Set<String> keys=new HashSet<>();
  for (  Map.Entry<String,String> entry : elementStyles.entrySet()) {
    if (CssConstants.INITIAL.equals(entry.getValue()) || CssConstants.INHERIT.equals(entry.getValue())) {
      keys.add(entry.getKey());
    }
  }
  for (  String key : keys) {
    elementStyles.put(key,CssDefaults.getDefaultValue(key));
  }
  CounterProcessorUtil.processCounters(elementStyles,context,element);
  resolveContentProperty(elementStyles,element,context);
  return elementStyles;
}

Fixed version (ground truth):
@Override public Map<String,String> resolveStyles(INode element,CssContext context){
  List<CssDeclaration> nodeCssDeclarations=UserAgentCss.getStyles(element);
  if (element instanceof IElementNode) {
    nodeCssDeclarations.addAll(HtmlStylesToCssConverter.convert((IElementNode)element));
  }
  nodeCssDeclarations.addAll(cssStyleSheet.getCssDeclarations(element,deviceDescription));
  if (element instanceof IElementNode) {
    String styleAttribute=((IElementNode)element).getAttribute(AttributeConstants.STYLE);
    if (styleAttribute != null) {
      nodeCssDeclarations.addAll(CssRuleSetParser.parsePropertyDeclarations(styleAttribute));
    }
  }
  Map<String,String> elementStyles=cssDeclarationsToMap(nodeCssDeclarations);
  String parentFontSizeStr=null;
  if (element.parentNode() instanceof IStylesContainer) {
    IStylesContainer parentNode=(IStylesContainer)element.parentNode();
    Map<String,String> parentStyles=parentNode.getStyles();
    if (parentStyles == null && !(element.parentNode() instanceof IDocumentNode)) {
      Logger logger=LoggerFactory.getLogger(DefaultCssResolver.class);
      logger.error(LogMessageConstant.ERROR_RESOLVING_PARENT_STYLES);
    }
    if (parentStyles != null) {
      for (      Map.Entry<String,String> entry : parentStyles.entrySet()) {
        mergeParentCssDeclaration(elementStyles,entry.getKey(),entry.getValue(),parentStyles);
      }
      parentFontSizeStr=parentStyles.get(CssConstants.FONT_SIZE);
    }
  }
  String elementFontSize=elementStyles.get(CssConstants.FONT_SIZE);
  if (CssUtils.isRelativeValue(elementFontSize) || CssConstants.LARGER.equals(elementFontSize) || CssConstants.SMALLER.equals(elementFontSize)) {
    float baseFontSize;
    if (CssUtils.isRemValue(elementFontSize)) {
      baseFontSize=context.getRootFontSize();
    }
 else {
      if (parentFontSizeStr == null) {
        baseFontSize=FontStyleApplierUtil.parseAbsoluteFontSize(CssDefaults.getDefaultValue(CssConstants.FONT_SIZE));
      }
 else {
        baseFontSize=CssUtils.parseAbsoluteLength(parentFontSizeStr);
      }
    }
    float absoluteFontSize=FontStyleApplierUtil.parseRelativeFontSize(elementFontSize,baseFontSize);
    elementStyles.put(CssConstants.FONT_SIZE,DecimalFormatUtil.formatNumber(absoluteFontSize,"String_Node_Str") + CssConstants.PT);
  }
 else {
    elementStyles.put(CssConstants.FONT_SIZE,Float.toString(FontStyleApplierUtil.parseAbsoluteFontSize(elementFontSize)) + CssConstants.PT);
  }
  if (element instanceof IElementNode && TagConstants.HTML.equals(((IElementNode)element).name())) {
    context.setRootFontSize(elementStyles.get(CssConstants.FONT_SIZE));
  }
  Set<String> keys=new HashSet<>();
  for (  Map.Entry<String,String> entry : elementStyles.entrySet()) {
    if (CssConstants.INITIAL.equals(entry.getValue()) || CssConstants.INHERIT.equals(entry.getValue())) {
      keys.add(entry.getKey());
    }
  }
  for (  String key : keys) {
    elementStyles.put(key,CssDefaults.getDefaultValue(key));
  }
  CounterProcessorUtil.processCounters(elementStyles,context,element);
  resolveContentProperty(elementStyles,element,context);
  return elementStyles;
}