Changeset 54215 in webkit
- Timestamp:
- Feb 2, 2010 12:52:18 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54213 r54215 1 2010-02-02 Avi Drissman <avi@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Sync up Chromium Mac render theme to Mac render theme 6 https://bugs.webkit.org/show_bug.cgi?id=34340 7 8 Covered by existing layout tests. 9 10 * platform/chromium/ThemeChromiumMac.mm: 11 (WebCore::updateStates): 12 (WebCore::checkbox): 13 (WebCore::paintCheckbox): 14 (WebCore::radio): 15 (WebCore::paintRadio): 16 (WebCore::listButtonSizes): 17 (WebCore::setupButtonCell): 18 (WebCore::button): 19 (WebCore::paintButton): 20 (WebCore::ThemeChromiumMac::controlSize): 21 (WebCore::ThemeChromiumMac::minimumControlSize): 22 (WebCore::ThemeChromiumMac::controlBorder): 23 (WebCore::ThemeChromiumMac::paint): 24 * rendering/RenderThemeChromiumMac.h: 25 * rendering/RenderThemeChromiumMac.mm: 26 (-[WebCoreRenderThemeNotificationObserver initWithTheme:WebCore::]): 27 (WebCore::convertNSColorToColor): 28 (WebCore::RenderThemeChromiumMac::systemColor): 29 (WebCore::RenderThemeChromiumMac::isControlStyled): 30 (WebCore::RenderThemeChromiumMac::adjustRepaintRect): 31 (WebCore::RenderThemeChromiumMac::convertToPaintingRect): 32 (WebCore::RenderThemeChromiumMac::paintCapsLockIndicator): 33 (WebCore::RenderThemeChromiumMac::paintMenuList): 34 (WebCore::RenderThemeChromiumMac::paintMenuListButton): 35 (WebCore::RenderThemeChromiumMac::adjustMenuListStyle): 36 (WebCore::RenderThemeChromiumMac::adjustMenuListButtonStyle): 37 (WebCore::RenderThemeChromiumMac::paintSliderTrack): 38 (WebCore::RenderThemeChromiumMac::paintSliderThumb): 39 (WebCore::RenderThemeChromiumMac::paintSearchField): 40 (WebCore::RenderThemeChromiumMac::setSearchFieldSize): 41 (WebCore::RenderThemeChromiumMac::adjustSearchFieldStyle): 42 (WebCore::RenderThemeChromiumMac::paintSearchFieldResultsButton): 43 (WebCore::RenderThemeChromiumMac::adjustSliderThumbSize): 44 (WebCore::RenderThemeChromiumMac::popupButton): 45 (WebCore::RenderThemeChromiumMac::sliderThumbHorizontal): 46 (WebCore::RenderThemeChromiumMac::sliderThumbVertical): 47 1 48 2010-02-02 Kwang Yul Seo <skyul@company100.net> 2 49 -
trunk/WebCore/platform/chromium/ThemeChromiumMac.mm
r48469 r54215 22 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 … … 116 116 { 117 117 // Hover state is not supported by Aqua. 118 118 119 119 // Pressed state 120 120 bool oldPressed = [cell isHighlighted]; … … 122 122 if (pressed != oldPressed) 123 123 [cell setHighlighted:pressed]; 124 124 125 125 // Enabled state 126 126 bool oldEnabled = [cell isEnabled]; … … 128 128 if (enabled != oldEnabled) 129 129 [cell setEnabled:enabled]; 130 130 131 131 // Focused state 132 132 bool oldFocused = [cell showsFirstResponder]; … … 142 142 if (oldIndeterminate != indeterminate || checked != oldChecked) 143 143 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSOffState)]; 144 144 145 145 // Window Inactive state 146 146 NSControlTint oldTint = [cell controlTint]; … … 198 198 } 199 199 200 static NSButtonCell *checkbox(ControlStates states, const IntRect& zoomedRect, float zoomFactor)201 { 202 static NSButtonCell *checkboxCell;200 static NSButtonCell *checkbox(ControlStates states, const IntRect& zoomedRect, float zoomFactor) 201 { 202 static NSButtonCell *checkboxCell; 203 203 if (!checkboxCell) { 204 204 checkboxCell = [[NSButtonCell alloc] init]; … … 208 208 [checkboxCell setFocusRingType:NSFocusRingTypeExterior]; 209 209 } 210 210 211 211 // Set the control size based off the rectangle we're painting into. 212 212 setControlSize(checkboxCell, checkboxSizes(), zoomedRect.size(), zoomFactor); … … 214 214 // Update the various states we respond to. 215 215 updateStates(checkboxCell, states); 216 216 217 217 return checkboxCell; 218 218 } … … 224 224 225 225 // Determine the width and height needed for the control and prepare the cell for painting. 226 NSButtonCell *checkboxCell = checkbox(states, zoomedRect, zoomFactor);226 NSButtonCell *checkboxCell = checkbox(states, zoomedRect, zoomFactor); 227 227 228 228 context->save(); … … 233 233 zoomedSize.setHeight(zoomedSize.height() * zoomFactor); 234 234 IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, checkboxMargins(controlSize), zoomFactor); 235 235 236 236 if (zoomFactor != 1.0f) { 237 237 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); … … 241 241 context->translate(-inflatedRect.x(), -inflatedRect.y()); 242 242 } 243 243 244 244 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:FlippedView()]; 245 245 [checkboxCell setControlView:nil]; 246 246 247 247 context->restore(); 248 248 249 249 END_BLOCK_OBJC_EXCEPTIONS 250 250 } … … 279 279 } 280 280 281 static NSButtonCell *radio(ControlStates states, const IntRect& zoomedRect, float zoomFactor)282 { 283 static NSButtonCell *radioCell;281 static NSButtonCell *radio(ControlStates states, const IntRect& zoomedRect, float zoomFactor) 282 { 283 static NSButtonCell *radioCell; 284 284 if (!radioCell) { 285 285 radioCell = [[NSButtonCell alloc] init]; … … 288 288 [radioCell setFocusRingType:NSFocusRingTypeExterior]; 289 289 } 290 290 291 291 // Set the control size based off the rectangle we're painting into. 292 292 setControlSize(radioCell, radioSizes(), zoomedRect.size(), zoomFactor); … … 294 294 // Update the various states we respond to. 295 295 updateStates(radioCell, states); 296 296 297 297 return radioCell; 298 298 } … … 301 301 { 302 302 // Determine the width and height needed for the control and prepare the cell for painting. 303 NSButtonCell *radioCell = radio(states, zoomedRect, zoomFactor);303 NSButtonCell *radioCell = radio(states, zoomedRect, zoomFactor); 304 304 305 305 context->save(); … … 310 310 zoomedSize.setHeight(zoomedSize.height() * zoomFactor); 311 311 IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, radioMargins(controlSize), zoomFactor); 312 312 313 313 if (zoomFactor != 1.0f) { 314 314 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); … … 318 318 context->translate(-inflatedRect.x(), -inflatedRect.y()); 319 319 } 320 320 321 321 BEGIN_BLOCK_OBJC_EXCEPTIONS 322 322 [radioCell drawWithFrame:NSRect(inflatedRect) inView:FlippedView()]; … … 335 335 return sizes; 336 336 } 337 338 #if ENABLE(DATALIST) 339 static const IntSize* listButtonSizes() 340 { 341 static const IntSize sizes[3] = { IntSize(21, 21), IntSize(19, 18), IntSize(17, 16) }; 342 return sizes; 343 } 344 #endif 337 345 338 346 static const int* buttonMargins(NSControlSize controlSize) … … 347 355 } 348 356 349 static NSButtonCell* button(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor) 350 { 351 static NSButtonCell *buttonCell; 352 static bool defaultButton; 357 static void setupButtonCell(NSButtonCell *&buttonCell, ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor) 358 { 353 359 if (!buttonCell) { 354 360 buttonCell = [[NSButtonCell alloc] init]; 355 361 [buttonCell setTitle:nil]; 356 362 [buttonCell setButtonType:NSMomentaryPushInButton]; 363 if (states & DefaultState) 364 [buttonCell setKeyEquivalent:@"\r"]; 357 365 } 358 366 359 367 // Set the control size based off the rectangle we're painting into. 368 const IntSize* sizes = buttonSizes(); 369 #if ENABLE(DATALIST) 370 if (part == ListButtonPart) { 371 [buttonCell setBezelStyle:NSRoundedDisclosureBezelStyle]; 372 sizes = listButtonSizes(); 373 } else 374 #endif 360 375 if (part == SquareButtonPart || zoomedRect.height() > buttonSizes()[NSRegularControlSize].height() * zoomFactor) { 361 376 // Use the square button … … 365 380 [buttonCell setBezelStyle:NSRoundedBezelStyle]; 366 381 367 setControlSize(buttonCell, buttonSizes(), zoomedRect.size(), zoomFactor); 368 369 if (defaultButton != (states & DefaultState)) { 370 defaultButton = !defaultButton; 371 [buttonCell setKeyEquivalent:(defaultButton ? @"\r" : @"")]; 372 } 382 setControlSize(buttonCell, sizes, zoomedRect.size(), zoomFactor); 373 383 374 384 // Update the various states we respond to. 375 385 updateStates(buttonCell, states); 376 377 return buttonCell; 386 } 387 388 static NSButtonCell *button(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor) 389 { 390 bool isDefault = states & DefaultState; 391 static NSButtonCell *cells[2]; 392 setupButtonCell(cells[isDefault], part, states, zoomedRect, zoomFactor); 393 return cells[isDefault]; 378 394 } 379 395 … … 381 397 { 382 398 BEGIN_BLOCK_OBJC_EXCEPTIONS 383 399 384 400 // Determine the width and height needed for the control and prepare the cell for painting. 385 401 NSButtonCell *buttonCell = button(part, states, zoomedRect, zoomFactor); … … 387 403 388 404 NSControlSize controlSize = [buttonCell controlSize]; 405 #if ENABLE(DATALIST) 406 IntSize zoomedSize = (part == ListButtonPart ? listButtonSizes() : buttonSizes())[controlSize]; 407 #else 389 408 IntSize zoomedSize = buttonSizes()[controlSize]; 409 #endif 390 410 zoomedSize.setWidth(zoomedRect.width()); // Buttons don't ever constrain width, so the zoomed width can just be honored. 391 411 zoomedSize.setHeight(zoomedSize.height() * zoomFactor); … … 408 428 context->translate(-inflatedRect.x(), -inflatedRect.y()); 409 429 } 410 } 430 } 411 431 412 432 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:FlippedView()]; … … 454 474 // Height is reset to auto so that specified heights can be ignored. 455 475 return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, buttonSizes()); 476 #if ENABLE(DATALIST) 477 case ListButtonPart: 478 return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, listButtonSizes()); 479 #endif 456 480 default: 457 481 return zoomedSize; … … 465 489 case DefaultButtonPart: 466 490 case ButtonPart: 491 case ListButtonPart: 467 492 return LengthSize(Length(0, Fixed), Length(static_cast<int>(15 * zoomFactor), Fixed)); 468 493 default: … … 477 502 case DefaultButtonPart: 478 503 case ButtonPart: 504 case ListButtonPart: 479 505 return LengthBox(0, zoomedBox.right().value(), 0, zoomedBox.left().value()); 480 506 default: … … 560 586 case ButtonPart: 561 587 case SquareButtonPart: 588 case ListButtonPart: 562 589 paintButton(part, states, context, zoomedRect, zoomFactor, scrollView); 563 590 break; -
trunk/WebCore/rendering/RenderThemeChromiumMac.h
r49259 r54215 192 192 193 193 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; 194 bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);195 194 }; 196 195 -
trunk/WebCore/rendering/RenderThemeChromiumMac.mm
r50781 r54215 42 42 #import "RenderView.h" 43 43 #import "SharedBuffer.h" 44 #import " UserAgentStyleSheets.h"44 #import "TimeRanges.h" 45 45 #import "WebCoreSystemInterface.h" 46 46 #import "UserAgentStyleSheets.h" … … 79 79 // The methods in this file are specific to the Mac OS X platform. 80 80 81 // FIXME: The platform-independent code in this class should be factored out and merged with RenderThemeSafari. 81 // FIXME: The platform-independent code in this class should be factored out and merged with RenderThemeSafari. 82 82 83 83 @interface WebCoreRenderThemeNotificationObserver : NSObject … … 97 97 [super init]; 98 98 _theme = theme; 99 99 100 100 return self; 101 101 } … … 323 323 } 324 324 325 // This conversion above can fail if the NSColor in question is an NSPatternColor 325 // This conversion above can fail if the NSColor in question is an NSPatternColor 326 326 // (as many system colors are). These colors are actually a repeating pattern 327 327 // not just a solid color. To work around this we simply draw a 1x1 image of … … 391 391 if (m_systemColorCache.contains(cssValueId)) 392 392 return m_systemColorCache.get(cssValueId); 393 393 394 394 Color color; 395 395 switch (cssValueId) { … … 505 505 if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart || style->appearance() == ListboxPart) 506 506 return style->border() != border; 507 507 508 508 // FIXME: This is horrible, but there is not much else that can be done. Menu lists cannot draw properly when 509 509 // scaled. They can't really draw properly when transformed either. We can't detect the transform case at style … … 519 519 { 520 520 ControlPart part = o->style()->appearance(); 521 521 522 522 #if USE(NEW_THEME) 523 523 switch (part) { … … 526 526 case PushButtonPart: 527 527 case SquareButtonPart: 528 case ListButtonPart: 528 529 case DefaultButtonPart: 529 530 case ButtonPart: … … 566 567 { 567 568 FloatRect partRect(inputRect); 568 569 569 570 // Compute an offset between the part renderer and the input renderer 570 571 FloatSize offsetFromInputRenderer; … … 761 762 LocalCurrentGraphicsContext localContext(paintInfo.context); 762 763 wkDrawCapsLockIndicator(paintInfo.context->platformContext(), r); 763 764 764 765 return false; 765 766 } … … 821 822 822 823 paintInfo.context->save(); 823 824 824 825 #ifndef BUILDING_ON_TIGER 825 826 // On Leopard, the cell will draw outside of the given rect, so we have to clip to the rect … … 981 982 if (bounds.width() < arrowWidth + arrowPaddingLeft * o->style()->effectiveZoom()) 982 983 return false; 983 984 984 985 paintInfo.context->save(); 985 986 986 paintInfo.context->setFillColor(o->style()->color(), DeviceColorSpace);987 paintInfo.context->setFillColor(o->style()->color(), o->style()->colorSpace()); 987 988 paintInfo.context->setStrokeStyle(NoStroke); 988 989 … … 1037 1038 style->resetBorder(); 1038 1039 style->resetPadding(); 1039 1040 1040 1041 // Height is locked to auto. 1041 1042 style->setHeight(Length(Auto)); … … 1107 1108 const int minHeight = 15; 1108 1109 style->setMinHeight(Length(minHeight, Fixed)); 1109 1110 1110 1111 style->setLineHeight(RenderStyle::initialLineHeight()); 1111 1112 } … … 1137 1138 } 1138 1139 1140 const int trackWidth = 5; 1141 const int trackRadius = 2; 1142 1139 1143 void RenderThemeChromiumMac::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const 1140 1144 { … … 1144 1148 bool RenderThemeChromiumMac::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 1145 1149 { 1146 static const int trackWidth = 5;1147 static const int trackRadius = 2;1148 1149 1150 IntRect bounds = r; 1150 1151 float zoomLevel = o->style()->effectiveZoom(); … … 1180 1181 CGContextDrawShading(context, mainShading.get()); 1181 1182 paintInfo.context->restore(); 1182 1183 1183 1184 return false; 1184 1185 } … … 1202 1203 1203 1204 // Update the various states we respond to. 1204 updateActiveState(sliderThumbCell, o );1205 updateActiveState(sliderThumbCell, o->parent()); 1205 1206 updateEnabledState(sliderThumbCell, o->parent()); 1206 1207 updateFocusedState(sliderThumbCell, o->parent()); … … 1234 1235 paintInfo.context->save(); 1235 1236 float zoomLevel = o->style()->effectiveZoom(); 1236 1237 1237 1238 FloatRect unzoomedRect = bounds; 1238 1239 if (zoomLevel != 1.0f) { … … 1252 1253 } 1253 1254 1254 void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const1255 {1256 static const int sliderThumbWidth = 15;1257 static const int sliderThumbHeight = 15;1258 1259 float zoomLevel = o->style()->effectiveZoom();1260 if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->appearance() == SliderThumbVerticalPart) {1261 o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fixed));1262 o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel), Fixed));1263 }1264 1265 #if ENABLE(VIDEO)1266 RenderMediaControlsChromium::adjustMediaSliderThumbSize(o);1267 #endif1268 }1269 1270 1255 bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 1271 1256 { … … 1280 1265 1281 1266 IntRect unzoomedRect = r; 1282 1267 1283 1268 if (zoomLevel != 1.0f) { 1284 1269 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); … … 1329 1314 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) 1330 1315 return; 1331 1316 1332 1317 // Use the font size to determine the intrinsic width of the control. 1333 1318 setSizeFromFont(style, searchFieldSizes()); … … 1346 1331 style->setBorderBottomStyle(INSET); 1347 1332 style->setBorderTopWidth(borderWidth); 1348 style->setBorderTopStyle(INSET); 1349 1333 style->setBorderTopStyle(INSET); 1334 1350 1335 // Override height. 1351 1336 style->setHeight(Length(Auto)); 1352 1337 setSearchFieldSize(style); 1353 1338 1354 1339 // Override padding size to match AppKit text positioning. 1355 1340 const int padding = 1 * style->effectiveZoom(); … … 1358 1343 style->setPaddingTop(Length(padding, Fixed)); 1359 1344 style->setPaddingBottom(Length(padding, Fixed)); 1360 1345 1361 1346 NSControlSize controlSize = controlSizeForFont(style); 1362 1347 setFontFromControlSize(selector, style, controlSize); … … 1496 1481 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(input->renderBox()->borderBoxRect())]; 1497 1482 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); 1498 1483 1499 1484 IntRect unzoomedRect(localBounds); 1500 1485 if (zoomLevel != 1.0f) { … … 1508 1493 [[search searchButtonCell] drawWithFrame:unzoomedRect inView:FlippedView()]; 1509 1494 [[search searchButtonCell] setControlView:nil]; 1510 1495 1511 1496 paintInfo.context->restore(); 1512 1497 1513 1498 return false; 1499 } 1500 1501 const int sliderThumbWidth = 15; 1502 const int sliderThumbHeight = 15; 1503 1504 void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const 1505 { 1506 float zoomLevel = o->style()->effectiveZoom(); 1507 if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->appearance() == SliderThumbVerticalPart) { 1508 o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fixed)); 1509 o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel), Fixed)); 1510 } 1511 1512 #if ENABLE(VIDEO) 1513 RenderMediaControlsChromium::adjustMediaSliderThumbSize(o); 1514 #endif 1514 1515 } 1515 1516 … … 1554 1555 return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect); 1555 1556 } 1556 1557 1557 1558 String RenderThemeChromiumMac::extraMediaControlsStyleSheet() 1558 1559 { … … 1569 1570 [m_popupButton.get() setFocusRingType:NSFocusRingTypeExterior]; 1570 1571 } 1571 1572 1572 1573 return m_popupButton.get(); 1573 1574 } … … 1603 1604 [m_sliderThumbHorizontal.get() setFocusRingType:NSFocusRingTypeExterior]; 1604 1605 } 1605 1606 1606 1607 return m_sliderThumbHorizontal.get(); 1607 1608 } … … 1616 1617 [m_sliderThumbVertical.get() setFocusRingType:NSFocusRingTypeExterior]; 1617 1618 } 1618 1619 1619 1620 return m_sliderThumbVertical.get(); 1620 1621 }
Note: See TracChangeset
for help on using the changeset viewer.