diff options
Diffstat (limited to 'Source/WebKit/gtk')
20 files changed, 802 insertions, 74 deletions
diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog index 6dbea6560..8c59bb93f 100644 --- a/Source/WebKit/gtk/ChangeLog +++ b/Source/WebKit/gtk/ChangeLog @@ -1,3 +1,157 @@ +2012-02-08 Mario Sanchez Prada <msanchez@igalia.com> + + [Gtk] atk_text_get_text_at_offset() fails to provide the correct line for list items whose text wraps + https://bugs.webkit.org/show_bug.cgi?id=73431 + + Reviewed by Chris Fleizach. + + Updated unit test to check text wrapping accross different lines + inside list items with bullet markers. + + * tests/testatk.c: + (testWebkitAtkGetTextAtOffsetWithSpecialCharacters): Updated test. + +2012-02-06 Martin Robinson <mrobinson@igalia.com> and Nayan Kumar K <nayankk@motorola.com> + + [GTK] Add TextureMapperGL implementation + https://bugs.webkit.org/show_bug.cgi?id=75308 + + Reviewed by Alejandro G. Castro. + + * GNUmakefile.am: Add AcceleratedCompositingContextGL to the list. + * WebCoreSupport/AcceleratedCompositingContext.h: + (AcceleratedCompositingContext): Added some members for AcceleratedCompositingContextGL. + * WebCoreSupport/AcceleratedCompositingContextClutter.cpp: Added empty implementations + for GraphicsLayerClient. This is only used for the GL variant. + * WebCoreSupport/AcceleratedCompositingContextGL.cpp: Added. + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::performAllPendingScrolls): Update the root layer while scrolling. + (WebKit::ChromeClient::paint): Update the root layer after painting. + * webkit/webkitwebsettings.cpp: Added an enable-accelerated-compositing setting. + * webkit/webkitwebsettingsprivate.h: Ditto. + * webkit/webkitwebview.cpp: + (webkit_web_view_draw): Call into TextureMapper now. + (webkit_web_view_realize): Use gdk_window_ensure_native here. + (webkit_web_view_update_settings): Support the new enable-accelerated-compositing setting. + (webkit_web_view_settings_notify): Ditto. + +2012-02-06 Gustavo Noronha Silva <gns@gnome.org> + + Do not try to chdir to the directory where the executable is in + only if the path is absolute. This makes tests runnable from + anywhere. + + Reviewed by Martin Robinson. + + * tests/test_utils.c: + (testutils_relative_chdir): + +2012-02-06 Gustavo Noronha Silva <gns@gnome.org> + + Unreviewed fix for the new API test that is failing - + WEBKIT_INSPECTOR_PATH needs to be set, since we do not install our + builds. + + * tests/testwebinspector.c: + (main): + +2012-02-05 Gustavo Noronha Silva <gns@gnome.org> + + [GTK] Insta-crash when closing browser with inspector window opened + https://bugs.webkit.org/show_bug.cgi?id=50744 + + Reviewed by Martin Robinson. + + * GNUmakefile.am: + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::InspectorClient::releaseFrontendPage): also let go of the + frontend client when releasing the frontend page; + (WebKit::InspectorFrontendClient::~InspectorFrontendClient(): Call releaseFrontendPage() + like other ports do instead of just disconnectFrontendClient(). + (WebKit::InspectorFrontendClient::destroyInspectorWindow): Use GRefPtr for the + inspector ref. + (WebKit::InspectorFrontendClient::bringToFront): Adjust for GRefPtr usage. + (WebKit::InspectorFrontendClient::attachWindow): Ditto. + (WebKit::InspectorFrontendClient::detachWindow): Ditto. + (WebKit::InspectorFrontendClient::inspectedURLChanged): Ditto. + * WebCoreSupport/InspectorClientGtk.h: + (InspectorFrontendClient): Use GRefPtr for inspector member. + * tests/testwebinspector.c: Added. Test that killing a WebView with the inspector + open does not crash, and that closing and reinspecting works. + (quitLoop): + (consoleMessageCallback): + (inspectElementCallback): + (closeInspector): + (showInspector): + (test_webkit_web_inspector_close_and_inspect): + (test_webkit_web_inspector_destroy_inspected_web_view): + (main): + +2012-02-06 Gustavo Noronha Silva <gns@gnome.org> + + Add a null check for the gdkwindow, that will happen if the window + is not mapped. + + Reviewed by Martin Robinson. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::setCursor): + +2012-02-06 Martin Robinson <mrobinson@igalia.com> + + [GTK] WebKitWebView does a lot of work during size_allocate when not mapped + https://bugs.webkit.org/show_bug.cgi?id=77743 + + Reviewed by Gustavo Noronha Silva. + + Instead of resizing the guts of a WebView when it's not mapped, wait + until it's mapped and do one resize. This prevents unmapped WebViews + from adding to a container's resize cost. + + * webkit/webkitwebview.cpp: + (resizeWebViewFromAllocation): Abstracted out this helper. + (webkit_web_view_size_allocate): Wait until map to resize umapped widgets. + (webkitWebViewMap): Added this vmethod implementation. + (webkit_web_view_class_init): Added vmethod. + * webkit/webkitwebviewprivate.h: Added new needsResizeOnMap member. + +2012-02-06 Carlos Garcia Campos <cgarcia@igalia.com> + + [GTK] Update NEWS and configure.ac for 1.7.5 release + https://bugs.webkit.org/show_bug.cgi?id=77859 + + Reviewed by Philippe Normand. + + * NEWS: Added release notes for 1.7.5. + +2012-02-06 Carlos Garcia Campos <cgarcia@igalia.com> + + [GTK] Fix several gtkdoc-fixxref warnings + https://bugs.webkit.org/show_bug.cgi?id=77613 + + Reviewed by Martin Robinson. + + * docs/webkitgtk-docs.sgml: Remove webkitspellcheckerenchant + section. + * docs/webkitgtk-sections.txt: Remove webkitspellcheckerenchant + symbols and move WebKitWebNavigationReason from the private + section to the global section. + * webkit/webkitwebnavigationaction.h: Document + WebKitWebNavigationReason enum. + +2012-02-02 Kalev Lember <kalevlember@gmail.com> + + [GTK] Don't use uint + https://bugs.webkit.org/show_bug.cgi?id=77678 + + Reviewed by Martin Robinson. + + With the MingGW cross compiler toolchain in Fedora, uint wasn't + defined, so use unsigned int instead. + + * WebCoreSupport/ChromeClientGtk.h: + (ChromeClient): Use unsigned int instead of uint + 2012-02-02 Claudio Saavedra <csaavedra@igalia.com> and Martin Robinson <mrobinson@igalia.com> [GTK] WebKitWebView won't work in a GtkOffscreenWindow diff --git a/Source/WebKit/gtk/GNUmakefile.am b/Source/WebKit/gtk/GNUmakefile.am index 2472212e9..38d2bb02a 100644 --- a/Source/WebKit/gtk/GNUmakefile.am +++ b/Source/WebKit/gtk/GNUmakefile.am @@ -184,6 +184,7 @@ webkitgtk_sources += \ Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.h \ Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h \ Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextClutter.cpp \ + Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp \ Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp \ Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \ Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h \ @@ -456,6 +457,7 @@ TEST_PROGS += \ Programs/unittests/testatk \ Programs/unittests/testatkroles \ Programs/unittests/testhittestresult \ + Programs/unittests/testwebinspector \ Programs/unittests/testwebsettings \ Programs/unittests/testwebresource \ Programs/unittests/testwebdatasource \ @@ -555,6 +557,11 @@ Programs_unittests_testatkroles_CFLAGS = $(webkit_tests_cflags) Programs_unittests_testatkroles_LDADD = $(webkit_tests_ldadd) Programs_unittests_testatkroles_LDFLAGS = $(webkit_tests_ldflags) +Programs_unittests_testwebinspector_SOURCES = Source/WebKit/gtk/tests/testwebinspector.c Source/WebKit/gtk/tests/test_utils.c +Programs_unittests_testwebinspector_CFLAGS = $(webkit_tests_cflags) +Programs_unittests_testwebinspector_LDADD = $(webkit_tests_ldadd) +Programs_unittests_testwebinspector_LDFLAGS = $(webkit_tests_ldflags) + Programs_unittests_testwebsettings_SOURCES = Source/WebKit/gtk/tests/testwebsettings.c Programs_unittests_testwebsettings_CFLAGS = $(webkit_tests_cflags) Programs_unittests_testwebsettings_LDADD = $(webkit_tests_ldadd) diff --git a/Source/WebKit/gtk/NEWS b/Source/WebKit/gtk/NEWS index 94096480d..0aa4791e7 100644 --- a/Source/WebKit/gtk/NEWS +++ b/Source/WebKit/gtk/NEWS @@ -1,4 +1,34 @@ ================= +WebKitGTK+ 1.7.5 +================= + +What's new in WebKitGTK+ 1.7.5? + + - Add new signals to track resources loading. + - Add --no-timeout command line option to DumpRenderTree. + - Expose accessibility hierarchy in WebKit2 to ATK/AT-SPI based ATs. + - Allow to build using extra jhbuild modulesets. + - Fix emission of ATK text-caret-moved and text-selection-changed + events. + - Update primary clipboard with the current selection in X11 + platforms in WebKit2. + - Implement the policy client in WebKit2 GTK+ API. + - Add basic printing support to WebKit2. + - Do not add unnecessary blanks at the end of a line of text to fix. + the line returned by atk_text_get_text_at_offset(). + - Make sure input text field is repainted when value is changed. + - Add print-backgrounds setting to WebKit2 GTK+ API. + - Respect the has-backward-stepper and has-forward-stepper + properties when drawing scrollbars. + - WebKit-3.0.gir now includes information about C includes or + exported packages. + - WebKit1 API documentation was not generated when building with + gtk-2.0. + - Make WebKitWebView work inside a GtkOffscreenWindow. + - Implement DownloadClient and add downloads API to WebKit2 GTK+ + API. + +================= WebKitGTK+ 1.7.4 ================= diff --git a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h index 61c23b70c..42a5f24b6 100644 --- a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h +++ b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h @@ -19,6 +19,7 @@ #ifndef AcceleratedCompositingContext_h #define AcceleratedCompositingContext_h +#include "GraphicsLayer.h" #include "GraphicsLayerClient.h" #include "IntRect.h" #include "IntSize.h" @@ -26,15 +27,16 @@ #include "webkitwebview.h" #include <wtf/PassOwnPtr.h> -#if USE(ACCELERATED_COMPOSITING) +#if USE(TEXTURE_MAPPER_GL) +#include "TextureMapperNode.h" +#include "WindowGLContext.h" +#endif -namespace WebCore { -class GraphicsLayer; -} +#if USE(ACCELERATED_COMPOSITING) namespace WebKit { -class AcceleratedCompositingContext { +class AcceleratedCompositingContext : public WebCore::GraphicsLayerClient { WTF_MAKE_NONCOPYABLE(AcceleratedCompositingContext); public: static PassOwnPtr<AcceleratedCompositingContext> create(WebKitWebView* webView) @@ -47,7 +49,17 @@ public: void scheduleRootLayerRepaint(const WebCore::IntRect&); void markForSync(); void syncLayersTimeout(WebCore::Timer<AcceleratedCompositingContext>*); + void syncLayersNow(); void resizeRootLayer(const WebCore::IntSize&); + bool renderLayersToWindow(const WebCore::IntRect& clipRect); + bool enabled(); + + // GraphicsLayerClient + virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); + virtual void notifySyncRequired(const WebCore::GraphicsLayer*); + virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& rectToPaint); + virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const; + virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const; private: WebKitWebView* m_webView; @@ -56,6 +68,13 @@ private: #if USE(CLUTTER) GtkWidget* m_rootLayerEmbedder; +#elif USE(TEXTURE_MAPPER_GL) + void initializeIfNecessary(); + + bool m_initialized; + WebCore::TextureMapperNode* m_rootTextureMapperNode; + OwnPtr<WebCore::WindowGLContext> m_context; + OwnPtr<WebCore::TextureMapper> m_textureMapper; #endif AcceleratedCompositingContext(WebKitWebView*); diff --git a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextClutter.cpp b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextClutter.cpp index 4657ec43f..b52b409e5 100644 --- a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextClutter.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextClutter.cpp @@ -45,6 +45,11 @@ AcceleratedCompositingContext::~AcceleratedCompositingContext() { } +bool AcceleratedCompositingContext::enabled() +{ + return m_rootGraphicsLayer; +} + bool AcceleratedCompositingContext::renderLayersToWindow(cairo_t* widgetCr, const IntRect& clipRect) { notImplemented(); @@ -116,6 +121,32 @@ void AcceleratedCompositingContext::syncLayersTimeout(Timer<AcceleratedCompositi core(m_webView)->mainFrame()->view()->syncCompositingStateIncludingSubframes(); } +void AcceleratedCompositingContext::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) +{ + ASSERT_NOT_REACHED(); +} +void AcceleratedCompositingContext::notifySyncRequired(const WebCore::GraphicsLayer*) +{ + ASSERT_NOT_REACHED(); +} + +void AcceleratedCompositingContext::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) +{ + ASSERT_NOT_REACHED(); +} + +bool AcceleratedCompositingContext::showDebugBorders(const WebCore::GraphicsLayer*) const +{ + ASSERT_NOT_REACHED(); + return false; +} + +bool AcceleratedCompositingContext::showRepaintCounter(const WebCore::GraphicsLayer*) const +{ + ASSERT_NOT_REACHED(); + return false; +} + } // namespace WebKit #endif // USE(ACCELERATED_COMPOSITING) && USE(CLUTTER) diff --git a/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp new file mode 100644 index 000000000..9bfa3d0fe --- /dev/null +++ b/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2012 Igalia, S.L. + * + * 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" +#include "AcceleratedCompositingContext.h" + +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) + +#include "CairoUtilities.h" +#include "Chrome.h" +#include "ChromeClientGtk.h" +#include "Frame.h" +#include "FrameView.h" +#include "PlatformContextCairo.h" +#include "TextureMapperGL.h" +#include "TextureMapperNode.h" +#include "webkitwebviewprivate.h" +#include <GL/gl.h> +#include <cairo.h> +#include <gdk/gdk.h> +#include <gtk/gtk.h> + +using namespace WebCore; + +namespace WebKit { + +AcceleratedCompositingContext::AcceleratedCompositingContext(WebKitWebView* webView) + : m_webView(webView) + , m_syncTimer(this, &AcceleratedCompositingContext::syncLayersTimeout) + , m_initialized(false) + , m_rootTextureMapperNode(0) +{ +} + +AcceleratedCompositingContext::~AcceleratedCompositingContext() +{ + +} + +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_rootTextureMapperNode && m_textureMapper; +} + + +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) + return false; + + m_context->startDrawing(); + + GtkAllocation allocation; + gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation); + glViewport(0, 0, allocation.width, allocation.height); + + m_textureMapper->beginPainting(); + m_rootTextureMapperNode->paint(); + m_textureMapper->endPainting(); + + m_context->finishDrawing(); + return true; +} + +void AcceleratedCompositingContext::attachRootGraphicsLayer(GraphicsLayer* graphicsLayer) +{ + if (!graphicsLayer) { + m_rootGraphicsLayer.clear(); + m_rootTextureMapperNode = 0; + return; + } + + m_rootGraphicsLayer = GraphicsLayer::create(this); + m_rootTextureMapperNode = toTextureMapperNode(m_rootGraphicsLayer.get()); + m_rootGraphicsLayer->addChild(graphicsLayer); + m_rootGraphicsLayer->setDrawsContent(true); + m_rootGraphicsLayer->setMasksToBounds(false); + 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) + 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(); + + GtkAllocation allocation; + gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation); + glViewport(0, 0, allocation.width, allocation.height); + + m_textureMapper = TextureMapperGL::create(); + m_rootTextureMapperNode->setTextureMapper(m_textureMapper.get()); + m_rootGraphicsLayer->syncCompositingStateForThisLayerOnly(); +} + +void AcceleratedCompositingContext::scheduleRootLayerRepaint(const IntRect& rect) +{ + if (!m_rootGraphicsLayer) + return; + if (rect.isEmpty()) { + m_rootGraphicsLayer->setNeedsDisplay(); + return; + } + m_rootGraphicsLayer->setNeedsDisplayInRect(rect); +} + +void AcceleratedCompositingContext::resizeRootLayer(const IntSize& size) +{ + if (!m_rootGraphicsLayer) + return; + m_rootGraphicsLayer->setSize(size); + m_rootGraphicsLayer->setNeedsDisplay(); +} + +void AcceleratedCompositingContext::markForSync() +{ + if (m_syncTimer.isActive()) + return; + m_syncTimer.startOneShot(0); +} + +void AcceleratedCompositingContext::syncLayersNow() +{ + if (m_rootGraphicsLayer) + m_rootGraphicsLayer->syncCompositingStateForThisLayerOnly(); + + core(m_webView)->mainFrame()->view()->syncCompositingStateIncludingSubframes(); +} + +void AcceleratedCompositingContext::syncLayersTimeout(Timer<AcceleratedCompositingContext>*) +{ + syncLayersNow(); + if (!m_rootGraphicsLayer) + return; + + renderLayersToWindow(IntRect()); + + if (toTextureMapperNode(m_rootGraphicsLayer.get())->descendantsOrSelfHaveRunningAnimations()) + m_syncTimer.startOneShot(1.0 / 60.0); +} + +void AcceleratedCompositingContext::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) +{ + +} +void AcceleratedCompositingContext::notifySyncRequired(const WebCore::GraphicsLayer*) +{ + +} + +void AcceleratedCompositingContext::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& rectToPaint) +{ + cairo_t* cr = context.platformContext()->cr(); + copyRectFromCairoSurfaceToContext(m_webView->priv->backingStore->cairoSurface(), cr, + IntSize(), rectToPaint); +} + +bool AcceleratedCompositingContext::showDebugBorders(const WebCore::GraphicsLayer*) const +{ + return false; +} + +bool AcceleratedCompositingContext::showRepaintCounter(const WebCore::GraphicsLayer*) const +{ + return false; +} + +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) diff --git a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp index 137b918ad..955c166a9 100644 --- a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp @@ -525,6 +525,20 @@ static void paintWebView(WebKitWebView* webView, Frame* frame, Region dirtyRegio gc.restore(); } +void ChromeClient::invalidateWidgetRect(const IntRect& rect) +{ +#if USE(ACCELERATED_COMPOSITING) + AcceleratedCompositingContext* acContext = m_webView->priv->acceleratedCompositingContext.get(); + if (acContext->enabled()) { + acContext->scheduleRootLayerRepaint(rect); + return; + } +#endif + gtk_widget_queue_draw_area(GTK_WIDGET(m_webView), + rect.x(), rect.y(), + rect.width(), rect.height()); +} + void ChromeClient::performAllPendingScrolls() { if (!m_webView->priv->backingStore) @@ -534,16 +548,13 @@ void ChromeClient::performAllPendingScrolls() for (size_t i = 0; i < m_rectsToScroll.size(); i++) { IntRect& scrollRect = m_rectsToScroll[i]; m_webView->priv->backingStore->scroll(scrollRect, m_scrollOffsets[i]); - gtk_widget_queue_draw_area(GTK_WIDGET(m_webView), - scrollRect.x(), scrollRect.y(), - scrollRect.width(), scrollRect.height()); + invalidateWidgetRect(scrollRect); } m_rectsToScroll.clear(); m_scrollOffsets.clear(); } - void ChromeClient::paint(WebCore::Timer<ChromeClient>*) { static const double minimumFrameInterval = 1.0 / 60.0; // No more than 60 frames a second. @@ -559,13 +570,10 @@ void ChromeClient::paint(WebCore::Timer<ChromeClient>*) if (!frame || !frame->contentRenderer() || !frame->view()) return; - performAllPendingScrolls(); frame->view()->updateLayoutAndStyleIfNeededRecursive(); + performAllPendingScrolls(); paintWebView(m_webView, frame, m_dirtyRegion); - const IntRect& rect = m_dirtyRegion.bounds(); - gtk_widget_queue_draw_area(GTK_WIDGET(m_webView), rect.x(), rect.y(), rect.width(), rect.height()); - HashSet<GtkWidget*> children = m_webView->priv->children; HashSet<GtkWidget*>::const_iterator end = children.end(); for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current) { @@ -575,6 +583,14 @@ void ChromeClient::paint(WebCore::Timer<ChromeClient>*) } } + const IntRect& rect = m_dirtyRegion.bounds(); + invalidateWidgetRect(rect); + +#if USE(ACCELERATED_COMPOSITING) + m_webView->priv->acceleratedCompositingContext->syncLayersNow(); + m_webView->priv->acceleratedCompositingContext->renderLayersToWindow(rect); +#endif + m_dirtyRegion = Region(); m_lastDisplayTime = currentTime(); m_repaintSoonSourceId = 0; @@ -829,6 +845,9 @@ void ChromeClient::setCursor(const Cursor& cursor) // Setting the cursor may be an expensive operation in some backends, // so don't re-set the cursor if it's already set to the target value. GdkWindow* window = gtk_widget_get_window(platformPageClient()); + if (!window) + return; + GdkCursor* currentCursor = gdk_window_get_cursor(window); GdkCursor* newCursor = cursor.platformCursor().get(); if (currentCursor != newCursor) diff --git a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h index 932224f04..8c7c89233 100644 --- a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h +++ b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h @@ -182,7 +182,9 @@ namespace WebKit { Vector<IntRect> m_rectsToScroll; Vector<IntSize> m_scrollOffsets; double m_lastDisplayTime; - uint m_repaintSoonSourceId; + unsigned int m_repaintSoonSourceId; + + void invalidateWidgetRect(const IntRect&); }; } diff --git a/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp index 2e55ca3cb..d4d321d93 100644 --- a/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Gustavo Noronha Silva + * Copyright (C) 2008, 2012 Gustavo Noronha Silva * Copyright (C) 2010 Collabora Ltd. * * This library is free software; you can redistribute it and/or @@ -171,6 +171,7 @@ void InspectorClient::bringFrontendToFront() void InspectorClient::releaseFrontendPage() { m_frontendPage = 0; + m_frontendClient = 0; } void InspectorClient::highlight() @@ -220,9 +221,10 @@ InspectorFrontendClient::InspectorFrontendClient(WebKitWebView* inspectedWebView InspectorFrontendClient::~InspectorFrontendClient() { if (m_inspectorClient) { - m_inspectorClient->disconnectFrontendClient(); + m_inspectorClient->releaseFrontendPage(); m_inspectorClient = 0; } + ASSERT(!m_webInspector); } @@ -230,11 +232,13 @@ void InspectorFrontendClient::destroyInspectorWindow(bool notifyInspectorControl { if (!m_webInspector) return; - WebKitWebInspector* webInspector = m_webInspector; - m_webInspector = 0; - g_signal_handlers_disconnect_by_func(m_inspectorWebView, (gpointer)notifyWebViewDestroyed, (gpointer)this); - m_inspectorWebView = 0; + GRefPtr<WebKitWebInspector> webInspector = adoptGRef(m_webInspector.leakRef()); + + if (m_inspectorWebView) { + g_signal_handlers_disconnect_by_func(m_inspectorWebView, reinterpret_cast<gpointer>(notifyWebViewDestroyed), this); + m_inspectorWebView = 0; + } if (notifyInspectorController) core(m_inspectedWebView)->inspectorController()->disconnectFrontend(); @@ -243,14 +247,11 @@ void InspectorFrontendClient::destroyInspectorWindow(bool notifyInspectorControl m_inspectorClient->releaseFrontendPage(); gboolean handled = FALSE; - g_signal_emit_by_name(webInspector, "close-window", &handled); + g_signal_emit_by_name(webInspector.get(), "close-window", &handled); ASSERT(handled); // Please do not use member variables here because InspectorFrontendClient object pointed by 'this' // has been implicitly deleted by "close-window" function. - - /* we should now dispose our own reference */ - g_object_unref(webInspector); } String InspectorFrontendClient::localizedStringsURL() @@ -274,7 +275,7 @@ void InspectorFrontendClient::bringToFront() return; gboolean handled = FALSE; - g_signal_emit_by_name(m_webInspector, "show-window", &handled); + g_signal_emit_by_name(m_webInspector.get(), "show-window", &handled); } void InspectorFrontendClient::closeWindow() @@ -288,7 +289,7 @@ void InspectorFrontendClient::attachWindow() return; gboolean handled = FALSE; - g_signal_emit_by_name(m_webInspector, "attach-window", &handled); + g_signal_emit_by_name(m_webInspector.get(), "attach-window", &handled); } void InspectorFrontendClient::detachWindow() @@ -297,7 +298,7 @@ void InspectorFrontendClient::detachWindow() return; gboolean handled = FALSE; - g_signal_emit_by_name(m_webInspector, "detach-window", &handled); + g_signal_emit_by_name(m_webInspector.get(), "detach-window", &handled); } void InspectorFrontendClient::setAttachedWindowHeight(unsigned height) @@ -310,7 +311,7 @@ void InspectorFrontendClient::inspectedURLChanged(const String& newURL) if (!m_inspectorWebView) return; - webkit_web_inspector_set_inspected_uri(m_webInspector, newURL.utf8().data()); + webkit_web_inspector_set_inspected_uri(m_webInspector.get(), newURL.utf8().data()); } } diff --git a/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h b/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h index c692e8f19..db558f096 100644 --- a/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h +++ b/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h @@ -30,6 +30,7 @@ #define InspectorClientGtk_h #include "GOwnPtr.h" +#include "GRefPtr.h" #include "InspectorClient.h" #include "InspectorFrontendClientLocal.h" #include "webkitwebview.h" @@ -98,7 +99,7 @@ namespace WebKit { private: WebKitWebView* m_inspectorWebView; WebKitWebView* m_inspectedWebView; - WebKitWebInspector* m_webInspector; + GRefPtr<WebKitWebInspector> m_webInspector; InspectorClient* m_inspectorClient; }; } diff --git a/Source/WebKit/gtk/docs/webkitgtk-docs.sgml b/Source/WebKit/gtk/docs/webkitgtk-docs.sgml index 3a7d35d44..3ad0fae10 100644 --- a/Source/WebKit/gtk/docs/webkitgtk-docs.sgml +++ b/Source/WebKit/gtk/docs/webkitgtk-docs.sgml @@ -40,7 +40,6 @@ <xi:include href="xml/webkitwebwindowfeatures.xml"/> <xi:include href="xml/webkiticondatabase.xml"/> <xi:include href="xml/webkitspellchecker.xml"/> - <xi:include href="xml/webkitspellcheckerenchant.xml"/> </chapter> <chapter> diff --git a/Source/WebKit/gtk/docs/webkitgtk-sections.txt b/Source/WebKit/gtk/docs/webkitgtk-sections.txt index a72aef726..4a358e83d 100644 --- a/Source/WebKit/gtk/docs/webkitgtk-sections.txt +++ b/Source/WebKit/gtk/docs/webkitgtk-sections.txt @@ -292,6 +292,7 @@ WebKitWebInspectorClass <FILE>webkitwebnavigationaction</FILE> <TITLE>WebKitWebNavigationAction</TITLE> WebKitWebNavigationAction +WebKitWebNavigationReason webkit_web_navigation_action_get_button webkit_web_navigation_action_get_modifier_state webkit_web_navigation_action_get_original_uri @@ -307,7 +308,6 @@ WEBKIT_WEB_NAVIGATION_ACTION WEBKIT_WEB_NAVIGATION_ACTION_CLASS WEBKIT_WEB_NAVIGATION_ACTION_GET_CLASS <SUBSECTION Private> -WebKitWebNavigationReason WebKitWebNavigationActionClass WebKitWebNavigationActionPrivate webkit_web_navigation_action_get_type @@ -639,23 +639,6 @@ webkit_spell_checker_get_type </SECTION> <SECTION> -<FILE>webkitspellcheckerenchant</FILE> -<TITLE>WebKitSpellCheckerEnchant</TITLE> -<SUBSECTION Standard> -WEBKIT_IS_SPELL_CHECKER_ENCHANT -WEBKIT_IS_SPELL_CHECKER_ENCHANT_CLASS -WEBKIT_SPELL_CHECKER_ENCHANT -WEBKIT_SPELL_CHECKER_ENCHANT_CLASS -WEBKIT_SPELL_CHECKER_ENCHANT_GET_CLASS -WEBKIT_TYPE_SPELL_CHECKER_ENCHANT -<SUBSECTION Private> -WebKitSpellCheckerEnchant -WebKitSpellCheckerEnchantClass -WebKitSpellCheckerEnchantPrivate -webkit_spell_checker_enchant_get_type -</SECTION> - -<SECTION> <FILE>webkiterror</FILE> WEBKIT_NETWORK_ERROR WEBKIT_PLUGIN_ERROR diff --git a/Source/WebKit/gtk/tests/test_utils.c b/Source/WebKit/gtk/tests/test_utils.c index 360a15b2a..6bb645d0d 100644 --- a/Source/WebKit/gtk/tests/test_utils.c +++ b/Source/WebKit/gtk/tests/test_utils.c @@ -29,10 +29,8 @@ int testutils_relative_chdir(const gchar *targetFilename, const gchar *executabl if (repoPath) { if (g_chdir(repoPath)) return -1; - } else if (g_path_is_absolute(executablePath)) { - if (g_chdir(g_path_get_dirname(executablePath))) + } else if (g_chdir(g_path_get_dirname(executablePath))) return -1; - } while (!g_file_test(targetFilename, G_FILE_TEST_EXISTS)) { gchar *pathName; diff --git a/Source/WebKit/gtk/tests/testatk.c b/Source/WebKit/gtk/tests/testatk.c index a79010175..60c27942b 100644 --- a/Source/WebKit/gtk/tests/testatk.c +++ b/Source/WebKit/gtk/tests/testatk.c @@ -35,7 +35,7 @@ static const char* contentsWithNewlines = "<html><body><p>This is a test. \n\nTh static const char* contentsWithPreformattedText = "<html><body><pre>\n\t\n\tfirst line\n\tsecond line\n</pre></body></html>"; -static const char* contentsWithSpecialChars = "<html><body><p>« This is a paragraph with “special” characters inside. »</p></body></html>"; +static const char* contentsWithSpecialChars = "<html><body><p>« This is a paragraph with “special” characters inside. »</p><ul><li style='max-width:100px;'>List item with some text that wraps across different lines.</li></ul></body></html>"; static const char* contentsInTextarea = "<html><body><textarea cols='80'>This is a test. This is the second sentence. And this the third.</textarea></body></html>"; @@ -810,23 +810,44 @@ static void testWebkitAtkGetTextAtOffsetWithSpecialCharacters() /* Get to the inner AtkText object. */ AtkObject* object = getWebAreaObject(webView); g_assert(object); - object = atk_object_ref_accessible_child(object, 0); - g_assert(object); - AtkText* textObject = ATK_TEXT(object); - g_assert(ATK_IS_TEXT(textObject)); + AtkObject* paragraph = atk_object_ref_accessible_child(object, 0); + g_assert(ATK_IS_TEXT(paragraph)); - const gchar* expectedText = "\302\253\302\240This is a paragraph with \342\200\234special\342\200\235 characters inside.\302\240\302\273"; - char* text = atk_text_get_text(textObject, 0, -1); + gchar* expectedText = g_strdup("\302\253\302\240This is a paragraph with \342\200\234special\342\200\235 characters inside.\302\240\302\273"); + char* text = atk_text_get_text(ATK_TEXT(paragraph), 0, -1); g_assert_cmpstr(text, ==, expectedText); g_free(text); /* Check that getting the text with ATK_TEXT_BOUNDARY_LINE_START and ATK_TEXT_BOUNDARY_LINE_END does not crash because of not properly handling characters inside the UTF-8 string. */ - testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 0, expectedText, 0, 57); - testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 0, expectedText, 0, 57); + testGetTextFunction(ATK_TEXT(paragraph), atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 0, expectedText, 0, 57); + testGetTextFunction(ATK_TEXT(paragraph), atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 0, expectedText, 0, 57); + g_free(expectedText); + + AtkObject* list = atk_object_ref_accessible_child(object, 1); + g_assert(ATK_OBJECT(list)); + + AtkText* listItem = ATK_TEXT(atk_object_ref_accessible_child(list, 0)); + g_assert(ATK_IS_TEXT(listItem)); + + text = atk_text_get_text(ATK_TEXT(listItem), 0, -1); + g_assert_cmpstr(text, ==, "\342\200\242 List item with some text that wraps across different lines."); + g_free(text); + /* Check that getting the text with ATK_TEXT_BOUNDARY_LINE_START + and ATK_TEXT_BOUNDARY_LINE_END for line items with bullets + (special character) and wrapped text always return the right + piece of text for each line. */ + testGetTextFunction(ATK_TEXT(listItem), atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 3, "\342\200\242 List item ", 0, 12); + testGetTextFunction(ATK_TEXT(listItem), atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 13, "with some ", 12, 22); + testGetTextFunction(ATK_TEXT(listItem), atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 0, "\342\200\242 List item", 0, 11); + testGetTextFunction(ATK_TEXT(listItem), atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 12, " with some", 11, 21); + + g_object_unref(list); + g_object_unref(listItem); + g_object_unref(paragraph); g_object_unref(webView); } diff --git a/Source/WebKit/gtk/tests/testwebinspector.c b/Source/WebKit/gtk/tests/testwebinspector.c new file mode 100644 index 000000000..40aa55334 --- /dev/null +++ b/Source/WebKit/gtk/tests/testwebinspector.c @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2012 Gustavo Noronha Silva <gns@gnome.org> + * + * 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 "test_utils.h" + +#include <string.h> +#include <glib.h> +#include <gtk/gtk.h> +#include <webkit/webkit.h> + +#if GTK_CHECK_VERSION(2, 14, 0) + +GMainLoop *loop; +GtkWidget *window; + +static gboolean quitLoop(gpointer data) +{ + g_main_loop_quit(loop); + return TRUE; +} + +/* Ignore simple translation-related messages and upgrade other + * messages to warnings. + */ +static gboolean consoleMessageCallback(WebKitWebView* webView, const char* message, unsigned int line, const char* sourceId) +{ + if (strstr(message, "Localized string") || strstr(message, "Protocol Error: the message is for non-existing domain 'Profiler'")) + return TRUE; + + g_warning("Console: %s @%d: %s\n", sourceId, line, message); + return TRUE; +} + +static WebKitWebView* inspectElementCallback(WebKitWebInspector *inspector, WebKitWebView *inspectedWebView, int *timesElementInspected) +{ + *timesElementInspected = *timesElementInspected + 1; + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + GtkWidget *newWebView = webkit_web_view_new(); + gtk_container_add(GTK_CONTAINER(window), newWebView); + + g_signal_connect(newWebView, "console-message", + G_CALLBACK(consoleMessageCallback), NULL); + + return WEBKIT_WEB_VIEW(newWebView); +} + +static gboolean closeInspector (WebKitWebInspector *inspector, int *timesClosed) +{ + *timesClosed = *timesClosed + 1; + + gtk_widget_destroy(window); + return TRUE; +} + +static gboolean showInspector (WebKitWebInspector *inspector, gpointer data) +{ + g_idle_add(quitLoop, NULL); + return TRUE; +} + +static void test_webkit_web_inspector_close_and_inspect() +{ + WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + + 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://"); + + WebKitWebInspector *inspector = webkit_web_view_get_inspector(webView); + + int timesElementInspected = 0; + int timesClosed = 0; + g_object_connect(inspector, + "signal::inspect-web-view", G_CALLBACK(inspectElementCallback), ×ElementInspected, + "signal::show-window", G_CALLBACK(showInspector), NULL, + "signal::close-window", G_CALLBACK(closeInspector), ×Closed, + NULL); + + 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); + g_assert_cmpint(timesClosed, ==, 1); + + webkit_web_inspector_inspect_coordinates(inspector, 0.0, 0.0); + g_assert_cmpint(timesElementInspected, ==, 2); + + g_main_loop_run(loop); + + gtk_widget_destroy(GTK_WIDGET(webView)); + g_assert_cmpint(timesClosed, ==, 2); + + g_main_loop_unref(loop); +} + +static void test_webkit_web_inspector_destroy_inspected_web_view() +{ + WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + + 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://"); + + WebKitWebInspector *inspector = webkit_web_view_get_inspector(webView); + + int timesElementInspected = 0; + int timesClosed = 0; + g_object_connect(inspector, + "signal::inspect-web-view", G_CALLBACK(inspectElementCallback), ×ElementInspected, + "signal::show-window", G_CALLBACK(showInspector), NULL, + "signal::close-window", G_CALLBACK(closeInspector), ×Closed, + NULL); + + 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)); + g_assert_cmpint(timesClosed, ==, 1); + + g_main_loop_unref(loop); +} + +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 (); +} + +#else +int main(int argc, char** argv) +{ + g_critical("You will need gtk-2.14.0 to run the unit tests. Doing nothing now."); + return 0; +} + +#endif diff --git a/Source/WebKit/gtk/webkit/webkitwebnavigationaction.h b/Source/WebKit/gtk/webkit/webkitwebnavigationaction.h index 4d8582e38..b317749f2 100644 --- a/Source/WebKit/gtk/webkit/webkitwebnavigationaction.h +++ b/Source/WebKit/gtk/webkit/webkitwebnavigationaction.h @@ -26,9 +26,16 @@ G_BEGIN_DECLS -/* - * The order of this enum must be the same as NavigationType in - * FrameLoaderTypes.h +/** + * WebKitWebNavigationReason: + * @WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED: The navigation was triggered by clicking a link. + * @WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED: The navigation was triggered by submitting a form. + * @WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD: The navigation was triggered by navigating forward or backward. + * @WEBKIT_WEB_NAVIGATION_REASON_RELOAD: The navigation was triggered by reloading. + * @WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED: The navigation was triggered by resubmitting a form. + * @WEBKIT_WEB_NAVIGATION_REASON_OTHER: The navigation was triggered by some other action. + * + * Enum values used to denote the various navigation reasons. */ typedef enum { WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED, diff --git a/Source/WebKit/gtk/webkit/webkitwebsettings.cpp b/Source/WebKit/gtk/webkit/webkitwebsettings.cpp index 6b260c29a..d91c3bbf3 100644 --- a/Source/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -119,7 +119,8 @@ enum { PROP_ENABLE_FULLSCREEN, PROP_ENABLE_DNS_PREFETCHING, PROP_ENABLE_WEBGL, - PROP_ENABLE_WEB_AUDIO + PROP_ENABLE_WEB_AUDIO, + PROP_ENABLE_ACCELERATED_COMPOSITING }; // Create a default user agent string @@ -899,6 +900,23 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) _("Whether WebGL content should be rendered"), FALSE, flags)); + + /** + * WebKitWebSettings:enable-accelerated-compositing: + * + * Enable or disable support for accelerated compositing on pages. Accelerated + * compositing uses the GPU to render animations on pages smoothly and also allows + * proper rendering of 3D CSS transforms. + * + * Since: 1.7.5 + */ + g_object_class_install_property(gobject_class, + PROP_ENABLE_ACCELERATED_COMPOSITING, + g_param_spec_boolean("enable-accelerated-compositing", + _("Enable accelerated compositing"), + _("Whether accelerated compositing should be enabled"), + FALSE, + flags)); /** * WebKitWebSettings:enable-webaudio: * @@ -1107,6 +1125,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_ENABLE_WEB_AUDIO: priv->enableWebAudio = g_value_get_boolean(value); break; + case PROP_ENABLE_ACCELERATED_COMPOSITING: + priv->enableAcceleratedCompositing = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1269,6 +1290,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_ENABLE_WEB_AUDIO: g_value_set_boolean(value, priv->enableWebAudio); break; + case PROP_ENABLE_ACCELERATED_COMPOSITING: + g_value_set_boolean(value, priv->enableAcceleratedCompositing); + 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 823c36ec9..d7d082e5b 100644 --- a/Source/WebKit/gtk/webkit/webkitwebsettingsprivate.h +++ b/Source/WebKit/gtk/webkit/webkitwebsettingsprivate.h @@ -79,6 +79,7 @@ struct _WebKitWebSettingsPrivate { gboolean enableDNSPrefetching; gboolean enableWebgl; gboolean enableWebAudio; + gboolean enableAcceleratedCompositing; }; 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 ac6158b44..c22461c74 100644 --- a/Source/WebKit/gtk/webkit/webkitwebview.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebview.cpp @@ -648,6 +648,12 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr) if (!gdk_cairo_get_clip_rectangle(cr, &clipRect)) return FALSE; + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv; +#if USE(TEXTURE_MAPPER_GL) + if (priv->acceleratedCompositingContext->renderLayersToWindow(clipRect)) + return FALSE; +#endif + cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr); if (rectList->status || !rectList->num_rectangles) { cairo_rectangle_list_destroy(rectList); @@ -656,8 +662,8 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr) Vector<IntRect> rects; for (int i = 0; i < rectList->num_rectangles; i++) { - copyRectFromCairoSurfaceToContext(WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface(), - cr, IntSize(), enclosingIntRect(FloatRect(rectList->rectangles[i]))); + copyRectFromCairoSurfaceToContext(priv->backingStore->cairoSurface(), cr, IntSize(), + enclosingIntRect(FloatRect(rectList->rectangles[i]))); } cairo_rectangle_list_destroy(rectList); @@ -859,28 +865,52 @@ static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*) *allocation = IntRect(); } -static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation) +static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation) { - GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation); - - Page* page = core(WEBKIT_WEB_VIEW(widget)); + Page* page = core(webView); IntSize oldSize; if (FrameView* frameView = page->mainFrame()->view()) { oldSize = frameView->size(); frameView->resize(allocation->width, allocation->height); } - gtk_container_forall(GTK_CONTAINER(widget), updateChildAllocationFromPendingAllocation, 0); + gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0); WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome()->client()); chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height)); chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars(); #if USE(ACCELERATED_COMPOSITING) - WEBKIT_WEB_VIEW(widget)->priv->acceleratedCompositingContext->resizeRootLayer(IntSize(allocation->width, allocation->height)); + webView->priv->acceleratedCompositingContext->resizeRootLayer(IntSize(allocation->width, allocation->height)); #endif } +static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation) +{ + GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation); + + WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + if (!gtk_widget_get_mapped(widget)) { + webView->priv->needsResizeOnMap = true; + return; + } + resizeWebViewFromAllocation(webView, allocation); +} + +static void webkitWebViewMap(GtkWidget* widget) +{ + GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget); + + WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + if (!webView->priv->needsResizeOnMap) + return; + + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + resizeWebViewFromAllocation(webView, &allocation); + webView->priv->needsResizeOnMap = false; +} + static void webkit_web_view_grab_focus(GtkWidget* widget) { @@ -941,6 +971,8 @@ static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus static void webkit_web_view_realize(GtkWidget* widget) { + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv; + gtk_widget_set_realized(widget, TRUE); GtkAllocation allocation; @@ -979,6 +1011,10 @@ static void webkit_web_view_realize(GtkWidget* widget) attributes_mask |= GDK_WA_COLORMAP; #endif GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); + +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) + priv->hasNativeWindow = gdk_window_ensure_native(window); +#endif gtk_widget_set_window(widget, window); gdk_window_set_user_data(window, widget); @@ -993,8 +1029,6 @@ static void webkit_web_view_realize(GtkWidget* widget) gtk_style_context_set_background(gtk_widget_get_style_context(widget), window); #endif - WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); - WebKitWebViewPrivate* priv = webView->priv; gtk_im_context_set_client_window(priv->imContext.get(), window); } @@ -2767,6 +2801,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) widgetClass->query_tooltip = webkit_web_view_query_tooltip; widgetClass->show_help = webkit_web_view_show_help; #endif + widgetClass->map = webkitWebViewMap; GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass); containerClass->add = webkit_web_view_container_add; @@ -3211,6 +3246,10 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) coreSettings->setWebGLEnabled(settingsPrivate->enableWebgl); #endif +#if USE(ACCELERATED_COMPOSITING) + coreSettings->setAcceleratedCompositingEnabled(settingsPrivate->enableAcceleratedCompositing); +#endif + #if ENABLE(WEB_AUDIO) coreSettings->setWebAudioEnabled(settingsPrivate->enableWebAudio); #endif @@ -3343,6 +3382,11 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar settings->setWebGLEnabled(g_value_get_boolean(&value)); #endif +#if USE(ACCELERATED_COMPOSITING) + else if (name == g_intern_string("enable-accelerated-compositing")) + settings->setAcceleratedCompositingEnabled(g_value_get_boolean(&value)); +#endif + #if ENABLE(WEB_AUDIO) else if (name == g_intern_string("enable-webaudio")) settings->setWebAudioEnabled(g_value_get_boolean(&value)); diff --git a/Source/WebKit/gtk/webkit/webkitwebviewprivate.h b/Source/WebKit/gtk/webkit/webkitwebviewprivate.h index 8d2b7b04b..75ba14cbe 100644 --- a/Source/WebKit/gtk/webkit/webkitwebviewprivate.h +++ b/Source/WebKit/gtk/webkit/webkitwebviewprivate.h @@ -44,6 +44,7 @@ extern "C" { typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; struct _WebKitWebViewPrivate { WebCore::Page* corePage; + bool hasNativeWindow; OwnPtr<WebCore::WidgetBackingStore> backingStore; GRefPtr<WebKitWebSettings> webSettings; GRefPtr<WebKitWebInspector> webInspector; @@ -61,6 +62,7 @@ struct _WebKitWebViewPrivate { GRefPtr<GtkIMContext> imContext; gboolean transparent; + bool needsResizeOnMap; #ifndef GTK_API_VERSION_2 // GtkScrollablePolicy needs to be checked when |