Log Message
[GTK] The Previous/Next gesture should handle RTL https://bugs.webkit.org/show_bug.cgi?id=198707
Patch by Alexander Mikhaylenko <[email protected]> on 2019-06-20 Reviewed by Michael Catanzaro. The gesture uses PageClientImpl::userInterfaceLayoutDirection() to determine the text direction. Implement that method, then adjust drawing so that the pages move from/to the left instead of right side for RTL locales. * UIProcess/API/gtk/PageClientImpl.cpp: (WebKit::): Implemented. * UIProcess/API/gtk/PageClientImpl.h: * UIProcess/gtk/ViewGestureControllerGtk.cpp: (WebKit::ViewGestureController::draw):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (246634 => 246635)
--- trunk/Source/WebKit/ChangeLog 2019-06-20 15:18:27 UTC (rev 246634)
+++ trunk/Source/WebKit/ChangeLog 2019-06-20 15:55:52 UTC (rev 246635)
@@ -1,3 +1,20 @@
+2019-06-20 Alexander Mikhaylenko <[email protected]>
+
+ [GTK] The Previous/Next gesture should handle RTL
+ https://bugs.webkit.org/show_bug.cgi?id=198707
+
+ Reviewed by Michael Catanzaro.
+
+ The gesture uses PageClientImpl::userInterfaceLayoutDirection() to determine the text
+ direction. Implement that method, then adjust drawing so that the pages move from/to
+ the left instead of right side for RTL locales.
+
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::): Implemented.
+ * UIProcess/API/gtk/PageClientImpl.h:
+ * UIProcess/gtk/ViewGestureControllerGtk.cpp:
+ (WebKit::ViewGestureController::draw):
+
2019-06-20 Carlos Garcia Campos <[email protected]>
[GTK] Remove support for GTK2 plugins
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (246634 => 246635)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-06-20 15:18:27 UTC (rev 246634)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-06-20 15:55:52 UTC (rev 246635)
@@ -538,6 +538,15 @@
completionHandler(WebCore::DOMPasteAccessResponse::DeniedForGesture);
}
+UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
+{
+ GtkTextDirection direction = gtk_widget_get_direction(m_viewWidget);
+ if (direction == GTK_TEXT_DIR_RTL)
+ return UserInterfaceLayoutDirection::RTL;
+
+ return UserInterfaceLayoutDirection::LTR;
+}
+
bool PageClientImpl::effectiveAppearanceIsDark() const
{
auto* settings = gtk_widget_get_settings(m_viewWidget);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (246634 => 246635)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2019-06-20 15:18:27 UTC (rev 246634)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2019-06-20 15:55:52 UTC (rev 246635)
@@ -161,7 +161,7 @@
bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override;
#endif
- WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
+ WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
bool effectiveAppearanceIsDark() const override;
Modified: trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (246634 => 246635)
--- trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-06-20 15:18:27 UTC (rev 246634)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-06-20 15:55:52 UTC (rev 246635)
@@ -328,6 +328,8 @@
void ViewGestureController::draw(cairo_t* cr, cairo_pattern_t* pageGroup)
{
bool swipingLeft = isPhysicallySwipingLeft(m_swipeProgressTracker.direction());
+ bool swipingBack = m_swipeProgressTracker.direction() == SwipeDirection::Back;
+ bool isRTL = m_webPageProxy.userInterfaceLayoutDirection() == WebCore::UserInterfaceLayoutDirection::RTL;
float progress = m_swipeProgressTracker.progress();
double width = m_webPageProxy.drawingArea()->size().width();
@@ -336,6 +338,8 @@
double swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress);
double dimmingProgress = swipingLeft ? 1 - progress : -progress;
+ if (isRTL)
+ dimmingProgress = 1 - dimmingProgress;
double remainingSwipeDistance = dimmingProgress * width;
double shadowFadeDistance = swipeOverlayShadowWidth;
@@ -344,7 +348,7 @@
if (remainingSwipeDistance < shadowFadeDistance)
shadowOpacity = (remainingSwipeDistance / shadowFadeDistance) * swipeOverlayShadowOpacity;
- RefPtr<cairo_pattern_t> shadowPattern = adoptRef(cairo_pattern_create_linear(0, 0, -swipeOverlayShadowWidth, 0));
+ RefPtr<cairo_pattern_t> shadowPattern = adoptRef(cairo_pattern_create_linear(0, 0, swipeOverlayShadowWidth, 0));
for (int i = 0; i < 16; i++) {
double offset = swipeOverlayShadowGradientOffsets[i];
double alpha = swipeOverlayShadowGradientAlpha[i] * shadowOpacity;
@@ -353,8 +357,11 @@
cairo_save(cr);
- cairo_rectangle(cr, 0, 0, swipingLayerOffset, height);
- cairo_set_source(cr, swipingLeft ? m_currentSwipeSnapshotPattern.get() : pageGroup);
+ if (isRTL)
+ cairo_rectangle(cr, swipingLayerOffset, 0, width - swipingLayerOffset, height);
+ else
+ cairo_rectangle(cr, 0, 0, swipingLayerOffset, height);
+ cairo_set_source(cr, swipingBack ? m_currentSwipeSnapshotPattern.get() : pageGroup);
cairo_fill_preserve(cr);
cairo_set_source_rgba(cr, 0, 0, 0, dimmingProgress * swipeOverlayDimmingOpacity);
@@ -363,13 +370,21 @@
cairo_translate(cr, swipingLayerOffset, 0);
if (progress) {
- cairo_rectangle(cr, -swipeOverlayShadowWidth, 0, swipeOverlayShadowWidth, height);
+ cairo_save(cr);
+ if (!isRTL)
+ cairo_scale(cr, -1, 1);
+ cairo_rectangle(cr, 0, 0, swipeOverlayShadowWidth, height);
cairo_set_source(cr, shadowPattern.get());
cairo_fill(cr);
+ cairo_restore(cr);
}
- cairo_rectangle(cr, 0, 0, width - swipingLayerOffset, height);
- cairo_set_source(cr, swipingLeft ? pageGroup : m_currentSwipeSnapshotPattern.get());
+ if (isRTL) {
+ cairo_translate(cr, -width, 0);
+ cairo_rectangle(cr, width - swipingLayerOffset, 0, swipingLayerOffset, height);
+ } else
+ cairo_rectangle(cr, 0, 0, width - swipingLayerOffset, height);
+ cairo_set_source(cr, swipingBack ? pageGroup : m_currentSwipeSnapshotPattern.get());
cairo_fill(cr);
cairo_restore(cr);
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
