[BlackBerry] speed up text selection for large selections
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 22:17:27 +0000 (22:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 22:17:27 +0000 (22:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81536

When selecting large disjoint areas of text the cost
of calculating the IntRectRegion union becomes very
expensive. Simply placing all of the text quads into
the IntRectRegion is faster despite the larger memory
footprint and the additional calculations at render
time.

Patch by Tyler Abbott <tabbott@rim.com> on 2012-03-19
Reviewed by Rob Buis.

* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111259 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

index 1ed6254020bfef72096031ddb006ef20d02f8e4d..9849695c3d320f97a5e7cb0b8cad8327f7a1de98 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-19  Tyler Abbott  <tabbott@rim.com>
+
+        [BlackBerry] speed up text selection for large selections
+        https://bugs.webkit.org/show_bug.cgi?id=81536
+
+        When selecting large disjoint areas of text the cost
+        of calculating the IntRectRegion union becomes very
+        expensive. Simply placing all of the text quads into
+        the IntRectRegion is faster despite the larger memory
+        footprint and the additional calculations at render
+        time.
+
+        Reviewed by Rob Buis.
+
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection):
+
 2012-03-19  Mike Lattanzio  <mlattanzio@rim.com>
 
         [BlackBerry] Use BlackBerry::Platform::DeviceInfo to generate UserAgent
index 8385deedad1392c65794ddb6582ac7c295e469c4..9a8f88e543958e5ad01fd4b15cbdb048b0d01b3f 100644 (file)
@@ -112,15 +112,18 @@ void SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection(const Visibl
         // framePosition is in main frame coordinates.
         WebCore::IntPoint framePosition = m_webPage->frameOffset(m_webPage->focusedOrMainFrame());
 
-        // The ranges rect list is based on render elements and may include multiple adjacent rects.
-        // Use IntRectRegion to consolidate these rects into bands as well as a container to pass
-        // to the client.
+        // Convert the text quads into a more platform friendy
+        // IntRectRegion and adjust for subframes.
+        std::vector<Platform::IntRect> adjustedIntRects;
+        Platform::IntRect selectionBoundingBox;
         for (unsigned i = 0; i < quadList.size(); i++) {
             WebCore::IntRect enclosingRect = quadList[i].enclosingBoundingBox();
             enclosingRect.intersect(frameRect);
             enclosingRect.move(framePosition.x(), framePosition.y());
-            region = unionRegions(region, IntRectRegion(enclosingRect));
+            adjustedIntRects.push_back(enclosingRect);
+            selectionBoundingBox = unionOfRects(enclosingRect, selectionBoundingBox);
         }
+        region = IntRectRegion(selectionBoundingBox, adjustedIntRects.size(), adjustedIntRects);
     }
 }