Changeset 112238 in webkit
- Timestamp:
- Mar 27, 2012 3:08:50 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r112237 r112238 1 2012-03-27 Levi Weintraub <leviw@chromium.org> 2 3 Update usage of LayoutUnits in RenderListMarker 4 https://bugs.webkit.org/show_bug.cgi?id=81921 5 6 Reviewed by Eric Seidel. 7 8 Implementing proper pixel snapping in list marker painting, and correcting usage of integers 9 for local coordinates/margins that should be sub-pixel. 10 11 No new tests. No change in behavior. 12 13 * rendering/RenderListMarker.cpp: 14 (WebCore::RenderListMarker::localSelectionRect): Changed to LayoutUnits since this represents 15 a rect in local coordinates. 16 (WebCore::RenderListMarker::paint): Doing proper pixel snapping, and using integers for 17 results from text measurement. 18 (WebCore::RenderListMarker::computePreferredLogicalWidths): Using integers for results 19 from text measurement. 20 (WebCore::RenderListMarker::updateMargins): Fixing to be LayoutUnits. 21 * rendering/RenderListMarker.h: 22 (RenderListMarker): 23 1 24 2012-03-27 Levi Weintraub <leviw@chromium.org> 2 25 -
trunk/Source/WebCore/rendering/RenderListMarker.cpp
r110323 r112238 1091 1091 } 1092 1092 1093 IntRect RenderListMarker::localSelectionRect()1093 LayoutRect RenderListMarker::localSelectionRect() 1094 1094 { 1095 1095 InlineBox* box = inlineBoxWrapper(); 1096 1096 if (!box) 1097 return IntRect(IntPoint(), size());1097 return LayoutRect(LayoutPoint(), size()); 1098 1098 RootInlineBox* root = m_inlineBoxWrapper->root(); 1099 int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();1099 LayoutUnit newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop(); 1100 1100 if (root->block()->style()->isHorizontalWritingMode()) 1101 return IntRect(0, newLogicalTop, width(), root->selectionHeight());1102 return IntRect(newLogicalTop, 0, root->selectionHeight(), height());1101 return LayoutRect(0, newLogicalTop, width(), root->selectionHeight()); 1102 return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height()); 1103 1103 } 1104 1104 … … 1111 1111 return; 1112 1112 1113 IntPoint boxOrigin(paintOffset + location());1113 LayoutPoint boxOrigin(paintOffset + location()); 1114 1114 LayoutRect overflowRect(visualOverflowRect()); 1115 1115 overflowRect.moveBy(boxOrigin); 1116 1116 overflowRect.inflate(maximalOutlineSize(paintInfo.phase)); 1117 1117 1118 if (!paintInfo.rect.intersects( overflowRect))1118 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) 1119 1119 return; 1120 1120 1121 LayoutRect box(boxOrigin, LayoutSize(width(), height()));1121 LayoutRect box(boxOrigin, size()); 1122 1122 1123 LayoutRect marker = getRelativeMarkerRect();1124 marker.moveBy( boxOrigin);1123 IntRect marker = getRelativeMarkerRect(); 1124 marker.moveBy(roundedIntPoint(boxOrigin)); 1125 1125 1126 1126 GraphicsContext* context = paintInfo.context; … … 1135 1135 LayoutRect selRect = localSelectionRect(); 1136 1136 selRect.moveBy(boxOrigin); 1137 context->fillRect( selRect, selectionBackgroundColor(), style()->colorSpace());1137 context->fillRect(pixelSnappedIntRect(selRect), selectionBackgroundColor(), style()->colorSpace()); 1138 1138 } 1139 1139 return; … … 1149 1149 LayoutRect selRect = localSelectionRect(); 1150 1150 selRect.moveBy(boxOrigin); 1151 context->fillRect( selRect, selectionBackgroundColor(), style()->colorSpace());1151 context->fillRect(pixelSnappedIntRect(selRect), selectionBackgroundColor(), style()->colorSpace()); 1152 1152 } 1153 1153 … … 1259 1259 GraphicsContextStateSaver stateSaver(*context, false); 1260 1260 if (!style()->isHorizontalWritingMode()) { 1261 marker.moveBy( -boxOrigin);1261 marker.moveBy(roundedIntPoint(-boxOrigin)); 1262 1262 marker = marker.transposedRect(); 1263 marker.move (box.x(), box.y() - logicalHeight());1263 marker.moveBy(IntPoint(roundToInt(box.x()), roundToInt(box.y() - logicalHeight()))); 1264 1264 stateSaver.save(); 1265 1265 context->translate(marker.x(), marker.maxY()); … … 1268 1268 } 1269 1269 1270 LayoutPoint textOrigin = LayoutPoint(marker.x(), marker.y() + style()->fontMetrics().ascent());1270 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + style()->fontMetrics().ascent()); 1271 1271 1272 1272 if (type == Asterisks || type == Footnotes) … … 1287 1287 const UChar suffix = listMarkerSuffix(type, m_listItem->value()); 1288 1288 if (style()->isLeftToRightDirection()) { 1289 LayoutUnit width = font.width(textRun);1289 int width = font.width(textRun); 1290 1290 context->drawText(font, textRun, textOrigin); 1291 1291 UChar suffixSpace[2] = { suffix, ' ' }; … … 1294 1294 UChar spaceSuffix[2] = { ' ', suffix }; 1295 1295 TextRun spaceSuffixRun = RenderBlock::constructTextRun(this, font, spaceSuffix, 2, style()); 1296 LayoutUnit width = font.width(spaceSuffixRun);1296 int width = font.width(spaceSuffixRun); 1297 1297 context->drawText(font, spaceSuffixRun, textOrigin); 1298 1298 context->drawText(font, textRun, textOrigin + IntSize(width, 0)); … … 1350 1350 // FIXME: This is a somewhat arbitrary width. Generated images for markers really won't become particularly useful 1351 1351 // until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box. 1352 LayoutUnit bulletWidth = fontMetrics.ascent() / 2;1353 m_image->setContainerSizeForRenderer(this, LayoutSize(bulletWidth, bulletWidth), style()->effectiveZoom());1352 int bulletWidth = fontMetrics.ascent() / 2; 1353 m_image->setContainerSizeForRenderer(this, IntSize(bulletWidth, bulletWidth), style()->effectiveZoom()); 1354 1354 LayoutSize imageSize = m_image->imageSize(this, style()->effectiveZoom()); 1355 1355 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height(); … … 1474 1474 const FontMetrics& fontMetrics = style()->fontMetrics(); 1475 1475 1476 int marginStart = 0;1477 int marginEnd = 0;1476 LayoutUnit marginStart = 0; 1477 LayoutUnit marginEnd = 0; 1478 1478 1479 1479 if (isInside()) { … … 1505 1505 break; 1506 1506 default: 1507 marginStart = m_text.isEmpty() ? 0: -minPreferredLogicalWidth() - offset / 2;1507 marginStart = m_text.isEmpty() ? zeroLayoutUnit : -minPreferredLogicalWidth() - offset / 2; 1508 1508 } 1509 1509 } -
trunk/Source/WebCore/rendering/RenderListMarker.h
r106900 r112238 75 75 76 76 IntRect getRelativeMarkerRect(); 77 IntRect localSelectionRect();77 LayoutRect localSelectionRect(); 78 78 79 79 String m_text;
Note: See TracChangeset
for help on using the changeset viewer.