From 8e6c2840b4149e356350cac7449a96323b4466ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 17 Nov 2009 20:20:48 +0000 Subject: [PATCH] Improved handling of anchors in wxHTML: scroll to better position (patch #11406). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62674 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + samples/html/test/test.htm | 15 ++++++++++----- src/html/htmlwin.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f87dbe627e..6ba84595a4 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -716,6 +716,7 @@ All (GUI): new CheckFit() method for more information. - Allow reading GIFs with incorrectly specified animation size. - Return number of frames in animated GIF from wxGIFHandler::GetImageCount(). +- Improved anchors handling in wxHTML. wxGTK: diff --git a/samples/html/test/test.htm b/samples/html/test/test.htm index 82a791c42a..2ca1052a2c 100644 --- a/samples/html/test/test.htm +++ b/samples/html/test/test.htm @@ -25,7 +25,11 @@ Agrave = 'à' This is - - default text, now switching to

center, now still ctr, now exiting

-exited!.[link to down] +exited!.[link to down] +

[link to REALLY Big Text (empty anchor)] + [link to REALLY Big Text (anchor containing text)] +

[link into paragraph (empty anchor)] [link into paragraph (anchor containing text)] + [link to empty container]

Hello, this *is* default charset (helvetica, probably) and it is displayed with one  COLOR CHANGE. Of course we can have as many color changes as we can, what about this MADNESS? @@ -38,7 +42,8 @@ V E R Y T H I N G.
 


-

Right now, centered REALLY Big Text, + +

Right now, centered REALLY Big Text, how do you like (space) it?

RIGHT: text-2, text-1, @@ -237,14 +242,14 @@ kjegiquw iuqdb qiud iquwd hurray googoo. fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN -fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN +fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen (anchor here) fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN


fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN

fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen -fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen -fourteenfourteen FOURTEEN +fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen fourteen fourteen fourteen fourteenfourteen FOURTEEN fourteen fourteen fourteen +fourteen fourteen fourteen fourteen fourteen FOURTEEN

  • This is item number 15.
  • diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index 86e997045a..636a07610f 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -657,6 +657,16 @@ bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor) } else { + // Go to next visible cell in current container, if it exists. This + // yields a bit better (even though still imperfect) results in that + // there's better chance of using a suitable cell for upper Y + // coordinate value. See bug #11406 for additional discussion. + const wxHtmlCell *c_save = c; + while ( c && c->IsFormattingCell() ) + c = c->GetNext(); + if ( !c ) + c = c_save; + int y; for (y = 0; c != NULL; c = c->GetParent()) y += c->GetPosY(); -- 2.45.2