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

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

Issue 219633002: Proper support for multiple text decorations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Resolve decoration colors dynamically. Created 6 years, 7 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "core/rendering/RenderMarquee.h" 66 #include "core/rendering/RenderMarquee.h"
67 #include "core/rendering/RenderScrollbarPart.h" 67 #include "core/rendering/RenderScrollbarPart.h"
68 #include "core/rendering/RenderTableCaption.h" 68 #include "core/rendering/RenderTableCaption.h"
69 #include "core/rendering/RenderTableCell.h" 69 #include "core/rendering/RenderTableCell.h"
70 #include "core/rendering/RenderTableCol.h" 70 #include "core/rendering/RenderTableCol.h"
71 #include "core/rendering/RenderTableRow.h" 71 #include "core/rendering/RenderTableRow.h"
72 #include "core/rendering/RenderTheme.h" 72 #include "core/rendering/RenderTheme.h"
73 #include "core/rendering/RenderView.h" 73 #include "core/rendering/RenderView.h"
74 #include "core/rendering/compositing/CompositedLayerMapping.h" 74 #include "core/rendering/compositing/CompositedLayerMapping.h"
75 #include "core/rendering/compositing/RenderLayerCompositor.h" 75 #include "core/rendering/compositing/RenderLayerCompositor.h"
76 #include "core/rendering/style/AppliedTextDecoration.h"
76 #include "core/rendering/style/ContentData.h" 77 #include "core/rendering/style/ContentData.h"
77 #include "core/rendering/style/CursorList.h" 78 #include "core/rendering/style/CursorList.h"
78 #include "core/rendering/style/ShadowList.h" 79 #include "core/rendering/style/ShadowList.h"
79 #include "core/rendering/svg/SVGRenderSupport.h" 80 #include "core/rendering/svg/SVGRenderSupport.h"
80 #include "platform/JSONValues.h" 81 #include "platform/JSONValues.h"
81 #include "platform/Partitions.h" 82 #include "platform/Partitions.h"
82 #include "platform/TraceEvent.h" 83 #include "platform/TraceEvent.h"
83 #include "platform/TracedValue.h" 84 #include "platform/TracedValue.h"
84 #include "platform/geometry/TransformState.h" 85 #include "platform/geometry/TransformState.h"
85 #include "platform/graphics/GraphicsContext.h" 86 #include "platform/graphics/GraphicsContext.h"
(...skipping 2946 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 if (style->textStrokeWidth() > 0) { 3033 if (style->textStrokeWidth() > 0) {
3033 // Prefer stroke color if possible but not if it's fully transparent. 3034 // Prefer stroke color if possible but not if it's fully transparent.
3034 Color textStrokeColor = object->resolveColor(style, CSSPropertyWebkitTex tStrokeColor); 3035 Color textStrokeColor = object->resolveColor(style, CSSPropertyWebkitTex tStrokeColor);
3035 if (textStrokeColor.alpha()) 3036 if (textStrokeColor.alpha())
3036 return textStrokeColor; 3037 return textStrokeColor;
3037 } 3038 }
3038 3039
3039 return object->resolveColor(style, CSSPropertyWebkitTextFillColor); 3040 return object->resolveColor(style, CSSPropertyWebkitTextFillColor);
3040 } 3041 }
3041 3042
3042 void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle) 3043 RenderObject::ResolvedDecoration::ResolvedDecoration()
3044 : line(TextDecorationUnderline)
3045 , style(TextDecorationStyleSolid)
3043 { 3046 {
3047 }
3048
3049 RenderObject::ResolvedDecoration::ResolvedDecoration(const AppliedTextDecoration & decoration, const Color& color)
3050 : line(decoration.line())
3051 , style(decoration.style())
3052 , color(color)
3053 {
3054 }
3055
3056 static RenderStyle* decorationStyle(RenderObject* renderObject, bool firstlineSt yle, TextDecoration decoration)
3057 {
3058 RenderStyle* styleToUse = renderObject->style(firstlineStyle);
3059
3060 if (styleToUse->textDecoration() == decoration)
3061 return styleToUse;
3062 if (!firstlineStyle)
3063 return nullptr;
3064
3065 styleToUse = renderObject->style(false);
3066 return styleToUse->textDecoration() == decoration ? styleToUse : nullptr;
3067 }
3068
3069 void RenderObject::resolvedDecorations(bool firstlineStyle, const Vector<Applied TextDecoration>& decorations, ResolvedDecorationVector& resolved)
3070 {
3071 ASSERT(decorations.size());
3072
3073 bool quirksMode = document().inQuirksMode();
3074
3044 RenderObject* curr = this; 3075 RenderObject* curr = this;
3045 RenderStyle* styleToUse = 0; 3076 Vector<AppliedTextDecoration>::const_reverse_iterator decoration = decoratio ns.rbegin();
3046 unsigned currDecs = TextDecorationNone; 3077
3047 Color resultColor;
3048 TextDecorationStyle resultStyle;
3049 do { 3078 do {
3050 styleToUse = curr->style(firstlineStyle); 3079 if (!curr->isText()) {
3051 currDecs = styleToUse->textDecoration(); 3080 RenderStyle* styleToUse = decorationStyle(curr, firstlineStyle, deco ration->line());
3052 currDecs &= decorations; 3081 if (styleToUse) {
3053 resultColor = decorationColor(this, styleToUse); 3082 resolved.append(RenderObject::ResolvedDecoration(*decoration, st yleToUse->visitedDependentDecorationColor()));
3054 resultStyle = styleToUse->textDecorationStyle(); 3083 ++decoration;
3055 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below.
3056 if (currDecs) {
3057 if (currDecs & TextDecorationUnderline) {
3058 decorations &= ~TextDecorationUnderline;
3059 underline.color = resultColor;
3060 underline.style = resultStyle;
3061 }
3062 if (currDecs & TextDecorationOverline) {
3063 decorations &= ~TextDecorationOverline;
3064 overline.color = resultColor;
3065 overline.style = resultStyle;
3066 }
3067 if (currDecs & TextDecorationLineThrough) {
3068 decorations &= ~TextDecorationLineThrough;
3069 linethrough.color = resultColor;
3070 linethrough.style = resultStyle;
3071 } 3084 }
3072 } 3085 }
3073 if (curr->isRubyText())
3074 return;
3075 curr = curr->parent(); 3086 curr = curr->parent();
3076 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n()) 3087 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n())
3077 curr = toRenderBlock(curr)->continuation(); 3088 curr = toRenderBlock(curr)->continuation();
3078 } while (curr && decorations && (!quirksMode || !curr->node() || (!isHTMLAnc horElement(*curr->node()) && !isHTMLFontElement(*curr->node())))); 3089 } while (curr && (decoration != decorations.rend()) && (!quirksMode || !curr ->node() || (!isHTMLAnchorElement(*curr->node()) && !isHTMLFontElement(*curr->no de()))));
3079 3090
3080 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element). 3091 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
3081 if (decorations && curr) { 3092 if (curr && (decoration != decorations.rend())) {
3082 styleToUse = curr->style(firstlineStyle); 3093 RenderStyle* styleToUse = decorationStyle(curr, firstlineStyle, decorati on->line());
3083 resultColor = decorationColor(this, styleToUse); 3094 if (styleToUse)
3084 if (decorations & TextDecorationUnderline) { 3095 resolved.append(RenderObject::ResolvedDecoration(*decoration, styleT oUse->visitedDependentDecorationColor()));
3085 underline.color = resultColor;
3086 underline.style = resultStyle;
3087 }
3088 if (decorations & TextDecorationOverline) {
3089 overline.color = resultColor;
3090 overline.style = resultStyle;
3091 }
3092 if (decorations & TextDecorationLineThrough) {
3093 linethrough.color = resultColor;
3094 linethrough.style = resultStyle;
3095 }
3096 } 3096 }
3097 } 3097 }
3098 3098
3099 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) 3099 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)
3100 { 3100 {
3101 // Convert the style regions to absolute coordinates. 3101 // Convert the style regions to absolute coordinates.
3102 if (style()->visibility() != VISIBLE || !isBox()) 3102 if (style()->visibility() != VISIBLE || !isBox())
3103 return; 3103 return;
3104 3104
3105 if (style()->getDraggableRegionMode() == DraggableRegionNone) 3105 if (style()->getDraggableRegionMode() == DraggableRegionNone)
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 { 3405 {
3406 if (object1) { 3406 if (object1) {
3407 const WebCore::RenderObject* root = object1; 3407 const WebCore::RenderObject* root = object1;
3408 while (root->parent()) 3408 while (root->parent())
3409 root = root->parent(); 3409 root = root->parent();
3410 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3410 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3411 } 3411 }
3412 } 3412 }
3413 3413
3414 #endif 3414 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698