diff options
author | Andrei Popescu <andreip@google.com> | 2009-11-24 12:04:22 +0000 |
---|---|---|
committer | Andrei Popescu <andreip@google.com> | 2009-11-25 16:11:39 +0000 |
commit | 1890130f485b2a3365409653a1b83396a02eed94 (patch) | |
tree | 1c473fd65e1f872ec60647cbc47166de0c66c437 /WebCore/platform/android | |
parent | fb5979ac6e2238d5ae16f43cca16e6a0932a4279 (diff) | |
download | external_webkit-1890130f485b2a3365409653a1b83396a02eed94.zip external_webkit-1890130f485b2a3365409653a1b83396a02eed94.tar.gz external_webkit-1890130f485b2a3365409653a1b83396a02eed94.tar.bz2 |
Update files in platform/android to match what was upstreamed in
https://bugs.webkit.org/show_bug.cgi?id=31825
https://bugs.webkit.org/show_bug.cgi?id=31831
Diffstat (limited to 'WebCore/platform/android')
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h (renamed from WebCore/platform/android/KeyGeneratorClient.h) | 31 | ||||
-rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.cpp | 113 | ||||
-rw-r--r-- | WebCore/platform/android/SSLKeyGeneratorAndroid.cpp | 18 |
3 files changed, 80 insertions, 82 deletions
diff --git a/WebCore/platform/android/KeyGeneratorClient.h b/WebCore/platform/android/PlatformBridge.h index 1bcd8e8..977a0fd 100644 --- a/WebCore/platform/android/KeyGeneratorClient.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -23,24 +23,31 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef KEY_GENERATOR_CLIENT_H -#define KEY_GENERATOR_CLIENT_H +#ifndef PlatformBridge_h +#define PlatformBridge_h #include "KURL.h" #include "PlatformString.h" #include <wtf/Vector.h> -using namespace WebCore; +namespace WebCore { -namespace android { - -class KeyGeneratorClient { +// An interface to the embedding layer, which has the ability to answer +// questions about the system and so on... +// This is very similar to ChromiumBridge and the two are likely to converge +// in the future. +// +// The methods in this class all need to reach across a JNI layer to the Java VM +// where the embedder runs. The JNI machinery is currently all in WebKit/android +// but the long term plan is to move to the WebKit API and share the bridge and its +// implementation with Chromium. The JNI machinery will then move outside of WebKit, +// similarly to how Chromium's IPC layer lives outside of WebKit. +class PlatformBridge { public: - virtual ~KeyGeneratorClient() { } - virtual WTF::Vector<String> getSupportedKeyStrengthList() = 0; - virtual String getSignedPublicKeyAndChallengeString(unsigned index, - const String& challenge, const KURL& url) = 0; - }; + // KeyGenerator + static WTF::Vector<String> getSupportedKeyStrengthList(); + static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&); +}; } -#endif +#endif // PlatformBridge_h 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); diff --git a/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp b/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp index 0279909..287d5c4 100644 --- a/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp +++ b/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp @@ -23,31 +23,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include "config.h" #include "SSLKeyGenerator.h" -#include "JavaSharedClient.h" -#include "KeyGeneratorClient.h" +#include "PlatformBridge.h" namespace WebCore { void getSupportedKeySizes(Vector<String>& keys) { - if (android::JavaSharedClient::GetKeyGeneratorClient()) { - keys = android::JavaSharedClient::GetKeyGeneratorClient()-> - getSupportedKeyStrengthList(); - } + keys = PlatformBridge::getSupportedKeyStrengthList(); } -String signedPublicKeyAndChallengeString(unsigned index, - const String& challenge, const KURL& url) +String signedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL& url) { - if (android::JavaSharedClient::GetKeyGeneratorClient()) { - return android::JavaSharedClient::GetKeyGeneratorClient()-> - getSignedPublicKeyAndChallengeString(index, challenge, url); - } - return String(); + return PlatformBridge::getSignedPublicKeyAndChallengeString(index, challenge, url); } } |