Diff
Modified: trunk/Source/WebKit/ChangeLog (118700 => 118701)
--- trunk/Source/WebKit/ChangeLog 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/ChangeLog 2012-05-28 18:53:56 UTC (rev 118701)
@@ -1,3 +1,18 @@
+2012-05-28 Arvid Nilsson <[email protected]>
+
+ [BlackBerry] Add a default tap highlight
+ https://bugs.webkit.org/show_bug.cgi?id=87569
+
+ Reviewed by Rob Buis.
+
+ Add DefaultTapHighlight to the build system
+
+ Reviewed internally by Mike Lattanzio and Mike Fenton.
+
+ PR #154329
+
+ * PlatformBlackBerry.cmake:
+
2012-05-24 Crystal Zhang <[email protected]>
[BlackBerry] Implement select popup and remove old hook to air popup
Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (118700 => 118701)
--- trunk/Source/WebKit/PlatformBlackBerry.cmake 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake 2012-05-28 18:53:56 UTC (rev 118701)
@@ -80,6 +80,7 @@
blackberry/WebKitSupport/BackingStoreCompositingSurface.cpp
blackberry/WebKitSupport/BackingStoreTile.cpp
blackberry/WebKitSupport/BackingStoreClient.cpp
+ blackberry/WebKitSupport/DefaultTapHighlight.cpp
blackberry/WebKitSupport/DOMSupport.cpp
blackberry/WebKitSupport/FrameLayers.cpp
blackberry/WebKitSupport/InPageSearchManager.cpp
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (118700 => 118701)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-05-28 18:53:56 UTC (rev 118701)
@@ -132,6 +132,7 @@
#endif
#if USE(ACCELERATED_COMPOSITING)
+#include "DefaultTapHighlight.h"
#include "FrameLayers.h"
#include "WebPageCompositor_p.h"
#endif
@@ -504,6 +505,10 @@
m_webSettings = WebSettings::createFromStandardSettings();
m_webSettings->setUserAgentString(defaultUserAgent());
+#if USE(ACCELERATED_COMPOSITING)
+ m_tapHighlight = DefaultTapHighlight::create(this);
+#endif
+
// FIXME: We explicitly call setDelegate() instead of passing ourself in createFromStandardSettings()
// so that we only get one didChangeSettings() callback when we set the page group name. This causes us
// to make a copy of the WebSettings since some WebSettings method make use of the page group name.
@@ -6186,6 +6191,16 @@
return *defaultUserAgent;
}
+WebTapHighlight* WebPage::tapHighlight() const
+{
+ return d->m_tapHighlight.get();
+}
+
+void WebPage::setTapHighlight(WebTapHighlight* tapHighlight)
+{
+ d->m_tapHighlight = adoptPtr(tapHighlight);
+}
+
void WebPage::popupOpened(PagePopupBlackBerry* webPopup)
{
ASSERT(!d->m_selectPopup);
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (118700 => 118701)
--- trunk/Source/WebKit/blackberry/Api/WebPage.h 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h 2012-05-28 18:53:56 UTC (rev 118701)
@@ -67,6 +67,7 @@
class WebPageGroupLoadDeferrer;
class WebPagePrivate;
class WebSettings;
+class WebTapHighlight;
class WebViewportArguments;
enum _javascript_DataType { JSUndefined = 0, JSNull, JSBoolean, JSNumber, JSString, JSObject, JSException, JSDataTypeMax };
@@ -334,6 +335,9 @@
void setUserViewportArguments(const WebViewportArguments&);
void resetUserViewportArguments();
+ WebTapHighlight* tapHighlight() const;
+ void setTapHighlight(WebTapHighlight*);
+
// Popup client
void initPopupWebView(BlackBerry::WebKit::WebPage*);
void popupOpened(WebCore::PagePopupBlackBerry* webPopup);
@@ -342,6 +346,7 @@
WebCore::PagePopupBlackBerry* popup();
void autofillTextField(const std::string&);
+
private:
virtual ~WebPage();
Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (118700 => 118701)
--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2012-05-28 18:53:56 UTC (rev 118701)
@@ -132,9 +132,6 @@
virtual void notifyContentRendered(const Platform::IntRect&) = 0;
virtual void notifyScreenRotated() = 0;
- virtual void drawTapHighlight(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0;
- virtual void hideTapHighlight() = 0;
-
virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle) = 0;
virtual void inputFocusLost() = 0;
virtual void inputTextChanged() = 0;
Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (118700 => 118701)
--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2012-05-28 18:53:56 UTC (rev 118701)
@@ -32,6 +32,7 @@
#include "ViewportArguments.h"
#include "WebPage.h"
#include "WebSettings.h"
+#include "WebTapHighlight.h"
#include <BlackBerryPlatformMessage.h>
@@ -42,6 +43,7 @@
class Frame;
class GeolocationControllerClientBlackBerry;
class _javascript_DebuggerBlackBerry;
+class LayerWebKitThread;
class Node;
class Page;
class PluginView;
@@ -429,6 +431,7 @@
WebCore::Frame* m_mainFrame;
RefPtr<WebCore::Node> m_currentContextNode;
WebSettings* m_webSettings;
+ OwnPtr<WebTapHighlight> m_tapHighlight;
#if ENABLE(_javascript__DEBUGGER)
OwnPtr<WebCore::_javascript_DebuggerBlackBerry> m_scriptDebugger;
Added: trunk/Source/WebKit/blackberry/Api/WebTapHighlight.h (0 => 118701)
--- trunk/Source/WebKit/blackberry/Api/WebTapHighlight.h (rev 0)
+++ trunk/Source/WebKit/blackberry/Api/WebTapHighlight.h 2012-05-28 18:53:56 UTC (rev 118701)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef WebTapHighlight_h
+#define WebTapHighlight_h
+
+#include "BlackBerryGlobal.h"
+
+#include <BlackBerryPlatformIntRectRegion.h>
+
+namespace BlackBerry {
+namespace WebKit {
+
+class BLACKBERRY_EXPORT WebTapHighlight {
+public:
+ virtual ~WebTapHighlight() { }
+
+ virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0;
+ virtual void hide() = 0;
+};
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // WebTapHighlight_h
Modified: trunk/Source/WebKit/blackberry/ChangeLog (118700 => 118701)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-05-28 18:53:56 UTC (rev 118701)
@@ -1,5 +1,58 @@
2012-05-28 Arvid Nilsson <[email protected]>
+ [BlackBerry] Add a default tap highlight
+ https://bugs.webkit.org/show_bug.cgi?id=87569
+
+ Reviewed by Rob Buis.
+
+ We used to require the embedder to implement tap highlight drawing.
+ Now, a default tap highlight, implemented using the recently added
+ accelerated compositing overlay layer support, can be used instead.
+
+ The tap highlight appears instantly but fades out when hidden.
+
+ The default tap highlight can be overridden using the new
+ WebPage::setTapHighlight() method.
+
+ Reviewed internally by Mike Lattanzio and Mike Fenton.
+
+ PR #154329
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::init):
+ (BlackBerry::WebKit::WebPage::tapHighlight):
+ (WebKit):
+ (BlackBerry::WebKit::WebPage::setTapHighlight):
+ * Api/WebPage.h:
+ (WebKit):
+ * Api/WebPageClient.h:
+ * Api/WebPage_p.h:
+ (WebCore):
+ (WebPagePrivate):
+ * Api/WebTapHighlight.h: Added.
+ (WebKit):
+ * WebKitSupport/DefaultTapHighlight.cpp: Added.
+ (WebKit):
+ (BlackBerry::WebKit::fadeAnimationName):
+ (BlackBerry::WebKit::DefaultTapHighlight::DefaultTapHighlight):
+ (BlackBerry::WebKit::DefaultTapHighlight::~DefaultTapHighlight):
+ (BlackBerry::WebKit::DefaultTapHighlight::draw):
+ (BlackBerry::WebKit::DefaultTapHighlight::hide):
+ (BlackBerry::WebKit::DefaultTapHighlight::notifySyncRequired):
+ (BlackBerry::WebKit::DefaultTapHighlight::paintContents):
+ * WebKitSupport/DefaultTapHighlight.h: Added.
+ (WebKit):
+ (DefaultTapHighlight):
+ (BlackBerry::WebKit::DefaultTapHighlight::create):
+ (BlackBerry::WebKit::DefaultTapHighlight::notifyAnimationStarted):
+ (BlackBerry::WebKit::DefaultTapHighlight::showDebugBorders):
+ (BlackBerry::WebKit::DefaultTapHighlight::showRepaintCounter):
+ (BlackBerry::WebKit::DefaultTapHighlight::contentsVisible):
+ * WebKitSupport/TouchEventHandler.cpp:
+ (BlackBerry::WebKit::TouchEventHandler::drawTapHighlight):
+
+2012-05-28 Arvid Nilsson <[email protected]>
+
[BlackBerry] Add an overlay layer
https://bugs.webkit.org/show_bug.cgi?id=87567
Added: trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp (0 => 118701)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp 2012-05-28 18:53:56 UTC (rev 118701)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "DefaultTapHighlight.h"
+
+#include "GraphicsContext.h"
+#include "GraphicsLayer.h"
+#include "LayerCompositingThread.h"
+#include "LayerWebKitThread.h"
+#include "Path.h"
+#include "PlatformContextSkia.h"
+#include "ScaleTransformOperation.h"
+#include "WebPageCompositorClient.h"
+#include "WebPageCompositor_p.h"
+#include "WebPage_p.h"
+
+#include <BlackBerryPlatformMessageClient.h>
+#include <SkCornerPathEffect.h>
+
+using namespace WebCore;
+
+namespace BlackBerry {
+namespace WebKit {
+
+const double ActiveTextFadeAnimationDuration = 0.3;
+
+static const char* fadeAnimationName() { return "fade"; }
+
+DefaultTapHighlight::DefaultTapHighlight(WebPagePrivate* page)
+ : m_page(page)
+ , m_visible(false)
+{
+}
+
+DefaultTapHighlight::~DefaultTapHighlight()
+{
+}
+
+void DefaultTapHighlight::draw(const Platform::IntRectRegion& region, int red, int green, int blue, int alpha, bool hideAfterScroll)
+{
+ ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+
+ m_region = region;
+ m_color = Color(red, green, blue, std::min(128, alpha));
+ IntRect rect = m_region.extents();
+ if (rect.isEmpty())
+ return;
+
+ m_visible = true;
+
+ if (!m_layer) {
+ m_layer = GraphicsLayer::create(this);
+ m_page->overlayLayer()->addChild(m_layer.get());
+ }
+
+ m_layer->setPosition(rect.location());
+ m_layer->setSize(rect.size());
+ m_layer->setDrawsContent(true);
+ m_layer->removeAnimation(fadeAnimationName());
+ m_layer->setOpacity(1.0);
+ m_layer->setNeedsDisplay();
+}
+
+void DefaultTapHighlight::hide()
+{
+ if (!m_layer)
+ return;
+
+ // This animation needs to be created anew each time, since
+ // the method may be called on differend threads.
+ RefPtr<Animation> fadeAnimation = Animation::create();
+ fadeAnimation->setDuration(ActiveTextFadeAnimationDuration);
+ KeyframeValueList keyframes(AnimatedPropertyOpacity);
+ keyframes.insert(new FloatAnimationValue(0, 1.0));
+ keyframes.insert(new FloatAnimationValue(1.0, 0));
+
+ // Normally, this method is called on the WebKit thread, but it can also be
+ // called from the compositing thread.
+ if (BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread()) {
+ if (!m_visible)
+ return;
+ m_visible = false;
+ m_layer->addAnimation(keyframes, m_region.extents().size(), fadeAnimation.get(), fadeAnimationName(), 0.0);
+ } else if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
+ RefPtr<LayerAnimation> animation = LayerAnimation::create(keyframes, m_region.extents().size(), fadeAnimation.get(), fadeAnimationName(), 0.0);
+ if (WebPageCompositorClient* compositorClient = m_page->compositor()->client()) {
+ double animationTime = compositorClient->requestAnimationFrame();
+ compositorClient->invalidate(animationTime);
+ }
+ // FIXME: Unfortunately WebPageCompositorClient::requestAnimationFrame uses a different time coordinate system
+ // than accelerated animations, so we can't use the time returned by RAF for starttime.
+ animation->setStartTime(currentTime());
+ m_layer->platformLayer()->layerCompositingThread()->addAnimation(animation.get());
+ }
+}
+
+void DefaultTapHighlight::notifySyncRequired(const GraphicsLayer*)
+{
+ m_page->scheduleRootLayerCommit();
+}
+
+void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& /*inClip*/)
+{
+ std::vector<Platform::IntRect> rects = m_region.rects();
+ Platform::IntRect rect = m_region.extents();
+ SkRegion windowRegion;
+
+ unsigned rectCount = m_region.numRects();
+ if (!rectCount)
+ return;
+
+ for (unsigned i = 0; i < rectCount; ++i) {
+ Platform::IntRect rectToPaint = rects[i];
+ SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height());
+ windowRegion.op(r, SkRegion::kUnion_Op);
+ }
+
+ SkPath pathToPaint;
+ windowRegion.getBoundaryPath(&pathToPaint);
+
+ Path path(pathToPaint);
+ c.save();
+ c.translate(-rect.x(), -rect.y());
+
+ // Draw tap highlight
+ c.setFillColor(m_color, ColorSpaceDeviceRGB);
+ c.fillPath(path);
+ Color darker = Color(m_color.red(), m_color.green(), m_color.blue()); // Get rid of alpha.
+ c.setStrokeColor(darker, ColorSpaceDeviceRGB);
+ c.setStrokeThickness(1);
+ c.strokePath(path);
+ c.restore();
+}
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // USE(ACCELERATED_COMPOSITING)
Added: trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h (0 => 118701)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h 2012-05-28 18:53:56 UTC (rev 118701)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DefaultTapHighlight_h
+#define DefaultTapHighlight_h
+
+#include "BlackBerryGlobal.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "Color.h"
+#include "GraphicsLayer.h"
+#include "GraphicsLayerClient.h"
+#include "WebTapHighlight.h"
+#include <BlackBerryPlatformIntRectRegion.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace BlackBerry {
+namespace WebKit {
+
+class WebPagePrivate;
+
+class DefaultTapHighlight : public WebTapHighlight, public WebCore::GraphicsLayerClient {
+public:
+ static PassOwnPtr<DefaultTapHighlight> create(WebPagePrivate* page)
+ {
+ return adoptPtr(new DefaultTapHighlight(page));
+ }
+
+ virtual ~DefaultTapHighlight();
+
+ virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll);
+ virtual void hide();
+
+ // GraphicsLayerClient
+ virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) { }
+ virtual void notifySyncRequired(const WebCore::GraphicsLayer*);
+ virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
+ virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; }
+ virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
+
+#if PLATFORM(BLACKBERRY)
+ virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
+#endif
+
+
+private:
+ DefaultTapHighlight(WebPagePrivate*);
+
+ WebPagePrivate* m_page;
+ OwnPtr<WebCore::GraphicsLayer> m_layer;
+ BlackBerry::Platform::IntRectRegion m_region;
+ WebCore::Color m_color;
+ bool m_visible;
+};
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // DefaultTapHighlight_h
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp (118700 => 118701)
--- trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp 2012-05-28 18:33:45 UTC (rev 118700)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp 2012-05-28 18:53:56 UTC (rev 118701)
@@ -44,6 +44,7 @@
#include "RenderedDocumentMarker.h"
#include "SelectionHandler.h"
#include "WebPage_p.h"
+#include "WebTapHighlight.h"
#include <wtf/MathExtras.h>
@@ -389,12 +390,9 @@
Color highlightColor = element->renderStyle()->tapHighlightColor();
- m_webPage->m_client->drawTapHighlight(region,
- highlightColor.red(),
- highlightColor.green(),
- highlightColor.blue(),
- highlightColor.alpha(),
- shouldHideTapHighlightRightAfterScrolling);
+ m_webPage->m_tapHighlight->draw(region,
+ highlightColor.red(), highlightColor.green(), highlightColor.blue(), highlightColor.alpha(),
+ shouldHideTapHighlightRightAfterScrolling);
}
}