Changeset 51386 in webkit
- Timestamp:
- Nov 25, 2009 8:50:38 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r51385 r51386 1 2009-11-25 Andrei Popescu <andreip@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 The select elements do not reflect the actual choice the user makes. 6 https://bugs.webkit.org/show_bug.cgi?id=31831 7 8 Handle the drawing of the listboxes in Android code. 9 10 No new features, just fixing an Android problem. Existing layout tests are sufficient. 11 12 * platform/android/RenderThemeAndroid.cpp: 13 (WebCore::theme): 14 (WebCore::RenderThemeAndroid::platformActiveSelectionBackgroundColor): 15 (WebCore::RenderThemeAndroid::platformActiveListBoxSelectionBackgroundColor): 16 (WebCore::RenderThemeAndroid::platformInactiveListBoxSelectionBackgroundColor): 17 (WebCore::RenderThemeAndroid::platformActiveListBoxSelectionForegroundColor): 18 (WebCore::RenderThemeAndroid::platformInactiveListBoxSelectionForegroundColor): 19 (WebCore::RenderThemeAndroid::adjustButtonStyle): 20 (WebCore::RenderThemeAndroid::paintTextArea): 21 (WebCore::RenderThemeAndroid::adjustListboxStyle): 22 * platform/android/RenderThemeAndroid.h: 23 1 24 2009-11-25 Alexander Pavlov <apavlov@chromium.org> 2 25 -
trunk/WebCore/platform/android/RenderThemeAndroid.cpp
r50971 r51386 1 1 /* 2 * Copyright 200 6, The Android Open Source Project2 * Copyright 2009, The Android Open Source Project 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 14 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC.OR16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 17 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, … … 30 30 #include "Element.h" 31 31 #include "GraphicsContext.h" 32 #include "HTMLNames.h" 33 #include "HTMLOptionElement.h" 34 #include "HTMLSelectElement.h" 35 #include "Node.h" 32 36 #include "PlatformGraphicsContext.h" 33 37 #include "RenderSkinAndroid.h" … … 42 46 // of buttons, so that our button images are large enough to properly fit 43 47 // the text. 44 const int BUTTON_PADDING= 18;48 const int buttonPadding = 18; 45 49 46 50 // Add padding to the fontSize of ListBoxes to get their maximum sizes. 47 51 // Listboxes often have a specified size. Since we change them into 48 52 // dropdowns, we want a much smaller height, which encompasses the text. 49 const int LISTBOX_PADDING= 5;53 const int listboxPadding = 5; 50 54 51 55 // This is the color of selection in a textfield. It was obtained by checking 52 56 // the color of selection in TextViews in the system. 53 const RGBA32 SELECTION_COLOR= makeRGB(255, 146, 0);57 const RGBA32 selectionColor = makeRGB(255, 146, 0); 54 58 55 59 static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info) … … 60 64 RenderTheme* theme() 61 65 { 62 static RenderThemeAndroid androidTheme;66 DEFINE_STATIC_LOCAL(RenderThemeAndroid, androidTheme, ()); 63 67 return &androidTheme; 64 68 } … … 98 102 Color RenderThemeAndroid::platformActiveSelectionBackgroundColor() const 99 103 { 100 return Color( SELECTION_COLOR);104 return Color(selectionColor); 101 105 } 102 106 … … 117 121 118 122 Color RenderThemeAndroid::platformTextSearchHighlightColor() const 123 { 124 return Color(Color::transparent); 125 } 126 127 Color RenderThemeAndroid::platformActiveListBoxSelectionBackgroundColor() const 128 { 129 return Color(Color::transparent); 130 } 131 132 Color RenderThemeAndroid::platformInactiveListBoxSelectionBackgroundColor() const 133 { 134 return Color(Color::transparent); 135 } 136 137 Color RenderThemeAndroid::platformActiveListBoxSelectionForegroundColor() const 138 { 139 return Color(Color::transparent); 140 } 141 142 Color RenderThemeAndroid::platformInactiveListBoxSelectionForegroundColor() const 119 143 { 120 144 return Color(Color::transparent); … … 178 202 style->setPaddingLeft(Length(padding, Fixed)); 179 203 style->setPaddingRight(Length(padding, Fixed)); 180 style->setMinHeight(Length(style->fontSize() + BUTTON_PADDING, Fixed));204 style->setMinHeight(Length(style->fontSize() + buttonPadding, Fixed)); 181 205 } 182 206 … … 237 261 bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) 238 262 { 239 if (obj->isMenuList()) 240 return paintCombo(obj, info, rect); 263 if (!obj->isListBox()) 264 return true; 265 266 paintCombo(obj, info, rect); 267 RenderStyle* style = obj->style(); 268 if (style) 269 style->setColor(Color::transparent); 270 Node* node = obj->node(); 271 if (!node || !node->hasTagName(HTMLNames::selectTag)) 272 return true; 273 274 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node); 275 // The first item may be visible. Make sure it does not draw. 276 // If it has a style, it overrides the RenderListBox's style, so we 277 // need to make sure both are set to transparent. 278 node = select->item(0); 279 if (node) { 280 RenderObject* renderer = node->renderer(); 281 if (renderer) { 282 RenderStyle* renderStyle = renderer->style(); 283 if (renderStyle) 284 renderStyle->setColor(Color::transparent); 285 } 286 } 287 // Find the first selected option, and draw its text. 288 // FIXME: In a later change, if there is more than one item selected, 289 // draw a string that says "X items" like iPhone Safari does 290 int index = select->selectedIndex(); 291 node = select->item(index); 292 if (!node || !node->hasTagName(HTMLNames::optionTag)) 293 return true; 294 295 HTMLOptionElement* option = static_cast<HTMLOptionElement*>(node); 296 String label = option->textIndentedToRespectGroupLabel(); 297 SkRect r(rect); 298 299 SkPaint paint; 300 paint.setAntiAlias(true); 301 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); 302 // Values for text size and positioning determined by trial and error 303 paint.setTextSize(r.height() - SkIntToScalar(6)); 304 305 SkCanvas* canvas = getCanvasFromInfo(info); 306 int saveCount = canvas->save(); 307 r.fRight -= SkIntToScalar(RenderSkinCombo::extraWidth()); 308 canvas->clipRect(r); 309 canvas->drawText(label.characters(), label.length() << 1, 310 r.fLeft + SkIntToScalar(5), r.fBottom - SkIntToScalar(5), paint); 311 canvas->restoreToCount(saveCount); 312 241 313 return true; 242 314 } … … 255 327 { 256 328 style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed)); 257 style->setMaxHeight(Length(style->fontSize() + LISTBOX_PADDING, Fixed)); 329 style->setMaxHeight(Length(style->fontSize() + listboxPadding, Fixed)); 330 // Make webkit draw invisible, since it will simply draw the first element 331 style->setColor(Color::transparent); 258 332 addIntrinsicMargins(style); 259 333 } -
trunk/WebCore/platform/android/RenderThemeAndroid.h
r50971 r51386 64 64 virtual Color platformInactiveSelectionForegroundColor() const; 65 65 virtual Color platformTextSearchHighlightColor() const; 66 66 67 virtual Color platformActiveListBoxSelectionBackgroundColor() const; 68 virtual Color platformInactiveListBoxSelectionBackgroundColor() const; 69 virtual Color platformActiveListBoxSelectionForegroundColor() const; 70 virtual Color platformInactiveListBoxSelectionForegroundColor() const; 71 67 72 virtual void systemFont(int, WebCore::FontDescription&) const {} 68 73
Note: See TracChangeset
for help on using the changeset viewer.