diff options
Diffstat (limited to 'Source/WebKit')
318 files changed, 12083 insertions, 5232 deletions
diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt index 8bf565edc..62f4b3116 100644 --- a/Source/WebKit/CMakeLists.txt +++ b/Source/WebKit/CMakeLists.txt @@ -1,6 +1,7 @@ SET(WebKit_INCLUDE_DIRECTORIES "${WEBKIT_DIR}" "${WEBCORE_DIR}" + "${WEBCORE_DIR}/Modules/webdatabase" "${WEBCORE_DIR}/accessibility" "${WEBCORE_DIR}/bindings/js" "${WEBCORE_DIR}/bindings" @@ -74,6 +75,7 @@ INCLUDE_DIRECTORIES(${WebKit_INCLUDE_DIRECTORIES}) ADD_LIBRARY(${WebKit_LIBRARY_NAME} ${WebKit_LIBRARY_TYPE} ${WebKit_SOURCES}) ADD_DEPENDENCIES(${WebKit_LIBRARY_NAME} ${WebCore_LIBRARY_NAME}) TARGET_LINK_LIBRARIES(${WebKit_LIBRARY_NAME} ${WebKit_LIBRARIES}) +SET_TARGET_PROPERTIES(${WebKit_LIBRARY_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "") IF (WebKit_LINK_FLAGS) ADD_TARGET_PROPERTIES(${WebKit_LIBRARY_NAME} LINK_FLAGS "${WebKit_LINK_FLAGS}") @@ -84,4 +86,4 @@ IF (VERSION_SCRIPT) ENDIF () SET_TARGET_PROPERTIES(${WebKit_LIBRARY_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) -INSTALL(TARGETS ${WebKit_LIBRARY_NAME} DESTINATION lib) +INSTALL(TARGETS ${WebKit_LIBRARY_NAME} DESTINATION "${LIB_INSTALL_DIR}") diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index c95efcf3c..4f1cf58b9 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,65 @@ +2012-03-11 Timothy Hatcher <timothy@apple.com> + + Update how the Web Inspector resources are loaded. + + https://bugs.webkit.org/show_bug.cgi?id=80798 + rdar://problem/10359959 + + Reviewed by Brian Weinstein. + + * WebKit.xcodeproj/project.pbxproj: Add a framework. + +2012-03-06 Raphael Kubo da Costa <kubo@profusion.mobi> + + [CMake] Make the removal of transitive library dependencies work with CMake < 2.8.7. + https://bugs.webkit.org/show_bug.cgi?id=80469 + + Reviewed by Antonio Gomes. + + * CMakeLists.txt: Manually set the LINK_INTERFACE_LIBRARIES target + property on the library being created. + +2012-03-06 Raphael Kubo da Costa <kubo@profusion.mobi> + + [EFL] Unreviewed; fix the build after r109877. + + * CMakeLists.txt: Add WebCore/Modules/webdatabase to the list of + include directories so that #include'ing DatabaseDetails.h and + friends still works. + +2012-03-04 Jonathan Dong <jonathan.dong@torchmobile.com.cn> + + [BlackBerry] upstream CredentialManager and CredentialTransformData implementation + https://bugs.webkit.org/show_bug.cgi?id=80107 + + Reviewed by Antonio Gomes. + + Initial upstream of CredentialManager.[h|cpp] and + CredentialTransformData.[h|cpp]. + No new test. + + * PlatformBlackBerry.cmake: + +2012-03-04 Raphael Kubo da Costa <kubo@profusion.mobi> + + [CMake] Libraries are installed to /usr/lib and not /usr/lib64 on x86_64 + https://bugs.webkit.org/show_bug.cgi?id=71507 + + Reviewed by Antonio Gomes. + + * CMakeLists.txt: Use ${LIB_INSTALL_DIR} instead of hardcoding "lib". + +2012-02-24 Grzegorz Czajkowski <g.czajkowski@samsung.com> + + [EFL][DRT] Implement setValueForUser and setAutofilled. + https://bugs.webkit.org/show_bug.cgi?id=79237 + + Reviewed by Andreas Kling. + + Adds the main directory of WebKit's source to find headers of JavaScriptCore. + + * PlatformEfl.cmake: + 2012-02-23 Patrick Gansterer <paroga@webkit.org> [CMake] Add WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS macro diff --git a/Source/WebKit/PlatformBlackBerry.cmake b/Source/WebKit/PlatformBlackBerry.cmake index 5d5c8b352..b0d07546a 100644 --- a/Source/WebKit/PlatformBlackBerry.cmake +++ b/Source/WebKit/PlatformBlackBerry.cmake @@ -51,6 +51,8 @@ LIST(APPEND WebKit_SOURCES blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp blackberry/WebCoreSupport/ClientExtension.cpp blackberry/WebCoreSupport/ContextMenuClientBlackBerry.cpp + blackberry/WebCoreSupport/CredentialManager.cpp + blackberry/WebCoreSupport/CredentialTransformData.cpp blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.cpp blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.cpp blackberry/WebCoreSupport/DragClientBlackBerry.cpp diff --git a/Source/WebKit/PlatformEfl.cmake b/Source/WebKit/PlatformEfl.cmake index daf22876e..1debe3684 100644 --- a/Source/WebKit/PlatformEfl.cmake +++ b/Source/WebKit/PlatformEfl.cmake @@ -6,8 +6,10 @@ LIST(APPEND WebKit_LINK_FLAGS ) LIST(APPEND WebKit_INCLUDE_DIRECTORIES + "${CMAKE_SOURCE_DIR}/Source" "${WEBKIT_DIR}/efl/ewk" "${WEBKIT_DIR}/efl/WebCoreSupport" + "${JAVASCRIPTCORE_DIR}/ForwardingHeaders" "${JAVASCRIPTCORE_DIR}/wtf/gobject" "${WEBCORE_DIR}/platform/efl" "${WEBCORE_DIR}/platform/graphics/cairo" diff --git a/Source/WebKit/blackberry/Api/BackingStore.cpp b/Source/WebKit/blackberry/Api/BackingStore.cpp index 2971d2698..0df6137c6 100644 --- a/Source/WebKit/blackberry/Api/BackingStore.cpp +++ b/Source/WebKit/blackberry/Api/BackingStore.cpp @@ -201,6 +201,10 @@ BackingStorePrivate::BackingStorePrivate() , m_currentWindowBackBuffer(0) , m_preferredTileMatrixDimension(Vertical) , m_blitGeneration(-1) +#if USE(ACCELERATED_COMPOSITING) + , m_needsDrawLayersOnCommit(false) + , m_isDirectRenderingAnimationMessageScheduled(false) +#endif { m_frontState = reinterpret_cast<unsigned>(new BackingStoreGeometry); m_backState = reinterpret_cast<unsigned>(new BackingStoreGeometry); @@ -464,10 +468,12 @@ void BackingStorePrivate::renderOnTimer(WebCore::Timer<BackingStorePrivate>*) while (m_renderQueue->hasCurrentVisibleZoomJob() || m_renderQueue->hasCurrentVisibleScrollJob()) m_renderQueue->render(!m_suspendRegularRenderJobs); - if (!shouldPerformRegularRenderJobs() || !m_renderQueue->hasCurrentRegularRenderJob()) - return; + if (shouldPerformRegularRenderJobs() && m_renderQueue->hasCurrentRegularRenderJob()) + m_renderQueue->renderAllCurrentRegularRenderJobs(); - m_renderQueue->renderAllCurrentRegularRenderJobs(); +#if USE(ACCELERATED_COMPOSITING) + drawLayersOnCommitIfNeeded(); +#endif } void BackingStorePrivate::renderOnIdle() @@ -483,6 +489,10 @@ void BackingStorePrivate::renderOnIdle() #endif m_renderQueue->render(!m_suspendRegularRenderJobs); + +#if USE(ACCELERATED_COMPOSITING) + drawLayersOnCommitIfNeeded(); +#endif } bool BackingStorePrivate::willFireTimer() @@ -512,6 +522,10 @@ bool BackingStorePrivate::willFireTimer() if (m_renderQueue->hasCurrentRegularRenderJob()) m_renderQueue->renderAllCurrentRegularRenderJobs(); +#if USE(ACCELERATED_COMPOSITING) + drawLayersOnCommitIfNeeded(); +#endif + // Let the caller yield and reschedule the timer. return false; } @@ -932,7 +946,6 @@ bool BackingStorePrivate::renderDirectToWindow(const Platform::IntRect& rect) Platform::IntRect screenRect = m_client->mapFromTransformedContentsToTransformedViewport(dirtyRect); windowFrontBufferState()->clearBlittedRegion(screenRect); - copyPreviousContentsToBackSurfaceOfWindow(); paintDefaultBackground(dirtyRect, TransformationMatrix(), true /*flush*/); @@ -941,10 +954,14 @@ bool BackingStorePrivate::renderDirectToWindow(const Platform::IntRect& rect) renderContents(0, origin, dirtyRect); windowBackBufferState()->addBlittedRegion(screenRect); -#if USE(ACCELERATED_COMPOSITING) && ENABLE_COMPOSITING_SURFACE - if (m_webPage->d->m_client->window()->windowUsage() != BlackBerry::Platform::Graphics::Window::GLES2Usage) { - Platform::IntRect clippedRect = intersection(dirtyRect, visibleContentsRect()); - blendCompositingSurface(clippedRect); +#if USE(ACCELERATED_COMPOSITING) + m_isDirectRenderingAnimationMessageScheduled = false; + + if (m_webPage->d->isAcceleratedCompositingActive()) { + BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage( + BlackBerry::Platform::createMethodCallMessage( + &BackingStorePrivate::drawAndBlendLayersForDirectRendering, + this, dirtyRect)); } #endif @@ -979,8 +996,6 @@ bool BackingStorePrivate::render(const Platform::IntRect& rect) TileMap currentMap = currentState->tileMap(); Platform::IntRect dirtyContentsRect; - const Platform::IntRect contentsRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedContentsSize()); - const Platform::IntRect viewportRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedViewportSize()); for (size_t i = 0; i < tileRectList.size(); ++i) { TileRect tileRect = tileRectList[i]; @@ -1106,6 +1121,11 @@ void BackingStorePrivate::blitVisibleContents(bool force) } if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) { +#if USE(ACCELERATED_COMPOSITING) + // The blit will call drawSubLayers if necessary + m_needsDrawLayersOnCommit = false; +#endif + BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage( BlackBerry::Platform::createMethodCallMessage( &BackingStorePrivate::blitVisibleContents, this, force)); @@ -1196,6 +1216,11 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect, } if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) { +#if USE(ACCELERATED_COMPOSITING) + // The blit will call drawSubLayers if necessary + m_needsDrawLayersOnCommit = false; +#endif + BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage( BlackBerry::Platform::createMethodCallMessage( &BackingStorePrivate::blitContents, this, dstRect, srcRect, force)); @@ -2069,13 +2094,13 @@ Platform::IntSize BackingStorePrivate::expandedContentsSize() const int BackingStorePrivate::tileWidth() { - static int tileWidth = BlackBerry::Platform::Graphics::Screen::landscapeWidth(); + static int tileWidth = BlackBerry::Platform::Graphics::Screen::primaryScreen()->landscapeWidth(); return tileWidth; } int BackingStorePrivate::tileHeight() { - static int tileHeight = BlackBerry::Platform::Graphics::Screen::landscapeHeight(); + static int tileHeight = BlackBerry::Platform::Graphics::Screen::primaryScreen()->landscapeHeight(); return tileHeight; } @@ -2131,7 +2156,15 @@ void BackingStorePrivate::renderContents(BlackBerry::Platform::Graphics::Buffer* return; #if USE(ACCELERATED_COMPOSITING) - m_webPage->d->commitRootLayerIfNeeded(); + // When committing the pending accelerated compositing layer changes, it's + // necessary to draw the new layer appearance. This is normally done as + // part of a blit, but if no blit happens because of this rendering, for + // example because we're rendering an offscreen rectangle, someone needs to + // catch this flag and make sure those layers get drawn. + // This is just a complicated way to do + // "if (commitRootLayerIfNeeded()) drawLayersOnCommit();" + if (m_webPage->d->commitRootLayerIfNeeded()) + m_needsDrawLayersOnCommit = true; #endif BlackBerry::Platform::Graphics::Drawable* bufferDrawable = @@ -2471,7 +2504,9 @@ bool BackingStorePrivate::drawSubLayers() if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) return false; - if (m_suspendBackingStoreUpdates) + bool blittingDirectlyToCompositingWindow = m_webPage->d->m_client->window()->windowUsage() == BlackBerry::Platform::Graphics::Window::GLES2Usage; + + if (m_suspendBackingStoreUpdates && !blittingDirectlyToCompositingWindow) return false; Platform::IntRect dst = m_webPage->client()->userInterfaceBlittedDestinationRect(); @@ -2483,6 +2518,46 @@ bool BackingStorePrivate::drawSubLayers() WebCore::FloatRect(WebCore::IntRect(src))); return m_webPage->d->drawSubLayers(dst, contentsRect); } + +bool BackingStorePrivate::drawLayersOnCommitIfNeeded() +{ + // Check if rendering caused a commit and we need to redraw the layers + if (!m_needsDrawLayersOnCommit) + return false; + + m_needsDrawLayersOnCommit = false; + m_webPage->d->drawLayersOnCommit(); + + return true; +} + +void BackingStorePrivate::drawAndBlendLayersForDirectRendering(const Platform::IntRect& dirtyRect) +{ + ASSERT(BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()); + if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) + return; + + // Because we're being called sync from the WebKit thread, we can use + // regular WebPage size and transformation functions without concerns. + WebCore::IntRect contentsRect = visibleContentsRect(); + WebCore::FloatRect untransformedContentsRect = m_webPage->d->mapFromTransformedFloatRect(WebCore::FloatRect(contentsRect)); + WebCore::IntRect contentsScreenRect = m_client->mapFromTransformedContentsToTransformedViewport(contentsRect); + WebCore::IntRect dstRect = intersection(contentsScreenRect, + WebCore::IntRect(WebCore::IntPoint(0, 0), m_webPage->d->transformedViewportSize())); + + // Check if rendering caused a commit and we need to redraw the layers. + m_needsDrawLayersOnCommit = false; + m_webPage->d->drawSubLayers(dstRect, untransformedContentsRect); + +#if ENABLE_COMPOSITING_SURFACE + // See above comment about sync calling, visibleContentsRect() is safe here. + Platform::IntRect visibleDirtyRect = dirtyRect; + visibleDirtyRect.intersect(visibleContentsRect()); + visibleDirtyRect = m_client->mapFromTransformedContentsToTransformedViewport(visibleDirtyRect); + + blendCompositingSurface(visibleDirtyRect); +#endif +} #endif bool BackingStorePrivate::isActive() const diff --git a/Source/WebKit/blackberry/Api/BackingStore.h b/Source/WebKit/blackberry/Api/BackingStore.h index 8673268ae..73194859f 100644 --- a/Source/WebKit/blackberry/Api/BackingStore.h +++ b/Source/WebKit/blackberry/Api/BackingStore.h @@ -40,6 +40,7 @@ namespace WebKit { class WebPage; class WebPagePrivate; +class WebPageCompositor; class BackingStorePrivate; class BackingStoreClient; @@ -77,6 +78,7 @@ private: friend class BlackBerry::WebKit::BackingStoreClient; friend class BlackBerry::WebKit::WebPage; friend class BlackBerry::WebKit::WebPagePrivate; // FIXME: For now, we expose our internals to WebPagePrivate. See PR #120301. + friend class BlackBerry::WebKit::WebPageCompositor; friend class WebCore::ChromeClientBlackBerry; friend class WebCore::FrameLoaderClientBlackBerry; friend class WebCore::GLES2Context; diff --git a/Source/WebKit/blackberry/Api/BackingStore_p.h b/Source/WebKit/blackberry/Api/BackingStore_p.h index 49c70a6a5..795b7711b 100644 --- a/Source/WebKit/blackberry/Api/BackingStore_p.h +++ b/Source/WebKit/blackberry/Api/BackingStore_p.h @@ -196,6 +196,13 @@ public: void blendCompositingSurface(const Platform::IntRect& dstRect); void clearCompositingSurface(); bool drawSubLayers(); + bool drawLayersOnCommitIfNeeded(); + void drawAndBlendLayersForDirectRendering(const Platform::IntRect& dirtyRect); + // WebPage will call this when drawing layers to tell us we don't need to + void willDrawLayersOnCommit() { m_needsDrawLayersOnCommit = false; } + // WebPageCompositor uses this to cut down on excessive message sending. + bool isDirectRenderingAnimationMessageScheduled() { return m_isDirectRenderingAnimationMessageScheduled; } + void setDirectRenderingAnimationMessageScheduled() { m_isDirectRenderingAnimationMessageScheduled = true; } #endif void blitHorizontalScrollbar(const Platform::IntPoint&); @@ -347,6 +354,11 @@ public: pthread_mutex_t m_blitGenerationLock; pthread_cond_t m_blitGenerationCond; struct timespec m_currentBlitEnd; + +#if USE(ACCELERATED_COMPOSITING) + mutable bool m_needsDrawLayersOnCommit; // Not thread safe, WebKit thread only + bool m_isDirectRenderingAnimationMessageScheduled; +#endif }; } // namespace WebKit } // namespace BlackBerry diff --git a/Source/WebKit/blackberry/Api/WebPage.cpp b/Source/WebKit/blackberry/Api/WebPage.cpp index f3ce5f0ce..ad433607e 100644 --- a/Source/WebKit/blackberry/Api/WebPage.cpp +++ b/Source/WebKit/blackberry/Api/WebPage.cpp @@ -72,6 +72,9 @@ #include "LayerWebKitThread.h" #include "NetworkManager.h" #include "NodeRenderStyle.h" +#if ENABLE(NOTIFICATIONS) +#include "NotificationPresenterImpl.h" +#endif #include "Page.h" #include "PageCache.h" #include "PageGroup.h" @@ -330,6 +333,13 @@ WebPagePrivate::WebPagePrivate(WebPage* webPage, WebPageClient* client, const In { } +WebPage::WebPage(WebPageClient* client, const WebString& pageGroupName, const Platform::IntRect& rect) +{ + globalInitialize(); + d = new WebPagePrivate(this, client, rect); + d->init(pageGroupName); +} + WebPagePrivate::~WebPagePrivate() { // Hand the backingstore back to another owner if necessary. @@ -368,6 +378,17 @@ WebPagePrivate::~WebPagePrivate() #endif } +WebPage::~WebPage() +{ + delete d; + d = 0; +} + +Page* WebPagePrivate::core(const WebPage* webPage) +{ + return webPage->d->m_page; +} + void WebPagePrivate::init(const WebString& pageGroupName) { ChromeClientBlackBerry* chromeClient = new ChromeClientBlackBerry(this); @@ -410,6 +431,10 @@ void WebPagePrivate::init(const WebString& pageGroupName) pageClients.deviceOrientationClient = new DeviceOrientationClientBlackBerry(this); m_page = new Page(pageClients); +#if ENABLE(NOTIFICATIONS) + WebCore::provideNotification(m_page, NotificationPresenterImpl::instance()); +#endif + #if ENABLE(CLIENT_BASED_GEOLOCATION) && ENABLE_DRT // In case running in DumpRenderTree mode set the controller to mock provider. if (getenv("drtRun")) @@ -449,6 +474,7 @@ void WebPagePrivate::init(const WebString& pageGroupName) m_page->settings()->setUseHixie76WebSocketProtocol(false); m_page->settings()->setInteractiveFormValidationEnabled(true); m_page->settings()->setAllowUniversalAccessFromFileURLs(false); + m_page->settings()->setAllowFileAccessFromFileURLs(false); m_backingStoreClient = BackingStoreClient::create(m_mainFrame, /* parent frame */ 0, m_webPage); // The direct access to BackingStore is left here for convenience since it @@ -456,7 +482,7 @@ void WebPagePrivate::init(const WebString& pageGroupName) m_backingStore = m_backingStoreClient->backingStore(); m_page->settings()->setSpatialNavigationEnabled(m_webSettings->isSpatialNavigationEnabled()); - blockClickRadius = int(roundf(0.35 * Platform::Graphics::Screen::pixelsPerInch(0).width())); // The clicked rectangle area should be a fixed unit of measurement. + blockClickRadius = int(roundf(0.35 * Platform::Graphics::Screen::primaryScreen()->pixelsPerInch(0).width())); // The clicked rectangle area should be a fixed unit of measurement. m_page->settings()->setDelegateSelectionPaint(true); } @@ -507,6 +533,32 @@ void WebPagePrivate::load(const char* url, const char* networkToken, const char* m_mainFrame->loader()->load(request, "" /* name */, false); } +void WebPage::load(const char* url, const char* networkToken, bool isInitial) +{ + d->load(url, networkToken, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, isInitial, false); +} + +void WebPage::loadExtended(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool mustHandleInternally) +{ + d->load(url, networkToken, method, cachePolicy, data, dataLength, headers, headersLength, false, mustHandleInternally, false, ""); +} + +void WebPage::loadFile(const char* path, const char* overrideContentType) +{ + std::string fileUrl(path); + if (!fileUrl.find("/")) + fileUrl.insert(0, "file://"); + else if (fileUrl.find("file:///")) + return; + + d->load(fileUrl.c_str(), 0, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, false, overrideContentType); +} + +void WebPage::download(const Platform::NetworkRequest& request) +{ + d->load(request.getUrlRef().c_str(), 0, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, true, ""); +} + void WebPagePrivate::loadString(const char* string, const char* baseURL, const char* contentType, const char* failingURL) { KURL kurl = parseUrl(baseURL); @@ -520,6 +572,11 @@ void WebPagePrivate::loadString(const char* string, const char* baseURL, const c m_mainFrame->loader()->load(request, substituteData, false); } +void WebPage::loadString(const char* string, const char* baseURL, const char* mimeType, const char* failingURL) +{ + d->loadString(string, baseURL, mimeType, failingURL); +} + bool WebPagePrivate::executeJavaScript(const char* script, JavaScriptDataType& returnType, WebString& returnValue) { ScriptValue result = m_mainFrame->script()->executeScript(String::fromUTF8(script), false); @@ -564,6 +621,11 @@ bool WebPagePrivate::executeJavaScript(const char* script, JavaScriptDataType& r return true; } +bool WebPage::executeJavaScript(const char* script, JavaScriptDataType& returnType, WebString& returnValue) +{ + return d->executeJavaScript(script, returnType, returnValue); +} + bool WebPagePrivate::executeJavaScriptInIsolatedWorld(const ScriptSourceCode& sourceCode, JavaScriptDataType& returnType, WebString& returnValue) { if (!m_isolatedWorld) @@ -612,6 +674,33 @@ bool WebPagePrivate::executeJavaScriptInIsolatedWorld(const ScriptSourceCode& so return true; } +bool WebPage::executeJavaScriptInIsolatedWorld(const std::wstring& script, JavaScriptDataType& returnType, WebString& returnValue) +{ + // On our platform wchar_t is unsigned int and UChar is unsigned short + // so we have to convert using ICU conversion function + int lengthCopied = 0; + UErrorCode error = U_ZERO_ERROR; + const int length = script.length() + 1 /*null termination char*/; + UChar data[length]; + + // FIXME: PR 138162 is giving U_INVALID_CHAR_FOUND error. + u_strFromUTF32(data, length, &lengthCopied, reinterpret_cast<const UChar32*>(script.c_str()), script.length(), &error); + BLACKBERRY_ASSERT(error == U_ZERO_ERROR); + if (error != U_ZERO_ERROR) { + Platform::logAlways(Platform::LogLevelCritical, "WebPage::executeJavaScriptInIsolatedWorld failed to convert UTF16 to JavaScript!"); + return false; + } + String str = String(data, lengthCopied); + ScriptSourceCode sourceCode(str, KURL()); + return d->executeJavaScriptInIsolatedWorld(sourceCode, returnType, returnValue); +} + +bool WebPage::executeJavaScriptInIsolatedWorld(const char* script, JavaScriptDataType& returnType, WebString& returnValue) +{ + ScriptSourceCode sourceCode(String::fromUTF8(script), KURL()); + return d->executeJavaScriptInIsolatedWorld(sourceCode, returnType, returnValue); +} + void WebPagePrivate::stopCurrentLoad() { // This function should contain all common code triggered by WebPage::load @@ -626,6 +715,11 @@ void WebPagePrivate::stopCurrentLoad() frameLoaderClient->setDeferredManualScript(KURL()); } +void WebPage::stopLoading() +{ + d->stopCurrentLoad(); +} + static void closeURLRecursively(Frame* frame) { // Do not create more frame please. @@ -652,6 +746,11 @@ void WebPagePrivate::prepareToDestroy() closeURLRecursively(m_mainFrame); } +void WebPage::prepareToDestroy() +{ + d->prepareToDestroy(); +} + void WebPagePrivate::setLoadState(LoadState state) { if (m_loadState == state) @@ -1028,6 +1127,24 @@ void WebPagePrivate::setScrollPosition(const IntPoint& pos) m_backingStoreClient->setScrollPosition(pos); } +// Setting the scroll position is in transformed coordinates. +void WebPage::setScrollPosition(const Platform::IntPoint& point) +{ + if (d->transformedPointEqualsUntransformedPoint(point, d->scrollPosition())) + return; + + // If the user recently performed an event, this new scroll position + // could possibly be a result of that. Or not, this is just a heuristic. + if (currentTime() - d->m_lastUserEventTimestamp < manualScrollInterval) + d->m_userPerformedManualScroll = true; + + d->m_backingStoreClient->setIsClientGeneratedScroll(true); + d->m_mainFrame->view()->setCanOverscroll(true); + d->setScrollPosition(d->mapFromTransformed(point)); + d->m_mainFrame->view()->setCanOverscroll(false); + d->m_backingStoreClient->setIsClientGeneratedScroll(false); +} + bool WebPagePrivate::shouldSendResizeEvent() { if (!m_mainFrame->document()) @@ -1066,14 +1183,6 @@ void WebPagePrivate::didResumeLoading() m_client->didResumeLoading(); } -bool WebPage::scrollBy(const Platform::IntSize& delta, bool scrollMainFrame) -{ - d->m_backingStoreClient->setIsClientGeneratedScroll(true); - bool b = d->scrollBy(delta.width(), delta.height(), scrollMainFrame); - d->m_backingStoreClient->setIsClientGeneratedScroll(false); - return b; -} - bool WebPagePrivate::scrollBy(int deltaX, int deltaY, bool scrollMainFrame) { IntSize delta(deltaX, deltaY); @@ -1104,9 +1213,12 @@ bool WebPagePrivate::scrollBy(int deltaX, int deltaY, bool scrollMainFrame) return true; } -void WebPage::notifyInRegionScrollStatusChanged(bool status) +bool WebPage::scrollBy(const Platform::IntSize& delta, bool scrollMainFrame) { - d->notifyInRegionScrollStatusChanged(status); + d->m_backingStoreClient->setIsClientGeneratedScroll(true); + bool b = d->scrollBy(delta.width(), delta.height(), scrollMainFrame); + d->m_backingStoreClient->setIsClientGeneratedScroll(false); + return b; } void WebPagePrivate::notifyInRegionScrollStatusChanged(bool status) @@ -1117,6 +1229,11 @@ void WebPagePrivate::notifyInRegionScrollStatusChanged(bool status) } } +void WebPage::notifyInRegionScrollStatusChanged(bool status) +{ + d->notifyInRegionScrollStatusChanged(status); +} + void WebPagePrivate::enqueueRenderingOfClippedContentOfScrollableNodeAfterInRegionScrolling(Node* scrolledNode) { ASSERT(scrolledNode); @@ -1399,6 +1516,11 @@ double WebPagePrivate::zoomToFitScale() const return contentWidth > 0.0 ? static_cast<double>(m_actualVisibleWidth) / contentWidth : 1.0; } +double WebPage::zoomToFitScale() const +{ + return d->zoomToFitScale(); +} + double WebPagePrivate::initialScale() const { if (m_initialScale > 0.0) @@ -1410,6 +1532,11 @@ double WebPagePrivate::initialScale() const return 1.0; } +double WebPage::initialScale() const +{ + return d->initialScale(); +} + void WebPage::initializeIconDataBase() { IconDatabaseClientBlackBerry::getInstance()->initIconDatabase(d->m_webSettings); @@ -1425,16 +1552,6 @@ double WebPage::currentScale() const return d->currentScale(); } -double WebPage::initialScale() const -{ - return d->initialScale(); -} - -double WebPage::zoomToFitScale() const -{ - return d->zoomToFitScale(); -} - void WebPage::setInitialScale(double initialScale) { d->setInitialScale(initialScale); @@ -1450,11 +1567,6 @@ void WebPage::setMinimumScale(double minimumScale) d->setMinimumScale(minimumScale); } -double WebPage::maximumScale() const -{ - return d->maximumScale(); -} - void WebPage::setMaximumScale(double maximumScale) { d->setMaximumScale(maximumScale); @@ -1468,6 +1580,11 @@ double WebPagePrivate::maximumScale() const return hasVirtualViewport() ? std::max<double>(zoomToFitScale(), 4.0) : 4.0; } +double WebPage::maximumScale() const +{ + return d->maximumScale(); +} + void WebPagePrivate::resetScales() { TransformationMatrix identity; @@ -1486,6 +1603,12 @@ IntPoint WebPagePrivate::transformedScrollPosition() const return m_backingStoreClient->transformedScrollPosition(); } +// Returned scroll position is in transformed coordinates. +Platform::IntPoint WebPage::scrollPosition() const +{ + return d->transformedScrollPosition(); +} + IntPoint WebPagePrivate::transformedMaximumScrollPosition() const { return m_backingStoreClient->transformedMaximumScrollPosition(); @@ -1496,9 +1619,14 @@ IntSize WebPagePrivate::transformedActualVisibleSize() const return IntSize(m_actualVisibleWidth, m_actualVisibleHeight); } +Platform::IntSize WebPage::viewportSize() const +{ + return d->transformedActualVisibleSize(); +} + IntSize WebPagePrivate::transformedViewportSize() const { - return Platform::Graphics::Screen::size(); + return Platform::Graphics::Screen::primaryScreen()->size(); } IntRect WebPagePrivate::transformedVisibleContentsRect() const @@ -1947,6 +2075,11 @@ ActiveNodeContext WebPagePrivate::activeNodeContext(TargetDetectionStrategy stra return context; } +ActiveNodeContext WebPage::activeNodeContext(TargetDetectionStrategy strategy) const +{ + return d->activeNodeContext(strategy); +} + void WebPagePrivate::updateCursor() { int buttonMask = 0; @@ -2029,10 +2162,10 @@ IntSize WebPagePrivate::fixedLayoutSize(bool snapToIncrement) const // layout width. #if ENABLE(ORIENTATION_EVENTS) minWidth = m_mainFrame->orientation() % 180 - ? Platform::Graphics::Screen::height() - : Platform::Graphics::Screen::width(); + ? Platform::Graphics::Screen::primaryScreen()->height() + : Platform::Graphics::Screen::primaryScreen()->width(); #else - minWidth = Platform::Graphics::Screen::width(); + minWidth = Platform::Graphics::Screen::primaryScreen()->width(); #endif } } @@ -2189,11 +2322,6 @@ IntRect WebPagePrivate::getRecursiveVisibleWindowRect(ScrollView* view, bool noC return visibleWindowRect; } -void WebPage::assignFocus(Platform::FocusDirection direction) -{ - d->assignFocus(direction); -} - void WebPagePrivate::assignFocus(Platform::FocusDirection direction) { ASSERT((int) Platform::FocusDirectionNone == (int) FocusDirectionNone); @@ -2217,6 +2345,11 @@ void WebPagePrivate::assignFocus(Platform::FocusDirection direction) } } +void WebPage::assignFocus(Platform::FocusDirection direction) +{ + d->assignFocus(direction); +} + Platform::IntRect WebPagePrivate::focusNodeRect() { Frame* frame = focusedOrMainFrame(); @@ -2563,11 +2696,6 @@ IntRect WebPagePrivate::blockZoomRectForNode(Node* node) return blockRect; } -void WebPage::blockZoomAnimationFinished() -{ - d->zoomBlock(); -} - // This function should not be called directly. // It is called after the animation ends (see above). void WebPagePrivate::zoomBlock() @@ -2649,6 +2777,10 @@ void WebPagePrivate::zoomBlock() m_client->zoomChanged(m_webPage->isMinZoomed(), m_webPage->isMaxZoomed(), !shouldZoomOnEscape(), currentScale()); } +void WebPage::blockZoomAnimationFinished() +{ + d->zoomBlock(); +} void WebPagePrivate::resetBlockZoom() { @@ -2657,13 +2789,6 @@ void WebPagePrivate::resetBlockZoom() m_shouldReflowBlock = false; } -WebPage::WebPage(WebPageClient* client, const WebString& pageGroupName, const Platform::IntRect& rect) -{ - globalInitialize(); - d = new WebPagePrivate(this, client, rect); - d->init(pageGroupName); -} - void WebPage::destroyWebPageCompositor() { #if USE(ACCELERATED_COMPOSITING) @@ -2703,90 +2828,11 @@ void WebPage::destroy() delete this; } -WebPage::~WebPage() -{ - delete d; - d = 0; -} - WebPageClient* WebPage::client() const { return d->m_client; } -void WebPage::load(const char* url, const char* networkToken, bool isInitial) -{ - d->load(url, networkToken, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, isInitial, false); -} - -void WebPage::loadExtended(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool mustHandleInternally) -{ - d->load(url, networkToken, method, cachePolicy, data, dataLength, headers, headersLength, false, mustHandleInternally, false, ""); -} - -void WebPage::loadFile(const char* path, const char* overrideContentType) -{ - std::string fileUrl(path); - if (!fileUrl.find("/")) - fileUrl.insert(0, "file://"); - else if (fileUrl.find("file:///")) - return; - - d->load(fileUrl.c_str(), 0, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, false, overrideContentType); -} - -void WebPage::loadString(const char* string, const char* baseURL, const char* mimeType, const char* failingURL) -{ - d->loadString(string, baseURL, mimeType, failingURL); -} - -void WebPage::download(const Platform::NetworkRequest& request) -{ - d->load(request.getUrlRef().c_str(), 0, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, true, ""); -} - -bool WebPage::executeJavaScript(const char* script, JavaScriptDataType& returnType, WebString& returnValue) -{ - return d->executeJavaScript(script, returnType, returnValue); -} - -bool WebPage::executeJavaScriptInIsolatedWorld(const std::wstring& script, JavaScriptDataType& returnType, WebString& returnValue) -{ - // On our platform wchar_t is unsigned int and UChar is unsigned short - // so we have to convert using ICU conversion function - int lengthCopied = 0; - UErrorCode error = U_ZERO_ERROR; - const int length = script.length() + 1 /*null termination char*/; - UChar data[length]; - - // FIXME: PR 138162 is giving U_INVALID_CHAR_FOUND error. - u_strFromUTF32(data, length, &lengthCopied, reinterpret_cast<const UChar32*>(script.c_str()), script.length(), &error); - BLACKBERRY_ASSERT(error == U_ZERO_ERROR); - if (error != U_ZERO_ERROR) { - Platform::logAlways(Platform::LogLevelCritical, "WebPage::executeJavaScriptInIsolatedWorld failed to convert UTF16 to JavaScript!"); - return false; - } - String str = String(data, lengthCopied); - ScriptSourceCode sourceCode(str, KURL()); - return d->executeJavaScriptInIsolatedWorld(sourceCode, returnType, returnValue); -} - -bool WebPage::executeJavaScriptInIsolatedWorld(const char* script, JavaScriptDataType& returnType, WebString& returnValue) -{ - ScriptSourceCode sourceCode(String::fromUTF8(script), KURL()); - return d->executeJavaScriptInIsolatedWorld(sourceCode, returnType, returnValue); -} - -void WebPage::stopLoading() -{ - d->stopCurrentLoad(); -} - -void WebPage::prepareToDestroy() -{ - d->prepareToDestroy(); -} - int WebPage::backForwardListLength() const { return d->m_page->getHistoryLength(); @@ -2953,11 +2999,6 @@ void WebPage::setColorInput(const WebString& value) d->m_inputHandler->setInputValue(String(value.impl())); } -ActiveNodeContext WebPage::activeNodeContext(TargetDetectionStrategy strategy) const -{ - return d->activeNodeContext(strategy); -} - void WebPage::setVirtualViewportSize(int width, int height) { d->m_virtualViewportWidth = width; @@ -2976,9 +3017,9 @@ IntSize WebPagePrivate::recomputeVirtualViewportFromViewportArguments() return IntSize(); int desktopWidth = defaultMaxLayoutSize().width(); - int deviceWidth = Platform::Graphics::Screen::width(); - int deviceHeight = Platform::Graphics::Screen::height(); - FloatSize currentPPI = Platform::Graphics::Screen::pixelsPerInch(-1); + int deviceWidth = Platform::Graphics::Screen::primaryScreen()->width(); + int deviceHeight = Platform::Graphics::Screen::primaryScreen()->height(); + FloatSize currentPPI = Platform::Graphics::Screen::primaryScreen()->pixelsPerInch(-1); int deviceDPI = int(roundf((currentPPI.width() + currentPPI.height()) / 2)); if (m_viewportArguments.targetDensityDpi == ViewportArguments::ValueAuto) { // Auto means 160dpi if we leave it alone. This looks terrible for pages wanting 1:1. @@ -2987,6 +3028,7 @@ IntSize WebPagePrivate::recomputeVirtualViewportFromViewportArguments() } ViewportAttributes result = computeViewportAttributes(m_viewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, m_defaultLayoutSize); + m_page->setDeviceScaleFactor(result.devicePixelRatio); return IntSize(result.layoutSize.width(), result.layoutSize.height()); } @@ -3048,15 +3090,9 @@ void WebPagePrivate::onInputLocaleChanged(bool isRTL) } } -void WebPage::setScreenOrientation(int orientation) -{ - d->m_pendingOrientation = orientation; -} - -void WebPage::applyPendingOrientationIfNeeded() +void WebPage::onInputLocaleChanged(bool isRTL) { - if (d->m_pendingOrientation != -1) - d->setScreenOrientation(d->m_pendingOrientation); + d->onInputLocaleChanged(isRTL); } void WebPagePrivate::suspendBackingStore() @@ -3111,14 +3147,15 @@ void WebPagePrivate::setScreenOrientation(int orientation) #endif } -Platform::IntSize WebPage::viewportSize() const +void WebPage::setScreenOrientation(int orientation) { - return d->transformedActualVisibleSize(); + d->m_pendingOrientation = orientation; } -void WebPage::setViewportSize(const Platform::IntSize& viewportSize, bool ensureFocusElementVisible) +void WebPage::applyPendingOrientationIfNeeded() { - d->setViewportSize(viewportSize, ensureFocusElementVisible); + if (d->m_pendingOrientation != -1) + d->setScreenOrientation(d->m_pendingOrientation); } void WebPagePrivate::screenRotated() @@ -3165,7 +3202,7 @@ void WebPagePrivate::setViewportSize(const IntSize& transformedActualVisibleSize bool newVisibleRectContainsOldVisibleRect = (m_actualVisibleHeight <= transformedActualVisibleSize.height()) && (m_actualVisibleWidth <= transformedActualVisibleSize.width()); - bool atInitialScale = currentScale() == initialScale(); + bool atInitialScale = m_webPage->isAtInitialZoom(); bool atTop = !scrollPosition().y(); bool atLeft = !scrollPosition().x(); @@ -3235,8 +3272,10 @@ void WebPagePrivate::setViewportSize(const IntSize& transformedActualVisibleSize if (setViewMode(viewMode())) needsLayout = true; + bool needsLayoutToFindContentSize = hasPendingOrientation; + // We need to update the viewport size of the WebCore::ScrollView... - updateViewportSize(!hasPendingOrientation /* setFixedReportedSize */, false /* sendResizeEvent */); + updateViewportSize(!needsLayoutToFindContentSize /* setFixedReportedSize */, false /* sendResizeEvent */); notifyTransformedContentsSizeChanged(); // If automatic zooming is disabled, prevent zooming below. @@ -3273,7 +3312,7 @@ void WebPagePrivate::setViewportSize(const IntSize& transformedActualVisibleSize // Do our own clamping. scale = clampedScale(scale); - if (hasPendingOrientation) { + if (needsLayoutToFindContentSize) { // Set the fixed reported size here so that innerWidth|innerHeight works // with this new scale. TransformationMatrix rotationMatrix; @@ -3281,6 +3320,7 @@ void WebPagePrivate::setViewportSize(const IntSize& transformedActualVisibleSize IntRect viewportRect = IntRect(IntPoint::zero(), transformedActualVisibleSize); IntRect actualVisibleRect = enclosingIntRect(rotationMatrix.inverse().mapRect(FloatRect(viewportRect))); m_mainFrame->view()->setFixedReportedSize(actualVisibleRect.size()); + m_mainFrame->view()->repaintFixedElementsAfterScrolling(); } // We're going to need to send a resize event to JavaScript because @@ -3339,26 +3379,30 @@ void WebPagePrivate::setViewportSize(const IntSize& transformedActualVisibleSize ensureContentVisible(!newVisibleRectContainsOldVisibleRect); } -void WebPage::setDefaultLayoutSize(int width, int height) +void WebPage::setViewportSize(const Platform::IntSize& viewportSize, bool ensureFocusElementVisible) { - IntSize size(width, height); - d->setDefaultLayoutSize(size); + d->setViewportSize(viewportSize, ensureFocusElementVisible); } void WebPagePrivate::setDefaultLayoutSize(const IntSize& size) { - if (size == m_defaultLayoutSize) - return; - - IntSize screenSize = Platform::Graphics::Screen::size(); + IntSize screenSize = Platform::Graphics::Screen::primaryScreen()->size(); ASSERT(size.width() <= screenSize.width() && size.height() <= screenSize.height()); m_defaultLayoutSize = size.expandedTo(minimumLayoutSize).shrunkTo(screenSize); +} + +void WebPage::setDefaultLayoutSize(int width, int height) +{ + IntSize size(width, height); + if (size == d->m_defaultLayoutSize) + return; - bool needsLayout = setViewMode(viewMode()); + d->setDefaultLayoutSize(size); + bool needsLayout = d->setViewMode(d->viewMode()); if (needsLayout) { - setNeedsLayout(); - if (!isLoading()) - requestLayoutIfNeeded(); + d->setNeedsLayout(); + if (!d->isLoading()) + d->requestLayoutIfNeeded(); } } @@ -3590,12 +3634,6 @@ bool WebPage::touchEvent(const Platform::TouchEvent& event) return false; } -void WebPage::setScrollOriginPoint(const Platform::IntPoint& point) -{ - Platform::IntPoint untransformedPoint = d->mapFromTransformed(point); - d->setScrollOriginPoint(untransformedPoint); -} - void WebPagePrivate::setScrollOriginPoint(const Platform::IntPoint& point) { m_inRegionScrollStartingNode = 0; @@ -3606,6 +3644,12 @@ void WebPagePrivate::setScrollOriginPoint(const Platform::IntPoint& point) m_client->notifyInRegionScrollingStartingPointChanged(inRegionScrollableAreasForPoint(point)); } +void WebPage::setScrollOriginPoint(const Platform::IntPoint& point) +{ + Platform::IntPoint untransformedPoint = d->mapFromTransformed(point); + d->setScrollOriginPoint(untransformedPoint); +} + bool WebPagePrivate::dispatchTouchEventToFullScreenPlugin(PluginView* plugin, const Platform::TouchEvent& event) { NPTouchEvent npTouchEvent; @@ -3735,6 +3779,38 @@ void WebPagePrivate::clearFocusNode() frame->page()->focusController()->setFocusedNode(0, frame); } +WebString WebPage::textEncoding() +{ + Frame* frame = d->focusedOrMainFrame(); + if (!frame) + return ""; + + Document* document = frame->document(); + if (!document) + return ""; + + return document->loader()->writer()->encoding(); +} + +WebString WebPage::forcedTextEncoding() +{ + Frame* frame = d->focusedOrMainFrame(); + if (!frame) + return ""; + + Document* document = frame->document(); + if (!document) + return ""; + + return document->loader()->overrideEncoding(); +} + +void WebPage::setForcedTextEncoding(const char* encoding) +{ + if (encoding && d->focusedOrMainFrame() && d->focusedOrMainFrame()->loader() && d->focusedOrMainFrame()->loader()) + return d->focusedOrMainFrame()->loader()->reloadWithOverrideEncoding(encoding); +} + bool WebPagePrivate::scrollNodeRecursively(Node* node, const IntSize& delta) { if (delta.isZero()) @@ -3960,7 +4036,7 @@ int32_t WebPage::commitText(spannable_string_t* spannableString, int32_t relativ return d->m_inputHandler->commitText(spannableString, relativeCursorPosition); } -void WebPage::spellCheckingEnabled(bool enabled) +void WebPage::setSpellCheckingEnabled(bool enabled) { static_cast<EditorClientBlackBerry*>(d->m_page->editorClient())->enableSpellChecking(enabled); } @@ -4053,62 +4129,6 @@ void WebPage::selectAtPoint(const Platform::IntPoint& location) d->m_selectionHandler->selectAtPoint(selectionLocation); } -// Returned scroll position is in transformed coordinates. -Platform::IntPoint WebPage::scrollPosition() const -{ - return d->transformedScrollPosition(); -} - -// Setting the scroll position is in transformed coordinates. -void WebPage::setScrollPosition(const Platform::IntPoint& point) -{ - if (d->transformedPointEqualsUntransformedPoint(point, d->scrollPosition())) - return; - - // If the user recently performed an event, this new scroll position - // could possibly be a result of that. Or not, this is just a heuristic. - if (currentTime() - d->m_lastUserEventTimestamp < manualScrollInterval) - d->m_userPerformedManualScroll = true; - - d->m_backingStoreClient->setIsClientGeneratedScroll(true); - d->m_mainFrame->view()->setCanOverscroll(true); - d->setScrollPosition(d->mapFromTransformed(point)); - d->m_mainFrame->view()->setCanOverscroll(false); - d->m_backingStoreClient->setIsClientGeneratedScroll(false); -} - -WebString WebPage::textEncoding() -{ - Frame* frame = d->focusedOrMainFrame(); - if (!frame) - return ""; - - Document* document = frame->document(); - if (!document) - return ""; - - return document->loader()->writer()->encoding(); -} - -WebString WebPage::forcedTextEncoding() -{ - Frame* frame = d->focusedOrMainFrame(); - if (!frame) - return ""; - - Document* document = frame->document(); - if (!document) - return ""; - - return document->loader()->overrideEncoding(); -} - -void WebPage::setForcedTextEncoding(const char* encoding) -{ - if (encoding && d->focusedOrMainFrame() && d->focusedOrMainFrame()->loader() && d->focusedOrMainFrame()->loader()) - return d->focusedOrMainFrame()->loader()->reloadWithOverrideEncoding(encoding); -} - // FIXME: Move to DOMSupport. bool WebPagePrivate::canScrollInnerFrame(Frame* frame) const { @@ -4152,7 +4172,6 @@ bool WebPagePrivate::canScrollRenderBox(RenderBox* box) static RenderLayer* parentLayer(RenderLayer* layer) { ASSERT(layer); - if (layer->parent()) return layer->parent(); @@ -4203,7 +4222,6 @@ std::vector<Platform::ScrollViewBase> WebPagePrivate::inRegionScrollableAreasFor return emptyReturn; RenderLayer* layer = renderer->enclosingLayer(); - do { RenderObject* renderer = layer->renderer(); @@ -4231,7 +4249,6 @@ std::vector<Platform::ScrollViewBase> WebPagePrivate::inRegionScrollableAreasFor } } while (layer = parentLayer(layer)); - if (validReturn.empty()) return emptyReturn; @@ -4535,11 +4552,6 @@ bool WebPage::zoomToOneOne() return d->zoomAboutPoint(scale, d->centerOfVisibleContentsRect()); } -Platform::IntRect WebPage::focusNodeRect() -{ - return d->focusNodeRect(); -} - void WebPage::setFocused(bool focused) { FocusController* focusController = d->m_page->focusController(); @@ -4903,20 +4915,12 @@ void WebPage::notifyPageResume() void WebPage::notifyPageBackground() { -#if USE(ACCELERATED_COMPOSITING) - d->suspendRootLayerCommit(); -#endif - FOR_EACH_PLUGINVIEW(d->m_pluginViews) (*it)->handleBackgroundEvent(); } void WebPage::notifyPageForeground() { -#if USE(ACCELERATED_COMPOSITING) - d->resumeRootLayerCommit(); -#endif - FOR_EACH_PLUGINVIEW(d->m_pluginViews) (*it)->handleForegroundEvent(); } @@ -4998,11 +5002,6 @@ void WebPage::clearPluginSiteData() (*it)->clearSiteData(String()); } -void WebPage::onInputLocaleChanged(bool isRTL) -{ - d->onInputLocaleChanged(isRTL); -} - void WebPage::onNetworkAvailabilityChanged(bool available) { updateOnlineStatus(available); @@ -5027,6 +5026,11 @@ void WebPage::disableWebInspector() d->m_page->settings()->setDeveloperExtrasEnabled(false); } +bool WebPage::isWebInspectorEnabled() +{ + return d->m_page->settings()->developerExtrasEnabled(); +} + void WebPage::enablePasswordEcho() { d->m_page->settings()->setPasswordEchoEnabled(true); @@ -5037,17 +5041,12 @@ void WebPage::disablePasswordEcho() d->m_page->settings()->setPasswordEchoEnabled(false); } -void WebPage::dispatchInspectorMessage(const char* message, int length) +void WebPage::dispatchInspectorMessage(const std::string& message) { - String stringMessage(message, length); + String stringMessage(message.c_str(), message.length()); d->m_page->inspectorController()->dispatchMessageFromFrontend(stringMessage); } -Frame* WebPage::mainFrame() const -{ - return d->m_mainFrame; -} - #if USE(ACCELERATED_COMPOSITING) void WebPagePrivate::drawLayersOnCommit() { @@ -5414,14 +5413,14 @@ void WebPagePrivate::enterFullscreenForNode(Node* node) if (!mmrPlayer) return; - Platform::Graphics::Window* window = mmrPlayer->windowGet(); + Platform::Graphics::Window* window = mmrPlayer->getWindow(); if (!window) return; unsigned x, y, width, height; - mmrPlayer->windowPositionGet(x, y, width, height); + mmrPlayer->getWindowPosition(x, y, width, height); - const char* contextName = mmrPlayer->mmrContextNameGet(); + const char* contextName = mmrPlayer->mmrContextName(); if (!contextName) return; @@ -5466,7 +5465,7 @@ void WebPagePrivate::didChangeSettings(WebSettings* webSettings) coreSettings->setPrivateBrowsingEnabled(webSettings->isPrivateBrowsingEnabled()); coreSettings->setDefaultFixedFontSize(webSettings->defaultFixedFontSize()); coreSettings->setDefaultFontSize(webSettings->defaultFontSize()); - coreSettings->setMinimumFontSize(webSettings->minimumFontSize()); + coreSettings->setMinimumLogicalFontSize(webSettings->minimumFontSize()); coreSettings->setSerifFontFamily(webSettings->serifFontFamily().impl()); coreSettings->setFixedFontFamily(webSettings->fixedFontFamily().impl()); coreSettings->setSansSerifFontFamily(webSettings->sansSerifFontFamily().impl()); @@ -5546,8 +5545,8 @@ IntSize WebPagePrivate::defaultMaxLayoutSize() { static IntSize size; if (size.isEmpty()) - size = IntSize(std::max(1024, Platform::Graphics::Screen::landscapeWidth()), - std::max(768, Platform::Graphics::Screen::landscapeHeight())); + size = IntSize(std::max(1024, Platform::Graphics::Screen::primaryScreen()->landscapeWidth()), + std::max(768, Platform::Graphics::Screen::primaryScreen()->landscapeHeight())); return size; } @@ -5594,5 +5593,11 @@ void WebPagePrivate::setNeedTouchEvents(bool value) m_needTouchEvents = value; } +void WebPagePrivate::frameUnloaded(const Frame* frame) +{ + m_inputHandler->frameUnloaded(frame); + m_inPageSearchManager->frameUnloaded(frame); +} + } } diff --git a/Source/WebKit/blackberry/Api/WebPage.h b/Source/WebKit/blackberry/Api/WebPage.h index 489f4536c..3a883ce66 100644 --- a/Source/WebKit/blackberry/Api/WebPage.h +++ b/Source/WebKit/blackberry/Api/WebPage.h @@ -34,17 +34,8 @@ typedef const struct OpaqueJSValue* JSValueRef; namespace WebCore { class ChromeClientBlackBerry; -class EditorClientBlackBerry; -class Element; class Frame; class FrameLoaderClientBlackBerry; -class GeolocationControllerClientBlackBerry; -class IconDatabaseClientBlackBerry; -class InspectorClientBlackBerry; -class JavaScriptDebuggerBlackBerry; -class Node; -class RenderObject; -class VisibleSelection; } class WebDOMDocument; @@ -67,7 +58,6 @@ namespace WebKit { class BackingStore; class BackingStoreClient; class BackingStorePrivate; -class DumpRenderTreeClient; class RenderQueue; class WebPageClient; class WebPageGroupLoadDeferrer; @@ -192,8 +182,6 @@ public: void assignFocus(Platform::FocusDirection); - Platform::IntRect focusNodeRect(); - void setFocused(bool); void clearBrowsingData(); @@ -250,7 +238,7 @@ public: int32_t setComposingText(spannable_string_t*, int32_t relativeCursorPosition); int32_t commitText(spannable_string_t*, int32_t relativeCursorPosition); - void spellCheckingEnabled(bool); + void setSpellCheckingEnabled(bool); void setSelection(const Platform::IntPoint& startPoint, const Platform::IntPoint& endPoint); void setCaretPosition(const Platform::IntPoint&); @@ -312,10 +300,10 @@ public: void enableWebInspector(); void disableWebInspector(); + bool isWebInspectorEnabled(); void enablePasswordEcho(); void disablePasswordEcho(); - void dispatchInspectorMessage(const char* message, int length); - WebCore::Frame* mainFrame() const; + void dispatchInspectorMessage(const std::string& message); // FIXME: Needs API review on this header. See PR #120402. void notifyPagePause(); @@ -344,6 +332,7 @@ private: friend class WebKit::BackingStorePrivate; friend class WebKit::RenderQueue; friend class WebKit::WebPageGroupLoadDeferrer; + friend class WebKit::WebPagePrivate; friend class WebCore::ChromeClientBlackBerry; friend class WebCore::FrameLoaderClientBlackBerry; WebPagePrivate* d; diff --git a/Source/WebKit/blackberry/Api/WebPageClient.h b/Source/WebKit/blackberry/Api/WebPageClient.h index 74b735c77..6799d428e 100644 --- a/Source/WebKit/blackberry/Api/WebPageClient.h +++ b/Source/WebKit/blackberry/Api/WebPageClient.h @@ -66,42 +66,6 @@ public: FlagWindowDefault = 0xFFFFFFFF, }; - enum FocusType { - FocusUnknown = 0, - FocusNone, - FocusCanvas, - FocusImage, - FocusInputButton, - FocusInputCheckBox, - FocusInputColor, - FocusInputDate, - FocusInputDateTime, - FocusInputDateTimeLocal, - FocusInputEmail, - FocusInputFile, - FocusInputImage, - FocusInputMonth, - FocusInputNumber, - FocusInputPassword, - FocusInputRadio, - FocusInputRange, - FocusInputReset, - FocusInputSearch, - FocusInputSubmit, - FocusInputTelephone, - FocusInputText, - FocusInputTime, - FocusInputURL, - FocusInputWeek, - FocusInputUnknown, - FocusLink, - FocusObject, - FocusSelect, - FocusSVGElement, - FocusTextArea, - FocusVideo, - }; - enum AlertType { MediaOK = 0, MediaDecodeError, @@ -165,7 +129,6 @@ public: virtual void drawTapHighlight(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0; virtual void hideTapHighlight() = 0; - virtual void focusChanged(FocusType, int elementId) = 0; virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle, bool waitForExplicitKeyboardShowCall) = 0; virtual void inputFocusLost() = 0; virtual void inputTextChanged() = 0; @@ -261,7 +224,6 @@ public: virtual void touchEventModeChanged(Platform::TouchEventMode) = 0; virtual bool downloadAllowed(const char* url) = 0; - virtual void downloadRequested(const Platform::NetworkRequest&) = 0; virtual void downloadRequested(Platform::FilterStream*, const WebString& suggestedFilename) = 0; virtual int fullscreenStart(const char* contextName, Platform::Graphics::Window*, unsigned x, unsigned y, unsigned width, unsigned height) = 0; diff --git a/Source/WebKit/blackberry/Api/WebPage_p.h b/Source/WebKit/blackberry/Api/WebPage_p.h index e0238b6d6..ed3739c22 100644 --- a/Source/WebKit/blackberry/Api/WebPage_p.h +++ b/Source/WebKit/blackberry/Api/WebPage_p.h @@ -37,7 +37,6 @@ namespace WebCore { class DOMWrapperWorld; class Document; class Frame; -class FrameView; class GeolocationControllerClientBlackBerry; class JavaScriptDebuggerBlackBerry; class KURL; @@ -60,7 +59,6 @@ class BackingStoreTile; class DumpRenderTreeClient; class InPageSearchManager; class InputHandler; -class InRegionScrollableArea; class SelectionHandler; class TouchEventHandler; class WebPageClient; @@ -82,6 +80,8 @@ public: WebPagePrivate(WebPage*, WebPageClient*, const WebCore::IntRect&); virtual ~WebPagePrivate(); + static WebCore::Page* core(const WebPage*); + void init(const WebString& pageGroupName); bool handleMouseEvent(WebCore::PlatformMouseEvent&); bool handleWheelEvent(WebCore::PlatformWheelEvent&); @@ -373,6 +373,7 @@ public: void setRootLayerCompositingThread(WebCore::LayerCompositingThread*); void commitRootLayer(const WebCore::IntRect&, const WebCore::IntSize&); void setIsAcceleratedCompositingActive(bool); + bool isAcceleratedCompositingActive() const { return m_isAcceleratedCompositingActive; } void destroyCompositor(); void syncDestroyCompositorOnCompositingThread(); void destroyLayerResources(); @@ -392,6 +393,8 @@ public: // Clean up any document related data we might be holding. void clearDocumentData(const WebCore::Document*); + void frameUnloaded(const WebCore::Frame*); + static WebCore::RenderLayer* enclosingPositionedAncestorOrSelfIfPositioned(WebCore::RenderLayer*); static WebCore::RenderLayer* enclosingFixedPositionedAncestorOrSelfIfFixedPositioned(WebCore::RenderLayer*); diff --git a/Source/WebKit/blackberry/Api/WebSettings.cpp b/Source/WebKit/blackberry/Api/WebSettings.cpp index 960964cd8..f6067178a 100644 --- a/Source/WebKit/blackberry/Api/WebSettings.cpp +++ b/Source/WebKit/blackberry/Api/WebSettings.cpp @@ -52,6 +52,7 @@ DEFINE_STATIC_LOCAL(String, BlackBerryUserAgentString, ("BlackBerryUserAgentStri DEFINE_STATIC_LOCAL(String, BlackBerryUserScalableEnabled, ("BlackBerryUserScalableEnabled")); DEFINE_STATIC_LOCAL(String, BlackBerryViewportWidth, ("BlackBerryViewportWidth")); DEFINE_STATIC_LOCAL(String, BlackBerryZoomToFitOnLoadEnabled, ("BlackBerryZoomToFitOnLoadEnabled")); +DEFINE_STATIC_LOCAL(String, SpatialNavigationEnabled, ("SpatialNavigationEnabled")); DEFINE_STATIC_LOCAL(String, WebKitDatabasePath, ("WebKitDatabasePath")); DEFINE_STATIC_LOCAL(String, WebKitDatabasesEnabled, ("WebKitDatabasesEnabled")); DEFINE_STATIC_LOCAL(String, WebKitDefaultFixedFontSize, ("WebKitDefaultFixedFontSize")); @@ -82,7 +83,6 @@ DEFINE_STATIC_LOCAL(String, WebKitUserStyleSheet, ("WebKitUserStyleSheet")); DEFINE_STATIC_LOCAL(String, WebKitUserStyleSheetLocation, ("WebKitUserStyleSheetLocation")); DEFINE_STATIC_LOCAL(String, WebKitWebSocketsEnabled, ("WebKitWebSocketsEnabled")); DEFINE_STATIC_LOCAL(String, WebKitXSSAuditorEnabled, ("WebKitXSSAuditorEnabled")); -DEFINE_STATIC_LOCAL(String, SpatialNavigationEnabled, ("SpatialNavigationEnabled")); // FIXME: We should consider moving all the mime type code into its own object. @@ -131,6 +131,7 @@ static const MIMETypeAssociationMap& mimeTypeAssociationMap() mimeTypeMap->add("audio/x-aac", "audio/aac"); mimeTypeMap->add("audio/x-amr", "audio/amr"); mimeTypeMap->add("audio/mpegurl", "audio/x-mpegurl"); + mimeTypeMap->add("audio/flac", "audio/x-flac"); mimeTypeMap->add("video/3gp", "video/3gpp"); mimeTypeMap->add("video/avi", "video/x-msvideo"); mimeTypeMap->add("video/x-m4v", "video/mp4"); @@ -214,25 +215,25 @@ WebSettings* WebSettings::standardSettings() // FIXME: We should detect whether we are embedded in a browser or an email client and default to TextReflowEnabledOnlyForBlockZoom and TextReflowEnabled, respectively. settings->m_private->setTextReflowMode(BlackBerryTextReflowMode, TextReflowDisabled); - settings->m_private->setBoolean(BlackBerryUserScalableEnabled, true); settings->m_private->setBoolean(BlackBerryUseWebKitCache, true); + settings->m_private->setBoolean(BlackBerryUserScalableEnabled, true); settings->m_private->setBoolean(BlackBerryZoomToFitOnLoadEnabled, true); + settings->m_private->setInteger(WebKitDefaultFontSize, 16); settings->m_private->setInteger(WebKitDefaultFixedFontSize, 13); - settings->m_private->setInteger(WebKitMinimumFontSize, 8); settings->m_private->setString(WebKitDefaultTextEncodingName, "iso-8859-1"); + settings->m_private->setBoolean(WebKitDownloadableBinaryFontsEnabled, true); settings->m_private->setInteger(WebKitFirstScheduledLayoutDelay, 250); // Match Document::cLayoutScheduleThreshold. + settings->m_private->setString(WebKitFixedFontFamily, "Courier New"); settings->m_private->setBoolean(WebKitJavaScriptEnabled, true); settings->m_private->setBoolean(WebKitLoadsImagesAutomatically, true); - settings->m_private->setBoolean(WebKitDownloadableBinaryFontsEnabled, true); settings->m_private->setUnsignedLongLong(WebKitLocalStorageQuota, 5 * 1024 * 1024); settings->m_private->setInteger(WebKitMaximumPagesInCache, 0); - settings->m_private->setBoolean(WebKitWebSocketsEnabled, true); - settings->m_private->setString(WebKitFixedFontFamily, "Courier New"); + settings->m_private->setInteger(WebKitMinimumFontSize, 8); settings->m_private->setString(WebKitSansSeriffFontFamily, "Arial"); settings->m_private->setString(WebKitSeriffFontFamily, "Times New Roman"); settings->m_private->setString(WebKitStandardFontFamily, "Times New Roman"); - settings->m_private->setBoolean(SpatialNavigationEnabled, false); + settings->m_private->setBoolean(WebKitWebSocketsEnabled, true); return settings; } diff --git a/Source/WebKit/blackberry/ChangeLog b/Source/WebKit/blackberry/ChangeLog index 60d341ad0..28317d8aa 100644 --- a/Source/WebKit/blackberry/ChangeLog +++ b/Source/WebKit/blackberry/ChangeLog @@ -1,3 +1,792 @@ +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * WebCoreSupport/NotificationPresenterImpl.cpp: + (WebCore::NotificationPresenterImpl::instance): + (WebCore::NotificationPresenterImpl::show): + (WebCore::NotificationPresenterImpl::checkPermission): + * WebCoreSupport/NotificationPresenterImpl.h: + (NotificationPresenterImpl): + +2012-03-09 Charles Wei <charles.wei@torchmobile.com.cn> + + [BlackBerry] Web Notification not working after rebase + https://bugs.webkit.org/show_bug.cgi?id=80690 + + Reviewed by George Staikos. + + 1. NotificationPresenterImpl should be in namespace WebCore + 2. Need to connect NotificationPresenterImpl to webcore the new way: + WebCore::provideNotification(Page*, NotificationPresenter*) + 3. Remove the old way of connecting the Notification: + ChromeClientBlackBerry::notificationPresenter() + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::init): + * WebCoreSupport/ChromeClientBlackBerry.cpp: + (WebCore): + * WebCoreSupport/ChromeClientBlackBerry.h: + (ChromeClientBlackBerry): + * WebCoreSupport/NotificationPresenterImpl.cpp: + * WebCoreSupport/NotificationPresenterImpl.h: + +2012-03-08 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Always use the current focused node when processing focus changes + https://bugs.webkit.org/show_bug.cgi?id=80594 + + Reviewed by Antonio Gomes. + + Guard against toRange or fromRange being null when called + as part of a clear event. + + * WebCoreSupport/EditorClientBlackBerry.cpp: + (WebCore::EditorClientBlackBerry::shouldChangeSelectedRange): + +2012-03-08 Yong Li <yoli@rim.com> + + [BlackBerry] Block file-to-file access by default + https://bugs.webkit.org/show_bug.cgi?id=80605 + + Reviewed by Rob Buis. + + Turn off allowFileAccessFromFileURLs() by default. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::init): + +2012-03-08 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Always use the current focused node when processing focus changes + https://bugs.webkit.org/show_bug.cgi?id=80594 + + Reviewed by Antonio Gomes. + + Update InputHandler focused node handling to strictly use + the currently focused node. This prevents a handling loop + when JS is modifying the focus and we get a late notification + of a past change from ChromeClientBlackBerry with the previously + unfocused node. + + * WebCoreSupport/ChromeClientBlackBerry.cpp: + (WebCore::ChromeClientBlackBerry::focusedNodeChanged): + * WebCoreSupport/EditorClientBlackBerry.cpp: + (WebCore::EditorClientBlackBerry::shouldChangeSelectedRange): + (WebCore::EditorClientBlackBerry::setInputMethodState): + * WebKitSupport/InputHandler.cpp: + (BlackBerry::WebKit::InputHandler::focusedNodeChanged): + * WebKitSupport/InputHandler.h: + +2012-03-07 Jacky Jiang <zhajiang@rim.com> + + [BlackBerry] WebKit rendering problem when show/hide VKB + https://bugs.webkit.org/show_bug.cgi?id=80448 + RIM PR: 141727 + + Reviewed by Antonio Gomes. + + When setting viewport size, layout happens inside + WebPagePrivate::setDefaultLayoutSize(), in this way, the layout is + outside of the code path of "needsLayout" so that the contents are + not rendered into the backing store. This is a regression of r108718, + switch back to do the layout inside the public API + WebPage::setDefaultLayoutSize(). + + We haven't upstreamed the manual tests directory yet, therefore, + the new manual test case will be upstreamed later. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::setDefaultLayoutSize): + (BlackBerry::WebKit::WebPage::setDefaultLayoutSize): + +2012-03-06 Lianghui Chen <liachen@rim.com> + + [BlackBerry] Set correct ResourceRequest target type. + https://bugs.webkit.org/show_bug.cgi?id=80430 + + Reviewed by Rob Buis. + + Removed unused code in dispatchWillSendRequest(). These codes are too + late as the target type has already been referred to when calling + ResourceRequest::initializePlatformRequest(). + + * WebCoreSupport/FrameLoaderClientBlackBerry.cpp: + (WebCore::FrameLoaderClientBlackBerry::dispatchWillSendRequest): + +2012-03-06 Lianghui Chen <liachen@rim.com> + + [BlackBerry] Remove unused and unneeded WebPageClient::downloadRequested(NetworkRequest&) + https://bugs.webkit.org/show_bug.cgi?id=80438 + + Reviewed by Antonio Gomes. + + * Api/WebPageClient.h: + +2012-03-06 Jakob Petsovits <jpetsovits@rim.com> + + [BlackBerry] Don't suspend accel comp when backgrounding a page. + https://bugs.webkit.org/show_bug.cgi?id=80369 + RIM PR: 137609 + + Reviewed by Adam Treat. + + Just because the page is in the background doesn't mean + it's invisible, doesn't mean it won't have to be redrawn + at some point - on rotation, for instance. + + We still suspend accelerated compositing on setVisible(false). + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPage::notifyPageBackground): + (BlackBerry::WebKit::WebPage::notifyPageForeground): + +2012-03-06 Jonathan Dong <jonathan.dong@torchmobile.com.cn> + + [BlackBerry] function rename issue after MediaPlayerPrivateBlackBerry.[cpp\h] upstream + https://bugs.webkit.org/show_bug.cgi?id=80377 + + Reviewed by Rob Buis. + + As some of the function names changed in class MediaPlayerPrivate + with the upstream of MediaPlayerPrivateBlackBerry.[cpp|h], we + should update WebKit/blackberry/Api/WebPage.cpp which uses these + functions accordingly. + Renamed functions in class MediaPlayerPrivate: + windowGet() -> getWindow() + windowPositionGet() -> getWindowPosition() + mmrContextNameGet() -> mmrContextName() + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::enterFullscreenForNode): + +2012-03-05 Eli Fidler <efidler@rim.com> + + The minimum font size WebSetting should actually change the LOGICAL font size in WebCore. + https://bugs.webkit.org/show_bug.cgi?id=80312 + RIM PR: 139874 + + Reviewed by George Staikos. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::didChangeSettings): + +2012-03-05 Jakob Petsovits <jpetsovits@rim.com> + + Make accelerated compositing work again with direct rendering. + https://bugs.webkit.org/show_bug.cgi?id=80181 + RIM PR: 139110 + + Reviewed by Antonio Gomes. + Internally reviewed by Arvid Nilsson. + + The significant amount of refactoring and optimization work + that has gone into accelerated compositing missed out on + some of the code paths that are being used in direct rendering. + + Animations were relying on blitVisibleContents() only (which + is a no-op in direct rendering mode). There were early returns + which are suitable to determine whether screen contents need + to be updated at all; however, when we're already forcing a + re-render then those checks would cause the composition surface + not to appear at all, or avoid drawing new animation frames. + + We went through dispatchMessage(), potentially causing + mismatches between rendered (but not yet posted) back content + and layers composited on top of it. As we're rendering onto + the sole target surface (the window) directly and posting + from the same thread, we have to wait for compositing on the + UI thread to finish before posting the window. + + In turn, this patch combines both drawSubLayers() and + blendCompositingSurface() calls into one method, reducing + the number of messages to the UI thread within + renderDirectToWindow() to one. + + blendCompositingMessage() in renderDirectToScreen() was called + with contents coordinates rather than viewport coordinates. + That caused some of the composited content to be cut off when + the scroll position wasn't (0, 0). + + We called copyPreviousContentsToBackSurfaceOfWindow() twice for + one frame, in both renderDirectToWindow() and invalidateWindow(). + Only one of those (the latter one) is necessary. + + * Api/BackingStore.cpp: + (BlackBerry::WebKit::BackingStorePrivate::BackingStorePrivate): + (BlackBerry::WebKit::BackingStorePrivate::renderDirectToWindow): + (BlackBerry::WebKit::BackingStorePrivate::drawSubLayers): + (WebKit): + (BlackBerry::WebKit::BackingStorePrivate::drawAndBlendLayersForDirectRendering): + * Api/BackingStore.h: + (WebKit): + * Api/BackingStore_p.h: + (BackingStorePrivate): + (BlackBerry::WebKit::BackingStorePrivate::isDirectRenderingAnimationMessageScheduled): + (BlackBerry::WebKit::BackingStorePrivate::setDirectRenderingAnimationMessageScheduled): + * Api/WebPage_p.h: + (BlackBerry::WebKit::WebPagePrivate::isAcceleratedCompositingActive): + (WebPagePrivate): + * WebKitSupport/WebPageCompositor.cpp: + (BlackBerry::WebKit::WebPageCompositor::WebPageCompositor): + (BlackBerry::WebKit::WebPageCompositor::~WebPageCompositor): + (BlackBerry::WebKit::WebPageCompositor::drawLayers): + (BlackBerry::WebKit::WebPageCompositor::animationTimerFired): + * WebKitSupport/WebPageCompositor.h: + (WebPageCompositor): + +2012-03-05 George Staikos <gstaikos@rim.com> + + [BlackBerry] DOMSupport visibleSelectionForRangeInputElement incorrectly dereferences a null range. + https://bugs.webkit.org/show_bug.cgi?id=80274 + + Reviewed by Antonio Gomes. + + A null range can be returned so we should not blindly deref it. + Reviewed Internally by Mike Fenton. + + * WebKitSupport/DOMSupport.cpp: + (BlackBerry::WebKit::DOMSupport::visibleSelectionForRangeInputElement): + +2012-03-04 Jonathan Dong <jonathan.dong@torchmobile.com.cn> + + [BlackBerry] upstream CredentialManager and CredentialTransformData implementation + https://bugs.webkit.org/show_bug.cgi?id=80107 + + Reviewed by Antonio Gomes. + + Initial upstream of CredentialManager.[h|cpp] and + CredentialTransformData.[h|cpp]. + No new test. + + * WebCoreSupport/CredentialManager.cpp: Added. + (WebCore): + (WebCore::CredentialManager::CredentialManager): + (WebCore::CredentialManager::autofillAuthenticationChallenge): + (WebCore::CredentialManager::autofillPasswordForms): + (WebCore::CredentialManager::saveCredentialIfConfirmed): + * WebCoreSupport/CredentialManager.h: Added. + (WebKit): + (WebCore): + (CredentialManager): + * WebCoreSupport/CredentialTransformData.cpp: Added. + (WebCore::CredentialTransformData::CredentialTransformData): + (WebCore): + (WebCore::CredentialTransformData::url): + (WebCore::CredentialTransformData::credential): + (WebCore::CredentialTransformData::setCredential): + (WebCore::CredentialTransformData::findPasswordFormFields): + * WebCoreSupport/CredentialTransformData.h: Added. + (WebCore): + (CredentialTransformData): + (WebCore::CredentialTransformData::isValid): + (WebCore::CredentialTransformData::protectionSpace): + +2012-03-04 Antonio Gomes <agomes@rim.com> + + [BlackBerry] Fixed positioned element not correctly positioned after orientation change, when viewport metatag is used + https://bugs.webkit.org/show_bug.cgi?id=80228 + PR #138865 + + Reviewed by George Staikos. + + Viewport size changes in two main scenarios: + - orientation changes; + - virtual keyboard pop up/hide. + + When we are setting a new viewport size, we need to + update the FixedReportedSize of the mainframe. This size + is used to return innerWidth|Heigth as well as to calculate + the fixed position elements height relative to the RenderView [1]. + + [1] RenderBox::containingBlockLogicalHeightForPositioned. + + When we are rotating, we need to delay setting the new FixedReportedSize + till we layout and are able to figure out the new contents size. At this + time we call setFixedReportedSize, but we do not reposition the fixed elemts + afterwards. + + Patch adds a call to FrameView::repaintFixedElementsAfterScrolling, after + setting the new size. + + Source/WebKit/blackberry: + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::setViewportSize): + +2012-03-02 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Expose WebInspector state to client and clean up WebSettings + https://bugs.webkit.org/show_bug.cgi?id=80177 + + Reviewed by Antonio Gomes. + + Expose the Web Inspector state to WebPage client's and + re-order initialization of WebSettings to be alphabetical + matching their definitions. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPage::isWebInspectorEnabled): + * Api/WebPage.h: + * Api/WebSettings.cpp: + (BlackBerry::WebKit::WebSettings::standardSettings): + +2012-03-02 Arvid Nilsson <anilsson@rim.com> + + Accelerated compositing: Checkerboard never goes away + https://bugs.webkit.org/show_bug.cgi?id=79020 + RIM PR #134164 + + Reviewed by Adam Treat. + + Checkerboard appears in accelerated compositing layers when there's no + texture for (part of) a layer. The layer renderer queues up some render + jobs and schedules a commit to make the WebKit thread process those + jobs. Render jobs performed during commit cause texture upload jobs to + be scheduled on the UI thread. Texture uploads are performed when next + drawing the layers. + + Unfortunately, sometimes commit operation happens without a subsequent + call draw the layers. + + In order to implement one-shot drawing sync, I added a call to + commitRootLayerIfNeeded() in BackingStore::renderContents(), and + I was lucky that most of the time, renderContents() is followed by + blit(Visible)Contents() which in turn draws the layers. + However, render is not always followed by a blit, for example when + rendering offscreen tiles in BackingStore::renderOnIdle(), and in + direct rendering mode. + + Fixed by making sure that every call to commitRootLayerIfNeeded() that + returns true is followed by a call to drawLayersOnCommit(), unless a + blit was requested already. + + Also tweak the logic for one-shot drawing sync to make the code in + drawLayersOnCommit() reusable outside of rootLayerCommitTimerFired(). + + * Api/BackingStore.cpp: + (BlackBerry::WebKit::BackingStorePrivate::BackingStorePrivate): + (BlackBerry::WebKit::BackingStorePrivate::renderOnTimer): + (BlackBerry::WebKit::BackingStorePrivate::renderOnIdle): + (BlackBerry::WebKit::BackingStorePrivate::willFireTimer): + (BlackBerry::WebKit::BackingStorePrivate::renderDirectToWindow): + (BlackBerry::WebKit::BackingStorePrivate::render): + (BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents): + (BlackBerry::WebKit::BackingStorePrivate::blitContents): + (BlackBerry::WebKit::BackingStorePrivate::renderContents): + (WebKit): + (BlackBerry::WebKit::BackingStorePrivate::drawLayersOnCommitIfNeeded): + * Api/BackingStore_p.h: + (BackingStorePrivate): + (BlackBerry::WebKit::BackingStorePrivate::willDrawLayersOnCommit): + +2012-03-02 Adam Treat <atreat@rim.com> + + https://bugs.webkit.org/show_bug.cgi?id=80161 + PR: 141157 + + BlackBerryPlatformScreen.h API has been updated. Reflect those + changes in our usage. + + Reviewed by Antonio Gomes. + Internally reviewed by Jakob Petsovits. + + * Api/BackingStore.cpp: + (BlackBerry::WebKit::BackingStorePrivate::tileWidth): + (BlackBerry::WebKit::BackingStorePrivate::tileHeight): + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::init): + (BlackBerry::WebKit::WebPagePrivate::transformedViewportSize): + (BlackBerry::WebKit::WebPagePrivate::fixedLayoutSize): + (BlackBerry::WebKit::WebPagePrivate::recomputeVirtualViewportFromViewportArguments): + (BlackBerry::WebKit::WebPagePrivate::setDefaultLayoutSize): + (BlackBerry::WebKit::WebPagePrivate::defaultMaxLayoutSize): + * WebCoreSupport/FrameLoaderClientBlackBerry.cpp: + (WebCore::FrameLoaderClientBlackBerry::restoreViewState): + * WebKitSupport/SurfacePool.cpp: + (BlackBerry::WebKit::createCompositingSurface): + +2012-03-02 Konrad Piascik <kpiascik@rim.com> + + [BlackBerry] Set the devicePixelRatio from the results of computeViewportAttributes + https://bugs.webkit.org/show_bug.cgi?id=80160 + + Reviewed by Antonio Gomes. + + Tested by going to layout test fast/viewport/viewport-95.html and viewport-93.html + Previously when executing window.devicePixelRatio these two pages returned 1 now + they report the devicePixelRatio returned by computeViewportAttributes. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::recomputeVirtualViewportFromViewportArguments): + +2012-03-02 Jacky Jiang <zhajiang@rim.com> + + Fix a warning in InputHandler::learnText() + https://bugs.webkit.org/show_bug.cgi?id=80049 + + Reviewed by Antonio Gomes. + + Fix a warning of the comparison "textInField.length() <= + MaxLearnTextDataSize" in InputHandler::learnText(). + + Rubber-stamped internally by Mike Fenton. + + * WebKitSupport/InputHandler.cpp: + (BlackBerry::WebKit::InputHandler::learnText): + +2012-03-01 Andy Chen <andchen@rim.com> + + [BlackBerry] Implement features for find-in-page + https://bugs.webkit.org/show_bug.cgi?id=79820 + + Reviewed by Antonio Gomes. + + - Make it be able to search text around the whole page instead of single frame. + - Make it be able to start new search from active selection and last active match. + + No new tests as this patch doesn't change behavior. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPagePrivate::frameUnloaded): + * Api/WebPage_p.h: + * WebCoreSupport/FrameLoaderClientBlackBerry.cpp: + (WebCore::FrameLoaderClientBlackBerry::dispatchWillClose): + (WebCore::FrameLoaderClientBlackBerry::detachedFromParent2): + * WebKitSupport/DOMSupport.cpp: + (BlackBerry::WebKit::DOMSupport::incrementFrame): + * WebKitSupport/DOMSupport.h: + * WebKitSupport/InPageSearchManager.cpp: + (BlackBerry::WebKit::InPageSearchManager::findNextString): + (BlackBerry::WebKit::InPageSearchManager::shouldSearchForText): + (BlackBerry::WebKit::InPageSearchManager::findAndMarkText): + (BlackBerry::WebKit::InPageSearchManager::setMarkerActive): + (BlackBerry::WebKit::InPageSearchManager::frameUnloaded): + * WebKitSupport/InPageSearchManager.h: + * WebKitSupport/InputHandler.cpp: + (BlackBerry::WebKit::InputHandler::frameUnloaded): + * WebKitSupport/InputHandler.h: + +2012-03-01 Charles Wei <charles.wei@torchmobile.com.cn> + + [BlackBerry] Web Notification crashes the browser. + https://bugs.webkit.org/show_bug.cgi?id=79897 + + Reviewed by Antonio Gomes. + + The reason of the crash is that it still uses the iterator + after been removed from the container, which invalidates the + iterator. + We should stop processing after we have found the element + and removed from the container through the iterator. + + This patch only fixes the crash issue, but not any notification + functionality issue, which is tracked seperatly. + + Test case: http://sandbox.gtaero.net/chrome/notifications.php + + * WebCoreSupport/NotificationPresenterImpl.cpp: + (WebKit::NotificationPresenterImpl::onPermission): + (WebKit::NotificationPresenterImpl::notificationClicked): + +2012-03-01 Mike Fenton <mifenton@rim.com> + + Autocomplete attribute should apply to textarea's. + https://bugs.webkit.org/show_bug.cgi?id=79929 + + Reviewed by Antonio Gomes. + + Add local static Qualified name for autocorrect attribute. + + * WebKitSupport/DOMSupport.cpp: + (BlackBerry::WebKit::DOMSupport::elementSupportsAutocorrect): + +2012-02-29 Mike Fenton <mifenton@rim.com> + + Autocomplete attribute should apply to textarea's. + https://bugs.webkit.org/show_bug.cgi?id=79929 + + Reviewed by Antonio Gomes. + + Allow the autocomplete attribute to bubble back to the form setting. + + Expand support to include checking autocorrect, autocomplete and + name/id matching to text areas. + + Reviewed internally by Nima Ghanavatian and Gen Mak. + + * WebKitSupport/DOMSupport.cpp: + (BlackBerry::WebKit::DOMSupport::elementSupportsAutocorrect): + (BlackBerry::WebKit::DOMSupport::elementSupportsAutocomplete): + (BlackBerry::WebKit::DOMSupport::elementAttributeState): + * WebKitSupport/DOMSupport.h: + * WebKitSupport/InputHandler.cpp: + (BlackBerry::WebKit::inputStyle): + +2012-02-29 Max Feil <mfeil@rim.com> + + [BlackBerry] Add support for FLAC audio and OGG/Vorbis audio + https://bugs.webkit.org/show_bug.cgi?id=79519 + + Reviewed by Antonio Gomes. + + * Api/WebSettings.cpp: + (BlackBerry::WebKit::mimeTypeAssociationMap): + +2012-02-28 Konrad Piascik <kpiascik@rim.com> + + [BlackBerry] Change the API to use std::string + https://bugs.webkit.org/show_bug.cgi?id=79818 + + Reviewed by Antonio Gomes. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPage::dispatchInspectorMessage): + * Api/WebPage.h: + +2012-02-28 Jacky Jiang <zhajiang@rim.com> + + [BlackBerry] x86 build fix after cleaning up WebPage.cpp + https://bugs.webkit.org/show_bug.cgi?id=79814 + + Reviewed by Antonio Gomes. + + x86 build fix, keep WebPage::destroyWebPageCompositor() method where it + was which was outside of USE(ACCELERATED_COMPOSITING). + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPage::destroyWebPageCompositor): + (WebKit): + +2012-02-28 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Remove unused focusedNodeChange notifications from the Chrome client. + https://bugs.webkit.org/show_bug.cgi?id=79794 + + Reviewed by Rob Buis. + + Remove unused notification for focusedNodeChanged. + + Internally reviewed by Gen Mak. + + * Api/WebPageClient.h: + * WebCoreSupport/ChromeClientBlackBerry.cpp: + (WebCore::ChromeClientBlackBerry::focusedNodeChanged): + +2012-02-27 Jacky Jiang <zhajiang@rim.com> + + [BlackBerry] Upstream BlackBerry API web page related files + https://bugs.webkit.org/show_bug.cgi?id=74380 + + Reviewed by Antonio Gomes. + + Clean up WebPage.{h, cpp} and WebPage_p.h. + - Remove WebPage::mainFrame() as it is bad to expose WebCore::Frame in + the public API, adapt to the change by adding a new method + WebPagePrivate::core(Const WebPage*) and expose it to + DumpRenderTreeSupport. + - Rename WebPage::spellCheckingEnabled to + WebPage::setSpellCheckingEnabled. + - Remove unused WebPage::focusNodeRect(). + - Remove extra blank lines. + - Put WebPage methods and their associated WebPagePrivate methods + together. + + No new tests as this patch doesn't change behavior. + + * Api/WebPage.cpp: + (BlackBerry::WebKit::WebPage::WebPage): + (WebKit): + (BlackBerry::WebKit::WebPage::~WebPage): + (BlackBerry::WebKit::WebPagePrivate::core): + (BlackBerry::WebKit::WebPage::load): + (BlackBerry::WebKit::WebPage::loadExtended): + (BlackBerry::WebKit::WebPage::loadFile): + (BlackBerry::WebKit::WebPage::download): + (BlackBerry::WebKit::WebPage::loadString): + (BlackBerry::WebKit::WebPage::executeJavaScript): + (BlackBerry::WebKit::WebPage::executeJavaScriptInIsolatedWorld): + (BlackBerry::WebKit::WebPage::stopLoading): + (BlackBerry::WebKit::WebPage::prepareToDestroy): + (BlackBerry::WebKit::WebPage::setScrollPosition): + (BlackBerry::WebKit::WebPage::scrollBy): + (BlackBerry::WebKit::WebPage::notifyInRegionScrollStatusChanged): + (BlackBerry::WebKit::WebPage::zoomToFitScale): + (BlackBerry::WebKit::WebPage::initialScale): + (BlackBerry::WebKit::WebPage::maximumScale): + (BlackBerry::WebKit::WebPage::scrollPosition): + (BlackBerry::WebKit::WebPage::viewportSize): + (BlackBerry::WebKit::WebPage::activeNodeContext): + (BlackBerry::WebKit::WebPage::assignFocus): + (BlackBerry::WebKit::WebPage::blockZoomAnimationFinished): + (BlackBerry::WebKit::WebPage::onInputLocaleChanged): + (BlackBerry::WebKit::WebPage::setScreenOrientation): + (BlackBerry::WebKit::WebPage::applyPendingOrientationIfNeeded): + (BlackBerry::WebKit::WebPage::setViewportSize): + (BlackBerry::WebKit::WebPage::setDefaultLayoutSize): + (BlackBerry::WebKit::WebPage::setScrollOriginPoint): + (BlackBerry::WebKit::WebPage::textEncoding): + (BlackBerry::WebKit::WebPage::forcedTextEncoding): + (BlackBerry::WebKit::WebPage::setForcedTextEncoding): + (BlackBerry::WebKit::WebPage::setSpellCheckingEnabled): + (BlackBerry::WebKit::parentLayer): + (BlackBerry::WebKit::WebPagePrivate::inRegionScrollableAreasForPoint): + (BlackBerry::WebKit::WebPage::destroyWebPageCompositor): + * Api/WebPage.h: + (WebCore): + (WebKit): + * Api/WebPage_p.h: + (WebCore): + (WebKit): + * WebKitSupport/DumpRenderTreeSupport.cpp: + (DumpRenderTreeSupport::corePage): + (DumpRenderTreeSupport::numberOfPendingGeolocationPermissionRequests): + (DumpRenderTreeSupport::resetGeolocationMock): + (DumpRenderTreeSupport::setMockGeolocationError): + (DumpRenderTreeSupport::setMockGeolocationPermission): + (DumpRenderTreeSupport::setMockGeolocationPosition): + (DumpRenderTreeSupport::scalePageBy): + * WebKitSupport/DumpRenderTreeSupport.h: + (WebCore): + (DumpRenderTreeSupport): + +2012-02-27 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Selection handling should be entirely directional + https://bugs.webkit.org/show_bug.cgi?id=79692 + + Reviewed by Antonio Gomes. + + Make all VisibleSelections directional. + + * WebKitSupport/SelectionHandler.cpp: + (BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection): + (BlackBerry::WebKit::SelectionHandler::setSelection): + +2012-02-27 Ed Baker <edbaker@rim.com> + + [BlackBerry] Dragging a selection handle outside of the content bounding box does not update the selection range correctly + https://bugs.webkit.org/show_bug.cgi?id=78608 + + Ensure that when selection handles leave the content bounding box that + the handle not being dragged remains fixed. Do not apply padding to a + direction that would cause the selection to shrink when performing the + handle direction detection. + + Reviewed by Antonio Gomes. + + * WebKitSupport/DOMSupport.cpp: + (BlackBerry::WebKit::DOMSupport::convertPointToFrame): + * WebKitSupport/DOMSupport.h: + * WebKitSupport/SelectionHandler.cpp: + (BlackBerry::WebKit::clamp): + (BlackBerry::WebKit::directionalVisiblePositionAtExtentOfBox): + (BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary): + (BlackBerry::WebKit::SelectionHandler::setSelection): + (BlackBerry::WebKit::SelectionHandler::clipPointToVisibleContainer): + * WebKitSupport/SelectionHandler.h: + +2012-02-27 Leo Yang <leo.yang@torchmobile.com.cn> + + [BlackBerry] Upstream accelerated compositing helper class + https://bugs.webkit.org/show_bug.cgi?id=78448 + + Reviewed by Antonio Gomes. + + Initial upstream, no new tests. + + * WebKitSupport/FrameLayers.cpp: Added. + * WebKitSupport/FrameLayers.h: Added. + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/ChromeClientBlackBerry.h: + (ChromeClientBlackBerry): + +2012-02-24 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Eliminate excessive BlackBerry::Platform use in InputHandler + https://bugs.webkit.org/show_bug.cgi?id=79393 + + Reviewed by Antonio Gomes. + + Cleanup usage of BlackBerry::Platform in InputHandler. + + * WebKitSupport/InputHandler.cpp: + (BlackBerry::WebKit::convertStringToWchar): + (BlackBerry::WebKit::convertStringToWcharVector): + (BlackBerry::WebKit::convertSpannableStringToString): + (BlackBerry::WebKit::InputHandler::learnText): + (BlackBerry::WebKit::InputHandler::setElementUnfocused): + (BlackBerry::WebKit::InputHandler::shouldAcceptInputFocus): + (BlackBerry::WebKit::InputHandler::setElementFocused): + (BlackBerry::WebKit::InputHandler::nodeTextChanged): + (BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible): + (BlackBerry::WebKit::InputHandler::frameUnloaded): + (BlackBerry::WebKit::InputHandler::selectionChanged): + (BlackBerry::WebKit::InputHandler::setSelection): + (BlackBerry::WebKit::InputHandler::handleKeyboardInput): + (BlackBerry::WebKit::InputHandler::deleteTextRelativeToCursor): + (BlackBerry::WebKit::InputHandler::deleteText): + (BlackBerry::WebKit::InputHandler::spannableTextInRange): + (BlackBerry::WebKit::InputHandler::setComposingRegion): + (BlackBerry::WebKit::InputHandler::finishComposition): + (BlackBerry::WebKit::InputHandler::setText): + (BlackBerry::WebKit::InputHandler::setTextAttributes): + (BlackBerry::WebKit::InputHandler::setRelativeCursorPosition): + (BlackBerry::WebKit::InputHandler::setSpannableTextAndRelativeCursor): + (BlackBerry::WebKit::InputHandler::setComposingText): + (BlackBerry::WebKit::InputHandler::commitText): + +2012-02-24 Mike Fenton <mifenton@rim.com> + + [BlackBerry] Eliminate excessive BlackBerry::Platform use in SelectionHandler. + https://bugs.webkit.org/show_bug.cgi?id=79391 + + Reviewed by Antonio Gomes. + + Clean up usage of BlackBerry::Platform in SelectionHandler and + explicitly define what namespace to use for ambiguous objects like + IntRect and IntPoint. + + * WebKitSupport/SelectionHandler.cpp: + (BlackBerry::WebKit::SelectionHandler::cancelSelection): + (BlackBerry::WebKit::SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection): + (BlackBerry::WebKit::visiblePositionForPointIgnoringClipping): + (BlackBerry::WebKit::directionOfPointRelativeToRect): + (BlackBerry::WebKit::SelectionHandler::shouldUpdateSelectionOrCaretForPoint): + (BlackBerry::WebKit::SelectionHandler::setCaretPosition): + (BlackBerry::WebKit::directionalVisiblePositionAtExtentOfBox): + (BlackBerry::WebKit::pointIsOutsideOfBoundingBoxInDirection): + (BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary): + (BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection): + (BlackBerry::WebKit::SelectionHandler::clipPointToFocusNode): + (BlackBerry::WebKit::SelectionHandler::setSelection): + (BlackBerry::WebKit::SelectionHandler::selectAtPoint): + (BlackBerry::WebKit::SelectionHandler::selectObject): + (BlackBerry::WebKit::comparePointsToReferencePoint): + (BlackBerry::WebKit::minXMinYCorner): + (BlackBerry::WebKit::maxXMinYCorner): + (BlackBerry::WebKit::minXMaxYCorner): + (BlackBerry::WebKit::maxXMaxYCorner): + (BlackBerry::WebKit::caretLocationForRect): + (BlackBerry::WebKit::caretComparisonPointForRect): + (BlackBerry::WebKit::adjustCaretRects): + (BlackBerry::WebKit::SelectionHandler::clipRegionToVisibleContainer): + (BlackBerry::WebKit::referencePoint): + (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged): + (BlackBerry::WebKit::SelectionHandler::caretPositionChanged): + (BlackBerry::WebKit::SelectionHandler::selectionContains): + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp b/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp index b12f49b21..3fc4afb62 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp +++ b/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp @@ -43,7 +43,6 @@ #include "KURL.h" #include "Node.h" #include "NotImplemented.h" -#include "NotificationPresenterImpl.h" #include "Page.h" #include "PageGroup.h" #include "PageGroupLoadDeferrer.h" @@ -188,85 +187,9 @@ void ChromeClientBlackBerry::takeFocus(FocusDirection) notImplemented(); } -void ChromeClientBlackBerry::focusedNodeChanged(Node* node) -{ - WebPageClient::FocusType type = WebPageClient::FocusUnknown; - - if (!node) - type = WebPageClient::FocusNone; - else if (node->isSVGElement()) - type = WebPageClient::FocusSVGElement; - else if (node->isHTMLElement()) { - if (node->hasTagName(HTMLNames::aTag)) { - type = WebPageClient::FocusLink; - } else if (node->hasTagName(HTMLNames::inputTag)) { - HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(node); - if (inputElement->hasTagName(HTMLNames::isindexTag) || inputElement->isInputTypeHidden()) - type = WebPageClient::FocusInputUnknown; - else if (inputElement->isTextButton()) - type = WebPageClient::FocusInputButton; - else if (inputElement->isCheckbox()) - type = WebPageClient::FocusInputCheckBox; -#if ENABLE(INPUT_COLOR) - else if (inputElement->isColorControl()) - type = WebPageClient::FocusInputColor; -#endif - else if (inputElement->isDateControl()) - type = WebPageClient::FocusInputDate; - else if (inputElement->isDateTimeControl()) - type = WebPageClient::FocusInputDateTime; - else if (inputElement->isDateTimeLocalControl()) - type = WebPageClient::FocusInputDateTimeLocal; - else if (inputElement->isEmailField()) - type = WebPageClient::FocusInputEmail; - else if (inputElement->isFileUpload()) - type = WebPageClient::FocusInputFile; - else if (inputElement->isImageButton()) - type = WebPageClient::FocusInputImage; - else if (inputElement->isMonthControl()) - type = WebPageClient::FocusInputMonth; - else if (inputElement->isNumberField()) - type = WebPageClient::FocusInputNumber; - else if (inputElement->isPasswordField()) - type = WebPageClient::FocusInputPassword; - else if (inputElement->isRadioButton()) - type = WebPageClient::FocusInputRadio; - else if (inputElement->isRangeControl()) - type = WebPageClient::FocusInputRange; - else if (inputElement->isResetButton()) - type = WebPageClient::FocusInputReset; - else if (inputElement->isSearchField()) - type = WebPageClient::FocusInputSearch; - else if (inputElement->isSubmitButton()) - type = WebPageClient::FocusInputSubmit; - else if (inputElement->isTelephoneField()) - type = WebPageClient::FocusInputTelephone; - else if (inputElement->isURLField()) - type = WebPageClient::FocusInputURL; - else if (inputElement->isTextField()) - type = WebPageClient::FocusInputText; - else if (inputElement->isTimeControl()) - type = WebPageClient::FocusInputTime; - // FIXME: missing WEEK popup selector - else - type = WebPageClient::FocusInputUnknown; - } else if (node->hasTagName(HTMLNames::imgTag)) - type = WebPageClient::FocusImage; - else if (node->hasTagName(HTMLNames::objectTag)) - type = WebPageClient::FocusObject; - else if (node->hasTagName(HTMLNames::videoTag)) - type = WebPageClient::FocusVideo; - else if (node->hasTagName(HTMLNames::selectTag)) - type = WebPageClient::FocusSelect; - else if (node->hasTagName(HTMLNames::textareaTag)) - type = WebPageClient::FocusTextArea; - else if (node->hasTagName(HTMLNames::canvasTag)) - type = WebPageClient::FocusCanvas; - } - - m_webPagePrivate->m_inputHandler->nodeFocused(node); - - m_webPagePrivate->m_client->focusChanged(type, reinterpret_cast<int>(node)); +void ChromeClientBlackBerry::focusedNodeChanged(Node*) +{ + m_webPagePrivate->m_inputHandler->focusedNodeChanged(); } void ChromeClientBlackBerry::focusedFrameChanged(Frame*) @@ -801,13 +724,6 @@ void ChromeClientBlackBerry::didSetSVGZoomAndPan(Frame* frame, unsigned short zo } #endif -#if ENABLE(NOTIFICATIONS) -NotificationPresenter* ChromeClientBlackBerry::notificationPresenter() const -{ - return WebKit::NotificationPresenterImpl::instance(); -} -#endif - #if USE(ACCELERATED_COMPOSITING) void ChromeClientBlackBerry::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer) { diff --git a/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h b/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h index 99c8b6062..b24d39c80 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h +++ b/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h @@ -128,10 +128,6 @@ public: virtual void requestWebGLPermission(Frame*); #endif -#if ENABLE(NOTIFICATIONS) - virtual NotificationPresenter* notificationPresenter() const; -#endif - #if ENABLE(SVG) virtual void didSetSVGZoomAndPan(Frame*, unsigned short zoomAndPan); #endif @@ -139,7 +135,6 @@ public: virtual bool selectItemAlignmentFollowsMenuWritingDirection(); virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; - virtual void showContextMenu() { } #if USE(ACCELERATED_COMPOSITING) virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*); diff --git a/Source/WebKit/blackberry/WebCoreSupport/CredentialManager.cpp b/Source/WebKit/blackberry/WebCoreSupport/CredentialManager.cpp new file mode 100644 index 000000000..97e7de6f8 --- /dev/null +++ b/Source/WebKit/blackberry/WebCoreSupport/CredentialManager.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST) +#include "CredentialManager.h" + +#include "CredentialBackingStore.h" +#include "CredentialTransformData.h" +#include "FrameLoaderClientBlackBerry.h" +#include "HTMLFormElement.h" +#include "KURL.h" +#include "Logging.h" +#include "WebPageClient.h" +#include "WebPage_p.h" +#include "WebString.h" + +using BlackBerry::WebKit::WebPageClient; +using BlackBerry::WebKit::WebString; + +namespace WebCore { + +CredentialManager::CredentialManager(FrameLoaderClientBlackBerry* frameLoaderClient) + : m_frameLoaderClient(frameLoaderClient) +{ + ASSERT(m_frameLoaderClient); +} + +void CredentialManager::autofillAuthenticationChallenge(const ProtectionSpace& protectionSpace, WebString& username, WebString& password) +{ + if (CredentialBackingStore::instance()->hasNeverRemember(protectionSpace)) + return; + + Credential savedCredential = CredentialBackingStore::instance()->getLogin(protectionSpace); + username = savedCredential.user(); + password = savedCredential.password(); +} + +void CredentialManager::autofillPasswordForms(PassRefPtr<HTMLCollection> docForms) +{ + ASSERT(docForms); + + RefPtr<HTMLCollection> forms = docForms; + size_t sourceLength = forms->length(); + for (size_t i = 0; i < sourceLength; ++i) { + Node* node = forms->item(i); + if (node && node->isHTMLElement()) { + CredentialTransformData data(static_cast<HTMLFormElement*>(node)); + if (!data.isValid() || !CredentialBackingStore::instance()->hasLogin(data.url(), data.protectionSpace())) + continue; + Credential savedCredential = CredentialBackingStore::instance()->getLogin(data.url()); + data.setCredential(savedCredential); + } + } +} + +void CredentialManager::saveCredentialIfConfirmed(const CredentialTransformData& data) +{ + if (!data.isValid() || data.credential().isEmpty() || CredentialBackingStore::instance()->hasNeverRemember(data.protectionSpace())) + return; + + Credential savedCredential = CredentialBackingStore::instance()->getLogin(data.url()); + if (savedCredential == data.credential()) + return; + + WebPageClient::SaveCredentialType type = m_frameLoaderClient->m_webPagePrivate->m_client->notifyShouldSaveCredential(savedCredential.isEmpty()); + if (type == WebPageClient::SaveCredentialYes) { + if (savedCredential.isEmpty()) + CredentialBackingStore::instance()->addLogin(data.url(), data.protectionSpace(), data.credential()); + else + CredentialBackingStore::instance()->updateLogin(data.url(), data.protectionSpace(), data.credential()); + } else if (type == WebPageClient::SaveCredentialNeverForThisSite) { + CredentialBackingStore::instance()->addNeverRemember(data.url(), data.protectionSpace()); + CredentialBackingStore::instance()->removeLogin(data.url(), data.protectionSpace()); + } +} + +} // namespace WebCore + +#endif // ENABLE(BLACKBERRY_CREDENTIAL_PERSIST) diff --git a/Source/WebKit/blackberry/WebCoreSupport/CredentialManager.h b/Source/WebKit/blackberry/WebCoreSupport/CredentialManager.h new file mode 100644 index 000000000..1d39f10c0 --- /dev/null +++ b/Source/WebKit/blackberry/WebCoreSupport/CredentialManager.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef CredentialManager_h +#define CredentialManager_h + +#if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST) + +#include "HTMLCollection.h" +#include <wtf/PassRefPtr.h> + +namespace BlackBerry { +namespace WebKit { +class WebString; +} +} + +namespace WebCore { +class FrameLoaderClientBlackBerry; +class KURL; +class ProtectionSpace; +class CredentialTransformData; + +class CredentialManager { +public: + CredentialManager(FrameLoaderClientBlackBerry*); + + void autofillAuthenticationChallenge(const ProtectionSpace&, BlackBerry::WebKit::WebString& username, BlackBerry::WebKit::WebString& password); + void autofillPasswordForms(PassRefPtr<HTMLCollection> docForms); + void saveCredentialIfConfirmed(const CredentialTransformData&); + +private: + FrameLoaderClientBlackBerry* m_frameLoaderClient; +}; + +} // WebCore + +#endif // ENABLE(BLACKBERRY_CREDENTIAL_PERSIST) + +#endif // CredentialManager_h diff --git a/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.cpp b/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.cpp new file mode 100644 index 000000000..8c22ae2a2 --- /dev/null +++ b/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * This methods are based on Chromium codes in + * Source/WebKit/chromium/src/WebPasswordFormUtils.cpp + */ + +#include "config.h" +#include "CredentialTransformData.h" + +#include "HTMLFormElement.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "KURL.h" +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> + +namespace WebCore { + +namespace { +// Maximum number of password fields we will observe before throwing our +// hands in the air and giving up with a given form. +static const size_t maxPasswords = 3; + +// Helper method to clear url of unneeded parts. +KURL stripURL(const KURL& url) +{ + KURL strippedURL = url; + strippedURL.setUser(String()); + strippedURL.setPass(String()); + strippedURL.setQuery(String()); + strippedURL.setFragmentIdentifier(String()); + return strippedURL; +} + +// Helper method to determine which password is the main one, and which is +// an old password (e.g on a "make new password" form), if any. +bool locateSpecificPasswords(Vector<HTMLInputElement*>& passwords, + HTMLInputElement** password) +{ + ASSERT(password); + + switch (passwords.size()) { + case 1: + // Single password, easy. + *password = passwords[0]; + break; + case 2: + if (passwords[0]->value() == passwords[1]->value()) + // Treat two identical passwords as a single password. + *password = passwords[0]; + else { + // Assume first is old password, second is new (no choice but to guess). + *password = passwords[1]; + } + break; + case 3: + if (passwords[0]->value() == passwords[1]->value() + && passwords[0]->value() == passwords[2]->value()) { + // All three passwords the same? Just treat as one and hope. + *password = passwords[0]; + } else if (passwords[0]->value() == passwords[1]->value()) { + // Two the same and one different -> old password is duplicated one. + *password = passwords[2]; + } else if (passwords[1]->value() == passwords[2]->value()) + *password = passwords[1]; + else { + // Three different passwords, or first and last match with middle + // different. No idea which is which, so no luck. + return false; + } + break; + default: + return false; + } + return true; +} + +} // namespace + +CredentialTransformData::CredentialTransformData(HTMLFormElement* form) + : m_userNameElement(0) + , m_passwordElement(0) + , m_isValid(false) +{ + ASSERT(form); + + // Get the document URL + KURL fullOrigin(ParsedURLString, form->document()->documentURI()); + + // Calculate the canonical action URL + String action = form->action(); + if (action.isNull()) + action = ""; // missing 'action' attribute implies current URL + KURL fullAction = form->document()->completeURL(action); + if (!fullAction.isValid()) + return; + + if (!findPasswordFormFields(form)) + return; + + m_url = stripURL(fullOrigin); + m_action = stripURL(fullAction); + m_protectionSpace = ProtectionSpace(m_url.host(), m_url.port(), ProtectionSpaceServerHTTP, "Form", ProtectionSpaceAuthenticationSchemeHTMLForm); + m_credential = Credential(m_userNameElement->value(), m_passwordElement->value(), CredentialPersistencePermanent); + + m_isValid = true; +} + +CredentialTransformData::CredentialTransformData(const KURL& url, const ProtectionSpace& protectionSpace, const Credential& credential) + : m_url(url) + , m_protectionSpace(protectionSpace) + , m_credential(credential) + , m_userNameElement(0) + , m_passwordElement(0) + , m_isValid(true) +{ +} + +KURL CredentialTransformData::url() const +{ + if (!m_isValid) + return KURL(); + + if (m_protectionSpace.authenticationScheme() == ProtectionSpaceAuthenticationSchemeHTMLForm) + return m_action; + return m_url; +} + +Credential CredentialTransformData::credential() const +{ + if (m_credential.isEmpty() && m_userNameElement && m_passwordElement) + return m_credential = Credential(m_userNameElement->value(), m_passwordElement->value(), CredentialPersistencePermanent); + return m_credential; +} + +void CredentialTransformData::setCredential(const Credential& credential) +{ + if (!m_isValid) + return; + + m_credential = credential; + m_userNameElement->setValue(credential.user()); + m_passwordElement->setValue(credential.password()); +} + +bool CredentialTransformData::findPasswordFormFields(HTMLFormElement* form) +{ + ASSERT(form); + + int firstPasswordIndex = 0; + // First, find the password fields and activated submit button. + const Vector<FormAssociatedElement*>& formElements = form->associatedElements(); + Vector<HTMLInputElement*> passwords; + for (size_t i = 0; i < formElements.size(); i++) { + if (!formElements[i]->isFormControlElement()) + continue; + HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(formElements[i]); + if (!formElement->hasLocalName(HTMLNames::inputTag)) + continue; + + HTMLInputElement* inputElement = formElement->toInputElement(); + if (!inputElement->isEnabledFormControl()) + continue; + + if ((passwords.size() < maxPasswords) + && inputElement->isPasswordField() + && inputElement->shouldAutocomplete()) { + if (passwords.isEmpty()) + firstPasswordIndex = i; + passwords.append(inputElement); + } + } + + if (!passwords.isEmpty()) { + // Then, search backwards for the username field. + for (int i = firstPasswordIndex - 1; i >= 0; i--) { + if (!formElements[i]->isFormControlElement()) + continue; + HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(formElements[i]); + if (!formElement->hasLocalName(HTMLNames::inputTag)) + continue; + + HTMLInputElement* inputElement = formElement->toInputElement(); + if (!inputElement->isEnabledFormControl()) + continue; + + // Various input types such as text, url, email can be a username field. + if ((inputElement->isTextField() && !inputElement->isPasswordField()) + && (inputElement->shouldAutocomplete())) { + m_userNameElement = inputElement; + break; + } + } + } + if (!m_userNameElement) + return false; + + if (!locateSpecificPasswords(passwords, &(m_passwordElement))) + return false; + return true; +} + +} // namespace WebCore diff --git a/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.h b/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.h new file mode 100644 index 000000000..409c5776b --- /dev/null +++ b/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef CredentialTransformData_h +#define CredentialTransformData_h + +#include "Credential.h" +#include "HTMLFormElement.h" +#include "KURL.h" +#include "ProtectionSpace.h" + +namespace WebCore { + +class HTMLFormElement; + +struct CredentialTransformData { + // If the provided form is suitable for password completion, isValid() will + // return true; + CredentialTransformData(HTMLFormElement*); + CredentialTransformData(const KURL&, const ProtectionSpace&, const Credential&); + + // If creation failed, return false. + bool isValid() const { return m_isValid; } + + KURL url() const; + ProtectionSpace protectionSpace() const { return m_protectionSpace; } + Credential credential() const; + void setCredential(const Credential&); + +private: + bool findPasswordFormFields(HTMLFormElement*); + + KURL m_url; + KURL m_action; + ProtectionSpace m_protectionSpace; + mutable Credential m_credential; + HTMLInputElement* m_userNameElement; + HTMLInputElement* m_passwordElement; + bool m_isValid; +}; + +} // namespace WebCore + +#endif diff --git a/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp b/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp index 0e4441d82..356fee9ea 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp +++ b/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp @@ -193,11 +193,9 @@ bool EditorClientBlackBerry::shouldChangeSelectedRange(Range* fromRange, Range* if (frame->document()->focusedNode() && frame->document()->focusedNode()->hasTagName(HTMLNames::selectTag)) return false; - // Update the focus state to re-show the keyboard if needed. - // FIXME, this should be removed and strictly be a show keyboard call if - // focus is active. - if (m_webPagePrivate->m_inputHandler->isInputMode()) - m_webPagePrivate->m_inputHandler->nodeFocused(frame->document()->focusedNode()); + // Check if this change does not represent a focus change and input is active and if so ensure the keyboard is visible. + if (m_webPagePrivate->m_inputHandler->isInputMode() && fromRange && toRange && (fromRange->startContainer() == toRange->startContainer())) + m_webPagePrivate->m_inputHandler->notifyClientOfKeyboardVisibilityChange(true); } return true; @@ -604,25 +602,9 @@ void EditorClientBlackBerry::willSetInputMethodState() notImplemented(); } -void EditorClientBlackBerry::setInputMethodState(bool active) +void EditorClientBlackBerry::setInputMethodState(bool) { - Frame* frame = m_webPagePrivate->focusedOrMainFrame(); - // Determines whether or not to provide input assistance. Password fields - // do not have this flag active, so it needs to be overridden. - if (frame && frame->document()) { - if (Node* focusNode = frame->document()->focusedNode()) { - if (!active && focusNode->hasTagName(HTMLNames::inputTag) - && static_cast<HTMLInputElement*>(focusNode)->isPasswordField()) - active = true; - - if (active) { - m_webPagePrivate->m_inputHandler->nodeFocused(focusNode); - return; - } - } - } - // No frame or document or a node that doesn't support IME. - m_webPagePrivate->m_inputHandler->nodeFocused(0); + m_webPagePrivate->m_inputHandler->focusedNodeChanged(); } } // namespace WebCore diff --git a/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp b/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp index afddd51a3..0eef1f3da 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp +++ b/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp @@ -790,7 +790,7 @@ ObjectContentType FrameLoaderClientBlackBerry::objectContentType(const KURL& url void FrameLoaderClientBlackBerry::dispatchWillClose() { - m_webPagePrivate->m_inputHandler->frameUnloaded(m_frame); + m_webPagePrivate->frameUnloaded(m_frame); } void FrameLoaderClientBlackBerry::setMainDocumentError(DocumentLoader*, const ResourceError& error) @@ -926,7 +926,7 @@ void FrameLoaderClientBlackBerry::detachedFromParent2() if (m_frame->document()) m_webPagePrivate->clearDocumentData(m_frame->document()); - m_webPagePrivate->m_inputHandler->frameUnloaded(m_frame); + m_webPagePrivate->frameUnloaded(m_frame); m_webPagePrivate->m_client->notifyFrameDetached(m_frame); } @@ -969,12 +969,6 @@ void FrameLoaderClientBlackBerry::dispatchWillSendRequest(DocumentLoader* docLoa finalUrl.characters(), finalUrl.length()); } - // FIXME: Update the request type. See PR #119792. - if (docLoader->frameLoader()->isLoadingMainFrame()) - request.setTargetType(ResourceRequest::TargetIsMainFrame); - else - request.setTargetType(ResourceRequest::TargetIsSubframe); - FrameLoader* loader = m_frame->loader(); ASSERT(loader); if (isBackForwardLoadType(loader->loadType())) { @@ -1058,7 +1052,7 @@ void FrameLoaderClientBlackBerry::restoreViewState() // When rotate happens, only zoom when previous page was zoomToFitScale, otherwise keep old scale. if (orientationChanged && viewState.isZoomToFitScale) - scale = BlackBerry::Platform::Graphics::Screen::width() * scale / static_cast<double>(BlackBerry::Platform::Graphics::Screen::height()); + scale = BlackBerry::Platform::Graphics::Screen::primaryScreen()->width() * scale / static_cast<double>(BlackBerry::Platform::Graphics::Screen::primaryScreen()->height()); m_webPagePrivate->m_backingStore->d->suspendScreenAndBackingStoreUpdates(); // don't flash checkerboard for the setScrollPosition call m_frame->view()->setContentsSizeFromHistory(contentsSize); diff --git a/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp b/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp index 505b1801b..16c451ec3 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp +++ b/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp @@ -26,11 +26,10 @@ #include <ScriptExecutionContext.h> #include <UUID.h> -using namespace WebCore; -namespace WebKit { +namespace WebCore { -NotificationPresenter* NotificationPresenterImpl::instance() +NotificationClient* NotificationPresenterImpl::instance() { static NotificationPresenterImpl* s_instance = 0; if (!s_instance) @@ -55,7 +54,7 @@ bool NotificationPresenterImpl::show(Notification* notification) if (m_notifications.contains(n)) return false; - if (checkPermission(notification->scriptExecutionContext()) != NotificationPresenter::PermissionAllowed) + if (checkPermission(notification->scriptExecutionContext()) != NotificationClient::PermissionAllowed) return false; String uuid = createCanonicalUUIDString(); @@ -108,10 +107,10 @@ void NotificationPresenterImpl::onPermission(const std::string& domain, bool isA ASSERT(!domain.empty()); String domainString = String::fromUTF8(domain.c_str()); PermissionRequestMap::iterator it = m_permissionRequests.begin(); - PermissionRequestMap::iterator end = m_permissionRequests.end(); - for (; it != end; ++it) { + for (; it != m_permissionRequests.end(); ++it) { if (it->first->url().host() != domainString) continue; + if (isAllowed) { m_allowedDomains.add(domainString); it->second->handleEvent(); @@ -119,6 +118,7 @@ void NotificationPresenterImpl::onPermission(const std::string& domain, bool isA m_allowedDomains.remove(domainString); m_permissionRequests.remove(it); + return; } } @@ -127,14 +127,14 @@ void NotificationPresenterImpl::cancelRequestsForPermission(ScriptExecutionConte // Because we are using modal dialogs to request permission, it's impossible to cancel them. } -NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context) +NotificationClient::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context) { ASSERT(context); // FIXME: Should store the permission information into file permanently instead of in m_allowedDomains. // The suggested place to do this is in m_platformPresenter->checkPermission(). if (m_allowedDomains.contains(context->url().host())) - return NotificationPresenter::PermissionAllowed; - return NotificationPresenter::PermissionNotAllowed; + return NotificationClient::PermissionAllowed; + return NotificationClient::PermissionNotAllowed; } // This function is called in platform side. @@ -143,11 +143,12 @@ void NotificationPresenterImpl::notificationClicked(const std::string& id) ASSERT(!id.empty()); String idString = String::fromUTF8(id.c_str()); NotificationMap::iterator it = m_notifications.begin(); - NotificationMap::iterator end = m_notifications.end(); - for (; it != end; ++it) { + for (; it != m_notifications.end(); ++it) { if (it->second == idString && it->first->scriptExecutionContext()) { + RefPtr<Notification> notification = it->first; it->first->dispatchEvent(Event::create(eventNames().clickEvent, false, true)); - m_notifications.remove(it); + m_notifications.remove(notification); + return; } } } diff --git a/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h b/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h index e26c15fe2..b708e002e 100644 --- a/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h +++ b/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h @@ -21,7 +21,7 @@ #if ENABLE(NOTIFICATIONS) #include <NotificationAckListener.h> -#include <NotificationPresenter.h> +#include <NotificationClient.h> #include <NotificationPresenterBlackBerry.h> #include <string> #include <wtf/HashMap.h> @@ -29,11 +29,11 @@ #include <wtf/OwnPtr.h> #include <wtf/text/StringHash.h> -namespace WebKit { +namespace WebCore { -class NotificationPresenterImpl : public WebCore::NotificationPresenter, public BlackBerry::Platform::NotificationAckListener { +class NotificationPresenterImpl : public WebCore::NotificationClient, public BlackBerry::Platform::NotificationAckListener { public: - static NotificationPresenter* instance(); + static NotificationClient* instance(); virtual ~NotificationPresenterImpl(); // Requests that a notification be shown. diff --git a/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp b/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp index 9dd5d2117..26c0e6cd2 100644 --- a/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp @@ -173,13 +173,28 @@ bool isColorInputField(const Element* element) return false; } +// This is a Tristate return to allow us to override name matching when +// the attribute is expressly requested for a field. Default indicates +// that the setting is On which is the default but not expressly requested +// for the element being checked. On indicates that it is directly added +// to the element. AttributeState elementSupportsAutocorrect(const Element* element) { + DEFINE_STATIC_LOCAL(QualifiedName, autocorrectAttr, (nullAtom, "autocorrect", nullAtom)); + return elementAttributeState(element, autocorrectAttr); +} + +AttributeState elementSupportsAutocomplete(const Element* element) +{ + return elementAttributeState(element, HTMLNames::autocompleteAttr); +} + +AttributeState elementAttributeState(const Element* element, const QualifiedName& attributeName) +{ // First we check the input item itself. If the attribute is not defined, // we check its parent form. - QualifiedName autocorrectAttr = QualifiedName(nullAtom, "autocorrect", nullAtom); - if (element->fastHasAttribute(autocorrectAttr)) { - AtomicString attributeString = element->fastGetAttribute(autocorrectAttr); + if (element->fastHasAttribute(attributeName)) { + AtomicString attributeString = element->fastGetAttribute(attributeName); if (equalIgnoringCase(attributeString, "off")) return Off; if (equalIgnoringCase(attributeString, "on")) @@ -189,8 +204,8 @@ AttributeState elementSupportsAutocorrect(const Element* element) } if (element->isFormControlElement()) { const HTMLFormControlElement* formElement = static_cast<const HTMLFormControlElement*>(element); - if (formElement->form() && formElement->form()->fastHasAttribute(autocorrectAttr)) { - AtomicString attributeString = formElement->form()->fastGetAttribute(autocorrectAttr); + if (formElement->form() && formElement->form()->fastHasAttribute(attributeName)) { + AtomicString attributeString = formElement->form()->fastGetAttribute(attributeName); if (equalIgnoringCase(attributeString, "off")) return Off; if (equalIgnoringCase(attributeString, "on")) @@ -254,6 +269,10 @@ VisibleSelection visibleSelectionForRangeInputElement(Element* element, int star // Must be content editable, generate the range. RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(element, start, end - start); + + if (!selectionRange) + return VisibleSelection(); + if (start == end) return VisibleSelection(selectionRange.get()->startPosition(), DOWNSTREAM); @@ -285,25 +304,6 @@ bool isPositionInNode(Node* node, const Position& position) return rangeForNode->isPointInRange(domNodeAtPos, offset, ec); } -// This is a Tristate return to allow us to override name matching when -// autocomplete is expressly requested for a field. Default indicates -// that the setting is On which is the default but not expressly requested -// for the element being checked. On indicates that it is directly added -// to the element. -AttributeState elementSupportsAutocomplete(const Element* element) -{ - if (!element->hasTagName(HTMLNames::inputTag)) - return Default; - - const HTMLInputElement* inputElement = static_cast<const HTMLInputElement*>(element); - if (inputElement->fastHasAttribute(HTMLNames::autocompleteAttr)) { - if (equalIgnoringCase(inputElement->fastGetAttribute(HTMLNames::autocompleteAttr), "on")) - return On; - } - - return inputElement->shouldAutocomplete() ? Default : Off; -} - bool matchesReservedStringPreventingAutocomplete(AtomicString& string) { if (string.contains("email", false /* caseSensitive */) @@ -336,7 +336,7 @@ bool elementIdOrNameIndicatesNoAutocomplete(const Element* element) return false; } -IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, const IntPoint& point) +IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, const IntPoint& point, const bool clampToTargetFrame) { ASSERT(sourceFrame && targetFrame); if (sourceFrame == targetFrame) @@ -347,6 +347,7 @@ IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, Frame* targetFrameParent = targetFrame->tree()->parent(); IntRect targetFrameRect = targetFrame->view()->frameRect(); + IntPoint targetPoint = point; // Convert the target frame rect to source window content coordinates. This is only required // if the parent frame is not the source. If the parent is the source, subframeRect @@ -355,11 +356,14 @@ IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, targetFrameRect = sourceFrame->view()->windowToContents(targetFrameParent->view()->contentsToWindow(targetFrameRect)); // Requested point is outside of target frame, return InvalidPoint. - if (!targetFrameRect.contains(point)) + if (clampToTargetFrame && !targetFrameRect.contains(targetPoint)) + targetPoint = IntPoint(targetPoint.x() < targetFrameRect.x() ? targetFrameRect.x() : std::min(targetPoint.x(), targetFrameRect.maxX()), + targetPoint.y() < targetFrameRect.y() ? targetFrameRect.y() : std::min(targetPoint.y(), targetFrameRect.maxY())); + else if (!targetFrameRect.contains(targetPoint)) return InvalidPoint; // Adjust the points to be relative to the target. - return targetFrame->view()->windowToContents(sourceFrame->view()->contentsToWindow(point)); + return targetFrame->view()->windowToContents(sourceFrame->view()->contentsToWindow(targetPoint)); } VisibleSelection visibleSelectionForClosestActualWordStart(const VisibleSelection& selection) @@ -399,6 +403,14 @@ VisibleSelection visibleSelectionForClosestActualWordStart(const VisibleSelectio return selection; } +// This function is copied from WebCore/page/Page.cpp. +Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag) +{ + return forward + ? curr->tree()->traverseNextWithWrap(wrapFlag) + : curr->tree()->traversePreviousWithWrap(wrapFlag); +} + } // DOMSupport } // WebKit } // BlackBerry diff --git a/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h b/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h index 1e0945189..85d9cbfa9 100644 --- a/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h +++ b/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h @@ -35,6 +35,7 @@ class Frame; class HTMLTextFormControlElement; class Node; class Position; +class QualifiedName; class Range; class VisibleSelection; } @@ -54,7 +55,10 @@ bool isPasswordElement(const WebCore::Element*); bool isPopupInputField(const WebCore::Element*); bool isDateTimeInputField(const WebCore::Element*); bool isColorInputField(const WebCore::Element*); + +AttributeState elementAttributeState(const WebCore::Element*, const WebCore::QualifiedName&); AttributeState elementSupportsAutocorrect(const WebCore::Element*); +AttributeState elementSupportsAutocomplete(const WebCore::Element*); WTF::String inputElementText(WebCore::Element*); @@ -69,15 +73,16 @@ WebCore::VisibleSelection visibleSelectionForInputElement(WebCore::Element*); WebCore::Node* DOMContainerNodeForPosition(const WebCore::Position&); bool isPositionInNode(WebCore::Node*, const WebCore::Position&); -AttributeState elementSupportsAutocomplete(const WebCore::Element*); bool elementIdOrNameIndicatesNoAutocomplete(const WebCore::Element*); -WebCore::IntPoint convertPointToFrame(const WebCore::Frame* sourceFrame, const WebCore::Frame* targetFrame, const WebCore::IntPoint& sourcePoint); +WebCore::IntPoint convertPointToFrame(const WebCore::Frame* sourceFrame, const WebCore::Frame* targetFrame, const WebCore::IntPoint& sourcePoint, const bool clampToTargetFrame = false); static const WebCore::IntPoint InvalidPoint = WebCore::IntPoint(-1, -1); WebCore::VisibleSelection visibleSelectionForClosestActualWordStart(const WebCore::VisibleSelection&); +WebCore::Frame* incrementFrame(WebCore::Frame* curr, bool forward, bool wrapFlag); + } // DOMSupport } // WebKit } // BlackBerry diff --git a/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp b/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp index a93005010..c8ede6e5a 100644 --- a/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp @@ -29,7 +29,7 @@ #include "JSElement.h" #include "Page.h" #include "ViewportArguments.h" -#include "WebPage.h" +#include "WebPage_p.h" #include "bindings/js/GCController.h" #include <JavaScriptCore/APICast.h> #include <wtf/CurrentTime.h> @@ -56,6 +56,11 @@ DumpRenderTreeSupport::~DumpRenderTreeSupport() { } +Page* DumpRenderTreeSupport::corePage(WebPage* webPage) +{ + return WebPagePrivate::core(webPage); +} + int DumpRenderTreeSupport::javaScriptObjectsCount() { return JSDOMWindowBase::commonJSGlobalData()->heap.globalObjectCount(); @@ -94,7 +99,7 @@ void DumpRenderTreeSupport::dumpConfigurationForViewport(Frame* mainFrame, int d int DumpRenderTreeSupport::numberOfPendingGeolocationPermissionRequests(WebPage* webPage) { #if ENABLE(CLIENT_BASED_GEOLOCATION) - GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client()); + GeolocationClientMock* mockClient = toGeolocationClientMock(corePage(webPage)->geolocationController()->client()); return mockClient->numberOfPendingPermissionRequests(); #else UNUSED_PARAM(webPage); @@ -105,7 +110,7 @@ int DumpRenderTreeSupport::numberOfPendingGeolocationPermissionRequests(WebPage* void DumpRenderTreeSupport::resetGeolocationMock(WebPage* webPage) { #if ENABLE(CLIENT_BASED_GEOLOCATION) - GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client()); + GeolocationClientMock* mockClient = toGeolocationClientMock(corePage(webPage)->geolocationController()->client()); mockClient->reset(); #endif } @@ -123,7 +128,7 @@ void DumpRenderTreeSupport::setMockGeolocationError(WebPage* webPage, int errorC break; } - GeolocationClientMock* mockClient = static_cast<GeolocationClientMock*>(webPage->mainFrame()->page()->geolocationController()->client()); + GeolocationClientMock* mockClient = static_cast<GeolocationClientMock*>(corePage(webPage)->geolocationController()->client()); mockClient->setError(GeolocationError::create(code, message)); #endif } @@ -131,7 +136,7 @@ void DumpRenderTreeSupport::setMockGeolocationError(WebPage* webPage, int errorC void DumpRenderTreeSupport::setMockGeolocationPermission(WebPage* webPage, bool allowed) { #if ENABLE(CLIENT_BASED_GEOLOCATION) - GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client()); + GeolocationClientMock* mockClient = toGeolocationClientMock(corePage(webPage)->geolocationController()->client()); mockClient->setPermission(allowed); #endif } @@ -139,14 +144,14 @@ void DumpRenderTreeSupport::setMockGeolocationPermission(WebPage* webPage, bool void DumpRenderTreeSupport::setMockGeolocationPosition(WebPage* webPage, double latitude, double longitude, double accuracy) { #if ENABLE(CLIENT_BASED_GEOLOCATION) - GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client()); + GeolocationClientMock* mockClient = toGeolocationClientMock(corePage(webPage)->geolocationController()->client()); mockClient->setPosition(GeolocationPosition::create(currentTime(), latitude, longitude, accuracy)); #endif } void DumpRenderTreeSupport::scalePageBy(WebPage* webPage, float scaleFactor, float x, float y) { - webPage->mainFrame()->page()->setPageScaleFactor(scaleFactor, IntPoint(x, y)); + corePage(webPage)->setPageScaleFactor(scaleFactor, IntPoint(x, y)); } JSValueRef DumpRenderTreeSupport::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value) diff --git a/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h b/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h index 3b140304b..54e48f029 100644 --- a/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h +++ b/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h @@ -29,6 +29,7 @@ class WebPage; namespace WebCore { class Frame; +class Page; } namespace WTF { @@ -40,6 +41,8 @@ public: DumpRenderTreeSupport(); ~DumpRenderTreeSupport(); + static WebCore::Page* corePage(BlackBerry::WebKit::WebPage*); + static void setLinksIncludedInFocusChain(bool); static bool linksIncludedInFocusChain(); diff --git a/Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp b/Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp new file mode 100644 index 000000000..b875646da --- /dev/null +++ b/Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#if USE(ACCELERATED_COMPOSITING) +#include "FrameLayers.h" + +#include "Frame.h" +#include "FrameView.h" +#include "LayerWebKitThread.h" +#include "Page.h" +#include "RenderPart.h" +#include "WebPage_p.h" +#include <wtf/Assertions.h> + +using namespace WebCore; + +namespace BlackBerry { +namespace WebKit { + +static FloatSize frameLayerAbsoluteOffset(Frame* frame) +{ + ASSERT(frame); + + if (!frame->view() || !frame->page() || !frame->page()->mainFrame() || !frame->page()->mainFrame()->view()) + return FloatSize(); + + IntPoint offset = frame->page()->mainFrame()->view()->windowToContents(frame->view()->contentsToWindow(IntPoint::zero())); + return FloatSize(offset.x(), offset.y()); +} + +FrameLayers::FrameLayers(WebPagePrivate* page) + : m_pagePrivate(page) + , m_rootGraphicsLayer() + , m_rootLayer(0) +{ +} + +FrameLayers::~FrameLayers() +{ + m_frameLayers.clear(); +} + +bool FrameLayers::containsLayerForFrame(Frame* frame) +{ + ASSERT(frame); + return m_frameLayers.contains(frame); +} + +void FrameLayers::addLayer(Frame* frame, LayerWebKitThread* layer) +{ + // If we have main frame layer we don't accept other layers. + // This should not happen actually. + ASSERT(frame != m_pagePrivate->m_mainFrame || !isRootLayerMainFrameLayer()); + if (frame == m_pagePrivate->m_mainFrame && isRootLayerMainFrameLayer()) + return; + + ASSERT(frame && layer && !m_frameLayers.contains(frame)); + + m_frameLayers.add(frame, layer); + + calculateRootLayer(); + if (!m_rootLayer) { + ASSERT(!m_rootGraphicsLayer); + m_rootGraphicsLayer = GraphicsLayer::create(0); + m_rootLayer = m_rootGraphicsLayer->platformLayer(); + } + + if (m_rootLayer != layer) + m_rootLayer->addSublayer(layer); +} + +void FrameLayers::removeLayerByFrame(Frame* frame) +{ + ASSERT(frame); + FrameLayerMap::iterator it = m_frameLayers.find(frame); + if (it != m_frameLayers.end()) { + LayerWebKitThread* layer = it->second; + if (layer->superlayer()) + layer->removeFromSuperlayer(); + m_frameLayers.remove(it); + calculateRootLayer(); + } +} + +void FrameLayers::commitOnWebKitThread(double scale) +{ + ASSERT(m_rootLayer); + if (!isRootLayerMainFrameLayer()) { + for (FrameLayerMap::iterator it = m_frameLayers.begin(); it != m_frameLayers.end(); ++it) + it->second->setAbsoluteOffset(frameLayerAbsoluteOffset(it->first)); + } + m_rootLayer->commitOnWebKitThread(scale); +} + +void FrameLayers::calculateRootLayer() +{ + if (m_frameLayers.size() == 1 && m_frameLayers.begin()->first == m_pagePrivate->m_mainFrame) + m_rootLayer = m_frameLayers.begin()->second; + else if (m_rootGraphicsLayer) + m_rootLayer = m_rootGraphicsLayer->platformLayer(); + else + m_rootLayer = 0; +} + +} // namespace BlackBerry +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebKit/blackberry/WebKitSupport/FrameLayers.h b/Source/WebKit/blackberry/WebKitSupport/FrameLayers.h new file mode 100644 index 000000000..b90138ba9 --- /dev/null +++ b/Source/WebKit/blackberry/WebKitSupport/FrameLayers.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef FrameLayers_h +#define FrameLayers_h + +#if USE(ACCELERATED_COMPOSITING) + +#include "GraphicsLayer.h" +#include <wtf/HashMap.h> +#include <wtf/OwnPtr.h> + +namespace WebCore { +class Frame; +class LayerWebKitThread; +} + +namespace BlackBerry { +namespace WebKit { + +class WebPagePrivate; + +// This class may only be used on the WebKit thread. +class FrameLayers { +public: + FrameLayers(WebPagePrivate*); + ~FrameLayers(); + + bool containsLayerForFrame(WebCore::Frame*); + void addLayer(WebCore::Frame*, WebCore::LayerWebKitThread*); + void removeLayerByFrame(WebCore::Frame*); + + bool hasLayer() const { return m_frameLayers.size(); } + + void commitOnWebKitThread(double scale); + + void calculateRootLayer(); + + bool isRootLayerMainFrameLayer() const { return m_rootLayer && !m_rootGraphicsLayer; } + + // FIXME: This function should only be called on the WebKit thread. + // But it's now also being called on the Compositing thread. + WebCore::LayerWebKitThread* rootLayer() const { return m_rootLayer; } + +private: + WebPagePrivate* m_pagePrivate; + OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer; + WebCore::LayerWebKitThread* m_rootLayer; + typedef HashMap<WebCore::Frame*, WebCore::LayerWebKitThread*> FrameLayerMap; + FrameLayerMap m_frameLayers; +}; + +} // namespace BlackBerry +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) + +#endif // FrameLayers_h diff --git a/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp b/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp index ae0402100..09cfd55bc 100644 --- a/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp @@ -19,6 +19,7 @@ #include "config.h" #include "InPageSearchManager.h" +#include "DOMSupport.h" #include "Document.h" #include "DocumentMarkerController.h" #include "Editor.h" @@ -51,43 +52,124 @@ bool InPageSearchManager::findNextString(const String& text, bool forward) return false; } - if (m_activeSearchString != text) { - clearTextMatches(); + if (!shouldSearchForText(text)) { m_activeSearchString = text; - m_activeMatchCount = m_webPage->m_page->markAllMatchesForText(text, WebCore::CaseInsensitive, true, TextMatchMarkerLimit); - } else - setMarkerActive(m_activeMatch.get(), false); - - if (!m_activeMatchCount) return false; + } + + // Validate the range in case any node has been removed since last search. + if (m_activeMatch && !m_activeMatch->boundaryPointsValid()) + m_activeMatch = 0; + + RefPtr<Range> searchStartingPoint(m_activeMatch); + if (m_activeSearchString != text) { // Start a new search. + m_activeSearchString = text; + m_webPage->m_page->unmarkAllTextMatches(); + m_activeMatchCount = m_webPage->m_page->markAllMatchesForText(text, CaseInsensitive, true /* shouldHighlight */, TextMatchMarkerLimit); + if (!m_activeMatchCount) { + clearTextMatches(); + return false; + } + } else { // Search same string for next occurrence. + setMarkerActive(m_activeMatch.get(), false /* active */); + // Searching for same string should start from the end of last match. + if (m_activeMatch) { + if (forward) + searchStartingPoint->setStart(searchStartingPoint->endPosition()); + else + searchStartingPoint->setEnd(searchStartingPoint->startPosition()); + } + } - const FindOptions findOptions = (forward ? 0 : WebCore::Backwards) - | WebCore::CaseInsensitive - | WebCore::WrapAround; // TODO should wrap around in page, not in frame + // If there is any active selection, new search should start from the beginning of it. + VisibleSelection selection = m_webPage->focusedOrMainFrame()->selection()->selection(); + if (!selection.isNone()) { + searchStartingPoint = selection.firstRange().get(); + m_webPage->focusedOrMainFrame()->selection()->clear(); + } + + Frame* currentActiveMatchFrame = selection.isNone() && m_activeMatch ? m_activeMatch->ownerDocument()->frame() : m_webPage->focusedOrMainFrame(); + + const FindOptions findOptions = (forward ? 0 : Backwards) + | CaseInsensitive + | StartInSelection; + + if (findAndMarkText(text, searchStartingPoint.get(), currentActiveMatchFrame, findOptions)) + return true; - // TODO StartInSelection + Frame* startFrame = currentActiveMatchFrame; + do { + currentActiveMatchFrame = DOMSupport::incrementFrame(currentActiveMatchFrame, forward, true /* wrapFlag */); + if (findAndMarkText(text, 0, currentActiveMatchFrame, findOptions)) + return true; + } while (currentActiveMatchFrame && startFrame != currentActiveMatchFrame); - m_activeMatch = m_webPage->mainFrame()->editor()->findStringAndScrollToVisible(text, m_activeMatch.get(), findOptions); - setMarkerActive(m_activeMatch.get(), true); + clearTextMatches(); + ASSERT_NOT_REACHED(); + return false; +} + +bool InPageSearchManager::shouldSearchForText(const String& text) +{ + if (text == m_activeSearchString) + return m_activeMatchCount; + + // If the previous search string is prefix of new search string, + // don't search if the previous one has zero result. + if (!m_activeMatchCount + && m_activeSearchString.length() + && text.length() > m_activeSearchString.length() + && m_activeSearchString == text.substring(0, m_activeSearchString.length())) + return false; return true; } +bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Frame* frame, const FindOptions& options) +{ + m_activeMatch = frame->editor()->findStringAndScrollToVisible(text, range, options); + if (m_activeMatch) { + setMarkerActive(m_activeMatch.get(), true /* active */); + return true; + } + return false; +} + void InPageSearchManager::clearTextMatches() { m_webPage->m_page->unmarkAllTextMatches(); m_activeMatch = 0; } -void InPageSearchManager::setMarkerActive(WebCore::Range* range, bool active) +void InPageSearchManager::setMarkerActive(Range* range, bool active) { if (!range) return; - WebCore::Document* doc = m_webPage->mainFrame()->document(); + Document* doc = m_activeMatch->ownerDocument(); if (!doc) return; doc->markers()->setMarkersActive(range, active); } +void InPageSearchManager::frameUnloaded(const Frame* frame) +{ + if (!m_activeMatch) { + if (m_webPage->mainFrame() == frame && m_activeSearchString.length()) + m_activeSearchString = String(); + return; + } + + Frame* currentActiveMatchFrame = m_activeMatch->ownerDocument()->frame(); + if (currentActiveMatchFrame == frame) { + m_activeMatch = 0; + m_activeSearchString = String(); + m_activeMatchCount = 0; + // FIXME: We need to notify client here. + if (frame == m_webPage->mainFrame()) // Don't need to unmark because the page will be destroyed. + return; + m_webPage->m_page->unmarkAllTextMatches(); + } +} + } } diff --git a/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.h b/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.h index 1f6bbb535..4b0562b17 100644 --- a/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.h +++ b/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.h @@ -19,12 +19,13 @@ #ifndef InPageSearchManager_h #define InPageSearchManager_h +#include "FindOptions.h" #include "WTFString.h" -#include <wtf/RefPtr.h> - namespace WebCore { +class Frame; class Range; +class VisibleSelection; } namespace BlackBerry { @@ -39,10 +40,13 @@ public: ~InPageSearchManager(); bool findNextString(const String& text, bool forward); + void frameUnloaded(const WebCore::Frame*); private: void clearTextMatches(); - void setMarkerActive(WebCore::Range*, bool active); + void setMarkerActive(WebCore::Range*, bool); + bool findAndMarkText(const String&, WebCore::Range*, WebCore::Frame*, const WebCore::FindOptions&); + bool shouldSearchForText(const String&); WebPagePrivate* m_webPage; RefPtr<WebCore::Range> m_activeMatch; diff --git a/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp b/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp index 27b941e6f..a3362287f 100644 --- a/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp @@ -64,23 +64,23 @@ #define ENABLE_INPUT_LOG 0 #define ENABLE_FOCUS_LOG 0 +static const unsigned MaxLearnTextDataSize = 500; + +using namespace BlackBerry::Platform; +using namespace WebCore; + #if ENABLE_INPUT_LOG -#define InputLog(severity, format, ...) BlackBerry::Platform::logAlways(severity, format, ## __VA_ARGS__) +#define InputLog(severity, format, ...) logAlways(severity, format, ## __VA_ARGS__) #else #define InputLog(severity, format, ...) #endif // ENABLE_INPUT_LOG #if ENABLE_FOCUS_LOG -#define FocusLog(severity, format, ...) BlackBerry::Platform::logAlways(severity, format, ## __VA_ARGS__) +#define FocusLog(severity, format, ...) logAlways(severity, format, ## __VA_ARGS__) #else #define FocusLog(severity, format, ...) #endif // ENABLE_FOCUS_LOG -static const int MaxLearnTextDataSize = 500; - -using namespace BlackBerry::Platform; -using namespace WebCore; - namespace BlackBerry { namespace WebKit { @@ -162,6 +162,7 @@ static int inputStyle(BlackBerryInputType type, const Element* element) switch (type) { case InputTypeText: case InputTypeSearch: + case InputTypeTextArea: { // Regular input mode, disable help if autocomplete is off. int imfMask = 0; @@ -189,7 +190,6 @@ static int inputStyle(BlackBerryInputType type, const Element* element) case InputTypeURL: // Disable special handling. return NO_AUTO_TEXT | NO_PREDICTION | NO_AUTO_CORRECTION; - case InputTypeTextArea: default: break; } @@ -222,8 +222,15 @@ BlackBerryInputType InputHandler::elementType(Element* element) const return InputTypeTextArea; } -void InputHandler::nodeFocused(Node* node) +void InputHandler::focusedNodeChanged() { + ASSERT(m_webPage->m_page->focusController()); + Frame* frame = m_webPage->m_page->focusController()->focusedOrMainFrame(); + if (!frame || !frame->document()) + return; + + Node* node = frame->document()->focusedNode(); + if (isActiveTextEdit() && m_currentFocusElement == node) { notifyClientOfKeyboardVisibilityChange(true); return; @@ -297,7 +304,7 @@ static bool convertStringToWchar(const String& string, wchar_t* dest, int destCa // wchar_t strings sent to IMF are 32 bit so casting to UChar32 is safe. u_strToUTF32(reinterpret_cast<UChar32*>(dest), destCapacity, destLength, string.characters(), string.length(), &ec); if (ec) { - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::convertStringToWchar Error converting string ec (%d).", ec); + InputLog(LogLevelInfo, "InputHandler::convertStringToWchar Error converting string ec (%d).", ec); destLength = 0; return false; } @@ -313,7 +320,7 @@ static bool convertStringToWcharVector(const String& string, WTF::Vector<wchar_t return true; if (!wcharString.tryReserveCapacity(length + 1)) { - BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelWarn, "InputHandler::convertStringToWcharVector Cannot allocate memory for string.\n"); + logAlways(LogLevelWarn, "InputHandler::convertStringToWcharVector Cannot allocate memory for string.\n"); return false; } @@ -333,7 +340,7 @@ static String convertSpannableStringToString(spannable_string_t* src) WTF::Vector<UChar> dest; int destCapacity = (src->length * 2) + 1; if (!dest.tryReserveCapacity(destCapacity)) { - BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelWarn, "InputHandler::convertSpannableStringToString Cannot allocate memory for string.\n"); + logAlways(LogLevelWarn, "InputHandler::convertSpannableStringToString Cannot allocate memory for string.\n"); return String(); } @@ -342,7 +349,7 @@ static String convertSpannableStringToString(spannable_string_t* src) // wchar_t strings sent from IMF are 32 bit so casting to UChar32 is safe. u_strFromUTF32(dest.data(), destCapacity, &destLength, reinterpret_cast<UChar32*>(src->str), src->length, &ec); if (ec) { - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::convertSpannableStringToString Error converting string ec (%d).", ec); + InputLog(LogLevelInfo, "InputHandler::convertSpannableStringToString Error converting string ec (%d).", ec); return String(); } dest.resize(destLength); @@ -368,7 +375,7 @@ void InputHandler::learnText() return; String textInField(elementText()); - textInField = textInField.substring(std::max(0, static_cast<int>(textInField.length()) - MaxLearnTextDataSize), textInField.length()); + textInField = textInField.substring(std::max(0, static_cast<int>(textInField.length() - MaxLearnTextDataSize)), textInField.length()); textInField.remove(0, textInField.find(" ")); // Build up the 500 character strings in word chunks. @@ -378,14 +385,14 @@ void InputHandler::learnText() if (textInField.isEmpty()) return; - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::learnText %s", textInField.latin1().data()); + InputLog(LogLevelInfo, "InputHandler::learnText %s", textInField.latin1().data()); sendLearnTextDetails(textInField); } void InputHandler::setElementUnfocused(bool refocusOccuring) { if (isActiveTextEdit()) { - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setElementUnfocused"); + FocusLog(LogLevelInfo, "InputHandler::setElementUnfocused"); // Pass any text into the field to IMF to learn. learnText(); @@ -412,36 +419,36 @@ bool InputHandler::shouldAcceptInputFocus() if (m_webPage->m_dumpRenderTree) return true; - if (BlackBerry::Platform::Settings::get()->alwaysShowKeyboardOnFocus()) { - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::shouldAcceptInputFocus alwaysShowKeyboardOnFocus is active."); + if (Platform::Settings::get()->alwaysShowKeyboardOnFocus()) { + FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus alwaysShowKeyboardOnFocus is active."); return true; } Frame* focusedFrame = m_webPage->focusedOrMainFrame(); if (!focusedFrame) { - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::shouldAcceptInputFocus Frame not valid."); + FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Frame not valid."); return false; } // Any user action should be respected. Mouse will be down when touch is // used to focus. if (focusedFrame->eventHandler()->mousePressed()) { - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::shouldAcceptInputFocus Mouse is pressed focusing."); + FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Mouse is pressed focusing."); return true; } if (!m_webPage->m_client->hasKeyboardFocus()) { - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::shouldAcceptInputFocus Client does not have input focus."); + FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Client does not have input focus."); return false; } if (m_webPage->isLoading()) { - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::shouldAcceptInputFocus Webpage is loading."); + FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Webpage is loading."); return false; } // Make sure the focused frame is not processing load events. - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::shouldAcceptInputFocus returning state of processingLoadEvent (%s).", !focusedFrame->document()->processingLoadEvent() ? "true" : "false"); + FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus returning state of processingLoadEvent (%s).", !focusedFrame->document()->processingLoadEvent() ? "true" : "false"); return !focusedFrame->document()->processingLoadEvent(); } @@ -473,7 +480,7 @@ void InputHandler::setElementFocused(Element* element) BlackBerryInputType type = elementType(element); m_currentFocusElementTextEditMask = inputStyle(type, element); - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d", type, m_currentFocusElementTextEditMask); + FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d", type, m_currentFocusElementTextEditMask); m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask, @@ -534,7 +541,7 @@ void InputHandler::nodeTextChanged(const Node* node) if (node != m_currentFocusElement) return; - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::nodeTextChanged"); + InputLog(LogLevelInfo, "InputHandler::nodeTextChanged"); m_webPage->m_client->inputTextChanged(); @@ -548,7 +555,7 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType) if (!m_currentFocusElement || !m_currentFocusElement->document()) return; - if (!BlackBerry::Platform::Settings::get()->allowCenterScrollAdjustmentForInputFields() && scrollType != EdgeIfNeeded) + if (!Platform::Settings::get()->allowCenterScrollAdjustmentForInputFields() && scrollType != EdgeIfNeeded) return; Frame* elementFrame = m_currentFocusElement->document()->frame(); @@ -710,7 +717,7 @@ void InputHandler::ensureFocusElementVisible(bool centerInView) ensureFocusTextElementVisible(centerInView ? CenterAlways : CenterIfNeeded); } -void InputHandler::frameUnloaded(Frame* frame) +void InputHandler::frameUnloaded(const Frame* frame) { if (!isActiveTextEdit()) return; @@ -718,7 +725,7 @@ void InputHandler::frameUnloaded(Frame* frame) if (m_currentFocusElement->document()->frame() != frame) return; - FocusLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::frameUnloaded"); + FocusLog(LogLevelInfo, "InputHandler::frameUnloaded"); setElementUnfocused(false /*refocusOccuring*/); } @@ -837,7 +844,7 @@ void InputHandler::selectionChanged() int newSelectionStart = selectionStart(); int newSelectionEnd = selectionEnd(); - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::selectionChanged selectionStart=%u, selectionEnd=%u", newSelectionStart, newSelectionEnd); + InputLog(LogLevelInfo, "InputHandler::selectionChanged selectionStart=%u, selectionEnd=%u", newSelectionStart, newSelectionEnd); m_webPage->m_client->inputSelectionChanged(newSelectionStart, newSelectionEnd); @@ -863,7 +870,7 @@ bool InputHandler::setSelection(int start, int end, bool changeIsPartOfCompositi VisibleSelection newSelection = DOMSupport::visibleSelectionForRangeInputElement(m_currentFocusElement.get(), start, end); m_currentFocusElement->document()->frame()->selection()->setSelection(newSelection, changeIsPartOfComposition ? 0 : FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setSelection selectionStart=%u, selectionEnd=%u", start, end); + InputLog(LogLevelInfo, "InputHandler::setSelection selectionStart=%u, selectionEnd=%u", start, end); return start == selectionStart() && end == selectionEnd(); } @@ -898,9 +905,9 @@ void InputHandler::cancelSelection() setCursorPosition(selectionStartPosition); } -bool InputHandler::handleKeyboardInput(const BlackBerry::Platform::KeyboardEvent& keyboardEvent, bool changeIsPartOfComposition) +bool InputHandler::handleKeyboardInput(const Platform::KeyboardEvent& keyboardEvent, bool changeIsPartOfComposition) { - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::handleKeyboardInput received character=%lc, type=%d", keyboardEvent.character(), keyboardEvent.type()); + InputLog(LogLevelInfo, "InputHandler::handleKeyboardInput received character=%lc, type=%d", keyboardEvent.character(), keyboardEvent.type()); // If we aren't specifically part of a composition, fail, IMF should never send key input // while composing text. If IMF has failed, we should have already finished the @@ -917,23 +924,23 @@ bool InputHandler::handleKeyboardInput(const BlackBerry::Platform::KeyboardEvent ASSERT(m_webPage->m_page->focusController()); bool keyboardEventHandled = false; if (Frame* focusedFrame = m_webPage->m_page->focusController()->focusedFrame()) { - bool isKeyChar = keyboardEvent.type() == BlackBerry::Platform::KeyboardEvent::KeyChar; - BlackBerry::Platform::KeyboardEvent::Type type = keyboardEvent.type(); + bool isKeyChar = keyboardEvent.type() == Platform::KeyboardEvent::KeyChar; + Platform::KeyboardEvent::Type type = keyboardEvent.type(); // If this is a KeyChar type then we handle it as a keydown followed by a key up. if (isKeyChar) - type = BlackBerry::Platform::KeyboardEvent::KeyDown; + type = Platform::KeyboardEvent::KeyDown; - BlackBerry::Platform::KeyboardEvent adjustedKeyboardEvent(keyboardEvent.character(), type, adjustedModifiers); + Platform::KeyboardEvent adjustedKeyboardEvent(keyboardEvent.character(), type, adjustedModifiers); keyboardEventHandled = focusedFrame->eventHandler()->keyEvent(PlatformKeyboardEvent(adjustedKeyboardEvent)); if (isKeyChar) { - type = BlackBerry::Platform::KeyboardEvent::KeyUp; - adjustedKeyboardEvent = BlackBerry::Platform::KeyboardEvent(keyboardEvent.character(), type, adjustedModifiers); + type = Platform::KeyboardEvent::KeyUp; + adjustedKeyboardEvent = Platform::KeyboardEvent(keyboardEvent.character(), type, adjustedModifiers); keyboardEventHandled = focusedFrame->eventHandler()->keyEvent(PlatformKeyboardEvent(adjustedKeyboardEvent)) || keyboardEventHandled; } - if (!changeIsPartOfComposition && type == BlackBerry::Platform::KeyboardEvent::KeyUp) + if (!changeIsPartOfComposition && type == Platform::KeyboardEvent::KeyUp) ensureFocusTextElementVisible(EdgeIfNeeded); } return keyboardEventHandled; @@ -1244,7 +1251,7 @@ bool InputHandler::deleteTextRelativeToCursor(int leftOffset, int rightOffset) ProcessingChangeGuard guard(this); - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::deleteTextRelativeToCursor left %d right %d", leftOffset, rightOffset); + InputLog(LogLevelInfo, "InputHandler::deleteTextRelativeToCursor left %d right %d", leftOffset, rightOffset); int caretOffset = caretPosition(); int start = relativeLeftOffset(caretOffset, leftOffset); @@ -1269,7 +1276,7 @@ bool InputHandler::deleteText(int start, int end) if (!setSelection(start, end, true /*changeIsPartOfComposition*/)) return false; - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::deleteText start %d end %d", start, end); + InputLog(LogLevelInfo, "InputHandler::deleteText start %d end %d", start, end); return deleteSelection(); } @@ -1289,13 +1296,13 @@ spannable_string_t* InputHandler::spannableTextInRange(int start, int end, int32 spannable_string_t* pst = (spannable_string_t*)malloc(sizeof(spannable_string_t)); if (!pst) { - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::spannableTextInRange error allocating spannable string."); + InputLog(LogLevelInfo, "InputHandler::spannableTextInRange error allocating spannable string."); return 0; } pst->str = (wchar_t*)malloc(sizeof(wchar_t) * (length + 1)); if (!pst->str) { - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::spannableTextInRange Cannot allocate memory for string.\n"); + InputLog(LogLevelInfo, "InputHandler::spannableTextInRange Cannot allocate memory for string.\n"); free(pst); return 0; } @@ -1438,7 +1445,7 @@ int32_t InputHandler::setComposingRegion(int32_t start, int32_t end) if (compositionActive()) addAttributedTextMarker(start, end, compositionTextStyle()); - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setComposingRegion start %d end %d", start, end); + InputLog(LogLevelInfo, "InputHandler::setComposingRegion start %d end %d", start, end); return 0; } @@ -1455,7 +1462,7 @@ int32_t InputHandler::finishComposition() // Remove all markers. removeAttributedTextMarker(); - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::finishComposition completed"); + InputLog(LogLevelInfo, "InputHandler::finishComposition completed"); return 0; } @@ -1519,7 +1526,7 @@ bool InputHandler::setText(spannable_string_t* spannableString) // Handle the case where text is being composed. if (firstSpanInString(spannableString, COMPOSED_TEXT_ATTRIB)) return editor->command("InsertText").execute(textToInsert.right(1)); - return handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(textToInsert[textLength - 1], BlackBerry::Platform::KeyboardEvent::KeyChar, 0), false /* changeIsPartOfComposition */); + return handleKeyboardInput(Platform::KeyboardEvent(textToInsert[textLength - 1], Platform::KeyboardEvent::KeyChar, 0), false /* changeIsPartOfComposition */); } // If no spans have changed, treat it as a delete operation. @@ -1544,7 +1551,7 @@ bool InputHandler::setText(spannable_string_t* spannableString) return true; } - InputLog(BlackBerry::Platform::LogLevelInfo, "setText spannableString is %s, %d \n", textToInsert.latin1().data(), textLength); + InputLog(LogLevelInfo, "setText spannableString is %s, %d \n", textToInsert.latin1().data(), textLength); // Triggering an insert of the text with a space character trailing // causes new text to adopt the previous text style. @@ -1557,27 +1564,27 @@ bool InputHandler::setText(spannable_string_t* spannableString) textToInsert.remove(textLength, 1); } - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setText Request being processed Text before %s", elementText().latin1().data()); + InputLog(LogLevelInfo, "InputHandler::setText Request being processed Text before %s", elementText().latin1().data()); if (textLength == 1 && !spannableString->spans_count) { // Handle single key non-attributed entry as key press rather than insert to allow // triggering of javascript events. - return handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(textToInsert[0], BlackBerry::Platform::KeyboardEvent::KeyChar, 0), true /* changeIsPartOfComposition */); + return handleKeyboardInput(Platform::KeyboardEvent(textToInsert[0], Platform::KeyboardEvent::KeyChar, 0), true /* changeIsPartOfComposition */); } // Perform the text change as a single command if there is one. if (!textToInsert.isEmpty() && !editor->command("InsertText").execute(textToInsert)) { - InputLog(BlackBerry::Platform::LogLevelWarn, "InputHandler::setText Failed to insert text %s", textToInsert.latin1().data()); + InputLog(LogLevelWarn, "InputHandler::setText Failed to insert text %s", textToInsert.latin1().data()); return false; } - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setText Request being processed Text after insert %s", elementText().latin1().data()); + InputLog(LogLevelInfo, "InputHandler::setText Request being processed Text after insert %s", elementText().latin1().data()); if (requiresSpaceKeyPress) - handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(32 /* space */, BlackBerry::Platform::KeyboardEvent::KeyChar, 0), true /* changeIsPartOfComposition */); + handleKeyboardInput(Platform::KeyboardEvent(32 /* space */, Platform::KeyboardEvent::KeyChar, 0), true /* changeIsPartOfComposition */); - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setText Text after %s", elementText().latin1().data()); + InputLog(LogLevelInfo, "InputHandler::setText Text after %s", elementText().latin1().data()); return true; } @@ -1602,13 +1609,13 @@ bool InputHandler::setTextAttributes(int insertionPoint, spannable_string_t* spa // used by IMF. When they add support for on the fly spell checking we can // use it to apply spelling markers and disable continuous spell checking. - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setTextAttributes adding marker %d to %d - %d", startPosition, endPosition, span->attributes_mask); + InputLog(LogLevelInfo, "InputHandler::setTextAttributes adding marker %d to %d - %d", startPosition, endPosition, span->attributes_mask); addAttributedTextMarker(startPosition, endPosition, textStyleFromMask(span->attributes_mask)); span++; } - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setTextAttributes attribute count %d", spannableString->spans_count); + InputLog(LogLevelInfo, "InputHandler::setTextAttributes attribute count %d", spannableString->spans_count); return true; } @@ -1639,14 +1646,14 @@ bool InputHandler::setRelativeCursorPosition(int insertionPoint, int relativeCur if (cursorPosition < 0 || cursorPosition > (int)elementText().length()) return false; - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setRelativeCursorPosition cursor position %d", cursorPosition); + InputLog(LogLevelInfo, "InputHandler::setRelativeCursorPosition cursor position %d", cursorPosition); return setCursorPosition(cursorPosition); } bool InputHandler::setSpannableTextAndRelativeCursor(spannable_string_t* spannableString, int relativeCursorPosition, bool markTextAsComposing) { - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setSpannableTextAndRelativeCursor(%d, %d, %d)\n", spannableString->length, relativeCursorPosition, markTextAsComposing); + InputLog(LogLevelInfo, "InputHandler::setSpannableTextAndRelativeCursor(%d, %d, %d)\n", spannableString->length, relativeCursorPosition, markTextAsComposing); int insertionPoint = compositionActive() ? m_composingTextStart : selectionStart(); ProcessingChangeGuard guard(this); @@ -1680,7 +1687,7 @@ int32_t InputHandler::setComposingText(spannable_string_t* spannableString, int3 if (!spannableString) return -1; - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setComposingText at relativeCursorPosition: %d", relativeCursorPosition); + InputLog(LogLevelInfo, "InputHandler::setComposingText at relativeCursorPosition: %d", relativeCursorPosition); return setSpannableTextAndRelativeCursor(spannableString, relativeCursorPosition, true /* markTextAsComposing */) ? 0 : -1; } @@ -1693,7 +1700,7 @@ int32_t InputHandler::commitText(spannable_string_t* spannableString, int32_t re if (!spannableString) return -1; - InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::commitText"); + InputLog(LogLevelInfo, "InputHandler::commitText"); return setSpannableTextAndRelativeCursor(spannableString, relativeCursorPosition, false /* markTextAsComposing */) ? 0 : -1; } diff --git a/Source/WebKit/blackberry/WebKitSupport/InputHandler.h b/Source/WebKit/blackberry/WebKitSupport/InputHandler.h index 1b64a78b1..94c93ff30 100644 --- a/Source/WebKit/blackberry/WebKitSupport/InputHandler.h +++ b/Source/WebKit/blackberry/WebKitSupport/InputHandler.h @@ -57,10 +57,10 @@ public: enum FocusElementType { TextEdit, TextPopup /* Date/Time & Color */, SelectPopup, Plugin }; enum CaretScrollType { CenterAlways, CenterIfNeeded, EdgeIfNeeded }; - void nodeFocused(WebCore::Node*); + void focusedNodeChanged(); void nodeTextChanged(const WebCore::Node*); void selectionChanged(); - void frameUnloaded(WebCore::Frame*); + void frameUnloaded(const WebCore::Frame*); bool handleKeyboardInput(const BlackBerry::Platform::KeyboardEvent&, bool changeIsPartOfComposition = false); diff --git a/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp b/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp index 0723c65c8..8385deeda 100644 --- a/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp @@ -49,14 +49,15 @@ #define SHOWDEBUG_SELECTIONHANDLER 0 +using namespace BlackBerry::Platform; +using namespace WebCore; + #if SHOWDEBUG_SELECTIONHANDLER -#define DEBUG_SELECTION(severity, format, ...) BlackBerry::Platform::logAlways(severity, format, ## __VA_ARGS__) +#define DEBUG_SELECTION(severity, format, ...) logAlways(severity, format, ## __VA_ARGS__) #else #define DEBUG_SELECTION(severity, format, ...) #endif // SHOWDEBUG_SELECTIONHANDLER -using namespace WebCore; - namespace BlackBerry { namespace WebKit { @@ -75,9 +76,9 @@ SelectionHandler::~SelectionHandler() void SelectionHandler::cancelSelection() { m_selectionActive = false; - m_lastSelectionRegion = BlackBerry::Platform::IntRectRegion(); + m_lastSelectionRegion = IntRectRegion(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::cancelSelection"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::cancelSelection"); if (m_webPage->m_inputHandler->isInputMode()) m_webPage->m_inputHandler->cancelSelection(); @@ -90,7 +91,7 @@ WebString SelectionHandler::selectedText() const return m_webPage->focusedOrMainFrame()->editor()->selectedText(); } -void SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection(const VisibleSelection& selection, BlackBerry::Platform::IntRectRegion& region) const +void SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection(const VisibleSelection& selection, IntRectRegion& region) const { ASSERT(region.isEmpty()); @@ -106,24 +107,24 @@ void SelectionHandler::getConsolidatedRegionOfTextQuadsForSelection(const Visibl FrameView* frameView = m_webPage->focusedOrMainFrame()->view(); // frameRect is in frame coordinates. - IntRect frameRect(IntPoint(0, 0), frameView->contentsSize()); + WebCore::IntRect frameRect(WebCore::IntPoint(0, 0), frameView->contentsSize()); // framePosition is in main frame coordinates. - IntPoint framePosition = m_webPage->frameOffset(m_webPage->focusedOrMainFrame()); + WebCore::IntPoint framePosition = m_webPage->frameOffset(m_webPage->focusedOrMainFrame()); // The ranges rect list is based on render elements and may include multiple adjacent rects. - // Use BlackBerry::Platform::IntRectRegion to consolidate these rects into bands as well as a container to pass + // Use IntRectRegion to consolidate these rects into bands as well as a container to pass // to the client. for (unsigned i = 0; i < quadList.size(); i++) { - IntRect enclosingRect = quadList[i].enclosingBoundingBox(); + WebCore::IntRect enclosingRect = quadList[i].enclosingBoundingBox(); enclosingRect.intersect(frameRect); enclosingRect.move(framePosition.x(), framePosition.y()); - region = unionRegions(region, BlackBerry::Platform::IntRectRegion(enclosingRect)); + region = unionRegions(region, IntRectRegion(enclosingRect)); } } } -static VisiblePosition visiblePositionForPointIgnoringClipping(const Frame& frame, const IntPoint& framePoint) +static VisiblePosition visiblePositionForPointIgnoringClipping(const Frame& frame, const WebCore::IntPoint& framePoint) { // Frame::visiblePositionAtPoint hard-codes ignoreClipping=false in the // call to hitTestResultAtPoint. This has a bug where some pages (such as @@ -148,7 +149,7 @@ static VisiblePosition visiblePositionForPointIgnoringClipping(const Frame& fram return visiblePos; } -static unsigned short directionOfPointRelativeToRect(const IntPoint& point, const IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true) +static unsigned short directionOfPointRelativeToRect(const WebCore::IntPoint& point, const WebCore::IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true) { ASSERT(!rect.contains(point)); @@ -169,7 +170,7 @@ static unsigned short directionOfPointRelativeToRect(const IntPoint& point, cons return 0; } -bool SelectionHandler::shouldUpdateSelectionOrCaretForPoint(const IntPoint& point, const IntRect& caretRect, bool startCaret) const +bool SelectionHandler::shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint& point, const WebCore::IntRect& caretRect, bool startCaret) const { ASSERT(m_webPage->m_inputHandler->isInputMode()); @@ -184,7 +185,7 @@ bool SelectionHandler::shouldUpdateSelectionOrCaretForPoint(const IntPoint& poin bool aboveCaret = point.y() < caretRect.y(); bool belowCaret = point.y() >= caretRect.maxY(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::shouldUpdateSelectionOrCaretForPoint multiline = %s above = %s below = %s first line = %s last line = %s start = %s \n" + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::shouldUpdateSelectionOrCaretForPoint multiline = %s above = %s below = %s first line = %s last line = %s start = %s \n" , m_webPage->m_inputHandler->isMultilineInputMode() ? "true" : "false", aboveCaret ? "true" : "false", belowCaret ? "true" : "false" , inSameLine(currentSelection.visibleStart(), startOfEditableContent(currentSelection.visibleStart())) ? "true" : "false" , inSameLine(currentSelection.visibleEnd(), endOfEditableContent(currentSelection.visibleEnd())) ? "true" : "false" @@ -200,19 +201,19 @@ bool SelectionHandler::shouldUpdateSelectionOrCaretForPoint(const IntPoint& poin return true; } -void SelectionHandler::setCaretPosition(const IntPoint &position) +void SelectionHandler::setCaretPosition(const WebCore::IntPoint &position) { if (!m_webPage->m_inputHandler->isInputMode()) return; m_caretActive = true; - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setCaretPosition requested point %d, %d", position.x(), position.y()); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::setCaretPosition requested point %d, %d", position.x(), position.y()); Frame* focusedFrame = m_webPage->focusedOrMainFrame(); FrameSelection* controller = focusedFrame->selection(); - IntPoint relativePoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, position); - IntRect currentCaretRect = controller->selection().visibleStart().absoluteCaretBounds(); + WebCore::IntPoint relativePoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, position); + WebCore::IntRect currentCaretRect = controller->selection().visibleStart().absoluteCaretBounds(); if (relativePoint == DOMSupport::InvalidPoint || !shouldUpdateSelectionOrCaretForPoint(relativePoint, currentCaretRect)) { selectionPositionChanged(); @@ -223,7 +224,7 @@ void SelectionHandler::setCaretPosition(const IntPoint &position) if (!DOMSupport::isPositionInNode(m_webPage->focusedOrMainFrame()->document()->focusedNode(), visibleCaretPosition.deepEquivalent())) { if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect)) - m_webPage->m_inputHandler->handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(character)); + m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character)); selectionPositionChanged(); return; @@ -237,7 +238,7 @@ void SelectionHandler::setCaretPosition(const IntPoint &position) controller->setSelection(newSelection); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setCaretPosition point valid, cursor updated"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::setCaretPosition point valid, cursor updated"); } // This function makes sure we are not reducing the selection to a caret selection. @@ -270,7 +271,12 @@ static bool shouldExtendSelectionInDirection(const VisibleSelection& selection, return tempSelection.selection().selectionType() == VisibleSelection::RangeSelection; } -static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const IntRect& boundingBox, unsigned short direction, const IntPoint& basePoint) +static int clamp(const int min, const int value, const int max) +{ + return value < min ? min : std::min(value, max); +} + +static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const WebCore::IntRect& boundingBox, unsigned short direction, const WebCore::IntPoint& basePoint) { ASSERT(frame); @@ -279,25 +285,25 @@ static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, con switch (direction) { case KEYCODE_LEFT: - // Extend x to start without modifying y. - return frame->visiblePositionForPoint(IntPoint(boundingBox.x(), basePoint.y())); + // Extend x to start and clamp y to the edge of bounding box. + return frame->visiblePositionForPoint(WebCore::IntPoint(boundingBox.x(), clamp(boundingBox.y(), basePoint.y(), boundingBox.maxY()))); case KEYCODE_RIGHT: - // Extend x to end without modifying y. - return frame->visiblePositionForPoint(IntPoint(boundingBox.maxX(), basePoint.y())); + // Extend x to end and clamp y to the edge of bounding box. + return frame->visiblePositionForPoint(WebCore::IntPoint(boundingBox.maxX(), clamp(boundingBox.y(), basePoint.y(), boundingBox.maxY()))); case KEYCODE_UP: - // Extend y to top without modifying x. - return frame->visiblePositionForPoint(IntPoint(basePoint.x(), boundingBox.y())); + // Extend y to top and clamp x to the edge of bounding box. + return frame->visiblePositionForPoint(WebCore::IntPoint(clamp(boundingBox.x(), basePoint.x(), boundingBox.maxX()), boundingBox.y())); case KEYCODE_DOWN: - // Extend y to bottom without modifying x. - return frame->visiblePositionForPoint(IntPoint(basePoint.x(), boundingBox.maxY())); + // Extend y to bottom and clamp x to the edge of bounding box. + return frame->visiblePositionForPoint(WebCore::IntPoint(clamp(boundingBox.x(), basePoint.x(), boundingBox.maxX()), boundingBox.maxY())); default: break; } - return frame->visiblePositionForPoint(IntPoint(basePoint.x(), basePoint.y())); + return frame->visiblePositionForPoint(WebCore::IntPoint(basePoint.x(), basePoint.y())); } -static bool pointIsOutsideOfBoundingBoxInDirection(unsigned direction, const IntPoint& selectionPoint, const IntRect& boundingBox) +static bool pointIsOutsideOfBoundingBoxInDirection(unsigned direction, const WebCore::IntPoint& selectionPoint, const WebCore::IntRect& boundingBox) { if ((direction == KEYCODE_LEFT && selectionPoint.x() < boundingBox.x()) || (direction == KEYCODE_UP && selectionPoint.y() < boundingBox.y()) @@ -308,7 +314,7 @@ static bool pointIsOutsideOfBoundingBoxInDirection(unsigned direction, const Int return false; } -unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const IntPoint& selectionPoint, VisibleSelection& newSelection) +unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, VisibleSelection& newSelection) { Frame* focusedFrame = m_webPage->focusedOrMainFrame(); if (!focusedFrame->document()->focusedNode() || !focusedFrame->document()->focusedNode()->renderer()) @@ -316,15 +322,15 @@ unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHand FrameSelection* controller = focusedFrame->selection(); - IntRect caretRect = isStartHandle ? controller->selection().visibleStart().absoluteCaretBounds() + WebCore::IntRect caretRect = isStartHandle ? controller->selection().visibleStart().absoluteCaretBounds() : controller->selection().visibleEnd().absoluteCaretBounds(); - IntRect nodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect(); + WebCore::IntRect nodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect(); nodeBoundingBox.inflate(-1); // Start handle is outside of the field. Treat it as the changed handle and move // relative to the start caret rect. - unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /*useTopPadding*/, !isStartHandle /*useBottomPadding*/); + unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding */, !isStartHandle /* useBottomPadding */); // Prevent incorrect movement, handles can only extend the selection this way // to prevent inversion of the handles. @@ -339,9 +345,9 @@ unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHand newVisiblePosition = directionalVisiblePositionAtExtentOfBox(focusedFrame, nodeBoundingBox, character, selectionPoint); if (isStartHandle) - newSelection = VisibleSelection(newVisiblePosition, newSelection.extent(), true /*isDirectional*/); + newSelection = VisibleSelection(newVisiblePosition, newSelection.extent(), true /* isDirectional */); else - newSelection = VisibleSelection(newSelection.base(), newVisiblePosition, true /*isDirectional*/); + newSelection = VisibleSelection(newSelection.base(), newVisiblePosition, true /* isDirectional */); // If no selection will be changed, return the character to extend using navigation. if (controller->selection() == newSelection) @@ -352,8 +358,8 @@ unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHand } // Returns true if handled. -bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelection, const IntPoint& relativeStart - , const IntPoint& relativeEnd) +bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelection, const WebCore::IntPoint& relativeStart + , const WebCore::IntPoint& relativeEnd) { ASSERT(m_webPage->m_inputHandler->isInputMode()); @@ -364,8 +370,8 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti FrameSelection* controller = focusedFrame->selection(); - IntRect currentStartCaretRect = controller->selection().visibleStart().absoluteCaretBounds(); - IntRect currentEndCaretRect = controller->selection().visibleEnd().absoluteCaretBounds(); + WebCore::IntRect currentStartCaretRect = controller->selection().visibleStart().absoluteCaretBounds(); + WebCore::IntRect currentEndCaretRect = controller->selection().visibleEnd().absoluteCaretBounds(); // Check if the handle movement is valid. if (!shouldUpdateSelectionOrCaretForPoint(relativeStart, currentStartCaretRect, true /* startCaret */) @@ -374,7 +380,7 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti return true; } - IntRect nodeBoundingBox = focusedNode->renderer()->absoluteBoundingBoxRect(); + WebCore::IntRect nodeBoundingBox = focusedNode->renderer()->absoluteBoundingBoxRect(); // Only do special handling if one handle is outside of the node. bool startIsOutsideOfField = relativeStart != DOMSupport::InvalidPoint && !nodeBoundingBox.contains(relativeStart); @@ -387,23 +393,23 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti character = extendSelectionToFieldBoundary(true /* isStartHandle */, relativeStart, newSelection); if (character) { // Invert the selection so that the cursor point is at the beginning. - controller->setSelection(VisibleSelection(controller->selection().end(), controller->selection().start())); + controller->setSelection(VisibleSelection(controller->selection().end(), controller->selection().start(), true /* isDirectional */)); } } else if (endIsOutsideOfField) { character = extendSelectionToFieldBoundary(false /* isStartHandle */, relativeEnd, newSelection); if (character) { // Reset the selection so that the end is the edit point. - controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end())); + controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end(), true /* isDirectional */)); } } if (!character) return false; - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setSelection making selection change attempt using key event %d", character); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::setSelection making selection change attempt using key event %d", character); if (shouldExtendSelectionInDirection(controller->selection(), character)) - m_webPage->m_inputHandler->handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(character, BlackBerry::Platform::KeyboardEvent::KeyDown, KEYMOD_SHIFT)); + m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character, Platform::KeyboardEvent::KeyDown, KEYMOD_SHIFT)); // Must send the selectionPositionChanged every time, sometimes this will duplicate but an accepted // handleNavigationMove may not make an actual selection change. @@ -411,27 +417,7 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti return true; } -IntPoint SelectionHandler::clipPointToFocusNode(const IntPoint& point) -{ - Frame* focusedFrame = m_webPage->focusedOrMainFrame(); - FrameSelection* controller = focusedFrame->selection(); - - if (!focusedFrame->document()->focusedNode() || !focusedFrame->document()->focusedNode()->renderer()) - return point; - - IntRect focusedNodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect(); - focusedNodeBoundingBox.inflate(-1); - - IntPoint clippedPoint = point; - if (!focusedNodeBoundingBox.contains(clippedPoint)) - clippedPoint = IntPoint( - point.x() < focusedNodeBoundingBox.x() ? focusedNodeBoundingBox.x() : std::min(focusedNodeBoundingBox.maxX(), point.x()), - point.y() < focusedNodeBoundingBox.y() ? focusedNodeBoundingBox.y() : std::min(focusedNodeBoundingBox.maxY(), point.y())); - - return clippedPoint; -} - -void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) +void SelectionHandler::setSelection(const WebCore::IntPoint& start, const WebCore::IntPoint& end) { m_selectionActive = true; @@ -442,7 +428,7 @@ void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) Frame* focusedFrame = m_webPage->focusedOrMainFrame(); FrameSelection* controller = focusedFrame->selection(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setSelection adjusted points %d, %d, %d, %d", start.x(), start.y(), end.x(), end.y()); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::setSelection adjusted points %d, %d, %d, %d", start.x(), start.y(), end.x(), end.y()); // Note that IntPoint(-1, -1) is being our sentinel so far for // clipped out selection starting or ending location. @@ -452,20 +438,20 @@ void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) // At least one of the locations must be valid. ASSERT(startIsValid || m_lastUpdatedEndPointIsValid); - IntPoint relativeStart = start; - IntPoint relativeEnd = end; + WebCore::IntPoint relativeStart = start; + WebCore::IntPoint relativeEnd = end; VisibleSelection newSelection(controller->selection()); // We need the selection to be ordered base then extent. if (!controller->selection().isBaseFirst()) - controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end())); + controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end(), true /* isDirectional */)); if (startIsValid) { relativeStart = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, start); // Set the selection with validation. - newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToFocusNode(relativeStart))); + newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(start))); // Reset the selection using the existing extent without validation. newSelection.setWithoutValidation(newSelection.base(), controller->selection().end()); @@ -475,12 +461,14 @@ void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) relativeEnd = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, end); // Set the selection with validation. - newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToFocusNode(relativeEnd))); + newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(end))); // Reset the selection using the existing base without validation. newSelection.setWithoutValidation(controller->selection().start(), newSelection.extent()); } + newSelection.setIsDirectional(true); + if (m_webPage->m_inputHandler->isInputMode()) { if (updateOrHandleInputSelection(newSelection, relativeStart, relativeEnd)) return; @@ -494,7 +482,7 @@ void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) // If the selection size is reduce to less than a character, selection type becomes // Caret. As long as it is still a range, it's a valid selection. Selection cannot // be cancelled through this function. - BlackBerry::Platform::IntRectRegion region; + IntRectRegion region; getConsolidatedRegionOfTextQuadsForSelection(newSelection, region); clipRegionToVisibleContainer(region); if (!region.isEmpty()) { @@ -504,12 +492,12 @@ void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) controller->setSelection(newSelection); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated"); } else { // Requested selection results in an empty selection, skip this change. selectionPositionChanged(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelWarn, "SelectionHandler::setSelection selection points invalid, selection not updated"); + DEBUG_SELECTION(LogLevelWarn, "SelectionHandler::setSelection selection points invalid, selection not updated"); } } @@ -526,7 +514,7 @@ static Node* enclosingLinkEventParentForNode(Node* node) return linkNode && linkNode->isLink() ? linkNode : 0; } -void SelectionHandler::selectAtPoint(const IntPoint& location) +void SelectionHandler::selectAtPoint(const WebCore::IntPoint& location) { // If point is invalid trigger selection based expansion. if (location == DOMSupport::InvalidPoint) { @@ -535,7 +523,7 @@ void SelectionHandler::selectAtPoint(const IntPoint& location) } Node* targetNode; - IntPoint targetPosition; + WebCore::IntPoint targetPosition; // FIXME: Factory this get right fat finger code into a helper. const FatFingersResult lastFatFingersResult = m_webPage->m_touchEventHandler->lastFatFingersResult(); if (lastFatFingersResult.positionWasAdjusted() && lastFatFingersResult.nodeAsElementIfApplicable()) { @@ -584,15 +572,15 @@ static bool expandSelectionToGranularity(Frame* frame, VisibleSelection selectio return frame->selection()->setSelectedRange(newRange.get(), affinity, true); } -void SelectionHandler::selectObject(const IntPoint& location, TextGranularity granularity) +void SelectionHandler::selectObject(const WebCore::IntPoint& location, TextGranularity granularity) { ASSERT(location.x() >= 0 && location.y() >= 0); ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection()); Frame* focusedFrame = m_webPage->focusedOrMainFrame(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::selectObject adjusted points %d, %d", location.x(), location.y()); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::selectObject adjusted points %d, %d", location.x(), location.y()); - IntPoint relativePoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, location); + WebCore::IntPoint relativePoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, location); VisiblePosition pointLocation(focusedFrame->visiblePositionForPoint(relativePoint)); VisibleSelection selection = VisibleSelection(pointLocation, pointLocation); @@ -609,7 +597,7 @@ void SelectionHandler::selectObject(TextGranularity granularity) ASSERT(m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection()); Frame* focusedFrame = m_webPage->focusedOrMainFrame(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::selectObject using current selection"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::selectObject using current selection"); // Use the current selection as the selection point. ASSERT(focusedFrame->selection()->selectionType() != VisibleSelection::NoSelection); @@ -626,7 +614,7 @@ void SelectionHandler::selectObject(Node* node) ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection()); Frame* focusedFrame = m_webPage->focusedOrMainFrame(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::selectNode"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::selectNode"); VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(node); focusedFrame->selection()->setSelection(selection); @@ -647,7 +635,7 @@ static TextDirection directionOfEnclosingBlock(FrameSelection* selection) // Returns > 0 if p1 is "closer" to referencePoint, < 0 if p2 is "closer", 0 if they are equidistant. // Because text is usually arranged in horizontal rows, distance is measured along the y-axis, with x-axis used only to break ties. // If rightGravity is true, the right-most x-coordinate is chosen, otherwise teh left-most coordinate is chosen. -static inline int comparePointsToReferencePoint(const IntPoint& p1, const IntPoint& p2, const IntPoint& referencePoint, bool rightGravity) +static inline int comparePointsToReferencePoint(const WebCore::IntPoint& p1, const WebCore::IntPoint& p2, const WebCore::IntPoint& referencePoint, bool rightGravity) { int dy1 = abs(referencePoint.y() - p1.y()); int dy2 = abs(referencePoint.y() - p2.y()); @@ -667,10 +655,10 @@ static inline int comparePointsToReferencePoint(const IntPoint& p1, const IntPoi // NOTE/FIXME: Due to r77286, we are getting off-by-one results in the IntRect class counterpart implementation of the // methods below. As done in r89803, r77928 and a few others, lets use local method to fix it. // We should keep our eyes very open on it, since it can affect BackingStore very badly. -static IntPoint minXMinYCorner(const IntRect& rect) { return rect.location(); } // typically topLeft -static IntPoint maxXMinYCorner(const IntRect& rect) { return IntPoint(rect.x() + rect.width() - 1, rect.y()); } // typically topRight -static IntPoint minXMaxYCorner(const IntRect& rect) { return IntPoint(rect.x(), rect.y() + rect.height() - 1); } // typically bottomLeft -static IntPoint maxXMaxYCorner(const IntRect& rect) { return IntPoint(rect.x() + rect.width() - 1, rect.y() + rect.height() - 1); } // typically bottomRight +static WebCore::IntPoint minXMinYCorner(const WebCore::IntRect& rect) { return rect.location(); } // typically topLeft +static WebCore::IntPoint maxXMinYCorner(const WebCore::IntRect& rect) { return WebCore::IntPoint(rect.x() + rect.width() - 1, rect.y()); } // typically topRight +static WebCore::IntPoint minXMaxYCorner(const WebCore::IntRect& rect) { return WebCore::IntPoint(rect.x(), rect.y() + rect.height() - 1); } // typically bottomLeft +static WebCore::IntPoint maxXMaxYCorner(const WebCore::IntRect& rect) { return WebCore::IntPoint(rect.x() + rect.width() - 1, rect.y() + rect.height() - 1); } // typically bottomRight // The caret is a one-pixel wide line down either the right or left edge of a // rect, depending on the text direction. @@ -682,12 +670,12 @@ static inline bool caretIsOnLeft(bool isStartCaret, bool isRTL) return isRTL; } -static inline IntPoint caretLocationForRect(const IntRect& rect, bool isStartCaret, bool isRTL) +static inline WebCore::IntPoint caretLocationForRect(const WebCore::IntRect& rect, bool isStartCaret, bool isRTL) { return caretIsOnLeft(isStartCaret, isRTL) ? minXMinYCorner(rect) : maxXMinYCorner(rect); } -static inline IntPoint caretComparisonPointForRect(const IntRect& rect, bool isStartCaret, bool isRTL) +static inline WebCore::IntPoint caretComparisonPointForRect(const WebCore::IntRect& rect, bool isStartCaret, bool isRTL) { if (isStartCaret) return caretIsOnLeft(isStartCaret, isRTL) ? minXMinYCorner(rect) : maxXMinYCorner(rect); @@ -695,11 +683,11 @@ static inline IntPoint caretComparisonPointForRect(const IntRect& rect, bool isS return caretIsOnLeft(isStartCaret, isRTL) ? minXMaxYCorner(rect) : maxXMaxYCorner(rect); } -static void adjustCaretRects(IntRect& startCaret, bool isStartCaretClippedOut, - IntRect& endCaret, bool isEndCaretClippedOut, - const std::vector<BlackBerry::Platform::IntRect> rectList, - const IntPoint& startReferencePoint, - const IntPoint& endReferencePoint, +static void adjustCaretRects(WebCore::IntRect& startCaret, bool isStartCaretClippedOut, + WebCore::IntRect& endCaret, bool isEndCaretClippedOut, + const std::vector<Platform::IntRect> rectList, + const WebCore::IntPoint& startReferencePoint, + const WebCore::IntPoint& endReferencePoint, bool isRTL) { // startReferencePoint is the best guess at the top left of the selection; endReferencePoint is the best guess at the bottom right. @@ -725,7 +713,7 @@ static void adjustCaretRects(IntRect& startCaret, bool isStartCaretClippedOut, endCaret.setWidth(1); for (unsigned i = 1; i < rectList.size(); i++) { - IntRect currentRect(rectList[i]); + WebCore::IntRect currentRect(rectList[i]); // Compare and update the start and end carets with their respective reference points. if (!isStartCaretClippedOut && comparePointsToReferencePoint( @@ -746,7 +734,7 @@ static void adjustCaretRects(IntRect& startCaret, bool isStartCaretClippedOut, } } -void SelectionHandler::clipRegionToVisibleContainer(BlackBerry::Platform::IntRectRegion& region) +void SelectionHandler::clipRegionToVisibleContainer(IntRectRegion& region) { ASSERT(m_webPage->m_mainFrame && m_webPage->m_mainFrame->view()); @@ -754,10 +742,10 @@ void SelectionHandler::clipRegionToVisibleContainer(BlackBerry::Platform::IntRec // Don't allow the region to extend outside of the all its ancestor frames' visible area. if (frame != m_webPage->mainFrame()) { - IntRect containingContentRect; + WebCore::IntRect containingContentRect; containingContentRect = m_webPage->getRecursiveVisibleWindowRect(frame->view(), true /* no clip to main frame window */); containingContentRect = m_webPage->m_mainFrame->view()->windowToContents(containingContentRect); - region = intersectRegions(BlackBerry::Platform::IntRectRegion(containingContentRect), region); + region = intersectRegions(IntRectRegion(containingContentRect), region); } // Don't allow the region to extend outside of the input field. @@ -766,20 +754,38 @@ void SelectionHandler::clipRegionToVisibleContainer(BlackBerry::Platform::IntRec && frame->document()->focusedNode()->renderer()) { // Adjust the bounding box to the frame offset. - IntRect boundingBox(frame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect()); + WebCore::IntRect boundingBox(frame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect()); boundingBox = m_webPage->mainFrame()->view()->windowToContents(frame->view()->contentsToWindow(boundingBox)); - region = intersectRegions(BlackBerry::Platform::IntRectRegion(boundingBox), region); + region = intersectRegions(IntRectRegion(boundingBox), region); } } -static IntPoint referencePoint(const VisiblePosition& position, const IntRect& boundingRect, const IntPoint& framePosition, bool isStartCaret, bool isRTL) +WebCore::IntPoint SelectionHandler::clipPointToVisibleContainer(const WebCore::IntPoint& point) const +{ + ASSERT(m_webPage->m_mainFrame && m_webPage->m_mainFrame->view()); + + Frame* frame = m_webPage->focusedOrMainFrame(); + WebCore::IntPoint clippedPoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), frame, point, true /* clampToTargetFrame */); + + if (m_webPage->m_inputHandler->isInputMode() + && frame->document()->focusedNode() + && frame->document()->focusedNode()->renderer()) { + WebCore::IntRect boundingBox(frame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect()); + boundingBox.inflate(-1); + clippedPoint = WebCore::IntPoint(clamp(boundingBox.x(), clippedPoint.x(), boundingBox.maxX()), clamp(boundingBox.y(), clippedPoint.y(), boundingBox.maxY())); + } + + return clippedPoint; +} + +static WebCore::IntPoint referencePoint(const VisiblePosition& position, const WebCore::IntRect& boundingRect, const WebCore::IntPoint& framePosition, bool isStartCaret, bool isRTL) { // If one of the carets is invalid (this happens, for instance, if the // selection ends in an empty div) fall back to using the corner of the // entire region (which is already in frame coordinates so doesn't need // adjusting). - IntRect startCaretBounds(position.absoluteCaretBounds()); + WebCore::IntRect startCaretBounds(position.absoluteCaretBounds()); if (startCaretBounds.isEmpty()) startCaretBounds = boundingRect; else @@ -792,7 +798,7 @@ static IntPoint referencePoint(const VisiblePosition& position, const IntRect& b // system is not entirely WebKit. void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) { - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::selectionPositionChanged visibleChangeOnly = %s", visualChangeOnly ? "true" : "false"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::selectionPositionChanged visibleChangeOnly = %s", visualChangeOnly ? "true" : "false"); // This method can get called during WebPage shutdown process. // If that is the case, just bail out since the client is not @@ -813,7 +819,7 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) // Enter selection mode if selection type is RangeSelection, and disable selection if // selection is active and becomes caret selection. Frame* frame = m_webPage->focusedOrMainFrame(); - IntPoint framePos = m_webPage->frameOffset(frame); + WebCore::IntPoint framePos = m_webPage->frameOffset(frame); if (m_selectionActive && (m_caretActive || frame->selection()->isNone())) m_selectionActive = false; else if (frame->selection()->isRange()) @@ -821,11 +827,11 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) else if (!m_selectionActive) return; - IntRect startCaret; - IntRect endCaret; + WebCore::IntRect startCaret; + WebCore::IntRect endCaret; // Get the text rects from the selections range. - BlackBerry::Platform::IntRectRegion region; + IntRectRegion region; getConsolidatedRegionOfTextQuadsForSelection(frame->selection()->selection(), region); // If there is no change in selected text and the visual rects @@ -836,15 +842,15 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) m_lastSelectionRegion = region; if (!region.isEmpty()) { - IntRect unclippedStartCaret; - IntRect unclippedEndCaret; + WebCore::IntRect unclippedStartCaret; + WebCore::IntRect unclippedEndCaret; bool isRTL = directionOfEnclosingBlock(frame->selection()) == RTL; - std::vector<BlackBerry::Platform::IntRect> rectList = region.rects(); + std::vector<Platform::IntRect> rectList = region.rects(); - IntPoint startCaretReferencePoint = referencePoint(frame->selection()->selection().visibleStart(), region.extents(), framePos, true /* isStartCaret */, isRTL); - IntPoint endCaretReferencePoint = referencePoint(frame->selection()->selection().visibleEnd(), region.extents(), framePos, false /* isStartCaret */, isRTL); + WebCore::IntPoint startCaretReferencePoint = referencePoint(frame->selection()->selection().visibleStart(), region.extents(), framePos, true /* isStartCaret */, isRTL); + WebCore::IntPoint endCaretReferencePoint = referencePoint(frame->selection()->selection().visibleEnd(), region.extents(), framePos, false /* isStartCaret */, isRTL); adjustCaretRects(unclippedStartCaret, false /* unclipped */, unclippedEndCaret, false /* unclipped */, rectList, startCaretReferencePoint, endCaretReferencePoint, isRTL); @@ -852,9 +858,9 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) #if SHOWDEBUG_SELECTIONHANDLER // Don't rely just on DEBUG_SELECTION to avoid loop. for (unsigned int i = 0; i < rectList.size(); i++) - DEBUG_SELECTION(BlackBerry::Platform::LogLevelCritical, "Rect list - Unmodified #%d, (%d, %d) (%d x %d)", i, rectList[i].x(), rectList[i].y(), rectList[i].width(), rectList[i].height()); + DEBUG_SELECTION(LogLevelCritical, "Rect list - Unmodified #%d, (%d, %d) (%d x %d)", i, rectList[i].x(), rectList[i].y(), rectList[i].width(), rectList[i].height()); for (unsigned int i = 0; i < region.numRects(); i++) - DEBUG_SELECTION(BlackBerry::Platform::LogLevelCritical, "Rect list - Consolidated #%d, (%d, %d) (%d x %d)", i, region.rects()[i].x(), region.rects()[i].y(), region.rects()[i].width(), region.rects()[i].height()); + DEBUG_SELECTION(LogLevelCritical, "Rect list - Consolidated #%d, (%d, %d) (%d x %d)", i, region.rects()[i].x(), region.rects()[i].y(), region.rects()[i].width(), region.rects()[i].height()); #endif bool shouldCareAboutPossibleClippedOutSelection = frame != m_webPage->mainFrame() || m_webPage->m_inputHandler->isInputMode(); @@ -868,7 +874,7 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) bool shouldClipEndCaret = !region.isRectInRegion(unclippedEndCaret); // Find the top corner and bottom corner. - std::vector<BlackBerry::Platform::IntRect> clippedRectList = region.rects(); + std::vector<Platform::IntRect> clippedRectList = region.rects(); adjustCaretRects(startCaret, shouldClipStartCaret, endCaret, shouldClipEndCaret, clippedRectList, startCaretReferencePoint, endCaretReferencePoint, isRTL); // Translate the caret values as they must be in transformed coordinates. @@ -894,9 +900,9 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly) // NOTE: This function is not in WebKit coordinates. void SelectionHandler::caretPositionChanged() { - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::caretPositionChanged"); + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::caretPositionChanged"); - IntRect caretLocation; + WebCore::IntRect caretLocation; // If the input field is not active, we must be turning off the caret. if (!m_webPage->m_inputHandler->isInputMode() && m_caretActive) { m_caretActive = false; @@ -911,20 +917,20 @@ void SelectionHandler::caretPositionChanged() ASSERT(m_webPage->m_inputHandler->isInputMode()); if (m_webPage->focusedOrMainFrame()->selection()->selectionType() == VisibleSelection::CaretSelection) { - IntPoint frameOffset = m_webPage->frameOffset(m_webPage->focusedOrMainFrame()); + WebCore::IntPoint frameOffset = m_webPage->frameOffset(m_webPage->focusedOrMainFrame()); caretLocation = m_webPage->focusedOrMainFrame()->selection()->selection().visibleStart().absoluteCaretBounds(); caretLocation.move(frameOffset.x(), frameOffset.y()); // Clip against the containing frame and node boundaries. - BlackBerry::Platform::IntRectRegion region(caretLocation); + IntRectRegion region(caretLocation); clipRegionToVisibleContainer(region); caretLocation = region.extents(); } m_caretActive = !caretLocation.isEmpty(); - DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::caretPositionChanged caret Rect %d, %d, %dx%d", + DEBUG_SELECTION(LogLevelInfo, "SelectionHandler::caretPositionChanged caret Rect %d, %d, %dx%d", caretLocation.x(), caretLocation.y(), caretLocation.width(), caretLocation.height()); caretLocation = m_webPage->mapToTransformed(caretLocation); @@ -933,7 +939,7 @@ void SelectionHandler::caretPositionChanged() m_webPage->m_client->notifyCaretChanged(caretLocation, m_webPage->m_touchEventHandler->lastFatFingersResult().isTextInput() /* userTouchTriggered */); } -bool SelectionHandler::selectionContains(const IntPoint& point) +bool SelectionHandler::selectionContains(const WebCore::IntPoint& point) { ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection()); return m_webPage->focusedOrMainFrame()->selection()->contains(point); diff --git a/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h b/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h index 8c5fe7637..41a69f8f6 100644 --- a/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h +++ b/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h @@ -76,7 +76,7 @@ private: WebCore::Node* DOMContainerNodeForVisiblePosition(const WebCore::VisiblePosition&) const; bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const; unsigned short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection); - WebCore::IntPoint clipPointToFocusNode(const WebCore::IntPoint&); + WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const; WebPagePrivate* m_webPage; diff --git a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp b/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp index 2642f39e3..5f0a2770a 100644 --- a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp @@ -38,7 +38,7 @@ namespace WebKit { #if USE(ACCELERATED_COMPOSITING) && ENABLE_COMPOSITING_SURFACE static PassRefPtr<BackingStoreCompositingSurface> createCompositingSurface() { - BlackBerry::Platform::IntSize screenSize = BlackBerry::Platform::Graphics::Screen::size(); + BlackBerry::Platform::IntSize screenSize = BlackBerry::Platform::Graphics::Screen::primaryScreen()->size(); return BackingStoreCompositingSurface::create(screenSize, false /*doubleBuffered*/); } #endif diff --git a/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp b/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp index fcbc1acff..91a4eb21d 100644 --- a/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp +++ b/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.cpp @@ -21,9 +21,13 @@ #if USE(ACCELERATED_COMPOSITING) #include "WebPageCompositor.h" +#include "BackingStore_p.h" #include "LayerWebKitThread.h" #include "WebPage_p.h" +#include <BlackBerryPlatformExecutableMessage.h> +#include <BlackBerryPlatformMessage.h> +#include <BlackBerryPlatformMessageClient.h> #include <GenericTimerClient.h> #include <ThreadTimerClient.h> @@ -38,15 +42,15 @@ WebPageCompositor::WebPageCompositor(WebPagePrivate* page) , m_generation(0) , m_compositedGeneration(-1) , m_compositingOntoMainWindow(false) - , m_blitTimer(this, &BlackBerry::WebKit::WebPageCompositor::blitTimerFired) - , m_timerClient(new BlackBerry::Platform::GenericTimerClient(BlackBerry::Platform::userInterfaceThreadTimerClient())) + , m_animationTimer(this, &WebPageCompositor::animationTimerFired) + , m_timerClient(new Platform::GenericTimerClient(Platform::userInterfaceThreadTimerClient())) { - m_blitTimer.setClient(m_timerClient); + m_animationTimer.setClient(m_timerClient); } WebPageCompositor::~WebPageCompositor() { - m_blitTimer.stop(); + m_animationTimer.stop(); delete m_timerClient; } @@ -93,7 +97,7 @@ bool WebPageCompositor::drawLayers(const IntRect& dstRect, const FloatRect& cont if (m_lastCompositingResults.needsAnimationFrame) { ++m_generation; // The animation update moves us along one generation. // Using a timeout of 0 actually won't start a timer, it will send a message. - m_blitTimer.start(1.0 / 60.0); + m_animationTimer.start(1.0 / 60.0); m_webPage->updateDelegatedOverlays(); } @@ -105,8 +109,18 @@ void WebPageCompositor::releaseLayerResources() m_layerRenderer->releaseLayerResources(); } -void WebPageCompositor::blitTimerFired() +void WebPageCompositor::animationTimerFired() { + if (m_webPage->m_backingStore->d->shouldDirectRenderingToWindow()) { + if (m_webPage->m_backingStore->d->isDirectRenderingAnimationMessageScheduled()) + return; // don't send new messages as long as we haven't rerendered + + m_webPage->m_backingStore->d->setDirectRenderingAnimationMessageScheduled(); + BlackBerry::Platform::webKitThreadMessageClient()->dispatchMessage( + BlackBerry::Platform::createMethodCallMessage( + &BackingStorePrivate::renderVisibleContents, m_webPage->m_backingStore->d)); + return; + } m_webPage->blitVisibleContents(); } diff --git a/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h b/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h index 437ab95e0..aa0a9a8c0 100644 --- a/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h +++ b/Source/WebKit/blackberry/WebKitSupport/WebPageCompositor.h @@ -65,7 +65,7 @@ public: void releaseLayerResources(); private: - void blitTimerFired(); + void animationTimerFired(); WebPagePrivate* m_webPage; OwnPtr<WebCore::LayerRenderer> m_layerRenderer; @@ -78,7 +78,7 @@ private: WebCore::IntRect m_compositedDstRect; WebCore::FloatRect m_compositedContentsRect; bool m_compositingOntoMainWindow; - BlackBerry::Platform::Timer<WebPageCompositor> m_blitTimer; + BlackBerry::Platform::Timer<WebPageCompositor> m_animationTimer; BlackBerry::Platform::TimerClient* m_timerClient; }; diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 797b31c6c..8fe572481 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,1792 @@ +2012-03-11 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r110359. + http://trac.webkit.org/changeset/110359 + https://bugs.webkit.org/show_bug.cgi?id=80799 + + SelectPopupMenuTest.ClickItem failure (Requested by ukai on + #webkit). + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::gestureEvent): + (WebKit::WebViewImpl::applyAutofillSuggestions): + +2012-03-11 Pavel Feldman <pfeldman@chromium.org> + + Web Inspector: [chromium] add provisional test for the downstream sanity test. + https://bugs.webkit.org/show_bug.cgi?id=80784 + + Reviewed by Yury Semikhatsky. + + * src/js/Tests.js: + (.TestSuite.prototype.checkLogAndErrorMessages.validMessage): + (.TestSuite.prototype.checkLogAndErrorMessages.onConsoleMessage): + (.TestSuite.prototype.checkLogAndErrorMessages): + +2012-03-10 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r110384. + http://trac.webkit.org/changeset/110384 + https://bugs.webkit.org/show_bug.cgi?id=80774 + + compile failed on Chromium Win Release (Requested by ukai_home + on #webkit). + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::LayerChromiumWithForcedDrawsContent::LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::opaqueContentsRegion): + (WebCore::LayerChromiumWithForcedDrawsContent::setOpaquePaintRect): + (LayerChromiumWithForcedDrawsContent): + (WebCore::setLayerPropertiesForTesting): + (WebCore): + (WebCore::TestCCOcclusionTracker::TestCCOcclusionTracker): + (WebCore::TestCCOcclusionTracker::occlusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::occlusionInTargetSurface): + (WebCore::TestCCOcclusionTracker::setOcclusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::setOcclusionInTargetSurface): + (WebCore::TestCCOcclusionTracker::layerScissorRectInTargetSurface): + (WebCore::TestDamageClient::damageRect): + (WebCore::layerAddedToOccludedRegion): + (WebCore::layerAddedToOccludedRegionWithRotation): + (WebCore::layerAddedToOccludedRegionWithTranslation): + (WebCore::layerAddedToOccludedRegionWithRotatedSurface): + (WebCore::layerAddedToOccludedRegionWithSurfaceAlreadyOnStack): + (WebCore::layerAddedToOccludedRegionWithRotatedOffAxisSurface): + (WebCore::layerAddedToOccludedRegionWithMultipleOpaqueLayers): + (WebCore::surfaceOcclusionWithOverlappingSiblingSurfaces): + (WebCore::surfaceOcclusionInScreenSpace): + (WebCore::surfaceOcclusionInScreenSpaceDifferentTransforms): + (WebCore::occlusionInteractionWithFilters): + (WebCore::layerScissorRectOverTile): + (WebCore::screenScissorRectOverTile): + (WebCore::layerScissorRectOverCulledTile): + (WebCore::screenScissorRectOverCulledTile): + (WebCore::layerScissorRectOverPartialTiles): + (WebCore::screenScissorRectOverPartialTiles): + (WebCore::layerScissorRectOverNoTiles): + (WebCore::screenScissorRectOverNoTiles): + (WebCore::layerScissorRectForLayerOffOrigin): + (WebCore::damageRectOverTile): + (WebCore::damageRectOverCulledTile): + (WebCore::damageRectOverPartialTiles): + (WebCore::damageRectOverNoTiles): + (WebCore::TEST): + +2012-03-10 Dana Jansens <danakj@chromium.org> + + [chromium] Clean up culling tests and templatize to test impl constructs + https://bugs.webkit.org/show_bug.cgi?id=80613 + + Reviewed by Adrienne Walker. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::TestContentLayerChromium::TestContentLayerChromium): + (WebCore::TestContentLayerChromium::opaqueContentsRegion): + (WebCore::TestContentLayerChromium::setOpaqueContentsRect): + (TestContentLayerChromium): + (TestContentLayerImpl): + (WebCore::TestContentLayerImpl::TestContentLayerImpl): + (WebCore::TestContentLayerImpl::opaqueContentsRegion): + (WebCore::TestContentLayerImpl::setOpaqueContentsRect): + (WebCore): + (WebCore::TestCCOcclusionTrackerBase::TestCCOcclusionTrackerBase): + (WebCore::TestCCOcclusionTrackerBase::occlusionInScreenSpace): + (WebCore::TestCCOcclusionTrackerBase::occlusionInTargetSurface): + (WebCore::TestCCOcclusionTrackerBase::setOcclusionInScreenSpace): + (WebCore::TestCCOcclusionTrackerBase::setOcclusionInTargetSurface): + (WebCore::TestCCOcclusionTrackerBase::layerScissorRectInTargetSurface): + (WebCore::TestDamageClient::damageRect): + (CCOcclusionTrackerTestMainThreadTypes): + (WebCore::CCOcclusionTrackerTestMainThreadTypes::createLayer): + (WebCore::CCOcclusionTrackerTestMainThreadTypes::createContentLayer): + (CCOcclusionTrackerTestImplThreadTypes): + (WebCore::CCOcclusionTrackerTestImplThreadTypes::createLayer): + (WebCore::CCOcclusionTrackerTestImplThreadTypes::createContentLayer): + (CCOcclusionTrackerTest): + (WebCore::CCOcclusionTrackerTest::TearDown): + (WebCore::CCOcclusionTrackerTest::createRoot): + (WebCore::CCOcclusionTrackerTest::createLayer): + (WebCore::CCOcclusionTrackerTest::createSurface): + (WebCore::CCOcclusionTrackerTest::createDrawingLayer): + (WebCore::CCOcclusionTrackerTest::createDrawingSurface): + (WebCore::CCOcclusionTrackerTest::calcDrawEtc): + (WebCore::CCOcclusionTrackerTest::setBaseProperties): + (WebCore::CCOcclusionTrackerTest::setProperties): + (CCOcclusionTrackerTestIdentityTransforms): + (WebCore::CCOcclusionTrackerTestIdentityTransforms::runMyTest): + (CCOcclusionTrackerTestRotatedChild): + (WebCore::CCOcclusionTrackerTestRotatedChild::runMyTest): + (CCOcclusionTrackerTestTranslatedChild): + (WebCore::CCOcclusionTrackerTestTranslatedChild::runMyTest): + (CCOcclusionTrackerTestChildInRotatedChild): + (WebCore::CCOcclusionTrackerTestChildInRotatedChild::runMyTest): + (CCOcclusionTrackerTestVisitTargetTwoTimes): + (WebCore::CCOcclusionTrackerTestVisitTargetTwoTimes::runMyTest): + (CCOcclusionTrackerTestSurfaceRotatedOffAxis): + (WebCore::CCOcclusionTrackerTestSurfaceRotatedOffAxis::runMyTest): + (CCOcclusionTrackerTestSurfaceWithTwoOpaqueChildren): + (WebCore::CCOcclusionTrackerTestSurfaceWithTwoOpaqueChildren::runMyTest): + (CCOcclusionTrackerTestOverlappingSurfaceSiblings): + (WebCore::CCOcclusionTrackerTestOverlappingSurfaceSiblings::runMyTest): + (CCOcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms): + (WebCore::CCOcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms::runMyTest): + (CCOcclusionTrackerTestFilters): + (WebCore::CCOcclusionTrackerTestFilters::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectOutsideChild): + (WebCore::CCOcclusionTrackerTestLayerScissorRectOutsideChild::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectOutsideChild): + (WebCore::CCOcclusionTrackerTestScreenScissorRectOutsideChild::runMyTest): + (CCOcclusionTrackerTestDamageRectOutsideChild): + (WebCore::CCOcclusionTrackerTestDamageRectOutsideChild::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectOverChild): + (WebCore::CCOcclusionTrackerTestLayerScissorRectOverChild::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectOverChild): + (WebCore::CCOcclusionTrackerTestScreenScissorRectOverChild::runMyTest): + (CCOcclusionTrackerTestDamageRectOverChild): + (WebCore::CCOcclusionTrackerTestDamageRectOverChild::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectPartlyOverChild): + (WebCore::CCOcclusionTrackerTestLayerScissorRectPartlyOverChild::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectPartlyOverChild): + (WebCore::CCOcclusionTrackerTestScreenScissorRectPartlyOverChild::runMyTest): + (CCOcclusionTrackerTestDamageRectPartlyOverChild): + (WebCore::CCOcclusionTrackerTestDamageRectPartlyOverChild::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectOverNothing): + (WebCore::CCOcclusionTrackerTestLayerScissorRectOverNothing::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectOverNothing): + (WebCore::CCOcclusionTrackerTestScreenScissorRectOverNothing::runMyTest): + (CCOcclusionTrackerTestDamageRectOverNothing): + (WebCore::CCOcclusionTrackerTestDamageRectOverNothing::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectForLayerOffOrigin): + (WebCore::CCOcclusionTrackerTestLayerScissorRectForLayerOffOrigin::runMyTest): + (CCOcclusionTrackerTestOpaqueContentsRegionEmpty): + (WebCore::CCOcclusionTrackerTestOpaqueContentsRegionEmpty::runMyTest): + (CCOcclusionTrackerTestOpaqueContentsRegionNonEmpty): + (WebCore::CCOcclusionTrackerTestOpaqueContentsRegionNonEmpty::runMyTest): + +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * src/AssertMatchingEnums.cpp: + * src/NotificationPresenterImpl.cpp: + (WebKit::NotificationPresenterImpl::checkPermission): + * src/NotificationPresenterImpl.h: + (NotificationPresenterImpl): + +2012-03-10 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r110363. + http://trac.webkit.org/changeset/110363 + https://bugs.webkit.org/show_bug.cgi?id=80757 + + link error in chromium: unresolved external symbol + webkit_support::CreateScopedTempDirectory(void) (Requested by + ukai_home on #webkit). + + * WebKit.gypi: + * tests/LevelDBTest.cpp: Removed. + +2012-03-10 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r110353. + http://trac.webkit.org/changeset/110353 + https://bugs.webkit.org/show_bug.cgi?id=80752 + + copmile failed on Chromium (Requested by ukai_home on + #webkit). + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::LayerChromiumWithForcedDrawsContent::LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::opaqueContentsRegion): + (WebCore::LayerChromiumWithForcedDrawsContent::setOpaquePaintRect): + (LayerChromiumWithForcedDrawsContent): + (WebCore::setLayerPropertiesForTesting): + (WebCore): + (WebCore::TestCCOcclusionTracker::TestCCOcclusionTracker): + (WebCore::TestCCOcclusionTracker::occlusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::occlusionInTargetSurface): + (WebCore::TestCCOcclusionTracker::setOcclusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::setOcclusionInTargetSurface): + (WebCore::TestCCOcclusionTracker::layerScissorRectInTargetSurface): + (WebCore::TestDamageClient::damageRect): + (WebCore::layerAddedToOccludedRegion): + (WebCore::layerAddedToOccludedRegionWithRotation): + (WebCore::layerAddedToOccludedRegionWithTranslation): + (WebCore::layerAddedToOccludedRegionWithRotatedSurface): + (WebCore::layerAddedToOccludedRegionWithSurfaceAlreadyOnStack): + (WebCore::layerAddedToOccludedRegionWithRotatedOffAxisSurface): + (WebCore::layerAddedToOccludedRegionWithMultipleOpaqueLayers): + (WebCore::surfaceOcclusionWithOverlappingSiblingSurfaces): + (WebCore::surfaceOcclusionInScreenSpace): + (WebCore::surfaceOcclusionInScreenSpaceDifferentTransforms): + (WebCore::occlusionInteractionWithFilters): + (WebCore::layerScissorRectOverTile): + (WebCore::screenScissorRectOverTile): + (WebCore::layerScissorRectOverCulledTile): + (WebCore::screenScissorRectOverCulledTile): + (WebCore::layerScissorRectOverPartialTiles): + (WebCore::screenScissorRectOverPartialTiles): + (WebCore::layerScissorRectOverNoTiles): + (WebCore::screenScissorRectOverNoTiles): + (WebCore::layerScissorRectForLayerOffOrigin): + (WebCore::damageRectOverTile): + (WebCore::damageRectOverCulledTile): + (WebCore::damageRectOverPartialTiles): + (WebCore::damageRectOverNoTiles): + (WebCore::TEST): + +2012-03-09 Robert Kroeger <rjkroege@chromium.org> + + Handle more Gesture* events by performing scrolls on the correct target ScrollableArea + https://bugs.webkit.org/show_bug.cgi?id=80311 + + Added a unit test for the changes to ScrollAnimatorNone to make sure that the two-call + transport of fling parameters is correctly delivered. + + Reviewed by James Robinson. + + * tests/ScrollAnimatorNoneTest.cpp: + (MockScrollAnimatorNone): + (MockScrollAnimatorNone::reset): + (MockScrollAnimatorNone::fireUpAnAnimation): + (TEST): + +2012-03-07 James Robinson <jamesr@chromium.org> + + [chromium] Deprecate renderDirectlyToWebView parameter of WebViewClient::createGraphicsContext3D() + https://bugs.webkit.org/show_bug.cgi?id=80523 + + Reviewed by Darin Fisher. + + * public/WebViewClient.h: + (WebViewClient): + (WebKit::WebViewClient::createGraphicsContext3D): + * public/platform/WebKitPlatformSupport.h: + (WebKit): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::createCompositorGraphicsContext3D): + +2012-03-09 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Handle LevelDB database corruption + https://bugs.webkit.org/show_bug.cgi?id=79413 + + Reviewed by Tony Chang. + + * WebKit.gypi: + * tests/LevelDBTest.cpp: Added. + (WebCore): + (SimpleComparator): + (WebCore::SimpleComparator::compare): + (WebCore::SimpleComparator::name): + (WebCore::encodeString): + (WebCore::TEST): + +2012-03-09 Tim Dresser <tdresser@chromium.org> + + [chromium] Increase size of Combo Box Options for touch and high DPI devices + https://bugs.webkit.org/show_bug.cgi?id=80027 + + Reviewed by Darin Fisher. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::gestureEvent): + (WebKit::WebViewImpl::applyAutofillSuggestions): + +2012-03-09 James Robinson <jamesr@chromium.org> + + [chromium] Roll chromium DEPS to r125600 + https://bugs.webkit.org/show_bug.cgi?id=80722 + + Unreviewed + + * DEPS: + +2012-03-09 Dana Jansens <danakj@chromium.org> + + [chromium] Clean up culling tests and templatize to test impl constructs + https://bugs.webkit.org/show_bug.cgi?id=80613 + + Reviewed by Adrienne Walker. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::TestContentLayerChromium::TestContentLayerChromium): + (WebCore::TestContentLayerChromium::opaqueContentsRegion): + (WebCore::TestContentLayerChromium::setOpaqueContentsRect): + (TestContentLayerChromium): + (TestContentLayerImpl): + (WebCore::TestContentLayerImpl::TestContentLayerImpl): + (WebCore::TestContentLayerImpl::opaqueContentsRegion): + (WebCore::TestContentLayerImpl::setOpaqueContentsRect): + (WebCore): + (WebCore::TestCCOcclusionTrackerBase::TestCCOcclusionTrackerBase): + (WebCore::TestCCOcclusionTrackerBase::occlusionInScreenSpace): + (WebCore::TestCCOcclusionTrackerBase::occlusionInTargetSurface): + (WebCore::TestCCOcclusionTrackerBase::setOcclusionInScreenSpace): + (WebCore::TestCCOcclusionTrackerBase::setOcclusionInTargetSurface): + (WebCore::TestCCOcclusionTrackerBase::layerScissorRectInTargetSurface): + (WebCore::TestDamageClient::damageRect): + (CCOcclusionTrackerTestMainThreadTypes): + (WebCore::CCOcclusionTrackerTestMainThreadTypes::createLayer): + (WebCore::CCOcclusionTrackerTestMainThreadTypes::createContentLayer): + (CCOcclusionTrackerTestImplThreadTypes): + (WebCore::CCOcclusionTrackerTestImplThreadTypes::createLayer): + (WebCore::CCOcclusionTrackerTestImplThreadTypes::createContentLayer): + (CCOcclusionTrackerTest): + (WebCore::CCOcclusionTrackerTest::TearDown): + (WebCore::CCOcclusionTrackerTest::createRoot): + (WebCore::CCOcclusionTrackerTest::createLayer): + (WebCore::CCOcclusionTrackerTest::createSurface): + (WebCore::CCOcclusionTrackerTest::createDrawingLayer): + (WebCore::CCOcclusionTrackerTest::createDrawingSurface): + (WebCore::CCOcclusionTrackerTest::calcDrawEtc): + (WebCore::CCOcclusionTrackerTest::setBaseProperties): + (WebCore::CCOcclusionTrackerTest::setProperties): + (CCOcclusionTrackerTestIdentityTransforms): + (WebCore::CCOcclusionTrackerTestIdentityTransforms::runMyTest): + (CCOcclusionTrackerTestRotatedChild): + (WebCore::CCOcclusionTrackerTestRotatedChild::runMyTest): + (CCOcclusionTrackerTestTranslatedChild): + (WebCore::CCOcclusionTrackerTestTranslatedChild::runMyTest): + (CCOcclusionTrackerTestChildInRotatedChild): + (WebCore::CCOcclusionTrackerTestChildInRotatedChild::runMyTest): + (CCOcclusionTrackerTestVisitTargetTwoTimes): + (WebCore::CCOcclusionTrackerTestVisitTargetTwoTimes::runMyTest): + (CCOcclusionTrackerTestSurfaceRotatedOffAxis): + (WebCore::CCOcclusionTrackerTestSurfaceRotatedOffAxis::runMyTest): + (CCOcclusionTrackerTestSurfaceWithTwoOpaqueChildren): + (WebCore::CCOcclusionTrackerTestSurfaceWithTwoOpaqueChildren::runMyTest): + (CCOcclusionTrackerTestOverlappingSurfaceSiblings): + (WebCore::CCOcclusionTrackerTestOverlappingSurfaceSiblings::runMyTest): + (CCOcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms): + (WebCore::CCOcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms::runMyTest): + (CCOcclusionTrackerTestFilters): + (WebCore::CCOcclusionTrackerTestFilters::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectOutsideChild): + (WebCore::CCOcclusionTrackerTestLayerScissorRectOutsideChild::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectOutsideChild): + (WebCore::CCOcclusionTrackerTestScreenScissorRectOutsideChild::runMyTest): + (CCOcclusionTrackerTestDamageRectOutsideChild): + (WebCore::CCOcclusionTrackerTestDamageRectOutsideChild::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectOverChild): + (WebCore::CCOcclusionTrackerTestLayerScissorRectOverChild::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectOverChild): + (WebCore::CCOcclusionTrackerTestScreenScissorRectOverChild::runMyTest): + (CCOcclusionTrackerTestDamageRectOverChild): + (WebCore::CCOcclusionTrackerTestDamageRectOverChild::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectPartlyOverChild): + (WebCore::CCOcclusionTrackerTestLayerScissorRectPartlyOverChild::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectPartlyOverChild): + (WebCore::CCOcclusionTrackerTestScreenScissorRectPartlyOverChild::runMyTest): + (CCOcclusionTrackerTestDamageRectPartlyOverChild): + (WebCore::CCOcclusionTrackerTestDamageRectPartlyOverChild::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectOverNothing): + (WebCore::CCOcclusionTrackerTestLayerScissorRectOverNothing::runMyTest): + (CCOcclusionTrackerTestScreenScissorRectOverNothing): + (WebCore::CCOcclusionTrackerTestScreenScissorRectOverNothing::runMyTest): + (CCOcclusionTrackerTestDamageRectOverNothing): + (WebCore::CCOcclusionTrackerTestDamageRectOverNothing::runMyTest): + (CCOcclusionTrackerTestLayerScissorRectForLayerOffOrigin): + (WebCore::CCOcclusionTrackerTestLayerScissorRectForLayerOffOrigin::runMyTest): + (CCOcclusionTrackerTestOpaqueContentsRegionEmpty): + (WebCore::CCOcclusionTrackerTestOpaqueContentsRegionEmpty::runMyTest): + (CCOcclusionTrackerTestOpaqueContentsRegionNonEmpty): + (WebCore::CCOcclusionTrackerTestOpaqueContentsRegionNonEmpty::runMyTest): + +2012-03-09 Emil A Eklund <eae@chromium.org> + + Add roundedPoint to HitTestResult and change platform code to use it + https://bugs.webkit.org/show_bug.cgi?id=80715 + + Reviewed by James Robinson. + + Change ports to use roundedPoint to avoid exposing subpixel types to + platform code. + + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::mouseDidMoveOverElement): + * src/ContextMenuClientImpl.cpp: + (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): + +2012-03-09 W. James MacLean <wjmaclean@chromium.org> + + [chromium] Implement scroll physics architecture for impl/main thread + https://bugs.webkit.org/show_bug.cgi?id=79827 + + Reviewed by James Robinson. + + * WebKit.gypi: + * tests/PlatformGestureCurveTest.cpp: Added. + +2012-03-09 Tien-Ren Chen <trchen@chromium.org> + + [chromium] ScrollbarLayerChromium/CCScrollbarLayerImpl for CC-side scrollbar painting + https://bugs.webkit.org/show_bug.cgi?id=78872 + + Reviewed by James Robinson. + + * WebKit.gypi: + * tests/ScrollbarLayerChromiumTest.cpp: Added. + (WebCore): + (MockScrollbar): + (WebCore::MockScrollbar::x): + (WebCore::MockScrollbar::y): + (WebCore::MockScrollbar::width): + (WebCore::MockScrollbar::height): + (WebCore::MockScrollbar::size): + (WebCore::MockScrollbar::location): + (WebCore::MockScrollbar::parent): + (WebCore::MockScrollbar::root): + (WebCore::MockScrollbar::setFrameRect): + (WebCore::MockScrollbar::frameRect): + (WebCore::MockScrollbar::invalidate): + (WebCore::MockScrollbar::invalidateRect): + (WebCore::MockScrollbar::scrollbarOverlayStyle): + (WebCore::MockScrollbar::getTickmarks): + (WebCore::MockScrollbar::isScrollableAreaActive): + (WebCore::MockScrollbar::isScrollViewScrollbar): + (WebCore::MockScrollbar::convertFromContainingWindow): + (WebCore::MockScrollbar::isCustomScrollbar): + (WebCore::MockScrollbar::orientation): + (WebCore::MockScrollbar::value): + (WebCore::MockScrollbar::currentPos): + (WebCore::MockScrollbar::visibleSize): + (WebCore::MockScrollbar::totalSize): + (WebCore::MockScrollbar::maximum): + (WebCore::MockScrollbar::controlSize): + (WebCore::MockScrollbar::lineStep): + (WebCore::MockScrollbar::pageStep): + (WebCore::MockScrollbar::pressedPart): + (WebCore::MockScrollbar::hoveredPart): + (WebCore::MockScrollbar::styleChanged): + (WebCore::MockScrollbar::enabled): + (WebCore::MockScrollbar::setEnabled): + (WebCore::MockScrollbar::MockScrollbar): + (WebCore::MockScrollbar::~MockScrollbar): + (WebCore::TEST): + +2012-03-08 James Robinson <jamesr@chromium.org> + + [chromium] Expose the shared graphics context on WebView so callers can allocate resources on the main thread for the compositor to use + https://bugs.webkit.org/show_bug.cgi?id=80670 + + Reviewed by Stephen White. + + This exposes a context on WebView that is in the compositor's share group and can be used directly from the main + thread. This is useful for content that needs to allocate resources for the compositor to use, but cannot + directly use the compositor's context either because it cannot access the correct thread or because it needs to + initialize in situations where we cannot initialize a compositor (view) context - for instance before the native + window is created. + + * public/WebView.h: + (WebView): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::sharedGraphicsContext3D): + (WebKit): + * src/WebViewImpl.h: + (WebViewImpl): + +2012-03-09 Dana Jansens <danakj@chromium.org> + + [chromium] Use opaque paints in CCOcclusionTracker + https://bugs.webkit.org/show_bug.cgi?id=80173 + + Reviewed by Adrienne Walker. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::LayerChromiumWithForcedDrawsContent::opaqueContentsRegion): + (LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::setOpaquePaintRect): + (WebCore::setLayerPropertiesForTesting): + (WebCore): + (WebCore::layerAddedToOccludedRegion): + (WebCore::layerAddedToOccludedRegionWithRotation): + (WebCore::layerAddedToOccludedRegionWithTranslation): + (WebCore::layerAddedToOccludedRegionWithRotatedSurface): + (WebCore::layerAddedToOccludedRegionWithSurfaceAlreadyOnStack): + (WebCore::layerAddedToOccludedRegionWithRotatedOffAxisSurface): + (WebCore::layerAddedToOccludedRegionWithMultipleOpaqueLayers): + (WebCore::surfaceOcclusionWithOverlappingSiblingSurfaces): + (WebCore::surfaceOcclusionInScreenSpace): + (WebCore::surfaceOcclusionInScreenSpaceDifferentTransforms): + (WebCore::occlusionInteractionWithFilters): + (WebCore::layerScissorRectOverTile): + (WebCore::screenScissorRectOverTile): + (WebCore::layerScissorRectOverCulledTile): + (WebCore::screenScissorRectOverCulledTile): + (WebCore::layerScissorRectOverPartialTiles): + (WebCore::screenScissorRectOverPartialTiles): + (WebCore::layerScissorRectOverNoTiles): + (WebCore::screenScissorRectOverNoTiles): + (WebCore::layerScissorRectForLayerOffOrigin): + (WebCore::damageRectOverTile): + (WebCore::damageRectOverCulledTile): + (WebCore::damageRectOverPartialTiles): + (WebCore::damageRectOverNoTiles): + (WebCore::TEST): + * tests/TiledLayerChromiumTest.cpp: + (WTF::TEST): + (WTF): + +2012-03-09 Jon Lee <jonlee@apple.com> + + Add support for ENABLE(LEGACY_NOTIFICATIONS) + https://bugs.webkit.org/show_bug.cgi?id=80497 + + Reviewed by Adam Barth. + + Prep for b80472: Update API for Web Notifications + * features.gypi: + +2012-03-09 Ian Vollick <vollick@chromium.org> + + [chromium] Ensure we use the correct time when notifying animation started + https://bugs.webkit.org/show_bug.cgi?id=79537 + + Reviewed by James Robinson + + * src/WebCompositorInputHandlerImpl.cpp: + (WebKit::WebCompositorInputHandlerImpl::willDraw): + * src/WebCompositorInputHandlerImpl.h: + (WebCompositorInputHandlerImpl): + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::CCLayerTreeHostImplTest::postAnimationEventsToMainThreadOnImplThread): + (WebKit::TEST_F): + * tests/CCLayerTreeHostTest.cpp: + (WTF::TestHooks::animateLayers): + (WTF::TestHooks::updateAnimations): + (WTF::MockLayerTreeHostImpl::animateLayers): + (WTF::MockLayerTreeHostClient::updateAnimations): + (WTF::CCLayerTreeHostTestAddAnimation::CCLayerTreeHostTestAddAnimation): + (WTF::CCLayerTreeHostTestAddAnimation::animateLayers): + (WTF::CCLayerTreeHostTestAddAnimation::notifyAnimationStarted): + (CCLayerTreeHostTestAddAnimation): + +2012-03-09 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r110191, r110202, and r110279. + http://trac.webkit.org/changeset/110191 + http://trac.webkit.org/changeset/110202 + http://trac.webkit.org/changeset/110279 + https://bugs.webkit.org/show_bug.cgi?id=80694 + + They broke !ENABLE(INSPECTOR) builds (Requested by Ossy on + #webkit). + + * features.gypi: + +2012-03-09 Alexander Pavlov <apavlov@chromium.org> + + [chromium] Unreviewed, build fix after r110191 + + * features.gypi: + +2012-03-08 Ian Vollick <vollick@chromium.org> + + [chromium] Ensure that the cc thread animation framework continues to tick when the tab is backgrounded + https://bugs.webkit.org/show_bug.cgi?id=77668 + + Reviewed by James Robinson. + + * tests/CCLayerTreeHostTest.cpp: + (WTF::CCLayerTreeHostTest::postAddInstantAnimationToMainThread): + (CCLayerTreeHostTest): + (WTF::CCLayerTreeHostTest::dispatchAddInstantAnimation): + (WTF::CCLayerTreeHostTest::dispatchAddAnimation): + (WTF::CCLayerTreeHostTestAddAnimation::beginTest): + (WTF): + (CCLayerTreeHostTestTickAnimationWhileBackgrounded): + (WTF::CCLayerTreeHostTestTickAnimationWhileBackgrounded::CCLayerTreeHostTestTickAnimationWhileBackgrounded): + (WTF::CCLayerTreeHostTestTickAnimationWhileBackgrounded::beginTest): + (WTF::CCLayerTreeHostTestTickAnimationWhileBackgrounded::animateLayers): + (WTF::CCLayerTreeHostTestTickAnimationWhileBackgrounded::afterTest): + (WTF::TEST_F): + +2012-03-08 Jeff Timanus <twiz@chromium.org> + + [chromium] Force the Canvas2D GPU texture cache to 0 bytes for backgrounded tabs. + https://bugs.webkit.org/show_bug.cgi?id=79948 + + Reviewed by Stephen White. + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GrMemoryAllocationChangedCallback::onGpuMemoryAllocationChanged): + (WebCore::GraphicsContext3DPrivate::grContext): + (WebCore::GraphicsContext3DPrivate::setVisibilityCHROMIUM): + +2012-03-08 Dana Jansens <danakj@chromium.org> + + [chromium] Replace completelyContains with Region::contains() + https://bugs.webkit.org/show_bug.cgi?id=80617 + + Reviewed by James Robinson. + + * tests/CCLayerTestCommon.cpp: + (CCLayerTestCommon): + (CCLayerTestCommon::verifyQuadsExactlyCoverRect): + * tests/CCLayerTestCommon.h: + (CCLayerTestCommon): + +2012-03-08 James Robinson <jamesr@chromium.org> + + Use an explicit attribute to signal that a context prefers to use a discrete GPU + https://bugs.webkit.org/show_bug.cgi?id=80639 + + Reviewed by Stephen White. + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3DPrivate::getContextAttributes): + (WebCore::GraphicsContext3D::create): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::createCompositorGraphicsContext3D): + +2012-03-08 Scott Byer <scottbyer@chromium.org> + + Have ScrollAnimatorNone use requestAnimationFrame + https://bugs.webkit.org/show_bug.cgi?id=78938 + + Reviewed by James Robinson. + + * src/ScrollbarGroup.h: + (WebCore): + (WebKit::ScrollbarGroup::hostWindow): + (ScrollbarGroup): + * tests/ScrollAnimatorNoneTest.cpp: + (MockScrollableArea::hostWindow): + +2012-03-08 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> + + Make elements with attributes smaller by eliminating the m_element back pointer in NamedNodeMap + https://bugs.webkit.org/show_bug.cgi?id=75069 + + Reviewed by Ryosuke Niwa. + + * src/WebElement.cpp: Include NamedNodeMap.h since Element.h doesn't include it anymore. + +2012-03-07 Kent Tamura <tkent@chromium.org> + + Remove meaningless code in RenderTextControlSingleLine::preferredContentWidth() + https://bugs.webkit.org/show_bug.cgi?id=80493 + + Reviewed by Hajime Morita. + + * src/WebInputElement.cpp: + RenderTextControlSingleLine::speechButtonElement() is removed. The + following functions get it from HTMLInputElement. + (WebKit::WebInputElement::getSpeechInputState): + (WebKit::WebInputElement::startSpeechInput): + (WebKit::WebInputElement::stopSpeechInput): + +2012-03-07 Adam Barth <abarth@webkit.org> + + Remove #define private public from WebCache.cpp + https://bugs.webkit.org/show_bug.cgi?id=80520 + + Reviewed by Eric Seidel. + + This patch removes a hack we added long ago when Chromium used a forked + copy of WebKit and editing WebCore caused merge pain. Now that we're + on trunk, we can unwind this hack. + + * src/WebCache.cpp: + (WebKit::WebCache::getUsageStats): + +2012-03-07 Joshua Bell <jsbell@chromium.org> + + [Chromium] IndexedDB: V8LocalContext creation in IDBKey extraction/injection is slow + https://bugs.webkit.org/show_bug.cgi?id=80358 + + Reviewed by Tony Chang. + + * tests/IDBBindingUtilitiesTest.cpp: + (WebCore::TEST): + +2012-03-07 Scott Byer <scottbyer@chromium.org> + + Get ScrollAnimatorNone to handle the stop and reverse cases. + https://bugs.webkit.org/show_bug.cgi?id=80455 + + Reviewed by James Robinson. + + * tests/ScrollAnimatorNoneTest.cpp: + (ScrollAnimatorNoneTest::updateDataFromParameters): + (TEST_F): + +2012-03-07 Dana Jansens <danakj@chromium.org> + + [chromium] Cull occluded tiles during paint + https://bugs.webkit.org/show_bug.cgi?id=76838 + + Reviewed by Adrienne Walker. + + * tests/CCLayerTreeHostTest.cpp: + (WTF::ContentLayerChromiumWithUpdateTracking::idlePaintContentsIfDirty): + * tests/TiledLayerChromiumTest.cpp: + (WTF::FakeLayerTextureUpdater::Texture::prepareRect): + (WTF::FakeLayerTextureUpdater::FakeLayerTextureUpdater): + (FakeLayerTextureUpdater): + (WTF::FakeLayerTextureUpdater::prepareRectCount): + (WTF::FakeLayerTextureUpdater::clearPrepareRectCount): + (WTF::FakeLayerTextureUpdater::prepareRect): + (WTF::FakeTiledLayerChromium::prepareToUpdate): + (WTF::FakeTiledLayerChromium::prepareToUpdateIdle): + (WTF::FakeTiledLayerChromium::paintContentsIfDirty): + (WTF::TEST): + (WTF): + +2012-03-07 Elliot Poger <epoger@google.com> + + [Chromium] Remove use_skia option from GYP + https://bugs.webkit.org/show_bug.cgi?id=75811 + + Reviewed by Tony Chang. + + * WebKit.gyp: + * WebKit.gypi: + * features.gypi: + +2012-03-06 Dana Jansens <danakj@chromium.org> + + [chromium] Add clipping to scissor rect to CCOcclusionTracker + https://bugs.webkit.org/show_bug.cgi?id=79927 + + Reviewed by Adrienne Walker. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::TestCCOcclusionTracker::TestCCOcclusionTracker): + (TestCCOcclusionTracker): + (WebCore::TestCCOcclusionTracker::setLayerScissorRect): + (WebCore::TestCCOcclusionTracker::useDefaultLayerScissorRect): + (WebCore::TestCCOcclusionTracker::layerScissorRect): + (WebCore): + (TestDamageClient): + (WebCore::TestDamageClient::damageRect): + (WebCore::TestDamageClient::TestDamageClient): + (WebCore::TestDamageClient::setDamageRect): + (WebCore::TEST): + +2012-03-06 Kenichi Ishibashi <bashi@chromium.org> + + [WebSocket] Introduce ThreadableWebSocketChannel::SendResult + https://bugs.webkit.org/show_bug.cgi?id=80356 + + Reviewed by Kent Tamura. + + * src/WebSocketImpl.cpp: + (WebKit::WebSocketImpl::sendText): Checks whether the return value of send() is ThreadableWebSocketChannel::SendSuccess. + (WebKit::WebSocketImpl::sendArrayBuffer): Ditto. + +2012-03-06 Nat Duca <nduca@chromium.org> + + [chromium] CCThreadProxy context lost support + https://bugs.webkit.org/show_bug.cgi?id=80100 + + Reviewed by James Robinson. + + * tests/CCSchedulerStateMachineTest.cpp: + * tests/CCSchedulerTest.cpp: + (WebKitTests::FakeCCSchedulerClient::scheduledActionBeginContextRecreation): + (WebKitTests::SchedulerClientThatSetNeedsDrawInsideDraw::scheduledActionBeginContextRecreation): + (WebKitTests::SchedulerClientThatSetNeedsCommitInsideDraw::scheduledActionBeginContextRecreation): + +2012-03-06 James Robinson <jamesr@chromium.org> + + [chromium] Null-check m_layerRenderer in CCLayerTreeHostImpl::finishAllRendering() + https://bugs.webkit.org/show_bug.cgi?id=80445 + + Reviewed by Adrienne Walker. + + * tests/CCLayerTreeHostImplTest.cpp: + (FakeWebGraphicsContext3DMakeCurrentFails): + (WebKit::FakeWebGraphicsContext3DMakeCurrentFails::makeContextCurrent): + (WebKit): + (WebKit::TEST_F): + +2012-03-06 David Grogan <dgrogan@chromium.org> + + [Chromium] Add OVERRIDEs to WebWorkerClientImpl.h + https://bugs.webkit.org/show_bug.cgi?id=80434 + + Reviewed by Tony Chang. + + Tests: just that it compiles. + + * src/WebWorkerClientImpl.h: + (WebWorkerClientImpl): + +2012-03-06 David Grogan <dgrogan@chromium.org> + + IndexedDB: Check WebCommonWorkerClient::allowIndexedDB before proceeding from a shared worker + https://bugs.webkit.org/show_bug.cgi?id=79954 + + Tests: The 'allow' case will be tested once the patch at + http://webkit.org/b/80189 and + https://chromiumcodereview.appspot.com/9585031/ both land. Bug for + testing the 'deny' case is http://crbug.com/113738. + + Reviewed by Tony Chang. + + * public/WebCommonWorkerClient.h: + (WebKit::WebCommonWorkerClient::allowDatabase): + (WebKit::WebCommonWorkerClient::allowFileSystem): + (WebKit::WebCommonWorkerClient::openFileSystem): + (WebCommonWorkerClient): + (WebKit::WebCommonWorkerClient::allowIndexedDB): + * public/WebSharedWorkerClient.h: + (WebSharedWorkerClient): + * src/IDBFactoryBackendProxy.cpp: + (WebKit::AllowIndexedDBMainThreadBridge::create): + (WebKit::AllowIndexedDBMainThreadBridge::cancel): + (WebKit::AllowIndexedDBMainThreadBridge::signalCompleted): + (WebKit::AllowIndexedDBMainThreadBridge::AllowIndexedDBMainThreadBridge): + (WebKit::AllowIndexedDBMainThreadBridge::allowIndexedDBTask): + (AllowIndexedDBMainThreadBridge): + (WebKit::IDBFactoryBackendProxy::allowIDBFromWorkerThread): + * src/WebWorkerClientImpl.cpp: + (WebKit): + (WebKit::WebWorkerClientImpl::allowIndexedDB): + * src/WebWorkerClientImpl.h: + (WebWorkerClientImpl): + +2012-03-06 Stephen White <senorblanco@chromium.org> + + Unreviewed, rolling out r109825. + http://trac.webkit.org/changeset/109825 + https://bugs.webkit.org/show_bug.cgi?id=79413 + + Broke webkit_unit_tests on Chromium Win + + * WebKit.gypi: + * tests/LevelDBTest.cpp: Removed. + +2012-03-06 Takashi Toyoshima <toyoshim@chromium.org> + + [Chromium] [WebSocket] Add WebSocket extensions query WebKit API + https://bugs.webkit.org/show_bug.cgi?id=80190 + + Reviewed by Darin Fisher. + + * public/WebSocket.h: Add extensions() declaration. + (WebSocket): + * src/WebSocketImpl.cpp: Implement extensions() bridge. + (WebKit::WebSocketImpl::extensions): + (WebKit): + * src/WebSocketImpl.h: Add extensions() declaration. + (WebSocketImpl): + +2012-03-05 Kent Tamura <tkent@chromium.org> + + Do not reformat strings in <input type=number> on platforms using LocalizedNumberICU. + https://bugs.webkit.org/show_bug.cgi?id=78326 + + Reviewed by Hajime Morita. + + Add a test for WebCore/platform/text/LocalizedNumberICU. + + * WebKit.gypi: Added LocalizedNumberICUTest.cpp + * tests/LocalizedNumberICUTest.cpp: Added. + +2012-03-05 Kenneth Russell <kbr@google.com> + + [chromium] Notify CCLayerImpl tree of context loss and restoration + https://bugs.webkit.org/show_bug.cgi?id=80339 + + Reviewed by James Robinson. + + Unit test for notification of context loss and restoration. + + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit): + (ContextLostNotificationCheckLayer): + (WebKit::ContextLostNotificationCheckLayer::create): + (WebKit::ContextLostNotificationCheckLayer::didLoseAndRecreateGraphicsContext): + (WebKit::ContextLostNotificationCheckLayer::didLoseAndRecreateGraphicsContextCalled): + (WebKit::ContextLostNotificationCheckLayer::ContextLostNotificationCheckLayer): + (WebKit::TEST_F): + +2012-03-05 Changhun Kang <temoochin@company100.net> + + Change the argument orders to match OpenGL's in GraphicsContext3D functions + https://bugs.webkit.org/show_bug.cgi?id=80120 + + Reviewed by Kenneth Russell. + + No new tests because this patch just change the order of arguments. + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3DPrivate::uniform1fv): + (WebCore::GraphicsContext3DPrivate::uniform1iv): + (WebCore::GraphicsContext3DPrivate::uniform2fv): + (WebCore::GraphicsContext3DPrivate::uniform2iv): + (WebCore::GraphicsContext3DPrivate::uniform3fv): + (WebCore::GraphicsContext3DPrivate::uniform3iv): + (WebCore::GraphicsContext3DPrivate::uniform4fv): + (WebCore::GraphicsContext3DPrivate::uniform4iv): + (WebCore::GraphicsContext3DPrivate::uniformMatrix2fv): + (WebCore::GraphicsContext3DPrivate::uniformMatrix3fv): + (WebCore::GraphicsContext3DPrivate::uniformMatrix4fv): + (WebCore): + * src/GraphicsContext3DPrivate.h: + (GraphicsContext3DPrivate): + +2012-03-05 Yoshifumi Inoue <yosin@chromium.org> + + [Chromium] WebOptionElement should inherit WebElement instead of WebFormControlElement + https://bugs.webkit.org/show_bug.cgi?id=80089 + + Change class hierarchy of WebOptionElement to match with specification. + + Reviewed by Darin Fisher. + + * public/WebOptionElement.h: Replace to WebElement from WebFormControlElement + (WebKit::WebOptionElement::WebOptionElement): + (WebKit::WebOptionElement::operator=): + (WebKit::WebOptionElement::assign): + * src/WebOptionElement.cpp: + (WebKit::WebOptionElement::WebOptionElement): + +2012-03-05 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Handle LevelDB database corruption + https://bugs.webkit.org/show_bug.cgi?id=79413 + + Reviewed by Tony Chang. + + * WebKit.gypi: + * tests/LevelDBTest.cpp: Added. + (WebCore): + (SimpleComparator): + (WebCore::SimpleComparator::compare): + (WebCore::SimpleComparator::name): + (WebCore::encodeString): + (WebCore::TEST): + +2012-03-05 Min Qin <qinmin@google.com> + + Enable context menu on android + + For android, long press is converted into a right mouse down event + So we will use that to invoke the context menu + https://bugs.webkit.org/show_bug.cgi?id=80332 + + Reviewed by Adam Barth. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::mouseDown): + +2012-03-05 Kent Tamura <tkent@chromium.org> + + [Chromium] Add new popup type: PagePopup + https://bugs.webkit.org/show_bug.cgi?id=80106 + + Reviewed by Darin Fisher. + + This is a preparation of implementing ChromeClient::openPagePopup and + closePagePopup. + + * WebKit.gyp: Add WebPagePopup.h and WebPagePopupImpl.cpp. + * public/WebPagePopup.h: + (WebPagePopup): Add WebPagePopup interface. + * public/WebPopupType.h: Add WebPopupTypePage. + * src/WebPagePopupImpl.cpp: + (WebKit::WebPagePopup::create): Temprary implementation which just returns 0. + +2012-03-05 Charlie Reis <creis@chromium.org> + + [chromium] Pass WebNavigationPolicy to WebViewClient::createView + https://bugs.webkit.org/show_bug.cgi?id=80057 + + Reviewed by Darin Fisher. + + * public/WebViewClient.h: + (WebViewClient): + (WebKit::WebViewClient::createView): + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::ChromeClientImpl): + (WebKit::ChromeClientImpl::createWindow): + (WebKit::ChromeClientImpl::getNavigationPolicy): + (WebKit): + (WebKit::ChromeClientImpl::show): + (WebKit::ChromeClientImpl::setNewWindowNavigationPolicy): + * src/ChromeClientImpl.h: + (ChromeClientImpl): + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchCreatePage): + (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNewWindowAction): + +2012-03-05 James Robinson <jamesr@chromium.org> + + [chromium] Initialize CCOverdrawCounts struct to zero + https://bugs.webkit.org/show_bug.cgi?id=80204 + + Reviewed by Adrienne Walker. + + Update test to use c'tor instead of {} struct initialization. + + * tests/CCQuadCullerTest.cpp: + (WebCore): + +2012-03-05 Takashi Toyoshima <toyoshim@chromium.org> + + [Chromium] [WebSocket] use OVERRIDE in WebSocketImpl.h + https://bugs.webkit.org/show_bug.cgi?id=80192 + + Reviewed by Kent Tamura. + + * src/WebSocketImpl.h: use OVERRIDE macro. + (WebSocketImpl): + +2012-03-05 Adam Barth <abarth@webkit.org> + + Geolocation should use a ScriptExecutionContext as its context object + https://bugs.webkit.org/show_bug.cgi?id=80248 + + Reviewed by Kentaro Hara. + + Rather than indirecting through the Frame to get the SecurityOrigin, we + should get the SecurityOrigin directly from ScriptExecutionContext. + + * src/WebGeolocationPermissionRequest.cpp: + (WebKit::WebGeolocationPermissionRequest::securityOrigin): + +2012-03-02 Andrey Kosyakov <caseq@chromium.org> + + Add instrumentation for frame start/end on timeline. + + Web Inspector: add timeline instrumentation for frame events + https://bugs.webkit.org/show_bug.cgi?id=80127 + + Reviewed by Pavel Feldman. + + - expose an instrumentation method from WebWidget to mark frame update start + + * public/WebWidget.h: + (WebWidget): + (WebKit::WebWidget::instrumentBeginFrame): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::instrumentBeginFrame): + (WebKit): + * src/WebViewImpl.h: + (WebViewImpl): + +2012-03-03 Benjamin Poulain <benjamin@webkit.org> + + Remove the redundant method KURL::protocolInHTTPFamily() + https://bugs.webkit.org/show_bug.cgi?id=80216 + + Reviewed by Anders Carlsson. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchWillPerformClientRedirect): + * src/WebPageSerializer.cpp: + (WebCore::retrieveResourcesForElement): + +2012-03-03 Hans Wennborg <hans@chromium.org> + + Implement Speech JavaScript API + https://bugs.webkit.org/show_bug.cgi?id=80019 + + Reviewed by Adam Barth. + + Add ENABLE_SCRIPTED_SPEECH and runtime flag. + + * features.gypi: + * public/WebRuntimeFeatures.h: + (WebRuntimeFeatures): + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableScriptedSpeech): + (WebKit): + (WebKit::WebRuntimeFeatures::isScriptedSpeechEnabled): + +2012-03-03 Bill Budge <bbudge@chromium.org> + + Fixes AssociatedURLLoader support for Access-Control-Expose-Headers field in response. + https://bugs.webkit.org/show_bug.cgi?id=80198 + + Reviewed by Adam Barth. + + * src/AssociatedURLLoader.cpp: + * tests/AssociatedURLLoaderTest.cpp: + +2012-03-02 Dana Jansens <danakj@chromium.org> + + [Chromium] Allow plugins to set opaque() on their platform layer + https://bugs.webkit.org/show_bug.cgi?id=80171 + + Reviewed by James Robinson. + + * public/WebPluginContainer.h: + (WebPluginContainer): + * src/WebPluginContainerImpl.cpp: + (WebKit::WebPluginContainerImpl::setOpaque): + (WebKit): + * src/WebPluginContainerImpl.h: + (WebPluginContainerImpl): + +2012-03-01 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> + + Make parser code not depend on NamedNodeMap + https://bugs.webkit.org/show_bug.cgi?id=79963 + + Reviewed by Adam Barth. + + * src/WebNamedNodeMap.cpp: + (WebKit::WebNamedNodeMap::attributeItem): + +2012-03-01 Dana Jansens <danakj@chromium.org> + + [chromium] Make opaque paint tracker aware of SkCanvas layers + https://bugs.webkit.org/show_bug.cgi?id=79145 + + Reviewed by Stephen White. + + * tests/PlatformContextSkiaTest.cpp: + (WebCore::TEST): + (WebCore): + +2012-03-01 Hironori Bono <hbono@chromium.org> + + Render overflow controls of an RTL element to its left-side. + https://bugs.webkit.org/show_bug.cgi?id=54623 + + This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the + vertical scrollbars and resizers of RTL elements to their left side if + this new flag is enabled. + + Reviewed by Ryosuke Niwa. + + * features.gypi: Set WTF_USE_RTL_SCROLLBAR to 1 on Chromium. + +2012-03-01 James Robinson <jamesr@chromium.org> + + [chromium] Rename LayerChromium::name to debugName to be more consistent with other debug properties, make threadsafe + https://bugs.webkit.org/show_bug.cgi?id=79723 + + Reviewed by Adrienne Walker. + + * tests/LayerChromiumTest.cpp: + +2012-03-01 Dale Curtis <dalecurtis@chromium.org> + + Remove deprecated FFmpeg build directories. + https://bugs.webkit.org/show_bug.cgi?id=79282 + + We've switched the layout of the FFmpeg repo in Chrome and these paths + are no longer needed or valid. + + Reviewed by Dirk Pranke. + + * DEPS: + +2012-03-01 Dirk Pranke <dpranke@chromium.org> + + Roll chromium DEPS to 124511 + + Unreviewed, DEPS change. + + * DEPS: + +2012-02-29 Nat Duca <nduca@chromium.org> + + [chromium] Move context lost control code from CCSingleThreadProxy to CCLayerTreeHost + https://bugs.webkit.org/show_bug.cgi?id=79964 + + Reviewed by James Robinson. + + * src/WebLayerTreeView.cpp: + (WebKit::WebLayerTreeView::loseCompositorContext): + * src/WebLayerTreeViewImpl.cpp: + (WebKit::WebLayerTreeViewImpl::createContext): + (WebKit::WebLayerTreeViewImpl::didRecreateContext): + * src/WebLayerTreeViewImpl.h: + (WebLayerTreeViewImpl): + * tests/CCLayerTreeHostTest.cpp: + (WTF::MockLayerTreeHostClient::createContext): + (WTF::MockLayerTreeHostClient::didRecreateContext): + * tests/FakeCCLayerTreeHostClient.h: + (WebCore::FakeCCLayerTreeHostClient::createContext): + (WebCore::FakeCCLayerTreeHostClient::didRecreateContext): + +2012-03-01 Kentaro Hara <haraken@chromium.org> + + REGRESSION(r109288): WebViewImpl::enableAutoResizeMode loops infinitely + https://bugs.webkit.org/show_bug.cgi?id=77452 + + Reviewed by Hajime Morita. + + WebViewImpl::enableAutoResizeMode loops infinitely. + This patch fixes the following line: + + enableAutoResizeMode(enable, minSize, maxSize); + + to + enableAutoResizeMode(minSize, maxSize); + + to avoid the infinite loop. I guess this is the change originally intended. + + Test: webkit_unit_tests.WebViewTest.AutoResizeMinimumSize + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::enableAutoResizeMode): + +2012-02-29 Kinuko Yasuda <kinuko@chromium.org> + + Use the new createSnapshotFileAndReadMetadata API for FileEntry.file() + https://bugs.webkit.org/show_bug.cgi?id=79928 + + Reviewed by David Levin. + + In the new flow we first create an internal Blob URL for the + snapshot file and call the new createSnapshotFileAndReadMetadata() + WebKit API with the Blob URL. + + The implementor of createSnapshotFileAndReadMetadata() (i.e. chromium) + registers the created snapshot file with the given internal Blob URL. + + In the callback chain we call File::createWithName() to create a + new File using the returned platform path, and then call + unregisterBlobURL() to clean up the internal Blob URL. + + * src/AsyncFileSystemChromium.cpp: + (WebCore::AsyncFileSystemChromium::createSnapshotFileAndReadMetadata): Added. + (WebCore::AsyncFileSystemChromium::createSnapshotFileCallback): Added. + * src/AsyncFileSystemChromium.h: + * src/WorkerAsyncFileSystemChromium.cpp: + (WebCore::WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata): Added. + * src/WorkerAsyncFileSystemChromium.h: + * src/WorkerFileSystemCallbacksBridge.cpp: + (WebKit::WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread): Added. + (WebKit::WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread): Added. + * src/WorkerFileSystemCallbacksBridge.h: + (WorkerFileSystemCallbacksBridge): + +2012-02-29 Kinuko Yasuda <kinuko@chromium.org> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-29 W. James MacLean <wjmaclean@chromium.org> + + [chromium] Estimate pixel count for frame rate control + https://bugs.webkit.org/show_bug.cgi?id=74982 + + Reviewed by James Robinson. + + Adds mechanism to compute and collect statistics on pixel overdraw for selected frames. + + * tests/CCQuadCullerTest.cpp: + (WebCore): + (WebCore::TEST): + +2012-02-29 James Simonsen <simonjam@chromium.org> + + [chromium] Fix navigation start time on cross-renderer navigation + https://bugs.webkit.org/show_bug.cgi?id=75922 + + Reviewed by Darin Fisher. + + * public/WebDataSource.h: + * src/WebDataSource.cpp: + (WebKit::WebDataSource::setNavigationStartTime): Added. + * src/WebDataSource.h: + +2012-02-29 Ian Vollick <vollick@chromium.org> + + [chromium] Add impl-thread support for animation-timing-function + https://bugs.webkit.org/show_bug.cgi?id=79819 + + Reviewed by James Robinson. + + * tests/CCKeyframedAnimationCurveTest.cpp: + (WebCore::TEST): + (WebCore): + +2012-02-29 David Levin <levin@chromium.org> + + [chromium] Add the ability to turn off autoresize. + https://bugs.webkit.org/show_bug.cgi?id=77452 + + Reviewed by Darin Fisher. + + * public/WebView.h: + (WebKit::WebViewImpl::enableAutoResizeMode): Cleaned up the api. + (WebKit::WebViewImpl::disableAutoResizeMode): Added the ability to disable auto-resize. + (WebKit::WebViewImpl::enableAutoResizeMode): Deprecated it. + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::enableAutoResizeMode): Adjust for new api. + (WebKit::WebViewImpl::disableAutoResizeMode): Allow turning off autoresize. + (WebKit::WebViewImpl::enableAutoResizeMode): Call the other two apis, but + this api will be deleted shortly. + (WebKit::WebViewImpl::configureAutoResizeMode): Common code. + * src/WebViewImpl.h: + (WebViewImpl): Adjust to new public api. + +2012-02-29 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-29 Dana Jansens <danakj@chromium.org> + + [chromium] Don't let invalidation for next frame prevent tile upload + https://bugs.webkit.org/show_bug.cgi?id=79841 + + Reviewed by James Robinson. + + * tests/TiledLayerChromiumTest.cpp: + (WTF::TEST): + +2012-02-28 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r107917 and r109188. + http://trac.webkit.org/changeset/107917 + http://trac.webkit.org/changeset/109188 + https://bugs.webkit.org/show_bug.cgi?id=79865 + + Fix the chromium build. (Requested by dcheng on #webkit). + + * src/WebDragData.cpp: + (WebKit::WebDragData::items): + +2012-02-28 Ryosuke Niwa <rniwa@webkit.org> + + Chromium build fix attempt. + + * src/WebDragData.cpp: + +2012-02-28 Jonathan Backer <backer@chromium.org> + + [chromium] Reset damage tracker on visibility change. + https://bugs.webkit.org/show_bug.cgi?id=79267 + + Reviewed by James Robinson. + + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::PartialSwapTrackerContext::getString): + (WebKit): + (WebKit::TEST_F): + +2012-02-28 Tim Dresser <tdresser@chromium.org> + + Provide DefaultDeviceScaleFactor though WebSettings + https://bugs.webkit.org/show_bug.cgi?id=79534 + + Reviewed by Darin Fisher. + + * public/WebSettings.h: + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setDefaultDeviceScaleFactor): + (WebKit): + * src/WebSettingsImpl.h: + (WebSettingsImpl): + +2012-02-28 Gary Kacmarcik <garykac@chromium.org> + + [chromium] Set nativeKeyCode to include Windows scan code + https://bugs.webkit.org/show_bug.cgi?id=79289 + + Reviewed by Ryosuke Niwa. + + Set the key event's nativeKeyCode on Windows Chromium so that it + actually includes the native scancode and other context bits. + Currently on Windows, the nativeKeyCode is set to be the same value as + the windowsKeyCode, which is redundant. + + The actual native key information is required so that components (like + plugins) can reconstruct the original key event. The value stored in + the windowsKeyCode is a Windows virtual key code which does not provide + sufficient info to disambiguate the actual key being pressed (for + example, it cannot distinguish between the left and right shift keys). + + All platforms except Windows currently send native key event info, so + this change will bring Windows in line with other platforms. + + This change is part of our effort to send enhanced keycode information + to Pepper plugins in Chromium. + + * src/win/WebInputEventFactory.cpp: + (WebKit::WebInputEventFactory::keyboardEvent): + +2012-02-28 Adam Klein <adamk@chromium.org> + + Unreviewed, speculative test fix after r109016. + + * tests/TransparencyWinTest.cpp: + (WebCore::TEST): Update all ImageBuffer::create calls to include a scale of 1. + +2012-02-28 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-27 James Kozianski <koz@chromium.org> + + Add missing parameter to didCreateScriptContext() so it overrides base class again. + https://bugs.webkit.org/show_bug.cgi?id=79742 + + Reviewed by Kent Tamura. + + * tests/WebFrameTest.cpp: + +2012-02-27 Kenichi Ishibashi <bashi@chromium.org> + + [Chromium] Unreviewed gardening, Disable TransparencyWin.OpaqueCompositeLayerPixel + + * tests/TransparencyWinTest.cpp: + (WebCore::TEST): + +2012-02-27 Kinuko Yasuda <kinuko@chromium.org> + + [chromium] Add createSnapshotFile API to WebFileSystem to create File snapshots for filesystem files + https://bugs.webkit.org/show_bug.cgi?id=79394 + + Reviewed by Darin Fisher. + + * public/platform/WebFileSystem.h: + (WebKit::WebFileSystem::createSnapshotFileAndReadMetadata): Added. + +2012-02-27 James Kozianski <koz@chromium.org> + + [chromium] Plumb extensionGroup into didCreateScriptContext(). + https://bugs.webkit.org/show_bug.cgi?id=79072 + + Reviewed by Darin Fisher. + + * public/WebFrameClient.h: + (WebKit::WebFrameClient::didCreateScriptContext): + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::didCreateScriptContext): + * src/FrameLoaderClientImpl.h: + (FrameLoaderClientImpl): + +2012-02-27 Adrienne Walker <enne@google.com> + + [chromium] Unreviewed gardening, disable TransparencyWinTest unit tests + https://bugs.webkit.org/show_bug.cgi?id=79718 + + * tests/TransparencyWinTest.cpp: + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * src/ChromeClientImpl.h: + (ChromeClientImpl): + +2012-02-26 James Robinson <jamesr@chromium.org> + + Take 2 build fix. + + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::TEST_F): + +2012-02-26 James Robinson <jamesr@chromium.org> + + Compile fix for CCLayerTreeHostImpl test. + + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::TEST_F): + +2012-02-26 James Robinson <jamesr@chromium.org> + + [chromium] Wire up shouldUpdateScrollPositionOnMainThread and nonFastScrollableRegion to compositor + https://bugs.webkit.org/show_bug.cgi?id=79155 + + Reviewed by Adam Barth. + + Add new tests for shouldScrollOnMainThread and nonFastScrollableRegion properties. + + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::TEST_F): + (WebKit): + * tests/LayerChromiumTest.cpp: + +2012-02-25 Adrienne Walker <enne@google.com> + + [chromium] Unreviewed gardening, fix Linux Clang OwnPtr breakage + https://bugs.webkit.org/show_bug.cgi?id=78404 + + r108886 doesn't compile on Linux Clang due to OwnPtr's public copy + constructor (i.e. "has internal linkage but is not defined"). Fixed + locally by changing copy initialization to direct initialization. + + * tests/TiledLayerChromiumTest.cpp: + (WTF::TEST): + +2012-02-24 Tien-Ren Chen <trchen@chromium.org> + + [chromium] Replace RefPtr with OwnPtr for CCLayerImpl tree structure + https://bugs.webkit.org/show_bug.cgi?id=78404 + + Reviewed by James Robinson. + + * tests/CCDamageTrackerTest.cpp: + (WebKitTests::executeCalculateDrawTransformsAndVisibility): + (WebKitTests::emulateDrawingOneFrame): + (WebKitTests::createTestTreeWithOneSurface): + (WebKitTests::createTestTreeWithTwoSurfaces): + (WebKitTests::createAndSetUpTestTreeWithOneSurface): + (WebKitTests::createAndSetUpTestTreeWithTwoSurfaces): + (WebKitTests::TEST_F): + * tests/CCLayerImplTest.cpp: + (WebCore::TEST): + * tests/CCLayerIteratorTest.cpp: + * tests/CCLayerSorterTest.cpp: + (WebCore::TEST): + * tests/CCLayerTreeHostCommonTest.cpp: + (WebCore::TEST): + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::CCLayerTreeHostImplTest::setupScrollAndContentsLayers): + (WebKit::TEST_F): + (WebKit::DidDrawCheckLayer::create): + (WebKit::BlendStateCheckLayer::create): + * tests/CCRenderSurfaceTest.cpp: + (WebCore::TEST): + * tests/CCSolidColorLayerImplTest.cpp: + (CCLayerTestCommon::TEST): + * tests/CCTiledLayerImplTest.cpp: + (CCLayerTestCommon::createLayer): + (CCLayerTestCommon::TEST): + (CCLayerTestCommon::getQuads): + * tests/Canvas2DLayerChromiumTest.cpp: + (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): + * tests/TiledLayerChromiumTest.cpp: + (WTF::TEST): + * tests/TreeSynchronizerTest.cpp: + (WebKitTests::MockCCLayerImpl::create): + (WebKitTests::MockLayerChromium::createCCLayerImpl): + (WebKitTests::expectTreesAreIdentical): + (WebKitTests::TEST): + +2012-02-08 James Robinson <jamesr@chromium.org> + + [chromium] Make WebViewImpl depend on WebLayerTreeView instead of CCLayerTreeHost + https://bugs.webkit.org/show_bug.cgi?id=75591 + + Reviewed by Kenneth Russell. + + This converts WebViewImpl from depending on CCLayerTreeHost to WebLayerTreeView in order to provide better + isolation and allow for future refactorings. The changes to WebViewImpl are mostly mechanical. The + WebLayerTreeView and WebLayerTreeViewClient interfaces have both grown and changed slightly: + + - Setup path for WebLayerTreeView changed to expose an initialize() function instead of a create() factory + function. The new model is that a WebLayerTreeView when constructed is in a null state. Calling initialize() + attempts to re-initialize the WLTV, which can either fail or succeed. All other functions must be called on a + successfully initialized view. + + - WebLayerTreeView expanded to include functionality that CCLayerTreeHost exposes but WebLayerTreeView did not. + Some of this is only valid for the single thread case and will be removed when we invert the scheduling control + logic, these bits are commented. + + - WebLayerTreeViewClient expanded with some flow-control related APIs. + + Refactor only, no change in behavior. + + * public/platform/WebLayerTreeView.h: + (WebKit::WebLayerTreeView::Settings::Settings): + (WebKit::WebLayerTreeView::isNull): + * public/platform/WebLayerTreeViewClient.h: + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::scheduleCompositingLayerSync): + * src/WebLayerTreeView.cpp: + (WebKit::WebLayerTreeView::initialize): + (WebKit::WebLayerTreeView::compositorIdentifier): + (WebKit::WebLayerTreeView::setVisible): + (WebKit::WebLayerTreeView::setNeedsAnimate): + (WebKit::WebLayerTreeView::updateAnimations): + (WebKit::WebLayerTreeView::setNeedsRedraw): + (WebKit::WebLayerTreeView::setPageScaleFactorAndLimits): + (WebKit::WebLayerTreeView::startPageScaleAnimation): + (WebKit::WebLayerTreeView::finishAllRendering): + (WebKit::WebLayerTreeView::context): + (WebKit::WebLayerTreeView::loseCompositorContext): + * src/WebLayerTreeViewImpl.cpp: + (WebKit::WebLayerTreeViewImpl::didRecreateGraphicsContext): + (WebKit::WebLayerTreeViewImpl::didCommitAndDrawFrame): + (WebKit::WebLayerTreeViewImpl::didCompleteSwapBuffers): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::animate): + (WebKit::WebViewImpl::doPixelReadbackToCanvas): + (WebKit::WebViewImpl::paint): + (WebKit::WebViewImpl::composite): + (WebKit::WebViewImpl::loseCompositorContext): + (WebKit::WebViewImpl::computePageScaleFactorLimits): + (WebKit::WebViewImpl::addPageOverlay): + (WebKit::WebViewImpl::removePageOverlay): + (WebKit::WebViewImpl::setRootGraphicsLayer): + (WebKit::WebViewImpl::scheduleCompositingLayerSync): + (WebKit::WebViewImpl::scrollRootLayerRect): + (WebKit::WebViewImpl::invalidateRootLayerRect): + (WebKit::WebViewImpl::scheduleAnimation): + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + (WebKit::WebViewImpl::createContext3D): + (WebKit::WebViewImpl::applyScrollAndScale): + (WebKit::WebViewImpl::didRebindGraphicsContext): + (WebKit::WebViewImpl::updateLayerTreeViewport): + (WebKit::WebViewImpl::graphicsContext3D): + (WebKit::WebViewImpl::setVisibilityState): + * src/WebViewImpl.h: + * tests/WebLayerTest.cpp: + +2012-02-24 Ian Vollick <vollick@chromium.org> + + [chromium] Plumb animation started notifications from CCLayerTreeHost to GraphicsLayerChromium + https://bugs.webkit.org/show_bug.cgi?id=77646 + + Reviewed by James Robinson. + + * tests/CCLayerTreeHostTest.cpp: + (TestHooks): + (WTF::TestHooks::notifyAnimationStarted): + (WTF::TestHooks::notifyAnimationFinished): + (WTF::MockLayerTreeHost::create): + (WTF::CCLayerTreeHostTestAddAnimation::CCLayerTreeHostTestAddAnimation): + (WTF::CCLayerTreeHostTestAddAnimation::animateLayers): + (WTF::CCLayerTreeHostTestAddAnimation::notifyAnimationStarted): + (CCLayerTreeHostTestAddAnimation): + (WTF::CCLayerTreeHostTestAddAnimation::notifyAnimationFinished): + +2012-02-24 James Robinson <jamesr@chromium.org> + + [chromium] WebKit::setColorNames is a client API + https://bugs.webkit.org/show_bug.cgi?id=79539 + + Reviewed by Darin Fisher. + + * WebKit.gyp: + * public/WebColorName.h: Renamed from Source/Platform/chromium/public/WebColorName.h. + (WebKit): + * public/platform/WebColorName.h: + * src/WebColor.cpp: + +2012-02-24 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r108860. + http://trac.webkit.org/changeset/108860 + https://bugs.webkit.org/show_bug.cgi?id=79544 + + "Breaks Linux compile" (Requested by enne on #webkit). + + * WebKit.gyp: + * public/platform/WebColorName.h: + * src/WebColor.cpp: Renamed from Source/WebKit/chromium/src/WebColorName.cpp. + (WebKit): + (WebKit::toCSSValueKeyword): + (WebKit::setNamedColors): + +2012-02-24 James Robinson <jamesr@chromium.org> + + [chromium] WebKit::setColorNames is a client API + https://bugs.webkit.org/show_bug.cgi?id=79539 + + Reviewed by Darin Fisher. + + * WebKit.gyp: + * public/WebColorName.h: Renamed from Source/Platform/chromium/public/WebColorName.h. + (WebKit): + * public/platform/WebColorName.h: + * src/WebColor.cpp: + +2012-02-22 James Robinson <jamesr@chromium.org> + + [chromium] Move WebGraphicsContext3D header into the Platform directory + https://bugs.webkit.org/show_bug.cgi?id=79301 + + Reviewed by Adam Barth. + + Moves WebGraphicsContext3D and WebNonCopyable (which WGC3D depends on). + + * public/platform/WebGraphicsContext3D.h: + * public/platform/WebNonCopyable.h: + +2012-02-24 Michal Mocny <mmocny@google.com> + + [chromium] Purge Skia's GPU texture cache using GL_CHROMIUM_gpu_memory_manager + https://bugs.webkit.org/show_bug.cgi?id=78265 + + Reviewed by Stephen White. + + * src/GraphicsContext3DChromium.cpp: + (GrMemoryAllocationChangedCallback): + (WebCore::GrMemoryAllocationChangedCallback::GrMemoryAllocationChangedCallback): + (WebCore::GrMemoryAllocationChangedCallback::onGpuMemoryAllocationChanged): + (WebCore): + (WebCore::GraphicsContext3DPrivate::grContext): + +2012-02-24 James Robinson <jamesr@chromium.org> + + [chromium] Remove deprecated and unused WebGraphicsContext3D::initialize call + https://bugs.webkit.org/show_bug.cgi?id=79296 + + Reviewed by Kenneth Russell. + + The old way to initialize a WebGraphicsContext3D from inside WebKit was to call initialize() on it with a + WebView*. The new way to do this is via the WebViewClient interface. This deletes the old, unused path. + + * public/platform/WebGraphicsContext3D.h: + (WebKit): + * tests/CCLayerTreeHostImplTest.cpp: + * tests/FakeWebGraphicsContext3D.h: + +2012-02-23 James Robinson <jamesr@chromium.org> + + [chromium] Move Web*Layer* headers into Platform + https://bugs.webkit.org/show_bug.cgi?id=79425 + + Reviewed by Adam Barth. + + Adds forwarding headers for Web*Layer* APIs and their dependencies. The forwarding headers for the Web*Layer* + APIs are temporary since Web*Layer* is not exposed in the client interface. The other headers (such as + WebColor) are exposed in both the client and platform APIs, so the forwarding headers are permanent, although we + might move them back down to public/ at some point. + + * public/platform/WebCanvas.h: + * public/platform/WebColor.h: + * public/platform/WebColorName.h: + * public/platform/WebContentLayer.h: + * public/platform/WebContentLayerClient.h: + * public/platform/WebExternalTextureLayer.h: + * public/platform/WebLayer.h: + * public/platform/WebLayerTreeView.h: + * public/platform/WebLayerTreeViewClient.h: + * public/platform/WebPrivatePtr.h: + * public/platform/WebSolidColorLayer.h: + +2012-02-24 Peter Collingbourne <peter@pcc.me.uk> + + [chromium] Have WebFrameImpl::selectionAsMarkup create interchange markup. + https://bugs.webkit.org/show_bug.cgi?id=77307 + + Reviewed by Tony Chang. + + This function is currently used to build markup in order to + print the selection, and will also be used to build markup for + the clipboard. Without this change, the markup will refer to + (for example) nonexistent CSS classes and invalid relative + paths and therefore will not be interpreted correctly. + + Chromium bug: http://crbug.com/23329 + + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::selectionAsMarkup): + +2012-02-24 Pavel Feldman <pfeldman@chromium.org> + + Not reviewed: chromium image for inspector status bar button updated. + + * src/js/Images/segmentSelectedEndChromium.png: + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/chromium/DEPS b/Source/WebKit/chromium/DEPS index ba422445c..23e521aa7 100644 --- a/Source/WebKit/chromium/DEPS +++ b/Source/WebKit/chromium/DEPS @@ -32,7 +32,7 @@ vars = { 'chromium_svn': 'http://src.chromium.org/svn/trunk/src', - 'chromium_rev': '123353' + 'chromium_rev': '125600' } deps = { @@ -145,8 +145,6 @@ deps_os = { 'win': { 'third_party/cygwin': From('chromium_deps', 'src/third_party/cygwin'), - 'third_party/ffmpeg/binaries/chromium/win/ia32': - From('chromium_deps', 'src/third_party/ffmpeg/binaries/chromium/win/ia32'), 'third_party/lighttpd': From('chromium_deps', 'src/third_party/lighttpd'), 'third_party/nss': diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index f8e58b383..1e1a41665 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -112,6 +112,7 @@ 'public/WebCache.h', 'public/WebColorChooser.h', 'public/WebColorChooserClient.h', + 'public/WebColorName.h', 'public/WebCommonWorkerClient.h', 'public/WebCompositionUnderline.h', 'public/WebCompositor.h', @@ -214,6 +215,7 @@ 'public/WebNotificationPresenter.h', 'public/WebOptionElement.h', 'public/WebPageOverlay.h', + 'public/WebPagePopup.h', 'public/WebPageSerializer.h', 'public/WebPageSerializerClient.h', 'public/WebPageVisibilityState.h', @@ -292,7 +294,6 @@ 'public/platform/WebCanvas.h', 'public/platform/WebClipboard.h', 'public/platform/WebColor.h', - 'public/platform/WebColorName.h', 'public/platform/WebCommon.h', 'public/platform/WebContentLayer.h', 'public/platform/WebContentLayerClient.h', @@ -494,9 +495,9 @@ 'src/WebBlob.cpp', 'src/WebBlobData.cpp', 'src/WebCache.cpp', - 'src/WebColor.cpp', 'src/WebColorChooserClientImpl.cpp', 'src/WebColorChooserClientImpl.h', + 'src/WebColorName.cpp', 'src/WebCommon.cpp', 'src/WebCompositorImpl.cpp', 'src/WebCompositorImpl.h', @@ -615,6 +616,7 @@ 'src/WebNodeList.cpp', 'src/WebNotification.cpp', 'src/WebOptionElement.cpp', + 'src/WebPagePopupImpl.cpp', 'src/WebPageSerializer.cpp', 'src/WebPageSerializerImpl.cpp', 'src/WebPageSerializerImpl.h', @@ -824,20 +826,13 @@ ['exclude', '/android/'], ], }], + # TODO: we exclude CG.cpp on both sides of the below conditional. Move elsewhere? ['OS=="mac"', { 'include_dirs': [ 'public/mac', ], - 'conditions': [ - ['use_skia==0', { - 'sources/': [ - ['exclude', 'Skia\\.cpp$'], - ], - },{ # use_skia - 'sources/': [ - ['exclude', 'CG\\.cpp$'], - ], - }], + 'sources/': [ + ['exclude', 'CG\\.cpp$'], ], }, { # else: OS!="mac" 'sources/': [ diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi index e91e336db..87d41bfb9 100644 --- a/Source/WebKit/chromium/WebKit.gypi +++ b/Source/WebKit/chromium/WebKit.gypi @@ -92,6 +92,7 @@ 'tests/ClipboardChromiumTest.cpp', 'tests/CompositorFakeGraphicsContext3D.h', 'tests/CompositorFakeWebGraphicsContext3D.h', + 'tests/DragImageTest.cpp', 'tests/FakeCCLayerTreeHostClient.h', 'tests/FakeGraphicsContext3DTest.cpp', 'tests/FakeWebGraphicsContext3D.h', @@ -101,15 +102,20 @@ 'tests/IDBBindingUtilitiesTest.cpp', 'tests/IDBKeyPathTest.cpp', 'tests/IDBLevelDBCodingTest.cpp', + 'tests/ImageLayerChromiumTest.cpp', 'tests/KeyboardTest.cpp', 'tests/KURLTest.cpp', 'tests/LayerChromiumTest.cpp', 'tests/LayerTextureUpdaterTest.cpp', + 'tests/LocalizedNumberICUTest.cpp', 'tests/PaintAggregatorTest.cpp', + 'tests/PlatformGestureCurveTest.cpp', + 'tests/PlatformContextSkiaTest.cpp', 'tests/PODArenaTest.cpp', 'tests/PODIntervalTreeTest.cpp', 'tests/PODRedBlackTreeTest.cpp', 'tests/RenderTableCellTest.cpp', + 'tests/ScrollbarLayerChromiumTest.cpp', 'tests/TextureManagerTest.cpp', 'tests/TiledLayerChromiumTest.cpp', 'tests/TilingDataTest.cpp', @@ -131,13 +137,6 @@ ], 'conditions': [ - ['use_skia == 1', { - 'webkit_unittest_files': [ - 'tests/DragImageTest.cpp', - 'tests/ImageLayerChromiumTest.cpp', - 'tests/PlatformContextSkiaTest.cpp', - ], - }], ['OS=="win"', { 'webkit_unittest_files': [ # FIXME: Port PopupMenuTest to Linux and Mac. diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi index 4c46d4de4..5a033c8cf 100644 --- a/Source/WebKit/chromium/features.gypi +++ b/Source/WebKit/chromium/features.gypi @@ -63,6 +63,7 @@ 'ENABLE_INPUT_TYPE_WEEK=0', 'ENABLE_JAVASCRIPT_DEBUGGER=1', 'ENABLE_JAVASCRIPT_I18N_API=1', + 'ENABLE_LEGACY_NOTIFICATIONS=1', 'ENABLE_LINK_PREFETCH=1', 'ENABLE_MEDIA_SOURCE=1', 'ENABLE_MEDIA_STATISTICS=1', @@ -81,6 +82,7 @@ 'ENABLE_REQUEST_ANIMATION_FRAME=1', 'ENABLE_RUBY=1', 'ENABLE_SANDBOX=1', + 'ENABLE_SCRIPTED_SPEECH=1', 'ENABLE_SHADOW_DOM=1', 'ENABLE_SHARED_WORKERS=1', 'ENABLE_SMOOTH_SCROLLING=1', @@ -106,6 +108,7 @@ # We can't define it here because it should be present only # in Debug or release_valgrind_build=1 builds. 'WTF_USE_OPENTYPE_SANITIZER=1', + 'WTF_USE_RTL_SCROLLBAR=1', 'WTF_USE_SKIA_TEXT=<(enable_skia_text)', 'WTF_USE_WEBP=1', 'WTF_USE_WEBKIT_IMAGE_DECODERS=1', @@ -118,7 +121,6 @@ 'enable_svg%': 1, 'enable_viewport%': 0, 'enable_touch_events%': 1, - 'use_skia%': 0, 'enable_touch_icon_loading%' : 0, 'enable_mutation_observers%': 1, }, @@ -126,7 +128,6 @@ 'enable_skia_text%': '<(enable_skia_text)', 'enable_svg%': '<(enable_svg)', 'enable_touch_events%': '<(enable_touch_events)', - 'use_skia%': '<(use_skia)', 'conditions': [ ['OS=="android"', { 'feature_defines': [ @@ -143,7 +144,7 @@ 'ENABLE_3D_RENDERING=1', ], }], - ['use_accelerated_compositing==1 and (OS!="mac" or use_skia==1)', { + ['use_accelerated_compositing==1', { 'feature_defines': [ 'ENABLE_ACCELERATED_2D_CANVAS=1', ], @@ -153,7 +154,6 @@ 'feature_defines': [ 'WTF_USE_WEBAUDIO_FFMPEG=1', ], - 'use_skia%': 1, }], ['enable_register_protocol_handler==1', { 'feature_defines': [ @@ -168,7 +168,7 @@ ['OS=="mac"', { 'feature_defines': [ 'ENABLE_RUBBER_BANDING=1', - 'WTF_USE_SKIA_ON_MAC_CHROMIUM=<(use_skia)', + 'WTF_USE_SKIA_ON_MAC_CHROMIUM=1', ], }], ], diff --git a/Source/WebKit/chromium/public/WebColorName.h b/Source/WebKit/chromium/public/WebColorName.h new file mode 100644 index 000000000..698f7ce60 --- /dev/null +++ b/Source/WebKit/chromium/public/WebColorName.h @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2009 Google Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Google Inc. nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef WebColorName_h +#define WebColorName_h + +#include "platform/WebColor.h" +#include "platform/WebCommon.h" + +namespace WebKit { + +enum WebColorName { + WebColorActiveBorder, + WebColorActiveCaption, + WebColorAppworkspace, + WebColorBackground, + WebColorButtonFace, + WebColorButtonHighlight, + WebColorButtonShadow, + WebColorButtonText, + WebColorCaptionText, + WebColorGrayText, + WebColorHighlight, + WebColorHighlightText, + WebColorInactiveBorder, + WebColorInactiveCaption, + WebColorInactiveCaptionText, + WebColorInfoBackground, + WebColorInfoText, + WebColorMenu, + WebColorMenuText, + WebColorScrollbar, + WebColorText, + WebColorThreedDarkShadow, + WebColorThreedShadow, + WebColorThreedFace, + WebColorThreedHighlight, + WebColorThreedLightShadow, + WebColorWebkitFocusRingColor, + WebColorWindow, + WebColorWindowFrame, + WebColorWindowText +}; + +// Sets the values of a set of named colors. +WEBKIT_EXPORT void setNamedColors(const WebColorName*, const WebColor*, size_t length); + +} // namespace WebKit + +#endif diff --git a/Source/WebKit/chromium/public/WebCommonWorkerClient.h b/Source/WebKit/chromium/public/WebCommonWorkerClient.h index 2ffb54d57..2d87c1401 100644 --- a/Source/WebKit/chromium/public/WebCommonWorkerClient.h +++ b/Source/WebKit/chromium/public/WebCommonWorkerClient.h @@ -47,13 +47,28 @@ class WebWorkerClient; class WebCommonWorkerClient { public: // Called on the main webkit thread before opening a web database. - virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) = 0; + virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) + { + return true; + } // Called on the main webkit thread before opening a file system. - virtual bool allowFileSystem() = 0; + virtual bool allowFileSystem() + { + return true; + } // Called on the main webkit thread before opening a file system. - virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*) = 0; + virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*) + { + WEBKIT_ASSERT_NOT_REACHED(); + } + + // Called on the main webkit thread before opening an indexed database. + virtual bool allowIndexedDB(const WebString& name) + { + return true; + } }; diff --git a/Source/WebKit/chromium/public/WebDataSource.h b/Source/WebKit/chromium/public/WebDataSource.h index 07b63490c..77d6e78dc 100644 --- a/Source/WebKit/chromium/public/WebDataSource.h +++ b/Source/WebKit/chromium/public/WebDataSource.h @@ -103,6 +103,14 @@ public: // testing. virtual void setDeferMainResourceDataLoad(bool) = 0; + // Sets the navigation start time for this datasource. Ordinarily, + // navigation start is determined in WebCore. But, in some situations, + // the embedder might have a better value and can override it here. This + // should be called before WebFrameClient::didCommitProvisionalLoad. + // Calling it later may confuse users, because JavaScript may have run and + // the user may have already recorded the original value. + virtual void setNavigationStartTime(double) = 0; + protected: ~WebDataSource() { } }; diff --git a/Source/WebKit/chromium/public/WebFrameClient.h b/Source/WebKit/chromium/public/WebFrameClient.h index d0507e3d1..fa6fc7a33 100644 --- a/Source/WebKit/chromium/public/WebFrameClient.h +++ b/Source/WebKit/chromium/public/WebFrameClient.h @@ -297,7 +297,7 @@ public: // Notifies that a new script context has been created for this frame. // This is similar to didClearWindowObject but only called once per // frame context. - virtual void didCreateScriptContext(WebFrame*, v8::Handle<v8::Context>, int worldId) { } + virtual void didCreateScriptContext(WebFrame*, v8::Handle<v8::Context>, int extensionGroup, int worldId) { } // WebKit is about to release its reference to a v8 context for a frame. virtual void willReleaseScriptContext(WebFrame*, v8::Handle<v8::Context>, int worldId) { } diff --git a/Source/WebKit/chromium/public/WebOptionElement.h b/Source/WebKit/chromium/public/WebOptionElement.h index 3d9390b71..d58ccb4e3 100644 --- a/Source/WebKit/chromium/public/WebOptionElement.h +++ b/Source/WebKit/chromium/public/WebOptionElement.h @@ -31,7 +31,7 @@ #ifndef WebOptionElement_h #define WebOptionElement_h -#include "WebFormControlElement.h" +#include "WebElement.h" #include "platform/WebVector.h" #if WEBKIT_IMPLEMENTATION @@ -41,17 +41,17 @@ namespace WebCore { class HTMLOptionElement; } namespace WebKit { // Provides readonly access to some properties of a DOM option element node. -class WebOptionElement : public WebFormControlElement { +class WebOptionElement : public WebElement { public: - WebOptionElement() : WebFormControlElement() { } - WebOptionElement(const WebOptionElement& element) : WebFormControlElement(element) { } + WebOptionElement() : WebElement() { } + WebOptionElement(const WebOptionElement& element) : WebElement(element) { } WebOptionElement& operator=(const WebOptionElement& element) { - WebFormControlElement::assign(element); + WebElement::assign(element); return *this; } - void assign(const WebOptionElement& element) { WebFormControlElement::assign(element); } + void assign(const WebOptionElement& element) { WebElement::assign(element); } WEBKIT_EXPORT void setValue(const WebString&); WEBKIT_EXPORT WebString value() const; diff --git a/Source/WebKit/chromium/public/WebPagePopup.h b/Source/WebKit/chromium/public/WebPagePopup.h new file mode 100644 index 000000000..d8ab18773 --- /dev/null +++ b/Source/WebKit/chromium/public/WebPagePopup.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebPagePopup_h +#define WebPagePopup_h + +#include "WebWidget.h" +#include "platform/WebCommon.h" + +namespace WebKit { + +class WebWidgetClient; + +class WebPagePopup : public WebWidget { +public: + WEBKIT_EXPORT static WebPagePopup* create(WebWidgetClient*); +}; + +} // namespace WebKit + +#endif diff --git a/Source/WebKit/chromium/public/WebPluginContainer.h b/Source/WebKit/chromium/public/WebPluginContainer.h index 845cb1a28..777431fb0 100644 --- a/Source/WebKit/chromium/public/WebPluginContainer.h +++ b/Source/WebKit/chromium/public/WebPluginContainer.h @@ -100,6 +100,9 @@ public: // Notifies that the zoom level has changed. virtual void zoomLevelChanged(double zoomLevel) = 0; + // Notifies whether the contents of the plugin are entirely opaque. + virtual void setOpaque(bool) = 0; + // Determines whether the given rectangle in this plugin is above all other // content. The rectangle is in the plugin's coordinate system. virtual bool isRectTopmost(const WebRect&) = 0; diff --git a/Source/WebKit/chromium/public/WebPopupType.h b/Source/WebKit/chromium/public/WebPopupType.h index 8a546bae4..2d0e8e4d2 100644 --- a/Source/WebKit/chromium/public/WebPopupType.h +++ b/Source/WebKit/chromium/public/WebPopupType.h @@ -35,8 +35,9 @@ namespace WebKit { enum WebPopupType { WebPopupTypeNone, // Not a popup. - WebPopupTypeSelect, // A HTML select (combo-box) popup. + WebPopupTypeSelect, // An HTML select (combo-box) popup. WebPopupTypeSuggestion, // An autofill/autocomplete popup. + WebPopupTypePage, // An HTML-capable popup. }; } // namespace WebKit diff --git a/Source/WebKit/chromium/public/WebRuntimeFeatures.h b/Source/WebKit/chromium/public/WebRuntimeFeatures.h index 34e3947f6..187ef0f55 100644 --- a/Source/WebKit/chromium/public/WebRuntimeFeatures.h +++ b/Source/WebKit/chromium/public/WebRuntimeFeatures.h @@ -91,6 +91,9 @@ public: WEBKIT_EXPORT static void enableSpeechInput(bool); WEBKIT_EXPORT static bool isSpeechInputEnabled(); + WEBKIT_EXPORT static void enableScriptedSpeech(bool); + WEBKIT_EXPORT static bool isScriptedSpeechEnabled(); + WEBKIT_EXPORT static void enableXHRResponseBlob(bool); WEBKIT_EXPORT static bool isXHRResponseBlobEnabled(); diff --git a/Source/WebKit/chromium/public/WebSettings.h b/Source/WebKit/chromium/public/WebSettings.h index 7f1bbb0c4..47aaeece0 100644 --- a/Source/WebKit/chromium/public/WebSettings.h +++ b/Source/WebKit/chromium/public/WebSettings.h @@ -62,6 +62,7 @@ public: virtual void setDefaultFixedFontSize(int) = 0; virtual void setMinimumFontSize(int) = 0; virtual void setMinimumLogicalFontSize(int) = 0; + virtual void setDefaultDeviceScaleFactor(int) = 0; virtual void setDefaultTextEncodingName(const WebString&) = 0; virtual void setJavaScriptEnabled(bool) = 0; virtual void setWebSecurityEnabled(bool) = 0; diff --git a/Source/WebKit/chromium/public/WebSharedWorkerClient.h b/Source/WebKit/chromium/public/WebSharedWorkerClient.h index a085a3ea2..4a2b8732f 100644 --- a/Source/WebKit/chromium/public/WebSharedWorkerClient.h +++ b/Source/WebKit/chromium/public/WebSharedWorkerClient.h @@ -79,21 +79,6 @@ public: // Called on the main webkit thread in the worker process during initialization. virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) = 0; - // Called on the main webkit thread before opening a web database. - virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) = 0; - - // Called on the main webkit thread before opening a file system. - virtual bool allowFileSystem() - { - return true; - } - - // Called on the main webkit thread before opening a file system. - virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*) - { - WEBKIT_ASSERT_NOT_REACHED(); - } - virtual void dispatchDevToolsMessage(const WebString&) { } virtual void saveDevToolsAgentState(const WebString&) { } diff --git a/Source/WebKit/chromium/public/WebSocket.h b/Source/WebKit/chromium/public/WebSocket.h index c10c372ad..f2a140cfa 100644 --- a/Source/WebKit/chromium/public/WebSocket.h +++ b/Source/WebKit/chromium/public/WebSocket.h @@ -80,6 +80,7 @@ public: virtual void connect(const WebURL&, const WebString& protocol) = 0; virtual WebString subprotocol() = 0; + virtual WebString extensions() = 0; virtual bool sendText(const WebString&) = 0; virtual bool sendArrayBuffer(const WebArrayBuffer&) = 0; virtual unsigned long bufferedAmount() const = 0; diff --git a/Source/WebKit/chromium/public/WebView.h b/Source/WebKit/chromium/public/WebView.h index ed853e23a..50cf2eaa0 100644 --- a/Source/WebKit/chromium/public/WebView.h +++ b/Source/WebKit/chromium/public/WebView.h @@ -260,10 +260,17 @@ public: // In auto-resize mode, the view is automatically adjusted to fit the html // content within the given bounds. virtual void enableAutoResizeMode( - bool enable, const WebSize& minSize, const WebSize& maxSize) = 0; + // Turn off auto-resize. + virtual void disableAutoResizeMode() = 0; + + // DEPRECATED + virtual void enableAutoResizeMode( + bool enable, + const WebSize& minSize, + const WebSize& maxSize) = 0; // Media --------------------------------------------------------------- @@ -423,6 +430,10 @@ public: // APIs. virtual WebGraphicsContext3D* graphicsContext3D() = 0; + // Context that's in the compositor's share group, but is not the compositor context itself. + // Can be used for allocating resources that the compositor will later access. + virtual WebGraphicsContext3D* sharedGraphicsContext3D() = 0; + // Visibility ----------------------------------------------------------- // Sets the visibility of the WebView. diff --git a/Source/WebKit/chromium/public/WebViewClient.h b/Source/WebKit/chromium/public/WebViewClient.h index b656fd5ad..b2c0e5665 100644 --- a/Source/WebKit/chromium/public/WebViewClient.h +++ b/Source/WebKit/chromium/public/WebViewClient.h @@ -93,10 +93,13 @@ public: // WebStorage specification. // The request parameter is only for the client to check if the request // could be fulfilled. The client should not load the request. + // The policy parameter indicates how the new view will be displayed in + // WebWidgetClient::show. virtual WebView* createView(WebFrame* creator, const WebURLRequest& request, const WebWindowFeatures& features, - const WebString& name) { + const WebString& name, + WebNavigationPolicy policy) { return 0; } @@ -110,10 +113,10 @@ public: // Create a session storage namespace object associated with this WebView. virtual WebStorageNamespace* createSessionStorageNamespace(unsigned quota) { return 0; } - // Creates a graphics context associated with the client's WebView. - // renderDirectlyToWebView means whether the context should be setup to - // render directly to the WebView (e.g. compositor context), or to an - // offscreen surface (e.g. WebGL context). + // Creates a graphics context that renders to the client's WebView. + virtual WebGraphicsContext3D* createGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return 0; } + + // Deprecated, use the first version of this function. If you want an offscreen context, use WebKitPlatformSupport::createOffscreenGraphicsContext3D(). virtual WebGraphicsContext3D* createGraphicsContext3D(const WebGraphicsContext3D::Attributes&, bool renderDirectlyToWebView) { return 0; } // Misc ---------------------------------------------------------------- diff --git a/Source/WebKit/chromium/public/WebWidget.h b/Source/WebKit/chromium/public/WebWidget.h index 58f3fa169..e9712d743 100644 --- a/Source/WebKit/chromium/public/WebWidget.h +++ b/Source/WebKit/chromium/public/WebWidget.h @@ -192,6 +192,10 @@ public: // rect.) virtual void didChangeWindowResizerRect() { } + // Instrumentation method that marks beginning of frame update that includes + // things like animate()/layout()/paint()/composite(). + virtual void instrumentBeginFrame() { } + protected: ~WebWidget() { } }; diff --git a/Source/WebKit/chromium/public/platform/WebCanvas.h b/Source/WebKit/chromium/public/platform/WebCanvas.h index 4cf729ee1..ba2a7189d 100644 --- a/Source/WebKit/chromium/public/platform/WebCanvas.h +++ b/Source/WebKit/chromium/public/platform/WebCanvas.h @@ -1,54 +1,26 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions + * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebCanvas_h -#define WebCanvas_h - -#include "WebCommon.h" - -#if WEBKIT_USING_SKIA -class SkCanvas; -#elif WEBKIT_USING_CG -struct CGContext; -#endif - -namespace WebKit { - -#if WEBKIT_USING_SKIA -typedef SkCanvas WebCanvas; -#elif WEBKIT_USING_CG -typedef struct CGContext WebCanvas; -#else -#error "Need to define WebCanvas" -#endif - -} // namespace WebKit - -#endif +#include "../../../../Platform/chromium/public/WebCanvas.h" diff --git a/Source/WebKit/chromium/public/platform/WebColor.h b/Source/WebKit/chromium/public/platform/WebColor.h index da45eb1c6..65677dae9 100644 --- a/Source/WebKit/chromium/public/platform/WebColor.h +++ b/Source/WebKit/chromium/public/platform/WebColor.h @@ -1,46 +1,26 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions + * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebColor_h -#define WebColor_h - -#include "WebColorName.h" -#include "WebCommon.h" - -namespace WebKit { - -typedef unsigned WebColor; // RGBA quad. Equivalent to SkColor. - -// Sets the values of a set of named colors. -WEBKIT_EXPORT void setNamedColors(const WebColorName*, const WebColor*, size_t length); - -} // namespace WebKit - -#endif +#include "../../../../Platform/chromium/public/WebColor.h" diff --git a/Source/WebKit/chromium/public/platform/WebColorName.h b/Source/WebKit/chromium/public/platform/WebColorName.h index f97ed265f..c3a8afedd 100644 --- a/Source/WebKit/chromium/public/platform/WebColorName.h +++ b/Source/WebKit/chromium/public/platform/WebColorName.h @@ -1,71 +1,29 @@ /* -* Copyright (C) 2009 Google Inc. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following disclaimer -* in the documentation and/or other materials provided with the -* distribution. -* * Neither the name of Google Inc. nor the names of its -* contributors may be used to endorse or promote products derived from -* this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ -#ifndef WebColorName_h -#define WebColorName_h +// FIXME: This is logically part of the WebKit client API and doesn't belong in platform. This is a forwarding header to avoid requiring a two-sided commit. +// As soon as all chromium code is updated for the new location of this header, remove this. -namespace WebKit { - -enum WebColorName { - WebColorActiveBorder, - WebColorActiveCaption, - WebColorAppworkspace, - WebColorBackground, - WebColorButtonFace, - WebColorButtonHighlight, - WebColorButtonShadow, - WebColorButtonText, - WebColorCaptionText, - WebColorGrayText, - WebColorHighlight, - WebColorHighlightText, - WebColorInactiveBorder, - WebColorInactiveCaption, - WebColorInactiveCaptionText, - WebColorInfoBackground, - WebColorInfoText, - WebColorMenu, - WebColorMenuText, - WebColorScrollbar, - WebColorText, - WebColorThreedDarkShadow, - WebColorThreedShadow, - WebColorThreedFace, - WebColorThreedHighlight, - WebColorThreedLightShadow, - WebColorWebkitFocusRingColor, - WebColorWindow, - WebColorWindowFrame, - WebColorWindowText -}; - -} // namespace WebKit - -#endif +#include "../WebColorName.h" diff --git a/Source/WebKit/chromium/public/platform/WebContentLayer.h b/Source/WebKit/chromium/public/platform/WebContentLayer.h index 6d7f91483..90a16ed91 100644 --- a/Source/WebKit/chromium/public/platform/WebContentLayer.h +++ b/Source/WebKit/chromium/public/platform/WebContentLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,49 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebContentLayer_h -#define WebContentLayer_h - -#include "WebCommon.h" -#include "WebLayer.h" - -namespace WebKit { -class WebContentLayerClient; -class WebContentLayerImpl; -struct WebFloatRect; - -class WebContentLayer : public WebLayer { -public: - WEBKIT_EXPORT static WebContentLayer create(WebContentLayerClient*); - - WebContentLayer() { } - WebContentLayer(const WebContentLayer& layer) : WebLayer(layer) { } - virtual ~WebContentLayer() { } - WebContentLayer& operator=(const WebContentLayer& layer) - { - WebLayer::assign(layer); - return *this; - } - - // Sets whether the layer draws its content when compositing. - WEBKIT_EXPORT void setDrawsContent(bool); - WEBKIT_EXPORT bool drawsContent() const; - - // Sets a region of the layer as invalid, i.e. needs to update its content. - // The visible area of the dirty rect will be passed to one or more calls to - // WebContentLayerClient::paintContents before the compositing pass occurs. - WEBKIT_EXPORT void invalidateRect(const WebFloatRect&); - - // Sets the entire layer as invalid, i.e. needs to update its content. - WEBKIT_EXPORT void invalidate(); - -#if WEBKIT_IMPLEMENTATION - WebContentLayer(const WTF::PassRefPtr<WebContentLayerImpl>&); - WebContentLayer& operator=(const WTF::PassRefPtr<WebContentLayerImpl>&); - operator WTF::PassRefPtr<WebContentLayerImpl>() const; -#endif -}; - -} // namespace WebKit - -#endif // WebContentLayer_h +#include "../../../../Platform/chromium/public/WebContentLayer.h" diff --git a/Source/WebKit/chromium/public/platform/WebContentLayerClient.h b/Source/WebKit/chromium/public/platform/WebContentLayerClient.h index deb36e077..8f1ca3324 100644 --- a/Source/WebKit/chromium/public/platform/WebContentLayerClient.h +++ b/Source/WebKit/chromium/public/platform/WebContentLayerClient.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,26 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebContentLayerClient_h -#define WebContentLayerClient_h - -#include "WebCanvas.h" - -namespace WebKit { -struct WebRect; - -class WebContentLayerClient { -public: - // Paints the content area for the layer, typically dirty rects submitted - // through WebContentLayer::setNeedsDisplay, submitting drawing commands - // through the WebCanvas. - // The canvas is already clipped to the |clip| rect. - virtual void paintContents(WebCanvas*, const WebRect& clip) = 0; - -protected: - virtual ~WebContentLayerClient() { } -}; - -} // namespace WebKit - -#endif // WebContentLayerClient_h +#include "../../../../Platform/chromium/public/WebContentLayerClient.h" diff --git a/Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h b/Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h index ce87bb238..000826df7 100644 --- a/Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h +++ b/Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,61 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebExternalTextureLayer_h -#define WebExternalTextureLayer_h - -#include "WebCommon.h" -#include "WebFloatRect.h" -#include "WebLayer.h" - -namespace WebKit { -class WebExternalTextureLayerImpl; - -// This class represents a layer that renders a texture that is generated -// externally (not managed by the WebLayerTreeView). -// The texture will be used by the WebLayerTreeView during compositing passes. -// When in single-thread mode, this means during WebLayerTreeView::composite(). -// When using the threaded compositor, this can mean at an arbitrary time until -// the WebLayerTreeView is destroyed. -class WebExternalTextureLayer : public WebLayer { -public: - WEBKIT_EXPORT static WebExternalTextureLayer create(); - - WebExternalTextureLayer() { } - WebExternalTextureLayer(const WebExternalTextureLayer& layer) : WebLayer(layer) { } - virtual ~WebExternalTextureLayer() { } - WebExternalTextureLayer& operator=(const WebExternalTextureLayer& layer) - { - WebLayer::assign(layer); - return *this; - } - - // Sets the texture id that represents the layer, in the namespace of the - // compositor context. - WEBKIT_EXPORT void setTextureId(unsigned); - WEBKIT_EXPORT unsigned textureId() const; - - // Sets whether or not the texture should be flipped in the Y direction when - // rendered. - WEBKIT_EXPORT void setFlipped(bool); - WEBKIT_EXPORT bool flipped() const; - - // Sets the rect in UV space of the texture that is mapped to the layer - // bounds. - WEBKIT_EXPORT void setUVRect(const WebFloatRect&); - WEBKIT_EXPORT WebFloatRect uvRect() const; - - // Marks a region of the layer as needing a display. These regions are - // collected in a union until the display occurs. - WEBKIT_EXPORT void invalidateRect(const WebFloatRect&); - -#if WEBKIT_IMPLEMENTATION - WebExternalTextureLayer(const WTF::PassRefPtr<WebExternalTextureLayerImpl>&); - WebExternalTextureLayer& operator=(const WTF::PassRefPtr<WebExternalTextureLayerImpl>&); - operator WTF::PassRefPtr<WebExternalTextureLayerImpl>() const; -#endif -}; - -} // namespace WebKit - -#endif // WebExternalTextureLayer_h +#include "../../../../Platform/chromium/public/WebExternalTextureLayer.h" diff --git a/Source/WebKit/chromium/public/platform/WebFileSystem.h b/Source/WebKit/chromium/public/platform/WebFileSystem.h index 583efe07c..2562ef1c3 100644 --- a/Source/WebKit/chromium/public/platform/WebFileSystem.h +++ b/Source/WebKit/chromium/public/platform/WebFileSystem.h @@ -71,6 +71,7 @@ public: virtual void removeRecursively(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } // Retrieves the metadata information of the file or directory at the given |path|. + // This may not always return the local platform path in remote filesystem cases. // WebFileSystemCallbacks::didReadMetadata() must be called with a valid metadata when the retrieval is completed successfully. // WebFileSystemCallbacks::didFail() must be called otherwise. virtual void readMetadata(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } @@ -114,6 +115,15 @@ public: // This is a fast, synchronous call, and should not stat the filesystem. virtual WebFileWriter* createFileWriter(const WebURL& path, WebFileWriterClient*) { WEBKIT_ASSERT_NOT_REACHED(); return 0; } + // Creates a snapshot file for a given file specified by |path| and registers the file with the |blobURL|. It returns the metadata of the created snapshot file. + // The returned metadata should include a local platform path to the snapshot image. + // In local filesystem cases the backend may simply return the metadata of the file itself (as well as readMetadata does), while in remote filesystem case the backend may download the file into a temporary snapshot file and return the metadata of the temporary file. + // The returned metadata is used to create a File object for the |path|. + // The snapshot file is supposed to be deleted when the last reference to the |blobURL| is dropped. + // WebFileSystemCallbacks::didReadMetadata() with the metadata of the snapshot file must be called when the operation is completed successfully. + // WebFileSystemCallbacks::didFail() must be called otherwise. + virtual void createSnapshotFileAndReadMetadata(const WebURL& blobURL, const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } + protected: virtual ~WebFileSystem() { } }; diff --git a/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h b/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h index f13f7c44d..876b5d9bb 100644 --- a/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h +++ b/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h @@ -1,421 +1,26 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions + * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebGraphicsContext3D_h -#define WebGraphicsContext3D_h - -#include "WebCommon.h" -#include "WebNonCopyable.h" -#include "WebString.h" - -#define USE_WGC3D_TYPES - -#if WEBKIT_USING_SKIA -struct GrGLInterface; -#endif - -namespace WebKit { - -// WGC3D types match the corresponding GL types as defined in OpenGL ES 2.0 -// header file gl2.h from khronos.org. -typedef char WGC3Dchar; -typedef unsigned int WGC3Denum; -typedef unsigned char WGC3Dboolean; -typedef unsigned int WGC3Dbitfield; -typedef signed char WGC3Dbyte; -typedef unsigned char WGC3Dubyte; -typedef short WGC3Dshort; -typedef unsigned short WGC3Dushort; -typedef int WGC3Dint; -typedef int WGC3Dsizei; -typedef unsigned int WGC3Duint; -typedef float WGC3Dfloat; -typedef float WGC3Dclampf; -typedef signed long int WGC3Dintptr; -typedef signed long int WGC3Dsizeiptr; - -// Typedef for server-side objects like OpenGL textures and program objects. -typedef WGC3Duint WebGLId; - -// FIXME: We shouldn't mention WebView in platform. -class WebView; - -// This interface abstracts the operations performed by the -// GraphicsContext3D in order to implement WebGL. Nearly all of the -// methods exposed on this interface map directly to entry points in -// the OpenGL ES 2.0 API. -// -// Creating a WebGraphicsContext does not make it current, or guarantee -// that the context has been created successfully. Use -// makeContextCurrent() to complete initialization of the context, treating -// a false return value as indication that the context could not be created -// successfully. -class WebGraphicsContext3D : public WebNonCopyable { -public: - // Return value from getActiveUniform and getActiveAttrib. - struct ActiveInfo { - WebString name; - WGC3Denum type; - WGC3Dint size; - }; - - // Context creation attributes. - struct Attributes { - Attributes() - : alpha(true) - , depth(true) - , stencil(true) - , antialias(true) - , premultipliedAlpha(true) - , canRecoverFromContextLoss(true) - , noExtensions(false) - , shareResources(true) - , forUseOnAnotherThread(false) - { - } - - bool alpha; - bool depth; - bool stencil; - bool antialias; - bool premultipliedAlpha; - bool canRecoverFromContextLoss; - bool noExtensions; - bool shareResources; - bool forUseOnAnotherThread; - }; - - class WebGraphicsContextLostCallback { - public: - virtual void onContextLost() = 0; - virtual ~WebGraphicsContextLostCallback() { } - }; - - class WebGraphicsErrorMessageCallback { - public: - virtual void onErrorMessage(const WebString&, WGC3Dint) = 0; - virtual ~WebGraphicsErrorMessageCallback() { } - }; - - class WebGraphicsSwapBuffersCompleteCallbackCHROMIUM { - public: - virtual void onSwapBuffersComplete() = 0; - virtual ~WebGraphicsSwapBuffersCompleteCallbackCHROMIUM() { } - }; - - class WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { - public: - virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) = 0; - - protected: - virtual ~WebGraphicsMemoryAllocationChangedCallbackCHROMIUM() { } - }; - - // This destructor needs to be public so that using classes can destroy instances if initialization fails. - virtual ~WebGraphicsContext3D() {} - - // This function is deprecated and will be removed soon. - virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return false; } - - // Makes the OpenGL context current on the current thread. Returns true on - // success. - virtual bool makeContextCurrent() = 0; - - // The size of the region into which this WebGraphicsContext3D is rendering. - // Returns the last values passed to reshape(). - virtual int width() = 0; - virtual int height() = 0; - - // Resizes the region into which this WebGraphicsContext3D is drawing. - virtual void reshape(int width, int height) = 0; - - // GL_CHROMIUM_setVisibility - Changes the visibility of the backbuffer - virtual void setVisibilityCHROMIUM(bool visible) = 0; - - // GL_CHROMIUM_gpu_memory_manager - sets callback to observe changes to memory allocation limits. - virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { } - - // Query whether it is built on top of compliant GLES2 implementation. - virtual bool isGLES2Compliant() = 0; - - virtual bool setParentContext(WebGraphicsContext3D* parentContext) { return false; } - - // Helper for software compositing path. Reads back the frame buffer into - // the memory region pointed to by "pixels" with size "bufferSize". It is - // expected that the storage for "pixels" covers (4 * width * height) bytes. - // Returns true on success. - virtual bool readBackFramebuffer(unsigned char* pixels, size_t bufferSize, WebGLId framebuffer, int width, int height) = 0; - - // Returns the id of the texture which is used for storing the contents of - // the framebuffer associated with this context. This texture is accessible - // by the gpu-based page compositor. - virtual WebGLId getPlatformTextureId() = 0; - - // Copies the contents of the off-screen render target used by the WebGL - // context to the corresponding texture used by the compositor. - virtual void prepareTexture() = 0; - - // GL_CHROMIUM_post_sub_buffer - Copies part of the back buffer to the front buffer. - virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) = 0; - - // Synthesizes an OpenGL error which will be returned from a - // later call to getError. This is used to emulate OpenGL ES - // 2.0 behavior on the desktop and to enforce additional error - // checking mandated by WebGL. - // - // Per the behavior of glGetError, this stores at most one - // instance of any given error, and returns them from calls to - // getError in the order they were added. - virtual void synthesizeGLError(WGC3Denum) = 0; - - virtual bool isContextLost() = 0; - - // GL_CHROMIUM_map_sub - virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target, WGC3Dintptr offset, WGC3Dsizeiptr size, WGC3Denum access) = 0; - virtual void unmapBufferSubDataCHROMIUM(const void*) = 0; - virtual void* mapTexSubImage2DCHROMIUM(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, WGC3Denum access) = 0; - virtual void unmapTexSubImage2DCHROMIUM(const void*) = 0; - - // GL_CHROMIUM_request_extension - virtual WebString getRequestableExtensionsCHROMIUM() = 0; - virtual void requestExtensionCHROMIUM(const char*) = 0; - - // GL_CHROMIUM_framebuffer_multisample - virtual void blitFramebufferCHROMIUM(WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, WGC3Dbitfield mask, WGC3Denum filter) = 0; - virtual void renderbufferStorageMultisampleCHROMIUM(WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height) = 0; - - // GL_CHROMIUM_swapbuffers_complete_callback - virtual void setSwapBuffersCompleteCallbackCHROMIUM(WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { } - - // GL_CHROMIUM_rate_limit_offscreen_context - virtual void rateLimitOffscreenContextCHROMIUM() { } - - // The entry points below map directly to the OpenGL ES 2.0 API. - // See: http://www.khronos.org/registry/gles/ - // and: http://www.khronos.org/opengles/sdk/docs/man/ - virtual void activeTexture(WGC3Denum texture) = 0; - virtual void attachShader(WebGLId program, WebGLId shader) = 0; - virtual void bindAttribLocation(WebGLId program, WGC3Duint index, const WGC3Dchar* name) = 0; - virtual void bindBuffer(WGC3Denum target, WebGLId buffer) = 0; - virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer) = 0; - virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer) = 0; - virtual void bindTexture(WGC3Denum target, WebGLId texture) = 0; - virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) = 0; - virtual void blendEquation(WGC3Denum mode) = 0; - virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha) = 0; - virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor) = 0; - virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB, WGC3Denum srcAlpha, WGC3Denum dstAlpha) = 0; - - virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage) = 0; - virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, WGC3Dsizeiptr size, const void* data) = 0; - - virtual WGC3Denum checkFramebufferStatus(WGC3Denum target) = 0; - virtual void clear(WGC3Dbitfield mask) = 0; - virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) = 0; - virtual void clearDepth(WGC3Dclampf depth) = 0; - virtual void clearStencil(WGC3Dint s) = 0; - virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, WGC3Dboolean blue, WGC3Dboolean alpha) = 0; - virtual void compileShader(WebGLId shader) = 0; - - virtual void compressedTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Dsizei imageSize, const void* data) = 0; - virtual void compressedTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Dsizei imageSize, const void* data) = 0; - virtual void copyTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border) = 0; - virtual void copyTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0; - virtual void cullFace(WGC3Denum mode) = 0; - virtual void depthFunc(WGC3Denum func) = 0; - virtual void depthMask(WGC3Dboolean flag) = 0; - virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar) = 0; - virtual void detachShader(WebGLId program, WebGLId shader) = 0; - virtual void disable(WGC3Denum cap) = 0; - virtual void disableVertexAttribArray(WGC3Duint index) = 0; - virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count) = 0; - virtual void drawElements(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset) = 0; - - virtual void enable(WGC3Denum cap) = 0; - virtual void enableVertexAttribArray(WGC3Duint index) = 0; - virtual void finish() = 0; - virtual void flush() = 0; - virtual void framebufferRenderbuffer(WGC3Denum target, WGC3Denum attachment, WGC3Denum renderbuffertarget, WebGLId renderbuffer) = 0; - virtual void framebufferTexture2D(WGC3Denum target, WGC3Denum attachment, WGC3Denum textarget, WebGLId texture, WGC3Dint level) = 0; - virtual void frontFace(WGC3Denum mode) = 0; - virtual void generateMipmap(WGC3Denum target) = 0; - - virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo&) = 0; - virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo&) = 0; - virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Dsizei* count, WebGLId* shaders) = 0; - virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) = 0; - virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) = 0; - virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0; - virtual Attributes getContextAttributes() = 0; - virtual WGC3Denum getError() = 0; - virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) = 0; - virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum attachment, WGC3Denum pname, WGC3Dint* value) = 0; - virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) = 0; - virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) = 0; - virtual WebString getProgramInfoLog(WebGLId program) = 0; - virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0; - virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) = 0; - virtual WebString getShaderInfoLog(WebGLId shader) = 0; - - // TBD - // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); - - virtual WebString getShaderSource(WebGLId shader) = 0; - virtual WebString getString(WGC3Denum name) = 0; - virtual void getTexParameterfv(WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value) = 0; - virtual void getTexParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0; - virtual void getUniformfv(WebGLId program, WGC3Dint location, WGC3Dfloat* value) = 0; - virtual void getUniformiv(WebGLId program, WGC3Dint location, WGC3Dint* value) = 0; - virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name) = 0; - virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value) = 0; - virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* value) = 0; - virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) = 0; - - virtual void hint(WGC3Denum target, WGC3Denum mode) = 0; - virtual WGC3Dboolean isBuffer(WebGLId buffer) = 0; - virtual WGC3Dboolean isEnabled(WGC3Denum cap) = 0; - virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer) = 0; - virtual WGC3Dboolean isProgram(WebGLId program) = 0; - virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer) = 0; - virtual WGC3Dboolean isShader(WebGLId shader) = 0; - virtual WGC3Dboolean isTexture(WebGLId texture) = 0; - virtual void lineWidth(WGC3Dfloat) = 0; - virtual void linkProgram(WebGLId program) = 0; - virtual void pixelStorei(WGC3Denum pname, WGC3Dint param) = 0; - virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units) = 0; - - virtual void readPixels(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, void* pixels) = 0; - - virtual void releaseShaderCompiler() = 0; - - virtual void renderbufferStorage(WGC3Denum target, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height) = 0; - virtual void sampleCoverage(WGC3Dclampf value, WGC3Dboolean invert) = 0; - virtual void scissor(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0; - virtual void shaderSource(WebGLId shader, const WGC3Dchar* string) = 0; - virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask) = 0; - virtual void stencilFuncSeparate(WGC3Denum face, WGC3Denum func, WGC3Dint ref, WGC3Duint mask) = 0; - virtual void stencilMask(WGC3Duint mask) = 0; - virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask) = 0; - virtual void stencilOp(WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass) = 0; - virtual void stencilOpSeparate(WGC3Denum face, WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass) = 0; - - virtual void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) = 0; - - virtual void texParameterf(WGC3Denum target, WGC3Denum pname, WGC3Dfloat param) = 0; - virtual void texParameteri(WGC3Denum target, WGC3Denum pname, WGC3Dint param) = 0; - - virtual void texSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, const void* pixels) = 0; - - virtual void uniform1f(WGC3Dint location, WGC3Dfloat x) = 0; - virtual void uniform1fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0; - virtual void uniform1i(WGC3Dint location, WGC3Dint x) = 0; - virtual void uniform1iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0; - virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y) = 0; - virtual void uniform2fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0; - virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y) = 0; - virtual void uniform2iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0; - virtual void uniform3f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z) = 0; - virtual void uniform3fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0; - virtual void uniform3i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z) = 0; - virtual void uniform3iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0; - virtual void uniform4f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w) = 0; - virtual void uniform4fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0; - virtual void uniform4i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w) = 0; - virtual void uniform4iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0; - virtual void uniformMatrix2fv(WGC3Dint location, WGC3Dsizei count, WGC3Dboolean transpose, const WGC3Dfloat* value) = 0; - virtual void uniformMatrix3fv(WGC3Dint location, WGC3Dsizei count, WGC3Dboolean transpose, const WGC3Dfloat* value) = 0; - virtual void uniformMatrix4fv(WGC3Dint location, WGC3Dsizei count, WGC3Dboolean transpose, const WGC3Dfloat* value) = 0; - - virtual void useProgram(WebGLId program) = 0; - virtual void validateProgram(WebGLId program) = 0; - - virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x) = 0; - virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values) = 0; - virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y) = 0; - virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values) = 0; - virtual void vertexAttrib3f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z) = 0; - virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values) = 0; - virtual void vertexAttrib4f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w) = 0; - virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values) = 0; - virtual void vertexAttribPointer(WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized, - WGC3Dsizei stride, WGC3Dintptr offset) = 0; - - virtual void viewport(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0; - - // Support for buffer creation and deletion. - virtual WebGLId createBuffer() = 0; - virtual WebGLId createFramebuffer() = 0; - virtual WebGLId createProgram() = 0; - virtual WebGLId createRenderbuffer() = 0; - virtual WebGLId createShader(WGC3Denum) = 0; - virtual WebGLId createTexture() = 0; - - virtual void deleteBuffer(WebGLId) = 0; - virtual void deleteFramebuffer(WebGLId) = 0; - virtual void deleteProgram(WebGLId) = 0; - virtual void deleteRenderbuffer(WebGLId) = 0; - virtual void deleteShader(WebGLId) = 0; - virtual void deleteTexture(WebGLId) = 0; - - virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback) {} - virtual void setErrorMessageCallback(WebGraphicsErrorMessageCallback* callback) { } - // GL_ARB_robustness - // - // This entry point must provide slightly different semantics than - // the GL_ARB_robustness extension; specifically, the lost context - // state is sticky, rather than reported only once. - virtual WGC3Denum getGraphicsResetStatusARB() { return 0; /* GL_NO_ERROR */ } - - // FIXME: make this function pure virtual once it is implemented in - // both command buffer port and in-process port. - virtual WebString getTranslatedShaderSourceANGLE(WebGLId shader) { return WebString(); } - - // GL_CHROMIUM_iosurface - virtual void texImageIOSurface2DCHROMIUM(WGC3Denum target, WGC3Dint width, WGC3Dint height, WGC3Duint ioSurfaceId, WGC3Duint plane) { } - - // GL_EXT_texture_storage - virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat, - WGC3Dint width, WGC3Dint height) { } - - -#if WEBKIT_USING_SKIA - GrGLInterface* createGrGLInterface(); -#endif - -protected: -#if WEBKIT_USING_SKIA - virtual GrGLInterface* onCreateGrGLInterface() { return 0; } -#endif - -}; - -} // namespace WebKit - -#endif +#include "../../../../Platform/chromium/public/WebGraphicsContext3D.h" diff --git a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h index 3bf4cb43a..d2c1fd814 100644 --- a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h +++ b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h @@ -58,7 +58,6 @@ class WebClipboard; class WebCookieJar; class WebFileSystem; class WebFileUtilities; -class WebGraphicsContext3D; class WebIDBFactory; // FIXME: Does this belong in platform? class WebIDBKey; // FIXME: Does this belong in platform? class WebMediaStreamCenter; @@ -386,8 +385,6 @@ public: // May return null if GPU is not supported. // Returns newly allocated and initialized offscreen WebGraphicsContext3D instance. virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return 0; } - // Deprecated. - virtual WebGraphicsContext3D* createGraphicsContext3D() { return 0; } // Audio -------------------------------------------------------------- diff --git a/Source/WebKit/chromium/public/platform/WebLayer.h b/Source/WebKit/chromium/public/platform/WebLayer.h index 3d919fa46..234c2fc4b 100644 --- a/Source/WebKit/chromium/public/platform/WebLayer.h +++ b/Source/WebKit/chromium/public/platform/WebLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,121 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebLayer_h -#define WebLayer_h - -#include "WebColor.h" -#include "WebCommon.h" -#include "WebPrivatePtr.h" - -class SkMatrix44; -namespace WebCore { class LayerChromium; } - -namespace WebKit { -struct WebFloatPoint; -struct WebSize; - -class WebLayer { -public: - WEBKIT_EXPORT static WebLayer create(); - - WebLayer() { } - WebLayer(const WebLayer& layer) { assign(layer); } - virtual ~WebLayer() { reset(); } - WebLayer& operator=(const WebLayer& layer) - { - assign(layer); - return *this; - } - bool isNull() { return m_private.isNull(); } - WEBKIT_EXPORT void reset(); - WEBKIT_EXPORT void assign(const WebLayer&); - WEBKIT_EXPORT bool equals(const WebLayer&) const; - - WEBKIT_EXPORT WebLayer rootLayer() const; - WEBKIT_EXPORT WebLayer parent() const; - WEBKIT_EXPORT void addChild(const WebLayer&); - WEBKIT_EXPORT void insertChild(const WebLayer&, size_t index); - WEBKIT_EXPORT void replaceChild(const WebLayer& reference, const WebLayer& newLayer); - WEBKIT_EXPORT void removeFromParent(); - WEBKIT_EXPORT void removeAllChildren(); - - WEBKIT_EXPORT void setAnchorPoint(const WebFloatPoint&); - WEBKIT_EXPORT WebFloatPoint anchorPoint() const; - - WEBKIT_EXPORT void setAnchorPointZ(float); - WEBKIT_EXPORT float anchorPointZ() const; - - WEBKIT_EXPORT void setBounds(const WebSize&); - WEBKIT_EXPORT WebSize bounds() const; - - WEBKIT_EXPORT void setMasksToBounds(bool); - WEBKIT_EXPORT bool masksToBounds() const; - - WEBKIT_EXPORT void setMaskLayer(const WebLayer&); - WEBKIT_EXPORT WebLayer maskLayer() const; - - WEBKIT_EXPORT void setOpacity(float); - WEBKIT_EXPORT float opacity() const; - - WEBKIT_EXPORT void setOpaque(bool); - WEBKIT_EXPORT bool opaque() const; - - WEBKIT_EXPORT void setPosition(const WebFloatPoint&); - WEBKIT_EXPORT WebFloatPoint position() const; - - WEBKIT_EXPORT void setSublayerTransform(const SkMatrix44&); - WEBKIT_EXPORT SkMatrix44 sublayerTransform() const; - - WEBKIT_EXPORT void setTransform(const SkMatrix44&); - WEBKIT_EXPORT SkMatrix44 transform() const; - - WEBKIT_EXPORT void setDebugBorderColor(const WebColor&); - WEBKIT_EXPORT void setDebugBorderWidth(float); - - template<typename T> T to() - { - T res; - res.WebLayer::assign(*this); - return res; - } - - template<typename T> const T toConst() const - { - T res; - res.WebLayer::assign(*this); - return res; - } - -#if WEBKIT_IMPLEMENTATION - WebLayer(const WTF::PassRefPtr<WebCore::LayerChromium>&); - WebLayer& operator=(const WTF::PassRefPtr<WebCore::LayerChromium>&); - operator WTF::PassRefPtr<WebCore::LayerChromium>() const; - template<typename T> T* unwrap() - { - return static_cast<T*>(m_private.get()); - } - - template<typename T> const T* constUnwrap() const - { - return static_cast<const T*>(m_private.get()); - } -#endif - -protected: - WebPrivatePtr<WebCore::LayerChromium> m_private; -}; - -inline bool operator==(const WebLayer& a, const WebLayer& b) -{ - return a.equals(b); -} - -inline bool operator!=(const WebLayer& a, const WebLayer& b) -{ - return !(a == b); -} - -} // namespace WebKit - -#endif // WebLayer_h +#include "../../../../Platform/chromium/public/WebLayer.h" diff --git a/Source/WebKit/chromium/public/platform/WebLayerTreeView.h b/Source/WebKit/chromium/public/platform/WebLayerTreeView.h index 17a876a98..2ea2915e1 100644 --- a/Source/WebKit/chromium/public/platform/WebLayerTreeView.h +++ b/Source/WebKit/chromium/public/platform/WebLayerTreeView.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,110 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebLayerTreeView_h -#define WebLayerTreeView_h - -#include "WebCommon.h" -#include "WebPrivatePtr.h" - -namespace WebCore { -class CCLayerTreeHost; -struct CCSettings; -} - -namespace WebKit { -class WebLayer; -class WebLayerTreeViewClient; -struct WebRect; -struct WebSize; - -class WebLayerTreeView { -public: - struct Settings { - Settings() - : acceleratePainting(false) - , compositeOffscreen(false) - , showFPSCounter(false) - , showPlatformLayerTree(false) - , refreshRate(0) - , perTilePainting(false) - , partialSwapEnabled(false) - , threadedAnimationEnabled(false) { } - - bool acceleratePainting; - bool compositeOffscreen; - bool showFPSCounter; - bool showPlatformLayerTree; - double refreshRate; - bool perTilePainting; - bool partialSwapEnabled; - bool threadedAnimationEnabled; -#if WEBKIT_IMPLEMENTATION - operator WebCore::CCSettings() const; -#endif - }; - - WEBKIT_EXPORT static WebLayerTreeView create(WebLayerTreeViewClient*, const WebLayer& root, const Settings&); - - WebLayerTreeView() { } - WebLayerTreeView(const WebLayerTreeView& layer) { assign(layer); } - ~WebLayerTreeView() { reset(); } - WebLayerTreeView& operator=(const WebLayerTreeView& layer) - { - assign(layer); - return *this; - } - WEBKIT_EXPORT void reset(); - WEBKIT_EXPORT void assign(const WebLayerTreeView&); - WEBKIT_EXPORT bool equals(const WebLayerTreeView&) const; - - // Triggers a compositing pass. If the compositor thread was not - // enabled via WebCompositor::initialize, the compositing pass happens - // immediately. If it is enabled, the compositing pass will happen at a - // later time. Before the compositing pass happens (i.e. before composite() - // returns when the compositor thread is disabled), WebContentLayers will be - // asked to paint their dirty region, through - // WebContentLayerClient::paintContents. - WEBKIT_EXPORT void composite(); - - WEBKIT_EXPORT void setViewportSize(const WebSize&); - WEBKIT_EXPORT WebSize viewportSize() const; - - // Composites and attempts to read back the result into the provided - // buffer. If it wasn't possible, e.g. due to context lost, will return - // false. Pixel format is 32bit (RGBA), and the provided buffer must be - // large enough contain viewportSize().width() * viewportSize().height() - // pixels. The WebLayerTreeView does not assume ownership of the buffer. - // The buffer is not modified if the false is returned. - WEBKIT_EXPORT bool compositeAndReadback(void *pixels, const WebRect&); - - // Sets the root of the tree. The root is set by way of the constructor. - // This is typically used to explicitly set the root to null to break - // cycles. - WEBKIT_EXPORT void setRootLayer(WebLayer*); - -#if WEBKIT_IMPLEMENTATION - WebLayerTreeView(const WTF::PassRefPtr<WebCore::CCLayerTreeHost>&); - WebLayerTreeView& operator=(const WTF::PassRefPtr<WebCore::CCLayerTreeHost>&); - operator WTF::PassRefPtr<WebCore::CCLayerTreeHost>() const; -#endif - - WEBKIT_EXPORT void setNeedsRedraw(); - -protected: - WebPrivatePtr<WebCore::CCLayerTreeHost> m_private; -}; - -inline bool operator==(const WebLayerTreeView& a, const WebLayerTreeView& b) -{ - return a.equals(b); -} - -inline bool operator!=(const WebLayerTreeView& a, const WebLayerTreeView& b) -{ - return !(a == b); -} - -} // namespace WebKit - -#endif // WebLayerTreeView_h +#include "../../../../Platform/chromium/public/WebLayerTreeView.h" diff --git a/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h b/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h index 9c4dfb77b..36c61f584 100644 --- a/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h +++ b/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,45 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebLayerTreeViewClient_h -#define WebLayerTreeViewClient_h - -namespace WebKit { -class WebGraphicsContext3D; -struct WebSize; -class WebThread; - -class WebLayerTreeViewClient { -public: - // Updates animation and layout. These are called before the compositing - // pass so that layers can be updated at the given frame time. - virtual void updateAnimations(double frameBeginTime) = 0; - virtual void layout() = 0; - - // Applies a scroll delta to the root layer, which is bundled with a page - // scale factor that may apply a CSS transform on the whole document (used - // for mobile-device pinch zooming). This is triggered by events sent to the - // compositor thread through the WebCompositor interface. - virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) = 0; - - // Creates a 3D context suitable for the compositing. This may be called - // more than once if the context gets lost. - virtual WebGraphicsContext3D* createContext3D() = 0; - - // Signals a successful rebinding of the 3D context (e.g. after a lost - // context event). - virtual void didRebindGraphicsContext(bool success) = 0; - - // Schedules a compositing pass, meaning the client should call - // WebLayerTreeView::composite at a later time. This is only called if the - // compositor thread is disabled; when enabled, the compositor will - // internally schedule a compositing pass when needed. - virtual void scheduleComposite() = 0; - -protected: - virtual ~WebLayerTreeViewClient() { } -}; - -} // namespace WebKit - -#endif // WebLayerTreeViewClient_h +#include "../../../../Platform/chromium/public/WebLayerTreeViewClient.h" diff --git a/Source/WebKit/chromium/public/platform/WebNonCopyable.h b/Source/WebKit/chromium/public/platform/WebNonCopyable.h index b0bd4565c..d44d2802c 100644 --- a/Source/WebKit/chromium/public/platform/WebNonCopyable.h +++ b/Source/WebKit/chromium/public/platform/WebNonCopyable.h @@ -1,49 +1,26 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions + * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebNonCopyable_h -#define WebNonCopyable_h - -namespace WebKit { - -// A base class to extend from if you do not support copying. -class WebNonCopyable { -protected: - WebNonCopyable() { } - ~WebNonCopyable() { } - -private: - WebNonCopyable(const WebNonCopyable&); - WebNonCopyable& operator=(const WebNonCopyable&); -}; - -} // namespace WebKit - -#endif +#include "../../../../Platform/chromium/public/WebNonCopyable.h" diff --git a/Source/WebKit/chromium/public/platform/WebPrivatePtr.h b/Source/WebKit/chromium/public/platform/WebPrivatePtr.h index 31d09a90b..208096ed3 100644 --- a/Source/WebKit/chromium/public/platform/WebPrivatePtr.h +++ b/Source/WebKit/chromium/public/platform/WebPrivatePtr.h @@ -1,107 +1,26 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions + * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebPrivatePtr_h -#define WebPrivatePtr_h - -#include "WebCommon.h" - -#if WEBKIT_IMPLEMENTATION -#include <wtf/PassRefPtr.h> -#endif - -namespace WebKit { - -// This class is an implementation detail of the WebKit API. It exists -// to help simplify the implementation of WebKit interfaces that merely -// wrap a reference counted WebCore class. -template <typename T> -class WebPrivatePtr { -public: - WebPrivatePtr() : m_ptr(0) { } - ~WebPrivatePtr() { WEBKIT_ASSERT(!m_ptr); } - - bool isNull() const { return !m_ptr; } - -#if WEBKIT_IMPLEMENTATION - WebPrivatePtr(const PassRefPtr<T>& prp) - : m_ptr(prp.leakRef()) - { - } - - void reset() - { - assign(0); - } - - WebPrivatePtr<T>& operator=(const WebPrivatePtr<T>& other) - { - T* p = other.m_ptr; - if (p) - p->ref(); - assign(p); - return *this; - } - - WebPrivatePtr<T>& operator=(const PassRefPtr<T>& prp) - { - assign(prp.leakRef()); - return *this; - } - - T* get() const - { - return m_ptr; - } - - T* operator->() const - { - ASSERT(m_ptr); - return m_ptr; - } -#endif - -private: -#if WEBKIT_IMPLEMENTATION - void assign(T* p) - { - // p is already ref'd for us by the caller - if (m_ptr) - m_ptr->deref(); - m_ptr = p; - } -#endif - - T* m_ptr; -}; - -} // namespace WebKit - -#endif +#include "../../../../Platform/chromium/public/WebPrivatePtr.h" diff --git a/Source/WebKit/chromium/public/platform/WebSolidColorLayer.h b/Source/WebKit/chromium/public/platform/WebSolidColorLayer.h index ad9123d96..f4edbd489 100644 --- a/Source/WebKit/chromium/public/platform/WebSolidColorLayer.h +++ b/Source/WebKit/chromium/public/platform/WebSolidColorLayer.h @@ -23,26 +23,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebSolidColorLayer_h -#define WebSolidColorLayer_h - -#include "WebCommon.h" -#include "WebFloatRect.h" -#include "WebLayer.h" - -namespace WebKit { -class WebSolidColorLayerImpl; - -class WebSolidColorLayer : public WebLayer { -public: - WEBKIT_EXPORT static WebSolidColorLayer create(); - WEBKIT_EXPORT void setBackgroundColor(const WebColor&); - -#if WEBKIT_IMPLEMENTATION - WebSolidColorLayer(const WTF::PassRefPtr<WebSolidColorLayerImpl>&); -#endif -}; - -} // namespace WebKit - -#endif // WebSolidColorLayer_h +#include "../../../../Platform/chromium/public/WebSolidColorLayer.h" diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp index 3f0875b53..ac6fa0447 100644 --- a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp +++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -53,7 +53,7 @@ #include "IconURL.h" #include "MediaPlayer.h" #include "MediaStreamSource.h" -#include "NotificationPresenter.h" +#include "NotificationClient.h" #include "PageVisibilityState.h" #include "PasteboardPrivate.h" #include "PlatformCursor.h" @@ -394,9 +394,9 @@ COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatASCII, VideoFrameChromium::ASC #endif #if ENABLE(NOTIFICATIONS) -COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionAllowed, NotificationPresenter::PermissionAllowed); -COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionNotAllowed, NotificationPresenter::PermissionNotAllowed); -COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionDenied, NotificationPresenter::PermissionDenied); +COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionAllowed, NotificationClient::PermissionAllowed); +COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionNotAllowed, NotificationClient::PermissionNotAllowed); +COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionDenied, NotificationClient::PermissionDenied); #endif COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::Horizontal, HorizontalScrollbar); diff --git a/Source/WebKit/chromium/src/AssociatedURLLoader.cpp b/Source/WebKit/chromium/src/AssociatedURLLoader.cpp index c314411b4..0c3a0cf55 100644 --- a/Source/WebKit/chromium/src/AssociatedURLLoader.cpp +++ b/Source/WebKit/chromium/src/AssociatedURLLoader.cpp @@ -79,6 +79,7 @@ void HTTPRequestHeaderValidator::visitHeader(const WebString& name, const WebStr m_isSafe = m_isSafe && isValidHTTPToken(name) && XMLHttpRequest::isAllowedHTTPHeader(name) && isValidHTTPHeaderValue(value); } +// FIXME: Remove this and use WebCore code that does the same thing. class HTTPResponseHeaderValidator : public WebHTTPHeaderVisitor { WTF_MAKE_NONCOPYABLE(HTTPResponseHeaderValidator); public: @@ -97,7 +98,7 @@ void HTTPResponseHeaderValidator::visitHeader(const WebString& name, const WebSt { String headerName(name); if (m_usingAccessControl) { - if (equalIgnoringCase(headerName, "access-control-expose-header")) + if (equalIgnoringCase(headerName, "access-control-expose-headers")) parseAccessControlExposeHeadersAllowList(value, m_exposedHeaders); else if (!isOnAccessControlResponseHeaderWhitelist(headerName)) m_blockedHeaders.add(name); @@ -112,7 +113,7 @@ const HTTPHeaderSet& HTTPResponseHeaderValidator::blockedHeaders() m_exposedHeaders.remove("set-cookie"); m_exposedHeaders.remove("set-cookie2"); // Block Access-Control-Expose-Header itself. It could be exposed later. - m_blockedHeaders.add("access-control-expose-header"); + m_blockedHeaders.add("access-control-expose-headers"); HTTPHeaderSet::const_iterator end = m_exposedHeaders.end(); for (HTTPHeaderSet::const_iterator it = m_exposedHeaders.begin(); it != end; ++it) m_blockedHeaders.remove(*it); diff --git a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp index 1f93cf93e..8d8a3fedc 100644 --- a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp +++ b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp @@ -34,7 +34,10 @@ #include "AsyncFileSystemCallbacks.h" #include "AsyncFileWriterChromium.h" +#include "BlobURL.h" +#include "FileMetadata.h" #include "SecurityOrigin.h" +#include "ThreadableBlobRegistry.h" #include "WebFileInfo.h" #include "WebFileSystemCallbacksImpl.h" #include "WebFileWriter.h" @@ -46,11 +49,51 @@ namespace WebCore { +namespace { + // ChromeOS-specific filesystem type. const AsyncFileSystem::Type externalType = static_cast<AsyncFileSystem::Type>(WebKit::WebFileSystem::TypeExternal); const char externalPathPrefix[] = "external"; const size_t externalPathPrefixLength = sizeof(externalPathPrefix) - 1; +// Specialized callback class for createSnapshotFileAndReadMetadata. +class SnapshotFileCallbacks : public AsyncFileSystemCallbacks { +public: + static PassOwnPtr<SnapshotFileCallbacks> create(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks) + { + return adoptPtr(new SnapshotFileCallbacks(internalBlobURL, callbacks)); + } + + virtual void didReadMetadata(const FileMetadata& metadata) + { + ASSERT(m_callbacks); + + // This will create a new File object using the metadata. + m_callbacks->didReadMetadata(metadata); + + // Now that we've registered the snapshot file, we can unregister our internalBlobURL which has played a placeholder for the file during the IPC. + ThreadableBlobRegistry::unregisterBlobURL(m_internalBlobURL); + } + + virtual void didFail(int error) + { + ASSERT(m_callbacks); + m_callbacks->didFail(error); + } + +private: + SnapshotFileCallbacks(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks) + : m_internalBlobURL(internalBlobURL) + , m_callbacks(callbacks) + { + } + + KURL m_internalBlobURL; + OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks; +}; + +} // namespace + // static bool AsyncFileSystem::isAvailable() { @@ -254,6 +297,15 @@ void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const m_webFileSystem->readMetadata(pathAsURL, new FileWriterHelperCallbacks(client, pathAsURL, m_webFileSystem, callbacks)); } +void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) +{ + KURL pathAsURL = virtualPathToFileSystemURL(path); + KURL internalBlobURL = BlobURL::createInternalURL(); + + // This will create a snapshot file and register the file to a blob using the given internalBlobURL. + m_webFileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, pathAsURL, new WebKit::WebFileSystemCallbacksImpl(createSnapshotFileCallback(internalBlobURL, callbacks))); +} + KURL AsyncFileSystemChromium::virtualPathToFileSystemURL(const String& virtualPath) const { ASSERT(!m_filesystemRootURL.isEmpty()); @@ -263,6 +315,11 @@ KURL AsyncFileSystemChromium::virtualPathToFileSystemURL(const String& virtualPa return url; } +PassOwnPtr<AsyncFileSystemCallbacks> AsyncFileSystemChromium::createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) const +{ + return SnapshotFileCallbacks::create(internalBlobURL, callbacks); +} + } // namespace WebCore #endif diff --git a/Source/WebKit/chromium/src/AsyncFileSystemChromium.h b/Source/WebKit/chromium/src/AsyncFileSystemChromium.h index a8cbca276..8255d8e72 100644 --- a/Source/WebKit/chromium/src/AsyncFileSystemChromium.h +++ b/Source/WebKit/chromium/src/AsyncFileSystemChromium.h @@ -66,9 +66,13 @@ public: virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); + virtual void createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); protected: AsyncFileSystemChromium(AsyncFileSystem::Type, const KURL& rootURL); + + PassOwnPtr<AsyncFileSystemCallbacks> createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks>) const; + WebKit::WebFileSystem* m_webFileSystem; // Converts a given absolute virtual path to a full origin-qualified FileSystem URL. diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp index 45a813859..ad35382b9 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp +++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp @@ -136,6 +136,7 @@ ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) , m_scrollbarsVisible(true) , m_menubarVisible(true) , m_resizable(true) + , m_nextNewWindowNavigationPolicy(WebNavigationPolicyIgnore) { } @@ -238,13 +239,23 @@ Page* ChromeClientImpl::createWindow( if (!m_webView->client()) return 0; + // FrameLoaderClientImpl may have given us a policy to use for the next new + // window navigation. If not, determine the policy using the same logic as + // show(). + WebNavigationPolicy policy; + if (m_nextNewWindowNavigationPolicy != WebNavigationPolicyIgnore) { + policy = m_nextNewWindowNavigationPolicy; + m_nextNewWindowNavigationPolicy = WebNavigationPolicyIgnore; + } else + policy = getNavigationPolicy(); + WrappedResourceRequest request; if (!r.resourceRequest().isEmpty()) request.bind(r.resourceRequest()); else if (!action.resourceRequest().isEmpty()) request.bind(action.resourceRequest()); WebViewImpl* newView = static_cast<WebViewImpl*>( - m_webView->client()->createView(WebFrameImpl::fromFrame(frame), request, features, r.frameName())); + m_webView->client()->createView(WebFrameImpl::fromFrame(frame), request, features, r.frameName(), policy)); if (!newView) return 0; @@ -287,11 +298,8 @@ static inline bool currentEventShouldCauseBackgroundTab(const WebInputEvent* inp return policy == WebNavigationPolicyNewBackgroundTab; } -void ChromeClientImpl::show() +WebNavigationPolicy ChromeClientImpl::getNavigationPolicy() { - if (!m_webView->client()) - return; - // If our default configuration was modified by a script or wasn't // created by a user gesture, then show as a popup. Else, let this // new window be opened as a toplevel window. @@ -306,8 +314,15 @@ void ChromeClientImpl::show() policy = WebNavigationPolicyNewPopup; if (currentEventShouldCauseBackgroundTab(WebViewImpl::currentInputEvent())) policy = WebNavigationPolicyNewBackgroundTab; + return policy; +} + +void ChromeClientImpl::show() +{ + if (!m_webView->client()) + return; - m_webView->client()->show(policy); + m_webView->client()->show(getNavigationPolicy()); } bool ChromeClientImpl::canRunModal() @@ -603,7 +618,7 @@ void ChromeClientImpl::mouseDidMoveOverElement( Widget* widget = toRenderWidget(object)->widget(); if (widget && widget->isPluginContainer()) { WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget); - url = plugin->plugin()->linkAtPosition(result.point()); + url = plugin->plugin()->linkAtPosition(result.roundedPoint()); } } } @@ -802,6 +817,11 @@ void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor) setCursor(cursor); } +void ChromeClientImpl::setNewWindowNavigationPolicy(WebNavigationPolicy policy) +{ + m_nextNewWindowNavigationPolicy = policy; +} + void ChromeClientImpl::formStateDidChange(const Node* node) { // The current history item is not updated yet. That happens lazily when @@ -890,7 +910,7 @@ void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* grap void ChromeClientImpl::scheduleCompositingLayerSync() { - m_webView->setRootLayerNeedsDisplay(); + m_webView->scheduleCompositingLayerSync(); } ChromeClient::CompositingTriggerFlags ChromeClientImpl::allowedCompositingTriggers() const diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.h b/Source/WebKit/chromium/src/ChromeClientImpl.h index 23e02ff3d..c34945404 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.h +++ b/Source/WebKit/chromium/src/ChromeClientImpl.h @@ -35,6 +35,7 @@ #include "ChromeClientChromium.h" #include "PopupMenu.h" #include "SearchPopupMenu.h" +#include "WebNavigationPolicy.h" namespace WebCore { class AccessibilityObject; @@ -189,6 +190,7 @@ public: // ChromeClientImpl: void setCursorForPlugin(const WebCursorInfo&); + void setNewWindowNavigationPolicy(WebNavigationPolicy); virtual bool selectItemWritingDirectionIsNatural(); virtual bool selectItemAlignmentFollowsMenuWritingDirection(); @@ -196,10 +198,6 @@ public: virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const; virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const; -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif - virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::FrameLoader::PageDismissalType) const; virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const; @@ -213,6 +211,7 @@ public: #endif private: + WebNavigationPolicy getNavigationPolicy(); void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*); void setCursor(const WebCursorInfo&); @@ -222,6 +221,9 @@ private: bool m_scrollbarsVisible; bool m_menubarVisible; bool m_resizable; + + // The policy for how the next webview to be created will be shown. + WebNavigationPolicy m_nextNewWindowNavigationPolicy; }; } // namespace WebKit diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp index 790a9c52b..4712eff7d 100644 --- a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp +++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -158,7 +158,7 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( Frame* selectedFrame = r.innerNonSharedNode()->document()->frame(); WebContextMenuData data; - data.mousePosition = selectedFrame->view()->contentsToWindow(r.point()); + data.mousePosition = selectedFrame->view()->contentsToWindow(r.roundedPoint()); // Compute edit flags. data.editFlags = WebContextMenuData::CanDoNone; diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp index a85ccbd2e..2dada5c50 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp @@ -145,10 +145,10 @@ void FrameLoaderClientImpl::documentElementAvailable() } #if USE(V8) -void FrameLoaderClientImpl::didCreateScriptContext(v8::Handle<v8::Context> context, int worldId) +void FrameLoaderClientImpl::didCreateScriptContext(v8::Handle<v8::Context> context, int extensionGroup, int worldId) { if (m_webFrame->client()) - m_webFrame->client()->didCreateScriptContext(m_webFrame, context, worldId); + m_webFrame->client()->didCreateScriptContext(m_webFrame, context, extensionGroup, worldId); } void FrameLoaderClientImpl::willReleaseScriptContext(v8::Handle<v8::Context> context, int worldId) @@ -612,7 +612,7 @@ void FrameLoaderClientImpl::dispatchWillPerformClientRedirect( // carry out such a navigation anyway, the best thing we can do for now to // not get confused is ignore this notification. if (m_expectedClientRedirectDest.isLocalFile() - && m_expectedClientRedirectSrc.protocolInHTTPFamily()) { + && m_expectedClientRedirectSrc.protocolIsInHTTPFamily()) { m_expectedClientRedirectSrc = KURL(); m_expectedClientRedirectDest = KURL(); return; @@ -873,21 +873,27 @@ void FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout() Frame* FrameLoaderClientImpl::dispatchCreatePage(const NavigationAction& action) { - struct WindowFeatures features; - Page* newPage = m_webFrame->frame()->page()->chrome()->createWindow( - m_webFrame->frame(), FrameLoadRequest(m_webFrame->frame()->document()->securityOrigin()), - features, action); - // Make sure that we have a valid disposition. This should have been set in // the preceeding call to dispatchDecidePolicyForNewWindowAction. ASSERT(m_nextNavigationPolicy != WebNavigationPolicyIgnore); WebNavigationPolicy policy = m_nextNavigationPolicy; m_nextNavigationPolicy = WebNavigationPolicyIgnore; + // Store the disposition on the opener ChromeClientImpl so that we can pass + // it to WebViewClient::createView. + ChromeClientImpl* chromeClient = static_cast<ChromeClientImpl*>(m_webFrame->frame()->page()->chrome()->client()); + chromeClient->setNewWindowNavigationPolicy(policy); + + struct WindowFeatures features; + Page* newPage = m_webFrame->frame()->page()->chrome()->createWindow( + m_webFrame->frame(), FrameLoadRequest(m_webFrame->frame()->document()->securityOrigin()), + features, action); + // createWindow can return null (e.g., popup blocker denies the window). if (!newPage) return 0; + // Also give the disposition to the new window. WebViewImpl::fromPage(newPage)->setInitialNavigationPolicy(policy); return newPage->mainFrame(); } @@ -949,6 +955,11 @@ void FrameLoaderClientImpl::dispatchDecidePolicyForNewWindowAction( // creating or showing the new window that would allow us to avoid having // to keep this state. m_nextNavigationPolicy = navigationPolicy; + + // Store the disposition on the opener ChromeClientImpl so that we can pass + // it to WebViewClient::createView. + ChromeClientImpl* chromeClient = static_cast<ChromeClientImpl*>(m_webFrame->frame()->page()->chrome()->client()); + chromeClient->setNewWindowNavigationPolicy(navigationPolicy); } (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction); } diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h index 0bf935d6d..53d5997e8 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h @@ -62,7 +62,7 @@ public: virtual void documentElementAvailable(); #if USE(V8) - virtual void didCreateScriptContext(v8::Handle<v8::Context>, int worldId); + virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId); virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId); #endif diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp index c7ac894b0..4bfa2e5bc 100644 --- a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp +++ b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp @@ -67,6 +67,15 @@ #include "GrGLInterface.h" #endif +namespace { + +// The limit of the number of textures we hold in the GrContext's bitmap->texture cache. +const int maxGaneshTextureCacheCount = 512; +// The limit of the bytes allocated toward textures in the GrContext's bitmap->texture cache. +const size_t maxGaneshTextureCacheBytes = 96 * 1024 * 1024; + +} + // There are two levels of delegation in this file: // // 1. GraphicsContext3D delegates to GraphicsContext3DPrivate. This is done @@ -158,18 +167,41 @@ Platform3DObject GraphicsContext3DPrivate::platformTexture() const } #if USE(SKIA) +class GrMemoryAllocationChangedCallback : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM { +public: + GrMemoryAllocationChangedCallback(GraphicsContext3DPrivate* context) + : m_context(context) + { + } + + virtual void onGpuMemoryAllocationChanged(size_t gpuResourceSizeInBytes) + { + GrContext* context = m_context->grContext(); + if (!context) + return; + + if (!gpuResourceSizeInBytes) { + context->freeGpuResources(); + context->setTextureCacheLimits(0, 0); + } else + context->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); + } + +private: + GraphicsContext3DPrivate* m_context; +}; + GrContext* GraphicsContext3DPrivate::grContext() { - // Limit the number of textures we hold in the bitmap->texture cache. - static const int maxTextureCacheCount = 512; - // Limit the bytes allocated toward textures in the bitmap->texture cache. - static const size_t maxTextureCacheBytes = 96 * 1024 * 1024; - if (!m_grContext) { SkAutoTUnref<GrGLInterface> interface(m_impl->createGrGLInterface()); m_grContext = GrContext::Create(kOpenGL_Shaders_GrEngine, reinterpret_cast<GrPlatform3DContext>(interface.get())); - if (m_grContext) - m_grContext->setTextureCacheLimits(maxTextureCacheCount, maxTextureCacheBytes); + if (m_grContext) { + m_grContext->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); + Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(getExtensions()); + if (extensions3DChromium->supports("GL_CHROMIUM_gpu_memory_manager")) + extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(adoptPtr(new GrMemoryAllocationChangedCallback(this))); + } } return m_grContext; } @@ -552,6 +584,7 @@ GraphicsContext3D::Attributes GraphicsContext3DPrivate::getContextAttributes() attributes.antialias = webAttributes.antialias; attributes.premultipliedAlpha = webAttributes.premultipliedAlpha; attributes.preserveDrawingBuffer = m_preserveDrawingBuffer; + attributes.preferDiscreteGPU = webAttributes.preferDiscreteGPU; return attributes; } @@ -651,71 +684,71 @@ void GraphicsContext3DPrivate::texSubImage2D(GC3Denum target, GC3Dint level, GC3 DELEGATE_TO_IMPL_2(uniform1f, GC3Dint, GC3Dfloat) -void GraphicsContext3DPrivate::uniform1fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform1fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) { m_impl->uniform1fv(location, size, v); } DELEGATE_TO_IMPL_2(uniform1i, GC3Dint, GC3Dint) -void GraphicsContext3DPrivate::uniform1iv(GC3Dint location, GC3Dint* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform1iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) { m_impl->uniform1iv(location, size, v); } DELEGATE_TO_IMPL_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat) -void GraphicsContext3DPrivate::uniform2fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform2fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) { m_impl->uniform2fv(location, size, v); } DELEGATE_TO_IMPL_3(uniform2i, GC3Dint, GC3Dint, GC3Dint) -void GraphicsContext3DPrivate::uniform2iv(GC3Dint location, GC3Dint* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform2iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) { m_impl->uniform2iv(location, size, v); } DELEGATE_TO_IMPL_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat) -void GraphicsContext3DPrivate::uniform3fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform3fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) { m_impl->uniform3fv(location, size, v); } DELEGATE_TO_IMPL_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint) -void GraphicsContext3DPrivate::uniform3iv(GC3Dint location, GC3Dint* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform3iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) { m_impl->uniform3iv(location, size, v); } DELEGATE_TO_IMPL_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat) -void GraphicsContext3DPrivate::uniform4fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform4fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) { m_impl->uniform4fv(location, size, v); } DELEGATE_TO_IMPL_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint) -void GraphicsContext3DPrivate::uniform4iv(GC3Dint location, GC3Dint* v, GC3Dsizei size) +void GraphicsContext3DPrivate::uniform4iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) { m_impl->uniform4iv(location, size, v); } -void GraphicsContext3DPrivate::uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size) +void GraphicsContext3DPrivate::uniformMatrix2fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value) { m_impl->uniformMatrix2fv(location, size, transpose, value); } -void GraphicsContext3DPrivate::uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size) +void GraphicsContext3DPrivate::uniformMatrix3fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value) { m_impl->uniformMatrix3fv(location, size, transpose, value); } -void GraphicsContext3DPrivate::uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size) +void GraphicsContext3DPrivate::uniformMatrix4fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value) { m_impl->uniformMatrix4fv(location, size, transpose, value); } @@ -996,6 +1029,7 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; webAttributes.noExtensions = attrs.noExtensions; webAttributes.shareResources = attrs.shareResources; + webAttributes.preferDiscreteGPU = attrs.preferDiscreteGPU; OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes)); if (!webContext) @@ -1155,24 +1189,24 @@ DELEGATE_TO_INTERNAL_3(texParameteri, GC3Denum, GC3Denum, GC3Dint) DELEGATE_TO_INTERNAL_9(texSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, const void*) DELEGATE_TO_INTERNAL_2(uniform1f, GC3Dint, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform1fv, GC3Dint, GC3Dfloat*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform1fv, GC3Dint, GC3Dsizei, GC3Dfloat*) DELEGATE_TO_INTERNAL_2(uniform1i, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform1iv, GC3Dint, GC3Dint*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform1iv, GC3Dint, GC3Dsizei, GC3Dint*) DELEGATE_TO_INTERNAL_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform2fv, GC3Dint, GC3Dfloat*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform2fv, GC3Dint, GC3Dsizei, GC3Dfloat*) DELEGATE_TO_INTERNAL_3(uniform2i, GC3Dint, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform2iv, GC3Dint, GC3Dint*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform2iv, GC3Dint, GC3Dsizei, GC3Dint*) DELEGATE_TO_INTERNAL_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform3fv, GC3Dint, GC3Dfloat*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform3fv, GC3Dint, GC3Dsizei, GC3Dfloat*) DELEGATE_TO_INTERNAL_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform3iv, GC3Dint, GC3Dint*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform3iv, GC3Dint, GC3Dsizei, GC3Dint*) DELEGATE_TO_INTERNAL_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform4fv, GC3Dint, GC3Dfloat*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform4fv, GC3Dint, GC3Dsizei, GC3Dfloat*) DELEGATE_TO_INTERNAL_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform4iv, GC3Dint, GC3Dint*, GC3Dsizei) -DELEGATE_TO_INTERNAL_4(uniformMatrix2fv, GC3Dint, GC3Dboolean, GC3Dfloat*, GC3Dsizei) -DELEGATE_TO_INTERNAL_4(uniformMatrix3fv, GC3Dint, GC3Dboolean, GC3Dfloat*, GC3Dsizei) -DELEGATE_TO_INTERNAL_4(uniformMatrix4fv, GC3Dint, GC3Dboolean, GC3Dfloat*, GC3Dsizei) +DELEGATE_TO_INTERNAL_3(uniform4iv, GC3Dint, GC3Dsizei, GC3Dint*) +DELEGATE_TO_INTERNAL_4(uniformMatrix2fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3Dfloat*) +DELEGATE_TO_INTERNAL_4(uniformMatrix3fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3Dfloat*) +DELEGATE_TO_INTERNAL_4(uniformMatrix4fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3Dfloat*) DELEGATE_TO_INTERNAL_1(useProgram, Platform3DObject) DELEGATE_TO_INTERNAL_1(validateProgram, Platform3DObject) diff --git a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h index d296eeb9b..be9db4287 100644 --- a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h +++ b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h @@ -209,24 +209,24 @@ public: void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels); void uniform1f(GC3Dint location, GC3Dfloat x); - void uniform1fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei); + void uniform1fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); void uniform1i(GC3Dint location, GC3Dint x); - void uniform1iv(GC3Dint location, GC3Dint* v, GC3Dsizei); + void uniform1iv(GC3Dint location, GC3Dsizei, GC3Dint* v); void uniform2f(GC3Dint location, GC3Dfloat x, float y); - void uniform2fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei); + void uniform2fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y); - void uniform2iv(GC3Dint location, GC3Dint* v, GC3Dsizei); + void uniform2iv(GC3Dint location, GC3Dsizei, GC3Dint* v); void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z); - void uniform3fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei); + void uniform3fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z); - void uniform3iv(GC3Dint location, GC3Dint* v, GC3Dsizei); + void uniform3iv(GC3Dint location, GC3Dsizei, GC3Dint* v); void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w); - void uniform4fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei); + void uniform4fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w); - void uniform4iv(GC3Dint location, GC3Dint* v, GC3Dsizei); - void uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei); - void uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei); - void uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei); + void uniform4iv(GC3Dint location, GC3Dsizei, GC3Dint* v); + void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value); + void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value); + void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value); void useProgram(Platform3DObject); void validateProgram(Platform3DObject); diff --git a/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp index a1cce45b0..149bfe12a 100755 --- a/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp +++ b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp @@ -90,16 +90,16 @@ static const char allowIndexedDBMode[] = "allowIndexedDBMode"; class AllowIndexedDBMainThreadBridge : public ThreadSafeRefCounted<AllowIndexedDBMainThreadBridge> { public: - static PassRefPtr<AllowIndexedDBMainThreadBridge> create(WebWorkerClientImpl* webWorkerClientImpl, const String& mode, const String& name) + static PassRefPtr<AllowIndexedDBMainThreadBridge> create(WebWorkerBase* webWorkerBase, const String& mode, const String& name) { - return adoptRef(new AllowIndexedDBMainThreadBridge(webWorkerClientImpl, mode, name)); + return adoptRef(new AllowIndexedDBMainThreadBridge(webWorkerBase, mode, name)); } // These methods are invoked on the worker context. void cancel() { MutexLocker locker(m_mutex); - m_webWorkerClientImpl = 0; + m_webWorkerBase = 0; } bool result() @@ -111,31 +111,28 @@ public: void signalCompleted(bool result, const String& mode) { MutexLocker locker(m_mutex); - if (m_webWorkerClientImpl) - m_webWorkerClientImpl->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode); + if (m_webWorkerBase) + m_webWorkerBase->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode); } private: - AllowIndexedDBMainThreadBridge(WebWorkerClientImpl* webWorkerClientImpl, const String& mode, const String& name) + AllowIndexedDBMainThreadBridge(WebWorkerBase* webWorkerBase, const String& mode, const String& name) : m_result(false) - , m_webWorkerClientImpl(webWorkerClientImpl) + , m_webWorkerBase(webWorkerBase) { - WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(webWorkerClientImpl->view()->mainFrame()); - // webFrame is not deleted as long as the process is alive, relying on - // it to exist on the main thread should be ok. + WebCommonWorkerClient* commonClient = webWorkerBase->commonClient(); + // See note about thread-safety below. WebWorkerBase::dispatchTaskToMainThread( - createCallbackTask(&allowIndexedDBTask, this, WebCore::AllowCrossThreadAccess(webFrame), name, mode)); + createCallbackTask(&allowIndexedDBTask, this, WebCore::AllowCrossThreadAccess(commonClient), name, mode)); } - static void allowIndexedDBTask(ScriptExecutionContext*, PassRefPtr<AllowIndexedDBMainThreadBridge> bridge, PassRefPtr<WebFrameImpl> prpWebFrame, const String& name, const String& mode) + static void allowIndexedDBTask(ScriptExecutionContext*, PassRefPtr<AllowIndexedDBMainThreadBridge> bridge, WebCommonWorkerClient* commonClient, const String& name, const String& mode) { - RefPtr<WebFrameImpl> webFrame = prpWebFrame; - WebViewImpl* webView = webFrame->viewImpl(); - if (!webView) { + if (!commonClient) { bridge->signalCompleted(false, mode); return; } - bool allowed = !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(webFrame.get(), name, WebSecurityOrigin()); + bool allowed = commonClient->allowIndexedDB(name); bridge->signalCompleted(allowed, mode); } @@ -146,29 +143,33 @@ private: bool m_result; Mutex m_mutex; - // WebWorkerClientImpl is never deleted as long as the renderer process - // is alive. We use it on the main thread to notify the worker thread that - // the permission result has been set. The underlying message proxy object - // is valid as long as the worker run loop hasn't returned - // MessageQueueTerminated, in which case we don't use the - // WebWorkerClientImpl. - WebWorkerClientImpl* m_webWorkerClientImpl; + // AllowIndexedDBMainThreadBridge uses two non-threadsafe classes across + // threads: WebWorkerBase and WebCommonWorkerClient. + // In the dedicated worker case, these are both the same object of type + // WebWorkerClientImpl, which isn't deleted for the life of the renderer + // process so we don't have to worry about use-after-frees. + // In the shared worker case, these are of type WebSharedWorkerImpl and + // chromium's WebSharedWorkerClientProxy, respectively. These are both + // deleted on the main thread in response to a request on the worker thread, + // but only after the worker run loop stops processing tasks. So even in + // the most interleaved case, we have: + // W AllowIndexedDBMainThreadBridge schedules allowIndexedDBTask + // M workerRunLoop marked as killed + // W runLoop stops and schedules object deletion on main thread + // M allowIndexedDBTask calls commonClient->allowIndexedDB() + // M WebWorkerBase and WebCommonWorkerClient are deleted + WebWorkerBase* m_webWorkerBase; }; bool IDBFactoryBackendProxy::allowIDBFromWorkerThread(WorkerContext* workerContext, const String& name, const WebSecurityOrigin&) { - // FIXME: Bypass checking for permission so as not to block shared worker - // testing until a permissions check is implemented. This has to be fixed - // before m19 goes to beta. http://crbug.com/112855 - if (workerContext->isSharedWorkerContext()) - return true; - WebWorkerClientImpl* webWorkerClientImpl = static_cast<WebWorkerClientImpl*>(&workerContext->thread()->workerLoaderProxy()); + WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(&workerContext->thread()->workerLoaderProxy()); WorkerRunLoop& runLoop = workerContext->thread()->runLoop(); String mode = allowIndexedDBMode; mode.append(String::number(runLoop.createUniqueId())); - RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThreadBridge::create(webWorkerClientImpl, mode, name); + RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThreadBridge::create(webWorkerBase, mode, name); // Either the bridge returns, or the queue gets terminated. if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated) { diff --git a/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp b/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp index 4b68235a1..99a7ea378 100644 --- a/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp +++ b/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp @@ -98,10 +98,10 @@ void NotificationPresenterImpl::notificationControllerDestroyed() { } -NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context) +NotificationClient::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context) { int result = m_presenter->checkPermission(WebSecurityOrigin(context->securityOrigin())); - return static_cast<NotificationPresenter::Permission>(result); + return static_cast<NotificationClient::Permission>(result); } void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback) diff --git a/Source/WebKit/chromium/src/NotificationPresenterImpl.h b/Source/WebKit/chromium/src/NotificationPresenterImpl.h index 3eb5a87da..cad5b8801 100644 --- a/Source/WebKit/chromium/src/NotificationPresenterImpl.h +++ b/Source/WebKit/chromium/src/NotificationPresenterImpl.h @@ -31,7 +31,7 @@ #ifndef NotificationPresenterImpl_h #define NotificationPresenterImpl_h -#include "NotificationPresenter.h" +#include "NotificationClient.h" #include "VoidCallback.h" #include <wtf/HashMap.h> @@ -43,7 +43,7 @@ namespace WebKit { class WebNotificationPresenter; -class NotificationPresenterImpl : public WebCore::NotificationPresenter { +class NotificationPresenterImpl : public WebCore::NotificationClient { public: NotificationPresenterImpl() : m_presenter(0) { } @@ -55,7 +55,7 @@ public: virtual void cancel(WebCore::Notification* object); virtual void notificationObjectDestroyed(WebCore::Notification* object); virtual void notificationControllerDestroyed(); - virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::ScriptExecutionContext*); + virtual WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*); virtual void requestPermission(WebCore::ScriptExecutionContext* , WTF::PassRefPtr<WebCore::VoidCallback> callback); virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) {} diff --git a/Source/WebKit/chromium/src/WebCache.cpp b/Source/WebKit/chromium/src/WebCache.cpp index fa260cc4c..d7bbc813b 100644 --- a/Source/WebKit/chromium/src/WebCache.cpp +++ b/Source/WebKit/chromium/src/WebCache.cpp @@ -31,14 +31,9 @@ #include "config.h" #include "WebCache.h" -// Instead of providing accessors, we make all members of MemoryCache public. -// This will make it easier to track WebCore changes to the MemoryCache class. -// FIXME: We should introduce public getters on the MemoryCache class. -#define private public #include "MemoryCache.h" -#undef private -using namespace WebCore; +using WebCore::MemoryCache; namespace WebKit { @@ -83,11 +78,11 @@ void WebCache::getUsageStats(UsageStats* result) MemoryCache* cache = WebCore::memoryCache(); if (cache) { - result->minDeadCapacity = cache->m_minDeadCapacity; - result->maxDeadCapacity = cache->m_maxDeadCapacity; - result->capacity = cache->m_capacity; - result->liveSize = cache->m_liveSize; - result->deadSize = cache->m_deadSize; + result->minDeadCapacity = cache->minDeadCapacity(); + result->maxDeadCapacity = cache->maxDeadCapacity(); + result->capacity = cache->capacity(); + result->liveSize = cache->liveSize(); + result->deadSize = cache->deadSize(); } else memset(result, 0, sizeof(UsageStats)); } diff --git a/Source/WebKit/chromium/src/WebColor.cpp b/Source/WebKit/chromium/src/WebColorName.cpp index 737338a8b..04d8ed8a8 100644 --- a/Source/WebKit/chromium/src/WebColor.cpp +++ b/Source/WebKit/chromium/src/WebColorName.cpp @@ -29,21 +29,21 @@ */ #include "config.h" -#include "platform/WebColor.h" +#include "WebColorName.h" -#include "Color.h" #include "CSSValueKeywords.h" +#include "Color.h" #include "RenderTheme.h" #include "UnusedParam.h" -#include "platform/WebColorName.h" +#include <public/WebColor.h> using namespace::WebCore; namespace WebKit { -static int toCSSValueKeyword(WebColorName in_value) +static int toCSSValueKeyword(WebColorName name) { - switch (in_value) { + switch (name) { case WebColorActiveBorder: return CSSValueActiveborder; case WebColorActiveCaption: diff --git a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp index 397308b52..c2dbee3b4 100644 --- a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp +++ b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp @@ -206,7 +206,7 @@ int WebCompositorInputHandlerImpl::identifier() const return m_identifier; } -void WebCompositorInputHandlerImpl::willDraw(double frameBeginTimeMs) +void WebCompositorInputHandlerImpl::willDraw(double monotonicTime) { } diff --git a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h index a2f13025d..83b4bd546 100644 --- a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h +++ b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h @@ -61,7 +61,7 @@ public: // WebCore::CCInputHandler implementation virtual int identifier() const; - virtual void willDraw(double frameBeginTimeMs); + virtual void willDraw(double monotonicTime); private: explicit WebCompositorInputHandlerImpl(WebCore::CCInputHandlerClient*); diff --git a/Source/WebKit/chromium/src/WebDataSourceImpl.cpp b/Source/WebKit/chromium/src/WebDataSourceImpl.cpp index d6d98c752..501fd447c 100644 --- a/Source/WebKit/chromium/src/WebDataSourceImpl.cpp +++ b/Source/WebKit/chromium/src/WebDataSourceImpl.cpp @@ -129,6 +129,11 @@ void WebDataSourceImpl::setDeferMainResourceDataLoad(bool defer) DocumentLoader::setDeferMainResourceDataLoad(defer); } +void WebDataSourceImpl::setNavigationStartTime(double navigationStart) +{ + timing()->setNavigationStart(navigationStart); +} + WebNavigationType WebDataSourceImpl::toWebNavigationType(NavigationType type) { switch (type) { diff --git a/Source/WebKit/chromium/src/WebDataSourceImpl.h b/Source/WebKit/chromium/src/WebDataSourceImpl.h index 8cc2c80c6..3e8c8bb55 100644 --- a/Source/WebKit/chromium/src/WebDataSourceImpl.h +++ b/Source/WebKit/chromium/src/WebDataSourceImpl.h @@ -70,6 +70,7 @@ public: virtual void setExtraData(ExtraData*); virtual WebApplicationCacheHost* applicationCacheHost(); virtual void setDeferMainResourceDataLoad(bool); + virtual void setNavigationStartTime(double); static WebNavigationType toWebNavigationType(WebCore::NavigationType type); diff --git a/Source/WebKit/chromium/src/WebDragData.cpp b/Source/WebKit/chromium/src/WebDragData.cpp index 9e634340e..322dfbaeb 100644 --- a/Source/WebKit/chromium/src/WebDragData.cpp +++ b/Source/WebKit/chromium/src/WebDragData.cpp @@ -69,8 +69,8 @@ void WebDragData::assign(const WebDragData& other) WebVector<WebDragData::Item> WebDragData::items() const { Vector<Item> itemList; - RefPtr<DOMStringList> types = m_private->types(); - if (types->contains(mimeTypeTextPlain)) { + const HashSet<String>& types = m_private->types(); + if (types.contains(mimeTypeTextPlain)) { Item item; item.storageType = Item::StorageTypeString; item.stringType = String(mimeTypeTextPlain); @@ -78,7 +78,7 @@ WebVector<WebDragData::Item> WebDragData::items() const item.stringData = m_private->getData(mimeTypeTextPlain, ignored); itemList.append(item); } - if (types->contains(mimeTypeTextURIList)) { + if (types.contains(mimeTypeTextURIList)) { Item item; item.storageType = Item::StorageTypeString; item.stringType = String(mimeTypeTextURIList); @@ -87,7 +87,7 @@ WebVector<WebDragData::Item> WebDragData::items() const item.title = m_private->urlTitle(); itemList.append(item); } - if (types->contains(mimeTypeTextHTML)) { + if (types.contains(mimeTypeTextHTML)) { Item item; item.storageType = Item::StorageTypeString; item.stringType = String(mimeTypeTextHTML); @@ -96,7 +96,7 @@ WebVector<WebDragData::Item> WebDragData::items() const item.baseURL = m_private->htmlBaseUrl(); itemList.append(item); } - if (types->contains(mimeTypeDownloadURL)) { + if (types.contains(mimeTypeDownloadURL)) { Item item; item.storageType = Item::StorageTypeString; item.stringType = String(mimeTypeDownloadURL); diff --git a/Source/WebKit/chromium/src/WebElement.cpp b/Source/WebKit/chromium/src/WebElement.cpp index 43e51d4bf..e6a1b6e4e 100644 --- a/Source/WebKit/chromium/src/WebElement.cpp +++ b/Source/WebKit/chromium/src/WebElement.cpp @@ -34,6 +34,7 @@ #include "WebDocument.h" #include "Element.h" +#include "NamedNodeMap.h" #include "RenderBoxModelObject.h" #include "RenderObject.h" #include <wtf/PassRefPtr.h> diff --git a/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp b/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp index b3a332b2a..c9ba0bc7b 100644 --- a/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp +++ b/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp @@ -68,7 +68,7 @@ WebFloatRect WebExternalTextureLayer::uvRect() const void WebExternalTextureLayer::invalidateRect(const WebFloatRect& updateRect) { - unwrap<WebExternalTextureLayerImpl>()->invalidateRect(updateRect); + unwrap<WebExternalTextureLayerImpl>()->setNeedsDisplayRect(updateRect); } WebExternalTextureLayer::WebExternalTextureLayer(const PassRefPtr<WebExternalTextureLayerImpl>& node) diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index adf202371..39897c823 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -1347,7 +1347,7 @@ WebString WebFrameImpl::selectionAsMarkup() const if (!range) return WebString(); - return createMarkup(range.get(), 0); + return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNonLocalURLs); } void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition pos) diff --git a/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp b/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp index b4c7f3d17..6d7ec631a 100644 --- a/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp +++ b/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp @@ -39,7 +39,7 @@ namespace WebKit { WebSecurityOrigin WebGeolocationPermissionRequest::securityOrigin() const { - return WebSecurityOrigin(m_private->frame()->document()->securityOrigin()); + return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin()); } void WebGeolocationPermissionRequest::setIsAllowed(bool allowed) diff --git a/Source/WebKit/chromium/src/WebInputElement.cpp b/Source/WebKit/chromium/src/WebInputElement.cpp index 736165bbf..f5d52da80 100644 --- a/Source/WebKit/chromium/src/WebInputElement.cpp +++ b/Source/WebKit/chromium/src/WebInputElement.cpp @@ -33,8 +33,6 @@ #include "HTMLInputElement.h" #include "HTMLNames.h" -#include "RenderObject.h" -#include "RenderTextControlSingleLine.h" #include "TextControlInnerElements.h" #include "platform/WebString.h" #include <wtf/PassRefPtr.h> @@ -165,12 +163,7 @@ bool WebInputElement::isSpeechInputEnabled() const WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const { #if ENABLE(INPUT_SPEECH) - RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer(); - if (!renderer) - return Idle; - - RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer); - InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement()); + InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement()); if (speechButton) return static_cast<WebInputElement::SpeechInputState>(speechButton->state()); #endif @@ -181,12 +174,7 @@ WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const void WebInputElement::startSpeechInput() { #if ENABLE(INPUT_SPEECH) - RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer(); - if (!renderer) - return; - - RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer); - InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement()); + InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement()); if (speechButton) speechButton->startSpeechInput(); #endif @@ -195,12 +183,7 @@ void WebInputElement::startSpeechInput() void WebInputElement::stopSpeechInput() { #if ENABLE(INPUT_SPEECH) - RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer(); - if (!renderer) - return; - - RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer); - InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement()); + InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement()); if (speechButton) speechButton->stopSpeechInput(); #endif diff --git a/Source/WebKit/chromium/src/WebLayerTreeView.cpp b/Source/WebKit/chromium/src/WebLayerTreeView.cpp index d2c0f0c12..3314dc2f5 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeView.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeView.cpp @@ -26,9 +26,11 @@ #include "config.h" #include "platform/WebLayerTreeView.h" +#include "GraphicsContext3DPrivate.h" #include "WebLayerTreeViewImpl.h" #include "cc/CCLayerTreeHost.h" #include "platform/WebLayer.h" +#include "platform/WebPoint.h" #include "platform/WebRect.h" #include "platform/WebSize.h" @@ -51,11 +53,6 @@ WebLayerTreeView::Settings::operator CCSettings() const return settings; } -WebLayerTreeView WebLayerTreeView::create(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings) -{ - return WebLayerTreeView(WebLayerTreeViewImpl::create(client, root, settings)); -} - void WebLayerTreeView::reset() { m_private.reset(); @@ -71,12 +68,23 @@ bool WebLayerTreeView::equals(const WebLayerTreeView& n) const return (m_private.get() == n.m_private.get()); } -void WebLayerTreeView::composite() +bool WebLayerTreeView::initialize(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings) { - if (CCProxy::hasImplThread()) - m_private->setNeedsCommit(); + m_private = WebLayerTreeViewImpl::create(client, root, settings); + return !isNull(); +} + +void WebLayerTreeView::setRootLayer(WebLayer *root) +{ + if (root) + m_private->setRootLayer(*root); else - m_private->composite(); + m_private->setRootLayer(PassRefPtr<LayerChromium>()); +} + +int WebLayerTreeView::compositorIdentifier() +{ + return m_private->compositorIdentifier(); } void WebLayerTreeView::setViewportSize(const WebSize& viewportSize) @@ -89,38 +97,62 @@ WebSize WebLayerTreeView::viewportSize() const return WebSize(m_private->viewportSize()); } -bool WebLayerTreeView::compositeAndReadback(void *pixels, const WebRect& rect) +void WebLayerTreeView::setVisible(bool visible) { - return m_private->compositeAndReadback(pixels, rect); + m_private->setVisible(visible); } -void WebLayerTreeView::setRootLayer(WebLayer *root) +void WebLayerTreeView::setPageScaleFactorAndLimits(float pageScaleFactor, float minimum, float maximum) { - if (root) - m_private->setRootLayer(*root); + m_private->setPageScaleFactorAndLimits(pageScaleFactor, minimum, maximum); +} + +void WebLayerTreeView::startPageScaleAnimation(const WebPoint& scroll, bool useAnchor, float newPageScale, double durationSec) +{ + m_private->startPageScaleAnimation(IntSize(scroll.x, scroll.y), useAnchor, newPageScale, durationSec); +} + +void WebLayerTreeView::setNeedsAnimate() +{ + m_private->setNeedsAnimate(); +} + +void WebLayerTreeView::setNeedsRedraw() +{ + m_private->setNeedsRedraw(); +} + +void WebLayerTreeView::composite() +{ + if (CCProxy::hasImplThread()) + m_private->setNeedsCommit(); else - m_private->setRootLayer(PassRefPtr<LayerChromium>()); + m_private->composite(); +} + +void WebLayerTreeView::updateAnimations(double frameBeginTime) +{ + m_private->updateAnimations(frameBeginTime); } -WebLayerTreeView::WebLayerTreeView(const PassRefPtr<CCLayerTreeHost>& node) - : m_private(node) +bool WebLayerTreeView::compositeAndReadback(void *pixels, const WebRect& rect) { + return m_private->compositeAndReadback(pixels, rect); } -WebLayerTreeView& WebLayerTreeView::operator=(const PassRefPtr<CCLayerTreeHost>& node) +void WebLayerTreeView::finishAllRendering() { - m_private = node; - return *this; + m_private->finishAllRendering(); } -WebLayerTreeView::operator PassRefPtr<CCLayerTreeHost>() const +WebGraphicsContext3D* WebLayerTreeView::context() { - return m_private.get(); + return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_private->context()); } -void WebLayerTreeView::setNeedsRedraw() +void WebLayerTreeView::loseCompositorContext(int numTimes) { - m_private->setNeedsRedraw(); + m_private->loseContext(numTimes); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp index 29d033215..335879b66 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp @@ -78,7 +78,7 @@ void WebLayerTreeViewImpl::applyScrollAndScale(const WebCore::IntSize& scrollDel m_client->applyScrollAndScale(WebSize(scrollDelta), pageScale); } -PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::createLayerTreeHostContext3D() +PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::createContext() { if (!m_client) return 0; @@ -89,20 +89,22 @@ PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::createLayerTreeHostContext3D return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow, false /* preserveDrawingBuffer */ ); } -void WebLayerTreeViewImpl::didCommitAndDrawFrame() +void WebLayerTreeViewImpl::didRecreateContext(bool success) { - // FIXME: route this up to the WebLayerTreeView client + if (m_client) + m_client->didRebindGraphicsContext(success); } -void WebLayerTreeViewImpl::didCompleteSwapBuffers() +void WebLayerTreeViewImpl::didCommitAndDrawFrame() { - // FIXME: route this up to the WebLayerTreeView client + if (m_client) + m_client->didCommitAndDrawFrame(); } -void WebLayerTreeViewImpl::didRecreateGraphicsContext(bool success) +void WebLayerTreeViewImpl::didCompleteSwapBuffers() { if (m_client) - m_client->didRebindGraphicsContext(success); + m_client->didCompleteSwapBuffers(); } void WebLayerTreeViewImpl::scheduleComposite() diff --git a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h index 580e9af84..b1b26d0fc 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h +++ b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h @@ -44,8 +44,8 @@ private: virtual void updateAnimations(double frameBeginTime); virtual void layout(); virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale); - virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D(); - virtual void didRecreateGraphicsContext(bool success); + virtual PassRefPtr<WebCore::GraphicsContext3D> createContext(); + virtual void didRecreateContext(bool success); virtual void didCommitAndDrawFrame(); virtual void didCompleteSwapBuffers(); diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index ec74b6bea..74c4a7200 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -152,7 +152,7 @@ void WebMediaPlayerClientImpl::repaint() ASSERT(m_mediaPlayer); #if USE(ACCELERATED_COMPOSITING) if (m_videoLayer && supportsAcceleratedRendering()) - m_videoLayer->contentChanged(); + m_videoLayer->setNeedsDisplay(); #endif m_mediaPlayer->repaint(); } diff --git a/Source/WebKit/chromium/src/WebNamedNodeMap.cpp b/Source/WebKit/chromium/src/WebNamedNodeMap.cpp index e2455e6b9..ba5f29625 100644 --- a/Source/WebKit/chromium/src/WebNamedNodeMap.cpp +++ b/Source/WebKit/chromium/src/WebNamedNodeMap.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebNamedNodeMap.h" +#include "Element.h" #include "NamedNodeMap.h" #include "Node.h" #include "WebAttribute.h" @@ -63,7 +64,7 @@ unsigned WebNamedNodeMap::length() const WebAttribute WebNamedNodeMap::attributeItem(unsigned index) const { - return WebAttribute(m_private->attributeItem(index)); + return WebAttribute(m_private->element()->attributeItem(index)); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebOptionElement.cpp b/Source/WebKit/chromium/src/WebOptionElement.cpp index d48492594..c71f7b565 100644 --- a/Source/WebKit/chromium/src/WebOptionElement.cpp +++ b/Source/WebKit/chromium/src/WebOptionElement.cpp @@ -83,7 +83,7 @@ bool WebOptionElement::isEnabled() const } WebOptionElement::WebOptionElement(const PassRefPtr<HTMLOptionElement>& elem) - : WebFormControlElement(elem) + : WebElement(elem) { } diff --git a/Source/WebKit/chromium/src/WebPagePopupImpl.cpp b/Source/WebKit/chromium/src/WebPagePopupImpl.cpp new file mode 100644 index 000000000..bc810c7b1 --- /dev/null +++ b/Source/WebKit/chromium/src/WebPagePopupImpl.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "WebPagePopup.h" + +namespace WebKit { + +// WebPagePopupImpl ---------------------------------------------------------------- + +// FIXME: WebPagePopupImpl implementation will be written here. + +// WebPagePopup ---------------------------------------------------------------- + +WebPagePopup* WebPagePopup::create(WebWidgetClient*) +{ + // FIXME: Returns a WebPagePopupImpl object. + return 0; +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebPageSerializer.cpp b/Source/WebKit/chromium/src/WebPageSerializer.cpp index dc2bc99e3..1ad70b1b4 100644 --- a/Source/WebKit/chromium/src/WebPageSerializer.cpp +++ b/Source/WebKit/chromium/src/WebPageSerializer.cpp @@ -127,7 +127,7 @@ void retrieveResourcesForElement(Element* element, // Ignore URLs that have a non-standard protocols. Since the FTP protocol // does no have a cache mechanism, we skip it as well. - if (!url.protocolInHTTPFamily() && !url.isLocalFile()) + if (!url.protocolIsInHTTPFamily() && !url.isLocalFile()) return; if (!resourceURLs->contains(url)) diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp index 10c3e2e4b..a71703b15 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp @@ -370,8 +370,8 @@ void WebPluginContainerImpl::setBackingIOSurfaceId(int width, void WebPluginContainerImpl::commitBackingTexture() { #if USE(ACCELERATED_COMPOSITING) - if (m_platformLayer.get()) - m_platformLayer->invalidateRect(FloatRect(FloatPoint(), m_platformLayer->bounds())); + if (m_platformLayer) + m_platformLayer->setNeedsDisplay(); #endif } @@ -435,6 +435,14 @@ void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel) view->fullFramePluginZoomLevelChanged(zoomLevel); } +void WebPluginContainerImpl::setOpaque(bool opaque) +{ +#if USE(ACCELERATED_COMPOSITING) + if (m_platformLayer) + m_platformLayer->setOpaque(opaque); +#endif +} + bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect) { Page* page = m_element->document()->page(); diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.h b/Source/WebKit/chromium/src/WebPluginContainerImpl.h index 898130084..9d970f2f8 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.h +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.h @@ -104,6 +104,7 @@ public: virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed); virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData); virtual void zoomLevelChanged(double zoomLevel); + virtual void setOpaque(bool); virtual bool isRectTopmost(const WebRect&); // This cannot be null. diff --git a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp index f1960eb31..d297a828c 100644 --- a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -34,7 +34,7 @@ #include "AbstractDatabase.h" #include "RuntimeEnabledFeatures.h" #include "WebMediaPlayerClientImpl.h" -#include "websockets/WebSocket.h" +#include "Modules/websockets/WebSocket.h" #include <wtf/UnusedParam.h> @@ -260,6 +260,22 @@ bool WebRuntimeFeatures::isSpeechInputEnabled() return RuntimeEnabledFeatures::speechInputEnabled(); } +void WebRuntimeFeatures::enableScriptedSpeech(bool enable) +{ +#if ENABLE(SCRIPTED_SPEECH) + RuntimeEnabledFeatures::setScriptedSpeechEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isScriptedSpeechEnabled() +{ +#if ENABLE(SCRIPTED_SPEECH) + return RuntimeEnabledFeatures::scriptedSpeechEnabled(); +#else + return false; +#endif +} + void WebRuntimeFeatures::enableXHRResponseBlob(bool enable) { #if ENABLE(XHR_RESPONSE_BLOB) diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/Source/WebKit/chromium/src/WebSettingsImpl.cpp index 485a5b051..3b3a84f98 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp @@ -109,6 +109,11 @@ void WebSettingsImpl::setMinimumLogicalFontSize(int size) m_settings->setMinimumLogicalFontSize(size); } +void WebSettingsImpl::setDefaultDeviceScaleFactor(int defaultDeviceScaleFactor) +{ + m_settings->setDefaultDeviceScaleFactor(defaultDeviceScaleFactor); +} + void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding) { m_settings->setDefaultTextEncodingName((String)encoding); diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.h b/Source/WebKit/chromium/src/WebSettingsImpl.h index 51d9323a4..7024b5164 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.h +++ b/Source/WebKit/chromium/src/WebSettingsImpl.h @@ -54,6 +54,7 @@ public: virtual void setDefaultFixedFontSize(int); virtual void setMinimumFontSize(int); virtual void setMinimumLogicalFontSize(int); + virtual void setDefaultDeviceScaleFactor(int); virtual void setDefaultTextEncodingName(const WebString&); virtual void setJavaScriptEnabled(bool); virtual void setWebSecurityEnabled(bool); diff --git a/Source/WebKit/chromium/src/WebSocketImpl.cpp b/Source/WebKit/chromium/src/WebSocketImpl.cpp index f0bf28206..30a6033d3 100644 --- a/Source/WebKit/chromium/src/WebSocketImpl.cpp +++ b/Source/WebKit/chromium/src/WebSocketImpl.cpp @@ -105,10 +105,19 @@ WebString WebSocketImpl::subprotocol() #endif } +WebString WebSocketImpl::extensions() +{ +#if ENABLE(WEB_SOCKETS) + return m_private->extensions(); +#else + ASSERT_NOT_REACHED(); +#endif +} + bool WebSocketImpl::sendText(const WebString& message) { #if ENABLE(WEB_SOCKETS) - return m_private->send(message); + return m_private->send(message) == ThreadableWebSocketChannel::SendSuccess; #else ASSERT_NOT_REACHED(); #endif @@ -117,7 +126,7 @@ bool WebSocketImpl::sendText(const WebString& message) bool WebSocketImpl::sendArrayBuffer(const WebArrayBuffer& webArrayBuffer) { #if ENABLE(WEB_SOCKETS) - return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer)); + return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer)) == ThreadableWebSocketChannel::SendSuccess; #else ASSERT_NOT_REACHED(); #endif diff --git a/Source/WebKit/chromium/src/WebSocketImpl.h b/Source/WebKit/chromium/src/WebSocketImpl.h index 3d42bd506..ef14b18c7 100644 --- a/Source/WebKit/chromium/src/WebSocketImpl.h +++ b/Source/WebKit/chromium/src/WebSocketImpl.h @@ -53,25 +53,26 @@ public: bool isNull() const { return !m_private; } - BinaryType binaryType() const; - virtual bool setBinaryType(BinaryType); - virtual void connect(const WebURL&, const WebString& protocol); - virtual WebString subprotocol(); - virtual bool sendText(const WebString&); - virtual bool sendArrayBuffer(const WebArrayBuffer&); - virtual unsigned long bufferedAmount() const; - virtual void close(int code, const WebString& reason); - virtual void fail(const WebString& reason); - virtual void disconnect(); + virtual BinaryType binaryType() const OVERRIDE; + virtual bool setBinaryType(BinaryType) OVERRIDE; + virtual void connect(const WebURL&, const WebString& protocol) OVERRIDE; + virtual WebString subprotocol() OVERRIDE; + virtual WebString extensions() OVERRIDE; + virtual bool sendText(const WebString&) OVERRIDE; + virtual bool sendArrayBuffer(const WebArrayBuffer&) OVERRIDE; + virtual unsigned long bufferedAmount() const OVERRIDE; + virtual void close(int code, const WebString& reason) OVERRIDE; + virtual void fail(const WebString& reason) OVERRIDE; + virtual void disconnect() OVERRIDE; // WebSocketChannelClient - virtual void didConnect(); - virtual void didReceiveMessage(const String& message); - virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData); - virtual void didReceiveMessageError(); - virtual void didUpdateBufferedAmount(unsigned long bufferedAmount); - virtual void didStartClosingHandshake(); - virtual void didClose(unsigned long bufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason); + virtual void didConnect() OVERRIDE; + virtual void didReceiveMessage(const String& message) OVERRIDE; + virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) OVERRIDE; + virtual void didReceiveMessageError() OVERRIDE; + virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; + virtual void didStartClosingHandshake() OVERRIDE; + virtual void didClose(unsigned long bufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE; private: RefPtr<WebCore::WebSocketChannel> m_private; diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index 55a2052a4..52a022ce9 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -34,6 +34,7 @@ #include "AutofillPopupMenuClient.h" #include "AXObjectCache.h" #include "BackForwardListChromium.h" +#include "cc/CCProxy.h" #include "CSSStyleSelector.h" #include "CSSValueKeywords.h" #include "Chrome.h" @@ -73,6 +74,7 @@ #include "Image.h" #include "ImageBuffer.h" #include "InspectorController.h" +#include "InspectorInstrumentation.h" #include "KeyboardCodes.h" #include "KeyboardEvent.h" #include "LayerChromium.h" @@ -102,6 +104,7 @@ #include "SecurityOrigin.h" #include "SecurityPolicy.h" #include "Settings.h" +#include "SharedGraphicsContext3D.h" #include "SpeechInputClientImpl.h" #include "TextIterator.h" #include "Timer.h" @@ -123,6 +126,8 @@ #include "WebInputEventConversion.h" #include "WebKit.h" #include "platform/WebKitPlatformSupport.h" +#include "platform/WebLayer.h" +#include "platform/WebLayerTreeView.h" #include "WebMediaPlayerAction.h" #include "WebNode.h" #include "WebPlugin.h" @@ -137,7 +142,6 @@ #include "platform/WebString.h" #include "platform/WebVector.h" #include "WebViewClient.h" -#include "cc/CCProxy.h" #include <wtf/ByteArray.h> #include <wtf/CurrentTime.h> #include <wtf/MainThread.h> @@ -168,27 +172,6 @@ using namespace WebCore; using namespace std; -namespace { - -WebKit::WebGraphicsContext3D::Attributes getCompositorContextAttributes(bool threaded) -{ - // Explicitly disable antialiasing for the compositor. As of the time of - // this writing, the only platform that supported antialiasing for the - // compositor was Mac OS X, because the on-screen OpenGL context creation - // code paths on Windows and Linux didn't yet have multisampling support. - // Mac OS X essentially always behaves as though it's rendering offscreen. - // Multisampling has a heavy cost especially on devices with relatively low - // fill rate like most notebooks, and the Mac implementation would need to - // be optimized to resolve directly into the IOSurface shared between the - // GPU and browser processes. For these reasons and to avoid platform - // disparities we explicitly disable antialiasing. - WebKit::WebGraphicsContext3D::Attributes attributes; - attributes.antialias = false; - attributes.shareResources = true; - attributes.forUseOnAnotherThread = threaded; - return attributes; -} - // The following constants control parameters for automated scaling of webpages // (such as due to a double tap gesture or find in page etc.). These are // experimentally determined. @@ -197,8 +180,6 @@ static const float minScaleDifference = 0.01; static const float doubleTapZoomContentDefaultMargin = 5; static const float doubleTapZoomContentMinimumMargin = 2; -} // anonymous namespace - namespace WebKit { // Change the text zoom level by kTextSizeMultiplierRatio each time the user @@ -525,7 +506,7 @@ void WebViewImpl::mouseDown(const WebMouseEvent& event) || (event.button == WebMouseEvent::ButtonLeft && event.modifiers & WebMouseEvent::ControlKey)) mouseContextMenu(event); -#elif OS(UNIX) +#elif OS(UNIX) || OS(ANDROID) if (event.button == WebMouseEvent::ButtonRight) mouseContextMenu(event); #endif @@ -627,8 +608,8 @@ bool WebViewImpl::gestureEvent(const WebGestureEvent& event) void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec) { - if (m_layerTreeHost) - m_layerTreeHost->startPageScaleAnimation(IntSize(scroll.x(), scroll.y()), useAnchor, newScale, durationSec); + if (!m_layerTreeView.isNull()) + m_layerTreeView.startPageScaleAnimation(scroll, useAnchor, newScale, durationSec); } #endif @@ -1264,6 +1245,11 @@ void WebViewImpl::didExitFullScreen() #endif } +void WebViewImpl::instrumentBeginFrame() +{ + InspectorInstrumentation::didBeginFrame(m_page.get()); +} + void WebViewImpl::animate(double frameBeginTime) { #if ENABLE(REQUEST_ANIMATION_FRAME) @@ -1276,7 +1262,7 @@ void WebViewImpl::animate(double frameBeginTime) // In composited mode, we always go through the compositor so it can apply // appropriate flow-control mechanisms. if (isAcceleratedCompositingActive()) - m_layerTreeHost->updateAnimations(frameBeginTime); + m_layerTreeView.updateAnimations(frameBeginTime); else #endif updateAnimations(frameBeginTime); @@ -1324,6 +1310,7 @@ void WebViewImpl::layout() #if USE(ACCELERATED_COMPOSITING) void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect) { + ASSERT(!m_layerTreeView.isNull()); #if USE(SKIA) PlatformContextSkia context(canvas); @@ -1342,7 +1329,7 @@ void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(rect.size())); RefPtr<ByteArray> pixelArray(ByteArray::create(rect.width() * rect.height() * 4)); if (imageBuffer && pixelArray) { - m_layerTreeHost->compositeAndReadback(pixelArray->data(), invertRect); + m_layerTreeView.compositeAndReadback(pixelArray->data(), invertRect); imageBuffer->putByteArray(Premultiplied, pixelArray.get(), rect.size(), IntRect(IntPoint(), rect.size()), IntPoint()); gc.save(); gc.translate(IntSize(0, bitmapHeight)); @@ -1364,7 +1351,7 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) if (canvas) { // Clip rect to the confines of the rootLayerTexture. IntRect resizeRect(rect); - resizeRect.intersect(IntRect(IntPoint(0, 0), m_layerTreeHost->viewportSize())); + resizeRect.intersect(IntRect(IntPoint(0, 0), m_layerTreeView.viewportSize())); doPixelReadbackToCanvas(canvas, resizeRect); } #endif @@ -1394,7 +1381,7 @@ void WebViewImpl::composite(bool) { #if USE(ACCELERATED_COMPOSITING) if (CCProxy::hasImplThread()) - m_layerTreeHost->setNeedsRedraw(); + m_layerTreeView.setNeedsRedraw(); else { ASSERT(isAcceleratedCompositingActive()); if (!page()) @@ -1403,7 +1390,7 @@ void WebViewImpl::composite(bool) if (m_pageOverlays) m_pageOverlays->update(); - m_layerTreeHost->composite(); + m_layerTreeView.composite(); } #endif } @@ -1411,16 +1398,16 @@ void WebViewImpl::composite(bool) void WebViewImpl::setNeedsRedraw() { #if USE(ACCELERATED_COMPOSITING) - if (m_layerTreeHost && isAcceleratedCompositingActive()) - m_layerTreeHost->setNeedsRedraw(); + if (!m_layerTreeView.isNull() && isAcceleratedCompositingActive()) + m_layerTreeView.setNeedsRedraw(); #endif } void WebViewImpl::loseCompositorContext(int numTimes) { #if USE(ACCELERATED_COMPOSITING) - if (m_layerTreeHost) - m_layerTreeHost->loseCompositorContext(numTimes); + if (!m_layerTreeView.isNull()) + m_layerTreeView.loseCompositorContext(numTimes); #endif } @@ -2261,15 +2248,27 @@ void WebViewImpl::enableFixedLayoutMode(bool enable) #endif } -void WebViewImpl::enableAutoResizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize) + +void WebViewImpl::enableAutoResizeMode(const WebSize& minSize, const WebSize& maxSize) { - m_shouldAutoResize = enable; + m_shouldAutoResize = true; m_minAutoSize = minSize; m_maxAutoSize = maxSize; - if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view()) - return; + configureAutoResizeMode(); +} - mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoResize, m_minAutoSize, m_maxAutoSize); +void WebViewImpl::disableAutoResizeMode() +{ + m_shouldAutoResize = false; + configureAutoResizeMode(); +} + +void WebViewImpl::enableAutoResizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize) +{ + if (enable) + enableAutoResizeMode(minSize, maxSize); + else + disableAutoResizeMode(); } void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale) @@ -2302,8 +2301,8 @@ bool WebViewImpl::computePageScaleFactorLimits() float clampedScale = clampPageScaleFactorToLimits(pageScaleFactor()); #if USE(ACCELERATED_COMPOSITING) - if (m_layerTreeHost) - m_layerTreeHost->setPageScaleFactorAndLimits(clampedScale, m_minimumPageScaleFactor, m_maximumPageScaleFactor); + if (!m_layerTreeView.isNull()) + m_layerTreeView.setPageScaleFactorAndLimits(clampedScale, m_minimumPageScaleFactor, m_maximumPageScaleFactor); #endif if (clampedScale != pageScaleFactor()) { setPageScaleFactorPreservingScrollOffset(clampedScale); @@ -2582,6 +2581,14 @@ void WebViewImpl::sendResizeEventAndRepaint() } } +void WebViewImpl::configureAutoResizeMode() +{ + if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view()) + return; + + mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoResize, m_minAutoSize, m_maxAutoSize); +} + unsigned long WebViewImpl::createUniqueIdentifierForRequest() { if (m_page) @@ -2929,17 +2936,12 @@ void WebViewImpl::addPageOverlay(WebPageOverlay* overlay, int zOrder) m_pageOverlays = PageOverlayList::create(this); m_pageOverlays->add(overlay, zOrder); - setRootLayerNeedsDisplay(); } void WebViewImpl::removePageOverlay(WebPageOverlay* overlay) { - if (m_pageOverlays && m_pageOverlays->remove(overlay)) { - setRootLayerNeedsDisplay(); - - if (m_pageOverlays->empty()) - m_pageOverlays = nullptr; - } + if (m_pageOverlays && m_pageOverlays->remove(overlay) && m_pageOverlays->empty()) + m_pageOverlays = nullptr; } void WebViewImpl::setOverlayLayer(WebCore::GraphicsLayer* layer) @@ -3047,29 +3049,31 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) } m_nonCompositedContentHost->setScrollLayer(scrollLayer); } - if (m_layerTreeHost) - m_layerTreeHost->setRootLayer(layer ? layer->platformLayer() : 0); + + if (layer) + m_rootLayer = WebLayer(layer->platformLayer()); + + if (!m_layerTreeView.isNull()) + m_layerTreeView.setRootLayer(layer ? &m_rootLayer : 0); IntRect damagedRect(0, 0, m_size.width, m_size.height); if (!m_isAcceleratedCompositingActive) m_client->didInvalidateRect(damagedRect); } -void WebViewImpl::setRootLayerNeedsDisplay() +void WebViewImpl::scheduleCompositingLayerSync() { - if (m_layerTreeHost) - m_layerTreeHost->setNeedsCommit(); + m_layerTreeView.setNeedsRedraw(); } -void WebViewImpl::scrollRootLayerRect(const IntSize& scrollDelta, const IntRect& clipRect) +void WebViewImpl::scrollRootLayerRect(const IntSize&, const IntRect&) { updateLayerTreeViewport(); - setRootLayerNeedsDisplay(); } void WebViewImpl::invalidateRootLayerRect(const IntRect& rect) { - ASSERT(m_layerTreeHost); + ASSERT(!m_layerTreeView.isNull()); if (!page()) return; @@ -3078,7 +3082,6 @@ void WebViewImpl::invalidateRootLayerRect(const IntRect& rect) IntRect dirtyRect = view->windowToContents(rect); updateLayerTreeViewport(); m_nonCompositedContentHost->invalidateRect(dirtyRect); - setRootLayerNeedsDisplay(); } NonCompositedContentHost* WebViewImpl::nonCompositedContentHost() @@ -3091,8 +3094,8 @@ void WebViewImpl::scheduleAnimation() { if (isAcceleratedCompositingActive()) { if (CCProxy::hasImplThread()) { - ASSERT(m_layerTreeHost); - m_layerTreeHost->setNeedsAnimate(); + ASSERT(!m_layerTreeView.isNull()); + m_layerTreeView.setNeedsAnimate(); } else m_client->scheduleAnimation(); } else @@ -3145,26 +3148,26 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) m_isAcceleratedCompositingActive = false; // We need to finish all GL rendering before sending didDeactivateCompositor() to prevent // flickering when compositing turns off. - if (m_layerTreeHost) - m_layerTreeHost->finishAllRendering(); + if (!m_layerTreeView.isNull()) + m_layerTreeView.finishAllRendering(); m_client->didDeactivateCompositor(); - } else if (m_layerTreeHost) { + } else if (!m_layerTreeView.isNull()) { m_isAcceleratedCompositingActive = true; updateLayerTreeViewport(); - m_client->didActivateCompositor(m_layerTreeHost->compositorIdentifier()); + m_client->didActivateCompositor(m_layerTreeView.compositorIdentifier()); } else { TRACE_EVENT("WebViewImpl::setIsAcceleratedCompositingActive(true)", this, 0); - WebCore::CCSettings ccSettings; - ccSettings.acceleratePainting = page()->settings()->acceleratedDrawingEnabled(); - ccSettings.compositeOffscreen = settings()->compositeToTextureEnabled(); - ccSettings.showFPSCounter = settings()->showFPSCounter(); - ccSettings.showPlatformLayerTree = settings()->showPlatformLayerTree(); + WebLayerTreeView::Settings layerTreeViewSettings; + layerTreeViewSettings.acceleratePainting = page()->settings()->acceleratedDrawingEnabled(); + layerTreeViewSettings.compositeOffscreen = settings()->compositeToTextureEnabled(); + layerTreeViewSettings.showFPSCounter = settings()->showFPSCounter(); + layerTreeViewSettings.showPlatformLayerTree = settings()->showPlatformLayerTree(); - ccSettings.perTilePainting = page()->settings()->perTileDrawingEnabled(); - ccSettings.partialSwapEnabled = page()->settings()->partialSwapEnabled(); - ccSettings.threadedAnimationEnabled = page()->settings()->threadedAnimationEnabled(); + layerTreeViewSettings.perTilePainting = page()->settings()->perTileDrawingEnabled(); + layerTreeViewSettings.partialSwapEnabled = page()->settings()->partialSwapEnabled(); + layerTreeViewSettings.threadedAnimationEnabled = page()->settings()->threadedAnimationEnabled(); m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this)); m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders()); @@ -3172,17 +3175,16 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) if (page() && page()->mainFrame()->view()) m_nonCompositedContentHost->setBackgroundColor(page()->mainFrame()->view()->documentBackgroundColor()); - m_layerTreeHost = CCLayerTreeHost::create(this, ccSettings); - if (m_layerTreeHost) { - m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); + m_layerTreeView.initialize(this, m_rootLayer, layerTreeViewSettings); + if (!m_layerTreeView.isNull()) { + m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); updateLayerTreeViewport(); - m_client->didActivateCompositor(m_layerTreeHost->compositorIdentifier()); + m_client->didActivateCompositor(m_layerTreeView.compositorIdentifier()); m_isAcceleratedCompositingActive = true; m_compositorCreationFailed = false; if (m_pageOverlays) m_pageOverlays->update(); } else { - m_layerTreeHost.clear(); m_nonCompositedContentHost.clear(); m_isAcceleratedCompositingActive = false; m_client->didDeactivateCompositor(); @@ -3195,29 +3197,44 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) #endif -PassRefPtr<GraphicsContext3D> WebViewImpl::createCompositorGraphicsContext3D() +PassOwnPtr<WebKit::WebGraphicsContext3D> WebViewImpl::createCompositorGraphicsContext3D() { - WebKit::WebGraphicsContext3D::Attributes attributes = getCompositorContextAttributes(CCProxy::hasImplThread()); - OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(client()->createGraphicsContext3D(attributes, true /* renderDirectlyToHostWindow */)); + // Explicitly disable antialiasing for the compositor. As of the time of + // this writing, the only platform that supported antialiasing for the + // compositor was Mac OS X, because the on-screen OpenGL context creation + // code paths on Windows and Linux didn't yet have multisampling support. + // Mac OS X essentially always behaves as though it's rendering offscreen. + // Multisampling has a heavy cost especially on devices with relatively low + // fill rate like most notebooks, and the Mac implementation would need to + // be optimized to resolve directly into the IOSurface shared between the + // GPU and browser processes. For these reasons and to avoid platform + // disparities we explicitly disable antialiasing. + WebKit::WebGraphicsContext3D::Attributes attributes; + attributes.antialias = false; + attributes.shareResources = true; + + OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(client()->createGraphicsContext3D(attributes)); if (!webContext) - return 0; + return nullptr; - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); + return webContext.release(); } -PassRefPtr<GraphicsContext3D> WebViewImpl::createLayerTreeHostContext3D() +WebKit::WebGraphicsContext3D* WebViewImpl::createContext3D() { - RefPtr<GraphicsContext3D> context; + OwnPtr<WebKit::WebGraphicsContext3D> webContext; // If we've already created an onscreen context for this view, return that. if (m_temporaryOnscreenGraphicsContext3D) - context = m_temporaryOnscreenGraphicsContext3D.release(); + webContext = m_temporaryOnscreenGraphicsContext3D.release(); else // Otherwise make a new one. - context = createCompositorGraphicsContext3D(); - return context; + webContext = createCompositorGraphicsContext3D(); + // The caller takes ownership of this object, but since there's no equivalent of PassOwnPtr<> in the WebKit API + // we return a raw pointer. + return webContext.leakPtr(); } -void WebViewImpl::applyScrollAndScale(const IntSize& scrollDelta, float pageScaleDelta) +void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScaleDelta) { if (!mainFrameImpl() || !mainFrameImpl()->frameView()) return; @@ -3230,8 +3247,8 @@ void WebViewImpl::applyScrollAndScale(const IntSize& scrollDelta, float pageScal // in the old coordinate space, so we first need to multiply them // by the page scale delta. WebSize scrollOffset = mainFrame()->scrollOffset(); - scrollOffset.width += scrollDelta.width(); - scrollOffset.height += scrollDelta.height(); + scrollOffset.width += scrollDelta.width; + scrollOffset.height += scrollDelta.height; WebPoint scaledScrollOffset(scrollOffset.width * pageScaleDelta, scrollOffset.height * pageScaleDelta); setPageScaleFactor(pageScaleFactor() * pageScaleDelta, scaledScrollOffset); @@ -3250,7 +3267,7 @@ void WebViewImpl::didCompleteSwapBuffers() m_client->didCompleteSwapBuffers(); } -void WebViewImpl::didRecreateGraphicsContext(bool success) +void WebViewImpl::didRebindGraphicsContext(bool success) { // Switch back to software rendering mode, if necessary @@ -3277,7 +3294,7 @@ void WebViewImpl::scheduleComposite() void WebViewImpl::updateLayerTreeViewport() { - if (!page() || !m_nonCompositedContentHost || !m_layerTreeHost) + if (!page() || !m_nonCompositedContentHost || m_layerTreeView.isNull()) return; FrameView* view = page()->mainFrame()->view(); @@ -3293,18 +3310,18 @@ void WebViewImpl::updateLayerTreeViewport() layerAdjustX = -view->contentsSize().width() + view->visibleContentRect(false).width(); } m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, pageScaleFactor(), layerAdjustX); - m_layerTreeHost->setViewportSize(visibleRect.size()); - m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); + m_layerTreeView.setViewportSize(visibleRect.size()); + m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); } WebGraphicsContext3D* WebViewImpl::graphicsContext3D() { #if USE(ACCELERATED_COMPOSITING) if (m_page->settings()->acceleratedCompositingEnabled() && allowsAcceleratedCompositing()) { - if (m_layerTreeHost) { - WebGraphicsContext3D* webContext = GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_layerTreeHost->context()); - if (webContext && !webContext->isContextLost()) - return webContext; + if (!m_layerTreeView.isNull()) { + WebGraphicsContext3D* context = m_layerTreeView.context(); + if (context && !context->isContextLost()) + return context; } // If we get here it means that some system needs access to the context the compositor will use but the compositor itself // hasn't requested a context or it was unable to successfully instantiate a context. @@ -3313,7 +3330,7 @@ WebGraphicsContext3D* WebViewImpl::graphicsContext3D() if (!m_temporaryOnscreenGraphicsContext3D) m_temporaryOnscreenGraphicsContext3D = createCompositorGraphicsContext3D(); - WebGraphicsContext3D* webContext = GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); + WebGraphicsContext3D* webContext = m_temporaryOnscreenGraphicsContext3D.get(); if (webContext && !webContext->isContextLost()) return webContext; } @@ -3321,6 +3338,14 @@ WebGraphicsContext3D* WebViewImpl::graphicsContext3D() return 0; } +WebGraphicsContext3D* WebViewImpl::sharedGraphicsContext3D() +{ + if (!m_page->settings()->acceleratedCompositingEnabled() || !allowsAcceleratedCompositing()) + return 0; + + return GraphicsContext3DPrivate::extractWebGraphicsContext3D(SharedGraphicsContext3D::get()); +} + void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, bool isInitialState) { if (!page()) @@ -3338,7 +3363,7 @@ void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, bool visible = visibilityState == WebPageVisibilityStateVisible; if (!visible) m_nonCompositedContentHost->protectVisibleTileTextures(); - m_layerTreeHost->setVisible(visible); + m_layerTreeView.setVisible(visible); } #endif } diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index bc7a53d04..3819ecb65 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -32,6 +32,9 @@ #define WebViewImpl_h #include "WebNavigationPolicy.h" +#include "platform/WebLayer.h" +#include "platform/WebLayerTreeView.h" +#include "platform/WebLayerTreeViewClient.h" #include "platform/WebPoint.h" #include "platform/WebRect.h" #include "platform/WebSize.h" @@ -50,7 +53,6 @@ #include "NotificationPresenterImpl.h" #include "PageOverlayList.h" #include "UserMediaClientImpl.h" -#include "cc/CCLayerTreeHost.h" #include <wtf/OwnPtr.h> #include <wtf/RefCounted.h> @@ -94,7 +96,7 @@ class WebMouseWheelEvent; class WebSettingsImpl; class WebTouchEvent; -class WebViewImpl : public WebView, public WebCore::CCLayerTreeHostClient, public RefCounted<WebViewImpl> { +class WebViewImpl : public WebView, public WebLayerTreeViewClient, public RefCounted<WebViewImpl> { public: enum AutoZoomType { DoubleTap, @@ -137,6 +139,7 @@ public: virtual void didNotAcquirePointerLock(); virtual void didLosePointerLock(); virtual void didChangeWindowResizerRect(); + virtual void instrumentBeginFrame(); // WebView methods: virtual void initializeMainFrame(WebFrameClient*); @@ -186,6 +189,10 @@ public: virtual WebSize fixedLayoutSize() const; virtual void setFixedLayoutSize(const WebSize&); virtual void enableAutoResizeMode( + const WebSize& minSize, + const WebSize& maxSize); + virtual void disableAutoResizeMode(); + virtual void enableAutoResizeMode( bool enable, const WebSize& minSize, const WebSize& maxSize); @@ -246,13 +253,13 @@ public: virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */); virtual void removePageOverlay(WebPageOverlay*); - // CCLayerTreeHostClient + // WebLayerTreeViewClient virtual void updateAnimations(double frameBeginTime); - virtual void applyScrollAndScale(const WebCore::IntSize&, float); - virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D(); + virtual void applyScrollAndScale(const WebSize&, float); + virtual WebGraphicsContext3D* createContext3D(); + virtual void didRebindGraphicsContext(bool); virtual void didCommitAndDrawFrame(); virtual void didCompleteSwapBuffers(); - virtual void didRecreateGraphicsContext(bool success); virtual void scheduleComposite(); // WebViewImpl @@ -434,7 +441,7 @@ public: bool allowsAcceleratedCompositing(); bool pageHasRTLStyle() const; void setRootGraphicsLayer(WebCore::GraphicsLayer*); - void setRootLayerNeedsDisplay(); + void scheduleCompositingLayerSync(); void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect); void invalidateRootLayerRect(const WebCore::IntRect&); NonCompositedContentHost* nonCompositedContentHost(); @@ -450,7 +457,9 @@ public: // we could not successfully instantiate a context. virtual WebGraphicsContext3D* graphicsContext3D(); - PassRefPtr<WebCore::GraphicsContext3D> createCompositorGraphicsContext3D(); + virtual WebGraphicsContext3D* sharedGraphicsContext3D(); + + PassOwnPtr<WebGraphicsContext3D> createCompositorGraphicsContext3D(); virtual void setVisibilityState(WebPageVisibilityState, bool); @@ -532,6 +541,7 @@ private: DragAction); void sendResizeEventAndRepaint(); + void configureAutoResizeMode(); #if USE(ACCELERATED_COMPOSITING) void setIsAcceleratedCompositingActive(bool); @@ -688,7 +698,8 @@ private: #if USE(ACCELERATED_COMPOSITING) WebCore::IntRect m_rootLayerScrollDamage; OwnPtr<NonCompositedContentHost> m_nonCompositedContentHost; - RefPtr<WebCore::CCLayerTreeHost> m_layerTreeHost; + WebLayerTreeView m_layerTreeView; + WebLayer m_rootLayer; WebCore::GraphicsLayer* m_rootGraphicsLayer; bool m_isAcceleratedCompositingActive; bool m_compositorCreationFailed; @@ -703,7 +714,7 @@ private: // If we attempt to fetch the on-screen GraphicsContext3D before // the compositor has been turned on, we need to instantiate it // early. This member holds on to the GC3D in this case. - RefPtr<WebCore::GraphicsContext3D> m_temporaryOnscreenGraphicsContext3D; + OwnPtr<WebGraphicsContext3D> m_temporaryOnscreenGraphicsContext3D; OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy; OwnPtr<GeolocationClientProxy> m_geolocationClientProxy; diff --git a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp index 1db2d1dd9..a69f01a5f 100644 --- a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp @@ -214,6 +214,16 @@ bool WebWorkerClientImpl::allowDatabase(WebFrame*, const WebString& name, const return false; return !webView->permissionClient() || webView->permissionClient()->allowDatabase(m_webFrame, name, displayName, estimatedSize); } + +bool WebWorkerClientImpl::allowIndexedDB(const WebString& name) +{ + if (m_proxy->askedToTerminate()) + return false; + WebKit::WebViewImpl* webView = m_webFrame->viewImpl(); + if (!webView) + return false; + return !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(m_webFrame, name, WebSecurityOrigin()); +} WebView* WebWorkerClientImpl::view() const { diff --git a/Source/WebKit/chromium/src/WebWorkerClientImpl.h b/Source/WebKit/chromium/src/WebWorkerClientImpl.h index 3d5dab0de..d47744c9c 100644 --- a/Source/WebKit/chromium/src/WebWorkerClientImpl.h +++ b/Source/WebKit/chromium/src/WebWorkerClientImpl.h @@ -69,45 +69,46 @@ public: virtual void startWorkerContext(const WebCore::KURL&, const WTF::String&, const WTF::String&, - WebCore::WorkerThreadStartMode); - virtual void terminateWorkerContext(); + WebCore::WorkerThreadStartMode) OVERRIDE; + virtual void terminateWorkerContext() OVERRIDE; virtual void postMessageToWorkerContext( PassRefPtr<WebCore::SerializedScriptValue> message, - PassOwnPtr<WebCore::MessagePortChannelArray> channels); - virtual bool hasPendingActivity() const; - virtual void workerObjectDestroyed(); + PassOwnPtr<WebCore::MessagePortChannelArray> channels) OVERRIDE; + virtual bool hasPendingActivity() const OVERRIDE; + virtual void workerObjectDestroyed() OVERRIDE; #if ENABLE(INSPECTOR) - virtual void connectToInspector(WebCore::WorkerContextProxy::PageInspector*); - virtual void disconnectFromInspector(); - virtual void sendMessageToInspector(const String&); - virtual void postMessageToPageInspector(const String&); - virtual void updateInspectorStateCookie(const String&); + virtual void connectToInspector(WebCore::WorkerContextProxy::PageInspector*) OVERRIDE; + virtual void disconnectFromInspector() OVERRIDE; + virtual void sendMessageToInspector(const String&) OVERRIDE; + virtual void postMessageToPageInspector(const String&) OVERRIDE; + virtual void updateInspectorStateCookie(const String&) OVERRIDE; #endif // WebCore::WorkerLoaderProxy methods: - virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>); - virtual void postTaskForModeToWorkerContext(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode); + virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>) OVERRIDE; + virtual void postTaskForModeToWorkerContext(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode) OVERRIDE; // WebCore::WorkerObjectProxy methods: - virtual void postMessageToWorkerObject(PassRefPtr<WebCore::SerializedScriptValue>, PassOwnPtr<WebCore::MessagePortChannelArray>); - virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL); + virtual void postMessageToWorkerObject(PassRefPtr<WebCore::SerializedScriptValue>, PassOwnPtr<WebCore::MessagePortChannelArray>) OVERRIDE; + virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) OVERRIDE; virtual void postConsoleMessageToWorkerObject(WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, - const String& message, int lineNumber, const String& sourceURL); - virtual void confirmMessageFromWorkerObject(bool); - virtual void reportPendingActivity(bool); - virtual void workerContextClosed(); - virtual void workerContextDestroyed(); + const String& message, int lineNumber, const String& sourceURL) OVERRIDE; + virtual void confirmMessageFromWorkerObject(bool) OVERRIDE; + virtual void reportPendingActivity(bool) OVERRIDE; + virtual void workerContextClosed() OVERRIDE; + virtual void workerContextDestroyed() OVERRIDE; // WebWorkerClientBase methods: - virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize); + virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) OVERRIDE; virtual bool allowFileSystem(); virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, - WebFileSystemCallbacks*); + WebFileSystemCallbacks*) OVERRIDE; + virtual bool allowIndexedDB(const WebString& name) OVERRIDE; // WebCommentWorkerBase methods: - virtual WebCommonWorkerClient* commonClient() { return this; } - virtual WebView* view() const; + virtual WebCommonWorkerClient* commonClient() OVERRIDE { return this; } + virtual WebView* view() const OVERRIDE; private: WebWorkerClientImpl(WebCore::Worker*, WebFrameImpl*); diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp index 7fbb1f468..80a26ff03 100644 --- a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp +++ b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp @@ -34,6 +34,7 @@ #if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS) #include "AsyncFileSystemCallbacks.h" +#include "BlobURL.h" #include "FileMetadata.h" #include "FileSystem.h" #include "NotImplemented.h" @@ -208,6 +209,14 @@ void WorkerAsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, createWorkerFileSystemCallbacksBridge(WorkerFileWriterHelperCallbacks::create(client, pathAsURL, m_webFileSystem, callbacks, m_workerContext))->postReadMetadataToMainThread(m_webFileSystem, pathAsURL, m_modeForCurrentOperation); } +void WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) +{ + KURL pathAsURL = virtualPathToFileSystemURL(path); + KURL internalBlobURL = BlobURL::createInternalURL(); + + createWorkerFileSystemCallbacksBridge(createSnapshotFileCallback(internalBlobURL, callbacks))->postCreateSnapshotFileToMainThread(m_webFileSystem, internalBlobURL, pathAsURL, m_modeForCurrentOperation); +} + PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks) { ASSERT(!m_synchronous || !m_bridgeForCurrentOperation); diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h index c8ae3565f..08918518a 100644 --- a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h +++ b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h @@ -74,6 +74,7 @@ public: virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); + virtual void createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>); private: WorkerAsyncFileSystemChromium(ScriptExecutionContext*, AsyncFileSystem::Type, const WebKit::WebURL& rootURL, bool synchronous); diff --git a/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp index b1dad7035..8fd5cfa6d 100644 --- a/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp +++ b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp @@ -289,6 +289,15 @@ void WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread(WebFileSyste this, mode)); } +void WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread(WebFileSystem* fileSystem, const KURL& internalBlobURL, const KURL& path, const String& mode) +{ + ASSERT(fileSystem); + dispatchTaskToMainThread( + createCallbackTask(&createSnapshotFileOnMainThread, + AllowCrossThreadAccess(fileSystem), + internalBlobURL, path, this, mode)); +} + void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode) { if (!commonClient) @@ -348,6 +357,11 @@ void WorkerFileSystemCallbacksBridge::readDirectoryOnMainThread(WebCore::ScriptE fileSystem->readDirectory(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode)); } +void WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& internalBlobURL, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode) +{ + fileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode)); +} + void WorkerFileSystemCallbacksBridge::didFailOnMainThread(WebFileError error, const String& mode) { mayPostTaskToWorker(createCallbackTask(&didFailOnWorkerThread, this, error), mode); diff --git a/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h index 350839cd5..e496de2ef 100644 --- a/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h +++ b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h @@ -94,6 +94,7 @@ public: void postFileExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode); void postDirectoryExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode); void postReadDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode); + void postCreateSnapshotFileToMainThread(WebFileSystem*, const WebCore::KURL& internalBlobURL, const WebCore::KURL& path, const String& mode); // Callback methods that are called on the main thread. void didFailOnMainThread(WebFileError, const String& mode); @@ -117,6 +118,7 @@ private: static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode); static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode); static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode); + static void createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& internalBlobURL, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode); friend class MainThreadFileSystemCallbacks; diff --git a/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png b/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png Binary files differindex abe8db8ec..425ab5ed2 100644 --- a/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png +++ b/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png diff --git a/Source/WebKit/chromium/src/js/Tests.js b/Source/WebKit/chromium/src/js/Tests.js index 16a1ba257..b8dc8de50 100644 --- a/Source/WebKit/chromium/src/js/Tests.js +++ b/Source/WebKit/chromium/src/js/Tests.js @@ -579,6 +579,50 @@ TestSuite.prototype.waitForTestResultsInConsole = function() this.takeControl(); }; +TestSuite.prototype.checkLogAndErrorMessages = function() +{ + var messages = WebInspector.console.messages; + + var matchesCount = 0; + function validMessage(message) + { + if (message.text === "log" && message.level === WebInspector.ConsoleMessage.MessageLevel.Log) { + ++matchesCount; + return true; + } + + if (message.text === "error" && message.level === WebInspector.ConsoleMessage.MessageLevel.Error) { + ++matchesCount; + return true; + } + return false; + } + + for (var i = 0; i < messages.length; ++i) { + if (validMessage(messages[i])) + continue; + this.fail(messages[i].text + ":" + messages[i].level); // This will throw. + } + + if (matchesCount === 2) + return; + + // Wait for more messages. + function onConsoleMessage(event) + { + var message = event.data; + if (validMessage(message)) { + if (matchesCount === 2) { + this.releaseControl(); + return; + } + } else + this.fail(message.text + ":" + messages[i].level); + } + + WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage, this); + this.takeControl(); +}; /** * Serializes array of uiSourceCodes to string. diff --git a/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp b/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp index c71a3b6c6..9da4b4a27 100644 --- a/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp +++ b/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp @@ -107,7 +107,9 @@ WebKeyboardEvent WebInputEventFactory::keyboardEvent(HWND hwnd, UINT message, // caller, who would know for sure. result.timeStampSeconds = GetMessageTime() / 1000.0; - result.windowsKeyCode = result.nativeKeyCode = static_cast<int>(wparam); + result.windowsKeyCode = static_cast<int>(wparam); + // Record the scan code (along with other context bits) for this key event. + result.nativeKeyCode = static_cast<int>(lparam); switch (message) { case WM_SYSKEYDOWN: diff --git a/Source/WebKit/chromium/tests/AssociatedURLLoaderTest.cpp b/Source/WebKit/chromium/tests/AssociatedURLLoaderTest.cpp index 677865ac0..a168ebca9 100644 --- a/Source/WebKit/chromium/tests/AssociatedURLLoaderTest.cpp +++ b/Source/WebKit/chromium/tests/AssociatedURLLoaderTest.cpp @@ -241,7 +241,7 @@ public: m_expectedResponse.setMIMEType("text/html"); m_expectedResponse.addHTTPHeaderField("Access-Control-Allow-Origin", "*"); if (exposed) - m_expectedResponse.addHTTPHeaderField("access-control-expose-header", headerNameString); + m_expectedResponse.addHTTPHeaderField("access-control-expose-headers", headerNameString); m_expectedResponse.addHTTPHeaderField(headerNameString, "foo"); webkit_support::RegisterMockedURL(url, m_expectedResponse, m_frameFilePath); diff --git a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp index a9f7b1c1a..74d635b40 100644 --- a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp +++ b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp @@ -39,11 +39,11 @@ using namespace WebKitTests; namespace { -void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* root, Vector<RefPtr<CCLayerImpl> >& renderSurfaceLayerList) +void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* root, Vector<CCLayerImpl*>& renderSurfaceLayerList) { CCLayerSorter layerSorter; TransformationMatrix identityMatrix; - Vector<RefPtr<CCLayerImpl> > dummyLayerList; + Vector<CCLayerImpl*> dummyLayerList; int dummyMaxTextureSize = 512; // Sanity check: The test itself should create the root layer's render surface, so @@ -64,7 +64,7 @@ void emulateDrawingOneFrame(CCLayerImpl* root) // 2. updating all damage trackers in the correct order // 3. resetting all updateRects and propertyChanged flags for all layers and surfaces. - Vector<RefPtr<CCLayerImpl> > renderSurfaceLayerList; + Vector<CCLayerImpl*> renderSurfaceLayerList; executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList); // Iterate back-to-front, so that damage correctly propagates from descendant surfaces to ancestors. @@ -76,10 +76,10 @@ void emulateDrawingOneFrame(CCLayerImpl* root) root->resetAllChangeTrackingForSubtree(); } -PassRefPtr<CCLayerImpl> createTestTreeWithOneSurface() +PassOwnPtr<CCLayerImpl> createTestTreeWithOneSurface() { - RefPtr<CCLayerImpl> root = CCLayerImpl::create(1); - RefPtr<CCLayerImpl> child = CCLayerImpl::create(2); + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2); root->setPosition(FloatPoint::zero()); root->setAnchorPoint(FloatPoint::zero()); @@ -92,22 +92,22 @@ PassRefPtr<CCLayerImpl> createTestTreeWithOneSurface() child->setAnchorPoint(FloatPoint::zero()); child->setBounds(IntSize(30, 30)); child->setDrawsContent(true); - root->addChild(child); + root->addChild(child.release()); return root.release(); } -PassRefPtr<CCLayerImpl> createTestTreeWithTwoSurfaces() +PassOwnPtr<CCLayerImpl> createTestTreeWithTwoSurfaces() { // This test tree has two render surfaces: one for the root, and one for // child1. Additionally, the root has a second child layer, and child1 has two // children of its own. - RefPtr<CCLayerImpl> root = CCLayerImpl::create(1); - RefPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); - RefPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); - RefPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); - RefPtr<CCLayerImpl> grandChild2 = CCLayerImpl::create(5); + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); + OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); + OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); + OwnPtr<CCLayerImpl> grandChild2 = CCLayerImpl::create(5); root->setPosition(FloatPoint::zero()); root->setAnchorPoint(FloatPoint::zero()); @@ -137,17 +137,17 @@ PassRefPtr<CCLayerImpl> createTestTreeWithTwoSurfaces() grandChild2->setBounds(IntSize(6, 8)); grandChild2->setDrawsContent(true); - child1->addChild(grandChild1); - child1->addChild(grandChild2); - root->addChild(child1); - root->addChild(child2); + child1->addChild(grandChild1.release()); + child1->addChild(grandChild2.release()); + root->addChild(child1.release()); + root->addChild(child2.release()); return root.release(); } -PassRefPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface() +PassOwnPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface() { - RefPtr<CCLayerImpl> root = createTestTreeWithOneSurface(); + OwnPtr<CCLayerImpl> root = createTestTreeWithOneSurface(); // Setup includes going past the first frame which always damages everything, so // that we can actually perform specific tests. @@ -156,9 +156,9 @@ PassRefPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface() return root.release(); } -PassRefPtr<CCLayerImpl> createAndSetUpTestTreeWithTwoSurfaces() +PassOwnPtr<CCLayerImpl> createAndSetUpTestTreeWithTwoSurfaces() { - RefPtr<CCLayerImpl> root = createTestTreeWithTwoSurfaces(); + OwnPtr<CCLayerImpl> root = createTestTreeWithTwoSurfaces(); // Setup includes going past the first frame which always damages everything, so // that we can actually perform specific tests. @@ -178,7 +178,7 @@ TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithOneSurface) // Sanity check that the simple test tree will actually produce the expected render // surfaces and layer lists. - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); EXPECT_EQ(static_cast<size_t>(2), root->renderSurface()->layerList().size()); EXPECT_EQ(1, root->renderSurface()->layerList()[0]->id()); @@ -193,10 +193,10 @@ TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) // Sanity check that the complex test tree will actually produce the expected render // surfaces and layer lists. - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - RefPtr<CCLayerImpl> child2 = root->children()[1]; + CCLayerImpl* child1 = root->children()[0].get(); + CCLayerImpl* child2 = root->children()[1].get(); FloatRect childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRect(); FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect(); @@ -212,8 +212,8 @@ TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child = root->children()[0].get(); // CASE 1: Setting the update rect should cause the corresponding damage to the surface. // @@ -243,8 +243,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects) TEST_F(CCDamageTrackerTest, verifyDamageForPropertyChanges) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child = root->children()[0].get(); // CASE 1: The layer's property changed flag takes priority over update rect. // @@ -284,8 +284,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) // If a layer is transformed, the damage rect should still enclose the entire // transformed layer. - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child = root->children()[0].get(); TransformationMatrix rotation; rotation.rotate(45); @@ -317,18 +317,20 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - - RefPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); - child2->setPosition(FloatPoint(400, 380)); - child2->setAnchorPoint(FloatPoint::zero()); - child2->setBounds(IntSize(6, 8)); - child2->setDrawsContent(true); + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child1 = root->children()[0].get(); + + { + OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); + child2->setPosition(FloatPoint(400, 380)); + child2->setAnchorPoint(FloatPoint::zero()); + child2->setBounds(IntSize(6, 8)); + child2->setDrawsContent(true); + root->addChild(child2.release()); + } // CASE 1: Adding a new layer should cause the appropriate damage. // - root->addChild(child2); emulateDrawingOneFrame(root.get()); // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere. @@ -353,15 +355,18 @@ TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer) TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - - RefPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); - child2->setPosition(FloatPoint(400, 380)); - child2->setAnchorPoint(FloatPoint::zero()); - child2->setBounds(IntSize(6, 8)); - child2->setDrawsContent(true); - root->addChild(child2); + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child1 = root->children()[0].get(); + + { + OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); + child2->setPosition(FloatPoint(400, 380)); + child2->setAnchorPoint(FloatPoint::zero()); + child2->setBounds(IntSize(6, 8)); + child2->setDrawsContent(true); + root->addChild(child2.release()); + } + CCLayerImpl* child2 = root->children()[1].get(); // In this test we don't want the above tree manipulation to be considered part of the same frame. emulateDrawingOneFrame(root.get()); @@ -378,10 +383,10 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers) TEST_F(CCDamageTrackerTest, verifyDamageForNestedSurfaces) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - RefPtr<CCLayerImpl> child2 = root->children()[1]; - RefPtr<CCLayerImpl> grandChild1 = root->children()[0]->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); + CCLayerImpl* child2 = root->children()[1].get(); + CCLayerImpl* grandChild1 = root->children()[0]->children()[0].get(); FloatRect childDamageRect; FloatRect rootDamageRect; @@ -415,9 +420,9 @@ TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer) // This is a tricky case, since only the first grandChild changes, but the entire // surface should be marked dirty. - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - RefPtr<CCLayerImpl> grandChild1 = root->children()[0]->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); + CCLayerImpl* grandChild1 = root->children()[0]->children()[0].get(); FloatRect childDamageRect; FloatRect rootDamageRect; @@ -447,9 +452,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromAncestorLayer) // should be completely unchanged, since we are only transforming it, while the // root surface would be damaged appropriately. - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - RefPtr<CCLayerImpl> grandChild1 = root->children()[0]->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); FloatRect childDamageRect; FloatRect rootDamageRect; @@ -469,8 +473,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromAncestorLayer) TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); FloatRect childDamageRect; FloatRect rootDamageRect; @@ -510,8 +514,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); FloatRect childDamageRect; FloatRect rootDamageRect; @@ -534,8 +538,8 @@ TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged) TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); FloatRect childDamageRect; FloatRect rootDamageRect; @@ -551,10 +555,10 @@ TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) TEST_F(CCDamageTrackerTest, verifyDamageForReplica) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - RefPtr<CCLayerImpl> grandChild1 = child1->children()[0]; - RefPtr<CCLayerImpl> grandChild2 = child1->children()[1]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); + CCLayerImpl* grandChild1 = child1->children()[0].get(); + CCLayerImpl* grandChild2 = child1->children()[1].get(); // Damage on a surface that has a reflection should cause the target surface to // receive the surface's damage and the surface's reflected damage. @@ -563,24 +567,28 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica) // of child1's surface. This way, we can test reflection changes without changing // contentBounds of the surface. grandChild2->setPosition(FloatPoint(180, 180)); - RefPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6); - grandChild3->setPosition(FloatPoint(240, 240)); - grandChild3->setAnchorPoint(FloatPoint::zero()); - grandChild3->setBounds(IntSize(10, 10)); - grandChild3->setDrawsContent(true); + { + OwnPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6); + grandChild3->setPosition(FloatPoint(240, 240)); + grandChild3->setAnchorPoint(FloatPoint::zero()); + grandChild3->setBounds(IntSize(10, 10)); + grandChild3->setDrawsContent(true); + child1->addChild(grandChild3.release()); + } child1->setOpacity(0.5); - child1->addChild(grandChild3); emulateDrawingOneFrame(root.get()); // CASE 1: adding a reflection about the left edge of grandChild1. // - RefPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7); - grandChild1Replica->setPosition(FloatPoint::zero()); - grandChild1Replica->setAnchorPoint(FloatPoint::zero()); - TransformationMatrix reflection; - reflection.scale3d(-1.0, 1.0, 1.0); - grandChild1Replica->setTransform(reflection); - grandChild1->setReplicaLayer(grandChild1Replica); + { + OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7); + grandChild1Replica->setPosition(FloatPoint::zero()); + grandChild1Replica->setAnchorPoint(FloatPoint::zero()); + TransformationMatrix reflection; + reflection.scale3d(-1.0, 1.0, 1.0); + grandChild1Replica->setTransform(reflection); + grandChild1->setReplicaLayer(grandChild1Replica.release()); + } emulateDrawingOneFrame(root.get()); FloatRect grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->currentDamageRect(); @@ -614,7 +622,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica) // CASE 3: removing the reflection should cause the entire region including reflection // to damage the target surface. - grandChild1->setReplicaLayer(0); + grandChild1->setReplicaLayer(nullptr); emulateDrawingOneFrame(root.get()); ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->contentRect().width()); ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->contentRect().height()); @@ -629,27 +637,32 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica) TEST_F(CCDamageTrackerTest, verifyDamageForMask) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child = root->children()[0].get(); // In the current implementation of the damage tracker, changes to mask layers should // damage the entire corresponding surface. // Set up the mask layer. - RefPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3); - maskLayer->setPosition(child->position()); - maskLayer->setAnchorPoint(FloatPoint::zero()); - maskLayer->setBounds(child->bounds()); - child->setMaskLayer(maskLayer); + { + OwnPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3); + maskLayer->setPosition(child->position()); + maskLayer->setAnchorPoint(FloatPoint::zero()); + maskLayer->setBounds(child->bounds()); + child->setMaskLayer(maskLayer.release()); + } + CCLayerImpl* maskLayer = child->maskLayer(); // Add opacity and a grandChild so that the render surface persists even after we remove the mask. child->setOpacity(0.5); - RefPtr<CCLayerImpl> grandChild = CCLayerImpl::create(4); - grandChild->setPosition(FloatPoint(2.0, 2.0)); - grandChild->setAnchorPoint(FloatPoint::zero()); - grandChild->setBounds(IntSize(2, 2)); - grandChild->setDrawsContent(true); - child->addChild(grandChild); + { + OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(4); + grandChild->setPosition(FloatPoint(2.0, 2.0)); + grandChild->setAnchorPoint(FloatPoint::zero()); + grandChild->setBounds(IntSize(2, 2)); + grandChild->setDrawsContent(true); + child->addChild(grandChild.release()); + } emulateDrawingOneFrame(root.get()); // Sanity check that a new surface was created for the child. @@ -685,7 +698,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask) EXPECT_TRUE(childDamageRect.isEmpty()); // Then test mask removal. - child->setMaskLayer(0); + child->setMaskLayer(nullptr); ASSERT_TRUE(child->layerPropertyChanged()); emulateDrawingOneFrame(root.get()); @@ -698,28 +711,34 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask) TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); - RefPtr<CCLayerImpl> child1 = root->children()[0]; - RefPtr<CCLayerImpl> grandChild1 = child1->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); + CCLayerImpl* child1 = root->children()[0].get(); + CCLayerImpl* grandChild1 = child1->children()[0].get(); // Changes to a replica's mask should not damage the original surface, because it is // not masked. But it does damage the ancestor target surface. // Create a reflection about the left edge of grandChild1. - RefPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); - grandChild1Replica->setPosition(FloatPoint::zero()); - grandChild1Replica->setAnchorPoint(FloatPoint::zero()); - TransformationMatrix reflection; - reflection.scale3d(-1.0, 1.0, 1.0); - grandChild1Replica->setTransform(reflection); - grandChild1->setReplicaLayer(grandChild1Replica); + { + OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); + grandChild1Replica->setPosition(FloatPoint::zero()); + grandChild1Replica->setAnchorPoint(FloatPoint::zero()); + TransformationMatrix reflection; + reflection.scale3d(-1.0, 1.0, 1.0); + grandChild1Replica->setTransform(reflection); + grandChild1->setReplicaLayer(grandChild1Replica.release()); + } + CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer(); // Set up the mask layer on the replica layer - RefPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7); - replicaMaskLayer->setPosition(FloatPoint::zero()); - replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); - replicaMaskLayer->setBounds(grandChild1->bounds()); - grandChild1Replica->setMaskLayer(replicaMaskLayer); + { + OwnPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7); + replicaMaskLayer->setPosition(FloatPoint::zero()); + replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); + replicaMaskLayer->setBounds(grandChild1->bounds()); + grandChild1Replica->setMaskLayer(replicaMaskLayer.release()); + } + CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); emulateDrawingOneFrame(root.get()); @@ -738,7 +757,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) // CASE 2: removing the replica mask damages only the reflected region on the target surface. // - grandChild1Replica->setMaskLayer(0); + grandChild1Replica->setMaskLayer(nullptr); emulateDrawingOneFrame(root.get()); grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->currentDamageRect(); @@ -750,8 +769,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) TEST_F(CCDamageTrackerTest, verifyDamageWhenReset) { - RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); - RefPtr<CCLayerImpl> child = root->children()[0]; + OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); + CCLayerImpl* child = root->children()[0].get(); // Case 1: This test ensures that when the tracker is forced to have full damage, that // it takes priority over any other partial damage. diff --git a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp index b7732aeab..15b554a06 100644 --- a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp +++ b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp @@ -48,9 +48,8 @@ void expectTranslateX(double translateX, const TransformationMatrix& matrix) // Tests that a float animation with one keyframe works as expected. TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) { - Vector<CCFloatKeyframe> keyframes; - keyframes.append(CCFloatKeyframe(0, 2)); - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); @@ -61,10 +60,9 @@ TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) // Tests that a float animation with two keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) { - Vector<CCFloatKeyframe> keyframes; - keyframes.append(CCFloatKeyframe(0, 2)); - keyframes.append(CCFloatKeyframe(1, 4)); - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -75,11 +73,10 @@ TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) // Tests that a float animation with three keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) { - Vector<CCFloatKeyframe> keyframes; - keyframes.append(CCFloatKeyframe(0, 2)); - keyframes.append(CCFloatKeyframe(1, 4)); - keyframes.append(CCFloatKeyframe(2, 8)); - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -92,13 +89,11 @@ TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) // Tests that a float animation with multiple keys at a given time works sanely. TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) { - Vector<CCFloatKeyframe> keyframes; - // A step function. - keyframes.append(CCFloatKeyframe(0, 4)); - keyframes.append(CCFloatKeyframe(1, 4)); - keyframes.append(CCFloatKeyframe(1, 6)); - keyframes.append(CCFloatKeyframe(2, 6)); - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 4, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 6, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(2, 6, nullptr)); EXPECT_FLOAT_EQ(4, curve->getValue(-1)); EXPECT_FLOAT_EQ(4, curve->getValue(0)); @@ -117,11 +112,11 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) // Tests that a transform animation with one keyframe works as expected. TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) { - Vector<CCTransformKeyframe> keyframes; + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); TransformOperations operations; operations.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); - keyframes.append(CCTransformKeyframe(0, operations)); - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations, nullptr)); + IntSize layerSize; // ignored expectTranslateX(2, curve->getValue(-1, layerSize)); expectTranslateX(2, curve->getValue(0, layerSize)); @@ -133,14 +128,13 @@ TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) // Tests that a transform animation with two keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) { - Vector<CCTransformKeyframe> keyframes; + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); TransformOperations operations1; operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); TransformOperations operations2; operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); - keyframes.append(CCTransformKeyframe(0, operations1)); - keyframes.append(CCTransformKeyframe(1, operations2)); - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); IntSize layerSize; // ignored expectTranslateX(2, curve->getValue(-1, layerSize)); expectTranslateX(2, curve->getValue(0, layerSize)); @@ -152,17 +146,16 @@ TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) // Tests that a transform animation with three keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) { - Vector<CCTransformKeyframe> keyframes; + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); TransformOperations operations1; operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); TransformOperations operations2; operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); TransformOperations operations3; operations3.operations().append(TranslateTransformOperation::create(Length(8, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); - keyframes.append(CCTransformKeyframe(0, operations1)); - keyframes.append(CCTransformKeyframe(1, operations2)); - keyframes.append(CCTransformKeyframe(2, operations3)); - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(2, operations3, nullptr)); IntSize layerSize; // ignored expectTranslateX(2, curve->getValue(-1, layerSize)); expectTranslateX(2, curve->getValue(0, layerSize)); @@ -176,7 +169,7 @@ TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) // Tests that a transform animation with multiple keys at a given time works sanely. TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) { - Vector<CCTransformKeyframe> keyframes; + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); // A step function. TransformOperations operations1; operations1.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); @@ -186,11 +179,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) operations3.operations().append(TranslateTransformOperation::create(Length(6, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); TransformOperations operations4; operations4.operations().append(TranslateTransformOperation::create(Length(6, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); - keyframes.append(CCTransformKeyframe(0, operations1)); - keyframes.append(CCTransformKeyframe(1, operations2)); - keyframes.append(CCTransformKeyframe(1, operations3)); - keyframes.append(CCTransformKeyframe(2, operations4)); - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(1, operations3, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(2, operations4, nullptr)); IntSize layerSize; // ignored @@ -209,33 +201,36 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) expectTranslateX(6, curve->getValue(3, layerSize)); } -// Tests that invalid lists of keyframes result in nothing being returned from ::create. -TEST(CCKeyframedAnimationCurveTest, InvalidKeyframes) +// Tests that the keyframes may be added out of order. +TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) { - // It is invalid to pass an empty vector of keyframes to create. - Vector<CCTransformKeyframe> transformKeyframes; - OwnPtr<CCKeyframedTransformAnimationCurve> transformCurve = CCKeyframedTransformAnimationCurve::create(transformKeyframes); - EXPECT_FALSE(transformCurve.get()); - - Vector<CCFloatKeyframe> floatKeyframes; - OwnPtr<CCKeyframedFloatAnimationCurve> floatCurve = CCKeyframedFloatAnimationCurve::create(floatKeyframes); - EXPECT_FALSE(floatCurve.get()); - - // It is invalid to pass a vector of unsorted keyframes to create; - TransformOperations operations1; - operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); - TransformOperations operations2; - operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); - transformKeyframes.append(CCTransformKeyframe(1, operations1)); - transformKeyframes.append(CCTransformKeyframe(0, operations2)); - transformCurve = CCKeyframedTransformAnimationCurve::create(transformKeyframes); - EXPECT_FALSE(transformCurve.get()); - - floatKeyframes.append(CCFloatKeyframe(1, 2)); - floatKeyframes.append(CCFloatKeyframe(0, 4)); - floatCurve = CCKeyframedFloatAnimationCurve::create(floatKeyframes); - EXPECT_FALSE(floatCurve.get()); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); + EXPECT_FLOAT_EQ(2, curve->getValue(-1)); + EXPECT_FLOAT_EQ(2, curve->getValue(0)); + EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); + EXPECT_FLOAT_EQ(4, curve->getValue(1)); + EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); + EXPECT_FLOAT_EQ(8, curve->getValue(2)); + EXPECT_FLOAT_EQ(8, curve->getValue(3)); } +// Tests that a cubic bezier timing function works as expected. +TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction) +{ + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1))); + curve->addKeyframe(CCFloatKeyframe::create(1, 1, nullptr)); + + EXPECT_FLOAT_EQ(0, curve->getValue(0)); + EXPECT_LT(0, curve->getValue(0.25)); + EXPECT_GT(0.25, curve->getValue(0.25)); + EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5)); + EXPECT_LT(0.75, curve->getValue(0.75)); + EXPECT_GT(1, curve->getValue(0.75)); + EXPECT_FLOAT_EQ(1, curve->getValue(1)); +} } // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp index 16a25e12e..8a9f35dc8 100644 --- a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp @@ -65,14 +65,11 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly) DebugScopedSetImplThread setImplThread; // Create a simple CCLayerImpl tree: - RefPtr<CCLayerImpl> root = CCLayerImpl::create(1); - RefPtr<CCLayerImpl> child = CCLayerImpl::create(2); - RefPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3); - root->addChild(child); - child->addChild(grandChild); - - RefPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(4); - RefPtr<CCLayerImpl> dummyReplica = CCLayerImpl::create(5); + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); + root->addChild(CCLayerImpl::create(2)); + CCLayerImpl* child = root->children()[0].get(); + child->addChild(CCLayerImpl::create(3)); + CCLayerImpl* grandChild = child->children()[0].get(); // Adding children is an internal operation and should not mark layers as changed. EXPECT_FALSE(root->layerPropertyChanged()); @@ -95,11 +92,11 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly) EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryFloatPoint)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPointZ(arbitraryNumber)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(arbitraryFilters)); - EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(dummyMask)); + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(CCLayerImpl::create(4))); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMasksToBounds(true)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setOpaque(true)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setOpacity(arbitraryNumber)); - EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setReplicaLayer(dummyReplica)); + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setReplicaLayer(CCLayerImpl::create(5))); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryFloatPoint)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setTransform(arbitraryTransform)); @@ -134,9 +131,7 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly) // not cause any change. EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPoint(arbitraryFloatPoint)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPointZ(arbitraryNumber)); - EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaskLayer(dummyMask)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMasksToBounds(true)); - EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setReplicaLayer(dummyReplica)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPosition(arbitraryFloatPoint)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransform)); diff --git a/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp b/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp index bff7e1ba9..2f5a7a25d 100644 --- a/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp @@ -67,8 +67,8 @@ private: EXPECT_EQ(contrib, layer->m_countRepresentingContributingSurface); \ EXPECT_EQ(itself, layer->m_countRepresentingItself); -typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> FrontToBack; -typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> BackToFront; +typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> FrontToBack; +typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> BackToFront; void resetCounts(Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList) { @@ -137,7 +137,7 @@ TEST(CCLayerIteratorTest, simpleTree) Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > layerList; - renderSurfaceLayerList.append(rootLayer); + renderSurfaceLayerList.append(rootLayer.get()); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(), TransformationMatrix(), TransformationMatrix(), renderSurfaceLayerList, layerList, @@ -184,7 +184,7 @@ TEST(CCLayerIteratorTest, complexTree) Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > layerList; - renderSurfaceLayerList.append(rootLayer); + renderSurfaceLayerList.append(rootLayer.get()); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(), TransformationMatrix(), TransformationMatrix(), renderSurfaceLayerList, layerList, @@ -243,7 +243,7 @@ TEST(CCLayerIteratorTest, complexTreeMultiSurface) Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > layerList; - renderSurfaceLayerList.append(rootLayer); + renderSurfaceLayerList.append(rootLayer.get()); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(), TransformationMatrix(), TransformationMatrix(), renderSurfaceLayerList, layerList, diff --git a/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp b/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp index 69342cda7..a533c9373 100644 --- a/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp @@ -174,11 +174,11 @@ TEST(CCLayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff) // - 3 and 4 do not have a 3d z difference, and therefore their relative ordering should be retained. // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5. - RefPtr<CCLayerImpl> layer1 = CCLayerImpl::create(1); - RefPtr<CCLayerImpl> layer2 = CCLayerImpl::create(2); - RefPtr<CCLayerImpl> layer3 = CCLayerImpl::create(3); - RefPtr<CCLayerImpl> layer4 = CCLayerImpl::create(4); - RefPtr<CCLayerImpl> layer5 = CCLayerImpl::create(5); + OwnPtr<CCLayerImpl> layer1 = CCLayerImpl::create(1); + OwnPtr<CCLayerImpl> layer2 = CCLayerImpl::create(2); + OwnPtr<CCLayerImpl> layer3 = CCLayerImpl::create(3); + OwnPtr<CCLayerImpl> layer4 = CCLayerImpl::create(4); + OwnPtr<CCLayerImpl> layer5 = CCLayerImpl::create(5); TransformationMatrix BehindMatrix; BehindMatrix.translate3d(0, 0, 2); @@ -205,12 +205,12 @@ TEST(CCLayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff) layer5->setDrawTransform(BehindMatrix); layer5->setDrawsContent(true); - Vector<RefPtr<CCLayerImpl> > layerList; - layerList.append(layer1); - layerList.append(layer2); - layerList.append(layer3); - layerList.append(layer4); - layerList.append(layer5); + Vector<CCLayerImpl*> layerList; + layerList.append(layer1.get()); + layerList.append(layer2.get()); + layerList.append(layer3.get()); + layerList.append(layer4.get()); + layerList.append(layer5.get()); ASSERT_EQ(static_cast<size_t>(5), layerList.size()); EXPECT_EQ(1, layerList[0]->id()); diff --git a/Source/WebKit/chromium/tests/CCLayerTestCommon.cpp b/Source/WebKit/chromium/tests/CCLayerTestCommon.cpp index 9fe377766..423c668d9 100644 --- a/Source/WebKit/chromium/tests/CCLayerTestCommon.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTestCommon.cpp @@ -36,15 +36,6 @@ namespace CCLayerTestCommon { // Align with expected and actual output const char* quadString = " Quad: "; -bool completelyContains(const Region& container, const IntRect& rect) -{ - Region tester(rect); - Vector<IntRect> rects = container.rects(); - for (size_t i = 0; i < rects.size(); ++i) - tester.subtract(rects[i]); - return tester.isEmpty(); -} - void verifyQuadsExactlyCoverRect(const CCQuadList& quads, const IntRect& rect) { Region remaining(rect); @@ -53,7 +44,7 @@ void verifyQuadsExactlyCoverRect(const CCQuadList& quads, const IntRect& rect) CCDrawQuad* quad = quads[i].get(); EXPECT_TRUE(rect.contains(quad->quadRect())) << quadString << i; - EXPECT_TRUE(completelyContains(remaining, quad->quadRect())) << quadString << i; + EXPECT_TRUE(remaining.contains(quad->quadRect())) << quadString << i; remaining.subtract(Region(quad->quadRect())); } diff --git a/Source/WebKit/chromium/tests/CCLayerTestCommon.h b/Source/WebKit/chromium/tests/CCLayerTestCommon.h index c5add93a9..052d44bc9 100644 --- a/Source/WebKit/chromium/tests/CCLayerTestCommon.h +++ b/Source/WebKit/chromium/tests/CCLayerTestCommon.h @@ -33,7 +33,6 @@ namespace CCLayerTestCommon { extern const char* quadString; -bool completelyContains(const WebCore::Region&, const WebCore::IntRect&); void verifyQuadsExactlyCoverRect(const WebCore::CCQuadList&, const WebCore::IntRect&); } // namespace CCLayerTestCommon diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp index d2e1cfef9..e6206cc58 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp @@ -573,7 +573,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); + renderSurfaceLayerList.append(parent.get()); CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp index 9ba1cf4ad..d75c12890 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp @@ -49,10 +49,11 @@ public: m_hostImpl = CCLayerTreeHostImpl::create(settings, this); } + virtual void didLoseContextOnImplThread() { } virtual void onSwapBuffersCompleteOnImplThread() { } virtual void setNeedsRedrawOnImplThread() { m_didRequestRedraw = true; } virtual void setNeedsCommitOnImplThread() { m_didRequestCommit = true; } - virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>) { } + virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) { } static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) { @@ -78,16 +79,16 @@ public: void setupScrollAndContentsLayers(const IntSize& contentSize) { - RefPtr<CCLayerImpl> root = CCLayerImpl::create(0); + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); root->setScrollable(true); root->setScrollPosition(IntPoint(0, 0)); root->setMaxScrollPosition(contentSize); - RefPtr<CCLayerImpl> contents = CCLayerImpl::create(1); + OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(1); contents->setDrawsContent(true); contents->setBounds(contentSize); contents->setContentBounds(contentSize); - root->addChild(contents); - m_hostImpl->setRootLayer(root); + root->addChild(contents.release()); + m_hostImpl->setRootLayer(root.release()); } protected: @@ -112,37 +113,43 @@ TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers) TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) { - RefPtr<CCLayerImpl> root = CCLayerImpl::create(0); - root->addChild(CCLayerImpl::create(1)); - root->addChild(CCLayerImpl::create(2)); - root->children()[1]->addChild(CCLayerImpl::create(3)); - root->children()[1]->addChild(CCLayerImpl::create(4)); - root->children()[1]->children()[0]->addChild(CCLayerImpl::create(5)); - m_hostImpl->setRootLayer(root); + { + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->addChild(CCLayerImpl::create(1)); + root->addChild(CCLayerImpl::create(2)); + root->children()[1]->addChild(CCLayerImpl::create(3)); + root->children()[1]->addChild(CCLayerImpl::create(4)); + root->children()[1]->children()[0]->addChild(CCLayerImpl::create(5)); + m_hostImpl->setRootLayer(root.release()); + } + CCLayerImpl* root = m_hostImpl->rootLayer(); - expectClearedScrollDeltasRecursive(root.get()); + expectClearedScrollDeltasRecursive(root); OwnPtr<CCScrollAndScaleSet> scrollInfo; scrollInfo = m_hostImpl->processScrollDeltas(); ASSERT_EQ(scrollInfo->scrolls.size(), 0u); - expectClearedScrollDeltasRecursive(root.get()); + expectClearedScrollDeltasRecursive(root); scrollInfo = m_hostImpl->processScrollDeltas(); ASSERT_EQ(scrollInfo->scrolls.size(), 0u); - expectClearedScrollDeltasRecursive(root.get()); + expectClearedScrollDeltasRecursive(root); } TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) { IntPoint scrollPosition(20, 30); IntSize scrollDelta(11, -15); - RefPtr<CCLayerImpl> root = CCLayerImpl::create(10); - root->setScrollPosition(scrollPosition); - root->setScrollable(true); - root->setMaxScrollPosition(IntSize(100, 100)); - root->scrollBy(scrollDelta); - m_hostImpl->setRootLayer(root); + { + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(10); + root->setScrollPosition(scrollPosition); + root->setScrollable(true); + root->setMaxScrollPosition(IntSize(100, 100)); + root->scrollBy(scrollDelta); + m_hostImpl->setRootLayer(root.release()); + } + CCLayerImpl* root = m_hostImpl->rootLayer(); OwnPtr<CCScrollAndScaleSet> scrollInfo; @@ -165,11 +172,14 @@ TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) { - RefPtr<CCLayerImpl> root = CCLayerImpl::create(0); - root->setScrollable(true); - root->setScrollPosition(IntPoint(0, 0)); - root->setMaxScrollPosition(IntSize(100, 100)); - m_hostImpl->setRootLayer(root); + { + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setScrollable(true); + root->setScrollPosition(IntPoint(0, 0)); + root->setMaxScrollPosition(IntSize(100, 100)); + m_hostImpl->setRootLayer(root.release()); + } + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted); m_hostImpl->scrollBy(IntSize(0, 10)); m_hostImpl->scrollEnd(); @@ -179,11 +189,15 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers) { - RefPtr<CCLayerImpl> root = CCLayerImpl::create(0); - root->setScrollable(true); - root->setScrollPosition(IntPoint(0, 0)); - root->setMaxScrollPosition(IntSize(100, 100)); - m_hostImpl->setRootLayer(root); + { + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setScrollable(true); + root->setScrollPosition(IntPoint(0, 0)); + root->setMaxScrollPosition(IntSize(100, 100)); + m_hostImpl->setRootLayer(root.release()); + } + CCLayerImpl* root = m_hostImpl->rootLayer(); + root->setHaveWheelEventHandlers(true); // With registered event handlers, wheel scrolls have to go to the main thread. EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed); @@ -192,6 +206,61 @@ TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers) EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollStarted); } +TEST_F(CCLayerTreeHostImplTest, shouldScrollOnMainThread) +{ + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setScrollable(true); + root->setScrollPosition(IntPoint(0, 0)); + root->setMaxScrollPosition(IntSize(100, 100)); + root->setShouldScrollOnMainThread(true); + m_hostImpl->setRootLayer(root.release()); + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed); + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollFailed); +} + +TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic) +{ + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setScrollable(true); + root->setScrollPosition(IntPoint(0, 0)); + root->setMaxScrollPosition(IntSize(100, 100)); + root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); + m_hostImpl->setRootLayer(root.release()); + // All scroll types inside the non-fast scrollable region should fail. + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed); + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollFailed); + + // All scroll types outside this region should succeed. + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted); + m_hostImpl->scrollBy(IntSize(0, 10)); + m_hostImpl->scrollEnd(); + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollStarted); + m_hostImpl->scrollBy(IntSize(0, 10)); + m_hostImpl->scrollEnd(); +} + +TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset) +{ + m_hostImpl->initializeLayerRenderer(createContext()); + + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setScrollable(true); + root->setScrollPosition(IntPoint(0, 0)); + root->setMaxScrollPosition(IntSize(100, 100)); + root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); + root->setPosition(FloatPoint(-25, 0)); + m_hostImpl->setRootLayer(root.release()); + m_hostImpl->drawLayers(); // Update draw transforms so we can correctly map points into layer space. + + // This point would fall into the non-fast scrollable region except that we've moved the layer down by 25 pixels. + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted); + m_hostImpl->scrollBy(IntSize(0, 1)); + m_hostImpl->scrollEnd(); + + // This point is still inside the non-fast region. + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed); +} + TEST_F(CCLayerTreeHostImplTest, pinchGesture) { setupScrollAndContentsLayers(IntSize(100, 100)); @@ -281,8 +350,10 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) ASSERT(scrollLayer); const float minPageScale = 0.5, maxPageScale = 4; - const double startTimeMs = 1000; - const double durationMs = 100; + const double startTime = 1; + const double duration = 0.1; + const double halfwayThroughAnimation = startTime + duration / 2; + const double endTime = startTime + duration; // Non-anchor zoom-in { @@ -290,10 +361,10 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) scrollLayer->setPageScaleDelta(1); scrollLayer->setScrollPosition(IntPoint(50, 50)); - m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTimeMs, durationMs); - m_hostImpl->animate(startTimeMs + durationMs / 2); + m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); + m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); EXPECT_TRUE(m_didRequestRedraw); - m_hostImpl->animate(startTimeMs + durationMs); + m_hostImpl->animate(endTime, endTime); EXPECT_TRUE(m_didRequestCommit); OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); @@ -307,8 +378,8 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) scrollLayer->setPageScaleDelta(1); scrollLayer->setScrollPosition(IntPoint(50, 50)); - m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTimeMs, durationMs); - m_hostImpl->animate(startTimeMs + durationMs); + m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); + m_hostImpl->animate(endTime, endTime); EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestCommit); @@ -321,7 +392,7 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) class DidDrawCheckLayer : public CCLayerImpl { public: - static PassRefPtr<DidDrawCheckLayer> create(int id) { return adoptRef(new DidDrawCheckLayer(id)); } + static PassOwnPtr<DidDrawCheckLayer> create(int id) { return adoptPtr(new DidDrawCheckLayer(id)); } virtual void didDraw() { @@ -353,14 +424,13 @@ private: TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) { - RefPtr<GraphicsContext3D> context = createContext(); - m_hostImpl->initializeLayerRenderer(context); + m_hostImpl->initializeLayerRenderer(createContext()); // Ensure visibleLayerRect for root layer is empty m_hostImpl->setViewportSize(IntSize(0, 0)); - RefPtr<DidDrawCheckLayer> root = DidDrawCheckLayer::create(0); - m_hostImpl->setRootLayer(root); + m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); + DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); EXPECT_FALSE(root->willDrawCalled()); EXPECT_FALSE(root->didDrawCalled()); @@ -388,18 +458,17 @@ TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) { - RefPtr<GraphicsContext3D> context = createContext(); - m_hostImpl->initializeLayerRenderer(context); + m_hostImpl->initializeLayerRenderer(createContext()); m_hostImpl->setViewportSize(IntSize(10, 10)); - RefPtr<DidDrawCheckLayer> root = DidDrawCheckLayer::create(0); - m_hostImpl->setRootLayer(root); + m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); + DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); - RefPtr<DidDrawCheckLayer> layer1 = DidDrawCheckLayer::create(1); - root->addChild(layer1); + root->addChild(DidDrawCheckLayer::create(1)); + DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()[0].get()); - RefPtr<DidDrawCheckLayer> layer2 = DidDrawCheckLayer::create(2); - layer1->addChild(layer2); + layer1->addChild(DidDrawCheckLayer::create(2)); + DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children()[0].get()); layer1->setOpacity(0.3); layer1->setPreserves3D(false); @@ -422,8 +491,6 @@ class BlendStateTrackerContext: public FakeWebGraphicsContext3D { public: BlendStateTrackerContext() : m_blend(false) { } - virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return true; } - virtual void enable(WGC3Denum cap) { if (cap == GraphicsContext3D::BLEND) @@ -444,7 +511,7 @@ private: class BlendStateCheckLayer : public CCLayerImpl { public: - static PassRefPtr<BlendStateCheckLayer> create(int id) { return adoptRef(new BlendStateCheckLayer(id)); } + static PassOwnPtr<BlendStateCheckLayer> create(int id) { return adoptPtr(new BlendStateCheckLayer(id)); } virtual void appendQuads(CCQuadList& quadList, const CCSharedQuadState* sharedQuadState) { @@ -489,18 +556,20 @@ private: // https://bugs.webkit.org/show_bug.cgi?id=75783 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) { - RefPtr<GraphicsContext3D> context = createContext(); - m_hostImpl->initializeLayerRenderer(context); + m_hostImpl->initializeLayerRenderer(createContext()); m_hostImpl->setViewportSize(IntSize(10, 10)); - RefPtr<CCLayerImpl> root = CCLayerImpl::create(0); - root->setAnchorPoint(FloatPoint(0, 0)); - root->setBounds(IntSize(10, 10)); - root->setDrawsContent(false); - m_hostImpl->setRootLayer(root); + { + OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setAnchorPoint(FloatPoint(0, 0)); + root->setBounds(IntSize(10, 10)); + root->setDrawsContent(false); + m_hostImpl->setRootLayer(root.release()); + } + CCLayerImpl* root = m_hostImpl->rootLayer(); - RefPtr<BlendStateCheckLayer> layer1 = BlendStateCheckLayer::create(1); - root->addChild(layer1); + root->addChild(BlendStateCheckLayer::create(1)); + BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->children()[0].get()); // Opaque layer, drawn without blending. layer1->setOpaque(true); @@ -539,8 +608,8 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) m_hostImpl->drawLayers(); EXPECT_TRUE(layer1->quadsAppended()); - RefPtr<BlendStateCheckLayer> layer2 = BlendStateCheckLayer::create(2); - layer1->addChild(layer2); + layer1->addChild(BlendStateCheckLayer::create(2)); + BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->children()[0].get()); // 2 opaque layers, drawn without blending. layer1->setOpaque(true); @@ -632,8 +701,6 @@ class ReshapeTrackerContext: public FakeWebGraphicsContext3D { public: ReshapeTrackerContext() : m_reshapeCalled(false) { } - virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return true; } - virtual void reshape(int width, int height) { m_reshapeCalled = true; @@ -660,11 +727,11 @@ TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) m_hostImpl->initializeLayerRenderer(context); m_hostImpl->setViewportSize(IntSize(10, 10)); - RefPtr<CCLayerImpl> root = adoptRef(new FakeDrawableCCLayerImpl(1)); + CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); root->setAnchorPoint(FloatPoint(0, 0)); root->setBounds(IntSize(10, 10)); root->setDrawsContent(true); - m_hostImpl->setRootLayer(root); + m_hostImpl->setRootLayer(adoptPtr(root)); EXPECT_FALSE(reshapeTracker->reshapeCalled()); m_hostImpl->drawLayers(); @@ -673,8 +740,6 @@ TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { public: - virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return true; } - virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) { m_partialSwapRect = IntRect(x, y, width, height); @@ -683,7 +748,7 @@ public: virtual WebString getString(WGC3Denum name) { if (name == GraphicsContext3D::EXTENSIONS) - return WebString("GL_CHROMIUM_post_sub_buffer"); + return WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibility"); return WebString(); } @@ -709,8 +774,8 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) layerTreeHostImpl->initializeLayerRenderer(context); layerTreeHostImpl->setViewportSize(IntSize(500, 500)); - RefPtr<CCLayerImpl> root = adoptRef(new FakeDrawableCCLayerImpl(1)); - RefPtr<CCLayerImpl> child = adoptRef(new FakeDrawableCCLayerImpl(2)); + CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); + CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); child->setPosition(FloatPoint(12, 13)); child->setAnchorPoint(FloatPoint(0, 0)); child->setBounds(IntSize(14, 15)); @@ -718,8 +783,8 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) root->setAnchorPoint(FloatPoint(0, 0)); root->setBounds(IntSize(500, 500)); root->setDrawsContent(true); - root->addChild(child); - layerTreeHostImpl->setRootLayer(root); + root->addChild(adoptPtr(child)); + layerTreeHostImpl->setRootLayer(adoptPtr(root)); // First frame, the entire screen should get swapped. layerTreeHostImpl->drawLayers(); @@ -760,4 +825,106 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); } +// Make sure that we reset damage tracking on visibility change because the +// state of the front buffer that we push to with PostSubBuffer is undefined. +TEST_F(CCLayerTreeHostImplTest, visibilityChangeResetsDamage) +{ + PartialSwapTrackerContext* partialSwapTracker = new PartialSwapTrackerContext(); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(partialSwapTracker), GraphicsContext3D::RenderDirectlyToHostWindow); + + // This test creates its own CCLayerTreeHostImpl, so + // that we can force partial swap enabled. + CCSettings settings; + settings.partialSwapEnabled = true; + OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create(settings, this); + layerTreeHostImpl->initializeLayerRenderer(context); + layerTreeHostImpl->setViewportSize(IntSize(500, 500)); + + CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); + root->setAnchorPoint(FloatPoint(0, 0)); + root->setBounds(IntSize(500, 500)); + root->setDrawsContent(true); + layerTreeHostImpl->setRootLayer(adoptPtr(root)); + + // First frame: ignore. + layerTreeHostImpl->drawLayers(); + layerTreeHostImpl->swapBuffers(); + + // Second frame: nothing has changed --- so we souldn't push anything with partial swap. + layerTreeHostImpl->drawLayers(); + layerTreeHostImpl->swapBuffers(); + EXPECT_TRUE(partialSwapTracker->partialSwapRect().isEmpty()); + + // Third frame: visibility change --- so we should push a full frame with partial swap. + layerTreeHostImpl->setVisible(false); + layerTreeHostImpl->setVisible(true); + layerTreeHostImpl->drawLayers(); + layerTreeHostImpl->swapBuffers(); + IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); + IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); + EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); + EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); + EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); + EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); +} + +// Make sure that context lost notifications are propagated through the tree. +class ContextLostNotificationCheckLayer : public CCLayerImpl { +public: + static PassOwnPtr<ContextLostNotificationCheckLayer> create(int id) { return adoptPtr(new ContextLostNotificationCheckLayer(id)); } + + virtual void didLoseContext() + { + m_didLoseContextCalled = true; + } + + bool didLoseContextCalled() const { return m_didLoseContextCalled; } + +private: + explicit ContextLostNotificationCheckLayer(int id) + : CCLayerImpl(id) + , m_didLoseContextCalled(false) + { + } + + bool m_didLoseContextCalled; +}; + +TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers) +{ + m_hostImpl->initializeLayerRenderer(createContext()); + m_hostImpl->setViewportSize(IntSize(10, 10)); + + m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(0)); + ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificationCheckLayer*>(m_hostImpl->rootLayer()); + + root->addChild(ContextLostNotificationCheckLayer::create(1)); + ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificationCheckLayer*>(root->children()[0].get()); + + layer1->addChild(ContextLostNotificationCheckLayer::create(2)); + ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificationCheckLayer*>(layer1->children()[0].get()); + + EXPECT_FALSE(root->didLoseContextCalled()); + EXPECT_FALSE(layer1->didLoseContextCalled()); + EXPECT_FALSE(layer2->didLoseContextCalled()); + + m_hostImpl->initializeLayerRenderer(createContext()); + + EXPECT_TRUE(root->didLoseContextCalled()); + EXPECT_TRUE(layer1->didLoseContextCalled()); + EXPECT_TRUE(layer2->didLoseContextCalled()); +} + +class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D { +public: + virtual bool makeContextCurrent() { return false; } +}; + +TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) +{ + // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects. + m_hostImpl->initializeLayerRenderer(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails), GraphicsContext3D::RenderDirectlyToHostWindow)); + m_hostImpl->finishAllRendering(); +} + } // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp index 10cfa6931..2c4e7ce59 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp @@ -38,6 +38,7 @@ #include "WebKit.h" #include "cc/CCActiveAnimation.h" #include "cc/CCLayerAnimationController.h" +#include "cc/CCLayerAnimationDelegate.h" #include "cc/CCLayerImpl.h" #include "cc/CCLayerTreeHostImpl.h" #include "cc/CCScopedThreadProxy.h" @@ -59,15 +60,21 @@ using namespace WTF; namespace { // Used by test stubs to notify the test when something interesting happens. -class TestHooks { +class TestHooks : public CCLayerAnimationDelegate { public: virtual void beginCommitOnCCThread(CCLayerTreeHostImpl*) { } virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) { } virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) { } - virtual void animateLayers(CCLayerTreeHostImpl*) { } + virtual void animateLayers(CCLayerTreeHostImpl*, double monotonicTime) { } virtual void applyScrollAndScale(const IntSize&, float) { } - virtual void updateAnimations(double frameBeginTime) { } + virtual void updateAnimations(double monotonicTime) { } virtual void layout() { } + virtual void didRecreateContext(bool succeded) { } + virtual void didCommitAndDrawFrame() { } + + // Implementation of CCLayerAnimationDelegate + virtual void notifyAnimationStarted(double time) { } + virtual void notifyAnimationFinished(int animationId) { } }; // Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks. @@ -97,10 +104,10 @@ public: } protected: - virtual void animateLayers(double frameBeginTimeMs) + virtual void animateLayers(double monotonicTime, double wallClockTime) { - CCLayerTreeHostImpl::animateLayers(frameBeginTimeMs); - m_testHooks->animateLayers(this); + CCLayerTreeHostImpl::animateLayers(monotonicTime, wallClockTime); + m_testHooks->animateLayers(this, monotonicTime); } private: @@ -130,6 +137,8 @@ public: // LayerTreeHostImpl won't draw if it has 1x1 viewport. layerTreeHost->setViewportSize(IntSize(1, 1)); + layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks); + return layerTreeHost.release(); } @@ -205,9 +214,9 @@ public: return adoptPtr(new MockLayerTreeHostClient(testHooks)); } - virtual void updateAnimations(double frameBeginTime) + virtual void updateAnimations(double monotonicTime) { - m_testHooks->updateAnimations(frameBeginTime); + m_testHooks->updateAnimations(monotonicTime); } virtual void layout() @@ -220,7 +229,7 @@ public: m_testHooks->applyScrollAndScale(scrollDelta, scale); } - virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() + virtual PassRefPtr<GraphicsContext3D> createContext() { GraphicsContext3D::Attributes attrs; WebGraphicsContext3D::Attributes webAttrs; @@ -232,14 +241,16 @@ public: virtual void didCommitAndDrawFrame() { + m_testHooks->didCommitAndDrawFrame(); } virtual void didCompleteSwapBuffers() { } - virtual void didRecreateGraphicsContext(bool) + virtual void didRecreateContext(bool succeeded) { + m_testHooks->didRecreateContext(succeeded); } virtual void scheduleComposite() @@ -279,6 +290,11 @@ public: callOnMainThread(CCLayerTreeHostTest::dispatchAddAnimation, this); } + void postAddInstantAnimationToMainThread() + { + callOnMainThread(CCLayerTreeHostTest::dispatchAddInstantAnimation, this); + } + void postSetNeedsCommitToMainThread() { callOnMainThread(CCLayerTreeHostTest::dispatchSetNeedsCommit, this); @@ -329,67 +345,76 @@ protected: static void dispatchSetNeedsAnimate(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT(test); - if (test->m_layerTreeHost) - test->m_layerTreeHost->setNeedsAnimate(); + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost) + test->m_layerTreeHost->setNeedsAnimate(); + } + + static void dispatchAddInstantAnimation(void* self) + { + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer()) + addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 0, 0, 1); } static void dispatchAddAnimation(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT(test); - if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer()) - addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 0, 0, 1); + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer()) + addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 10, 0, 1); } static void dispatchSetNeedsAnimateAndCommit(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT(test); - if (test->m_layerTreeHost) { - test->m_layerTreeHost->setNeedsAnimate(); - test->m_layerTreeHost->setNeedsCommit(); - } + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost) { + test->m_layerTreeHost->setNeedsAnimate(); + test->m_layerTreeHost->setNeedsCommit(); + } } static void dispatchSetNeedsCommit(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT_TRUE(test); - if (test->m_layerTreeHost) - test->m_layerTreeHost->setNeedsCommit(); + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT_TRUE(test); + if (test->m_layerTreeHost) + test->m_layerTreeHost->setNeedsCommit(); } static void dispatchSetNeedsRedraw(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT_TRUE(test); - if (test->m_layerTreeHost) - test->m_layerTreeHost->setNeedsRedraw(); + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT_TRUE(test); + if (test->m_layerTreeHost) + test->m_layerTreeHost->setNeedsRedraw(); } static void dispatchSetVisible(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT(test); - if (test->m_layerTreeHost) - test->m_layerTreeHost->setVisible(true); + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost) + test->m_layerTreeHost->setVisible(true); } static void dispatchSetInvisible(void* self) { - ASSERT(isMainThread()); - CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); - ASSERT(test); - if (test->m_layerTreeHost) - test->m_layerTreeHost->setVisible(false); + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost) + test->m_layerTreeHost->setVisible(false); } class TimeoutTask : public WebThread::Task { @@ -827,34 +852,57 @@ class CCLayerTreeHostTestAddAnimation : public CCLayerTreeHostTestThreadOnly { public: CCLayerTreeHostTestAddAnimation() : m_numAnimates(0) - , m_layerTreeHostImpl(0) + , m_receivedAnimationStartedNotification(false) + , m_receivedAnimationFinishedNotification(false) + , m_startTime(0) + , m_firstMonotonicTime(0) { } virtual void beginTest() { - postAddAnimationToMainThread(); + postAddInstantAnimationToMainThread(); } - virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl) + virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime) { if (!m_numAnimates) { // The animation had zero duration so layerTreeHostImpl should no // longer need to animate its layers. EXPECT_FALSE(layerTreeHostImpl->needsAnimateLayers()); m_numAnimates++; + m_firstMonotonicTime = monotonicTime; return; } + EXPECT_LT(0, m_startTime); + EXPECT_LT(0, m_firstMonotonicTime); + EXPECT_NE(m_startTime, m_firstMonotonicTime); + EXPECT_TRUE(m_receivedAnimationStartedNotification); + EXPECT_TRUE(m_receivedAnimationFinishedNotification); endTest(); } + virtual void notifyAnimationStarted(double wallClockTime) + { + m_receivedAnimationStartedNotification = true; + m_startTime = wallClockTime; + } + + virtual void notifyAnimationFinished(int) + { + m_receivedAnimationFinishedNotification = true; + } + virtual void afterTest() { } private: int m_numAnimates; - CCLayerTreeHostImpl* m_layerTreeHostImpl; + bool m_receivedAnimationStartedNotification; + bool m_receivedAnimationFinishedNotification; + double m_startTime; + double m_firstMonotonicTime; }; TEST_F(CCLayerTreeHostTestAddAnimation, runMultiThread) @@ -862,6 +910,43 @@ TEST_F(CCLayerTreeHostTestAddAnimation, runMultiThread) runTestThreaded(); } +// Ensures that animations continue to be ticked when we are backgrounded. +class CCLayerTreeHostTestTickAnimationWhileBackgrounded : public CCLayerTreeHostTestThreadOnly { +public: + CCLayerTreeHostTestTickAnimationWhileBackgrounded() + : m_numAnimates(0) + { + } + + virtual void beginTest() + { + postAddAnimationToMainThread(); + } + + virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime) + { + if (!m_numAnimates) { + // We have a long animation running. It should continue to tick even if we are not visible. + postSetVisibleToMainThread(false); + m_numAnimates++; + return; + } + endTest(); + } + + virtual void afterTest() + { + } + +private: + int m_numAnimates; +}; + +TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded, runMultiThread) +{ + runTestThreaded(); +} + class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTestThreadOnly { public: CCLayerTreeHostTestScrollSimple() @@ -1154,9 +1239,9 @@ public: m_paintContentsCount++; } - virtual void idlePaintContentsIfDirty() + virtual void idlePaintContentsIfDirty(const Region& occluded) { - ContentLayerChromium::idlePaintContentsIfDirty(); + ContentLayerChromium::idlePaintContentsIfDirty(occluded); m_idlePaintContentsCount++; } @@ -1883,4 +1968,72 @@ public: SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestManySurfaces) +// A loseContext(1) should lead to a didRecreateContext(true) +class CCLayerTreeHostTestSetSingleLostContext : public CCLayerTreeHostTestThreadOnly { +public: + CCLayerTreeHostTestSetSingleLostContext() + { + } + + virtual void beginTest() + { + postSetNeedsCommitToMainThread(); + } + + virtual void didCommitAndDrawFrame() + { + m_layerTreeHost->loseContext(1); + } + + virtual void didRecreateContext(bool succeeded) + { + EXPECT_TRUE(succeeded); + endTest(); + } + + virtual void afterTest() + { + } +}; + +TEST_F(CCLayerTreeHostTestSetSingleLostContext, runMultiThread) +{ + runTestThreaded(); +} + +// A loseContext(10) should lead to a didRecreateContext(false), and +// a finishAllRendering() should not hang. +class CCLayerTreeHostTestSetRepeatedLostContext : public CCLayerTreeHostTestThreadOnly { +public: + CCLayerTreeHostTestSetRepeatedLostContext() + { + } + + virtual void beginTest() + { + postSetNeedsCommitToMainThread(); + } + + virtual void didCommitAndDrawFrame() + { + m_layerTreeHost->loseContext(10); + } + + virtual void didRecreateContext(bool succeeded) + { + EXPECT_FALSE(succeeded); + m_layerTreeHost->finishAllRendering(); + endTest(); + } + + virtual void afterTest() + { + } +}; + +TEST_F(CCLayerTreeHostTestSetRepeatedLostContext, runMultiThread) +{ + runTestThreaded(); +} + } // namespace diff --git a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp index 678ec9645..26d52523b 100644 --- a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp +++ b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp @@ -45,16 +45,6 @@ using namespace WebCore; namespace { -void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatrix& transform, const TransformationMatrix& sublayerTransform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque) -{ - layer->setTransform(transform); - layer->setSublayerTransform(sublayerTransform); - layer->setAnchorPoint(anchor); - layer->setPosition(position); - layer->setBounds(bounds); - layer->setOpaque(opaque); -} - class LayerChromiumWithForcedDrawsContent : public LayerChromium { public: LayerChromiumWithForcedDrawsContent() @@ -63,30 +53,106 @@ public: } virtual bool drawsContent() const { return true; } + virtual Region opaqueContentsRegion() const + { + return intersection(m_opaquePaintRect, visibleLayerRect()); + } + + void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; } + +private: + IntRect m_opaquePaintRect; }; +void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) +{ + layer->setTransform(transform); + layer->setSublayerTransform(TransformationMatrix()); + layer->setAnchorPoint(FloatPoint(0, 0)); + layer->setPosition(position); + layer->setBounds(bounds); +} + +void setLayerPropertiesForTesting(LayerChromiumWithForcedDrawsContent* layer, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque, bool opaqueLayers) +{ + setLayerPropertiesForTesting(layer, transform, position, bounds); + if (opaqueLayers) + layer->setOpaque(opaque); + else { + layer->setOpaque(false); + if (opaque) + layer->setOpaquePaintRect(IntRect(IntPoint(), bounds)); + else + layer->setOpaquePaintRect(IntRect()); + } +} + // A subclass to expose the total current occlusion. class TestCCOcclusionTracker : public CCOcclusionTracker { public: + TestCCOcclusionTracker(IntRect screenScissorRect) + : CCOcclusionTracker(screenScissorRect) + , m_overrideLayerScissorRect(false) + { + } + + TestCCOcclusionTracker(IntRect screenScissorRect, const CCOcclusionTrackerDamageClient* damageClient) + : CCOcclusionTracker(screenScissorRect, damageClient) + , m_overrideLayerScissorRect(false) + { + } + Region occlusionInScreenSpace() const { return CCOcclusionTracker::m_stack.last().occlusionInScreen; } Region occlusionInTargetSurface() const { return CCOcclusionTracker::m_stack.last().occlusionInTarget; } void setOcclusionInScreenSpace(const Region& region) { CCOcclusionTracker::m_stack.last().occlusionInScreen = region; } void setOcclusionInTargetSurface(const Region& region) { CCOcclusionTracker::m_stack.last().occlusionInTarget = region; } + + void setLayerScissorRect(const IntRect& rect) { m_overrideLayerScissorRect = true; m_layerScissorRect = rect;} + void useDefaultLayerScissorRect() { m_overrideLayerScissorRect = false; } + +protected: + virtual IntRect layerScissorRectInTargetSurface(const LayerChromium* layer) const { return m_overrideLayerScissorRect ? m_layerScissorRect : CCOcclusionTracker::layerScissorRectInTargetSurface(layer); } + +private: + bool m_overrideLayerScissorRect; + IntRect m_layerScissorRect; }; -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegion) +class TestDamageClient : public CCOcclusionTrackerDamageClient { +public: + // The interface + virtual FloatRect damageRect(const RenderSurfaceChromium*) const { return m_damageRect; } + + // Testing stuff + TestDamageClient(const FloatRect& damageRect) : m_damageRect(damageRect) { } + void setDamageRect(const FloatRect& damageRect) { m_damageRect = damageRect; } + +private: + FloatRect m_damageRect; +}; + +#define TEST_OPAQUE_AND_PAINTED_OPAQUE(FULLTESTNAME, SHORTTESTNAME) \ + TEST(FULLTESTNAME, opaqueLayer) \ + { \ + SHORTTESTNAME(true); \ + } \ + TEST(FULLTESTNAME, opaquePaintRect) \ + { \ + SHORTTESTNAME(false); \ + } + +void layerAddedToOccludedRegion(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); parent->createRenderSurface(); parent->addChild(layer); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(30, 30), IntSize(500, 500), true, opaqueLayers); Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > dummyLayerList; @@ -98,6 +164,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegion) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + occlusion.enterTargetRenderSurface(parent->renderSurface()); occlusion.markOccludedBehindLayer(layer.get()); EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); @@ -111,6 +180,14 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegion) EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(31, 30, 70, 70))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 31, 70, 70))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 29, 70, 70))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(31, 30, 70, 70))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 31, 70, 70))); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 30, 70, 70)).isEmpty()); EXPECT_EQ_RECT(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 30, 70, 70))); EXPECT_EQ_RECT(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 29, 70, 70))); @@ -122,10 +199,11 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegion) EXPECT_EQ_RECT(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 31, 70, 70))); } -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotation) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegion, layerAddedToOccludedRegion); + +void layerAddedToOccludedRegionWithRotation(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); @@ -137,8 +215,8 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotation) layerTransform.rotate(90); layerTransform.translate(-250, -250); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(layer.get(), layerTransform, FloatPoint(30, 30), IntSize(500, 500), true, opaqueLayers); Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > dummyLayerList; @@ -150,6 +228,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotation) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + occlusion.enterTargetRenderSurface(parent->renderSurface()); occlusion.markOccludedBehindLayer(layer.get()); EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); @@ -163,6 +244,14 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotation) EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(31, 30, 70, 70))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 31, 70, 70))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 29, 70, 70))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(31, 30, 70, 70))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 31, 70, 70))); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 30, 70, 70)).isEmpty()); EXPECT_EQ_RECT(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 30, 70, 70))); EXPECT_EQ_RECT(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 29, 70, 70))); @@ -174,10 +263,11 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotation) EXPECT_EQ_RECT(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 31, 70, 70))); } -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithTranslation) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegionWithRotation, layerAddedToOccludedRegionWithRotation); + +void layerAddedToOccludedRegionWithTranslation(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); @@ -187,8 +277,8 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithTranslation) TransformationMatrix layerTransform; layerTransform.translate(20, 20); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(layer.get(), layerTransform, FloatPoint(30, 30), IntSize(500, 500), true, opaqueLayers); Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; Vector<RefPtr<LayerChromium> > dummyLayerList; @@ -200,6 +290,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithTranslation) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + occlusion.enterTargetRenderSurface(parent->renderSurface()); occlusion.markOccludedBehindLayer(layer.get()); EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occlusion.occlusionInScreenSpace().bounds()); @@ -213,6 +306,14 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithTranslation) EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(51, 50, 50, 50))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(50, 51, 50, 50))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(50, 50, 50, 50))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(49, 50, 50, 50))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(50, 49, 50, 50))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(51, 50, 50, 50))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(50, 51, 50, 50))); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(50, 50, 50, 50)).isEmpty()); EXPECT_EQ_RECT(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 50, 50, 50))); EXPECT_EQ_RECT(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 49, 50, 50))); @@ -222,12 +323,25 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithTranslation) EXPECT_EQ_RECT(IntRect(51, 51, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(51, 51, 50, 50))); EXPECT_EQ_RECT(IntRect(50, 100, 50, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(50, 51, 50, 50))); EXPECT_EQ_RECT(IntRect(49, 51, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 51, 50, 50))); + + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(50, 50, 50, 50)).isEmpty()); + EXPECT_EQ_RECT(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 50, 50, 50))); + EXPECT_EQ_RECT(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 49, 50, 50))); + EXPECT_EQ_RECT(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(50, 49, 50, 50))); + EXPECT_EQ_RECT(IntRect(51, 49, 49, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(51, 49, 50, 50))); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(51, 50, 50, 50)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(51, 51, 50, 50)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(50, 51, 50, 50)).isEmpty()); + EXPECT_EQ_RECT(IntRect(49, 51, 1, 49), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 51, 50, 50))); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); } -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegionWithTranslation, layerAddedToOccludedRegionWithTranslation); + +void layerAddedToOccludedRegionWithRotatedSurface(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child = LayerChromium::create(); @@ -241,9 +355,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) childTransform.rotate(90); childTransform.translate(-250, -250); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child.get(), childTransform, FloatPoint(30, 30), IntSize(500, 500)); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(10, 10), IntSize(500, 500), true, opaqueLayers); child->setMasksToBounds(true); @@ -257,6 +371,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + occlusion.enterTargetRenderSurface(child->renderSurface()); occlusion.markOccludedBehindLayer(layer.get()); @@ -271,6 +388,14 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 430, 61, 70))); EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 71))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(9, 430, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 61, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 71))); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + occlusion.markOccludedBehindLayer(child.get()); occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -283,6 +408,16 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 40, 70, 60))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 40, 70, 60))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 39, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(31, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 41, 70, 60))); + + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 39, 70, 60))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(31, 40, 70, 60))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 41, 70, 60))); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); /* Justification for the above occlusion from |layer|: @@ -311,10 +446,11 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) */ } -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegionWithRotatedSurface, layerAddedToOccludedRegionWithRotatedSurface); + +void layerAddedToOccludedRegionWithSurfaceAlreadyOnStack(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child = LayerChromium::create(); @@ -330,13 +466,13 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack childTransform.rotate(90); childTransform.translate(-250, -250); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child.get(), childTransform, FloatPoint(30, 30), IntSize(500, 500)); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(10, 10), IntSize(500, 500), true, opaqueLayers); // |child2| makes |parent|'s surface get considered by CCOcclusionTracker first, instead of |child|'s. This exercises different code in // leaveToTargetRenderSurface, as the target surface has already been seen. - setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(60, 20), true); + setLayerPropertiesForTesting(child2.get(), identityMatrix, FloatPoint(30, 30), IntSize(60, 20), true, opaqueLayers); child->setMasksToBounds(true); @@ -350,6 +486,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(-10, -10, 1000, 1000)); + occlusion.enterTargetRenderSurface(parent->renderSurface()); occlusion.markOccludedBehindLayer(child2.get()); @@ -372,6 +511,14 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(11, 430, 60, 70))); EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 431, 60, 70))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(9, 430, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(11, 430, 60, 70))); + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 431, 60, 70))); + occlusion.setLayerScissorRect(IntRect(-10, -10, 1000, 1000)); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(10, 430, 60, 70)).isEmpty()); // This is the little piece not occluded by child2 EXPECT_EQ_RECT(IntRect(9, 430, 1, 10), occlusion.unoccludedContentRect(child.get(), IntRect(9, 430, 60, 70))); @@ -387,8 +534,16 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack EXPECT_EQ_RECT(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child.get(), IntRect(11, 430, 60, 70))); EXPECT_EQ_RECT(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child.get(), IntRect(10, 431, 60, 70))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.surfaceUnoccludedContentRect(child.get(), IntRect(10, 430, 60, 70))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(10, 430, 60, 70)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(9, 430, 60, 70)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(9, 430, 60, 80)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(-10, 430, 60, 70)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(-10, 430, 60, 80)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(10, 429, 60, 70)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(11, 430, 60, 70)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(10, 431, 60, 70)).isEmpty()); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); occlusion.markOccludedBehindLayer(child.get()); // |child2| should get merged with the surface we are leaving now @@ -433,10 +588,6 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack EXPECT_EQ_RECT(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 40, 70, 60))); EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 41, 70, 60))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(30, 40, 70, 60))); - - /* Justification for the above occlusion from |layer|: 100 +---------------------+ +---------------------+ @@ -463,9 +614,10 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack */ } -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedOffAxisSurface) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegionWithSurfaceAlreadyOnStack, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack); + +void layerAddedToOccludedRegionWithRotatedOffAxisSurface(bool opaqueLayers) { - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child = LayerChromium::create(); @@ -485,9 +637,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedOffAxisSurface TransformationMatrix layerTransform; layerTransform.translate(10, 10); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child.get(), childTransform, FloatPoint(30, 30), IntSize(500, 500)); + setLayerPropertiesForTesting(layer.get(), layerTransform, FloatPoint(0, 0), IntSize(500, 500), true, opaqueLayers); child->setMasksToBounds(true); @@ -501,6 +653,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedOffAxisSurface CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + IntRect clippedLayerInChild = layerTransform.mapRect(layer->visibleLayerRect()); occlusion.enterTargetRenderSurface(child->renderSurface()); @@ -530,9 +685,6 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedOffAxisSurface EXPECT_FALSE(occlusion.unoccludedContentRect(parent.get(), clippedLayerInChild).isEmpty()); clippedLayerInChild.move(0, -1); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(0, 0, 500, 500), occlusion.surfaceUnoccludedContentRect(child.get(), IntRect(0, 0, 500, 500))); - occlusion.markOccludedBehindLayer(child.get()); occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -544,15 +696,13 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedOffAxisSurface EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(75, 55, 1, 1))); EXPECT_EQ_RECT(IntRect(75, 55, 1, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(75, 55, 1, 1))); - - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(0, 0, 100, 100), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(0, 0, 100, 100))); } -TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegionWithRotatedOffAxisSurface, layerAddedToOccludedRegionWithRotatedOffAxisSurface); + +void layerAddedToOccludedRegionWithMultipleOpaqueLayers(bool opaqueLayers) { // This is similar to the previous test but now we make a few opaque layers inside of |child| so that the occluded parts of child are not a simple rect. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child = LayerChromium::create(); @@ -568,10 +718,10 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) childTransform.rotate(90); childTransform.translate(-250, -250); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 440), true); - setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 450), IntSize(500, 60), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child.get(), childTransform, FloatPoint(30, 30), IntSize(500, 500)); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, FloatPoint(10, 10), IntSize(500, 440), true, opaqueLayers); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, FloatPoint(10, 450), IntSize(500, 60), true, opaqueLayers); child->setMasksToBounds(true); @@ -585,6 +735,9 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + occlusion.enterTargetRenderSurface(child->renderSurface()); occlusion.markOccludedBehindLayer(layer2.get()); occlusion.markOccludedBehindLayer(layer1.get()); @@ -606,9 +759,6 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) EXPECT_EQ_RECT(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child.get(), IntRect(11, 430, 60, 70))); EXPECT_EQ_RECT(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child.get(), IntRect(10, 431, 60, 70))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.surfaceUnoccludedContentRect(child.get(), IntRect(10, 430, 60, 70))); - occlusion.markOccludedBehindLayer(child.get()); occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -628,10 +778,6 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) EXPECT_EQ_RECT(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 40, 70, 60))); EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 41, 70, 60))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(30, 40, 70, 60))); - - /* Justification for the above occlusion from |layer1| and |layer2|: +---------------------+ @@ -658,10 +804,11 @@ TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) */ } -TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerAddedToOccludedRegionWithMultipleOpaqueLayers, layerAddedToOccludedRegionWithMultipleOpaqueLayers); + +void surfaceOcclusionWithOverlappingSiblingSurfaces(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child1 = LayerChromium::create(); @@ -679,11 +826,11 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) childTransform.rotate(90); childTransform.translate(-250, -250); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child1.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), true); - setLayerPropertiesForTesting(child2.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(20, 40), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child1.get(), childTransform, FloatPoint(30, 30), IntSize(500, 500)); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, FloatPoint(0, 0), IntSize(500, 500), true, opaqueLayers); + setLayerPropertiesForTesting(child2.get(), childTransform, FloatPoint(20, 40), IntSize(500, 500)); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, FloatPoint(0, 0), IntSize(500, 500), true, opaqueLayers); child1->setMasksToBounds(true); child2->setMasksToBounds(true); @@ -698,6 +845,9 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(-10, -10, 1000, 1000)); + occlusion.enterTargetRenderSurface(child2->renderSurface()); occlusion.markOccludedBehindLayer(layer2.get()); @@ -712,9 +862,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(0, 420, 61, 80))); EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(0, 420, 60, 81))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(0, 420, 60, 80), occlusion.surfaceUnoccludedContentRect(child2.get(), IntRect(0, 420, 60, 80))); - occlusion.markOccludedBehindLayer(child2.get()); occlusion.finishedTargetRenderSurface(child2.get(), child2->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -732,9 +879,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(0, 430, 71, 70))); EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(0, 430, 70, 71))); - // Surface is not occluded by things that draw into itself, but the |child1| surface should be occluded by the |child2| surface. - EXPECT_EQ_RECT(IntRect(0, 430, 10, 70), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(0, 430, 70, 70))); - occlusion.markOccludedBehindLayer(child1.get()); occlusion.finishedTargetRenderSurface(child1.get(), child1->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -754,10 +898,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(19, 40, 80, 60))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(20, 39, 80, 60))); - // |child1| and |child2| both draw into parent so they should not occlude it. - EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(20, 30, 80, 70))); - - /* Justification for the above occlusion: 100 +---------------------+ @@ -784,10 +924,11 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) */ } -TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_surfaceOcclusionWithOverlappingSiblingSurfaces, surfaceOcclusionWithOverlappingSiblingSurfaces); + +void surfaceOcclusionInScreenSpace(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child1 = LayerChromium::create(); @@ -806,11 +947,11 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) childTransform.translate(-250, -250); // The owning layers have very different bounds from the surfaces that they own. - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child1.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(10, 10), false); - setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -10), IntSize(510, 510), true); - setLayerPropertiesForTesting(child2.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(20, 40), IntSize(10, 10), false); - setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -10), IntSize(510, 510), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child1.get(), childTransform, FloatPoint(30, 30), IntSize(10, 10)); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true, opaqueLayers); + setLayerPropertiesForTesting(child2.get(), childTransform, FloatPoint(20, 40), IntSize(10, 10)); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true, opaqueLayers); // Make them both render surfaces FilterOperations filters; @@ -831,6 +972,9 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(-20, -20, 1000, 1000)); + occlusion.enterTargetRenderSurface(child2->renderSurface()); occlusion.markOccludedBehindLayer(layer2.get()); @@ -845,9 +989,13 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 71, 80))); EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 81))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.surfaceUnoccludedContentRect(child2.get(), IntRect(-10, 420, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child2.get(), IntRect(30, 250, 1, 1))); + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 80))); + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-11, 420, 70, 80))); + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-10, 419, 70, 80))); + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-10, 420, 71, 80))); + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 81))); + occlusion.setLayerScissorRect(IntRect(-20, -20, 1000, 1000)); occlusion.markOccludedBehindLayer(child2.get()); occlusion.finishedTargetRenderSurface(child2.get(), child2->renderSurface()); @@ -866,14 +1014,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-10, 430, 81, 70))); EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-10, 430, 80, 71))); - // Surface is not occluded by things that draw into itself, but the |child1| surface should be occluded by the |child2| surface. - EXPECT_EQ_RECT(IntRect(-10, 430, 10, 80), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(-10, 430, 70, 80))); - EXPECT_TRUE(occlusion.surfaceOccluded(child1.get(), IntRect(0, 430, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(-1, 430, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(0, 429, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(1, 430, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(0, 431, 70, 80))); - occlusion.markOccludedBehindLayer(child1.get()); occlusion.finishedTargetRenderSurface(child1.get(), child1->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -893,11 +1033,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(19, 30, 80, 70))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(20, 29, 80, 70))); - // |child1| and |child2| both draw into parent so they should not occlude it. - EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(20, 20, 80, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(50, 50, 1, 1))); - - /* Justification for the above occlusion: 100 +---------------------+ @@ -923,10 +1058,11 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) */ } -TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_surfaceOcclusionInScreenSpace, surfaceOcclusionInScreenSpace); + +void surfaceOcclusionInScreenSpaceDifferentTransforms(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> child1 = LayerChromium::create(); @@ -950,11 +1086,11 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) child2Transform.translate(-250, -250); // The owning layers have very different bounds from the surfaces that they own. - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child1.get(), child1Transform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 20), IntSize(10, 10), false); - setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -20), IntSize(510, 520), true); - setLayerPropertiesForTesting(child2.get(), child2Transform, identityMatrix, FloatPoint(0, 0), FloatPoint(20, 40), IntSize(10, 10), false); - setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -10), IntSize(510, 510), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(child1.get(), child1Transform, FloatPoint(30, 20), IntSize(10, 10)); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, FloatPoint(-10, -20), IntSize(510, 520), true, opaqueLayers); + setLayerPropertiesForTesting(child2.get(), child2Transform, FloatPoint(20, 40), IntSize(10, 10)); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true, opaqueLayers); // Make them both render surfaces FilterOperations filters; @@ -975,6 +1111,9 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(-30, -30, 1000, 1000)); + occlusion.enterTargetRenderSurface(child2->renderSurface()); occlusion.markOccludedBehindLayer(layer2.get()); @@ -989,10 +1128,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 71, 80))); EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 81))); - // Surface is not occluded by things that draw into itself. - EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.surfaceUnoccludedContentRect(child2.get(), IntRect(-10, 420, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child2.get(), IntRect(30, 250, 1, 1))); - occlusion.markOccludedBehindLayer(child2.get()); occlusion.finishedTargetRenderSurface(child2.get(), child2->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -1010,16 +1145,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(420, -19, 80, 90))); EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(421, -20, 80, 90))); - // Surface is not occluded by things that draw into itself, but the |child1| surface should be occluded by the |child2| surface. - EXPECT_EQ_RECT(IntRect(420, -20, 80, 90), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(420, -20, 80, 90))); - EXPECT_EQ_RECT(IntRect(490, -10, 10, 80), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(420, -10, 80, 80))); - EXPECT_EQ_RECT(IntRect(420, -20, 70, 10), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(420, -20, 70, 90))); - EXPECT_TRUE(occlusion.surfaceOccluded(child1.get(), IntRect(420, -10, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(419, -10, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(420, -11, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(421, -10, 70, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(420, -9, 70, 80))); - occlusion.markOccludedBehindLayer(child1.get()); occlusion.finishedTargetRenderSurface(child1.get(), child1->renderSurface()); occlusion.leaveToTargetRenderSurface(parent->renderSurface()); @@ -1035,14 +1160,6 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(11, 20, 90, 80))); EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(10, 21, 90, 80))); - // |child1| and |child2| both draw into parent so they should not occlude it. - EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(10, 20, 90, 80))); - EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(10, 20, 1, 1))); - EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(99, 20, 1, 1))); - EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(10, 9, 1, 1))); - EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(99, 99, 1, 1))); - - /* Justification for the above occlusion: 100 +---------------------+ @@ -1068,10 +1185,11 @@ TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) */ } -TEST(CCOcclusionTrackerTest, occlusionInteractionWithFilters) +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_surfaceOcclusionInScreenSpaceDifferentTransforms, surfaceOcclusionInScreenSpaceDifferentTransforms); + +void occlusionInteractionWithFilters(bool opaqueLayers) { // This tests that the right transforms are being used. - TestCCOcclusionTracker occlusion; const TransformationMatrix identityMatrix; RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromiumWithForcedDrawsContent> blurLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); @@ -1087,10 +1205,10 @@ TEST(CCOcclusionTrackerTest, occlusionInteractionWithFilters) layerTransform.rotate(90); layerTransform.translate(-250, -250); - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(blurLayer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(opaqueLayer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(opacityLayer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); + setLayerPropertiesForTesting(blurLayer.get(), layerTransform, FloatPoint(30, 30), IntSize(500, 500), true, opaqueLayers); + setLayerPropertiesForTesting(opaqueLayer.get(), layerTransform, FloatPoint(30, 30), IntSize(500, 500), true, opaqueLayers); + setLayerPropertiesForTesting(opacityLayer.get(), layerTransform, FloatPoint(30, 30), IntSize(500, 500), true, opaqueLayers); { FilterOperations filters; @@ -1121,6 +1239,9 @@ TEST(CCOcclusionTrackerTest, occlusionInteractionWithFilters) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + // Opacity layer won't contribute to occlusion. occlusion.enterTargetRenderSurface(opacityLayer->renderSurface()); occlusion.markOccludedBehindLayer(opacityLayer.get()); @@ -1170,4 +1291,922 @@ TEST(CCOcclusionTrackerTest, occlusionInteractionWithFilters) EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); } +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_occlusionInteractionWithFilters, occlusionInteractionWithFilters); + +void layerScissorRectOverTile(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(200, 100, 100, 100)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + + occlusion.useDefaultLayerScissorRect(); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + occlusion.setLayerScissorRect(IntRect(200, 100, 100, 100)); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerScissorRectOverTile, layerScissorRectOverTile); + +void screenScissorRectOverTile(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(200, 100, 100, 100)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + // Occluded since its outside the surface bounds. + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + + // Test without any scissors. + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + occlusion.useDefaultLayerScissorRect(); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_screenScissorRectOverTile, screenScissorRectOverTile); + +void layerScissorRectOverCulledTile(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(100, 100, 100, 100)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300)).isEmpty()); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerScissorRectOverCulledTile, layerScissorRectOverCulledTile); + +void screenScissorRectOverCulledTile(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(100, 100, 100, 100)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300)).isEmpty()); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_screenScissorRectOverCulledTile, screenScissorRectOverCulledTile); + +void layerScissorRectOverPartialTiles(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(50, 50, 200, 200)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300))); + EXPECT_EQ_RECT(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 100))); + EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 100, 300, 100))); + EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(200, 100, 100, 100))); + EXPECT_EQ_RECT(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(100, 200, 100, 100))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerScissorRectOverPartialTiles, layerScissorRectOverPartialTiles); + +void screenScissorRectOverPartialTiles(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(50, 50, 200, 200)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300))); + EXPECT_EQ_RECT(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 100))); + EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 100, 300, 100))); + EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(200, 100, 100, 100))); + EXPECT_EQ_RECT(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(100, 200, 100, 100))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_screenScissorRectOverPartialTiles, screenScissorRectOverPartialTiles); + +void layerScissorRectOverNoTiles(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + occlusion.setLayerScissorRect(IntRect(500, 500, 100, 100)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 100, 300, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(200, 100, 100, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(100, 200, 100, 100)).isEmpty()); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerScissorRectOverNoTiles, layerScissorRectOverNoTiles); + +void screenScissorRectOverNoTiles(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(500, 500, 100, 100)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 100, 300, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(200, 100, 100, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(100, 200, 100, 100)).isEmpty()); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_screenScissorRectOverNoTiles, screenScissorRectOverNoTiles); + +void layerScissorRectForLayerOffOrigin(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(100, 100), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + // This layer is translated when drawn into its target. So if the scissor rect given from the target surface + // is not in that target space, then after translating these query rects into the target, they will fall outside + // the scissor and be considered occluded. + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_layerScissorRectForLayerOffOrigin, layerScissorRectForLayerOffOrigin); + +void damageRectOverTile(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestDamageClient damage(FloatRect(200, 100, 100, 100)); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000), &damage); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + // Outside the layer's clip rect. + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_damageRectOverTile, damageRectOverTile); + +void damageRectOverCulledTile(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestDamageClient damage(FloatRect(100, 100, 100, 100)); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000), &damage); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300)).isEmpty()); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_damageRectOverCulledTile, damageRectOverCulledTile); + +void damageRectOverPartialTiles(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestDamageClient damage(FloatRect(50, 50, 200, 200)); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000), &damage); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300))); + EXPECT_EQ_RECT(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 100))); + EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(0, 100, 300, 100))); + EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent.get(), IntRect(200, 100, 100, 100))); + EXPECT_EQ_RECT(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(100, 200, 100, 100))); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_damageRectOverPartialTiles, damageRectOverPartialTiles); + +void damageRectOverNoTiles(bool opaqueLayers) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> parentLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(parentLayer); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + parentLayer->setFilters(filters); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(parentLayer.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false, opaqueLayers); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true, opaqueLayers); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestDamageClient damage(FloatRect(500, 500, 100, 100)); + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000), &damage); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(parentLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 0, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(0, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(100, 200, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parentLayer.get(), IntRect(200, 200, 100, 100))); + + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 300)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 0, 300, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(0, 100, 300, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(200, 100, 100, 100)).isEmpty()); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(100, 200, 100, 100)).isEmpty()); +} + +TEST_OPAQUE_AND_PAINTED_OPAQUE(CCOcclusionTrackerTest_damageRectOverNoTiles, damageRectOverNoTiles); + +TEST(CCOcclusionTrackerTest, opaqueContentsRegionEmpty) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(layer); + + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + layer->setFilters(filters); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(0, 0), IntSize(200, 200), false, false); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + + occlusion.enterTargetRenderSurface(layer->renderSurface()); + + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 0, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(100, 100, 100, 100))); + + // Occluded since its outside the surface bounds. + EXPECT_TRUE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + + // Test without any scissors. + occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000)); + EXPECT_FALSE(occlusion.occluded(layer.get(), IntRect(200, 100, 100, 100))); + occlusion.useDefaultLayerScissorRect(); + + occlusion.markOccludedBehindLayer(layer.get()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_TRUE(occlusion.occlusionInScreenSpace().bounds().isEmpty()); + EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); +} + +TEST(CCOcclusionTrackerTest, opaqueContentsRegionNonEmpty) +{ + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(layer); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); + setLayerPropertiesForTesting(layer.get(), identityMatrix, FloatPoint(100, 100), IntSize(200, 200), false, false); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + { + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + layer->setOpaquePaintRect(IntRect(0, 0, 100, 100)); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + + EXPECT_EQ_RECT(IntRect(100, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(0, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(200, 200, 100, 100))); + } + + { + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + layer->setOpaquePaintRect(IntRect(20, 20, 180, 180)); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + + EXPECT_EQ_RECT(IntRect(120, 120, 180, 180), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(100, 100, 100, 100))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(200, 200, 100, 100))); + } + + { + TestCCOcclusionTracker occlusion(IntRect(0, 0, 1000, 1000)); + layer->setOpaquePaintRect(IntRect(150, 150, 100, 100)); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + + EXPECT_EQ_RECT(IntRect(250, 250, 50, 50), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(0, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(100, 100, 100, 100))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(200, 200, 100, 100))); + } +} + } // namespace diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp index d49703e14..42776bc94 100644 --- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp +++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp @@ -64,6 +64,7 @@ void setQuads(CCSharedQuadState* rootState, CCSharedQuadState* childState, CCQua #define DECLARE_AND_INITIALIZE_TEST_QUADS \ CCQuadList quadList; \ + CCOverdrawCounts overdraw; \ TransformationMatrix childTransform; \ IntSize rootSize = IntSize(300, 300); \ IntRect rootRect = IntRect(IntPoint(), rootSize); \ @@ -79,8 +80,11 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 9u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 40000, 1); } TEST(CCQuadCullerTest, verifyCullWhenChildOpacityNotOne) @@ -92,8 +96,11 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpacityNotOne) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 13u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 40000, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 0, 1); } TEST(CCQuadCullerTest, verifyCullWhenChildOpaqueFlagFalse) @@ -105,8 +112,11 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpaqueFlagFalse) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 13u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 40000, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 0, 1); } TEST(CCQuadCullerTest, verifyCullCenterTileOnly) @@ -120,7 +130,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 12u); IntRect quadVisibleRect1 = quadList[1].get()->quadVisibleRect(); @@ -137,6 +147,10 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly) IntRect quadVisibleRect6 = quadList[6].get()->quadVisibleRect(); EXPECT_EQ(quadVisibleRect6.height(), 50); EXPECT_EQ(quadVisibleRect6.y(), 250); + + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 100000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 30000, 1); } TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize1) @@ -158,8 +172,12 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize1) quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100)))); EXPECT_EQ(quadList.size(), 2u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 2u); + + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 20363, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 0, 1); } TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize2) @@ -181,8 +199,12 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize2) quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100)))); EXPECT_EQ(quadList.size(), 2u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 2u); + + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 19643, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 0, 1); } TEST(CCQuadCullerTest, verifyCullChildLinesUpBottomRight) @@ -196,8 +218,11 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpBottomRight) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 9u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 40000, 1); } TEST(CCQuadCullerTest, verifyCullSubRegion) @@ -212,8 +237,11 @@ TEST(CCQuadCullerTest, verifyCullSubRegion) setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 12u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 30000, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 10000, 1); } TEST(CCQuadCullerTest, verifyCullSubRegion2) @@ -228,8 +256,11 @@ TEST(CCQuadCullerTest, verifyCullSubRegion2) setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 12u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 25000, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 15000, 1); } TEST(CCQuadCullerTest, verifyCullSubRegionCheckOvercull) @@ -244,7 +275,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegionCheckOvercull) setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 13u); } @@ -260,8 +291,11 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 13u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 130000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 0, 1); } // This test requires some explanation: here we are rotating the quads to be culled. @@ -282,11 +316,14 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw); EXPECT_EQ(quadList.size(), 12u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 120000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 10000, 1); } -TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverTile) +TEST(CCQuadCullerTest, verifyCullOutsideScissorOverTile) { DECLARE_AND_INITIALIZE_TEST_QUADS @@ -295,11 +332,14 @@ TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverTile) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(200, 100, 100, 100)); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(200, 100, 100, 100), &overdraw); EXPECT_EQ(quadList.size(), 1u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 10000, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 120000, 1); } -TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverCulledTile) +TEST(CCQuadCullerTest, verifyCullOutsideScissorOverCulledTile) { DECLARE_AND_INITIALIZE_TEST_QUADS @@ -308,11 +348,11 @@ TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverCulledTile) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(100, 100, 100, 100)); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(100, 100, 100, 100), &overdraw); EXPECT_EQ(quadList.size(), 1u); } -TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverPartialTiles) +TEST(CCQuadCullerTest, verifyCullOutsideScissorOverPartialTiles) { DECLARE_AND_INITIALIZE_TEST_QUADS @@ -321,11 +361,11 @@ TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverPartialTiles) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(50, 50, 200, 200)); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(50, 50, 200, 200), &overdraw); EXPECT_EQ(quadList.size(), 9u); } -TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverNoTiles) +TEST(CCQuadCullerTest, verifyCullOutsideScissorOverNoTiles) { DECLARE_AND_INITIALIZE_TEST_QUADS @@ -334,8 +374,11 @@ TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverNoTiles) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(500, 500, 100, 100)); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(500, 500, 100, 100), &overdraw); EXPECT_EQ(quadList.size(), 0u); + EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1); + EXPECT_NEAR(overdraw.m_pixelsCulled, 130000, 1); } diff --git a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp index c3b366dda..1201587c7 100644 --- a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp +++ b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp @@ -54,7 +54,7 @@ TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) // This will fake that we are on the correct thread for testing purposes. DebugScopedSetImplThread setImplThread; - RefPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0); + OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0); owningLayer->createRenderSurface(); ASSERT_TRUE(owningLayer->renderSurface()); CCRenderSurface* renderSurface = owningLayer->renderSurface(); @@ -74,7 +74,7 @@ TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRect)); EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect)); - RefPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1); + OwnPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1); TransformationMatrix dummyMatrix; dummyMatrix.translate(1.0, 2.0); diff --git a/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp b/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp index 3908f40a9..0853e5a36 100644 --- a/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp +++ b/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp @@ -604,4 +604,178 @@ TEST(CCSchedulerStateMachineTest, TestGoesInvisibleMidCommit) EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); } +TEST(CCSchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) +{ + StateMachine state; + state.setVisible(true); + + state.didLoseContext(); + + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); + state.updateState(state.nextAction()); + + // Once context recreation begins, nothing should happen. + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + + // Recreate the context + state.didRecreateContext(); + + // When the context is recreated, we should begin a commit + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); + state.updateState(state.nextAction()); +} + +TEST(CCSchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhileRecreating) +{ + StateMachine state; + state.setVisible(true); + + state.didLoseContext(); + + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); + state.updateState(state.nextAction()); + + // Once context recreation begins, nothing should happen. + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + + // While context is recreating, commits shouldn't begin. + state.setNeedsCommit(true); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + + // Recreate the context + state.didRecreateContext(); + + // When the context is recreated, we should begin a commit + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); + state.updateState(state.nextAction()); + + // Once the context is recreated, whether we draw should be based on + // setCanDraw. + state.setNeedsRedraw(true); + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction()); + state.setCanDraw(false); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + state.setCanDraw(true); + state.didLeaveVSync(); +} + +TEST(CCSchedulerStateMachineTest, TestContextLostWhileCommitInProgress) +{ + StateMachine state; + state.setVisible(true); + + // Get a commit in flight. + state.setNeedsCommit(true); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); + state.updateState(state.nextAction()); + + // Set damage and expect a draw. + state.setNeedsRedraw(true); + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction()); + state.updateState(state.nextAction()); + state.didLeaveVSync(); + + // Cause a lost context while the begin frame is in flight. + state.didLoseContext(); + + // Ask for another draw. Expect nothing happens. + state.setNeedsRedraw(true); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + + // Finish the frame, update resources, and commit. + state.beginFrameComplete(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); + state.updateState(state.nextAction()); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + state.beginUpdateMoreResourcesComplete(false); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); + state.updateState(state.nextAction()); + + // Expect to be told to begin context recreation, independent of vsync state + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); + state.didLeaveVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); +} + +TEST(CCSchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCommitRequested) +{ + StateMachine state; + state.setVisible(true); + + // Get a commit in flight. + state.setNeedsCommit(true); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); + state.updateState(state.nextAction()); + + // Set damage and expect a draw. + state.setNeedsRedraw(true); + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction()); + state.updateState(state.nextAction()); + state.didLeaveVSync(); + + // Cause a lost context while the begin frame is in flight. + state.didLoseContext(); + + // Ask for another draw and also set needs commit. Expect nothing happens. + // Setting another commit will put us into + // COMMIT_STATE_WAITING_FOR_FIRST_DRAW after we finish the frame on the main + // thread. + state.setNeedsRedraw(true); + state.setNeedsCommit(true); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + + // Finish the frame, update resources, and commit. + state.beginFrameComplete(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); + state.updateState(state.nextAction()); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); + state.beginUpdateMoreResourcesComplete(false); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); + state.updateState(state.nextAction()); + + EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state.commitState()); + + EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction()); + state.updateState(state.nextAction()); + + // Expect to be told to begin context recreation, independent of vsync state + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); + state.didLeaveVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); +} + + +TEST(CCSchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) +{ + StateMachine state; + state.setVisible(true); + + // Cause a lost context lost. + state.didLoseContext(); + + // Ask a forced redraw and verify it ocurrs. + state.setNeedsForcedRedraw(true); + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction()); + state.didLeaveVSync(); + + // Clear the forced redraw bit. + state.setNeedsForcedRedraw(false); + + // Expect to be told to begin context recreation, independent of vsync state + EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); + state.updateState(state.nextAction()); + + // Ask a forced redraw and verify it ocurrs. + state.setNeedsForcedRedraw(true); + state.didEnterVSync(); + EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction()); + state.didLeaveVSync(); +} + } diff --git a/Source/WebKit/chromium/tests/CCSchedulerTest.cpp b/Source/WebKit/chromium/tests/CCSchedulerTest.cpp index 475987f13..45f61b90b 100644 --- a/Source/WebKit/chromium/tests/CCSchedulerTest.cpp +++ b/Source/WebKit/chromium/tests/CCSchedulerTest.cpp @@ -59,6 +59,7 @@ public: virtual void scheduledActionDrawAndSwap() { m_actions.push_back("scheduledActionDrawAndSwap"); } virtual void scheduledActionUpdateMoreResources() { m_actions.push_back("scheduledActionUpdateMoreResources"); } virtual void scheduledActionCommit() { m_actions.push_back("scheduledActionCommit"); } + virtual void scheduledActionBeginContextRecreation() { m_actions.push_back("scheduledActionBeginContextRecreation"); } protected: bool m_hasMoreResourceUpdates; @@ -158,6 +159,7 @@ public: virtual void scheduledActionUpdateMoreResources() { } virtual void scheduledActionCommit() { } + virtual void scheduledActionBeginContextRecreation() { } protected: int m_numDraws; @@ -215,6 +217,7 @@ public: virtual void scheduledActionUpdateMoreResources() { } virtual void scheduledActionCommit() { } + virtual void scheduledActionBeginContextRecreation() { } protected: int m_numDraws; diff --git a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp index 059ef2adc..02dc908ab 100644 --- a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp @@ -46,7 +46,7 @@ TEST(CCSolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) IntSize layerSize = IntSize(800, 600); IntRect visibleLayerRect = IntRect(IntPoint(), layerSize); - RefPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0); + OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0); layer->setVisibleLayerRect(visibleLayerRect); layer->setBounds(layerSize); @@ -66,7 +66,7 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) IntSize layerSize = IntSize(100, 100); IntRect visibleLayerRect = IntRect(IntPoint(), layerSize); - RefPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0); + OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0); layer->setVisibleLayerRect(visibleLayerRect); layer->setBounds(layerSize); layer->setBackgroundColor(testColor); diff --git a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp index d55c0bc16..ff7daa3c9 100644 --- a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp @@ -39,9 +39,9 @@ namespace { // Create a default tiled layer with textures for all tiles and a default // visibility of the entire layer size. -static PassRefPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexels) +static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexels) { - RefPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0); + OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0); OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(tileSize, borderTexels); tiler->setBounds(layerSize); layer->setTilingData(*tiler); @@ -68,7 +68,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) // Verify default layer does creates quads { - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); CCQuadList quads; OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); layer->appendQuads(quads, sharedQuadState.get()); @@ -78,7 +78,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) // Layer with empty visible layer rect produces no quads { - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); layer->setVisibleLayerRect(IntRect()); CCQuadList quads; @@ -89,7 +89,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) // Layer with non-intersecting visible layer rect produces no quads { - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); IntRect outsideBounds(IntPoint(-100, -100), IntSize(50, 50)); layer->setVisibleLayerRect(outsideBounds); @@ -102,7 +102,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList) // Layer with skips draw produces no quads { - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); layer->setSkipsDraw(true); CCQuadList quads; @@ -121,7 +121,7 @@ TEST(CCTiledLayerImplTest, checkerboarding) const int numTilesY = 2; const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY); - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); // No checkerboarding @@ -150,7 +150,7 @@ TEST(CCTiledLayerImplTest, checkerboarding) static PassOwnPtr<CCSharedQuadState> getQuads(CCQuadList& quads, IntSize tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexelOption, const IntRect& visibleLayerRect) { - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexelOption); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexelOption); layer->setVisibleLayerRect(visibleLayerRect); layer->setBounds(layerSize); @@ -260,7 +260,7 @@ TEST(CCTiledLayerImplTest, backgroundCoversViewport) const int numTilesY = 2; const unsigned numTiles = numTilesX * numTilesY; const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY); - RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); + OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels); layer->setBackgroundColor(Color::gray); layer->setBackgroundCoversViewport(true); diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp index ec0ce0c6a..580f15791 100644 --- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp @@ -131,7 +131,7 @@ protected: canvas->setBounds(IntSize(600, 300)); canvas->setTextureId(backTextureId); - canvas->contentChanged(); + canvas->setNeedsDisplay(); EXPECT_TRUE(canvas->needsDisplay()); Region occludedScreenSpace; canvas->paintContentsIfDirty(occludedScreenSpace); @@ -139,7 +139,7 @@ protected: { DebugScopedSetImplThread scopedImplThread; - RefPtr<CCLayerImpl> layerImpl = canvas->createCCLayerImpl(); + OwnPtr<CCLayerImpl> layerImpl = canvas->createCCLayerImpl(); EXPECT_EQ(0u, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId()); canvas->updateCompositorResources(implContext.get(), updater); diff --git a/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h b/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h index 23231038a..38876d737 100755 --- a/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h +++ b/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h @@ -37,12 +37,12 @@ public: virtual void updateAnimations(double frameBeginTime) { } virtual void layout() { } virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { } - virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() + virtual PassRefPtr<GraphicsContext3D> createContext() { GraphicsContext3D::Attributes attrs; return createCompositorMockGraphicsContext3D(attrs); } - virtual void didRecreateGraphicsContext(bool success) { } + virtual void didRecreateContext(bool success) { } virtual void didCommitAndDrawFrame() { } virtual void didCompleteSwapBuffers() { } diff --git a/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h b/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h index ae27da730..268dc1da3 100644 --- a/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h +++ b/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h @@ -35,8 +35,6 @@ namespace WebKit { // All operations are no-ops (returning 0 if necessary). class FakeWebGraphicsContext3D : public WebGraphicsContext3D { public: - virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return false; } - virtual bool makeContextCurrent() { return true; } virtual int width() { return 0; } diff --git a/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp b/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp index adceadf08..d60295a5f 100644 --- a/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp +++ b/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp @@ -95,7 +95,7 @@ void checkKeyPathNumberValue(SerializedScriptValue* value, const String& keyPath TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) { - V8LocalContext v8context; + V8AuxiliaryContext v8context; v8::Local<v8::Object> object = v8::Object::New(); object->Set(v8::String::New("foo"), v8::String::New("zoo")); @@ -107,7 +107,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) { - V8LocalContext v8context; + V8AuxiliaryContext v8context; v8::Local<v8::Object> object = v8::Object::New(); object->Set(v8::String::New("foo"), v8::Number::New(456)); @@ -119,7 +119,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) TEST(IDBKeyFromValueAndKeyPathTest, SubProperty) { - V8LocalContext v8context; + V8AuxiliaryContext v8context; v8::Local<v8::Object> object = v8::Object::New(); v8::Local<v8::Object> subProperty = v8::Object::New(); subProperty->Set(v8::String::New("bar"), v8::String::New("zee")); @@ -133,7 +133,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, SubProperty) TEST(InjectIDBKeyTest, TopLevelPropertyStringValue) { - V8LocalContext v8context; + V8AuxiliaryContext v8context; v8::Local<v8::Object> object = v8::Object::New(); object->Set(v8::String::New("foo"), v8::String::New("zoo")); @@ -145,7 +145,7 @@ TEST(InjectIDBKeyTest, TopLevelPropertyStringValue) TEST(InjectIDBKeyTest, SubProperty) { - V8LocalContext v8context; + V8AuxiliaryContext v8context; v8::Local<v8::Object> object = v8::Object::New(); v8::Local<v8::Object> subProperty = v8::Object::New(); subProperty->Set(v8::String::New("bar"), v8::String::New("zee")); diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp index 2e9ca9661..d8858cc12 100644 --- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp @@ -489,7 +489,6 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXPECT_FALSE(testLayer->needsDisplay()); // Test properties that should not call needsDisplay and needsCommit when changed. - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setName("Test Layer")); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUsesLayerClipping(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true)); @@ -515,10 +514,13 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(Region(IntRect(1, 1, 2, 2)))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer")); // The above tests should not have caused a change to the needsDisplay flag. EXPECT_FALSE(testLayer->needsDisplay()); diff --git a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp new file mode 100644 index 000000000..6203d35d7 --- /dev/null +++ b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LocalizedNumberICU.h" + +#include <gtest/gtest.h> +#include <wtf/PassOwnPtr.h> + +using namespace WebCore; + +void testNumberIsReversible(const char* localeString, const char* original, const char* shouldHave = 0) +{ + OwnPtr<ICULocale> locale = ICULocale::create(localeString); + String localized = locale->convertToLocalizedNumber(original); + if (shouldHave) + EXPECT_TRUE(localized.contains(shouldHave)); + String converted = locale->convertFromLocalizedNumber(localized); + EXPECT_EQ(original, converted); +} + +void testNumbers(const char* localeString) +{ + testNumberIsReversible(localeString, "123456789012345678901234567890"); + testNumberIsReversible(localeString, "-123.456"); + testNumberIsReversible(localeString, ".456"); + testNumberIsReversible(localeString, "-0.456"); +} + +TEST(LocalizedNumberICUTest, Reversible) +{ + testNumberIsReversible("en_US", "123456789012345678901234567890"); + testNumberIsReversible("en_US", "-123.456", "."); + testNumberIsReversible("en_US", ".456", "."); + testNumberIsReversible("en_US", "-0.456", "."); + + testNumberIsReversible("fr", "123456789012345678901234567890"); + testNumberIsReversible("fr", "-123.456", ","); + testNumberIsReversible("fr", ".456", ","); + testNumberIsReversible("fr", "-0.456", ","); + + // Persian locale has a negative prefix and a negative suffix. + testNumbers("fa"); + + // Test some of major locales. + testNumbers("ar"); + testNumbers("de_DE"); + testNumbers("es_ES"); + testNumbers("ja_JP"); + testNumbers("ko_KR"); + testNumbers("zh_CN"); + testNumbers("zh_HK"); + testNumbers("zh_TW"); +} diff --git a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp index d097c499a..b0d86ddf6 100644 --- a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp +++ b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp @@ -641,4 +641,44 @@ TEST(PlatformContextSkiaTest, layerTransformScaleOpaqueTest) EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); } +TEST(PlatformContextSkiaTest, contextTransparencyLayerTest) +{ + SkBitmap bitmap; + bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400); + bitmap.allocPixels(); + bitmap.eraseColor(0); + SkCanvas canvas(bitmap); + AffineTransform transform; + transform.scale(2); + + PlatformContextSkia platformContext(&canvas); + platformContext.setTrackOpaqueRegion(true); + platformContext.setOpaqueRegionTransform(transform); + GraphicsContext context(&platformContext); + + Color opaque(1.0f, 0.0f, 0.0f, 1.0f); + + context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver); + EXPECT_EQ_RECT(IntRect(40, 40, 20, 20), platformContext.opaqueRegion().asRect()); + EXPECT_PIXELS_MATCH(bitmap, transform.inverse().mapRect(platformContext.opaqueRegion().asRect())); + + context.clearRect(FloatRect(20, 20, 10, 10)); + EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); + + context.beginTransparencyLayer(0.5); + context.save(); + context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver); + context.restore(); + context.endTransparencyLayer(); + EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); + + context.clearRect(FloatRect(20, 20, 10, 10)); + EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); + + context.beginTransparencyLayer(0.5); + context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver); + context.endTransparencyLayer(); + EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); +} + } // namespace diff --git a/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp b/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp new file mode 100644 index 000000000..74ca57667 --- /dev/null +++ b/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "PlatformGestureCurve.h" + +#include "ActivePlatformGestureAnimation.h" +#include "PlatformGestureCurveTarget.h" +#include "TouchFlingPlatformGestureCurve.h" +#include "WheelFlingPlatformGestureCurve.h" +#include "cc/CCActiveGestureAnimation.h" +#include "cc/CCGestureCurve.h" +#include <gtest/gtest.h> +#include <wtf/OwnPtr.h> + +namespace { + +using namespace WebCore; + +class MockPlatformGestureCurveTarget : public PlatformGestureCurveTarget { +public: + virtual void setScrollIncrement(const IntPoint& delta) + { + m_cumulativeDelta = m_cumulativeDelta + delta; + } + + IntPoint cumulativeDelta() const { return m_cumulativeDelta; } + void resetCumulativeDelta() { m_cumulativeDelta = IntPoint(); } + +private: + IntPoint m_cumulativeDelta; +}; + +TEST(PlatformGestureCurve, flingCurve) +{ + MockPlatformGestureCurveTarget target; + OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(0, WheelFlingPlatformGestureCurve::create(FloatPoint(100, 0)), &target); + + // Note: the expectations below are dependent on the value of sigma hard-coded in the Rayleigh + // curve. If sigma changes, these test expectations will also change. + EXPECT_TRUE(animation->animate(0)); + EXPECT_TRUE(animation->animate(0.25)); + EXPECT_TRUE(animation->animate(0.45)); // Use non-uniform tick spacing. + EXPECT_TRUE(animation->animate(0.75)); + EXPECT_TRUE(animation->animate(1000)); + EXPECT_FALSE(animation->animate(1001)); + // Since the Rayleigh CDF maxes out at 1, we expect the cumulative scroll increments to + // match the input velocity parameter. + // Since we can be off by +/-0.5 on each conversion to int for setScrollIncrement, + // pick the 'nearness' to be within the number of times animate returns true. + EXPECT_NEAR(target.cumulativeDelta().x(), 100, 1); + EXPECT_EQ(target.cumulativeDelta().y(), 0); + + double baseTime = 42.42; + animation = ActivePlatformGestureAnimation::create(baseTime, WheelFlingPlatformGestureCurve::create(FloatPoint(100, 0)), &target); + target.resetCumulativeDelta(); + + EXPECT_TRUE(animation->animate(baseTime + 0.35)); + EXPECT_TRUE(animation->animate(baseTime + 1.35)); + EXPECT_FALSE(animation->animate(baseTime + 1000)); + EXPECT_NEAR(target.cumulativeDelta().x(), 100, 1); + + animation = ActivePlatformGestureAnimation::create(0, WheelFlingPlatformGestureCurve::create(FloatPoint(50, 150)), &target); + target.resetCumulativeDelta(); + + EXPECT_TRUE(animation->animate(0)); + EXPECT_TRUE(animation->animate(0.25)); + EXPECT_TRUE(animation->animate(0.45)); + EXPECT_TRUE(animation->animate(0.75)); + EXPECT_TRUE(animation->animate(1000)); + EXPECT_FALSE(animation->animate(1001)); + EXPECT_NEAR(target.cumulativeDelta().x(), 50, 1); + EXPECT_NEAR(target.cumulativeDelta().y(), 150, 1); +} + +TEST(PlatformGestureCurve, flingCurveTouch) +{ + MockPlatformGestureCurveTarget target; + OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(0, TouchFlingPlatformGestureCurve::create(FloatPoint(1000, 0)), &target); + + // Note: the expectations below are dependent on the value of sigma hard-coded in the Rayleigh + // curve. If sigma changes, these test expectations will also change. + EXPECT_TRUE(animation->animate(0)); + EXPECT_TRUE(animation->animate(0.25)); + EXPECT_TRUE(animation->animate(0.45)); // Use non-uniform tick spacing. + EXPECT_TRUE(animation->animate(0.75)); + EXPECT_TRUE(animation->animate(0.9)); + EXPECT_TRUE(animation->animate(1000)); + EXPECT_FALSE(animation->animate(1001)); + // Since we can be off by +/-0.5 on each conversion to int for setScrollIncrement, + // pick the 'nearness' to be within the 5 * number of times animate returns true. + EXPECT_NEAR(target.cumulativeDelta().x(), 1000, 1); + EXPECT_EQ(target.cumulativeDelta().y(), 0); +} + +} // namespace anonymous diff --git a/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp b/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp index 85cca9066..9d21b8a9e 100644 --- a/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp +++ b/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp @@ -81,6 +81,9 @@ public: float currentX() { return m_currentPosX; } float currentY() { return m_currentPosY; } + FloatPoint m_fp; + int m_count; + void reset() { stopAnimationTimerIfNeeded(); @@ -88,6 +91,14 @@ public: m_currentPosY = 0; m_horizontalData.reset(); m_verticalData.reset(); + m_fp = FloatPoint::zero(); + m_count = 0; + } + + virtual void fireUpAnAnimation(FloatPoint fp) + { + m_fp = fp; + m_count++; } MOCK_METHOD1(scrollToOffsetWithoutAnimation, void(const FloatPoint&)); @@ -120,6 +131,30 @@ TEST(ScrollAnimatorEnabled, Enabled) scrollAnimatorNone.reset(); } +TEST(ScrollAnimatorEnabled, flingScrollEncoding) +{ + MockScrollableArea scrollableArea(true); + MockScrollAnimatorNone scrollAnimatorNone(&scrollableArea); + + scrollAnimatorNone.reset(); + + scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPixelVelocity, 111, -42); + scrollAnimatorNone.scroll(VerticalScrollbar, ScrollByPixelVelocity, 222, 42); + EXPECT_EQ(-42, scrollAnimatorNone.m_fp.x()); + EXPECT_EQ(42, scrollAnimatorNone.m_fp.y()); + EXPECT_EQ(1, scrollAnimatorNone.m_count); + scrollAnimatorNone.reset(); + + scrollAnimatorNone.scroll(VerticalScrollbar, ScrollByPixelVelocity, 222, 42); + scrollAnimatorNone.scroll(HorizontalScrollbar, ScrollByPixelVelocity, 111, -42); + EXPECT_EQ(-42, scrollAnimatorNone.m_fp.x()); + EXPECT_EQ(42, scrollAnimatorNone.m_fp.y()); + EXPECT_EQ(1, scrollAnimatorNone.m_count); + scrollAnimatorNone.reset(); +} + + + TEST(ScrollAnimatorEnabled, Disabled) { MockScrollableArea scrollableArea(false); @@ -231,7 +266,8 @@ void ScrollAnimatorNoneTest::reset() bool ScrollAnimatorNoneTest::updateDataFromParameters(float step, float multiplier, float scrollableSize, double currentTime, ScrollAnimatorNone::Parameters* parameters) { - m_scrollingDown = (step * multiplier > 0); + if (step * multiplier) + m_scrollingDown = (step * multiplier > 0); double oldVelocity = m_data->m_currentVelocity; double oldDesiredVelocity = m_data->m_desiredVelocity; @@ -249,16 +285,18 @@ bool ScrollAnimatorNoneTest::updateDataFromParameters(float step, float multipli double sustainTimeLeft = max(0., timeLeft - releaseTimeLeft - attackTimeLeft); // If we're getting near the finish, the desired velocity can decrease since the time left gets increased. - double allowedVelocityDecreaseFactor = 0.99 * oldTimeLeft / timeLeft; - allowedVelocityDecreaseFactor *= allowedVelocityDecreaseFactor; - if (m_scrollingDown) - EXPECT_LE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data->m_desiredVelocity); - else - EXPECT_GE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data->m_desiredVelocity); - - double startPosition = attackTimeLeft ? m_data->m_attackPosition : m_currentPosition; - double expectedReleasePosition = startPosition + sustainTimeLeft * m_data->m_desiredVelocity; - EXPECT_NEAR(expectedReleasePosition, m_data->m_releasePosition, result ? .0001 : 1); + if (step * multiplier) { + double allowedVelocityDecreaseFactor = 0.99 * oldTimeLeft / timeLeft; + allowedVelocityDecreaseFactor *= allowedVelocityDecreaseFactor; + if (m_scrollingDown) + EXPECT_LE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data->m_desiredVelocity); + else + EXPECT_GE(oldDesiredVelocity * allowedVelocityDecreaseFactor, m_data->m_desiredVelocity); + + double startPosition = attackTimeLeft ? m_data->m_attackPosition : m_currentPosition; + double expectedReleasePosition = startPosition + sustainTimeLeft * m_data->m_desiredVelocity; + EXPECT_NEAR(expectedReleasePosition, m_data->m_releasePosition, result ? .0001 : 1); + } return result; } @@ -427,7 +465,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollOnceLinear) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Linear, 3 * kTickTime, ScrollAnimatorNone::Linear, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -437,7 +475,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollOnceQuadratic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -447,7 +485,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollLongQuadratic) { ScrollAnimatorNone::Parameters parameters(true, 20 * kTickTime, 0, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -457,7 +495,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollQuadraticNoSustain) { ScrollAnimatorNone::Parameters parameters(true, 8 * kTickTime, 0, ScrollAnimatorNone::Quadratic, 4 * kTickTime, ScrollAnimatorNone::Quadratic, 4 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -467,7 +505,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollQuadraticSmoothed) { ScrollAnimatorNone::Parameters parameters(true, 8 * kTickTime, 8 * kTickTime, ScrollAnimatorNone::Quadratic, 4 * kTickTime, ScrollAnimatorNone::Quadratic, 4 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -477,7 +515,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollOnceCubic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -487,7 +525,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollOnceQuartic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Quartic, 3 * kTickTime, ScrollAnimatorNone::Quartic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kAnimationTime) result = animateScroll(t); @@ -497,7 +535,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollOnceShort) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; for (double t = kStartTime; result && t < kEndTime; t += kTickTime) result = animateScroll(t); @@ -507,7 +545,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollTwiceQuadratic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; double t; for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) @@ -538,7 +576,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollLotsQuadratic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters)); bool result = true; double t; for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) @@ -559,7 +597,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollLotsQuadraticSmoothed) { ScrollAnimatorNone::Parameters parameters(true, 10 * kTickTime, 6 * kTickTime, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Quadratic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters)); bool result = true; double t; for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) @@ -580,7 +618,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollTwiceCubic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); bool result = true; double t; for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) @@ -611,7 +649,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollLotsCubic) { ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters)); bool result = true; double t; for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) @@ -632,7 +670,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollLotsCubicSmoothed) { ScrollAnimatorNone::Parameters parameters(true, 10 * kTickTime, 6 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 40, 10000, kStartTime, ¶meters)); bool result = true; double t; for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) @@ -761,7 +799,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollDownToBumper) { ScrollAnimatorNone::Parameters parameters(true, 10 * kTickTime, 7 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, 20, 200, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 20, 200, kStartTime, ¶meters)); bool result = true; double t = kStartTime; for (int i = 0; i < 10; ++i) { @@ -781,7 +819,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollUpToBumper) { ScrollAnimatorNone::Parameters parameters(true, 10 * kTickTime, 7 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); - updateDataFromParameters(1, -20, 200, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, -20, 200, kStartTime, ¶meters)); bool result = true; double t = kStartTime; for (int i = 0; i < 10; ++i) { @@ -802,7 +840,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollUpToBumperCoast) ScrollAnimatorNone::Parameters parameters(true, 11 * kTickTime, 2 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 1); m_currentPosition = 40000; - updateDataFromParameters(1, -10000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, -10000, 50000, kStartTime, ¶meters)); bool result = true; double t = kStartTime; for (int i = 0; i < 10; ++i) { @@ -823,7 +861,7 @@ TEST_F(ScrollAnimatorNoneTest, ScrollDownToBumperCoast) ScrollAnimatorNone::Parameters parameters(true, 11 * kTickTime, 2 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 1); m_currentPosition = 10000; - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); bool result = true; double t = kStartTime; for (int i = 0; i < 10; ++i) { @@ -844,27 +882,27 @@ TEST_F(ScrollAnimatorNoneTest, VaryingInputsEquivalency) ScrollAnimatorNone::Parameters parameters(true, 15 * kTickTime, 10 * kTickTime, ScrollAnimatorNone::Cubic, 5 * kTickTime, ScrollAnimatorNone::Cubic, 5 * kTickTime, ScrollAnimatorNone::Linear, 0); reset(); - updateDataFromParameters(1, 300, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 300, 50000, kStartTime, ¶meters)); SavePerAxisData dataSingle(*m_data); reset(); - updateDataFromParameters(1, 150, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 150, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 150, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 150, 50000, kStartTime, ¶meters)); SavePerAxisData dataDouble(*m_data); reset(); - updateDataFromParameters(1, 100, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 100, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 100, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 100, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 100, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 100, 50000, kStartTime, ¶meters)); SavePerAxisData dataTriple(*m_data); reset(); - updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 50, 50000, kStartTime, ¶meters)); SavePerAxisData dataMany(*m_data); EXPECT_EQ(dataSingle, dataDouble); @@ -910,27 +948,27 @@ TEST_F(ScrollAnimatorNoneTest, VaryingInputsEquivalencyCoastLarge) ScrollAnimatorNone::Parameters parameters(true, 15 * kTickTime, 10 * kTickTime, ScrollAnimatorNone::Cubic, 5 * kTickTime, ScrollAnimatorNone::Cubic, 5 * kTickTime, ScrollAnimatorNone::Linear, 1); reset(); - updateDataFromParameters(1, 30000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 30000, 50000, kStartTime, ¶meters)); SavePerAxisData dataSingle(*m_data); reset(); - updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters)); SavePerAxisData dataDouble(*m_data); reset(); - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); SavePerAxisData dataTriple(*m_data); reset(); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); SavePerAxisData dataMany(*m_data); EXPECT_EQ(dataSingle, dataDouble); @@ -943,27 +981,27 @@ TEST_F(ScrollAnimatorNoneTest, VaryingInputsEquivalencyCoastSteep) ScrollAnimatorNone::Parameters parameters(true, 15 * kTickTime, 10 * kTickTime, ScrollAnimatorNone::Cubic, 5 * kTickTime, ScrollAnimatorNone::Cubic, 5 * kTickTime, ScrollAnimatorNone::Quadratic, 1); reset(); - updateDataFromParameters(1, 30000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 30000, 50000, kStartTime, ¶meters)); SavePerAxisData dataSingle(*m_data); reset(); - updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 15000, 50000, kStartTime, ¶meters)); SavePerAxisData dataDouble(*m_data); reset(); - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 10000, 50000, kStartTime, ¶meters)); SavePerAxisData dataTriple(*m_data); reset(); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); - updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); + EXPECT_TRUE(updateDataFromParameters(1, 5000, 50000, kStartTime, ¶meters)); SavePerAxisData dataMany(*m_data); EXPECT_EQ(dataSingle, dataDouble); @@ -971,5 +1009,50 @@ TEST_F(ScrollAnimatorNoneTest, VaryingInputsEquivalencyCoastSteep) EXPECT_EQ(dataSingle, dataMany); } +TEST_F(ScrollAnimatorNoneTest, ScrollStopInMiddle) +{ + ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); + + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); + bool result = true; + double t; + for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) + result = animateScroll(t); + + result = result && animateScroll(t); + EXPECT_TRUE(result); + double before = m_currentPosition; + result = result && updateDataFromParameters(0, 0, 1000, t, ¶meters); + EXPECT_FALSE(result); + result = result && animateScroll(t); + double after = m_currentPosition; + EXPECT_EQ(before, after); + checkDesiredPosition(after); +} + +TEST_F(ScrollAnimatorNoneTest, ReverseInMiddle) +{ + ScrollAnimatorNone::Parameters parameters(true, 7 * kTickTime, 0, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Cubic, 3 * kTickTime, ScrollAnimatorNone::Linear, 0); + + EXPECT_TRUE(updateDataFromParameters(1, 40, 1000, kStartTime, ¶meters)); + bool result = true; + double t; + for (t = kStartTime; result && t < kStartTime + 1.5 * kTickTime; t += kAnimationTime) + result = animateScroll(t); + + result = result && animateScroll(t); + EXPECT_TRUE(result); + double before = m_currentPosition; + result = result && updateDataFromParameters(1, -10, 1000, t, ¶meters); + EXPECT_TRUE(result); + result = result && animateScroll(t); + double after = m_currentPosition; + EXPECT_GE(before, after); + + t += kAnimationTime; + for (; result && t < kEndTime; t += kAnimationTime) + result = result && animateScroll(t); + EXPECT_GE(before, m_currentPosition); +} #endif // ENABLE(SMOOTH_SCROLLING) diff --git a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp new file mode 100644 index 000000000..78b96b495 --- /dev/null +++ b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "ScrollbarLayerChromium.h" + +#include "Scrollbar.h" +#include "TreeSynchronizer.h" +#include "cc/CCScrollbarLayerImpl.h" +#include "cc/CCSingleThreadProxy.h" +#include <gtest/gtest.h> + +using namespace WebCore; + +namespace { + +class MockScrollbar : public Scrollbar { +public: + virtual int x() const { return 0; } + virtual int y() const { return 0; } + virtual int width() const { return 0; } + virtual int height() const { return 0; } + virtual IntSize size() const { return IntSize(); } + virtual IntPoint location() const { return IntPoint(); } + + virtual ScrollView* parent() const { return 0; } + virtual ScrollView* root() const { return 0; } + + virtual void setFrameRect(const IntRect&) { } + virtual IntRect frameRect() const { return IntRect(); } + + virtual void invalidate() { } + virtual void invalidateRect(const IntRect&) { } + + virtual ScrollbarOverlayStyle scrollbarOverlayStyle() const { return ScrollbarOverlayStyleDefault; } + virtual void getTickmarks(Vector<IntRect>&) const { } + virtual bool isScrollableAreaActive() const { return false; } + virtual bool isScrollViewScrollbar() const { return false; } + + virtual IntPoint convertFromContainingWindow(const IntPoint& windowPoint) { return IntPoint(); } + + virtual bool isCustomScrollbar() const { return false; } + virtual ScrollbarOrientation orientation() const { return HorizontalScrollbar; } + + virtual int value() const { return 0; } + virtual float currentPos() const { return 0; } + virtual int visibleSize() const { return 1; } + virtual int totalSize() const { return 1; } + virtual int maximum() const { return 0; } + virtual ScrollbarControlSize controlSize() const { return RegularScrollbar; } + + virtual int lineStep() const { return 0; } + virtual int pageStep() const { return 0; } + + virtual ScrollbarPart pressedPart() const { return NoPart; } + virtual ScrollbarPart hoveredPart() const { return NoPart; } + + virtual void styleChanged() { } + + virtual bool enabled() const { return false; } + virtual void setEnabled(bool) { } + + MockScrollbar() : Scrollbar(0, HorizontalScrollbar, RegularScrollbar) { } + virtual ~MockScrollbar() { } +}; + +TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer) +{ + DebugScopedSetImplThread impl; + + { + RefPtr<MockScrollbar> scrollbar = adoptRef(new MockScrollbar); + RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create(); + RefPtr<LayerChromium> child1 = LayerChromium::create(); + RefPtr<LayerChromium> child2 = ScrollbarLayerChromium::create(scrollbar.get(), child1->id()); + layerTreeRoot->addChild(child1); + layerTreeRoot->addChild(child2); + + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); + + CCLayerImpl* ccChild1 = ccLayerTreeRoot->children()[0].get(); + CCScrollbarLayerImpl* ccChild2 = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[1].get()); + + EXPECT_EQ(ccChild1, ccChild2->scrollLayer()); + } + + { // another traverse order + RefPtr<MockScrollbar> scrollbar = adoptRef(new MockScrollbar); + RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create(); + RefPtr<LayerChromium> child2 = LayerChromium::create(); + RefPtr<LayerChromium> child1 = ScrollbarLayerChromium::create(scrollbar.get(), child2->id()); + layerTreeRoot->addChild(child1); + layerTreeRoot->addChild(child2); + + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); + + CCScrollbarLayerImpl* ccChild1 = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[0].get()); + CCLayerImpl* ccChild2 = ccLayerTreeRoot->children()[1].get(); + + EXPECT_EQ(ccChild1->scrollLayer(), ccChild2); + } +} + +} diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp index e03559046..2523230e0 100644 --- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp @@ -68,6 +68,7 @@ public: virtual ~Texture() { } virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { m_layer->updateRect(); } + virtual void prepareRect(const IntRect&) { m_layer->prepareRect(); } private: FakeLayerTextureUpdater* m_layer; @@ -76,6 +77,7 @@ public: FakeLayerTextureUpdater() : m_prepareCount(0) , m_updateCount(0) + , m_prepareRectCount(0) { } virtual ~FakeLayerTextureUpdater() { } @@ -93,6 +95,11 @@ public: void clearUpdateCount() { m_updateCount = 0; } void updateRect() { m_updateCount++; } + // Number of times prepareRect() has been invoked on a texture. + int prepareRectCount() const { return m_prepareRectCount; } + void clearPrepareRectCount() { m_prepareRectCount = 0; } + void prepareRect() { m_prepareRectCount++; } + void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; } // Last rect passed to prepareToUpdate(). @@ -105,6 +112,7 @@ public: private: int m_prepareCount; int m_updateCount; + int m_prepareRectCount; IntRect m_rectToInvalidate; IntRect m_lastUpdateRect; IntRect m_opaquePaintRect; @@ -142,14 +150,14 @@ public: TiledLayerChromium::invalidateRect(rect); } - void prepareToUpdate(const IntRect& rect) + void prepareToUpdate(const IntRect& rect, const Region& occluded) { - TiledLayerChromium::prepareToUpdate(rect); + TiledLayerChromium::prepareToUpdate(rect, occluded); } - void prepareToUpdateIdle(const IntRect& rect) + void prepareToUpdateIdle(const IntRect& rect, const Region& occluded) { - TiledLayerChromium::prepareToUpdateIdle(rect); + TiledLayerChromium::prepareToUpdateIdle(rect, occluded); } bool needsIdlePaint(const IntRect& rect) @@ -174,9 +182,9 @@ public: virtual TextureManager* textureManager() const { return m_textureManager; } - virtual void paintContentsIfDirty(const Region& /* occludedScreenSpace */) + virtual void paintContentsIfDirty(const Region& occludedScreenSpace) { - prepareToUpdate(visibleLayerRect()); + prepareToUpdate(visibleLayerRect(), occludedScreenSpace); } private: @@ -231,7 +239,8 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles) OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; - RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); + Region noOcclusion; FakeTextureAllocator textureAllocator; CCTextureUpdater updater(&textureAllocator); @@ -239,7 +248,7 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles) // The tile size is 100x100, so this invalidates and then paints two tiles. layer->setBounds(IntSize(100, 200)); layer->invalidateRect(IntRect(0, 0, 100, 200)); - layer->prepareToUpdate(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); @@ -252,7 +261,7 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles) // Invalidates both tiles... layer->invalidateRect(IntRect(0, 0, 100, 200)); // ....but then only update one of them. - layer->prepareToUpdate(IntRect(0, 0, 100, 100)); + layer->prepareToUpdate(IntRect(0, 0, 100, 100), noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); @@ -261,12 +270,49 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles) EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); } +TEST(TiledLayerChromiumTest, pushOccludedDirtyTiles) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + DebugScopedSetImplThread implThread; + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); + Region noOcclusion; + + FakeTextureAllocator textureAllocator; + CCTextureUpdater updater(&textureAllocator); + + // The tile size is 100x100, so this invalidates and then paints two tiles. + layer->setBounds(IntSize(100, 200)); + layer->invalidateRect(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); + layer->updateCompositorResources(0, updater); + layer->pushPropertiesTo(layerImpl.get()); + + // We should have both tiles on the impl side. + EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); + EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); + + textureManager->unprotectAllTextures(); + + // Invalidates part of the top tile... + layer->invalidateRect(IntRect(0, 0, 50, 50)); + // ....but the area is occluded. + Region occlusion(IntRect(0, 0, 50, 50)); + layer->prepareToUpdate(IntRect(0, 0, 100, 100), occlusion); + layer->updateCompositorResources(0, updater); + layer->pushPropertiesTo(layerImpl.get()); + + // We should still have both tiles, as part of the top tile is still unoccluded. + EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); + EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); +} + TEST(TiledLayerChromiumTest, pushIdlePaintTiles) { OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; - RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); FakeTextureAllocator textureAllocator; CCTextureUpdater updater(&textureAllocator); @@ -275,12 +321,13 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles) IntSize contentBounds(500, 500); IntRect contentRect(IntPoint::zero(), contentBounds); IntRect visibleRect(200, 200, 100, 100); + Region noOcclusion; // This invalidates 25 tiles and then paints one visible tile. layer->setBounds(contentBounds); layer->setVisibleLayerRect(visibleRect); layer->invalidateRect(contentRect); - layer->prepareToUpdate(visibleRect); + layer->prepareToUpdate(visibleRect, noOcclusion); // We should need idle-painting for 3x3 tiles in the center. EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); @@ -295,9 +342,9 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles) // For the next four updates, we should detect we still need idle painting. for (int i = 0; i < 4; i++) { - layer->prepareToUpdate(visibleRect); + layer->prepareToUpdate(visibleRect, noOcclusion); EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); - layer->prepareToUpdateIdle(visibleRect); + layer->prepareToUpdateIdle(visibleRect, noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); textureManager->unprotectAllTextures(); @@ -318,6 +365,105 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles) } } +TEST(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + DebugScopedSetImplThread implThread; + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); + + FakeTextureAllocator textureAllocator; + CCTextureUpdater updater(&textureAllocator); + Region noOcclusion; + + // The tile size is 100x100, so this invalidates and then paints two tiles. + // However, during the paint, we invalidate one of the tiles. This should + // not prevent the tile from being pushed. + layer->setBounds(IntSize(100, 200)); + layer->invalidateRect(IntRect(0, 0, 100, 200)); + layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer.get()); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); + layer->updateCompositorResources(0, updater); + layer->pushPropertiesTo(layerImpl.get()); + + // We should have both tiles on the impl side. + EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); + EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); +} + +TEST(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + DebugScopedSetImplThread implThread; + OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0))); + OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0))); + + FakeTextureAllocator textureAllocator; + CCTextureUpdater updater(&textureAllocator); + Region noOcclusion; + + layer1->setBounds(IntSize(100, 200)); + layer1->invalidateRect(IntRect(0, 0, 100, 200)); + layer2->setBounds(IntSize(100, 200)); + layer2->invalidateRect(IntRect(0, 0, 100, 200)); + + layer1->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); + + // Invalidate a tile on layer1 + layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get()); + layer2->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); + + layer1->updateCompositorResources(0, updater); + layer2->updateCompositorResources(0, updater); + + layer1->pushPropertiesTo(layer1Impl.get()); + layer2->pushPropertiesTo(layer2Impl.get()); + + // We should have both tiles on the impl side for all layers. + EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); + EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); + EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); + EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); +} + +TEST(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + DebugScopedSetImplThread implThread; + OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0))); + OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0))); + + FakeTextureAllocator textureAllocator; + CCTextureUpdater updater(&textureAllocator); + Region noOcclusion; + + layer1->setBounds(IntSize(100, 200)); + layer1->invalidateRect(IntRect(0, 0, 100, 200)); + layer2->setBounds(IntSize(100, 200)); + layer2->invalidateRect(IntRect(0, 0, 100, 200)); + + // Invalidate a tile on layer2 + layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get()); + layer1->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); + + layer2->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); + + layer1->updateCompositorResources(0, updater); + layer2->updateCompositorResources(0, updater); + + layer1->pushPropertiesTo(layer1Impl.get()); + layer2->pushPropertiesTo(layer2Impl.get()); + + // We should have both tiles on the impl side for all layers. + EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); + EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); + EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); + EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); +} TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) { @@ -325,6 +471,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) IntSize contentBounds(300, 300); IntRect contentRect(IntPoint::zero(), contentBounds); IntRect visibleRect(100, 100, 100, 100); + Region noOcclusion; // We have enough memory for only the visible rect, so we will run out of memory in first idle paint. int memoryLimit = 4 * 100 * 100; // 2 tiles, 4 bytes per pixel. @@ -332,7 +479,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) OwnPtr<TextureManager> textureManager = TextureManager::create(memoryLimit, memoryLimit / 2, 1024); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; - RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); FakeTextureAllocator textureAllocator; CCTextureUpdater updater(&textureAllocator); @@ -341,7 +488,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) layer->setBounds(contentBounds); layer->setVisibleLayerRect(visibleRect); layer->invalidateRect(contentRect); - layer->prepareToUpdate(visibleRect); + layer->prepareToUpdate(visibleRect, noOcclusion); // We should need idle-painting for 3x3 tiles surounding visible tile. EXPECT_TRUE(layer->needsIdlePaint(visibleRect)); @@ -353,8 +500,8 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); textureManager->unprotectAllTextures(); - layer->prepareToUpdate(visibleRect); - layer->prepareToUpdateIdle(visibleRect); + layer->prepareToUpdate(visibleRect, noOcclusion); + layer->prepareToUpdateIdle(visibleRect, noOcclusion); // We shouldn't signal we need another idle paint after we run out of memory. EXPECT_FALSE(layer->needsIdlePaint(visibleRect)); @@ -368,7 +515,8 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare) OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; - RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); + Region noOcclusion; FakeTextureAllocator textureAllocator; CCTextureUpdater updater(&textureAllocator); @@ -376,7 +524,7 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare) // The tile size is 100x100, so this invalidates and then paints two tiles. layer->setBounds(IntSize(100, 200)); layer->invalidateRect(IntRect(0, 0, 100, 200)); - layer->prepareToUpdate(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); @@ -389,18 +537,18 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare) layer->fakeLayerTextureUpdater()->clearPrepareCount(); // Invoke prepareToUpdate again. As the layer is valid prepareToUpdate shouldn't be invoked on // the LayerTextureUpdater. - layer->prepareToUpdate(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount()); layer->invalidateRect(IntRect(0, 0, 50, 50)); // setRectToInvalidate triggers invalidateRect() being invoked from prepareToUpdate. layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get()); layer->fakeLayerTextureUpdater()->clearPrepareCount(); - layer->prepareToUpdate(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); layer->fakeLayerTextureUpdater()->clearPrepareCount(); // The layer should still be invalid as prepareToUpdate invoked invalidate. - layer->prepareToUpdate(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), noOcclusion); EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); } @@ -411,6 +559,7 @@ TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(textureManager.get())); + Region noOcclusion; FakeTextureAllocator textureAllocator; CCTextureUpdater updater(&textureAllocator); @@ -425,20 +574,20 @@ TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) // On first update, the updateRect includes all tiles, even beyond the boundaries of the layer. // However, it should still be in layer space, not content space. layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); + layer->prepareToUpdate(contentBounds, noOcclusion); layer->updateCompositorResources(0, updater); EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect()); // After the tiles are updated once, another invalidate only needs to update the bounds of the layer. layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); + layer->prepareToUpdate(contentBounds, noOcclusion); layer->updateCompositorResources(0, updater); EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect()); // Partial re-paint should also be represented by the updateRect in layer space, not content space. IntRect partialDamage(30, 100, 10, 10); layer->invalidateRect(partialDamage); - layer->prepareToUpdate(contentBounds); + layer->prepareToUpdate(contentBounds, noOcclusion); layer->updateCompositorResources(0, updater); EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); } @@ -448,10 +597,11 @@ TEST(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); DebugScopedSetImplThread implThread; - RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); + OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); FakeTextureAllocator textureAllocator; CCTextureUpdater updater(&textureAllocator); + Region noOcclusion; // Create a layer with one tile. layer->setBounds(IntSize(100, 100)); @@ -461,7 +611,7 @@ TEST(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect()); // Push the tiles to the impl side and check that there is exactly one. - layer->prepareToUpdate(IntRect(0, 0, 100, 100)); + layer->prepareToUpdate(IntRect(0, 0, 100, 100), noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); @@ -475,7 +625,7 @@ TEST(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect()); // The impl side should get 2x2 tiles now. - layer->prepareToUpdate(IntRect(0, 0, 200, 200)); + layer->prepareToUpdate(IntRect(0, 0, 200, 200), noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); @@ -486,6 +636,7 @@ TEST(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the // impl side. layer->setNeedsDisplay(); + layer->prepareToUpdate(IntRect(0, 0, 0, 0), noOcclusion); layer->updateCompositorResources(0, updater); layer->pushPropertiesTo(layerImpl.get()); EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); @@ -547,132 +698,15 @@ TEST(TiledLayerChromiumTest, skipsDrawGetsReset) WebKit::WebCompositor::shutdown(); } -TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) -{ - OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); - RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); - - // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. - - Region occluded; - IntRect contentBounds = IntRect(0, 0, 100, 200); - IntRect visibleBounds = IntRect(0, 0, 100, 150); - - layer->setBounds(contentBounds.size()); - layer->setVisibleLayerRect(visibleBounds); - layer->setDrawOpacity(1); - - // The screenSpaceTransform is verified in CCLayerTreeHostCommonTests - TransformationMatrix screenSpaceTransform; - layer->setScreenSpaceTransform(screenSpaceTransform); - - // If the layer is opaque then the occluded region should be the whole layer's visible region. - layer->setOpaque(true); - layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(visibleBounds, occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If the layer is not opaque then the occluded region should be empty. - layer->setOpaque(false); - layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(), occluded.bounds()); - EXPECT_EQ(0u, occluded.rects().size()); - - // If the layer paints opaque content, then the occluded region should match the visible opaque content. - IntRect opaquePaintRect = IntRect(10, 10, 90, 190); - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); - layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If we paint again without invalidating, the same stuff should be occluded. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If we repaint a non-opaque part of the tile, then it shouldn't lose its opaque-ness. And other tiles should - // not be affected. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); - layer->invalidateRect(IntRect(0, 0, 1, 1)); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If we repaint an opaque part of the tile, then it should lose its opaque-ness. But other tiles should still - // not be affected. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); - layer->invalidateRect(IntRect(10, 10, 1, 1)); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If the layer is transformed then the resulting occluded area needs to be transformed to its target space. - TransformationMatrix transform; - transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - transform.rotate(90); - transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - transform.translate(10, 10); - screenSpaceTransform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - screenSpaceTransform *= transform; - screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - layer->setScreenSpaceTransform(screenSpaceTransform); - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); - layer->invalidateRect(opaquePaintRect); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(screenSpaceTransform.mapRect(intersection(opaquePaintRect, visibleBounds)), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // But a non-axis-aligned transform does not get considered for occlusion. - transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - transform.rotate(5); - transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - screenSpaceTransform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - screenSpaceTransform *= transform; - screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - layer->setScreenSpaceTransform(screenSpaceTransform); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - // FIXME: If we find an opaque rect contained in the rotated non-axis-aligned rect, then - // this won't be an empty result. - EXPECT_EQ_RECT(IntRect(), occluded.bounds()); - EXPECT_EQ(0u, occluded.rects().size()); -} - TEST(TiledLayerChromiumTest, resizeToSmaller) { OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024, 60*1024*1024, 1024); RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region noOcclusion; layer->setBounds(IntSize(700, 700)); layer->invalidateRect(IntRect(0, 0, 700, 700)); - layer->prepareToUpdate(IntRect(0, 0, 700, 700)); + layer->prepareToUpdate(IntRect(0, 0, 700, 700), noOcclusion); layer->setBounds(IntSize(200, 200)); layer->invalidateRect(IntRect(0, 0, 200, 200)); @@ -749,4 +783,238 @@ TEST(TiledLayerChromiumTest, partialUpdates) WebKit::WebCompositor::shutdown(); } +TEST(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region occluded; + + // The tile size is 100x100, so this invalidates and then paints two tiles. + layer->setBounds(IntSize(100, 200)); + + layer->invalidateRect(IntRect(0, 0, 100, 200)); + layer->prepareToUpdate(IntRect(0, 0, 100, 200), occluded); + EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->prepareRectCount()); +} + +TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusion) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region occluded; + + // The tile size is 100x100. + + layer->setBounds(IntSize(600, 600)); + + occluded = IntRect(200, 200, 300, 100); + layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds())); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + occluded = IntRect(250, 200, 300, 100); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + occluded = IntRect(250, 250, 300, 100); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->prepareRectCount()); +} + +TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region occluded; + + // The tile size is 100x100. + + layer->setBounds(IntSize(600, 600)); + + // The partially occluded tiles (by the 150 occlusion height) are visible beyond the occlusion, so not culled. + occluded = IntRect(200, 200, 300, 150); + layer->setVisibleLayerRect(IntRect(0, 0, 600, 360)); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + // Now the visible region stops at the edge of the occlusion so the partly visible tiles become fully occluded. + occluded = IntRect(200, 200, 300, 150); + layer->setVisibleLayerRect(IntRect(0, 0, 600, 350)); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + // Now the visible region is even smaller than the occlusion, it should have the same result. + occluded = IntRect(200, 200, 300, 150); + layer->setVisibleLayerRect(IntRect(0, 0, 600, 340)); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); +} + +TEST(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region occluded; + + // The tile size is 100x100. + + layer->setBounds(IntSize(600, 600)); + + occluded = IntRect(200, 200, 300, 100); + layer->setVisibleLayerRect(IntRect(0, 0, 600, 600)); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + // Repaint without marking it dirty. + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareRectCount()); +} + +TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region occluded; + + // The tile size is 100x100. + + // This makes sure the painting works when the occluded region (in screen space) + // is transformed differently than the layer. + layer->setBounds(IntSize(600, 600)); + TransformationMatrix screenTransform; + screenTransform.scale(0.5); + layer->setScreenSpaceTransform(screenTransform); + + occluded = IntRect(100, 100, 150, 50); + layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds())); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); +} + +TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + Region occluded; + + // The tile size is 100x100. + + // This makes sure the painting works when the content space is scaled to + // a different layer space. In this case tiles are scaled to be 200x200 + // pixels, which means none should be occluded. + layer->setContentsScale(0.5); + layer->setBounds(IntSize(600, 600)); + + occluded = IntRect(200, 200, 300, 100); + layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds())); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + // The content is half the size of the layer (so the number of tiles is fewer). + // In this case, the content is 300x300, and since the tile size is 100, the + // number of tiles 3x3. + EXPECT_EQ(9, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + // This makes sure the painting works when the content space is scaled to + // a different layer space. In this case the occluded region catches the + // blown up tiles. + occluded = IntRect(200, 200, 300, 200); + layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds())); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); + + layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); + + // This makes sure content scaling and transforms work together. + TransformationMatrix screenTransform; + screenTransform.scale(0.5); + layer->setScreenSpaceTransform(screenTransform); + + occluded = IntRect(100, 100, 150, 100); + layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds())); + layer->invalidateRect(IntRect(0, 0, 600, 600)); + layer->prepareToUpdate(IntRect(0, 0, 600, 600), occluded); + EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); +} + +TEST(TiledLayerChromiumTest, opaqueContentsRegion) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + + // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. + + IntRect opaquePaintRect; + Region opaqueContents; + Region noOcclusion; + + IntRect contentBounds = IntRect(0, 0, 100, 200); + IntRect visibleBounds = IntRect(0, 0, 100, 150); + + layer->setBounds(contentBounds.size()); + layer->setVisibleLayerRect(visibleBounds); + layer->setDrawOpacity(1); + + // If the layer doesn't paint opaque content, then the opaqueContentsRegion should be empty. + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); + layer->invalidateRect(contentBounds); + layer->prepareToUpdate(contentBounds, noOcclusion); + opaqueContents = layer->opaqueContentsRegion(); + EXPECT_TRUE(opaqueContents.isEmpty()); + + // opaqueContentsRegion should match the visible part of what is painted opaque. + opaquePaintRect = IntRect(10, 10, 90, 190); + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); + layer->invalidateRect(contentBounds); + layer->prepareToUpdate(contentBounds, noOcclusion); + opaqueContents = layer->opaqueContentsRegion(); + EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); + EXPECT_EQ(1u, opaqueContents.rects().size()); + + // If we paint again without invalidating, the same stuff should be opaque. + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->prepareToUpdate(contentBounds, noOcclusion); + opaqueContents = layer->opaqueContentsRegion(); + EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); + EXPECT_EQ(1u, opaqueContents.rects().size()); + + // If we repaint a non-opaque part of the tile, then it shouldn't lose its opaque-ness. And other tiles should + // not be affected. + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->invalidateRect(IntRect(0, 0, 1, 1)); + layer->prepareToUpdate(contentBounds, noOcclusion); + opaqueContents = layer->opaqueContentsRegion(); + EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); + EXPECT_EQ(1u, opaqueContents.rects().size()); + + // If we repaint an opaque part of the tile, then it should lose its opaque-ness. But other tiles should still + // not be affected. + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->invalidateRect(IntRect(10, 10, 1, 1)); + layer->prepareToUpdate(contentBounds, noOcclusion); + opaqueContents = layer->opaqueContentsRegion(); + EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds()); + EXPECT_EQ(1u, opaqueContents.rects().size()); +} + } // namespace diff --git a/Source/WebKit/chromium/tests/TransparencyWinTest.cpp b/Source/WebKit/chromium/tests/TransparencyWinTest.cpp index 54898ca8a..5052bb166 100644 --- a/Source/WebKit/chromium/tests/TransparencyWinTest.cpp +++ b/Source/WebKit/chromium/tests/TransparencyWinTest.cpp @@ -100,7 +100,7 @@ static std::ostream& operator<<(std::ostream& out, const Color& c) TEST(TransparencyWin, NoLayer) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(17, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(17, 16), 1, ColorSpaceDeviceRGB)); // KeepTransform { @@ -139,7 +139,7 @@ TEST(TransparencyWin, NoLayer) TEST(TransparencyWin, WhiteLayer) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); // KeepTransform { @@ -191,7 +191,7 @@ TEST(TransparencyWin, WhiteLayer) TEST(TransparencyWin, TextComposite) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); // KeepTransform is the only valid transform mode for TextComposite. { @@ -210,7 +210,7 @@ TEST(TransparencyWin, TextComposite) TEST(TransparencyWin, OpaqueCompositeLayer) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); // KeepTransform { @@ -280,7 +280,7 @@ TEST(TransparencyWin, OpaqueCompositeLayer) TEST(TransparencyWin, WhiteLayerPixelTest) { // Make a total transparent buffer, and draw the white layer inset by 1 px. - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); { TransparencyWin helper; @@ -309,7 +309,7 @@ TEST(TransparencyWin, OpaqueCompositeLayerPixel) Color green(0xFF00FF00); // Make a red bottom layer, followed by a half green next layer @ 50%. - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); FloatRect fullRect(0, 0, 16, 16); src->context()->fillRect(fullRect, red, ColorSpaceDeviceRGB); @@ -362,7 +362,7 @@ TEST(TransparencyWin, OpaqueCompositeLayerPixel) TEST(TransparencyWin, TranslateOpaqueCompositeLayer) { // Fill with white. - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); Color white(0xFFFFFFFF); FloatRect fullRect(0, 0, 16, 16); src->context()->fillRect(fullRect, white, ColorSpaceDeviceRGB); @@ -399,7 +399,7 @@ TEST(TransparencyWin, TranslateOpaqueCompositeLayer) // tests that the propert transform is applied to the copied layer. TEST(TransparencyWin, RotateOpaqueCompositeLayer) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); // The background is white. Color white(0xFFFFFFFF); @@ -478,7 +478,7 @@ TEST(TransparencyWin, RotateOpaqueCompositeLayer) TEST(TransparencyWin, DISABLED_TranslateScaleOpaqueCompositeLayer) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); // The background is white on top with red on bottom. Color white(0xFFFFFFFF); @@ -526,7 +526,7 @@ TEST(TransparencyWin, DISABLED_TranslateScaleOpaqueCompositeLayer) TEST(TransparencyWin, Scale) { // Create an opaque white buffer. - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); FloatRect fullBuffer(0, 0, 16, 16); src->context()->fillRect(fullBuffer, Color::white, ColorSpaceDeviceRGB); @@ -579,7 +579,7 @@ TEST(TransparencyWin, Scale) TEST(TransparencyWin, ScaleTransparency) { // Create an opaque white buffer. - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); FloatRect fullBuffer(0, 0, 16, 16); src->context()->fillRect(fullBuffer, Color::white, ColorSpaceDeviceRGB); @@ -637,7 +637,7 @@ TEST(TransparencyWin, ScaleTransparency) TEST(TransparencyWin, Text) { - OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), ColorSpaceDeviceRGB)); + OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB)); // Our text should end up 50% transparent blue-green. Color fullResult(0x80008080); diff --git a/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp b/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp index 4724b4a43..eb3850dab 100644 --- a/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp +++ b/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp @@ -41,9 +41,9 @@ namespace { class MockCCLayerImpl : public CCLayerImpl { public: - static PassRefPtr<MockCCLayerImpl> create(int layerId) + static PassOwnPtr<MockCCLayerImpl> create(int layerId) { - return adoptRef(new MockCCLayerImpl(layerId)); + return adoptPtr(new MockCCLayerImpl(layerId)); } virtual ~MockCCLayerImpl() { @@ -72,7 +72,7 @@ public: virtual ~MockLayerChromium() { } - virtual PassRefPtr<CCLayerImpl> createCCLayerImpl() + virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl() { return MockCCLayerImpl::create(m_layerId); } @@ -134,7 +134,7 @@ void expectTreesAreIdentical(LayerChromium* layer, CCLayerImpl* ccLayer) expectTreesAreIdentical(layer->replicaLayer(), ccLayer->replicaLayer()); const Vector<RefPtr<LayerChromium> >& layerChildren = layer->children(); - const Vector<RefPtr<CCLayerImpl> >& ccLayerChildren = ccLayer->children(); + const Vector<OwnPtr<CCLayerImpl> >& ccLayerChildren = ccLayer->children(); ASSERT_EQ(layerChildren.size(), ccLayerChildren.size()); @@ -150,7 +150,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty) layerTreeRoot->addChild(LayerChromium::create()); layerTreeRoot->addChild(LayerChromium::create()); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); } @@ -165,7 +165,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) layerTreeRoot->addChild(MockLayerChromium::create(&ccLayerDestructionList)); layerTreeRoot->addChild(MockLayerChromium::create(&ccLayerDestructionList)); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); // Add a new layer to the LayerChromium side @@ -199,7 +199,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) IntSize secondChildBounds = IntSize(25, 53); layerTreeRoot->children()[1]->setBounds(secondChildBounds); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); // Check that the property values we set on the LayerChromium tree are reflected in the CCLayerImpl tree. @@ -236,7 +236,7 @@ TEST(TreeSynchronizerTest, reuseCCLayersAfterStructuralChange) layerB->addChild(MockLayerChromium::create(&ccLayerDestructionList)); RefPtr<LayerChromium> layerD = layerB->children()[1].get(); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); // Now restructure the tree to look like this: @@ -274,7 +274,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id(); int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id(); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(oldLayerTreeRoot.get(), 0); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(oldLayerTreeRoot.get(), nullptr); expectTreesAreIdentical(oldLayerTreeRoot.get(), ccLayerTreeRoot.get()); // Remove all children on the LayerChromium side. @@ -314,23 +314,23 @@ TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) replicaLayerWithMask->setMaskLayer(replicaMaskLayer.get()); layerTreeRoot->children()[2]->setReplicaLayer(replicaLayerWithMask.get()); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); // Remove the mask layer. layerTreeRoot->children()[0]->setMaskLayer(0); - ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get()); + ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release()); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); // Remove the replica layer. layerTreeRoot->children()[1]->setReplicaLayer(0); - ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get()); + ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release()); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); // Remove the replica mask. replicaLayerWithMask->setMaskLayer(0); - ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get()); + ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release()); expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); } @@ -343,8 +343,8 @@ TEST(TreeSynchronizerTest, synchronizeAnimations) EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); - RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); - ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get()); + OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr); + ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release()); EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); } diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index f61e98648..481bd916f 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -186,27 +186,27 @@ TEST_F(WebFrameTest, DivAutoZoomParamsTest) EXPECT_EQ(vScroll, scroll.y); // Test zoom out to overview scale. - webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); EXPECT_FLOAT_EQ(1, scale); EXPECT_EQ(WebPoint(0, 0), scroll); // Tests for clamped scaling. // Test clamp to device scale: - webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); webViewImpl->setDeviceScaleFactor(2.5); webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); EXPECT_FLOAT_EQ(2.5, scale); // Test clamp to minimum scale: - webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); webViewImpl->setPageScaleFactorLimits(1.5 / webViewImpl->deviceScaleFactor(), 4 / webViewImpl->deviceScaleFactor()); webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); EXPECT_FLOAT_EQ(1.5, scale); EXPECT_EQ(WebPoint(0, 0), scroll); // Test clamp to maximum scale: - webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); webViewImpl->setDeviceScaleFactor(4); webViewImpl->setPageScaleFactorLimits(0, 3 / webViewImpl->deviceScaleFactor()); webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); @@ -322,12 +322,12 @@ public: std::vector<Notification*> releaseNotifications; private: - virtual void didCreateScriptContext(WebFrame* frame, v8::Handle<v8::Context> context, int worldId) + virtual void didCreateScriptContext(WebFrame* frame, v8::Handle<v8::Context> context, int extensionGroup, int worldId) OVERRIDE { createNotifications.push_back(new Notification(frame, context, worldId)); } - virtual void willReleaseScriptContext(WebFrame* frame, v8::Handle<v8::Context> context, int worldId) + virtual void willReleaseScriptContext(WebFrame* frame, v8::Handle<v8::Context> context, int worldId) OVERRIDE { releaseNotifications.push_back(new Notification(frame, context, worldId)); } diff --git a/Source/WebKit/chromium/tests/WebLayerTest.cpp b/Source/WebKit/chromium/tests/WebLayerTest.cpp index e0cab87bd..1eed81aea 100644 --- a/Source/WebKit/chromium/tests/WebLayerTest.cpp +++ b/Source/WebKit/chromium/tests/WebLayerTest.cpp @@ -57,6 +57,8 @@ public: virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { } virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); } virtual void didRebindGraphicsContext(bool success) { } + virtual void didCommitAndDrawFrame() { } + virtual void didCompleteSwapBuffers() { } }; class MockWebContentLayerClient : public WebContentLayerClient { @@ -72,7 +74,7 @@ public: WebKit::WebCompositor::initialize(0); m_rootLayer = WebLayer::create(); EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); - m_view = WebLayerTreeView::create(&m_client, m_rootLayer, WebLayerTreeView::Settings()); + EXPECT_TRUE(m_view.initialize(&m_client, m_rootLayer, WebLayerTreeView::Settings())); Mock::VerifyAndClearExpectations(&m_client); } diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog index db22d44eb..09d0e7796 100644 --- a/Source/WebKit/efl/ChangeLog +++ b/Source/WebKit/efl/ChangeLog @@ -1,3 +1,166 @@ +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * WebCoreSupport/ChromeClientEfl.cpp: + (WebCore::ChromeClientEfl::notificationPresenter): + * WebCoreSupport/ChromeClientEfl.h: + (ChromeClientEfl): + +2012-03-08 Hyowon Kim <hw1008.kim@samsung.com> + + [Texmap][EFL] Implementation of AcceleratedCompositingContext for EFL port + https://bugs.webkit.org/show_bug.cgi?id=80266 + + Reviewed by Noam Rosenthal. + + This patch adds EFL's implementation of AcceleratedCompositingContext to WebCoreSupport. + + * WebCoreSupport/AcceleratedCompositingContextEfl.cpp: Added. + (WebCore): + (WebCore::AcceleratedCompositingContext::create): + (WebCore::AcceleratedCompositingContext::AcceleratedCompositingContext): + (WebCore::AcceleratedCompositingContext::~AcceleratedCompositingContext): + (WebCore::AcceleratedCompositingContext::initialize): + (WebCore::AcceleratedCompositingContext::syncLayersNow): + (WebCore::AcceleratedCompositingContext::renderLayers): + (WebCore::AcceleratedCompositingContext::attachRootGraphicsLayer): + (WebCore::AcceleratedCompositingContext::context): + * WebCoreSupport/AcceleratedCompositingContextEfl.h: Added. + (WebCore): + (AcceleratedCompositingContext): + +2012-03-02 Grzegorz Czajkowski <g.czajkowski@samsung.com> + + [EFL] Enabling 'Inspect Element' in Ewk_Context_Menu_Action. + https://bugs.webkit.org/show_bug.cgi?id=79646 + + Reviewed by Andreas Kling. + + INSPECTOR feature is already enabled for WebKit-Efl port (OptionsEfl.cmake). + As a result WebCore's ContextMenuAction contains ContextMenuItemTagInspectElement + and enums order has been changed. WebKit-Efl has to synchronize ContextMenuAction + with Ewk_Context_Menu_Action. + To avoid similar case in the feature I added checks between WebCore and + WebKit-EFL's enums by using COMPILE_ASSERT_MATCHING_ENUM. + + * WebCoreSupport/AssertMatchingEnums.cpp: + * ewk/ewk_contextmenu.h: + +2012-02-29 Tomasz Morawski <t.morawski@samsung.com> + + [EFL] Replace malloc/calloc/free to new/delete. + https://bugs.webkit.org/show_bug.cgi?id=75848 + + Reviewed by Hajime Morita. + + Replaced almost all malloc/calloc/free to new/delete operator and where it was possible smart pointers were also + used. Left few c memory allocation by intention to not mix c and c++ memory managment. Left malloc for Ewk_Tile + object due to const fields present in Ewk_tile structure. + + * ewk/ewk_auth_soup.cpp: + * ewk/ewk_contextmenu.cpp: + (ewk_context_menu_unref): + (ewk_context_menu_item_new): + (ewk_context_menu_item_free): + (ewk_context_menu_new): + * ewk/ewk_cookies.cpp: + (ewk_cookies_get_all): + (ewk_cookies_cookie_free): + * ewk/ewk_frame.cpp: + (ewk_frame_hit_test_free): + (ewk_frame_hit_test_new): + * ewk/ewk_history.cpp: + (ewk_history_item_new_from_core): + (_ewk_history_item_free): + (ewk_history_new): + (ewk_history_free): + * ewk/ewk_tiled_backing_store.cpp: + (_Ewk_Tiled_Backing_Store_Item): + (_ewk_tiled_backing_store_pre_render_request_add): + (_ewk_tiled_backing_store_pre_render_request_del): + (_ewk_tiled_backing_store_pre_render_request_flush): + (_ewk_tiled_backing_store_pre_render_request_clear): + (_ewk_tiled_backing_store_item_add): + (_ewk_tiled_backing_store_item_del): + * ewk/ewk_tiled_matrix.cpp: + (_ewk_tile_matrix_tile_free): + (ewk_tile_matrix_new): + (ewk_tile_matrix_zoom_level_set): + (ewk_tile_matrix_invalidate): + (ewk_tile_matrix_free): + * ewk/ewk_tiled_model.cpp: + (tile_account): + (ewk_tile_unused_cache_new): + (_ewk_tile_unused_cache_free): + (ewk_tile_unused_cache_clear): + (ewk_tile_unused_cache_flush): + (ewk_tile_unused_cache_tile_get): + (ewk_tile_unused_cache_tile_put): + * ewk/ewk_tiled_private.h: + * ewk/ewk_view.cpp: + (_Ewk_View_Private_Data): + (_ewk_view_core_frame_new): + (_ewk_view_priv_new): + (_ewk_view_priv_del): + (ewk_view_core_page_get): + (ewk_view_popup_new): + (ewk_view_popup_destroy): + (EWKPrivate::corePage): + * ewk/ewk_window_features.cpp: + (ewk_window_features_unref): + (ewk_window_features_new_from_core): + +2012-02-27 JungJik Lee <jungjik.lee@samsung.com> + + [EFL] Pairing up between evas_object_image_data_get and evas_object_image_data_set. + https://bugs.webkit.org/show_bug.cgi?id=79031 + + Reviewed by Zoltan Herczeg. + + - Get the pixel data when the cairo surface is created. + - evas_object_image_data_get increases the reference count and returns the image buffer pointer. + evas_object_image_data_set decreases the reference count and when the ref count become zero, + the function releases the cached image inside evas engine. + We should make a pair between evas_object_image_data_set/get to return evas resource. + + * ewk/ewk_tiled_backing_store.h: + (_Ewk_Tile): + * ewk/ewk_tiled_model.cpp: + (tile_account): + (ewk_tile_new): + * ewk/ewk_view_tiled.cpp: + (_ewk_view_tiled_render_cb): + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/ChromeClientEfl.h: + (ChromeClientEfl): + +2012-02-24 Grzegorz Czajkowski <g.czajkowski@samsung.com> + + [EFL][DRT] Implement setValueForUser and setAutofilled. + https://bugs.webkit.org/show_bug.cgi?id=79237 + + Reviewed by Andreas Kling. + + Adds missing implementation setValueForUser and setAutofilled to EFL's DumpRenderTreeSupport. + + * WebCoreSupport/DumpRenderTreeSupportEfl.cpp: + (DumpRenderTreeSupportEfl::setValueForUser): + (DumpRenderTreeSupportEfl::setAutofilled): + * WebCoreSupport/DumpRenderTreeSupportEfl.h: + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.cpp b/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.cpp new file mode 100755 index 000000000..75f8632f5 --- /dev/null +++ b/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.cpp @@ -0,0 +1,121 @@ +/* + Copyright (C) 2012 Samsung Electronics + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) + +#include "AcceleratedCompositingContextEfl.h" + +#include "FrameView.h" +#include "GraphicsContext3D.h" +#include "HostWindow.h" +#include "PageClientEfl.h" +#include "TextureMapperGL.h" +#include "TextureMapperLayer.h" + +namespace WebCore { + +PassOwnPtr<AcceleratedCompositingContext> AcceleratedCompositingContext::create(HostWindow* hostWindow) +{ + OwnPtr<AcceleratedCompositingContext> context = adoptPtr(new AcceleratedCompositingContext); + if (!context->initialize(hostWindow)) + return nullptr; + + return context.release(); +} + +AcceleratedCompositingContext::AcceleratedCompositingContext() + : m_view(0) + , m_rootTextureMapperLayer(0) +{ +} + +AcceleratedCompositingContext::~AcceleratedCompositingContext() +{ +} + +bool AcceleratedCompositingContext::initialize(HostWindow* hostWindow) +{ + m_view = hostWindow->platformPageClient()->view(); + if (!m_view) + return false; + + m_context3D = GraphicsContext3D::create(GraphicsContext3D::Attributes(), hostWindow, WebCore::GraphicsContext3D::RenderDirectlyToHostWindow); + if (!m_context3D) + return false; + + return true; +} + +void AcceleratedCompositingContext::syncLayersNow() +{ + if (m_rootGraphicsLayer) + m_rootGraphicsLayer->syncCompositingStateForThisLayerOnly(); + + ewk_view_core_page_get(m_view)->mainFrame()->view()->syncCompositingStateIncludingSubframes(); +} + +void AcceleratedCompositingContext::renderLayers() +{ + if (!m_rootGraphicsLayer) + return; + + if (!m_context3D->makeContextCurrent()) + return; + + int width = 0; + int height = 0; + evas_object_geometry_get(m_view, 0, 0, &width, &height); + m_context3D->viewport(0, 0, width, height); + + m_textureMapper->beginPainting(); + m_rootTextureMapperLayer->paint(); + m_textureMapper->endPainting(); +} + +void AcceleratedCompositingContext::attachRootGraphicsLayer(GraphicsLayer* rootLayer) +{ + if (!rootLayer) { + m_rootGraphicsLayer.clear(); + m_rootTextureMapperLayer = 0; + return; + } + + m_rootGraphicsLayer = WebCore::GraphicsLayer::create(0); + m_rootTextureMapperLayer = toTextureMapperLayer(m_rootGraphicsLayer.get()); + m_rootGraphicsLayer->addChild(rootLayer); + m_rootGraphicsLayer->setDrawsContent(false); + m_rootGraphicsLayer->setMasksToBounds(false); + m_rootGraphicsLayer->setSize(WebCore::IntSize(1, 1)); + + m_textureMapper = TextureMapperGL::create(); + m_rootTextureMapperLayer->setTextureMapper(m_textureMapper.get()); + + m_rootGraphicsLayer->syncCompositingStateForThisLayerOnly(); +} + +GraphicsContext3D* AcceleratedCompositingContext::context() +{ + return m_context3D.get(); +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) diff --git a/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.h b/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.h new file mode 100755 index 000000000..50b89b9ca --- /dev/null +++ b/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2012 Samsung Electronics + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef AcceleratedCompositingContextEfl_h +#define AcceleratedCompositingContextEfl_h + +#include <wtf/Noncopyable.h> +#include <wtf/PassOwnPtr.h> + +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) + +#include "ewk_private.h" + +namespace WebCore { + +class HostWindow; +class TextureMapper; +class TextureMapperLayer; + +class AcceleratedCompositingContext { + WTF_MAKE_NONCOPYABLE(AcceleratedCompositingContext); +public: + static PassOwnPtr<AcceleratedCompositingContext> create(HostWindow*); + virtual ~AcceleratedCompositingContext(); + + virtual void syncLayersNow(); + virtual void renderLayers(); + virtual void attachRootGraphicsLayer(GraphicsLayer* rootLayer); + virtual GraphicsContext3D* context(); + +private: + AcceleratedCompositingContext(); + + virtual bool initialize(HostWindow*); + + Evas_Object* m_view; + + OwnPtr<TextureMapper> m_textureMapper; + OwnPtr<GraphicsLayer> m_rootGraphicsLayer; + TextureMapperLayer* m_rootTextureMapperLayer; + + RefPtr<GraphicsContext3D> m_context3D; +}; + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) +#endif // AcceleratedCompositingContextEfl_h diff --git a/Source/WebKit/efl/WebCoreSupport/AssertMatchingEnums.cpp b/Source/WebKit/efl/WebCoreSupport/AssertMatchingEnums.cpp index bff2fcd3b..158cf0123 100644 --- a/Source/WebKit/efl/WebCoreSupport/AssertMatchingEnums.cpp +++ b/Source/WebKit/efl/WebCoreSupport/AssertMatchingEnums.cpp @@ -23,8 +23,10 @@ #include "config.h" +#include "ContextMenuItem.h" #include "Page.h" #include "VisibleSelection.h" +#include "ewk_contextmenu.h" #include "ewk_frame.h" #include "ewk_view.h" #include <wtf/Assertions.h> @@ -62,3 +64,81 @@ COMPILE_ASSERT_MATCHING_ENUM(EWK_VIEW_MODE_FLOATING, Page::ViewModeFloating); COMPILE_ASSERT_MATCHING_ENUM(EWK_VIEW_MODE_FULLSCREEN, Page::ViewModeFullscreen); COMPILE_ASSERT_MATCHING_ENUM(EWK_VIEW_MODE_MAXIMIZED, Page::ViewModeMaximized); COMPILE_ASSERT_MATCHING_ENUM(EWK_VIEW_MODE_MINIMIZED, Page::ViewModeMinimized); + +#if ENABLE(CONTEXT_MENUS) +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION, ContextMenuItemTagNoAction); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW, ContextMenuItemTagOpenLinkInNewWindow); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, ContextMenuItemTagDownloadLinkToDisk); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, ContextMenuItemTagCopyLinkToClipboard); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW, ContextMenuItemTagOpenImageInNewWindow); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, ContextMenuItemTagDownloadImageToDisk); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, ContextMenuItemTagCopyImageToClipboard); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_URL_TO_CLIPBOARD, ContextMenuItemTagCopyImageUrlToClipboard); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW, ContextMenuItemTagOpenFrameInNewWindow); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_COPY, ContextMenuItemTagCopy); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_GO_BACK, ContextMenuItemTagGoBack); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_GO_FORWARD, ContextMenuItemTagGoForward); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_STOP, ContextMenuItemTagStop); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_RELOAD, ContextMenuItemTagReload); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_CUT, ContextMenuItemTagCut); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_PASTE, ContextMenuItemTagPaste); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, ContextMenuItemTagSelectAll); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_GUESS, ContextMenuItemTagSpellingGuess); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_NO_GUESSES_FOUND, ContextMenuItemTagNoGuessesFound); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING, ContextMenuItemTagIgnoreSpelling); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING, ContextMenuItemTagLearnSpelling); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OTHER, ContextMenuItemTagOther); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_IN_SPOTLIGHT, ContextMenuItemTagSearchInSpotlight); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB, ContextMenuItemTagSearchWeb); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_LOOK_UP_IN_DICTIONARY, ContextMenuItemTagLookUpInDictionary); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OPEN_WITH_DEFAULT_APPLICATION, ContextMenuItemTagOpenWithDefaultApplication); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFACTUAL_SIZE, ContextMenuItemPDFActualSize); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFZOOM_IN, ContextMenuItemPDFZoomIn); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFZOOM_OUT, ContextMenuItemPDFZoomOut); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFAUTO_SIZE, ContextMenuItemPDFAutoSize); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFSINGLE_PAGE, ContextMenuItemPDFSinglePage); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFFACING_PAGES, ContextMenuItemPDFFacingPages); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFCONTINUOUS, ContextMenuItemPDFContinuous); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFNEXT_PAGE, ContextMenuItemPDFNextPage); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_PDFPREVIOUS_PAGE, ContextMenuItemPDFPreviousPage); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK, ContextMenuItemTagOpenLink); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_GRAMMAR, ContextMenuItemTagIgnoreGrammar); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, ContextMenuItemTagSpellingMenu); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SHOW_SPELLING_PANEL, ContextMenuItemTagShowSpellingPanel); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING, ContextMenuItemTagCheckSpelling); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING, ContextMenuItemTagCheckSpellingWhileTyping); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_CHECK_GRAMMAR_WITH_SPELLING, ContextMenuItemTagCheckGrammarWithSpelling); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_FONT_MENU, ContextMenuItemTagFontMenu); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SHOW_FONTS, ContextMenuItemTagShowFonts); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_BOLD, ContextMenuItemTagBold); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_ITALIC, ContextMenuItemTagItalic); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_UNDERLINE, ContextMenuItemTagUnderline); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_OUTLINE, ContextMenuItemTagOutline); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_STYLES, ContextMenuItemTagStyles); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SHOW_COLORS, ContextMenuItemTagShowColors); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_SPEECH_MENU, ContextMenuItemTagSpeechMenu); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_START_SPEAKING, ContextMenuItemTagStartSpeaking); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_STOP_SPEAKING, ContextMenuItemTagStopSpeaking); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_WRITING_DIRECTION_MENU, ContextMenuItemTagWritingDirectionMenu); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_DEFAULT_DIRECTION, ContextMenuItemTagDefaultDirection); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_LEFT_TO_RIGHT, ContextMenuItemTagLeftToRight); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_RIGHT_TO_LEFT, ContextMenuItemTagRightToLeft); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_PDFSINGLE_PAGE_SCROLLING, ContextMenuItemTagPDFSinglePageScrolling); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_PDFFACING_PAGES_SCROLLING, ContextMenuItemTagPDFFacingPagesScrolling); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_INSPECT_ELEMENT, ContextMenuItemTagInspectElement); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_MENU, ContextMenuItemTagTextDirectionMenu); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_DEFAULT, ContextMenuItemTagTextDirectionDefault); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_LEFT_TO_RIGHT, ContextMenuItemTagTextDirectionLeftToRight); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_RIGHT_TO_LEFT, ContextMenuItemTagTextDirectionRightToLeft); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_OPEN_MEDIA_IN_NEW_WINDOW, ContextMenuItemTagOpenMediaInNewWindow); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_COPY_MEDIA_LINK_TO_CLIPBOARD, ContextMenuItemTagCopyMediaLinkToClipboard); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_CONTROLS, ContextMenuItemTagToggleMediaControls); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_LOOP, ContextMenuItemTagToggleMediaLoop); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_ENTER_VIDEO_FULLSCREEN, ContextMenuItemTagEnterVideoFullscreen); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_PLAY_PAUSE, ContextMenuItemTagMediaPlayPause); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_MUTE, ContextMenuItemTagMediaMute); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_BASE_CUSTOM_TAG, ContextMenuItemBaseCustomTag); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_CUSTOM_TAG_NO_ACTION, ContextMenuItemCustomTagNoAction); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_LAST_CUSTOM_TAG, ContextMenuItemLastCustomTag); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, ContextMenuItemBaseApplicationTag); +#endif diff --git a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp index a25f9d0e4..a58a11b33 100644 --- a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp +++ b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp @@ -418,7 +418,7 @@ void ChromeClientEfl::exceededDatabaseQuota(Frame* frame, const String& database #endif #if ENABLE(NOTIFICATIONS) -NotificationPresenter* ChromeClientEfl::notificationPresenter() const +NotificationClient* ChromeClientEfl::notificationPresenter() const { notImplemented(); return 0; diff --git a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h index 82512251f..1526245e4 100644 --- a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h +++ b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h @@ -29,7 +29,7 @@ #include "PopupMenu.h" #if ENABLE(NOTIFICATIONS) -#include "NotificationPresenter.h" +#include "NotificationClient.h" #endif typedef struct _Evas_Object Evas_Object; @@ -115,16 +115,12 @@ public: #endif #if ENABLE(NOTIFICATIONS) - virtual WebCore::NotificationPresenter* notificationPresenter() const; + virtual WebCore::NotificationClient* notificationPresenter() const; #endif virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded); -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif - #if ENABLE(TOUCH_EVENTS) virtual void needTouchEvents(bool); #endif diff --git a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp index 2a4a9fcc9..fd3d6b50b 100644 --- a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp +++ b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp @@ -31,13 +31,16 @@ #include <FindOptions.h> #include <FloatSize.h> #include <FrameView.h> +#include <HTMLInputElement.h> #include <IntRect.h> +#include <JSElement.h> #include <PrintContext.h> #include <RenderTreeAsText.h> #include <Settings.h> #include <bindings/js/GCController.h> #include <history/HistoryItem.h> #include <workers/WorkerThread.h> +#include <wtf/OwnArrayPtr.h> #include <wtf/text/AtomicString.h> unsigned DumpRenderTreeSupportEfl::activeAnimationsCount(const Evas_Object* ewkFrame) @@ -279,6 +282,35 @@ void DumpRenderTreeSupportEfl::suspendAnimations(Evas_Object* ewkFrame) animationController->suspendAnimations(); } +void DumpRenderTreeSupportEfl::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value) +{ + JSC::ExecState* exec = toJS(context); + WebCore::Element* element = WebCore::toElement(toJS(exec, nodeObject)); + if (!element) + return; + WebCore::HTMLInputElement* inputElement = element->toInputElement(); + if (!inputElement) + return; + + size_t bufferSize = JSStringGetMaximumUTF8CStringSize(value); + OwnArrayPtr<char> valueBuffer = adoptArrayPtr(new char[bufferSize]); + JSStringGetUTF8CString(value, valueBuffer.get(), bufferSize); + inputElement->setValueForUser(String::fromUTF8(valueBuffer.get())); +} + +void DumpRenderTreeSupportEfl::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool autofilled) +{ + JSC::ExecState* exec = toJS(context); + WebCore::Element* element = WebCore::toElement(toJS(exec, nodeObject)); + if (!element) + return; + WebCore::HTMLInputElement* inputElement = element->toInputElement(); + if (!inputElement) + return; + + inputElement->setAutofilled(autofilled); +} + bool DumpRenderTreeSupportEfl::findString(const Evas_Object* ewkView, const char* text, WebCore::FindOptions options) { WebCore::Page* page = EWKPrivate::corePage(ewkView); diff --git a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h index 42af811d3..950a78d67 100644 --- a/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h +++ b/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h @@ -24,6 +24,8 @@ #include <Eina.h> #include <FindOptions.h> #include <IntRect.h> +#include <JavaScriptCore/APICast.h> +#include <JavaScriptCore/JSStringRef.h> #include <wtf/Vector.h> #include <wtf/text/WTFString.h> @@ -60,6 +62,8 @@ public: static WebCore::IntRect selectionRectangle(const Evas_Object* ewkFrame); static String suitableDRTFrameName(const Evas_Object* ewkFrame); static void suspendAnimations(Evas_Object* ewkFrame); + static void setValueForUser(JSContextRef, JSValueRef nodeObject, JSStringRef value); + static void setAutofilled(JSContextRef, JSValueRef nodeObject, bool autofilled); static bool findString(const Evas_Object* ewkView, const char* text, WebCore::FindOptions); diff --git a/Source/WebKit/efl/ewk/ewk_auth_soup.cpp b/Source/WebKit/efl/ewk/ewk_auth_soup.cpp index 834dac7ac..d85427ddc 100644 --- a/Source/WebKit/efl/ewk/ewk_auth_soup.cpp +++ b/Source/WebKit/efl/ewk/ewk_auth_soup.cpp @@ -93,19 +93,13 @@ static void session_authenticate(SoupSession* session, SoupMessage* message, Sou if (!ewk_auth_show_dialog_callback) return; - authenticationData = static_cast<Ewk_Auth_Data*>(calloc(1, sizeof(Ewk_Auth_Data))); - - if (!authenticationData) { - CRITICAL("could not allocate Ewk_Auth_Data"); - return; - } - soup_session_pause_message(session, message); // We need to make sure the message sticks around when pausing it. g_object_ref(message); g_object_ref(session); g_object_ref(auth); + authenticationData = new Ewk_Auth_Data; authenticationData->message = message; authenticationData->auth = auth; authenticationData->session = session; @@ -122,7 +116,7 @@ static void free_auth_data(Ewk_Auth_Data* authData) g_object_unref(authData->message); g_object_unref(authData->session); g_object_unref(authData->auth); - free(authData); + delete authData; } static void attach(SoupSessionFeature* manager, SoupSession* session) diff --git a/Source/WebKit/efl/ewk/ewk_contextmenu.cpp b/Source/WebKit/efl/ewk/ewk_contextmenu.cpp index d2b9f1974..6dfe909d9 100644 --- a/Source/WebKit/efl/ewk/ewk_contextmenu.cpp +++ b/Source/WebKit/efl/ewk/ewk_contextmenu.cpp @@ -75,7 +75,7 @@ void ewk_context_menu_unref(Ewk_Context_Menu* menu) EINA_LIST_FREE(menu->items, item) ewk_context_menu_item_free(static_cast<Ewk_Context_Menu_Item*>(item)); - free(menu); + delete menu; } Eina_Bool ewk_context_menu_destroy(Ewk_Context_Menu* menu) @@ -101,10 +101,7 @@ Ewk_Context_Menu_Item* ewk_context_menu_item_new(Ewk_Context_Menu_Item_Type type Ewk_Context_Menu_Action action, Ewk_Context_Menu* submenu, const char* title, Eina_Bool checked, Eina_Bool enabled) { - Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(malloc(sizeof(*item))); - if (!item) - return 0; - + Ewk_Context_Menu_Item* item = new Ewk_Context_Menu_Item; item->type = type; item->action = action; item->title = eina_stringshare_add(title); @@ -137,7 +134,7 @@ void ewk_context_menu_item_free(Ewk_Context_Menu_Item* item) EINA_SAFETY_ON_NULL_RETURN(item); eina_stringshare_del(item->title); - free(item); + delete item; } Ewk_Context_Menu_Item_Type ewk_context_menu_item_type_get(const Ewk_Context_Menu_Item* item) @@ -226,11 +223,7 @@ Ewk_Context_Menu* ewk_context_menu_new(Evas_Object* view, WebCore::ContextMenuCo EINA_SAFETY_ON_NULL_RETURN_VAL(view, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(controller, 0); - menu = static_cast<Ewk_Context_Menu*>(malloc(sizeof(*menu))); - if (!menu) { - CRITICAL("Could not allocate context menu memory."); - return 0; - } + menu = new Ewk_Context_Menu; menu->__ref = 1; menu->view = view; diff --git a/Source/WebKit/efl/ewk/ewk_contextmenu.h b/Source/WebKit/efl/ewk/ewk_contextmenu.h index e781f4d9c..2ed473898 100644 --- a/Source/WebKit/efl/ewk/ewk_contextmenu.h +++ b/Source/WebKit/efl/ewk/ewk_contextmenu.h @@ -109,7 +109,7 @@ enum _Ewk_Context_Menu_Action { EWK_CONTEXT_MENU_ITEM_TAG_RIGHT_TO_LEFT, EWK_CONTEXT_MENU_ITEM_TAG_PDFSINGLE_PAGE_SCROLLING, EWK_CONTEXT_MENU_ITEM_TAG_PDFFACING_PAGES_SCROLLING, - // EWK_CONTEXT_MENU_ITEM_TAG_INSPECT_ELEMENT, /**< This feature is disabled in WebKit-EFL - it is a subject to INSPECTOR build variable */ + EWK_CONTEXT_MENU_ITEM_TAG_INSPECT_ELEMENT, EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_MENU, /**< text direction sub-menu */ EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_DEFAULT, EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_LEFT_TO_RIGHT, diff --git a/Source/WebKit/efl/ewk/ewk_cookies.cpp b/Source/WebKit/efl/ewk/ewk_cookies.cpp index 7980c0120..6ef203478 100644 --- a/Source/WebKit/efl/ewk/ewk_cookies.cpp +++ b/Source/WebKit/efl/ewk/ewk_cookies.cpp @@ -76,7 +76,7 @@ Eina_List* ewk_cookies_get_all(void) list = soup_cookie_jar_all_cookies(cookieJar); for (p = list; p; p = p->next) { SoupCookie* cookie = static_cast<SoupCookie*>(p->data); - Ewk_Cookie* ewkCookie = static_cast<Ewk_Cookie*>(malloc(sizeof(*ewkCookie))); + Ewk_Cookie* ewkCookie = new Ewk_Cookie; ewkCookie->name = strdup(cookie->name); ewkCookie->value = strdup(cookie->value); ewkCookie->domain = strdup(cookie->domain); @@ -121,7 +121,7 @@ void ewk_cookies_cookie_free(Ewk_Cookie* cookie) free(cookie->value); free(cookie->domain); free(cookie->path); - free(cookie); + delete cookie; } void ewk_cookies_policy_set(Ewk_Cookie_Policy cookiePolicy) diff --git a/Source/WebKit/efl/ewk/ewk_frame.cpp b/Source/WebKit/efl/ewk/ewk_frame.cpp index 29fe4f059..c229f8090 100644 --- a/Source/WebKit/efl/ewk/ewk_frame.cpp +++ b/Source/WebKit/efl/ewk/ewk_frame.cpp @@ -659,7 +659,7 @@ void ewk_frame_hit_test_free(Ewk_Hit_Test* hitTest) eina_stringshare_del(hitTest->link.title); eina_stringshare_del(hitTest->image_uri); eina_stringshare_del(hitTest->media_uri); - free(hitTest); + delete hitTest; } Ewk_Hit_Test* ewk_frame_hit_test_new(const Evas_Object* ewkFrame, int x, int y) @@ -680,12 +680,7 @@ Ewk_Hit_Test* ewk_frame_hit_test_new(const Evas_Object* ewkFrame, int x, int y) if (!result.innerNode()) return 0; - Ewk_Hit_Test* hitTest = static_cast<Ewk_Hit_Test*>(calloc(1, sizeof(Ewk_Hit_Test))); - if (!hitTest) { - CRITICAL("Could not allocate memory for hit test."); - return 0; - } - + Ewk_Hit_Test* hitTest = new Ewk_Hit_Test; hitTest->x = result.point().x(); hitTest->y = result.point().y(); #if 0 diff --git a/Source/WebKit/efl/ewk/ewk_history.cpp b/Source/WebKit/efl/ewk/ewk_history.cpp index faef0c805..c0a0b185d 100644 --- a/Source/WebKit/efl/ewk/ewk_history.cpp +++ b/Source/WebKit/efl/ewk/ewk_history.cpp @@ -241,13 +241,10 @@ Ewk_History_Item* ewk_history_item_new_from_core(WebCore::HistoryItem* core) return 0; } - item = (Ewk_History_Item*)calloc(1, sizeof(Ewk_History_Item)); - if (!item) { - CRITICAL("Could not allocate item memory."); - return 0; - } - core->ref(); + + item = new Ewk_History_Item; + memset(item, 0, sizeof(*item)); item->core = core; return item; @@ -265,7 +262,7 @@ Ewk_History_Item* ewk_history_item_new(const char* uri, const char* title) static inline void _ewk_history_item_free(Ewk_History_Item* item, WebCore::HistoryItem* core) { core->deref(); - free(item); + delete item; } void ewk_history_item_free(Ewk_History_Item* item) @@ -399,14 +396,9 @@ Ewk_History* ewk_history_new(WebCore::BackForwardListImpl* core) EINA_SAFETY_ON_NULL_RETURN_VAL(core, 0); DBG("core=%p", core); - history = static_cast<Ewk_History*>(malloc(sizeof(Ewk_History))); - if (!history) { - CRITICAL("Could not allocate history memory."); - return 0; - } - - core->ref(); + history = new Ewk_History; history->core = core; + core->ref(); return history; } @@ -423,7 +415,7 @@ void ewk_history_free(Ewk_History* history) { DBG("history=%p", history); history->core->deref(); - free(history); + delete history; } namespace EWKPrivate { diff --git a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp index e0dde4d74..3a46c80b6 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp +++ b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp @@ -26,6 +26,8 @@ #include "ewk_tiled_private.h" #include <Ecore.h> #include <Eina.h> +#include <OwnPtr.h> +#include <PassOwnPtr.h> #include <algorithm> #include <errno.h> #include <math.h> @@ -249,11 +251,7 @@ static void _ewk_tiled_backing_store_tile_dissociate_all(Ewk_Tiled_Backing_Store static inline Eina_Bool _ewk_tiled_backing_store_pre_render_request_add(Ewk_Tiled_Backing_Store_Data* priv, unsigned long column, unsigned long row, float zoom) { - Ewk_Tiled_Backing_Store_Pre_Render_Request* request; - - request = static_cast<Ewk_Tiled_Backing_Store_Pre_Render_Request*>(malloc(sizeof(*request))); - if (!request) - return false; + Ewk_Tiled_Backing_Store_Pre_Render_Request* request = new Ewk_Tiled_Backing_Store_Pre_Render_Request; priv->render.preRenderRequests = eina_inlist_append (priv->render.preRenderRequests, EINA_INLIST_GET(request)); @@ -269,7 +267,7 @@ static inline void _ewk_tiled_backing_store_pre_render_request_del(Ewk_Tiled_Bac { priv->render.preRenderRequests = eina_inlist_remove (priv->render.preRenderRequests, EINA_INLIST_GET(request)); - free(request); + delete request; } static inline Ewk_Tiled_Backing_Store_Pre_Render_Request* _ewk_tiled_backing_store_pre_render_request_first(const Ewk_Tiled_Backing_Store_Data* priv) @@ -286,7 +284,7 @@ static void _ewk_tiled_backing_store_pre_render_request_flush(Ewk_Tiled_Backing_ Ewk_Tiled_Backing_Store_Pre_Render_Request* request; request = _ewk_tiled_backing_store_pre_render_request_first(priv); *preRenderList = eina_inlist_remove(*preRenderList, *preRenderList); - free(request); + delete request; } } @@ -301,7 +299,7 @@ static void _ewk_tiled_backing_store_pre_render_request_clear(Ewk_Tiled_Backing_ next = iter->next; *preRenderList = eina_inlist_remove(*preRenderList, iter); iter = next; - free(request); + delete request; } } @@ -471,31 +469,25 @@ end: static Ewk_Tiled_Backing_Store_Item* _ewk_tiled_backing_store_item_add(Ewk_Tiled_Backing_Store_Data* priv, unsigned long column, unsigned long row) { - Ewk_Tiled_Backing_Store_Item* item; Evas_Coord x, y, tileWidth, tileHeight; DBG("ewkBackingStore=%p", priv->self); - item = static_cast<Ewk_Tiled_Backing_Store_Item*>(malloc(sizeof(*item))); - if (!item) - return 0; - tileWidth = priv->view.tile.width; tileHeight = priv->view.tile.height; x = priv->view.offset.base.x + priv->view.x + tileWidth * column; y = priv->view.offset.base.y + priv->view.y + tileHeight * row; + OwnPtr<Ewk_Tiled_Backing_Store_Item> item = adoptPtr(new Ewk_Tiled_Backing_Store_Item); item->tile = 0; - item->smoothScale = priv->view.tile.zoomWeakSmoothScale; - _ewk_tiled_backing_store_item_move(item, x, y); - _ewk_tiled_backing_store_item_resize(item, tileWidth, tileHeight); - if (!_ewk_tiled_backing_store_item_fill(priv, item, column, row)) { - free(item); + + _ewk_tiled_backing_store_item_move(item.get(), x, y); + _ewk_tiled_backing_store_item_resize(item.get(), tileWidth, tileHeight); + if (!_ewk_tiled_backing_store_item_fill(priv, item.get(), column, row)) return 0; - } - return item; + return item.leakPtr(); } static void _ewk_tiled_backing_store_item_del(Ewk_Tiled_Backing_Store_Data* priv, Ewk_Tiled_Backing_Store_Item* item) @@ -505,7 +497,7 @@ static void _ewk_tiled_backing_store_item_del(Ewk_Tiled_Backing_Store_Data* priv _ewk_tiled_backing_store_tile_dissociate(priv, item, last_used); } - free(item); + delete item; } static void _ewk_tiled_backing_store_item_smooth_scale_set(Ewk_Tiled_Backing_Store_Item* item, Eina_Bool smoothScale) diff --git a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h index 7b8ce0d6f..9e5a048d8 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h +++ b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h @@ -77,7 +77,6 @@ struct _Ewk_Tile { */ int visible; /**< visibility counter of this tile */ Evas_Object *image; /**< Evas Image, the tile to be rendered */ - uint8_t *pixels; }; #include "ewk_tiled_matrix.h" diff --git a/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp b/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp index 5d991b436..55a0f5da1 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp +++ b/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp @@ -25,6 +25,8 @@ #include "ewk_tiled_backing_store.h" #include "ewk_tiled_private.h" #include <Eina.h> +#include <OwnPtr.h> +#include <PassOwnPtr.h> #include <errno.h> #include <inttypes.h> #include <math.h> @@ -170,7 +172,7 @@ static void _ewk_tile_matrix_tile_free(void* data, Ewk_Tile* tile) if (!entry->count && entry->matrix != tileMatrix->matrix) { eina_matrixsparse_free(entry->matrix); tileMatrix->matrices = eina_inlist_remove(tileMatrix->matrices, EINA_INLIST_GET(entry)); - free(entry); + delete entry; } ewk_tile_free(tile); @@ -197,18 +199,16 @@ static void _ewk_tile_matrix_tile_free(void* data, Ewk_Tile* tile) */ Ewk_Tile_Matrix* ewk_tile_matrix_new(Ewk_Tile_Unused_Cache* tileUnusedCache, unsigned long columns, unsigned long rows, float zoomLevel, Evas_Colorspace colorSpace, void (*renderCallback)(void* data, Ewk_Tile* tile, const Eina_Rectangle* update), const void* renderData) { - Ewk_Tile_Matrix* tileMatrix = static_cast<Ewk_Tile_Matrix*>(calloc(1, sizeof(Ewk_Tile_Matrix))); - if (!tileMatrix) - return 0; + OwnPtr<Ewk_Tile_Matrix> tileMatrix = adoptPtr(new Ewk_Tile_Matrix); - tileMatrix->matrix = eina_matrixsparse_new(rows, columns, _ewk_tile_matrix_cell_free, tileMatrix); + tileMatrix->matrix = eina_matrixsparse_new(rows, columns, _ewk_tile_matrix_cell_free, tileMatrix.get()); if (!tileMatrix->matrix) { ERR("could not create sparse matrix."); - free(tileMatrix); return 0; } - ewk_tile_matrix_zoom_level_set(tileMatrix, zoomLevel); + tileMatrix->matrices = 0; + ewk_tile_matrix_zoom_level_set(tileMatrix.get(), zoomLevel); if (tileUnusedCache) tileMatrix->tileUnusedCache = ewk_tile_unused_cache_ref(tileUnusedCache); @@ -217,7 +217,6 @@ Ewk_Tile_Matrix* ewk_tile_matrix_new(Ewk_Tile_Unused_Cache* tileUnusedCache, uns if (!tileMatrix->tileUnusedCache) { ERR("no cache of unused tile!"); eina_matrixsparse_free(tileMatrix->matrix); - free(tileMatrix); return 0; } } @@ -227,8 +226,16 @@ Ewk_Tile_Matrix* ewk_tile_matrix_new(Ewk_Tile_Unused_Cache* tileUnusedCache, uns tileMatrix->render.data = (void*)renderData; tileMatrix->tile.width = defaultTileWidth; tileMatrix->tile.height = defaultTileHeigth; + tileMatrix->frozen = 0; + tileMatrix->updates = 0; - return tileMatrix; +#ifdef DEBUG_MEM_LEAKS + tileMatrix->stats.tiles.allocated = 0; + tileMatrix->stats.tiles.freed = 0; + tileMatrix->stats.bytes.allocated = 0; + tileMatrix->stats.bytes.freed = 0; +#endif + return tileMatrix.leakPtr(); } void ewk_tile_matrix_zoom_level_set(Ewk_Tile_Matrix* tileMatrix, float zoom) @@ -249,12 +256,14 @@ void ewk_tile_matrix_zoom_level_set(Ewk_Tile_Matrix* tileMatrix, float zoom) } if (!entry) { - entry = static_cast<Ewk_Tile_Matrix_Entry*>(calloc(1, sizeof(Ewk_Tile_Matrix_Entry))); - entry->zoom = zoom; + entry = new Ewk_Tile_Matrix_Entry; + memset(entry, 0, sizeof(Ewk_Tile_Matrix_Entry)); entry->matrix = eina_matrixsparse_new(rows, columns, _ewk_tile_matrix_cell_free, tileMatrix); + entry->count = 0; + entry->zoom = zoom; if (!entry->matrix) { ERR("could not create sparse matrix."); - free(entry); + delete entry; return; } tileMatrix->matrices = eina_inlist_prepend(tileMatrix->matrices, EINA_INLIST_GET(entry)); @@ -277,7 +286,7 @@ void ewk_tile_matrix_invalidate(Ewk_Tile_Matrix* tileMatrix) if (iterator->matrix != tileMatrix->matrix) { eina_matrixsparse_free(iterator->matrix); tileMatrix->matrices = eina_inlist_remove(tileMatrix->matrices, matrixList); - free(iterator); + delete iterator; } matrixList = next; @@ -303,8 +312,8 @@ void ewk_tile_matrix_free(Ewk_Tile_Matrix* tileMatrix) entry = EINA_INLIST_CONTAINER_GET(tileMatrix->matrices, Ewk_Tile_Matrix_Entry); eina_matrixsparse_free(entry->matrix); tileMatrix->matrices = eina_inlist_remove(tileMatrix->matrices, reinterpret_cast<Eina_Inlist*>(entry)); - free(entry); tileMatrix->matrices = 0; + delete entry; ewk_tile_unused_cache_thaw(tileMatrix->tileUnusedCache); ewk_tile_unused_cache_unref(tileMatrix->tileUnusedCache); @@ -335,7 +344,7 @@ void ewk_tile_matrix_free(Ewk_Tile_Matrix* tileMatrix) tileMatrix->stats.bytes.allocated, tileMatrix->stats.bytes.freed); #endif - free(tileMatrix); + delete tileMatrix; } /** diff --git a/Source/WebKit/efl/ewk/ewk_tiled_model.cpp b/Source/WebKit/efl/ewk/ewk_tiled_model.cpp index 87fa83c11..c0e7020d6 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_model.cpp +++ b/Source/WebKit/efl/ewk/ewk_tiled_model.cpp @@ -221,7 +221,6 @@ Ewk_Tile* ewk_tile_new(Evas* evas, Evas_Coord width, Evas_Coord height, float zo evas_object_image_size_set(tile->image, tile->width, tile->height); evas_object_image_colorspace_set(tile->image, tile->cspace); - tile->pixels = static_cast<uint8_t*>(evas_object_image_data_get(tile->image, true)); _ewk_tile_account_allocated(tile); return tile; @@ -440,9 +439,8 @@ Ewk_Tile_Unused_Cache* ewk_tile_unused_cache_new(size_t max) { Ewk_Tile_Unused_Cache* tileUnusedCache; - tileUnusedCache = static_cast<Ewk_Tile_Unused_Cache*>(calloc(1, sizeof(Ewk_Tile_Unused_Cache))); - if (!tileUnusedCache) - return 0; + tileUnusedCache = new Ewk_Tile_Unused_Cache; + memset(tileUnusedCache, 0, sizeof(Ewk_Tile_Unused_Cache)); DBG("tileUnusedCache=%p", tileUnusedCache); tileUnusedCache->memory.max = max; @@ -492,7 +490,7 @@ static void _ewk_tile_unused_cache_free(Ewk_Tile_Unused_Cache* tileUnusedCache) tileUnusedCache->memory.max, tileUnusedCache->memory.used); ewk_tile_unused_cache_clear(tileUnusedCache); - free(tileUnusedCache); + delete tileUnusedCache; } /** @@ -512,7 +510,7 @@ void ewk_tile_unused_cache_clear(Ewk_Tile_Unused_Cache* tileUnusedCache) EINA_LIST_FREE(tileUnusedCache->entries.list, item) { Ewk_Tile_Unused_Cache_Entry* itr = static_cast<Ewk_Tile_Unused_Cache_Entry*>(item); itr->tile_free.callback(itr->tile_free.data, itr->tile); - free(itr); + delete itr; } tileUnusedCache->memory.used = 0; @@ -605,7 +603,7 @@ size_t ewk_tile_unused_cache_flush(Ewk_Tile_Unused_Cache* tileUnusedCache, size_ done += ewk_tile_memory_size_get(itr->tile); itr->tile_free.callback(itr->tile_free.data, itr->tile); tileUnusedCache->entries.list = eina_list_remove_list(tileUnusedCache->entries.list, list); - free(itr); + delete itr; count++; } @@ -670,28 +668,23 @@ void ewk_tile_unused_cache_thaw(Ewk_Tile_Unused_Cache* tileUnusedCache) */ Eina_Bool ewk_tile_unused_cache_tile_get(Ewk_Tile_Unused_Cache* tileUnusedCache, Ewk_Tile* tile) { - Eina_List* foundEntry, *iterateEntry; - + Eina_List* iterateEntry; void* item; - foundEntry = 0; + EINA_LIST_FOREACH(tileUnusedCache->entries.list, iterateEntry, item) { Ewk_Tile_Unused_Cache_Entry* entry = static_cast<Ewk_Tile_Unused_Cache_Entry*>(item); if (entry->tile == tile) { - foundEntry = iterateEntry; - break; + tileUnusedCache->entries.count--; + tileUnusedCache->memory.used -= ewk_tile_memory_size_get(tile); + tileUnusedCache->entries.list = eina_list_remove_list(tileUnusedCache->entries.list, iterateEntry); + delete entry; + + return true; } } - if (!foundEntry) { - ERR("tile %p not found in cache %p", tile, tileUnusedCache); - return false; - } - - tileUnusedCache->entries.count--; - tileUnusedCache->memory.used -= ewk_tile_memory_size_get(tile); - tileUnusedCache->entries.list = eina_list_remove_list(tileUnusedCache->entries.list, foundEntry); - free(item); - return true; + ERR("tile %p not found in cache %p", tile, tileUnusedCache); + return false; } /** @@ -725,9 +718,7 @@ Eina_Bool ewk_tile_unused_cache_tile_put(Ewk_Tile_Unused_Cache* tileUnusedCache, return false; } - unusedCacheEntry = static_cast<Ewk_Tile_Unused_Cache_Entry*>(malloc(sizeof(Ewk_Tile_Unused_Cache_Entry))); - if (!unusedCacheEntry) - return false; + unusedCacheEntry = new Ewk_Tile_Unused_Cache_Entry; tileUnusedCache->entries.list = eina_list_append(tileUnusedCache->entries.list, unusedCacheEntry); if (eina_error_get()) { diff --git a/Source/WebKit/efl/ewk/ewk_tiled_private.h b/Source/WebKit/efl/ewk/ewk_tiled_private.h index 94896c4ea..8a15aa226 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_private.h +++ b/Source/WebKit/efl/ewk/ewk_tiled_private.h @@ -29,34 +29,4 @@ extern int _ewk_tiled_log_dom; #define WRN(...) EINA_LOG_DOM_WARN(_ewk_tiled_log_dom, __VA_ARGS__) #define INF(...) EINA_LOG_DOM_INFO(_ewk_tiled_log_dom, __VA_ARGS__) #define DBG(...) EINA_LOG_DOM_DBG(_ewk_tiled_log_dom, __VA_ARGS__) -#define OOM(op, size) CRITICAL("could not %s %zd bytes: %s", op, size, strerror(errno)) -#define MALLOC_OR_OOM_RET(ptr, size, ...) \ - do { \ - ptr = malloc(size); \ - if (!ptr && (size) > 0) { \ - OOM("malloc", (size)); \ - return __VA_ARGS__; \ - } \ - } while (0) - -#define CALLOC_OR_OOM_RET(ptr, size, ...) \ - do { \ - ptr = calloc(1, size); \ - if (!ptr && (size) > 0) { \ - OOM("calloc", (size)); \ - return __VA_ARGS__; \ - } \ - } while (0) - -#define REALLOC_OR_OOM_RET(ptr, size, ...) \ - do { \ - void* __tmp_ptr; \ - __tmp_ptr = realloc(ptr, size); \ - if (!__tmp_ptr && (size) > 0) { \ - OOM("realloc", (size)); \ - return __VA_ARGS__; \ - } \ - ptr = __tmp_ptr; \ - } while (0) - #endif // ewk_tiled_private_h diff --git a/Source/WebKit/efl/ewk/ewk_view.cpp b/Source/WebKit/efl/ewk/ewk_view.cpp index 8a9674022..17a6ea069 100644 --- a/Source/WebKit/efl/ewk/ewk_view.cpp +++ b/Source/WebKit/efl/ewk/ewk_view.cpp @@ -133,7 +133,7 @@ static const Evas_Smart_Cb_Description _ewk_view_callback_names[] = { * @internal */ struct _Ewk_View_Private_Data { - WebCore::Page* page; + OwnPtr<WebCore::Page> page; WebCore::Settings* pageSettings; WebCore::Frame* mainFrame; WebCore::ViewportArguments viewportArguments; @@ -589,47 +589,36 @@ static WTF::PassRefPtr<WebCore::Frame> _ewk_view_core_frame_new(Ewk_View_Smart_D } frameLoaderClient->setCustomUserAgent(String::fromUTF8(priv->settings.userAgent)); - return WebCore::Frame::create(priv->page, owner, frameLoaderClient); + return WebCore::Frame::create(priv->page.get(), owner, frameLoaderClient); } static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL; static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) { - Ewk_View_Private_Data* priv = - static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data))); + Ewk_View_Private_Data* priv = new Ewk_View_Private_Data; + memset(priv, 0, sizeof(Ewk_View_Private_Data)); AtomicString string; WebCore::KURL url; - if (!priv) { - CRITICAL("could not allocate Ewk_View_Private_Data"); - return 0; - } - WebCore::Page::PageClients pageClients; pageClients.chromeClient = new WebCore::ChromeClientEfl(smartData->self); pageClients.editorClient = new WebCore::EditorClientEfl(smartData->self); pageClients.dragClient = new WebCore::DragClientEfl; pageClients.inspectorClient = new WebCore::InspectorClientEfl; - priv->page = new WebCore::Page(pageClients); - if (!priv->page) { - CRITICAL("Could not create WebKit Page"); - goto error_page; - } + + priv->page = adoptPtr(new WebCore::Page(pageClients)); + #if ENABLE(DEVICE_ORIENTATION) - WebCore::provideDeviceMotionTo(priv->page, new WebCore::DeviceMotionClientEfl); - WebCore::provideDeviceOrientationTo(priv->page, new WebCore::DeviceOrientationClientEfl); + WebCore::provideDeviceMotionTo(priv->page.get(), new WebCore::DeviceMotionClientEfl); + WebCore::provideDeviceOrientationTo(priv->page.get(), new WebCore::DeviceOrientationClientEfl); #endif #if ENABLE(VIBRATION) - WebCore::provideVibrationTo(priv->page, new WebCore::VibrationClientEfl(smartData->self)); + WebCore::provideVibrationTo(priv->page.get(), new WebCore::VibrationClientEfl(smartData->self)); #endif priv->pageSettings = priv->page->settings(); - if (!priv->pageSettings) { - CRITICAL("Could not get page settings."); - goto error_settings; - } priv->viewportArguments.width = WebCore::ViewportArguments::ValueAuto; priv->viewportArguments.height = WebCore::ViewportArguments::ValueAuto; @@ -714,29 +703,12 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) priv->settings.domTimerInterval = priv->pageSettings->defaultMinDOMTimerInterval(); priv->mainFrame = _ewk_view_core_frame_new(smartData, priv, 0).get(); - if (!priv->mainFrame) { - CRITICAL("Could not create main frame."); - goto error_main_frame; - } priv->history = ewk_history_new(static_cast<WebCore::BackForwardListImpl*>(priv->page->backForwardList())); - if (!priv->history) { - CRITICAL("Could not create history instance for view."); - goto error_history; - } priv->soupSession = WebCore::ResourceHandle::defaultSession(); return priv; - -error_history: - // delete priv->main_frame; /* do not delete priv->main_frame */ -error_main_frame: -error_settings: - delete priv->page; -error_page: - free(priv); - return 0; } static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) @@ -766,8 +738,7 @@ static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) ewk_history_free(priv->history); - delete priv->page; - free(priv); + delete priv; } static void _ewk_view_smart_add(Evas_Object* ewkView) @@ -3395,7 +3366,7 @@ WebCore::Page* ewk_view_core_page_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - return priv->page; + return priv->page.get(); } /** @@ -3474,7 +3445,7 @@ void ewk_view_popup_new(Evas_Object* ewkView, WebCore::PopupMenuClient* client, // populate items const int size = client->listSize(); for (int i = 0; i < size; ++i) { - Ewk_Menu_Item* item = static_cast<Ewk_Menu_Item*>(malloc(sizeof(*item))); + Ewk_Menu_Item* item = new Ewk_Menu_Item; if (client->itemIsSeparator(i)) item->type = EWK_MENU_SEPARATOR; else if (client->itemIsLabel(i)) @@ -3508,7 +3479,7 @@ Eina_Bool ewk_view_popup_destroy(Evas_Object* ewkView) EINA_LIST_FREE(priv->popup.menu.items, itemv) { Ewk_Menu_Item* item = static_cast<Ewk_Menu_Item*>(itemv); eina_stringshare_del(item->text); - free(item); + delete item; } priv->popup.menuClient->popupDidHide(); priv->popup.menuClient = 0; @@ -3951,7 +3922,7 @@ WebCore::Page *corePage(const Evas_Object *ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - return priv->page; + return priv->page.get(); } } // namespace EWKPrivate diff --git a/Source/WebKit/efl/ewk/ewk_view_single.cpp b/Source/WebKit/efl/ewk/ewk_view_single.cpp index 4981ef0cc..1dece06c9 100644 --- a/Source/WebKit/efl/ewk/ewk_view_single.cpp +++ b/Source/WebKit/efl/ewk/ewk_view_single.cpp @@ -106,14 +106,14 @@ static inline void _ewk_view_screen_move(uint32_t* image, size_t destinationX, s uint32_t* source, * destination; if (sourceX >= destinationX) { - for (int i = 0; i < copyHeight; i++) { + for (size_t i = 0; i < copyHeight; i++) { source = sourceBegin + (frameWidth * startHeight); destination = destinationBegin + (frameWidth * startHeight); startHeight = startHeight + moveLineUpDown; memcpy(destination, source, copyLength); } } else { - for (int i = 0; i < copyHeight; i++) { + for (size_t i = 0; i < copyHeight; i++) { source = sourceBegin + (frameWidth * startHeight); destination = destinationBegin + (frameWidth * startHeight); startHeight = startHeight + moveLineUpDown; diff --git a/Source/WebKit/efl/ewk/ewk_view_tiled.cpp b/Source/WebKit/efl/ewk/ewk_view_tiled.cpp index bfb2d95f8..342cc4eb4 100644 --- a/Source/WebKit/efl/ewk/ewk_view_tiled.cpp +++ b/Source/WebKit/efl/ewk/ewk_view_tiled.cpp @@ -49,7 +49,12 @@ static Eina_Bool _ewk_view_tiled_render_cb(void* data, Ewk_Tile* tile, const Ein return false; } - RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(tile->pixels, format, tile->width, tile->height, stride)); + uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(tile->image, true)); + if (!pixels) { + ERR("fail to get the pixel data from the image object"); + return false; + } + RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(pixels, format, tile->width, tile->height, stride)); cairo_status_t status = cairo_surface_status(surface.get()); if (status != CAIRO_STATUS_SUCCESS) { ERR("failed to create cairo surface: %s", cairo_status_to_string(status)); @@ -65,7 +70,9 @@ static Eina_Bool _ewk_view_tiled_render_cb(void* data, Ewk_Tile* tile, const Ein cairo_translate(cairo.get(), -tile->x, -tile->y); - return ewk_view_paint_contents(priv, cairo.get(), &rect); + bool result = ewk_view_paint_contents(priv, cairo.get(), &rect); + evas_object_image_data_set(tile->image, pixels); + return result; } static void* _ewk_view_tiled_updates_process_pre(void* data, Evas_Object* ewkView) diff --git a/Source/WebKit/efl/ewk/ewk_window_features.cpp b/Source/WebKit/efl/ewk/ewk_window_features.cpp index 982c7fa3a..6181bda06 100644 --- a/Source/WebKit/efl/ewk/ewk_window_features.cpp +++ b/Source/WebKit/efl/ewk/ewk_window_features.cpp @@ -45,7 +45,7 @@ void ewk_window_features_unref(Ewk_Window_Features* windowFeatures) delete windowFeatures->core; windowFeatures->core = 0; - free(windowFeatures); + delete windowFeatures; } void ewk_window_features_ref(Ewk_Window_Features* windowFeatures) @@ -109,11 +109,7 @@ void ewk_window_features_int_property_get(const Ewk_Window_Features* windowFeatu */ Ewk_Window_Features* ewk_window_features_new_from_core(const WebCore::WindowFeatures* core) { - Ewk_Window_Features* window_features = static_cast<Ewk_Window_Features*>(malloc(sizeof(*window_features))); - if (!window_features) { - CRITICAL("Could not allocate Ewk_Window_Features."); - return 0; - } + Ewk_Window_Features* window_features = new Ewk_Window_Features; if (core) window_features->core = new WebCore::WindowFeatures(*core); diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog index 59bb90acb..7940ca3cd 100644 --- a/Source/WebKit/gtk/ChangeLog +++ b/Source/WebKit/gtk/ChangeLog @@ -1,3 +1,185 @@ +2012-03-07 Kangil Han <kangil.han@samsung.com> + + [DRT] Remove PlainTextController implementations. + https://bugs.webkit.org/show_bug.cgi?id=79959 + + Reviewed by Hajime Morita. + + PlainTextController usages in existing tests have been + replaced by internals API by bug 78570. + So this patch will remove PlainTextController implementations + to avoid further usage in new tests. + + * WebCoreSupport/DumpRenderTreeSupportGtk.cpp: + * WebCoreSupport/DumpRenderTreeSupportGtk.h: + (DumpRenderTreeSupportGtk): + +2012-03-06 Martin Robinson <mrobinson@igalia.com> + + Fix a compilation warning encountered during the GTK+ build. + + Reviewed by Gustavo Noronha Silva. + + * tests/testcopyandpaste.c: + (test_copy_and_paste): Cast the WebKitWebView to a GtkWidget. + +2012-03-06 Philippe Normand <pnormand@igalia.com> + + [GTK] FrameLoader signals: gtk-doc fixes + https://bugs.webkit.org/show_bug.cgi?id=79495 + + Reviewed by Martin Robinson. + + * webkit/webkitwebframe.cpp: + (webkit_web_frame_class_init): + * webkit/webkitwebresource.cpp: + (webkit_web_resource_class_init): + * webkit/webkitwebview.cpp: + (webkit_web_view_class_init): + +2012-01-26 Philippe Normand <pnormand@igalia.com> + + [GStreamer] disable GStreamerGWorld when building against 0.11 + https://bugs.webkit.org/show_bug.cgi?id=77088 + + Disable the FullscreenVideoController if we build against + GStreamer 0.11. This code depends on GStreamerGWorld which wasn't + ported to 0.11 because it will soon be removed anyway. + + Reviewed by Martin Robinson. + + * WebCoreSupport/FullscreenVideoController.cpp: + * WebCoreSupport/FullscreenVideoController.h: + * webkit/webkitwebview.cpp: + (webViewEnterFullscreen): + (webViewExitFullscreen): + * webkit/webkitwebviewprivate.h: + (_WebKitWebViewPrivate): + +2012-03-05 Zan Dobersek <zandobersek@gmail.com> + + [GTK] plugins/netscape-plugin-page-cache-works.html fails + https://bugs.webkit.org/show_bug.cgi?id=74409 + + Reviewed by Martin Robinson. + + Add a method to override page-cache-for-plugins preference. + + * WebCoreSupport/DumpRenderTreeSupportGtk.cpp: + (DumpRenderTreeSupportGtk::setPageCacheSupportsPlugins): + * WebCoreSupport/DumpRenderTreeSupportGtk.h: + (DumpRenderTreeSupportGtk): + +2012-03-04 Martin Robinson <mrobinson@igalia.com> + + [GTK] "Console: undefined @0: ReferenceError: Can't find variable: WebInspector" during testwebinspector + https://bugs.webkit.org/show_bug.cgi?id=80235 + + Reviewed by Philippe Normand. + + Wait to inspect the WebView until the page has finished loading. Also + clean up some minor style errors. + + * tests/testwebinspector.c: + (closeInspector): Small style fixes. + (showInspector): Ditto. + (loadFinished): Ditto. + (test_webkit_web_inspector_close_and_inspect): Wait to inspect until the page has loaded. + (test_webkit_web_inspector_destroy_inspected_web_view): Ditto. + (main): Small style fixes. + +2012-03-04 Martin Robinson <mrobinson@igalia.com> + + [GTK] REGRESSION: r108278 broke some tests that expect focus + https://bugs.webkit.org/show_bug.cgi?id=79084 + + Reviewed by Philippe Normand. + + Grab focus before running the test. This ensures that if the + WebView lost focus, it has it before sending events. + + * tests/testcopyandpaste.c: + (test_copy_and_paste): Grab focus. + +2012-02-18 Martin Robinson <mrobinson@igalia.com> + + [GTK] [AC] Generalize WindowContextGL + https://bugs.webkit.org/show_bug.cgi?id=78969 + + Reviewed by Gustavo Noronha Silva. + + Use GLContext instead of WindowContextGL. Remove a few unnecessary + namespace specifiers in the implementation of AcceleratedCompositingContext. + + * WebCoreSupport/AcceleratedCompositingContext.h: Now we find the GLContext + of our widget, which is cached in WebCore. Remove m_initialized as it isn't needed. + (AcceleratedCompositingContext): + * WebCoreSupport/AcceleratedCompositingContextGL.cpp: + (WebKit::AcceleratedCompositingContext::AcceleratedCompositingContext): No longer initialize + m_initialized. + (WebKit::AcceleratedCompositingContext::glContext): Added. + (WebKit::AcceleratedCompositingContext::renderLayersToWindow): Use glContext() now. + (WebKit::AcceleratedCompositingContext::attachRootGraphicsLayer): Ditto. + (WebKit::AcceleratedCompositingContext::notifyAnimationStarted): Remove unnecessary namespace specifier. + (WebKit::AcceleratedCompositingContext::notifySyncRequired): Ditto. + (WebKit::AcceleratedCompositingContext::paintContents): Ditto. + (WebKit::AcceleratedCompositingContext::showDebugBorders): Ditto. + (WebKit::AcceleratedCompositingContext::showRepaintCounter): Ditto. + +2012-03-02 Zan Dobersek <zandobersek@gmail.com> + + [GTK] Smooth scrolling support + https://bugs.webkit.org/show_bug.cgi?id=16123 + + Reviewed by Martin Robinson. + + Add a new settings option to enable smooth scrolling. + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + (webkit_web_settings_set_property): + (webkit_web_settings_get_property): + * webkit/webkitwebsettingsprivate.h: + * webkit/webkitwebview.cpp: + (webkit_web_view_update_settings): + (webkit_web_view_settings_notify): + +2012-03-01 Carlos Garcia Campos <cgarcia@igalia.com> + + [GTK] Simplify the code to adjust font sizes depending on screen DPI + https://bugs.webkit.org/show_bug.cgi?id=80032 + + Reviewed by Martin Robinson. + + * webkit/webkitwebview.cpp: + (screenDPI): Helper function to get the DPI of a given + GdkScreen. Added also fallback code when gdk_screen_resolution + returns -1. + (webViewGetDPI): Use screenDPI() from WebCore. + (webViewConvertFontSizeToPixels): This is the existing + pixelsFromSize(), renamed and moved to be used also in + webkit_web_view_screen_changed(). + (webkit_web_view_screen_changed): Use + webViewConvertFontSizeToPixels() instead of duplicating the code. + (webkit_web_view_settings_notify): Use + webViewConvertFontSizeToPixels() instead of pixelsFromSize(). + +2012-02-27 Vincent Untz <vuntz@gnome.org>> and Gustavo Noronha Silva <gns@gnome.org> + + Build fix for building with GTK+ 2.x. + + * tests/testwebview.c: + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/ChromeClientGtk.h: + (ChromeClient): + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h index cad47495d..b2567eb5f 100644 --- a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h +++ b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h @@ -28,8 +28,8 @@ #include <wtf/PassOwnPtr.h> #if USE(TEXTURE_MAPPER_GL) +#include "GLContext.h" #include "TextureMapperLayer.h" -#include "WindowGLContext.h" #endif #if USE(ACCELERATED_COMPOSITING) @@ -69,11 +69,8 @@ private: #if USE(CLUTTER) GtkWidget* m_rootLayerEmbedder; #elif USE(TEXTURE_MAPPER_GL) - void initializeIfNecessary(); - - bool m_initialized; + WebCore::GLContext* glContext(); WebCore::TextureMapperLayer* m_rootTextureMapperLayer; - OwnPtr<WebCore::WindowGLContext> m_context; OwnPtr<WebCore::TextureMapper> m_textureMapper; #endif diff --git a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp index 8c4300f27..6d338970a 100644 --- a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp @@ -42,7 +42,6 @@ namespace WebKit { AcceleratedCompositingContext::AcceleratedCompositingContext(WebKitWebView* webView) : m_webView(webView) , m_syncTimerCallbackId(0) - , m_initialized(false) , m_rootTextureMapperLayer(0) { } @@ -53,38 +52,30 @@ AcceleratedCompositingContext::~AcceleratedCompositingContext() g_source_remove(m_syncTimerCallbackId); } -void AcceleratedCompositingContext::initializeIfNecessary() -{ - if (m_initialized) - return; - - m_initialized = true; - - // The GTK+ docs say that we can fail to create a native window. - // FIXME: We should fall back to the ImageBuffer TextureMapper when it exists. - if (!m_webView->priv->hasNativeWindow) - return; - - m_context = WebCore::WindowGLContext::createContextWithGdkWindow(gtk_widget_get_window(GTK_WIDGET(m_webView))); -} - bool AcceleratedCompositingContext::enabled() { return m_rootTextureMapperLayer && m_textureMapper; } +GLContext* AcceleratedCompositingContext::glContext() +{ + GLContext* context = GLContext::getContextForWidget(GTK_WIDGET(m_webView)); + if (!context->canRenderToDefaultFramebuffer()) + return 0; + return context; +} bool AcceleratedCompositingContext::renderLayersToWindow(const IntRect& clipRect) { if (!enabled()) return false; - // We initialize the context lazily here so that we know that the GdkWindow realized. - initializeIfNecessary(); - if (!m_context) + GLContext* context = glContext(); + if (!context) return false; - m_context->startDrawing(); + if (!context->makeContextCurrent()) + return false; GtkAllocation allocation; gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation); @@ -94,7 +85,7 @@ bool AcceleratedCompositingContext::renderLayersToWindow(const IntRect& clipRect m_rootTextureMapperLayer->paint(); m_textureMapper->endPainting(); - m_context->finishDrawing(); + context->swapBuffers(); return true; } @@ -114,14 +105,14 @@ void AcceleratedCompositingContext::attachRootGraphicsLayer(GraphicsLayer* graph m_rootGraphicsLayer->setNeedsDisplay(); m_rootGraphicsLayer->setSize(core(m_webView)->mainFrame()->view()->frameRect().size()); - // We initialize the context lazily here so that we know that the GdkWindow realized. - initializeIfNecessary(); - if (!m_context) + GLContext* context = glContext(); + if (!context) return; // The context needs to be active when creating the texture mapper. It's fine to - // avoid calling endDrawing here, because it will just initialize shaders. - m_context->startDrawing(); + // avoid calling swapBuffers here, because it will just initialize shaders. + if (!context->makeContextCurrent()) + return; GtkAllocation allocation; gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation); @@ -188,28 +179,28 @@ void AcceleratedCompositingContext::syncLayersTimeout() m_syncTimerCallbackId = g_timeout_add_full(GDK_PRIORITY_EVENTS, 1000.0 / 60.0, reinterpret_cast<GSourceFunc>(syncLayersTimeoutCallback), this, 0); } -void AcceleratedCompositingContext::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) +void AcceleratedCompositingContext::notifyAnimationStarted(const GraphicsLayer*, double time) { } -void AcceleratedCompositingContext::notifySyncRequired(const WebCore::GraphicsLayer*) +void AcceleratedCompositingContext::notifySyncRequired(const GraphicsLayer*) { } -void AcceleratedCompositingContext::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& rectToPaint) +void AcceleratedCompositingContext::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const IntRect& rectToPaint) { cairo_t* cr = context.platformContext()->cr(); copyRectFromCairoSurfaceToContext(m_webView->priv->backingStore->cairoSurface(), cr, IntSize(), rectToPaint); } -bool AcceleratedCompositingContext::showDebugBorders(const WebCore::GraphicsLayer*) const +bool AcceleratedCompositingContext::showDebugBorders(const GraphicsLayer*) const { return false; } -bool AcceleratedCompositingContext::showRepaintCounter(const WebCore::GraphicsLayer*) const +bool AcceleratedCompositingContext::showRepaintCounter(const GraphicsLayer*) const { return false; } diff --git a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h index 5905f5679..dcea2f0c4 100644 --- a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h +++ b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h @@ -125,9 +125,6 @@ namespace WebKit { #endif virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded); -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); virtual void loadIconForFiles(const Vector<WTF::String>&, FileIconLoader*); diff --git a/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp index 8e6e26b14..80437ffe5 100644 --- a/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp @@ -46,7 +46,6 @@ #include "JSElement.h" #include "JSLock.h" #include "JSNodeList.h" -#include "JSRange.h" #include "JSValue.h" #include "NodeList.h" #include "PageGroup.h" @@ -60,7 +59,6 @@ #include "Settings.h" #include "TextIterator.h" #include "WebKitAccessibleWrapperAtk.h" -#include "WebKitDOMRangePrivate.h" #include "WebKitMutationObserver.h" #include "WorkerThread.h" #include "webkitglobalsprivate.h" @@ -131,20 +129,6 @@ JSValueRef DumpRenderTreeSupportGtk::nodesFromRect(JSContextRef context, JSValue return toRef(exec, toJS(exec, jsDocument->globalObject(), nodes.get())); } -WebKitDOMRange* DumpRenderTreeSupportGtk::jsValueToDOMRange(JSContextRef context, JSValueRef value) -{ - if (!value) - return 0; - - JSLock lock(SilenceAssertionsOnly); - ExecState* exec = toJS(context); - - Range* range = toRange(toJS(exec, value)); - if (!range) - return 0; - return kit(range); -} - /** * getFrameChildren: * @frame: a #WebKitWebFrame @@ -894,6 +878,11 @@ void DumpRenderTreeSupportGtk::setHixie76WebSocketProtocolEnabled(WebKitWebView* #endif } +void DumpRenderTreeSupportGtk::setPageCacheSupportsPlugins(WebKitWebView* webView, bool enabled) +{ + core(webView)->settings()->setPageCacheSupportsPlugins(enabled); +} + bool DumpRenderTreeSupportGtk::elementDoesAutoCompleteForElementWithId(WebKitWebFrame* frame, JSStringRef id) { Frame* coreFrame = core(frame); diff --git a/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h b/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h index 02b80c476..41ab40fff 100644 --- a/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h +++ b/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h @@ -23,7 +23,6 @@ #include <atk/atk.h> #include <glib.h> #include <webkit/webkitdefines.h> -#include <webkit/webkitdomdefines.h> #include <wtf/text/CString.h> namespace WebKit { @@ -59,8 +58,6 @@ public: static void clearOpener(WebKitWebFrame*); - static WebKitDOMRange* jsValueToDOMRange(JSContextRef, JSValueRef); - // FIXME: Move these to webkitwebframe.h once their API has been discussed. static GSList* getFrameChildren(WebKitWebFrame*); static WTF::CString getInnerText(WebKitWebFrame*); @@ -128,6 +125,7 @@ public: static int numberOfPendingGeolocationPermissionRequests(WebKitWebView*); static void setHixie76WebSocketProtocolEnabled(WebKitWebView*, bool enabled); + static void setPageCacheSupportsPlugins(WebKitWebView*, bool enabled); static void deliverAllMutationsIfNecessary(); diff --git a/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.cpp b/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.cpp index 3300fe133..d14dc9754 100644 --- a/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.cpp @@ -19,7 +19,7 @@ #include "config.h" -#if ENABLE(VIDEO) +#if ENABLE(VIDEO) && !defined(GST_API_VERSION_1) #include "FullscreenVideoController.h" diff --git a/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h b/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h index 3fb8b16f6..cbc5c2552 100644 --- a/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h +++ b/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h @@ -20,7 +20,7 @@ #ifndef FullscreenVideoController_h #define FullscreenVideoController_h -#if ENABLE(VIDEO) +#if ENABLE(VIDEO) && !defined(GST_API_VERSION_1) #include "GRefPtr.h" #include "GStreamerGWorld.h" diff --git a/Source/WebKit/gtk/po/ChangeLog b/Source/WebKit/gtk/po/ChangeLog index 1a0a97921..6cd5910a0 100644 --- a/Source/WebKit/gtk/po/ChangeLog +++ b/Source/WebKit/gtk/po/ChangeLog @@ -1,3 +1,12 @@ +2012-03-02 Alexandre Rostovtsev <tetromino@gentoo.org> + + Make webkit-gtk translations respect LINGUAS + https://bugs.webkit.org/show_bug.cgi?id=79605 + + Reviewed by Martin Robinson. + + * GNUmakefile.am: + 2011-11-09 Philippe Normand <pnormand@igalia.com> Esperanto-translation diff --git a/Source/WebKit/gtk/po/GNUmakefile.am b/Source/WebKit/gtk/po/GNUmakefile.am index 1c5598dfa..3eddaac2b 100644 --- a/Source/WebKit/gtk/po/GNUmakefile.am +++ b/Source/WebKit/gtk/po/GNUmakefile.am @@ -27,7 +27,15 @@ MSGMERGE_UPDATE := $(MSGMERGE) --update POFILES += $(shell ls $(srcdir)/Source/WebKit/gtk/po/*.po) -MOFILES += $(shell echo $(POFILES) | tr ' ' '\n' | sed "s,^$(srcdir)/,,g" | sed 's/\.po/.mo/g') +PO_LINGUAS += $(patsubst $(srcdir)/Source/WebKit/gtk/po/%.po,%,$(POFILES)) + +USER_LINGUAS += $(filter $(LINGUAS),$(PO_LINGUAS)) + +USE_LINGUAS += $(shell if test -n "$(USER_LINGUAS)" -o -n "$(LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else LLINGUAS="$(PO_LINGUAS)"; fi; for lang in $$LLINGUAS; do printf "$$lang "; done) + +MOFILES += $(USE_LINGUAS:%=Source/WebKit/gtk/po/%.mo) + +ALL_MOFILES := $(shell echo $(POFILES) | tr ' ' '\n' | sed "s,^$(srcdir)/,,g" | sed 's/\.po/.mo/g') .po.mo: test -d Source/WebKit/gtk/po/ || mkdir -p Source/WebKit/gtk/po/ @@ -124,11 +132,11 @@ CLEANFILES += \ $(top_builddir)/stamp-po MAINTAINERCLEANFILES += \ - $(MOFILES) \ + $(ALL_MOFILES) \ $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot DISTCLEANFILES += \ - $(MOFILES) \ + $(ALL_MOFILES) \ $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot po-install-data-local: all diff --git a/Source/WebKit/gtk/tests/testcopyandpaste.c b/Source/WebKit/gtk/tests/testcopyandpaste.c index 7d8dd8f0d..f25969a73 100644 --- a/Source/WebKit/gtk/tests/testcopyandpaste.c +++ b/Source/WebKit/gtk/tests/testcopyandpaste.c @@ -126,6 +126,7 @@ static void test_copy_and_paste(CopyAndPasteFixture* fixture, gconstpointer data gtk_widget_show(fixture->window); gtk_widget_show(GTK_WIDGET(fixture->webView)); gtk_window_present(GTK_WINDOW(fixture->window)); + gtk_widget_grab_focus(GTK_WIDGET(fixture->webView)); g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_status_cb), fixture); diff --git a/Source/WebKit/gtk/tests/testwebinspector.c b/Source/WebKit/gtk/tests/testwebinspector.c index 40aa55334..86a35b937 100644 --- a/Source/WebKit/gtk/tests/testwebinspector.c +++ b/Source/WebKit/gtk/tests/testwebinspector.c @@ -62,7 +62,7 @@ static WebKitWebView* inspectElementCallback(WebKitWebInspector *inspector, WebK return WEBKIT_WEB_VIEW(newWebView); } -static gboolean closeInspector (WebKitWebInspector *inspector, int *timesClosed) +static gboolean closeInspector(WebKitWebInspector *inspector, int *timesClosed) { *timesClosed = *timesClosed + 1; @@ -70,23 +70,33 @@ static gboolean closeInspector (WebKitWebInspector *inspector, int *timesClosed) return TRUE; } -static gboolean showInspector (WebKitWebInspector *inspector, gpointer data) +static gboolean showInspector(WebKitWebInspector *inspector, gpointer data) { g_idle_add(quitLoop, NULL); return TRUE; } +static void loadFinished(WebKitWebView *webView, WebKitWebFrame *frame, gboolean *isLoadFinished) +{ + *isLoadFinished = TRUE; + if (g_main_loop_is_running(loop)) + g_main_loop_quit(loop); +} + static void test_webkit_web_inspector_close_and_inspect() { WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + loop = g_main_loop_new(NULL, TRUE); - WebKitWebSettings *settings = webkit_web_view_get_settings(webView); - g_object_set(settings, "enable-developer-extras", TRUE, NULL); - - webkit_web_view_load_string (webView, - "<html><body><p>woohoo</p></body></html>", - "text/html", "UTF-8", "file://"); + gboolean isLoadFinished = FALSE; + g_signal_connect(webView, "load-finished", G_CALLBACK(loadFinished), &isLoadFinished); + webkit_web_view_load_string(webView, + "<html><body><p>woohoo</p></body></html>", + "text/html", "UTF-8", "file://"); + if (!isLoadFinished) + g_main_loop_run(loop); + g_object_set(webkit_web_view_get_settings(webView), "enable-developer-extras", TRUE, NULL); WebKitWebInspector *inspector = webkit_web_view_get_inspector(webView); int timesElementInspected = 0; @@ -100,7 +110,6 @@ static void test_webkit_web_inspector_close_and_inspect() webkit_web_inspector_inspect_coordinates(inspector, 0.0, 0.0); g_assert_cmpint(timesElementInspected, ==, 1); - loop = g_main_loop_new(NULL, TRUE); g_main_loop_run(loop); webkit_web_inspector_close(inspector); @@ -120,14 +129,17 @@ static void test_webkit_web_inspector_close_and_inspect() static void test_webkit_web_inspector_destroy_inspected_web_view() { WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + loop = g_main_loop_new(NULL, TRUE); - WebKitWebSettings *settings = webkit_web_view_get_settings(webView); - g_object_set(settings, "enable-developer-extras", TRUE, NULL); - - webkit_web_view_load_string (webView, - "<html><body><p>woohoo</p></body></html>", - "text/html", "UTF-8", "file://"); + gboolean isLoadFinished = FALSE; + g_signal_connect(webView, "load-finished", G_CALLBACK(loadFinished), &isLoadFinished); + webkit_web_view_load_string(webView, + "<html><body><p>woohoo</p></body></html>", + "text/html", "UTF-8", "file://"); + if (!isLoadFinished) + g_main_loop_run(loop); + g_object_set(webkit_web_view_get_settings(webView), "enable-developer-extras", TRUE, NULL); WebKitWebInspector *inspector = webkit_web_view_get_inspector(webView); int timesElementInspected = 0; @@ -141,7 +153,6 @@ static void test_webkit_web_inspector_destroy_inspected_web_view() webkit_web_inspector_inspect_coordinates(inspector, 0.0, 0.0); g_assert_cmpint(timesElementInspected, ==, 1); - loop = g_main_loop_new(NULL, TRUE); g_main_loop_run(loop); gtk_widget_destroy(GTK_WIDGET(webView)); @@ -154,17 +165,11 @@ int main(int argc, char** argv) { gtk_test_init(&argc, &argv, NULL); - testutils_relative_chdir("Programs/resources/inspector/inspector.html", argv[0]); - - char *currentDir = g_get_current_dir(); - g_setenv("WEBKIT_INSPECTOR_PATH", currentDir, TRUE); - g_free(currentDir); - g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/webinspector/destroy-inspected-web-view", test_webkit_web_inspector_destroy_inspected_web_view); g_test_add_func("/webkit/webinspector/close-and-inspect", test_webkit_web_inspector_close_and_inspect); - return g_test_run (); + return g_test_run(); } #else diff --git a/Source/WebKit/gtk/tests/testwebview.c b/Source/WebKit/gtk/tests/testwebview.c index ab3bd5576..22dff131c 100644 --- a/Source/WebKit/gtk/tests/testwebview.c +++ b/Source/WebKit/gtk/tests/testwebview.c @@ -27,6 +27,8 @@ #include <glib.h> #include <glib/gstdio.h> +#include <gdk/gdk.h> +#include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> #include <webkit/webkit.h> @@ -389,7 +391,12 @@ static void test_webkit_web_view_does_not_steal_focus() GtkWidget *window = gtk_offscreen_window_new(); GtkWidget *webView = webkit_web_view_new(); GtkWidget *entry = gtk_entry_new(); + +#ifdef GTK_API_VERSION_2 + GtkWidget *box = gtk_hbox_new(FALSE, 0); +#else GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); +#endif gtk_container_add(GTK_CONTAINER(box), webView); gtk_container_add(GTK_CONTAINER(box), entry); @@ -424,8 +431,10 @@ static gboolean emitKeyStroke(WebKitWebView* webView) pressEvent->key.window = window; g_object_ref(pressEvent->key.window); +#ifndef GTK_API_VERSION_2 GdkDeviceManager* manager = gdk_display_get_device_manager(gdk_window_get_display(window)); gdk_event_set_device(pressEvent, gdk_device_manager_get_client_pointer(manager)); +#endif // When synthesizing an event, an invalid hardware_keycode value // can cause it to be badly processed by Gtk+. diff --git a/Source/WebKit/gtk/webkit/webkitwebframe.cpp b/Source/WebKit/gtk/webkit/webkitwebframe.cpp index 4de192704..39bdbb3aa 100644 --- a/Source/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebframe.cpp @@ -351,13 +351,13 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass) WEBKIT_TYPE_NETWORK_REQUEST, WEBKIT_TYPE_NETWORK_RESPONSE); - /* - * WebKitWebFrame::resource-response-received - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource being loaded + /** + * WebKitWebFrame::resource-response-received: + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource being loaded * @response: the #WebKitNetworkResponse that was received. * - * Emitted when the first byte of data arrives + * Emitted when the response is received from the server. * * Since: 1.7.5 */ @@ -371,10 +371,10 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass) WEBKIT_TYPE_WEB_RESOURCE, WEBKIT_TYPE_NETWORK_RESPONSE); - /* - * WebKitWebFrame::resource-load-finished - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource being loaded + /** + * WebKitWebFrame::resource-load-finished: + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource being loaded * * Emitted when all the data for the resource was loaded. * @@ -389,13 +389,16 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass) G_TYPE_NONE, 1, WEBKIT_TYPE_WEB_RESOURCE); - /* - * WebKitWebFrame::resource-content-length-received - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource that was loaded - * @lengthReceived: the resource data length in bytes + /** + * WebKitWebFrame::resource-content-length-received: + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource that was loaded + * @length_received: the amount of data received since the last signal emission * - * Emitted when all the data for the resource was loaded. + * Emitted when new resource data has been received. The + * @length_received variable stores the amount of bytes received + * since the last time this signal was emitted. This is useful to + * provide progress information about the resource load operation. * * Since: 1.7.5 */ @@ -409,11 +412,11 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass) WEBKIT_TYPE_WEB_RESOURCE, G_TYPE_INT); - /* - * WebKitWebFrame::resource-load-failed - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource that was loaded - * @webError: the #GError that was triggered + /** + * WebKitWebFrame::resource-load-failed: + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource that was loaded + * @error: the #GError that was triggered * * Invoked when a resource failed to load. * diff --git a/Source/WebKit/gtk/webkit/webkitwebresource.cpp b/Source/WebKit/gtk/webkit/webkitwebresource.cpp index f3239626b..4bd198077 100644 --- a/Source/WebKit/gtk/webkit/webkitwebresource.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebresource.cpp @@ -122,12 +122,12 @@ static void webkit_web_resource_class_init(WebKitWebResourceClass* webResourceCl gobject_class->get_property = webkit_web_resource_get_property; gobject_class->set_property = webkit_web_resource_set_property; - /* - * WebKitWebResource::response-received - * @webResource: the #WebKitWebResource being loaded + /** + * WebKitWebResource::response-received: + * @web_resource: the #WebKitWebResource being loaded * @response: the #WebKitNetworkResponse that was received * - * Emitted when the first byte of data arrives + * Emitted when the response is received from the server. * * Since: 1.7.5 */ @@ -140,12 +140,12 @@ static void webkit_web_resource_class_init(WebKitWebResourceClass* webResourceCl G_TYPE_NONE, 1, WEBKIT_TYPE_NETWORK_RESPONSE); - /* - * WebKitWebResource::load-failed - * @webResource: the #WebKitWebResource that was loaded - * @webError: the #GError that was triggered + /** + * WebKitWebResource::load-failed: + * @web_resource: the #WebKitWebResource that was loaded + * @error: the #GError that was triggered * - * Invoked when a resource failed to load + * Invoked when the @web_resource failed to load * * Since: 1.7.5 */ @@ -158,9 +158,9 @@ static void webkit_web_resource_class_init(WebKitWebResourceClass* webResourceCl G_TYPE_NONE, 1, G_TYPE_POINTER); - /* - * WebKitWebResource::load-finished - * @webResource: the #WebKitWebResource being loaded + /** + * WebKitWebResource::load-finished: + * @web_resource: the #WebKitWebResource being loaded * * Emitted when all the data for the resource was loaded * @@ -174,12 +174,15 @@ static void webkit_web_resource_class_init(WebKitWebResourceClass* webResourceCl g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - /* - * WebKitWebResource::content-length-received - * @webResource: the #WebKitWebResource that was loaded - * @lengthReceived: the resource data length in bytes + /** + * WebKitWebResource::content-length-received: + * @web_resource: the #WebKitWebResource that was loaded + * @length_received: the amount of data received since the last signal emission * - * Emitted when all the data for the resource was loaded + * Emitted when new resource data has been received. The + * @length_received variable stores the amount of bytes received + * since the last time this signal was emitted. This is useful to + * provide progress information about the resource load operation. * * Since: 1.7.5 */ diff --git a/Source/WebKit/gtk/webkit/webkitwebsettings.cpp b/Source/WebKit/gtk/webkit/webkitwebsettings.cpp index bf6ff600d..2531258b3 100644 --- a/Source/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -120,7 +120,8 @@ enum { PROP_ENABLE_DNS_PREFETCHING, PROP_ENABLE_WEBGL, PROP_ENABLE_WEB_AUDIO, - PROP_ENABLE_ACCELERATED_COMPOSITING + PROP_ENABLE_ACCELERATED_COMPOSITING, + PROP_ENABLE_SMOOTH_SCROLLING }; // Create a default user agent string @@ -953,6 +954,22 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) _("Whether WebKit prefetches domain names"), TRUE, flags)); + + /** + * WebKitWebSettings:enable-smooth-scrolling + * + * Enable or disable support for smooth scrolling. The current implementation relies upon + * CPU work to produce a smooth scrolling experience. + * + * Since: 1.9.0 + */ + g_object_class_install_property(gobject_class, + PROP_ENABLE_SMOOTH_SCROLLING, + g_param_spec_boolean("enable-smooth-scrolling", + _("Enable smooth scrolling"), + _("Whether to enable smooth scrolling"), + FALSE, + flags)); } static void webkit_web_settings_init(WebKitWebSettings* web_settings) @@ -1128,6 +1145,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_ENABLE_ACCELERATED_COMPOSITING: priv->enableAcceleratedCompositing = g_value_get_boolean(value); break; + case PROP_ENABLE_SMOOTH_SCROLLING: + priv->enableSmoothScrolling = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1293,6 +1313,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_ENABLE_ACCELERATED_COMPOSITING: g_value_set_boolean(value, priv->enableAcceleratedCompositing); break; + case PROP_ENABLE_SMOOTH_SCROLLING: + g_value_set_boolean(value, priv->enableSmoothScrolling); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; diff --git a/Source/WebKit/gtk/webkit/webkitwebsettingsprivate.h b/Source/WebKit/gtk/webkit/webkitwebsettingsprivate.h index d7d082e5b..240d79fad 100644 --- a/Source/WebKit/gtk/webkit/webkitwebsettingsprivate.h +++ b/Source/WebKit/gtk/webkit/webkitwebsettingsprivate.h @@ -80,6 +80,7 @@ struct _WebKitWebSettingsPrivate { gboolean enableWebgl; gboolean enableWebAudio; gboolean enableAcceleratedCompositing; + gboolean enableSmoothScrolling; }; WEBKIT_API void webkit_web_settings_add_extra_plugin_directory(WebKitWebView*, const gchar* directory); diff --git a/Source/WebKit/gtk/webkit/webkitwebview.cpp b/Source/WebKit/gtk/webkit/webkitwebview.cpp index 89b9c228f..880f24438 100644 --- a/Source/WebKit/gtk/webkit/webkitwebview.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebview.cpp @@ -1416,6 +1416,19 @@ static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget) return axRoot; } +static double screenDPI(GdkScreen* screen) +{ + // gdk_screen_get_resolution() returns -1 when no DPI is set. + double dpi = gdk_screen_get_resolution(screen); + if (dpi != -1) + return dpi; + + static const double kMillimetresPerInch = 25.4; + double diagonalSizeInPixels = hypot(gdk_screen_get_width(screen), gdk_screen_get_height(screen)); + double diagonalSizeInInches = hypot(gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm(screen)) / kMillimetresPerInch; + return diagonalSizeInPixels / diagonalSizeInInches; +} + static gdouble webViewGetDPI(WebKitWebView* webView) { if (webView->priv->webSettings->priv->enforce96DPI) @@ -1423,12 +1436,12 @@ static gdouble webViewGetDPI(WebKitWebView* webView) static const double defaultDPI = 96; GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default(); - if (!screen) - return defaultDPI; + return screen ? screenDPI(screen) : defaultDPI; +} - // gdk_screen_get_resolution() returns -1 when no DPI is set. - gdouble DPI = gdk_screen_get_resolution(screen); - return DPI != -1 ? DPI : defaultDPI; +static inline gint webViewConvertFontSizeToPixels(WebKitWebView* webView, double fontSize) +{ + return fontSize / 72.0 * webViewGetDPI(webView); } static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen) @@ -1441,8 +1454,6 @@ static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previou WebKitWebSettings* webSettings = priv->webSettings.get(); Settings* settings = core(webView)->settings(); - gdouble DPI = webViewGetDPI(webView); - guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize; g_object_get(webSettings, @@ -1452,10 +1463,10 @@ static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previou "minimum-logical-font-size", &minimumLogicalFontSize, NULL); - settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI); - settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI); - settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI); - settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI); + settings->setDefaultFontSize(webViewConvertFontSizeToPixels(webView, defaultFontSize)); + settings->setDefaultFixedFontSize(webViewConvertFontSizeToPixels(webView, defaultMonospaceFontSize)); + settings->setMinimumFontSize(webViewConvertFontSizeToPixels(webView, minimumFontSize)); + settings->setMinimumLogicalFontSize(webViewConvertFontSizeToPixels(webView, minimumLogicalFontSize)); } static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) @@ -2520,8 +2531,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * purpose, to make them not be catched by gtk-doc. */ - /* - * WebKitWebView::document-load-finished + /** + * WebKitWebView::document-load-finished: * @web_view: the object which received the signal * @web_frame: the #WebKitWebFrame whose load dispatched this request * @@ -2537,8 +2548,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) G_TYPE_NONE, 1, WEBKIT_TYPE_WEB_FRAME); - /* - * WebKitWebView::frame-created + /** + * WebKitWebView::frame-created: * @web_view: the object which received the signal * @web_frame: the #WebKitWebFrame which was just created. * @@ -2720,11 +2731,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT); - /* - * WebKitWebView::resource-response-received - * @webView: the object which received the signal - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource being loaded + /** + * WebKitWebView::resource-response-received: + * @web_view: the object which received the signal + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource being loaded * @response: the #WebKitNetworkResponse that was received * * Emitted when the first byte of data arrives @@ -2742,11 +2753,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_RESOURCE, WEBKIT_TYPE_NETWORK_RESPONSE); - /* - * WebKitWebView::resource-load-finished - * @webView: the object which received the signal - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource that was loaded + /** + * WebKitWebView::resource-load-finished: + * @web_view: the object which received the signal + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource that was loaded * * Emitted when all the data for the resource was loaded * @@ -2762,15 +2773,17 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_FRAME, WEBKIT_TYPE_WEB_RESOURCE); - /* - * WebKitWebView::resource-content-length-received - * @webView: the object which received the signal - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource that was loaded - * @lengthReceived: the resource data length in bytes + /** + * WebKitWebView::resource-content-length-received: + * @web_view: the object which received the signal + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource that was loaded + * @length_received: the amount of data received since the last signal emission * - * Emitted when the HTTP Content-Length response header has been - * received and parsed successfully. + * Emitted when new resource data has been received. The + * @length_received variable stores the amount of bytes received + * since the last time this signal was emitted. This is useful to + * provide progress information about the resource load operation. * * Since: 1.7.5 */ @@ -2785,12 +2798,12 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_RESOURCE, G_TYPE_INT); - /* - * WebKitWebView::resource-load-failed - * @webView: the object which received the signal - * @webFrame: the #WebKitWebFrame the response was received for - * @webResource: the #WebKitWebResource that was loaded - * @webError: the #GError that was triggered + /** + * WebKitWebView::resource-load-failed: + * @web_view: the object which received the signal + * @web_frame: the #WebKitWebFrame the response was received for + * @web_resource: the #WebKitWebResource that was loaded + * @error: the #GError that was triggered * * Invoked when a resource failed to load * @@ -3330,17 +3343,16 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) coreSettings->setUseHixie76WebSocketProtocol(false); #endif +#if ENABLE(SMOOTH_SCROLLING) + coreSettings->setEnableScrollAnimator(settingsPrivate->enableSmoothScrolling); +#endif + if (Page* page = core(webView)) page->setTabKeyCyclesThroughElements(settingsPrivate->tabKeyCyclesThroughElements); webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL); } -static inline gint pixelsFromSize(WebKitWebView* webView, gint size) -{ - return size / 72.0 * webViewGetDPI(webView); -} - static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView) { Settings* settings = core(webView)->settings(); @@ -3365,13 +3377,13 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar else if (name == g_intern_string("serif-font-family")) settings->setSerifFontFamily(g_value_get_string(&value)); else if (name == g_intern_string("default-font-size")) - settings->setDefaultFontSize(pixelsFromSize(webView, g_value_get_int(&value))); + settings->setDefaultFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); else if (name == g_intern_string("default-monospace-font-size")) - settings->setDefaultFixedFontSize(pixelsFromSize(webView, g_value_get_int(&value))); + settings->setDefaultFixedFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); else if (name == g_intern_string("minimum-font-size")) - settings->setMinimumFontSize(pixelsFromSize(webView, g_value_get_int(&value))); + settings->setMinimumFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); else if (name == g_intern_string("minimum-logical-font-size")) - settings->setMinimumLogicalFontSize(pixelsFromSize(webView, g_value_get_int(&value))); + settings->setMinimumLogicalFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); else if (name == g_intern_string("enforce-96-dpi")) webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL); else if (name == g_intern_string("auto-load-images")) @@ -3464,6 +3476,11 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar settings->setWebAudioEnabled(g_value_get_boolean(&value)); #endif +#if ENABLE(SMOOTH_SCROLLING) + else if (name == g_intern_string("enable-smooth-scrolling")) + settings->setEnableScrollAnimator(g_value_get_boolean(&value)); +#endif + else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name)) g_warning("Unexpected setting '%s'", name); g_value_unset(&value); @@ -5099,7 +5116,7 @@ void webViewEnterFullscreen(WebKitWebView* webView, Node* node) if (!node->hasTagName(HTMLNames::videoTag)) return; -#if ENABLE(VIDEO) +#if ENABLE(VIDEO) && !defined(GST_API_VERSION_1) HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node); WebKitWebViewPrivate* priv = webView->priv; @@ -5115,7 +5132,7 @@ void webViewEnterFullscreen(WebKitWebView* webView, Node* node) void webViewExitFullscreen(WebKitWebView* webView) { -#if ENABLE(VIDEO) +#if ENABLE(VIDEO) && !defined(GST_API_VERSION_1) WebKitWebViewPrivate* priv = webView->priv; if (priv->fullscreenVideoController) priv->fullscreenVideoController->exitFullscreen(); diff --git a/Source/WebKit/gtk/webkit/webkitwebviewprivate.h b/Source/WebKit/gtk/webkit/webkitwebviewprivate.h index 75ba14cbe..2967da92f 100644 --- a/Source/WebKit/gtk/webkit/webkitwebviewprivate.h +++ b/Source/WebKit/gtk/webkit/webkitwebviewprivate.h @@ -80,7 +80,7 @@ struct _WebKitWebViewPrivate { gboolean disposing; -#if ENABLE(VIDEO) +#if ENABLE(VIDEO) && !defined(GST_API_VERSION_1) FullscreenVideoController* fullscreenVideoController; #endif diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog index 898482ec1..cdef8f903 100644 --- a/Source/WebKit/mac/ChangeLog +++ b/Source/WebKit/mac/ChangeLog @@ -1,3 +1,433 @@ +2012-03-11 Timothy Hatcher <timothy@apple.com> + + Update how the Web Inspector resources are loaded. + + https://bugs.webkit.org/show_bug.cgi?id=80798 + rdar://problem/10359959 + + Reviewed by Brian Weinstein. + + * WebCoreSupport/WebInspectorClient.mm: + (useWebKitWebInspector): Return if we are using the WebCore resources for compatibility + with local and nightly builds. + (WebInspectorFrontendClient::localizedStringsURL): Decide what path to use. + (-[WebInspectorWindowController init]): Ditto. + (-[WebInspectorWindowController window]): Decide if the window is textured or not. + +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * WebCoreSupport/WebNotificationClient.h: + * WebCoreSupport/WebNotificationClient.mm: + (WebNotificationClient::checkPermission): + * WebView/WebViewPrivate.h: + +2012-03-09 Enrica Casucci <enrica@apple.com> + + Move WebNSURLExtras code down to WebCore. + https://bugs.webkit.org/show_bug.cgi?id=80611 + + Reviewed by Alexey Proskuryakov. + + Changed the implementation to use newly moved WebCore functions. + + * Misc/WebKitNSStringExtras.mm: + (-[NSString _webkit_hasCaseInsensitivePrefix:]): + * Misc/WebNSURLExtras.mm: + (+[NSURL _web_URLWithUserTypedString:]): + (+[NSURL _web_URLWithDataAsString:relativeToURL:]): + (+[NSURL _web_URLWithData:]): + (+[NSURL _web_URLWithData:relativeToURL:]): + (-[NSURL _web_originalData]): + (-[NSURL _web_originalDataAsString]): + (-[NSURL _web_userVisibleString]): + (-[NSURL _web_isEmpty]): + (-[NSURL _web_URLCString]): + (-[NSURL _web_URLByTruncatingOneCharacterBeforeComponent:]): + (-[NSURL _webkit_URLByRemovingFragment]): + (-[NSURL _webkit_URLByRemovingResourceSpecifier]): + (-[NSURL _web_URLByRemovingUserInfo]): + (-[NSURL _web_dataForURLComponentType:]): + (-[NSURL _web_schemeData]): + (-[NSURL _web_hostData]): + (-[NSString _web_isUserVisibleURL]): + (-[NSString _web_hostNameNeedsDecodingWithRange:]): + (-[NSString _web_hostNameNeedsEncodingWithRange:]): + (-[NSString _web_decodeHostNameWithRange:]): + (-[NSString _web_encodeHostNameWithRange:]): + (-[NSString _web_decodeHostName]): + (-[NSString _web_encodeHostName]): + * WebCoreSupport/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2012-03-09 Emil A Eklund <eae@chromium.org> + + Add roundedPoint to HitTestResult and change platform code to use it + https://bugs.webkit.org/show_bug.cgi?id=80715 + + Reviewed by James Robinson. + + Change ports to use roundedPoint to avoid exposing subpixel types to + platform code. + + * WebCoreSupport/WebContextMenuClient.mm: + (WebContextMenuClient::showContextMenu): + +2012-03-09 Jon Lee <jonlee@apple.com> + + Add support for ENABLE(LEGACY_NOTIFICATIONS) + https://bugs.webkit.org/show_bug.cgi?id=80497 + + Reviewed by Adam Barth. + + Prep for b80472: Update API for Web Notifications + * Configurations/FeatureDefines.xcconfig: + +2012-03-08 Ryosuke Niwa <rniwa@webkit.org> + + Mac build fix for micro data API. + + * Configurations/FeatureDefines.xcconfig: + +2012-03-08 Jer Noble <jer.noble@apple.com> + + Unreviewed Snow Leopard build fix. + + On Leopard and Snow Leopard, provide an implementation for -[NSWindow convertRectToScreen:]. + + * WebView/WebFullScreenController.mm: + (-[NSWindow convertRectToScreen:]): + +2012-02-20 Jer Noble <jer.noble@apple.com> + + Full Screen Refactor Part 4: Animate into Full Screen mode using new animation classes, WebKit edition. + https://bugs.webkit.org/show_bug.cgi?id=78930 + + Reviewed by Anders Carlsson. + + Revise WebFullScreenController to have the same general functionality and code path as WKFullScreenWindowController + in WebKit2. As such, the following functions are copies of their equivalents in WKFullScreenWindowController: + * WebView/WebFullScreenController.mm: + (-[WebFullScreenController init]): + (-[WebFullScreenController dealloc]): + (-[WebFullScreenController windowDidLoad]): + (-[WebFullScreenController cancelOperation:]): + (-[WebFullScreenController applicationDidResignActive:]): + (-[WebFullScreenController applicationDidChangeScreenParameters:]): + (-[WebFullScreenController finishedEnterFullScreenAnimation:]): + (-[WebFullScreenController finishedExitFullScreenAnimation:]): + (-[WebFullScreenController close]): + (-[WebFullScreenController animationDidEnd:]): + (-[WebFullScreenController _updateMenuAndDockForFullScreen]): + (-[WebFullScreenController _swapView:with:]): + (createBackgroundFullscreenWindow): + (windowFrameFromApparentFrames): + (-[WebFullScreenController _startEnterFullScreenAnimationWithDuration:]): + (-[WebFullScreenController _startExitFullScreenAnimationWithDuration:]): + + The following is a copy of the equivalent function in WebFullScreenManager: + * WebView/WebFullScreenController.mm: + (screenRectOfContents): + + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::fullScreenRendererChanged): No longer tell the WebView the renderer changed (as it doesn't care.) + * WebView/WebFullScreenController.h: + * WebView/WebFullScreenController.mm: + (-[WebFullScreenController setElement:]): No need to add event listeners to the media element. + (-[WebFullScreenController enterFullScreen:]): Same as WKFullScreenWindowController, but not asynchronous. + (-[WebFullScreenController exitFullScreen]): Ditto. + * WebView/WebView.mm: + (-[WebView _enterFullScreenForElement:WebCore::]): Fullscreen -> FullScreen. + (-[WebView _exitFullScreenForElement:WebCore::]): Ditto. + +2012-03-08 Matt Lilek <mrl@apple.com> + + Don't enable VIDEO_TRACK on all OS X platforms + https://bugs.webkit.org/show_bug.cgi?id=80635 + + Reviewed by Eric Carlson. + + * Configurations/FeatureDefines.xcconfig: + +2012-03-07 Joseph Pecoraro <pecoraro@apple.com> + + <http://webkit.org/b/80510> Web Inspector crash (iCab) + + Reviewed by Timothy Hatcher. + + * WebCoreSupport/WebInspectorClient.mm: + (WebInspectorClient::didResizeMainFrame): + +2012-03-06 Benjamin Poulain <bpoulain@apple.com> + + [Mac] Update the configuration files for iOS + https://bugs.webkit.org/show_bug.cgi?id=80435 + + Reviewed by David Kilzer. + + * Configurations/WebKit.xcconfig: + +2012-03-06 Eric Seidel <eric@webkit.org> + + Make WTF public headers use fully-qualified include paths and remove ForwardingHeaders/wtf + https://bugs.webkit.org/show_bug.cgi?id=80363 + + Reviewed by Mark Rowe. + + ForwardingHeaders/wtf is no longer necessary (or functional) now that JavaScriptCore + no longer includes the WTF headers as private headers. + + * ForwardingHeaders/wtf/ASCIICType.h: Removed. + * ForwardingHeaders/wtf/AlwaysInline.h: Removed. + * ForwardingHeaders/wtf/Assertions.h: Removed. + * ForwardingHeaders/wtf/Deque.h: Removed. + * ForwardingHeaders/wtf/DisallowCType.h: Removed. + * ForwardingHeaders/wtf/FastMalloc.h: Removed. + * ForwardingHeaders/wtf/Forward.h: Removed. + * ForwardingHeaders/wtf/GetPtr.h: Removed. + * ForwardingHeaders/wtf/HashCountedSet.h: Removed. + * ForwardingHeaders/wtf/HashMap.h: Removed. + * ForwardingHeaders/wtf/HashSet.h: Removed. + * ForwardingHeaders/wtf/HashTraits.h: Removed. + * ForwardingHeaders/wtf/ListHashSet.h: Removed. + * ForwardingHeaders/wtf/ListRefPtr.h: Removed. + * ForwardingHeaders/wtf/Locker.h: Removed. + * ForwardingHeaders/wtf/MathExtras.h: Removed. + * ForwardingHeaders/wtf/Noncopyable.h: Removed. + * ForwardingHeaders/wtf/OwnArrayPtr.h: Removed. + * ForwardingHeaders/wtf/OwnPtr.h: Removed. + * ForwardingHeaders/wtf/OwnPtrCommon.h: Removed. + * ForwardingHeaders/wtf/PassOwnPtr.h: Removed. + * ForwardingHeaders/wtf/PassRefPtr.h: Removed. + * ForwardingHeaders/wtf/Platform.h: Removed. + * ForwardingHeaders/wtf/RefCounted.h: Removed. + * ForwardingHeaders/wtf/RefCountedLeakCounter.h: Removed. + * ForwardingHeaders/wtf/RefPtr.h: Removed. + * ForwardingHeaders/wtf/RetainPtr.h: Removed. + * ForwardingHeaders/wtf/StdLibExtras.h: Removed. + * ForwardingHeaders/wtf/TemporaryChange.h: Removed. + * ForwardingHeaders/wtf/Threading.h: Removed. + * ForwardingHeaders/wtf/UnusedParam.h: Removed. + * ForwardingHeaders/wtf/VMTags.h: Removed. + * ForwardingHeaders/wtf/ValueCheck.h: Removed. + * ForwardingHeaders/wtf/Vector.h: Removed. + * ForwardingHeaders/wtf/VectorTraits.h: Removed. + * ForwardingHeaders/wtf/unicode/Unicode.h: Removed. + * ForwardingHeaders/wtf/unicode/icu/UnicodeIcu.h: Removed. + +2012-03-05 Joseph Pecoraro <pecoraro@apple.com> + + Web Inspector: Hide dock button when not allowed to dock + https://bugs.webkit.org/show_bug.cgi?id=78575 + + Reviewed by Pavel Feldman. + + * WebCoreSupport/WebInspectorClient.h: + (WebCore): + (WebInspectorClient): + * WebCoreSupport/WebInspectorClient.mm: + (WebInspectorClient::didResizeMainFrame): + +2012-03-05 Gavin Barraclough <barraclough@apple.com> + + putByIndex should throw in strict mode + https://bugs.webkit.org/show_bug.cgi?id=80335 + + Reviewed by Filip Pizlo. + + Make the MethodTable PutByIndex trap take a boolean 'shouldThrow' parameter. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::setProperty): + +2012-03-05 Joseph Pecoraro <pecoraro@apple.com> + + Unreviewed rollout of r109858 for restructuring. + +2012-03-05 Joseph Pecoraro <pecoraro@apple.com> + + <http://webkit.org/b/78575> Web Inspector: Hide dock button when not allowed to dock + + Reviewed by Timothy Hatcher. + + * WebCoreSupport/WebInspectorClient.h: + (WebInspectorClient): + * WebCoreSupport/WebInspectorClient.mm: + (WebInspectorClient::updateDockingAvailability): + +2012-03-02 Jon Lee <jonlee@apple.com> + + Add support for notification replaceId in Mac WebKit and WK2 + https://bugs.webkit.org/show_bug.cgi?id=80206 + <rdar://problem/10965574> + + Reviewed by Sam Weinig. + + * WebView/WebNotification.h: Add replaceID method. + * WebView/WebNotification.mm: + (-[WebNotification replaceID]): + +2012-03-05 Adam Barth <abarth@webkit.org> + + Geolocation should use a ScriptExecutionContext as its context object + https://bugs.webkit.org/show_bug.cgi?id=80248 + + Reviewed by Kentaro Hara. + + * WebView/WebFrame.mm: + (-[WebFrame _cacheabilityDictionary]): + - We no longer special-case Geolocation. + +2012-03-03 Benjamin Poulain <benjamin@webkit.org> + + Remove the redundant method KURL::protocolInHTTPFamily() + https://bugs.webkit.org/show_bug.cgi?id=80216 + + Reviewed by Anders Carlsson. + + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::createPlugin): + +2012-03-03 Hans Wennborg <hans@chromium.org> + + Implement Speech JavaScript API + https://bugs.webkit.org/show_bug.cgi?id=80019 + + Reviewed by Adam Barth. + + Add ENABLE_SCRIPTED_SPEECH. + + * Configurations/FeatureDefines.xcconfig: + +2012-03-03 Anders Carlsson <andersca@apple.com> + + Fix build with newer versions of clang. + + * Panels/WebAuthenticationPanel.m: + (-[WebAuthenticationPanel setUpForChallenge:]): + Use %ld and cast to long. + + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView getVariable:value:]): + Cast the switch parameter to unsigned to prevent warnings about case values not being part of the enum type. + +2012-03-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Unreviewed, rolling out r109255. + http://trac.webkit.org/changeset/109255 + https://bugs.webkit.org/show_bug.cgi?id=79932 + + Breaks rounded rects with dashed strokes in SVG + + * WebCoreSupport/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2012-02-29 Adam Barth <abarth@webkit.org> + + ScriptExecutionContext has too many ifdef ENABLE(SQL_DATABASE) + https://bugs.webkit.org/show_bug.cgi?id=79633 + + Reviewed by Eric Seidel. + + * WebView/WebFrame.mm: + (-[WebFrame _cacheabilityDictionary]): + +2012-02-29 Tim Horton <timothy_horton@apple.com> + + Make use of CG rounded-rect primitives + https://bugs.webkit.org/show_bug.cgi?id=79932 + <rdar://problem/9274953> + + Reviewed by Simon Fraser. + + Add wkCGPathAddRoundedRect. + + * WebCoreSupport/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2012-02-29 Enrica Casucci <enrica@apple.com> + + Crash at -[WebFrame(WebInternal) _setTypingStyle:withUndoAction:] + https://bugs.webkit.org/show_bug.cgi?id=79937 + <rdar://problem/10942936> + + Reviewed by Dan Bernstein. + + * WebView/WebFrame.mm: + (-[WebFrame _setTypingStyle:withUndoAction:]): Adding a null check. + +2012-02-28 Simon Fraser <simon.fraser@apple.com> + + Update WebKitSystemInterface. + + Reviewed by Sam Weinig. + + * WebCoreSupport/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2012-02-28 Enrica Casucci <enrica@apple.com> + + More Pasteboard code cleanup. + https://bugs.webkit.org/show_bug.cgi?id=79816 + + Removing the last references to NSPasteboard. + + Reviewed by Alexey Proskuryakov. + + * WebCoreSupport/WebEditorClient.h: + * WebCoreSupport/WebEditorClient.mm: + (WebEditorClient::setInsertionPasteboard): + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/WebContextMenuClient.h: + (WebContextMenuClient): + * WebCoreSupport/WebContextMenuClient.mm: + (WebContextMenuClient::showContextMenu): Moved from WebChromeClient + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + +2012-02-25 Sam Weinig <sam@webkit.org> + + QuickLook events don't make it to WebKit plugins. + <rdar://problem/10931721> + + Reviewed by Anders Carlsson. + + * WebView/WebHTMLView.mm: + (isQuickLookEvent): + (-[WebHTMLView hitTest:]): + Allow QuickLook events to hit test down to subviews. + +2012-02-24 Brady Eidson <beidson@apple.com> + + <rdar://problem/10805709> and https://bugs.webkit.org/show_bug.cgi?id=79421 + Need a WK1 Mac API to filter which subframes go into WebArchives as they are created + + Reviewed by Sam Weinig (with additional comments by Adam Roben) + + Add webArchiveByFilteringSubframes: which takes a callback block: + * DOM/WebDOMOperationsPrivate.h: + + Add FrameFilter that adapts the block, and use it to implement the new SPI: + * DOM/WebDOMOperations.mm: + (WebFrameFilter): + (WebFrameFilter::WebFrameFilter): + (WebFrameFilter::~WebFrameFilter): + (WebFrameFilter::shouldIncludeSubframe): + (-[DOMNode webArchiveByFilteringSubframes:]): + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig b/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig index 3e2090355..58a02f521 100644 --- a/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig +++ b/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig @@ -90,12 +90,14 @@ ENABLE_INDEXED_DATABASE = ; ENABLE_INPUT_COLOR = ; ENABLE_INPUT_SPEECH = ; ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER; +ENABLE_LEGACY_NOTIFICATIONS = ENABLE_LEGACY_NOTIFICATIONS; ENABLE_LINK_PREFETCH = ; ENABLE_MATHML = ENABLE_MATHML; ENABLE_MEDIA_SOURCE = ; ENABLE_MEDIA_STATISTICS = ; ENABLE_METER_TAG = ENABLE_METER_TAG; ENABLE_MHTML = ; +ENABLE_MICRODATA = ; ENABLE_MUTATION_OBSERVERS = ENABLE_MUTATION_OBSERVERS; ENABLE_NOTIFICATIONS = $(ENABLE_NOTIFICATIONS_$(REAL_PLATFORM_NAME)); @@ -109,6 +111,7 @@ ENABLE_PROGRESS_TAG = ENABLE_PROGRESS_TAG; ENABLE_QUOTA = ; ENABLE_REGISTER_PROTOCOL_HANDLER = ; ENABLE_REQUEST_ANIMATION_FRAME = ENABLE_REQUEST_ANIMATION_FRAME; +ENABLE_SCRIPTED_SPEECH = ; ENABLE_SHADOW_DOM = ; ENABLE_SHARED_WORKERS = ENABLE_SHARED_WORKERS; ENABLE_SQL_DATABASE = ENABLE_SQL_DATABASE; @@ -118,7 +121,10 @@ ENABLE_SVG_FONTS = ENABLE_SVG_FONTS; ENABLE_TEXT_NOTIFICATIONS_ONLY = ENABLE_TEXT_NOTIFICATIONS_ONLY; ENABLE_TOUCH_ICON_LOADING = ; ENABLE_VIDEO = ENABLE_VIDEO; -ENABLE_VIDEO_TRACK = ENABLE_VIDEO_TRACK; + +ENABLE_VIDEO_TRACK = $(ENABLE_VIDEO_TRACK_$(REAL_PLATFORM_NAME)); +ENABLE_VIDEO_TRACK_macosx = ENABLE_VIDEO_TRACK; + ENABLE_WEBGL = ENABLE_WEBGL; ENABLE_WEB_AUDIO = ENABLE_WEB_AUDIO; ENABLE_WEB_SOCKETS = ENABLE_WEB_SOCKETS; @@ -126,4 +132,4 @@ ENABLE_WEB_TIMING = ; ENABLE_WORKERS = ENABLE_WORKERS; ENABLE_XSLT = ENABLE_XSLT; -FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_ANIMATION_API) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_GRID_LAYOUT) $(ENABLE_CSS_SHADERS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_COLOR) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LINK_PREFETCH) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_TAG) $(ENABLE_MUTATION_OBSERVERS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PROGRESS_TAG) $(ENABLE_QUOTA) $(ENABLE_REGISTER_PROTOCOL_HANDLER) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XSLT); +FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_ANIMATION_API) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_GRID_LAYOUT) $(ENABLE_CSS_SHADERS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_COLOR) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LINK_PREFETCH) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_TAG) $(ENABLE_MICRODATA) $(ENABLE_MUTATION_OBSERVERS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PROGRESS_TAG) $(ENABLE_QUOTA) $(ENABLE_REGISTER_PROTOCOL_HANDLER) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XSLT); diff --git a/Source/WebKit/mac/Configurations/Version.xcconfig b/Source/WebKit/mac/Configurations/Version.xcconfig index 5344a720d..be7e0399c 100644 --- a/Source/WebKit/mac/Configurations/Version.xcconfig +++ b/Source/WebKit/mac/Configurations/Version.xcconfig @@ -21,8 +21,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -MAJOR_VERSION = 535; -MINOR_VERSION = 23; +MAJOR_VERSION = 536; +MINOR_VERSION = 3; TINY_VERSION = 0; FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION); diff --git a/Source/WebKit/mac/Configurations/WebKit.xcconfig b/Source/WebKit/mac/Configurations/WebKit.xcconfig index 0a0cf9f41..41ab11f37 100644 --- a/Source/WebKit/mac/Configurations/WebKit.xcconfig +++ b/Source/WebKit/mac/Configurations/WebKit.xcconfig @@ -30,9 +30,8 @@ EXCLUDED_SOURCE_FILE_NAMES_iphonesimulator = $(EXCLUDED_SOURCE_FILE_NAMES_iphone EXPORTED_SYMBOLS_FILE = $(EXPORTED_SYMBOLS_FILE_$(CURRENT_ARCH)); EXPORTED_SYMBOLS_FILE_ = mac/WebKit.exp; -EXPORTED_SYMBOLS_FILE_armv5 = mac/WebKit.exp; -EXPORTED_SYMBOLS_FILE_armv6 = mac/WebKit.exp; -EXPORTED_SYMBOLS_FILE_armv7 = mac/WebKit.exp; +EXPORTED_SYMBOLS_FILE_armv6 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp; +EXPORTED_SYMBOLS_FILE_armv7 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp; EXPORTED_SYMBOLS_FILE_i386 = mac/WebKit.exp; EXPORTED_SYMBOLS_FILE_ppc = mac/WebKit.exp; EXPORTED_SYMBOLS_FILE_ppc64 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.LP64.exp; @@ -54,15 +53,22 @@ GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) FRAMEWORK_NAM HEADER_SEARCH_PATHS = $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(WEBCORE_PRIVATE_HEADERS_DIR)/icu $(WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH) "${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit" $(HEADER_SEARCH_PATHS); INFOPLIST_FILE = mac/Info.plist; INSTALL_PATH = $(INSTALL_PATH_$(REAL_PLATFORM_NAME)); +INSTALL_PATH_iphoneos = $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks; +INSTALL_PATH_iphonesimulator = $(INDIGO_INSTALL_PATH_PREFIX)$(INSTALL_PATH_ACTUAL); INSTALL_PATH_macosx = $(WEBKIT_FRAMEWORKS_DIR); -DYLIB_INSTALL_NAME_BASE = $(NORMAL_WEBKIT_FRAMEWORKS_DIR); +INSTALL_PATH_ACTUAL = $(INSTALL_PATH_ACTUAL_$(REAL_PLATFORM_NAME)); +INSTALL_PATH_ACTUAL_iphonesimulator = $(INSTALL_PATH_iphoneos); +DYLIB_INSTALL_NAME_BASE = $(DYLIB_INSTALL_NAME_BASE_$(REAL_PLATFORM_NAME)); +DYLIB_INSTALL_NAME_BASE_macosx = $(NORMAL_WEBKIT_FRAMEWORKS_DIR); +DYLIB_INSTALL_NAME_BASE_iphoneos = $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks; +DYLIB_INSTALL_NAME_BASE_iphonesimulator = $(SDKROOT)$(DYLIB_INSTALL_NAME_BASE_iphoneos); INSTALLHDRS_COPY_PHASE = YES; INSTALLHDRS_SCRIPT_PHASE = YES; PRODUCT_NAME = WebKit; UMBRELLA_FRAMEWORKS_DIR = $(PRODUCTION_FRAMEWORKS_DIR)/WebKit.framework/Versions/A/Frameworks; OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(REAL_PLATFORM_NAME)); -OTHER_LDFLAGS_iphoneos = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework Foundation -framework GraphicsServices -framework ImageIO -framework WebCore; +OTHER_LDFLAGS_iphoneos = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework QuartzCore; OTHER_LDFLAGS_iphonesimulator = $(OTHER_LDFLAGS_iphoneos); OTHER_LDFLAGS_macosx = -sub_umbrella WebCore $(OTHER_LDFLAGS) $(OTHER_LDFLAGS_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR)); OTHER_LDFLAGS_macosx_1070 = -Xlinker -objc_gc_compaction; @@ -83,7 +89,7 @@ WEBKIT_FRAMEWORKS_DIR_macosx_USE_STAGING_INSTALL_PATH_NO = $(NORMAL_WEBKIT_FRAME WEBKIT_FRAMEWORKS_DIR_macosx_USE_STAGING_INSTALL_PATH_YES = $(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari; NORMAL_PRODUCTION_FRAMEWORKS_DIR = $(NORMAL_PRODUCTION_FRAMEWORKS_DIR_$(REAL_PLATFORM_NAME)); -NORMAL_PRODUCTION_FRAMEWORKS_DIR_iphoneos = $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks; +NORMAL_PRODUCTION_FRAMEWORKS_DIR_iphoneos = $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks; NORMAL_PRODUCTION_FRAMEWORKS_DIR_iphonesimulator = $(NORMAL_PRODUCTION_FRAMEWORKS_DIR_iphoneos); NORMAL_PRODUCTION_FRAMEWORKS_DIR_macosx = $(NEXT_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks; @@ -117,5 +123,8 @@ WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH = $(WEBKITSYSTEMINTERFA WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_Debug = $(WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering); WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_Release = $(WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering); WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_Production = $(PRODUCTION_ROOT)/usr/local/include; -WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering = $(BUILT_PRODUCTS_DIR)/usr/local/include; +WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering = $(WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering_$(REAL_PLATFORM_NAME)); +WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering_iphoneos = $(BUILT_PRODUCTS_DIR)/usr/local/include; +WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering_iphonesimulator = $(BUILT_PRODUCTS_DIR)$(PRODUCTION_ROOT_iphonesimulator)/usr/local/include; +WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH_engineering_macosx = $(BUILT_PRODUCTS_DIR)/usr/local/include; diff --git a/Source/WebKit/mac/DOM/WebDOMOperations.mm b/Source/WebKit/mac/DOM/WebDOMOperations.mm index 5ea99461f..d3b254500 100644 --- a/Source/WebKit/mac/DOM/WebDOMOperations.mm +++ b/Source/WebKit/mac/DOM/WebDOMOperations.mm @@ -35,10 +35,12 @@ #import "WebArchiveInternal.h" #import "WebDataSourcePrivate.h" #import "WebFrameInternal.h" +#import "WebFrameLoaderClient.h" #import "WebFramePrivate.h" #import "WebKitNSStringExtras.h" #import <JavaScriptCore/APICast.h> #import <WebCore/Document.h> +#import <WebCore/Frame.h> #import <WebCore/HTMLInputElement.h> #import <WebCore/HTMLParserIdioms.h> #import <WebCore/JSElement.h> @@ -76,6 +78,35 @@ using namespace JSC; @end +class WebFrameFilter : public WebCore::FrameFilter { +public: + WebFrameFilter(WebArchiveSubframeFilter filterBlock); + ~WebFrameFilter(); +private: + virtual bool shouldIncludeSubframe(Frame*) const OVERRIDE; + + WebArchiveSubframeFilter m_filterBlock; +}; + +WebFrameFilter::WebFrameFilter(WebArchiveSubframeFilter filterBlock) + : m_filterBlock(Block_copy(filterBlock)) +{ +} + +WebFrameFilter::~WebFrameFilter() +{ + Block_release(m_filterBlock); +} + +bool WebFrameFilter::shouldIncludeSubframe(Frame* frame) const +{ + if (!m_filterBlock) + return true; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + return m_filterBlock(webFrame); +} + @implementation DOMNode (WebDOMNodeOperations) - (WebArchive *)webArchive @@ -83,6 +114,12 @@ using namespace JSC; return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self))] autorelease]; } +- (WebArchive *)webArchiveByFilteringSubframes:(WebArchiveSubframeFilter)webArchiveSubframeFilter +{ + WebFrameFilter filter(webArchiveSubframeFilter); + return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self), &filter)] autorelease]; +} + @end @implementation DOMNode (WebDOMNodeOperationsPendingPublic) diff --git a/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h b/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h index b579a6f87..d3bf68c52 100644 --- a/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h +++ b/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h @@ -47,3 +47,9 @@ - (NSString *)markupString; - (NSRect)_renderRect:(bool *)isReplaced; @end + +typedef BOOL (^WebArchiveSubframeFilter)(WebFrame* subframe); + +@interface DOMNode (WebDOMNodeOperationsPrivate) +- (WebArchive *)webArchiveByFilteringSubframes:(WebArchiveSubframeFilter)webArchiveSubframeFilter; +@end diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/ASCIICType.h b/Source/WebKit/mac/ForwardingHeaders/wtf/ASCIICType.h deleted file mode 100644 index f2258d298..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/ASCIICType.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/ASCIICType.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/AlwaysInline.h b/Source/WebKit/mac/ForwardingHeaders/wtf/AlwaysInline.h deleted file mode 100644 index 156bd34ca..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/AlwaysInline.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/AlwaysInline.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Assertions.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Assertions.h deleted file mode 100644 index c4cc25cf3..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Assertions.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Assertions.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Deque.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Deque.h deleted file mode 100644 index f1721ca14..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Deque.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Deque.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/DisallowCType.h b/Source/WebKit/mac/ForwardingHeaders/wtf/DisallowCType.h deleted file mode 100644 index 445944be9..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/DisallowCType.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/DisallowCType.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/FastMalloc.h b/Source/WebKit/mac/ForwardingHeaders/wtf/FastMalloc.h deleted file mode 100644 index 8733b5fbf..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/FastMalloc.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/FastMalloc.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Forward.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Forward.h deleted file mode 100644 index 2d707ecb7..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Forward.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/Forward.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/GetPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/GetPtr.h deleted file mode 100644 index 61baf6df8..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/GetPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/GetPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/HashCountedSet.h b/Source/WebKit/mac/ForwardingHeaders/wtf/HashCountedSet.h deleted file mode 100644 index 23120ed16..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/HashCountedSet.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/HashCountedSet.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/HashMap.h b/Source/WebKit/mac/ForwardingHeaders/wtf/HashMap.h deleted file mode 100644 index 4d7d60f91..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/HashMap.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/HashMap.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/HashSet.h b/Source/WebKit/mac/ForwardingHeaders/wtf/HashSet.h deleted file mode 100644 index 03b7a7098..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/HashSet.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/HashSet.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/HashTraits.h b/Source/WebKit/mac/ForwardingHeaders/wtf/HashTraits.h deleted file mode 100644 index fa2ce1c45..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/HashTraits.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/HashTraits.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/ListHashSet.h b/Source/WebKit/mac/ForwardingHeaders/wtf/ListHashSet.h deleted file mode 100644 index 8ed045dd6..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/ListHashSet.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/ListHashSet.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/ListRefPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/ListRefPtr.h deleted file mode 100644 index 2aa23116d..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/ListRefPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/ListRefPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Locker.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Locker.h deleted file mode 100644 index 7718305b7..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Locker.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Locker.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/MathExtras.h b/Source/WebKit/mac/ForwardingHeaders/wtf/MathExtras.h deleted file mode 100644 index 865479e00..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/MathExtras.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/MathExtras.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Noncopyable.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Noncopyable.h deleted file mode 100644 index 050802453..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Noncopyable.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Noncopyable.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/OwnArrayPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/OwnArrayPtr.h deleted file mode 100644 index f10532cdd..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/OwnArrayPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/OwnArrayPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/OwnPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/OwnPtr.h deleted file mode 100644 index ccf0e22ed..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/OwnPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/OwnPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/OwnPtrCommon.h b/Source/WebKit/mac/ForwardingHeaders/wtf/OwnPtrCommon.h deleted file mode 100644 index efffb81b7..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/OwnPtrCommon.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/PassOwnPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/PassOwnPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/PassOwnPtr.h deleted file mode 100644 index efffb81b7..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/PassOwnPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/PassOwnPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/PassRefPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/PassRefPtr.h deleted file mode 100644 index f1eb4666f..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/PassRefPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/PassRefPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Platform.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Platform.h deleted file mode 100644 index 18eaa34b9..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Platform.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Platform.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/RefCounted.h b/Source/WebKit/mac/ForwardingHeaders/wtf/RefCounted.h deleted file mode 100644 index 02c1236f6..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/RefCounted.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/RefCounted.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/RefCountedLeakCounter.h b/Source/WebKit/mac/ForwardingHeaders/wtf/RefCountedLeakCounter.h deleted file mode 100644 index 3f229d1aa..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/RefCountedLeakCounter.h +++ /dev/null @@ -1,2 +0,0 @@ -#include <JavaScriptCore/RefCountedLeakCounter.h> - diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/RefPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/RefPtr.h deleted file mode 100644 index 33c43be7b..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/RefPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/RefPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/RetainPtr.h b/Source/WebKit/mac/ForwardingHeaders/wtf/RetainPtr.h deleted file mode 100644 index 8471d5d6d..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/RetainPtr.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/RetainPtr.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/StdLibExtras.h b/Source/WebKit/mac/ForwardingHeaders/wtf/StdLibExtras.h deleted file mode 100644 index d48b3242c..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/StdLibExtras.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/StdLibExtras.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/TemporaryChange.h b/Source/WebKit/mac/ForwardingHeaders/wtf/TemporaryChange.h deleted file mode 100644 index 3367eb2d2..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/TemporaryChange.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/TemporaryChange.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Threading.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Threading.h deleted file mode 100644 index 771edd126..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Threading.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Threading.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/UnusedParam.h b/Source/WebKit/mac/ForwardingHeaders/wtf/UnusedParam.h deleted file mode 100644 index f1a660060..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/UnusedParam.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/UnusedParam.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/VMTags.h b/Source/WebKit/mac/ForwardingHeaders/wtf/VMTags.h deleted file mode 100644 index 701e514f7..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/VMTags.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/VMTags.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/ValueCheck.h b/Source/WebKit/mac/ForwardingHeaders/wtf/ValueCheck.h deleted file mode 100644 index 7a067ff57..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/ValueCheck.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/ValueCheck.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/Vector.h b/Source/WebKit/mac/ForwardingHeaders/wtf/Vector.h deleted file mode 100644 index 769a55043..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/Vector.h +++ /dev/null @@ -1 +0,0 @@ -#import <JavaScriptCore/Vector.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/VectorTraits.h b/Source/WebKit/mac/ForwardingHeaders/wtf/VectorTraits.h deleted file mode 100644 index 2fc115827..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/VectorTraits.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/VectorTraits.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/unicode/Unicode.h b/Source/WebKit/mac/ForwardingHeaders/wtf/unicode/Unicode.h deleted file mode 100644 index 623917f76..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/unicode/Unicode.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/Unicode.h> diff --git a/Source/WebKit/mac/ForwardingHeaders/wtf/unicode/icu/UnicodeIcu.h b/Source/WebKit/mac/ForwardingHeaders/wtf/unicode/icu/UnicodeIcu.h deleted file mode 100644 index 6b64eb509..000000000 --- a/Source/WebKit/mac/ForwardingHeaders/wtf/unicode/icu/UnicodeIcu.h +++ /dev/null @@ -1 +0,0 @@ -#include <JavaScriptCore/UnicodeIcu.h> diff --git a/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm b/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm index 2ba333fdd..08f8e6aff 100644 --- a/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm +++ b/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm @@ -184,7 +184,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length) -(BOOL)_webkit_hasCaseInsensitivePrefix:(NSString *)prefix { - return [self rangeOfString:prefix options:(NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound; + return hasCaseInsensitivePrefix(self, prefix); } -(BOOL)_webkit_hasCaseInsensitiveSuffix:(NSString *)suffix diff --git a/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm b/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm index 39d489cfd..fa150233d 100644 --- a/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm +++ b/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm @@ -31,7 +31,7 @@ #import "WebKitNSStringExtras.h" #import "WebNSObjectExtras.h" #import "WebNSURLExtras.h" -#import <JavaScriptCore/Assertions.h> +#import <wtf/Assertions.h> #import <WebKitSystemInterface.h> #import <sys/stat.h> #import <wtf/RetainPtr.h> diff --git a/Source/WebKit/mac/Misc/WebNSURLExtras.mm b/Source/WebKit/mac/Misc/WebNSURLExtras.mm index c2351dd3d..98fff7aaa 100644 --- a/Source/WebKit/mac/Misc/WebNSURLExtras.mm +++ b/Source/WebKit/mac/Misc/WebNSURLExtras.mm @@ -37,366 +37,27 @@ #import <Foundation/NSURLRequest.h> #import <WebCore/KURL.h> #import <WebCore/LoaderNSURLExtras.h> +#import <WebCore/WebCoreNSURLExtras.h> #import <WebKitSystemInterface.h> #import <wtf/Assertions.h> #import <unicode/uchar.h> -#import <unicode/uidna.h> #import <unicode/uscript.h> using namespace WebCore; using namespace WTF; -typedef void (* StringRangeApplierFunction)(NSString *string, NSRange range, void *context); - -// Needs to be big enough to hold an IDN-encoded name. -// For host names bigger than this, we won't do IDN encoding, which is almost certainly OK. -#define HOST_NAME_BUFFER_LENGTH 2048 - #define URL_BYTES_BUFFER_LENGTH 2048 -static pthread_once_t IDNScriptWhiteListFileRead = PTHREAD_ONCE_INIT; -static uint32_t IDNScriptWhiteList[(USCRIPT_CODE_LIMIT + 31) / 32]; - -static inline BOOL isLookalikeCharacter(int charCode) -{ -// FIXME: Move this code down into WebCore so it can be shared with other platforms. - -// This function treats the following as unsafe, lookalike characters: -// any non-printable character, any character considered as whitespace that isn't already converted to a space by ICU, -// and any ignorable character. - -// We also considered the characters in Mozilla's blacklist (http://kb.mozillazine.org/Network.IDN.blacklist_chars), -// and included all of these characters that ICU can encode. - - if (!u_isprint(charCode) || u_isUWhiteSpace(charCode) || u_hasBinaryProperty(charCode, UCHAR_DEFAULT_IGNORABLE_CODE_POINT)) - return YES; - - switch (charCode) { - case 0x00ED: /* LATIN SMALL LETTER I WITH ACUTE */ - case 0x01C3: /* LATIN LETTER RETROFLEX CLICK */ - case 0x0251: /* LATIN SMALL LETTER ALPHA */ - case 0x0261: /* LATIN SMALL LETTER SCRIPT G */ - case 0x0337: /* COMBINING SHORT SOLIDUS OVERLAY */ - case 0x0338: /* COMBINING LONG SOLIDUS OVERLAY */ - case 0x05B4: /* HEBREW POINT HIRIQ */ - case 0x05BC: /* HEBREW POINT DAGESH OR MAPIQ */ - case 0x05C3: /* HEBREW PUNCTUATION SOF PASUQ */ - case 0x05F4: /* HEBREW PUNCTUATION GERSHAYIM */ - case 0x0660: /* ARABIC INDIC DIGIT ZERO */ - case 0x06D4: /* ARABIC FULL STOP */ - case 0x06F0: /* EXTENDED ARABIC INDIC DIGIT ZERO */ - case 0x2027: /* HYPHENATION POINT */ - case 0x2039: /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */ - case 0x203A: /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */ - case 0x2044: /* FRACTION SLASH */ - case 0x2215: /* DIVISION SLASH */ - case 0x2216: /* SET MINUS */ - case 0x233F: /* APL FUNCTIONAL SYMBOL SLASH BAR */ - case 0x23AE: /* INTEGRAL EXTENSION */ - case 0x244A: /* OCR DOUBLE BACKSLASH */ - case 0x2571: /* BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT */ - case 0x2572: /* BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT */ - case 0x29F8: /* BIG SOLIDUS */ - case 0x29f6: /* SOLIDUS WITH OVERBAR */ - case 0x2AFB: /* TRIPLE SOLIDUS BINARY RELATION */ - case 0x2AFD: /* DOUBLE SOLIDUS OPERATOR */ - case 0x3008: /* LEFT ANGLE BRACKET */ - case 0x3014: /* LEFT TORTOISE SHELL BRACKET */ - case 0x3015: /* RIGHT TORTOISE SHELL BRACKET */ - case 0x3033: /* VERTICAL KANA REPEAT MARK UPPER HALF */ - case 0x3035: /* VERTICAL KANA REPEAT MARK LOWER HALF */ - case 0x321D: /* PARENTHESIZED KOREAN CHARACTER OJEON */ - case 0x321E: /* PARENTHESIZED KOREAN CHARACTER O HU */ - case 0x33DF: /* SQUARE A OVER M */ - case 0xFE14: /* PRESENTATION FORM FOR VERTICAL SEMICOLON */ - case 0xFE15: /* PRESENTATION FORM FOR VERTICAL EXCLAMATION MARK */ - case 0xFE3F: /* PRESENTATION FORM FOR VERTICAL LEFT ANGLE BRACKET */ - case 0xFE5D: /* SMALL LEFT TORTOISE SHELL BRACKET */ - case 0xFE5E: /* SMALL RIGHT TORTOISE SHELL BRACKET */ - return YES; - default: - return NO; - } -} - -static char hexDigit(int i) -{ - if (i < 0 || i > 16) { - LOG_ERROR("illegal hex digit"); - return '0'; - } - int h = i; - if (h >= 10) { - h = h - 10 + 'A'; - } - else { - h += '0'; - } - return h; -} - -static BOOL isHexDigit(char c) -{ - return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); -} - -static int hexDigitValue(char c) -{ - if (c >= '0' && c <= '9') { - return c - '0'; - } - if (c >= 'A' && c <= 'F') { - return c - 'A' + 10; - } - if (c >= 'a' && c <= 'f') { - return c - 'a' + 10; - } - LOG_ERROR("illegal hex digit"); - return 0; -} - -static void applyHostNameFunctionToMailToURLString(NSString *string, StringRangeApplierFunction f, void *context) -{ - // In a mailto: URL, host names come after a '@' character and end with a '>' or ',' or '?' character. - // Skip quoted strings so that characters in them don't confuse us. - // When we find a '?' character, we are past the part of the URL that contains host names. - - static NSCharacterSet *hostNameOrStringStartCharacters; - if (hostNameOrStringStartCharacters == nil) { - hostNameOrStringStartCharacters = [NSCharacterSet characterSetWithCharactersInString:@"\"@?"]; - CFRetain(hostNameOrStringStartCharacters); - } - static NSCharacterSet *hostNameEndCharacters; - if (hostNameEndCharacters == nil) { - hostNameEndCharacters = [NSCharacterSet characterSetWithCharactersInString:@">,?"]; - CFRetain(hostNameEndCharacters); - } - static NSCharacterSet *quotedStringCharacters; - if (quotedStringCharacters == nil) { - quotedStringCharacters = [NSCharacterSet characterSetWithCharactersInString:@"\"\\"]; - CFRetain(quotedStringCharacters); - } - - unsigned stringLength = [string length]; - NSRange remaining = NSMakeRange(0, stringLength); - - while (1) { - // Find start of host name or of quoted string. - NSRange hostNameOrStringStart = [string rangeOfCharacterFromSet:hostNameOrStringStartCharacters options:0 range:remaining]; - if (hostNameOrStringStart.location == NSNotFound) { - return; - } - unichar c = [string characterAtIndex:hostNameOrStringStart.location]; - remaining.location = NSMaxRange(hostNameOrStringStart); - remaining.length = stringLength - remaining.location; - - if (c == '?') { - return; - } - - if (c == '@') { - // Find end of host name. - unsigned hostNameStart = remaining.location; - NSRange hostNameEnd = [string rangeOfCharacterFromSet:hostNameEndCharacters options:0 range:remaining]; - BOOL done; - if (hostNameEnd.location == NSNotFound) { - hostNameEnd.location = stringLength; - done = YES; - } else { - remaining.location = hostNameEnd.location; - remaining.length = stringLength - remaining.location; - done = NO; - } - - // Process host name range. - f(string, NSMakeRange(hostNameStart, hostNameEnd.location - hostNameStart), context); - - if (done) { - return; - } - } else { - // Skip quoted string. - ASSERT(c == '"'); - while (1) { - NSRange escapedCharacterOrStringEnd = [string rangeOfCharacterFromSet:quotedStringCharacters options:0 range:remaining]; - if (escapedCharacterOrStringEnd.location == NSNotFound) { - return; - } - c = [string characterAtIndex:escapedCharacterOrStringEnd.location]; - remaining.location = NSMaxRange(escapedCharacterOrStringEnd); - remaining.length = stringLength - remaining.location; - - // If we are the end of the string, then break from the string loop back to the host name loop. - if (c == '"') { - break; - } - - // Skip escaped character. - ASSERT(c == '\\'); - if (remaining.length == 0) { - return; - } - remaining.location += 1; - remaining.length -= 1; - } - } - } -} - -static void applyHostNameFunctionToURLString(NSString *string, StringRangeApplierFunction f, void *context) -{ - // Find hostnames. Too bad we can't use any real URL-parsing code to do this, - // but we have to do it before doing all the %-escaping, and this is the only - // code we have that parses mailto URLs anyway. - - // Maybe we should implement this using a character buffer instead? - - if ([string _webkit_hasCaseInsensitivePrefix:@"mailto:"]) { - applyHostNameFunctionToMailToURLString(string, f, context); - return; - } - - // Find the host name in a hierarchical URL. - // It comes after a "://" sequence, with scheme characters preceding. - // If ends with the end of the string or a ":", "/", or a "?". - // If there is a "@" character, the host part is just the part after the "@". - NSRange separatorRange = [string rangeOfString:@"://"]; - if (separatorRange.location == NSNotFound) { - return; - } - - // Check that all characters before the :// are valid scheme characters. - static NSCharacterSet *nonSchemeCharacters; - if (nonSchemeCharacters == nil) { - nonSchemeCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-."] invertedSet]; - CFRetain(nonSchemeCharacters); - } - if ([string rangeOfCharacterFromSet:nonSchemeCharacters options:0 range:NSMakeRange(0, separatorRange.location)].location != NSNotFound) { - return; - } - - unsigned stringLength = [string length]; - - static NSCharacterSet *hostTerminators; - if (hostTerminators == nil) { - hostTerminators = [NSCharacterSet characterSetWithCharactersInString:@":/?#"]; - CFRetain(hostTerminators); - } - - // Start after the separator. - unsigned authorityStart = NSMaxRange(separatorRange); - - // Find terminating character. - NSRange hostNameTerminator = [string rangeOfCharacterFromSet:hostTerminators options:0 range:NSMakeRange(authorityStart, stringLength - authorityStart)]; - unsigned hostNameEnd = hostNameTerminator.location == NSNotFound ? stringLength : hostNameTerminator.location; - - // Find "@" for the start of the host name. - NSRange userInfoTerminator = [string rangeOfString:@"@" options:0 range:NSMakeRange(authorityStart, hostNameEnd - authorityStart)]; - unsigned hostNameStart = userInfoTerminator.location == NSNotFound ? authorityStart : NSMaxRange(userInfoTerminator); - - f(string, NSMakeRange(hostNameStart, hostNameEnd - hostNameStart), context); -} - @implementation NSURL (WebNSURLExtras) -static void collectRangesThatNeedMapping(NSString *string, NSRange range, void *context, BOOL encode) -{ - BOOL needsMapping = encode - ? [string _web_hostNameNeedsEncodingWithRange:range] - : [string _web_hostNameNeedsDecodingWithRange:range]; - if (!needsMapping) { - return; - } - - NSMutableArray **array = (NSMutableArray **)context; - if (*array == nil) { - *array = [[NSMutableArray alloc] init]; - } - - [*array addObject:[NSValue valueWithRange:range]]; -} - -static void collectRangesThatNeedEncoding(NSString *string, NSRange range, void *context) -{ - return collectRangesThatNeedMapping(string, range, context, YES); -} - -static void collectRangesThatNeedDecoding(NSString *string, NSRange range, void *context) -{ - return collectRangesThatNeedMapping(string, range, context, NO); -} - -static NSString *mapHostNames(NSString *string, BOOL encode) -{ - // Generally, we want to optimize for the case where there is one host name that does not need mapping. - - if (encode && [string canBeConvertedToEncoding:NSASCIIStringEncoding]) - return string; - - // Make a list of ranges that actually need mapping. - NSMutableArray *hostNameRanges = nil; - StringRangeApplierFunction f = encode - ? collectRangesThatNeedEncoding - : collectRangesThatNeedDecoding; - applyHostNameFunctionToURLString(string, f, &hostNameRanges); - if (hostNameRanges == nil) - return string; - - // Do the mapping. - NSMutableString *mutableCopy = [string mutableCopy]; - unsigned i = [hostNameRanges count]; - while (i-- != 0) { - NSRange hostNameRange = [[hostNameRanges objectAtIndex:i] rangeValue]; - NSString *mappedHostName = encode - ? [string _web_encodeHostNameWithRange:hostNameRange] - : [string _web_decodeHostNameWithRange:hostNameRange]; - [mutableCopy replaceCharactersInRange:hostNameRange withString:mappedHostName]; - } - [hostNameRanges release]; - return [mutableCopy autorelease]; -} - + (NSURL *)_web_URLWithUserTypedString:(NSString *)string relativeToURL:(NSURL *)URL { - if (string == nil) { - return nil; - } - string = mapHostNames([string _webkit_stringByTrimmingWhitespace], YES); - - NSData *userTypedData = [string dataUsingEncoding:NSUTF8StringEncoding]; - ASSERT(userTypedData); - - const UInt8 *inBytes = static_cast<const UInt8 *>([userTypedData bytes]); - int inLength = [userTypedData length]; - if (inLength == 0) { - return [NSURL URLWithString:@""]; - } - - char *outBytes = static_cast<char *>(malloc(inLength * 3)); // large enough to %-escape every character - char *p = outBytes; - int outLength = 0; - int i; - for (i = 0; i < inLength; i++) { - UInt8 c = inBytes[i]; - if (c <= 0x20 || c >= 0x7f) { - *p++ = '%'; - *p++ = hexDigit(c >> 4); - *p++ = hexDigit(c & 0xf); - outLength += 3; - } - else { - *p++ = c; - outLength++; - } - } - - NSData *data = [NSData dataWithBytesNoCopy:outBytes length:outLength]; // adopts outBytes - return [self _web_URLWithData:data relativeToURL:URL]; + return URLWithUserTypedString(string, URL); } + (NSURL *)_web_URLWithUserTypedString:(NSString *)string { - return [self _web_URLWithUserTypedString:string relativeToURL:nil]; + return URLWithUserTypedString(string, nil); } + (NSURL *)_web_URLWithDataAsString:(NSString *)string @@ -414,191 +75,45 @@ static NSString *mapHostNames(NSString *string, BOOL encode) } string = [string _webkit_stringByTrimmingWhitespace]; NSData *data = [string dataUsingEncoding:NSISOLatin1StringEncoding]; - return [self _web_URLWithData:data relativeToURL:baseURL]; + return URLWithData(data, baseURL); } + (NSURL *)_web_URLWithData:(NSData *)data { - return [NSURL _web_URLWithData:data relativeToURL:nil]; + return URLWithData(data, nil); } + (NSURL *)_web_URLWithData:(NSData *)data relativeToURL:(NSURL *)baseURL { - if (data == nil) - return nil; - - NSURL *result = nil; - size_t length = [data length]; - if (length > 0) { - // work around <rdar://4470771>: CFURLCreateAbsoluteURLWithBytes(.., TRUE) doesn't remove non-path components. - baseURL = [baseURL _webkit_URLByRemovingResourceSpecifier]; - - const UInt8 *bytes = static_cast<const UInt8*>([data bytes]); - - // CFURLCreateAbsoluteURLWithBytes would complain to console if we passed a path to it. - if (bytes[0] == '/' && !baseURL) - return nil; - - // NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components - // (e.g calls to NSURL -path). However, this function is not tolerant of illegal UTF-8 sequences, which - // could either be a malformed string or bytes in a different encoding, like shift-jis, so we fall back - // onto using ISO Latin 1 in those cases. - result = WebCFAutorelease(CFURLCreateAbsoluteURLWithBytes(NULL, bytes, length, kCFStringEncodingUTF8, (CFURLRef)baseURL, YES)); - if (!result) - result = WebCFAutorelease(CFURLCreateAbsoluteURLWithBytes(NULL, bytes, length, kCFStringEncodingISOLatin1, (CFURLRef)baseURL, YES)); - } else - result = [NSURL URLWithString:@""]; - - return result; + return URLWithData(data, baseURL); } - (NSData *)_web_originalData { - UInt8 *buffer = (UInt8 *)malloc(URL_BYTES_BUFFER_LENGTH); - CFIndex bytesFilled = CFURLGetBytes((CFURLRef)self, buffer, URL_BYTES_BUFFER_LENGTH); - if (bytesFilled == -1) { - CFIndex bytesToAllocate = CFURLGetBytes((CFURLRef)self, NULL, 0); - buffer = (UInt8 *)realloc(buffer, bytesToAllocate); - bytesFilled = CFURLGetBytes((CFURLRef)self, buffer, bytesToAllocate); - ASSERT(bytesFilled == bytesToAllocate); - } - - // buffer is adopted by the NSData - NSData *data = [NSData dataWithBytesNoCopy:buffer length:bytesFilled freeWhenDone:YES]; - - NSURL *baseURL = (NSURL *)CFURLGetBaseURL((CFURLRef)self); - if (baseURL) - return [[NSURL _web_URLWithData:data relativeToURL:baseURL] _web_originalData]; - return data; + return originalURLData(self); } - (NSString *)_web_originalDataAsString { - return [[[NSString alloc] initWithData:[self _web_originalData] encoding:NSISOLatin1StringEncoding] autorelease]; -} - -static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) -{ - CFIndex length = CFStringGetLength(string); - Vector<UChar, 2048> sourceBuffer(length); - CFStringGetCharacters(string, CFRangeMake(0, length), sourceBuffer.data()); - - Vector<UChar, 2048> outBuffer; - - CFIndex i = 0; - while (i < length) { - UChar32 c; - U16_NEXT(sourceBuffer, i, length, c) - - if (isLookalikeCharacter(c)) { - uint8_t utf8Buffer[4]; - CFIndex offset = 0; - UBool failure = false; - U8_APPEND(utf8Buffer, offset, 4, c, failure) - ASSERT(!failure); - - for (CFIndex j = 0; j < offset; ++j) { - outBuffer.append('%'); - outBuffer.append(hexDigit(utf8Buffer[j] >> 4)); - outBuffer.append(hexDigit(utf8Buffer[j] & 0xf)); - } - } else { - UChar utf16Buffer[2]; - CFIndex offset = 0; - UBool failure = false; - U16_APPEND(utf16Buffer, offset, 2, c, failure) - ASSERT(!failure); - for (CFIndex j = 0; j < offset; ++j) - outBuffer.append(utf16Buffer[j]); - } - } - - return CFStringCreateWithCharacters(NULL, outBuffer.data(), outBuffer.size()); + return [[[NSString alloc] initWithData:originalURLData(self) encoding:NSISOLatin1StringEncoding] autorelease]; } - (NSString *)_web_userVisibleString { - NSData *data = [self _web_originalData]; - const unsigned char *before = static_cast<const unsigned char*>([data bytes]); - int length = [data length]; - - bool needsHostNameDecoding = false; - - const unsigned char *p = before; - int bufferLength = (length * 3) + 1; - char *after = static_cast<char *>(malloc(bufferLength)); // large enough to %-escape every character - char *q = after; - int i; - for (i = 0; i < length; i++) { - unsigned char c = p[i]; - // unescape escape sequences that indicate bytes greater than 0x7f - if (c == '%' && (i + 1 < length && isHexDigit(p[i + 1])) && i + 2 < length && isHexDigit(p[i + 2])) { - unsigned char u = (hexDigitValue(p[i + 1]) << 4) | hexDigitValue(p[i + 2]); - if (u > 0x7f) { - // unescape - *q++ = u; - } else { - // do not unescape - *q++ = p[i]; - *q++ = p[i + 1]; - *q++ = p[i + 2]; - } - i += 2; - } else { - *q++ = c; - - // Check for "xn--" in an efficient, non-case-sensitive, way. - if (c == '-' && i >= 3 && !needsHostNameDecoding && (q[-4] | 0x20) == 'x' && (q[-3] | 0x20) == 'n' && q[-2] == '-') - needsHostNameDecoding = true; - } - } - *q = '\0'; - - // Check string to see if it can be converted to display using UTF-8 - NSString *result = [NSString stringWithUTF8String:after]; - if (!result) { - // Could not convert to UTF-8. - // Convert characters greater than 0x7f to escape sequences. - // Shift current string to the end of the buffer - // then we will copy back bytes to the start of the buffer - // as we convert. - int afterlength = q - after; - char *p = after + bufferLength - afterlength - 1; - memmove(p, after, afterlength + 1); // copies trailing '\0' - char *q = after; - while (*p) { - unsigned char c = *p; - if (c > 0x7f) { - *q++ = '%'; - *q++ = hexDigit(c >> 4); - *q++ = hexDigit(c & 0xf); - } else { - *q++ = *p; - } - p++; - } - *q = '\0'; - result = [NSString stringWithUTF8String:after]; - } - - free(after); - - result = mapHostNames(result, !needsHostNameDecoding); - result = [result precomposedStringWithCanonicalMapping]; - return WebCFAutorelease(createStringWithEscapedUnsafeCharacters((CFStringRef)result)); + return userVisibleString(self); } - (BOOL)_web_isEmpty { if (!CFURLGetBaseURL((CFURLRef)self)) return CFURLGetBytes((CFURLRef)self, NULL, 0) == 0; - return [[self _web_originalData] length] == 0; + return [originalURLData(self) length] == 0; } - (const char *)_web_URLCString { NSMutableData *data = [NSMutableData data]; - [data appendData:[self _web_originalData]]; + [data appendData:originalURLData(self)]; [data appendBytes:"\0" length:1]; return (const char *)[data bytes]; } @@ -626,76 +141,22 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) - (NSURL *)_web_URLByTruncatingOneCharacterBeforeComponent:(CFURLComponentType)component { - CFRange fragRg = CFURLGetByteRangeForComponent((CFURLRef)self, component, NULL); - if (fragRg.location == kCFNotFound) - return self; - - UInt8 *urlBytes, buffer[2048]; - CFIndex numBytes = CFURLGetBytes((CFURLRef)self, buffer, 2048); - if (numBytes == -1) { - numBytes = CFURLGetBytes((CFURLRef)self, NULL, 0); - urlBytes = static_cast<UInt8*>(malloc(numBytes)); - CFURLGetBytes((CFURLRef)self, urlBytes, numBytes); - } else - urlBytes = buffer; - - NSURL *result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, fragRg.location - 1, kCFStringEncodingUTF8, NULL)); - if (!result) - result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, fragRg.location - 1, kCFStringEncodingISOLatin1, NULL)); - - if (urlBytes != buffer) free(urlBytes); - return result ? [result autorelease] : self; + return URLByTruncatingOneCharacterBeforeComponent(self, component); } - (NSURL *)_webkit_URLByRemovingFragment { - return [self _web_URLByTruncatingOneCharacterBeforeComponent:kCFURLComponentFragment]; + return URLByTruncatingOneCharacterBeforeComponent(self, kCFURLComponentFragment); } - (NSURL *)_webkit_URLByRemovingResourceSpecifier { - return [self _web_URLByTruncatingOneCharacterBeforeComponent:kCFURLComponentResourceSpecifier]; -} - -- (NSURL *)_web_URLByRemovingComponentAndSubsequentCharacter:(CFURLComponentType)component -{ - CFRange range = CFURLGetByteRangeForComponent((CFURLRef)self, component, 0); - if (range.location == kCFNotFound) - return self; - - // Remove one subsequent character. - ++range.length; - - UInt8* urlBytes; - UInt8 buffer[2048]; - CFIndex numBytes = CFURLGetBytes((CFURLRef)self, buffer, 2048); - if (numBytes == -1) { - numBytes = CFURLGetBytes((CFURLRef)self, NULL, 0); - urlBytes = static_cast<UInt8*>(malloc(numBytes)); - CFURLGetBytes((CFURLRef)self, urlBytes, numBytes); - } else - urlBytes = buffer; - - if (numBytes < range.location) - return self; - if (numBytes < range.location + range.length) - range.length = numBytes - range.location; - - memmove(urlBytes + range.location, urlBytes + range.location + range.length, numBytes - range.location + range.length); - - NSURL *result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, numBytes - range.length, kCFStringEncodingUTF8, NULL)); - if (!result) - result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, numBytes - range.length, kCFStringEncodingISOLatin1, NULL)); - - if (urlBytes != buffer) - free(urlBytes); - - return result ? [result autorelease] : self; + return URLByTruncatingOneCharacterBeforeComponent(self, kCFURLComponentResourceSpecifier); } - (NSURL *)_web_URLByRemovingUserInfo { - return [self _web_URLByRemovingComponentAndSubsequentCharacter:kCFURLComponentUserInfo]; + return URLByRemovingUserInfo(self); } - (BOOL)_webkit_isJavaScriptURL @@ -764,16 +225,6 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) } --(BOOL)_web_hasQuestionMarkOnlyQueryString -{ - CFRange rangeWithSeparators; - CFURLGetByteRangeForComponent((CFURLRef)self, kCFURLComponentQuery, &rangeWithSeparators); - if (rangeWithSeparators.location != kCFNotFound && rangeWithSeparators.length == 1) { - return YES; - } - return NO; -} - -(NSData *)_web_schemeSeparatorWithoutColon { NSData *result = nil; @@ -790,77 +241,19 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) return result; } -#define completeURL (CFURLComponentType)-1 - -(NSData *)_web_dataForURLComponentType:(CFURLComponentType)componentType { - static int URLComponentTypeBufferLength = 2048; - - UInt8 staticAllBytesBuffer[URLComponentTypeBufferLength]; - UInt8 *allBytesBuffer = staticAllBytesBuffer; - - CFIndex bytesFilled = CFURLGetBytes((CFURLRef)self, allBytesBuffer, URLComponentTypeBufferLength); - if (bytesFilled == -1) { - CFIndex bytesToAllocate = CFURLGetBytes((CFURLRef)self, NULL, 0); - allBytesBuffer = static_cast<UInt8 *>(malloc(bytesToAllocate)); - bytesFilled = CFURLGetBytes((CFURLRef)self, allBytesBuffer, bytesToAllocate); - } - - CFRange range; - if (componentType != completeURL) { - range = CFURLGetByteRangeForComponent((CFURLRef)self, componentType, NULL); - if (range.location == kCFNotFound) { - return nil; - } - } - else { - range.location = 0; - range.length = bytesFilled; - } - - NSData *componentData = [NSData dataWithBytes:allBytesBuffer + range.location length:range.length]; - - const unsigned char *bytes = static_cast<const unsigned char *>([componentData bytes]); - NSMutableData *resultData = [NSMutableData data]; - // NOTE: add leading '?' to query strings non-zero length query strings. - // NOTE: retain question-mark only query strings. - if (componentType == kCFURLComponentQuery) { - if (range.length > 0 || [self _web_hasQuestionMarkOnlyQueryString]) { - [resultData appendBytes:"?" length:1]; - } - } - int i; - for (i = 0; i < range.length; i++) { - unsigned char c = bytes[i]; - if (c <= 0x20 || c >= 0x7f) { - char escaped[3]; - escaped[0] = '%'; - escaped[1] = hexDigit(c >> 4); - escaped[2] = hexDigit(c & 0xf); - [resultData appendBytes:escaped length:3]; - } - else { - char b[1]; - b[0] = c; - [resultData appendBytes:b length:1]; - } - } - - if (staticAllBytesBuffer != allBytesBuffer) { - free(allBytesBuffer); - } - - return resultData; + return dataForURLComponentType(self, componentType); } -(NSData *)_web_schemeData { - return [self _web_dataForURLComponentType:kCFURLComponentScheme]; + return dataForURLComponentType(self, kCFURLComponentScheme); } -(NSData *)_web_hostData { - NSData *result = [self _web_dataForURLComponentType:kCFURLComponentHost]; + NSData *result = dataForURLComponentType(self, kCFURLComponentHost); NSData *scheme = [self _web_schemeData]; // Take off localhost for file if ([scheme _web_isCaseInsensitiveEqualToCString:"file"]) { @@ -897,49 +290,9 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) - (BOOL)_web_isUserVisibleURL { - BOOL valid = YES; - // get buffer - - char static_buffer[1024]; - const char *p; - BOOL success = CFStringGetCString((CFStringRef)self, static_buffer, 1023, kCFStringEncodingUTF8); - if (success) { - p = static_buffer; - } else { - p = [self UTF8String]; - } - - int length = strlen(p); - - // check for characters <= 0x20 or >=0x7f, %-escape sequences of %7f, and xn--, these - // are the things that will lead _web_userVisibleString to actually change things. - int i; - for (i = 0; i < length; i++) { - unsigned char c = p[i]; - // escape control characters, space, and delete - if (c <= 0x20 || c == 0x7f) { - valid = NO; - break; - } else if (c == '%' && (i + 1 < length && isHexDigit(p[i + 1])) && i + 2 < length && isHexDigit(p[i + 2])) { - unsigned char u = (hexDigitValue(p[i + 1]) << 4) | hexDigitValue(p[i + 2]); - if (u > 0x7f) { - valid = NO; - break; - } - i += 2; - } else { - // Check for "xn--" in an efficient, non-case-sensitive, way. - if (c == '-' && i >= 3 && (p[i - 3] | 0x20) == 'x' && (p[i - 2] | 0x20) == 'n' && p[i - 1] == '-') { - valid = NO; - break; - } - } - } - - return valid; + return isUserVisibleURL(self); } - - (BOOL)_webkit_isJavaScriptURL { return [self _webkit_hasCaseInsensitivePrefix:@"javascript:"]; @@ -973,204 +326,34 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) return lastChar == '/' && [self _webkit_hasCaseInsensitivePrefix:@"ftp:"]; } - -static BOOL readIDNScriptWhiteListFile(NSString *filename) -{ - if (!filename) { - return NO; - } - FILE *file = fopen([filename fileSystemRepresentation], "r"); - if (file == NULL) { - return NO; - } - - // Read a word at a time. - // Allow comments, starting with # character to the end of the line. - while (1) { - // Skip a comment if present. - int result = fscanf(file, " #%*[^\n\r]%*[\n\r]"); - if (result == EOF) { - break; - } - - // Read a script name if present. - char word[33]; - result = fscanf(file, " %32[^# \t\n\r]%*[^# \t\n\r] ", word); - if (result == EOF) { - break; - } - if (result == 1) { - // Got a word, map to script code and put it into the array. - int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, word); - if (script >= 0 && script < USCRIPT_CODE_LIMIT) { - size_t index = script / 32; - uint32_t mask = 1 << (script % 32); - IDNScriptWhiteList[index] |= mask; - } - } - } - fclose(file); - return YES; -} - -static void readIDNScriptWhiteList(void) -{ - // Read white list from library. - NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSAllDomainsMask, YES); - int i, numDirs = [dirs count]; - for (i = 0; i < numDirs; i++) { - NSString *dir = [dirs objectAtIndex:i]; - if (readIDNScriptWhiteListFile([dir stringByAppendingPathComponent:@"IDNScriptWhiteList.txt"])) { - return; - } - } - - // Fall back on white list inside bundle. - NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit"]; - readIDNScriptWhiteListFile([bundle pathForResource:@"IDNScriptWhiteList" ofType:@"txt"]); -} - -static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t length) -{ - pthread_once(&IDNScriptWhiteListFileRead, readIDNScriptWhiteList); - - int32_t i = 0; - while (i < length) { - UChar32 c; - U16_NEXT(buffer, i, length, c) - UErrorCode error = U_ZERO_ERROR; - UScriptCode script = uscript_getScript(c, &error); - if (error != U_ZERO_ERROR) { - LOG_ERROR("got ICU error while trying to look at scripts: %d", error); - return NO; - } - if (script < 0) { - LOG_ERROR("got negative number for script code from ICU: %d", script); - return NO; - } - if (script >= USCRIPT_CODE_LIMIT) { - return NO; - } - size_t index = script / 32; - uint32_t mask = 1 << (script % 32); - if (!(IDNScriptWhiteList[index] & mask)) { - return NO; - } - - if (isLookalikeCharacter(c)) - return NO; - } - return YES; -} - -static BOOL allCharactersAllowedByTLDRules(const UChar* buffer, int32_t length) -{ - // Skip trailing dot for root domain. - if (buffer[length - 1] == '.') - --length; - - if (length > 3 - && buffer[length - 3] == '.' - && buffer[length - 2] == 0x0440 // CYRILLIC SMALL LETTER ER - && buffer[length - 1] == 0x0444) // CYRILLIC SMALL LETTER EF - { - // Rules defined by <http://www.cctld.ru/ru/docs/rulesrf.php>. This code only checks requirements that matter for presentation purposes. - for (int32_t i = length - 4; i; --i) { - UChar ch = buffer[i]; - - // Only modern Russian letters, digits and dashes are allowed. - if ((ch >= 0x0430 && ch <= 0x044f) - || ch == 0x0451 - || (ch >= '0' && ch <= '9') - || ch == '-') - continue; - - // Only check top level domain. Lower level registrars may have different rules. - if (ch == '.') - break; - - return NO; - } - return YES; - } - - // Not a known top level domain with special rules. - return NO; -} - -// Return value of nil means no mapping is necessary. -// If makeString is NO, then return value is either nil or self to indicate mapping is necessary. -// If makeString is YES, then return value is either nil or the mapped string. -- (NSString *)_web_mapHostNameWithRange:(NSRange)range encode:(BOOL)encode makeString:(BOOL)makeString -{ - if (range.length > HOST_NAME_BUFFER_LENGTH) { - return nil; - } - - if ([self length] == 0) - return nil; - - UChar sourceBuffer[HOST_NAME_BUFFER_LENGTH]; - UChar destinationBuffer[HOST_NAME_BUFFER_LENGTH]; - - NSString *string = self; - if (encode && [self rangeOfString:@"%" options:NSLiteralSearch range:range].location != NSNotFound) { - NSString *substring = [self substringWithRange:range]; - substring = WebCFAutorelease(CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)substring, CFSTR(""))); - if (substring != nil) { - string = substring; - range = NSMakeRange(0, [string length]); - } - } - - int length = range.length; - [string getCharacters:sourceBuffer range:range]; - - UErrorCode error = U_ZERO_ERROR; - int32_t numCharactersConverted = (encode ? uidna_IDNToASCII : uidna_IDNToUnicode) - (sourceBuffer, length, destinationBuffer, HOST_NAME_BUFFER_LENGTH, UIDNA_ALLOW_UNASSIGNED, NULL, &error); - if (error != U_ZERO_ERROR) { - return nil; - } - if (numCharactersConverted == length && memcmp(sourceBuffer, destinationBuffer, length * sizeof(UChar)) == 0) { - return nil; - } - if (!encode && !allCharactersInIDNScriptWhiteList(destinationBuffer, numCharactersConverted) && !allCharactersAllowedByTLDRules(destinationBuffer, numCharactersConverted)) { - return nil; - } - return makeString ? (NSString *)[NSString stringWithCharacters:destinationBuffer length:numCharactersConverted] : (NSString *)self; -} - - (BOOL)_web_hostNameNeedsDecodingWithRange:(NSRange)range { - return [self _web_mapHostNameWithRange:range encode:NO makeString:NO] != nil; + return hostNameNeedsDecodingWithRange(self, range); } - (BOOL)_web_hostNameNeedsEncodingWithRange:(NSRange)range { - return [self _web_mapHostNameWithRange:range encode:YES makeString:NO] != nil; + return hostNameNeedsEncodingWithRange(self, range); } - (NSString *)_web_decodeHostNameWithRange:(NSRange)range { - return [self _web_mapHostNameWithRange:range encode:NO makeString:YES]; + return decodeHostNameWithRange(self, range); } - (NSString *)_web_encodeHostNameWithRange:(NSRange)range { - return [self _web_mapHostNameWithRange:range encode:YES makeString:YES]; + return encodeHostNameWithRange(self, range); } - (NSString *)_web_decodeHostName { - NSString *name = [self _web_mapHostNameWithRange:NSMakeRange(0, [self length]) encode:NO makeString:YES]; - return name == nil ? self : name; + return decodeHostName(self); } - (NSString *)_web_encodeHostName { - NSString *name = [self _web_mapHostNameWithRange:NSMakeRange(0, [self length]) encode:YES makeString:YES]; - return name == nil ? self : name; + return encodeHostName(self); } -(NSRange)_webkit_rangeOfURLScheme diff --git a/Source/WebKit/mac/Panels/WebAuthenticationPanel.m b/Source/WebKit/mac/Panels/WebAuthenticationPanel.m index e2f483e0f..f843f3208 100644 --- a/Source/WebKit/mac/Panels/WebAuthenticationPanel.m +++ b/Source/WebKit/mac/Panels/WebAuthenticationPanel.m @@ -125,7 +125,7 @@ if ([space port] == 0) { host = [[space host] _web_decodeHostName]; } else { - host = [NSString stringWithFormat:@"%@:%u", [[space host] _web_decodeHostName], [space port]]; + host = [NSString stringWithFormat:@"%@:%ld", [[space host] _web_decodeHostName], (long)[space port]]; } NSString *realm = [space realm]; diff --git a/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm index 7248f464b..609ccf0cc 100644 --- a/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm +++ b/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm @@ -1085,7 +1085,7 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, unsigned proper JSLock lock(SilenceAssertionsOnly); JSValue value = demarshalValue(exec, valueData, valueLength); - object->methodTable()->putByIndex(object, exec, propertyName, value); + object->methodTable()->putByIndex(object, exec, propertyName, value, false); exec->clearException(); return true; diff --git a/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm b/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm index 57df2fe02..5f1f55694 100644 --- a/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm +++ b/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm @@ -1998,7 +1998,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) - (NPError)getVariable:(NPNVariable)variable value:(void *)value { - switch (variable) { + switch (static_cast<unsigned>(variable)) { case NPNVWindowNPObject: { Frame* frame = core([self webFrame]); diff --git a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h index 66fa060b5..46d1201d5 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h @@ -184,10 +184,6 @@ public: virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const OVERRIDE; virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const OVERRIDE; -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() OVERRIDE; -#endif - virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE { } virtual void numTouchEventHandlersChanged(unsigned) OVERRIDE { } virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE { return false; } diff --git a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm index 3bac87b9c..fc3a1f2b4 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm @@ -857,35 +857,6 @@ PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebC return adoptRef(new SearchPopupMenuMac(client)); } -#if ENABLE(CONTEXT_MENUS) -void WebChromeClient::showContextMenu() -{ - Page* page = [m_webView page]; - if (!page) - return; - - ContextMenuController* controller = page->contextMenuController(); - Node* node = controller->hitTestResult().innerNonSharedNode(); - if (!node) - return; - Frame* frame = node->document()->frame(); - if (!frame) - return; - FrameView* frameView = frame->view(); - if (!frameView) - return; - NSView* view = frameView->documentView(); - - IntPoint point = frameView->contentsToWindow(controller->hitTestResult().point()); - NSPoint nsScreenPoint = [view convertPoint:point toView:nil]; - // Show the contextual menu for this event. - NSEvent* event = [NSEvent mouseEventWithType:NSRightMouseDown location:nsScreenPoint modifierFlags:0 timestamp:0 windowNumber:[[view window] windowNumber] context:0 eventNumber:0 clickCount:1 pressure:1]; - NSMenu* nsMenu = [view menuForEvent:event]; - if (nsMenu) - [NSMenu popUpContextMenu:nsMenu withEvent:event forView:view]; -} -#endif - #if USE(ACCELERATED_COMPOSITING) void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer) @@ -983,8 +954,6 @@ void WebChromeClient::fullScreenRendererChanged(RenderBox* renderer) SEL selector = @selector(webView:fullScreenRendererChanged:); if ([[m_webView UIDelegate] respondsToSelector:selector]) CallUIDelegate(m_webView, selector, (id)renderer); - else - [m_webView _fullScreenRendererChanged:renderer]; } @implementation WebKitFullScreenListener diff --git a/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h b/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h index 21b0d0f25..e536f3c24 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h +++ b/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h @@ -46,6 +46,7 @@ public: virtual void speak(const WTF::String&) OVERRIDE; virtual void stopSpeaking() OVERRIDE; virtual void searchWithSpotlight() OVERRIDE; + virtual void showContextMenu() OVERRIDE; WebView *webView() { return m_webView; } diff --git a/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm b/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm index 08c0d6087..e31313603 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm @@ -42,9 +42,12 @@ #import "WebViewInternal.h" #import <WebCore/ContextMenu.h> #import <WebCore/ContextMenuController.h> +#import <WebCore/Document.h> #import <WebCore/KURL.h> #import <WebCore/LocalizedStrings.h> #import <WebCore/Page.h> +#import <WebCore/Frame.h> +#import <WebCore/FrameView.h> #import <WebCore/RuntimeApplicationChecks.h> #import <WebKit/DOMPrivate.h> @@ -346,3 +349,29 @@ void WebContextMenuClient::stopSpeaking() { [NSApp stopSpeaking:nil]; } + +void WebContextMenuClient::showContextMenu() +{ + Page* page = [m_webView page]; + if (!page) + return; + ContextMenuController* controller = page->contextMenuController(); + Node* node = controller->hitTestResult().innerNonSharedNode(); + if (!node) + return; + Frame* frame = node->document()->frame(); + if (!frame) + return; + FrameView* frameView = frame->view(); + if (!frameView) + return; + + IntPoint point = frameView->contentsToWindow(controller->hitTestResult().roundedPoint()); + NSView* view = frameView->documentView(); + NSPoint nsScreenPoint = [view convertPoint:point toView:nil]; + // Show the contextual menu for this event. + NSEvent* event = [NSEvent mouseEventWithType:NSRightMouseDown location:nsScreenPoint modifierFlags:0 timestamp:0 windowNumber:[[view window] windowNumber] context:0 eventNumber:0 clickCount:1 pressure:1]; + NSMenu* nsMenu = [view menuForEvent:event]; + if (nsMenu) + [NSMenu popUpContextMenu:nsMenu withEvent:event forView:view]; +} diff --git a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h b/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h index c75fee09f..06fca8d0e 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h +++ b/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h @@ -72,7 +72,7 @@ public: virtual NSString* userVisibleString(NSURL *) OVERRIDE; virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource> >&) OVERRIDE; - virtual void setInsertionPasteboard(NSPasteboard *) OVERRIDE; + virtual void setInsertionPasteboard(const String&) OVERRIDE; virtual NSURL* canonicalizeURL(NSURL*) OVERRIDE; virtual NSURL* canonicalizeURLString(NSString*) OVERRIDE; diff --git a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm index 478553034..4ffef315d 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm @@ -373,9 +373,9 @@ DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttrib return core(fragment); } -void WebEditorClient::setInsertionPasteboard(NSPasteboard *pasteboard) +void WebEditorClient::setInsertionPasteboard(const String& pasteboardName) { - [m_webView _setInsertionPasteboard:pasteboard]; + [m_webView _setInsertionPasteboard:[NSPasteboard pasteboardWithName:pasteboardName]]; } diff --git a/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm index 819dd16ce..8ff420c6a 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm @@ -1714,7 +1714,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView); if (implementations->plugInFailedWithErrorFunc) { KURL pluginPageURL = document->completeURL(stripLeadingAndTrailingHTMLSpaces(parameterValue(paramNames, paramValues, "pluginspage"))); - if (!pluginPageURL.protocolInHTTPFamily()) + if (!pluginPageURL.protocolIsInHTTPFamily()) pluginPageURL = KURL(); NSString *pluginName = pluginPackage ? (NSString *)[pluginPackage pluginInfo].name : nil; diff --git a/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h b/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h index 2239d5e7f..b145dc4e4 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h +++ b/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h @@ -47,6 +47,7 @@ class WebView; namespace WebCore { +class Frame; class Page; } @@ -62,6 +63,7 @@ public: virtual void openInspectorFrontend(WebCore::InspectorController*) OVERRIDE; virtual void closeInspectorFrontend() OVERRIDE; virtual void bringFrontendToFront() OVERRIDE; + virtual void didResizeMainFrame(WebCore::Frame*) OVERRIDE; virtual void highlight() OVERRIDE; virtual void hideHighlight() OVERRIDE; diff --git a/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm index 2ae865951..b288f9f97 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm @@ -41,10 +41,13 @@ #import "WebViewInternal.h" #import <WebCore/InspectorController.h> #import <WebCore/Page.h> +#import <WebCore/SoftLinking.h> #import <WebKit/DOMExtensions.h> #import <WebKitSystemInterface.h> #import <wtf/PassOwnPtr.h> +SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(WebInspector) + using namespace WebCore; @interface WebInspectorWindowController : NSWindowController <NSWindowDelegate> { @@ -111,6 +114,12 @@ void WebInspectorClient::bringFrontendToFront() m_frontendClient->bringToFront(); } +void WebInspectorClient::didResizeMainFrame(Frame*) +{ + if (m_frontendClient) + m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow()); +} + void WebInspectorClient::highlight() { [m_highlighter.get() highlight]; @@ -154,10 +163,20 @@ void WebInspectorFrontendClient::frontendLoaded() setAttachedWindow(attached); } +static bool useWebKitWebInspector() +{ + // Call the soft link framework function to dlopen it, then [NSBundle bundleWithIdentifier:] will work. + WebInspectorLibrary(); + + return [[NSUserDefaults standardUserDefaults] boolForKey:@"UseWebKitWebInspector"] || + ![[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] pathForResource:@"Main" ofType:@"html"]; +} + String WebInspectorFrontendClient::localizedStringsURL() { - NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"localizedStrings" ofType:@"js"]; - if (path) + NSBundle *bundle = useWebKitWebInspector() ? [NSBundle bundleWithIdentifier:@"com.apple.WebCore"] : [NSBundle bundleWithIdentifier:@"com.apple.WebInspector"]; + NSString *path = [bundle pathForResource:@"localizedStrings" ofType:@"js"]; + if ([path length]) return [[NSURL fileURLWithPath:path] absoluteString]; return String(); } @@ -252,7 +271,14 @@ void WebInspectorFrontendClient::updateWindowTitle() const [preferences release]; - NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"]; + NSString *path; + if (useWebKitWebInspector()) + path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"]; + else + path = [[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] pathForResource:@"Main" ofType:@"html"]; + + ASSERT([path length]); + NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL fileURLWithPath:path]]; [[_webView mainFrame] loadRequest:request]; [request release]; @@ -289,18 +315,22 @@ void WebInspectorFrontendClient::updateWindowTitle() const if (window) return window; + bool useTexturedWindow = useWebKitWebInspector(); + NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask); - styleMask |= NSTexturedBackgroundWindowMask; + if (useTexturedWindow) + styleMask |= NSTexturedBackgroundWindowMask; window = [[NSWindow alloc] initWithContentRect:NSMakeRect(60.0, 200.0, 750.0, 650.0) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO]; [window setDelegate:self]; [window setMinSize:NSMakeSize(400.0, 400.0)]; - [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; - [window setContentBorderThickness:55. forEdge:NSMaxYEdge]; - - WKNSWindowMakeBottomCornersSquare(window); + if (useTexturedWindow) { + [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; + [window setContentBorderThickness:55. forEdge:NSMaxYEdge]; + WKNSWindowMakeBottomCornersSquare(window); + } [self setWindow:window]; [window release]; diff --git a/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h b/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h index a40ce81e5..d68d92275 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h +++ b/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h @@ -23,7 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import <WebCore/NotificationPresenter.h> +#import <WebCore/NotificationClient.h> #if ENABLE(NOTIFICATIONS) #import <WebCore/Notification.h> @@ -41,7 +41,7 @@ class VoidCallback; @class WebNotification; @class WebView; -class WebNotificationClient : public WebCore::NotificationPresenter { +class WebNotificationClient : public WebCore::NotificationClient { public: WebNotificationClient(WebView *); WebView *webView() { return m_webView; } @@ -54,7 +54,7 @@ private: virtual void notificationControllerDestroyed() OVERRIDE; virtual void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::VoidCallback>) OVERRIDE; virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) OVERRIDE { } - virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::ScriptExecutionContext*) OVERRIDE; + virtual WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) OVERRIDE; WebView *m_webView; #if ENABLE(NOTIFICATIONS) diff --git a/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm b/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm index 2f7cd5411..3fdf0bc7f 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm @@ -171,29 +171,29 @@ void WebNotificationClient::requestPermission(ScriptExecutionContext* context, P #endif } -NotificationPresenter::Permission WebNotificationClient::checkPermission(ScriptExecutionContext* context) +NotificationClient::Permission WebNotificationClient::checkPermission(ScriptExecutionContext* context) { #if ENABLE(NOTIFICATIONS) if (!context || !context->isDocument()) - return NotificationPresenter::PermissionDenied; + return NotificationClient::PermissionDenied; if (![[m_webView preferences] notificationsEnabled]) - return NotificationPresenter::PermissionDenied; + return NotificationClient::PermissionDenied; WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:context->securityOrigin()]; WebNotificationPermission permission = [[m_webView _notificationProvider] policyForOrigin:webOrigin]; [webOrigin release]; switch (permission) { case WebNotificationPermissionAllowed: - return NotificationPresenter::PermissionAllowed; + return NotificationClient::PermissionAllowed; case WebNotificationPermissionDenied: - return NotificationPresenter::PermissionDenied; + return NotificationClient::PermissionDenied; case WebNotificationPermissionNotAllowed: - return NotificationPresenter::PermissionNotAllowed; + return NotificationClient::PermissionNotAllowed; default: - return NotificationPresenter::PermissionNotAllowed; + return NotificationClient::PermissionNotAllowed; } #else UNUSED_PARAM(context); - return NotificationPresenter::PermissionDenied; + return NotificationClient::PermissionDenied; #endif } diff --git a/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm b/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm index 2a76c98a9..86a44d675 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm @@ -43,6 +43,9 @@ void InitWebCoreSystemInterface(void) return; INIT(AdvanceDefaultButtonPulseAnimation); +#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + INIT(CALayerEnumerateRectsBeingDrawnWithBlock); +#endif INIT(CGContextGetShouldSmoothFonts); INIT(CGPatternCreateWithImageAndTransform); INIT(CGContextResetClip); @@ -166,6 +169,8 @@ void InitWebCoreSystemInterface(void) INIT(CopyCFURLResponseSuggestedFilename); INIT(SetCFURLResponseMIMEType); + INIT(SetMetadataURL); + #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) INIT(CreateVMPressureDispatchOnMainQueue); #endif diff --git a/Source/WebKit/mac/WebView/WebArchiveInternal.h b/Source/WebKit/mac/WebView/WebArchiveInternal.h index 071d4ab70..4ff5096a6 100644 --- a/Source/WebKit/mac/WebView/WebArchiveInternal.h +++ b/Source/WebKit/mac/WebView/WebArchiveInternal.h @@ -27,7 +27,7 @@ */ #import "WebArchive.h" -#import <JavaScriptCore/Forward.h> +#import <wtf/Forward.h> namespace WebCore { class LegacyWebArchive; diff --git a/Source/WebKit/mac/WebView/WebFrame.mm b/Source/WebKit/mac/WebView/WebFrame.mm index 24bb8f39c..e085bc17f 100644 --- a/Source/WebKit/mac/WebView/WebFrame.mm +++ b/Source/WebKit/mac/WebView/WebFrame.mm @@ -60,6 +60,7 @@ #import <WebCore/Chrome.h> #import <WebCore/ColorMac.h> #import <WebCore/DOMImplementation.h> +#import <WebCore/DatabaseContext.h> #import <WebCore/DocumentFragment.h> #import <WebCore/DocumentLoader.h> #import <WebCore/DocumentMarkerController.h> @@ -797,7 +798,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) - (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction { - if (!_private->coreFrame) + if (!_private->coreFrame || !style) return; // FIXME: We shouldn't have to create a copy here. _private->coreFrame->editor()->computeAndSetTypingStyle(core(style)->copy().get(), undoAction); @@ -1120,13 +1121,9 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) if (Document* document = _private->coreFrame->document()) { #if ENABLE(SQL_DATABASE) - if (document->hasOpenDatabases()) + if (DatabaseContext::hasOpenDatabases(document)) [result setObject:[NSNumber numberWithBool:YES] forKey:WebFrameUsesDatabases]; #endif - - if (document->usingGeolocation()) - [result setObject:[NSNumber numberWithBool:YES] forKey:WebFrameUsesGeolocation]; - if (!document->canSuspendActiveDOMObjects()) [result setObject:[NSNumber numberWithBool:YES] forKey:WebFrameCanSuspendActiveDOMObjects]; } diff --git a/Source/WebKit/mac/WebView/WebFullScreenController.h b/Source/WebKit/mac/WebView/WebFullScreenController.h index 0cb25d974..ea03af4ba 100644 --- a/Source/WebKit/mac/WebView/WebFullScreenController.h +++ b/Source/WebKit/mac/WebView/WebFullScreenController.h @@ -27,8 +27,10 @@ #import <wtf/OwnPtr.h> #import <wtf/RefPtr.h> +#import <wtf/RetainPtr.h> @class WebWindowFadeAnimation; +@class WebWindowScaleAnimation; @class WebView; namespace WebCore { class DisplaySleepDisabler; @@ -40,16 +42,18 @@ namespace WebCore { @interface WebFullScreenController : NSWindowController { @private RefPtr<WebCore::Element> _element; - WebCore::RenderBox* _renderer; // (set) WebView *_webView; - NSView* _placeholderView; - RefPtr<WebCore::EventListener> _mediaEventListener; + RetainPtr<NSView> _webViewPlaceholder; + RetainPtr<WebWindowScaleAnimation> _scaleAnimation; + RetainPtr<WebWindowFadeAnimation> _fadeAnimation; + RetainPtr<NSWindow> _backgroundWindow; + NSRect _initialFrame; + NSRect _finalFrame; - BOOL _isAnimating; - BOOL _isFullscreen; - BOOL _forceDisableAnimation; - OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler; - CGRect _initialFrame; + BOOL _isEnteringFullScreen; + BOOL _isExitingFullScreen; + BOOL _isFullScreen; + BOOL _isPlaying; } - (WebView*)webView; @@ -58,12 +62,9 @@ namespace WebCore { - (void)setElement:(PassRefPtr<WebCore::Element>)element; - (WebCore::Element*)element; -- (void)setRenderer:(WebCore::RenderBox*)renderer; -- (WebCore::RenderBox*)renderer; - -- (void)enterFullscreen:(NSScreen *)screen; -- (void)exitFullscreen; - +- (void)enterFullScreen:(NSScreen *)screen; +- (void)exitFullScreen; +- (void)close; @end #endif // ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit/mac/WebView/WebFullScreenController.mm b/Source/WebKit/mac/WebView/WebFullScreenController.mm index aae92e841..eda499cd9 100644 --- a/Source/WebKit/mac/WebView/WebFullScreenController.mm +++ b/Source/WebKit/mac/WebView/WebFullScreenController.mm @@ -30,72 +30,61 @@ #import "WebNSWindowExtras.h" #import "WebPreferencesPrivate.h" #import "WebViewInternal.h" -#import <IOKit/pwr_mgt/IOPMLib.h> -#import <OSServices/Power.h> -#import <WebCore/AnimationList.h> -#import <WebCore/CSSPropertyNames.h> -#import <WebCore/Color.h> -#import <WebCore/DOMDocument.h> -#import <WebCore/DOMDocumentInternal.h> -#import <WebCore/DOMHTMLElement.h> -#import <WebCore/DOMWindow.h> -#import <WebCore/DisplaySleepDisabler.h> #import <WebCore/Document.h> -#import <WebCore/EventListener.h> -#import <WebCore/EventNames.h> +#import <WebCore/Element.h> +#import <WebCore/FloatRect.h> #import <WebCore/HTMLElement.h> -#import <WebCore/HTMLMediaElement.h> -#import <WebCore/HTMLNames.h> #import <WebCore/IntRect.h> -#import <WebCore/NodeList.h> -#import <WebCore/RenderBlock.h> +#import <WebCore/Page.h> #import <WebCore/RenderLayer.h> #import <WebCore/RenderLayerBacking.h> +#import <WebCore/RenderObject.h> +#import <WebCore/RenderView.h> #import <WebCore/SoftLinking.h> -#import <objc/objc-runtime.h> +#import <WebCore/WebCoreFullScreenWindow.h> +#import <WebCore/WebWindowAnimation.h> +#import <WebKitSystemInterface.h> #import <wtf/RetainPtr.h> #import <wtf/UnusedParam.h> -static NSString* const isEnteringFullscreenKey = @"isEnteringFullscreen"; - using namespace WebCore; -@interface WebFullscreenWindow : NSWindow -#ifndef BUILDING_ON_LEOPARD -<NSAnimationDelegate> -#endif +static const CFTimeInterval defaultAnimationDuration = 0.5; + +static IntRect screenRectOfContents(Element* element) { - NSView* _animationView; - - CALayer* _rendererLayer; - CALayer* _backgroundLayer; + ASSERT(element); + if (element->renderer() && element->renderer()->hasLayer() && element->renderer()->enclosingLayer()->isComposited()) { + FloatQuad contentsBox = static_cast<FloatRect>(element->renderer()->enclosingLayer()->backing()->contentsBox()); + contentsBox = element->renderer()->localToAbsoluteQuad(contentsBox); + return element->renderer()->view()->frameView()->contentsToScreen(contentsBox.enclosingBoundingBox()); + } + return element->screenRect(); } -- (CALayer*)rendererLayer; -- (void)setRendererLayer:(CALayer*)rendererLayer; -- (CALayer*)backgroundLayer; -- (NSView*)animationView; -@end -class MediaEventListener : public EventListener { -public: - static PassRefPtr<MediaEventListener> create(WebFullScreenController* delegate); - virtual bool operator==(const EventListener&); - virtual void handleEvent(ScriptExecutionContext*, Event*); - -private: - MediaEventListener(WebFullScreenController* delegate); - WebFullScreenController* delegate; -}; - -@interface WebFullScreenController(Private) -- (void)_requestExitFullscreenWithAnimation:(BOOL)animation; -- (void)_updateMenuAndDockForFullscreen; -- (void)_updatePowerAssertions; -- (WebFullscreenWindow *)_fullscreenWindow; +@interface WebFullScreenController(Private)<NSAnimationDelegate> +- (void)_updateMenuAndDockForFullScreen; +- (void)_swapView:(NSView*)view with:(NSView*)otherView; - (Document*)_document; -- (CFTimeInterval)_animationDuration; -- (BOOL)_isAnyMoviePlaying; +- (void)_startEnterFullScreenAnimationWithDuration:(NSTimeInterval)duration; +- (void)_startExitFullScreenAnimationWithDuration:(NSTimeInterval)duration; +@end + +#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) +@interface NSWindow(convertRectToScreenForLeopardAndSnowLeopard) +- (NSRect)convertRectToScreen:(NSRect)aRect; +@end + +@implementation NSWindow(convertRectToScreenForLeopardAndSnowLeopard) +- (NSRect)convertRectToScreen:(NSRect)rect +{ + NSRect frame = [self frame]; + rect.origin.x += frame.origin.x; + rect.origin.y += frame.origin.y; + return rect; +} @end +#endif @interface NSWindow(IsOnActiveSpaceAdditionForTigerAndLeopard) - (BOOL)isOnActiveSpace; @@ -108,21 +97,21 @@ private: - (id)init { // Do not defer window creation, to make sure -windowNumber is created (needed by WebWindowScaleAnimation). - NSWindow *window = [[WebFullscreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + NSWindow *window = [[WebCoreFullScreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; self = [super initWithWindow:window]; [window release]; if (!self) return nil; [self windowDidLoad]; - _mediaEventListener = MediaEventListener::create(self); + return self; - } - (void)dealloc { [self setWebView:nil]; - [_placeholderView release]; + + [NSObject cancelPreviousPerformRequestsWithTarget:self]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; @@ -130,7 +119,8 @@ private: - (void)windowDidLoad { - + [super windowDidLoad]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidResignActive:) name:NSApplicationDidResignActiveNotification object:NSApp]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidChangeScreenParameters:) name:NSApplicationDidChangeScreenParametersNotification object:NSApp]; } @@ -157,157 +147,25 @@ private: - (void)setElement:(PassRefPtr<Element>)element { - // When a new Element is set as the current full screen element, register event - // listeners on that Element's window, listening for changes in media play states. - // We will use these events to determine whether to disable the screensaver and - // display sleep timers when playing video in full screen. Make sure to unregister - // the events on the old element's window, if necessary, as well. - - EventNames& eventNames = WebCore::eventNames(); - - if (_element) { - DOMWindow* window = _element->document()->domWindow(); - if (window) { - window->removeEventListener(eventNames.playEvent, _mediaEventListener.get(), true); - window->removeEventListener(eventNames.pauseEvent, _mediaEventListener.get(), true); - window->removeEventListener(eventNames.endedEvent, _mediaEventListener.get(), true); - } - } - _element = element; - - if (_element) { - DOMWindow* window = _element->document()->domWindow(); - if (window) { - window->addEventListener(eventNames.playEvent, _mediaEventListener, true); - window->addEventListener(eventNames.pauseEvent, _mediaEventListener, true); - window->addEventListener(eventNames.endedEvent, _mediaEventListener, true); - } - } } -- (RenderBox*)renderer -{ - return _renderer; -} +#pragma mark - +#pragma mark NSWindowController overrides -- (void)setRenderer:(RenderBox*)renderer +- (void)cancelOperation:(id)sender { - _renderer = renderer; + [self performSelector:@selector(exitFullScreen) withObject:nil afterDelay:0]; } #pragma mark - #pragma mark Notifications -- (void)windowDidExitFullscreen:(BOOL)finished -{ - if (!_isAnimating) - return; - - if (_isFullscreen) - return; - - NSDisableScreenUpdates(); - ASSERT(_element); - [self _document]->setFullScreenRendererBackgroundColor(Color::black); - [self _document]->webkitDidExitFullScreenForElement(_element.get()); - [self setElement:nil]; - - if (finished) { - [self _updateMenuAndDockForFullscreen]; - [self _updatePowerAssertions]; - - [[_webView window] display]; - [[self _fullscreenWindow] setRendererLayer:nil]; - [[self window] close]; - } - - NSEnableScreenUpdates(); - - _isAnimating = NO; - [self autorelease]; // Associated -retain is in -exitFullscreen. -} - -- (void)windowDidEnterFullscreen:(BOOL)finished -{ - if (!_isAnimating) - return; - - if (!_isFullscreen) - return; - - NSDisableScreenUpdates(); - [self _document]->webkitDidEnterFullScreenForElement(_element.get()); - [self _document]->setFullScreenRendererBackgroundColor(Color::black); - - if (finished) { - [self _updateMenuAndDockForFullscreen]; - [self _updatePowerAssertions]; - [NSCursor setHiddenUntilMouseMoves:YES]; - - // Move the webView into our fullscreen Window - if (!_placeholderView) - _placeholderView = [[NSView alloc] init]; - - WebView *webView = [self webView]; - NSWindow *webWindow = [webView window]; - NSResponder *webWindowFirstResponder = [webWindow firstResponder]; - - // Do not swap the placeholder into place if already is in a window, - // assuming the placeholder's window will always be the webView's - // original window. - if (![_placeholderView window]) { - [_placeholderView setFrame:[webView frame]]; - [_placeholderView setAutoresizingMask:[webView autoresizingMask]]; - [_placeholderView removeFromSuperview]; - [[webView superview] replaceSubview:webView with:_placeholderView]; - - [[[self window] contentView] addSubview:webView]; - [[self window] makeResponder:webWindowFirstResponder firstResponderIfDescendantOfView:webView]; - [webView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; - [webView setFrame:[(NSView *)[[self window] contentView] bounds]]; - } - -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that - // behavior here, making sure to reset the animation behavior afterward. - NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior]; - [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone]; -#endif - [webWindow orderOut:self]; -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - [webWindow setAnimationBehavior:animationBehavior]; -#endif - - WebFullscreenWindow* window = [self _fullscreenWindow]; - [window setBackgroundColor:[NSColor blackColor]]; - [window setOpaque:YES]; - - [CATransaction begin]; - [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions]; - [[[window animationView] layer] setOpacity:0]; - [CATransaction commit]; - } - NSEnableScreenUpdates(); - - _isAnimating = NO; -} - -- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)finished -{ - BOOL isEnteringFullscreenAnimation = [[anim valueForKey:isEnteringFullscreenKey] boolValue]; - - if (!isEnteringFullscreenAnimation) - [self windowDidExitFullscreen:finished]; - else - [self windowDidEnterFullscreen:finished]; -} - - (void)applicationDidResignActive:(NSNotification*)notification { // Check to see if the fullscreenWindow is on the active space; this function is available // on 10.6 and later, so default to YES if the function is not available: - NSWindow* fullscreenWindow = [self _fullscreenWindow]; + NSWindow* fullscreenWindow = [self window]; BOOL isOnActiveSpace = ([fullscreenWindow respondsToSelector:@selector(isOnActiveSpace)] ? [fullscreenWindow isOnActiveSpace] : YES); // Replicate the QuickTime Player (X) behavior when losing active application status: @@ -315,7 +173,7 @@ private: // single screen is available.) Is the fullscreen screen on the current space? IFF so, // then exit fullscreen mode. if ([fullscreenWindow screen] == [[NSScreen screens] objectAtIndex:0] && isOnActiveSpace) - [self _requestExitFullscreenWithAnimation:NO]; + [self cancelOperation:self]; } - (void)applicationDidChangeScreenParameters:(NSNotification*)notification @@ -324,306 +182,230 @@ private: // the Dock's size or location, or they may have changed the fullscreen screen's dimensions. // Update our presentation parameters, and ensure that the full screen window occupies the // entire screen: - [self _updateMenuAndDockForFullscreen]; + [self _updateMenuAndDockForFullScreen]; NSWindow* window = [self window]; - [window setFrame:[[window screen] frame] display:YES]; + NSRect screenFrame = [[window screen] frame]; + [window setFrame:screenFrame display:YES]; + [_backgroundWindow.get() setFrame:screenFrame display:YES]; } #pragma mark - #pragma mark Exposed Interface -- (void)enterFullscreen:(NSScreen *)screen +- (void)enterFullScreen:(NSScreen *)screen { - // Disable animation if we are already in full-screen mode. - BOOL shouldAnimate = !_isFullscreen; - - if (_isAnimating) { - // The CAAnimation delegate functions will only be called the - // next trip through the run-loop, so manually call the delegate - // function here, letting it know the animation did not complete: - [self windowDidExitFullscreen:NO]; - ASSERT(!_isAnimating); - } - _isFullscreen = YES; - _isAnimating = YES; - - // setElement: must be called with a non-nil value before calling enterFullscreen:. - ASSERT(_element); + if (_isFullScreen) + return; + _isFullScreen = YES; - NSDisableScreenUpdates(); + [self _updateMenuAndDockForFullScreen]; if (!screen) screen = [NSScreen mainScreen]; NSRect screenFrame = [screen frame]; - WebView* webView = [self webView]; - NSRect webViewFrame = [webView convertRectToBase:[webView frame]]; - webViewFrame.origin = [[webView window] convertBaseToScreen:webViewFrame.origin]; + NSRect webViewFrame = [[_webView window] convertRectToScreen: + [_webView convertRect:[_webView frame] toView:nil]]; - NSRect elementFrame = _element->screenRect(); + // Flip coordinate system: + webViewFrame.origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(webViewFrame); - // In the case of a multi-monitor setup where the webView straddles two - // monitors, we must create a window large enough to contain the destination - // frame and the initial frame. - NSRect windowFrame = NSUnionRect(screenFrame, elementFrame); - [[self window] setFrame:windowFrame display:YES]; + CGWindowID windowID = [[_webView window] windowNumber]; + RetainPtr<CGImageRef> webViewContents = adoptCF(CGWindowListCreateImage(NSRectToCGRect(webViewFrame), kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageShouldBeOpaque)); - // In a previous incarnation, the NSWindow attached to this controller may have - // been on a different screen. Temporarily change the collectionBehavior of the window: - NSWindowCollectionBehavior behavior = [[self window] collectionBehavior]; - [[self window] setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; - [[self window] makeKeyAndOrderFront:self]; - [[self window] setCollectionBehavior:behavior]; - - NSView* animationView = [[self _fullscreenWindow] animationView]; - - NSRect backgroundBounds = {[[self window] convertScreenToBase:screenFrame.origin], screenFrame.size}; - backgroundBounds = [animationView convertRectFromBase:backgroundBounds]; - // Flip the background layer's coordinate system. - backgroundBounds.origin.y = windowFrame.size.height - NSMaxY(backgroundBounds); - - // Set our fullscreen element's initial frame, and flip the coordinate systems from - // screen coordinates (bottom/left) to layer coordinates (top/left): - _initialFrame = NSRectToCGRect(NSIntersectionRect(elementFrame, webViewFrame)); - _initialFrame.origin.y = screenFrame.size.height - CGRectGetMaxY(_initialFrame); - - // Inform the document that we will begin entering full screen. This will change - // pseudo-classes on the fullscreen element and the document element. - Document* document = [self _document]; - document->webkitWillEnterFullScreenForElement(_element.get()); - - // Check to see if the fullscreen renderer is composited. If not, accelerated graphics - // may be disabled. In this case, do not attempt to animate the contents into place; - // merely snap to the final position: - if (!shouldAnimate || !_renderer || !_renderer->layer()->isComposited()) { - [self windowDidEnterFullscreen:YES]; - NSEnableScreenUpdates(); - return; - } + // Screen updates to be re-enabled in beganEnterFullScreenWithInitialFrame:finalFrame: + NSDisableScreenUpdates(); + [[self window] setAutodisplay:NO]; - // Set up the final style of the FullScreen render block. Set an absolute - // width and height equal to the size of the screen, and anchor the layer - // at the top, left at (0,0). The RenderFullScreen style is already set - // to position:fixed. - [self _document]->setFullScreenRendererSize(IntSize(screenFrame.size)); - [self _document]->setFullScreenRendererBackgroundColor(Color::transparent); + NSResponder *webWindowFirstResponder = [[_webView window] firstResponder]; + [[self window] setFrame:screenFrame display:NO]; + + _initialFrame = screenRectOfContents(_element.get()); + + // Swap the webView placeholder into place. + if (!_webViewPlaceholder) { + _webViewPlaceholder.adoptNS([[NSView alloc] init]); + [_webViewPlaceholder.get() setLayer:[CALayer layer]]; + [_webViewPlaceholder.get() setWantsLayer:YES]; + } + [[_webViewPlaceholder.get() layer] setContents:(id)webViewContents.get()]; + [self _swapView:_webView with:_webViewPlaceholder.get()]; - // Cause the document to layout, thus calculating a new fullscreen element size: - [self _document]->updateLayout(); + // Then insert the WebView into the full screen window + NSView* contentView = [[self window] contentView]; + [contentView addSubview:_webView positioned:NSWindowBelow relativeTo:nil]; + [_webView setFrame:[contentView bounds]]; - // FIXME: try to use the fullscreen element's calculated x, y, width, and height instead of the - // renderBox functions: - RenderBox* childRenderer = _renderer->firstChildBox(); - CGRect destinationFrame = CGRectMake(childRenderer->x(), childRenderer->y(), childRenderer->width(), childRenderer->height()); - - // Some properties haven't propogated from the GraphicsLayer to the CALayer yet. So - // tell the renderer's layer to sync it's compositing state: - GraphicsLayer* rendererGraphics = _renderer->layer()->backing()->graphicsLayer(); - rendererGraphics->syncCompositingState(destinationFrame); - - CALayer* rendererLayer = rendererGraphics->platformLayer(); - [[self _fullscreenWindow] setRendererLayer:rendererLayer]; - - CFTimeInterval duration = [self _animationDuration]; - - // Create a transformation matrix that will transform the renderer layer such that - // the fullscreen element appears to move from its starting position and size to its - // final one. Perform the transformation in two steps, using the CALayer's matrix - // math to calculate the effects of each step: - // 1. Apply a scale tranform to shrink the apparent size of the layer to the original - // element screen size. - // 2. Apply a translation transform to move the shrunk layer into the same screen position - // as the original element. - CATransform3D shrinkTransform = CATransform3DMakeScale(_initialFrame.size.width / destinationFrame.size.width, _initialFrame.size.height / destinationFrame.size.height, 1); - [rendererLayer setTransform:shrinkTransform]; - CGRect shrunkDestinationFrame = [rendererLayer convertRect:destinationFrame toLayer:[animationView layer]]; - CATransform3D moveTransform = CATransform3DMakeTranslation(_initialFrame.origin.x - shrunkDestinationFrame.origin.x, _initialFrame.origin.y - shrunkDestinationFrame.origin.y, 0); - CATransform3D finalTransform = CATransform3DConcat(shrinkTransform, moveTransform); - [rendererLayer setTransform:finalTransform]; - - CALayer* backgroundLayer = [[self _fullscreenWindow] backgroundLayer]; - - // Start the opacity animation. We can use implicit animations here because we don't care when - // the animation finishes. - [CATransaction begin]; - [CATransaction setValue:[NSNumber numberWithDouble:duration] forKey:kCATransactionAnimationDuration]; - [backgroundLayer setOpacity:1]; - [CATransaction commit]; + [[self window] makeResponder:webWindowFirstResponder firstResponderIfDescendantOfView:_webView]; - // Use a CABasicAnimation here for the zoom effect. We want to be notified that the animation has - // completed by way of the CAAnimation delegate. - CABasicAnimation* zoomAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; - [zoomAnimation setFromValue:[NSValue valueWithCATransform3D:finalTransform]]; - [zoomAnimation setToValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; - [zoomAnimation setDelegate:self]; - [zoomAnimation setDuration:duration]; - [zoomAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; - [zoomAnimation setFillMode:kCAFillModeForwards]; - [zoomAnimation setValue:(id)kCFBooleanTrue forKey:isEnteringFullscreenKey]; - - // Disable implicit animations and set the layer's transformation matrix to its final state. - [CATransaction begin]; - [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions]; - [rendererLayer setTransform:CATransform3DIdentity]; - [rendererLayer addAnimation:zoomAnimation forKey:@"zoom"]; - [backgroundLayer setFrame:NSRectToCGRect(backgroundBounds)]; - [CATransaction commit]; + [self _document]->webkitWillEnterFullScreenForElement(_element.get()); + [self _document]->setAnimatingFullScreen(true); + [self _document]->updateLayout(); + + _finalFrame = screenRectOfContents(_element.get()); - NSEnableScreenUpdates(); + [self _updateMenuAndDockForFullScreen]; + + [self _startEnterFullScreenAnimationWithDuration:defaultAnimationDuration]; + + _isEnteringFullScreen = true; } -- (void)exitFullscreen +- (void)finishedEnterFullScreenAnimation:(bool)completed { - if (!_isFullscreen) - return; - - CATransform3D startTransform = CATransform3DIdentity; - if (_isAnimating) { - if (_renderer && _renderer->layer()->isComposited()) { - CALayer* rendererLayer = _renderer->layer()->backing()->graphicsLayer()->platformLayer(); - startTransform = [[rendererLayer presentationLayer] transform]; - } - - // The CAAnimation delegate functions will only be called the - // next trip through the run-loop, so manually call the delegate - // function here, letting it know the animation did not complete: - [self windowDidEnterFullscreen:NO]; - ASSERT(!_isAnimating); - } - _isFullscreen = NO; - _isAnimating = YES; - - NSDisableScreenUpdates(); - + if (!_isEnteringFullScreen) + return; + _isEnteringFullScreen = NO; - // The fullscreen animation may have been cancelled before the - // webView was moved to the fullscreen window. Check to see - // if the _placeholderView exists and is in a window before - // attempting to swap the webView back to it's original tree: - if (_placeholderView && [_placeholderView window]) { - // Move the webView back to its own native window: - WebView* webView = [self webView]; - NSResponder *fullScreenWindowFirstResponder = [[self window] firstResponder]; - [webView setFrame:[_placeholderView frame]]; - [webView setAutoresizingMask:[_placeholderView autoresizingMask]]; - [webView removeFromSuperview]; - [[_placeholderView superview] replaceSubview:_placeholderView with:webView]; - [[webView window] makeResponder:fullScreenWindowFirstResponder firstResponderIfDescendantOfView:webView]; + if (completed) { + // Screen updates to be re-enabled at the end of this block + NSDisableScreenUpdates(); + [self _document]->setAnimatingFullScreen(false); + [self _document]->webkitDidEnterFullScreenForElement(_element.get()); - NSWindow *webWindow = [[self webView] window]; + NSRect windowBounds = [[self window] frame]; + windowBounds.origin = NSZeroPoint; + WKWindowSetClipRect([self window], windowBounds); + + NSWindow *webWindow = [_webViewPlaceholder.get() window]; #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that // behavior here, making sure to reset the animation behavior afterward. NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior]; [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone]; #endif - // The user may have moved the fullscreen window in Spaces, so temporarily change - // the collectionBehavior of the fullscreen window: + [webWindow orderOut:self]; +#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + [webWindow setAnimationBehavior:animationBehavior]; +#endif + + [_fadeAnimation.get() stopAnimation]; + [_fadeAnimation.get() setWindow:nil]; + _fadeAnimation = nullptr; + + [_backgroundWindow.get() orderOut:self]; + [_backgroundWindow.get() setFrame:NSZeroRect display:YES]; + NSEnableScreenUpdates(); + } else + [_scaleAnimation.get() stopAnimation]; +} + +- (void)exitFullScreen +{ + if (!_isFullScreen) + return; + _isFullScreen = NO; + + // Screen updates to be re-enabled in beganExitFullScreenWithInitialFrame:finalFrame: + NSDisableScreenUpdates(); + [[self window] setAutodisplay:NO]; + + _finalFrame = screenRectOfContents(_element.get()); + + [self _document]->webkitWillExitFullScreenForElement(_element.get()); + [self _document]->setAnimatingFullScreen(true); + + if (_isEnteringFullScreen) + [self finishedEnterFullScreenAnimation:NO]; + + [self _updateMenuAndDockForFullScreen]; + + NSWindow* webWindow = [_webViewPlaceholder.get() window]; +#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that + // behavior here, making sure to reset the animation behavior afterward. + NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior]; + [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone]; +#endif + // If the user has moved the fullScreen window into a new space, temporarily change + // the collectionBehavior of the webView's window so that it is pulled into the active space: + if (![webWindow isOnActiveSpace]) { NSWindowCollectionBehavior behavior = [webWindow collectionBehavior]; [webWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; [webWindow setCollectionBehavior:behavior]; + } else + [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - [webWindow setAnimationBehavior:animationBehavior]; + [webWindow setAnimationBehavior:animationBehavior]; #endif - // Because the animation view is layer-hosted, make sure to - // disable animations when changing the layer's opacity. Other- - // wise, the content will appear to fade into view. - [CATransaction begin]; - [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions]; - WebFullscreenWindow* window = [self _fullscreenWindow]; - [[[window animationView] layer] setOpacity:1]; - [window setBackgroundColor:[NSColor clearColor]]; - [window setOpaque:NO]; - [CATransaction commit]; - } - - NSView* animationView = [[self _fullscreenWindow] animationView]; - CGRect layerEndFrame = NSRectToCGRect([animationView convertRect:NSRectFromCGRect(_initialFrame) fromView:nil]); + [self _startExitFullScreenAnimationWithDuration:defaultAnimationDuration]; + _isExitingFullScreen = YES; +} - // The _renderer might be NULL due to its ancestor being removed: - CGRect layerStartFrame = CGRectZero; - if (_renderer) { - RenderBox* childRenderer = _renderer->firstChildBox(); - layerStartFrame = CGRectMake(childRenderer->x(), childRenderer->y(), childRenderer->width(), childRenderer->height()); - } +- (void)finishedExitFullScreenAnimation:(bool)completed +{ + if (!_isExitingFullScreen) + return; + _isExitingFullScreen = NO; - [self _document]->webkitWillExitFullScreenForElement(_element.get()); - [self _document]->updateLayout(); + [self _updateMenuAndDockForFullScreen]; - // We have to retain ourselves because we want to be alive for the end of the animation. - // If our owner releases us we could crash if this is not the case. - // Balanced in windowDidExitFullscreen - [self retain]; + // Screen updates to be re-enabled at the end of this function + NSDisableScreenUpdates(); - // Check to see if the fullscreen renderer is composited. If not, accelerated graphics - // may be disabled. In this case, do not attempt to animate the contents into place; - // merely snap to the final position: - if (!_renderer || !_renderer->layer()->isComposited()) { - [self windowDidExitFullscreen:YES]; - NSEnableScreenUpdates(); - return; - } - - GraphicsLayer* rendererGraphics = _renderer->layer()->backing()->graphicsLayer(); + [self _document]->setAnimatingFullScreen(false); + [self _document]->webkitDidExitFullScreenForElement(_element.get()); - [self _document]->setFullScreenRendererBackgroundColor(Color::transparent); - - rendererGraphics->syncCompositingState(layerEndFrame); - - CALayer* rendererLayer = rendererGraphics->platformLayer(); - [[self _fullscreenWindow] setRendererLayer:rendererLayer]; + NSResponder *firstResponder = [[self window] firstResponder]; + [self _swapView:_webViewPlaceholder.get() with:_webView]; + [[_webView window] makeResponder:firstResponder firstResponderIfDescendantOfView:_webView]; - // Create a transformation matrix that will transform the renderer layer such that - // the fullscreen element appears to move from the full screen to its original position - // and size. Perform the transformation in two steps, using the CALayer's matrix - // math to calculate the effects of each step: - // 1. Apply a scale tranform to shrink the apparent size of the layer to the original - // element screen size. - // 2. Apply a translation transform to move the shrunk layer into the same screen position - // as the original element. - CATransform3D shrinkTransform = CATransform3DMakeScale(layerEndFrame.size.width / layerStartFrame.size.width, layerEndFrame.size.height / layerStartFrame.size.height, 1); - [rendererLayer setTransform:shrinkTransform]; - CGRect shrunkDestinationFrame = [rendererLayer convertRect:layerStartFrame toLayer:[animationView layer]]; - CATransform3D moveTransform = CATransform3DMakeTranslation(layerEndFrame.origin.x - shrunkDestinationFrame.origin.x, layerEndFrame.origin.y - shrunkDestinationFrame.origin.y, 0); - CATransform3D finalTransform = CATransform3DConcat(shrinkTransform, moveTransform); - [rendererLayer setTransform:finalTransform]; - - CFTimeInterval duration = [self _animationDuration]; - - CALayer* backgroundLayer = [[self _fullscreenWindow] backgroundLayer]; - [CATransaction begin]; - [CATransaction setValue:[NSNumber numberWithDouble:duration] forKey:kCATransactionAnimationDuration]; - [backgroundLayer setOpacity:0]; - [CATransaction commit]; + NSRect windowBounds = [[self window] frame]; + windowBounds.origin = NSZeroPoint; + WKWindowSetClipRect([self window], windowBounds); + + [[self window] orderOut:self]; + [[self window] setFrame:NSZeroRect display:YES]; - CABasicAnimation* zoomAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; - [zoomAnimation setFromValue:[NSValue valueWithCATransform3D:startTransform]]; - [zoomAnimation setToValue:[NSValue valueWithCATransform3D:finalTransform]]; - [zoomAnimation setDelegate:self]; - [zoomAnimation setDuration:duration]; - [zoomAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; - [zoomAnimation setFillMode:kCAFillModeBoth]; - [zoomAnimation setRemovedOnCompletion:NO]; - [zoomAnimation setValue:(id)kCFBooleanFalse forKey:isEnteringFullscreenKey]; + [_fadeAnimation.get() stopAnimation]; + [_fadeAnimation.get() setWindow:nil]; + _fadeAnimation = nullptr; - [rendererLayer addAnimation:zoomAnimation forKey:@"zoom"]; + [_backgroundWindow.get() orderOut:self]; + [_backgroundWindow.get() setFrame:NSZeroRect display:YES]; NSEnableScreenUpdates(); } +- (void)close +{ + // We are being asked to close rapidly, most likely because the page + // has closed or the web process has crashed. Just walk through our + // normal exit full screen sequence, but don't wait to be called back + // in response. + if (_isFullScreen) + [self exitFullScreen]; + + if (_isExitingFullScreen) + [self finishedExitFullScreenAnimation:YES]; + + [super close]; +} + +#pragma mark - +#pragma mark NSAnimation delegate + +- (void)animationDidEnd:(NSAnimation*)animation +{ + if (_isFullScreen) + [self finishedEnterFullScreenAnimation:YES]; + else + [self finishedExitFullScreenAnimation:YES]; +} + #pragma mark - #pragma mark Internal Interface -- (void)_updateMenuAndDockForFullscreen +- (void)_updateMenuAndDockForFullScreen { // NSApplicationPresentationOptions is available on > 10.6 only: #ifndef BUILDING_ON_LEOPARD NSApplicationPresentationOptions options = NSApplicationPresentationDefault; NSScreen* fullscreenScreen = [[self window] screen]; - if (_isFullscreen) { + if (_isFullScreen) { // Auto-hide the menu bar if the fullscreenScreen contains the menu bar: // NOTE: if the fullscreenScreen contains the menu bar but not the dock, we must still // auto-hide the dock, or an exception will be thrown. @@ -640,212 +422,145 @@ private: [NSApp setPresentationOptions:options]; else #endif - SetSystemUIMode(_isFullscreen ? kUIModeNormal : kUIModeAllHidden, 0); + SetSystemUIMode(_isFullScreen ? kUIModeNormal : kUIModeAllHidden, 0); } -- (void)_updatePowerAssertions -{ - BOOL isPlaying = [self _isAnyMoviePlaying]; - - if (isPlaying && _isFullscreen) { - if (!_displaySleepDisabler) - _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebKit - Fullscreen video"); - } else - _displaySleepDisabler = nullptr; -} - -- (void)_requestExit -{ - [self exitFullscreen]; - _forceDisableAnimation = NO; -} +#pragma mark - +#pragma mark Utility Functions -- (void)_requestExitFullscreenWithAnimation:(BOOL)animation +- (Document*)_document { - _forceDisableAnimation = !animation; - [self performSelector:@selector(_requestExit) withObject:nil afterDelay:0]; - + return _element->document(); } -- (BOOL)_isAnyMoviePlaying +- (void)_swapView:(NSView*)view with:(NSView*)otherView { -#if ENABLE(VIDEO) - if (!_element) - return NO; - - Node* nextNode = _element.get(); - while (nextNode) - { - if (nextNode->hasTagName(HTMLNames::videoTag) && static_cast<Element*>(nextNode)->isMediaElement()) { - HTMLMediaElement* element = static_cast<HTMLMediaElement*>(nextNode); - if (!element->paused() && !element->ended()) - return YES; - } - - nextNode = nextNode->traverseNextNode(_element.get()); - } -#endif - - return NO; + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [otherView setFrame:[view frame]]; + [otherView setAutoresizingMask:[view autoresizingMask]]; + [otherView removeFromSuperview]; + [[view superview] replaceSubview:view with:otherView]; + [CATransaction commit]; } -#pragma mark - -#pragma mark Utility Functions - -- (WebFullscreenWindow *)_fullscreenWindow +static RetainPtr<NSWindow> createBackgroundFullscreenWindow(NSRect frame) { - return (WebFullscreenWindow *)[self window]; + NSWindow *window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + [window setOpaque:YES]; + [window setBackgroundColor:[NSColor blackColor]]; + [window setReleasedWhenClosed:NO]; + return adoptNS(window); } -- (Document*)_document +static NSRect windowFrameFromApparentFrames(NSRect screenFrame, NSRect initialFrame, NSRect finalFrame) { - return _element->document(); + NSRect initialWindowFrame; + CGFloat xScale = NSWidth(screenFrame) / NSWidth(finalFrame); + CGFloat yScale = NSHeight(screenFrame) / NSHeight(finalFrame); + CGFloat xTrans = NSMinX(screenFrame) - NSMinX(finalFrame); + CGFloat yTrans = NSMinY(screenFrame) - NSMinY(finalFrame); + initialWindowFrame.size = NSMakeSize(NSWidth(initialFrame) * xScale, NSHeight(initialFrame) * yScale); + initialWindowFrame.origin = NSMakePoint + ( NSMinX(initialFrame) + xTrans / (NSWidth(finalFrame) / NSWidth(initialFrame)) + , NSMinY(initialFrame) + yTrans / (NSHeight(finalFrame) / NSHeight(initialFrame))); + return initialWindowFrame; } -- (CFTimeInterval)_animationDuration +- (void)_startEnterFullScreenAnimationWithDuration:(NSTimeInterval)duration { - static const CFTimeInterval defaultDuration = 0.5; - CFTimeInterval duration = defaultDuration; -#ifndef BUILDING_ON_LEOPARD - NSUInteger modifierFlags = [NSEvent modifierFlags]; -#else - NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; -#endif - if ((modifierFlags & NSControlKeyMask) == NSControlKeyMask) - duration *= 2; - if ((modifierFlags & NSShiftKeyMask) == NSShiftKeyMask) - duration *= 10; - if (_forceDisableAnimation) { - // This will disable scale animation - duration = 0; + NSRect screenFrame = [[[self window] screen] frame]; + NSRect initialWindowFrame = windowFrameFromApparentFrames(screenFrame, _initialFrame, _finalFrame); + + _scaleAnimation = adoptNS([[WebWindowScaleAnimation alloc] initWithHintedDuration:duration window:[self window] initalFrame:initialWindowFrame finalFrame:screenFrame]); + + [_scaleAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking]; + [_scaleAnimation.get() setDelegate:self]; + [_scaleAnimation.get() setCurrentProgress:0]; + [_scaleAnimation.get() startAnimation]; + + // WKWindowSetClipRect takes window coordinates, so convert from screen coordinates here: + NSRect finalBounds = _finalFrame; + finalBounds.origin = [[self window] convertScreenToBase:finalBounds.origin]; + WKWindowSetClipRect([self window], finalBounds); + + [[self window] makeKeyAndOrderFront:self]; + + if (!_backgroundWindow) + _backgroundWindow = createBackgroundFullscreenWindow(screenFrame); + else + [_backgroundWindow.get() setFrame:screenFrame display:NO]; + + CGFloat currentAlpha = 0; + if (_fadeAnimation) { + currentAlpha = [_fadeAnimation.get() currentAlpha]; + [_fadeAnimation.get() stopAnimation]; + [_fadeAnimation.get() setWindow:nil]; } - return duration; + + _fadeAnimation = adoptNS([[WebWindowFadeAnimation alloc] initWithDuration:duration + window:_backgroundWindow.get() + initialAlpha:currentAlpha + finalAlpha:1]); + [_fadeAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking]; + [_fadeAnimation.get() setCurrentProgress:0]; + [_fadeAnimation.get() startAnimation]; + + [_backgroundWindow.get() orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; + + [[self window] setAutodisplay:YES]; + [[self window] displayIfNeeded]; + // Screen updates disabled in enterFullScreen: + NSEnableScreenUpdates(); } -@end - -#pragma mark - -@implementation WebFullscreenWindow - -- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag +- (void)_startExitFullScreenAnimationWithDuration:(NSTimeInterval)duration { - UNUSED_PARAM(aStyle); - self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag]; - if (!self) - return nil; - [self setOpaque:NO]; - [self setBackgroundColor:[NSColor clearColor]]; - [self setIgnoresMouseEvents:NO]; - [self setAcceptsMouseMovedEvents:YES]; - [self setReleasedWhenClosed:NO]; - [self setHasShadow:YES]; -#ifndef BUILDING_ON_LEOPARD - [self setMovable:NO]; -#else - [self setMovableByWindowBackground:NO]; -#endif + NSRect screenFrame = [[[self window] screen] frame]; + NSRect initialWindowFrame = windowFrameFromApparentFrames(screenFrame, _initialFrame, _finalFrame); - NSView* contentView = [self contentView]; - _animationView = [[NSView alloc] initWithFrame:[contentView bounds]]; + NSRect currentFrame = _scaleAnimation ? [_scaleAnimation.get() currentFrame] : [[self window] frame]; + _scaleAnimation = adoptNS([[WebWindowScaleAnimation alloc] initWithHintedDuration:duration window:[self window] initalFrame:currentFrame finalFrame:initialWindowFrame]); - RetainPtr<CALayer> contentLayer(AdoptNS, [[CALayer alloc] init]); - [_animationView setLayer:contentLayer.get()]; - [_animationView setWantsLayer:YES]; - [_animationView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; - [contentView addSubview:_animationView]; + [_scaleAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking]; + [_scaleAnimation.get() setDelegate:self]; + [_scaleAnimation.get() setCurrentProgress:0]; + [_scaleAnimation.get() startAnimation]; - _backgroundLayer = [[CALayer alloc] init]; - [contentLayer.get() addSublayer:_backgroundLayer]; -#ifndef BUILDING_ON_LEOPARD - [contentLayer.get() setGeometryFlipped:YES]; -#else - [contentLayer.get() setSublayerTransform:CATransform3DMakeScale(1, -1, 1)]; -#endif - [contentLayer.get() setOpacity:0]; + if (!_backgroundWindow) + _backgroundWindow = createBackgroundFullscreenWindow(screenFrame); + else + [_backgroundWindow.get() setFrame:screenFrame display:NO]; - [_backgroundLayer setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)]; - [_backgroundLayer setOpacity:0]; - return self; -} - -- (void)dealloc -{ - [_animationView release]; - [_backgroundLayer release]; - [_rendererLayer release]; - [super dealloc]; -} - -- (BOOL)canBecomeKeyWindow -{ - return YES; -} - -- (void)keyDown:(NSEvent *)theEvent -{ - if ([[theEvent charactersIgnoringModifiers] isEqual:@"\e"]) // Esacpe key-code - [self cancelOperation:self]; - else [super keyDown:theEvent]; -} - -- (void)cancelOperation:(id)sender -{ - UNUSED_PARAM(sender); - [[self windowController] _requestExitFullscreenWithAnimation:YES]; -} - -- (CALayer*)rendererLayer -{ - return _rendererLayer; -} - -- (void)setRendererLayer:(CALayer *)rendererLayer -{ - [CATransaction begin]; - [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions]; - [rendererLayer retain]; - [_rendererLayer removeFromSuperlayer]; - [_rendererLayer release]; - _rendererLayer = rendererLayer; - - if (_rendererLayer) - [[[self animationView] layer] addSublayer:_rendererLayer]; - [CATransaction commit]; -} + CGFloat currentAlpha = 1; + if (_fadeAnimation) { + currentAlpha = [_fadeAnimation.get() currentAlpha]; + [_fadeAnimation.get() stopAnimation]; + [_fadeAnimation.get() setWindow:nil]; + } + _fadeAnimation = adoptNS([[WebWindowFadeAnimation alloc] initWithDuration:duration + window:_backgroundWindow.get() + initialAlpha:currentAlpha + finalAlpha:0]); + [_fadeAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking]; + [_fadeAnimation.get() setCurrentProgress:0]; + [_fadeAnimation.get() startAnimation]; + + [_backgroundWindow.get() orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; + + // WKWindowSetClipRect takes window coordinates, so convert from screen coordinates here: + NSRect finalBounds = _finalFrame; + finalBounds.origin = [[self window] convertScreenToBase:finalBounds.origin]; + WKWindowSetClipRect([self window], finalBounds); + + [[self window] setAutodisplay:YES]; + [[self window] displayIfNeeded]; -- (CALayer*)backgroundLayer -{ - return _backgroundLayer; + // Screen updates disabled in exitFullScreen: + NSEnableScreenUpdates(); } -- (NSView*)animationView -{ - return _animationView; -} @end -#pragma mark - -#pragma mark MediaEventListener - -MediaEventListener::MediaEventListener(WebFullScreenController* delegate) - : EventListener(CPPEventListenerType) - , delegate(delegate) -{ -} - -PassRefPtr<MediaEventListener> MediaEventListener::create(WebFullScreenController* delegate) -{ - return adoptRef(new MediaEventListener(delegate)); -} - -bool MediaEventListener::operator==(const EventListener& listener) -{ - return this == &listener; -} - -void MediaEventListener::handleEvent(ScriptExecutionContext* context, Event* event) -{ - [delegate _updatePowerAssertions]; -} #endif /* ENABLE(FULLSCREEN_API) */ diff --git a/Source/WebKit/mac/WebView/WebHTMLView.mm b/Source/WebKit/mac/WebView/WebHTMLView.mm index 7052fca0b..a9b291e49 100644 --- a/Source/WebKit/mac/WebView/WebHTMLView.mm +++ b/Source/WebKit/mac/WebView/WebHTMLView.mm @@ -1372,6 +1372,16 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart) return self != [self _topHTMLView]; } +static BOOL isQuickLookEvent(NSEvent *event) +{ +#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) + const int kCGSEventSystemSubtypeHotKeyCombinationReleased = 9; + return [event type] == NSSystemDefined && [event subtype] == kCGSEventSystemSubtypeHotKeyCombinationReleased && [event data1] == 'lkup'; +#else + return NO; +#endif +} + - (NSView *)hitTest:(NSPoint)point { // WebHTMLView objects handle all events for objects inside them. @@ -1412,7 +1422,8 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart) captureHitsOnSubviews = !([event type] == NSMouseMoved || [event type] == NSRightMouseDown || ([event type] == NSLeftMouseDown && ([event modifierFlags] & NSControlKeyMask) != 0) - || [event type] == NSFlagsChanged); + || [event type] == NSFlagsChanged + || isQuickLookEvent(event)); } if (!captureHitsOnSubviews) { diff --git a/Source/WebKit/mac/WebView/WebNotification.h b/Source/WebKit/mac/WebView/WebNotification.h index c04b2ad07..8ecc10686 100644 --- a/Source/WebKit/mac/WebView/WebNotification.h +++ b/Source/WebKit/mac/WebView/WebNotification.h @@ -36,6 +36,7 @@ - (NSString *)title; - (NSString *)body; +- (NSString *)replaceID; - (WebSecurityOrigin *)origin; - (uint64_t)notificationID; diff --git a/Source/WebKit/mac/WebView/WebNotification.mm b/Source/WebKit/mac/WebView/WebNotification.mm index bbd0248f6..557332cba 100644 --- a/Source/WebKit/mac/WebView/WebNotification.mm +++ b/Source/WebKit/mac/WebView/WebNotification.mm @@ -101,6 +101,16 @@ Notification* core(WebNotification *notification) #endif } +- (NSString *)replaceID +{ +#if ENABLE(NOTIFICATIONS) + ASSERT(core(self)); + return core(self)->replaceId(); +#else + return nil; +#endif +} + - (WebSecurityOrigin *)origin { #if ENABLE(NOTIFICATIONS) diff --git a/Source/WebKit/mac/WebView/WebPDFDocumentExtras.mm b/Source/WebKit/mac/WebView/WebPDFDocumentExtras.mm index f2c6c833b..3e701cf5c 100644 --- a/Source/WebKit/mac/WebView/WebPDFDocumentExtras.mm +++ b/Source/WebKit/mac/WebView/WebPDFDocumentExtras.mm @@ -26,8 +26,8 @@ #import "WebPDFDocumentExtras.h" #import "WebTypesInternal.h" -#import <JavaScriptCore/Vector.h> -#import <JavaScriptCore/RetainPtr.h> +#import <wtf/Vector.h> +#import <wtf/RetainPtr.h> #import <PDFKit/PDFDocument.h> #import <objc/objc-runtime.h> diff --git a/Source/WebKit/mac/WebView/WebPDFRepresentation.mm b/Source/WebKit/mac/WebView/WebPDFRepresentation.mm index 44a1362f3..a36853349 100644 --- a/Source/WebKit/mac/WebView/WebPDFRepresentation.mm +++ b/Source/WebKit/mac/WebView/WebPDFRepresentation.mm @@ -35,7 +35,7 @@ #import "WebPDFDocumentExtras.h" #import "WebPDFView.h" #import "WebTypesInternal.h" -#import <JavaScriptCore/Assertions.h> +#import <wtf/Assertions.h> #import <JavaScriptCore/JSContextRef.h> #import <JavaScriptCore/JSStringRef.h> #import <JavaScriptCore/JSStringRefCF.h> diff --git a/Source/WebKit/mac/WebView/WebResource.mm b/Source/WebKit/mac/WebView/WebResource.mm index 463f76846..3964f6f79 100644 --- a/Source/WebKit/mac/WebView/WebResource.mm +++ b/Source/WebKit/mac/WebView/WebResource.mm @@ -35,7 +35,7 @@ #import "WebNSObjectExtras.h" #import "WebNSURLExtras.h" #import <JavaScriptCore/InitializeThreading.h> -#import <JavaScriptCore/PassRefPtr.h> +#import <wtf/PassRefPtr.h> #import <WebCore/ArchiveResource.h> #import <WebCore/LegacyWebArchive.h> #import <WebCore/RunLoop.h> diff --git a/Source/WebKit/mac/WebView/WebTextIterator.mm b/Source/WebKit/mac/WebView/WebTextIterator.mm index e80d4671f..9b1bd8feb 100644 --- a/Source/WebKit/mac/WebView/WebTextIterator.mm +++ b/Source/WebKit/mac/WebView/WebTextIterator.mm @@ -28,7 +28,7 @@ #import "DOMNodeInternal.h" #import "DOMRangeInternal.h" #import "WebTypesInternal.h" -#import <JavaScriptCore/Vector.h> +#import <wtf/Vector.h> #import <WebCore/RunLoop.h> #import <WebCore/TextIterator.h> #import <WebCore/WebCoreObjCExtras.h> diff --git a/Source/WebKit/mac/WebView/WebView.mm b/Source/WebKit/mac/WebView/WebView.mm index 9b722026e..9cfe8b348 100644 --- a/Source/WebKit/mac/WebView/WebView.mm +++ b/Source/WebKit/mac/WebView/WebView.mm @@ -6304,21 +6304,14 @@ bool LayerFlushController::flushLayers() [_private->newFullscreenController setElement:element]; [_private->newFullscreenController setWebView:self]; - [_private->newFullscreenController enterFullscreen:[[self window] screen]]; + [_private->newFullscreenController enterFullScreen:[[self window] screen]]; } - (void)_exitFullScreenForElement:(WebCore::Element*)element { if (!_private->newFullscreenController) return; - [_private->newFullscreenController exitFullscreen]; -} - -- (void)_fullScreenRendererChanged:(WebCore::RenderBox*)renderer -{ - if (!_private->newFullscreenController) - _private->newFullscreenController = [[WebFullScreenController alloc] init]; - [_private->newFullscreenController setRenderer:renderer]; + [_private->newFullscreenController exitFullScreen]; } #endif diff --git a/Source/WebKit/mac/WebView/WebViewPrivate.h b/Source/WebKit/mac/WebView/WebViewPrivate.h index e0fee81d1..1b61821d1 100644 --- a/Source/WebKit/mac/WebView/WebViewPrivate.h +++ b/Source/WebKit/mac/WebView/WebViewPrivate.h @@ -106,7 +106,7 @@ typedef enum { WebPaginationModeVertical, } WebPaginationMode; -// This needs to be in sync with WebCore::NotificationPresenter::Permission +// This needs to be in sync with WebCore::NotificationClient::Permission typedef enum { WebNotificationPermissionAllowed, WebNotificationPermissionNotAllowed, diff --git a/Source/WebKit/qt/Api/qwebelement.cpp b/Source/WebKit/qt/Api/qwebelement.cpp index 40c69f4bf..3fc64c96f 100644 --- a/Source/WebKit/qt/Api/qwebelement.cpp +++ b/Source/WebKit/qt/Api/qwebelement.cpp @@ -33,6 +33,7 @@ #include "GraphicsContext.h" #include "HTMLElement.h" #include "StylePropertySet.h" +#include "StyleRule.h" #if USE(JSC) #include "Completion.h" #include "JSGlobalObject.h" @@ -843,7 +844,7 @@ QString QWebElement::styleProperty(const QString &name, StyleResolveStrategy str if (!propID) return QString(); - StylePropertySet* style = static_cast<StyledElement*>(m_element)->ensureInlineStyleDecl(); + const StylePropertySet* style = static_cast<StyledElement*>(m_element)->ensureInlineStyle(); if (strategy == InlineStyle) return style->getPropertyValue(propID); @@ -865,11 +866,11 @@ QString QWebElement::styleProperty(const QString &name, StyleResolveStrategy str for (int i = rules->length(); i > 0; --i) { CSSStyleRule* rule = static_cast<CSSStyleRule*>(rules->item(i - 1)); - if (rule->declaration()->propertyIsImportant(propID)) - return rule->declaration()->getPropertyValue(propID); + if (rule->styleRule()->properties()->propertyIsImportant(propID)) + return rule->styleRule()->properties()->getPropertyValue(propID); if (style->getPropertyValue(propID).isEmpty()) - style = rule->declaration(); + style = rule->styleRule()->properties(); } } @@ -908,11 +909,7 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value) return; int propID = cssPropertyID(name); - StylePropertySet* style = static_cast<StyledElement*>(m_element)->ensureInlineStyleDecl(); - if (!propID || !style) - return; - - style->setProperty(propID, value); + static_cast<StyledElement*>(m_element)->setInlineStyleProperty(propID, value); } /*! diff --git a/Source/WebKit/qt/Api/qwebframe.cpp b/Source/WebKit/qt/Api/qwebframe.cpp index 211f0ef20..dcf23061d 100644 --- a/Source/WebKit/qt/Api/qwebframe.cpp +++ b/Source/WebKit/qt/Api/qwebframe.cpp @@ -783,12 +783,12 @@ QString QWebFrame::title() const Given the above HTML code the metaData() function will return a map with two entries: \table - \header \o Key - \o Value - \row \o "description" - \o "This document is a tutorial about Qt development" - \row \o "keywords" - \o "Qt, WebKit, Programming" + \header \li Key + \li Value + \row \li "description" + \li "This document is a tutorial about Qt development" + \row \li "keywords" + \li "Qt, WebKit, Programming" \endtable This function returns a multi map to support multiple meta tags with the same attribute name. @@ -1750,7 +1750,7 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult { if (!hitTest.innerNode()) return; - pos = hitTest.point(); + pos = hitTest.roundedPoint(); WebCore::TextDirection dir; title = hitTest.title(dir); linkText = hitTest.textContent(); diff --git a/Source/WebKit/qt/Api/qwebhistory.cpp b/Source/WebKit/qt/Api/qwebhistory.cpp index 33bad4174..fc5bdd5fc 100644 --- a/Source/WebKit/qt/Api/qwebhistory.cpp +++ b/Source/WebKit/qt/Api/qwebhistory.cpp @@ -53,13 +53,13 @@ enum { the functions used to access them. \table - \header \o Function \o Description - \row \o title() \o The page title. - \row \o url() \o The location of the page. - \row \o originalUrl() \o The URL used to access the page. - \row \o lastVisited() \o The date and time of the user's last visit to the page. - \row \o icon() \o The icon associated with the page that was provided by the server. - \row \o userData() \o The user specific data that was stored with the history item. + \header \li Function \li Description + \row \li title() \li The page title. + \row \li url() \li The location of the page. + \row \li originalUrl() \li The URL used to access the page. + \row \li lastVisited() \li The date and time of the user's last visit to the page. + \row \li icon() \li The icon associated with the page that was provided by the server. + \row \li userData() \li The user specific data that was stored with the history item. \endtable \note QWebHistoryItem objects are value based, but \e{explicitly shared}. Changing diff --git a/Source/WebKit/qt/Api/qwebinspector.cpp b/Source/WebKit/qt/Api/qwebinspector.cpp index 52feb8895..2fbbab249 100644 --- a/Source/WebKit/qt/Api/qwebinspector.cpp +++ b/Source/WebKit/qt/Api/qwebinspector.cpp @@ -50,8 +50,8 @@ \note A QWebInspector will display a blank widget if either: \list - \o page() is null - \o QWebSettings::DeveloperExtrasEnabled is false + \li page() is null + \li QWebSettings::DeveloperExtrasEnabled is false \endlist \section1 Resources @@ -60,8 +60,8 @@ Most of the resources needed by the inspector are owned by the associated QWebPage and are allocated the first time that: \list - \o an element is inspected - \o the QWebInspector is shown. + \li an element is inspected + \li the QWebInspector is shown. \endlist \section1 Inspector configuration persistence @@ -98,12 +98,12 @@ QWebInspector::~QWebInspector() /*! Bind this inspector to the QWebPage to be inspected. - \bold {Notes:} + \b {Notes:} \list - \o There can only be one QWebInspector associated with a QWebPage + \li There can only be one QWebInspector associated with a QWebPage and vice versa. - \o Calling this method with a null \a page will break the current association, if any. - \o If \a page is already associated to another QWebInspector, the association + \li Calling this method with a null \a page will break the current association, if any. + \li If \a page is already associated to another QWebInspector, the association will be replaced and the previous QWebInspector will become unbound \endlist diff --git a/Source/WebKit/qt/Api/qwebpage.cpp b/Source/WebKit/qt/Api/qwebpage.cpp index 898899bf5..4928318d6 100644 --- a/Source/WebKit/qt/Api/qwebpage.cpp +++ b/Source/WebKit/qt/Api/qwebpage.cpp @@ -3290,15 +3290,11 @@ bool QWebPage::swallowContextMenuEvent(QContextMenuEvent *event) { d->page->contextMenuController()->clearContextMenu(); -#if HAVE(QSTYLE) - if (!RenderThemeQt::useMobileTheme()) { - if (QWebFrame* webFrame = frameAt(event->pos())) { - Frame* frame = QWebFramePrivate::core(webFrame); - if (Scrollbar* scrollbar = frame->view()->scrollbarAtPoint(convertMouseEvent(event, 1).position())) - return handleScrollbarContextMenuEvent(scrollbar, event); - } + if (QWebFrame* webFrame = frameAt(event->pos())) { + Frame* frame = QWebFramePrivate::core(webFrame); + if (Scrollbar* scrollbar = frame->view()->scrollbarAtPoint(convertMouseEvent(event, 1).position())) + return handleScrollbarContextMenuEvent(scrollbar, event); } -#endif WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame(); focusedFrame->eventHandler()->sendContextMenuEvent(convertMouseEvent(event, 1)); @@ -3744,11 +3740,11 @@ QWebPluginFactory *QWebPage::pluginFactory() const In this string the following values are replaced at run-time: \list - \o %Platform% expands to the windowing system followed by "; " if it is not Windows (e.g. "X11; "). - \o %Security% expands to "N; " if SSL is disabled. - \o %Subplatform% expands to the operating system version (e.g. "Windows NT 6.1" or "Intel Mac OS X 10.5"). - \o %WebKitVersion% is the version of WebKit the application was compiled against. - \o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version. + \li %Platform% expands to the windowing system followed by "; " if it is not Windows (e.g. "X11; "). + \li %Security% expands to "N; " if SSL is disabled. + \li %Subplatform% expands to the operating system version (e.g. "Windows NT 6.1" or "Intel Mac OS X 10.5"). + \li %WebKitVersion% is the version of WebKit the application was compiled against. + \li %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version. \endlist */ QString QWebPage::userAgentForUrl(const QUrl&) const diff --git a/Source/WebKit/qt/Api/qwebpluginfactory.cpp b/Source/WebKit/qt/Api/qwebpluginfactory.cpp index b9180be94..34ea05265 100644 --- a/Source/WebKit/qt/Api/qwebpluginfactory.cpp +++ b/Source/WebKit/qt/Api/qwebpluginfactory.cpp @@ -181,16 +181,16 @@ void QWebPluginFactory::refreshPlugins() The above object element will result in a call to create() with the following arguments: \table - \header \o Parameter - \o Value - \row \o mimeType - \o "application/x-pdf" - \row \o url - \o "http://qt.nokia.com/document.pdf" - \row \o argumentNames - \o "showTableOfContents" "hideThumbnails" - \row \o argumentVaues - \o "true" "false" + \header \li Parameter + \li Value + \row \li mimeType + \li "application/x-pdf" + \row \li url + \li "http://qt.nokia.com/document.pdf" + \row \li argumentNames + \li "showTableOfContents" "hideThumbnails" + \row \li argumentVaues + \li "true" "false" \endtable \note Ownership of the returned object will be transferred to the caller. diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp index 2885f01ee..0f55b0b89 100644 --- a/Source/WebKit/qt/Api/qwebsettings.cpp +++ b/Source/WebKit/qt/Api/qwebsettings.cpp @@ -703,7 +703,7 @@ void QWebSettings::clearIconDatabase() /*! Returns the web site's icon for \a url. - If the web site does not specify an icon \bold OR if the icon is not in the + If the web site does not specify an icon \b OR if the icon is not in the database, a null QIcon is returned. \note The returned icon's size is arbitrary. @@ -850,10 +850,10 @@ int QWebSettings::maximumPagesInCache() dead objects should consume when the cache is under pressure. \a cacheMaxDead is the \e maximum number of bytes that dead objects should - consume when the cache is \bold not under pressure. + consume when the cache is \b not under pressure. \a totalCapacity specifies the \e maximum number of bytes that the cache - should consume \bold overall. + should consume \b overall. The cache is enabled by default. Calling setObjectCacheCapacities(0, 0, 0) will disable the cache. Calling it with one non-zero enables it again. diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog index 175b43df2..d9c4ee953 100644 --- a/Source/WebKit/qt/ChangeLog +++ b/Source/WebKit/qt/ChangeLog @@ -1,3 +1,316 @@ +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (WebCore::NotificationPresenterClientQt::checkPermission): + (WebCore::NotificationPresenterClientQt::allowNotificationForFrame): + * WebCoreSupport/NotificationPresenterClientQt.h: + (NotificationPresenterClientQt): + +2012-03-09 Emil A Eklund <eae@chromium.org> + + Add roundedPoint to HitTestResult and change platform code to use it + https://bugs.webkit.org/show_bug.cgi?id=80715 + + Reviewed by James Robinson. + + Change ports to use roundedPoint to avoid exposing subpixel types to + platform code. + + * Api/qwebframe.cpp: + (QWebHitTestResultPrivate::QWebHitTestResultPrivate): + +2012-03-09 Jon Lee <jonlee@apple.com> + + Add support for ENABLE(LEGACY_NOTIFICATIONS) + https://bugs.webkit.org/show_bug.cgi?id=80497 + + Reviewed by Adam Barth. + + Prep for b80472: Update API for Web Notifications + * examples/platformplugin/platformplugin.pro: + +2012-03-09 Csaba Osztrogonác <ossy@webkit.org> + + [Qt] Fix compilation without QtQuick1 + https://bugs.webkit.org/show_bug.cgi?id=80503 + + Qt 4.8 API test fix after r110050. + + Reviewed by Zoltan Herczeg. + + * declarative/public.pri: Add load(features) to ensure HAVE_QQUICK1=1 is set. + +2012-03-08 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + [Qt] Use Qt's module system for install rules and depending on QtWebKit + + Instead of rolling our own install rules we now use the same approach as + every other Qt module, by loading qt_module.prf and qt_module_config.prf. + + This ensures that we follow the same semantics as the rest of Qt on + what sort of config options are enabled by default (create_cmake eg.). + It also allows us to use QT += webkit instead of the workaround we had + with CONFIG += qtwebkit. + + We do however force Qt to always treat our build as a non-developer build, + so the libraries will end up in the WebKit lib directory instead of the + qtbase directory (as with a normal developer-build). This allows us to + keep the webkit-build self-contained. If Qt is a developer build we still + copy the module file manually to Qt, so that you don't have to install + WebKit to make it available. + + For non-developer builds of Qt, it is still possible to use the built + WebKit libraries without having to install them, by having the variable + QMAKE_EXTRA_MODULE_FORWARDS set in the project's .qmake.cache file, + pointing to $WEBKITOUTUTDIR/$CONFIGURATION/modules. + + https://bugs.webkit.org/show_bug.cgi?id=80590 + + Reviewed by Simon Hausmann. + + * declarative/experimental/experimental.pri: + * declarative/experimental/plugin.cpp: + * declarative/plugin.cpp: + * declarative/public.pri: + * tests/tests.pri: + +2012-03-08 Antti Koivisto <antti@apple.com> + + https://bugs.webkit.org/show_bug.cgi?id=80370 + Enable matched declaration caching for elements with a style attribute + + Reviewed by Andreas Kling + + * Api/qwebelement.cpp: + (QWebElement::styleProperty): + (QWebElement::setStyleProperty): + +2012-03-07 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Fix compilation without QtQuick1 + https://bugs.webkit.org/show_bug.cgi?id=80503 + + Reviewed by Tor Arne Vestbø. + + Compile and enable the QtQuick1/QML1 plugin and webview + only if we're using Qt 4 at the moment. QQuick1 clashes + with QQuick2 right now because both declare QDeclarativeEngine + and friends as classes. + + * declarative/plugin.cpp: + (WebKitQmlPlugin::registerTypes): + * declarative/public.pri: + * tests/tests.pri: + +2012-03-07 Kangil Han <kangil.han@samsung.com> + + [DRT] Remove PlainTextController implementations. + https://bugs.webkit.org/show_bug.cgi?id=79959 + + Reviewed by Hajime Morita. + + PlainTextController usages in existing tests have been + replaced by internals API by bug 78570. + So this patch will remove PlainTextController implementations + to avoid further usage in new tests. + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + * WebCoreSupport/DumpRenderTreeSupportQt.h: + +2012-03-06 Philippe Normand <pnormand@igalia.com> + + [GStreamer] disable GStreamerGWorld when building against 0.11 + https://bugs.webkit.org/show_bug.cgi?id=77088 + + Reviewed by Martin Robinson. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::ChromeClientQt): + (WebCore::ChromeClientQt::~ChromeClientQt): + (WebCore): + * WebCoreSupport/FullScreenVideoQt.cpp: + (WebCore): + (WebCore::FullScreenVideoQt::FullScreenVideoQt): + (WebCore::FullScreenVideoQt::~FullScreenVideoQt): + (WebCore::FullScreenVideoQt::enterFullScreenForNode): + (WebCore::FullScreenVideoQt::exitFullScreenForNode): + (WebCore::FullScreenVideoQt::isValid): + * WebCoreSupport/FullScreenVideoQt.h: + (WebCore): + +2012-03-03 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Fix static_libs_as_shared build + https://bugs.webkit.org/show_bug.cgi?id=80214 + + Reviewed by Tor Arne Vestbø. + + Add helper function to be called by WebProcess main + to potentially initialize the QStyle theme. + + * WebCoreSupport/InitWebCoreQt.cpp: + (WebKit): + (WebKit::initializeWebKit2Theme): + +2012-03-02 Casper van Donderen <casper.vandonderen@nokia.com> + + [Qt] Documentation cleanup + https://bugs.webkit.org/show_bug.cgi?id=80131 + + Reviewed by Simon Hausmann. + + QDoc uses different commands to do bold, lists, and italics. + This change updates the documentation accordingly. + QTBUG-24578 + + * Api/qwebframe.cpp: + * Api/qwebhistory.cpp: + * Api/qwebinspector.cpp: + * Api/qwebpage.cpp: + * Api/qwebpluginfactory.cpp: + * Api/qwebsettings.cpp: + * declarative/qdeclarativewebview.cpp: + * docs/qtwebkit-bridge.qdoc: + * docs/qtwebkit.qdoc: + * docs/qtwebkit.qdocconf: + +2012-03-02 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Build system cleanup + + Rubber-stamped by Antti Koivisto. + + * tests/MIMESniffing/MIMESniffing.pro: Don't link in WTFAssertions.cpp for ASSERT, now + that the symbols are properly exported with export macros from the DLL. + +2012-03-02 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Move QStyle theming code out of WebCore into WebKit1 + https://bugs.webkit.org/show_bug.cgi?id=80128 + + Reviewed by Kenneth Rohde Christiansen. + + Moved the bulk of the QStyle dependant code here, where it's okay to depend on QtWidgets/QStyle. + Install the QStyle factory functions in initWebCoreQt.cpp. + + * Api/qwebpage.cpp: + (QWebPage::swallowContextMenuEvent): + * WebCoreSupport/InitWebCoreQt.cpp: + (WebCore::initializeWebCoreQt): + * WebCoreSupport/RenderThemeQStyle.cpp: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.cpp. + (WebCore): + (WebCore::initStyleOption): + (WebCore::RenderThemeQStyle::getStylePainter): + (WebCore::StylePainterQStyle::StylePainterQStyle): + (WebCore::StylePainterQStyle::init): + (WebCore::RenderThemeQStyle::create): + (WebCore::RenderThemeQStyle::RenderThemeQStyle): + (WebCore::RenderThemeQStyle::~RenderThemeQStyle): + (WebCore::RenderThemeQStyle::fallbackStyle): + (WebCore::RenderThemeQStyle::qStyle): + (WebCore::RenderThemeQStyle::findFrameLineWidth): + (WebCore::RenderThemeQStyle::inflateButtonRect): + (WebCore::RenderThemeQStyle::computeSizeBasedOnStyle): + (WebCore::RenderThemeQStyle::adjustButtonStyle): + (WebCore::RenderThemeQStyle::setButtonPadding): + (WebCore::RenderThemeQStyle::paintButton): + (WebCore::RenderThemeQStyle::paintTextField): + (WebCore::RenderThemeQStyle::adjustTextAreaStyle): + (WebCore::RenderThemeQStyle::paintTextArea): + (WebCore::RenderThemeQStyle::setPopupPadding): + (WebCore::RenderThemeQStyle::paintMenuList): + (WebCore::RenderThemeQStyle::adjustMenuListButtonStyle): + (WebCore::RenderThemeQStyle::paintMenuListButton): + (WebCore::RenderThemeQStyle::animationDurationForProgressBar): + (WebCore::RenderThemeQStyle::paintProgressBar): + (WebCore::RenderThemeQStyle::paintSliderTrack): + (WebCore::RenderThemeQStyle::adjustSliderTrackStyle): + (WebCore::RenderThemeQStyle::paintSliderThumb): + (WebCore::RenderThemeQStyle::adjustSliderThumbStyle): + (WebCore::RenderThemeQStyle::paintSearchField): + (WebCore::RenderThemeQStyle::adjustSearchFieldDecorationStyle): + (WebCore::RenderThemeQStyle::paintSearchFieldDecoration): + (WebCore::RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle): + (WebCore::RenderThemeQStyle::paintSearchFieldResultsDecoration): + (WebCore::RenderThemeQStyle::paintInnerSpinButton): + (WebCore::RenderThemeQStyle::initializeCommonQStyleOptions): + (WebCore::RenderThemeQStyle::adjustSliderThumbSize): + * WebCoreSupport/RenderThemeQStyle.h: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.h. + (WebCore): + (RenderThemeQStyle): + (StylePainterQStyle): + (WebCore::StylePainterQStyle::isValid): + (WebCore::StylePainterQStyle::drawPrimitive): + (WebCore::StylePainterQStyle::drawControl): + (WebCore::StylePainterQStyle::drawComplexControl): + * WebCoreSupport/ScrollbarThemeQStyle.cpp: Copied from Source/WebCore/platform/qt/ScrollbarThemeQt.cpp. + (WebCore): + (WebCore::ScrollbarThemeQStyle::~ScrollbarThemeQStyle): + (WebCore::scPart): + (WebCore::scrollbarPart): + (WebCore::styleOptionSlider): + (WebCore::ScrollbarThemeQStyle::paint): + (WebCore::ScrollbarThemeQStyle::hitTest): + (WebCore::ScrollbarThemeQStyle::shouldCenterOnThumb): + (WebCore::ScrollbarThemeQStyle::invalidatePart): + (WebCore::ScrollbarThemeQStyle::scrollbarThickness): + (WebCore::ScrollbarThemeQStyle::thumbPosition): + (WebCore::ScrollbarThemeQStyle::thumbLength): + (WebCore::ScrollbarThemeQStyle::trackPosition): + (WebCore::ScrollbarThemeQStyle::trackLength): + (WebCore::ScrollbarThemeQStyle::paintScrollCorner): + (WebCore::ScrollbarThemeQStyle::style): + * WebCoreSupport/ScrollbarThemeQStyle.h: Renamed from Source/WebCore/platform/qt/ScrollbarThemeQt.h. + (WebCore): + (ScrollbarThemeQStyle): + +2012-02-27 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> + + [Qt] Move registration of experimental types to the proper plugin + https://bugs.webkit.org/show_bug.cgi?id=79706 + + Reviewed by Tor Arne Vestbø. + + * declarative/experimental/plugin.cpp: + * declarative/plugin.cpp: + (WebKitQmlPlugin::registerTypes): + +2012-02-28 Antti Koivisto <antti@apple.com> + + Try to fix build. + + Not reviewed. + + * Api/qwebelement.cpp: + (QWebElement::styleProperty): + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/ChromeClientQt.h: + (ChromeClientQt): + +2012-02-24 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + [Qt] API: Unify the loading properties and signals. + https://bugs.webkit.org/show_bug.cgi?id=79486 + + Reviewed by Simon Hausmann. + + * declarative/plugin.cpp: + (WebKitQmlPlugin::registerTypes): + 2012-02-24 Holger Hans Peter Freyther <holger@moiji-mobile.com> [Qt] Build fix. macro "QSKIP" now only takes 1 argument on Qt5 diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index f129b5871..aee2cf8fc 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -73,7 +73,7 @@ #include <wtf/OwnPtr.h> #include <wtf/qt/UtilsQt.h> -#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT)) +#if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT)) #include "FullScreenVideoQt.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" @@ -90,7 +90,7 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false; ChromeClientQt::ChromeClientQt(QWebPage* webPage) : m_webPage(webPage) , m_eventLoop(0) -#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT)) +#if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT)) , m_fullScreenVideo(0) #endif { @@ -102,7 +102,7 @@ ChromeClientQt::~ChromeClientQt() if (m_eventLoop) m_eventLoop->exit(); -#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT)) +#if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT)) delete m_fullScreenVideo; #endif } @@ -650,7 +650,7 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const } #endif -#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT)) +#if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT)) FullScreenVideoQt* ChromeClientQt::fullScreenVideo() { if (!m_fullScreenVideo) diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h index 3d45b7b51..386b986d4 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -138,9 +138,6 @@ public: #endif virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded); -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif #if USE(ACCELERATED_COMPOSITING) // This is a hook for WebCore to tell us what we need to do with the GraphicsLayers. diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index 92c98cd37..457b49e26 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -992,15 +992,6 @@ void DumpRenderTreeSupportQt::simulateDesktopNotificationClick(const QString& ti #endif } -QString DumpRenderTreeSupportQt::plainText(const QVariant& range) -{ - QMap<QString, QVariant> map = range.toMap(); - QVariant startContainer = map.value(QLatin1String("startContainer")); - map = startContainer.toMap(); - - return map.value(QLatin1String("innerText")).toString(); -} - QVariantList DumpRenderTreeSupportQt::nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping) { QVariantList res; diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index 4b0314350..d949e5154 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -167,7 +167,6 @@ public: static QString markerTextForListItem(const QWebElement& listItem); static QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element); - static QString plainText(const QVariant& rng); static void dumpFrameLoader(bool b); static void dumpProgressFinishedCallback(bool); diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp index 81d2720b5..3b244c657 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp @@ -47,7 +47,7 @@ namespace WebCore { -#if USE(GSTREAMER) +#if USE(GSTREAMER) && !defined(GST_API_VERSION_1) GStreamerFullScreenVideoHandler::GStreamerFullScreenVideoHandler() : m_videoElement(0) , m_fullScreenWidget(0) @@ -148,7 +148,7 @@ FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient) connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose())); #endif -#if USE(GSTREAMER) +#if USE(GSTREAMER) && !defined(GST_API_VERSION_1) m_FullScreenVideoHandlerGStreamer = new GStreamerFullScreenVideoHandler; #endif @@ -162,7 +162,7 @@ FullScreenVideoQt::~FullScreenVideoQt() #if USE(QT_MULTIMEDIA) delete m_FullScreenVideoHandler; #endif -#if USE(GSTREAMER) +#if USE(GSTREAMER) && !defined(GST_API_VERSION_1) delete m_FullScreenVideoHandlerGStreamer; #endif #if USE(QTKIT) @@ -192,7 +192,7 @@ void FullScreenVideoQt::enterFullScreenForNode(Node* node) m_FullScreenVideoHandler->enterFullScreen(mediaPlayerQt->mediaPlayer()); #endif -#if USE(GSTREAMER) +#if USE(GSTREAMER) && !defined(GST_API_VERSION_1) m_FullScreenVideoHandlerGStreamer->setVideoElement(m_videoElement); m_FullScreenVideoHandlerGStreamer->enterFullScreen(); #endif @@ -223,7 +223,7 @@ void FullScreenVideoQt::exitFullScreenForNode(Node* node) MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer(); mediaPlayerQt->restoreVideoItem(); #endif -#if USE(GSTREAMER) +#if USE(GSTREAMER) && !defined(GST_API_VERSION_1) m_FullScreenVideoHandlerGStreamer->exitFullScreen(); #endif @@ -262,7 +262,7 @@ bool FullScreenVideoQt::isValid() const #if USE(QT_MULTIMEDIA) return m_FullScreenVideoHandler; #endif -#if USE(GSTREAMER) +#if USE(GSTREAMER) && !defined(GST_API_VERSION_1) return m_FullScreenVideoHandlerGStreamer; #elif USE(QTKIT) return m_FullScreenVideoHandlerQTKit; diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h index 06438ea46..6c7c7e926 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h @@ -43,7 +43,7 @@ class QTKitFullScreenVideoHandler; #endif // We do not use ENABLE or USE because moc does not expand these macros. -#if defined(WTF_USE_GSTREAMER) && WTF_USE_GSTREAMER +#if defined(WTF_USE_GSTREAMER) && WTF_USE_GSTREAMER && !defined(GST_API_VERSION_1) class FullScreenVideoWindow; class GStreamerFullScreenVideoHandler : public QObject { diff --git a/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp b/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp index 5cbd82c58..b09413345 100644 --- a/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp @@ -33,7 +33,9 @@ #include "Image.h" #include "NotImplemented.h" #include "PlatformStrategiesQt.h" +#include "RenderThemeQStyle.h" #include "ScriptController.h" +#include "ScrollbarThemeQStyle.h" #include "SecurityPolicy.h" #if USE(QTKIT) #include "WebSystemInterface.h" @@ -46,6 +48,17 @@ #include <runtime/InitializeThreading.h> #include <wtf/MainThread.h> +namespace WebKit { + +// Called also from WebKit2's WebProcess. +Q_DECL_EXPORT void initializeWebKit2Theme() +{ + if (qgetenv("QT_WEBKIT_THEME_NAME") == "qstyle") + WebCore::RenderThemeQt::setCustomTheme(WebCore::RenderThemeQStyle::create, new WebCore::ScrollbarThemeQStyle); +} + +} + namespace WebCore { void initializeWebCoreQt() @@ -62,6 +75,8 @@ void initializeWebCoreQt() PlatformStrategiesQt::initialize(); QtWebElementRuntime::initialize(); + RenderThemeQt::setCustomTheme(RenderThemeQStyle::create, new ScrollbarThemeQStyle); + #if USE(QTKIT) InitWebCoreSystemInterface(); #endif diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index 8200664ad..00052184a 100644 --- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -337,9 +337,9 @@ void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* co } } -NotificationPresenter::Permission NotificationPresenterClientQt::checkPermission(ScriptExecutionContext* context) +NotificationClient::Permission NotificationPresenterClientQt::checkPermission(ScriptExecutionContext* context) { - return m_cachedPermissions.value(context, NotificationPresenter::PermissionNotAllowed); + return m_cachedPermissions.value(context, NotificationClient::PermissionNotAllowed); } void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionContext* context) @@ -367,7 +367,7 @@ void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionC void NotificationPresenterClientQt::allowNotificationForFrame(Frame* frame) { - m_cachedPermissions.insert(frame->document(), NotificationPresenter::PermissionAllowed); + m_cachedPermissions.insert(frame->document(), NotificationClient::PermissionAllowed); QHash<ScriptExecutionContext*, CallbacksInfo>::iterator iter = m_pendingPermissionRequests.begin(); while (iter != m_pendingPermissionRequests.end()) { diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index 77dcd3bc8..12b06fe9b 100644 --- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -33,7 +33,7 @@ #define NotificationPresenterClientQt_h #include "Notification.h" -#include "NotificationPresenter.h" +#include "NotificationClient.h" #include "QtPlatformPlugin.h" #include "Timer.h" @@ -81,18 +81,18 @@ public: typedef QHash <Notification*, NotificationWrapper*> NotificationsQueue; -class NotificationPresenterClientQt : public NotificationPresenter { +class NotificationPresenterClientQt : public NotificationClient { public: NotificationPresenterClientQt(); ~NotificationPresenterClientQt(); - /* WebCore::NotificationPresenter interface */ + /* WebCore::NotificationClient interface */ virtual bool show(Notification*); virtual void cancel(Notification*); virtual void notificationObjectDestroyed(Notification*); virtual void notificationControllerDestroyed(); virtual void requestPermission(ScriptExecutionContext*, PassRefPtr<VoidCallback>); - virtual NotificationPresenter::Permission checkPermission(ScriptExecutionContext*); + virtual NotificationClient::Permission checkPermission(ScriptExecutionContext*); virtual void cancelRequestsForPermission(ScriptExecutionContext*); void cancel(NotificationWrapper*); @@ -125,7 +125,7 @@ private: QList<RefPtr<VoidCallback> > m_callbacks; }; QHash<ScriptExecutionContext*, CallbacksInfo > m_pendingPermissionRequests; - QHash<ScriptExecutionContext*, NotificationPresenter::Permission> m_cachedPermissions; + QHash<ScriptExecutionContext*, NotificationClient::Permission> m_cachedPermissions; NotificationsQueue m_notifications; QtPlatformPlugin m_platformPlugin; diff --git a/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp new file mode 100644 index 000000000..ac42fdd8b --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp @@ -0,0 +1,809 @@ +/* + * This file is part of the WebKit project. + * + * Copyright (C) 2008-2012 Nokia Corporation and/or its subsidiary(-ies) + * + * Copyright (C) 2006 Zack Rusin <zack@kde.org> + * 2006 Dirk Mueller <mueller@kde.org> + * 2006 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2008 Holger Hans Peter Freyther + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "RenderThemeQStyle.h" + +#include "CSSFontSelector.h" +#include "CSSStyleSelector.h" +#include "CSSValueKeywords.h" +#include "Chrome.h" +#include "ChromeClient.h" +#include "Color.h" +#include "Document.h" +#include "Font.h" +#include "FontSelector.h" +#include "GraphicsContext.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "LocalizedStrings.h" +#include "NotImplemented.h" +#include "Page.h" +#include "PaintInfo.h" +#include "QWebPageClient.h" +#include "RenderBox.h" +#if ENABLE(PROGRESS_TAG) +#include "RenderProgress.h" +#endif +#include "RenderSlider.h" +#include "ScrollbarThemeQStyle.h" +#include "SliderThumbElement.h" +#include "UserAgentStyleSheets.h" + +#include <QApplication> +#include <QColor> +#include <QFile> +#include <QFontMetrics> +#include <QLineEdit> +#include <QMacStyle> +#include <QPainter> +#ifndef QT_NO_STYLE_PLASTIQUE +#include <QPlastiqueStyle> +#endif +#include <QPushButton> +#include <QStyleFactory> +#include <QStyleOptionButton> +#include <QStyleOptionFrameV2> +#if ENABLE(PROGRESS_TAG) +#include <QStyleOptionProgressBarV2> +#endif +#include <QStyleOptionSlider> +#include <QWidget> + +namespace WebCore { + +using namespace HTMLNames; + +inline static void initStyleOption(QWidget* widget, QStyleOption& option) +{ + if (widget) + option.initFrom(widget); + else { + // If a widget is not directly available for rendering, we fallback to default + // value for an active widget. + option.state = QStyle::State_Active | QStyle::State_Enabled; + } +} + + +QSharedPointer<StylePainter> RenderThemeQStyle::getStylePainter(const PaintInfo& paintInfo) +{ + return QSharedPointer<StylePainter>(new StylePainterQStyle(this, paintInfo)); +} + +StylePainterQStyle::StylePainterQStyle(RenderThemeQStyle* theme, const PaintInfo& paintInfo) + : StylePainter(theme, paintInfo) +{ + init(paintInfo.context ? paintInfo.context : 0, theme->qStyle()); +} + +StylePainterQStyle::StylePainterQStyle(ScrollbarThemeQStyle* theme, GraphicsContext* context) + : StylePainter() +{ + init(context, theme->style()); +} + +void StylePainterQStyle::init(GraphicsContext* context, QStyle* themeStyle) +{ + painter = static_cast<QPainter*>(context->platformContext()); + widget = 0; + QPaintDevice* dev = 0; + if (painter) + dev = painter->device(); + if (dev && dev->devType() == QInternal::Widget) + widget = static_cast<QWidget*>(dev); + style = themeStyle; + + StylePainter::init(context); +} + +PassRefPtr<RenderTheme> RenderThemeQStyle::create(Page* page) +{ + return adoptRef(new RenderThemeQStyle(page)); +} + +RenderThemeQStyle::RenderThemeQStyle(Page* page) + : RenderThemeQt(page) +#ifndef QT_NO_LINEEDIT + , m_lineEdit(0) +#endif +{ + QPushButton button; + QFont defaultButtonFont = QApplication::font(&button); + m_buttonFontFamily = defaultButtonFont.family(); +#ifdef Q_WS_MAC + button.setAttribute(Qt::WA_MacSmallSize); + QFontInfo fontInfo(defaultButtonFont); + m_buttonFontPixelSize = fontInfo.pixelSize(); +#endif + + m_fallbackStyle = QStyleFactory::create(QLatin1String("windows")); +} + +RenderThemeQStyle::~RenderThemeQStyle() +{ + delete m_fallbackStyle; +#ifndef QT_NO_LINEEDIT + delete m_lineEdit; +#endif +} + + +// for some widget painting, we need to fallback to Windows style +QStyle* RenderThemeQStyle::fallbackStyle() const +{ + return (m_fallbackStyle) ? m_fallbackStyle : QApplication::style(); +} + +QStyle* RenderThemeQStyle::qStyle() const +{ + if (m_page) { + QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient(); + + if (pageClient) + return pageClient->style(); + } + + return QApplication::style(); +} + +int RenderThemeQStyle::findFrameLineWidth(QStyle* style) const +{ +#ifndef QT_NO_LINEEDIT + if (!m_lineEdit) + m_lineEdit = new QLineEdit(); +#endif + + QStyleOptionFrameV2 opt; + QWidget* widget = 0; +#ifndef QT_NO_LINEEDIT + widget = m_lineEdit; +#endif + return style->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, widget); +} + +QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const +{ + QStyleOptionButton option; + option.state |= QStyle::State_Small; + option.rect = originalRect; + + QRect layoutRect = qStyle()->subElementRect(QStyle::SE_PushButtonLayoutItem, &option, 0); + if (!layoutRect.isNull()) { + int paddingLeft = layoutRect.left() - originalRect.left(); + int paddingRight = originalRect.right() - layoutRect.right(); + int paddingTop = layoutRect.top() - originalRect.top(); + int paddingBottom = originalRect.bottom() - layoutRect.bottom(); + + return originalRect.adjusted(-paddingLeft, -paddingTop, paddingRight, paddingBottom); + } + return originalRect; +} + +void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle* renderStyle) const +{ + QSize size(0, 0); + const QFontMetrics fm(renderStyle->font().font()); + QStyle* style = qStyle(); + + switch (renderStyle->appearance()) { + case TextAreaPart: + case SearchFieldPart: + case TextFieldPart: { + int padding = findFrameLineWidth(style); + renderStyle->setPaddingLeft(Length(padding, Fixed)); + renderStyle->setPaddingRight(Length(padding, Fixed)); + renderStyle->setPaddingTop(Length(padding, Fixed)); + renderStyle->setPaddingBottom(Length(padding, Fixed)); + break; + } + default: + break; + } + // If the width and height are both specified, then we have nothing to do. + if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto()) + return; + + switch (renderStyle->appearance()) { + case CheckboxPart: { + QStyleOption styleOption; + styleOption.state |= QStyle::State_Small; + int checkBoxWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &styleOption); + checkBoxWidth *= renderStyle->effectiveZoom(); + size = QSize(checkBoxWidth, checkBoxWidth); + break; + } + case RadioPart: { + QStyleOption styleOption; + styleOption.state |= QStyle::State_Small; + int radioWidth = style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &styleOption); + radioWidth *= renderStyle->effectiveZoom(); + size = QSize(radioWidth, radioWidth); + break; + } + case PushButtonPart: + case ButtonPart: { + QStyleOptionButton styleOption; + styleOption.state |= QStyle::State_Small; + QSize contentSize = fm.size(Qt::TextShowMnemonic, QString::fromLatin1("X")); + QSize pushButtonSize = style->sizeFromContents(QStyle::CT_PushButton, + &styleOption, contentSize, 0); + styleOption.rect = QRect(0, 0, pushButtonSize.width(), pushButtonSize.height()); + QRect layoutRect = style->subElementRect(QStyle::SE_PushButtonLayoutItem, + &styleOption, 0); + + // If the style supports layout rects we use that, and compensate accordingly + // in paintButton() below. + if (!layoutRect.isNull()) + size.setHeight(layoutRect.height()); + else + size.setHeight(pushButtonSize.height()); + + break; + } + case MenulistPart: { + QStyleOptionComboBox styleOption; + styleOption.state |= QStyle::State_Small; + int contentHeight = qMax(fm.lineSpacing(), 14) + 2; + QSize menuListSize = style->sizeFromContents(QStyle::CT_ComboBox, + &styleOption, QSize(0, contentHeight), 0); + size.setHeight(menuListSize.height()); + break; + } + default: + break; + } + + // FIXME: Check is flawed, since it doesn't take min-width/max-width into account. + if (renderStyle->width().isIntrinsicOrAuto() && size.width() > 0) + renderStyle->setMinWidth(Length(size.width(), Fixed)); + if (renderStyle->height().isAuto() && size.height() > 0) + renderStyle->setMinHeight(Length(size.height(), Fixed)); +} + + + +void RenderThemeQStyle::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element*) const +{ + // Ditch the border. + style->resetBorder(); + +#ifdef Q_WS_MAC + if (style->appearance() == PushButtonPart) { + // The Mac ports ignore the specified height for <input type="button"> elements + // unless a border and/or background CSS property is also specified. + style->setHeight(Length(Auto)); + } +#endif + + FontDescription fontDescription = style->fontDescription(); + fontDescription.setIsAbsoluteSize(true); + +#ifdef Q_WS_MAC // Use fixed font size and family on Mac (like Safari does) + fontDescription.setSpecifiedSize(m_buttonFontPixelSize); + fontDescription.setComputedSize(m_buttonFontPixelSize); +#else + fontDescription.setSpecifiedSize(style->fontSize()); + fontDescription.setComputedSize(style->fontSize()); +#endif + + FontFamily fontFamily; + fontFamily.setFamily(m_buttonFontFamily); + fontDescription.setFamily(fontFamily); + style->setFontDescription(fontDescription); + style->font().update(selector->fontSelector()); + style->setLineHeight(RenderStyle::initialLineHeight()); + setButtonSize(style); + setButtonPadding(style); +} + +void RenderThemeQStyle::setButtonPadding(RenderStyle* style) const +{ + QStyleOptionButton styleOption; + styleOption.state |= QStyle::State_Small; + + // Fake a button rect here, since we're just computing deltas + QRect originalRect = QRect(0, 0, 100, 30); + styleOption.rect = originalRect; + + // Default padding is based on the button margin pixel metric + int buttonMargin = qStyle()->pixelMetric(QStyle::PM_ButtonMargin, &styleOption, 0); + int paddingLeft = buttonMargin; + int paddingRight = buttonMargin; + int paddingTop = buttonMargin; + int paddingBottom = buttonMargin; + + // Then check if the style uses layout margins + QRect layoutRect = qStyle()->subElementRect(QStyle::SE_PushButtonLayoutItem, + &styleOption, 0); + if (!layoutRect.isNull()) { + QRect contentsRect = qStyle()->subElementRect(QStyle::SE_PushButtonContents, + &styleOption, 0); + paddingLeft = contentsRect.left() - layoutRect.left(); + paddingRight = layoutRect.right() - contentsRect.right(); + paddingTop = contentsRect.top() - layoutRect.top(); + + // Can't use this right now because we don't have the baseline to compensate + // paddingBottom = layoutRect.bottom() - contentsRect.bottom(); + } + style->setPaddingLeft(Length(paddingLeft, Fixed)); + style->setPaddingRight(Length(paddingRight, Fixed)); + style->setPaddingTop(Length(paddingTop, Fixed)); + style->setPaddingBottom(Length(paddingBottom, Fixed)); +} + +bool RenderThemeQStyle::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + StylePainterQStyle p(this, i); + if (!p.isValid()) + return true; + + QStyleOptionButton option; + initStyleOption(p.widget, option); + option.rect = r; + option.state |= QStyle::State_Small; + + ControlPart appearance = initializeCommonQStyleOptions(option, o); + if (appearance == PushButtonPart || appearance == ButtonPart) { + option.rect = inflateButtonRect(option.rect); + p.drawControl(QStyle::CE_PushButton, option); + } else if (appearance == RadioPart) + p.drawControl(QStyle::CE_RadioButton, option); + else if (appearance == CheckboxPart) + p.drawControl(QStyle::CE_CheckBox, option); + + return false; +} + +bool RenderThemeQStyle::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + StylePainterQStyle p(this, i); + if (!p.isValid()) + return true; + + QStyleOptionFrameV2 panel; + initStyleOption(p.widget, panel); + panel.rect = r; + panel.lineWidth = findFrameLineWidth(qStyle()); + panel.state |= QStyle::State_Sunken; + panel.features = QStyleOptionFrameV2::None; + + // Get the correct theme data for a text field + ControlPart appearance = initializeCommonQStyleOptions(panel, o); + if (appearance != TextFieldPart + && appearance != SearchFieldPart + && appearance != TextAreaPart + && appearance != ListboxPart) + return true; + + // Now paint the text field. + p.drawPrimitive(QStyle::PE_PanelLineEdit, panel); + return false; +} + +void RenderThemeQStyle::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, Element* element) const +{ + adjustTextFieldStyle(selector, style, element); +} + +bool RenderThemeQStyle::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + return paintTextField(o, i, r); +} + +void RenderThemeQStyle::setPopupPadding(RenderStyle* style) const +{ + const int paddingLeft = 4; + const int paddingRight = style->width().isFixed() || style->width().isPercent() ? 5 : 8; + + style->setPaddingLeft(Length(paddingLeft, Fixed)); + + QStyleOptionComboBox opt; + int w = qStyle()->pixelMetric(QStyle::PM_ButtonIconSize, &opt, 0); + style->setPaddingRight(Length(paddingRight + w, Fixed)); + + style->setPaddingTop(Length(2, Fixed)); + style->setPaddingBottom(Length(2, Fixed)); +} + + +bool RenderThemeQStyle::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + StylePainterQStyle p(this, i); + if (!p.isValid()) + return true; + + QStyleOptionComboBox opt; + initStyleOption(p.widget, opt); + initializeCommonQStyleOptions(opt, o); + + IntRect rect = r; + +#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) + // QMacStyle makes the combo boxes a little bit smaller to leave space for the focus rect. + // Because of it, the combo button is drawn at a point to the left of where it was expect to be and may end up + // overlapped with the text. This will force QMacStyle to draw the combo box with the expected width. + if (qobject_cast<QMacStyle*>(p.style)) + rect.inflateX(3); +#endif + + const QPoint topLeft = rect.location(); + p.painter->translate(topLeft); + opt.rect.moveTo(QPoint(0, 0)); + opt.rect.setSize(rect.size()); + + p.drawComplexControl(QStyle::CC_ComboBox, opt); + p.painter->translate(-topLeft); + return false; +} + +void RenderThemeQStyle::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const +{ + // WORKAROUND because html.css specifies -webkit-border-radius for <select> so we override it here + // see also http://bugs.webkit.org/show_bug.cgi?id=18399 + style->resetBorderRadius(); + + RenderThemeQt::adjustMenuListButtonStyle(selector, style, e); +} + +bool RenderThemeQStyle::paintMenuListButton(RenderObject* o, const PaintInfo& i, + const IntRect& r) +{ + StylePainterQStyle p(this, i); + if (!p.isValid()) + return true; + + QStyleOptionComboBox option; + initStyleOption(p.widget, option); + initializeCommonQStyleOptions(option, o); + option.rect = r; + + // for drawing the combo box arrow, rely only on the fallback style + p.style = fallbackStyle(); + option.subControls = QStyle::SC_ComboBoxArrow; + p.drawComplexControl(QStyle::CC_ComboBox, option); + + return false; +} + +#if ENABLE(PROGRESS_TAG) +double RenderThemeQStyle::animationDurationForProgressBar(RenderProgress* renderProgress) const +{ + if (renderProgress->position() >= 0) + return 0; + + QStyleOptionProgressBarV2 option; + option.rect.setSize(renderProgress->size()); + // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, + // we simulate one square animating across the progress bar. + return (option.rect.width() / qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option)) * animationRepeatIntervalForProgressBar(renderProgress); +} + +bool RenderThemeQStyle::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r) +{ + if (!o->isProgress()) + return true; + + StylePainterQStyle p(this, pi); + if (!p.isValid()) + return true; + + QStyleOptionProgressBarV2 option; + initStyleOption(p.widget, option); + initializeCommonQStyleOptions(option, o); + + RenderProgress* renderProgress = toRenderProgress(o); + option.rect = r; + option.maximum = std::numeric_limits<int>::max(); + option.minimum = 0; + option.progress = (renderProgress->position() * std::numeric_limits<int>::max()); + + const QPoint topLeft = r.location(); + p.painter->translate(topLeft); + option.rect.moveTo(QPoint(0, 0)); + option.rect.setSize(r.size()); + + if (option.progress < 0) { + // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, + // we simulate one square animating across the progress bar. + p.drawControl(QStyle::CE_ProgressBarGroove, option); + int chunkWidth = qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option); + QColor color = (option.palette.highlight() == option.palette.background()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight); + if (renderProgress->style()->direction() == RTL) + p.painter->fillRect(option.rect.right() - chunkWidth - renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); + else + p.painter->fillRect(renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); + } else + p.drawControl(QStyle::CE_ProgressBar, option); + + p.painter->translate(-topLeft); + + return false; +} +#endif + +bool RenderThemeQStyle::paintSliderTrack(RenderObject* o, const PaintInfo& pi, + const IntRect& r) +{ + StylePainterQStyle p(this, pi); + if (!p.isValid()) + return true; + + const QPoint topLeft = r.location(); + p.painter->translate(topLeft); + + QStyleOptionSlider option; + initStyleOption(p.widget, option); + option.subControls = QStyle::SC_SliderGroove; + ControlPart appearance = initializeCommonQStyleOptions(option, o); + option.rect = r; + option.rect.moveTo(QPoint(0, 0)); + if (appearance == SliderVerticalPart) + option.orientation = Qt::Vertical; + if (isPressed(o)) + option.state |= QStyle::State_Sunken; + + // some styles need this to show a highlight on one side of the groove + HTMLInputElement* slider = o->node()->toInputElement(); + if (slider) { + option.upsideDown = (appearance == SliderHorizontalPart) && !o->style()->isLeftToRightDirection(); + // Use the width as a multiplier in case the slider values are <= 1 + const int width = r.width() > 0 ? r.width() : 100; + option.maximum = slider->maximum() * width; + option.minimum = slider->minimum() * width; + if (!option.upsideDown) + option.sliderPosition = slider->valueAsNumber() * width; + else + option.sliderPosition = option.minimum + option.maximum - slider->valueAsNumber() * width; + } + + p.drawComplexControl(QStyle::CC_Slider, option); + + if (option.state & QStyle::State_HasFocus) { + QStyleOptionFocusRect focusOption; + focusOption.rect = r; + p.drawPrimitive(QStyle::PE_FrameFocusRect, focusOption); + } + p.painter->translate(-topLeft); + return false; +} + +void RenderThemeQStyle::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ + style->setBoxShadow(nullptr); +} + +bool RenderThemeQStyle::paintSliderThumb(RenderObject* o, const PaintInfo& pi, + const IntRect& r) +{ + StylePainterQStyle p(this, pi); + if (!p.isValid()) + return true; + + const QPoint topLeft = r.location(); + p.painter->translate(topLeft); + + QStyleOptionSlider option; + initStyleOption(p.widget, option); + option.subControls = QStyle::SC_SliderHandle; + ControlPart appearance = initializeCommonQStyleOptions(option, o); + option.rect = r; + option.rect.moveTo(QPoint(0, 0)); + if (appearance == SliderThumbVerticalPart) + option.orientation = Qt::Vertical; + if (isPressed(o)) { + option.activeSubControls = QStyle::SC_SliderHandle; + option.state |= QStyle::State_Sunken; + } + + p.drawComplexControl(QStyle::CC_Slider, option); + p.painter->translate(-topLeft); + return false; +} + +void RenderThemeQStyle::adjustSliderThumbStyle(CSSStyleSelector* selector, RenderStyle* style, Element* element) const +{ + RenderTheme::adjustSliderThumbStyle(selector, style, element); + style->setBoxShadow(nullptr); +} + +bool RenderThemeQStyle::paintSearchField(RenderObject* o, const PaintInfo& pi, + const IntRect& r) +{ + return paintTextField(o, pi, r); +} + +void RenderThemeQStyle::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, + Element* e) const +{ + notImplemented(); + RenderTheme::adjustSearchFieldDecorationStyle(selector, style, e); +} + +bool RenderThemeQStyle::paintSearchFieldDecoration(RenderObject* o, const PaintInfo& pi, + const IntRect& r) +{ + notImplemented(); + return RenderTheme::paintSearchFieldDecoration(o, pi, r); +} + +void RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, + Element* e) const +{ + notImplemented(); + RenderTheme::adjustSearchFieldResultsDecorationStyle(selector, style, e); +} + +bool RenderThemeQStyle::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& pi, + const IntRect& r) +{ + notImplemented(); + return RenderTheme::paintSearchFieldResultsDecoration(o, pi, r); +} + +#ifndef QT_NO_SPINBOX + +bool RenderThemeQStyle::paintInnerSpinButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + StylePainterQStyle p(this, paintInfo); + if (!p.isValid()) + return true; + + QStyleOptionSpinBox option; + initStyleOption(p.widget, option); + option.subControls = QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown; + if (!isReadOnlyControl(o)) { + if (isEnabled(o)) + option.stepEnabled = QAbstractSpinBox::StepUpEnabled | QAbstractSpinBox::StepDownEnabled; + if (isPressed(o)) { + option.state |= QStyle::State_Sunken; + if (isSpinUpButtonPartPressed(o)) + option.activeSubControls = QStyle::SC_SpinBoxUp; + else + option.activeSubControls = QStyle::SC_SpinBoxDown; + } + } + // Render the spin buttons for LTR or RTL accordingly. + option.direction = o->style()->isLeftToRightDirection() ? Qt::LeftToRight : Qt::RightToLeft; + + IntRect buttonRect = rect; + // Default to moving the buttons a little bit within the editor frame. + int inflateX = -2; + int inflateY = -2; +#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) + // QMacStyle will position the aqua buttons flush to the right. + // This will move them more within the control for better style, a la + // Chromium look & feel. + if (qobject_cast<QMacStyle*>(p.style)) { + inflateX = -4; + // Render mini aqua spin buttons for QMacStyle to fit nicely into + // the editor area, like Chromium. + option.state |= QStyle::State_Mini; + } +#endif +#if !defined(QT_NO_STYLE_PLASTIQUE) + // QPlastiqueStyle looks best when the spin buttons are flush with the frame's edge. + if (qobject_cast<QPlastiqueStyle*>(p.style)) { + inflateX = 0; + inflateY = 0; + } +#endif + + buttonRect.inflateX(inflateX); + buttonRect.inflateY(inflateY); + option.rect = buttonRect; + + p.drawComplexControl(QStyle::CC_SpinBox, option); + return false; +} +#endif + +ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleOption& option, RenderObject* o) const +{ + // Default bits: no focus, no mouse over + option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); + + if (isReadOnlyControl(o)) + // Readonly is supported on textfields. + option.state |= QStyle::State_ReadOnly; + + option.direction = Qt::LeftToRight; + + if (isHovered(o)) + option.state |= QStyle::State_MouseOver; + + setPaletteFromPageClientIfExists(option.palette); + + if (!isEnabled(o)) { + option.palette.setCurrentColorGroup(QPalette::Disabled); + option.state &= ~QStyle::State_Enabled; + } + + RenderStyle* style = o->style(); + if (!style) + return NoControlPart; + + ControlPart result = style->appearance(); + if (supportsFocus(result) && isFocused(o)) { + option.state |= QStyle::State_HasFocus; + option.state |= QStyle::State_KeyboardFocusChange; + } + + if (style->direction() == WebCore::RTL) + option.direction = Qt::RightToLeft; + + switch (result) { + case PushButtonPart: + case SquareButtonPart: + case ButtonPart: + case ButtonBevelPart: + case ListItemPart: + case MenulistButtonPart: + case SearchFieldResultsButtonPart: + case SearchFieldCancelButtonPart: { + if (isPressed(o)) + option.state |= QStyle::State_Sunken; + else if (result == PushButtonPart || result == ButtonPart) + option.state |= QStyle::State_Raised; + break; + } + case RadioPart: + case CheckboxPart: + option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); + } + + return result; +} + +void RenderThemeQStyle::adjustSliderThumbSize(RenderStyle* style) const +{ + const ControlPart part = style->appearance(); + if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) { + QStyleOptionSlider option; + if (part == SliderThumbVerticalPart) + option.orientation = Qt::Vertical; + + QStyle* qstyle = qStyle(); + + int length = qstyle->pixelMetric(QStyle::PM_SliderLength, &option); + int thickness = qstyle->pixelMetric(QStyle::PM_SliderThickness, &option); + if (option.orientation == Qt::Vertical) { + style->setWidth(Length(thickness, Fixed)); + style->setHeight(Length(length, Fixed)); + } else { + style->setWidth(Length(length, Fixed)); + style->setHeight(Length(thickness, Fixed)); + } + } else + RenderThemeQt::adjustSliderThumbSize(style); +} + +} + +// vim: ts=4 sw=4 et diff --git a/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h new file mode 100644 index 000000000..a83e02f5a --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h @@ -0,0 +1,144 @@ +/* + * This file is part of the theme implementation for form controls in WebCore. + * + * Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef RenderThemeQStyle_h +#define RenderThemeQStyle_h + +#include "RenderThemeQt.h" + +#include <QStyle> + +QT_BEGIN_NAMESPACE +#ifndef QT_NO_LINEEDIT +class QLineEdit; +#endif +class QPainter; +class QWidget; +QT_END_NAMESPACE + +namespace WebCore { + +class ScrollbarThemeQStyle; + +class RenderThemeQStyle : public RenderThemeQt { +private: + RenderThemeQStyle(Page*); + virtual ~RenderThemeQStyle(); + +public: + static PassRefPtr<RenderTheme> create(Page*); + + virtual void adjustSliderThumbSize(RenderStyle*) const; + + QStyle* qStyle() const; + +protected: + virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); + + virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); + + virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); + virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + + virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); + + virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + +#if ENABLE(PROGRESS_TAG) + // Returns the duration of the animation for the progress bar. + virtual double animationDurationForProgressBar(RenderProgress*) const; + virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); +#endif + + virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + + virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); + virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + + virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&); + +#ifndef QT_NO_SPINBOX + virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&); +#endif + +protected: + virtual void computeSizeBasedOnStyle(RenderStyle*) const; + + virtual QSharedPointer<StylePainter> getStylePainter(const PaintInfo&); + + virtual QRect inflateButtonRect(const QRect& originalRect) const; + + virtual void setPopupPadding(RenderStyle*) const; + +private: + ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const; + + void setButtonPadding(RenderStyle*) const; + + int findFrameLineWidth(QStyle*) const; + + QStyle* fallbackStyle() const; + +#ifdef Q_OS_MAC + int m_buttonFontPixelSize; +#endif + + QStyle* m_fallbackStyle; +#ifndef QT_NO_LINEEDIT + mutable QLineEdit* m_lineEdit; +#endif +}; + +class StylePainterQStyle : public StylePainter { +public: + explicit StylePainterQStyle(RenderThemeQStyle*, const PaintInfo&); + explicit StylePainterQStyle(ScrollbarThemeQStyle*, GraphicsContext*); + + bool isValid() const { return style && StylePainter::isValid(); } + + QWidget* widget; + QStyle* style; + + void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption& opt) + { style->drawPrimitive(pe, &opt, painter, widget); } + void drawControl(QStyle::ControlElement ce, const QStyleOption& opt) + { style->drawControl(ce, &opt, painter, widget); } + void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex& opt) + { style->drawComplexControl(cc, &opt, painter, widget); } + +private: + void init(GraphicsContext*, QStyle*); + + Q_DISABLE_COPY(StylePainterQStyle) +}; + +} + +#endif // RenderThemeQStyle_h diff --git a/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp b/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp new file mode 100644 index 000000000..b0827fea4 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> + * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScrollbarThemeQStyle.h" + +#include "GraphicsContext.h" +#include "PlatformMouseEvent.h" +#include "RenderThemeQStyle.h" +#include "RenderThemeQtMobile.h" +#include "ScrollView.h" +#include "Scrollbar.h" + +#include <QApplication> +#ifdef Q_WS_MAC +#include <QMacStyle> +#endif +#include <QMenu> +#include <QPainter> +#include <QStyle> +#include <QStyleOptionSlider> + +namespace WebCore { + +ScrollbarThemeQStyle::~ScrollbarThemeQStyle() +{ +} + +static QStyle::SubControl scPart(const ScrollbarPart& part) +{ + switch (part) { + case NoPart: + return QStyle::SC_None; + case BackButtonStartPart: + case BackButtonEndPart: + return QStyle::SC_ScrollBarSubLine; + case BackTrackPart: + return QStyle::SC_ScrollBarSubPage; + case ThumbPart: + return QStyle::SC_ScrollBarSlider; + case ForwardTrackPart: + return QStyle::SC_ScrollBarAddPage; + case ForwardButtonStartPart: + case ForwardButtonEndPart: + return QStyle::SC_ScrollBarAddLine; + } + + return QStyle::SC_None; +} + +static ScrollbarPart scrollbarPart(const QStyle::SubControl& sc) +{ + switch (sc) { + case QStyle::SC_None: + return NoPart; + case QStyle::SC_ScrollBarSubLine: + return BackButtonStartPart; + case QStyle::SC_ScrollBarSubPage: + return BackTrackPart; + case QStyle::SC_ScrollBarSlider: + return ThumbPart; + case QStyle::SC_ScrollBarAddPage: + return ForwardTrackPart; + case QStyle::SC_ScrollBarAddLine: + return ForwardButtonStartPart; + } + return NoPart; +} + +static QStyleOptionSlider* styleOptionSlider(ScrollbarThemeClient* scrollbar, QWidget* widget = 0) +{ + static QStyleOptionSlider opt; + if (widget) + opt.initFrom(widget); + else + opt.state |= QStyle::State_Active; + + opt.state &= ~QStyle::State_HasFocus; + + opt.rect = scrollbar->frameRect(); + if (scrollbar->enabled()) + opt.state |= QStyle::State_Enabled; + if (scrollbar->controlSize() != RegularScrollbar) + opt.state |= QStyle::State_Mini; + opt.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal; + + if (scrollbar->orientation() == HorizontalScrollbar) + opt.state |= QStyle::State_Horizontal; + else + opt.state &= ~QStyle::State_Horizontal; + + opt.sliderValue = scrollbar->value(); + opt.sliderPosition = opt.sliderValue; + opt.pageStep = scrollbar->pageStep(); + opt.singleStep = scrollbar->lineStep(); + opt.minimum = 0; + opt.maximum = qMax(0, scrollbar->maximum()); + ScrollbarPart pressedPart = scrollbar->pressedPart(); + ScrollbarPart hoveredPart = scrollbar->hoveredPart(); + if (pressedPart != NoPart) { + opt.activeSubControls = scPart(scrollbar->pressedPart()); + if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart + || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart + || pressedPart == ThumbPart) + opt.state |= QStyle::State_Sunken; + } else + opt.activeSubControls = scPart(hoveredPart); + if (hoveredPart != NoPart) + opt.state |= QStyle::State_MouseOver; + return &opt; +} + +bool ScrollbarThemeQStyle::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& dirtyRect) +{ + if (graphicsContext->updatingControlTints()) { + scrollbar->invalidateRect(dirtyRect); + return false; + } + + StylePainterQStyle p(this, graphicsContext); + if (!p.isValid()) + return true; + + p.painter->save(); + QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget); + + p.painter->setClipRect(opt->rect.intersected(dirtyRect), Qt::IntersectClip); + +#ifdef Q_WS_MAC + // FIXME: We also need to check the widget style but today ScrollbarTheme is not aware of the page so we + // can't get the widget. + if (qobject_cast<QMacStyle*>(style())) + p.drawComplexControl(QStyle::CC_ScrollBar, *opt); + else +#endif + { + // The QStyle expects the background to be already filled. + p.painter->fillRect(opt->rect, opt->palette.background()); + + const QPoint topLeft = opt->rect.topLeft(); + p.painter->translate(topLeft); + opt->rect.moveTo(QPoint(0, 0)); + p.drawComplexControl(QStyle::CC_ScrollBar, *opt); + opt->rect.moveTo(topLeft); + } + p.painter->restore(); + + return true; +} + +ScrollbarPart ScrollbarThemeQStyle::hitTest(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt) +{ + QStyleOptionSlider* opt = styleOptionSlider(scrollbar); + const QPoint pos = scrollbar->convertFromContainingWindow(evt.position()); + opt->rect.moveTo(QPoint(0, 0)); + QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0); + return scrollbarPart(sc); +} + +bool ScrollbarThemeQStyle::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt) +{ + // Middle click centers slider thumb (if supported). + return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton; +} + +void ScrollbarThemeQStyle::invalidatePart(ScrollbarThemeClient* scrollbar, ScrollbarPart) +{ + // FIXME: Do more precise invalidation. + scrollbar->invalidate(); +} + +int ScrollbarThemeQStyle::scrollbarThickness(ScrollbarControlSize controlSize) +{ + QStyleOptionSlider o; + o.orientation = Qt::Vertical; + o.state &= ~QStyle::State_Horizontal; + if (controlSize != RegularScrollbar) + o.state |= QStyle::State_Mini; + return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0); +} + +int ScrollbarThemeQStyle::thumbPosition(ScrollbarThemeClient* scrollbar) +{ + if (scrollbar->enabled()) { + float pos = (float)scrollbar->currentPos() * (trackLength(scrollbar) - thumbLength(scrollbar)) / scrollbar->maximum(); + return (pos < 1 && pos > 0) ? 1 : pos; + } + return 0; +} + +int ScrollbarThemeQStyle::thumbLength(ScrollbarThemeClient* scrollbar) +{ + QStyleOptionSlider* opt = styleOptionSlider(scrollbar); + IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0); + return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height(); +} + +int ScrollbarThemeQStyle::trackPosition(ScrollbarThemeClient* scrollbar) +{ + QStyleOptionSlider* opt = styleOptionSlider(scrollbar); + IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0); + return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y(); +} + +int ScrollbarThemeQStyle::trackLength(ScrollbarThemeClient* scrollbar) +{ + QStyleOptionSlider* opt = styleOptionSlider(scrollbar); + IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0); + return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height(); +} + +void ScrollbarThemeQStyle::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& rect) +{ + StylePainterQStyle p(this, context); + if (!p.isValid()) + return; + + QStyleOption option; + option.rect = rect; + p.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, option); +} + +QStyle* ScrollbarThemeQStyle::style() const +{ + return QApplication::style(); +} + +} + diff --git a/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.h b/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.h new file mode 100644 index 000000000..2537b9ae4 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScrollbarThemeQStyle_h +#define ScrollbarThemeQStyle_h + +#include "ScrollbarTheme.h" + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE +class QStyle; +QT_END_NAMESPACE + +namespace WebCore { + +class ScrollbarThemeQStyle : public ScrollbarTheme { +public: + virtual ~ScrollbarThemeQStyle(); + + virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& dirtyRect); + virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect); + + virtual ScrollbarPart hitTest(ScrollbarThemeClient*, const PlatformMouseEvent&); + + virtual bool shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent&); + + virtual void invalidatePart(ScrollbarThemeClient*, ScrollbarPart); + + virtual int thumbPosition(ScrollbarThemeClient*); + virtual int thumbLength(ScrollbarThemeClient*); + virtual int trackPosition(ScrollbarThemeClient*); + virtual int trackLength(ScrollbarThemeClient*); + + virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); + + QStyle* style() const; +}; + +} +#endif diff --git a/Source/WebKit/qt/declarative/experimental/experimental.pri b/Source/WebKit/qt/declarative/experimental/experimental.pri index bbecabb5c..583726f62 100644 --- a/Source/WebKit/qt/declarative/experimental/experimental.pri +++ b/Source/WebKit/qt/declarative/experimental/experimental.pri @@ -24,9 +24,7 @@ contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols wince*:LIBS += $$QMAKE_LIBS_GUI -CONFIG += qtwebkit qtwebkit-private - -QT += declarative widgets network quick +QT += declarative widgets network quick webkit webkit-private DESTDIR = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name} @@ -37,8 +35,8 @@ SOURCES += plugin.cpp DEFINES += HAVE_WEBKIT2 +# FIXME: Why are these needed, and why can't we use WEBKIT += ... ? INCLUDEPATH += \ - ../../../../WebKit2/UIProcess/API/qt \ ../../../../WebKit2/Shared/qt \ ../../../../JavaScriptCore \ ../../../../JavaScriptCore/wtf \ diff --git a/Source/WebKit/qt/declarative/experimental/plugin.cpp b/Source/WebKit/qt/declarative/experimental/plugin.cpp index da228521f..7d380e66a 100644 --- a/Source/WebKit/qt/declarative/experimental/plugin.cpp +++ b/Source/WebKit/qt/declarative/experimental/plugin.cpp @@ -19,14 +19,16 @@ #include "config.h" -#include "qquicknetworkreply_p.h" -#include "qquicknetworkrequest_p.h" -#include "qquickwebpage_p.h" -#include "qquickwebview_p.h" -#include "qwebdownloaditem_p.h" -#include "qwebviewportinfo_p.h" - -#include "qwebnavigationhistory_p.h" +#include "private/qquicknetworkreply_p.h" +#include "private/qquicknetworkrequest_p.h" +#include "private/qquickwebpage_p.h" +#include "private/qquickwebview_p.h" +#include "private/qtwebsecurityorigin_p.h" +#include "private/qwebdownloaditem_p.h" +#include "private/qwebnavigationhistory_p.h" +#include "private/qwebpermissionrequest_p.h" +#include "private/qwebpreferences_p.h" +#include "private/qwebviewportinfo_p.h" #include <QtDeclarative/qdeclarative.h> #include <QtDeclarative/qdeclarativeextensionplugin.h> @@ -54,6 +56,10 @@ public: qmlRegisterUncreatableType<QWebDownloadItem>(uri, 1, 0, "DownloadItem", QObject::tr("Cannot create separate instance of DownloadItem")); qmlRegisterUncreatableType<QWebNavigationListModel>(uri, 1, 0, "NavigationListModel", QObject::tr("Cannot create separate instance of NavigationListModel")); qmlRegisterUncreatableType<QWebNavigationHistory>(uri, 1, 0, "NavigationHistory", QObject::tr("Cannot create separate instance of NavigationHistory")); + qmlRegisterUncreatableType<QWebPreferences>(uri, 1, 0, "WebPreferences", QObject::tr("Cannot create separate instance of WebPreferences")); + qmlRegisterUncreatableType<QWebPermissionRequest>(uri, 1, 0, "PermissionRequest", QObject::tr("Cannot create separate instance of PermissionRequest")); + qmlRegisterUncreatableType<QtWebSecurityOrigin>(uri, 1, 0, "SecurityOrigin", QObject::tr("Cannot create separate instance of SecurityOrigin")); + qmlRegisterExtendedType<QQuickWebView, QQuickWebViewExperimentalExtension>(uri, 1, 0, "WebView"); qmlRegisterUncreatableType<QQuickWebViewExperimental>(uri, 1, 0, "WebViewExperimental", QObject::tr("Cannot create separate instance of WebViewExperimental")); diff --git a/Source/WebKit/qt/declarative/plugin.cpp b/Source/WebKit/qt/declarative/plugin.cpp index e2f0fb3ec..968b1fe18 100644 --- a/Source/WebKit/qt/declarative/plugin.cpp +++ b/Source/WebKit/qt/declarative/plugin.cpp @@ -17,19 +17,19 @@ Boston, MA 02110-1301, USA. */ +#if defined(HAVE_QQUICK1) #include "qdeclarativewebview_p.h" +#endif #include <QtDeclarative/qdeclarative.h> #include <QtDeclarative/qdeclarativeextensionplugin.h> #if defined(HAVE_WEBKIT2) -#include "qquickwebpage_p.h" -#include "qquickwebview_p.h" -#include "qtwebsecurityorigin_p.h" -#include "qwebiconimageprovider_p.h" -#include "qwebnavigationrequest_p.h" -#include "qwebpermissionrequest_p.h" -#include "qwebpreferences_p.h" +#include "private/qquickwebpage_p.h" +#include "private/qquickwebview_p.h" +#include "private/qwebiconimageprovider_p.h" +#include "private/qwebloadrequest_p.h" +#include "private/qwebnavigationrequest_p.h" #include <QtDeclarative/qdeclarativeengine.h> #include <QtNetwork/qnetworkreply.h> @@ -51,6 +51,7 @@ public: virtual void registerTypes(const char* uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit")); +#if defined(HAVE_QQUICK1) qmlRegisterType<QDeclarativeWebSettings>(); qmlRegisterType<QDeclarativeWebView>(uri, 1, 0, "WebView"); #ifdef Q_REVISION @@ -58,16 +59,14 @@ public: qmlRegisterRevision<QDeclarativeWebView, 0>("QtWebKit", 1, 0); qmlRegisterRevision<QDeclarativeWebView, 1>("QtWebKit", 1, 1); #endif +#endif #if defined(HAVE_WEBKIT2) qmlRegisterType<QQuickWebView>(uri, 3, 0, "WebView"); - qmlRegisterUncreatableType<QWebPreferences>(uri, 3, 0, "WebPreferences", QObject::tr("Cannot create separate instance of WebPreferences")); qmlRegisterUncreatableType<QQuickWebPage>(uri, 3, 0, "WebPage", QObject::tr("Cannot create separate instance of WebPage, use WebView")); qmlRegisterUncreatableType<QNetworkReply>(uri, 3, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply")); - qmlRegisterUncreatableType<QWebPermissionRequest>(uri, 3, 0, "PermissionRequest", QObject::tr("Cannot create separate instance of PermissionRequest")); qmlRegisterUncreatableType<QWebNavigationRequest>(uri, 3, 0, "NavigationRequest", QObject::tr("Cannot create separate instance of NavigationRequest")); - qmlRegisterUncreatableType<QtWebSecurityOrigin>(uri, 3, 0, "SecurityOrigin", QObject::tr("Cannot create separate instance of SecurityOrigin")); - + qmlRegisterUncreatableType<QWebLoadRequest>(uri, 3, 0, "WebLoadRequest", QObject::tr("Cannot create separate instance of WebLoadRequest")); #endif } }; @@ -77,4 +76,3 @@ QT_END_NAMESPACE #include "plugin.moc" Q_EXPORT_PLUGIN2(qmlwebkitplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin)); - diff --git a/Source/WebKit/qt/declarative/public.pri b/Source/WebKit/qt/declarative/public.pri index a6665eda6..e389e38eb 100644 --- a/Source/WebKit/qt/declarative/public.pri +++ b/Source/WebKit/qt/declarative/public.pri @@ -11,6 +11,8 @@ TARGET.module_name = QtWebKit CONFIG += qt plugin +load(features) + QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir copy2build.input = QMLDIRFILE copy2build.output = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name}/qmldir @@ -24,24 +26,27 @@ contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols wince*:LIBS += $$QMAKE_LIBS_GUI -CONFIG += qtwebkit qtwebkit-private +QT += declarative webkit webkit-private +haveQt(5): QT += widgets quick -QT += declarative -haveQt(5): QT += widgets quick quick1 +contains(DEFINES, HAVE_QQUICK1=1) { + SOURCES += qdeclarativewebview.cpp + HEADERS += qdeclarativewebview_p.h +} DESTDIR = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name} CONFIG += rpath RPATHDIR_RELATIVE_TO_DESTDIR = ../../lib +# FIXME: Why are these needed, and why can't we use WEBKIT += ... ? INCLUDEPATH += \ ../../../WebKit2/Shared/qt \ ../../../JavaScriptCore \ ../../../JavaScriptCore/runtime \ ../../../JavaScriptCore/wtf -SOURCES += qdeclarativewebview.cpp plugin.cpp -HEADERS += qdeclarativewebview_p.h +SOURCES += plugin.cpp !no_webkit2: { DEFINES += HAVE_WEBKIT2 diff --git a/Source/WebKit/qt/declarative/qdeclarativewebview.cpp b/Source/WebKit/qt/declarative/qdeclarativewebview.cpp index abf9bb218..d184c087e 100644 --- a/Source/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/Source/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -162,7 +162,7 @@ bool GraphicsWebView::sceneEvent(QEvent *event) This type is made available by importing the \c QtWebKit module: - \bold{import QtWebKit 1.0} + \b{import QtWebKit 1.0} The WebView item includes no scrolling, scaling, toolbars, or other common browser components. These must be implemented around WebView. See the \l{QML Web Browser} @@ -577,11 +577,11 @@ void QDeclarativeWebView::setRenderingEnabled(bool enabled) Finds a zoom that: \list - \i shows a whole item - \i includes (\a clickX, \a clickY) - \i fits into the preferredWidth and preferredHeight - \i zooms by no more than \a maxZoom - \i is more than 10% above the current zoom + \li shows a whole item + \li includes (\a clickX, \a clickY) + \li fits into the preferredWidth and preferredHeight + \li zooms by no more than \a maxZoom + \li is more than 10% above the current zoom \endlist If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise, diff --git a/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc b/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc index 877eb4d33..807cdaec0 100644 --- a/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc +++ b/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc @@ -79,20 +79,20 @@ with the QtWebKit bridge: \list - \i \bold{Hybrid C++/script}: C++ application code connects a + \li \b{Hybrid C++/script}: C++ application code connects a signal to a script function. This approach is useful if you have a QObject but don't want to expose the object itself to the scripting environment. You just want to define how the script responds to a signal and leave it up to the C++ side of your application to establish the connection between the C++ signal and the JavaScript slot. - \i \bold{Hybrid script/C++}: A script can connect signals and slots + \li \b{Hybrid script/C++}: A script can connect signals and slots to establish connections between pre-defined objects that the application exposes to the scripting environment. In this scenario, the slots themselves are still written in C++, but the definition of the connections is fully dynamic (script-defined). - \i \bold{Purely script-defined}: A script can both define signal + \li \b{Purely script-defined}: A script can both define signal handler functions (effectively "slots written in JavaScript"), \e{and} set up the connections that utilize those handlers. For example, a script can define a function that will handle the diff --git a/Source/WebKit/qt/docs/qtwebkit.qdoc b/Source/WebKit/qt/docs/qtwebkit.qdoc index 710d19478..f8cd8e702 100644 --- a/Source/WebKit/qt/docs/qtwebkit.qdoc +++ b/Source/WebKit/qt/docs/qtwebkit.qdoc @@ -106,54 +106,54 @@ The following locations are searched for plugins: \table - \header \o Linux/Unix (X11) - \row \o + \header \li Linux/Unix (X11) + \row \li \list - \o \c{.mozilla/plugins} in the user's home directory - \o \c{.netscape/plugins} in the user's home directory - \o System locations, such as + \li \c{.mozilla/plugins} in the user's home directory + \li \c{.netscape/plugins} in the user's home directory + \li System locations, such as \list - \o \c{/usr/lib/browser/plugins} - \o \c{/usr/local/lib/mozilla/plugins} - \o \c{/usr/lib/firefox/plugins} - \o \c{/usr/lib64/browser-plugins} - \o \c{/usr/lib/browser-plugins} - \o \c{/usr/lib/mozilla/plugins} - \o \c{/usr/local/netscape/plugins} - \o \c{/opt/mozilla/plugins} - \o \c{/opt/mozilla/lib/plugins} - \o \c{/opt/netscape/plugins} - \o \c{/opt/netscape/communicator/plugins} - \o \c{/usr/lib/netscape/plugins} - \o \c{/usr/lib/netscape/plugins-libc5} - \o \c{/usr/lib/netscape/plugins-libc6} - \o \c{/usr/lib64/netscape/plugins} - \o \c{/usr/lib64/mozilla/plugins} + \li \c{/usr/lib/browser/plugins} + \li \c{/usr/local/lib/mozilla/plugins} + \li \c{/usr/lib/firefox/plugins} + \li \c{/usr/lib64/browser-plugins} + \li \c{/usr/lib/browser-plugins} + \li \c{/usr/lib/mozilla/plugins} + \li \c{/usr/local/netscape/plugins} + \li \c{/opt/mozilla/plugins} + \li \c{/opt/mozilla/lib/plugins} + \li \c{/opt/netscape/plugins} + \li \c{/opt/netscape/communicator/plugins} + \li \c{/usr/lib/netscape/plugins} + \li \c{/usr/lib/netscape/plugins-libc5} + \li \c{/usr/lib/netscape/plugins-libc6} + \li \c{/usr/lib64/netscape/plugins} + \li \c{/usr/lib64/mozilla/plugins} \endlist - \o Locations specified by environment variables: + \li Locations specified by environment variables: \list - \o \c{$MOZILLA_HOME/plugins} - \o \c{$MOZ_PLUGIN_PATH} - \o \c{$QTWEBKIT_PLUGIN_PATH} + \li \c{$MOZILLA_HOME/plugins} + \li \c{$MOZ_PLUGIN_PATH} + \li \c{$QTWEBKIT_PLUGIN_PATH} \endlist \endlist \endtable \table - \header \o Windows - \row \o + \header \li Windows + \row \li \list - \o The user's \c{Application Data\Mozilla\plugins} directory - \o Standard system locations of plugins for Quicktime, Flash, etc. + \li The user's \c{Application Data\Mozilla\plugins} directory + \li Standard system locations of plugins for Quicktime, Flash, etc. \endlist \endtable \table - \header \o Mac OS X - \row \o + \header \li Mac OS X + \row \li \list - \o \c{Library/Internet Plug-Ins} in the user's home directory - \o The system \c{/Library/Internet Plug-Ins} directory + \li \c{Library/Internet Plug-Ins} in the user's home directory + \li The system \c{/Library/Internet Plug-Ins} directory \endlist \endtable diff --git a/Source/WebKit/qt/docs/qtwebkit.qdocconf b/Source/WebKit/qt/docs/qtwebkit.qdocconf index 4f11d18bb..278d77ba8 100644 --- a/Source/WebKit/qt/docs/qtwebkit.qdocconf +++ b/Source/WebKit/qt/docs/qtwebkit.qdocconf @@ -17,17 +17,17 @@ indexes = $QTDIR/doc/html/qt.index macro.aring.HTML = "å" macro.Auml.HTML = "Ä" -macro.author = "\\bold{Author:}" +macro.author = "\\b{Author:}" macro.br.HTML = "<br />" macro.BR.HTML = "<br />" macro.aacute.HTML = "á" macro.eacute.HTML = "é" macro.iacute.HTML = "í" -macro.gui = "\\bold" +macro.gui = "\\b" macro.hr.HTML = "<hr />" -macro.key = "\\bold" -macro.menu = "\\bold" -macro.note = "\\bold{Note:}" +macro.key = "\\b" +macro.menu = "\\b" +macro.note = "\\b{Note:}" macro.oslash.HTML = "ø" macro.ouml.HTML = "ö" macro.QA = "\\e{Qt Assistant}" @@ -50,24 +50,24 @@ macro.0 = "\\\\0" macro.b = "\\\\b" macro.n = "\\\\n" macro.r = "\\\\r" -macro.i = "\\o" -macro.i11 = "\\o{1,1}" -macro.i12 = "\\o{1,2}" -macro.i13 = "\\o{1,3}" -macro.i14 = "\\o{1,4}" -macro.i15 = "\\o{1,5}" -macro.i16 = "\\o{1,6}" -macro.i17 = "\\o{1,7}" -macro.i18 = "\\o{1,8}" -macro.i19 = "\\o{1,9}" -macro.i21 = "\\o{2,1}" -macro.i31 = "\\o{3,1}" -macro.i41 = "\\o{4,1}" -macro.i51 = "\\o{5,1}" -macro.i61 = "\\o{6,1}" -macro.i71 = "\\o{7,1}" -macro.i81 = "\\o{8,1}" -macro.i91 = "\\o{9,1}" +macro.i = "\\li" +macro.i11 = "\\li{1,1}" +macro.i12 = "\\li{1,2}" +macro.i13 = "\\li{1,3}" +macro.i14 = "\\li{1,4}" +macro.i15 = "\\li{1,5}" +macro.i16 = "\\li{1,6}" +macro.i17 = "\\li{1,7}" +macro.i18 = "\\li{1,8}" +macro.i19 = "\\li{1,9}" +macro.i21 = "\\li{2,1}" +macro.i31 = "\\li{3,1}" +macro.i41 = "\\li{4,1}" +macro.i51 = "\\li{5,1}" +macro.i61 = "\\li{6,1}" +macro.i71 = "\\li{7,1}" +macro.i81 = "\\li{8,1}" +macro.i91 = "\\li{9,1}" macro.img = "\\image" macro.endquote = "\\endquotation" diff --git a/Source/WebKit/qt/examples/platformplugin/platformplugin.pro b/Source/WebKit/qt/examples/platformplugin/platformplugin.pro index 896da8a3e..db3789958 100644 --- a/Source/WebKit/qt/examples/platformplugin/platformplugin.pro +++ b/Source/WebKit/qt/examples/platformplugin/platformplugin.pro @@ -31,4 +31,5 @@ HEADERS += \ qwebkitplatformplugin.h \ WebNotificationPresenter.h +!contains(DEFINES, ENABLE_LEGACY_NOTIFICATIONS=.): DEFINES += ENABLE_LEGACY_NOTIFICATIONS=1 !contains(DEFINES, ENABLE_NOTIFICATIONS=.): DEFINES += ENABLE_NOTIFICATIONS=1 diff --git a/Source/WebKit/qt/tests/MIMESniffing/MIMESniffing.pro b/Source/WebKit/qt/tests/MIMESniffing/MIMESniffing.pro index e960c0f6a..fe50f1b34 100644 --- a/Source/WebKit/qt/tests/MIMESniffing/MIMESniffing.pro +++ b/Source/WebKit/qt/tests/MIMESniffing/MIMESniffing.pro @@ -12,8 +12,4 @@ INCLUDEPATH += \ ../../../../JavaScriptCore \ ../../../../JavaScriptCore/runtime -debug { - SOURCES += ../../../../JavaScriptCore/wtf/Assertions.cpp -} - RESOURCES += resources.qrc diff --git a/Source/WebKit/qt/tests/tests.pri b/Source/WebKit/qt/tests/tests.pri index c4a5818f9..90c61f093 100644 --- a/Source/WebKit/qt/tests/tests.pri +++ b/Source/WebKit/qt/tests/tests.pri @@ -16,16 +16,10 @@ INCLUDEPATH += \ $$PWD \ $$PWD/../Api -QT += testlib network +QT += testlib network webkit haveQt(5): QT += widgets -CONFIG += qtwebkit - -haveQt(5) { - QT += declarative quick1 -} else { - contains(QT_CONFIG, declarative): QT += declarative -} +haveQt(4): haveQtModule(declarative): QT += declarative # This define is used by some tests to look up resources in the source tree DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog index 1c7f320a2..795dca1af 100644 --- a/Source/WebKit/win/ChangeLog +++ b/Source/WebKit/win/ChangeLog @@ -1,3 +1,67 @@ +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * WebCoreSupport/WebChromeClient.h: + (WebChromeClient::notificationPresenter): + * WebCoreSupport/WebDesktopNotificationsDelegate.cpp: + (WebDesktopNotificationsDelegate::checkPermission): + * WebCoreSupport/WebDesktopNotificationsDelegate.h: + (WebDesktopNotificationsDelegate): + +2012-03-09 Emil A Eklund <eae@chromium.org> + + Add roundedPoint to HitTestResult and change platform code to use it + https://bugs.webkit.org/show_bug.cgi?id=80715 + + Reviewed by James Robinson. + + Change ports to use roundedPoint to avoid exposing subpixel types to + platform code. + + * WebView.cpp: + (WebView::handleContextMenuEvent): + +2012-03-08 Steve Falkenburg <sfalken@apple.com> + + Separate WTF parts of JavaScriptCoreGenerated into WTFGenerated for Windows build + https://bugs.webkit.org/show_bug.cgi?id=80657 + + Preparation for WTF separation from JavaScriptCore. + The "Generated" vcproj files on Windows are necessary so Visual Studio can calculate correct + dependencies for generated files. + + Reviewed by Jessie Berlin. + + * WebKit.vcproj/WebKit.sln: Add WTFGenerated, update dependent projects. + +2012-03-03 Benjamin Poulain <benjamin@webkit.org> + + Remove the redundant method KURL::protocolInHTTPFamily() + https://bugs.webkit.org/show_bug.cgi?id=80216 + + Reviewed by Anders Carlsson. + + * WebCoreSupport/WebFrameLoaderClient.cpp: + (WebFrameLoaderClient::dispatchDidFailToStartPlugin): + * WebHistory.cpp: + (WebHistory::visitedURL): + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/WebChromeClient.h: + (WebChromeClient): + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/win/WebCoreSupport/WebChromeClient.h b/Source/WebKit/win/WebCoreSupport/WebChromeClient.h index 2a9a8fe7f..478f5d53b 100644 --- a/Source/WebKit/win/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit/win/WebCoreSupport/WebChromeClient.h @@ -120,10 +120,6 @@ public: virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*, int64_t totalSpaceNeeded); -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif - virtual void populateVisitedLinks(); virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); @@ -160,7 +156,7 @@ public: #endif #if ENABLE(NOTIFICATIONS) - virtual WebCore::NotificationPresenter* notificationPresenter() const { return reinterpret_cast<WebCore::NotificationPresenter*>(m_notificationsDelegate.get()); } + virtual WebCore::NotificationClient* notificationPresenter() const { return reinterpret_cast<WebCore::NotificationClient*>(m_notificationsDelegate.get()); } #endif virtual bool selectItemWritingDirectionIsNatural(); diff --git a/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp b/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp index b80590687..70ed482c3 100644 --- a/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp +++ b/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp @@ -180,13 +180,13 @@ void WebDesktopNotificationsDelegate::cancelRequestsForPermission(ScriptExecutio { } -NotificationPresenter::Permission WebDesktopNotificationsDelegate::checkPermission(const KURL& url) +NotificationClient::Permission WebDesktopNotificationsDelegate::checkPermission(const KURL& url) { int out = 0; BString org(SecurityOrigin::create(url)->toString()); if (hasNotificationDelegate()) notificationDelegate()->checkNotificationPermission(org, &out); - return (NotificationPresenter::Permission) out; + return (NotificationClient::Permission) out; } bool WebDesktopNotificationsDelegate::hasNotificationDelegate() diff --git a/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h b/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h index f0441cffe..a1a1185c5 100644 --- a/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h +++ b/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h @@ -30,7 +30,7 @@ #include <WebCore/COMPtr.h> #include <WebCore/Notification.h> -#include <WebCore/NotificationPresenter.h> +#include <WebCore/NotificationClient.h> #if ENABLE(NOTIFICATIONS) @@ -41,18 +41,18 @@ class Document; class KURL; } -class WebDesktopNotificationsDelegate : public WebCore::NotificationPresenter { +class WebDesktopNotificationsDelegate : public WebCore::NotificationClient { public: WebDesktopNotificationsDelegate(WebView* view); - /* WebCore::NotificationPresenter interface */ + /* WebCore::NotificationClient interface */ virtual bool show(WebCore::Notification* object); virtual void cancel(WebCore::Notification* object); virtual void notificationObjectDestroyed(WebCore::Notification* object); virtual void notificationControllerDestroyed(); virtual void requestPermission(WebCore::SecurityOrigin* origin, PassRefPtr<WebCore::VoidCallback> callback); virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*); - virtual WebCore::NotificationPresenter::Permission checkPermission(const KURL& url); + virtual WebCore::NotificationClient::Permission checkPermission(const KURL&); private: bool hasNotificationDelegate(); diff --git a/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp index daaf26a7c..f2e81aca4 100644 --- a/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp @@ -826,7 +826,7 @@ void WebFrameLoaderClient::dispatchDidFailToStartPlugin(const PluginView* plugin if (!pluginView->pluginsPage().isNull()) { KURL pluginPageURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(pluginView->pluginsPage())); - if (pluginPageURL.protocolInHTTPFamily()) { + if (pluginPageURL.protocolIsInHTTPFamily()) { static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInPageURLStringKey); RetainPtr<CFStringRef> str(AdoptCF, pluginPageURL.string().createCFString()); CFDictionarySetValue(userInfo.get(), key, str.get()); diff --git a/Source/WebKit/win/WebHistory.cpp b/Source/WebKit/win/WebHistory.cpp index 69dab5c67..e842c1407 100644 --- a/Source/WebKit/win/WebHistory.cpp +++ b/Source/WebKit/win/WebHistory.cpp @@ -735,7 +735,7 @@ void WebHistory::visitedURL(const KURL& url, const String& title, const String& entryPrivate->setLastVisitWasFailure(wasFailure); if (!httpMethod.isEmpty()) - entryPrivate->setLastVisitWasHTTPNonGet(!equalIgnoringCase(httpMethod, "GET") && url.protocolInHTTPFamily()); + entryPrivate->setLastVisitWasHTTPNonGet(!equalIgnoringCase(httpMethod, "GET") && url.protocolIsInHTTPFamily()); COMPtr<WebHistoryItem> item(Query, entry); item->historyItem()->setRedirectURLs(nullptr); diff --git a/Source/WebKit/win/WebKit.vcproj/WebKit.sln b/Source/WebKit/win/WebKit.vcproj/WebKit.sln index 6b3fc061d..a41ab21ae 100644 --- a/Source/WebKit/win/WebKit.vcproj/WebKit.sln +++ b/Source/WebKit/win/WebKit.vcproj/WebKit.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaScriptCore", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\JavaScriptCore\JavaScriptCore.vcproj", "{011D10F1-B656-4A1B-A0C3-3842F02122C5}" ProjectSection(ProjectDependencies) = postProject - {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6} + {4FF5BA11-59EC-4C24-8F52-F235C2E7D43A} = {4FF5BA11-59EC-4C24-8F52-F235C2E7D43A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore", "..\..\..\WebCore\WebCore.vcproj\WebCore.vcproj", "{1C16337B-ACF3-4D03-AA90-851C5B5EADA6}" @@ -13,7 +13,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore", "..\..\..\WebCore EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTF", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\WTF\WTF.vcproj", "{AA8A5A85-592B-4357-BC60-E0E91E026AF6}" ProjectSection(ProjectDependencies) = postProject - {4FF5BA11-59EC-4C24-8F52-F235C2E7D43A} = {4FF5BA11-59EC-4C24-8F52-F235C2E7D43A} + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950} = {5AE5F5E4-782D-4F63-B4D7-3977B52B9950} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsc", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\jsc\jsc.vcproj", "{C59E5129-B453-49B7-A52B-1E104715F76E}" @@ -24,6 +24,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "JavaScriptCore Folder", "JavaScriptCore Folder", "{557FA164-0E39-4DEC-B66C-8795C8E52399}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaScriptCoreGenerated", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\JavaScriptCore\JavaScriptCoreGenerated.vcproj", "{4FF5BA11-59EC-4C24-8F52-F235C2E7D43A}" + ProjectSection(ProjectDependencies) = postProject + {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6} + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebCore Folder", "WebCore Folder", "{63FB6F8A-C601-43E3-BD16-A00A465C2CB6}" EndProject @@ -183,6 +186,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitTestRunnerLauncher", {3B99669B-1817-443B-BCBE-835580146668} = {3B99669B-1817-443B-BCBE-835580146668} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WTF", "WTF", "{A671AE22-FBCE-4C41-A723-82939FCA3E92}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTFGenerated", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\WTF\WTFGenerated.vcproj", "{5AE5F5E4-782D-4F63-B4D7-3977B52B9950}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_All|Win32 = Debug_All|Win32 @@ -611,12 +618,23 @@ Global {C13FA6EF-B531-4BAD-9A23-18E2BEB8B040}.Release_Cairo_CFLite|Win32.Build.0 = Release_Cairo_CFLite|Win32 {C13FA6EF-B531-4BAD-9A23-18E2BEB8B040}.Release|Win32.ActiveCfg = Release|Win32 {C13FA6EF-B531-4BAD-9A23-18E2BEB8B040}.Release|Win32.Build.0 = Release|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Debug_All|Win32.ActiveCfg = Debug_All|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Debug_All|Win32.Build.0 = Debug_All|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Debug_Cairo_CFLite|Win32.ActiveCfg = Debug_Cairo_CFLite|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Debug_Cairo_CFLite|Win32.Build.0 = Debug_Cairo_CFLite|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Debug|Win32.ActiveCfg = Debug|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Debug|Win32.Build.0 = Debug|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Production|Win32.ActiveCfg = Production|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Production|Win32.Build.0 = Production|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Release_Cairo_CFLite|Win32.ActiveCfg = Release_Cairo_CFLite|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Release_Cairo_CFLite|Win32.Build.0 = Release_Cairo_CFLite|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Release|Win32.ActiveCfg = Release|Win32 + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {557FA164-0E39-4DEC-B66C-8795C8E52399} {C59E5129-B453-49B7-A52B-1E104715F76E} = {557FA164-0E39-4DEC-B66C-8795C8E52399} {011D10F1-B656-4A1B-A0C3-3842F02122C5} = {557FA164-0E39-4DEC-B66C-8795C8E52399} {4FF5BA11-59EC-4C24-8F52-F235C2E7D43A} = {557FA164-0E39-4DEC-B66C-8795C8E52399} @@ -651,5 +669,7 @@ Global {DD7949B6-F2B4-47C2-9C42-E21E84CB1017} = {62DCDFE4-EAD2-48E1-A2BD-BD54AD3C7459} {2974EA02-840B-4995-8719-8920A61006F1} = {62DCDFE4-EAD2-48E1-A2BD-BD54AD3C7459} {C13FA6EF-B531-4BAD-9A23-18E2BEB8B040} = {62DCDFE4-EAD2-48E1-A2BD-BD54AD3C7459} + {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {A671AE22-FBCE-4C41-A723-82939FCA3E92} + {5AE5F5E4-782D-4F63-B4D7-3977B52B9950} = {A671AE22-FBCE-4C41-A723-82939FCA3E92} EndGlobalSection EndGlobal diff --git a/Source/WebKit/win/WebView.cpp b/Source/WebKit/win/WebView.cpp index 5927c9664..141d36c95 100644 --- a/Source/WebKit/win/WebView.cpp +++ b/Source/WebKit/win/WebView.cpp @@ -1349,7 +1349,7 @@ bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) if (!view) return false; - POINT point(view->contentsToWindow(contextMenuController->hitTestResult().point())); + POINT point(view->contentsToWindow(contextMenuController->hitTestResult().roundedPoint())); // Translate the point to screen coordinates if (!::ClientToScreen(m_viewWindow, &point)) diff --git a/Source/WebKit/wince/ChangeLog b/Source/WebKit/wince/ChangeLog index 998f5d165..5ca6d91b7 100644 --- a/Source/WebKit/wince/ChangeLog +++ b/Source/WebKit/wince/ChangeLog @@ -1,3 +1,25 @@ +2012-03-09 Jon Lee <jonlee@apple.com> + + Rename NotificationPresenter to NotificationClient + https://bugs.webkit.org/show_bug.cgi?id=80488 + <rdar://problem/10965558> + + Reviewed by Kentaro Hara. + + Refactor to use renamed WebCore::NotificationClient. + * WebCoreSupport/ChromeClientWinCE.h: + (ChromeClientWinCE): + +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebCoreSupport/ChromeClientWinCE.h: + (ChromeClientWinCE): + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h b/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h index 613783a03..41792026b 100644 --- a/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h +++ b/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h @@ -131,12 +131,8 @@ public: // for this origin. virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*, int64_t totalSpaceNeeded); -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif - #if ENABLE(NOTIFICATIONS) - virtual WebCore::NotificationPresenter* notificationPresenter() const; + virtual WebCore::NotificationClient* notificationPresenter() const; #endif // This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission diff --git a/Source/WebKit/wx/ChangeLog b/Source/WebKit/wx/ChangeLog index 0c6021eab..de5aef92c 100644 --- a/Source/WebKit/wx/ChangeLog +++ b/Source/WebKit/wx/ChangeLog @@ -1,3 +1,13 @@ +2012-02-26 Hajime Morrita <morrita@chromium.org> + + Move ChromeClient::showContextMenu() to ContextMenuClient + https://bugs.webkit.org/show_bug.cgi?id=79427 + + Reviewed by Adam Barth. + + * WebKitSupport/ChromeClientWx.h: + (ChromeClientWx): + 2012-02-24 Shinya Kawanaka <shinyak@chromium.org> SpellCheckRequest needs to know the context where the spellcheck happened. diff --git a/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h b/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h index 2b6cdef61..f95871ba6 100644 --- a/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h +++ b/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h @@ -126,11 +126,6 @@ public: virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded); - -#if ENABLE(CONTEXT_MENUS) - virtual void showContextMenu() { } -#endif - virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*); |