Ejemplo n.º 1
0
int MetabarFunctions::getHeight(DOM::HTMLElement &element)
{
    int height = 0;
    DOM::NodeList children = element.childNodes();
    for(uint i = 0; i < children.length(); i++) {
        DOM::HTMLElement node = static_cast<DOM::HTMLElement>(children.item(i));
        DOM::CSSStyleDeclaration style = node.style();

        DOM::DOMString css_height = style.getPropertyValue("height");
        if(!css_height.isNull()) {
            height += css_height.string().left(css_height.string().length() - 2).toInt();
        }
        else {
            int h = 0;
            if(!node.isNull()) {
                h = node.getRect().height();
            }

            DOM::DOMString display = style.getPropertyValue("display");
            if(display == "none") {
                h = 0;
            }
            else if(h == 0) {
                h = 20;
            }

            height += h;
        }
    }

    return height;
}
Ejemplo n.º 2
0
Value DOMCSSStyleDeclarationProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
    KJS_CHECK_THIS(KJS::DOMCSSStyleDeclaration, thisObj);
    DOM::CSSStyleDeclaration styleDecl = static_cast< DOMCSSStyleDeclaration * >(thisObj.imp())->toStyleDecl();
    String str = args[0].toString(exec);
    DOM::DOMString s = str.value().string();

    switch(id)
    {
        case DOMCSSStyleDeclaration::GetPropertyValue:
            return String(styleDecl.getPropertyValue(s));
        case DOMCSSStyleDeclaration::GetPropertyCSSValue:
            return getDOMCSSValue(exec, styleDecl.getPropertyCSSValue(s));
        case DOMCSSStyleDeclaration::RemoveProperty:
            return String(styleDecl.removeProperty(s));
        case DOMCSSStyleDeclaration::GetPropertyPriority:
            return String(styleDecl.getPropertyPriority(s));
        case DOMCSSStyleDeclaration::SetProperty:
            styleDecl.setProperty(args[0].toString(exec).string(), args[1].toString(exec).string(), args[2].toString(exec).string());
            return Undefined();
        case DOMCSSStyleDeclaration::Item:
            return String(styleDecl.item(args[0].toInteger(exec)));
        default:
            return Undefined();
    }
}
Ejemplo n.º 3
0
void MetabarFunctions::animate()
{
    QMap<QString, int>::Iterator it;
    for(it = resizeMap.begin(); it != resizeMap.end(); ++it ) {
        QString id = it.key();
        int height = it.data();
        int currentHeight = 0;

        DOM::HTMLDocument doc = m_html->htmlDocument();
        DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(id));
        DOM::CSSStyleDeclaration style = node.style();

        QString currentHeightString = style.getPropertyValue("height").string();
        if(currentHeightString.endsWith("px")) {
            currentHeight = currentHeightString.left(currentHeightString.length() - 2).toInt();
        }

        if(currentHeight == height) {
            resizeMap.remove(id);

            if(resizeMap.isEmpty()) {
                timer->stop();
            }
        }
        else {
            int diff = kAbs(currentHeight - height);
            int changeValue = RESIZE_STEP;

            if(diff < RESIZE_STEP) {
                changeValue = diff;
            }

            int change = currentHeight < height ? changeValue : -changeValue;
            style.setProperty("height", QString("%1px").arg(currentHeight + change), CSS_PRIORITY);
            doc.updateRendering();
        }
    }
}
Ejemplo n.º 4
0
void DOMTreeView::initializeCSSInfoFromElement(const DOM::Element &element)
{
  DOM::Document doc = element.ownerDocument();
  DOM::AbstractView view = doc.defaultView();
  DOM::CSSStyleDeclaration styleDecl = view.getComputedStyle(element,
                                                             DOM::DOMString());

  unsigned long l = styleDecl.length();
  cssProperties->clear();
  cssProperties->setEnabled(true);
  QList<QTreeWidgetItem *> items;
  for (unsigned long i = 0; i < l; ++i) {
    DOM::DOMString name = styleDecl.item(i);
    DOM::DOMString value = styleDecl.getPropertyValue(name);

    QStringList values;
    values.append(name.string());
    values.append(value.string());
    items.append(new QTreeWidgetItem(static_cast<QTreeWidget*>(0), values));
  }

  cssProperties->insertTopLevelItems(0, items);
  cssProperties->resizeColumnToContents(0);
}