Changeset 246635 in webkit


Ignore:
Timestamp:
Jun 20, 2019 8:55:52 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] The Previous/Next gesture should handle RTL
https://bugs.webkit.org/show_bug.cgi?id=198707

Patch by Alexander Mikhaylenko <exalm7659@gmail.com> 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):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246632 r246635  
     12019-06-20  Alexander Mikhaylenko  <exalm7659@gmail.com>
     2
     3        [GTK] The Previous/Next gesture should handle RTL
     4        https://bugs.webkit.org/show_bug.cgi?id=198707
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        The gesture uses PageClientImpl::userInterfaceLayoutDirection() to determine the text
     9        direction. Implement that method, then adjust drawing so that the pages move from/to
     10        the left instead of right side for RTL locales.
     11
     12        * UIProcess/API/gtk/PageClientImpl.cpp:
     13        (WebKit::): Implemented.
     14        * UIProcess/API/gtk/PageClientImpl.h:
     15        * UIProcess/gtk/ViewGestureControllerGtk.cpp:
     16        (WebKit::ViewGestureController::draw):
     17
    1182019-06-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp

    r246592 r246635  
    539539}
    540540
     541UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
     542{
     543    GtkTextDirection direction = gtk_widget_get_direction(m_viewWidget);
     544    if (direction == GTK_TEXT_DIR_RTL)
     545        return UserInterfaceLayoutDirection::RTL;
     546
     547    return UserInterfaceLayoutDirection::LTR;
     548}
     549
    541550bool PageClientImpl::effectiveAppearanceIsDark() const
    542551{
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h

    r246592 r246635  
    162162#endif
    163163
    164     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
     164    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
    165165
    166166    bool effectiveAppearanceIsDark() const override;
  • trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp

    r246496 r246635  
    329329{
    330330    bool swipingLeft = isPhysicallySwipingLeft(m_swipeProgressTracker.direction());
     331    bool swipingBack = m_swipeProgressTracker.direction() == SwipeDirection::Back;
     332    bool isRTL = m_webPageProxy.userInterfaceLayoutDirection() == WebCore::UserInterfaceLayoutDirection::RTL;
    331333    float progress = m_swipeProgressTracker.progress();
    332334
     
    337339
    338340    double dimmingProgress = swipingLeft ? 1 - progress : -progress;
     341    if (isRTL)
     342        dimmingProgress = 1 - dimmingProgress;
    339343
    340344    double remainingSwipeDistance = dimmingProgress * width;
     
    345349        shadowOpacity = (remainingSwipeDistance / shadowFadeDistance) * swipeOverlayShadowOpacity;
    346350
    347     RefPtr<cairo_pattern_t> shadowPattern = adoptRef(cairo_pattern_create_linear(0, 0, -swipeOverlayShadowWidth, 0));
     351    RefPtr<cairo_pattern_t> shadowPattern = adoptRef(cairo_pattern_create_linear(0, 0, swipeOverlayShadowWidth, 0));
    348352    for (int i = 0; i < 16; i++) {
    349353        double offset = swipeOverlayShadowGradientOffsets[i];
     
    354358    cairo_save(cr);
    355359
    356     cairo_rectangle(cr, 0, 0, swipingLayerOffset, height);
    357     cairo_set_source(cr, swipingLeft ? m_currentSwipeSnapshotPattern.get() : pageGroup);
     360    if (isRTL)
     361        cairo_rectangle(cr, swipingLayerOffset, 0, width - swipingLayerOffset, height);
     362    else
     363        cairo_rectangle(cr, 0, 0, swipingLayerOffset, height);
     364    cairo_set_source(cr, swipingBack ? m_currentSwipeSnapshotPattern.get() : pageGroup);
    358365    cairo_fill_preserve(cr);
    359366
     
    364371
    365372    if (progress) {
    366         cairo_rectangle(cr, -swipeOverlayShadowWidth, 0, swipeOverlayShadowWidth, height);
     373        cairo_save(cr);
     374        if (!isRTL)
     375            cairo_scale(cr, -1, 1);
     376        cairo_rectangle(cr, 0, 0, swipeOverlayShadowWidth, height);
    367377        cairo_set_source(cr, shadowPattern.get());
    368378        cairo_fill(cr);
    369     }
    370 
    371     cairo_rectangle(cr, 0, 0, width - swipingLayerOffset, height);
    372     cairo_set_source(cr, swipingLeft ? pageGroup : m_currentSwipeSnapshotPattern.get());
     379        cairo_restore(cr);
     380    }
     381
     382    if (isRTL) {
     383        cairo_translate(cr, -width, 0);
     384        cairo_rectangle(cr, width - swipingLayerOffset, 0, swipingLayerOffset, height);
     385    } else
     386        cairo_rectangle(cr, 0, 0, width - swipingLayerOffset, height);
     387    cairo_set_source(cr, swipingBack ? pageGroup : m_currentSwipeSnapshotPattern.get());
    373388    cairo_fill(cr);
    374389
Note: See TracChangeset for help on using the changeset viewer.