-
leandrogracia@chromium.org authored
https://bugs.webkit.org/show_bug.cgi?id=93111 Reviewed by Adam Barth. Source/WebCore: Introduce the find-in-page coordinate system. This system tries to solve the unintuitive tickmark results presented in pages with multiple frames and scrolled contents where the find results might not be in the visible area of a frame, which might lead to tickmarks below the container frame. To achieve this, this coordinate system goes up the render tree normalizing the coordinates by the actual contents size of its container. This leads to tickmarks scaled to the visible size of their frame independently of its scroll. This coordinate system supports also CSS scroll:overflow, transforms and the different positions. Also add an auxiliary method to Range in order to provide a transform friendly way to retrieve the absolute coordinates of the enclosing bounding box without the adjustment operations that the existing enclosingRect method does. Tested by WebFrameTest WebKit unit test. * dom/Range.cpp: (WebCore::Range::transformFriendlyBoundingBox): add a transform-friendly equivalent of boundingBox. (WebCore): * dom/Range.h: move boundingBox to the group of non-transform-friendly methods. (Range): Source/WebKit/chromium: Implement the funcionality of the find-in-page match rects API in WebFrame. These methods keep a cache of the match rects in a special coordinate system (find-in-page coordinates) and update them on size changes. They also allow to recover the match closest to a given point, therefore enabling to move to find matches when tapping on their corresponding tickmarks. * WebKit.gyp: add FindInPageCoordinates.h / cpp. * src/ChromeClientImpl.cpp: (WebKit::ChromeClientImpl::contentsSizeChanged): propagate didChangeContentsSize to WebFrameImpl. * src/FindInPageCoordinates.cpp: Added. (WebKit): (WebKit::toNormalizedRect): auxiliary internal function. (WebKit::findInPageRectFromAbsoluteRect): main coordinate conversion function. (WebKit::findInPageRectFromRange): convenience conversion function for Ranges. * src/FindInPageCoordinates.h: Added. (WebCore): (WebKit): * src/WebFrameImpl.cpp: (WebKit::WebFrameImpl::FindMatch::FindMatch): find matches cache constructor. (WebKit): (WebKit::WebFrameImpl::find): clear match cache when appropriate and zoom into results on the Android port. (WebKit::WebFrameImpl::stopFinding): clear matches cache. (WebKit::WebFrameImpl::scopeStringMatches): add new results to the matches cache. (WebKit::WebFrameImpl::increaseMatchCount): update the matches cache version. (WebKit::WebFrameImpl::resetMatchCount): update the matches cache version. (WebKit::WebFrameImpl::findMatchMarkersVersion): new API providing the matches cache version. (WebKit::WebFrameImpl::clearFindMatchesCache): internal utility method to reset the matches cache. (WebKit::WebFrameImpl::isActiveMatchFrameValid): internal utility method to check if the local frame is still in the frame tree. (WebKit::WebFrameImpl::updateFindMatchRects): internal utility method to update the match result rects if required. (WebKit::WebFrameImpl::activeFindMatchRect): new API providing the active find match rect in find-in-page coordinates. (WebKit::WebFrameImpl::findMatchRects): new API returning the valid match rects in find-in-page coordinates. (WebKit::WebFrameImpl::appendFindMatchRects): internal utility method to concatenate the match results of multiple frames. (WebKit::WebFrameImpl::selectNearestFindMatch): new API selecting the find match closer to a point in find-in-page coordinates. (WebKit::WebFrameImpl::nearestFindMatch): internal utility method to find the nearest find match to a point in a frame. (WebKit::WebFrameImpl::selectFindMatch): internal utility method to select a match in the cache. (WebKit::WebFrameImpl::WebFrameImpl): initialization of new variables. (WebKit::WebFrameImpl::didChangeContentsSize): invalidate the cached match rect coordinates on frame content size changes. * src/WebFrameImpl.h: (WebCore): (WebFrameImpl): (WebKit::WebFrameImpl::activeMatchFrame): remove unrequired const. (WebKit::WebFrameImpl::activeMatch): expose the range of the active match to allow testing. (FindMatch): cache structure for find matches. * tests/WebFrameTest.cpp: new test case for find-in-page match rects. * tests/data/find_in_page.html: Added. Test case layout. * tests/data/find_in_page_frame.html: Added. Test case layout. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
5b94144f