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

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: Fix review issues. 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 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 if (style->textStrokeWidth() > 0) { 3053 if (style->textStrokeWidth() > 0) {
3053 // Prefer stroke color if possible but not if it's fully transparent. 3054 // Prefer stroke color if possible but not if it's fully transparent.
3054 Color textStrokeColor = object->resolveColor(style, CSSPropertyWebkitTex tStrokeColor); 3055 Color textStrokeColor = object->resolveColor(style, CSSPropertyWebkitTex tStrokeColor);
3055 if (textStrokeColor.alpha()) 3056 if (textStrokeColor.alpha())
3056 return textStrokeColor; 3057 return textStrokeColor;
3057 } 3058 }
3058 3059
3059 return object->resolveColor(style, CSSPropertyWebkitTextFillColor); 3060 return object->resolveColor(style, CSSPropertyWebkitTextFillColor);
3060 } 3061 }
3061 3062
3062 void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle) 3063 RenderObject::ResolvedDecoration::ResolvedDecoration()
3064 : line(TextDecorationUnderline)
3065 , style(TextDecorationStyleSolid)
3063 { 3066 {
3067 }
3068
3069 RenderObject::ResolvedDecoration::ResolvedDecoration(const AppliedTextDecoration & decoration, const Color& color)
3070 : line(decoration.line())
3071 , style(decoration.style())
3072 , color(color)
3073 {
3074 }
3075
3076 static RenderStyle* decorationStyle(RenderObject* renderObject, bool firstlineSt yle, TextDecoration decoration)
3077 {
3078 RenderStyle* styleToUse = renderObject->style(firstlineStyle);
3079
3080 if (styleToUse->textDecoration() == decoration)
3081 return styleToUse;
3082 if (!firstlineStyle)
3083 return nullptr;
3084
3085 styleToUse = renderObject->style(false);
3086 return styleToUse->textDecoration() == decoration ? styleToUse : nullptr;
3087 }
3088
3089 void RenderObject::resolvedDecorations(bool firstlineStyle, const Vector<Applied TextDecoration>& decorations, ResolvedDecorationVector& resolved)
3090 {
3091 ASSERT(decorations.size());
3092
3093 bool quirksMode = document().inQuirksMode();
3094
3064 RenderObject* curr = this; 3095 RenderObject* curr = this;
3065 RenderStyle* styleToUse = 0; 3096 Vector<AppliedTextDecoration>::const_reverse_iterator decoration = decoratio ns.rbegin();
3066 unsigned currDecs = TextDecorationNone; 3097
3067 Color resultColor;
3068 TextDecorationStyle resultStyle;
3069 do { 3098 do {
3070 styleToUse = curr->style(firstlineStyle); 3099 if (!curr->isText()) {
3071 currDecs = styleToUse->textDecoration(); 3100 RenderStyle* styleToUse = decorationStyle(curr, firstlineStyle, deco ration->line());
3072 currDecs &= decorations; 3101 if (styleToUse) {
3073 resultColor = decorationColor(this, styleToUse); 3102 resolved.append(RenderObject::ResolvedDecoration(*decoration, st yleToUse->visitedDependentDecorationColor()));
3074 resultStyle = styleToUse->textDecorationStyle(); 3103 ++decoration;
3075 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below.
3076 if (currDecs) {
3077 if (currDecs & TextDecorationUnderline) {
3078 decorations &= ~TextDecorationUnderline;
3079 underline.color = resultColor;
3080 underline.style = resultStyle;
3081 }
3082 if (currDecs & TextDecorationOverline) {
3083 decorations &= ~TextDecorationOverline;
3084 overline.color = resultColor;
3085 overline.style = resultStyle;
3086 }
3087 if (currDecs & TextDecorationLineThrough) {
3088 decorations &= ~TextDecorationLineThrough;
3089 linethrough.color = resultColor;
3090 linethrough.style = resultStyle;
3091 } 3104 }
3092 } 3105 }
3093 if (curr->isRubyText())
3094 return;
3095 curr = curr->parent(); 3106 curr = curr->parent();
3096 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n()) 3107 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n())
3097 curr = toRenderBlock(curr)->continuation(); 3108 curr = toRenderBlock(curr)->continuation();
3098 } while (curr && decorations && (!quirksMode || !curr->node() || (!isHTMLAnc horElement(*curr->node()) && !isHTMLFontElement(*curr->node())))); 3109 } while (curr && (decoration != decorations.rend()) && (!quirksMode || !curr ->node() || (!isHTMLAnchorElement(*curr->node()) && !isHTMLFontElement(*curr->no de()))));
3099 3110
3100 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element). 3111 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
3101 if (decorations && curr) { 3112 if (curr && (decoration != decorations.rend())) {
3102 styleToUse = curr->style(firstlineStyle); 3113 RenderStyle* styleToUse = decorationStyle(curr, firstlineStyle, decorati on->line());
3103 resultColor = decorationColor(this, styleToUse); 3114 if (styleToUse)
3104 if (decorations & TextDecorationUnderline) { 3115 resolved.append(RenderObject::ResolvedDecoration(*decoration, styleT oUse->visitedDependentDecorationColor()));
3105 underline.color = resultColor;
3106 underline.style = resultStyle;
3107 }
3108 if (decorations & TextDecorationOverline) {
3109 overline.color = resultColor;
3110 overline.style = resultStyle;
3111 }
3112 if (decorations & TextDecorationLineThrough) {
3113 linethrough.color = resultColor;
3114 linethrough.style = resultStyle;
3115 }
3116 } 3116 }
3117 } 3117 }
3118 3118
3119 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) 3119 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)
3120 { 3120 {
3121 // Convert the style regions to absolute coordinates. 3121 // Convert the style regions to absolute coordinates.
3122 if (style()->visibility() != VISIBLE || !isBox()) 3122 if (style()->visibility() != VISIBLE || !isBox())
3123 return; 3123 return;
3124 3124
3125 if (style()->getDraggableRegionMode() == DraggableRegionNone) 3125 if (style()->getDraggableRegionMode() == DraggableRegionNone)
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 { 3425 {
3426 if (object1) { 3426 if (object1) {
3427 const WebCore::RenderObject* root = object1; 3427 const WebCore::RenderObject* root = object1;
3428 while (root->parent()) 3428 while (root->parent())
3429 root = root->parent(); 3429 root = root->parent();
3430 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3430 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3431 } 3431 }
3432 } 3432 }
3433 3433
3434 #endif 3434 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698