mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

434 lines
15 KiB

  1. Index: khtml/khtml_ext.cpp
  2. ===================================================================
  3. RCS file: /home/kde/kdelibs/khtml/khtml_ext.cpp,v
  4. retrieving revision 1.85.2.2
  5. diff -u -p -r1.85.2.2 khtml_ext.cpp
  6. --- kde-old/khtml/khtml_ext.cpp 24 Apr 2004 08:20:46 -0000 1.85.2.2
  7. +++ kde-new/khtml/khtml_ext.cpp 3 Aug 2004 14:36:43 -0000
  8. @@ -646,6 +646,19 @@ bool KHTMLPartBrowserHostExtension::open
  9. return m_part->openURLInFrame( url, urlArgs );
  10. }
  11. +void KHTMLPartBrowserHostExtension::virtual_hook( int id, void *data )
  12. +{
  13. + if (id == VIRTUAL_FIND_FRAME_PARENT)
  14. + {
  15. + FindFrameParentParams *param = static_cast<FindFrameParentParams*>(data);
  16. + KHTMLPart *parentPart = m_part->findFrameParent(param->callingPart, param->frame);
  17. + if (parentPart)
  18. + param->parent = parentPart->browserHostExtension();
  19. + return;
  20. + }
  21. + BrowserHostExtension::virtual_hook( id, data );
  22. +}
  23. +
  24. // BCI: remove in KDE 4
  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 )
  27. Index: khtml/khtml_ext.h
  28. ===================================================================
  29. RCS file: /home/kde/kdelibs/khtml/khtml_ext.h,v
  30. retrieving revision 1.26.2.1
  31. diff -u -p -r1.26.2.1 khtml_ext.h
  32. --- kde-old/khtml/khtml_ext.h 29 Feb 2004 15:27:43 -0000 1.26.2.1
  33. +++ kde-new/khtml/khtml_ext.h 3 Aug 2004 14:36:43 -0000
  34. @@ -98,6 +98,9 @@ public:
  35. virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
  36. virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
  37. +
  38. +protected:
  39. + virtual void virtual_hook( int id, void* data );
  40. private:
  41. KHTMLPart *m_part;
  42. };
  43. Index: khtml/khtml_part.cpp
  44. ===================================================================
  45. RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
  46. retrieving revision 1.959.2.20
  47. diff -u -p -r1.959.2.20 khtml_part.cpp
  48. --- kde-old/khtml/khtml_part.cpp 29 Jun 2004 09:08:16 -0000 1.959.2.20
  49. +++ kde-new/khtml/khtml_part.cpp 3 Aug 2004 14:36:46 -0000
  50. @@ -757,12 +757,16 @@ DOM::Document KHTMLPart::document() cons
  51. return d->m_doc;
  52. }
  53. -
  54. KParts::BrowserExtension *KHTMLPart::browserExtension() const
  55. {
  56. return d->m_extension;
  57. }
  58. +KParts::BrowserHostExtension *KHTMLPart::browserHostExtension() const
  59. +{
  60. + return d->m_hostExtension;
  61. +}
  62. +
  63. KHTMLView *KHTMLPart::view() const
  64. {
  65. return d->m_view;
  66. @@ -880,29 +884,18 @@ QVariant KHTMLPart::crossFrameExecuteScr
  67. // we always allow these
  68. }
  69. else {
  70. - while (destpart->parentPart())
  71. - destpart = destpart->parentPart();
  72. - destpart = destpart->findFrame(target);
  73. -
  74. + destpart = findFrame(target);
  75. if (!destpart)
  76. - destpart = this; // ### doesn't make sense, does it?
  77. + destpart = this;
  78. }
  79. // easy way out?
  80. if (destpart == this)
  81. return executeScript(DOM::Node(), script);
  82. -
  83. // now compare the domains
  84. - if (!destpart->htmlDocument().isNull() &&
  85. - !htmlDocument().isNull()) {
  86. - DOM::DOMString actDomain = htmlDocument().domain();
  87. - DOM::DOMString destDomain = destpart->htmlDocument().domain();
  88. -
  89. - if (actDomain == destDomain)
  90. - return destpart->executeScript(DOM::Node(), script);
  91. - }
  92. -
  93. + if (destpart->checkFrameAccess(this))
  94. + return destpart->executeScript(DOM::Node(), script);
  95. // eww, something went wrong. better execute it in our frame
  96. return executeScript(DOM::Node(), script);
  97. @@ -3358,7 +3351,7 @@ void KHTMLPart::urlSelected( const QStri
  98. if ( hasTarget )
  99. {
  100. // unknown frame names should open in a new window.
  101. - khtml::ChildFrame *frame = recursiveFrameRequest( cURL, args, false );
  102. + khtml::ChildFrame *frame = recursiveFrameRequest( this, cURL, args, false );
  103. if ( frame )
  104. {
  105. args.metaData()["referrer"] = d->m_referrer;
  106. @@ -4364,6 +4357,7 @@ void KHTMLPart::slotChildDocCreated()
  107. void KHTMLPart::slotChildURLRequest( const KURL &url, const KParts::URLArgs &args )
  108. {
  109. khtml::ChildFrame *child = frame( sender()->parent() );
  110. + KHTMLPart *callingHtmlPart = const_cast<KHTMLPart *>(dynamic_cast<const KHTMLPart *>(sender()->parent()));
  111. // TODO: handle child target correctly! currently the script are always executed fur the parent
  112. QString urlStr = url.url();
  113. @@ -4395,7 +4389,7 @@ void KHTMLPart::slotChildURLRequest( con
  114. }
  115. else if ( frameName != QString::fromLatin1( "_self" ) )
  116. {
  117. - khtml::ChildFrame *_frame = recursiveFrameRequest( url, args );
  118. + khtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart, url, args );
  119. if ( !_frame )
  120. {
  121. @@ -4437,46 +4431,92 @@ khtml::ChildFrame *KHTMLPart::frame( con
  122. return 0L;
  123. }
  124. -//#define DEBUG_FINDFRAME
  125. +//#define DEBUG_FINDFRAME
  126. -KHTMLPart *KHTMLPart::findFrame( const QString &f )
  127. +bool KHTMLPart::checkFrameAccess(KHTMLPart *callingHtmlPart)
  128. {
  129. + if (callingHtmlPart == this)
  130. + return true; // trivial
  131. +
  132. + if (htmlDocument().isNull()) {
  133. #ifdef DEBUG_FINDFRAME
  134. - kdDebug(6050) << "KHTMLPart::findFrame '" << f << "'" << endl;
  135. - FrameIt it2 = d->m_frames.begin();
  136. - FrameIt end = d->m_frames.end();
  137. - for (; it2 != end; ++it2 )
  138. - kdDebug(6050) << " - having frame '" << (*it2).m_name << "'" << endl;
  139. + kdDebug(6050) << "KHTMLPart::checkFrameAccess: Empty part " << this << " URL = " << m_url << endl;
  140. #endif
  141. - // ### http://www.w3.org/TR/html4/appendix/notes.html#notes-frames
  142. - ConstFrameIt it = d->m_frames.find( f );
  143. - if ( it == d->m_frames.end() )
  144. - {
  145. + return false; // we are empty?
  146. + }
  147. +
  148. + // now compare the domains
  149. + if (callingHtmlPart && !callingHtmlPart->htmlDocument().isNull() &&
  150. + !htmlDocument().isNull()) {
  151. + DOM::DOMString actDomain = callingHtmlPart->htmlDocument().domain();
  152. + DOM::DOMString destDomain = htmlDocument().domain();
  153. +
  154. #ifdef DEBUG_FINDFRAME
  155. - kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " not found" << endl;
  156. + kdDebug(6050) << "KHTMLPart::checkFrameAccess: actDomain = '" << actDomain.string() << "' destDomain = '" << destDomain.string() << "'" << endl;
  157. #endif
  158. - return 0L;
  159. +
  160. + if (actDomain == destDomain)
  161. + return true;
  162. }
  163. - else {
  164. - KParts::ReadOnlyPart *p = (*it).m_part;
  165. - if ( p && p->inherits( "KHTMLPart" ))
  166. - {
  167. #ifdef DEBUG_FINDFRAME
  168. - kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " is a KHTMLPart, ok" << endl;
  169. + else
  170. + {
  171. + kdDebug(6050) << "KHTMLPart::checkFrameAccess: Unknown part/domain " << callingHtmlPart << " tries to access part " << this << endl;
  172. + }
  173. #endif
  174. - return (KHTMLPart*)p;
  175. - }
  176. - else
  177. - {
  178. + return false;
  179. +}
  180. +
  181. +KHTMLPart *
  182. +KHTMLPart::findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame )
  183. +{
  184. #ifdef DEBUG_FINDFRAME
  185. - if (p)
  186. - kdWarning() << "KHTMLPart::findFrame frame " << f << " found but isn't a KHTMLPart ! " << p->className() << endl;
  187. - else
  188. - kdWarning() << "KHTMLPart::findFrame frame " << f << " found but m_part=0L" << endl;
  189. + kdDebug(6050) << "KHTMLPart::findFrameParent: this = " << this << " URL = " << m_url << " findFrameParent( " << f << " )" << endl;
  190. +#endif
  191. + // Check access
  192. + KHTMLPart *callingHtmlPart = dynamic_cast<KHTMLPart *>(callingPart);
  193. +
  194. + if (!checkFrameAccess(callingHtmlPart))
  195. + return 0;
  196. +
  197. + FrameIt it = d->m_frames.find( f );
  198. + FrameIt end = d->m_frames.end();
  199. + if ( it != end )
  200. + {
  201. +#ifdef DEBUG_FINDFRAME
  202. + kdDebug(6050) << "KHTMLPart::findFrameParent: FOUND!" << endl;
  203. #endif
  204. - return 0L;
  205. + if (childFrame)
  206. + *childFrame = &(*it);
  207. + return this;
  208. + }
  209. +
  210. + it = d->m_frames.begin();
  211. + for (; it != end; ++it )
  212. + {
  213. + KParts::ReadOnlyPart *p = (*it).m_part;
  214. + if ( p && p->inherits( "KHTMLPart" ))
  215. + {
  216. + KHTMLPart *frameParent = static_cast<KHTMLPart*>(p)->findFrameParent(callingPart, f, childFrame);
  217. + if (frameParent)
  218. + return frameParent;
  219. }
  220. }
  221. + return 0;
  222. +}
  223. +
  224. +
  225. +KHTMLPart *KHTMLPart::findFrame( const QString &f )
  226. +{
  227. + khtml::ChildFrame *childFrame;
  228. + KHTMLPart *parentFrame = findFrameParent(this, f, &childFrame);
  229. + if (parentFrame)
  230. + {
  231. + KParts::ReadOnlyPart *p = childFrame->m_part;
  232. + if ( p && p->inherits( "KHTMLPart" ))
  233. + return static_cast<KHTMLPart *>(p);
  234. + }
  235. + return 0;
  236. }
  237. KParts::ReadOnlyPart *KHTMLPart::currentFrame() const
  238. @@ -4514,37 +4554,29 @@ KHTMLPart *KHTMLPart::parentPart()
  239. return (KHTMLPart *)parent();
  240. }
  241. -khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args,
  242. - bool callParent )
  243. +khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KURL &url,
  244. + const KParts::URLArgs &args, bool callParent )
  245. {
  246. - FrameIt it = d->m_frames.find( args.frameName );
  247. -
  248. - if ( it != d->m_frames.end() )
  249. - return &(*it);
  250. -
  251. - it = d->m_frames.begin();
  252. - FrameIt end = d->m_frames.end();
  253. - for (; it != end; ++it )
  254. - if ( (*it).m_part && (*it).m_part->inherits( "KHTMLPart" ) )
  255. - {
  256. - KHTMLPart *childPart = (KHTMLPart *)(KParts::ReadOnlyPart *)(*it).m_part;
  257. -
  258. - khtml::ChildFrame *res = childPart->recursiveFrameRequest( url, args, false );
  259. - if ( !res )
  260. - continue;
  261. -
  262. - childPart->requestObject( res, url, args );
  263. - return 0L;
  264. - }
  265. +#ifdef DEBUG_FINDFRAME
  266. + kdDebug( 6050 ) << "KHTMLPart::recursiveFrameRequest this = " << this << ", frame = " << args.frameName << ", url = " << url << endl;
  267. +#endif
  268. + khtml::ChildFrame *childFrame;
  269. + KHTMLPart *childPart = findFrameParent(callingHtmlPart, args.frameName, &childFrame);
  270. + if (childPart)
  271. + {
  272. + if (childPart == this)
  273. + return childFrame;
  274. +
  275. + childPart->requestObject( childFrame, url, args );
  276. + return 0;
  277. + }
  278. if ( parentPart() && callParent )
  279. {
  280. - khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( url, args );
  281. + khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( callingHtmlPart, url, args, callParent );
  282. - if ( res )
  283. - parentPart()->requestObject( res, url, args );
  284. -
  285. - return 0L;
  286. + if ( res )
  287. + parentPart()->requestObject( res, url, args );
  288. }
  289. return 0L;
  290. @@ -4552,7 +4584,7 @@ khtml::ChildFrame *KHTMLPart::recursiveF
  291. void KHTMLPart::saveState( QDataStream &stream )
  292. {
  293. - kdDebug( 6050 ) << "KHTMLPart::saveState saving URL " << m_url.url() << endl;
  294. + kdDebug( 6050 ) << "KHTMLPart::saveState this = " << this << " saving URL " << m_url.url() << endl;
  295. stream << m_url << (Q_INT32)d->m_view->contentsX() << (Q_INT32)d->m_view->contentsY()
  296. << (Q_INT32) d->m_view->contentsWidth() << (Q_INT32) d->m_view->contentsHeight() << (Q_INT32) d->m_view->marginWidth() << (Q_INT32) d->m_view->marginHeight();
  297. Index: khtml/khtml_part.h
  298. ===================================================================
  299. RCS file: /home/kde/kdelibs/khtml/khtml_part.h,v
  300. retrieving revision 1.248.2.5
  301. diff -u -p -r1.248.2.5 khtml_part.h
  302. --- kde-old/khtml/khtml_part.h 29 Jun 2004 09:08:16 -0000 1.248.2.5
  303. +++ kde-new/khtml/khtml_part.h 3 Aug 2004 14:36:47 -0000
  304. @@ -287,6 +287,7 @@ public:
  305. */
  306. KParts::BrowserExtension *browserExtension() const;
  307. KParts::LiveConnectExtension *liveConnectExtension( const khtml::RenderPart *) const;
  308. + KParts::BrowserHostExtension *browserHostExtension() const;
  309. /**
  310. * Returns a pointer to the HTML document's view.
  311. @@ -812,6 +813,16 @@ public:
  312. KHTMLPart *findFrame( const QString &f );
  313. /**
  314. + * @internal
  315. + * Recursively finds the part containing the frame with name @p f
  316. + * and checks if it is accessible by @p callingPart
  317. + * Returns 0L if no suitable frame can't be found.
  318. + * Returns parent part if a suitable frame was found and
  319. + * frame info in @p *childFrame
  320. + */
  321. + KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame=0 );
  322. +
  323. + /**
  324. * Return the current frame (the one that has focus)
  325. * Not necessarily a direct child of ours, framesets can be nested.
  326. * Returns "this" if this part isn't a frameset.
  327. @@ -1376,6 +1387,8 @@ private:
  328. bool restoreURL( const KURL &url );
  329. void emitSelectionChanged();
  330. + // Returns whether callingHtmlPart may access this part
  331. + bool checkFrameAccess(KHTMLPart *callingHtmlPart);
  332. bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
  333. void startAutoScroll();
  334. void stopAutoScroll();
  335. @@ -1434,7 +1447,7 @@ private:
  336. DOM::DocumentImpl *xmlDocImpl() const;
  337. khtml::ChildFrame *frame( const QObject *obj );
  338. - khtml::ChildFrame *recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args, bool callParent = true );
  339. + khtml::ChildFrame *recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KURL &url, const KParts::URLArgs &args, bool callParent = true );
  340. bool checkLinkSecurity( const KURL &linkURL,const QString &message = QString::null, const QString &button = QString::null );
  341. QVariant executeScript( const QString& filename, int baseLine, const DOM::Node &n, const QString& script );
  342. Index: kparts/browserextension.cpp
  343. ===================================================================
  344. RCS file: /home/kde/kdelibs/kparts/browserextension.cpp,v
  345. retrieving revision 1.60.2.1
  346. diff -u -p -r1.60.2.1 browserextension.cpp
  347. --- kde-old/kparts/browserextension.cpp 10 Apr 2004 15:08:49 -0000 1.60.2.1
  348. +++ kde-new/kparts/browserextension.cpp 3 Aug 2004 14:36:48 -0000
  349. @@ -636,6 +636,17 @@ BrowserHostExtension *BrowserHostExtensi
  350. void BrowserExtension::virtual_hook( int, void* )
  351. { /*BASE::virtual_hook( id, data );*/ }
  352. +BrowserHostExtension *
  353. +BrowserHostExtension::findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame)
  354. +{
  355. + FindFrameParentParams param;
  356. + param.parent = 0;
  357. + param.callingPart = callingPart;
  358. + param.frame = frame;
  359. + virtual_hook(VIRTUAL_FIND_FRAME_PARENT, &param);
  360. + return param.parent;
  361. +}
  362. +
  363. void BrowserHostExtension::virtual_hook( int, void* )
  364. { /*BASE::virtual_hook( id, data );*/ }
  365. Index: kparts/browserextension.h
  366. ===================================================================
  367. RCS file: /home/kde/kdelibs/kparts/browserextension.h,v
  368. retrieving revision 1.110
  369. diff -u -p -r1.110 browserextension.h
  370. --- kde-old/kparts/browserextension.h 26 Sep 2003 07:13:13 -0000 1.110
  371. +++ kde-new/kparts/browserextension.h 3 Aug 2004 14:36:48 -0000
  372. @@ -671,10 +671,16 @@ public:
  373. *
  374. * Note that this method does not query the child objects recursively.
  375. */
  376. -
  377. virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
  378. /**
  379. + * @internal
  380. + * Returns the part that contains @p frame and that may be accessed
  381. + * by @p callingPart
  382. + */
  383. + BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame);
  384. +
  385. + /**
  386. * Opens the given url in a hosted child frame. The frame name is specified in the
  387. * frameName variable in the urlArgs argument structure (see KParts::URLArgs ) .
  388. */
  389. @@ -687,6 +693,19 @@ public:
  390. static BrowserHostExtension *childObject( QObject *obj );
  391. protected:
  392. + /** This 'enum' along with the structure below is NOT part of the public API.
  393. + * It's going to disappear in KDE 4.0 and is likely to change inbetween.
  394. + *
  395. + * @internal
  396. + */
  397. + enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
  398. + struct FindFrameParentParams
  399. + {
  400. + BrowserHostExtension *parent;
  401. + KParts::ReadOnlyPart *callingPart;
  402. + QString frame;
  403. + };
  404. +
  405. virtual void virtual_hook( int id, void* data );
  406. private:
  407. class BrowserHostExtensionPrivate;