QWebPage CUT and JS range problem
-
I'm not sure how Qt implements the QwebPage::Cut action but it seems to be messing up my script functions implemented via the QtWebKit Bridge. I tried looking at the code but had trouble tracing the QwebPage::Cut action. From what little I was able to trace in the code it appears that the cut action is implemented via the JavaScriptCore modules and I'm wondering if this is where the problem lies. Hopefully someone reading this will be able to enlighten me on the following problem:
Using the bridge I created a namespace object with properties and methods. In this namespace I have an array where I store range clones. Supposedly these clones are not affected by a window selection or its range but when I execute the following line of (C++) code:
@page()->action(QWebPage::Cut)->activate(QAction::Trigger);@
I find that my cloned range offsets are changed. This is causing me some serious headaches and I'm looking for any advice on how to further isolate this problem.
NOTE: I tried the following two methods to clone a range
- @var setRange = range.cloneRange()@
- @var setRange=document.createRange();
setRange.setStart(range.startContainer,range.startOffset);
setRange.setEnd(range.endContainer,range.endOffset);@
Both methods are messed up by Qt's cut action.
-
FYI: Apparently one cannot depend on cloning a range and saving it but I found a cumbersome but effective solution. What I did was save the start and end nodes and their offsets separately. Then when I needed a saved range equivalent I used createRange() to form a temporary range object as needed.