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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp

Issue 2683233005: Set caret width based on device scale factor (Closed)
Patch Set: Fix compile error Created 3 years, 10 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 alignment = AlignRight; 1157 alignment = AlignRight;
1158 break; 1158 break;
1159 case ETextAlign::kEnd: 1159 case ETextAlign::kEnd:
1160 if (currentStyle.isLeftToRightDirection()) 1160 if (currentStyle.isLeftToRightDirection())
1161 alignment = AlignRight; 1161 alignment = AlignRight;
1162 break; 1162 break;
1163 } 1163 }
1164 1164
1165 LayoutUnit x = borderLeft() + paddingLeft(); 1165 LayoutUnit x = borderLeft() + paddingLeft();
1166 LayoutUnit maxX = width - borderRight() - paddingRight(); 1166 LayoutUnit maxX = width - borderRight() - paddingRight();
1167 LayoutUnit caretWidth = blink::caretWidth(frameView()->getHostWindow());
1167 1168
1168 switch (alignment) { 1169 switch (alignment) {
1169 case AlignLeft: 1170 case AlignLeft:
1170 if (currentStyle.isLeftToRightDirection()) 1171 if (currentStyle.isLeftToRightDirection())
1171 x += textIndentOffset; 1172 x += textIndentOffset;
1172 break; 1173 break;
1173 case AlignCenter: 1174 case AlignCenter:
1174 x = (x + maxX) / 2; 1175 x = (x + maxX) / 2;
1175 if (currentStyle.isLeftToRightDirection()) 1176 if (currentStyle.isLeftToRightDirection())
1176 x += textIndentOffset / 2; 1177 x += textIndentOffset / 2;
1177 else 1178 else
1178 x -= textIndentOffset / 2; 1179 x -= textIndentOffset / 2;
1179 break; 1180 break;
1180 case AlignRight: 1181 case AlignRight:
1181 x = maxX - caretWidth(); 1182 x = maxX - caretWidth;
1182 if (!currentStyle.isLeftToRightDirection()) 1183 if (!currentStyle.isLeftToRightDirection())
1183 x -= textIndentOffset; 1184 x -= textIndentOffset;
1184 break; 1185 break;
1185 } 1186 }
1186 x = std::min(x, (maxX - caretWidth()).clampNegativeToZero()); 1187 x = std::min(x, (maxX - caretWidth));
1187 1188
1188 const Font& font = style()->font(); 1189 const Font& font = style()->font();
1189 const SimpleFontData* fontData = font.primaryFont(); 1190 const SimpleFontData* fontData = font.primaryFont();
1190 LayoutUnit height; 1191 LayoutUnit height;
1191 // crbug.com/595692 This check should not be needed but sometimes 1192 // crbug.com/595692 This check should not be needed but sometimes
1192 // primaryFont is null. 1193 // primaryFont is null.
1193 if (fontData) 1194 if (fontData)
1194 height = LayoutUnit(fontData->getFontMetrics().height()); 1195 height = LayoutUnit(fontData->getFontMetrics().height());
1195 LayoutUnit verticalSpace = 1196 LayoutUnit verticalSpace =
1196 lineHeight(true, currentStyle.isHorizontalWritingMode() ? HorizontalLine 1197 lineHeight(true, currentStyle.isHorizontalWritingMode() ? HorizontalLine
1197 : VerticalLine, 1198 : VerticalLine,
1198 PositionOfInteriorLineBoxes) - 1199 PositionOfInteriorLineBoxes) -
1199 height; 1200 height;
1200 LayoutUnit y = paddingTop() + borderTop() + (verticalSpace / 2); 1201 LayoutUnit y = paddingTop() + borderTop() + (verticalSpace / 2);
1201 return currentStyle.isHorizontalWritingMode() 1202 return currentStyle.isHorizontalWritingMode()
1202 ? LayoutRect(x, y, caretWidth(), height) 1203 ? LayoutRect(x, y, caretWidth, height)
1203 : LayoutRect(y, x, height, caretWidth()); 1204 : LayoutRect(y, x, height, caretWidth);
1204 } 1205 }
1205 1206
1206 const LayoutObject* LayoutBoxModelObject::pushMappingToContainer( 1207 const LayoutObject* LayoutBoxModelObject::pushMappingToContainer(
1207 const LayoutBoxModelObject* ancestorToStopAt, 1208 const LayoutBoxModelObject* ancestorToStopAt,
1208 LayoutGeometryMap& geometryMap) const { 1209 LayoutGeometryMap& geometryMap) const {
1209 ASSERT(ancestorToStopAt != this); 1210 ASSERT(ancestorToStopAt != this);
1210 1211
1211 AncestorSkipInfo skipInfo(ancestorToStopAt); 1212 AncestorSkipInfo skipInfo(ancestorToStopAt);
1212 LayoutObject* container = this->container(&skipInfo); 1213 LayoutObject* container = this->container(&skipInfo);
1213 if (!container) 1214 if (!container)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 if (rootElementStyle->hasBackground()) 1348 if (rootElementStyle->hasBackground())
1348 return false; 1349 return false;
1349 1350
1350 if (node() != document().firstBodyElement()) 1351 if (node() != document().firstBodyElement())
1351 return false; 1352 return false;
1352 1353
1353 return true; 1354 return true;
1354 } 1355 }
1355 1356
1356 } // namespace blink 1357 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698