Changeset 135753 in webkit


Ignore:
Timestamp:
Nov 26, 2012, 12:27:36 PM (12 years ago)
Author:
tony@chromium.org
Message:

Move more functions from internals.settings to internals
https://bugs.webkit.org/show_bug.cgi?id=102976

Reviewed by Adam Barth.

Source/WebCore:

Move functions that don't have to do with Settings off of internals.settings.
setPagination and configurationForViewport were defined on internals, so we
can inline the functions (no test change).

setEnableMockPagePopup is moved to Internals.

No new tests, this is a refactor.

  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::reset): Move reset code into Internals.

  • testing/InternalSettings.h:

(InternalSettings): Remove code for setPagination, configurationForViewport and setEnableMockPagePopup.

  • testing/InternalSettings.idl: Remove setPagination and setEnableMockPagePopup.
  • testing/Internals.cpp:

(WebCore): Use a static to keep track of the MockPagePopupDriver.
(WebCore::Internals::resetToConsistentState): Code from InternalSettings::reset
(WebCore::Internals::setEnableMockPagePopup): Code copied from InternalSettings.
(WebCore::Internals::pagePopupController): Code copied from InternalSettings.
(WebCore::Internals::setPagination): Code copied from InternalSettings.
(WebCore::Internals::configurationForViewport): Code copied from InternalSettings.

  • testing/Internals.h:

(Internals): Add setEnableMockPagePopup.

  • testing/Internals.idl: Add setEnableMockPagePopup.

LayoutTests:

Move internals.settings.setEnableMockPagePopup to internals.setEnableMockPagePopup.

  • fast/forms/resources/picker-common.js:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r135750 r135753  
     12012-11-26  Tony Chang  <tony@chromium.org>
     2
     3        Move more functions from internals.settings to internals
     4        https://bugs.webkit.org/show_bug.cgi?id=102976
     5
     6        Reviewed by Adam Barth.
     7
     8        Move internals.settings.setEnableMockPagePopup to internals.setEnableMockPagePopup.
     9
     10        * fast/forms/resources/picker-common.js:
     11
    1122012-11-26  Andrei Bucur  <abucur@adobe.com>
    213
  • trunk/LayoutTests/fast/forms/resources/picker-common.js

    r134180 r135753  
    11window.jsTestIsAsync = true;
    22if (window.internals)
    3     internals.settings.setEnableMockPagePopup(true);
     3    internals.setEnableMockPagePopup(true);
    44
    55var popupWindow = null;
  • trunk/Source/WebCore/ChangeLog

    r135750 r135753  
     12012-11-26  Tony Chang  <tony@chromium.org>
     2
     3        Move more functions from internals.settings to internals
     4        https://bugs.webkit.org/show_bug.cgi?id=102976
     5
     6        Reviewed by Adam Barth.
     7
     8        Move functions that don't have to do with Settings off of internals.settings.
     9        setPagination and configurationForViewport were defined on internals, so we
     10        can inline the functions (no test change).
     11
     12        setEnableMockPagePopup is moved to Internals.
     13
     14        No new tests, this is a refactor.
     15
     16        * testing/InternalSettings.cpp:
     17        (WebCore::InternalSettings::reset): Move reset code into Internals.
     18        * testing/InternalSettings.h:
     19        (InternalSettings): Remove code for setPagination, configurationForViewport and setEnableMockPagePopup.
     20        * testing/InternalSettings.idl: Remove setPagination and setEnableMockPagePopup.
     21        * testing/Internals.cpp:
     22        (WebCore): Use a static to keep track of the MockPagePopupDriver.
     23        (WebCore::Internals::resetToConsistentState): Code from InternalSettings::reset
     24        (WebCore::Internals::setEnableMockPagePopup): Code copied from InternalSettings.
     25        (WebCore::Internals::pagePopupController): Code copied from InternalSettings.
     26        (WebCore::Internals::setPagination): Code copied from InternalSettings.
     27        (WebCore::Internals::configurationForViewport): Code copied from InternalSettings.
     28        * testing/Internals.h:
     29        (Internals): Add setEnableMockPagePopup.
     30        * testing/Internals.idl: Add setEnableMockPagePopup.
     31
    1322012-11-26  Andrei Bucur  <abucur@adobe.com>
    233
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r135227 r135753  
    2727#include "InternalSettings.h"
    2828
    29 #include "Chrome.h"
    30 #include "ChromeClient.h"
    3129#include "Document.h"
    3230#include "ExceptionCode.h"
     
    3533#include "Language.h"
    3634#include "LocaleToScriptMapping.h"
    37 #include "MockPagePopupDriver.h"
    3835#include "Page.h"
    3936#include "RuntimeEnabledFeatures.h"
     
    176173}
    177174
    178 #if ENABLE(PAGE_POPUP)
    179 PagePopupController* InternalSettings::pagePopupController()
    180 {
    181     return m_pagePopupDriver ? m_pagePopupDriver->pagePopupController() : 0;
    182 }
    183 #endif
    184 
    185175void InternalSettings::reset()
    186176{
    187     page()->setPagination(Pagination());
    188177    page()->setPageScaleFactor(1, IntPoint(0, 0));
    189 #if ENABLE(PAGE_POPUP)
    190     m_pagePopupDriver.clear();
    191     if (page()->chrome())
    192         page()->chrome()->client()->resetPagePopupDriver();
    193 #endif
    194178
    195179    m_backup.restoreTo(page(), settings());
     
    559543}
    560544
    561 void InternalSettings::setPagination(const String& mode, int gap, int pageLength, ExceptionCode& ec)
    562 {
    563     if (!page()) {
    564         ec = INVALID_ACCESS_ERR;
    565         return;
    566     }
    567 
    568     Pagination pagination;
    569     if (mode == "Unpaginated")
    570         pagination.mode = Pagination::Unpaginated;
    571     else if (mode == "LeftToRightPaginated")
    572         pagination.mode = Pagination::LeftToRightPaginated;
    573     else if (mode == "RightToLeftPaginated")
    574         pagination.mode = Pagination::RightToLeftPaginated;
    575     else if (mode == "TopToBottomPaginated")
    576         pagination.mode = Pagination::TopToBottomPaginated;
    577     else if (mode == "BottomToTopPaginated")
    578         pagination.mode = Pagination::BottomToTopPaginated;
    579     else {
    580         ec = SYNTAX_ERR;
    581         return;
    582     }
    583 
    584     pagination.gap = gap;
    585     pagination.pageLength = pageLength;
    586     page()->setPagination(pagination);
    587 }
    588 
    589 void InternalSettings::setEnableMockPagePopup(bool enabled, ExceptionCode& ec)
    590 {
    591 #if ENABLE(PAGE_POPUP)
    592     InternalSettingsGuardForPage();
    593     if (!page()->chrome())
    594         return;
    595     if (!enabled) {
    596         page()->chrome()->client()->resetPagePopupDriver();
    597         return;
    598     }
    599     if (!m_pagePopupDriver)
    600         m_pagePopupDriver = MockPagePopupDriver::create(page()->mainFrame());
    601     page()->chrome()->client()->setPagePopupDriver(m_pagePopupDriver.get());
    602 #else
    603     UNUSED_PARAM(enabled);
    604     UNUSED_PARAM(ec);
    605 #endif
    606 }
    607 
    608 String InternalSettings::configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
    609 {
    610     if (!page()) {
    611         ec = INVALID_ACCESS_ERR;
    612         return String();
    613     }
    614 
    615     const int defaultLayoutWidthForNonMobilePages = 980;
    616 
    617     ViewportArguments arguments = page()->viewportArguments();
    618     ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight));
    619     restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio);
    620     restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
    621 
    622     return "viewport size " + String::number(attributes.layoutSize.width()) + "x" + String::number(attributes.layoutSize.height()) + " scale " + String::number(attributes.initialScale) + " with limits [" + String::number(attributes.minimumScale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (attributes.userScalable ? "true" : "false");
    623 }
    624 
    625545void InternalSettings::setMemoryInfoEnabled(bool enabled, ExceptionCode& ec)
    626546{
  • trunk/Source/WebCore/testing/InternalSettings.h

    r135227 r135753  
    4040class Frame;
    4141class Document;
    42 class MockPagePopupDriver;
    4342class Page;
    44 class PagePopupController;
    4543class Settings;
    4644
     
    10199
    102100    virtual ~InternalSettings();
    103 #if ENABLE(PAGE_POPUP)
    104     PagePopupController* pagePopupController();
    105 #endif
    106101    void reset();
    107102
     
    149144    void setWindowFocusRestricted(bool, ExceptionCode&);
    150145    void setDialogElementEnabled(bool, ExceptionCode&);
    151     void setPagination(const String& mode, int gap, ExceptionCode& ec) { setPagination(mode, gap, 0, ec); }
    152     void setPagination(const String& mode, int gap, int pageLength, ExceptionCode&);
    153146    void setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode&);
    154147    bool shouldDisplayTrackKind(const String& kind, ExceptionCode&);
    155     void setEnableMockPagePopup(bool, ExceptionCode&);
    156     String configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode&);
    157148    void setMemoryInfoEnabled(bool, ExceptionCode&);
    158149    void setStorageBlockingPolicy(const String&, ExceptionCode&);
     
    169160    Page* m_page;
    170161    Backup m_backup;
    171 #if ENABLE(PAGE_POPUP)
    172     OwnPtr<MockPagePopupDriver> m_pagePopupDriver;
    173 #endif
    174162};
    175163
  • trunk/Source/WebCore/testing/InternalSettings.idl

    r135227 r135753  
    7171    void setLangAttributeAwareFormControlUIEnabled(in boolean enabled);
    7272
    73     void setPagination(in DOMString mode, in long gap, in [Optional] long pageLength) raises(DOMException);
    74     void setEnableMockPagePopup(in boolean enabled) raises(DOMException);
    7573    [Conditional=VIDEO_TRACK] void setShouldDisplayTrackKind(in DOMString kind, in boolean enabled) raises (DOMException);
    7674    [Conditional=VIDEO_TRACK] boolean shouldDisplayTrackKind(in DOMString trackKind) raises (DOMException);
  • trunk/Source/WebCore/testing/Internals.cpp

    r135251 r135753  
    2929#include "BackForwardController.h"
    3030#include "CachedResourceLoader.h"
     31#include "Chrome.h"
     32#include "ChromeClient.h"
    3133#include "ClientRect.h"
    3234#include "ClientRectList.h"
     
    6365#include "Language.h"
    6466#include "MallocStatistics.h"
     67#include "MockPagePopupDriver.h"
    6568#include "NodeRenderingContext.h"
    6669#include "Page.h"
     
    112115
    113116namespace WebCore {
     117
     118#if ENABLE(PAGE_POPUP)
     119static MockPagePopupDriver* s_pagePopupDriver = 0;
     120#endif
    114121
    115122using namespace HTMLNames;
     
    214221    ASSERT(page);
    215222
     223    page->setPagination(Pagination());
    216224    TextRun::setAllowsRoundingHacks(false);
    217225    WebCore::overrideUserPreferredLanguages(Vector<String>());
    218226    WebCore::Settings::setUsesOverlayScrollbars(false);
     227#if ENABLE(PAGE_POPUP)
     228    delete s_pagePopupDriver;
     229    s_pagePopupDriver = 0;
     230    if (page->chrome())
     231        page->chrome()->client()->resetPagePopupDriver();
     232#endif
    219233#if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
    220234    if (page->inspectorController())
     
    666680}
    667681
     682void Internals::setEnableMockPagePopup(bool enabled, ExceptionCode& ec)
     683{
     684#if ENABLE(PAGE_POPUP)
     685    Document* document = contextDocument();
     686    if (!document || !document->page() || !document->page()->chrome())
     687        return;
     688    Page* page = document->page();
     689    if (!enabled) {
     690        page->chrome()->client()->resetPagePopupDriver();
     691        return;
     692    }
     693    if (!s_pagePopupDriver)
     694        s_pagePopupDriver = MockPagePopupDriver::create(page->mainFrame()).leakPtr();
     695    page->chrome()->client()->setPagePopupDriver(s_pagePopupDriver);
     696#else
     697    UNUSED_PARAM(enabled);
     698    UNUSED_PARAM(ec);
     699#endif
     700}
     701
    668702#if ENABLE(PAGE_POPUP)
    669703PassRefPtr<PagePopupController> Internals::pagePopupController()
    670704{
    671     InternalSettings* settings = this->settings();
    672     if (!settings)
    673         return 0;
    674     return settings->pagePopupController();
     705    return s_pagePopupDriver ? s_pagePopupDriver->pagePopupController() : 0;
    675706}
    676707#endif
     
    829860}
    830861
    831 void Internals::setPagination(Document*, const String& mode, int gap, int pageLength, ExceptionCode& ec)
    832 {
    833     settings()->setPagination(mode, gap, pageLength, ec);
    834 }
    835 
    836 String Internals::configurationForViewport(Document*, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
    837 {
    838     return settings()->configurationForViewport(devicePixelRatio, deviceWidth, deviceHeight, availableWidth, availableHeight, ec);
     862void Internals::setPagination(Document* document, const String& mode, int gap, int pageLength, ExceptionCode& ec)
     863{
     864    if (!document || !document->page()) {
     865        ec = INVALID_ACCESS_ERR;
     866        return;
     867    }
     868    Page* page = document->page();
     869
     870    Pagination pagination;
     871    if (mode == "Unpaginated")
     872        pagination.mode = Pagination::Unpaginated;
     873    else if (mode == "LeftToRightPaginated")
     874        pagination.mode = Pagination::LeftToRightPaginated;
     875    else if (mode == "RightToLeftPaginated")
     876        pagination.mode = Pagination::RightToLeftPaginated;
     877    else if (mode == "TopToBottomPaginated")
     878        pagination.mode = Pagination::TopToBottomPaginated;
     879    else if (mode == "BottomToTopPaginated")
     880        pagination.mode = Pagination::BottomToTopPaginated;
     881    else {
     882        ec = SYNTAX_ERR;
     883        return;
     884    }
     885
     886    pagination.gap = gap;
     887    pagination.pageLength = pageLength;
     888    page->setPagination(pagination);
     889}
     890
     891String Internals::configurationForViewport(Document* document, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
     892{
     893    if (!document || !document->page()) {
     894        ec = INVALID_ACCESS_ERR;
     895        return String();
     896    }
     897    Page* page = document->page();
     898
     899    const int defaultLayoutWidthForNonMobilePages = 980;
     900
     901    ViewportArguments arguments = page->viewportArguments();
     902    ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight));
     903    restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio);
     904    restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
     905
     906    return "viewport size " + String::number(attributes.layoutSize.width()) + "x" + String::number(attributes.layoutSize.height()) + " scale " + String::number(attributes.initialScale) + " with limits [" + String::number(attributes.minimumScale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (attributes.userScalable ? "true" : "false");
    839907}
    840908
  • trunk/Source/WebCore/testing/Internals.h

    r135227 r135753  
    119119    PassRefPtr<DOMStringList> formControlStateOfPreviousHistoryItem(ExceptionCode&);
    120120    void setFormControlStateOfPreviousHistoryItem(PassRefPtr<DOMStringList>, ExceptionCode&);
     121    void setEnableMockPagePopup(bool, ExceptionCode&);
    121122#if ENABLE(PAGE_POPUP)
    122123    PassRefPtr<PagePopupController> pagePopupController();
  • trunk/Source/WebCore/testing/Internals.idl

    r135227 r135753  
    7979    DOMString[] formControlStateOfPreviousHistoryItem() raises(DOMException);
    8080    void setFormControlStateOfPreviousHistoryItem(in DOMString[] values) raises(DOMException);
     81    void setEnableMockPagePopup(in boolean enabled) raises(DOMException);
    8182#if defined(ENABLE_PAGE_POPUP) && ENABLE_PAGE_POPUP
    8283    readonly attribute PagePopupController pagePopupController;
Note: See TracChangeset for help on using the changeset viewer.