[haiku-webkit-commits] r269 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 02 Mar 2010 18:56:42 +0000

Author: stippi
Date: Tue Mar  2 18:56:42 2010
New Revision: 269
URL: http://mmlr.dyndns.org/changeset/269

Log:
Ok, the most simplistic way to avoid having too many similars in the 
autocompletion
choices is to find the "base url" (I am taking the string between :// and the
next /) and avoid adding any more urls with the same base URL. Seems to work
reasonably well. If anyone has any smarter ideas, please speak up! :-)

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Tue Mar  2 
18:40:50 2010        (r268)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Tue Mar  2 
18:56:42 2010        (r269)
@@ -109,6 +109,8 @@
                if (!history->Lock())
                        return;
 
+               BString lastBaseURL;
+
                count = history->countItems();
                for (int32 i = 0; i < count; i++) {
                        BrowsingHistoryItem item = history->historyItemAt(i);
@@ -116,6 +118,14 @@
                        int32 matchPos = choiceText.IFindFirst(pattern);
                        if (matchPos < 0)
                                continue;
+                       if (lastBaseURL.Length() > 0
+                               && choiceText.FindFirst(lastBaseURL) >= 0) {
+                               continue;
+                       }
+                       int32 baseURLStart = choiceText.FindFirst("://") + 3;
+                       int32 baseURLEnd = choiceText.FindFirst("/", 
baseURLStart + 1);
+                       lastBaseURL.SetTo(choiceText.String() + baseURLStart,
+                               baseURLEnd - baseURLStart);
                        fChoices.AddItem(new BAutoCompleter::Choice(choiceText,
                                choiceText, matchPos, pattern.Length()));
                }

Other related posts: