1 Index: khtml/khtml_ext.cpp
2 ===================================================================
3 RCS file: /home/kde/kdelibs/khtml/khtml_ext.cpp,v
4 retrieving revision 1.55.2.3
5 diff -u -p -r1.55.2.3 khtml_ext.cpp
6 --- khtml/khtml_ext.cpp 29 Jun 2003 21:43:00 -0000 1.55.2.3
7 +++ khtml/khtml_ext.cpp 3 Aug 2004 16:15:15 -0000
8 @@ -546,6 +546,19 @@ bool KHTMLPartBrowserHostExtension::open
9 return m_part->openURLInFrame( url, urlArgs );
12 +void KHTMLPartBrowserHostExtension::virtual_hook( int id, void *data )
14 + if (id == VIRTUAL_FIND_FRAME_PARENT)
16 + FindFrameParentParams *param = static_cast<FindFrameParentParams*>(data);
17 + KHTMLPart *parentPart = m_part->findFrameParent(param->callingPart, param->frame);
19 + param->parent = parentPart->browserHostExtension();
22 + BrowserHostExtension::virtual_hook( id, data );
25 KHTMLZoomFactorAction::KHTMLZoomFactorAction( KHTMLPart *part, bool direction, const QString &text, const QString &icon, const QObject *receiver, const char *slot, QObject *parent, const char *name )
26 : KAction( text, icon, 0, receiver, slot, parent, name )
28 Index: khtml/khtml_ext.h
29 ===================================================================
30 RCS file: /home/kde/kdelibs/khtml/khtml_ext.h,v
31 retrieving revision 1.18.4.1
32 diff -u -p -r1.18.4.1 khtml_ext.h
33 --- khtml/khtml_ext.h 18 May 2003 12:34:35 -0000 1.18.4.1
34 +++ khtml/khtml_ext.h 3 Aug 2004 16:15:15 -0000
35 @@ -66,6 +66,9 @@ public:
36 virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
38 virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
41 + virtual void virtual_hook( int id, void* data );
45 Index: khtml/khtml_part.cpp
46 ===================================================================
47 RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
48 retrieving revision 1.770.2.28
49 diff -u -p -r1.770.2.28 khtml_part.cpp
50 --- khtml/khtml_part.cpp 10 Jul 2003 12:13:14 -0000 1.770.2.28
51 +++ khtml/khtml_part.cpp 3 Aug 2004 16:15:18 -0000
52 @@ -571,12 +571,16 @@ DOM::Document KHTMLPart::document() cons
57 KParts::BrowserExtension *KHTMLPart::browserExtension() const
59 return d->m_extension;
62 +KParts::BrowserHostExtension *KHTMLPart::browserHostExtension() const
64 + return d->m_hostExtension;
67 KHTMLView *KHTMLPart::view() const
70 @@ -797,7 +801,7 @@ void KHTMLPart::slotShowDocument( const
72 else if ( frameName != QString::fromLatin1( "_self" ) )
74 - khtml::ChildFrame *_frame = recursiveFrameRequest( url, args );
75 + khtml::ChildFrame *_frame = recursiveFrameRequest( this, url, args );
79 @@ -2675,7 +2679,7 @@ void KHTMLPart::urlSelected( const QStri
82 // unknown frame names should open in a new window.
83 - khtml::ChildFrame *frame = recursiveFrameRequest( cURL, args, false );
84 + khtml::ChildFrame *frame = recursiveFrameRequest( this, cURL, args, false );
87 args.metaData()["referrer"] = d->m_referrer;
88 @@ -3584,6 +3588,7 @@ void KHTMLPart::slotChildDocCreated()
89 void KHTMLPart::slotChildURLRequest( const KURL &url, const KParts::URLArgs &args )
91 khtml::ChildFrame *child = frame( sender()->parent() );
92 + KHTMLPart *callingHtmlPart = const_cast<KHTMLPart *>(dynamic_cast<const KHTMLPart *>(sender()->parent()));
94 // TODO: handle child target correctly! currently the script are always executed fur the parent
95 QString urlStr = url.url();
96 @@ -3616,7 +3621,7 @@ void KHTMLPart::slotChildURLRequest( con
98 else if ( frameName != QString::fromLatin1( "_self" ) )
100 - khtml::ChildFrame *_frame = recursiveFrameRequest( url, args );
101 + khtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart, url, args );
105 @@ -3654,46 +3659,92 @@ khtml::ChildFrame *KHTMLPart::frame( con
109 -//#define DEBUG_FINDFRAME
110 +//#define DEBUG_FINDFRAME
112 -KHTMLPart *KHTMLPart::findFrame( const QString &f )
113 +bool KHTMLPart::checkFrameAccess(KHTMLPart *callingHtmlPart)
115 + if (callingHtmlPart == this)
116 + return true; // trivial
118 + if (htmlDocument().isNull()) {
119 #ifdef DEBUG_FINDFRAME
120 - kdDebug(6050) << "KHTMLPart::findFrame '" << f << "'" << endl;
121 - FrameIt it2 = d->m_frames.begin();
122 - FrameIt end = d->m_frames.end();
123 - for (; it2 != end; ++it2 )
124 - kdDebug(6050) << " - having frame '" << (*it2).m_name << "'" << endl;
125 + kdDebug(6050) << "KHTMLPart::checkFrameAccess: Empty part " << this << " URL = " << m_url.prettyURL() << endl;
127 - // ### http://www.w3.org/TR/html4/appendix/notes.html#notes-frames
128 - ConstFrameIt it = d->m_frames.find( f );
129 - if ( it == d->m_frames.end() )
131 + return false; // we are empty?
134 + // now compare the domains
135 + if (callingHtmlPart && !callingHtmlPart->htmlDocument().isNull() &&
136 + !htmlDocument().isNull()) {
137 + DOM::DOMString actDomain = callingHtmlPart->htmlDocument().domain();
138 + DOM::DOMString destDomain = htmlDocument().domain();
140 #ifdef DEBUG_FINDFRAME
141 - kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " not found" << endl;
142 + kdDebug(6050) << "KHTMLPart::checkFrameAccess: actDomain = '" << actDomain.string() << "' destDomain = '" << destDomain.string() << "'" << endl;
146 + if (actDomain == destDomain)
150 - KParts::ReadOnlyPart *p = (*it).m_part;
151 - if ( p && p->inherits( "KHTMLPart" ))
153 #ifdef DEBUG_FINDFRAME
154 - kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " is a KHTMLPart, ok" << endl;
157 + kdDebug(6050) << "KHTMLPart::checkFrameAccess: Unknown part/domain " << callingHtmlPart << " tries to access part " << this << endl;
160 - return (KHTMLPart*)p;
168 +KHTMLPart::findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame )
170 #ifdef DEBUG_FINDFRAME
172 - kdWarning() << "KHTMLPart::findFrame frame " << f << " found but isn't a KHTMLPart ! " << p->className() << endl;
174 - kdWarning() << "KHTMLPart::findFrame frame " << f << " found but m_part=0L" << endl;
175 + kdDebug(6050) << "KHTMLPart::findFrameParent: this = " << this << " URL = " << m_url.prettyURL() << " findFrameParent( " << f << " )" << endl;
179 + KHTMLPart *callingHtmlPart = dynamic_cast<KHTMLPart *>(callingPart);
181 + if (!checkFrameAccess(callingHtmlPart))
184 + FrameIt it = d->m_frames.find( f );
185 + FrameIt end = d->m_frames.end();
188 +#ifdef DEBUG_FINDFRAME
189 + kdDebug(6050) << "KHTMLPart::findFrameParent: FOUND!" << endl;
192 + *childFrame = &(*it);
196 + it = d->m_frames.begin();
197 + for (; it != end; ++it )
199 + KParts::ReadOnlyPart *p = (*it).m_part;
200 + if ( p && p->inherits( "KHTMLPart" ))
202 + KHTMLPart *frameParent = static_cast<KHTMLPart*>(p)->findFrameParent(callingPart, f, childFrame);
204 + return frameParent;
211 +KHTMLPart *KHTMLPart::findFrame( const QString &f )
213 + khtml::ChildFrame *childFrame;
214 + KHTMLPart *parentFrame = findFrameParent(this, f, &childFrame);
217 + KParts::ReadOnlyPart *p = childFrame->m_part;
218 + if ( p && p->inherits( "KHTMLPart" ))
219 + return static_cast<KHTMLPart *>(p);
224 KParts::ReadOnlyPart *KHTMLPart::currentFrame() const
225 @@ -3731,37 +3782,29 @@ KHTMLPart *KHTMLPart::parentPart()
226 return (KHTMLPart *)parent();
229 -khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args,
231 +khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KURL &url,
232 + const KParts::URLArgs &args, bool callParent )
234 - FrameIt it = d->m_frames.find( args.frameName );
236 - if ( it != d->m_frames.end() )
239 - it = d->m_frames.begin();
240 - FrameIt end = d->m_frames.end();
241 - for (; it != end; ++it )
242 - if ( (*it).m_part && (*it).m_part->inherits( "KHTMLPart" ) )
244 - KHTMLPart *childPart = (KHTMLPart *)(KParts::ReadOnlyPart *)(*it).m_part;
246 - khtml::ChildFrame *res = childPart->recursiveFrameRequest( url, args, false );
250 - childPart->requestObject( res, url, args );
253 +#ifdef DEBUG_FINDFRAME
254 + kdDebug( 6050 ) << "KHTMLPart::recursiveFrameRequest this = " << this << ", frame = " << args.frameName << ", url = " << url.prettyURL() << endl;
256 + khtml::ChildFrame *childFrame;
257 + KHTMLPart *childPart = findFrameParent(callingHtmlPart, args.frameName, &childFrame);
260 + if (childPart == this)
263 + childPart->requestObject( childFrame, url, args );
267 if ( parentPart() && callParent )
269 - khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( url, args );
272 - parentPart()->requestObject( res, url, args );
273 + khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( callingHtmlPart, url, args, callParent );
277 + parentPart()->requestObject( res, url, args );
281 @@ -3769,7 +3812,7 @@ khtml::ChildFrame *KHTMLPart::recursiveF
283 void KHTMLPart::saveState( QDataStream &stream )
285 - kdDebug( 6050 ) << "KHTMLPart::saveState saving URL " << m_url.url() << endl;
286 + kdDebug( 6050 ) << "KHTMLPart::saveState this = " << this << " saving URL " << m_url.url() << endl;
288 stream << m_url << (Q_INT32)d->m_view->contentsX() << (Q_INT32)d->m_view->contentsY()
289 << (Q_INT32) d->m_view->contentsWidth() << (Q_INT32) d->m_view->contentsHeight() << (Q_INT32) d->m_view->marginWidth() << (Q_INT32) d->m_view->marginHeight();
290 Index: khtml/khtml_part.h
291 ===================================================================
292 RCS file: /home/kde/kdelibs/khtml/khtml_part.h,v
293 retrieving revision 1.197.2.6
294 diff -u -p -r1.197.2.6 khtml_part.h
295 --- khtml/khtml_part.h 10 Jul 2003 12:13:14 -0000 1.197.2.6
296 +++ khtml/khtml_part.h 3 Aug 2004 16:15:18 -0000
297 @@ -245,6 +245,8 @@ public:
299 KParts::BrowserExtension *browserExtension() const;
300 KParts::LiveConnectExtension *liveConnectExtension( const khtml::RenderPart *) const;
301 + KParts::BrowserHostExtension *browserHostExtension() const;
304 * Returns a pointer to the HTML document's view.
306 @@ -653,6 +655,16 @@ public:
307 KHTMLPart *findFrame( const QString &f );
311 + * Recursively finds the part containing the frame with name @p f
312 + * and checks if it is accessible by @p callingPart
313 + * Returns 0L if no suitable frame can't be found.
314 + * Returns parent part if a suitable frame was found and
315 + * frame info in @p *childFrame
317 + KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame=0 );
320 * Return the current frame (the one that has focus)
321 * Not necessarily a direct child of ours, framesets can be nested.
322 * Returns "this" if this part isn't a frameset.
323 @@ -1050,6 +1062,12 @@ private:
326 bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
330 + * Returns whether callingHtmlPart may access this part
332 + bool checkFrameAccess(KHTMLPart *callingHtmlPart);
334 void startAutoScroll();
335 void stopAutoScroll();
336 @@ -1103,7 +1121,7 @@ private:
337 DOM::DocumentImpl *xmlDocImpl() const;
338 khtml::ChildFrame *frame( const QObject *obj );
340 - khtml::ChildFrame *recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args, bool callParent = true );
341 + khtml::ChildFrame *recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KURL &url, const KParts::URLArgs &args, bool callParent = true );
343 bool checkLinkSecurity(const KURL &linkURL,const QString &message = QString::null, const QString &button = QString::null);
344 QVariant executeScript(QString filename, int baseLine, const DOM::Node &n, const QString &script);
345 Index: kparts/browserextension.cpp
346 ===================================================================
347 RCS file: /home/kde/kdelibs/kparts/browserextension.cpp,v
348 retrieving revision 1.40.2.3
349 diff -u -p -r1.40.2.3 browserextension.cpp
350 --- kparts/browserextension.cpp 15 Jul 2003 00:40:51 -0000 1.40.2.3
351 +++ kparts/browserextension.cpp 3 Aug 2004 16:15:19 -0000
352 @@ -599,6 +599,17 @@ BrowserHostExtension *BrowserHostExtensi
353 void BrowserExtension::virtual_hook( int, void* )
354 { /*BASE::virtual_hook( id, data );*/ }
356 +BrowserHostExtension *
357 +BrowserHostExtension::findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame)
359 + FindFrameParentParams param;
361 + param.callingPart = callingPart;
362 + param.frame = frame;
363 + virtual_hook(VIRTUAL_FIND_FRAME_PARENT, ¶m);
364 + return param.parent;
367 void BrowserHostExtension::virtual_hook( int, void* )
368 { /*BASE::virtual_hook( id, data );*/ }
370 Index: kparts/browserextension.h
371 ===================================================================
372 RCS file: /home/kde/kdelibs/kparts/browserextension.h,v
373 retrieving revision 1.94.2.2
374 diff -u -p -r1.94.2.2 browserextension.h
375 --- kparts/browserextension.h 18 May 2003 12:36:17 -0000 1.94.2.2
376 +++ kparts/browserextension.h 3 Aug 2004 16:15:19 -0000
377 @@ -610,10 +610,16 @@ public:
379 * Note that this method does not query the child objects recursively.
382 virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
386 + * Returns the part that contains @p frame and that may be accessed
387 + * by @p callingPart
389 + BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame);
392 * Opens the given url in a hosted child frame. The frame name is specified in the
393 * frameName variable in the urlArgs argument structure (see @ref KParts::URLArgs ) .
395 @@ -626,6 +632,19 @@ public:
396 static BrowserHostExtension *childObject( QObject *obj );
399 + /** This 'enum' along with the structure below is NOT part of the public API.
400 + * It's going to disappear in KDE 4.0 and is likely to change inbetween.
404 + enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
405 + struct FindFrameParentParams
407 + BrowserHostExtension *parent;
408 + KParts::ReadOnlyPart *callingPart;
412 virtual void virtual_hook( int id, void* data );
414 class BrowserHostExtensionPrivate;