On Mon, Mar 3, 2014 at 5:19 PM, Boris Zbarsky <bzbar...@mit.edu> wrote:

> On 3/3/14 2:28 PM, Felipe G wrote:
>
>> A possible solution to that is to only pause the page that is being
>> translated (with,
>> say, EnterModalState) until we can finish working on it, while letting
>> other pages and the UI work normally.
>>
>
> The other pages can still modify the DOM of the page in question, right?
>  It'll just be a bit more rare...
>
>
That is true..  Although given the rarity of this case, I think I could
watch for changes and just bail out of the work if that happens.  Keeping
the page's script/events from running is probably the main thing to cover.



>
>  Another option exists if it's possible to make a fast copy of the whole
>> DOM, and then work on this snapshot'ed copy which is not live.
>>
>
> How feasible is just doing .innerHTML to do that, then doing some sort of
> async parse (e.g. XHR or DOMParser) to get a DOM snapshot?  That said, this
> would mean that you end up with a snapshot that's actual DOM stuff, on the
> main thread.
>
> Hmm ideally I need to keep (weak) references to the text nodes from the
page in order to replace their text when translation is ready.  If I do a
.innerHTML conversion back and forth I'll lose the refs.  In theory they
can be found again but it would require (again) walking the tree and
running heuristics on it, which is potentially worse..
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to