diff options
| author | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-29 12:18:48 +0100 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-29 12:18:57 +0100 |
| commit | 4c01d0526ba4dd8cff0c0ff22a6f0ab5eb973064 (patch) | |
| tree | bed2fe914fe0f7ec70abfb47d2d84af8a3604d09 /Source/WebCore/testing/Internals.cpp | |
| parent | 01485457c9a5da3f1121015afd25bb53af77662e (diff) | |
| download | qtwebkit-4c01d0526ba4dd8cff0c0ff22a6f0ab5eb973064.tar.gz | |
Imported WebKit commit c60cfe0fc09efd257aa0111d7b133b02deb8a63e (http://svn.webkit.org/repository/webkit/trunk@136119)
New snapshot that includes the fix for installing the QtWebProcess into libexec
Change-Id: I01344e079cbdac5678c4cba6ffcc05f4597cf0d7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebCore/testing/Internals.cpp')
| -rw-r--r-- | Source/WebCore/testing/Internals.cpp | 96 |
1 files changed, 88 insertions, 8 deletions
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp index ea794b772..94a3b052e 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -28,6 +28,8 @@ #include "BackForwardController.h" #include "CachedResourceLoader.h" +#include "Chrome.h" +#include "ChromeClient.h" #include "ClientRect.h" #include "ClientRectList.h" #include "ComposedShadowTreeWalker.h" @@ -62,6 +64,7 @@ #include "IntRect.h" #include "Language.h" #include "MallocStatistics.h" +#include "MockPagePopupDriver.h" #include "NodeRenderingContext.h" #include "Page.h" #include "PrintContext.h" @@ -112,6 +115,10 @@ namespace WebCore { +#if ENABLE(PAGE_POPUP) +static MockPagePopupDriver* s_pagePopupDriver = 0; +#endif + using namespace HTMLNames; #if ENABLE(INSPECTOR) @@ -213,9 +220,17 @@ void Internals::resetToConsistentState(Page* page) { ASSERT(page); + page->setPageScaleFactor(1, IntPoint(0, 0)); + page->setPagination(Pagination()); TextRun::setAllowsRoundingHacks(false); WebCore::overrideUserPreferredLanguages(Vector<String>()); WebCore::Settings::setUsesOverlayScrollbars(false); +#if ENABLE(PAGE_POPUP) + delete s_pagePopupDriver; + s_pagePopupDriver = 0; + if (page->chrome()) + page->chrome()->client()->resetPagePopupDriver(); +#endif #if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER) if (page->inspectorController()) page->inspectorController()->setProfilerEnabled(false); @@ -665,13 +680,30 @@ void Internals::setFormControlStateOfPreviousHistoryItem(PassRefPtr<DOMStringLis ec = INVALID_ACCESS_ERR; } +void Internals::setEnableMockPagePopup(bool enabled, ExceptionCode& ec) +{ +#if ENABLE(PAGE_POPUP) + Document* document = contextDocument(); + if (!document || !document->page() || !document->page()->chrome()) + return; + Page* page = document->page(); + if (!enabled) { + page->chrome()->client()->resetPagePopupDriver(); + return; + } + if (!s_pagePopupDriver) + s_pagePopupDriver = MockPagePopupDriver::create(page->mainFrame()).leakPtr(); + page->chrome()->client()->setPagePopupDriver(s_pagePopupDriver); +#else + UNUSED_PARAM(enabled); + UNUSED_PARAM(ec); +#endif +} + #if ENABLE(PAGE_POPUP) PassRefPtr<PagePopupController> Internals::pagePopupController() { - InternalSettings* settings = this->settings(); - if (!settings) - return 0; - return settings->pagePopupController(); + return s_pagePopupDriver ? s_pagePopupDriver->pagePopupController() : 0; } #endif @@ -828,14 +860,51 @@ void Internals::setScrollViewPosition(Document* document, long x, long y, Except frameView->setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdgeOldValue); } -void Internals::setPagination(Document*, const String& mode, int gap, int pageLength, ExceptionCode& ec) +void Internals::setPagination(Document* document, const String& mode, int gap, int pageLength, ExceptionCode& ec) { - settings()->setPagination(mode, gap, pageLength, ec); + if (!document || !document->page()) { + ec = INVALID_ACCESS_ERR; + return; + } + Page* page = document->page(); + + Pagination pagination; + if (mode == "Unpaginated") + pagination.mode = Pagination::Unpaginated; + else if (mode == "LeftToRightPaginated") + pagination.mode = Pagination::LeftToRightPaginated; + else if (mode == "RightToLeftPaginated") + pagination.mode = Pagination::RightToLeftPaginated; + else if (mode == "TopToBottomPaginated") + pagination.mode = Pagination::TopToBottomPaginated; + else if (mode == "BottomToTopPaginated") + pagination.mode = Pagination::BottomToTopPaginated; + else { + ec = SYNTAX_ERR; + return; + } + + pagination.gap = gap; + pagination.pageLength = pageLength; + page->setPagination(pagination); } -String Internals::configurationForViewport(Document*, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec) +String Internals::configurationForViewport(Document* document, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec) { - return settings()->configurationForViewport(devicePixelRatio, deviceWidth, deviceHeight, availableWidth, availableHeight, ec); + if (!document || !document->page()) { + ec = INVALID_ACCESS_ERR; + return String(); + } + Page* page = document->page(); + + const int defaultLayoutWidthForNonMobilePages = 980; + + ViewportArguments arguments = page->viewportArguments(); + ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight)); + restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio); + restrictScaleFactorToInitialScaleIfNotUserScalable(attributes); + + 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"); } bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec) @@ -1470,6 +1539,17 @@ String Internals::pageSizeAndMarginsInPixels(int pageNumber, int width, int heig return PrintContext::pageSizeAndMarginsInPixels(frame(), pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft); } +void Internals::setPageScaleFactor(float scaleFactor, int x, int y, ExceptionCode& ec) +{ + Document* document = contextDocument(); + if (!document || !document->page()) { + ec = INVALID_ACCESS_ERR; + return; + } + Page* page = document->page(); + page->setPageScaleFactor(scaleFactor, IntPoint(x, y)); +} + #if ENABLE(FULLSCREEN_API) void Internals::webkitWillEnterFullScreenForElement(Document* document, Element* element) { |
