diff options
| -rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 53 | ||||
| -rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.cpp | 113 | ||||
| -rw-r--r-- | WebCore/platform/android/SSLKeyGeneratorAndroid.cpp | 18 | ||||
| -rw-r--r-- | WebKit/Android.mk | 3 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/KeyGeneratorClient.h (renamed from WebCore/platform/android/KeyGeneratorClient.h) | 0 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/PlatformBridge.cpp | 54 |
6 files changed, 170 insertions, 71 deletions
diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h new file mode 100644 index 0000000..977a0fd --- /dev/null +++ b/WebCore/platform/android/PlatformBridge.h @@ -0,0 +1,53 @@ +/* + * 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 + * 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 PlatformBridge_h +#define PlatformBridge_h + +#include "KURL.h" +#include "PlatformString.h" + +#include <wtf/Vector.h> + +namespace WebCore { + +// 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: + // KeyGenerator + static WTF::Vector<String> getSupportedKeyStrengthList(); + static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&); +}; +} +#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); } } diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 990e896..07d030b 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -21,8 +21,9 @@ LOCAL_SRC_FILES := \ android/WebCoreSupport/DragClientAndroid.cpp \ android/WebCoreSupport/EditorClientAndroid.cpp \ android/WebCoreSupport/FrameLoaderClientAndroid.cpp \ - android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp \ android/WebCoreSupport/GeolocationPermissions.cpp \ + android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp \ + android/WebCoreSupport/PlatformBridge.cpp \ \ android/RenderSkinAndroid.cpp \ android/RenderSkinButton.cpp \ diff --git a/WebCore/platform/android/KeyGeneratorClient.h b/WebKit/android/WebCoreSupport/KeyGeneratorClient.h index 1bcd8e8..1bcd8e8 100644 --- a/WebCore/platform/android/KeyGeneratorClient.h +++ b/WebKit/android/WebCoreSupport/KeyGeneratorClient.h diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp new file mode 100644 index 0000000..e4fe4ce --- /dev/null +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -0,0 +1,54 @@ +/* + * 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 + * 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 "PlatformBridge.h" + +#include "JavaSharedClient.h" +#include "KeyGeneratorClient.h" + +using namespace android; + +namespace WebCore { + +WTF::Vector<String> PlatformBridge::getSupportedKeyStrengthList() +{ + KeyGeneratorClient* client = JavaSharedClient::GetKeyGeneratorClient(); + if (!client) + return Vector<String>(); + + return client->getSupportedKeyStrengthList(); +} + +String PlatformBridge::getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL& url) +{ + KeyGeneratorClient* client = JavaSharedClient::GetKeyGeneratorClient(); + if (!client) + return String(); + + return client->getSignedPublicKeyAndChallengeString(index, challenge, url); +} + +}
\ No newline at end of file |
