bool setEnd(Range &r, const VisiblePosition &c)
{
    RangeImpl *ri = r.handle();
    if (!ri)
        return false;
    Position p = c.position();
    int code = 0;
    ri->setEnd(p.node(), p.offset(), code);
    return code == 0;
}
Ejemplo n.º 2
0
RangeImpl* RangeImpl::cloneRange() const
{
    if( fDetached) {
        throw DOM_DOMException(
            DOM_DOMException::INVALID_STATE_ERR, null);
    }

    RangeImpl* range = ((DocumentImpl*)fDocument.fImpl)->createRange();
    range->setStart(fStartContainer, fStartOffset);
    range->setEnd(fEndContainer, fEndOffset);

    return range;
}
Ejemplo n.º 3
0
bool operator==(const Range &a, const Range &b)
{
    RangeImpl *ai = a.handle();
    RangeImpl *bi = b.handle();
    if (ai == bi)
        return true;
    if (!ai || !bi)
        return false;
    bool ad = ai->isDetached();
    bool bd = bi->isDetached();
    if (ad && bd)
        return true;
    if (ad || bd)
        return false;
    return a.startContainer() == b.startContainer()
        && a.endContainer() == b.endContainer()
        && a.startOffset() == b.startOffset()
        && a.endOffset() == b.endOffset();
}