Make sure the removal of user stylesheets results in all of the WebViews being updated to
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Oct 2009 00:13:39 +0000 (00:13 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Oct 2009 00:13:39 +0000 (00:13 +0000)
reflect the changes.

Reviewed by Tim Hatcher.

* page/PageGroup.cpp:
(WebCore::PageGroup::removeUserContentWithURLForWorld):
(WebCore::PageGroup::removeUserContentForWorld):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48951 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/PageGroup.cpp

index 45d38d521a4526b6614dd0c9526d5f56474475a6..bdae905efec5677e24282114071b58c9a8b96239 100644 (file)
@@ -1,3 +1,14 @@
+2009-09-30  Dave Hyatt  <hyatt@apple.com>
+
+        Reviewed by Tim Hatcher.
+
+        Make sure the removal of user stylesheets results in all of the WebViews being updated to
+        reflect the changes.
+
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::removeUserContentWithURLForWorld):
+        (WebCore::PageGroup::removeUserContentForWorld):
+
 2009-09-30  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Sam Weinig.
index 9d6f792df9129c7b1a5f45acbef749ad22367b44..210a02aa96c1134a957c5c3d3e7a3d54bb3cd12c 100644 (file)
@@ -253,11 +253,14 @@ void PageGroup::removeUserContentWithURLForWorld(const KURL& url, unsigned world
     
     if (m_userStyleSheets) {
         UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
+        bool sheetsChanged = false;
         if (it != m_userStyleSheets->end()) {
             UserStyleSheetVector* stylesheets = it->second;
             for (int i = stylesheets->size() - 1; i >= 0; --i) {
-                if (stylesheets->at(i)->url() == url)
+                if (stylesheets->at(i)->url() == url) {
                     stylesheets->remove(i);
+                    sheetsChanged = true;
+                }
             }
             
             if (stylesheets->isEmpty()) {
@@ -265,6 +268,15 @@ void PageGroup::removeUserContentWithURLForWorld(const KURL& url, unsigned world
                 delete it->second;
             }
         }
+        
+        // Clear our cached sheets and have them just reparse.
+        if (sheetsChanged) {
+            HashSet<Page*>::const_iterator end = m_pages.end();
+            for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) {
+                for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
+                    frame->document()->clearPageGroupUserSheets();
+            }
+        }
     }
 }
 
@@ -279,11 +291,22 @@ void PageGroup::removeUserContentForWorld(unsigned worldID)
     }
     
     if (m_userStyleSheets) {
+        bool sheetsChanged = false;
         UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
         if (it != m_userStyleSheets->end()) {
             m_userStyleSheets->remove(it);
+            sheetsChanged = true;
             delete it->second;
         }
+    
+        if (sheetsChanged) {
+            // Clear our cached sheets and have them just reparse.
+            HashSet<Page*>::const_iterator end = m_pages.end();
+            for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) {
+                for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
+                    frame->document()->clearPageGroupUserSheets();
+            }
+        }
     }
 }