| OLD | NEW |
| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // Text shadows are disabled when printing. http://crbug.com/258321 | 394 // Text shadows are disabled when printing. http://crbug.com/258321 |
| 395 bool hasShadow = shadow && !context->printing(); | 395 bool hasShadow = shadow && !context->printing(); |
| 396 Color fillColor = context->fillColor(); | 396 Color fillColor = context->fillColor(); |
| 397 | 397 |
| 398 if (hasShadow) { | 398 if (hasShadow) { |
| 399 DrawLooper drawLooper; | 399 DrawLooper drawLooper; |
| 400 do { | 400 do { |
| 401 int shadowX = horizontal ? shadow->x() : shadow->y(); | 401 int shadowX = horizontal ? shadow->x() : shadow->y(); |
| 402 int shadowY = horizontal ? shadow->y() : -shadow->x(); | 402 int shadowY = horizontal ? shadow->y() : -shadow->x(); |
| 403 FloatSize offset(shadowX, shadowY); | 403 FloatSize offset(shadowX, shadowY); |
| 404 drawLooper.addShadow(offset, shadow->blur(), | 404 drawLooper.addShadow(offset, shadow->blur(), renderer->resolveColor(
shadow->color()), |
| 405 renderer->resolveColor(shadow->color(), Color::stdShadowColor), | |
| 406 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); | 405 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); |
| 407 } while ((shadow = shadow->next())); | 406 } while ((shadow = shadow->next())); |
| 408 drawLooper.addUnmodifiedContent(); | 407 drawLooper.addUnmodifiedContent(); |
| 409 context->setDrawLooper(drawLooper); | 408 context->setDrawLooper(drawLooper); |
| 410 } | 409 } |
| 411 | 410 |
| 412 TextRunPaintInfo textRunPaintInfo(textRun); | 411 TextRunPaintInfo textRunPaintInfo(textRun); |
| 413 textRunPaintInfo.bounds = boxRect; | 412 textRunPaintInfo.bounds = boxRect; |
| 414 if (startOffset <= endOffset) { | 413 if (startOffset <= endOffset) { |
| 415 textRunPaintInfo.from = startOffset; | 414 textRunPaintInfo.from = startOffset; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 bool paintSelectedTextSeparately = false; | 584 bool paintSelectedTextSeparately = false; |
| 586 | 585 |
| 587 Color selectionFillColor = textFillColor; | 586 Color selectionFillColor = textFillColor; |
| 588 Color selectionStrokeColor = textStrokeColor; | 587 Color selectionStrokeColor = textStrokeColor; |
| 589 Color selectionEmphasisMarkColor = emphasisMarkColor; | 588 Color selectionEmphasisMarkColor = emphasisMarkColor; |
| 590 float selectionStrokeWidth = textStrokeWidth; | 589 float selectionStrokeWidth = textStrokeWidth; |
| 591 const ShadowData* selectionShadow = textShadow; | 590 const ShadowData* selectionShadow = textShadow; |
| 592 if (haveSelection) { | 591 if (haveSelection) { |
| 593 // Check foreground color first. | 592 // Check foreground color first. |
| 594 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer(
)->selectionForegroundColor(); | 593 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer(
)->selectionForegroundColor(); |
| 595 if (foreground != Color::transparent && foreground != selectionFillColor
) { | 594 if (foreground.isValid() && foreground != selectionFillColor) { |
| 596 if (!paintSelectedTextOnly) | 595 if (!paintSelectedTextOnly) |
| 597 paintSelectedTextSeparately = true; | 596 paintSelectedTextSeparately = true; |
| 598 selectionFillColor = foreground; | 597 selectionFillColor = foreground; |
| 599 } | 598 } |
| 600 | 599 |
| 601 Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black
: renderer()->selectionEmphasisMarkColor(); | 600 Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black
: renderer()->selectionEmphasisMarkColor(); |
| 602 if (emphasisMarkForeground != Color::transparent && emphasisMarkForegrou
nd != selectionEmphasisMarkColor) { | 601 if (emphasisMarkForeground.isValid() && emphasisMarkForeground != select
ionEmphasisMarkColor) { |
| 603 if (!paintSelectedTextOnly) | 602 if (!paintSelectedTextOnly) |
| 604 paintSelectedTextSeparately = true; | 603 paintSelectedTextSeparately = true; |
| 605 selectionEmphasisMarkColor = emphasisMarkForeground; | 604 selectionEmphasisMarkColor = emphasisMarkForeground; |
| 606 } | 605 } |
| 607 | 606 |
| 608 if (RenderStyle* pseudoStyle = renderer()->getCachedPseudoStyle(SELECTIO
N)) { | 607 if (RenderStyle* pseudoStyle = renderer()->getCachedPseudoStyle(SELECTIO
N)) { |
| 609 // Text shadows are disabled when printing. http://crbug.com/258321 | 608 // Text shadows are disabled when printing. http://crbug.com/258321 |
| 610 const ShadowData* shadow = (context->printing() || paintInfo.forceBl
ackText()) ? 0 : pseudoStyle->textShadow(); | 609 const ShadowData* shadow = (context->printing() || paintInfo.forceBl
ackText()) ? 0 : pseudoStyle->textShadow(); |
| 611 if (shadow != selectionShadow) { | 610 if (shadow != selectionShadow) { |
| 612 if (!paintSelectedTextOnly) | 611 if (!paintSelectedTextOnly) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 if (context->paintingDisabled()) | 831 if (context->paintingDisabled()) |
| 833 return; | 832 return; |
| 834 | 833 |
| 835 // See if we have a selection to paint at all. | 834 // See if we have a selection to paint at all. |
| 836 int sPos, ePos; | 835 int sPos, ePos; |
| 837 selectionStartEnd(sPos, ePos); | 836 selectionStartEnd(sPos, ePos); |
| 838 if (sPos >= ePos) | 837 if (sPos >= ePos) |
| 839 return; | 838 return; |
| 840 | 839 |
| 841 Color c = renderer()->selectionBackgroundColor(); | 840 Color c = renderer()->selectionBackgroundColor(); |
| 842 if (!c.alpha()) | 841 if (!c.isValid() || !c.alpha()) |
| 843 return; | 842 return; |
| 844 | 843 |
| 845 // If the text color ends up being the same as the selection background, inv
ert the selection | 844 // If the text color ends up being the same as the selection background, inv
ert the selection |
| 846 // background. | 845 // background. |
| 847 if (textColor == c) | 846 if (textColor == c) |
| 848 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); | 847 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); |
| 849 | 848 |
| 850 GraphicsContextStateSaver stateSaver(*context); | 849 GraphicsContextStateSaver stateSaver(*context); |
| 851 updateGraphicsContext(context, c, c, 0); // Don't draw text at all! | 850 updateGraphicsContext(context, c, c, 0); // Don't draw text at all! |
| 852 | 851 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 | 1125 |
| 1127 do { | 1126 do { |
| 1128 if (shadow) { | 1127 if (shadow) { |
| 1129 if (!shadow->next()) { | 1128 if (!shadow->next()) { |
| 1130 // The last set of lines paints normally inside the clip. | 1129 // The last set of lines paints normally inside the clip. |
| 1131 localOrigin.move(0, -extraOffset); | 1130 localOrigin.move(0, -extraOffset); |
| 1132 extraOffset = 0; | 1131 extraOffset = 0; |
| 1133 } | 1132 } |
| 1134 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); | 1133 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); |
| 1135 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); | 1134 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); |
| 1136 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow
->blur(), | 1135 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow
->blur(), shadow->color()); |
| 1137 renderer()->resolveColor(shadow->color(), Color::stdShadowColor)
); | |
| 1138 shadow = shadow->next(); | 1136 shadow = shadow->next(); |
| 1139 } | 1137 } |
| 1140 | 1138 |
| 1141 // Offset between lines - always non-zero, so lines never cross each oth
er. | 1139 // Offset between lines - always non-zero, so lines never cross each oth
er. |
| 1142 float doubleOffset = textDecorationThickness + 1.f; | 1140 float doubleOffset = textDecorationThickness + 1.f; |
| 1143 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle
)); | 1141 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle
)); |
| 1144 if (deco & TextDecorationUnderline) { | 1142 if (deco & TextDecorationUnderline) { |
| 1145 context->setStrokeColor(underline); | 1143 context->setStrokeColor(underline); |
| 1146 #if ENABLE(CSS3_TEXT) | 1144 #if ENABLE(CSS3_TEXT) |
| 1147 TextUnderlinePosition underlinePosition = styleToUse->textUnderlineP
osition(); | 1145 TextUnderlinePosition underlinePosition = styleToUse->textUnderlineP
osition(); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1557 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
| 1560 const int rendererCharacterOffset = 24; | 1558 const int rendererCharacterOffset = 24; |
| 1561 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1559 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1562 fputc(' ', stderr); | 1560 fputc(' ', stderr); |
| 1563 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1561 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 1564 } | 1562 } |
| 1565 | 1563 |
| 1566 #endif | 1564 #endif |
| 1567 | 1565 |
| 1568 } // namespace WebCore | 1566 } // namespace WebCore |
| OLD | NEW |