|
Lines 757-768
DOM::Document KHTMLPart::document() cons
Link Here
|
| 757 |
return d->m_doc; |
757 |
return d->m_doc; |
| 758 |
} |
758 |
} |
| 759 |
|
759 |
|
| 760 |
|
|
|
| 761 |
KParts::BrowserExtension *KHTMLPart::browserExtension() const |
760 |
KParts::BrowserExtension *KHTMLPart::browserExtension() const |
| 762 |
{ |
761 |
{ |
| 763 |
return d->m_extension; |
762 |
return d->m_extension; |
| 764 |
} |
763 |
} |
| 765 |
|
764 |
|
|
|
765 |
KParts::BrowserHostExtension *KHTMLPart::browserHostExtension() const |
| 766 |
{ |
| 767 |
return d->m_hostExtension; |
| 768 |
} |
| 769 |
|
| 766 |
KHTMLView *KHTMLPart::view() const |
770 |
KHTMLView *KHTMLPart::view() const |
| 767 |
{ |
771 |
{ |
| 768 |
return d->m_view; |
772 |
return d->m_view; |
|
Lines 880-908
QVariant KHTMLPart::crossFrameExecuteScr
Link Here
|
| 880 |
// we always allow these |
884 |
// we always allow these |
| 881 |
} |
885 |
} |
| 882 |
else { |
886 |
else { |
| 883 |
while (destpart->parentPart()) |
887 |
destpart = findFrame(target); |
| 884 |
destpart = destpart->parentPart(); |
|
|
| 885 |
destpart = destpart->findFrame(target); |
| 886 |
|
| 887 |
if (!destpart) |
888 |
if (!destpart) |
| 888 |
destpart = this; // ### doesn't make sense, does it? |
889 |
destpart = this; |
| 889 |
} |
890 |
} |
| 890 |
|
891 |
|
| 891 |
// easy way out? |
892 |
// easy way out? |
| 892 |
if (destpart == this) |
893 |
if (destpart == this) |
| 893 |
return executeScript(DOM::Node(), script); |
894 |
return executeScript(DOM::Node(), script); |
| 894 |
|
895 |
|
| 895 |
|
|
|
| 896 |
// now compare the domains |
896 |
// now compare the domains |
| 897 |
if (!destpart->htmlDocument().isNull() && |
897 |
if (destpart->checkFrameAccess(this)) |
| 898 |
!htmlDocument().isNull()) { |
898 |
return destpart->executeScript(DOM::Node(), script); |
| 899 |
DOM::DOMString actDomain = htmlDocument().domain(); |
|
|
| 900 |
DOM::DOMString destDomain = destpart->htmlDocument().domain(); |
| 901 |
|
| 902 |
if (actDomain == destDomain) |
| 903 |
return destpart->executeScript(DOM::Node(), script); |
| 904 |
} |
| 905 |
|
| 906 |
|
899 |
|
| 907 |
// eww, something went wrong. better execute it in our frame |
900 |
// eww, something went wrong. better execute it in our frame |
| 908 |
return executeScript(DOM::Node(), script); |
901 |
return executeScript(DOM::Node(), script); |
|
Lines 3358-3364
void KHTMLPart::urlSelected( const QStri
Link Here
|
| 3358 |
if ( hasTarget ) |
3351 |
if ( hasTarget ) |
| 3359 |
{ |
3352 |
{ |
| 3360 |
// unknown frame names should open in a new window. |
3353 |
// unknown frame names should open in a new window. |
| 3361 |
khtml::ChildFrame *frame = recursiveFrameRequest( cURL, args, false ); |
3354 |
khtml::ChildFrame *frame = recursiveFrameRequest( this, cURL, args, false ); |
| 3362 |
if ( frame ) |
3355 |
if ( frame ) |
| 3363 |
{ |
3356 |
{ |
| 3364 |
args.metaData()["referrer"] = d->m_referrer; |
3357 |
args.metaData()["referrer"] = d->m_referrer; |
|
Lines 4364-4369
void KHTMLPart::slotChildDocCreated()
Link Here
|
| 4364 |
void KHTMLPart::slotChildURLRequest( const KURL &url, const KParts::URLArgs &args ) |
4357 |
void KHTMLPart::slotChildURLRequest( const KURL &url, const KParts::URLArgs &args ) |
| 4365 |
{ |
4358 |
{ |
| 4366 |
khtml::ChildFrame *child = frame( sender()->parent() ); |
4359 |
khtml::ChildFrame *child = frame( sender()->parent() ); |
|
|
4360 |
KHTMLPart *callingHtmlPart = const_cast<KHTMLPart *>(dynamic_cast<const KHTMLPart *>(sender())); |
| 4367 |
|
4361 |
|
| 4368 |
// TODO: handle child target correctly! currently the script are always executed fur the parent |
4362 |
// TODO: handle child target correctly! currently the script are always executed fur the parent |
| 4369 |
QString urlStr = url.url(); |
4363 |
QString urlStr = url.url(); |
|
Lines 4395-4401
void KHTMLPart::slotChildURLRequest( con
Link Here
|
| 4395 |
} |
4389 |
} |
| 4396 |
else if ( frameName != QString::fromLatin1( "_self" ) ) |
4390 |
else if ( frameName != QString::fromLatin1( "_self" ) ) |
| 4397 |
{ |
4391 |
{ |
| 4398 |
khtml::ChildFrame *_frame = recursiveFrameRequest( url, args ); |
4392 |
khtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart, url, args ); |
| 4399 |
|
4393 |
|
| 4400 |
if ( !_frame ) |
4394 |
if ( !_frame ) |
| 4401 |
{ |
4395 |
{ |
|
Lines 4437-4482
khtml::ChildFrame *KHTMLPart::frame( con
Link Here
|
| 4437 |
return 0L; |
4431 |
return 0L; |
| 4438 |
} |
4432 |
} |
| 4439 |
|
4433 |
|
| 4440 |
//#define DEBUG_FINDFRAME |
4434 |
#define DEBUG_FINDFRAME |
| 4441 |
|
4435 |
|
| 4442 |
KHTMLPart *KHTMLPart::findFrame( const QString &f ) |
4436 |
bool KHTMLPart::checkFrameAccess(KHTMLPart *callingHtmlPart) |
| 4443 |
{ |
4437 |
{ |
|
|
4438 |
if (callingHtmlPart == this) |
| 4439 |
return true; // trivial |
| 4440 |
|
| 4441 |
if (htmlDocument().isNull()) { |
| 4444 |
#ifdef DEBUG_FINDFRAME |
4442 |
#ifdef DEBUG_FINDFRAME |
| 4445 |
kdDebug(6050) << "KHTMLPart::findFrame '" << f << "'" << endl; |
4443 |
kdDebug(6050) << "KHTMLPart::checkFrameAccess: Empty part " << this << " URL = " << m_url << endl; |
| 4446 |
FrameIt it2 = d->m_frames.begin(); |
|
|
| 4447 |
FrameIt end = d->m_frames.end(); |
| 4448 |
for (; it2 != end; ++it2 ) |
| 4449 |
kdDebug(6050) << " - having frame '" << (*it2).m_name << "'" << endl; |
| 4450 |
#endif |
4444 |
#endif |
| 4451 |
// ### http://www.w3.org/TR/html4/appendix/notes.html#notes-frames |
4445 |
return false; // we are empty? |
| 4452 |
ConstFrameIt it = d->m_frames.find( f ); |
4446 |
} |
| 4453 |
if ( it == d->m_frames.end() ) |
4447 |
|
| 4454 |
{ |
4448 |
// now compare the domains |
|
|
4449 |
if (callingHtmlPart && !callingHtmlPart->htmlDocument().isNull() && |
| 4450 |
!htmlDocument().isNull()) { |
| 4451 |
DOM::DOMString actDomain = callingHtmlPart->htmlDocument().domain(); |
| 4452 |
DOM::DOMString destDomain = htmlDocument().domain(); |
| 4453 |
|
| 4455 |
#ifdef DEBUG_FINDFRAME |
4454 |
#ifdef DEBUG_FINDFRAME |
| 4456 |
kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " not found" << endl; |
4455 |
kdDebug(6050) << "KHTMLPart::checkFrameAccess: actDomain = '" << actDomain.string() << "' destDomain = '" << destDomain.string() << "'" << endl; |
| 4457 |
#endif |
4456 |
#endif |
| 4458 |
return 0L; |
4457 |
|
|
|
4458 |
if (actDomain == destDomain) |
| 4459 |
return true; |
| 4459 |
} |
4460 |
} |
| 4460 |
else { |
|
|
| 4461 |
KParts::ReadOnlyPart *p = (*it).m_part; |
| 4462 |
if ( p && p->inherits( "KHTMLPart" )) |
| 4463 |
{ |
| 4464 |
#ifdef DEBUG_FINDFRAME |
4461 |
#ifdef DEBUG_FINDFRAME |
| 4465 |
kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " is a KHTMLPart, ok" << endl; |
4462 |
else |
|
|
4463 |
{ |
| 4464 |
kdDebug(6050) << "KHTMLPart::checkFrameAccess: Unknown part/domain " << callingHtmlPart << " tries to access part " << this << endl; |
| 4465 |
} |
| 4466 |
#endif |
4466 |
#endif |
| 4467 |
return (KHTMLPart*)p; |
4467 |
return false; |
| 4468 |
} |
4468 |
} |
| 4469 |
else |
4469 |
|
| 4470 |
{ |
4470 |
KHTMLPart * |
|
|
4471 |
KHTMLPart::findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame ) |
| 4472 |
{ |
| 4471 |
#ifdef DEBUG_FINDFRAME |
4473 |
#ifdef DEBUG_FINDFRAME |
| 4472 |
if (p) |
4474 |
kdDebug(6050) << "KHTMLPart::findFrameParent: this = " << this << " URL = " << m_url << " findFrameParent( " << f << " )" << endl; |
| 4473 |
kdWarning() << "KHTMLPart::findFrame frame " << f << " found but isn't a KHTMLPart ! " << p->className() << endl; |
4475 |
#endif |
| 4474 |
else |
4476 |
// Check access |
| 4475 |
kdWarning() << "KHTMLPart::findFrame frame " << f << " found but m_part=0L" << endl; |
4477 |
KHTMLPart *callingHtmlPart = dynamic_cast<KHTMLPart *>(callingPart); |
|
|
4478 |
|
| 4479 |
if (!checkFrameAccess(callingHtmlPart)) |
| 4480 |
return 0; |
| 4481 |
|
| 4482 |
FrameIt it = d->m_frames.find( f ); |
| 4483 |
FrameIt end = d->m_frames.end(); |
| 4484 |
if ( it != end ) |
| 4485 |
{ |
| 4486 |
#ifdef DEBUG_FINDFRAME |
| 4487 |
kdDebug(6050) << "KHTMLPart::findFrameParent: FOUND!" << endl; |
| 4476 |
#endif |
4488 |
#endif |
| 4477 |
return 0L; |
4489 |
if (childFrame) |
|
|
4490 |
*childFrame = &(*it); |
| 4491 |
return this; |
| 4492 |
} |
| 4493 |
|
| 4494 |
it = d->m_frames.begin(); |
| 4495 |
for (; it != end; ++it ) |
| 4496 |
{ |
| 4497 |
KParts::ReadOnlyPart *p = (*it).m_part; |
| 4498 |
if ( p && p->inherits( "KHTMLPart" )) |
| 4499 |
{ |
| 4500 |
KHTMLPart *frameParent = static_cast<KHTMLPart*>(p)->findFrameParent(callingPart, f, childFrame); |
| 4501 |
if (frameParent) |
| 4502 |
return frameParent; |
| 4478 |
} |
4503 |
} |
| 4479 |
} |
4504 |
} |
|
|
4505 |
return 0; |
| 4506 |
} |
| 4507 |
|
| 4508 |
|
| 4509 |
KHTMLPart *KHTMLPart::findFrame( const QString &f ) |
| 4510 |
{ |
| 4511 |
khtml::ChildFrame *childFrame; |
| 4512 |
KHTMLPart *parentFrame = findFrameParent(this, f, &childFrame); |
| 4513 |
if (parentFrame) |
| 4514 |
{ |
| 4515 |
KParts::ReadOnlyPart *p = childFrame->m_part; |
| 4516 |
if ( p && p->inherits( "KHTMLPart" )) |
| 4517 |
return static_cast<KHTMLPart *>(p); |
| 4518 |
} |
| 4519 |
return 0; |
| 4480 |
} |
4520 |
} |
| 4481 |
|
4521 |
|
| 4482 |
KParts::ReadOnlyPart *KHTMLPart::currentFrame() const |
4522 |
KParts::ReadOnlyPart *KHTMLPart::currentFrame() const |
|
Lines 4514-4550
KHTMLPart *KHTMLPart::parentPart()
Link Here
|
| 4514 |
return (KHTMLPart *)parent(); |
4554 |
return (KHTMLPart *)parent(); |
| 4515 |
} |
4555 |
} |
| 4516 |
|
4556 |
|
| 4517 |
khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args, |
4557 |
khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KURL &url, |
| 4518 |
bool callParent ) |
4558 |
const KParts::URLArgs &args, bool callParent ) |
| 4519 |
{ |
4559 |
{ |
| 4520 |
FrameIt it = d->m_frames.find( args.frameName ); |
4560 |
#ifdef DEBUG_FINDFRAME |
| 4521 |
|
4561 |
kdDebug( 6050 ) << "KHTMLPart::recursiveFrameRequest this = " << this << ", frame = " << args.frameName << ", url = " << url << endl; |
| 4522 |
if ( it != d->m_frames.end() ) |
4562 |
#endif |
| 4523 |
return &(*it); |
4563 |
khtml::ChildFrame *childFrame; |
| 4524 |
|
4564 |
KHTMLPart *childPart = findFrameParent(callingHtmlPart, args.frameName, &childFrame); |
| 4525 |
it = d->m_frames.begin(); |
4565 |
if (childPart) |
| 4526 |
FrameIt end = d->m_frames.end(); |
4566 |
{ |
| 4527 |
for (; it != end; ++it ) |
4567 |
if (childPart == this) |
| 4528 |
if ( (*it).m_part && (*it).m_part->inherits( "KHTMLPart" ) ) |
4568 |
return childFrame; |
| 4529 |
{ |
4569 |
|
| 4530 |
KHTMLPart *childPart = (KHTMLPart *)(KParts::ReadOnlyPart *)(*it).m_part; |
4570 |
childPart->requestObject( childFrame, url, args ); |
| 4531 |
|
4571 |
return 0; |
| 4532 |
khtml::ChildFrame *res = childPart->recursiveFrameRequest( url, args, false ); |
4572 |
} |
| 4533 |
if ( !res ) |
|
|
| 4534 |
continue; |
| 4535 |
|
| 4536 |
childPart->requestObject( res, url, args ); |
| 4537 |
return 0L; |
| 4538 |
} |
| 4539 |
|
4573 |
|
| 4540 |
if ( parentPart() && callParent ) |
4574 |
if ( parentPart() && callParent ) |
| 4541 |
{ |
4575 |
{ |
| 4542 |
khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( url, args ); |
4576 |
khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( callingHtmlPart, url, args, callParent ); |
| 4543 |
|
4577 |
|
| 4544 |
if ( res ) |
4578 |
if ( res ) |
| 4545 |
parentPart()->requestObject( res, url, args ); |
4579 |
parentPart()->requestObject( res, url, args ); |
| 4546 |
|
|
|
| 4547 |
return 0L; |
| 4548 |
} |
4580 |
} |
| 4549 |
|
4581 |
|
| 4550 |
return 0L; |
4582 |
return 0L; |
|
Lines 4552-4558
khtml::ChildFrame *KHTMLPart::recursiveF
Link Here
|
| 4552 |
|
4584 |
|
| 4553 |
void KHTMLPart::saveState( QDataStream &stream ) |
4585 |
void KHTMLPart::saveState( QDataStream &stream ) |
| 4554 |
{ |
4586 |
{ |
| 4555 |
kdDebug( 6050 ) << "KHTMLPart::saveState saving URL " << m_url.url() << endl; |
4587 |
kdDebug( 6050 ) << "KHTMLPart::saveState this = " << this << " saving URL " << m_url.url() << endl; |
| 4556 |
|
4588 |
|
| 4557 |
stream << m_url << (Q_INT32)d->m_view->contentsX() << (Q_INT32)d->m_view->contentsY() |
4589 |
stream << m_url << (Q_INT32)d->m_view->contentsX() << (Q_INT32)d->m_view->contentsY() |
| 4558 |
<< (Q_INT32) d->m_view->contentsWidth() << (Q_INT32) d->m_view->contentsHeight() << (Q_INT32) d->m_view->marginWidth() << (Q_INT32) d->m_view->marginHeight(); |
4590 |
<< (Q_INT32) d->m_view->contentsWidth() << (Q_INT32) d->m_view->contentsHeight() << (Q_INT32) d->m_view->marginWidth() << (Q_INT32) d->m_view->marginHeight(); |