Пример #1
0
static bool resolutionMediaFeatureEval(CSSValueImpl* value, RenderStyle*, KHTMLPart* part,  MediaFeaturePrefix op)
{
    DOM::DocumentImpl *d = static_cast<DOM::DocumentImpl*>(part->document().handle());
    int logicalDpiY = d ? d->logicalDpiY() : 0;

    if (value && logicalDpiY)
        return value->isPrimitiveValue() && compareValue(logicalDpiY, static_cast<CSSPrimitiveValueImpl*>(value)->getDPIResolution(), op);

    return logicalDpiY != 0;
}
Пример #2
0
static bool heightMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, KHTMLPart* part,  MediaFeaturePrefix op)
{
    KHTMLPart* rootPart = part;
    while (rootPart->parentPart()) rootPart = rootPart->parentPart();
    DOM::DocumentImpl *doc =  static_cast<DOM::DocumentImpl*>(rootPart->document().handle());
    QPaintDevice *pd = doc->paintDevice(); 
    bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
    int height;
    if (printing)
        height = pd->height();
    else {
        height = part->view()->visibleHeight();
        doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
    }
    int logicalDpiY = doc->logicalDpiY();
    if (value)
        return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, logicalDpiY), op);

    return height > 0;
}
Пример #3
0
static bool device_widthMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, KHTMLPart* part,  MediaFeaturePrefix op)
{
    if (value) {
        KHTMLPart* rootPart = part;
        while (rootPart->parentPart()) rootPart = rootPart->parentPart();
        DOM::DocumentImpl *doc =  static_cast<DOM::DocumentImpl*>(rootPart->document().handle());
        QPaintDevice *pd = doc->paintDevice(); 
        bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
        int width;
        if (printing)
            width = pd->width();
        else {
            width = QApplication::desktop()->screen(QApplication::desktop()->screenNumber( rootPart->view() ))->rect().width();
            doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
        }
        int logicalDpiY = doc->logicalDpiY();
        return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style,logicalDpiY), op);
    }
    // ({,min-,max-}device-width)
    // assume if we have a device, assume non-zero
    return true;
}
Пример #4
0
static bool widthMediaFeatureEval(CSSValueImpl *value, RenderStyle *style, KHTMLPart *part,  MediaFeaturePrefix op)
{
    KHTMLPart *rootPart = part;
    while (rootPart->parentPart()) {
        rootPart = rootPart->parentPart();
    }
    DOM::DocumentImpl *doc =  static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
    QPaintDevice *pd = doc->paintDevice();
    bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
    int width;
    if (printing) {
        width = pd->width();
    } else {
        width = part->view()->visibleWidth();
        doc = static_cast<DOM::DocumentImpl *>(part->document().handle());
    }
    int logicalDpiY = doc->logicalDpiY();
    if (value) {
        return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl *>(value)->computeLength(style, style, logicalDpiY), op);
    }

    return width > 0;
}