Will it be a good idea to look for something in QtWebkit source that can get us bounding rects ?
Cheers, Jaydeep On Fri, Jun 7, 2013 at 3:41 AM, Jaydeep Solanki <jayd...@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 <aa...@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 <aa...@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@kde.org >> > > https://mail.kde.org/mailman/listinfo/okular-devel >> _______________________________________________ >> Okular-devel mailing list >> Okular-devel@kde.org >> https://mail.kde.org/mailman/listinfo/okular-devel >> > >
_______________________________________________ Okular-devel mailing list Okular-devel@kde.org https://mail.kde.org/mailman/listinfo/okular-devel