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

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

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // Text shadows are disabled when printing. http://crbug.com/258321 402 // Text shadows are disabled when printing. http://crbug.com/258321
403 bool hasShadow = shadow && !context->printing(); 403 bool hasShadow = shadow && !context->printing();
404 Color fillColor = context->fillColor(); 404 Color fillColor = context->fillColor();
405 405
406 if (hasShadow) { 406 if (hasShadow) {
407 DrawLooper drawLooper; 407 DrawLooper drawLooper;
408 do { 408 do {
409 int shadowX = horizontal ? shadow->x() : shadow->y(); 409 int shadowX = horizontal ? shadow->x() : shadow->y();
410 int shadowY = horizontal ? shadow->y() : -shadow->x(); 410 int shadowY = horizontal ? shadow->y() : -shadow->x();
411 FloatSize offset(shadowX, shadowY); 411 FloatSize offset(shadowX, shadowY);
412 drawLooper.addShadow(offset, shadow->blur(), renderer->resolveColor( shadow->color()), 412 drawLooper.addShadow(offset, shadow->blur(),
413 renderer->resolveColor(shadow->color(), Color::stdShadowColor),
413 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA lpha); 414 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA lpha);
414 } while ((shadow = shadow->next())); 415 } while ((shadow = shadow->next()));
415 drawLooper.addUnmodifiedContent(); 416 drawLooper.addUnmodifiedContent();
416 context->setDrawLooper(drawLooper); 417 context->setDrawLooper(drawLooper);
417 } 418 }
418 419
419 TextRunPaintInfo textRunPaintInfo(textRun); 420 TextRunPaintInfo textRunPaintInfo(textRun);
420 textRunPaintInfo.bounds = boxRect; 421 textRunPaintInfo.bounds = boxRect;
421 if (startOffset <= endOffset) { 422 if (startOffset <= endOffset) {
422 textRunPaintInfo.from = startOffset; 423 textRunPaintInfo.from = startOffset;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 bool paintSelectedTextSeparately = false; 593 bool paintSelectedTextSeparately = false;
593 594
594 Color selectionFillColor = textFillColor; 595 Color selectionFillColor = textFillColor;
595 Color selectionStrokeColor = textStrokeColor; 596 Color selectionStrokeColor = textStrokeColor;
596 Color selectionEmphasisMarkColor = emphasisMarkColor; 597 Color selectionEmphasisMarkColor = emphasisMarkColor;
597 float selectionStrokeWidth = textStrokeWidth; 598 float selectionStrokeWidth = textStrokeWidth;
598 const ShadowData* selectionShadow = textShadow; 599 const ShadowData* selectionShadow = textShadow;
599 if (haveSelection) { 600 if (haveSelection) {
600 // Check foreground color first. 601 // Check foreground color first.
601 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer( )->selectionForegroundColor(); 602 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer( )->selectionForegroundColor();
602 if (foreground.isValid() && foreground != selectionFillColor) { 603 if (foreground != Color::transparent && foreground != selectionFillColor ) {
603 if (!paintSelectedTextOnly) 604 if (!paintSelectedTextOnly)
604 paintSelectedTextSeparately = true; 605 paintSelectedTextSeparately = true;
605 selectionFillColor = foreground; 606 selectionFillColor = foreground;
606 } 607 }
607 608
608 Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionEmphasisMarkColor(); 609 Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionEmphasisMarkColor();
609 if (emphasisMarkForeground.isValid() && emphasisMarkForeground != select ionEmphasisMarkColor) { 610 if (emphasisMarkForeground != Color::transparent && emphasisMarkForegrou nd != selectionEmphasisMarkColor) {
610 if (!paintSelectedTextOnly) 611 if (!paintSelectedTextOnly)
611 paintSelectedTextSeparately = true; 612 paintSelectedTextSeparately = true;
612 selectionEmphasisMarkColor = emphasisMarkForeground; 613 selectionEmphasisMarkColor = emphasisMarkForeground;
613 } 614 }
614 615
615 if (RenderStyle* pseudoStyle = renderer()->getCachedPseudoStyle(SELECTIO N)) { 616 if (RenderStyle* pseudoStyle = renderer()->getCachedPseudoStyle(SELECTIO N)) {
616 // Text shadows are disabled when printing. http://crbug.com/258321 617 // Text shadows are disabled when printing. http://crbug.com/258321
617 const ShadowData* shadow = (context->printing() || paintInfo.forceBl ackText()) ? 0 : pseudoStyle->textShadow(); 618 const ShadowData* shadow = (context->printing() || paintInfo.forceBl ackText()) ? 0 : pseudoStyle->textShadow();
618 if (shadow != selectionShadow) { 619 if (shadow != selectionShadow) {
619 if (!paintSelectedTextOnly) 620 if (!paintSelectedTextOnly)
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 if (context->paintingDisabled()) 839 if (context->paintingDisabled())
839 return; 840 return;
840 841
841 // See if we have a selection to paint at all. 842 // See if we have a selection to paint at all.
842 int sPos, ePos; 843 int sPos, ePos;
843 selectionStartEnd(sPos, ePos); 844 selectionStartEnd(sPos, ePos);
844 if (sPos >= ePos) 845 if (sPos >= ePos)
845 return; 846 return;
846 847
847 Color c = renderer()->selectionBackgroundColor(); 848 Color c = renderer()->selectionBackgroundColor();
848 if (!c.isValid() || c.alpha() == 0) 849 if (!c.alpha())
849 return; 850 return;
850 851
851 // If the text color ends up being the same as the selection background, inv ert the selection 852 // If the text color ends up being the same as the selection background, inv ert the selection
852 // background. 853 // background.
853 if (textColor == c) 854 if (textColor == c)
854 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); 855 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
855 856
856 GraphicsContextStateSaver stateSaver(*context); 857 GraphicsContextStateSaver stateSaver(*context);
857 updateGraphicsContext(context, c, c, 0); // Don't draw text at all! 858 updateGraphicsContext(context, c, c, 0); // Don't draw text at all!
858 859
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1133
1133 do { 1134 do {
1134 if (shadow) { 1135 if (shadow) {
1135 if (!shadow->next()) { 1136 if (!shadow->next()) {
1136 // The last set of lines paints normally inside the clip. 1137 // The last set of lines paints normally inside the clip.
1137 localOrigin.move(0, -extraOffset); 1138 localOrigin.move(0, -extraOffset);
1138 extraOffset = 0; 1139 extraOffset = 0;
1139 } 1140 }
1140 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); 1141 int shadowX = isHorizontal() ? shadow->x() : shadow->y();
1141 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); 1142 int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
1142 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow ->blur(), shadow->color()); 1143 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow ->blur(),
1144 renderer()->resolveColor(shadow->color(), Color::stdShadowColor) );
1143 shadow = shadow->next(); 1145 shadow = shadow->next();
1144 } 1146 }
1145 1147
1146 // Offset between lines - always non-zero, so lines never cross each oth er. 1148 // Offset between lines - always non-zero, so lines never cross each oth er.
1147 float doubleOffset = textDecorationThickness + 1.f; 1149 float doubleOffset = textDecorationThickness + 1.f;
1148 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle )); 1150 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle ));
1149 if (deco & TextDecorationUnderline) { 1151 if (deco & TextDecorationUnderline) {
1150 context->setStrokeColor(underline); 1152 context->setStrokeColor(underline);
1151 #if ENABLE(CSS3_TEXT) 1153 #if ENABLE(CSS3_TEXT)
1152 TextUnderlinePosition underlinePosition = styleToUse->textUnderlineP osition(); 1154 TextUnderlinePosition underlinePosition = styleToUse->textUnderlineP osition();
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); 1559 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj);
1558 const int rendererCharacterOffset = 24; 1560 const int rendererCharacterOffset = 24;
1559 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1561 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1560 fputc(' ', stderr); 1562 fputc(' ', stderr);
1561 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1563 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1562 } 1564 }
1563 1565
1564 #endif 1566 #endif
1565 1567
1566 } // namespace WebCore 1568 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698