2841
2841
ChildFrame *childFrame = childPart->d->m_frame;
2842
2842
if (!childFrame)
2844
return childFrame->m_partContainerElement;
2844
return childFrame->m_partContainerElement.data();
2847
khtml::SecurityOrigin* DocumentImpl::origin() const
2850
m_origin = SecurityOrigin::create(URL());
2851
return m_origin.get();
2854
void DocumentImpl::setOrigin(khtml::SecurityOrigin* newOrigin)
2856
assert(origin()->isEmpty());
2857
m_origin = newOrigin;
2847
2860
DOMString DocumentImpl::domain() const
2849
if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
2850
m_domain = URL().host(); // Initially set to the host
2862
return origin()->domain();
2854
2865
void DocumentImpl::setDomain(const DOMString &newDomain)
2856
if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
2857
m_domain = URL().host().toLower(); // Initially set to the host
2859
if ( m_domain.isEmpty() /*&& part() && part()->openedByJS()*/ )
2860
m_domain = newDomain.lower();
2867
// ### this test really should move to SecurityOrigin..
2868
DOMString oldDomain = origin()->domain();
2862
2870
// Both NS and IE specify that changing the domain is only allowed when
2863
2871
// the new domain is a suffix of the old domain.
2864
int oldLength = m_domain.length();
2872
int oldLength = oldDomain.length();
2865
2873
int newLength = newDomain.length();
2866
2874
if ( newLength < oldLength ) // e.g. newDomain=kde.org (7) and m_domain=www.kde.org (11)
2868
DOMString test = m_domain.copy();
2876
DOMString test = oldDomain.copy();
2869
2877
DOMString reference = newDomain.lower();
2870
2878
if ( test[oldLength - newLength - 1] == '.' ) // Check that it's a subdomain, not e.g. "de.org"
2872
2880
test.remove( 0, oldLength - newLength ); // now test is "kde.org" from m_domain
2873
2881
if ( test == reference ) // and we check that it's the same thing as newDomain
2874
m_domain = reference;
2882
m_origin->setDomainFromDOM( reference.string() );