Changeset 109817 in webkit


Ignore:
Timestamp:
Mar 5, 2012 4:47:10 PM (12 years ago)
Author:
morrita@google.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=80257
Lifecycle of InternalSettings should be simplified.

Reviewed by Ryosuke Niwa.

  • Moved settings update code to separate restoreTo() method.
  • Eliminated flags which indidate the changed field. Now these modifiable parameters are backed up at the initialization.

No new tests. Refactoring.

  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::create):
(WebCore::InternalSettings::InternalSettings):
(WebCore):
(WebCore::InternalSettings::restoreTo):

  • testing/InternalSettings.h:

(InternalSettings):

  • testing/Internals.cpp:

(WebCore::Internals::reset):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109812 r109817  
     12012-03-05  MORITA Hajime  <morrita@google.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=80257
     4        Lifecycle of InternalSettings should be simplified.
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        - Moved settings update code to separate restoreTo() method.
     9        - Eliminated flags which indidate the changed field.
     10          Now these modifiable parameters are backed up at the initialization.
     11
     12        No new tests. Refactoring.
     13
     14        * testing/InternalSettings.cpp:
     15        (WebCore::InternalSettings::create):
     16        (WebCore::InternalSettings::InternalSettings):
     17        (WebCore):
     18        (WebCore::InternalSettings::restoreTo):
     19        * testing/InternalSettings.h:
     20        (InternalSettings):
     21        * testing/Internals.cpp:
     22        (WebCore::Internals::reset):
     23
    1242012-03-05  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r107665 r109817  
    8080
    8181
    82 PassRefPtr<InternalSettings> InternalSettings::create(Frame* frame, InternalSettings* old)
    83 {
    84     return adoptRef(new InternalSettings(frame, old));
     82PassRefPtr<InternalSettings> InternalSettings::create(Frame* frame)
     83{
     84    return adoptRef(new InternalSettings(frame));
    8585}
    8686
     
    8989}
    9090
    91 InternalSettings::InternalSettings(Frame* frame, InternalSettings* old)
     91InternalSettings::InternalSettings(Frame* frame)
    9292    : FrameDestructionObserver(frame)
    93     , m_passwordEchoDurationInSecondsBackup(0)
    94     , m_passwordEchoDurationInSecondsBackedUp(false)
    95     , m_passwordEchoEnabledBackedUp(false)
    96 {
    97     if (old && settings()) {
    98         if (old->m_passwordEchoDurationInSecondsBackedUp)
    99             settings()->setPasswordEchoDurationInSeconds(old->m_passwordEchoDurationInSecondsBackup);
    100         if (old->m_passwordEchoEnabledBackedUp)
    101             settings()->setPasswordEchoEnabled(old->m_passwordEchoEnabledBackup);
    102     }
     93    , m_originalPasswordEchoDurationInSeconds(settings()->passwordEchoDurationInSeconds())
     94    , m_originalPasswordEchoEnabled(settings()->passwordEchoEnabled())
     95
     96{
     97}
     98
     99void InternalSettings::restoreTo(Settings* settings)
     100{
     101    settings->setPasswordEchoDurationInSeconds(m_originalPasswordEchoDurationInSeconds);
     102    settings->setPasswordEchoEnabled(m_originalPasswordEchoEnabled);
    103103}
    104104
     
    174174{
    175175    InternalSettingsGuardForSettings();
    176     if (!m_passwordEchoEnabledBackedUp) {
    177         m_passwordEchoEnabledBackup = settings()->passwordEchoEnabled();
    178         m_passwordEchoEnabledBackedUp = true;
    179     }
    180176    settings()->setPasswordEchoEnabled(enabled);
    181177}
     
    184180{
    185181    InternalSettingsGuardForSettings();
    186     if (!m_passwordEchoDurationInSecondsBackedUp) {
    187         m_passwordEchoDurationInSecondsBackup = settings()->passwordEchoDurationInSeconds();
    188         m_passwordEchoDurationInSecondsBackedUp = true;
    189     }
    190182    settings()->setPasswordEchoDurationInSeconds(durationInSeconds);
    191183}
  • trunk/Source/WebCore/testing/InternalSettings.h

    r107665 r109817  
    4444                         public FrameDestructionObserver {
    4545public:
    46     static PassRefPtr<InternalSettings> create(Frame*, InternalSettings* old);
     46    static PassRefPtr<InternalSettings> create(Frame*);
    4747    virtual ~InternalSettings();
    4848
     
    6363    void setTouchEventEmulationEnabled(bool enabled, ExceptionCode&);
    6464
     65    void restoreTo(Settings*);
     66
    6567private:
    66     InternalSettings(Frame*, InternalSettings* old);
     68    InternalSettings(Frame*);
    6769
    6870    Settings* settings() const;
     
    7072    Page* page() const;
    7173
    72     double m_passwordEchoDurationInSecondsBackup;
    73     bool m_passwordEchoEnabledBackup : 1;
    74     bool m_passwordEchoDurationInSecondsBackedUp : 1;
    75     bool m_passwordEchoEnabledBackedUp : 1;
     74    double m_originalPasswordEchoDurationInSeconds;
     75    bool m_originalPasswordEchoEnabled;
    7676};
    7777
  • trunk/Source/WebCore/testing/Internals.cpp

    r109402 r109817  
    435435
    436436    observeFrame(document->frame());
    437     m_settings = InternalSettings::create(document->frame(), m_settings.get());
     437
     438    if (m_settings)
     439        m_settings->restoreTo(document->page()->settings());
     440    m_settings = InternalSettings::create(document->frame());
    438441    if (Page* page = document->page())
    439442        page->setPagination(Page::Pagination());
Note: See TracChangeset for help on using the changeset viewer.