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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 IntRect RenderedPosition::absoluteRect(LayoutUnit* extraWidthToEndOfLine) const 229 IntRect RenderedPosition::absoluteRect(LayoutUnit* extraWidthToEndOfLine) const
230 { 230 {
231 if (isNull()) 231 if (isNull())
232 return IntRect(); 232 return IntRect();
233 233
234 IntRect localRect = pixelSnappedIntRect(m_layoutObject->localCaretRect(m_inl ineBox, m_offset, extraWidthToEndOfLine)); 234 IntRect localRect = pixelSnappedIntRect(m_layoutObject->localCaretRect(m_inl ineBox, m_offset, extraWidthToEndOfLine));
235 return localRect == IntRect() ? IntRect() : m_layoutObject->localToAbsoluteQ uad(FloatRect(localRect)).enclosingBoundingBox(); 235 return localRect == IntRect() ? IntRect() : m_layoutObject->localToAbsoluteQ uad(FloatRect(localRect)).enclosingBoundingBox();
236 } 236 }
237 237
238 void RenderedPosition::positionInGraphicsLayerBacking(CompositedSelectionBound& bound) const 238 void RenderedPosition::positionInGraphicsLayerBacking(CompositedSelectionBound& bound, bool selectionStart) const
239 { 239 {
240 bound.layer = nullptr; 240 bound.layer = nullptr;
241 bound.edgeTopInLayer = bound.edgeBottomInLayer = FloatPoint(); 241 bound.edgeTopInLayer = bound.edgeBottomInLayer = FloatPoint();
242 242
243 if (isNull()) 243 if (isNull())
244 return; 244 return;
245 245
246 LayoutRect rect = m_layoutObject->localCaretRect(m_inlineBox, m_offset); 246 LayoutRect rect = m_layoutObject->localCaretRect(m_inlineBox, m_offset);
247 PaintLayer* layer = nullptr; 247 PaintLayer* layer = nullptr;
248 bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(rect. minXMinYCorner(), &layer); 248 if (m_layoutObject->style()->isHorizontalWritingMode()) {
249 bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoint(re ct.minXMaxYCorner(), nullptr); 249 bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(r ect.minXMinYCorner(), &layer);
250 bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoin t(rect.minXMaxYCorner(), nullptr);
251 } else {
252 bound.edgeTopInLayer = m_layoutObject->localToInvalidationBackingPoint(r ect.minXMinYCorner(), &layer);
253 bound.edgeBottomInLayer = m_layoutObject->localToInvalidationBackingPoin t(rect.maxXMinYCorner(), nullptr);
254
255 // When text is vertical, it looks better for the start handle baseline to
256 // be at the starting edge, to enclose the selection fully between the
257 // handles.
258 if (selectionStart) {
259 float xSwap = bound.edgeBottomInLayer.x();
260 bound.edgeBottomInLayer.setX(bound.edgeTopInLayer.x());
261 bound.edgeTopInLayer.setX(xSwap);
262 }
263
264 // Flipped blocks writing mode is not only vertical but also right to le ft.
265 bound.isTextDirectionRTL = m_layoutObject->hasFlippedBlocksWritingMode() ;
266 }
267
250 bound.layer = layer ? layer->graphicsLayerBacking() : nullptr; 268 bound.layer = layer ? layer->graphicsLayerBacking() : nullptr;
251 } 269 }
252 270
253 bool layoutObjectContainsPosition(LayoutObject* target, const Position& position ) 271 bool layoutObjectContainsPosition(LayoutObject* target, const Position& position )
254 { 272 {
255 for (LayoutObject* layoutObject = layoutObjectFromPosition(position); layout Object && layoutObject->node(); layoutObject = layoutObject->parent()) { 273 for (LayoutObject* layoutObject = layoutObjectFromPosition(position); layout Object && layoutObject->node(); layoutObject = layoutObject->parent()) {
256 if (layoutObject == target) 274 if (layoutObject == target)
257 return true; 275 return true;
258 } 276 }
259 return false; 277 return false;
260 } 278 }
261 279
262 }; 280 };
OLDNEW
« 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