davidedmundson added a comment.

  hypothetically (and this would still require a Qt change) if we could 
override loadResource would that be enough for doing what this is doing?

INLINE COMMENTS

> textsanitizer.cpp:41
> +
> +    QScopedPointer<QTextDocument> newDocument(new QTextDocument());
> +    newDocument->setHtml(text);

just make it on the stack?

> textsanitizer.cpp:59
> +            // all of this trouble already we might as well look at 
> everything.
> +            QUrl backgroundUrl = 
> format.property(QTextFormat::BackgroundImageUrl).toUrl();
> +            if (!backgroundUrl.isLocalFile()) {

format might not be valid here, does that cause a problem?

> textsanitizer.cpp:60
> +            QUrl backgroundUrl = 
> format.property(QTextFormat::BackgroundImageUrl).toUrl();
> +            if (!backgroundUrl.isLocalFile()) {
> +                format.setProperty(QTextFormat::BackgroundImageUrl, 
> QVariant());

probably better to do do:

!backgroundUrl.isEmpty() && !isLocalFile..

QTextFormat was still doing some processing at least.

> textsanitizer.cpp:86
> +
> +        // FIXME is there a better way?
> +        // we cannot just setHtml on the TextEdit's textDocument at the 
> beginning

(untested)

Make a QTextCursor on qqdoc->textDocument() and then you can insertFragment.
This way you can do it with only shallow copies, and all in a single pass over 
the original document.

Removing images becomes a lot easier then, as you just skip that fragment 
rather than trying to remove text.

REPOSITORY
  R120 Plasma Workspace

REVISION DETAIL
  https://phabricator.kde.org/D6673

To: broulik, #plasma, fvogt
Cc: davidedmundson, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, 
jensreuterberg, abetts, sebas, apol, mart, lukas

Reply via email to