Title: [124050] trunk/Source/WebKit/blackberry
Revision
124050
Author
[email protected]
Date
2012-07-30 10:48:34 -0700 (Mon, 30 Jul 2012)

Log Message

[BlackBerry] Optimize the generation of selection details generation.
https://bugs.webkit.org/show_bug.cgi?id=92522

Reviewed by Antonio Gomes.

PR 179264.

Reduce the number of times we generate selection details notifications.

This removes several notifications that are handled by the standard
notification path and makes skipping duplicate notifications the default
so that only those that must generate a response do.

Reviewed Internally by Gen Mak.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::notifyTransformedContentsSizeChanged):
(BlackBerry::WebKit::WebPagePrivate::updateDelegatedOverlays):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::setElementUnfocused):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::setCaretPosition):
(BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
(BlackBerry::WebKit::SelectionHandler::setSelection):
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
* WebKitSupport/SelectionHandler.h:
(SelectionHandler):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (124049 => 124050)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-07-30 17:46:47 UTC (rev 124049)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-07-30 17:48:34 UTC (rev 124050)
@@ -2085,7 +2085,6 @@
     const IntSize size = transformedContentsSize();
     m_backingStore->d->contentsSizeChanged(size);
     m_client->contentsSizeChanged(size);
-    m_selectionHandler->selectionPositionChanged();
 }
 
 void WebPagePrivate::notifyTransformedScrollChanged()
@@ -3392,7 +3391,7 @@
     if (Platform::webKitThreadMessageClient()->isCurrentThread()) {
         // Must be called on the WebKit thread.
         if (m_selectionHandler->isSelectionActive())
-            m_selectionHandler->selectionPositionChanged(true /* visualChangeOnly */);
+            m_selectionHandler->selectionPositionChanged();
         if (m_inspectorOverlay)
             m_inspectorOverlay->update();
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (124049 => 124050)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-07-30 17:46:47 UTC (rev 124049)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-07-30 17:48:34 UTC (rev 124050)
@@ -1,3 +1,33 @@
+2012-07-30  Mike Fenton  <[email protected]>
+
+        [BlackBerry] Optimize the generation of selection details generation.
+        https://bugs.webkit.org/show_bug.cgi?id=92522
+
+        Reviewed by Antonio Gomes.
+
+        PR 179264.
+
+        Reduce the number of times we generate selection details notifications.
+
+        This removes several notifications that are handled by the standard
+        notification path and makes skipping duplicate notifications the default
+        so that only those that must generate a response do.
+
+        Reviewed Internally by Gen Mak.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::notifyTransformedContentsSizeChanged):
+        (BlackBerry::WebKit::WebPagePrivate::updateDelegatedOverlays):
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::setElementUnfocused):
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::setCaretPosition):
+        (BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
+        (BlackBerry::WebKit::SelectionHandler::setSelection):
+        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
+        * WebKitSupport/SelectionHandler.h:
+        (SelectionHandler):
+
 2012-07-30  Robin Cao  <[email protected]>
 
         [BlackBerry] Adapt to changes in the SharedArray platform API

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (124049 => 124050)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-07-30 17:46:47 UTC (rev 124049)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-07-30 17:48:34 UTC (rev 124050)
@@ -659,7 +659,6 @@
             notifyClientOfKeyboardVisibilityChange(false);
 
         m_webPage->m_client->inputFocusLost();
-        m_webPage->m_selectionHandler->selectionPositionChanged();
 
         // If the frame selection isn't focused, focus it.
         if (!m_currentFocusElement->document()->frame()->selection()->isFocused())

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp (124049 => 124050)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp	2012-07-30 17:46:47 UTC (rev 124049)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp	2012-07-30 17:48:34 UTC (rev 124050)
@@ -243,7 +243,7 @@
     WebCore::IntRect currentCaretRect = controller->selection().visibleStart().absoluteCaretBounds();
 
     if (relativePoint == DOMSupport::InvalidPoint || !shouldUpdateSelectionOrCaretForPoint(relativePoint, currentCaretRect)) {
-        selectionPositionChanged();
+        selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return;
     }
 
@@ -253,13 +253,15 @@
         if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
             m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character));
 
-        selectionPositionChanged();
+        // Send the selection changed in case this does not trigger a selection change to
+        // ensure the caret position is accurate. This may be a duplicate event.
+        selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return;
     }
 
     VisibleSelection newSelection(visibleCaretPosition);
     if (controller->selection() == newSelection) {
-        selectionPositionChanged();
+        selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return;
     }
 
@@ -403,7 +405,7 @@
     // Check if the handle movement is valid.
     if (!shouldUpdateSelectionOrCaretForPoint(relativeStart, currentStartCaretRect, true /* startCaret */)
         || !shouldUpdateSelectionOrCaretForPoint(relativeEnd, currentEndCaretRect, false /* startCaret */)) {
-        selectionPositionChanged();
+        selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return true;
     }
 
@@ -438,9 +440,9 @@
     if (shouldExtendSelectionInDirection(controller->selection(), character))
         m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character, Platform::KeyboardEvent::KeyDown, KEYMOD_SHIFT));
 
-    // Must send the selectionPositionChanged every time, sometimes this will duplicate but an accepted
-    // handleNavigationMove may not make an actual selection change.
-    selectionPositionChanged();
+    // Send the selection changed in case this does not trigger a selection change to
+    // ensure the caret position is accurate. This may be a duplicate event.
+    selectionPositionChanged(true /* forceUpdateWithoutChange */);
     return true;
 }
 
@@ -513,7 +515,7 @@
     }
 
     if (controller->selection() == newSelection) {
-        selectionPositionChanged();
+        selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return;
     }
 
@@ -525,20 +527,21 @@
 
     IntRectRegion unclippedRegion;
     regionForTextQuads(quads, unclippedRegion, false /* shouldClipToVisibleContent */);
-    if (!unclippedRegion.isEmpty()) {
-        // Check if the handles reversed position.
-        if (m_selectionActive && !newSelection.isBaseFirst())
-            m_webPage->m_client->notifySelectionHandlesReversed();
 
-        controller->setSelection(newSelection);
-
-        SelectionLog(LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated.");
-    } else {
+    if (unclippedRegion.isEmpty()) {
         // Requested selection results in an empty selection, skip this change.
-        selectionPositionChanged();
+        selectionPositionChanged(true /* forceUpdateWithoutChange */);
 
         SelectionLog(LogLevelWarn, "SelectionHandler::setSelection selection points invalid, selection not updated.");
+        return;
     }
+
+    // Check if the handles reversed position.
+    if (m_selectionActive && !newSelection.isBaseFirst())
+        m_webPage->m_client->notifySelectionHandlesReversed();
+
+    controller->setSelection(newSelection);
+    SelectionLog(LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated.");
 }
 
 // FIXME re-use this in context. Must be updated to include an option to return the href.
@@ -838,9 +841,9 @@
 
 // Note: This is the only function in SelectionHandler in which the coordinate
 // system is not entirely WebKit.
-void SelectionHandler::selectionPositionChanged(bool visualChangeOnly)
+void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
 {
-    SelectionLog(LogLevelInfo, "SelectionHandler::selectionPositionChanged visibleChangeOnly = %s", visualChangeOnly ? "true" : "false");
+    SelectionLog(LogLevelInfo, "SelectionHandler::selectionPositionChanged forceUpdateWithoutChange = %s", forceUpdateWithoutChange ? "true" : "false");
 
     // This method can get called during WebPage shutdown process.
     // If that is the case, just bail out since the client is not
@@ -883,7 +886,7 @@
 
     // If there is no change in selected text and the visual rects
     // have not changed then don't bother notifying anything.
-    if (visualChangeOnly && m_lastSelectionRegion.isEqual(unclippedRegion))
+    if (!forceUpdateWithoutChange && m_lastSelectionRegion.isEqual(unclippedRegion))
         return;
 
     m_lastSelectionRegion = unclippedRegion;

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h (124049 => 124050)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h	2012-07-30 17:46:47 UTC (rev 124049)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h	2012-07-30 17:48:34 UTC (rev 124050)
@@ -65,7 +65,7 @@
     void selectObject(WebCore::TextGranularity);
     void selectObject(WebCore::Node*);
 
-    void selectionPositionChanged(bool visualChangeOnly = false);
+    void selectionPositionChanged(bool forceUpdateWithoutChange = false);
 
     void setCaretPosition(const WebCore::IntPoint&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to