// Path: shared/src/main/java/org/kobjects/nativehtml/dom/Element.java
// public interface Element {
//   String getLocalName();
//   void setAttribute(String name, String value);
//   String getAttribute(String name);
// 
//   Element getParentElement();
//   void setComputedStyle(CssStyleDeclaration style);
//   
//   /**
//    * Used internally
//    */
//   ElementType getElementType();
//   ContentType getElementContentType();
// 
//   /**
//    * Used internally in insertBefore.
//    */
//   void setParentElement(Element parent);
// 
//   HtmlCollection getChildren();
// 
//   CssStyleDeclaration getStyle();
//   CssStyleDeclaration getComputedStyle();
// 
//   String getTextContent();
// 
//   void setTextContent(String textContent);
// 
//   void insertBefore(Element newChild, Element referenceChild);
//   Document getOwnerDocument();
//   
// }
// 
// Path: shared/src/main/java/org/kobjects/nativehtml/dom/HtmlCollection.java
// public interface HtmlCollection {
// 
//     HtmlCollection EMPTY = new HtmlCollection() {
//         @Override
//         public int getLength() {
//             return 0;
//         }
// 
//         @Override
//         public Element item(int index) {
//             return null;
//         }
//     };
// 
//     int getLength();
//     Element item(int index);
// }


import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.kobjects.nativehtml.dom.Element;
import org.kobjects.nativehtml.dom.HtmlCollection;
    }
    return s;
  }

  /**
   * Helper method for collectStyles(). Determines whether the given key is 
   * in the given map. If so, the style search continues in the corresponding 
   * style sheet.
   * 
   * @param element the element under consideration (may be the target element
   *            or any parent)
   * @param map corresponding sub style sheet map
   * @param key element name or attribute value
   * @param queue queue of matching rules to be processed further
   */
  private static void collectStyles(Element element, Map<String, CssStyleSheet> map, String key,
                                    List<CssStyleDeclaration> queue, List<CssStyleSheet> children, List<CssStyleSheet> descendants) {
    if (key == null || map == null) {
      return;
    }
    CssStyleSheet sh = map.get(key);
    if (sh != null) {
      sh.collectStyles(element, queue, children, descendants);
    }
  }

  /**
   * Performs a depth first search of all matching selectors and enqueues the
   * corresponding style information.
   */
// Path: shared/src/main/java/org/kobjects/nativehtml/dom/Element.java
// public interface Element {
//   String getLocalName();
//   void setAttribute(String name, String value);
//   String getAttribute(String name);
// 
//   Element getParentElement();
//   void setComputedStyle(CssStyleDeclaration style);
//   
//   /**
//    * Used internally
//    */
//   ElementType getElementType();
//   ContentType getElementContentType();
// 
//   /**
//    * Used internally in insertBefore.
//    */
//   void setParentElement(Element parent);
// 
//   HtmlCollection getChildren();
// 
//   CssStyleDeclaration getStyle();
//   CssStyleDeclaration getComputedStyle();
// 
//   String getTextContent();
// 
//   void setTextContent(String textContent);
// 
//   void insertBefore(Element newChild, Element referenceChild);
//   Document getOwnerDocument();
//   
// }
// 
// Path: shared/src/main/java/org/kobjects/nativehtml/dom/HtmlCollection.java
// public interface HtmlCollection {
// 
//     HtmlCollection EMPTY = new HtmlCollection() {
//         @Override
//         public int getLength() {
//             return 0;
//         }
// 
//         @Override
//         public Element item(int index) {
//             return null;
//         }
//     };
// 
//     int getLength();
//     Element item(int index);
// }


// Path: shared/src/main/java/org/kobjects/nativehtml/css/CssStyleSheet.java
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.kobjects.nativehtml.dom.Element;
import org.kobjects.nativehtml.dom.HtmlCollection;

    }
    return s;
  }

  /**
   * Helper method for collectStyles(). Determines whether the given key is 
   * in the given map. If so, the style search continues in the corresponding 
   * style sheet.
   * 
   * @param element the element under consideration (may be the target element
   *            or any parent)
   * @param map corresponding sub style sheet map
   * @param key element name or attribute value
   * @param queue queue of matching rules to be processed further
   */
  private static void collectStyles(Element element, Map<String, CssStyleSheet> map, String key,
                                    List<CssStyleDeclaration> queue, List<CssStyleSheet> children, List<CssStyleSheet> descendants) {
    if (key == null || map == null) {
      return;
    }
    CssStyleSheet sh = map.get(key);
    if (sh != null) {
      sh.collectStyles(element, queue, children, descendants);
    }
  }

  /**
   * Performs a depth first search of all matching selectors and enqueues the
   * corresponding style information.
   */
  public void collectStyles(Element element, List<CssStyleDeclaration> queue,