]> git.pld-linux.org Git - packages/kdelibs.git/blob - post-3.1.5-kdelibs-htmlframes.patch
- unify macros
[packages/kdelibs.git] / post-3.1.5-kdelibs-htmlframes.patch
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 );
10  }
11  
12 +void KHTMLPartBrowserHostExtension::virtual_hook( int id, void *data )
13 +{ 
14 +  if (id == VIRTUAL_FIND_FRAME_PARENT)
15 +  {
16 +    FindFrameParentParams *param = static_cast<FindFrameParentParams*>(data);
17 +    KHTMLPart *parentPart = m_part->findFrameParent(param->callingPart, param->frame);
18 +    if (parentPart)
19 +       param->parent = parentPart->browserHostExtension();
20 +    return;
21 +  }
22 +  BrowserHostExtension::virtual_hook( id, data );
23 +}
24 +
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  {
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;
37  
38    virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
39 +
40 +protected:
41 +  virtual void virtual_hook( int id, void* data );
42  private:
43    KHTMLPart *m_part;
44  };
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
53      return d->m_doc;
54  }
55  
56 -
57  KParts::BrowserExtension *KHTMLPart::browserExtension() const
58  {
59    return d->m_extension;
60  }
61  
62 +KParts::BrowserHostExtension *KHTMLPart::browserHostExtension() const
63 +{
64 +  return d->m_hostExtension;
65 +}
66 +
67  KHTMLView *KHTMLPart::view() const
68  {
69    return d->m_view;
70 @@ -797,7 +801,7 @@ void KHTMLPart::slotShowDocument( const 
71      }
72      else if ( frameName != QString::fromLatin1( "_self" ) )
73      {
74 -      khtml::ChildFrame *_frame = recursiveFrameRequest( url, args );
75 +      khtml::ChildFrame *_frame = recursiveFrameRequest( this, url, args );
76  
77        if ( !_frame )
78        {
79 @@ -2675,7 +2679,7 @@ void KHTMLPart::urlSelected( const QStri
80    if ( hasTarget )
81    {
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 );
85      if ( frame )
86      {
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 )
90  {
91    khtml::ChildFrame *child = frame( sender()->parent() );
92 +  KHTMLPart *callingHtmlPart = const_cast<KHTMLPart *>(dynamic_cast<const KHTMLPart *>(sender()->parent()));
93  
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
97      }
98      else if ( frameName != QString::fromLatin1( "_self" ) )
99      {
100 -      khtml::ChildFrame *_frame = recursiveFrameRequest( url, args );
101 +      khtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart, url, args );
102  
103        if ( !_frame )
104        {
105 @@ -3654,46 +3659,92 @@ khtml::ChildFrame *KHTMLPart::frame( con
106      return 0L;
107  }
108  
109 -//#define DEBUG_FINDFRAME
110 +//#define DEBUG_FINDFRAME
111  
112 -KHTMLPart *KHTMLPart::findFrame( const QString &f )
113 +bool KHTMLPart::checkFrameAccess(KHTMLPart *callingHtmlPart)
114  {
115 +  if (callingHtmlPart == this)
116 +    return true; // trivial
117 +
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;
126  #endif
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() )
130 -  {
131 +    return false; // we are empty?
132 +  }
133 +
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();
139 +
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;
143  #endif
144 -    return 0L;
145 +
146 +    if (actDomain == destDomain)
147 +      return true;
148    }
149 -  else {
150 -    KParts::ReadOnlyPart *p = (*it).m_part;
151 -    if ( p && p->inherits( "KHTMLPart" ))
152 -    {
153  #ifdef DEBUG_FINDFRAME
154 -      kdDebug(6050) << "KHTMLPart::findFrame frame " << f << " is a KHTMLPart, ok" << endl;
155 +  else
156 +  {
157 +    kdDebug(6050) << "KHTMLPart::checkFrameAccess: Unknown part/domain " << callingHtmlPart << " tries to access part " << this << endl;
158 +  }
159  #endif
160 -      return (KHTMLPart*)p;
161 -    }
162 -    else
163 -    {
164 +  return false;
165 +}
166 +
167 +KHTMLPart *
168 +KHTMLPart::findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame )
169 +{
170  #ifdef DEBUG_FINDFRAME
171 -      if (p)
172 -        kdWarning() << "KHTMLPart::findFrame frame " << f << " found but isn't a KHTMLPart ! " << p->className() << endl;
173 -      else
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;
176  #endif
177 -      return 0L;
178 +  // Check access
179 +  KHTMLPart *callingHtmlPart = dynamic_cast<KHTMLPart *>(callingPart);
180 +  
181 +  if (!checkFrameAccess(callingHtmlPart))
182 +     return 0;
183 +
184 +  FrameIt it = d->m_frames.find( f );
185 +  FrameIt end = d->m_frames.end();
186 +  if ( it != end )
187 +  {
188 +#ifdef DEBUG_FINDFRAME
189 +     kdDebug(6050) << "KHTMLPart::findFrameParent: FOUND!" << endl;
190 +#endif
191 +     if (childFrame)
192 +        *childFrame = &(*it);
193 +     return this;
194 +  }
195 +     
196 +  it = d->m_frames.begin();
197 +  for (; it != end; ++it )
198 +  {
199 +    KParts::ReadOnlyPart *p = (*it).m_part;
200 +    if ( p && p->inherits( "KHTMLPart" ))
201 +    {
202 +      KHTMLPart *frameParent = static_cast<KHTMLPart*>(p)->findFrameParent(callingPart, f, childFrame);
203 +      if (frameParent)
204 +         return frameParent;
205      }
206    }
207 +  return 0;
208 +}
209 +
210 +
211 +KHTMLPart *KHTMLPart::findFrame( const QString &f )
212 +{
213 +  khtml::ChildFrame *childFrame;
214 +  KHTMLPart *parentFrame = findFrameParent(this, f, &childFrame);
215 +  if (parentFrame)
216 +  {
217 +     KParts::ReadOnlyPart *p = childFrame->m_part;
218 +     if ( p && p->inherits( "KHTMLPart" ))
219 +        return static_cast<KHTMLPart *>(p);
220 +  }
221 +  return 0;
222  }
223  
224  KParts::ReadOnlyPart *KHTMLPart::currentFrame() const
225 @@ -3731,37 +3782,29 @@ KHTMLPart *KHTMLPart::parentPart()
226    return (KHTMLPart *)parent();
227  }
228  
229 -khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args,
230 -                                                     bool callParent )
231 +khtml::ChildFrame *KHTMLPart::recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KURL &url, 
232 +                                                     const KParts::URLArgs &args, bool callParent )
233  {
234 -  FrameIt it = d->m_frames.find( args.frameName );
235 -
236 -  if ( it != d->m_frames.end() )
237 -    return &(*it);
238 -
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" ) )
243 -    {
244 -      KHTMLPart *childPart = (KHTMLPart *)(KParts::ReadOnlyPart *)(*it).m_part;
245 -
246 -      khtml::ChildFrame *res = childPart->recursiveFrameRequest( url, args, false );
247 -      if ( !res )
248 -        continue;
249 -
250 -      childPart->requestObject( res, url, args );
251 -      return 0L;
252 -    }
253 +#ifdef DEBUG_FINDFRAME
254 +  kdDebug( 6050 ) << "KHTMLPart::recursiveFrameRequest this = " << this << ", frame = " << args.frameName << ", url = " << url.prettyURL() << endl;
255 +#endif  
256 +  khtml::ChildFrame *childFrame;
257 +  KHTMLPart *childPart = findFrameParent(callingHtmlPart, args.frameName, &childFrame);
258 +  if (childPart)
259 +  {
260 +     if (childPart == this)
261 +        return childFrame;
262 +     
263 +     childPart->requestObject( childFrame, url, args );
264 +     return 0;
265 +  }
266  
267    if ( parentPart() && callParent )
268    {
269 -    khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( url, args );
270 -
271 -    if ( res )
272 -      parentPart()->requestObject( res, url, args );
273 +     khtml::ChildFrame *res = parentPart()->recursiveFrameRequest( callingHtmlPart, url, args, callParent );
274  
275 -    return 0L;
276 +     if ( res )
277 +       parentPart()->requestObject( res, url, args );
278    }
279  
280    return 0L;
281 @@ -3769,7 +3812,7 @@ khtml::ChildFrame *KHTMLPart::recursiveF
282  
283  void KHTMLPart::saveState( QDataStream &stream )
284  {
285 -  kdDebug( 6050 ) << "KHTMLPart::saveState saving URL " << m_url.url() << endl;
286 +  kdDebug( 6050 ) << "KHTMLPart::saveState this = " << this << " saving URL " << m_url.url() << endl;
287  
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:
298     */
299    KParts::BrowserExtension *browserExtension() const;
300    KParts::LiveConnectExtension *liveConnectExtension( const khtml::RenderPart *) const;
301 +  KParts::BrowserHostExtension *browserHostExtension() const;
302 +  
303    /**
304     * Returns a pointer to the HTML document's view.
305     */
306 @@ -653,6 +655,16 @@ public:
307    KHTMLPart *findFrame( const QString &f );
308  
309    /**
310 +   * @internal
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
316 +   */
317 +  KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame=0 );
318 +
319 +  /**
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:
324     * @internal
325     */
326    bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
327 +  
328 +  /**
329 +   * @internal
330 +   * Returns whether callingHtmlPart may access this part
331 +   */
332 +  bool checkFrameAccess(KHTMLPart *callingHtmlPart);
333  
334    void startAutoScroll();
335    void stopAutoScroll();
336 @@ -1103,7 +1121,7 @@ private:
337    DOM::DocumentImpl *xmlDocImpl() const;
338    khtml::ChildFrame *frame( const QObject *obj );
339  
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 );
342  
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 );*/ }
355  
356 +BrowserHostExtension *
357 +BrowserHostExtension::findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame)
358 +{
359 +    FindFrameParentParams param;
360 +    param.parent = 0;
361 +    param.callingPart = callingPart;
362 +    param.frame = frame;
363 +    virtual_hook(VIRTUAL_FIND_FRAME_PARENT, &param);
364 +    return param.parent;
365 +}
366 +
367  void BrowserHostExtension::virtual_hook( int, void* )
368  { /*BASE::virtual_hook( id, data );*/ }
369  
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:
378     *
379     * Note that this method does not query the child objects recursively.
380     */
381 -
382    virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
383  
384    /**
385 +   * @internal
386 +   * Returns the part that contains @p frame and that may be accessed
387 +   * by @p callingPart
388 +   */
389 +  BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame);
390 +
391 +  /**
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 ) .
394     */
395 @@ -626,6 +632,19 @@ public:
396    static BrowserHostExtension *childObject( QObject *obj );
397  
398  protected:
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.
401 +   *
402 +   * @internal
403 +   */
404 +  enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
405 +  struct FindFrameParentParams
406 +  {
407 +      BrowserHostExtension *parent;
408 +      KParts::ReadOnlyPart *callingPart;
409 +      QString frame;
410 +  };
411 +                                                    
412    virtual void virtual_hook( int id, void* data );
413  private:
414    class BrowserHostExtensionPrivate;
This page took 0.072821 seconds and 3 git commands to generate.