RESOLVED INVALID 31099
[Qt] Add a way to access text nodes tree with QWebElement
https://bugs.webkit.org/show_bug.cgi?id=31099
Summary [Qt] Add a way to access text nodes tree with QWebElement
Benjamin Poulain
Reported 2009-11-03 22:24:51 PST
There is no way to access text nodes children of QWebElement. This limit the use of the API. Here is an example How do I get "prefix" and "suffix" with QWebElement in the following snippet: "<div> prefix <img src=""/> suffix </div>" To solve this, we could introduce a new class to iterate over the content of the QWebElement (QWebElementIterator || QWebElementCusor). E.g.: QWebElementCursor cursor(element); while (cursor.next()) { if (cursor.isText()) { cursor.setHtml(QString("<p>%1</p>").arg(cursor.text())); //? int selectionOffset = cursor.textSelectionBeginning(); } else if (cursor.isElement()) { QWebElement child = cursor.element(); child.encloseWith("<div>"); } }
Attachments
Kenneth Rohde Christiansen
Comment 1 2009-11-09 06:36:46 PST
4.7 stuff definately. I have also had requests for iterating the text itself, and querying for size, position etc. This is useful for ebook readers etc that want to split text blocks to fit as much contents on a page as possible, and put all overflow to the next page. There are probably more usecases for this.
Antonio Gomes
Comment 2 2010-11-08 14:23:07 PST
Maybe it should be not blocking 2.1 API metabug(?)
Paul Masurel
Comment 3 2012-07-04 10:05:32 PDT
Meanwhile, has anyone found any workaround?
Benjamin Poulain
Comment 4 2012-07-04 14:04:25 PDT
(In reply to comment #3) > Meanwhile, has anyone found any workaround? I think this is pretty much dead after the switch of focus to WebKit2. I don't know what API will replace QWebElement (if any). I think the only way to workaround this is to use JavaScript to modify the DOM.
Jocelyn Turcotte
Comment 5 2014-02-03 03:15:53 PST
=== Bulk closing of Qt bugs === If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary. If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.
Note You need to log in before you can comment on or make changes to this bug.