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

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: 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 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 x += textIndentOffset; 1171 x += textIndentOffset;
1172 break; 1172 break;
1173 case AlignCenter: 1173 case AlignCenter:
1174 x = (x + maxX) / 2; 1174 x = (x + maxX) / 2;
1175 if (currentStyle.isLeftToRightDirection()) 1175 if (currentStyle.isLeftToRightDirection())
1176 x += textIndentOffset / 2; 1176 x += textIndentOffset / 2;
1177 else 1177 else
1178 x -= textIndentOffset / 2; 1178 x -= textIndentOffset / 2;
1179 break; 1179 break;
1180 case AlignRight: 1180 case AlignRight:
1181 x = maxX - caretWidth(); 1181 x = maxX - caretWidth(frameView()->getHostWindow());
oshima 2017/02/10 19:55:16 can you just get once in this function?
malaykeshav 2017/02/10 21:00:54 Done
1182 if (!currentStyle.isLeftToRightDirection()) 1182 if (!currentStyle.isLeftToRightDirection())
1183 x -= textIndentOffset; 1183 x -= textIndentOffset;
1184 break; 1184 break;
1185 } 1185 }
1186 x = std::min(x, (maxX - caretWidth()).clampNegativeToZero()); 1186 x = std::min(
1187 x,
1188 (maxX - caretWidth(frameView()->getHostWindow())).clampNegativeToZero());
1187 1189
1188 const Font& font = style()->font(); 1190 const Font& font = style()->font();
1189 const SimpleFontData* fontData = font.primaryFont(); 1191 const SimpleFontData* fontData = font.primaryFont();
1190 LayoutUnit height; 1192 LayoutUnit height;
1191 // crbug.com/595692 This check should not be needed but sometimes 1193 // crbug.com/595692 This check should not be needed but sometimes
1192 // primaryFont is null. 1194 // primaryFont is null.
1193 if (fontData) 1195 if (fontData)
1194 height = LayoutUnit(fontData->getFontMetrics().height()); 1196 height = LayoutUnit(fontData->getFontMetrics().height());
1195 LayoutUnit verticalSpace = 1197 LayoutUnit verticalSpace =
1196 lineHeight(true, currentStyle.isHorizontalWritingMode() ? HorizontalLine 1198 lineHeight(true, currentStyle.isHorizontalWritingMode() ? HorizontalLine
1197 : VerticalLine, 1199 : VerticalLine,
1198 PositionOfInteriorLineBoxes) - 1200 PositionOfInteriorLineBoxes) -
1199 height; 1201 height;
1200 LayoutUnit y = paddingTop() + borderTop() + (verticalSpace / 2); 1202 LayoutUnit y = paddingTop() + borderTop() + (verticalSpace / 2);
1201 return currentStyle.isHorizontalWritingMode() 1203 return currentStyle.isHorizontalWritingMode()
1202 ? LayoutRect(x, y, caretWidth(), height) 1204 ? LayoutRect(x, y, caretWidth(frameView()->getHostWindow()),
1203 : LayoutRect(y, x, height, caretWidth()); 1205 height)
1206 : LayoutRect(y, x, height,
1207 caretWidth(frameView()->getHostWindow()));
1204 } 1208 }
1205 1209
1206 const LayoutObject* LayoutBoxModelObject::pushMappingToContainer( 1210 const LayoutObject* LayoutBoxModelObject::pushMappingToContainer(
1207 const LayoutBoxModelObject* ancestorToStopAt, 1211 const LayoutBoxModelObject* ancestorToStopAt,
1208 LayoutGeometryMap& geometryMap) const { 1212 LayoutGeometryMap& geometryMap) const {
1209 ASSERT(ancestorToStopAt != this); 1213 ASSERT(ancestorToStopAt != this);
1210 1214
1211 AncestorSkipInfo skipInfo(ancestorToStopAt); 1215 AncestorSkipInfo skipInfo(ancestorToStopAt);
1212 LayoutObject* container = this->container(&skipInfo); 1216 LayoutObject* container = this->container(&skipInfo);
1213 if (!container) 1217 if (!container)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 if (rootElementStyle->hasBackground()) 1351 if (rootElementStyle->hasBackground())
1348 return false; 1352 return false;
1349 1353
1350 if (node() != document().firstBodyElement()) 1354 if (node() != document().firstBodyElement())
1351 return false; 1355 return false;
1352 1356
1353 return true; 1357 return true;
1354 } 1358 }
1355 1359
1356 } // namespace blink 1360 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698