summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-02-06 09:00:44 -0800
committerJohn Reck <jreck@google.com>2012-02-15 16:57:38 -0800
commitceeeab6161d7d8bf970ecf98affa4f4966df6f01 (patch)
tree0666a9ebf25e9d4e09ef3f8ee8ed0f6cf33fd4f1 /Source/WebCore
parent628a06bda2490e4c405ce3263381412423f4c735 (diff)
downloadexternal_webkit-ceeeab6161d7d8bf970ecf98affa4f4966df6f01.zip
external_webkit-ceeeab6161d7d8bf970ecf98affa4f4966df6f01.tar.gz
external_webkit-ceeeab6161d7d8bf970ecf98affa4f4966df6f01.tar.bz2
Initial support for keyboard navigation
Bug: 6019693 Change-Id: I7b4f6d83e8913e647e8ac7340afd01d609c4343b
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/editing/SelectionController.cpp4
-rw-r--r--Source/WebCore/html/HTMLAnchorElement.cpp4
-rw-r--r--Source/WebCore/platform/android/KeyEventAndroid.cpp2
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.cpp11
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.h1
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp29
6 files changed, 44 insertions, 7 deletions
diff --git a/Source/WebCore/editing/SelectionController.cpp b/Source/WebCore/editing/SelectionController.cpp
index e9bdd6a..acae6bf 100644
--- a/Source/WebCore/editing/SelectionController.cpp
+++ b/Source/WebCore/editing/SelectionController.cpp
@@ -1217,10 +1217,6 @@ void SelectionController::invalidateCaretRect()
void SelectionController::paintCaret(GraphicsContext* context, int tx, int ty, const IntRect& clipRect)
{
-#ifdef ANDROID_ALLOW_TURNING_OFF_CARET
- if (m_frame && !android::WebViewCore::getWebViewCore(m_frame->view())->shouldPaintCaret())
- return;
-#endif
#if ENABLE(TEXT_CARET)
if (!m_caretVisible)
return;
diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp
index 60f5b4a..4636f20 100644
--- a/Source/WebCore/html/HTMLAnchorElement.cpp
+++ b/Source/WebCore/html/HTMLAnchorElement.cpp
@@ -531,7 +531,11 @@ bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const
bool isEnterKeyKeydownEvent(Event* event)
{
+#if OS(ANDROID)
+ return event->type() == eventNames().keyupEvent && event->isKeyboardEvent() && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "Enter";
+#else
return event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "Enter";
+#endif
}
bool isMiddleMouseButtonEvent(Event* event)
diff --git a/Source/WebCore/platform/android/KeyEventAndroid.cpp b/Source/WebCore/platform/android/KeyEventAndroid.cpp
index eaf34a9..f309e99 100644
--- a/Source/WebCore/platform/android/KeyEventAndroid.cpp
+++ b/Source/WebCore/platform/android/KeyEventAndroid.cpp
@@ -191,7 +191,7 @@ static String keyIdentifierForAndroidKeyCode(int keyCode)
return "U+00007F";
default:
char upper[16];
- sprintf(upper, "U+%06X", windowsKeyCodeForKeyEvent(keyCode));
+ sprintf(upper, "U+%04X", windowsKeyCodeForKeyEvent(keyCode));
return String(upper);
}
}
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
index d579003..b570d0e 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
@@ -621,8 +621,19 @@ bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo&
return paintCombo(obj, info, rect);
}
+Color RenderThemeAndroid::platformFocusRingColor() const
+{
+ static Color focusRingColor(0x66, 0x33, 0xB5, 0xE5);
+ return focusRingColor;
+}
+
bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const
{
+ // TODO: Draw this on the UI side
+ // For now, just return false to let WebKit draw the focus ring. We only
+ // draw this ring when navigating via the keyboard, this does not affect
+ // the touch ring
+ return false;
return style->opacity() > 0
&& style->hasAppearance()
&& style->appearance() != TextFieldPart
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h
index 89a6d46..802d3c3 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.h
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.h
@@ -60,6 +60,7 @@ public:
virtual Color platformActiveSelectionForegroundColor() const;
virtual Color platformInactiveSelectionForegroundColor() const;
virtual Color platformTextSearchHighlightColor() const;
+ virtual Color platformFocusRingColor() const;
virtual Color platformActiveListBoxSelectionBackgroundColor() const;
virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
index 848b713..9cfed60 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
@@ -36,6 +36,7 @@
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
+#include "SkCornerPathEffect.h"
#include "SkDashPathEffect.h"
#include "SkDevice.h"
#include "SkGradientShader.h"
@@ -949,9 +950,33 @@ void GraphicsContext::clearPlatformShadow()
///////////////////////////////////////////////////////////////////////////////
-void GraphicsContext::drawFocusRing(const Vector<IntRect>&, int, int, const Color&)
+void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
{
- // Do nothing, since we draw the focus ring independently.
+ if (paintingDisabled())
+ return;
+
+ unsigned rectCount = rects.size();
+ if (!rectCount)
+ return;
+
+ SkRegion focusRingRegion;
+ const SkScalar focusRingOutset = WebCoreFloatToSkScalar(0.8);
+ for (unsigned i = 0; i < rectCount; i++) {
+ SkIRect r = rects[i];
+ r.inset(-focusRingOutset, -focusRingOutset);
+ focusRingRegion.op(r, SkRegion::kUnion_Op);
+ }
+
+ SkPath path;
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ paint.setColor(color.rgb());
+ paint.setStrokeWidth(focusRingOutset * 2);
+ paint.setPathEffect(new SkCornerPathEffect(focusRingOutset * 2))->unref();
+ focusRingRegion.getBoundaryPath(&path);
+ platformContext()->mCanvas->drawPath(path, paint);
}
void GraphicsContext::drawFocusRing(const Path&, int, int, const Color&)