Closed Bug 299155 Opened 20 years ago Closed 18 years ago

Force-reload should invalidate the page's associated favicon.

Categories

(Camino Graveyard :: General, defect)

PowerPC
macOS
defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED
Camino1.5

People

(Reporter: moz, Assigned: froodian)

Details

(Keywords: fixed1.8.1.3)

Attachments

(1 file, 5 obsolete files)

The summary pretty much says it all. Currently, if the favicon changes after the
page has been visited, only a cache wipe will make Camino grab the new one.
It'd be good, but probably not for 1.0.
Target Milestone: --- → Camino1.1
Assignee: sfraser_bugs → nobody
QA Contact: general
STR:

1) Visit a page with a favicon (on some server you control)
2) Change the favicon to something else (or add a png using link rel to supplement a favicon.ico or whatever)
3) Visit the page again; note the favicon displayed is still favicon#1
4) Shift-reload; note the favicon displayed is still favicon#1

Expected: Step 4 should end with favicon#2 being displayed
Simon, a hint, please? :)

cl
You'll have to either purge from the caches the site icon and associated data for the current URL when you detect a force-reload, or pass the force-reload flags down into site icon loading.
Attached patch Patch (obsolete) — Splinter Review
A couple things here:

1. The portion in PreferenceManager.h is just a warning fix (SiteIconCache calls the method).
2. It feels kind of sketchy to me to be doing this as low down as CHBrowserView, but if I did it in BWC I'd have to triple some code or do some reload logic re-factoring.  Hmm... maybe that should be done anyway...
Assignee: nobody → stridey
Status: NEW → ASSIGNED
Attachment #247511 - Flags: review?(stuart.morgan)
Comment on attachment 247511 [details] [diff] [review]
Patch

Index: src/preferences/PreferenceManager.h
===================================================================

@@ -79,16 +79,17 @@
 - (void)setPref:(const char*)prefName toString:(NSString*)value;
 - (void)setPref:(const char*)prefName toInt:(int)value;
 - (void)setPref:(const char*)prefName toBoolean:(BOOL)value;
 
 - (void)clearPref:(const char*)prefName;
 
 // the path to the user profile's root folder, used by camino 0.8+
 - (NSString*)profilePath;
+- (NSString*)cacheParentDirPath;

It's not at all clear to me why this is necessary. Rest of it looks good, r=me with a satisfactory explanation of why that's needed (or with it removed if it's not).
Attachment #247511 - Flags: review?(stuart.morgan) → review+
(In reply to comment #6)
> It's not at all clear to me why this is necessary.

I am an idiot, and read the patch without seeing comment 5. Please ignore me. :)

On a related note, I can't think of any compelling reason why BWC should know about a page's favicon any more than CHBrowserView would.
(In reply to comment #7)
> On a related note, I can't think of any compelling reason why BWC should know
> about a page's favicon any more than CHBrowserView would.

Because favicons are used by BWC, and not by CHBrowserView. This seems like it should be done higher up.
Attached patch Patch (obsolete) — Splinter Review
Does it higher up.  As I mentioned in comment 5, this included some reload logic refactoring (some of which should have been done long ago) in order to do it gracefully.
Attachment #247511 - Attachment is obsolete: true
Attachment #248674 - Flags: review?(stuart.morgan)
Comment on attachment 248674 [details] [diff] [review]
Patch

Sorry this sat for so long :P

>+// uuid arg is optional (for speed)
>+- (void)removeImageForURL:(NSString*)inURL uuid:(NSString*)inUUID;

I haven't looked too much into this, but I assume that uuid is meaningless outside this class? If so, rather than making this public, make a public removeImageForURL that calls it with a nil UUID.

>+- (unsigned int)reloadFlagsForSender:(id)sender;

Is there an advantage to having this method rather than just passing the sender into the core reload method? It looks like it could just be folded in.

> // run a modal according to the users pref on opening a feed
> - (BOOL)shouldWarnBeforeOpeningFeed;
> - (void)buildFeedsDetectedListMenu:(NSNotification*)notifer; 
> - (IBAction)openFeedInExternalApp:(id)sender;
> 
> - (void)insertForceAlternatesIntoMenu:(NSMenu *)inMenu;
> - (BOOL)prepareSpellingSuggestionMenu:(NSMenu*)inMenu tag:(int)inTag;
> 
>@@ -2985,28 +2990,61 @@
> 
> - (IBAction)forward:(id)aSender
> {
>   [[mBrowserView getBrowserView] goForward];
> }
> 
> - (IBAction)reload:(id)aSender
> {
>-  unsigned int reloadFlags = NSLoadFlagsNone;
>+  [self reloadBrowserWrapper:mBrowserView withFlags:[self reloadFlagsForSender:aSender]];
>+}
>+
>+- (IBAction)reloadSendersTab:(id)sender
>+{
>+  if ([sender isMemberOfClass:[NSMenuItem class]]) {
>+    BrowserTabViewItem* tabViewItem = [mTabBrowser itemWithTag:[sender tag]];
>+    if (tabViewItem)
>+      [self reloadBrowserWrapper:[tabViewItem view] withFlags:[self reloadFlagsForSender:sender]];
>+  }
>+}
> 
>-  if ([aSender respondsToSelector:@selector(keyEquivalent)]) {
>+- (IBAction)reloadAllTabs:(id)sender
>+{
>+  NSEnumerator* tabsEnum = [[mTabBrowser tabViewItems] objectEnumerator];
>+  BrowserTabViewItem* curTabItem;
>+  while ((curTabItem = [tabsEnum nextObject])) {
>+    if ([curTabItem isKindOfClass:[BrowserTabViewItem class]])
>+      [self reloadBrowserWrapper:[curTabItem view] withFlags:[self reloadFlagsForSender:sender]];
>+  }
>+}
>+
>+- (void)reloadBrowserWrapper:(BrowserWrapper *)inWrapper withFlags:(unsigned int)reloadFlags
>+{
>+  if (reloadFlags == NSLoadFlagsBypassCacheAndProxy) {
>+    // Toss the favicon
>+    NSString* faviconURL = [[SiteIconProvider sharedFavoriteIconProvider] favoriteIconURLFromPageURL:[inWrapper getCurrentURI]];
>+    [[SiteIconCache sharedSiteIconCache] removeImageForURL:faviconURL uuid:nil];
>+  }
>+
>+  [[inWrapper getBrowserView] reload:reloadFlags];
>+}
>+
>+- (unsigned int)reloadFlagsForSender:(id)sender
>+{
>+  if ([sender respondsToSelector:@selector(keyEquivalent)]) {
>     // Capital R tests for shift when there's a keyEquivalent, keyEquivalentModifierMask tests when there isn't
>-    if ([[aSender keyEquivalent] isEqualToString:@"R"] || ([aSender keyEquivalentModifierMask] & NSShiftKeyMask))
>-      reloadFlags = NSLoadFlagsBypassCacheAndProxy;
>+    if ([[sender keyEquivalent] isEqualToString:@"R"] || ([sender keyEquivalentModifierMask] & NSShiftKeyMask))
>+      return NSLoadFlagsBypassCacheAndProxy;
>   }
>   // It's a toolbar button, so we test for shift using modifierFlags
>   else if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask)
>-    reloadFlags = NSLoadFlagsBypassCacheAndProxy;
>+    return NSLoadFlagsBypassCacheAndProxy;
> 
>-  [[mBrowserView getBrowserView] reload:reloadFlags];
>+  return NSLoadFlagsNone;
> }
> 
> - (IBAction)stop:(id)aSender
> {
>   [[mBrowserView getBrowserView] stop:NSStopLoadAll];
> }
> 
> - (IBAction)home:(id)aSender
>@@ -3397,52 +3435,16 @@
>         
>         [[doomedItem view] windowClosed];
>         [mTabBrowser removeTabViewItem:doomedItem];
>       }
>     }
>   }
> }
> 
>-- (IBAction)reloadSendersTab:(id)sender
>-{
>-  if ([sender isMemberOfClass:[NSMenuItem class]]) {
>-    BrowserTabViewItem* tabViewItem = [mTabBrowser itemWithTag:[sender tag]];
>-    if (tabViewItem) {
>-      unsigned int reloadFlags = NSLoadFlagsNone;
>-      // Capital R tests for shift when there's a keyEquivalent, keyEquivalentModifierMask tests when there isn't
>-      if ([[sender keyEquivalent] isEqualToString:@"R"] || ([sender keyEquivalentModifierMask] & NSShiftKeyMask))
>-        reloadFlags = NSLoadFlagsBypassCacheAndProxy;
>-
>-      [[[tabViewItem view] getBrowserView] reload:reloadFlags];
>-    }
>-  }
>-}
>-
>-- (IBAction)reloadAllTabs:(id)sender
>-{
>-  unsigned int reloadFlags = NSLoadFlagsNone;
>-
>-  if ([sender respondsToSelector:@selector(keyEquivalent)]) {
>-    // Capital R tests for shift when there's a keyEquivalent, keyEquivalentModifierMask tests when there isn't
>-    if ([[sender keyEquivalent] isEqualToString:@"R"] || ([sender keyEquivalentModifierMask] & NSShiftKeyMask))
>-      reloadFlags = NSLoadFlagsBypassCacheAndProxy;
>-  }
>-  // It's a toolbar button, so we test for shift using modifierFlags
>-  else if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask)
>-    reloadFlags = NSLoadFlagsBypassCacheAndProxy;
>-
>-  NSEnumerator* tabsEnum = [[mTabBrowser tabViewItems] objectEnumerator];
>-  BrowserTabViewItem* curTabItem;
>-  while ((curTabItem = [tabsEnum nextObject])) {
>-    if ([curTabItem isKindOfClass:[BrowserTabViewItem class]])
>-      [[[curTabItem view] getBrowserView] reload:reloadFlags];
>-  }
>-}
>-
> - (IBAction)moveTabToNewWindow:(id)sender
> {
>   if ([sender isMemberOfClass:[NSMenuItem class]])
>   {
>     BrowserTabViewItem* tabViewItem = [mTabBrowser itemWithTag:[sender tag]];
>     if (tabViewItem)
>     {
>       NSString* url = [[tabViewItem view] getCurrentURI];
>Index: src/preferences/PreferenceManager.h
>===================================================================
>RCS file: /cvsroot/mozilla/camino/src/preferences/PreferenceManager.h,v
>retrieving revision 1.21
>diff -u -8 -r1.21 PreferenceManager.h
>--- src/preferences/PreferenceManager.h	15 Nov 2006 23:39:15 -0000	1.21
>+++ src/preferences/PreferenceManager.h	14 Dec 2006 18:35:41 -0000
>@@ -79,16 +79,17 @@
> - (void)setPref:(const char*)prefName toString:(NSString*)value;
> - (void)setPref:(const char*)prefName toInt:(int)value;
> - (void)setPref:(const char*)prefName toBoolean:(BOOL)value;
> 
> - (void)clearPref:(const char*)prefName;
> 
> // the path to the user profile's root folder, used by camino 0.8+
> - (NSString*)profilePath;
>+- (NSString*)cacheParentDirPath;
> 
> // turn notifications on and off when the given pref changes. 
> // if not nil, inObject is used at the 'object' of the resulting notification.
> - (void)addObserver:(id)inObject forPref:(const char*)inPrefName;
> - (void)removeObserver:(id)inObject;    // remove from all prefs that it observes
> - (void)removeObserver:(id)inObject forPref:(const char*)inPrefName;
> 
> @end
Attachment #248674 - Flags: review?(stuart.morgan) → review-
Attached patch Patch (obsolete) — Splinter Review
(In reply to comment #10)
> (From update of attachment 248674 [details] [diff] [review])
> Sorry this sat for so long :P
> 
> >+// uuid arg is optional (for speed)
> >+- (void)removeImageForURL:(NSString*)inURL uuid:(NSString*)inUUID;
> 
> I haven't looked too much into this, but I assume that uuid is meaningless
> outside this class? If so, rather than making this public, make a public
> removeImageForURL that calls it with a nil UUID.

Done

> 
> >+- (unsigned int)reloadFlagsForSender:(id)sender;
> 
> Is there an advantage to having this method rather than just passing the sender
> into the core reload method? It looks like it could just be folded in.

No reason really.  I had considered doing it the way you suggest too - this patch does that.
Attachment #248674 - Attachment is obsolete: true
Comment on attachment 251599 [details] [diff] [review]
Patch

Sorry, two more things I didn't catch:

>+#import "SiteIconCache.h"

I think SiteIconCache should continue to be private to SiteIconProvider; no-one else should need to know how SIP does its work. So there needs to be a purge method in SIP that passes through to SIC.

>+#import "SiteIconProvider.h"

This one I feel stupid about, since I said to push it to BWC... I thought BWC already dealt with the site icon provider, but it doesn't, BrowserWrapper does. Since that's the layer those things happen at (and since if there's one thing BWC absolutely doesn't need it's to be tied to even more pieces), I think there should be a reload method added to BW that is called instead of a direct call past BW from BWC, and BW's reload should do this.

Please do keep the much-needed BWC reload refactoring though!
Attachment #251599 - Flags: review-
Attached patch Patch (obsolete) — Splinter Review
Done
Attachment #251599 - Attachment is obsolete: true
Attachment #252067 - Flags: review?(stuart.morgan)
Comment on attachment 252067 [details] [diff] [review]
Patch

What's here looks good, but the diff looks like it's missing the SiteIconProvider changes.
Attachment #252067 - Flags: review?(stuart.morgan)
Attached patch Patch (obsolete) — Splinter Review
Whoops.  Fixed.
Attachment #252067 - Attachment is obsolete: true
Attachment #252097 - Flags: review?(stuart.morgan)
Comment on attachment 252097 [details] [diff] [review]
Patch

Looks great; r=me
Attachment #252097 - Flags: superreview?(mikepinkerton)
Attachment #252097 - Flags: review?(stuart.morgan)
Attachment #252097 - Flags: review+
can we get some function-level comments on all the new methods added?
Attached patch PatchSplinter Review
Better documented.

Some things to note:
- The portion in BWC is largely refactoring, and moving the similar "reload" methods to be next to the plain-vanilla "reload"
- The PreferenceMaager portion is just a warning fix for an existing call
Attachment #252097 - Attachment is obsolete: true
Attachment #253901 - Flags: superreview?(mikepinkerton)
Attachment #252097 - Flags: superreview?(mikepinkerton)
Attachment #253901 - Flags: superreview?(mikepinkerton) → superreview+
Checked in on trunk and MOZILLA_1_8_BRANCH
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Keywords: fixed1.8.1.2
Resolution: --- → FIXED
Whiteboard: [needs checkin]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: