diff options
Diffstat (limited to 'WebCore/platform/android/RenderThemeAndroid.cpp')
-rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.cpp | 113 |
1 files changed, 57 insertions, 56 deletions
diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp index 4dafae2..4c5cff5 100644 --- a/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/WebCore/platform/android/RenderThemeAndroid.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, The Android Open Source Project + * Copyright 2009, The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -45,16 +45,16 @@ namespace WebCore { // Add a constant amount of padding to the textsize to get the final height // of buttons, so that our button images are large enough to properly fit // the text. -const int BUTTON_PADDING = 18; +const int buttonPadding = 18; // Add padding to the fontSize of ListBoxes to get their maximum sizes. // Listboxes often have a specified size. Since we change them into // dropdowns, we want a much smaller height, which encompasses the text. -const int LISTBOX_PADDING = 5; +const int listboxPadding = 5; // This is the color of selection in a textfield. It was obtained by checking // the color of selection in TextViews in the system. -const RGBA32 SELECTION_COLOR = makeRGB(255, 146, 0); +const RGBA32 selectionColor = makeRGB(255, 146, 0); static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info) { @@ -63,7 +63,7 @@ static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info) RenderTheme* theme() { - static RenderThemeAndroid androidTheme; + DEFINE_STATIC_LOCAL(RenderThemeAndroid, androidTheme, ()); return &androidTheme; } @@ -101,7 +101,7 @@ bool RenderThemeAndroid::stateChanged(RenderObject* obj, ControlState state) con Color RenderThemeAndroid::platformActiveSelectionBackgroundColor() const { - return Color(SELECTION_COLOR); + return Color(selectionColor); } Color RenderThemeAndroid::platformInactiveSelectionBackgroundColor() const @@ -201,7 +201,7 @@ void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style const int padding = 8; style->setPaddingLeft(Length(padding, Fixed)); style->setPaddingRight(Length(padding, Fixed)); - style->setMinHeight(Length(style->fontSize() + BUTTON_PADDING, Fixed)); + style->setMinHeight(Length(style->fontSize() + buttonPadding, Fixed)); } bool RenderThemeAndroid::paintCheckbox(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) @@ -260,55 +260,56 @@ void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* sty bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - if (obj->isListBox()) { - paintCombo(obj, info, rect); - RenderStyle* style = obj->style(); - if (style) - style->setColor(Color::transparent); - Node* node = obj->node(); - if (!node || !node->hasTagName(HTMLNames::selectTag)) { - return true; - } - HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node); - // The first item may be visible. Make sure it does not draw. - // If it has a style, it overrides the RenderListBox's style, so we - // need to make sure both are set to transparent. - node = select->item(0); - if (node) { - RenderObject* renderer = node->renderer(); - if (renderer) { - RenderStyle* renderStyle = renderer->style(); - if (renderStyle) - renderStyle->setColor(Color::transparent); - } - } - // Find the first selected option, and draw its text. - // FIXME: In a later change, if there is more than one item selected, - // draw a string that says "X items" like iPhone Safari does - int index = select->selectedIndex(); - node = select->item(index); - if (!node || !node->hasTagName(HTMLNames::optionTag)) { - return true; + if (!obj->isListBox()) + return true; + + paintCombo(obj, info, rect); + RenderStyle* style = obj->style(); + if (style) + style->setColor(Color::transparent); + Node* node = obj->node(); + if (!node || !node->hasTagName(HTMLNames::selectTag)) + return true; + + HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node); + // The first item may be visible. Make sure it does not draw. + // If it has a style, it overrides the RenderListBox's style, so we + // need to make sure both are set to transparent. + node = select->item(0); + if (node) { + RenderObject* renderer = node->renderer(); + if (renderer) { + RenderStyle* renderStyle = renderer->style(); + if (renderStyle) + renderStyle->setColor(Color::transparent); } - HTMLOptionElement* option = static_cast<HTMLOptionElement*>(node); - String label = option->textIndentedToRespectGroupLabel(); - SkRect r(rect); - - SkPaint paint; - paint.setAntiAlias(true); - paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); - // Values for text size and positioning determined by trial and error - paint.setTextSize(r.height() - SkIntToScalar(6)); - - SkCanvas* canvas = getCanvasFromInfo(info); - int saveCount = canvas->save(); - r.fRight -= SkIntToScalar(RenderSkinCombo::extraWidth()); - canvas->clipRect(r); - canvas->drawText(label.characters(), label.length() << 1, - r.fLeft + SkIntToScalar(5), r.fBottom - SkIntToScalar(5), - paint); - canvas->restoreToCount(saveCount); } + // Find the first selected option, and draw its text. + // FIXME: In a later change, if there is more than one item selected, + // draw a string that says "X items" like iPhone Safari does + int index = select->selectedIndex(); + node = select->item(index); + if (!node || !node->hasTagName(HTMLNames::optionTag)) + return true; + + HTMLOptionElement* option = static_cast<HTMLOptionElement*>(node); + String label = option->textIndentedToRespectGroupLabel(); + SkRect r(rect); + + SkPaint paint; + paint.setAntiAlias(true); + paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); + // Values for text size and positioning determined by trial and error + paint.setTextSize(r.height() - SkIntToScalar(6)); + + SkCanvas* canvas = getCanvasFromInfo(info); + int saveCount = canvas->save(); + r.fRight -= SkIntToScalar(RenderSkinCombo::extraWidth()); + canvas->clipRect(r); + canvas->drawText(label.characters(), label.length() << 1, + r.fLeft + SkIntToScalar(5), r.fBottom - SkIntToScalar(5), paint); + canvas->restoreToCount(saveCount); + return true; } @@ -325,7 +326,7 @@ bool RenderThemeAndroid::paintSearchField(RenderObject*, const RenderObject::Pai void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed)); - style->setMaxHeight(Length(style->fontSize() + LISTBOX_PADDING, Fixed)); + style->setMaxHeight(Length(style->fontSize() + listboxPadding, Fixed)); // Make webkit draw invisible, since it will simply draw the first element style->setColor(Color::transparent); addIntrinsicMargins(style); |