[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: keep javascript from changing window properties
From: Leo Savernik <l.savernik () aon ! at>
Date: 2002-10-10 20:36:19
[Download RAW message or body]
Hello,
Well, given the fact that not even kde 3.1 has been released, it might be a
little early for kde 3.2 wishlist items, but I think its potential massive
relief onto the web surfing experience justifies that -- as inconspicuous as
it might seem.
The idea is about keeping khtml's ecma bindings from changing some properties
of the window object, namely
focus()
moveTo()
moveBy()
resizeTo()
resizeBy()
defaultStatus
status
That will keep some pages from resizing my carefully sized window or to move
it to another position. I also can't stand those pages which pop into the
foreground unexpectedly and interrupt my workflow and which think that they
are smarter than me for not letting me see the real url of links in the
status bar.
Besides of that, I'm not the only one who thinks so. Mozilla, for example,
provides the following options under Preferences/Advanced/Scripts & Plugins
for a fairly long time:
- open unrequested windows
- move or resize existing windows
- raise or lower windows
- change status line text
- (and some more which I don't care so I'm not mentioning them here)
Given the fact that an implementation seems to be easy, I'd really like to see
this included in kde 3.2. Can I get that on the 3.2 feature plan somehow?
Ah, before I forget, I certainly created a proof of concept implementation
against KDE-CVS of two weeks ago. Its patch is attached below, it still seems
to apply unchanged to today's CVS as far as lxr.kde.org tells me.
This patch merely imitates the handling for window.open() and introduces four
new boolean configuration settings under "Java/Javascript Settings"
WindowFocus
WindowStatus
WindowResize
WindowMove
which default to true meaning that the write-access to the property resp. the
invocation of the function is granted. Setting any of these to false
immediately disables changes (making them effectively no-op).
So there is no plea not to have this feature in Konqueror, though I'm
certainly not insisting that *my* patch is incorporated. Any implementation
that fulfills my needs will make me happy :-)
mfg
Leo Savernik
["kjs_window.cpp.diff" (text/x-diff)]
--- kdelibs/khtml/ecma/kjs_window.cpp.old Fri Sep 27 16:18:30 2002
+++ kdelibs/khtml/ecma/kjs_window.cpp Thu Oct 10 21:05:31 2002
@@ -689,13 +689,25 @@
#endif
switch( entry->value ) {
case Status: {
- String s = value.toString(exec);
- m_part->setJSStatusBarText(s.value().qstring());
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowStatus", true );
+ delete config;
+ if (allowed) {
+ String s = value.toString(exec);
+ m_part->setJSStatusBarText(s.value().qstring());
+ }
return;
}
case DefaultStatus: {
- String s = value.toString(exec);
- m_part->setJSDefaultStatusBarText(s.value().qstring());
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowStatus", true );
+ delete config;
+ if (allowed) {
+ String s = value.toString(exec);
+ m_part->setJSDefaultStatusBarText(s.value().qstring());
+ }
return;
}
case _Location: {
@@ -1192,7 +1204,12 @@
widget->setContentsPos(args[0].toInt32(exec), args[1].toInt32(exec));
return Undefined();
case Window::MoveBy:
- if(args.size() == 2 && widget)
+ {
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowMove", true );
+ delete config;
+ if(args.size() == 2 && widget && allowed)
{
QWidget * tl = widget->topLevelWidget();
QRect sg = QApplication::desktop()->screenGeometry(QApplication::desktop()->screenNumber(tl));
@@ -1204,8 +1221,14 @@
tl->move( dest );
}
return Undefined();
+ }
case Window::MoveTo:
- if(args.size() == 2 && widget)
+ {
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowMove", true );
+ delete config;
+ if(args.size() == 2 && widget && allowed)
{
QWidget * tl = widget->topLevelWidget();
QRect sg = QApplication::desktop()->screenGeometry(QApplication::desktop()->screenNumber(tl));
@@ -1217,8 +1240,14 @@
tl->move( dest );
}
return Undefined();
+ }
case Window::ResizeBy:
- if(args.size() == 2 && widget)
+ {
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowResize", true );
+ delete config;
+ if(args.size() == 2 && widget && allowed)
{
QWidget * tl = widget->topLevelWidget();
QSize dest = tl->size() + QSize( args[0].toInt32(exec), args[1].toInt32(exec) );
@@ -1235,8 +1264,14 @@
}
}
return Undefined();
+ }
case Window::ResizeTo:
- if(args.size() == 2 && widget)
+ {
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowResize", true );
+ delete config;
+ if(args.size() == 2 && widget && allowed)
{
QWidget * tl = widget->topLevelWidget();
QSize dest = QSize( args[0].toInt32(exec), args[1].toInt32(exec) );
@@ -1253,6 +1288,7 @@
}
}
return Undefined();
+ }
case Window::SetTimeout:
if (args.size() == 2 && v.isA(StringType)) {
int i = args[1].toInt32(exec);
@@ -1299,9 +1335,15 @@
(const_cast<Window*>(window))->clearTimeout(v.toInt32(exec));
return Undefined();
case Window::Focus:
- if (widget)
+ {
+ KConfig *config = new KConfig("konquerorrc");
+ config->setGroup("Java/JavaScript Settings");
+ bool allowed = config->readBoolEntry( "WindowFocus", true );
+ delete config;
+ if (widget && allowed)
widget->setActiveWindow();
return Undefined();
+ }
case Window::Blur:
// TODO
return Undefined();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic