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

📄 renderthemechromiummac.mm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 MM
📖 第 1 页 / 共 5 页
字号:
    return sizes;}void RenderThemeChromiumMac::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    NSControlSize controlSize = controlSizeForFont(style);    style->resetBorder();    style->resetPadding();        // Height is locked to auto.    style->setHeight(Length(Auto));    // White-space is locked to pre    style->setWhiteSpace(PRE);    // Set the foreground color to black or gray when we have the aqua look.    // Cast to RGB32 is to work around a compiler bug.    bool isEnabled = true;    if (FormControlElement* formControlElement = toFormControlElement(e))        isEnabled = formControlElement->isEnabled();    style->setColor(isEnabled ? static_cast<RGBA32>(Color::black) : Color::darkGray);    // Set the button's vertical size.    setSizeFromFont(style, menuListButtonSizes());    // Our font is locked to the appropriate system font size for the control.  To clarify, we first use the CSS-specified font to figure out    // a reasonable control size, but once that control size is determined, we throw that font away and use the appropriate    // system font for the control size instead.    setFontFromControlSize(selector, style, controlSize);    style->setBoxShadow(0);}int RenderThemeChromiumMac::popupInternalPaddingLeft(RenderStyle* style) const{    if (style->appearance() == MenulistPart)        return popupButtonPadding(controlSizeForFont(style))[LeftPadding] * style->effectiveZoom();    if (style->appearance() == MenulistButtonPart)        return styledPopupPaddingLeft * style->effectiveZoom();    return 0;}int RenderThemeChromiumMac::popupInternalPaddingRight(RenderStyle* style) const{    if (style->appearance() == MenulistPart)        return popupButtonPadding(controlSizeForFont(style))[RightPadding] * style->effectiveZoom();    if (style->appearance() == MenulistButtonPart) {        float fontScale = style->fontSize() / baseFontSize;        float arrowWidth = baseArrowWidth * fontScale;        return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPaddingRight + paddingBeforeSeparator) * style->effectiveZoom()));    }    return 0;}int RenderThemeChromiumMac::popupInternalPaddingTop(RenderStyle* style) const{    if (style->appearance() == MenulistPart)        return popupButtonPadding(controlSizeForFont(style))[TopPadding] * style->effectiveZoom();    if (style->appearance() == MenulistButtonPart)        return styledPopupPaddingTop * style->effectiveZoom();    return 0;}int RenderThemeChromiumMac::popupInternalPaddingBottom(RenderStyle* style) const{    if (style->appearance() == MenulistPart)        return popupButtonPadding(controlSizeForFont(style))[BottomPadding] * style->effectiveZoom();    if (style->appearance() == MenulistButtonPart)        return styledPopupPaddingBottom * style->effectiveZoom();    return 0;}void RenderThemeChromiumMac::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    float fontScale = style->fontSize() / baseFontSize;    style->resetPadding();    style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up?    const int minHeight = 15;    style->setMinHeight(Length(minHeight, Fixed));        style->setLineHeight(RenderStyle::initialLineHeight());}void RenderThemeChromiumMac::setPopupButtonCellState(const RenderObject* o, const IntRect& r){    NSPopUpButtonCell* popupButton = this->popupButton();    // Set the control size based off the rectangle we're painting into.    setControlSize(popupButton, popupButtonSizes(), r.size(), o->style()->effectiveZoom());    // Update the various states we respond to.    updateCheckedState(popupButton, o);    updateEnabledState(popupButton, o);    updatePressedState(popupButton, o);    updateFocusedState(popupButton, o);}const IntSize* RenderThemeChromiumMac::menuListSizes() const{    static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0) };    return sizes;}int RenderThemeChromiumMac::minimumMenuListSize(RenderStyle* style) const{    return sizeForSystemFont(style, menuListSizes()).width();}static const int trackWidth = 5;static const int trackRadius = 2;void RenderThemeChromiumMac::adjustSliderTrackStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    style->setBoxShadow(0);}bool RenderThemeChromiumMac::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    IntRect bounds = r;    float zoomLevel = o->style()->effectiveZoom();    float zoomedTrackWidth = trackWidth * zoomLevel;    if (o->style()->appearance() ==  SliderHorizontalPart || o->style()->appearance() ==  MediaSliderPart) {        bounds.setHeight(zoomedTrackWidth);        bounds.setY(r.y() + r.height() / 2 - zoomedTrackWidth / 2);    } else if (o->style()->appearance() == SliderVerticalPart) {        bounds.setWidth(zoomedTrackWidth);        bounds.setX(r.x() + r.width() / 2 - zoomedTrackWidth / 2);    }    LocalCurrentGraphicsContext localContext(paintInfo.context);    CGContextRef context = paintInfo.context->platformContext();    RetainPtr<CGColorSpaceRef> cspace(AdoptCF, CGColorSpaceCreateDeviceRGB());    paintInfo.context->save();    CGContextClipToRect(context, bounds);    struct CGFunctionCallbacks mainCallbacks = { 0, TrackGradientInterpolate, NULL };    RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks));    RetainPtr<CGShadingRef> mainShading;    if (o->style()->appearance() == SliderVerticalPart)        mainShading.adoptCF(CGShadingCreateAxial(cspace.get(), CGPointMake(bounds.x(),  bounds.bottom()), CGPointMake(bounds.right(), bounds.bottom()), mainFunction.get(), false, false));    else        mainShading.adoptCF(CGShadingCreateAxial(cspace.get(), CGPointMake(bounds.x(),  bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(), false, false));    IntSize radius(trackRadius, trackRadius);    paintInfo.context->addRoundedRectClip(bounds,        radius, radius,        radius, radius);    CGContextDrawShading(context, mainShading.get());    paintInfo.context->restore();        return false;}void RenderThemeChromiumMac::adjustSliderThumbStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    style->setBoxShadow(0);}static const float verticalSliderHeightPadding = 0.1f;bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    ASSERT(o->parent()->isSlider());    NSSliderCell* sliderThumbCell = o->style()->appearance() == SliderThumbVerticalPart        ? sliderThumbVertical()        : sliderThumbHorizontal();    LocalCurrentGraphicsContext localContext(paintInfo.context);    // Update the various states we respond to.    updateEnabledState(sliderThumbCell, o->parent());    updateFocusedState(sliderThumbCell, o->parent());    // Update the pressed state using the NSCell tracking methods, since that's how NSSliderCell keeps track of it.    bool oldPressed;    if (o->style()->appearance() == SliderThumbVerticalPart)        oldPressed = m_isSliderThumbVerticalPressed;    else        oldPressed = m_isSliderThumbHorizontalPressed;    bool pressed = static_cast<RenderSlider*>(o->parent())->inDragMode();    if (o->style()->appearance() == SliderThumbVerticalPart)        m_isSliderThumbVerticalPressed = pressed;    else        m_isSliderThumbHorizontalPressed = pressed;    if (pressed != oldPressed) {        if (pressed)            [sliderThumbCell startTrackingAt:NSPoint() inView:nil];        else            [sliderThumbCell stopTracking:NSPoint() at:NSPoint() inView:nil mouseIsUp:YES];    }    FloatRect bounds = r;    // Make the height of the vertical slider slightly larger so NSSliderCell will draw a vertical slider.    if (o->style()->appearance() == SliderThumbVerticalPart)        bounds.setHeight(bounds.height() + verticalSliderHeightPadding * o->style()->effectiveZoom());    paintInfo.context->save();    float zoomLevel = o->style()->effectiveZoom();        FloatRect unzoomedRect = bounds;    if (zoomLevel != 1.0f) {        unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);        unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);        paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());        paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));        paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());    }    [sliderThumbCell drawWithFrame:FloatRectToNSRect(unzoomedRect) inView:nil];    [sliderThumbCell setControlView:nil];    paintInfo.context->restore();    return false;}const int sliderThumbWidth = 15;const int sliderThumbHeight = 15;const int mediaSliderThumbWidth = 13;const int mediaSliderThumbHeight = 14;void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const{    float zoomLevel = o->style()->effectiveZoom();    if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->appearance() == SliderThumbVerticalPart) {        o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fixed));        o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel), Fixed));    } else if (o->style()->appearance() == MediaSliderThumbPart) {        o->style()->setWidth(Length(mediaSliderThumbWidth, Fixed));        o->style()->setHeight(Length(mediaSliderThumbHeight, Fixed));    }}bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r){    NSSearchFieldCell* search = this->search();    LocalCurrentGraphicsContext localContext(paintInfo.context);    setSearchCellState(o, r);    paintInfo.context->save();    float zoomLevel = o->style()->effectiveZoom();    IntRect unzoomedRect = r;        if (zoomLevel != 1.0f) {        unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);        unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);        paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());        paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));        paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());    }    // Set the search button to nil before drawing.  Then reset it so we can draw it later.    [search setSearchButtonCell:nil];    [search drawWithFrame:NSRect(IntRectToNSRect(unzoomedRect)) inView:nil];#ifdef BUILDING_ON_TIGER    if ([search showsFirstResponder])        wkDrawTextFieldCellFocusRing(search, NSRect(unzoomedRect));#endif    [search setControlView:nil];    [search resetSearchButtonCell];    paintInfo.context->restore();    return false;}void RenderThemeChromiumMac::setSearchCellState(RenderObject* o, const IntRect& r){    NSSearchFieldCell* search = this->search();    [search setControlSize:controlSizeForFont(o->style())];    // Update the various states we respond to.    updateEnabledState(search, o);    updateFocusedState(search, o);}const IntSize* RenderThemeChromiumMac::searchFieldSizes() const{    static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17) };    return sizes;}void RenderThemeChromiumMac::setSearchFieldSize(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;        // Use the font size to determine the intrinsic width of the control.    setSizeFromFont(style, searchFieldSizes());}void RenderThemeChromiumMac::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const{    // Override border.    style->resetBorder();    const short borderWidth = 2 * style->effectiveZoom();    style->setBorderLeftWidth(borderWidth);    style->setBorderLeftStyle(INSET);    style->setBorderRightWidth(borderWidth);    style->setBorderRightStyle(INSET);    style->setBorderBottomWidth(borderWidth);    style->setBorderBottomStyle(INSET);    style->setBorderTopWidth(borderWidth);    style->setBorder

⌨️ 快捷键说明

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