function findStyleRuleSource(baseURL, styleDeclaration, parentNode) {
  if (!styleDeclaration ||
    styleDeclaration.type === 'Attributes' ||
    styleDeclaration.type === 'Inline'
  ) {
    return {
      source: {type: 'url', value: baseURL},
      selector: nodeToTableNode(parentNode),
    };
  }

  if (styleDeclaration.parentRule &&
    styleDeclaration.parentRule.origin === 'user-agent') {
    return {
      source: {type: 'code', value: 'User Agent Stylesheet'},
      selector: styleDeclaration.parentRule.selectors.map(item => item.text).join(', '),
    };
  }

  // Combine all the selectors for the associated style rule
  // example: .some-selector, .other-selector {...} => `.some-selector, .other-selector`
  let selector = '';
  if (styleDeclaration.parentRule) {
    const rule = styleDeclaration.parentRule;
    selector = rule.selectors.map(item => item.text).join(', ');
  }

  if (styleDeclaration.stylesheet && !styleDeclaration.stylesheet.sourceURL) {
    // Dynamically injected into page.
    return {
      source: {type: 'code', value: 'dynamic'},
      selector,
    };
  }

  // !!range == has defined location in a source file (.css or .html)
  // sourceURL == stylesheet URL || raw value of magic `sourceURL` comment
  // hasSourceURL == flag that signals sourceURL is the raw value of a magic `sourceURL` comment, *not* a real resource
  if (styleDeclaration.stylesheet && styleDeclaration.range) {
    const {range, stylesheet} = styleDeclaration;

    // DevTools protocol does not provide the resource URL if there is a magic `sourceURL` comment.
    // `sourceURL` will be the raw value of the magic `sourceURL` comment, which likely refers to
    // a file at build time, not one that is served over the network that we could link to.
    const urlProvider = stylesheet.hasSourceURL ? 'comment' : 'network';

    let line = range.startLine;
    let column = range.startColumn;

    // Add the startLine/startColumn of the <style> element to the range, if stylesheet
    // is inline.
    // Always use the rule's location if a sourceURL magic comment is
    // present (`hasSourceURL` is true) - this makes the line/col relative to the start
    // of the style tag, which makes them relevant when the "file" is open in DevTool's
    // Sources panel.
    const addHtmlLocationOffset = stylesheet.isInline && urlProvider !== 'comment';
    if (addHtmlLocationOffset) {
      line += stylesheet.startLine;
      // The column the stylesheet begins on is only relevant if the rule is declared on the same line.
      if (range.startLine === 0) {
        column += stylesheet.startColumn;
      }
    }

    const source = Audit.makeSourceLocation(stylesheet.sourceURL, line, column);
    source.urlProvider = urlProvider;

    return {
      source,
      selector,
    };
  }

  // The responsible style declaration was not captured in the font-size gatherer due to
  // the rate limiting we do in `fetchFailingNodeSourceRules`.
  return {
    selector,
    source: {type: 'code', value: 'Unknown'},
  };
}
@param {string} baseURL
@param {FailingNodeData['cssRule']} styleDeclaration
@param {FailingNodeData['parentNode']} parentNode
@return {{source: LH.Audit.Details.UrlValue | LH.Audit.Details.SourceLocationValue | LH.Audit.Details.CodeValue, selector: string | LH.Audit.Details.NodeValue}}