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

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

Issue 23581008: Revert r154797: "Move isValid/isCurrentColor from Color to StyleColor" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 * 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 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 1655
1656 #endif // NDEBUG 1656 #endif // NDEBUG
1657 1657
1658 bool RenderObject::isSelectable() const 1658 bool RenderObject::isSelectable() const
1659 { 1659 {
1660 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user Modify() == READ_ONLY); 1660 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user Modify() == READ_ONLY);
1661 } 1661 }
1662 1662
1663 Color RenderObject::selectionBackgroundColor() const 1663 Color RenderObject::selectionBackgroundColor() const
1664 { 1664 {
1665 Color backgroundColor= Color::transparent; 1665 Color backgroundColor;
1666 if (isSelectable()) { 1666 if (isSelectable()) {
1667 RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION)); 1667 RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION));
1668 if (pseudoStyle) { 1668 if (pseudoStyle && resolveColor(pseudoStyle.get(), CSSPropertyBackground Color).isValid()) {
1669 StyleColor styleColor = resolveCurrentColor(pseudoStyle.get(), CSSPr opertyBackgroundColor); 1669 backgroundColor = resolveColor(pseudoStyle.get(), CSSPropertyBackgro undColor).blendWithWhite();
1670 if (styleColor.isValid()) 1670 } else {
1671 return styleColor.color().blendWithWhite(); 1671 backgroundColor = frame()->selection().isFocusedAndActive() ?
1672 RenderTheme::theme().activeSelectionBackgroundColor() :
1673 RenderTheme::theme().inactiveSelectionBackgroundColor();
1672 } 1674 }
1673
1674 backgroundColor = frame()->selection().isFocusedAndActive() ?
1675 RenderTheme::theme().activeSelectionBackgroundColor() :
1676 RenderTheme::theme().inactiveSelectionBackgroundColor();
1677 } 1675 }
1678 1676
1679 return backgroundColor; 1677 return backgroundColor;
1680 } 1678 }
1681 1679
1682 Color RenderObject::selectionColor(int colorProperty) const 1680 Color RenderObject::selectionColor(int colorProperty) const
1683 { 1681 {
1684 // If the element is unselectable, or we are only painting the selection, 1682 // If the element is unselectable, or we are only painting the selection,
1685 // don't override the foreground color with the selection foreground color. 1683 // don't override the foreground color with the selection foreground color.
1686 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele ctionOnly)) 1684 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele ctionOnly))
1687 return Color::transparent; 1685 return Color::transparent;
1688 1686
1689 Color color; 1687 Color color;
1690 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) { 1688 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) {
1691 StyleColor styleColor = resolveCurrentColor(pseudoStyle.get(), colorProp erty); 1689 Color selectionColor = resolveColor(pseudoStyle.get(), colorProperty);
1692 color = styleColor.isValid() ? styleColor.color() : resolveColor(pseudoS tyle.get(), CSSPropertyColor); 1690 color = selectionColor.isValid() ? selectionColor : resolveColor(pseudoS tyle.get(), CSSPropertyColor);
1693 } else { 1691 } else {
1694 color = frame()->selection().isFocusedAndActive() ? 1692 color = frame()->selection().isFocusedAndActive() ?
1695 RenderTheme::theme().activeSelectionForegroundColor() : 1693 RenderTheme::theme().activeSelectionForegroundColor() :
1696 RenderTheme::theme().inactiveSelectionForegroundColor(); 1694 RenderTheme::theme().inactiveSelectionForegroundColor();
1697 } 1695 }
1696
1698 return color; 1697 return color;
1699 } 1698 }
1700 1699
1701 Color RenderObject::selectionForegroundColor() const 1700 Color RenderObject::selectionForegroundColor() const
1702 { 1701 {
1703 return selectionColor(CSSPropertyWebkitTextFillColor); 1702 return selectionColor(CSSPropertyWebkitTextFillColor);
1704 } 1703 }
1705 1704
1706 Color RenderObject::selectionEmphasisMarkColor() const 1705 Color RenderObject::selectionEmphasisMarkColor() const
1707 { 1706 {
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 return document().styleResolver()->pseudoStyleForElement(element, pseudoStyl eRequest, parentStyle); 2902 return document().styleResolver()->pseudoStyleForElement(element, pseudoStyl eRequest, parentStyle);
2904 } 2903 }
2905 2904
2906 bool RenderObject::hasBlendMode() const 2905 bool RenderObject::hasBlendMode() const
2907 { 2906 {
2908 return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style() ->hasBlendMode(); 2907 return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style() ->hasBlendMode();
2909 } 2908 }
2910 2909
2911 static Color decorationColor(const RenderObject* object, RenderStyle* style) 2910 static Color decorationColor(const RenderObject* object, RenderStyle* style)
2912 { 2911 {
2913 StyleColor result; 2912 Color result;
2914 // Check for text decoration color first. 2913 // Check for text decoration color first.
2915 result = object->resolveStyleColor(style, CSSPropertyTextDecorationColor); 2914 result = object->resolveColor(style, CSSPropertyTextDecorationColor);
2916 if (result.isValid()) 2915 if (result.isValid())
2917 return result.color(); 2916 return result;
2918 if (style->textStrokeWidth() > 0) { 2917 if (style->textStrokeWidth() > 0) {
2919 // Prefer stroke color if possible but not if it's fully transparent. 2918 // Prefer stroke color if possible but not if it's fully transparent.
2920 result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor); 2919 result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor);
2921 if (result.alpha()) 2920 if (result.alpha())
2922 return result.color(); 2921 return result;
2923 } 2922 }
2924 2923
2925 result = object->resolveColor(style, CSSPropertyWebkitTextFillColor); 2924 result = object->resolveColor(style, CSSPropertyWebkitTextFillColor);
2926 return result.color(); 2925 return result;
2927 } 2926 }
2928 2927
2929 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co lor& overline, 2928 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co lor& overline,
2930 Color& linethrough, bool quirksMode, bool firstlineStyle) 2929 Color& linethrough, bool quirksMode, bool firstlineStyle)
2931 { 2930 {
2932 RenderObject* curr = this; 2931 RenderObject* curr = this;
2933 RenderStyle* styleToUse = 0; 2932 RenderStyle* styleToUse = 0;
2934 TextDecoration currDecs = TextDecorationNone; 2933 TextDecoration currDecs = TextDecorationNone;
2935 Color resultColor; 2934 Color resultColor;
2936 do { 2935 do {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 { 3316 {
3318 if (object1) { 3317 if (object1) {
3319 const WebCore::RenderObject* root = object1; 3318 const WebCore::RenderObject* root = object1;
3320 while (root->parent()) 3319 while (root->parent())
3321 root = root->parent(); 3320 root = root->parent();
3322 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3321 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3323 } 3322 }
3324 } 3323 }
3325 3324
3326 #endif 3325 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698