⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 renderthemeqt.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    return false;}void RenderThemeQt::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style,                                           Element* e) const{    notImplemented();    RenderTheme::adjustSearchFieldStyle(selector, style, e);}void RenderThemeQt::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style,                                                       Element* e) const{    notImplemented();    RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e);}bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& pi,                                                 const IntRect& r){    notImplemented();    return RenderTheme::paintSearchFieldCancelButton(o, pi, r);}void RenderThemeQt::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style,                                                     Element* e) const{    notImplemented();    RenderTheme::adjustSearchFieldDecorationStyle(selector, style, e);}bool RenderThemeQt::paintSearchFieldDecoration(RenderObject* o, const RenderObject::PaintInfo& pi,                                               const IntRect& r){    notImplemented();    return RenderTheme::paintSearchFieldDecoration(o, pi, r);}void RenderThemeQt::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style,                                                            Element* e) const{    notImplemented();    RenderTheme::adjustSearchFieldResultsDecorationStyle(selector, style, e);}bool RenderThemeQt::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& pi,                                                      const IntRect& r){    notImplemented();    return RenderTheme::paintSearchFieldResultsDecoration(o, pi, r);}bool RenderThemeQt::supportsFocus(ControlPart appearance) const{    switch (appearance) {        case PushButtonPart:        case ButtonPart:        case TextFieldPart:        case TextAreaPart:        case ListboxPart:        case MenulistPart:        case RadioPart:        case CheckboxPart:            return true;        default: // No for all others...            return false;    }}ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const{    // Default bits: no focus, no mouse over    option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);    if (!isEnabled(o))        option.state &= ~QStyle::State_Enabled;    if (isReadOnlyControl(o))        // Readonly is supported on textfields.        option.state |= QStyle::State_ReadOnly;    if (supportsFocus(o->style()->appearance()) && isFocused(o)) {        option.state |= QStyle::State_HasFocus;        option.state |= QStyle::State_KeyboardFocusChange;    }    if (isHovered(o))        option.state |= QStyle::State_MouseOver;    ControlPart result = o->style()->appearance();    switch (result) {        case PushButtonPart:        case SquareButtonPart:        case ButtonPart:        case ButtonBevelPart:        case ListItemPart:        case MenulistButtonPart:        case SearchFieldResultsButtonPart:        case SearchFieldCancelButtonPart: {            if (isPressed(o))                option.state |= QStyle::State_Sunken;            else if (result == PushButtonPart)                option.state |= QStyle::State_Raised;            break;        }    }    if(result == RadioPart || result == CheckboxPart)        option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);    // If the webview has a custom palette, use it    Page* page = o->document()->page();    if (page) {        QWidget* view = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage->view();        if (view)            option.palette = view->palette();    }    return result;}#if ENABLE(VIDEO)String RenderThemeQt::extraMediaControlsStyleSheet(){    QFile platformStyleSheet(QLatin1String(":/webcore/css/mediaControls-extras.css"));    if (platformStyleSheet.open(QFile::ReadOnly)) {        QByteArray sheetData = platformStyleSheet.readAll();        return QString::fromUtf8(sheetData.constData(), sheetData.length());    }    return String();}// Helper class to transform the painter's world matrix to the object's content area, scaled to 0,0,100,100class WorldMatrixTransformer{public:    WorldMatrixTransformer(QPainter* painter, RenderObject* renderObject, const IntRect& r) : m_painter(painter) {        RenderStyle* style = renderObject->style();        m_originalTransform = m_painter->transform();        m_painter->translate(r.x() + style->paddingLeft().value(), r.y() + style->paddingTop().value());        m_painter->scale((r.width() - style->paddingLeft().value() - style->paddingRight().value()) / 100.0,             (r.height() - style->paddingTop().value() - style->paddingBottom().value()) / 100.0);    }    ~WorldMatrixTransformer() { m_painter->setTransform(m_originalTransform); }private:    QPainter* m_painter;    QTransform m_originalTransform;};HTMLMediaElement* RenderThemeQt::getMediaElementFromRenderObject(RenderObject* o) const{    Node* node = o->node();    Node* mediaNode = node ? node->shadowAncestorNode() : 0;    if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag)))        return 0;    return static_cast<HTMLMediaElement*>(mediaNode);}void RenderThemeQt::paintMediaBackground(QPainter* painter, const IntRect& r) const{    painter->setPen(Qt::NoPen);    static QColor transparentBlack(0,0,0,100);    painter->setBrush(transparentBlack);    painter->drawRoundedRect(r.x(), r.y(), r.width(), r.height(), 5.0, 5.0);}QColor RenderThemeQt::getMediaControlForegroundColor(RenderObject* o) const{    QColor fgColor = platformActiveSelectionBackgroundColor();    if (o && o->node()->active())        fgColor = fgColor.lighter();    return fgColor;}bool RenderThemeQt::paintMediaFullscreenButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){   return RenderTheme::paintMediaFullscreenButton(o, paintInfo, r);}bool RenderThemeQt::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o);    if (!mediaElement)        return false;    StylePainter p(paintInfo);    if (!p.isValid())        return true;    p.painter->setRenderHint(QPainter::Antialiasing, true);    paintMediaBackground(p.painter, r);    WorldMatrixTransformer transformer(p.painter, o, r);    const QPointF speakerPolygon[6] = { QPointF(20, 30), QPointF(50, 30), QPointF(80, 0),            QPointF(80, 100), QPointF(50, 70), QPointF(20, 70)};    p.painter->setBrush(getMediaControlForegroundColor(o));    p.painter->drawPolygon(speakerPolygon, 6);    if (mediaElement->muted()) {        p.painter->setPen(Qt::red);        p.painter->drawLine(0, 100, 100, 0);    }    return false;}bool RenderThemeQt::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o);    if (!mediaElement)        return false;    StylePainter p(paintInfo);    if (!p.isValid())        return true;    p.painter->setRenderHint(QPainter::Antialiasing, true);    paintMediaBackground(p.painter, r);    WorldMatrixTransformer transformer(p.painter, o, r);    p.painter->setBrush(getMediaControlForegroundColor(o));    if (mediaElement->canPlay()) {        const QPointF playPolygon[3] = { QPointF(0, 0), QPointF(100, 50), QPointF(0, 100)};        p.painter->drawPolygon(playPolygon, 3);    } else {        p.painter->drawRect(0, 0, 30, 100);        p.painter->drawRect(70, 0, 30, 100);    }    return false;}bool RenderThemeQt::paintMediaSeekBackButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    // We don't want to paint this at the moment.    return false;}bool RenderThemeQt::paintMediaSeekForwardButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    // We don't want to paint this at the moment.    return false;}bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o);    if (!mediaElement)        return false;    StylePainter p(paintInfo);    if (!p.isValid())        return true;    p.painter->setRenderHint(QPainter::Antialiasing, true);    paintMediaBackground(p.painter, r);    if (MediaPlayer* player = mediaElement->player()) {        if (player->totalBytesKnown()) {            float percentLoaded = static_cast<float>(player->bytesLoaded()) / player->totalBytes();            WorldMatrixTransformer transformer(p.painter, o, r);            p.painter->setBrush(getMediaControlForegroundColor());            p.painter->drawRect(0, 37, 100 * percentLoaded, 26);        }    }    return false;}bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o->parent());    if (!mediaElement)        return false;    StylePainter p(paintInfo);    if (!p.isValid())        return true;    p.painter->setRenderHint(QPainter::Antialiasing, true);    p.painter->setPen(Qt::NoPen);    p.painter->setBrush(getMediaControlForegroundColor(o));    p.painter->drawRect(r.x(), r.y(), r.width(), r.height());    return false;}#endifvoid RenderThemeQt::adjustSliderThumbSize(RenderObject* o) const{    if (o->style()->appearance() == MediaSliderThumbPart) {        RenderStyle* parentStyle = o->parent()->style();        Q_ASSERT(parentStyle);        int parentHeight = parentStyle->height().value();        o->style()->setWidth(Length(parentHeight / 3, Fixed));        o->style()->setHeight(Length(parentHeight, Fixed));    }}double RenderThemeQt::caretBlinkInterval() const{    return  QApplication::cursorFlashTime() / 1000.0 / 2.0;}}// vim: ts=4 sw=4 et

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -