diff options
Diffstat (limited to 'WebKit/android')
| -rw-r--r-- | WebKit/android/RenderSkinAndroid.cpp | 2 | ||||
| -rw-r--r-- | WebKit/android/RenderSkinCombo.cpp | 94 | ||||
| -rw-r--r-- | WebKit/android/RenderSkinCombo.h | 20 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 5 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.h | 2 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 17 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h | 8 | ||||
| -rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 2 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedInput.cpp | 5 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedInput.h | 5 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedNode.h | 1 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedNodeType.h | 3 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 12 |
13 files changed, 127 insertions, 49 deletions
diff --git a/WebKit/android/RenderSkinAndroid.cpp b/WebKit/android/RenderSkinAndroid.cpp index d148262..31c327a 100644 --- a/WebKit/android/RenderSkinAndroid.cpp +++ b/WebKit/android/RenderSkinAndroid.cpp @@ -45,7 +45,7 @@ RenderSkinAndroid::RenderSkinAndroid() void RenderSkinAndroid::Init(android::AssetManager* am, String drawableDirectory) { RenderSkinButton::Init(am, drawableDirectory); - RenderSkinCombo::Init(am); + RenderSkinCombo::Init(am, drawableDirectory); RenderSkinRadio::Init(am, drawableDirectory); } diff --git a/WebKit/android/RenderSkinCombo.cpp b/WebKit/android/RenderSkinCombo.cpp index 6f88ee3..4378371 100644 --- a/WebKit/android/RenderSkinCombo.cpp +++ b/WebKit/android/RenderSkinCombo.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "RenderSkinCombo.h" +#include "CString.h" #include "Document.h" #include "Element.h" #include "Node.h" @@ -36,43 +37,85 @@ namespace WebCore { -static SkBitmap s_bitmap[2]; // Collection of assets for a combo box -static bool s_decoded; // True if all assets were decoded -static const int s_margin = 2; -static const SkIRect s_mar = { s_margin, s_margin, - RenderSkinCombo::extraWidth(), s_margin }; -static SkIRect s_subset; +// Indicates if the entire asset is being drawn, or if the border is being +// excluded and just the arrow drawn. +enum BorderStyle { + FullAsset, + NoBorder +}; +// There are 2.5 different concepts of a 'border' here, which results +// in rather a lot of magic constants. In each case, there are 2 +// numbers, one for medium res and one for high-res. All sizes are in pixels. -RenderSkinCombo::RenderSkinCombo() -{ -} +// Firstly, we have the extra padding that webkit needs to know about, +// which defines how much bigger this element is made by the +// asset. This is actually a bit broader than the actual border on the +// asset, to make things look less cramped. The border is the same +// width on all sides, except on the right when it's significantly +// wider to allow for the arrow. +const int RenderSkinCombo::arrowMargin[2] = {22, 34}; +const int RenderSkinCombo::padMargin[2] = {2, 5}; + +// Then we have the borders used for the 9-patch stretch. The +// rectangle at the centre of these borders is entirely below and to +// the left of the arrow in the asset. Hence the border widths are the +// same for the bottom and left, but are different for the top. The +// right hand border width happens to be the same as arrowMargin +// defined above. +static const int stretchMargin[2] = {3, 5}; // border width for the bottom and left of the 9-patch +static const int stretchTop[2] = {15, 23}; // border width for the top of the 9-patch + +// Finally, if the border is defined by the CSS, we only draw the +// arrow and not the border. We do this by drawing the relevant subset +// of the bitmap, which must now be precisely determined by what's in +// the asset with no extra padding to make things look properly +// spaced. The border to remove at the top, right and bottom of the +// image is the same as stretchMargin above, but we need to know the width +// of the arrow. +static const int arrowWidth[2] = {22, 31}; + +RenderSkinCombo::Resolution RenderSkinCombo::resolution = MedRes; + +const SkIRect RenderSkinCombo::margin[2][2] = {{{ stretchMargin[MedRes], stretchTop[MedRes], + RenderSkinCombo::arrowMargin[MedRes] + stretchMargin[MedRes], stretchMargin[MedRes] }, + {0, stretchTop[MedRes], 0, stretchMargin[MedRes]}}, + {{ stretchMargin[HighRes], stretchTop[HighRes], + RenderSkinCombo::arrowMargin[HighRes] + stretchMargin[HighRes], stretchMargin[HighRes] }, + {0, stretchTop[HighRes], 0, stretchMargin[HighRes]}}}; +static SkBitmap bitmaps[2][2]; // Collection of assets for a combo box +static bool isDecoded; // True if all assets were decoded -void RenderSkinCombo::Init(android::AssetManager* am) +void RenderSkinCombo::Init(android::AssetManager* am, String drawableDirectory) { - if (s_decoded) + if (isDecoded) return; - // Maybe short circuiting is fine, since I don't even draw if one state is not decoded properly - // but is that necessary in the final version? - s_decoded = RenderSkinAndroid::DecodeBitmap(am, "images/combobox-noHighlight.png", &s_bitmap[kNormal]); - s_decoded = RenderSkinAndroid::DecodeBitmap(am, "images/combobox-disabled.png", &s_bitmap[kDisabled]) && s_decoded; - - int width = s_bitmap[kNormal].width(); - int height = s_bitmap[kNormal].height(); - s_subset.set(width - RenderSkinCombo::extraWidth() + s_margin, 0, width, height); + + if (drawableDirectory[drawableDirectory.length() - 5] == 'h') + resolution = HighRes; + + isDecoded = RenderSkinAndroid::DecodeBitmap(am, (drawableDirectory + "combobox_nohighlight.png").utf8().data(), &bitmaps[kNormal][FullAsset]); + isDecoded &= RenderSkinAndroid::DecodeBitmap(am, (drawableDirectory + "combobox_disabled.png").utf8().data(), &bitmaps[kDisabled][FullAsset]); + + int width = bitmaps[kNormal][FullAsset].width(); + int height = bitmaps[kNormal][FullAsset].height(); + SkIRect subset; + subset.set(width - arrowWidth[resolution], 0, width, height); + bitmaps[kNormal][FullAsset].extractSubset(&bitmaps[kNormal][NoBorder], subset); + bitmaps[kDisabled][FullAsset].extractSubset(&bitmaps[kDisabled][NoBorder], subset); } bool RenderSkinCombo::Draw(SkCanvas* canvas, Node* element, int x, int y, int width, int height) { - if (!s_decoded) + if (!isDecoded) return true; State state = (element->isElementNode() && static_cast<Element*>(element)->isEnabledFormControl()) ? kNormal : kDisabled; - if (height < (s_margin<<1) + 1) { - height = (s_margin<<1) + 1; - } + height = std::max(height, (stretchMargin[resolution]<<1) + 1); + SkRect bounds; + BorderStyle drawBorder = FullAsset; bounds.set(SkIntToScalar(x+1), SkIntToScalar(y+1), SkIntToScalar(x + width-1), SkIntToScalar(y + height-1)); RenderStyle* style = element->renderStyle(); @@ -90,10 +133,9 @@ bool RenderSkinCombo::Draw(SkCanvas* canvas, Node* element, int x, int y, int wi bounds.fRight -= SkIntToScalar(style->borderRightWidth()); bounds.fTop += SkIntToScalar(style->borderTopWidth()); bounds.fBottom -= SkIntToScalar(style->borderBottomWidth()); - canvas->drawBitmapRect(s_bitmap[state], &s_subset, bounds); - } else { - SkNinePatch::DrawNine(canvas, bounds, s_bitmap[state], s_mar); + drawBorder = NoBorder; } + SkNinePatch::DrawNine(canvas, bounds, bitmaps[state][drawBorder], margin[resolution][drawBorder]); return false; } diff --git a/WebKit/android/RenderSkinCombo.h b/WebKit/android/RenderSkinCombo.h index 91c9367..38cd048 100644 --- a/WebKit/android/RenderSkinCombo.h +++ b/WebKit/android/RenderSkinCombo.h @@ -37,13 +37,10 @@ namespace WebCore { class RenderSkinCombo : public RenderSkinAndroid { public: - RenderSkinCombo(); - virtual ~RenderSkinCombo() {} - /** * Initialize the class before use. Uses the AssetManager to initialize any bitmaps the class may use. */ - static void Init(android::AssetManager*); + static void Init(android::AssetManager*, String drawableDirectory); /** * Draw the provided Node on the SkCanvas, using the dimensions provided by @@ -53,11 +50,18 @@ public: static bool Draw(SkCanvas* , Node* , int x, int y, int w, int h); // The image is wider than the RenderObject, so this accounts for that. - static int extraWidth() { return arrowMargin; } - + static int extraWidth() { return arrowMargin[resolution]; } + static int padding() { return padMargin[resolution]; } + + enum Resolution { + MedRes, + HighRes + }; private: - - static const int arrowMargin = 22; + static Resolution resolution; + const static int arrowMargin[2]; + const static int padMargin[2]; + const static SkIRect margin[2][2]; }; } // WebCore diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index c258d79..6d912fd 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -492,6 +492,11 @@ void ChromeClientAndroid::runOpenPanel(Frame* frame, core->openFileChooser(chooser); } +void ChromeClientAndroid::iconForFiles(const Vector<WebCore::String>&, PassRefPtr<WebCore::FileChooser>) +{ + notImplemented(); +} + bool ChromeClientAndroid::setCursor(PlatformCursorHandle) { notImplemented(); diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index 68cac24..0e4d5c9 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -151,6 +151,7 @@ namespace android { virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); virtual bool setCursor(PlatformCursorHandle); + virtual void iconForFiles(const Vector<String>&, PassRefPtr<FileChooser>); // Notification that the given form element has changed. This function // will be called frequently, so handling should be very fast. @@ -160,6 +161,7 @@ namespace android { // Android-specific void setWebFrame(android::WebFrame* webframe); + android::WebFrame* webFrame() { return m_webFrame; } void wakeUpMainThreadWithNewQuota(long newQuota); #if USE(ACCELERATED_COMPOSITING) diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 9112afe..a0b8475 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -32,6 +32,8 @@ #include "CString.h" #include "CachedFrame.h" #include "CachedFramePlatformDataAndroid.h" +#include "Chrome.h" +#include "ChromeClientAndroid.h" #include "DOMImplementation.h" #include "Document.h" #include "DocumentLoader.h" @@ -1215,6 +1217,21 @@ WTF::PassRefPtr<Widget> FrameLoaderClientAndroid::createJavaAppletWidget(const I return 0; } +void FrameLoaderClientAndroid::didTransferChildFrameToNewDocument() +{ + ASSERT(m_frame); + // m_webFrame points to the WebFrame for the page that our frame previosuly + // belonged to. If the frame now belongs to a new page, we need to update + // m_webFrame to point to the WebFrame for the new page. + Page* newPage = m_frame->page(); + if (newPage != m_webFrame->page()) { + ChromeClientAndroid* chromeClient = static_cast<ChromeClientAndroid*>(newPage->chrome()->client()); + Release(m_webFrame); + m_webFrame = chromeClient->webFrame(); + Retain(m_webFrame); + } +} + // This function is used by the <OBJECT> element to determine the type of // the contents and work out if it can render it. ObjectContentType FrameLoaderClientAndroid::objectContentType(const KURL& url, diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h index 3b754b8..fe58124 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h @@ -176,11 +176,9 @@ namespace android { virtual bool canCachePage() const; virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&); - virtual WTF::PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, - const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); - virtual WTF::PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, - const WTF::Vector<String>&, const WTF::Vector<String>&, - const String&, bool loadManually); + virtual WTF::PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); + virtual void didTransferChildFrameToNewDocument(); + virtual WTF::PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const WTF::Vector<String>&, const WTF::Vector<String>&, const String&, bool loadManually); virtual void redirectDataToPlugin(Widget* pluginWidget); virtual WTF::PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const WTF::Vector<String>& paramNames, const WTF::Vector<String>& paramValues); diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 7ee2a16..b98b31f 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -1216,6 +1216,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, if (!href.isEmpty() && !WebCore::protocolIsJavaScript(href.string())) // Set the exported string for all non-javascript anchors. exported = href.string().threadsafeCopy(); + } else if (node->hasTagName(HTMLNames::selectTag)) { + type = SELECT_CACHEDNODETYPE; } if (type == TEXT_INPUT_CACHEDNODETYPE) { RenderTextControl* renderText = diff --git a/WebKit/android/nav/CachedInput.cpp b/WebKit/android/nav/CachedInput.cpp index 924bbca..dcd9ccd 100644 --- a/WebKit/android/nav/CachedInput.cpp +++ b/WebKit/android/nav/CachedInput.cpp @@ -28,6 +28,11 @@ namespace android { +void CachedInput::init() { + bzero(this, sizeof(CachedInput)); + mName = WebCore::String(); +} + #if DUMP_NAV_CACHE #define DEBUG_PRINT_BOOL(field) \ diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h index 42cadf1..a3d6b10 100644 --- a/WebKit/android/nav/CachedInput.h +++ b/WebKit/android/nav/CachedInput.h @@ -39,10 +39,7 @@ public: // constructor } void* formPointer() const { return mForm; } - void init() { - bzero(this, sizeof(CachedInput)); - mName = WebCore::String(); - } + void init(); WebCore::HTMLInputElement::InputType inputType() const { return mInputType; } bool isRtlText() const { return mIsRtlText; } bool isTextField() const { return mIsTextField; } diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h index f3cfd98..b707ac1 100644 --- a/WebKit/android/nav/CachedNode.h +++ b/WebKit/android/nav/CachedNode.h @@ -118,6 +118,7 @@ public: return clip.intersects(bounds(frame)); } bool isPlugin() const { return mType == PLUGIN_CACHEDNODETYPE; } + bool isSelect() const { return mType == SELECT_CACHEDNODETYPE; } bool isSyntheticLink() const { return mType >= ADDRESS_CACHEDNODETYPE && mType <= PHONE_CACHEDNODETYPE; } diff --git a/WebKit/android/nav/CachedNodeType.h b/WebKit/android/nav/CachedNodeType.h index 21e2d40..8334b2f 100644 --- a/WebKit/android/nav/CachedNodeType.h +++ b/WebKit/android/nav/CachedNodeType.h @@ -37,7 +37,8 @@ enum CachedNodeType { AREA_CACHEDNODETYPE, FRAME_CACHEDNODETYPE, PLUGIN_CACHEDNODETYPE, - TEXT_INPUT_CACHEDNODETYPE + TEXT_INPUT_CACHEDNODETYPE, + SELECT_CACHEDNODETYPE }; enum CachedNodeBits { diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index bdcafbf..d5c0758 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -882,7 +882,8 @@ bool motionUp(int x, int y, int slop) viewInvalidate(); if (!result->isTextInput()) { clearTextEntry(); - setFollowedLink(true); + if (!result->isSelect()) + setFollowedLink(true); if (syntheticLink) overrideUrlLoading(result->getExport()); } @@ -1634,9 +1635,12 @@ static void nativeSetFindIsEmpty(JNIEnv *env, jobject obj) static void nativeSetFollowedLink(JNIEnv *env, jobject obj, bool followed) { - WebView* view = GET_NATIVE_VIEW(env, obj); - LOG_ASSERT(view, "view not set in %s", __FUNCTION__); - view->setFollowedLink(followed); + const CachedNode* cursor = getCursorNode(env, obj); + if (cursor && !cursor->isSelect()) { + WebView* view = GET_NATIVE_VIEW(env, obj); + LOG_ASSERT(view, "view not set in %s", __FUNCTION__); + view->setFollowedLink(followed); + } } static void nativeSetHeightCanMeasure(JNIEnv *env, jobject obj, bool measure) |
