summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/WebPageProxy.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-11 09:43:24 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-11 09:43:24 +0200
commit1b914638db989aaa98631a1c1e02c7b2d44805d8 (patch)
tree87f4fd2c7b38db320079a5de8877890d2ca3c485 /Source/WebKit2/UIProcess/WebPageProxy.cpp
parent2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (diff)
downloadqtwebkit-1b914638db989aaa98631a1c1e02c7b2d44805d8.tar.gz
Imported WebKit commit 9a52e27980f47e8b0d8f8b7cc0fd7b5741bceb92 (http://svn.webkit.org/repository/webkit/trunk@116736)
New snapshot to include QDeclarative* -> QQml* build fixes
Diffstat (limited to 'Source/WebKit2/UIProcess/WebPageProxy.cpp')
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.cpp191
1 files changed, 110 insertions, 81 deletions
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp
index 043cdb690..ca11b64ca 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -109,6 +109,9 @@
using namespace WebCore;
+// Represents the number of wheel events we can hold in the queue before we start pushing them preemptively.
+static const unsigned wheelEventQueueSizeThreshold = 10;
+
namespace WebKit {
WKPageDebugPaintFlags WebPageProxy::s_debugPaintFlags = 0;
@@ -657,13 +660,15 @@ void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, CoreIPC::Argumen
String WebPageProxy::activeURL() const
{
- if (!m_mainFrame)
- return String();
-
- // If there is a currently pending url, it is the active URL.
+ // If there is a currently pending url, it is the active URL,
+ // even when there's no main frame yet, as it might be the
+ // first API request.
if (!m_pendingAPIRequestURL.isNull())
return m_pendingAPIRequestURL;
+ if (!m_mainFrame)
+ return String();
+
if (!m_mainFrame->unreachableURL().isEmpty())
return m_mainFrame->unreachableURL();
@@ -985,6 +990,68 @@ void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
process()->send(Messages::WebPage::MouseEvent(event), m_pageID);
}
+#if MERGE_WHEEL_EVENTS
+static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
+{
+ if (a.position() != b.position())
+ return false;
+ if (a.globalPosition() != b.globalPosition())
+ return false;
+ if (a.modifiers() != b.modifiers())
+ return false;
+ if (a.granularity() != b.granularity())
+ return false;
+#if PLATFORM(MAC)
+ if (a.phase() != b.phase())
+ return false;
+ if (a.momentumPhase() != b.momentumPhase())
+ return false;
+ if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
+ return false;
+#endif
+
+ return true;
+}
+
+static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
+{
+ ASSERT(canCoalesce(a, b));
+
+ FloatSize mergedDelta = a.delta() + b.delta();
+ FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
+
+#if PLATFORM(MAC)
+ return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp(), b.directionInvertedFromDevice());
+#else
+ return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
+#endif
+}
+#endif // MERGE_WHEEL_EVENTS
+
+static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
+{
+ ASSERT(!queue.isEmpty());
+ ASSERT(coalescedEvents.isEmpty());
+
+#if MERGE_WHEEL_EVENTS
+ NativeWebWheelEvent firstEvent = queue.takeFirst();
+ coalescedEvents.append(firstEvent);
+
+ WebWheelEvent event = firstEvent;
+ while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
+ NativeWebWheelEvent firstEvent = queue.takeFirst();
+ coalescedEvents.append(firstEvent);
+ event = coalesce(event, firstEvent);
+ }
+
+ return event;
+#else
+ while (!queue.isEmpty())
+ coalescedEvents.append(queue.takeFirst());
+ return coalescedEvents.last();
+#endif
+}
+
void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
{
if (!isValid())
@@ -992,19 +1059,42 @@ void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
if (!m_currentlyProcessedWheelEvents.isEmpty()) {
m_wheelEventQueue.append(event);
+ if (m_wheelEventQueue.size() < wheelEventQueueSizeThreshold)
+ return;
+ // The queue has too many wheel events, so push a new event.
+ }
+
+ if (!m_wheelEventQueue.isEmpty()) {
+ processNextQueuedWheelEvent();
return;
}
- m_currentlyProcessedWheelEvents.append(event);
+ OwnPtr<Vector<NativeWebWheelEvent> > coalescedWheelEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
+ coalescedWheelEvent->append(event);
+ m_currentlyProcessedWheelEvents.append(coalescedWheelEvent.release());
+ sendWheelEvent(event);
+}
+
+void WebPageProxy::processNextQueuedWheelEvent()
+{
+ OwnPtr<Vector<NativeWebWheelEvent> > nextCoalescedEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
+ WebWheelEvent nextWheelEvent = coalescedWheelEvent(m_wheelEventQueue, *nextCoalescedEvent.get());
+ m_currentlyProcessedWheelEvents.append(nextCoalescedEvent.release());
+ sendWheelEvent(nextWheelEvent);
+}
+void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
+{
process()->responsivenessTimer()->start();
if (m_shouldSendEventsSynchronously) {
bool handled = false;
process()->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
didReceiveEvent(event.type(), handled);
- } else
- process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, event, canGoBack(), canGoForward()), 0);
+ return;
+ }
+
+ process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, event, canGoBack(), canGoForward()), 0);
}
void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
@@ -2309,12 +2399,13 @@ void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTest
m_uiClient.mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
}
-void WebPageProxy::missingPluginButtonClicked(const String& mimeType, const String& url, const String& pluginsPageURL)
+void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& url, const String& pluginsPageURL)
{
MESSAGE_CHECK_URL(url);
MESSAGE_CHECK_URL(pluginsPageURL);
- m_uiClient.missingPluginButtonClicked(this, mimeType, url, pluginsPageURL);
+ WKPluginUnavailabilityReason pluginUnavailabilityReason = static_cast<WKPluginUnavailabilityReason>(opaquePluginUnavailabilityReason);
+ m_uiClient.unavailablePluginButtonClicked(this, pluginUnavailabilityReason, mimeType, url, pluginsPageURL);
}
void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
@@ -2967,68 +3058,6 @@ void WebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
m_pageClient->setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
}
-#if MERGE_WHEEL_EVENTS
-static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
-{
- if (a.position() != b.position())
- return false;
- if (a.globalPosition() != b.globalPosition())
- return false;
- if (a.modifiers() != b.modifiers())
- return false;
- if (a.granularity() != b.granularity())
- return false;
-#if PLATFORM(MAC)
- if (a.phase() != b.phase())
- return false;
- if (a.momentumPhase() != b.momentumPhase())
- return false;
- if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
- return false;
-#endif
-
- return true;
-}
-
-static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
-{
- ASSERT(canCoalesce(a, b));
-
- FloatSize mergedDelta = a.delta() + b.delta();
- FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
-
-#if PLATFORM(MAC)
- return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp(), b.directionInvertedFromDevice());
-#else
- return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
-#endif
-}
-#endif
-
-static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
-{
- ASSERT(!queue.isEmpty());
- ASSERT(coalescedEvents.isEmpty());
-
-#if MERGE_WHEEL_EVENTS
- NativeWebWheelEvent firstEvent = queue.takeFirst();
- coalescedEvents.append(firstEvent);
-
- WebWheelEvent event = firstEvent;
- while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
- NativeWebWheelEvent firstEvent = queue.takeFirst();
- coalescedEvents.append(firstEvent);
- event = coalesce(event, firstEvent);
- }
-
- return event;
-#else
- while (!queue.isEmpty())
- coalescedEvents.append(queue.takeFirst());
- return coalescedEvents.last();
-#endif
-}
-
void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
{
WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
@@ -3091,19 +3120,14 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
case WebEvent::Wheel: {
ASSERT(!m_currentlyProcessedWheelEvents.isEmpty());
+ OwnPtr<Vector<NativeWebWheelEvent> > oldestCoalescedEvent = m_currentlyProcessedWheelEvents.takeFirst();
+
// FIXME: Dispatch additional events to the didNotHandleWheelEvent client function.
if (!handled && m_uiClient.implementsDidNotHandleWheelEvent())
- m_uiClient.didNotHandleWheelEvent(this, m_currentlyProcessedWheelEvents.last());
-
- m_currentlyProcessedWheelEvents.clear();
-
- if (!m_wheelEventQueue.isEmpty()) {
- WebWheelEvent newWheelEvent = coalescedWheelEvent(m_wheelEventQueue, m_currentlyProcessedWheelEvents);
-
- process()->responsivenessTimer()->start();
- process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, newWheelEvent, canGoBack(), canGoForward()), 0);
- }
+ m_uiClient.didNotHandleWheelEvent(this, oldestCoalescedEvent->last());
+ if (!m_wheelEventQueue.isEmpty())
+ processNextQueuedWheelEvent();
break;
}
@@ -3597,6 +3621,11 @@ void WebPageProxy::didFailToInitializePlugin(const String& mimeType)
m_loaderClient.didFailToInitializePlugin(this, mimeType);
}
+void WebPageProxy::didBlockInsecurePluginVersion(const String& mimeType)
+{
+ m_loaderClient.didBlockInsecurePluginVersion(this, mimeType);
+}
+
bool WebPageProxy::willHandleHorizontalScrollEvents() const
{
return !m_canShortCircuitHorizontalWheelEvents;