Bug 31099
| Summary: | [Qt] Add a way to access text nodes tree with QWebElement | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Benjamin Poulain <benjamin> |
| Component: | WebKit Qt | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Enhancement | CC: | abecsi, benjamin, cmarcelo, hausmann, kenneth, kling, paul.masurel, robert, skyul, tonikitoo |
| Priority: | P3 | Keywords: | Qt, QtTriaged |
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
| Bug Depends on: | 48957 | ||
| Bug Blocks: | |||
Benjamin Poulain
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Kenneth Rohde Christiansen
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
Maybe it should be not blocking 2.1 API metabug(?)
Paul Masurel
Meanwhile, has anyone found any workaround?
Benjamin Poulain
(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
=== 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.