summaryrefslogtreecommitdiffstats
path: root/khtml
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
commit96900dbce3aaa1fcac74a07a71482c5c6fcd3cab (patch)
treebf3fc68d0dcc660fce0e21171373a2d4e2395707 /khtml
parent5f99bff82d3413803bcc652999f4f631058179d6 (diff)
downloadtdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.tar.gz
tdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.zip
* Large set of SuSE patches to fix bugs and add functionality
* kdemm is included but not used by knotify as it does not work out of the box git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khtml')
-rw-r--r--khtml/ecma/xmlhttprequest.cpp22
-rw-r--r--khtml/khtmlview.cpp164
-rw-r--r--khtml/khtmlview.h20
-rw-r--r--khtml/rendering/render_form.cpp18
-rw-r--r--khtml/rendering/render_form.h4
5 files changed, 210 insertions, 18 deletions
diff --git a/khtml/ecma/xmlhttprequest.cpp b/khtml/ecma/xmlhttprequest.cpp
index d3ebebaec..b20515de7 100644
--- a/khtml/ecma/xmlhttprequest.cpp
+++ b/khtml/ecma/xmlhttprequest.cpp
@@ -342,16 +342,16 @@ void XMLHttpRequest::send(const TQString& _body)
{
aborted = false;
- if (method == "post") {
- TQString protocol = url.protocol().lower();
+ const TQString protocol = url.protocol().lower();
+ // Abandon the request when the protocol is other than "http",
+ // instead of blindly doing a KIO::get on other protocols like file:/.
+ if (!protocol.startsWith("http") && !protocol.startsWith("webdav"))
+ {
+ abort();
+ return;
+ }
- // Abondon the request when the protocol is other than "http",
- // instead of blindly changing it to a "get" request.
- if (!protocol.startsWith("http") && !protocol.startsWith("webdav"))
- {
- abort();
- return;
- }
+ if (method == "post") {
// FIXME: determine post encoding correctly by looking in headers
// for charset.
@@ -763,11 +763,11 @@ Value XMLHttpRequestProtoFunc::tryCall(ExecState *exec, Object &thisObj, const L
if (obj.isValid() && obj.inherits(&DOMDocument::info)) {
DOM::Node docNode = static_cast<KJS::DOMDocument *>(obj.imp())->toNode();
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(docNode.handle());
-
+
try {
body = doc->toString().string();
// FIXME: also need to set content type, including encoding!
-
+
} catch(DOM::DOMException& e) {
Object err = Error::create(exec, GeneralError, "Exception serializing document");
exec->setException(err);
diff --git a/khtml/khtmlview.cpp b/khtml/khtmlview.cpp
index 7f800a670..850d8e9cd 100644
--- a/khtml/khtmlview.cpp
+++ b/khtml/khtmlview.cpp
@@ -151,6 +151,9 @@ public:
KHTMLViewPrivate()
: underMouse( 0 ), underMouseNonShared( 0 ), visibleWidgets( 107 )
+#ifndef NO_SMOOTH_SCROLL_HACK
+ , dx(0), dy(0), ddx(0), ddy(0), rdx(0), rdy(0), scrolling(false)
+#endif
{
#ifndef KHTML_NO_CARET
m_caretViewContext = 0;
@@ -396,6 +399,17 @@ public:
short m_mouseScroll_byY;
TQTimer *m_mouseScrollTimer;
TQWidget *m_mouseScrollIndicator;
+#ifndef NO_SMOOTH_SCROLL_HACK
+ TQTimer timer2;
+ int dx;
+ int dy;
+ // Step size * 16 and residual to avoid huge difference between 1px/step and 2px/step
+ int ddx;
+ int ddy;
+ int rdx;
+ int rdy;
+ bool scrolling;
+#endif
};
#ifndef QT_NO_TOOLTIP
@@ -504,6 +518,11 @@ KHTMLView::KHTMLView( KHTMLPart *part, TQWidget *parent, const char *name)
init();
viewport()->show();
+#ifndef NO_SMOOTH_SCROLL_HACK
+#define timer timer2
+ connect(&d->timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(scrollTick()));
+#undef timer
+#endif
}
KHTMLView::~KHTMLView()
@@ -1544,7 +1563,7 @@ void KHTMLView::keyPressEvent( TQKeyEvent *_ke )
case Key_Down:
case Key_J:
if (!d->scrollTimerId || d->scrollSuspended)
- scrollBy( 0, 10 );
+ scrollBy( 0, 10 * _ke->count() );
if (d->scrollTimerId)
d->newScrollTimer(this, 0);
break;
@@ -1559,7 +1578,7 @@ void KHTMLView::keyPressEvent( TQKeyEvent *_ke )
case Key_Up:
case Key_K:
if (!d->scrollTimerId || d->scrollSuspended)
- scrollBy( 0, -10 );
+ scrollBy( 0, -10 * _ke->count());
if (d->scrollTimerId)
d->newScrollTimer(this, 0);
break;
@@ -1572,14 +1591,14 @@ void KHTMLView::keyPressEvent( TQKeyEvent *_ke )
case Key_Right:
case Key_L:
if (!d->scrollTimerId || d->scrollSuspended)
- scrollBy( 10, 0 );
+ scrollBy( 10 * _ke->count(), 0 );
if (d->scrollTimerId)
d->newScrollTimer(this, 0);
break;
case Key_Left:
case Key_H:
if (!d->scrollTimerId || d->scrollSuspended)
- scrollBy( -10, 0 );
+ scrollBy( -10 * _ke->count(), 0 );
if (d->scrollTimerId)
d->newScrollTimer(this, 0);
break;
@@ -1712,8 +1731,16 @@ void KHTMLView::keyReleaseEvent(TQKeyEvent *_ke)
d->scrollSuspendPreActivate = false;
if( _ke->key() == Key_Shift && d->scrollSuspendPreActivate && _ke->state() == Qt::ShiftButton
&& !(KApplication::keyboardMouseState() & Qt::ShiftButton))
+ {
if (d->scrollTimerId)
- d->scrollSuspended = !d->scrollSuspended;
+ {
+ d->scrollSuspended = !d->scrollSuspended;
+#ifndef NO_SMOOTH_SCROLL_HACK
+ if( d->scrollSuspended )
+ stopScrolling();
+#endif
+ }
+ }
if (d->accessKeysEnabled)
{
@@ -3061,6 +3088,16 @@ void KHTMLView::addFormCompletionItem(const TQString &name, const TQString &valu
d->formCompletions->writeEntry(name, items);
}
+void KHTMLView::removeFormCompletionItem(const TQString &name, const TQString &value)
+{
+ if (!m_part->settings()->isFormCompletionEnabled())
+ return;
+
+ TQStringList items = formCompletionItems(name);
+ if (items.remove(value))
+ d->formCompletions->writeEntry(name, items);
+}
+
void KHTMLView::addNonPasswordStorableSite(const TQString& host)
{
if (!d->formCompletions) {
@@ -3259,7 +3296,11 @@ void KHTMLView::viewportWheelEvent(TQWheelEvent* e)
else
{
d->scrollBarMoved = true;
+#ifndef NO_SMOOTH_SCROLL_HACK
+ scrollViewWheelEvent( e );
+#else
TQScrollView::viewportWheelEvent( e );
+#endif
TQMouseEvent *tempEvent = new TQMouseEvent( TQEvent::MouseMove, TQPoint(-1,-1), TQPoint(-1,-1), Qt::NoButton, e->state() );
emit viewportMouseMoveEvent ( tempEvent );
@@ -4462,4 +4503,117 @@ void KHTMLView::moveCaretToLineEnd()
#endif // KHTML_NO_CARET
+#ifndef NO_SMOOTH_SCROLL_HACK
+#define timer timer2
+
+// All scrolls must be completed within 240ms of last keypress
+static const int SCROLL_TIME = 240;
+// Each step is 20 ms == 50 frames/second
+static const int SCROLL_TICK = 20;
+
+void KHTMLView::scrollBy(int dx, int dy)
+{
+ KConfigGroup cfg( KGlobal::config(), "KDE" );
+ if( !cfg.readBoolEntry( "SmoothScrolling", true )) {
+ TQScrollView::scrollBy( dx, dy );
+ return;
+ }
+ // scrolling destination
+ int full_dx = d->dx + dx;
+ int full_dy = d->dy + dy;
+
+ // scrolling speed
+ int ddx = 0;
+ int ddy = 0;
+
+ int steps = SCROLL_TIME/SCROLL_TICK;
+
+ ddx = (full_dx*16)/steps;
+ ddy = (full_dy*16)/steps;
+
+ // don't go under 1px/step
+ if (ddx > 0 && ddx < 16) ddx = 16;
+ if (ddy > 0 && ddy < 16) ddy = 16;
+ if (ddx < 0 && ddx > -16) ddx = -16;
+ if (ddy < 0 && ddy > -16) ddy = -16;
+
+ d->dx = full_dx;
+ d->dy = full_dy;
+ d->ddx = ddx;
+ d->ddy = ddy;
+
+ if (!d->scrolling) {
+ scrollTick();
+ startScrolling();
+ }
+}
+
+void KHTMLView::scrollTick() {
+ if (d->dx == 0 && d->dy == 0) {
+ stopScrolling();
+ return;
+ }
+
+ int tddx = d->ddx + d->rdx;
+ int tddy = d->ddy + d->rdy;
+
+ int ddx = tddx / 16;
+ int ddy = tddy / 16;
+ d->rdx = tddx % 16;
+ d->rdy = tddy % 16;
+
+ if (d->dx > 0 && ddx > d->dx) ddx = d->dx;
+ else
+ if (d->dx < 0 && ddx < d->dx) ddx = d->dx;
+
+ if (d->dy > 0 && ddy > d->dy) ddy = d->dy;
+ else
+ if (d->dy < 0 && ddy < d->dy) ddy = d->dy;
+
+ d->dx -= ddx;
+ d->dy -= ddy;
+
+// TQScrollView::setContentsPos( contentsX() + ddx, contentsY() + ddy);
+ kapp->syncX();
+ TQScrollView::scrollBy(ddx, ddy);
+// Unaccelerated X can get seriously overloaded by scrolling and for some reason
+// will send KeyPress events only infrequently. This should help to reduce
+// the load.
+ kapp->syncX();
+}
+
+void KHTMLView::startScrolling()
+{
+ d->scrolling = true;
+ d->timer.start(SCROLL_TICK, false);
+}
+
+void KHTMLView::stopScrolling()
+{
+ d->timer.stop();
+ d->dx = d->dy = 0;
+ d->scrolling = false;
+}
+
+// Overloaded from TQScrollView and TQScrollBar
+void KHTMLView::scrollViewWheelEvent( TQWheelEvent *e )
+{
+ int pageStep = verticalScrollBar()->pageStep();
+ int lineStep = verticalScrollBar()->lineStep();
+ int step = QMIN( TQApplication::wheelScrollLines()*lineStep, pageStep );
+ if ( ( e->state() & ControlButton ) || ( e->state() & ShiftButton ) )
+ step = pageStep;
+
+ if(e->orientation() == Horizontal)
+ scrollBy(-((e->delta()*step)/120), 0);
+ else if(e->orientation() == Vertical)
+ scrollBy(0,-((e->delta()*step)/120));
+
+ e->accept();
+}
+
+#undef timer
+
+#endif // NO_SMOOTH_SCROLL_HACK
+
#undef DEBUG_CARETMODE
diff --git a/khtml/khtmlview.h b/khtml/khtmlview.h
index 1efb347a6..a79eff17f 100644
--- a/khtml/khtmlview.h
+++ b/khtml/khtmlview.h
@@ -181,6 +181,11 @@ signals:
void hideAccessKeys();
void repaintAccessKeys();
void findAheadActive( bool );
+//#define NO_SMOOTH_SCROLL_HACK
+#ifndef NO_SMOOTH_SCROLL_HACK
+public slots:
+ void scrollBy(int dx, int dy);
+#endif
protected:
void clear();
@@ -211,9 +216,23 @@ protected:
void contentsContextMenuEvent ( TQContextMenuEvent *_ce );
void doAutoScroll();
void timerEvent ( TQTimerEvent * );
+
+#ifndef NO_SMOOTH_SCROLL_HACK
+ void startScrolling();
+ void stopScrolling();
+#ifndef QT_NO_WHEELEVENT
+ void scrollViewWheelEvent( TQWheelEvent* e );
+#endif
+#endif
+
protected slots:
void slotPaletteChanged();
void slotScrollBarMoved();
+#ifndef NO_SMOOTH_SCROLL_HACK
+ void scrollTick();
+#else
+ void scrollTick() {}; // moc cannot handle #if
+#endif
private slots:
void tripleClickTimeout();
@@ -295,6 +314,7 @@ private:
TQStringList formCompletionItems(const TQString &name) const;
void clearCompletionHistory(const TQString& name);
void addFormCompletionItem(const TQString &name, const TQString &value);
+ void removeFormCompletionItem(const TQString &name, const TQString &value);
void addNonPasswordStorableSite( const TQString& host );
bool nonPasswordStorableSite( const TQString& host ) const;
diff --git a/khtml/rendering/render_form.cpp b/khtml/rendering/render_form.cpp
index 403295a8f..58a9a8d33 100644
--- a/khtml/rendering/render_form.cpp
+++ b/khtml/rendering/render_form.cpp
@@ -385,7 +385,9 @@ TQPopupMenu *LineEditWidget::createPopupMenu()
if (m_input->autoComplete()) {
popup->insertSeparator();
- int id = popup->insertItem( SmallIconSet("history_clear"), i18n("Clear &History"), ClearHistory );
+ int id = popup->insertItem( SmallIconSet("edit"), i18n("&Edit History..."), EditHistory );
+ popup->setItemEnabled( id, (compObj() && !compObj()->isEmpty()) );
+ id = popup->insertItem( SmallIconSet("history_clear"), i18n("Clear &History"), ClearHistory );
popup->setItemEnabled( id, (compObj() && !compObj()->isEmpty()) );
}
@@ -409,11 +411,25 @@ void LineEditWidget::extendedMenuActivated( int id)
m_view->clearCompletionHistory(m_input->name().string());
if (compObj())
compObj()->clear();
+ case EditHistory:
+ {
+ KHistoryComboEditor dlg( compObj() ? compObj()->items() : TQStringList(), this );
+ connect( &dlg, TQT_SIGNAL( removeFromHistory(const TQString&) ), TQT_SLOT( slotRemoveFromHistory(const TQString&)) );
+ dlg.exec();
+ }
default:
break;
}
}
+void LineEditWidget::slotRemoveFromHistory(const TQString &entry)
+{
+ m_view->removeFormCompletionItem(m_input->name().string(), entry);
+ if (compObj())
+ compObj()->removeItem(entry);
+}
+
+
bool LineEditWidget::event( TQEvent *e )
{
if (KLineEdit::event(e))
diff --git a/khtml/rendering/render_form.h b/khtml/rendering/render_form.h
index 33a31a910..c414e079c 100644
--- a/khtml/rendering/render_form.h
+++ b/khtml/rendering/render_form.h
@@ -272,10 +272,12 @@ private slots:
void spellCheckerMisspelling( const TQString &text, const TQStringList &, unsigned int pos);
void spellCheckerCorrected( const TQString &, const TQString &, unsigned int );
void spellCheckerFinished();
+ void slotRemoveFromHistory( const TQString & );
private:
enum LineEditMenuID {
- ClearHistory
+ ClearHistory,
+ EditHistory
};
DOM::HTMLInputElementImpl* m_input;
KHTMLView* m_view;