Commit ab528fba authored by beidson@apple.com's avatar beidson@apple.com

2008-04-24 Brady Eidson <beidson@apple.com>

        Reviewed by Teh Mitzpettel

        Make it so PageGroups know what their own name is.

        * WebCore.base.exp:

        * page/Page.cpp:
        (WebCore::Page::setGroupName):
        (WebCore::Page::groupName):
        * page/Page.h:

        * page/PageGroup.cpp: Move the PageGroupMap into the PageGroup class.
        (WebCore::PageGroup::PageGroup): Added a c'tor that takes the group name as an argument instead of
          the initial Page.
        (WebCore::PageGroup::pageGroup): Handles creating and mapping names to groups
        * page/PageGroup.h:
        (WebCore::PageGroup::name):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32524 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 32d02344
2008-04-24 Brady Eidson <beidson@apple.com>
Reviewed by Teh Mitzpettel
Make it so PageGroups know what their own name is.
* WebCore.base.exp:
* page/Page.cpp:
(WebCore::Page::setGroupName):
(WebCore::Page::groupName):
* page/Page.h:
* page/PageGroup.cpp: Move the PageGroupMap into the PageGroup class.
(WebCore::PageGroup::PageGroup): Added a c'tor that takes the group name as an argument instead of
the initial Page.
(WebCore::PageGroup::pageGroup): Handles creating and mapping names to groups
* page/PageGroup.h:
(WebCore::PageGroup::name):
2008-04-24 Adele Peterson <adele@apple.com>
Reviewed by Darin.
......@@ -727,6 +727,7 @@ __ZNK7WebCore4Node18getSubresourceURLsERN3WTF6VectorINS_4KURLELm0EEE
__ZNK7WebCore4Node9nodeIndexEv
__ZNK7WebCore4Page10pluginDataEv
__ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
__ZNK7WebCore4Page9groupNameEv
__ZNK7WebCore5Frame10isFrameSetEv
__ZNK7WebCore5Frame11currentFormEv
__ZNK7WebCore5Frame11typingStyleEv
......
......@@ -61,10 +61,7 @@
namespace WebCore {
typedef HashMap<String, PageGroup*> PageGroupMap;
static HashSet<Page*>* allPages;
static PageGroupMap* pageGroups;
#ifndef NDEBUG
WTFLogChannel LogWebCorePageLeaks = { 0x00000000, "", WTFLogChannelOn };
......@@ -182,33 +179,27 @@ void Page::goToItem(HistoryItem* item, FrameLoadType type)
void Page::setGroupName(const String& name)
{
if (!m_groupName.isEmpty()) {
if (m_group && !m_group->name().isEmpty()) {
ASSERT(m_group != m_singlePageGroup.get());
ASSERT(!m_singlePageGroup);
ASSERT(m_group);
ASSERT(pageGroups);
ASSERT(pageGroups->get(m_groupName) == m_group);
m_group->removePage(this);
}
m_groupName = name;
if (name.isEmpty())
m_group = 0;
else {
m_singlePageGroup.clear();
if (!pageGroups)
pageGroups = new PageGroupMap;
pair<PageGroupMap::iterator, bool> result = pageGroups->add(name, 0);
if (!result.second) {
ASSERT(result.first->second);
m_group = result.first->second;
m_group->addPage(this);
} else {
ASSERT(!result.first->second);
m_group = new PageGroup(this);
result.first->second = m_group;
}
m_group = PageGroup::pageGroup(name);
m_group->addPage(this);
}
}
const String& Page::groupName() const
{
static String nullString;
return m_group ? m_group->name() : nullString;
}
void Page::initGroup()
{
ASSERT(!m_singlePageGroup);
......
......@@ -95,7 +95,7 @@ namespace WebCore {
void goToItem(HistoryItem*, FrameLoadType);
void setGroupName(const String&);
const String& groupName() const { return m_groupName; }
const String& groupName() const;
PageGroup& group() { if (!m_group) initGroup(); return *m_group; }
PageGroup* groupPtr() { return m_group; } // can return 0
......
......@@ -47,6 +47,13 @@ static unsigned getUniqueIdentifier()
static bool shouldTrackVisitedLinks;
PageGroup::PageGroup(const String& name)
: m_name(name)
, m_visitedLinksPopulated(false)
, m_identifier(getUniqueIdentifier())
{
}
PageGroup::PageGroup(Page* page)
: m_visitedLinksPopulated(false)
, m_identifier(getUniqueIdentifier())
......@@ -55,6 +62,27 @@ PageGroup::PageGroup(Page* page)
m_pages.add(page);
}
typedef HashMap<String, PageGroup*> PageGroupMap;
static PageGroupMap* pageGroups = 0;
PageGroup* PageGroup::pageGroup(const String& groupName)
{
ASSERT(!groupName.isEmpty());
if (!pageGroups)
pageGroups = new PageGroupMap;
pair<PageGroupMap::iterator, bool> result = pageGroups->add(groupName, 0);
if (result.second) {
ASSERT(!result.first->second);
result.first->second = new PageGroup(groupName);
}
ASSERT(result.first->second);
return result.first->second;
}
void PageGroup::addPage(Page* page)
{
ASSERT(page);
......
......@@ -38,8 +38,11 @@ namespace WebCore {
class PageGroup : Noncopyable {
public:
PageGroup(const String& name);
PageGroup(Page*);
static PageGroup* pageGroup(const String& groupName);
const HashSet<Page*>& pages() const { return m_pages; }
void addPage(Page*);
......@@ -54,6 +57,7 @@ namespace WebCore {
static void setShouldTrackVisitedLinks(bool);
static void removeAllVisitedLinks();
const String& name() { return m_name; }
unsigned identifier() { return m_identifier; }
#if ENABLE(DOM_STORAGE)
......@@ -63,6 +67,8 @@ namespace WebCore {
private:
void addVisitedLink(unsigned stringHash);
String m_name;
HashSet<Page*> m_pages;
HashSet<unsigned, AlreadyHashed> m_visitedLinkHashes;
bool m_visitedLinksPopulated;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment