Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: third_party/WebKit/Source/core/editing/RenderedPosition.cpp

Issue 1531473004: Fix selection handles in vertical writing modes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply code review comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/RenderedPosition.cpp
diff --git a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
index 96e85c1bb18ee59afaeaafe8a885b277bac0e17d..6069b69706d99996d3ebdc98d12cb18f6d866f48 100644
--- a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
+++ b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
@@ -235,7 +235,7 @@ IntRect RenderedPosition::absoluteRect(LayoutUnit* extraWidthToEndOfLine) const
return localRect == IntRect() ? IntRect() : m_layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoundingBox();
}
-void RenderedPosition::positionInGraphicsLayerBacking(CompositedSelectionBound& bound) const
+void RenderedPosition::positionInGraphicsLayerBacking(CompositedSelectionBound& bound, bool selectionStart) const
{
bound.layer = nullptr;
bound.edgeTopInLayer = bound.edgeBottomInLayer = FloatPoint();
@@ -245,8 +245,26 @@ void RenderedPosition::positionInGraphicsLayerBacking(CompositedSelectionBound&
LayoutRect rect = m_layoutObject->localCaretRect(m_inlineBox, m_offset);
PaintLayer* layer = nullptr;
- bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(rect.minXMinYCorner(), &layer);
- bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(rect.minXMaxYCorner(), nullptr);
+ if (m_layoutObject->style()->isHorizontalWritingMode()) {
+ bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(rect.minXMinYCorner(), &layer);
+ bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(rect.minXMaxYCorner(), nullptr);
+ } else {
+ bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(rect.minXMinYCorner(), &layer);
+ bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(rect.maxXMinYCorner(), nullptr);
+
+ // When text is vertical, it looks better for the start handle baseline to
+ // be at the starting edge, to enclose the selection fully between the
+ // handles.
+ if (selectionStart) {
+ float xSwap = bound.edgeBottomInLayer.x();
+ bound.edgeBottomInLayer.setX(bound.edgeTopInLayer.x());
+ bound.edgeTopInLayer.setX(xSwap);
+ }
+
+ // Flipped blocks writing mode is not only vertical but also right to left.
+ bound.isTextDirectionRTL = m_layoutObject->hasFlippedBlocksWritingMode();
+ }
+
bound.layer = layer ? layer->graphicsLayerBacking() : nullptr;
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/RenderedPosition.h ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698