Changeset 122326 in webkit


Ignore:
Timestamp:
Jul 11, 2012 4:26:50 AM (12 years ago)
Author:
morrita@google.com
Message:

WebCoreSupport needs objects each of which follows major WebCore objects
https://bugs.webkit.org/show_bug.cgi?id=88499

Reviewed by Alexey Proskuryakov.

Source/WebCore:

This change

  • Makes Internals rough lifetime to follow Document. Note that Internals can survive longer than Document in same case. Internals::m_document is cleared when the document destruction is notified.
  • Makes InternalSettings rough lifetime to follow the Page. This is done by making InternalSettings a supplement of the page. Now InternalSettings object is created per Page instead of per Frame.

Per-test setting clearance is done by newly introduced InternalSettings::Backup,
which recovers the modified settings and refreshes it for each time a test starts.

  • WebCore.exp.in:
  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::Backup::Backup):
(WebCore):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::from):
(WebCore::InternalSettings::~InternalSettings):
(WebCore::InternalSettings::InternalSettings):
(WebCore::InternalSettings::reset):
(WebCore::InternalSettings::settings):
(WebCore::InternalSettings::setFixedElementsLayoutRelativeToFrame):
(WebCore::InternalSettings::setFixedPositionCreatesStackingContext):
(WebCore::InternalSettings::allowRoundingHacks):
(WebCore::InternalSettings::userPreferredLanguages):
(WebCore::InternalSettings::setUserPreferredLanguages):
(WebCore::InternalSettings::setShouldDisplayTrackKind):
(WebCore::InternalSettings::shouldDisplayTrackKind):
(WebCore::InternalSettings::setPagination):

  • testing/InternalSettings.h:

(Backup):
(InternalSettings):
(WebCore::InternalSettings::page):

  • testing/InternalSettings.idl:
  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore):
(WebCore::Internals::contextDocument):
(WebCore::Internals::frame):
(WebCore::Internals::settings):
(WebCore::Internals::setPagination): Replaced as an alias.
(WebCore::Internals::userPreferredLanguages): Replaced as an alias.
(WebCore::Internals::setUserPreferredLanguages): Replaced as an alias.
(WebCore::Internals::setShouldDisplayTrackKind): Replaced as an alias.
(WebCore::Internals::shouldDisplayTrackKind): Replaced as an alias.
(WebCore::Internals::emitInspectorDidBeginFrame):
(WebCore::Internals::emitInspectorDidCancelFrame):
(WebCore::Internals::allowRoundingHacks): Replaced as an alias.

  • testing/Internals.h:

(WebCore):
(Internals):

  • testing/js/WebCoreTestSupport.cpp:

(WebCoreTestSupport::injectInternalsObject):
(WebCoreTestSupport::resetInternalsObject):

  • testing/v8/WebCoreTestSupport.cpp:

(WebCoreTestSupport::injectInternalsObject):
(WebCoreTestSupport::resetInternalsObject):

Source/WebKit2:

Added exporting symbols.

  • win/WebKit2.def:
  • win/WebKit2CFLite.def:
Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122320 r122326  
     12012-07-11  MORITA Hajime  <morrita@google.com>
     2
     3        WebCoreSupport needs objects each of which follows major WebCore objects
     4        https://bugs.webkit.org/show_bug.cgi?id=88499
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        This change
     9
     10        - Makes Internals rough lifetime to follow Document.
     11          Note that Internals can survive longer than Document in same case.
     12          Internals::m_document is cleared when the document destruction is notified.
     13        - Makes InternalSettings rough lifetime to follow the Page.
     14          This is done by making InternalSettings a supplement of the page.
     15          Now InternalSettings object is created per Page instead of per Frame.
     16
     17        Per-test setting clearance is done by newly introduced InternalSettings::Backup,
     18        which recovers the modified settings and refreshes it for each time a test starts.
     19
     20        * WebCore.exp.in:
     21        * testing/InternalSettings.cpp:
     22        (WebCore::InternalSettings::Backup::Backup):
     23        (WebCore):
     24        (WebCore::InternalSettings::Backup::restoreTo):
     25        (WebCore::InternalSettings::from):
     26        (WebCore::InternalSettings::~InternalSettings):
     27        (WebCore::InternalSettings::InternalSettings):
     28        (WebCore::InternalSettings::reset):
     29        (WebCore::InternalSettings::settings):
     30        (WebCore::InternalSettings::setFixedElementsLayoutRelativeToFrame):
     31        (WebCore::InternalSettings::setFixedPositionCreatesStackingContext):
     32        (WebCore::InternalSettings::allowRoundingHacks):
     33        (WebCore::InternalSettings::userPreferredLanguages):
     34        (WebCore::InternalSettings::setUserPreferredLanguages):
     35        (WebCore::InternalSettings::setShouldDisplayTrackKind):
     36        (WebCore::InternalSettings::shouldDisplayTrackKind):
     37        (WebCore::InternalSettings::setPagination):
     38        * testing/InternalSettings.h:
     39        (Backup):
     40        (InternalSettings):
     41        (WebCore::InternalSettings::page):
     42        * testing/InternalSettings.idl:
     43        * testing/Internals.cpp:
     44        (WebCore::Internals::Internals):
     45        (WebCore):
     46        (WebCore::Internals::contextDocument):
     47        (WebCore::Internals::frame):
     48        (WebCore::Internals::settings):
     49        (WebCore::Internals::setPagination): Replaced as an alias.
     50        (WebCore::Internals::userPreferredLanguages): Replaced as an alias.
     51        (WebCore::Internals::setUserPreferredLanguages): Replaced as an alias.
     52        (WebCore::Internals::setShouldDisplayTrackKind): Replaced as an alias.
     53        (WebCore::Internals::shouldDisplayTrackKind): Replaced as an alias.
     54        (WebCore::Internals::emitInspectorDidBeginFrame):
     55        (WebCore::Internals::emitInspectorDidCancelFrame):
     56        (WebCore::Internals::allowRoundingHacks): Replaced as an alias.
     57        * testing/Internals.h:
     58        (WebCore):
     59        (Internals):
     60        * testing/js/WebCoreTestSupport.cpp:
     61        (WebCoreTestSupport::injectInternalsObject):
     62        (WebCoreTestSupport::resetInternalsObject):
     63        * testing/v8/WebCoreTestSupport.cpp:
     64        (WebCoreTestSupport::injectInternalsObject):
     65        (WebCoreTestSupport::resetInternalsObject):
     66
    1672012-07-11  Yoshifumi Inoue  <yosin@chromium.org>
    268
  • trunk/Source/WebCore/WebCore.exp.in

    r122205 r122326  
    612612__ZN7WebCore26UserTypingGestureIndicator28focusedElementAtGestureStartEv
    613613__ZN7WebCore26stopObservingCookieChangesEv
     614__ZN7WebCore26ContextDestructionObserverD2Ev
     615__ZN7WebCore26ContextDestructionObserverC2EPNS_22ScriptExecutionContextE
     616__ZN7WebCore26ContextDestructionObserver16contextDestroyedEv
    614617__ZN7WebCore27AuthenticationChallengeBaseC2Ev
    615618__ZN7WebCore27CSSComputedStyleDeclarationC1EN3WTF10PassRefPtrINS_4NodeEEEbRKNS1_6StringE
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r121907 r122326  
    3838#include "RuntimeEnabledFeatures.h"
    3939#include "Settings.h"
     40#include "TextRun.h"
    4041
    4142#if ENABLE(INPUT_TYPE_COLOR)
     
    5556    }
    5657
    57 #define InternalSettingsGuardForFrame() \
    58     if (!frame()) { \
    59         ec = INVALID_ACCESS_ERR; \
    60         return; \
    61     }
    62 
    63 #define InternalSettingsGuardForFrameView() \
    64     if (!frame() || !frame()->view()) { \
    65         ec = INVALID_ACCESS_ERR; \
    66         return; \
    67     }
    68 
    6958#define InternalSettingsGuardForPageReturn(returnValue) \
    7059    if (!page()) { \
     
    8170namespace WebCore {
    8271
    83 
    84 PassRefPtr<InternalSettings> InternalSettings::create(Frame* frame)
    85 {
    86     return adoptRef(new InternalSettings(frame));
    87 }
    88 
    89 InternalSettings::~InternalSettings()
    90 {
    91 }
    92 
    93 InternalSettings::InternalSettings(Frame* frame)
    94     : FrameDestructionObserver(frame)
    95     , m_originalPasswordEchoDurationInSeconds(settings()->passwordEchoDurationInSeconds())
    96     , m_originalPasswordEchoEnabled(settings()->passwordEchoEnabled())
     72InternalSettings::Backup::Backup(Page* page, Settings* settings)
     73    : m_originalPasswordEchoDurationInSeconds(settings->passwordEchoDurationInSeconds())
     74    , m_originalPasswordEchoEnabled(settings->passwordEchoEnabled())
    9775    , m_originalCSSExclusionsEnabled(RuntimeEnabledFeatures::cssExclusionsEnabled())
    9876#if ENABLE(SHADOW_DOM)
    9977    , m_originalShadowDOMEnabled(RuntimeEnabledFeatures::shadowDOMEnabled())
    10078#endif
    101     , m_originalEditingBehavior(settings()->editingBehaviorType())
    102     , m_originalFixedPositionCreatesStackingContext(settings()->fixedPositionCreatesStackingContext())
    103     , m_originalSyncXHRInDocumentsEnabled(settings()->syncXHRInDocumentsEnabled())
     79    , m_originalEditingBehavior(settings->editingBehaviorType())
     80    , m_originalFixedPositionCreatesStackingContext(settings->fixedPositionCreatesStackingContext())
     81    , m_originalSyncXHRInDocumentsEnabled(settings->syncXHRInDocumentsEnabled())
    10482#if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
    105     , m_originalJavaScriptProfilingEnabled(page() && page()->inspectorController() && page()->inspectorController()->profilerEnabled())
    106 #endif
    107     , m_originalWindowFocusRestricted(settings()->windowFocusRestricted())
    108     , m_originalDeviceSupportsTouch(settings()->deviceSupportsTouch())
    109     , m_originalDeviceSupportsMouse(settings()->deviceSupportsMouse())
     83    , m_originalJavaScriptProfilingEnabled(page->inspectorController() && page->inspectorController()->profilerEnabled())
     84#endif
     85    , m_originalWindowFocusRestricted(settings->windowFocusRestricted())
     86    , m_originalDeviceSupportsTouch(settings->deviceSupportsTouch())
     87    , m_originalDeviceSupportsMouse(settings->deviceSupportsMouse())
    11088#if ENABLE(TEXT_AUTOSIZING)
    111     , m_originalTextAutosizingEnabled(settings()->textAutosizingEnabled())
    112     , m_originalTextAutosizingWindowSizeOverride(settings()->textAutosizingWindowSizeOverride())
    113 #endif
    114 {
    115 }
    116 
    117 void InternalSettings::restoreTo(Settings* settings)
     89    , m_originalTextAutosizingEnabled(settings->textAutosizingEnabled())
     90    , m_originalTextAutosizingWindowSizeOverride(settings->textAutosizingWindowSizeOverride())
     91#endif
     92{
     93}
     94
     95
     96void InternalSettings::Backup::restoreTo(Page* page, Settings* settings)
    11897{
    11998    settings->setPasswordEchoDurationInSeconds(m_originalPasswordEchoDurationInSeconds);
     
    127106    settings->setSyncXHRInDocumentsEnabled(m_originalSyncXHRInDocumentsEnabled);
    128107#if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
    129     if (page() && page()->inspectorController())
    130         page()->inspectorController()->setProfilerEnabled(m_originalJavaScriptProfilingEnabled);
     108    if (page->inspectorController())
     109        page->inspectorController()->setProfilerEnabled(m_originalJavaScriptProfilingEnabled);
    131110#endif
    132111    settings->setWindowFocusRestricted(m_originalWindowFocusRestricted);
     
    139118}
    140119
     120InternalSettings* InternalSettings::from(Page* page)
     121{
     122    DEFINE_STATIC_LOCAL(AtomicString, name, ("InternalSettings"));
     123    if (!SuperType::from(page, name))
     124        SuperType::provideTo(page, name, adoptRef(new InternalSettings(page)));
     125    return static_cast<InternalSettings*>(SuperType::from(page, name));
     126}
     127
     128InternalSettings::~InternalSettings()
     129{
     130}
     131
     132InternalSettings::InternalSettings(Page* page)
     133    : m_page(page)
     134    , m_backup(page, page->settings())
     135{
     136}
     137
     138void InternalSettings::reset()
     139{
     140    TextRun::setAllowsRoundingHacks(false);
     141    setUserPreferredLanguages(Vector<String>());
     142    page()->setPagination(Page::Pagination());
     143    page()->setPageScaleFactor(1, IntPoint(0, 0));
     144
     145    m_backup.restoreTo(page(), settings());
     146    m_backup = Backup(page(), settings());
     147}
     148
    141149Settings* InternalSettings::settings() const
    142150{
    143     if (!frame() || !frame()->page())
     151    if (!page())
    144152        return 0;
    145     return frame()->page()->settings();
    146 }
    147 
    148 Document* InternalSettings::document() const
    149 {
    150     return frame() ? frame()->document() : 0;
    151 }
    152 
    153 Page* InternalSettings::page() const
    154 {
    155     return document() ? document()->page() : 0;
     153    return page()->settings();
    156154}
    157155
     
    221219void InternalSettings::setFixedElementsLayoutRelativeToFrame(bool enabled, ExceptionCode& ec)
    222220{
    223     InternalSettingsGuardForFrameView();
     221    InternalSettingsGuardForSettings();
    224222    settings()->setFixedElementsLayoutRelativeToFrame(enabled);
    225223}
     
    413411void InternalSettings::setFixedPositionCreatesStackingContext(bool creates, ExceptionCode& ec)
    414412{
    415     InternalSettingsGuardForFrameView();
     413    InternalSettingsGuardForSettings();
    416414    settings()->setFixedPositionCreatesStackingContext(creates);
    417415}
     
    445443}
    446444
    447 }
     445void InternalSettings::allowRoundingHacks() const
     446{
     447    TextRun::setAllowsRoundingHacks(true);
     448}
     449
     450Vector<String> InternalSettings::userPreferredLanguages() const
     451{
     452    return WebCore::userPreferredLanguages();
     453}
     454
     455void InternalSettings::setUserPreferredLanguages(const Vector<String>& languages)
     456{
     457    WebCore::overrideUserPreferredLanguages(languages);
     458}
     459
     460void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
     461{
     462    InternalSettingsGuardForSettings();
     463
     464#if ENABLE(VIDEO_TRACK)
     465    if (equalIgnoringCase(kind, "Subtitles"))
     466        settings()->setShouldDisplaySubtitles(enabled);
     467    else if (equalIgnoringCase(kind, "Captions"))
     468        settings()->setShouldDisplayCaptions(enabled);
     469    else if (equalIgnoringCase(kind, "TextDescriptions"))
     470        settings()->setShouldDisplayTextDescriptions(enabled);
     471    else
     472        ec = SYNTAX_ERR;
     473#else
     474    UNUSED_PARAM(kind);
     475    UNUSED_PARAM(enabled);
     476#endif
     477}
     478
     479bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
     480{
     481    InternalSettingsGuardForSettingsReturn(false);
     482
     483#if ENABLE(VIDEO_TRACK)
     484    if (equalIgnoringCase(kind, "Subtitles"))
     485        return settings()->shouldDisplaySubtitles();
     486    if (equalIgnoringCase(kind, "Captions"))
     487        return settings()->shouldDisplayCaptions();
     488    if (equalIgnoringCase(kind, "TextDescriptions"))
     489        return settings()->shouldDisplayTextDescriptions();
     490
     491    ec = SYNTAX_ERR;
     492    return false;
     493#else
     494    UNUSED_PARAM(kind);
     495    return false;
     496#endif
     497}
     498
     499void InternalSettings::setPagination(const String& mode, int gap, ExceptionCode& ec)
     500{
     501    if (!page()) {
     502        ec = INVALID_ACCESS_ERR;
     503        return;
     504    }
     505
     506    Page::Pagination pagination;
     507    if (mode == "Unpaginated")
     508        pagination.mode = Page::Pagination::Unpaginated;
     509    else if (mode == "LeftToRightPaginated")
     510        pagination.mode = Page::Pagination::LeftToRightPaginated;
     511    else if (mode == "RightToLeftPaginated")
     512        pagination.mode = Page::Pagination::RightToLeftPaginated;
     513    else if (mode == "TopToBottomPaginated")
     514        pagination.mode = Page::Pagination::TopToBottomPaginated;
     515    else if (mode == "BottomToTopPaginated")
     516        pagination.mode = Page::Pagination::BottomToTopPaginated;
     517    else {
     518        ec = SYNTAX_ERR;
     519        return;
     520    }
     521
     522    pagination.gap = gap;
     523    page()->setPagination(pagination);
     524}
     525
     526String InternalSettings::configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
     527{
     528    if (!page()) {
     529        ec = INVALID_ACCESS_ERR;
     530        return String();
     531    }
     532
     533    const int defaultLayoutWidthForNonMobilePages = 980;
     534
     535    ViewportArguments arguments = page()->viewportArguments();
     536    ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight));
     537    restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight));
     538    restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
     539
     540    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");
     541}
     542
     543
     544}
  • trunk/Source/WebCore/testing/InternalSettings.h

    r121907 r122326  
    2828
    2929#include "EditingBehaviorTypes.h"
    30 #include "FrameDestructionObserver.h"
     30#include "RefCountedSupplement.h"
    3131#include <wtf/PassRefPtr.h>
    3232#include <wtf/RefCounted.h>
     
    4646class Settings;
    4747
    48 class InternalSettings : public RefCounted<InternalSettings>,
    49                          public FrameDestructionObserver {
     48class InternalSettings : public RefCountedSupplement<Page, InternalSettings> {
    5049public:
    51     static PassRefPtr<InternalSettings> create(Frame*);
     50    class Backup {
     51    public:
     52        Backup(Page*, Settings*);
     53        void restoreTo(Page*, Settings*);
     54
     55        double m_originalPasswordEchoDurationInSeconds;
     56        bool m_originalPasswordEchoEnabled;
     57        bool m_originalCSSExclusionsEnabled;
     58#if ENABLE(SHADOW_DOM)
     59        bool m_originalShadowDOMEnabled;
     60#endif
     61        EditingBehaviorType m_originalEditingBehavior;
     62        bool m_originalFixedPositionCreatesStackingContext;
     63        bool m_originalSyncXHRInDocumentsEnabled;
     64#if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
     65        bool m_originalJavaScriptProfilingEnabled;
     66#endif
     67        bool m_originalWindowFocusRestricted;
     68        bool m_originalDeviceSupportsTouch;
     69        bool m_originalDeviceSupportsMouse;
     70#if ENABLE(TEXT_AUTOSIZING)
     71        bool m_originalTextAutosizingEnabled;
     72        IntSize m_originalTextAutosizingWindowSizeOverride;
     73#endif
     74    };
     75
     76    typedef RefCountedSupplement<Page, InternalSettings> SuperType;
     77    static InternalSettings* from(Page*);
    5278
    5379    virtual ~InternalSettings();
     80
     81    void reset();
    5482
    5583    void setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode&);
     
    89117    void setSyncXHRInDocumentsEnabled(bool, ExceptionCode&);
    90118    void setWindowFocusRestricted(bool, ExceptionCode&);
    91 
    92     void restoreTo(Settings*);
    93 
    94119    void setJavaScriptProfilingEnabled(bool enabled, ExceptionCode&);
    95 
     120    Vector<String> userPreferredLanguages() const;
     121    void setUserPreferredLanguages(const Vector<String>&);
     122    void setPagination(const String& mode, int gap, ExceptionCode&);
     123    void allowRoundingHacks() const;
     124    void setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode&);
     125    bool shouldDisplayTrackKind(const String& kind, ExceptionCode&);
     126    String configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode&);
    96127private:
    97     InternalSettings(Frame*);
     128    explicit InternalSettings(Page*);
     129    virtual void hostDestroyed() OVERRIDE { m_page = 0; }
    98130
    99131    Settings* settings() const;
    100     Document* document() const;
    101     Page* page() const;
     132    Page* page() const { return m_page; }
    102133
    103     double m_originalPasswordEchoDurationInSeconds;
    104     bool m_originalPasswordEchoEnabled;
    105     bool m_originalCSSExclusionsEnabled;
    106 #if ENABLE(SHADOW_DOM)
    107     bool m_originalShadowDOMEnabled;
    108 #endif
    109     EditingBehaviorType m_originalEditingBehavior;
    110     bool m_originalFixedPositionCreatesStackingContext;
    111     bool m_originalSyncXHRInDocumentsEnabled;
    112 #if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
    113     bool m_originalJavaScriptProfilingEnabled;
    114 #endif
    115     bool m_originalWindowFocusRestricted;
    116     bool m_originalDeviceSupportsTouch;
    117     bool m_originalDeviceSupportsMouse;
    118 #if ENABLE(TEXT_AUTOSIZING)
    119     bool m_originalTextAutosizingEnabled;
    120     IntSize m_originalTextAutosizingWindowSizeOverride;
    121 #endif
     134    Page* m_page;
     135    Backup m_backup;
    122136};
    123137
  • trunk/Source/WebCore/testing/InternalSettings.idl

    r121907 r122326  
    6565        void setJavaScriptProfilingEnabled(in boolean creates) raises(DOMException);
    6666        void setWindowFocusRestricted(in boolean restricted) raises(DOMException);
     67
     68        void setPagination(in DOMString mode, in long gap) raises(DOMException);
     69        sequence<String> userPreferredLanguages();
     70        void setUserPreferredLanguages(in sequence<String> languages);
     71        void allowRoundingHacks();
     72#if defined(ENABLE_VIDEO_TRACK) && ENABLE_VIDEO_TRACK
     73        void setShouldDisplayTrackKind(in DOMString kind, in boolean enabled) raises (DOMException);
     74        boolean shouldDisplayTrackKind(in DOMString trackKind) raises (DOMException);
     75#endif
    6776    };
    6877}
  • trunk/Source/WebCore/testing/Internals.cpp

    r122205 r122326  
    6464#include "SpellChecker.h"
    6565#include "TextIterator.h"
    66 #include "TextRun.h"
    6766#include "TreeScope.h"
    6867#include "ViewportArguments.h"
     
    148147
    149148Internals::Internals(Document* document)
    150     : FrameDestructionObserver(0)
    151 {
    152     reset(document);
     149    : ContextDestructionObserver(document)
     150{
     151}
     152
     153Document* Internals::contextDocument() const
     154{
     155    return static_cast<Document*>(scriptExecutionContext());
     156}
     157
     158Frame* Internals::frame() const
     159{
     160    if (!contextDocument())
     161        return 0;
     162    return contextDocument()->frame();
     163}
     164
     165InternalSettings* Internals::settings() const
     166{
     167    Document* document = contextDocument();
     168    if (!document)
     169        return 0;
     170    Page* page = document->page();
     171    if (!page)
     172        return 0;
     173    return InternalSettings::from(page);
    153174}
    154175
     
    608629}
    609630
    610 void Internals::setPagination(Document* document, const String& mode, int gap, ExceptionCode& ec)
    611 {
    612     if (!document || !document->page()) {
    613         ec = INVALID_ACCESS_ERR;
    614         return;
    615     }
    616 
    617     Page::Pagination pagination;
    618     if (mode == "Unpaginated")
    619         pagination.mode = Page::Pagination::Unpaginated;
    620     else if (mode == "LeftToRightPaginated")
    621         pagination.mode = Page::Pagination::LeftToRightPaginated;
    622     else if (mode == "RightToLeftPaginated")
    623         pagination.mode = Page::Pagination::RightToLeftPaginated;
    624     else if (mode == "TopToBottomPaginated")
    625         pagination.mode = Page::Pagination::TopToBottomPaginated;
    626     else if (mode == "BottomToTopPaginated")
    627         pagination.mode = Page::Pagination::BottomToTopPaginated;
    628     else {
    629         ec = SYNTAX_ERR;
    630         return;
    631     }
    632 
    633     pagination.gap = gap;
    634 
    635     document->page()->setPagination(pagination);
    636 }
    637 
    638 String Internals::configurationForViewport(Document* document, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
    639 {
    640     if (!document || !document->page()) {
    641         ec = INVALID_ACCESS_ERR;
    642         return String();
    643     }
    644 
    645     const int defaultLayoutWidthForNonMobilePages = 980;
    646 
    647     ViewportArguments arguments = document->page()->viewportArguments();
    648     ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight));
    649     restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight));
    650     restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
    651 
    652     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");
    653 }
    654 
    655 void Internals::reset(Document* document)
    656 {
    657     if (!document || !document->settings())
    658         return;
    659 
    660     observeFrame(document->frame());
    661 
    662     if (m_settings)
    663         m_settings->restoreTo(document->page()->settings());
    664     m_settings = InternalSettings::create(document->frame());
    665     if (Page* page = document->page()) {
    666         page->setPagination(Page::Pagination());
    667 
    668         if (document->frame() == page->mainFrame())
    669             setUserPreferredLanguages(Vector<String>());
    670 
    671         page->setPageScaleFactor(1, IntPoint(0, 0));
    672     }
    673 
    674     resetDefaultsToConsistentValues();
    675 }
    676 
    677 void Internals::resetDefaultsToConsistentValues()
    678 {
    679     TextRun::setAllowsRoundingHacks(false);
     631void Internals::setPagination(Document*, const String& mode, int gap, ExceptionCode& ec)
     632{
     633    settings()->setPagination(mode, gap, ec);
     634}
     635
     636String Internals::configurationForViewport(Document*, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
     637{
     638    return settings()->configurationForViewport(devicePixelRatio, deviceWidth, deviceHeight, availableWidth, availableHeight, ec);
    680639}
    681640
     
    908867Vector<String> Internals::userPreferredLanguages() const
    909868{
    910     return WebCore::userPreferredLanguages();
     869    return settings()->userPreferredLanguages();
    911870}
    912871
    913872void Internals::setUserPreferredLanguages(const Vector<String>& languages)
    914873{
    915     WebCore::overrideUserPreferredLanguages(languages);
    916 }
    917 
    918 void Internals::setShouldDisplayTrackKind(Document* document, const String& kind, bool enabled, ExceptionCode& ec)
    919 {
    920     if (!document || !document->frame() || !document->frame()->settings()) {
    921         ec = INVALID_ACCESS_ERR;
    922         return;
    923     }
    924    
    925 #if ENABLE(VIDEO_TRACK)
    926     Settings* settings = document->frame()->settings();
    927    
    928     if (equalIgnoringCase(kind, "Subtitles"))
    929         settings->setShouldDisplaySubtitles(enabled);
    930     else if (equalIgnoringCase(kind, "Captions"))
    931         settings->setShouldDisplayCaptions(enabled);
    932     else if (equalIgnoringCase(kind, "TextDescriptions"))
    933         settings->setShouldDisplayTextDescriptions(enabled);
    934     else
    935         ec = SYNTAX_ERR;
    936 #else
    937     UNUSED_PARAM(kind);
    938     UNUSED_PARAM(enabled);
    939 #endif
    940 }
    941 
    942 bool Internals::shouldDisplayTrackKind(Document* document, const String& kind, ExceptionCode& ec)
    943 {
    944     if (!document || !document->frame() || !document->frame()->settings()) {
    945         ec = INVALID_ACCESS_ERR;
    946         return false;
    947     }
    948    
    949 #if ENABLE(VIDEO_TRACK)
    950     Settings* settings = document->frame()->settings();
    951    
    952     if (equalIgnoringCase(kind, "Subtitles"))
    953         return settings->shouldDisplaySubtitles();
    954     if (equalIgnoringCase(kind, "Captions"))
    955         return settings->shouldDisplayCaptions();
    956     if (equalIgnoringCase(kind, "TextDescriptions"))
    957         return settings->shouldDisplayTextDescriptions();
    958 
    959     ec = SYNTAX_ERR;
    960     return false;
    961 #else
    962     UNUSED_PARAM(kind);
    963     return false;
    964 #endif
     874    settings()->setUserPreferredLanguages(languages);
     875}
     876
     877void Internals::setShouldDisplayTrackKind(Document*, const String& kind, bool enabled, ExceptionCode& ec)
     878{
     879    settings()->setShouldDisplayTrackKind(kind, enabled, ec);
     880}
     881
     882bool Internals::shouldDisplayTrackKind(Document*, const String& kind, ExceptionCode& ec)
     883{
     884    return settings()->shouldDisplayTrackKind(kind, ec);
    965885}
    966886
     
    998918void Internals::emitInspectorDidBeginFrame()
    999919{
    1000     InspectorInstrumentation::didBeginFrame(frame()->page());
     920    InspectorInstrumentation::didBeginFrame(contextDocument()->frame()->page());
    1001921}
    1002922
    1003923void Internals::emitInspectorDidCancelFrame()
    1004924{
    1005     InspectorInstrumentation::didCancelFrame(frame()->page());
     925    InspectorInstrumentation::didCancelFrame(contextDocument()->frame()->page());
    1006926}
    1007927
     
    11461066void Internals::allowRoundingHacks() const
    11471067{
    1148     TextRun::setAllowsRoundingHacks(true);
     1068    settings()->allowRoundingHacks();
    11491069}
    11501070
  • trunk/Source/WebCore/testing/Internals.h

    r122205 r122326  
    2727#define Internals_h
    2828
    29 #include "FrameDestructionObserver.h"
     29#include "ContextDestructionObserver.h"
    3030#include "NodeList.h"
    3131#include "PlatformString.h"
     
    4242class DocumentMarker;
    4343class Element;
     44class Frame;
    4445class InternalSettings;
    4546class Node;
    4647class Range;
     48class ScriptExecutionContext;
    4749class ShadowRoot;
    4850class WebKitPoint;
     
    5052typedef int ExceptionCode;
    5153
    52 class Internals : public RefCounted<Internals>,
    53                   public FrameDestructionObserver {
     54class Internals : public RefCounted<Internals>
     55                , public ContextDestructionObserver {
    5456public:
    5557    static PassRefPtr<Internals> create(Document*);
    5658    virtual ~Internals();
    57 
    58     void reset(Document*);
    5959
    6060    String elementRenderTreeAsText(Element*, ExceptionCode&);
     
    116116
    117117    void setScrollViewPosition(Document*, long x, long y, ExceptionCode&);
    118 
    119118    void setPagination(Document*, const String& mode, int gap, ExceptionCode&);
    120119    String configurationForViewport(Document*, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode&);
     
    168167    static const char* internalsId;
    169168
    170     InternalSettings* settings() const { return m_settings.get(); }
     169    InternalSettings* settings() const;
    171170
    172171    void setBatteryStatus(Document*, const String& eventType, bool charging, double chargingTime, double dischargingTime, double level, ExceptionCode&);
     
    199198private:
    200199    explicit Internals(Document*);
     200    Document* contextDocument() const;
     201    Frame* frame() const;
     202
    201203    DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
    202     void resetDefaultsToConsistentValues();
    203 
    204     RefPtr<InternalSettings> m_settings;
    205204};
    206205
  • trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp

    r121912 r122326  
    2727#include "WebCoreTestSupport.h"
    2828
     29#include "Frame.h"
     30#include "InternalSettings.h"
    2931#include "Internals.h"
    3032#include "JSDocument.h"
     
    4446    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
    4547    ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
    46     Document* document = scriptContext->isDocument() ? static_cast<Document*>(scriptContext) : 0;
    47     globalObject->putDirect(exec->globalData(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(document)));
     48    if (scriptContext->isDocument())
     49        globalObject->putDirect(exec->globalData(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(static_cast<Document*>(scriptContext))));
    4850}
    4951
     
    5355    JSLockHolder lock(exec);
    5456    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
    55     JSValue internalsJS = globalObject->getDirect(exec->globalData(), Identifier(exec, Internals::internalsId));
    56     if (internalsJS.isNull() || internalsJS.isEmpty())
    57         return;
    58     if (Internals* internals = toInternals(internalsJS)) {
    59         ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
    60         if (scriptContext->isDocument())
    61             internals->reset(static_cast<Document*>(scriptContext));
    62     }
     57    ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
     58    ASSERT(scriptContext->isDocument());
     59    InternalSettings::from(static_cast<Document*>(scriptContext)->frame()->page())->reset();
    6360}
    6461
  • trunk/Source/WebCore/testing/v8/WebCoreTestSupport.cpp

    r105900 r122326  
    2828
    2929#include "Document.h"
     30#include "InternalSettings.h"
    3031#include "Internals.h"
    3132#include "ScriptExecutionContext.h"
     
    4445
    4546    ScriptExecutionContext* scriptContext = getScriptExecutionContext();
    46     Document* document = scriptContext->isDocument() ? static_cast<Document*>(scriptContext) : 0;
    47     context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create(document)));
     47    if (scriptContext->isDocument())
     48        context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create(static_cast<Document*>(scriptContext))));
    4849}
    4950
     
    5758    v8::HandleScope scope;
    5859
    59     v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(v8::String::New(Internals::internalsId)));
    60     Internals* internals = object->IsUndefined() ? 0 : V8Internals::toNative(object);
    61     if (internals) {
    62         ScriptExecutionContext* scriptContext = getScriptExecutionContext();
    63         if (scriptContext->isDocument())
    64             internals->reset(static_cast<Document*>(scriptContext));
    65     }
     60    ScriptExecutionContext* scriptContext = getScriptExecutionContext();
     61    ASSERT(scriptContext->isDocument());
     62    InternalSettings::from(static_cast<Document*>(scriptContext)->frame()->page())->reset();
    6663}
    6764
  • trunk/Source/WebKit2/ChangeLog

    r122325 r122326  
     12012-07-11  MORITA Hajime  <morrita@google.com>
     2
     3        WebCoreSupport needs objects each of which follows major WebCore objects
     4        https://bugs.webkit.org/show_bug.cgi?id=88499
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Added exporting symbols.
     9
     10        * win/WebKit2.def:
     11        * win/WebKit2CFLite.def:
     12
    1132012-07-11  Sheriff Bot  <webkit.review.bot@gmail.com>
    214
  • trunk/Source/WebKit2/win/WebKit2.def

    r122205 r122326  
    256256        ?view@Document@WebCore@@QBEPAVFrameView@2@XZ
    257257        ?willDetachPage@FrameDestructionObserver@WebCore@@UAEXXZ
     258        ??1ContextDestructionObserver@WebCore@@MAE@XZ
     259        ?contextDestroyed@ContextDestructionObserver@WebCore@@UAEXXZ
     260        ??0ContextDestructionObserver@WebCore@@QAE@PAVScriptExecutionContext@1@@Z
    258261        ?nodesFromRect@Document@WebCore@@QBE?AV?$PassRefPtr@VNodeList@WebCore@@@WTF@@HHIIII_N0@Z
    259262        ?selectionStartHasMarkerFor@Editor@WebCore@@QBE_NW4MarkerType@DocumentMarker@2@HH@Z
  • trunk/Source/WebKit2/win/WebKit2CFLite.def

    r122204 r122326  
    149149        ??1FrameDestructionObserver@WebCore@@MAE@XZ
    150150        ??0FrameDestructionObserver@WebCore@@QAE@PAVFrame@1@@Z
     151        ??1ContextDestructionObserver@WebCore@@MAE@XZ
     152        ?contextDestroyed@ContextDestructionObserver@WebCore@@UAEXXZ
     153        ??0ContextDestructionObserver@WebCore@@QAE@PAVScriptExecutionContext@1@@Z
    151154        ?absoluteBoundingBoxRect@RenderObject@WebCore@@QBE?AVIntRect@2@_N@Z
    152155        ?absoluteBoundingBoxRectIgnoringTransforms@RenderObject@WebCore@@QBE?AVIntRect@2@XZ
     
    262265        ?profilerEnabled@InspectorController@WebCore@@QAE_NXZ
    263266        ?setProfilerEnabled@InspectorController@WebCore@@QAEX_N@Z
     267        ??1ContextDestructionObserver@WebCore@@MAE@XZ
    264268        ?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@U?$PtrHash@PAVStringImpl@WTF@@@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z
    265269        ?registerURLSchemeAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z
  • trunk/Source/autotools/symbols.filter

    r122205 r122326  
    168168_ZN7WebCore7TextRun22setAllowsRoundingHacksEb;
    169169_ZNK7WebCore14InsertionPoint8isActiveEv;
     170_ZN7WebCore26ContextDestructionObserverD2Ev;
     171_ZN7WebCore26ContextDestructionObserverC2EPNS_22ScriptExecutionContextE;
     172_ZN7WebCore26ContextDestructionObserver16contextDestroyedEv;
    170173local:
    171174_Z*;
Note: See TracChangeset for help on using the changeset viewer.