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

📄 renderthemechromiumwin.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            fontSize = systemFontSize(metrics.lfSmCaptionFont);        }        break;    case CSSValueMenu:        cachedDesc = &menuFont;        if (!menuFont.isAbsoluteSize()) {            NONCLIENTMETRICS metrics;            getNonClientMetrics(&metrics);            faceName = metrics.lfMenuFont.lfFaceName;            fontSize = systemFontSize(metrics.lfMenuFont);        }        break;    case CSSValueStatusBar:        cachedDesc = &labelFont;        if (!labelFont.isAbsoluteSize()) {            NONCLIENTMETRICS metrics;            getNonClientMetrics(&metrics);            faceName = metrics.lfStatusFont.lfFaceName;            fontSize = systemFontSize(metrics.lfStatusFont);        }        break;    case CSSValueWebkitMiniControl:    case CSSValueWebkitSmallControl:    case CSSValueWebkitControl:        faceName = defaultGUIFont(document);        // Why 2 points smaller?  Because that's what Gecko does.        fontSize = defaultFontSize - pointsToPixels(2);        break;    default:        faceName = defaultGUIFont(document);        fontSize = defaultFontSize;        break;    }    if (!cachedDesc)        cachedDesc = &fontDescription;    if (fontSize) {        ASSERT(faceName);        cachedDesc->firstFamily().setFamily(AtomicString(faceName,                                                         wcslen(faceName)));        cachedDesc->setIsAbsoluteSize(true);        cachedDesc->setGenericFamily(FontDescription::NoFamily);        cachedDesc->setSpecifiedSize(fontSize);        cachedDesc->setWeight(FontWeightNormal);        cachedDesc->setItalic(false);    }    fontDescription = *cachedDesc;}int RenderThemeChromiumWin::minimumMenuListSize(RenderStyle* style) const{    return 0;}void RenderThemeChromiumWin::setCheckboxSize(RenderStyle* style) const{    // If the width and height are both specified, then we have nothing to do.    if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())        return;    // FIXME:  A hard-coded size of 13 is used.  This is wrong but necessary    // for now.  It matches Firefox.  At different DPI settings on Windows,    // querying the theme gives you a larger size that accounts for the higher    // DPI.  Until our entire engine honors a DPI setting other than 96, we    // can't rely on the theme's metrics.    const IntSize size(13, 13);    setSizeIfAuto(style, size);}void RenderThemeChromiumWin::setRadioSize(RenderStyle* style) const{    // Use same sizing for radio box as checkbox.    setCheckboxSize(style);}bool RenderThemeChromiumWin::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r){    const ThemeData& themeData = getThemeData(o);    WebCore::ThemePainter painter(i.context, r);    ChromiumBridge::paintButton(painter.context(),                                themeData.m_part,                                themeData.m_state,                                themeData.m_classicState,                                painter.drawRect());    return false;}bool RenderThemeChromiumWin::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r){    return paintTextFieldInternal(o, i, r, true);}bool RenderThemeChromiumWin::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r){    return paintTextField(o, i, r);}void RenderThemeChromiumWin::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    // Height is locked to auto on all browsers.    style->setLineHeight(RenderStyle::initialLineHeight());}// Used to paint unstyled menulists (i.e. with the default border)bool RenderThemeChromiumWin::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r){    if (!o->isBox())        return false;    const RenderBox* box = toRenderBox(o);    int borderRight = box->borderRight();    int borderLeft = box->borderLeft();    int borderTop = box->borderTop();    int borderBottom = box->borderBottom();    // If all the borders are 0, then tell skia not to paint the border on the    // textfield.  FIXME: http://b/1210017 Figure out how to get Windows to not    // draw individual borders and then pass that to skia so we can avoid    // drawing any borders that are set to 0. For non-zero borders, we draw the    // border, but webkit just draws over it.    bool drawEdges = !(borderRight == 0 && borderLeft == 0 && borderTop == 0 && borderBottom == 0);    paintTextFieldInternal(o, i, r, drawEdges);    // Take padding and border into account.  If the MenuList is smaller than    // the size of a button, make sure to shrink it appropriately and not put    // its x position to the left of the menulist.    const int buttonWidth = GetSystemMetrics(SM_CXVSCROLL);    int spacingLeft = borderLeft + box->paddingLeft();    int spacingRight = borderRight + box->paddingRight();    int spacingTop = borderTop + box->paddingTop();    int spacingBottom = borderBottom + box->paddingBottom();    int buttonX;    if (r.right() - r.x() < buttonWidth)        buttonX = r.x();    else        buttonX = o->style()->direction() == LTR ? r.right() - spacingRight - buttonWidth : r.x() + spacingLeft;    // Compute the rectangle of the button in the destination image.    IntRect rect(buttonX,                 r.y() + spacingTop,                 std::min(buttonWidth, r.right() - r.x()),                 r.height() - (spacingTop + spacingBottom));    // Get the correct theme data for a textfield and paint the menu.    WebCore::ThemePainter painter(i.context, rect);    ChromiumBridge::paintMenuList(painter.context(),                                  CP_DROPDOWNBUTTON,                                  determineState(o),                                  determineClassicState(o),                                  painter.drawRect());    return false;}void RenderThemeChromiumWin::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    adjustMenuListStyle(selector, style, e);}// Used to paint styled menulists (i.e. with a non-default border)bool RenderThemeChromiumWin::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r){    return paintMenuList(o, i, r);}int RenderThemeChromiumWin::popupInternalPaddingLeft(RenderStyle* style) const{    return menuListInternalPadding(style, LeftPadding);}int RenderThemeChromiumWin::popupInternalPaddingRight(RenderStyle* style) const{    return menuListInternalPadding(style, RightPadding);}int RenderThemeChromiumWin::popupInternalPaddingTop(RenderStyle* style) const{    return menuListInternalPadding(style, TopPadding);}int RenderThemeChromiumWin::popupInternalPaddingBottom(RenderStyle* style) const{    return menuListInternalPadding(style, BottomPadding);}int RenderThemeChromiumWin::buttonInternalPaddingLeft() const{    return 3;}int RenderThemeChromiumWin::buttonInternalPaddingRight() const{    return 3;}int RenderThemeChromiumWin::buttonInternalPaddingTop() const{    return 1;}int RenderThemeChromiumWin::buttonInternalPaddingBottom() const{    return 1;}// staticvoid RenderThemeChromiumWin::setDefaultFontSize(int fontSize) {    defaultFontSize = static_cast<float>(fontSize);    // Reset cached fonts.    smallSystemFont = menuFont = labelFont = FontDescription();}unsigned RenderThemeChromiumWin::determineState(RenderObject* o){    unsigned result = TS_NORMAL;    ControlPart appearance = o->style()->appearance();    if (!isEnabled(o))        result = TS_DISABLED;    else if (isReadOnlyControl(o) && (TextFieldPart == appearance || TextAreaPart == appearance))        result = ETS_READONLY; // Readonly is supported on textfields.    else if (isPressed(o)) // Active overrides hover and focused.        result = TS_PRESSED;    else if (supportsFocus(appearance) && isFocused(o))        result = ETS_FOCUSED;    else if (isHovered(o))        result = TS_HOT;    if (isChecked(o))        result += 4; // 4 unchecked states, 4 checked states.    return result;}unsigned RenderThemeChromiumWin::determineClassicState(RenderObject* o){    unsigned result = 0;    if (!isEnabled(o))        result = DFCS_INACTIVE;    else if (isPressed(o)) // Active supersedes hover        result = DFCS_PUSHED;    else if (isHovered(o))        result = DFCS_HOT;    if (isChecked(o))        result |= DFCS_CHECKED;    return result;}ThemeData RenderThemeChromiumWin::getThemeData(RenderObject* o){    ThemeData result;    switch (o->style()->appearance()) {    case PushButtonPart:    case ButtonPart:        result.m_part = BP_PUSHBUTTON;        result.m_classicState = DFCS_BUTTONPUSH;        break;    case CheckboxPart:        result.m_part = BP_CHECKBOX;        result.m_classicState = DFCS_BUTTONCHECK;        break;    case RadioPart:        result.m_part = BP_RADIOBUTTON;        result.m_classicState = DFCS_BUTTONRADIO;        break;    case ListboxPart:    case MenulistPart:    case TextFieldPart:    case TextAreaPart:        result.m_part = ETS_NORMAL;        break;    }    result.m_state = determineState(o);    result.m_classicState |= determineClassicState(o);    return result;}bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o,                                                    const RenderObject::PaintInfo& i,                                                    const IntRect& r,                                                    bool drawEdges){    // Nasty hack to make us not paint the border on text fields with a    // border-radius. Webkit paints elements with border-radius for us.    // FIXME: Get rid of this if-check once we can properly clip rounded    // borders: http://b/1112604 and http://b/1108635    // FIXME: make sure we do the right thing if css background-clip is set.    if (o->style()->hasBorderRadius())        return false;    const ThemeData& themeData = getThemeData(o);    WebCore::ThemePainter painter(i.context, r);    ChromiumBridge::paintTextField(painter.context(),                                   themeData.m_part,                                   themeData.m_state,                                   themeData.m_classicState,                                   painter.drawRect(),                                   o->style()->backgroundColor(),                                   true,                                   drawEdges);    return false;}int RenderThemeChromiumWin::menuListInternalPadding(RenderStyle* style, int paddingType) const{    // This internal padding is in addition to the user-supplied padding.    // Matches the FF behavior.    int padding = styledMenuListInternalPadding[paddingType];    // Reserve the space for right arrow here. The rest of the padding is set    // by adjustMenuListStyle, since PopupMenuChromium.cpp uses the padding    // from RenderMenuList to lay out the individual items in the popup.  If    // the MenuList actually has appearance "NoAppearance", then that means we    // don't draw a button, so don't reserve space for it.    const int barType = style->direction() == LTR ? RightPadding : LeftPadding;    if (paddingType == barType && style->appearance() != NoControlPart)        padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();    return padding;}// staticvoid RenderThemeChromiumWin::setFindInPageMode(bool enable) {  if (m_findInPageMode == enable)      return;  m_findInPageMode = enable;  theme()->platformColorsDidChange();}} // namespace WebCore

⌨️ 快捷键说明

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