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

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

Issue 19697011: Change rendering code to use RenderObject::resolveColor (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
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderTable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 break; 1109 break;
1110 } 1110 }
1111 } 1111 }
1112 } 1112 }
1113 1113
1114 void RenderObject::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& paint Offset, RenderStyle* style) 1114 void RenderObject::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& paint Offset, RenderStyle* style)
1115 { 1115 {
1116 Vector<IntRect> focusRingRects; 1116 Vector<IntRect> focusRingRects;
1117 addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer); 1117 addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
1118 if (style->outlineStyleIsAuto()) 1118 if (style->outlineStyleIsAuto())
1119 paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), style->visitedDependentColor(CSSPropertyOutlineColor)); 1119 paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), resolveColor(style, CSSPropertyOutlineColor));
1120 else 1120 else
1121 addPDFURLRect(paintInfo.context, unionRect(focusRingRects)); 1121 addPDFURLRect(paintInfo.context, unionRect(focusRingRects));
1122 } 1122 }
1123 1123
1124 void RenderObject::addPDFURLRect(GraphicsContext* context, const LayoutRect& rec t) 1124 void RenderObject::addPDFURLRect(GraphicsContext* context, const LayoutRect& rec t)
1125 { 1125 {
1126 if (rect.isEmpty()) 1126 if (rect.isEmpty())
1127 return; 1127 return;
1128 Node* n = node(); 1128 Node* n = node();
1129 if (!n || !n->isLink() || !n->isElementNode()) 1129 if (!n || !n->isLink() || !n->isElementNode())
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 inner.inflate(outlineOffset); 1167 inner.inflate(outlineOffset);
1168 1168
1169 IntRect outer = pixelSnappedIntRect(inner); 1169 IntRect outer = pixelSnappedIntRect(inner);
1170 outer.inflate(outlineWidth); 1170 outer.inflate(outlineWidth);
1171 1171
1172 // FIXME: This prevents outlines from painting inside the object. See bug 12 042 1172 // FIXME: This prevents outlines from painting inside the object. See bug 12 042
1173 if (outer.isEmpty()) 1173 if (outer.isEmpty())
1174 return; 1174 return;
1175 1175
1176 EBorderStyle outlineStyle = styleToUse->outlineStyle(); 1176 EBorderStyle outlineStyle = styleToUse->outlineStyle();
1177 Color outlineColor = styleToUse->visitedDependentColor(CSSPropertyOutlineCol or); 1177 Color outlineColor = resolveColor(styleToUse, CSSPropertyOutlineColor);
1178 1178
1179 GraphicsContext* graphicsContext = paintInfo.context; 1179 GraphicsContext* graphicsContext = paintInfo.context;
1180 bool useTransparencyLayer = outlineColor.hasAlpha(); 1180 bool useTransparencyLayer = outlineColor.hasAlpha();
1181 if (useTransparencyLayer) { 1181 if (useTransparencyLayer) {
1182 if (outlineStyle == SOLID) { 1182 if (outlineStyle == SOLID) {
1183 Path path; 1183 Path path;
1184 path.addRect(outer); 1184 path.addRect(outer);
1185 path.addRect(inner); 1185 path.addRect(inner);
1186 graphicsContext->setFillRule(RULE_EVENODD); 1186 graphicsContext->setFillRule(RULE_EVENODD);
1187 graphicsContext->setFillColor(outlineColor); 1187 graphicsContext->setFillColor(outlineColor);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 static bool shouldUseSelectionColor(const RenderStyle& style) 1650 static bool shouldUseSelectionColor(const RenderStyle& style)
1651 { 1651 {
1652 return style.userSelect() != SELECT_NONE || style.userModify() != READ_ONLY; 1652 return style.userSelect() != SELECT_NONE || style.userModify() != READ_ONLY;
1653 } 1653 }
1654 1654
1655 Color RenderObject::selectionBackgroundColor() const 1655 Color RenderObject::selectionBackgroundColor() const
1656 { 1656 {
1657 Color color; 1657 Color color;
1658 if (shouldUseSelectionColor(*style())) { 1658 if (shouldUseSelectionColor(*style())) {
1659 RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION)); 1659 RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION));
1660 if (pseudoStyle && pseudoStyle->visitedDependentColor(CSSPropertyBackgro undColor).isValid()) 1660 if (pseudoStyle && resolveColor(pseudoStyle.get(), CSSPropertyBackground Color).isValid())
1661 color = pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColo r).blendWithWhite(); 1661 color = resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor). blendWithWhite();
1662 else 1662 else
1663 color = frame()->selection()->isFocusedAndActive() ? 1663 color = frame()->selection()->isFocusedAndActive() ?
1664 theme()->activeSelectionBackgroundColor() : 1664 theme()->activeSelectionBackgroundColor() :
1665 theme()->inactiveSelectionBackgroundColor(); 1665 theme()->inactiveSelectionBackgroundColor();
1666 } 1666 }
1667 1667
1668 return color; 1668 return color;
1669 } 1669 }
1670 1670
1671 Color RenderObject::selectionColor(int colorProperty) const 1671 Color RenderObject::selectionColor(int colorProperty) const
1672 { 1672 {
1673 Color color; 1673 Color color;
1674 // If the element is unselectable, or we are only painting the selection, 1674 // If the element is unselectable, or we are only painting the selection,
1675 // don't override the foreground color with the selection foreground color. 1675 // don't override the foreground color with the selection foreground color.
1676 if (!shouldUseSelectionColor(*style()) 1676 if (!shouldUseSelectionColor(*style())
1677 || (frame()->view()->paintBehavior() & PaintBehaviorSelectionOnly)) 1677 || (frame()->view()->paintBehavior() & PaintBehaviorSelectionOnly))
1678 return color; 1678 return color;
1679 1679
1680 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) { 1680 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) {
1681 color = pseudoStyle->visitedDependentColor(colorProperty); 1681 Color selectionColor = resolveColor(pseudoStyle.get(), colorProperty);
1682 if (!color.isValid()) 1682 color = selectionColor.isValid() ? selectionColor : resolveColor(pseudoS tyle.get(), CSSPropertyColor);
1683 color = pseudoStyle->visitedDependentColor(CSSPropertyColor);
1684 } else 1683 } else
1685 color = frame()->selection()->isFocusedAndActive() ? 1684 color = frame()->selection()->isFocusedAndActive() ?
1686 theme()->activeSelectionForegroundColor() : 1685 theme()->activeSelectionForegroundColor() :
1687 theme()->inactiveSelectionForegroundColor(); 1686 theme()->inactiveSelectionForegroundColor();
1688 1687
1689 return color; 1688 return color;
1690 } 1689 }
1691 1690
1692 Color RenderObject::selectionForegroundColor() const 1691 Color RenderObject::selectionForegroundColor() const
1693 { 1692 {
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 } 2807 }
2809 2808
2810 return document()->styleResolver()->pseudoStyleForElement(element, pseudoSty leRequest, parentStyle); 2809 return document()->styleResolver()->pseudoStyleForElement(element, pseudoSty leRequest, parentStyle);
2811 } 2810 }
2812 2811
2813 bool RenderObject::hasBlendMode() const 2812 bool RenderObject::hasBlendMode() const
2814 { 2813 {
2815 return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style() ->hasBlendMode(); 2814 return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style() ->hasBlendMode();
2816 } 2815 }
2817 2816
2818 static Color decorationColor(RenderStyle* style) 2817 static Color decorationColor(const RenderObject* object, RenderStyle* style)
2819 { 2818 {
2820 Color result; 2819 Color result;
2821 // Check for text decoration color first. 2820 // Check for text decoration color first.
2822 result = style->visitedDependentColor(CSSPropertyTextDecorationColor); 2821 result = object->resolveColor(style, CSSPropertyTextDecorationColor);
2823 if (result.isValid()) 2822 if (result.isValid())
2824 return result; 2823 return result;
2825 if (style->textStrokeWidth() > 0) { 2824 if (style->textStrokeWidth() > 0) {
2826 // Prefer stroke color if possible but not if it's fully transparent. 2825 // Prefer stroke color if possible but not if it's fully transparent.
2827 result = style->visitedDependentColor(CSSPropertyWebkitTextStrokeColor); 2826 result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor);
2828 if (result.alpha()) 2827 if (result.alpha())
2829 return result; 2828 return result;
2830 } 2829 }
2831 2830
2832 result = style->visitedDependentColor(CSSPropertyWebkitTextFillColor); 2831 result = object->resolveColor(style, CSSPropertyWebkitTextFillColor);
2833 return result; 2832 return result;
2834 } 2833 }
2835 2834
2836 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co lor& overline, 2835 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co lor& overline,
2837 Color& linethrough, bool quirksMode, bool firstlineStyle) 2836 Color& linethrough, bool quirksMode, bool firstlineStyle)
2838 { 2837 {
2839 RenderObject* curr = this; 2838 RenderObject* curr = this;
2840 RenderStyle* styleToUse = 0; 2839 RenderStyle* styleToUse = 0;
2841 TextDecoration currDecs = TextDecorationNone; 2840 TextDecoration currDecs = TextDecorationNone;
2842 Color resultColor; 2841 Color resultColor;
2843 do { 2842 do {
2844 styleToUse = curr->style(firstlineStyle); 2843 styleToUse = curr->style(firstlineStyle);
2845 currDecs = styleToUse->textDecoration(); 2844 currDecs = styleToUse->textDecoration();
2846 resultColor = decorationColor(styleToUse); 2845 resultColor = decorationColor(this, styleToUse);
2847 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below. 2846 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below.
2848 if (currDecs) { 2847 if (currDecs) {
2849 if (currDecs & TextDecorationUnderline) { 2848 if (currDecs & TextDecorationUnderline) {
2850 decorations &= ~TextDecorationUnderline; 2849 decorations &= ~TextDecorationUnderline;
2851 underline = resultColor; 2850 underline = resultColor;
2852 } 2851 }
2853 if (currDecs & TextDecorationOverline) { 2852 if (currDecs & TextDecorationOverline) {
2854 decorations &= ~TextDecorationOverline; 2853 decorations &= ~TextDecorationOverline;
2855 overline = resultColor; 2854 overline = resultColor;
2856 } 2855 }
2857 if (currDecs & TextDecorationLineThrough) { 2856 if (currDecs & TextDecorationLineThrough) {
2858 decorations &= ~TextDecorationLineThrough; 2857 decorations &= ~TextDecorationLineThrough;
2859 linethrough = resultColor; 2858 linethrough = resultColor;
2860 } 2859 }
2861 } 2860 }
2862 if (curr->isRubyText()) 2861 if (curr->isRubyText())
2863 return; 2862 return;
2864 curr = curr->parent(); 2863 curr = curr->parent();
2865 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n()) 2864 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n())
2866 curr = toRenderBlock(curr)->continuation(); 2865 curr = toRenderBlock(curr)->continuation();
2867 } while (curr && decorations && (!quirksMode || !curr->node() || (!isHTMLAnc horElement(curr->node()) && !curr->node()->hasTagName(fontTag)))); 2866 } while (curr && decorations && (!quirksMode || !curr->node() || (!isHTMLAnc horElement(curr->node()) && !curr->node()->hasTagName(fontTag))));
2868 2867
2869 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element). 2868 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
2870 if (decorations && curr) { 2869 if (decorations && curr) {
2871 styleToUse = curr->style(firstlineStyle); 2870 styleToUse = curr->style(firstlineStyle);
2872 resultColor = decorationColor(styleToUse); 2871 resultColor = decorationColor(this, styleToUse);
2873 if (decorations & TextDecorationUnderline) 2872 if (decorations & TextDecorationUnderline)
2874 underline = resultColor; 2873 underline = resultColor;
2875 if (decorations & TextDecorationOverline) 2874 if (decorations & TextDecorationOverline)
2876 overline = resultColor; 2875 overline = resultColor;
2877 if (decorations & TextDecorationLineThrough) 2876 if (decorations & TextDecorationLineThrough)
2878 linethrough = resultColor; 2877 linethrough = resultColor;
2879 } 2878 }
2880 } 2879 }
2881 2880
2882 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) 2881 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 { 3199 {
3201 if (object1) { 3200 if (object1) {
3202 const WebCore::RenderObject* root = object1; 3201 const WebCore::RenderObject* root = object1;
3203 while (root->parent()) 3202 while (root->parent())
3204 root = root->parent(); 3203 root = root->parent();
3205 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3204 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3206 } 3205 }
3207 } 3206 }
3208 3207
3209 #endif 3208 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698