Google Suggest

Darin Adler darin at apple.com
Wed Apr 27 02:24:35 CEST 2005


On Apr 26, 2005, at 12:32 AM, Allan Sandfeld Jensen wrote:

> You might have noticed Google Suggest don't work fully in Safari  
> anymore. You
> need to implement window.frameElement like my patch below does. I  
> think it is
> also what fixed address-completion in GMail.

I did implement frameElement to fix Google Suggest, a couple days back.

But your version doesn't look like ours. In particular, it looks like  
it's returning the parent window. That's not what the frame element  
is. It's the element inside the parent window that contains the  
frame. Here's our implementation.

Index: khtml/ecma/kjs_window.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.146
diff -p -u -r1.146 kjs_window.cpp
--- kjs_window.cpp      2005/03/10 04:04:46     1.146
+++ kjs_window.cpp      2005/04/27 00:22:22
@@ -66,6 +66,7 @@
using DOM::DocumentImpl;
using DOM::DOMString;
+using DOM::ElementImpl;
using DOM::Node;
using DOM::Position;
using khtml::TypingCommand;
@@ -291,6 +292,7 @@ const ClassInfo Window::info = { "Window
    onselect     Window::Onselect        DontDelete
    onsubmit     Window::Onsubmit        DontDelete
    onunload     Window::Onunload        DontDelete
+  frameElement  Window::FrameElement    DontDelete|ReadOnly
@end
*/
IMPLEMENT_PROTOFUNC(WindowFunc)
@@ -457,6 +459,32 @@ UString Window::toString(ExecState *) co
    return "[object Window]";
}
+static ElementImpl *frameElement(ExecState *exec, KHTMLPart *part)
+{
+    // Find the frame element.
+    DocumentImpl *document = part->xmlDocImpl();
+    if (!document)
+        return 0;
+    ElementImpl *frameElement = document->ownerElement();
+    if (!frameElement)
+        return 0;
+
+    // Find the window object for the frame element, and do a cross- 
domain check.
+    DocumentImpl *frameElementDocument = frameElement->getDocument();
+    if (!frameElementDocument)
+        return 0;
+    KHTMLPart *frameElementPart = frameElementDocument->part();
+    if (!frameElementPart)
+        return 0;
+    Window *frameElementWindow = Window::retrieveWindow 
(frameElementPart);
+    if (!frameElementWindow)
+        return 0;
+    if (!frameElementWindow->isSafeScript(exec))
+        return 0;
+
+    return frameElement;
+}
+
Value Window::get(ExecState *exec, const Identifier &p) const
{
#ifdef KJS_VERBOSE
@@ -824,6 +852,12 @@ Value Window::get(ExecState *exec, const
          return getListener(exec,DOM::EventImpl::UNLOAD_EVENT);
        else
          return Undefined();
+    case FrameElement: {
+      ElementImpl *fe = frameElement(exec, m_part);
+      if (!fe)
+        return Undefined();
+      return Value(fe);
+    }
      }
    }




More information about the Khtml-devel mailing list