| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Google, Inc. | 3 * Copyright (C) 2008, 2009 Google, Inc. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 ThemePainterMac::ThemePainterMac(LayoutThemeMac& layoutTheme, Theme* platformThe
me) | 52 ThemePainterMac::ThemePainterMac(LayoutThemeMac& layoutTheme, Theme* platformThe
me) |
| 53 : ThemePainter(platformTheme) | 53 : ThemePainter(platformTheme) |
| 54 , m_layoutTheme(layoutTheme) | 54 , m_layoutTheme(layoutTheme) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool ThemePainterMac::paintTextField(const LayoutObject& o, const PaintInfo& pai
ntInfo, const IntRect& r) | 58 bool ThemePainterMac::paintTextField(const LayoutObject& o, const PaintInfo& pai
ntInfo, const IntRect& r) |
| 59 { | 59 { |
| 60 LocalCurrentGraphicsContext localContext(paintInfo.context, &paintInfo.cullR
ect().m_rect, r); | 60 LocalCurrentGraphicsContext localContext(paintInfo.context, r); |
| 61 | 61 |
| 62 #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 | 62 #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 |
| 63 bool useNSTextFieldCell = o.styleRef().hasAppearance() | 63 bool useNSTextFieldCell = o.styleRef().hasAppearance() |
| 64 && o.styleRef().visitedDependentColor(CSSPropertyBackgroundColor) == Col
or::white | 64 && o.styleRef().visitedDependentColor(CSSPropertyBackgroundColor) == Col
or::white |
| 65 && !o.styleRef().hasBackgroundImage(); | 65 && !o.styleRef().hasBackgroundImage(); |
| 66 | 66 |
| 67 // We do not use NSTextFieldCell to draw styled text fields on Lion and | 67 // We do not use NSTextFieldCell to draw styled text fields on Lion and |
| 68 // SnowLeopard because there are a number of bugs on those platforms that | 68 // SnowLeopard because there are a number of bugs on those platforms that |
| 69 // require NSTextFieldCell to be in charge of painting its own | 69 // require NSTextFieldCell to be in charge of painting its own |
| 70 // background. We need WebCore to paint styled backgrounds, so we'll use | 70 // background. We need WebCore to paint styled backgrounds, so we'll use |
| (...skipping 13 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 [textField setControlView:nil]; | 85 [textField setControlView:nil]; |
| 86 | 86 |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool ThemePainterMac::paintCapsLockIndicator(const LayoutObject&, const PaintInf
o& paintInfo, const IntRect& r) | 90 bool ThemePainterMac::paintCapsLockIndicator(const LayoutObject&, const PaintInf
o& paintInfo, const IntRect& r) |
| 91 { | 91 { |
| 92 // This draws the caps lock indicator as it was done by | 92 // This draws the caps lock indicator as it was done by |
| 93 // WKDrawCapsLockIndicator. | 93 // WKDrawCapsLockIndicator. |
| 94 LocalCurrentGraphicsContext localContext(paintInfo.context, &paintInfo.cullR
ect().m_rect, r); | 94 LocalCurrentGraphicsContext localContext(paintInfo.context, r); |
| 95 CGContextRef c = localContext.cgContext(); | 95 CGContextRef c = localContext.cgContext(); |
| 96 CGMutablePathRef shape = CGPathCreateMutable(); | 96 CGMutablePathRef shape = CGPathCreateMutable(); |
| 97 | 97 |
| 98 // To draw the caps lock indicator, draw the shape into a small | 98 // To draw the caps lock indicator, draw the shape into a small |
| 99 // square that is then scaled to the size of r. | 99 // square that is then scaled to the size of r. |
| 100 const CGFloat kSquareSize = 17; | 100 const CGFloat kSquareSize = 17; |
| 101 | 101 |
| 102 // Create a rounted square shape. | 102 // Create a rounted square shape. |
| 103 CGPathMoveToPoint(shape, NULL, 16.5, 4.5); | 103 CGPathMoveToPoint(shape, NULL, 16.5, 4.5); |
| 104 CGPathAddArc(shape, NULL, 12.5, 12.5, 4, 0, M_PI_2, false); | 104 CGPathAddArc(shape, NULL, 12.5, 12.5, 4, 0, M_PI_2, false); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 CGContextBeginPath(c); | 143 CGContextBeginPath(c); |
| 144 CGContextAddPath(c, paintPath); | 144 CGContextAddPath(c, paintPath); |
| 145 CGContextFillPath(c); | 145 CGContextFillPath(c); |
| 146 CGPathRelease(paintPath); | 146 CGPathRelease(paintPath); |
| 147 | 147 |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool ThemePainterMac::paintTextArea(const LayoutObject& o, const PaintInfo& pain
tInfo, const IntRect& r) | 151 bool ThemePainterMac::paintTextArea(const LayoutObject& o, const PaintInfo& pain
tInfo, const IntRect& r) |
| 152 { | 152 { |
| 153 LocalCurrentGraphicsContext localContext(paintInfo.context, &paintInfo.cullR
ect().m_rect, r); | 153 LocalCurrentGraphicsContext localContext(paintInfo.context, r); |
| 154 _NSDrawCarbonThemeListBox(r, LayoutTheme::isEnabled(o) && !LayoutTheme::isRe
adOnlyControl(o), YES, YES); | 154 _NSDrawCarbonThemeListBox(r, LayoutTheme::isEnabled(o) && !LayoutTheme::isRe
adOnlyControl(o), YES, YES); |
| 155 return false; | 155 return false; |
| 156 } | 156 } |
| 157 | 157 |
| 158 bool ThemePainterMac::paintMenuList(const LayoutObject& o, const PaintInfo& pain
tInfo, const IntRect& r) | 158 bool ThemePainterMac::paintMenuList(const LayoutObject& o, const PaintInfo& pain
tInfo, const IntRect& r) |
| 159 { | 159 { |
| 160 m_layoutTheme.setPopupButtonCellState(o, r); | 160 m_layoutTheme.setPopupButtonCellState(o, r); |
| 161 | 161 |
| 162 NSPopUpButtonCell* popupButton = m_layoutTheme.popupButton(); | 162 NSPopUpButtonCell* popupButton = m_layoutTheme.popupButton(); |
| 163 | 163 |
| 164 float zoomLevel = o.styleRef().effectiveZoom(); | 164 float zoomLevel = o.styleRef().effectiveZoom(); |
| 165 IntSize size = m_layoutTheme.popupButtonSizes()[[popupButton controlSize]]; | 165 IntSize size = m_layoutTheme.popupButtonSizes()[[popupButton controlSize]]; |
| 166 size.setHeight(size.height() * zoomLevel); | 166 size.setHeight(size.height() * zoomLevel); |
| 167 size.setWidth(r.width()); | 167 size.setWidth(r.width()); |
| 168 | 168 |
| 169 // Now inflate it to account for the shadow. | 169 // Now inflate it to account for the shadow. |
| 170 IntRect inflatedRect = r; | 170 IntRect inflatedRect = r; |
| 171 if (r.width() >= m_layoutTheme.minimumMenuListSize(o.styleRef())) | 171 if (r.width() >= m_layoutTheme.minimumMenuListSize(o.styleRef())) |
| 172 inflatedRect = ThemeMac::inflateRect(inflatedRect, size, m_layoutTheme.p
opupButtonMargins(), zoomLevel); | 172 inflatedRect = ThemeMac::inflateRect(inflatedRect, size, m_layoutTheme.p
opupButtonMargins(), zoomLevel); |
| 173 | 173 |
| 174 LocalCurrentGraphicsContext localContext(paintInfo.context, &paintInfo.cullR
ect().m_rect, ThemeMac::inflateRectForFocusRing(inflatedRect)); | 174 LocalCurrentGraphicsContext localContext(paintInfo.context, ThemeMac::inflat
eRectForFocusRing(inflatedRect)); |
| 175 | 175 |
| 176 if (zoomLevel != 1.0f) { | 176 if (zoomLevel != 1.0f) { |
| 177 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | 177 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); |
| 178 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | 178 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); |
| 179 paintInfo.context.translate(inflatedRect.x(), inflatedRect.y()); | 179 paintInfo.context.translate(inflatedRect.x(), inflatedRect.y()); |
| 180 paintInfo.context.scale(zoomLevel, zoomLevel); | 180 paintInfo.context.scale(zoomLevel, zoomLevel); |
| 181 paintInfo.context.translate(-inflatedRect.x(), -inflatedRect.y()); | 181 paintInfo.context.translate(-inflatedRect.x(), -inflatedRect.y()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 NSView *view = m_layoutTheme.documentViewFor(o); | 184 NSView *view = m_layoutTheme.documentViewFor(o); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 trackInfo.attributes = kThemeTrackHorizontal; | 222 trackInfo.attributes = kThemeTrackHorizontal; |
| 223 trackInfo.enableState = LayoutTheme::isActive(layoutObject) ? kThemeTrackAct
ive : kThemeTrackInactive; | 223 trackInfo.enableState = LayoutTheme::isActive(layoutObject) ? kThemeTrackAct
ive : kThemeTrackInactive; |
| 224 trackInfo.reserved = 0; | 224 trackInfo.reserved = 0; |
| 225 trackInfo.filler1 = 0; | 225 trackInfo.filler1 = 0; |
| 226 | 226 |
| 227 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect.size()); | 227 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect.size()); |
| 228 if (!imageBuffer) | 228 if (!imageBuffer) |
| 229 return true; | 229 return true; |
| 230 | 230 |
| 231 IntRect clipRect = IntRect(IntPoint(), inflatedRect.size()); | 231 IntRect clipRect = IntRect(IntPoint(), inflatedRect.size()); |
| 232 LocalCurrentGraphicsContext localContext(imageBuffer->canvas(), 1, &clipRect
, clipRect); | 232 LocalCurrentGraphicsContext localContext(imageBuffer->canvas(), 1, clipRect)
; |
| 233 CGContextRef cgContext = localContext.cgContext(); | 233 CGContextRef cgContext = localContext.cgContext(); |
| 234 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); | 234 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); |
| 235 | 235 |
| 236 GraphicsContextStateSaver stateSaver(paintInfo.context); | 236 GraphicsContextStateSaver stateSaver(paintInfo.context); |
| 237 | 237 |
| 238 if (!layoutProgress.styleRef().isLeftToRightDirection()) { | 238 if (!layoutProgress.styleRef().isLeftToRightDirection()) { |
| 239 paintInfo.context.translate(2 * inflatedRect.x() + inflatedRect.width(),
0); | 239 paintInfo.context.translate(2 * inflatedRect.x() + inflatedRect.width(),
0); |
| 240 paintInfo.context.scale(-1, 1); | 240 paintInfo.context.scale(-1, 1); |
| 241 } | 241 } |
| 242 | 242 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 int fontSize = style.fontSize(); | 444 int fontSize = style.fontSize(); |
| 445 if (fontSize >= 13) | 445 if (fontSize >= 13) |
| 446 return NSRegularControlSize; | 446 return NSRegularControlSize; |
| 447 if (fontSize >= 11) | 447 if (fontSize >= 11) |
| 448 return NSSmallControlSize; | 448 return NSSmallControlSize; |
| 449 return NSMiniControlSize; | 449 return NSMiniControlSize; |
| 450 } | 450 } |
| 451 | 451 |
| 452 bool ThemePainterMac::paintSearchField(const LayoutObject& o, const PaintInfo& p
aintInfo, const IntRect& r) | 452 bool ThemePainterMac::paintSearchField(const LayoutObject& o, const PaintInfo& p
aintInfo, const IntRect& r) |
| 453 { | 453 { |
| 454 LocalCurrentGraphicsContext localContext(paintInfo.context, &paintInfo.cullR
ect().m_rect, r); | 454 LocalCurrentGraphicsContext localContext(paintInfo.context, r); |
| 455 | 455 |
| 456 NSSearchFieldCell* search = m_layoutTheme.search(); | 456 NSSearchFieldCell* search = m_layoutTheme.search(); |
| 457 m_layoutTheme.setSearchCellState(o, r); | 457 m_layoutTheme.setSearchCellState(o, r); |
| 458 [search setControlSize:searchFieldControlSizeForFont(o.styleRef())]; | 458 [search setControlSize:searchFieldControlSizeForFont(o.styleRef())]; |
| 459 | 459 |
| 460 GraphicsContextStateSaver stateSaver(paintInfo.context); | 460 GraphicsContextStateSaver stateSaver(paintInfo.context); |
| 461 | 461 |
| 462 float zoomLevel = o.styleRef().effectiveZoom(); | 462 float zoomLevel = o.styleRef().effectiveZoom(); |
| 463 | 463 |
| 464 IntRect unzoomedRect = r; | 464 IntRect unzoomedRect = r; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 float zoomLevel = o.styleRef().effectiveZoom(); | 560 float zoomLevel = o.styleRef().effectiveZoom(); |
| 561 FloatRect unzoomedRect(r); | 561 FloatRect unzoomedRect(r); |
| 562 if (zoomLevel != 1) { | 562 if (zoomLevel != 1) { |
| 563 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 563 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 564 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 564 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 565 paintInfo.context.translate(unzoomedRect.x(), unzoomedRect.y()); | 565 paintInfo.context.translate(unzoomedRect.x(), unzoomedRect.y()); |
| 566 paintInfo.context.scale(zoomLevel, zoomLevel); | 566 paintInfo.context.scale(zoomLevel, zoomLevel); |
| 567 paintInfo.context.translate(-unzoomedRect.x(), -unzoomedRect.y()); | 567 paintInfo.context.translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 568 } | 568 } |
| 569 | 569 |
| 570 LocalCurrentGraphicsContext localContext(paintInfo.context, &paintInfo.cullR
ect().m_rect, r); | 570 LocalCurrentGraphicsContext localContext(paintInfo.context, r); |
| 571 | 571 |
| 572 NSSearchFieldCell* search = m_layoutTheme.search(); | 572 NSSearchFieldCell* search = m_layoutTheme.search(); |
| 573 m_layoutTheme.setSearchCellState(*input->layoutObject(), r); | 573 m_layoutTheme.setSearchCellState(*input->layoutObject(), r); |
| 574 [search setControlSize:searchFieldControlSizeForFont(o.styleRef())]; | 574 [search setControlSize:searchFieldControlSizeForFont(o.styleRef())]; |
| 575 if ([search searchMenuTemplate] != nil) | 575 if ([search searchMenuTemplate] != nil) |
| 576 [search setSearchMenuTemplate:nil]; | 576 [search setSearchMenuTemplate:nil]; |
| 577 | 577 |
| 578 m_layoutTheme.updateActiveState([search searchButtonCell], o); | 578 m_layoutTheme.updateActiveState([search searchButtonCell], o); |
| 579 | 579 |
| 580 [[search searchButtonCell] drawWithFrame:unzoomedRect inView:m_layoutTheme.d
ocumentViewFor(o)]; | 580 [[search searchButtonCell] drawWithFrame:unzoomedRect inView:m_layoutTheme.d
ocumentViewFor(o)]; |
| 581 [[search searchButtonCell] setControlView:nil]; | 581 [[search searchButtonCell] setControlView:nil]; |
| 582 return false; | 582 return false; |
| 583 } | 583 } |
| 584 | 584 |
| 585 } // namespace blink | 585 } // namespace blink |
| OLD | NEW |