Example #1
0
void DOMTreeView::initializeStyleSheetsFromDocument(const DOM::Document &doc)
{
  styleSheetsTree->clear();
  styleSheetsTree->setEnabled(true);

  DOM::StyleSheetList sheets = doc.styleSheets();
  unsigned long l = sheets.length();
  for (unsigned long i = 0; i < l; ++i) {
    DOM::StyleSheet sheet = sheets.item(i);
    // some info about the sheet itself
    QString str = "type=\"" + sheet.type().string() + "\"";
    if (!sheet.href().isEmpty())
      str += " href=\"" + sheet.href().string() + "\"";
    if (!sheet.title().isEmpty())
      str += " title=\"" + sheet.title().string() + "\"";
    if (sheet.disabled())
      str += " disabled";
    QStringList strList = QStringList(str);
    QTreeWidgetItem *topLevel = new QTreeWidgetItem(strList);
    styleSheetsTree->addTopLevelItem(topLevel);

    // list the content
    DOM::CSSStyleSheet cssSheet(sheet);
    if (!cssSheet.isNull()) {
      DOM::CSSRuleList cssRules = cssSheet.cssRules();
      unsigned long numRules = cssRules.length();
      for (unsigned long r = 0; r < numRules; ++r) {
        DOM::CSSRule rule = cssRules.item(r);
        QString cssText = rule.cssText().string();
        (void)new QTreeWidgetItem(topLevel, QStringList(cssText));
      }
    }
  }
}
Example #2
0
Value DOMCSSRuleListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
  KJS_CHECK_THIS( KJS::DOMCSSRuleList, thisObj );
  DOM::CSSRuleList cssRuleList = static_cast<DOMCSSRuleList *>(thisObj.imp())->toCSSRuleList();
  switch (id) {
    case DOMCSSRuleList::Item:
      return getDOMCSSRule(exec,cssRuleList.item(args[0].toInteger(exec)));
    default:
      return Undefined();
  }
}