| Index: Source/core/layout/LayoutThemeMac.mm
|
| diff --git a/Source/core/layout/LayoutThemeMac.mm b/Source/core/layout/LayoutThemeMac.mm
|
| index f88856577927cc3ede19a88be79b67a17bf70e4a..3f09121fe1bf322e9b1f45181793c57d71626253 100644
|
| --- a/Source/core/layout/LayoutThemeMac.mm
|
| +++ b/Source/core/layout/LayoutThemeMac.mm
|
| @@ -23,33 +23,17 @@
|
|
|
| #import "core/CSSValueKeywords.h"
|
| #import "core/HTMLNames.h"
|
| -#import "core/css/CSSValueList.h"
|
| -#import "core/dom/Document.h"
|
| -#import "core/dom/Element.h"
|
| #import "core/fileapi/FileList.h"
|
| -#import "core/frame/FrameView.h"
|
| -#import "core/html/HTMLInputElement.h"
|
| -#import "core/html/HTMLMediaElement.h"
|
| #import "core/html/HTMLMeterElement.h"
|
| -#import "core/html/TimeRanges.h"
|
| -#import "core/html/shadow/MediaControlElements.h"
|
| -#import "core/layout/LayoutSlider.h"
|
| -#import "core/layout/LayoutMedia.h"
|
| -#import "core/layout/LayoutMediaControls.h"
|
| #import "core/layout/LayoutMeter.h"
|
| #import "core/layout/LayoutProgress.h"
|
| #import "core/layout/LayoutView.h"
|
| -#import "core/paint/PaintInfo.h"
|
| +#import "core/paint/MediaControlsPainter.h"
|
| #import "core/style/AuthorStyleInfo.h"
|
| #import "core/style/ShadowList.h"
|
| #import "platform/LayoutTestSupport.h"
|
| #import "platform/PlatformResourceLoader.h"
|
| -#import "platform/SharedBuffer.h"
|
| -#import "platform/geometry/FloatRoundedRect.h"
|
| #import "platform/graphics/BitmapImage.h"
|
| -#import "platform/graphics/GraphicsContextStateSaver.h"
|
| -#import "platform/graphics/Image.h"
|
| -#import "platform/graphics/ImageBuffer.h"
|
| #import "platform/mac/ColorMac.h"
|
| #import "platform/mac/LocalCurrentGraphicsContext.h"
|
| #import "platform/mac/ThemeMac.h"
|
| @@ -60,18 +44,9 @@
|
| #import <Carbon/Carbon.h>
|
| #import <Cocoa/Cocoa.h>
|
| #import <math.h>
|
| -#import <wtf/RetainPtr.h>
|
| -#import <wtf/StdLibExtras.h>
|
|
|
| // The methods in this file are specific to the Mac OS X platform.
|
|
|
| -// We estimate the animation rate of a Mac OS X progress bar is 33 fps.
|
| -// Hard code the value here because we haven't found API for it.
|
| -const double progressAnimationFrameRate = 0.033;
|
| -
|
| -// Mac OS X progress bar animation seems to have 256 frames.
|
| -const double progressAnimationNumFrames = 256;
|
| -
|
| @interface LayoutThemeNotificationObserver : NSObject
|
| {
|
| blink::LayoutTheme *_theme;
|
| @@ -140,19 +115,13 @@ const double progressAnimationNumFrames = 256;
|
|
|
| @end
|
|
|
| -// Forward declare Mac SPIs.
|
| -extern "C" {
|
| -void _NSDrawCarbonThemeBezel(NSRect frame, BOOL enabled, BOOL flipped);
|
| -// Request for public API: rdar://13787640
|
| -void _NSDrawCarbonThemeListBox(NSRect frame, BOOL enabled, BOOL flipped, BOOL always_yes);
|
| -}
|
| -
|
| namespace blink {
|
|
|
| using namespace HTMLNames;
|
|
|
| LayoutThemeMac::LayoutThemeMac()
|
| : m_notificationObserver(AdoptNS, [[LayoutThemeNotificationObserver alloc] initWithTheme:this])
|
| + , m_painter(*this)
|
| {
|
| [[NSNotificationCenter defaultCenter] addObserver:m_notificationObserver.get()
|
| selector:@selector(systemColorsDidChange:)
|
| @@ -489,8 +458,6 @@ bool LayoutThemeMac::isControlStyled(const ComputedStyle& style, const AuthorSty
|
| return LayoutTheme::isControlStyled(style, authorStyle);
|
| }
|
|
|
| -const int sliderThumbShadowBlur = 1;
|
| -
|
| void LayoutThemeMac::adjustPaintInvalidationRect(const LayoutObject* o, IntRect& r)
|
| {
|
| ControlPart part = o->style()->appearance();
|
| @@ -522,28 +489,6 @@ void LayoutThemeMac::adjustPaintInvalidationRect(const LayoutObject* o, IntRect&
|
| }
|
| }
|
|
|
| -FloatRect LayoutThemeMac::convertToPaintingRect(const LayoutObject* inputLayoutObject, const LayoutObject* partLayoutObject, const FloatRect& inputRect, const IntRect& r) const
|
| -{
|
| - FloatRect partRect(inputRect);
|
| -
|
| - // Compute an offset between the part layoutObject and the input layoutObject.
|
| - FloatSize offsetFromInputLayoutObject;
|
| - const LayoutObject* layoutObject = partLayoutObject;
|
| - while (layoutObject && layoutObject != inputLayoutObject) {
|
| - LayoutObject* containingLayoutObject = layoutObject->container();
|
| - offsetFromInputLayoutObject -= roundedIntSize(layoutObject->offsetFromContainer(containingLayoutObject, LayoutPoint()));
|
| - layoutObject = containingLayoutObject;
|
| - }
|
| - // If the input layoutObject was not a container, something went wrong.
|
| - ASSERT(layoutObject == inputLayoutObject);
|
| - // Move the rect into partLayoutObject's coords.
|
| - partRect.move(offsetFromInputLayoutObject);
|
| - // Account for the local drawing offset (tx, ty).
|
| - partRect.move(r.x(), r.y());
|
| -
|
| - return partRect;
|
| -}
|
| -
|
| void LayoutThemeMac::updateCheckedState(NSCell* cell, const LayoutObject* o)
|
| {
|
| bool oldIndeterminate = [cell state] == NSMixedState;
|
| @@ -594,19 +539,6 @@ NSControlSize LayoutThemeMac::controlSizeForFont(const ComputedStyle& style) con
|
| return NSMiniControlSize;
|
| }
|
|
|
| -// We don't use controlSizeForFont() for search field decorations because it
|
| -// needs to fit into the search field. The font size will already be modified by
|
| -// setFontFromControlSize() called on the search field.
|
| -static NSControlSize searchFieldControlSizeForFont(const ComputedStyle& style)
|
| -{
|
| - int fontSize = style.fontSize();
|
| - if (fontSize >= 13)
|
| - return NSRegularControlSize;
|
| - if (fontSize >= 11)
|
| - return NSSmallControlSize;
|
| - return NSMiniControlSize;
|
| -}
|
| -
|
| void LayoutThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize, float zoomLevel)
|
| {
|
| NSControlSize size;
|
| @@ -684,106 +616,6 @@ NSControlSize LayoutThemeMac::controlSizeForSystemFont(const ComputedStyle& styl
|
| return NSMiniControlSize;
|
| }
|
|
|
| -bool LayoutThemeMac::paintTextField(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| -
|
| -#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
|
| - bool useNSTextFieldCell = o->style()->hasAppearance()
|
| - && o->style()->visitedDependentColor(CSSPropertyBackgroundColor) == Color::white
|
| - && !o->style()->hasBackgroundImage();
|
| -
|
| - // We do not use NSTextFieldCell to draw styled text fields on Lion and
|
| - // SnowLeopard because there are a number of bugs on those platforms that
|
| - // require NSTextFieldCell to be in charge of painting its own
|
| - // background. We need WebCore to paint styled backgrounds, so we'll use
|
| - // this AppKit SPI function instead.
|
| - if (!useNSTextFieldCell) {
|
| - _NSDrawCarbonThemeBezel(r, isEnabled(o) && !isReadOnlyControl(o), YES);
|
| - return false;
|
| - }
|
| -#endif
|
| -
|
| - NSTextFieldCell *textField = this->textField();
|
| -
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - [textField setEnabled:(isEnabled(o) && !isReadOnlyControl(o))];
|
| - [textField drawWithFrame:NSRect(r) inView:documentViewFor(o)];
|
| -
|
| - [textField setControlView:nil];
|
| -
|
| - return false;
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintCapsLockIndicator(LayoutObject*, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - // This draws the caps lock indicator as it was done by
|
| - // WKDrawCapsLockIndicator.
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| - CGContextRef c = localContext.cgContext();
|
| - CGMutablePathRef shape = CGPathCreateMutable();
|
| -
|
| - // To draw the caps lock indicator, draw the shape into a small
|
| - // square that is then scaled to the size of r.
|
| - const CGFloat kSquareSize = 17;
|
| -
|
| - // Create a rounted square shape.
|
| - CGPathMoveToPoint(shape, NULL, 16.5, 4.5);
|
| - CGPathAddArc(shape, NULL, 12.5, 12.5, 4, 0, M_PI_2, false);
|
| - CGPathAddArc(shape, NULL, 4.5, 12.5, 4, M_PI_2, M_PI, false);
|
| - CGPathAddArc(shape, NULL, 4.5, 4.5, 4, M_PI, 3*M_PI/2, false);
|
| - CGPathAddArc(shape, NULL, 12.5, 4.5, 4, 3*M_PI/2, 0, false);
|
| -
|
| - // Draw the arrow - note this is drawing in a flipped coordinate system, so
|
| - // the arrow is pointing down.
|
| - CGPathMoveToPoint(shape, NULL, 8.5, 2); // Tip point.
|
| - CGPathAddLineToPoint(shape, NULL, 4, 7);
|
| - CGPathAddLineToPoint(shape, NULL, 6.25, 7);
|
| - CGPathAddLineToPoint(shape, NULL, 6.25, 10.25);
|
| - CGPathAddLineToPoint(shape, NULL, 10.75, 10.25);
|
| - CGPathAddLineToPoint(shape, NULL, 10.75, 7);
|
| - CGPathAddLineToPoint(shape, NULL, 13, 7);
|
| - CGPathAddLineToPoint(shape, NULL, 8.5, 2);
|
| -
|
| - // Draw the rectangle that underneath (or above in the flipped system) the
|
| - // arrow.
|
| - CGPathAddLineToPoint(shape, NULL, 10.75, 12);
|
| - CGPathAddLineToPoint(shape, NULL, 6.25, 12);
|
| - CGPathAddLineToPoint(shape, NULL, 6.25, 14.25);
|
| - CGPathAddLineToPoint(shape, NULL, 10.75, 14.25);
|
| - CGPathAddLineToPoint(shape, NULL, 10.75, 12);
|
| -
|
| - // Scale and translate the shape.
|
| - CGRect cgr = r;
|
| - CGFloat maxX = CGRectGetMaxX(cgr);
|
| - CGFloat minY = CGRectGetMinY(cgr);
|
| - CGFloat heightScale = r.height() / kSquareSize;
|
| - CGAffineTransform transform = CGAffineTransformMake(
|
| - heightScale, 0, // A B
|
| - 0, heightScale, // C D
|
| - maxX - r.height(), minY); // Tx Ty
|
| -
|
| - CGMutablePathRef paintPath = CGPathCreateMutable();
|
| - CGPathAddPath(paintPath, &transform, shape);
|
| - CGPathRelease(shape);
|
| -
|
| - CGContextSetRGBFillColor(c, 0, 0, 0, 0.4);
|
| - CGContextBeginPath(c);
|
| - CGContextAddPath(c, paintPath);
|
| - CGContextFillPath(c);
|
| - CGPathRelease(paintPath);
|
| -
|
| - return false;
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintTextArea(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| - _NSDrawCarbonThemeListBox(r, isEnabled(o) && !isReadOnlyControl(o), YES, YES);
|
| - return false;
|
| -}
|
| -
|
| const int* LayoutThemeMac::popupButtonMargins() const
|
| {
|
| static const int margins[3][4] =
|
| @@ -812,48 +644,6 @@ const int* LayoutThemeMac::popupButtonPadding(NSControlSize size) const
|
| return padding[size];
|
| }
|
|
|
| -bool LayoutThemeMac::paintMenuList(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - setPopupButtonCellState(o, r);
|
| -
|
| - NSPopUpButtonCell* popupButton = this->popupButton();
|
| -
|
| - float zoomLevel = o->style()->effectiveZoom();
|
| - IntSize size = popupButtonSizes()[[popupButton controlSize]];
|
| - size.setHeight(size.height() * zoomLevel);
|
| - size.setWidth(r.width());
|
| -
|
| - // Now inflate it to account for the shadow.
|
| - IntRect inflatedRect = r;
|
| - if (r.width() >= minimumMenuListSize(o->styleRef()))
|
| - inflatedRect = ThemeMac::inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel);
|
| -
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, ThemeMac::inflateRectForFocusRing(inflatedRect));
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - // On Leopard, the cell will draw outside of the given rect, so we have to
|
| - // clip to the rect.
|
| - paintInfo.context->clip(inflatedRect);
|
| -
|
| - if (zoomLevel != 1.0f) {
|
| - inflatedRect.setWidth(inflatedRect.width() / zoomLevel);
|
| - inflatedRect.setHeight(inflatedRect.height() / zoomLevel);
|
| - paintInfo.context->translate(inflatedRect.x(), inflatedRect.y());
|
| - paintInfo.context->scale(zoomLevel, zoomLevel);
|
| - paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y());
|
| - }
|
| -
|
| - NSView *view = documentViewFor(o);
|
| - [popupButton drawWithFrame:inflatedRect inView:view];
|
| -#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
|
| - if (isFocused(o) && o->style()->outlineStyleIsAuto())
|
| - [popupButton _web_drawFocusRingWithFrame:inflatedRect inView:view];
|
| -#endif
|
| - [popupButton setControlView:nil];
|
| -
|
| - return false;
|
| -}
|
| -
|
| IntSize LayoutThemeMac::meterSizeForBounds(const LayoutMeter* layoutMeter, const IntRect& bounds) const
|
| {
|
| if (NoControlPart == layoutMeter->style()->appearance())
|
| @@ -866,21 +656,6 @@ IntSize LayoutThemeMac::meterSizeForBounds(const LayoutMeter* layoutMeter, const
|
| bounds.height() < cellSize.height ? cellSize.height : bounds.height());
|
| }
|
|
|
| -bool LayoutThemeMac::paintMeter(LayoutObject* layoutObject, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - if (!layoutObject->isMeter())
|
| - return true;
|
| -
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, rect);
|
| -
|
| - NSLevelIndicatorCell* cell = levelIndicatorFor(toLayoutMeter(layoutObject));
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - [cell drawWithFrame:rect inView:documentViewFor(layoutObject)];
|
| - [cell setControlView:nil];
|
| - return false;
|
| -}
|
| -
|
| bool LayoutThemeMac::supportsMeter(ControlPart part) const
|
| {
|
| switch (part) {
|
| @@ -986,110 +761,6 @@ double LayoutThemeMac::animationDurationForProgressBar() const
|
| return progressAnimationNumFrames * progressAnimationFrameRate;
|
| }
|
|
|
| -bool LayoutThemeMac::paintProgressBar(LayoutObject* layoutObject, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - if (!layoutObject->isProgress())
|
| - return true;
|
| -
|
| - float zoomLevel = layoutObject->style()->effectiveZoom();
|
| - NSControlSize controlSize = controlSizeForFont(layoutObject->styleRef());
|
| - IntSize size = progressBarSizes()[controlSize];
|
| - size.setHeight(size.height() * zoomLevel);
|
| - size.setWidth(rect.width());
|
| -
|
| - // Now inflate it to account for the shadow.
|
| - IntRect inflatedRect = rect;
|
| - if (rect.height() <= minimumProgressBarHeight(layoutObject->styleRef()))
|
| - inflatedRect = ThemeMac::inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel);
|
| -
|
| - LayoutProgress* layoutProgress = toLayoutProgress(layoutObject);
|
| - HIThemeTrackDrawInfo trackInfo;
|
| - trackInfo.version = 0;
|
| - if (controlSize == NSRegularControlSize)
|
| - trackInfo.kind = layoutProgress->position() < 0 ? kThemeLargeIndeterminateBar : kThemeLargeProgressBar;
|
| - else
|
| - trackInfo.kind = layoutProgress->position() < 0 ? kThemeMediumIndeterminateBar : kThemeMediumProgressBar;
|
| -
|
| - trackInfo.bounds = IntRect(IntPoint(), inflatedRect.size());
|
| - trackInfo.min = 0;
|
| - trackInfo.max = std::numeric_limits<SInt32>::max();
|
| - trackInfo.value = lround(layoutProgress->position() * nextafter(trackInfo.max, 0));
|
| - trackInfo.trackInfo.progress.phase = lround(layoutProgress->animationProgress() * nextafter(progressAnimationNumFrames, 0));
|
| - trackInfo.attributes = kThemeTrackHorizontal;
|
| - trackInfo.enableState = isActive(layoutObject) ? kThemeTrackActive : kThemeTrackInactive;
|
| - trackInfo.reserved = 0;
|
| - trackInfo.filler1 = 0;
|
| -
|
| - OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect.size());
|
| - if (!imageBuffer)
|
| - return true;
|
| -
|
| - LocalCurrentGraphicsContext localContext(imageBuffer->context(), IntRect(IntPoint(), inflatedRect.size()));
|
| - CGContextRef cgContext = localContext.cgContext();
|
| - HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
|
| -
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - if (!layoutProgress->style()->isLeftToRightDirection()) {
|
| - paintInfo.context->translate(2 * inflatedRect.x() + inflatedRect.width(), 0);
|
| - paintInfo.context->scale(-1, 1);
|
| - }
|
| -
|
| - paintInfo.context->drawImageBuffer(imageBuffer.get(),
|
| - FloatRect(inflatedRect.location(), imageBuffer->size()));
|
| - return false;
|
| -}
|
| -
|
| -const float baseFontSize = 11.0f;
|
| -const float baseArrowHeight = 4.0f;
|
| -const float baseArrowWidth = 5.0f;
|
| -const float baseSpaceBetweenArrows = 2.0f;
|
| -const int arrowPaddingLeft = 6;
|
| -const int arrowPaddingRight = 6;
|
| -const int paddingBeforeSeparator = 4;
|
| -const int baseBorderRadius = 5;
|
| -const int styledPopupPaddingLeft = 8;
|
| -const int styledPopupPaddingTop = 1;
|
| -const int styledPopupPaddingBottom = 2;
|
| -
|
| -bool LayoutThemeMac::paintMenuListButton(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - IntRect bounds = IntRect(r.x() + o->style()->borderLeftWidth(),
|
| - r.y() + o->style()->borderTopWidth(),
|
| - r.width() - o->style()->borderLeftWidth() - o->style()->borderRightWidth(),
|
| - r.height() - o->style()->borderTopWidth() - o->style()->borderBottomWidth());
|
| - // Since we actually know the size of the control here, we restrict the font
|
| - // scale to make sure the arrows will fit vertically in the bounds
|
| - float fontScale = std::min(o->style()->fontSize() / baseFontSize, bounds.height() / (baseArrowHeight * 2 + baseSpaceBetweenArrows));
|
| - float centerY = bounds.y() + bounds.height() / 2.0f;
|
| - float arrowHeight = baseArrowHeight * fontScale;
|
| - float arrowWidth = baseArrowWidth * fontScale;
|
| - float leftEdge = bounds.maxX() - arrowPaddingRight * o->style()->effectiveZoom() - arrowWidth;
|
| - float spaceBetweenArrows = baseSpaceBetweenArrows * fontScale;
|
| -
|
| - if (bounds.width() < arrowWidth + arrowPaddingLeft * o->style()->effectiveZoom())
|
| - return false;
|
| -
|
| - Color color = o->style()->visitedDependentColor(CSSPropertyColor);
|
| -
|
| - FloatPoint arrow1[3];
|
| - arrow1[0] = FloatPoint(leftEdge, centerY - spaceBetweenArrows / 2.0f);
|
| - arrow1[1] = FloatPoint(leftEdge + arrowWidth, centerY - spaceBetweenArrows / 2.0f);
|
| - arrow1[2] = FloatPoint(leftEdge + arrowWidth / 2.0f, centerY - spaceBetweenArrows / 2.0f - arrowHeight);
|
| -
|
| - // Draw the top arrow.
|
| - paintInfo.context->fillPolygon(3, arrow1, color, true);
|
| -
|
| - FloatPoint arrow2[3];
|
| - arrow2[0] = FloatPoint(leftEdge, centerY + spaceBetweenArrows / 2.0f);
|
| - arrow2[1] = FloatPoint(leftEdge + arrowWidth, centerY + spaceBetweenArrows / 2.0f);
|
| - arrow2[2] = FloatPoint(leftEdge + arrowWidth / 2.0f, centerY + spaceBetweenArrows / 2.0f + arrowHeight);
|
| -
|
| - // Draw the bottom arrow.
|
| - paintInfo.context->fillPolygon(3, arrow2, color, true);
|
| - return false;
|
| -}
|
| -
|
| static const IntSize* menuListButtonSizes()
|
| {
|
| static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) };
|
| @@ -1124,7 +795,12 @@ void LayoutThemeMac::adjustMenuListStyle(ComputedStyle& style, Element* e) const
|
| setFontFromControlSize(style, controlSize);
|
| }
|
|
|
| -const int autofillPopupHorizontalPadding = 4;
|
| +static const int autofillPopupHorizontalPadding = 4;
|
| +static const int paddingBeforeSeparator = 4;
|
| +static const int baseBorderRadius = 5;
|
| +static const int styledPopupPaddingLeft = 8;
|
| +static const int styledPopupPaddingTop = 1;
|
| +static const int styledPopupPaddingBottom = 2;
|
|
|
| // These functions are called with MenuListPart or MenulistButtonPart appearance
|
| // by LayoutMenuList, or with TextFieldPart appearance by
|
| @@ -1153,8 +829,8 @@ int LayoutThemeMac::popupInternalPaddingRight(const ComputedStyle& style) const
|
| return popupButtonPadding(controlSizeForFont(style))[ThemeMac::RightMargin] * 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()));
|
| + float arrowWidth = menuListBaseArrowWidth * fontScale;
|
| + return static_cast<int>(ceilf(arrowWidth + (menuListArrowPaddingLeft + menuListArrowPaddingRight + paddingBeforeSeparator) * style.effectiveZoom()));
|
| }
|
| return 0;
|
| }
|
| @@ -1218,198 +894,6 @@ int LayoutThemeMac::minimumMenuListSize(const ComputedStyle& style) const
|
| return sizeForSystemFont(style, menuListSizes()).width();
|
| }
|
|
|
| -const int sliderTrackWidth = 5;
|
| -const int sliderTrackBorderWidth = 1;
|
| -
|
| -bool LayoutThemeMac::paintSliderTrack(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - paintSliderTicks(o, paintInfo, r);
|
| -
|
| - float zoomLevel = o->style()->effectiveZoom();
|
| - FloatRect unzoomedRect = r;
|
| -
|
| - if (o->style()->appearance() == SliderHorizontalPart || o->style()->appearance() == MediaSliderPart) {
|
| - unzoomedRect.setY(ceilf(unzoomedRect.y() + unzoomedRect.height() / 2 - zoomLevel * sliderTrackWidth / 2));
|
| - unzoomedRect.setHeight(zoomLevel * sliderTrackWidth);
|
| - } else if (o->style()->appearance() == SliderVerticalPart) {
|
| - unzoomedRect.setX(ceilf(unzoomedRect.x() + unzoomedRect.width() / 2 - zoomLevel * sliderTrackWidth / 2));
|
| - unzoomedRect.setWidth(zoomLevel * sliderTrackWidth);
|
| - }
|
| -
|
| - if (zoomLevel != 1) {
|
| - unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
|
| - unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
|
| - }
|
| -
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| - if (zoomLevel != 1) {
|
| - paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
|
| - paintInfo.context->scale(zoomLevel, zoomLevel);
|
| - paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
|
| - }
|
| -
|
| - Color fillColor(205, 205, 205);
|
| - Color borderGradientTopColor(109, 109, 109);
|
| - Color borderGradientBottomColor(181, 181, 181);
|
| - Color shadowColor(0, 0, 0, 118);
|
| -
|
| - if (!isEnabled(o)) {
|
| - Color tintColor(255, 255, 255, 128);
|
| - fillColor = fillColor.blend(tintColor);
|
| - borderGradientTopColor = borderGradientTopColor.blend(tintColor);
|
| - borderGradientBottomColor = borderGradientBottomColor.blend(tintColor);
|
| - shadowColor = shadowColor.blend(tintColor);
|
| - }
|
| -
|
| - Color tintColor;
|
| - if (!isEnabled(o))
|
| - tintColor = Color(255, 255, 255, 128);
|
| -
|
| - bool isVerticalSlider = o->style()->appearance() == SliderVerticalPart;
|
| -
|
| - int fillRadiusSize = (sliderTrackWidth - sliderTrackBorderWidth) / 2;
|
| - IntSize fillRadius(fillRadiusSize, fillRadiusSize);
|
| - IntRect fillBounds = enclosedIntRect(unzoomedRect);
|
| - FloatRoundedRect fillRect(fillBounds, fillRadius, fillRadius, fillRadius, fillRadius);
|
| - paintInfo.context->fillRoundedRect(fillRect, fillColor);
|
| -
|
| - IntSize shadowOffset(isVerticalSlider ? 1 : 0,
|
| - isVerticalSlider ? 0 : 1);
|
| - int shadowBlur = 3;
|
| - int shadowSpread = 0;
|
| - paintInfo.context->save();
|
| - paintInfo.context->drawInnerShadow(fillRect, shadowColor, shadowOffset, shadowBlur, shadowSpread);
|
| - paintInfo.context->restore();
|
| -
|
| - RefPtr<Gradient> borderGradient = Gradient::create(fillBounds.minXMinYCorner(),
|
| - isVerticalSlider ? fillBounds.maxXMinYCorner() : fillBounds.minXMaxYCorner());
|
| - borderGradient->addColorStop(0.0, borderGradientTopColor);
|
| - borderGradient->addColorStop(1.0, borderGradientBottomColor);
|
| - Path borderPath;
|
| - FloatRect borderRect(unzoomedRect);
|
| - borderRect.inflate(-sliderTrackBorderWidth / 2.0);
|
| - float borderRadiusSize = (isVerticalSlider ? borderRect.width() : borderRect.height()) / 2;
|
| - FloatSize borderRadius(borderRadiusSize, borderRadiusSize);
|
| - borderPath.addRoundedRect(borderRect, borderRadius, borderRadius, borderRadius, borderRadius);
|
| - paintInfo.context->setStrokeGradient(borderGradient);
|
| - paintInfo.context->setStrokeThickness(sliderTrackBorderWidth);
|
| - paintInfo.context->strokePath(borderPath);
|
| - return false;
|
| -}
|
| -
|
| -const int sliderThumbWidth = 15;
|
| -const int sliderThumbHeight = 15;
|
| -const int sliderThumbBorderWidth = 1;
|
| -
|
| -bool LayoutThemeMac::paintSliderThumb(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| - float zoomLevel = o->style()->effectiveZoom();
|
| -
|
| - FloatRect unzoomedRect(r.x(), r.y(), sliderThumbWidth, sliderThumbHeight);
|
| - if (zoomLevel != 1.0f) {
|
| - paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
|
| - paintInfo.context->scale(zoomLevel, zoomLevel);
|
| - paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
|
| - }
|
| -
|
| - Color fillGradientTopColor(250, 250, 250);
|
| - Color fillGradientUpperMiddleColor(244, 244, 244);
|
| - Color fillGradientLowerMiddleColor(236, 236, 236);
|
| - Color fillGradientBottomColor(238, 238, 238);
|
| - Color borderGradientTopColor(151, 151, 151);
|
| - Color borderGradientBottomColor(128, 128, 128);
|
| - Color shadowColor(0, 0, 0, 36);
|
| -
|
| - if (!isEnabled(o)) {
|
| - Color tintColor(255, 255, 255, 128);
|
| - fillGradientTopColor = fillGradientTopColor.blend(tintColor);
|
| - fillGradientUpperMiddleColor = fillGradientUpperMiddleColor.blend(tintColor);
|
| - fillGradientLowerMiddleColor = fillGradientLowerMiddleColor.blend(tintColor);
|
| - fillGradientBottomColor = fillGradientBottomColor.blend(tintColor);
|
| - borderGradientTopColor = borderGradientTopColor.blend(tintColor);
|
| - borderGradientBottomColor = borderGradientBottomColor.blend(tintColor);
|
| - shadowColor = shadowColor.blend(tintColor);
|
| - } else if (isPressed(o)) {
|
| - Color tintColor(0, 0, 0, 32);
|
| - fillGradientTopColor = fillGradientTopColor.blend(tintColor);
|
| - fillGradientUpperMiddleColor = fillGradientUpperMiddleColor.blend(tintColor);
|
| - fillGradientLowerMiddleColor = fillGradientLowerMiddleColor.blend(tintColor);
|
| - fillGradientBottomColor = fillGradientBottomColor.blend(tintColor);
|
| - borderGradientTopColor = borderGradientTopColor.blend(tintColor);
|
| - borderGradientBottomColor = borderGradientBottomColor.blend(tintColor);
|
| - shadowColor = shadowColor.blend(tintColor);
|
| - }
|
| -
|
| - FloatRect borderBounds = unzoomedRect;
|
| - borderBounds.inflate(sliderThumbBorderWidth / 2.0);
|
| -
|
| - borderBounds.inflate(-sliderThumbBorderWidth);
|
| - FloatSize shadowOffset(0, 1);
|
| - paintInfo.context->setShadow(shadowOffset, sliderThumbShadowBlur, shadowColor);
|
| - paintInfo.context->setFillColor(Color::black);
|
| - paintInfo.context->fillEllipse(borderBounds);
|
| - paintInfo.context->clearShadow();
|
| -
|
| - IntRect fillBounds = enclosedIntRect(unzoomedRect);
|
| - RefPtr<Gradient> fillGradient = Gradient::create(fillBounds.minXMinYCorner(), fillBounds.minXMaxYCorner());
|
| - fillGradient->addColorStop(0.0, fillGradientTopColor);
|
| - fillGradient->addColorStop(0.52, fillGradientUpperMiddleColor);
|
| - fillGradient->addColorStop(0.52, fillGradientLowerMiddleColor);
|
| - fillGradient->addColorStop(1.0, fillGradientBottomColor);
|
| - paintInfo.context->setFillGradient(fillGradient);
|
| - paintInfo.context->fillEllipse(borderBounds);
|
| -
|
| - RefPtr<Gradient> borderGradient = Gradient::create(fillBounds.minXMinYCorner(), fillBounds.minXMaxYCorner());
|
| - borderGradient->addColorStop(0.0, borderGradientTopColor);
|
| - borderGradient->addColorStop(1.0, borderGradientBottomColor);
|
| - paintInfo.context->setStrokeGradient(borderGradient);
|
| - paintInfo.context->setStrokeThickness(sliderThumbBorderWidth);
|
| - paintInfo.context->strokeEllipse(borderBounds);
|
| -
|
| - if (isFocused(o)) {
|
| - Path borderPath;
|
| - borderPath.addEllipse(borderBounds);
|
| - paintInfo.context->drawFocusRing(borderPath, 5, -2, focusRingColor());
|
| - }
|
| -
|
| - return false;
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintSearchField(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| -
|
| - NSSearchFieldCell* search = this->search();
|
| - setSearchCellState(o, r);
|
| - [search setControlSize:searchFieldControlSizeForFont(o->styleRef())];
|
| -
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - 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(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(unzoomedRect) inView:documentViewFor(o)];
|
| -
|
| - [search setControlView:nil];
|
| - [search resetSearchButtonCell];
|
| -
|
| - return false;
|
| -}
|
| -
|
| void LayoutThemeMac::setSearchCellState(LayoutObject* o, const IntRect&)
|
| {
|
| NSSearchFieldCell* search = this->search();
|
| @@ -1476,63 +960,6 @@ void LayoutThemeMac::adjustSearchFieldStyle(ComputedStyle& style, Element*) cons
|
| style.setBoxShadow(nullptr);
|
| }
|
|
|
| -bool LayoutThemeMac::paintSearchFieldCancelButton(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - if (!o->node())
|
| - return false;
|
| - Element* input = o->node()->shadowHost();
|
| - if (!input)
|
| - input = toElement(o->node());
|
| -
|
| - if (!input->layoutObject()->isBox())
|
| - return false;
|
| -
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - float zoomLevel = o->style()->effectiveZoom();
|
| - FloatRect 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(zoomLevel, zoomLevel);
|
| - paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
|
| - }
|
| -
|
| - Color fillColor(200, 200, 200);
|
| -
|
| - if (isPressed(o)) {
|
| - Color tintColor(0, 0, 0, 32);
|
| - fillColor = fillColor.blend(tintColor);
|
| - }
|
| -
|
| - float centerX = unzoomedRect.x() + unzoomedRect.width() / 2;
|
| - float centerY = unzoomedRect.y() + unzoomedRect.height() / 2;
|
| - // The line width is 3px on a regular sized, high DPI NSCancelButtonCell
|
| - // (which is 28px wide).
|
| - float lineWidth = unzoomedRect.width() * 3 / 28;
|
| - // The line length is 16px on a regular sized, high DPI NSCancelButtonCell.
|
| - float lineLength = unzoomedRect.width() * 16 / 28;
|
| -
|
| - Path xPath;
|
| - FloatSize lineRectRadius(lineWidth / 2, lineWidth / 2);
|
| - xPath.addRoundedRect(FloatRect(-lineLength / 2, -lineWidth / 2, lineLength, lineWidth),
|
| - lineRectRadius, lineRectRadius, lineRectRadius, lineRectRadius);
|
| - xPath.addRoundedRect(FloatRect(-lineWidth / 2, -lineLength / 2, lineWidth, lineLength),
|
| - lineRectRadius, lineRectRadius, lineRectRadius, lineRectRadius);
|
| -
|
| - paintInfo.context->translate(centerX, centerY);
|
| - paintInfo.context->rotate(deg2rad(45.0));
|
| - paintInfo.context->clipOut(xPath);
|
| - paintInfo.context->rotate(deg2rad(-45.0));
|
| - paintInfo.context->translate(-centerX, -centerY);
|
| -
|
| - paintInfo.context->setFillColor(fillColor);
|
| - paintInfo.context->fillEllipse(unzoomedRect);
|
| -
|
| - return false;
|
| -}
|
| -
|
| const IntSize* LayoutThemeMac::cancelButtonSizes() const
|
| {
|
| static const IntSize sizes[3] = { IntSize(14, 14), IntSize(11, 11), IntSize(9, 9) };
|
| @@ -1563,11 +990,6 @@ void LayoutThemeMac::adjustSearchFieldDecorationStyle(ComputedStyle& style, Elem
|
| style.setBoxShadow(nullptr);
|
| }
|
|
|
| -bool LayoutThemeMac::paintSearchFieldDecoration(LayoutObject*, const PaintInfo&, const IntRect&)
|
| -{
|
| - return false;
|
| -}
|
| -
|
| void LayoutThemeMac::adjustSearchFieldResultsDecorationStyle(ComputedStyle& style, Element*) const
|
| {
|
| IntSize size = sizeForSystemFont(style, resultsButtonSizes());
|
| @@ -1576,43 +998,6 @@ void LayoutThemeMac::adjustSearchFieldResultsDecorationStyle(ComputedStyle& styl
|
| style.setBoxShadow(nullptr);
|
| }
|
|
|
| -bool LayoutThemeMac::paintSearchFieldResultsDecoration(LayoutObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| -{
|
| - if (!o->node())
|
| - return false;
|
| - Node* input = o->node()->shadowHost();
|
| - if (!input)
|
| - input = o->node();
|
| - if (!input->layoutObject()->isBox())
|
| - return false;
|
| -
|
| - GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| -
|
| - float zoomLevel = o->style()->effectiveZoom();
|
| - FloatRect unzoomedRect(r);
|
| - if (zoomLevel != 1) {
|
| - unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
|
| - unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
|
| - paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
|
| - paintInfo.context->scale(zoomLevel, zoomLevel);
|
| - paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
|
| - }
|
| -
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| -
|
| - NSSearchFieldCell* search = this->search();
|
| - setSearchCellState(input->layoutObject(), r);
|
| - [search setControlSize:searchFieldControlSizeForFont(o->styleRef())];
|
| - if ([search searchMenuTemplate] != nil)
|
| - [search setSearchMenuTemplate:nil];
|
| -
|
| - updateActiveState([search searchButtonCell], o);
|
| -
|
| - [[search searchButtonCell] drawWithFrame:unzoomedRect inView:documentViewFor(o)];
|
| - [[search searchButtonCell] setControlView:nil];
|
| - return false;
|
| -}
|
| -
|
| IntSize LayoutThemeMac::sliderTickSize() const
|
| {
|
| return IntSize(1, 3);
|
| @@ -1764,27 +1149,7 @@ bool LayoutThemeMac::shouldShowPlaceholderWhenFocused() const
|
|
|
| void LayoutThemeMac::adjustMediaSliderThumbSize(ComputedStyle& style) const
|
| {
|
| - LayoutMediaControls::adjustMediaSliderThumbSize(style);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaPlayButton(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaOverlayPlayButton(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaOverlayPlayButton, object, paintInfo, rect);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaMuteButton(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaSliderTrack(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaSlider, object, paintInfo, rect);
|
| + MediaControlsPainter::adjustMediaSliderThumbSize(style);
|
| }
|
|
|
| String LayoutThemeMac::extraFullScreenStyleSheet()
|
| @@ -1801,46 +1166,6 @@ String LayoutThemeMac::extraDefaultStyleSheet()
|
| loadResourceAsASCIIString("themeMac.css");
|
| }
|
|
|
| -bool LayoutThemeMac::paintMediaVolumeSliderContainer(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return true;
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaVolumeSliderTrack(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaVolumeSliderThumb(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaSliderThumb(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect);
|
| -}
|
| -
|
| -String LayoutThemeMac::formatMediaControlsTime(float time) const
|
| -{
|
| - return LayoutMediaControls::formatMediaControlsTime(time);
|
| -}
|
| -
|
| -String LayoutThemeMac::formatMediaControlsCurrentTime(float currentTime, float duration) const
|
| -{
|
| - return LayoutMediaControls::formatMediaControlsCurrentTime(currentTime, duration);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaFullscreenButton(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaEnterFullscreenButton, object, paintInfo, rect);
|
| -}
|
| -
|
| -bool LayoutThemeMac::paintMediaToggleClosedCaptionsButton(LayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect)
|
| -{
|
| - return LayoutMediaControls::paintMediaControlsPart(MediaShowClosedCaptionsButton, object, paintInfo, rect);
|
| -}
|
| -
|
| bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const
|
| {
|
| ControlPart part = style.appearance();
|
|
|