Beispiel #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));
      }
    }
  }
}
Beispiel #2
0
Value DOMStyleSheetListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
    KJS_CHECK_THIS(KJS::DOMStyleSheetList, thisObj);
    DOM::StyleSheetList styleSheetList = static_cast< DOMStyleSheetList * >(thisObj.imp())->toStyleSheetList();
    if(id == DOMStyleSheetList::Item)
        return getDOMStyleSheet(exec, styleSheetList.item(args[0].toInteger(exec)));
    return Undefined();
}
Beispiel #3
0
Value getDOMStyleSheetList(ExecState *exec, const DOM::StyleSheetList& ssl, const DOM::Document& doc)
{
  // Can't use the cacheDOMObject macro because of the doc argument
  DOMObject *ret;
  if (ssl.isNull())
    return Null();
  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
  if ((ret = interp->getDOMObject(ssl.handle())))
    return Value(ret);
  else {
    ret = new DOMStyleSheetList(exec, ssl, doc);
    interp->putDOMObject(ssl.handle(),ret);
    return Value(ret);
  }
}