Changeset 163644 in webkit


Ignore:
Timestamp:
Feb 7, 2014 1:42:30 PM (10 years ago)
Author:
andersca@apple.com
Message:

Simplify WebPreferences creation inside WebPageGroup
https://bugs.webkit.org/show_bug.cgi?id=128392

Reviewed by Andreas Kling.

Always create a WebPreferences object when creating the web page group.
This is another step towards letting WebPageProxy manage web preferences.

  • UIProcess/WebPageGroup.cpp:

(WebKit::pageGroupData):
(WebKit::WebPageGroup::WebPageGroup):
(WebKit::WebPageGroup::~WebPageGroup):
(WebKit::WebPageGroup::setPreferences):
(WebKit::WebPageGroup::preferences):

  • UIProcess/WebPageGroup.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r163643 r163644  
     12014-02-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Simplify WebPreferences creation inside WebPageGroup
     4        https://bugs.webkit.org/show_bug.cgi?id=128392
     5
     6        Reviewed by Andreas Kling.
     7
     8        Always create a WebPreferences object when creating the web page group.
     9        This is another step towards letting WebPageProxy manage web preferences.
     10
     11        * UIProcess/WebPageGroup.cpp:
     12        (WebKit::pageGroupData):
     13        (WebKit::WebPageGroup::WebPageGroup):
     14        (WebKit::WebPageGroup::~WebPageGroup):
     15        (WebKit::WebPageGroup::setPreferences):
     16        (WebKit::WebPageGroup::preferences):
     17        * UIProcess/WebPageGroup.h:
     18
    1192014-02-07  Gavin Barraclough  <barraclough@apple.com>
    220
  • trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp

    r163635 r163644  
    6666}
    6767
    68 WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
     68static WebPageGroupData pageGroupData(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
    6969{
    70     m_data.pageGroupID = generatePageGroupID();
     70    WebPageGroupData data;
     71
     72    data.pageGroupID = generatePageGroupID();
    7173
    7274    if (!identifier.isEmpty())
    73         m_data.identifer = identifier;
     75        data.identifer = identifier;
    7476    else
    75         m_data.identifer = m_data.identifer = makeString("__uniquePageGroupID-", String::number(m_data.pageGroupID));
     77        data.identifer = makeString("__uniquePageGroupID-", String::number(data.pageGroupID));
    7678
    77     m_data.visibleToInjectedBundle = visibleToInjectedBundle;
    78     m_data.visibleToHistoryClient = visibleToHistoryClient;
    79    
     79    data.visibleToInjectedBundle = visibleToInjectedBundle;
     80    data.visibleToHistoryClient = visibleToHistoryClient;
     81
     82    return data;
     83}
     84
     85WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
     86    : m_data(pageGroupData(identifier, visibleToInjectedBundle, visibleToHistoryClient))
     87    , m_preferences(WebPreferences::create(m_data.identifer))
     88{
     89    m_preferences->addPageGroup(this);
    8090    webPageGroupMap().set(m_data.pageGroupID, this);
    8191}
     
    8393WebPageGroup::~WebPageGroup()
    8494{
    85     if (m_preferences)
    86         m_preferences->removePageGroup(this);
     95    m_preferences->removePageGroup(this);
    8796    webPageGroupMap().remove(pageGroupID());
    8897}
     
    103112        return;
    104113
    105     if (!m_preferences) {
    106         m_preferences = preferences;
    107         m_preferences->addPageGroup(this);
     114    m_preferences->removePageGroup(this);
     115    m_preferences = preferences;
     116    m_preferences->addPageGroup(this);
    108117
    109         for (auto& webPageProxy : m_pages)
    110             webPageProxy->setPreferences(*m_preferences);
    111     } else {
    112         m_preferences->removePageGroup(this);
    113         m_preferences = preferences;
    114         m_preferences->addPageGroup(this);
     118    for (auto& webPageProxy : m_pages)
     119        webPageProxy->setPreferences(*m_preferences);
    115120
    116         for (auto& webPageProxy : m_pages)
    117             webPageProxy->setPreferences(*m_preferences);
    118 
    119         preferencesDidChange();
    120     }
     121    preferencesDidChange();
    121122}
    122123
    123124WebPreferences& WebPageGroup::preferences() const
    124125{
    125     if (!m_preferences) {
    126         if (!m_data.identifer.isNull())
    127             m_preferences = WebPreferences::create(m_data.identifer);
    128         else
    129             m_preferences = WebPreferences::create();
    130         m_preferences->addPageGroup(const_cast<WebPageGroup*>(this));
    131     }
    132 
    133126    return *m_preferences;
    134127}
  • trunk/Source/WebKit2/UIProcess/WebPageGroup.h

    r163597 r163644  
    7070
    7171    WebPageGroupData m_data;
    72     mutable RefPtr<WebPreferences> m_preferences;
     72    RefPtr<WebPreferences> m_preferences;
    7373    HashSet<WebPageProxy*> m_pages;
    7474};
Note: See TracChangeset for help on using the changeset viewer.