Source/WebCore/ChangeLog

 12011-11-10 Keishi Hattori <keishi@webkit.org>
 2
 3 Implement combobox appearance
 4 https://bugs.webkit.org/show_bug.cgi?id=72006
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * css/CSSPrimitiveValueMappings.h:
 9 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added ComboBoxPart case.
 10 * css/CSSValueKeywords.in: Added combobox.
 11 * platform/ThemeTypes.h:
 12 * platform/mac/ThemeMac.mm:
 13 (WebCore::comboBoxSizes): Added.
 14 (WebCore::comboBoxMargins): Added.
 15 (WebCore::comboBox): Added. Returns a NSComboButtonCell with a bordered button.
 16 (WebCore::paintComboBox): Added.
 17 (WebCore::ThemeMac::paint): Added ComboBoxPart case.
 18 * rendering/RenderTheme.cpp:
 19 (WebCore::RenderTheme::adjustStyle): Added ComboBoxPart case.
 20 (WebCore::RenderTheme::paint): Added ComboBoxPart case.
 21
1222011-11-09 Kevin Ollivier <kevino@theolliviers.com>
223
324 [wx] Unreviewed build fix. Add stub for new method.

Source/WebCore/css/CSSPrimitiveValueMappings.h

@@template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
329329 case CheckboxPart:
330330 m_value.ident = CSSValueCheckbox;
331331 break;
 332 case ComboBoxPart:
 333 m_value.ident = CSSValueCombobox;
 334 break;
332335 case RadioPart:
333336 m_value.ident = CSSValueRadio;
334337 break;

Source/WebCore/css/CSSValueKeywords.in

@@after-white-space
583583// The order here should match the order in the ControlPart enum in ThemeTypes.h.
584584// All appearance values that should be accepted by the parser should be listed between 'checkbox' and 'textarea':
585585checkbox
 586combobox
586587radio
587588push-button
588589square-button

Source/WebCore/platform/ThemeTypes.h

@@typedef unsigned ControlStates;
4646
4747// Must follow CSSValueKeywords.in order
4848enum ControlPart {
49  NoControlPart, CheckboxPart, RadioPart, PushButtonPart, SquareButtonPart, ButtonPart,
 49 NoControlPart, CheckboxPart, ComboBoxPart, RadioPart, PushButtonPart, SquareButtonPart, ButtonPart,
5050 ButtonBevelPart, DefaultButtonPart, InnerSpinButtonPart, InputSpeechButtonPart, ListButtonPart, ListboxPart, ListItemPart,
5151 MediaFullscreenButtonPart, MediaMuteButtonPart, MediaPlayButtonPart, MediaSeekBackButtonPart,
5252 MediaSeekForwardButtonPart, MediaRewindButtonPart, MediaReturnToRealtimeButtonPart, MediaToggleClosedCaptionsButtonPart,

Source/WebCore/platform/mac/ThemeMac.mm

@@static void paintCheckbox(ControlStates states, GraphicsContext* context, const
282282 END_BLOCK_OBJC_EXCEPTIONS
283283}
284284
 285// ComboBox
 286
 287static const IntSize* comboBoxSizes()
 288{
 289 static const IntSize sizes[3] = { IntSize(19, 21), IntSize(17, 18), IntSize(15, 15) };
 290 return sizes;
 291}
 292// to right bottom left
 293static const int* comboBoxMargins(NSControlSize controlSize)
 294{
 295 static const int margins[3][4] =
 296 {
 297 { 1, 2, 1, 2 },
 298 { 1, 2, 1, 2 },
 299 { 1, 0, 1, 0 },
 300 };
 301 return margins[controlSize];
 302}
 303
 304static NSComboBoxCell *comboBox(ControlStates states, const IntRect& zoomedRect, float zoomFactor)
 305{
 306 static NSComboBoxCell *comboBoxCell;
 307 if (!comboBoxCell) {
 308 comboBoxCell = [[NSComboBoxCell alloc] init];
 309 [comboBoxCell setButtonBordered:YES];
 310 [comboBoxCell setTitle:@""];
 311 }
 312
 313 // Set the control size based off the rectangle we're painting into.
 314 setControlSize(comboBoxCell, comboBoxSizes(), zoomedRect.size(), zoomFactor);
 315
 316 // Update the various states we respond to.
 317 updateStates(comboBoxCell, states);
 318
 319 return comboBoxCell;
 320}
 321
 322static void paintComboBox(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
 323{
 324 BEGIN_BLOCK_OBJC_EXCEPTIONS
 325
 326 // Determine the width and height needed for the control and prepare the cell for painting.
 327 NSComboBoxCell *comboBoxCell = comboBox(states, zoomedRect, zoomFactor);
 328 LocalCurrentGraphicsContext localContext(context);
 329
 330 GraphicsContextStateSaver stateSaver(*context);
 331
 332 NSControlSize controlSize = [comboBoxCell controlSize];
 333 IntSize zoomedSize = comboBoxSizes()[controlSize];
 334 zoomedSize.setWidth(zoomedRect.width()); // Buttons don't ever constrain width, so the zoomed width can just be honored.
 335 zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
 336 IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, comboBoxMargins(controlSize), zoomFactor);
 337
 338 if (zoomFactor != 1.0f) {
 339 inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
 340 inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
 341 context->translate(inflatedRect.x(), inflatedRect.y());
 342 context->scale(FloatSize(zoomFactor, zoomFactor));
 343 context->translate(-inflatedRect.x(), -inflatedRect.y());
 344 }
 345
 346 [comboBoxCell drawWithFrame:NSRect(inflatedRect) inView:ThemeMac::ensuredView(scrollView)];
 347 [comboBoxCell setControlView:nil];
 348
 349 END_BLOCK_OBJC_EXCEPTIONS
 350}
 351
285352// Radio Buttons
286353
287354static const IntSize* radioSizes()

@@void ThemeMac::paint(ControlPart part, ControlStates states, GraphicsContext* co
723790 case CheckboxPart:
724791 paintCheckbox(states, context, zoomedRect, zoomFactor, scrollView);
725792 break;
 793 case ComboBoxPart:
 794 paintComboBox(states, context, zoomedRect, zoomFactor, scrollView);
 795 break;
726796 case RadioPart:
727797 paintRadio(states, context, zoomedRect, zoomFactor, scrollView);
728798 break;

Source/WebCore/rendering/RenderTheme.cpp

@@void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El
102102 switch (part) {
103103 case ListButtonPart:
104104 case CheckboxPart:
 105 case ComboBoxPart:
105106 case InnerSpinButtonPart:
106107 case RadioPart:
107108 case PushButtonPart:

@@bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe
260261#if USE(NEW_THEME)
261262 switch (part) {
262263 case CheckboxPart:
 264 case ComboBoxPart:
263265 case RadioPart:
264266 case PushButtonPart:
265267 case SquareButtonPart: