/** 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);
            }
          }
        }
      }
    }
  }
 @Override
 public void setDisabled(boolean disabled) {
   this.disabled = disabled;
   CSSStyleSheet sheet = this.styleSheet;
   if (sheet != null) {
     sheet.setDisabled(disabled);
   }
 }