Ejemplo n.º 1
0
DOMString TextImpl::toString(long long startOffset, long long endOffset) const
{
    DOMString str = nodeValue();
    if(endOffset >=0 || startOffset >0)
	str = str.copy(); //we are going to modify this, so make a copy.  I hope I'm doing this right.
    if(endOffset >= 0)
        str.truncate(endOffset);
    if(startOffset > 0)    //note the order of these 2 'if' statements so that it works right when n==m_startContainer==m_endContainer
        str.remove(0, startOffset);
    return textNeedsEscaping( this ) ? escapeHTML( str ) : str;
}
Ejemplo n.º 2
0
DOMString TextImpl::toString(long long startOffset, long long endOffset) const
{
    // FIXME: substitute entity references as needed!

    DOMString str = nodeValue();
    if(endOffset >=0 || startOffset >0)
	str = str.copy(); //we are going to modify this, so make a copy.  I hope I'm doing this right.
    if(endOffset >= 0)
        str.truncate(endOffset);
    if(startOffset > 0)    //note the order of these 2 'if' statements so that it works right when n==m_startContainer==m_endContainer
        str.remove(0, startOffset);
    return escapeHTML( str );
}
void HTMLDocumentImpl::setDomain(const DOMString &newDomain)
{
    if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
        m_domain = KURL(URL()).host().lower(); // Initially set to the host

    if ( m_domain.isEmpty() /*&& view() && view()->part()->openedByJS()*/ )
        m_domain = newDomain.lower();

    // Both NS and IE specify that changing the domain is only allowed when
    // the new domain is a suffix of the old domain.
    int oldLength = m_domain.length();
    int newLength = newDomain.length();
    if ( newLength < oldLength ) // e.g. newDomain=kde.org (7) and m_domain=www.kde.org (11)
    {
        DOMString test = m_domain.copy();
        DOMString reference = newDomain.lower();
        if ( test[oldLength - newLength - 1] == '.' ) // Check that it's a subdomain, not e.g. "de.org"
        {
            test.remove( 0, oldLength - newLength ); // now test is "kde.org" from m_domain
            if ( test == reference )                 // and we check that it's the same thing as newDomain
                m_domain = reference;
        }
    }
}