TextIndicator for embedded PDFs is slightly offset
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Apr 2015 00:16:52 +0000 (00:16 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Apr 2015 00:16:52 +0000 (00:16 +0000)
commiteb9df52862d9ff4e5f1ca73fadb721c749fbab7b
tree3a394f0397700d286fcfc903ac6baa4a819a18dc
parentb8125284ac9fbc22df7fdc4f73127221c4b5e8d8
TextIndicator for embedded PDFs is slightly offset
https://bugs.webkit.org/show_bug.cgi?id=144172
<rdar://problem/20691304>

Reviewed by Tim Horton.

When I converted the existing DOM Range logic to work with PDFSelections, I omitted the
step where the font ascent was used to adjust the origin used for the TextIndicator. This
patch determines the correct ascent for the range of characters in the selection, and
adjusts the offset by the difference between the ascent and the height of the selection rect.

Also, since the PDFSelection only supplies the bounding rect for the selection, I calculate
an equivalent text bounding box by insetting the rect by half the size of the ascent.

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::scaleFactor): Add accessor for PDF scale factor.
* WebProcess/Plugins/PDF/PDFPlugin.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::dictionaryPopupInfoForPDFSelectionInPluginView): Adjusted to take the
font ascent and scale factor into account.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183297 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm