Source/WebCore/ChangeLog

 12019-06-26 Cathie Chen <cathiechen@igalia.com>
 2
 3 Add supporting for writing-mode of scrollIntoViewOptions.
 4 https://bugs.webkit.org/show_bug.cgi?id=161611
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 To support writing-mode, toScrollAlignment*() will return the physical align side.
 9 RenderLayer::getRectToExpose() will compute the scroll offset according to the alignment.
 10
 11 * dom/Element.cpp:
 12 (WebCore::toScrollAlignmentForInlineDirection):
 13 (WebCore::toScrollAlignmentForBlockDirection):
 14 (WebCore::Element::scrollIntoView):
 15 (WebCore::toScrollAlignment): Deleted. Split to two.
 16 * rendering/RenderLayer.cpp:
 17 (WebCore::RenderLayer::getRectToExpose const): Support writing-mode.
 18
1192019-06-24 Michael Catanzaro <mcatanzaro@igalia.com>
220
321 Add user agent quirk for Google Drive

Source/WebCore/dom/Element.cpp

@@void Element::setHovered(bool flag)
701701 renderer()->theme().stateChanged(*renderer(), ControlStates::HoverState);
702702}
703703
704 // FIXME(webkit.org/b/161611): Take into account orientation/direction.
705 inline ScrollAlignment toScrollAlignment(Optional<ScrollLogicalPosition> position, bool isVertical)
706 {
707  switch (position.valueOr(isVertical ? ScrollLogicalPosition::Start : ScrollLogicalPosition::Nearest)) {
708  case ScrollLogicalPosition::Start:
709  return isVertical ? ScrollAlignment::alignTopAlways : ScrollAlignment::alignLeftAlways;
 704inline ScrollAlignment toScrollAlignmentForInlineDirection(Optional<ScrollLogicalPosition> position, WritingMode writingMode)
 705{
 706 switch (position.valueOr(ScrollLogicalPosition::Nearest)) {
 707 case ScrollLogicalPosition::Start: {
 708 switch (writingMode) {
 709 case TopToBottomWritingMode:
 710 case BottomToTopWritingMode:
 711 return ScrollAlignment::alignLeftAlways;
 712 case LeftToRightWritingMode:
 713 case RightToLeftWritingMode:
 714 return ScrollAlignment::alignTopAlways;
 715 default:
 716 ASSERT_NOT_REACHED();
 717 return ScrollAlignment::alignLeftAlways;
 718 }
 719 }
710720 case ScrollLogicalPosition::Center:
711721 return ScrollAlignment::alignCenterAlways;
712  case ScrollLogicalPosition::End:
713  return isVertical ? ScrollAlignment::alignBottomAlways : ScrollAlignment::alignRightAlways;
 722 case ScrollLogicalPosition::End: {
 723 switch (writingMode) {
 724 case TopToBottomWritingMode:
 725 case BottomToTopWritingMode:
 726 return ScrollAlignment::alignRightAlways;
 727 case LeftToRightWritingMode:
 728 case RightToLeftWritingMode:
 729 return ScrollAlignment::alignBottomAlways;
 730 default:
 731 ASSERT_NOT_REACHED();
 732 return ScrollAlignment::alignRightAlways;
 733 }
 734 }
 735 case ScrollLogicalPosition::Nearest:
 736 return ScrollAlignment::alignToEdgeIfNeeded;
 737 default:
 738 ASSERT_NOT_REACHED();
 739 return ScrollAlignment::alignToEdgeIfNeeded;
 740 }
 741}
 742
 743inline ScrollAlignment toScrollAlignmentForBlockDirection(Optional<ScrollLogicalPosition> position, WritingMode writingMode)
 744{
 745 switch (position.valueOr(ScrollLogicalPosition::Start)) {
 746 case ScrollLogicalPosition::Start: {
 747 switch (writingMode) {
 748 case TopToBottomWritingMode:
 749 return ScrollAlignment::alignTopAlways;
 750 case BottomToTopWritingMode:
 751 return ScrollAlignment::alignBottomAlways;
 752 case LeftToRightWritingMode:
 753 return ScrollAlignment::alignLeftAlways;
 754 case RightToLeftWritingMode:
 755 return ScrollAlignment::alignRightAlways;
 756 default:
 757 ASSERT_NOT_REACHED();
 758 return ScrollAlignment::alignTopAlways;
 759 }
 760 }
 761 case ScrollLogicalPosition::Center:
 762 return ScrollAlignment::alignCenterAlways;
 763 case ScrollLogicalPosition::End: {
 764 switch (writingMode) {
 765 case TopToBottomWritingMode:
 766 return ScrollAlignment::alignBottomAlways;
 767 case BottomToTopWritingMode:
 768 return ScrollAlignment::alignTopAlways;
 769 case LeftToRightWritingMode:
 770 return ScrollAlignment::alignRightAlways;
 771 case RightToLeftWritingMode:
 772 return ScrollAlignment::alignLeftAlways;
 773 default:
 774 ASSERT_NOT_REACHED();
 775 return ScrollAlignment::alignBottomAlways;
 776 }
 777 }
714778 case ScrollLogicalPosition::Nearest:
715779 return ScrollAlignment::alignToEdgeIfNeeded;
716780 default:

@@void Element::scrollIntoView(Optional<Variant<bool, ScrollIntoViewOptions>>&& ar
739803 options.blockPosition = ScrollLogicalPosition::End;
740804 }
741805
742  ScrollAlignment alignX = toScrollAlignment(options.inlinePosition, false);
743  ScrollAlignment alignY = toScrollAlignment(options.blockPosition, true);
 806 auto writingMode = renderer()->style().writingMode();
 807 ScrollAlignment alignX = toScrollAlignmentForInlineDirection(options.inlinePosition, writingMode);
 808 ScrollAlignment alignY = toScrollAlignmentForBlockDirection(options.blockPosition, writingMode);
744809 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, alignX, alignY, ShouldAllowCrossOriginScrolling::No });
745810}
746811

Source/WebCore/rendering/RenderLayer.cpp

@@LayoutRect RenderLayer::getRectToExpose(const LayoutRect& visibleRect, const Lay
27732773 if (scrollX == ScrollAlignment::Behavior::AlignToClosestEdge && exposeRect.maxX() > visibleRect.maxX() && exposeRect.width() < visibleRect.width())
27742774 scrollX = ScrollAlignment::Behavior::AlignRight;
27752775
2776  // Given the X behavior, compute the X coordinate.
2777  LayoutUnit x;
2778  if (scrollX == ScrollAlignment::Behavior::NoScroll)
2779  x = visibleRect.x();
2780  else if (scrollX == ScrollAlignment::Behavior::AlignRight)
2781  x = exposeRect.maxX() - visibleRect.width();
2782  else if (scrollX == ScrollAlignment::Behavior::AlignCenter)
2783  x = exposeRect.x() + (exposeRect.width() - visibleRect.width()) / 2;
2784  else
2785  x = exposeRect.x();
2786 
27872776 // Determine the appropriate Y behavior.
27882777 ScrollAlignment::Behavior scrollY;
27892778 LayoutRect exposeRectY(visibleRect.x(), exposeRect.y(), visibleRect.width(), exposeRect.height());

@@LayoutRect RenderLayer::getRectToExpose(const LayoutRect& visibleRect, const Lay
28062795 if (scrollY == ScrollAlignment::Behavior::AlignToClosestEdge && exposeRect.maxY() > visibleRect.maxY() && exposeRect.height() < visibleRect.height())
28072796 scrollY = ScrollAlignment::Behavior::AlignBottom;
28082797
2809  // Given the Y behavior, compute the Y coordinate.
 2798 // Given the behavior and WritingMode, compute the X and Y coordinate.
 2799 LayoutUnit x;
28102800 LayoutUnit y;
2811  if (scrollY == ScrollAlignment::Behavior::NoScroll)
 2801 bool isHorizontal = renderer().style().isHorizontalWritingMode();
 2802 auto physicalScrollX = isHorizontal ? scrollX : scrollY;
 2803 auto physicalScrollY = isHorizontal ? scrollY : scrollX;
 2804
 2805 if (physicalScrollX == ScrollAlignment::Behavior::NoScroll)
 2806 x = visibleRect.x();
 2807 else if (physicalScrollX == ScrollAlignment::Behavior::AlignCenter)
 2808 x = exposeRect.x() + (exposeRect.width() - visibleRect.width()) / 2;
 2809 else if (physicalScrollX == ScrollAlignment::Behavior::AlignRight)
 2810 x = exposeRect.maxX() - visibleRect.width();
 2811 else
 2812 x = exposeRect.x();
 2813
 2814 if (physicalScrollY == ScrollAlignment::Behavior::NoScroll)
28122815 y = visibleRect.y();
2813  else if (scrollY == ScrollAlignment::Behavior::AlignBottom)
 2816 else if (physicalScrollY == ScrollAlignment::Behavior::AlignBottom)
28142817 y = exposeRect.maxY() - visibleRect.height();
2815  else if (scrollY == ScrollAlignment::Behavior::AlignCenter)
 2818 else if (physicalScrollY == ScrollAlignment::Behavior::AlignCenter)
28162819 y = exposeRect.y() + (exposeRect.height() - visibleRect.height()) / 2;
28172820 else
28182821 y = exposeRect.y();

LayoutTests/imported/w3c/ChangeLog

 12019-06-26 Cathie Chen <cathiechen@igalia.com>
 2
 3 Add supporting for writing-mode of scrollIntoViewOptions.
 4 https://bugs.webkit.org/show_bug.cgi?id=161611
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 The x scroll coordinate of vertical-rl starts from the right side of scroll bar not left.
 9
 10 * web-platform-tests/css/cssom-view/scrollIntoView-vertical-rl-writing-mode-expected.txt:
 11 * web-platform-tests/css/cssom-view/scrollIntoView-vertical-rl-writing-mode.html:
 12
1132019-06-24 Antoine Quint <graouts@apple.com>
214
315 [Pointer Events] Respect pointer capture when dispatching mouse boundary events and updating :hover

LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-vertical-rl-writing-mode-expected.txt

11
2 FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected -200 +/- 0.5 but got -100
3 FAIL scrollIntoView({block: "start", inline: "center"}) assert_approx_equals: scrollX expected -200 +/- 0.5 but got -143
4 FAIL scrollIntoView({block: "start", inline: "end"}) assert_approx_equals: scrollX expected -200 +/- 0.5 but got -185
5 FAIL scrollIntoView({block: "center", inline: "start"}) assert_approx_equals: scrollX expected -157.5 +/- 0.5 but got -100
6 FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected -157.5 +/- 0.5 but got -143
7 FAIL scrollIntoView({block: "center", inline: "end"}) assert_approx_equals: scrollX expected -157.5 +/- 0.5 but got -185
8 FAIL scrollIntoView({block: "end", inline: "start"}) assert_approx_equals: scrollX expected -115 +/- 0.5 but got -100
9 FAIL scrollIntoView({block: "end", inline: "center"}) assert_approx_equals: scrollX expected -115 +/- 0.5 but got -143
10 FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected -115 +/- 0.5 but got -185
 2PASS scrollIntoView({block: "start", inline: "start"})
 3PASS scrollIntoView({block: "start", inline: "center"})
 4PASS scrollIntoView({block: "start", inline: "end"})
 5PASS scrollIntoView({block: "center", inline: "start"})
 6PASS scrollIntoView({block: "center", inline: "center"})
 7PASS scrollIntoView({block: "center", inline: "end"})
 8PASS scrollIntoView({block: "end", inline: "start"})
 9PASS scrollIntoView({block: "end", inline: "center"})
 10PASS scrollIntoView({block: "end", inline: "end"})
1111

LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-vertical-rl-writing-mode.html

@@var expectedY = [ box_height, ((3*box_height - scroller_height)/2) + (scrollbar_
6969// in a right-to-left mode, we adjust the expectation
7070// to match the semantics of scrollLeft.
7171if(scroller.scrollLeft === 0)
72  expectedX = [ -box_width, -(((3*box_width - scroller_width)/2)+ (scrollbar_width/2)), -(((2*box_width)-scroller_width)+scrollbar_width)];
 72 expectedX = [ -(box_width - scrollbar_width), -(((3*box_width - scroller_width)/2)+ (scrollbar_width/2) - scrollbar_width), -((2*box_width)-scroller_width)];
7373
7474// This formats dict as a string suitable as test name.
7575// format_value() is provided by testharness.js,