RTL document in <iframe> should have left-hand scrollbar (see https://crbug.com/250514#c34)

This commit is contained in:
Marshall Greenblatt
2018-08-02 14:34:22 -04:00
parent de363ee473
commit 4a354e6cf1
2 changed files with 91 additions and 0 deletions

View File

@@ -378,4 +378,9 @@ patches = [
# https://bitbucket.org/chromiumembedded/cef/issues/2466
'name': 'linux_poll_2466',
},
{
# RTL document in <iframe> should have left-hand scrollbar.
# https://bugs.chromium.org/p/chromium/issues/detail?id=250514#c34
'name': 'webkit_rtl_scrollbars_250514',
},
]

View File

@@ -0,0 +1,86 @@
diff --git third_party/blink/renderer/core/layout/layout_box.cc third_party/blink/renderer/core/layout/layout_box.cc
index d56be3429c19..c87209743c34 100644
--- third_party/blink/renderer/core/layout/layout_box.cc
+++ third_party/blink/renderer/core/layout/layout_box.cc
@@ -4402,6 +4402,7 @@ void LayoutBox::ComputePositionedLogicalWidthUsing(
}
if (container_block->IsBox() &&
+ container_block->IsHorizontalWritingMode() == IsHorizontalWritingMode() &&
ToLayoutBox(container_block)->ScrollsOverflowY() &&
ToLayoutBox(container_block)
->ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
@@ -4758,6 +4759,15 @@ void LayoutBox::ComputePositionedLogicalHeightUsing(
}
computed_values.extent_ = logical_height_value;
+ if (container_block->IsBox() &&
+ container_block->IsHorizontalWritingMode() != IsHorizontalWritingMode() &&
+ ToLayoutBox(container_block)->ScrollsOverflowY() &&
+ ToLayoutBox(container_block)
+ ->ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
+ logical_top_value = logical_top_value +
+ ToLayoutBox(container_block)->VerticalScrollbarWidth();
+ }
+
// Use computed values to calculate the vertical position.
computed_values.position_ =
logical_top_value + computed_values.margins_.before_;
diff --git third_party/blink/renderer/core/layout/layout_view.cc third_party/blink/renderer/core/layout/layout_view.cc
index bc3bf00be630..82a6e77878ef 100644
--- third_party/blink/renderer/core/layout/layout_view.cc
+++ third_party/blink/renderer/core/layout/layout_view.cc
@@ -253,6 +253,22 @@ void LayoutView::SetShouldDoFullPaintInvalidationOnResizeIfNeeded(
}
}
+bool LayoutView::ShouldPlaceBlockDirectionScrollbarOnLogicalLeft() const {
+ LocalFrame& frame = GetFrameView()->GetFrame();
+ // See crbug.com/249860
+ if (frame.IsMainFrame())
+ return false;
+ // <body> inherits 'direction' from <html>, so checking style on the body is
+ // sufficient.
+ if (Element* body = GetDocument().body()) {
+ if (LayoutObject* body_layout_object = body->GetLayoutObject()) {
+ return body_layout_object->Style()
+ ->ShouldPlaceBlockDirectionScrollbarOnLogicalLeft();
+ }
+ }
+ return false;
+}
+
void LayoutView::UpdateBlockLayout(bool relayout_children) {
SubtreeLayoutScope layout_scope(*this);
diff --git third_party/blink/renderer/core/layout/layout_view.h third_party/blink/renderer/core/layout/layout_view.h
index 867d64060c1e..e0f87a8d555f 100644
--- third_party/blink/renderer/core/layout/layout_view.h
+++ third_party/blink/renderer/core/layout/layout_view.h
@@ -230,13 +230,7 @@ class CORE_EXPORT LayoutView final : public LayoutBlockFlow {
void SetShouldDoFullPaintInvalidationOnResizeIfNeeded(bool width_changed,
bool height_changed);
- // The document scrollbar is always on the right, even in RTL. This is to
- // prevent it from moving around on navigations.
- // TODO(skobes): This is not quite the ideal behavior, see
- // http://crbug.com/250514 and http://crbug.com/249860.
- bool ShouldPlaceBlockDirectionScrollbarOnLogicalLeft() const override {
- return false;
- }
+ bool ShouldPlaceBlockDirectionScrollbarOnLogicalLeft() const override;
LayoutRect DebugRect() const override;
diff --git third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc
index 32861ebbc2cc..0bee41ae2cb2 100644
--- third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc
+++ third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc
@@ -1313,6 +1313,7 @@ void CompositedLayerMapping::ComputeGraphicsLayerParentLocation(
IntSize scroll_offset = layout_box.ScrolledContentOffset();
IntPoint scroll_origin =
compositing_container->GetScrollableArea()->ScrollOrigin();
+ scroll_origin.Move(-layout_box.OriginAdjustmentForScrollbars());
scroll_origin.Move(-layout_box.BorderLeft().ToInt(),
-layout_box.BorderTop().ToInt());
graphics_layer_parent_location = -(scroll_origin + scroll_offset);