[webkit-changes] cvs commit: WebCore/manual-tests/resources 200x100.png popup200x100.html

Geoffrey ggaren at opensource.apple.com
Fri Dec 23 15:04:09 PST 2005


ggaren      05/12/23 15:04:09

  Modified:    .        ChangeLog
               khtml/ecma kjs_window.cpp
               kwq      KWQKHTMLPartBrowserExtension.mm
                        KWQKPartsBrowserExtension.h
               manual-tests window-open-features.html
  Added:       manual-tests window-open-features-parsing.html
               manual-tests/resources 200x100.png popup200x100.html
  Log:
          Reviewed by vicki (yay!), eric.
  
          - Fixed: <rdar://problem/4377597> parsing of window.open features strings needs to be more forgiving
  
          Manual test case: WebCore/manual-tests/window-open-features-parsing.html
          Also fixed: WebCore/manual-tests/window-open-features.html, which had an incorrect URL in it.
  
          This patch is long. Luckily, it's also complicated.
  
          The main thing I've done is to change our parsing of the window.open 'features' argument to match Win IE. This is important because we now implement the correct defaults for window.open, and resizing and scrolling are turned off by default. So, if we parse the 'features' string incorrectly, we'll end up with an annoying, incorrectly sized window that can't resize or scroll.
  
          To honor a long-standing request by Eric, I factored out the parsing into two new functions: parseWindowFeatures and constrainToScreen. I also added support for "innerWidth" and "innerHeight," since they're just synonyms for "width" and "height."
  
          * khtml/ecma/kjs_window.cpp: removed "emit" statements, since emit is #defined as ""
          (KJS::parseDialogFeatures): renamed from parseFeatures, since we now have a 'parseWindowFeatures'.
          (KJS::showModalDialog): ditto on parseFeatures. Also added some missing initializations for WindowArgs data members.
          (KJS::parseWindowFeatures): new function, all new functionality.
          (KJS::constrainToScreen): new function, no new functionality -- just cut and pasted code that used to run as part of our parsing routine.
          (KJS::WindowFunc::callAsFunction):
          (1) Factored out previous parsing code.
          (2) Factored 17 lines of custom popup-blocking code into 3 lines that use pre-existing 'allowPopUp' function. Gratuitous, but it cried out to me.
          (3) Changed URL parsing to substitute "" for undefined *and* null values (we already did this for undefined), to avoid trying to navigate to 'http://null'.
          (4) Factore a multiline if () { if () {}} into an if ( && )
          (4) Removed the main body of code from a giant 'else' block by inserting early returns for the exceptional cases. This caused some things to show up in the diff even though they're just whitespace changes. I didn't actually change any code past the line "if (!str.isEmpty() && activePart)"
          * kwq/KWQKHTMLPartBrowserExtension.mm:
          (KHTMLPartBrowserExtension::createNewWindow): Added code to set toolbars to visible if toolBarVisible is true *or* locationBarVisible is true. The parser used to do this for us, but it's really the browser that's responsible for saying that the toolbar and the locationbar are the same thing. Hopefully, we can add a setLocationBarVisible delegate in the future so that other webkit clients can make their own UI decisions.
          * kwq/KWQKPartsBrowserExtension.h: Added locationBarVisible data member to WindowArgs structure and renamed toolBarsVisible to toolBarVisible (see above). Removed initialization code from WindowArgs structure because this file is for platform-specific code, and what defaults to use for window arguments is purely engine stuff.
  
  Revision  Changes    Path
  1.36      +30 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ChangeLog	23 Dec 2005 18:43:59 -0000	1.35
  +++ ChangeLog	23 Dec 2005 23:04:06 -0000	1.36
  @@ -1,3 +1,33 @@
  +2005-12-22  Geoffrey Garen  <ggaren at apple.com>
  +    
  +        Reviewed by vicki (yay!), eric.
  +
  +        - Fixed: <rdar://problem/4377597> parsing of window.open features strings needs to be more forgiving
  +
  +        Manual test case: WebCore/manual-tests/window-open-features-parsing.html
  +        Also fixed: WebCore/manual-tests/window-open-features.html, which had an incorrect URL in it.
  +
  +        This patch is long. Luckily, it's also complicated.
  +
  +        The main thing I've done is to change our parsing of the window.open 'features' argument to match Win IE. This is important because we now implement the correct defaults for window.open, and resizing and scrolling are turned off by default. So, if we parse the 'features' string incorrectly, we'll end up with an annoying, incorrectly sized window that can't resize or scroll.
  +
  +        To honor a long-standing request by Eric, I factored out the parsing into two new functions: parseWindowFeatures and constrainToScreen. I also added support for "innerWidth" and "innerHeight," since they're just synonyms for "width" and "height."
  +
  +        * khtml/ecma/kjs_window.cpp: removed "emit" statements, since emit is #defined as ""
  +        (KJS::parseDialogFeatures): renamed from parseFeatures, since we now have a 'parseWindowFeatures'.
  +        (KJS::showModalDialog): ditto on parseFeatures. Also added some missing initializations for WindowArgs data members.
  +        (KJS::parseWindowFeatures): new function, all new functionality.
  +        (KJS::constrainToScreen): new function, no new functionality -- just cut and pasted code that used to run as part of our parsing routine.
  +        (KJS::WindowFunc::callAsFunction):
  +        (1) Factored out previous parsing code.
  +        (2) Factored 17 lines of custom popup-blocking code into 3 lines that use pre-existing 'allowPopUp' function. Gratuitous, but it cried out to me.
  +        (3) Changed URL parsing to substitute "" for undefined *and* null values (we already did this for undefined), to avoid trying to navigate to 'http://null'.
  +        (4) Factore a multiline if () { if () {}} into an if ( && )
  +        (4) Removed the main body of code from a giant 'else' block by inserting early returns for the exceptional cases. This caused some things to show up in the diff even though they're just whitespace changes. I didn't actually change any code past the line "if (!str.isEmpty() && activePart)"
  +        * kwq/KWQKHTMLPartBrowserExtension.mm:
  +        (KHTMLPartBrowserExtension::createNewWindow): Added code to set toolbars to visible if toolBarVisible is true *or* locationBarVisible is true. The parser used to do this for us, but it's really the browser that's responsible for saying that the toolbar and the locationbar are the same thing. Hopefully, we can add a setLocationBarVisible delegate in the future so that other webkit clients can make their own UI decisions.
  +        * kwq/KWQKPartsBrowserExtension.h: Added locationBarVisible data member to WindowArgs structure and renamed toolBarsVisible to toolBarVisible (see above). Removed initialization code from WindowArgs structure because this file is for platform-specific code, and what defaults to use for window arguments is purely engine stuff.
  +
   2005-12-23  Eric Seidel  <eseidel at apple.com>
   
           Reviewed by mjs.
  
  
  
  1.207     +201 -173  WebCore/khtml/ecma/kjs_window.cpp
  
  Index: kjs_window.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
  retrieving revision 1.206
  retrieving revision 1.207
  diff -u -r1.206 -r1.207
  --- kjs_window.cpp	23 Dec 2005 18:44:09 -0000	1.206
  +++ kjs_window.cpp	23 Dec 2005 23:04:07 -0000	1.207
  @@ -479,7 +479,7 @@
               || static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture());
   }
   
  -static QMap<QString, QString> parseFeatures(ExecState *exec, JSValue *featuresArg)
  +static QMap<QString, QString> parseModalDialogFeatures(ExecState *exec, JSValue *featuresArg)
   {
       QMap<QString, QString> map;
   
  @@ -559,7 +559,7 @@
       // We'd have to resolve all those issues to pass the URL instead of "".
   
       ReadOnlyPart *newReadOnlyPart = 0;
  -    emit openerPart->browserExtension()->createNewWindow("", uargs, windowArgs, newReadOnlyPart);
  +    openerPart->browserExtension()->createNewWindow("", uargs, windowArgs, newReadOnlyPart);
   
       if (!newReadOnlyPart || !newReadOnlyPart->inherits("KHTMLPart"))
           return 0;
  @@ -603,7 +603,7 @@
       if (!canShowModalDialogNow(openerWindow) || !allowPopUp(exec, openerWindow))
           return jsUndefined();
       
  -    const QMap<QString, QString> features = parseFeatures(exec, args[2]);
  +    const QMap<QString, QString> features = parseModalDialogFeatures(exec, args[2]);
   
       bool trusted = false;
   
  @@ -644,8 +644,11 @@
       wargs.resizable = boolFeature(features, "resizable");
       wargs.scrollBarsVisible = boolFeature(features, "scroll", true);
       wargs.statusBarVisible = boolFeature(features, "status", !trusted);
  -    wargs.toolBarsVisible = false;
  -
  +    wargs.menuBarVisible = false;
  +    wargs.toolBarVisible = false;
  +    wargs.locationBarVisible = false;
  +    wargs.fullscreen = false;
  +    
       KHTMLPart *dialogPart = createNewWindow(exec, openerWindow, URL.qstring(), "", wargs, args[1]);
       if (!dialogPart)
           return jsUndefined();
  @@ -1265,7 +1268,7 @@
       QString message;
       message.sprintf("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n", 
                     targetDocument->URL().latin1(), originDocument->URL().latin1());
  -    KWQ(targetPart)->addMessageToConsole(message, 1, QString()); //fixme: provide a real line number and sourceurl
  +    KWQ(targetPart)->addMessageToConsole(DOMString(message), 1, DOMString()); //fixme: provide a real line number and sourceurl
   
       return false;
   }
  @@ -1418,6 +1421,146 @@
     //kdDebug(6070) << "Window " << this << " (part=" << m_part << ")::setCurrentEvent m_evt=" << evt << endl;
   }
   
  +static void setWindowFeature(const QString& keyString, const QString& valueString, WindowArgs& windowArgs)
  +{
  +    int value;
  +    
  +    if (valueString.length() == 0 || // listing a key with no value is shorthand for key=yes
  +        valueString == "yes")
  +        value = 1;
  +    else
  +        value = valueString.toInt();
  +    
  +    if (keyString == "left" || keyString == "screenx") {
  +        windowArgs.xSet = true;
  +        windowArgs.x = value;
  +    } else if (keyString == "top" || keyString == "screeny") {
  +        windowArgs.ySet = true;
  +        windowArgs.y = value;
  +    } else if (keyString == "width" || keyString == "innerwidth") {
  +        windowArgs.widthSet = true;
  +        windowArgs.width = value;
  +    } else if (keyString == "height" || keyString == "innerheight") {
  +        windowArgs.heightSet = true;
  +        windowArgs.height = value;
  +    } else if (keyString == "menubar")
  +        windowArgs.menuBarVisible = value;
  +    else if (keyString == "toolbar")
  +        windowArgs.toolBarVisible = value;
  +    else if (keyString == "location")
  +        windowArgs.locationBarVisible = value;
  +    else if (keyString == "status")
  +        windowArgs.statusBarVisible = value;
  +    else if (keyString == "resizable")
  +        windowArgs.resizable = value;
  +    else if (keyString == "fullscreen")
  +        windowArgs.fullscreen = value;
  +    else if (keyString == "scrollbars")
  +        windowArgs.scrollBarsVisible = value;
  +}
  +
  +static void parseWindowFeatures(const QString& features, KParts::WindowArgs& windowArgs)
  +{
  +    /*
  +     The IE rule is: all features except for channelmode and fullscreen default to YES, but
  +     if the user specifies a feature string, all features default to NO. (There is no public
  +     standard that applies to this method.)
  +     
  +     <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp>
  +     */
  +    
  +    windowArgs.dialog = false;
  +    windowArgs.fullscreen = false;
  +    
  +    if (features.length() == 0) {
  +        windowArgs.menuBarVisible = true;
  +        windowArgs.statusBarVisible = true;
  +        windowArgs.toolBarVisible = true;
  +        windowArgs.locationBarVisible = true;
  +        windowArgs.scrollBarsVisible = true;
  +        windowArgs.resizable = true;
  +        
  +        windowArgs.xSet = false;
  +        windowArgs.ySet = false;
  +        windowArgs.widthSet = false;
  +        windowArgs.heightSet = false;
  +        
  +        return;
  +    }
  +    
  +    windowArgs.menuBarVisible = false;
  +    windowArgs.statusBarVisible = false;
  +    windowArgs.toolBarVisible = false;
  +    windowArgs.locationBarVisible = false;
  +    windowArgs.scrollBarsVisible = false;
  +    windowArgs.resizable = false;
  +    
  +    // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
  +    int keyBegin, keyEnd;
  +    int valueBegin, valueEnd;
  +    
  +    int i = 0;
  +    int length = features.length();
  +    QString buffer = features.lower();
  +    while (i < length) {
  +        // skip to first letter or number, but don't skip past the end of the string
  +        while (!buffer[i].isLetterOrNumber()) {
  +            if (i > length)
  +                break;
  +            i++;
  +        }
  +        keyBegin = i;
  +        
  +        // skip to first non-letter, non-number
  +        while (buffer[i].isLetterOrNumber())
  +            i++;
  +        keyEnd = i;
  +        
  +        // skip to first '=', but don't skip past a ',' or the end of the string
  +        while (buffer[i] != '=') {
  +            if (buffer[i] == ',' || i >= length)
  +                break;
  +            i++;
  +        }
  +        
  +        // skip to first letter or number, but don't skip past a ',' or the end of the string
  +        while (!buffer[i].isLetterOrNumber()) {
  +            if (buffer[i] == ',' || i >= length)
  +                break;
  +            i++;
  +        }
  +        valueBegin = i;
  +        
  +        // skip to first non-letter, non-number
  +        while (buffer[i].isLetterOrNumber())
  +            i++;
  +        valueEnd = i;
  +        
  +        setWindowFeature(buffer.mid(keyBegin, keyEnd - keyBegin), buffer.mid(valueBegin, valueEnd - valueBegin), windowArgs);
  +    }
  +}
  +
  +static void constrainToVisible(const QRect &screen, KParts::WindowArgs& windowArgs)
  +{
  +    windowArgs.x += screen.x();
  +    if (windowArgs.x < screen.x() || windowArgs.x > screen.right())
  +        windowArgs.x = screen.x(); // only safe choice until size is determined
  +    
  +    windowArgs.y += screen.y();
  +    if (windowArgs.y < screen.y() || windowArgs.y > screen.bottom())
  +        windowArgs.y = screen.y(); // only safe choice until size is determined
  +    
  +    if (windowArgs.height > screen.height())  // should actually check workspace
  +        windowArgs.height = screen.height();
  +    if (windowArgs.height < 100)
  +        windowArgs.height = 100;
  +    
  +    if (windowArgs.width > screen.width())    // should actually check workspace
  +        windowArgs.width = screen.width();
  +    if (windowArgs.width < 100)
  +        windowArgs.width = 100;
  +}
  +
   JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
   {
     if (!thisObj->inherits(&Window::info))
  @@ -1456,201 +1599,86 @@
     }
     case Window::Open:
     {
  -    KConfig *config = new KConfig("konquerorrc");
  -    config->setGroup("Java/JavaScript Settings");
  -    int policy = config->readUnsignedNumEntry( part->settings(), "WindowOpenPolicy", 0 ); // 0=allow, 1=ask, 2=deny, 3=smart
  -    delete config;
  -    if ( policy == 1 ) {
  -        policy = 0;
  -    } else if ( policy == 3 ) // smart
  -    {
  -      // window.open disabled unless from a key/mouse event
  -      if (static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture())
  -      {
  -        policy = 0;
  -	LOG(PopupBlocking, "Allowed JavaScript window open of %s", args[0]->toString(exec).qstring().ascii());
  -      } else {
  -	LOG(PopupBlocking, "Blocked JavaScript window open of %s", args[0]->toString(exec).qstring().ascii());
  -      }
  -    }
  -
  -    QString frameName = args[1]->isUndefinedOrNull() ? QString("_blank") : args[1]->toString(exec).qstring();
  -
  -    if ( policy != 0 && !(part->findFrame(frameName) || frameName == "_top" || frameName == "_parent" || frameName == "_self")) {
  -      return jsUndefined();
  -    } else {
  -      if (v->isUndefined())
  -        str = QString();
  -
  -      KParts::WindowArgs winargs;
  -
  -      QString features = args[2]->toString(exec).qstring();
  -      if (features.length() > 0) {
  -        // when features is specified, all features default to false
  -        winargs.menuBarVisible = false;
  -        winargs.toolBarsVisible = false;
  -        winargs.statusBarVisible = false;
  -        winargs.scrollBarsVisible = false;
  -        winargs.resizable = false;
  -        QStringList flist = QStringList::split(',', features);
  -        QStringList::ConstIterator it = flist.begin();
  -        while (it != flist.end()) {
  -          QString s = *it++;
  -          QString key, val;
  -          int pos = s.find('=');
  -          if (pos >= 0) {
  -            key = s.left(pos).stripWhiteSpace().lower();
  -            val = s.mid(pos + 1).stripWhiteSpace().lower();
  -	    int spacePos = val.find(' ');
  -	    if (spacePos != -1) {
  -	      val = val.left(spacePos);
  -	    }
  -
  -            int scnum = QApplication::desktop()->screenNumber(widget->topLevelWidget());
  -
  -	    QRect screen = QApplication::desktop()->screenGeometry(scnum);
  -            if (key == "left" || key == "screenx") {
  -              bool ok;
  -              double d = val.toDouble(&ok);
  -              if ((d != 0 || ok) && !isnan(d)) {
  -                d += screen.x();
  -                if (d < screen.x() || d > screen.right())
  -		  d = screen.x(); // only safe choice until size is determined
  -                winargs.x = (int)d;
  -	        winargs.xSet = true;
  -              }
  -            } else if (key == "top" || key == "screeny") {
  -              bool ok;
  -              double d = val.toDouble(&ok);
  -              if ((d != 0 || ok) && !isnan(d)) {
  -                d += screen.y();
  -                if (d < screen.y() || d > screen.bottom())
  -		  d = screen.y(); // only safe choice until size is determined
  -                winargs.y = (int)d;
  -	        winargs.ySet = true;
  -              }
  -            } else if (key == "height") {
  -              bool ok;
  -              double d = val.toDouble(&ok);
  -              if ((d != 0 || ok) && !isnan(d)) {
  -	        if (d > screen.height())  // should actually check workspace
  -		  d = screen.height();
  -                if (d < 100)
  -		  d = 100;
  -                winargs.height = (int)d;
  -	        winargs.heightSet = true;
  -              }
  -            } else if (key == "width") {
  -              bool ok;
  -              double d = val.toDouble(&ok);
  -              if ((d != 0 || ok) && !isnan(d)) {
  -	        if (d > screen.width())    // should actually check workspace
  -		  d = screen.width();
  -                if (d < 100)
  -		  d = 100;
  -                winargs.width = (int)d;
  -	        winargs.widthSet = true;
  -              }
  -            } else {
  -              goto boolargs;
  -	    }
  -            continue;
  -          } else {
  -            // leaving away the value gives true
  -            key = s.stripWhiteSpace().lower();
  -            val = "1";
  -          }
  -        boolargs:
  -          if (key == "menubar")
  -            winargs.menuBarVisible = (val == "1" || val == "yes");
  -          else if (key == "toolbar")
  -            winargs.toolBarsVisible = (val == "1" || val == "yes");
  -          else if (key == "location")  // ### missing in WindowArgs
  -            winargs.toolBarsVisible = (val == "1" || val == "yes");
  -          else if (key == "status" || key == "statusbar")
  -            winargs.statusBarVisible = (val == "1" || val == "yes");
  -          else if (key == "resizable")
  -            winargs.resizable = (val == "1" || val == "yes");
  -          else if (key == "fullscreen")
  -            winargs.fullscreen = (val == "1" || val == "yes");
  -          else if (key == "scrollbars")
  -            winargs.scrollBarsVisible = !(val == "0" || val == "no");
  -        }
  -      }
  -
  +      QString frameName = args[1]->isUndefinedOrNull() ? QString("_blank") : args[1]->toString(exec).qstring();
  +      if (!allowPopUp(exec, window) && !(part->findFrame(frameName)))
  +          return jsUndefined();
  +      if (frameName == "_top" || frameName == "_parent" || frameName == "_self")
  +          return jsUndefined();
  +      
  +      KParts::WindowArgs windowArgs;
  +      QString features = args[2]->isUndefinedOrNull() ? QString() : args[2]->toString(exec).qstring();
  +      parseWindowFeatures(features, windowArgs);
  +      
  +      int screenNumber = QApplication::desktop()->screenNumber(widget->topLevelWidget());
  +      constrainToVisible(QApplication::desktop()->screenGeometry(screenNumber), windowArgs);
  +      
         // prepare arguments
         KURL url;
         KHTMLPart* activePart = Window::retrieveActive(exec)->m_part;
  -      if (!str.isEmpty()) {
  -        if (activePart)
  +      if (!str.isEmpty() && activePart)
             url = activePart->xmlDocImpl()->completeURL(str.qstring());
  -      }
   
         KParts::URLArgs uargs;
         uargs.frameName = frameName;
  -      if ( uargs.frameName == "_top" )
  -      {
  -          while ( part->parentPart() )
  +      if (uargs.frameName == "_top") {
  +          while (part->parentPart())
                 part = part->parentPart();
  -
  +          
             const Window* window = Window::retrieveWindow(part);
             if (!url.url().startsWith("javascript:", false) || (window && window->isSafeScript(exec))) {
  -            bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
  -            part->scheduleLocationChange(url.url(), activePart->referrer(), false/*don't lock history*/, userGesture);
  +              bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
  +              part->scheduleLocationChange(url.url(), activePart->referrer(), false/*don't lock history*/, userGesture);
             }
             return Window::retrieve(part);
         }
  -      if ( uargs.frameName == "_parent" )
  -      {
  -          if ( part->parentPart() )
  +      if (uargs.frameName == "_parent") {
  +          if (part->parentPart())
                 part = part->parentPart();
  -
  +          
             const Window* window = Window::retrieveWindow(part);
             if (!url.url().startsWith("javascript:", false) || (window && window->isSafeScript(exec))) {
  -            bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
  -            part->scheduleLocationChange(url.url(), activePart->referrer(), false/*don't lock history*/, userGesture);
  +              bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
  +              part->scheduleLocationChange(url.url(), activePart->referrer(), false/*don't lock history*/, userGesture);
             }
             return Window::retrieve(part);
         }
         uargs.serviceType = "text/html";
  -
  +      
         // request window (new or existing if framename is set)
         KParts::ReadOnlyPart *newPart = 0L;
         uargs.metaData()["referrer"] = activePart->referrer();
  -      emit part->browserExtension()->createNewWindow("", uargs,winargs,newPart);
  -      if (newPart && newPart->inherits("KHTMLPart")) {
  -        KHTMLPart *khtmlpart = static_cast<KHTMLPart*>(newPart);
  -        //qDebug("opener set to %p (this Window's part) in new Window %p  (this Window=%p)",part,win,window);
  -        khtmlpart->setOpener(part);
  -        khtmlpart->setOpenedByJS(true);
  -        
  -        if (!khtmlpart->xmlDocImpl()) {
  -            DocumentImpl *oldDoc = part->xmlDocImpl();
  -            if (oldDoc && oldDoc->baseURL() != 0)
  -                khtmlpart->begin(oldDoc->baseURL());
  -            else
  -                khtmlpart->begin();
  -            
  -            khtmlpart->write("<HTML><BODY>");
  -            khtmlpart->end();
  -
  -            if (oldDoc) {
  +      part->browserExtension()->createNewWindow("", uargs, windowArgs, newPart);
  +      if (!newPart || !newPart->inherits("KHTMLPart"))
  +          return jsUndefined();
  +      KHTMLPart *khtmlpart = static_cast<KHTMLPart*>(newPart);
  +      //qDebug("opener set to %p (this Window's part) in new Window %p  (this Window=%p)",part,win,window);
  +      khtmlpart->setOpener(part);
  +      khtmlpart->setOpenedByJS(true);
  +      
  +      if (!khtmlpart->xmlDocImpl()) {
  +          DocumentImpl *oldDoc = part->xmlDocImpl();
  +          if (oldDoc && oldDoc->baseURL() != 0)
  +              khtmlpart->begin(oldDoc->baseURL());
  +          else
  +              khtmlpart->begin();
  +          
  +          khtmlpart->write("<HTML><BODY>");
  +          khtmlpart->end();
  +          
  +          if (oldDoc) {
                 kdDebug(6070) << "Setting domain to " << oldDoc->domain().qstring() << endl;
                 khtmlpart->xmlDocImpl()->setDomain( oldDoc->domain(), true );
                 khtmlpart->xmlDocImpl()->setBaseURL( oldDoc->baseURL() );
  -            }
  -        }
  -        if (!url.isEmpty()) {
  +          }
  +      }
  +      if (!url.isEmpty()) {
             const Window* window = Window::retrieveWindow(khtmlpart);
             if (!url.url().startsWith("javascript:", false) || (window && window->isSafeScript(exec))) {
  -            bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
  -            khtmlpart->scheduleLocationChange(url.url(), activePart->referrer(), false, userGesture);
  +              bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
  +              khtmlpart->scheduleLocationChange(url.url(), activePart->referrer(), false, userGesture);
             } 
  -	}
  -        return Window::retrieve(khtmlpart); // global object
  -      } else
  -        return jsUndefined();
  -    }
  +      }
  +      return Window::retrieve(khtmlpart); // global object
     }
     case Window::Print:
       part->print();
  @@ -1872,7 +1900,7 @@
                   int lineNumber = exception->get(exec, "line")->toInt32(exec);
                   if (Interpreter::shouldPrintExceptions())
                       printf("(timer):%s\n", message.qstring().utf8().data());
  -                KWQ(window->m_part)->addMessageToConsole(message, lineNumber, QString());
  +                KWQ(window->m_part)->addMessageToConsole(message, lineNumber, DOMString());
               }
           }
       } else
  
  
  
  1.54      +1 -1      WebCore/kwq/KWQKHTMLPartBrowserExtension.mm
  
  Index: KWQKHTMLPartBrowserExtension.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPartBrowserExtension.mm,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- KWQKHTMLPartBrowserExtension.mm	21 Dec 2005 00:00:21 -0000	1.53
  +++ KWQKHTMLPartBrowserExtension.mm	23 Dec 2005 23:04:08 -0000	1.54
  @@ -123,7 +123,7 @@
       if (partResult)
   	*partResult = [bridge part];
       
  -    [bridge setToolbarsVisible:winArgs.toolBarsVisible];
  +    [bridge setToolbarsVisible:winArgs.toolBarVisible || winArgs.locationBarVisible];
       [bridge setStatusbarVisible:winArgs.statusBarVisible];
       [bridge setScrollbarsVisible:winArgs.scrollBarsVisible];
       [bridge setWindowIsResizable:winArgs.resizable];
  
  
  
  1.29      +2 -10     WebCore/kwq/KWQKPartsBrowserExtension.h
  
  Index: KWQKPartsBrowserExtension.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKPartsBrowserExtension.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- KWQKPartsBrowserExtension.h	20 Dec 2005 17:05:53 -0000	1.28
  +++ KWQKPartsBrowserExtension.h	23 Dec 2005 23:04:08 -0000	1.29
  @@ -73,14 +73,14 @@
   };
   
   struct WindowArgs {
  -
       int x;
       int y;
       int width;
       int height;
       bool menuBarVisible;
       bool statusBarVisible;
  -    bool toolBarsVisible;
  +    bool toolBarVisible;
  +    bool locationBarVisible;
       bool scrollBarsVisible;
       bool resizable;
       bool fullscreen;
  @@ -89,14 +89,6 @@
       bool widthSet;
       bool heightSet;
       bool dialog;
  -
  -    WindowArgs() : x(0), y(0), width(0), height(0),
  -        menuBarVisible(true), statusBarVisible(true), toolBarsVisible(true), scrollBarsVisible(true),
  -        resizable(true), fullscreen(false),
  -        xSet(false), ySet(false), widthSet(false), heightSet(false),
  -        dialog(false)
  -        { }
  -
   };
   
   class BrowserExtension : public QObject {
  
  
  
  1.2       +1 -1      WebCore/manual-tests/window-open-features.html
  
  Index: window-open-features.html
  ===================================================================
  RCS file: /cvs/root/WebCore/manual-tests/window-open-features.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- window-open-features.html	20 Dec 2005 17:05:55 -0000	1.1
  +++ window-open-features.html	23 Dec 2005 23:04:08 -0000	1.2
  @@ -7,7 +7,7 @@
       if (w && !w.closed)
   	w.close();
       
  -    w = window.open("popup200x200.html", "popup", sFeatures);
  +    w = window.open("resources/popup200x200.html", "popup", sFeatures);
   }
   </script>
   </head>
  
  
  
  1.1                  WebCore/manual-tests/window-open-features-parsing.html
  
  Index: window-open-features-parsing.html
  ===================================================================
  <html><head><script>
  function test() {
      /* The lowdown on this feature string:
          - width: reads as 0200|0, which, after strtol, gives you 200
          - height: reads as "", which means yes, which means 1, but the minimum size is 100
          - width1: reads as width1, an invalid key, so it doesn't override width
          - left: reads as no, which means 0, which means aligned to the left side of the screen
          - toolBAR: reads as yes
          - resizable: reads as yess, which is invalid, which means no
          - status: reads as "", which means yes
      */    
      var sFeatures = " 	,=width ==	= = 	0200|0=height  400,1width=400,left=nO toolBAR=yeS,resizable=yess,  \t\v\f\r\nstatus= "; 
      var w = window.open("resources/popup200x100.html", undefined, sFeatures); 
      w.focus();
  }
  </script></head>
  <body>
  <p>This test checks whether parsing of the 'features' argument to window.open matches Win IE's behavior.</p>
  <p>The link below should open a window with the following attributes:</p>
  <ul>
  <li> A WebView exactly 200x100, such that you can see a red 1 pixel border around the edge of the whole WebView.
  <li> A window aligned to the left hand side of the screen.
  <li> Toolbar visible.
  <li> Statusbar visible.
  <li> Not resizable.
  </ul>
  <hr>
  <a href="" onclick="test(); return false;">Click to test.</a>
  </body></html>
  
  
  
  1.1                  WebCore/manual-tests/resources/200x100.png
  
  	<<Binary file>>
  
  
  1.1                  WebCore/manual-tests/resources/popup200x100.html
  
  Index: popup200x100.html
  ===================================================================
  <html>
  <head>
  <title>Popup 200x100</title>
  </head>
  <body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
  <img src="200x100.png" width="200" height="100">
  </body>
  </html>
  
  
  



More information about the webkit-changes mailing list