[Okular-devel] Epub - webkit, getting text bounds

Albert Astals Cid aacid at kde.org
Tue Jun 11 18:14:27 UTC 2013


El Dimarts, 11 de juny de 2013, a les 16:26:07, Jaydeep Solanki va escriure:
> The current version of QtWebkit works only with Qt5, will that be a problem
> ?

Yes, closest estimate for Qt5 based Okular is at least 1 year from now, i'd 
prefer if we have something that works on current Okular.

Cheers,
  Albert

> 
> Cheers,
> Jaydeep
> 
> On Mon, Jun 10, 2013 at 1:02 PM, Jaydeep Solanki <jaydp17 at gmail.com> wrote:
> > On Sat, Jun 8, 2013 at 9:28 PM, Albert Astals Cid <aacid at kde.org> wrote:
> >> El Divendres, 7 de juny de 2013, a les 23:35:41, Jaydeep Solanki va
> >> 
> >> escriure:
> >> > Will it be a good idea to look for something in QtWebkit source that
> >> > can
> >> > get us bounding rects ?
> >> 
> >> Makes sense, there is *something* in there that can select text, so there
> >> is
> >> information of where the text is.
> >> 
> >> Working on it.
> >> 
> >> Cheers,
> >> 
> >>   Albert
> >>   
> >> > Cheers,
> >> > Jaydeep
> >> > 
> >> > On Fri, Jun 7, 2013 at 3:41 AM, Jaydeep Solanki <jaydp17 at gmail.com>
> >> 
> >> wrote:
> >> > > But it will give the bounding rect of the HTML element, not the text.
> >> 
> >> We
> >> 
> >> > > can use the box of the HTML element to predict the bounding box of
> >> 
> >> text
> >> 
> >> > > with the help of font metrics, but it will fail in situations with an
> >> > > image
> >> > > or a floating element between text.
> >> > > Example: image <
> >> 
> >> http://s11.postimg.org/5ysz1z79v/wrapp_all_arround.png>
> >> 
> >> > > Cheers,
> >> > > Jaydeep
> >> > > 
> >> > > On Fri, Jun 7, 2013 at 2:41 AM, Albert Astals Cid <aacid at kde.org>
> >> 
> >> wrote:
> >> > >> El Dimarts, 4 de juny de 2013, a les 20:00:51, Jaydeep Solanki va
> >> > >> 
> >> > >> escriure:
> >> > >> > On Mon, Jun 3, 2013 at 2:43 AM, Albert Astals Cid <aacid at kde.org>
> >> > >> 
> >> > >> wrote:
> >> > >> > > El Dilluns, 3 de juny de 2013, a les 01:52:04, Jaydeep Solanki
> >> > >> > > va
> >> > >> 
> >> > >> escriure:
> >> > >> > > > Hi,
> >> > >> > > > While working on getting text bounds work I discovered that
> >> > >> > > > QWebFrame::hitTestContent(QPoint()) hits the outermost
> >> > >> > > > element,
> >> > >> 
> >> > >> inside
> >> > >> 
> >> > >> > > body.
> >> > >> > > 
> >> > >> > > > Consider the below HTML,
> >> > >> > > > 
> >> > >> > > > <section>
> >> > >> > > > <p id="p1">some text...</p>
> >> > >> > > > <div>...</div>
> >> > >> > > > <p id="p2">some other text..</p>
> >> > >> > > > </section>
> >> > >> > > > 
> >> > >> > > > Now we have two QPoints;
> >> > >> > > > QPoint pt1 => which points somewhere within p1
> >> > >> > > > QPoint pt2 => which points somewhere within p2
> >> > >> > > > 
> >> > >> > > > var ht1 = QWebFrame::hitTestContent(pt1);
> >> > >> > > > var ht2 = QWebFrame::hitTestContent(pt2);
> >> > >> > > 
> >> > >> > > Why are you using hitTestContent to get the data? Isn't there
> >> > >> 
> >> > >> something
> >> > >> 
> >> > >> > > better? What's your plan? call hitTestContent for all the points
> >> 
> >> or?
> >> 
> >> > >> > Yes, I agree traversing the DOM is a better idea.
> >> > >> > 
> >> > >> > I googled a bit & found that we cannot get the bounding rect of
> >> 
> >> text
> >> 
> >> > >> from
> >> > >> 
> >> > >> > webkit
> >> > >> > (source<
> >> 
> >> http://comments.gmane.org/gmane.os.opendarwin.webkit.qt/1130>),
> >> 
> >> > >> but
> >> > >> 
> >> > >> > we can get the bounding box of the HTML element. I don't get it,
> >> 
> >> why it
> >> 
> >> > >> > isn't possible, because in QWebView when we select any text, it
> >> 
> >> gets
> >> 
> >> > >> > highlighted, which is basically filling color in the bounding box
> >> 
> >> of
> >> 
> >> > >> > the
> >> > >> > text, which indirectly means that Webview knows the bounding
> >> 
> >> rects. Do
> >> 
> >> > >> > I
> >> > >> > make sense ?
> >> > >> > Please comment on this.
> >> > >> 
> >> > >> What about the suggestion in that very same url of using
> >> > >> qwebelement?
> >> > >> 
> >> > >> Cheers,
> >> > >> 
> >> > >>   Albert
> >> > >>   
> >> > >> > & if everything fails, QFontMetrics may be of some use. We can get
> >> 
> >> the
> >> 
> >> > >> font
> >> > >> 
> >> > >> > metrics, & using it + the bounding box of the HTML element, we can
> >> > >> 
> >> > >> predict
> >> > >> 
> >> > >> > the bounding rects.
> >> > >> > 
> >> > >> > Cheers,
> >> > >> > Jaydeep
> >> > >> > 
> >> > >> > > Cheers,
> >> > >> > > 
> >> > >> > >   Albert
> >> > >> > >   
> >> > >> > > > Analysing ht1 & ht2 turns out that both of them point to the
> >> > >> > > > section
> >> > >> > > > element, which seems to be a little problem. I'm searching for
> >> > >> > > > other
> >> > >> > > > ways
> >> > >> > > > to do it. If you have any idea to get it work, please share.
> >> > >> > > > 
> >> > >> > > > Cheers,
> >> > >> > > > Jaydeep
> >> > >> > > 
> >> > >> > > _______________________________________________
> >> > >> > > Okular-devel mailing list
> >> > >> > > Okular-devel at kde.org
> >> > >> > > https://mail.kde.org/mailman/listinfo/okular-devel
> >> > >> 
> >> > >> _______________________________________________
> >> > >> Okular-devel mailing list
> >> > >> Okular-devel at kde.org
> >> > >> https://mail.kde.org/mailman/listinfo/okular-devel
> >> 
> >> _______________________________________________
> >> Okular-devel mailing list
> >> Okular-devel at kde.org
> >> https://mail.kde.org/mailman/listinfo/okular-devel


More information about the Okular-devel mailing list