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

📄 rendertheme.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}Color RenderTheme::inactiveListBoxSelectionForegroundColor() const{    if (!m_inactiveListBoxSelectionForegroundColor.isValid() && supportsListBoxSelectionForegroundColors())        m_inactiveListBoxSelectionForegroundColor = platformInactiveListBoxSelectionForegroundColor();    return m_inactiveListBoxSelectionForegroundColor;}Color RenderTheme::platformActiveSelectionBackgroundColor() const{    // Use a blue color by default if the platform theme doesn't define anything.    return Color(0, 0, 255);}Color RenderTheme::platformActiveSelectionForegroundColor() const{    // Use a white color by default if the platform theme doesn't define anything.    return Color::white;}Color RenderTheme::platformInactiveSelectionBackgroundColor() const{    // Use a grey color by default if the platform theme doesn't define anything.    // This color matches Firefox's inactive color.    return Color(176, 176, 176);}Color RenderTheme::platformInactiveSelectionForegroundColor() const{    // Use a black color by default.    return Color::black;}Color RenderTheme::platformActiveListBoxSelectionBackgroundColor() const{    return platformActiveSelectionBackgroundColor();}Color RenderTheme::platformActiveListBoxSelectionForegroundColor() const{    return platformActiveSelectionForegroundColor();}Color RenderTheme::platformInactiveListBoxSelectionBackgroundColor() const{    return platformInactiveSelectionBackgroundColor();}Color RenderTheme::platformInactiveListBoxSelectionForegroundColor() const{    return platformInactiveSelectionForegroundColor();}int RenderTheme::baselinePosition(const RenderObject* o) const{    if (!o->isBox())        return 0;    const RenderBox* box = toRenderBox(o);#if USE(NEW_THEME)    return box->height() + box->marginTop() + m_theme->baselinePositionAdjustment(o->style()->appearance()) * o->style()->effectiveZoom();#else    return box->height() + box->marginTop();#endif}bool RenderTheme::isControlContainer(ControlPart appearance) const{    // There are more leaves than this, but we'll patch this function as we add support for    // more controls.    return appearance != CheckboxPart && appearance != RadioPart;}bool RenderTheme::isControlStyled(const RenderStyle* style, const BorderData& border, const FillLayer& background,                                  const Color& backgroundColor) const{    switch (style->appearance()) {        case PushButtonPart:        case SquareButtonPart:        case DefaultButtonPart:        case ButtonPart:        case ListboxPart:        case MenulistPart:        // FIXME: Uncomment this when making search fields style-able.        // case SearchFieldPart:        case TextFieldPart:        case TextAreaPart:            // Test the style to see if the UA border and background match.            return (style->border() != border ||                    *style->backgroundLayers() != background ||                    style->backgroundColor() != backgroundColor);        default:            return false;    }}void RenderTheme::adjustRepaintRect(const RenderObject* o, IntRect& r){#if USE(NEW_THEME)    m_theme->inflateControlPaintRect(o->style()->appearance(), controlStatesForRenderer(o), r, o->style()->effectiveZoom());#endif}bool RenderTheme::supportsFocusRing(const RenderStyle* style) const{    return (style->hasAppearance() && style->appearance() != TextFieldPart && style->appearance() != TextAreaPart && style->appearance() != MenulistButtonPart && style->appearance() != ListboxPart);}bool RenderTheme::stateChanged(RenderObject* o, ControlState state) const{    // Default implementation assumes the controls dont respond to changes in :hover state    if (state == HoverState && !supportsHover(o->style()))        return false;    // Assume pressed state is only responded to if the control is enabled.    if (state == PressedState && !isEnabled(o))        return false;    // Repaint the control.    o->repaint();    return true;}ControlStates RenderTheme::controlStatesForRenderer(const RenderObject* o) const{    ControlStates result = 0;    if (isHovered(o))        result |= HoverState;    if (isPressed(o))        result |= PressedState;    if (isFocused(o) && o->style()->outlineStyleIsAuto())        result |= FocusState;    if (isEnabled(o))        result |= EnabledState;    if (isChecked(o))        result |= CheckedState;    if (isReadOnlyControl(o))        result |= ReadOnlyState;    if (isDefault(o))        result |= DefaultState;    if (!isActive(o))        result |= WindowInactiveState;    if (isIndeterminate(o))        result |= IndeterminateState;    return result;}bool RenderTheme::isActive(const RenderObject* o) const{    Node* node = o->node();    if (!node)        return false;    Frame* frame = node->document()->frame();    if (!frame)        return false;    Page* page = frame->page();    if (!page)        return false;    return page->focusController()->isActive();}bool RenderTheme::isChecked(const RenderObject* o) const{    if (!o->node() || !o->node()->isElementNode())        return false;    InputElement* inputElement = toInputElement(static_cast<Element*>(o->node()));    if (!inputElement)        return false;    return inputElement->isChecked();}bool RenderTheme::isIndeterminate(const RenderObject* o) const{    if (!o->node() || !o->node()->isElementNode())        return false;    InputElement* inputElement = toInputElement(static_cast<Element*>(o->node()));    if (!inputElement)        return false;    return inputElement->isIndeterminate();}bool RenderTheme::isEnabled(const RenderObject* o) const{    if (!o->node() || !o->node()->isElementNode())        return true;    FormControlElement* formControlElement = toFormControlElement(static_cast<Element*>(o->node()));    if (!formControlElement)        return true;    return formControlElement->isEnabled();}bool RenderTheme::isFocused(const RenderObject* o) const{    Node* node = o->node();    if (!node)        return false;    Document* document = node->document();    Frame* frame = document->frame();    return node == document->focusedNode() && frame && frame->selection()->isFocusedAndActive();}bool RenderTheme::isPressed(const RenderObject* o) const{    if (!o->node())        return false;    return o->node()->active();}bool RenderTheme::isReadOnlyControl(const RenderObject* o) const{    if (!o->node() || !o->node()->isElementNode())        return false;    FormControlElement* formControlElement = toFormControlElement(static_cast<Element*>(o->node()));    if (!formControlElement)        return false;    return formControlElement->isReadOnlyControl();}bool RenderTheme::isHovered(const RenderObject* o) const{    if (!o->node())        return false;    return o->node()->hovered();}bool RenderTheme::isDefault(const RenderObject* o) const{    if (!o->document())        return false;    Settings* settings = o->document()->settings();    if (!settings || !settings->inApplicationChromeMode())        return false;        return o->style()->appearance() == DefaultButtonPart;}#if !USE(NEW_THEME)void RenderTheme::adjustCheckboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const{    // A summary of the rules for checkbox designed to match WinIE:    // width/height - honored (WinIE actually scales its control for small widths, but lets it overflow for small heights.)    // font-size - not honored (control has no text), but we use it to decide which control size to use.    setCheckboxSize(style);    // padding - not honored by WinIE, needs to be removed.    style->resetPadding();    // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)    // for now, we will not honor it.    style->resetBorder();    style->setBoxShadow(0);}void RenderTheme::adjustRadioStyle(CSSStyleSelector*, RenderStyle* style, Element*) const{    // A summary of the rules for checkbox designed to match WinIE:    // width/height - honored (WinIE actually scales its control for small widths, but lets it overflow for small heights.)    // font-size - not honored (control has no text), but we use it to decide which control size to use.    setRadioSize(style);    // padding - not honored by WinIE, needs to be removed.    style->resetPadding();    // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)    // for now, we will not honor it.    style->resetBorder();    style->setBoxShadow(0);}void RenderTheme::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const{    // Most platforms will completely honor all CSS, and so we have no need to adjust the style    // at all by default.  We will still allow the theme a crack at setting up a desired vertical size.    setButtonSize(style);}#endifvoid RenderTheme::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSliderThumbSize(RenderObject*) const{}void RenderTheme::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const{}void RenderTheme::platformColorsDidChange(){    m_activeSelectionForegroundColor = Color();    m_inactiveSelectionForegroundColor = Color();    m_activeSelectionBackgroundColor = Color();    m_inactiveSelectionBackgroundColor = Color();    m_activeListBoxSelectionForegroundColor = Color();    m_inactiveListBoxSelectionForegroundColor = Color();    m_activeListBoxSelectionBackgroundColor = Color();    m_inactiveListBoxSelectionForegroundColor = Color();}Color RenderTheme::systemColor(int cssValueId) const{    switch (cssValueId) {        case CSSValueActiveborder:            return 0xFFFFFFFF;        case CSSValueActivecaption:            return 0xFFCCCCCC;        case CSSValueAppworkspace:            return 0xFFFFFFFF;        case CSSValueBackground:            return 0xFF6363CE;        case CSSValueButtonface:            return 0xFFC0C0C0;        case CSSValueButtonhighlight:            return 0xFFDDDDDD;        case CSSValueButtonshadow:            return 0xFF888888;        case CSSValueButtontext:            return 0xFF000000;        case CSSValueCaptiontext:            return 0xFF000000;        case CSSValueGraytext:            return 0xFF808080;        case CSSValueHighlight:            return 0xFFB5D5FF;        case CSSValueHighlighttext:            return 0xFF000000;        case CSSValueInactiveborder:            return 0xFFFFFFFF;        case CSSValueInactivecaption:            return 0xFFFFFFFF;        case CSSValueInactivecaptiontext:            return 0xFF7F7F7F;        case CSSValueInfobackground:            return 0xFFFBFCC5;        case CSSValueInfotext:            return 0xFF000000;        case CSSValueMenu:            return 0xFFC0C0C0;        case CSSValueMenutext:            return 0xFF000000;        case CSSValueScrollbar:            return 0xFFFFFFFF;        case CSSValueText:            return 0xFF000000;        case CSSValueThreeddarkshadow:            return 0xFF666666;        case CSSValueThreedface:            return 0xFFC0C0C0;        case CSSValueThreedhighlight:            return 0xFFDDDDDD;        case CSSValueThreedlightshadow:            return 0xFFC0C0C0;        case CSSValueThreedshadow:            return 0xFF888888;        case CSSValueWindow:            return 0xFFFFFFFF;        case CSSValueWindowframe:            return 0xFFCCCCCC;        case CSSValueWindowtext:            return 0xFF000000;    }    return Color();}Color RenderTheme::platformTextSearchHighlightColor() const{    return Color(255, 255, 0);}} // namespace WebCore

⌨️ 快捷键说明

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