OLD | NEW |
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 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 | 1647 |
1648 #endif // NDEBUG | 1648 #endif // NDEBUG |
1649 | 1649 |
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 backgroundColor= Color::transparent; |
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 && resolveColor(pseudoStyle.get(), CSSPropertyBackground
Color).isValid()) | 1660 if (pseudoStyle) { |
1661 color = resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).
blendWithWhite(); | 1661 StyleColor styleColor = resolveCurrentColor(pseudoStyle.get(), CSSPr
opertyBackgroundColor); |
1662 else | 1662 if (styleColor.isValid()) |
1663 color = frame()->selection()->isFocusedAndActive() ? | 1663 return styleColor.color().blendWithWhite(); |
1664 theme()->activeSelectionBackgroundColor() : | 1664 } |
1665 theme()->inactiveSelectionBackgroundColor(); | 1665 |
| 1666 backgroundColor = frame()->selection()->isFocusedAndActive() ? |
| 1667 theme()->activeSelectionBackgroundColor() : |
| 1668 theme()->inactiveSelectionBackgroundColor(); |
1666 } | 1669 } |
1667 | 1670 |
1668 return color; | 1671 return backgroundColor; |
1669 } | 1672 } |
1670 | 1673 |
1671 Color RenderObject::selectionColor(int colorProperty) const | 1674 Color RenderObject::selectionColor(int colorProperty) const |
1672 { | 1675 { |
1673 Color color; | |
1674 // If the element is unselectable, or we are only painting the selection, | 1676 // If the element is unselectable, or we are only painting the selection, |
1675 // don't override the foreground color with the selection foreground color. | 1677 // don't override the foreground color with the selection foreground color. |
1676 if (!shouldUseSelectionColor(*style()) | 1678 if (!shouldUseSelectionColor(*style()) |
1677 || (frame()->view()->paintBehavior() & PaintBehaviorSelectionOnly)) | 1679 || (frame()->view()->paintBehavior() & PaintBehaviorSelectionOnly)) |
1678 return color; | 1680 return Color::transparent; |
1679 | 1681 |
| 1682 Color color; |
1680 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ
est(SELECTION))) { | 1683 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ
est(SELECTION))) { |
1681 Color selectionColor = resolveColor(pseudoStyle.get(), colorProperty); | 1684 StyleColor styleColor = resolveCurrentColor(pseudoStyle.get(), colorProp
erty); |
1682 color = selectionColor.isValid() ? selectionColor : resolveColor(pseudoS
tyle.get(), CSSPropertyColor); | 1685 color = styleColor.isValid() ? styleColor.color() : resolveColor(pseudoS
tyle.get(), CSSPropertyColor); |
1683 } else | 1686 } else |
1684 color = frame()->selection()->isFocusedAndActive() ? | 1687 color = frame()->selection()->isFocusedAndActive() ? |
1685 theme()->activeSelectionForegroundColor() : | 1688 theme()->activeSelectionForegroundColor() : |
1686 theme()->inactiveSelectionForegroundColor(); | 1689 theme()->inactiveSelectionForegroundColor(); |
1687 | 1690 |
1688 return color; | 1691 return color; |
1689 } | 1692 } |
1690 | 1693 |
1691 Color RenderObject::selectionForegroundColor() const | 1694 Color RenderObject::selectionForegroundColor() const |
1692 { | 1695 { |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 return document()->styleResolver()->pseudoStyleForElement(element, pseudoSty
leRequest, parentStyle); | 2866 return document()->styleResolver()->pseudoStyleForElement(element, pseudoSty
leRequest, parentStyle); |
2864 } | 2867 } |
2865 | 2868 |
2866 bool RenderObject::hasBlendMode() const | 2869 bool RenderObject::hasBlendMode() const |
2867 { | 2870 { |
2868 return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style()
->hasBlendMode(); | 2871 return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style()
->hasBlendMode(); |
2869 } | 2872 } |
2870 | 2873 |
2871 static Color decorationColor(const RenderObject* object, RenderStyle* style) | 2874 static Color decorationColor(const RenderObject* object, RenderStyle* style) |
2872 { | 2875 { |
2873 Color result; | 2876 StyleColor result; |
2874 // Check for text decoration color first. | 2877 // Check for text decoration color first. |
2875 result = object->resolveColor(style, CSSPropertyTextDecorationColor); | 2878 result = object->resolveStyleColor(style, CSSPropertyTextDecorationColor); |
2876 if (result.isValid()) | 2879 if (result.isValid()) |
2877 return result; | 2880 return result.color(); |
2878 if (style->textStrokeWidth() > 0) { | 2881 if (style->textStrokeWidth() > 0) { |
2879 // Prefer stroke color if possible but not if it's fully transparent. | 2882 // Prefer stroke color if possible but not if it's fully transparent. |
2880 result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor); | 2883 result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor); |
2881 if (result.alpha()) | 2884 if (result.alpha()) |
2882 return result; | 2885 return result.color(); |
2883 } | 2886 } |
2884 | 2887 |
2885 result = object->resolveColor(style, CSSPropertyWebkitTextFillColor); | 2888 result = object->resolveColor(style, CSSPropertyWebkitTextFillColor); |
2886 return result; | 2889 return result.color(); |
2887 } | 2890 } |
2888 | 2891 |
2889 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co
lor& overline, | 2892 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co
lor& overline, |
2890 Color& linethrough, bool quirksMode,
bool firstlineStyle) | 2893 Color& linethrough, bool quirksMode,
bool firstlineStyle) |
2891 { | 2894 { |
2892 RenderObject* curr = this; | 2895 RenderObject* curr = this; |
2893 RenderStyle* styleToUse = 0; | 2896 RenderStyle* styleToUse = 0; |
2894 TextDecoration currDecs = TextDecorationNone; | 2897 TextDecoration currDecs = TextDecorationNone; |
2895 Color resultColor; | 2898 Color resultColor; |
2896 do { | 2899 do { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3280 { | 3283 { |
3281 if (object1) { | 3284 if (object1) { |
3282 const WebCore::RenderObject* root = object1; | 3285 const WebCore::RenderObject* root = object1; |
3283 while (root->parent()) | 3286 while (root->parent()) |
3284 root = root->parent(); | 3287 root = root->parent(); |
3285 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3288 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3286 } | 3289 } |
3287 } | 3290 } |
3288 | 3291 |
3289 #endif | 3292 #endif |
OLD | NEW |