summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.cpp70
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.h1
-rw-r--r--Source/WebKit/Android.mk1
-rw-r--r--Source/WebKit/android/RenderSkinAndroid.cpp1
-rw-r--r--Source/WebKit/android/RenderSkinRadio.cpp113
-rw-r--r--Source/WebKit/android/RenderSkinRadio.h61
6 files changed, 65 insertions, 182 deletions
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
index 5f40ede..585dce5 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
@@ -40,7 +40,6 @@
#include "RenderSkinAndroid.h"
#include "RenderSkinCombo.h"
#include "RenderSkinMediaButton.h"
-#include "RenderSkinRadio.h"
#include "RoundedIntRect.h"
#include "SkCanvas.h"
#include "UserAgentStyleSheets.h"
@@ -67,16 +66,27 @@ const RGBA32 selectionColor = makeRGB(181, 224, 136);
const RGBA32 defaultBgColor = makeRGBA(204, 204, 204, 197);
const RGBA32 defaultBgBright = makeRGBA(213, 213, 213, 221);
const RGBA32 defaultBgDark = makeRGBA(92, 92, 92, 160);
+const RGBA32 defaultBgMedium = makeRGBA(132, 132, 132, 111);
const RGBA32 defaultFgColor = makeRGBA(101, 101, 101, 225);
+const RGBA32 defaultCheckColor = makeRGBA(154, 204, 2, 255);
const RGBA32 disabledBgColor = makeRGBA(205, 205, 205, 107);
const RGBA32 disabledBgBright = makeRGBA(213, 213, 213, 133);
const RGBA32 disabledBgDark = makeRGBA(92, 92, 92, 96);
+const RGBA32 disabledBgMedium = makeRGBA(132, 132, 132, 111);
const RGBA32 disabledFgColor = makeRGBA(148, 148, 148, 137);
const int paddingButton = 2;
const int cornerButton = 2;
+// scale factors for various resolutions
+const float scaleFactor[RenderSkinAndroid::ResolutionCount] = {
+ 1.0f, // medium res
+ 1.5f, // high res
+ 2.0f // extra high res
+};
+
+
static SkCanvas* getCanvasFromInfo(const PaintInfo& info)
{
return info.context->platformContext()->mCanvas;
@@ -180,7 +190,7 @@ int RenderThemeAndroid::baselinePosition(const RenderObject* obj) const
// controls that need to do this.
//
// Our checkboxes and radio buttons need to be offset to line up properly.
- return RenderTheme::baselinePosition(obj) - 2;
+ return RenderTheme::baselinePosition(obj) - 8;
}
void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const
@@ -228,7 +238,7 @@ void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style
bool RenderThemeAndroid::paintCheckbox(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
- RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, true);
+ paintRadio(obj, info, rect);
return false;
}
@@ -244,15 +254,17 @@ bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, c
IntRect innerrect = IntRect(rect.x() + paddingButton, rect.y() + paddingButton,
rect.width() - 2 * paddingButton, rect.height() - 2 * paddingButton);
IntSize cornerrect = IntSize(cornerButton, cornerButton);
- Color bg, bright, dark;
+ Color bg, bright, dark, medium;
if (formControlElement->isEnabledFormControl()) {
bg = Color(defaultBgColor);
bright = Color(defaultBgBright);
dark = Color(defaultBgDark);
+ medium = Color(defaultBgMedium);
} else {
bg = Color(disabledBgColor);
bright = Color(disabledBgBright);
dark = Color(disabledBgDark);
+ medium = Color(disabledBgMedium);
}
context->save();
context->clip(
@@ -272,6 +284,12 @@ bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, c
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, bg, context->fillColorSpace());
context->restore();
+ context->setStrokeColor(medium, context->strokeColorSpace());
+ context->setStrokeThickness(1.0f);
+ context->drawLine(IntPoint(innerrect.x(), innerrect.y() + cornerButton),
+ IntPoint(innerrect.x(), innerrect.y() + innerrect.height() - cornerButton));
+ context->drawLine(IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + cornerButton),
+ IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + innerrect.height() - cornerButton));
}
}
@@ -406,7 +424,49 @@ void RenderThemeAndroid::adjustSliderThumbSize(RenderObject* o) const
bool RenderThemeAndroid::paintRadio(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
- RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, false);
+ Node* node = obj->node();
+ Element* element = static_cast<Element*>(node);
+ if (element) {
+ InputElement* input = element->toInputElement();
+ GraphicsContext* context = info.context;
+ if (!element->isEnabledFormControl()) {
+ context->setAlpha(0.5f);
+ }
+ const IntRect inner = IntRect(rect.x() - 2, rect.y() - 2, rect.width() - 4, rect.height() - 4);
+ context->setFillColor(Color(defaultBgBright), context->fillColorSpace());
+ context->setStrokeColor(Color(defaultBgBright), context->strokeColorSpace());
+ context->setStrokeThickness(1.0f);
+ if (input->isCheckbox()) {
+ context->drawRect(inner);
+ } else {
+ context->drawEllipse(inner);
+ }
+ context->setStrokeColor(Color(defaultFgColor), context->strokeColorSpace());
+ if (input->isCheckbox()) {
+ context->drawRect(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4));
+ } else {
+ context->drawEllipse(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4));
+ }
+ if (input->isChecked()) {
+ context->setFillColor(Color(defaultCheckColor), context->fillColorSpace());
+ context->setStrokeColor(Color(defaultCheckColor), context->strokeColorSpace());
+ if (input->isCheckbox()) {
+ const float w2 = ((float) rect.width() / 2);
+ const float cx = ((float) rect.x());
+ const float cy = ((float) rect.y());
+ context->save();
+ // magic numbers due to weird scale in context
+ context->translate(cx + w2 / 2.2f, cy + w2 / 1.2f);
+ context->rotate(3.93f); // 225 degrees
+ context->drawRect(IntRect(0, 0, rect.width() / 4, 2));
+ context->rotate(1.57f); // 90 degrees
+ context->drawRect(IntRect(0, 0, rect.width() / 2, 2));
+ context->restore();
+ } else {
+ context->drawEllipse(IntRect(inner.x() + 5, inner.y() + 5, inner.width() - 10, inner.height() - 10));
+ }
+ }
+ }
return false;
}
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h
index 7ac372d..dccc0b7 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.h
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.h
@@ -31,7 +31,6 @@
namespace WebCore {
-class RenderSkinRadio;
class RenderSkinCombo;
struct ThemeData {
diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk
index 6f9d8eb..fa0082d 100644
--- a/Source/WebKit/Android.mk
+++ b/Source/WebKit/Android.mk
@@ -52,7 +52,6 @@ LOCAL_SRC_FILES += \
android/RenderSkinCombo.cpp \
android/RenderSkinMediaButton.cpp \
android/RenderSkinNinePatch.cpp \
- android/RenderSkinRadio.cpp \
\
android/benchmark/Intercept.cpp \
android/benchmark/MyJavaVM.cpp \
diff --git a/Source/WebKit/android/RenderSkinAndroid.cpp b/Source/WebKit/android/RenderSkinAndroid.cpp
index 0662bbe..64f1365 100644
--- a/Source/WebKit/android/RenderSkinAndroid.cpp
+++ b/Source/WebKit/android/RenderSkinAndroid.cpp
@@ -29,7 +29,6 @@
#include "RenderSkinAndroid.h"
#include "RenderSkinCombo.h"
#include "RenderSkinMediaButton.h"
-#include "RenderSkinRadio.h"
#include "SkImageDecoder.h"
#include <utils/AssetManager.h>
diff --git a/Source/WebKit/android/RenderSkinRadio.cpp b/Source/WebKit/android/RenderSkinRadio.cpp
deleted file mode 100644
index 3c29818..0000000
--- a/Source/WebKit/android/RenderSkinRadio.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 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 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
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RenderSkinRadio.h"
-
-#include "android_graphics.h"
-#include "Document.h"
-#include "Element.h"
-#include "InputElement.h"
-#include "IntRect.h"
-#include "Node.h"
-#include "RenderSkinAndroid.h"
-#include "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkRect.h"
-#include <utils/AssetManager.h>
-#include <wtf/text/CString.h>
-
-extern android::AssetManager* globalAssetManager();
-
-static const char* checks[] = { "btn_check_off_holo.png",
- "btn_check_on_holo.png",
- "btn_radio_off_holo.png",
- "btn_radio_on_holo.png"};
-// Matches the width of the bitmap
-static SkScalar s_bitmapWidth;
-
-namespace WebCore {
-
-static SkBitmap s_bitmap[4];
-static bool s_decodingAttempted = false;
-static bool s_decoded = false;
-
-void RenderSkinRadio::Decode() {
- if (s_decodingAttempted)
- return;
-
- s_decodingAttempted = true;
- s_decoded = false;
-
- android::AssetManager* am = globalAssetManager();
- String drawableDir = RenderSkinAndroid::DrawableDirectory();
- for (int i = 0; i < 4; i++) {
- String path = drawableDir + checks[i];
- if (!RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &s_bitmap[i]))
- return;
- }
- s_decoded = true;
- s_bitmapWidth = SkIntToScalar(s_bitmap[0].width());
-}
-
-void RenderSkinRadio::Draw(SkCanvas* canvas, Node* element, const IntRect& ir,
- bool isCheckBox)
-{
- if (!element)
- return;
-
- if (!s_decodingAttempted)
- Decode();
-
- if (!s_decoded)
- return;
-
- SkRect r(ir);
- // Set up a paint to with filtering to look better.
- SkPaint paint;
- paint.setFlags(SkPaint::kFilterBitmap_Flag);
- int saveScaleCount = 0;
-
- if (!element->isElementNode() ||
- !static_cast<Element*>(element)->isEnabledFormControl()) {
- paint.setAlpha(0x80);
- }
- SkScalar width = r.width();
- SkScalar scale = SkScalarDiv(width, s_bitmapWidth);
- saveScaleCount = canvas->save();
- canvas->translate(r.fLeft, r.fTop);
- canvas->scale(scale, scale);
-
- bool checked = false;
- if (InputElement* inputElement = element->toInputElement()) {
- checked = inputElement->isChecked();
- }
-
- canvas->drawBitmap(s_bitmap[checked + 2*(!isCheckBox)],
- 0, 0, &paint);
- canvas->restoreToCount(saveScaleCount);
-}
-
-} //WebCore
diff --git a/Source/WebKit/android/RenderSkinRadio.h b/Source/WebKit/android/RenderSkinRadio.h
deleted file mode 100644
index 34101cf..0000000
--- a/Source/WebKit/android/RenderSkinRadio.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 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 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
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RenderSkinRadio_h
-#define RenderSkinRadio_h
-
-#include "PlatformString.h"
-
-class SkCanvas;
-
-namespace android {
- class AssetManager;
-}
-
-namespace WebCore {
-
-class Node;
-class IntRect;
-
-/* RenderSkin for a radio button or a checkbox
- */
-class RenderSkinRadio
-{
-public:
- static void SetDrawableDirectory(String drawableDirectory);
-
- // Perform lazy decoding the first time this a radio/checkbox is needed.
- static void Decode();
-
- /**
- * Draw the element to the canvas at the specified size and location.
- * param isCheckBox If true, draws a checkbox. Else, draw a radio button.
- */
- static void Draw(SkCanvas* canvas, Node* element, const IntRect&,
- bool isCheckBox);
-};
-
-} // WebCore
-#endif