From kfm-devel Sun Jun 27 22:55:28 2004 From: bj () altern ! org Date: Sun, 27 Jun 2004 22:55:28 +0000 To: kfm-devel Subject: [PATCH] fix imagemap titles (#66722) Message-Id: <200406280102.03446.bj () altern ! org> X-MARC-Message: https://marc.info/?l=kfm-devel&m=108837692810720 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--nextPart1620044.FhJgRYGHzJ" --nextPart1620044.FhJgRYGHzJ Content-Type: multipart/mixed; boundary="Boundary-01=_G423AaYiuHMlmLV" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_G423AaYiuHMlmLV Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello! The following patch fixes bug 66722: image map titles are not shown=20 (http://bugs.kde.org/show_bug.cgi?id=3D66722) You can test it on http://www.ader.ch/abc/effet.php Country names should now pop up correctly with the patch. It also works when there are several images with the same map on a page. There may be a better way to fix it, but I am not familiar with khtml. Anybody wants to review/correct/commit ? --Boundary-01=_G423AaYiuHMlmLV Content-Type: text/x-diff; charset="us-ascii"; name="maptitle.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="maptitle.diff" Index: khtmlview.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v retrieving revision 1.639 diff -u -3 -r1.639 khtmlview.cpp =2D-- khtmlview.cpp 19 Jun 2004 20:47:34 -0000 1.639 +++ khtmlview.cpp 27 Jun 2004 22:46:40 -0000 @@ -111,7 +111,7 @@ }; =20 protected: =2D virtual void maybeTip(const QPoint &); + virtual void maybeTip(const QPoint &p); =20 private: KHTMLView *m_view; @@ -326,18 +326,26 @@ =20 #ifndef QT_NO_TOOLTIP =20 =2Dvoid KHTMLToolTip::maybeTip(const QPoint& /*p*/) +void KHTMLToolTip::maybeTip(const QPoint& p) { DOM::NodeImpl *node =3D m_viewprivate->underMouse; + int vx,vy; + m_view->contentsToViewport(0,0,vx,vy); QRect region; while ( node ) { if ( node->isElementNode() ) { QString s =3D static_cast( node )->getAttri= bute( ATTR_TITLE ).string(); =2D QRect r =3D node->getRect(); + QRect r=3DQRect(); + if (node->id()=3D=3DID_AREA) + r =3D static_cast(node)->getRect(QP= oint(p.x()-vx,p.y()-vy)); + else r=3Dnode->getRect(); + if (!r.isEmpty()) + { region |=3D QRect( m_view->contentsToViewport( r.topLeft() ), = r.size() ); =2D if ( !s.isEmpty() ) { + if ( !s.isEmpty()) { tip( region, QStyleSheet::convertFromPlainText( s, QStyleS= heetItem::WhiteSpaceNormal ) ); break; + } } } node =3D node->parentNode(); Index: html/html_imageimpl.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/khtml/html/html_imageimpl.cpp,v retrieving revision 1.146 diff -u -3 -r1.146 html_imageimpl.cpp =2D-- html/html_imageimpl.cpp 25 Feb 2004 00:41:34 -0000 1.146 +++ html/html_imageimpl.cpp 27 Jun 2004 22:46:42 -0000 @@ -387,13 +387,29 @@ return inside; } =20 =2DQRect HTMLAreaElementImpl::getRect() const +QRect HTMLAreaElementImpl::getRect(const QPoint& p) const { =2D if (parentNode()->renderer()=3D=3D0) =2D return QRect(); =2D int dx, dy; =2D if (!parentNode()->renderer()->absolutePosition(dx, dy)) + if (!parentNode()) return QRect(); + + int dx=3D0, dy=3D0; + QString mapName=3Dstatic_cast(parentNode())->getAtt= ribute(ATTR_NAME).string(); + NodeImpl *de =3D static_cast(getDocument()); = =20 + for (NodeImpl* n =3D de->firstChild(); n; n =3D n->traverseNextNode()) + if ((n->id() =3D=3D ID_IMG)) + if (static_cast(n)->getAttribute( ATTR_USEMAP ).strin= g().section("#",-1)=3D=3DmapName) + { + QRect rec=3Dstatic_cast(n)->getRect(); + if (!rec.isNull()) + { + dx=3Drec.x(); + dy=3Drec.y(); + if (QRect(dx,dy,lastw,lasth).contains(p)) break; + } + } + =20 + //if (!parentNode()->renderer()->absolutePosition(dx, dy)) + // return QRect(); QRegion region =3D getRegion(lastw,lasth); region.translate(dx, dy); return region.boundingRect(); Index: html/html_imageimpl.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/khtml/html/html_imageimpl.h,v retrieving revision 1.66 diff -u -3 -r1.66 html_imageimpl.h =2D-- html/html_imageimpl.h 24 Jun 2003 21:56:04 -0000 1.66 +++ html/html_imageimpl.h 27 Jun 2004 22:46:42 -0000 @@ -87,7 +87,7 @@ bool mapMouseEvent(int x_, int y_, int width_, int height_, khtml::RenderObject::NodeInfo& info); =20 =2D virtual QRect getRect() const; + virtual QRect getRect(const QPoint& p) const; =20 protected: QRegion getRegion(int width_, int height) const; --Boundary-01=_G423AaYiuHMlmLV-- --nextPart1620044.FhJgRYGHzJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQBA324LB+BYfnGUHkURAu1wAJ42GHRESzvqU8tsfKIK18sQUpP//wCfVaOC Bz0mV09tUbpGyb/U9oLvVns= =fvPC -----END PGP SIGNATURE----- --nextPart1620044.FhJgRYGHzJ--