[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

benm at google.com benm at google.com
Wed Apr 7 23:57:05 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 3e70d975610cc95b722eaa53dae2d0ad6046ec0e
Author: benm at google.com <benm at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 25 16:50:38 2009 +0000

    The select elements do not reflect the actual choice the user makes.
    https://bugs.webkit.org/show_bug.cgi?id=31831
    
    Patch by Andrei Popescu <andreip at google.com> on 2009-11-25
    Reviewed by Dimitri Glazkov.
    
    Handle the drawing of the listboxes in Android code.
    
    No new features, just fixing an Android problem. Existing layout tests are sufficient.
    
    * platform/android/RenderThemeAndroid.cpp:
    (WebCore::theme):
    (WebCore::RenderThemeAndroid::platformActiveSelectionBackgroundColor):
    (WebCore::RenderThemeAndroid::platformActiveListBoxSelectionBackgroundColor):
    (WebCore::RenderThemeAndroid::platformInactiveListBoxSelectionBackgroundColor):
    (WebCore::RenderThemeAndroid::platformActiveListBoxSelectionForegroundColor):
    (WebCore::RenderThemeAndroid::platformInactiveListBoxSelectionForegroundColor):
    (WebCore::RenderThemeAndroid::adjustButtonStyle):
    (WebCore::RenderThemeAndroid::paintTextArea):
    (WebCore::RenderThemeAndroid::adjustListboxStyle):
    * platform/android/RenderThemeAndroid.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51386 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f0fae05..199603c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2009-11-25  Andrei Popescu  <andreip at google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        The select elements do not reflect the actual choice the user makes.
+        https://bugs.webkit.org/show_bug.cgi?id=31831
+
+        Handle the drawing of the listboxes in Android code.
+
+        No new features, just fixing an Android problem. Existing layout tests are sufficient.
+
+        * platform/android/RenderThemeAndroid.cpp:
+        (WebCore::theme):
+        (WebCore::RenderThemeAndroid::platformActiveSelectionBackgroundColor):
+        (WebCore::RenderThemeAndroid::platformActiveListBoxSelectionBackgroundColor):
+        (WebCore::RenderThemeAndroid::platformInactiveListBoxSelectionBackgroundColor):
+        (WebCore::RenderThemeAndroid::platformActiveListBoxSelectionForegroundColor):
+        (WebCore::RenderThemeAndroid::platformInactiveListBoxSelectionForegroundColor):
+        (WebCore::RenderThemeAndroid::adjustButtonStyle):
+        (WebCore::RenderThemeAndroid::paintTextArea):
+        (WebCore::RenderThemeAndroid::adjustListboxStyle):
+        * platform/android/RenderThemeAndroid.h:
+
 2009-11-25  Alexander Pavlov  <apavlov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp
index ff20014..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
@@ -29,6 +29,10 @@
 #include "Color.h"
 #include "Element.h"
 #include "GraphicsContext.h"
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "HTMLSelectElement.h"
+#include "Node.h"
 #include "PlatformGraphicsContext.h"
 #include "RenderSkinAndroid.h"
 #include "RenderSkinButton.h"
@@ -41,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)
 {
@@ -59,7 +63,7 @@ static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info)
 
 RenderTheme* theme()
 {
-    static RenderThemeAndroid androidTheme;
+    DEFINE_STATIC_LOCAL(RenderThemeAndroid, androidTheme, ());
     return &androidTheme;
 }
 
@@ -97,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
@@ -120,6 +124,26 @@ Color RenderThemeAndroid::platformTextSearchHighlightColor() const
     return Color(Color::transparent);
 }
 
+Color RenderThemeAndroid::platformActiveListBoxSelectionBackgroundColor() const
+{
+    return Color(Color::transparent);
+}
+
+Color RenderThemeAndroid::platformInactiveListBoxSelectionBackgroundColor() const
+{
+    return Color(Color::transparent);
+}
+
+Color RenderThemeAndroid::platformActiveListBoxSelectionForegroundColor() const
+{
+    return Color(Color::transparent);
+}
+
+Color RenderThemeAndroid::platformInactiveListBoxSelectionForegroundColor() const
+{
+    return Color(Color::transparent);
+}
+
 int RenderThemeAndroid::baselinePosition(const RenderObject* obj) const
 {
     // From the description of this function in RenderTheme.h:
@@ -177,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)
@@ -236,8 +260,56 @@ void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* sty
 
 bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect)
 {
-    if (obj->isMenuList())
-        return paintCombo(obj, info, rect);
+    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);
+        }
+    }
+    // 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;    
 }
 
@@ -254,7 +326,9 @@ 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);
 }
 
diff --git a/WebCore/platform/android/RenderThemeAndroid.h b/WebCore/platform/android/RenderThemeAndroid.h
index 2e54302..ae1213c 100644
--- a/WebCore/platform/android/RenderThemeAndroid.h
+++ b/WebCore/platform/android/RenderThemeAndroid.h
@@ -63,7 +63,12 @@ public:
     virtual Color platformActiveSelectionForegroundColor() const;
     virtual Color platformInactiveSelectionForegroundColor() const;
     virtual Color platformTextSearchHighlightColor() const;
-    
+
+    virtual Color platformActiveListBoxSelectionBackgroundColor() const;
+    virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
+    virtual Color platformActiveListBoxSelectionForegroundColor() const;
+    virtual Color platformInactiveListBoxSelectionForegroundColor() const;
+
     virtual void systemFont(int, WebCore::FontDescription&) const {}
 
     virtual int minimumMenuListSize(RenderStyle*) const { return 0; }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list