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

Side by Side Diff: Source/core/rendering/InlineTextBox.cpp

Issue 23241010: Support subpixel values for text-shadow and box-shadow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: all working! Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 const FloatPoint& textOrigin, const FloatRect& boxRect, 395 const FloatPoint& textOrigin, const FloatRect& boxRect,
396 const ShadowList* shadowList, bool stroked, bool horizontal) 396 const ShadowList* shadowList, bool stroked, bool horizontal)
397 { 397 {
398 // Text shadows are disabled when printing. http://crbug.com/258321 398 // Text shadows are disabled when printing. http://crbug.com/258321
399 bool hasShadow = shadowList && !context->printing(); 399 bool hasShadow = shadowList && !context->printing();
400 400
401 if (hasShadow) { 401 if (hasShadow) {
402 DrawLooper drawLooper; 402 DrawLooper drawLooper;
403 for (size_t i = shadowList->shadows().size(); i--; ) { 403 for (size_t i = shadowList->shadows().size(); i--; ) {
404 const ShadowData& shadow = shadowList->shadows()[i]; 404 const ShadowData& shadow = shadowList->shadows()[i];
405 int shadowX = horizontal ? shadow.x() : shadow.y(); 405 LayoutUnit shadowX = horizontal ? shadow.x() : shadow.y();
406 int shadowY = horizontal ? shadow.y() : -shadow.x(); 406 LayoutUnit shadowY = horizontal ? shadow.y() : -shadow.x();
407 FloatSize offset(shadowX, shadowY); 407 FloatSize offset(shadowX, shadowY);
408 drawLooper.addShadow(offset, shadow.blur(), renderer->resolveColor(s hadow.color()), 408 drawLooper.addShadow(offset, shadow.blur(), renderer->resolveColor(s hadow.color()),
409 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA lpha); 409 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA lpha);
410 } 410 }
411 drawLooper.addUnmodifiedContent(); 411 drawLooper.addUnmodifiedContent();
412 context->setDrawLooper(drawLooper); 412 context->setDrawLooper(drawLooper);
413 } 413 }
414 414
415 TextRunPaintInfo textRunPaintInfo(textRun); 415 TextRunPaintInfo textRunPaintInfo(textRun);
416 textRunPaintInfo.bounds = boxRect; 416 textRunPaintInfo.bounds = boxRect;
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1090
1091 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); 1091 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle());
1092 int baseline = styleToUse->fontMetrics().ascent(); 1092 int baseline = styleToUse->fontMetrics().ascent();
1093 1093
1094 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; 1094 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0;
1095 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. 1095 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px.
1096 // Using computedFontSize should take care of zoom as well. 1096 // Using computedFontSize should take care of zoom as well.
1097 const float textDecorationThickness = std::max(1.f, styleToUse->computedFont Size() / 10.f); 1097 const float textDecorationThickness = std::max(1.f, styleToUse->computedFont Size() / 10.f);
1098 context->setStrokeThickness(textDecorationThickness); 1098 context->setStrokeThickness(textDecorationThickness);
1099 1099
1100 int extraOffset = 0; 1100 LayoutUnit extraOffset = 0;
1101 if (!linesAreOpaque && shadowCount > 1) { 1101 if (!linesAreOpaque && shadowCount > 1) {
1102 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); 1102 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2));
1103 for (size_t i = shadowCount; i--; ) { 1103 for (size_t i = shadowCount; i--; ) {
1104 const ShadowData& s = shadowList->shadows()[i]; 1104 const ShadowData& s = shadowList->shadows()[i];
1105 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); 1105 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2));
1106 shadowRect.inflate(s.blur()); 1106 shadowRect.inflate(s.blur());
1107 int shadowX = isHorizontal() ? s.x() : s.y(); 1107 LayoutUnit shadowX = isHorizontal() ? s.x() : s.y();
1108 int shadowY = isHorizontal() ? s.y() : -s.x(); 1108 LayoutUnit shadowY = isHorizontal() ? s.y() : -s.x();
1109 shadowRect.move(shadowX, shadowY); 1109 shadowRect.move(shadowX, shadowY);
1110 clipRect.unite(shadowRect); 1110 clipRect.unite(shadowRect);
1111 extraOffset = max(extraOffset, max(0, shadowY) + s.blur()); 1111 extraOffset = max(extraOffset, max(LayoutUnit(0), shadowY) + s.blur( ));
1112 } 1112 }
1113 context->clip(clipRect); 1113 context->clip(clipRect);
1114 extraOffset += baseline + 2; 1114 extraOffset += baseline + 2;
1115 localOrigin.move(0, extraOffset); 1115 localOrigin.move(0, extraOffset);
1116 } 1116 }
1117 1117
1118 for (size_t i = max(static_cast<size_t>(1), shadowCount); i--; ) { 1118 for (size_t i = max(static_cast<size_t>(1), shadowCount); i--; ) {
1119 // Even if we have no shadows, we still want to run the code below this once. 1119 // Even if we have no shadows, we still want to run the code below this once.
1120 if (i < shadowCount) { 1120 if (i < shadowCount) {
1121 if (!i) { 1121 if (!i) {
1122 // The last set of lines paints normally inside the clip. 1122 // The last set of lines paints normally inside the clip.
1123 localOrigin.move(0, -extraOffset); 1123 localOrigin.move(0, -extraOffset);
1124 extraOffset = 0; 1124 extraOffset = 0;
1125 } 1125 }
1126 const ShadowData& shadow = shadowList->shadows()[i]; 1126 const ShadowData& shadow = shadowList->shadows()[i];
1127 int shadowX = isHorizontal() ? shadow.x() : shadow.y(); 1127 LayoutUnit shadowX = isHorizontal() ? shadow.x() : shadow.y();
1128 int shadowY = isHorizontal() ? shadow.y() : -shadow.x(); 1128 LayoutUnit shadowY = isHorizontal() ? shadow.y() : -shadow.x();
1129 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow .blur(), shadow.color()); 1129 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow .blur(), shadow.color());
1130 } 1130 }
1131 1131
1132 // Offset between lines - always non-zero, so lines never cross each oth er. 1132 // Offset between lines - always non-zero, so lines never cross each oth er.
1133 float doubleOffset = textDecorationThickness + 1.f; 1133 float doubleOffset = textDecorationThickness + 1.f;
1134 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle )); 1134 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle ));
1135 if (deco & TextDecorationUnderline) { 1135 if (deco & TextDecorationUnderline) {
1136 context->setStrokeColor(underline); 1136 context->setStrokeColor(underline);
1137 const int underlineOffset = computeUnderlineOffset(styleToUse->textU nderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness); 1137 const int underlineOffset = computeUnderlineOffset(styleToUse->textU nderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness);
1138 switch (decorationStyle) { 1138 switch (decorationStyle) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); 1565 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj);
1566 const int rendererCharacterOffset = 24; 1566 const int rendererCharacterOffset = 24;
1567 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1567 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1568 fputc(' ', stderr); 1568 fputc(' ', stderr);
1569 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1569 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1570 } 1570 }
1571 1571
1572 #endif 1572 #endif
1573 1573
1574 } // namespace WebCore 1574 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698