lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev dev.10 progress


From: Leonid Pauzner
Subject: Re: lynx-dev dev.10 progress
Date: Tue, 19 Nov 2002 02:10:16 +0300 (MSK)

One more patch

* in partial mode, load document with #fragment on the fly. Long awaited fix.
  LYMainLoop_pageDisplay() now returns BOOL.



diff -u -p -r LYNX2-8-.59F/src/lymainlo.c LYNX2-8-/src/lymainlo.c
--- LYNX2-8-.59F/src/lymainlo.c Mon Nov 18 19:51:46 2002
+++ LYNX2-8-/src/lymainlo.c     Tue Nov 19 01:29:48 2002
@@ -474,13 +474,22 @@ PRIVATE void move_address ARGS2(
 /*
  * This is for traversal call from within partial mode in LYUtils.c
  * and HTFormat.c  It simply calls HText_pageDisplay() but utilizes
- * LYMainLoop.c PRIVATE variables.
- * Perhaps, this could adhere more logic from mainloop(), in the future.
+ * LYMainLoop.c PRIVATE variables to manage proper newline position
+ * in case of #fragment
  */
-PUBLIC void LYMainLoop_pageDisplay ARGS1(
+PUBLIC BOOL LYMainLoop_pageDisplay ARGS1(
        int,            line_num)
 {
 #ifdef DISP_PARTIAL
+    CONST char * pound;
+    int prev_newline = Newline;
+
+    /*
+     *  Override Newline with a new value if user
+     *  scrolled the document while loading (in LYUtils.c).
+     */
+    Newline = line_num;
+
 #ifdef SOURCE_CACHE
     /*
      * reparse_document() acts on 'curdoc' which always on top of the
@@ -490,29 +499,30 @@ PUBLIC void LYMainLoop_pageDisplay ARGS1
      */
     if (!from_source_cache)
 #endif
-    /*
-     * Disable display_partial if requested URL has #fragment and we are not
-     * popped from the history stack so can't calculate correct newline
-     * position for fragment.  Otherwise user got the new document from the
-     * first page and was moved to #fragment later after download completed,
-     * but only if s/he did not mess screen up by scrolling before...  So fall
-     * down to old behavior here ... until we rewrite HTFindPoundSelector()
-     */
-    if (display_partial
-     && newdoc.line == 1
-     && findPoundSelector(newdoc.address)) {
-       display_partial = FALSE; /* restrict for this document */
-       return;                 /* no repaint */
-    }
-
-    /*
-     *  Override Newline with a new value if user
-     *  scrolled the document while loading (in LYUtils.c).
-     */
+       /*
+        * If the requested URL has the #fragment, and we are not popped
+        * from the history stack, and have not scrolled the document yet -
+        * we should calculate correct newline position for the fragment.
+        * (This is a bit suboptimal since HTFindPoundSelector() traverse
+        * anchors list each time, so we have a quadratic complexity
+        * and may load CPU in a worst case).
+        */
+       if (display_partial
+            && newdoc.line == 1 && line_num == 1 && prev_newline == 1
+            && (pound = findPoundSelector(newdoc.address))
+            && *pound && *(pound+1)) {
+           if (HTFindPoundSelector(pound+1)) {
+               /* HTFindPoundSelector will initialize www_search_result */
+               Newline = www_search_result;
+           } else {
+               Newline = prev_newline; /* restore ??? */
+               return NO;      /* no repaint */
+           }
+       }
 #endif /* DISP_PARTIAL */
-    Newline = line_num;

     HText_pageDisplay(Newline, prev_target);
+    return YES;
 }


diff -u -p -r LYNX2-8-.59F/src/lymainlo.h LYNX2-8-/src/lymainlo.h
--- LYNX2-8-.59F/src/lymainlo.h Fri Jun 23 08:15:08 2000
+++ LYNX2-8-/src/lymainlo.h     Tue Nov 19 00:39:38 2002
@@ -10,7 +10,7 @@ extern int LYGetNewline NOPARAMS;
 extern int mainloop NOPARAMS;
 extern void HTAddGotoURL PARAMS((char *url));
 extern void LYCloseTracelog NOPARAMS;
-extern void LYMainLoop_pageDisplay PARAMS((int line_num));
+extern BOOL LYMainLoop_pageDisplay PARAMS((int line_num));
 extern void LYSetNewline PARAMS((int value));
 extern void handle_LYK_TRACE_TOGGLE NOPARAMS;
 extern void handle_LYK_WHEREIS PARAMS((int cmd, BOOLEAN *refresh_screen));
diff -u -p -r LYNX2-8-.59F/src/lyutils.c LYNX2-8-/src/lyutils.c
--- LYNX2-8-.59F/src/lyutils.c  Mon Nov 18 19:51:46 2002
+++ LYNX2-8-/src/lyutils.c      Tue Nov 19 00:39:20 2002
@@ -1731,8 +1731,8 @@ PUBLIC int HTCheckForInterrupt NOARGS
            } /* end switch */
            if (Newline_partial < 1)
                Newline_partial = 1;
-           NumOfLines_partial = HText_getNumOfLines();
-           LYMainLoop_pageDisplay(Newline_partial);
+           if (LYMainLoop_pageDisplay(Newline_partial))
+               NumOfLines_partial = HText_getNumOfLines();
        }
 #endif /* DISP_PARTIAL */
        break;
--- LYNX2-8-.59F/www/library/implemen/htformat.c        Sun Jun  3 12:58:00 2001
+++ LYNX2-8-/www/library/implemen/htformat.c    Tue Nov 19 00:37:48 2002
@@ -627,8 +627,8 @@ PUBLIC void HTDisplayPartial NOARGS
                 * If partial_threshold <= 0, then it's a full page
                 */
        ) {
-           NumOfLines_partial = HText_getNumOfLines();
-           LYMainLoop_pageDisplay(Newline_partial);
+           if (LYMainLoop_pageDisplay(Newline_partial))
+               NumOfLines_partial = HText_getNumOfLines();
        }
     }
 #else /* nothing */
diff -u -p -r LYNX2-8-.59F/src/gridtext.c LYNX2-8-/src/gridtext.c
--- LYNX2-8-.59F/src/gridtext.c Mon Nov 18 19:51:44 2002
+++ LYNX2-8-/src/gridtext.c     Tue Nov 19 00:33:04 2002
@@ -7028,7 +7023,7 @@ PUBLIC BOOL HText_POSTReplyLoaded ARGS1(
 }

 PUBLIC BOOL HTFindPoundSelector ARGS1(
-       char *,         selector)
+       CONST char *,           selector)
 {
     TextAnchor * a;

diff -u -p -r LYNX2-8-.59F/src/gridtext.h LYNX2-8-/src/gridtext.h
--- LYNX2-8-.59F/src/gridtext.h Mon Nov 18 19:51:44 2002
+++ LYNX2-8-/src/gridtext.h     Tue Nov 19 00:33:22 2002
@@ -112,7 +114,7 @@ extern void HText_setMainTextOwner PARAM
 extern void print_wwwfile_to_fd PARAMS((FILE * fp, BOOLEAN is_reply));
 extern BOOL HText_select PARAMS((HText *text));
 extern BOOL HText_POSTReplyLoaded PARAMS((DocInfo *doc));
-extern BOOL HTFindPoundSelector PARAMS((char *selector));
+extern BOOL HTFindPoundSelector PARAMS((CONST char *selector));
 extern int HTGetRelLinkNum PARAMS((int num, int rel, int cur));
 extern int HTGetLinkInfo PARAMS((
        int             number,
diff -u -p -r LYNX2-8-.59F/src/htalert.c LYNX2-8-/src/htalert.c
--- LYNX2-8-.59F/src/htalert.c  Sun Oct  6 17:43:28 2002
+++ LYNX2-8-/src/htalert.c      Sun Oct 13 15:15:58 2002
@@ -244,15 +244,18 @@ PUBLIC void HTReadProgress ARGS2(
        total_last = total;

        /*
-        * Optimal refresh time:  every 0.2 sec, use interpolation.  Transfer
-        * rate is not constant when we have partial content in a proxy, so
-        * interpolation lies - will check every second at least for sure.
+        * Optimal refresh time:  every 0.2 sec
         */
-#ifdef HAVE_GETTIMEOFDAY
+#if defined(HAVE_GETTIMEOFDAY) || (defined(HAVE_FTIME) && 
defined(HAVE_SYS_TIMEB_H))
        if (now >= last + 0.2)
            renew = 1;
 #else
-       if (((bytes - bytes_last) > (transfer_rate / 5)) || (now != last)) {
+       /*
+        * Use interpolation.  (The transfer rate may be not constant
+        * when we have partial content in a proxy.  We adjust transfer_rate
+        * once a second to minimize interpolation error below.)
+        */
+       if ((now != last) || ((bytes - bytes_last) > (transfer_rate / 5))) {
            renew = 1;
            bytes_last += (transfer_rate / 5);  /* until we got next second */
        }
@@ -263,7 +266,7 @@ PUBLIC void HTReadProgress ARGS2(
                if (bytes_last != bytes)
                    last_active = now;
                bytes_last = bytes;
-               transfer_rate = (long)(bytes / (now - first)); /* more accurate 
here */
+               transfer_rate = (long)(bytes / (now - first)); /* more accurate 
value */
            }

            if (total > 0)


; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]