Log Message
Merge r246635 - [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
- releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog
- releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
- releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
- releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp
Diff
Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog (246982 => 246983)
--- releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog 2019-07-01 09:21:53 UTC (rev 246982)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog 2019-07-01 09:21:56 UTC (rev 246983)
@@ -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 Charlie Turner <[email protected]>
[GTK] Make startup pause available in DEVELOPER_MODE rather than DEBUG.
Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (246982 => 246983)
--- releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-07-01 09:21:53 UTC (rev 246982)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-07-01 09:21:56 UTC (rev 246983)
@@ -517,4 +517,13 @@
}
#endif
+UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
+{
+ GtkTextDirection direction = gtk_widget_get_direction(m_viewWidget);
+ if (direction == GTK_TEXT_DIR_RTL)
+ return UserInterfaceLayoutDirection::RTL;
+
+ return UserInterfaceLayoutDirection::LTR;
+}
+
} // namespace WebKit
Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (246982 => 246983)
--- releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2019-07-01 09:21:53 UTC (rev 246982)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2019-07-01 09:21:56 UTC (rev 246983)
@@ -152,7 +152,7 @@
bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override;
#endif
- WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
+ WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
// Members of PageClientImpl class
GtkWidget* m_viewWidget;
Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (246982 => 246983)
--- releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-07-01 09:21:53 UTC (rev 246982)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-07-01 09:21:56 UTC (rev 246983)
@@ -304,6 +304,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();
@@ -312,6 +314,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;
@@ -320,7 +324,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;
@@ -329,8 +333,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);
@@ -339,13 +346,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
