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

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 18859010: Move colorFromPrimitiveValue from StyleResolverState to TextLinkColors (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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 2091 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
2092 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2092 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
2093 2093
2094 // Start loading resources referenced by this style. 2094 // Start loading resources referenced by this style.
2095 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); 2095 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources());
2096 2096
2097 ASSERT(!state.fontDirty()); 2097 ASSERT(!state.fontDirty());
2098 2098
2099 if (cachedMatchedProperties || !cacheHash) 2099 if (cachedMatchedProperties || !cacheHash)
2100 return; 2100 return;
2101 if (!state.isMatchedPropertiesCacheable())
2102 return;
2103 if (!MatchedPropertiesCache::isCacheable(state.element(), state.style(), sta te.parentStyle())) 2101 if (!MatchedPropertiesCache::isCacheable(state.element(), state.style(), sta te.parentStyle()))
2104 return; 2102 return;
2105 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHash, matchResult); 2103 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHash, matchResult);
2106 } 2104 }
2107 2105
2108 void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, Rend erStyle* style) 2106 void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, Rend erStyle* style)
2109 { 2107 {
2110 m_state.initForStyleResolve(document(), 0, style); 2108 m_state.initForStyleResolve(document(), 0, style);
2111 m_state.setStyle(style); 2109 m_state.setStyle(style);
2112 applyPropertyToCurrentStyle(id, value); 2110 applyPropertyToCurrentStyle(id, value);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue()); 2318 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue());
2321 2319
2322 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit 2320 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
2323 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle()) 2321 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle())
2324 2322
2325 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) { 2323 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) {
2326 // Limit the properties that can be applied to only the ones honored by :visited. 2324 // Limit the properties that can be applied to only the ones honored by :visited.
2327 return; 2325 return;
2328 } 2326 }
2329 2327
2328 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0;
2329 if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor)
2330 state.style()->setHasCurrentColor();
2331
2330 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) 2332 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
2331 state.parentStyle()->setHasExplicitlyInheritedProperties(); 2333 state.parentStyle()->setHasExplicitlyInheritedProperties();
2332 2334
2333 if (id == CSSPropertyVariable) { 2335 if (id == CSSPropertyVariable) {
2334 ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue()); 2336 ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue());
2335 CSSVariableValue* variable = static_cast<CSSVariableValue*>(value); 2337 CSSVariableValue* variable = static_cast<CSSVariableValue*>(value);
2336 ASSERT(!variable->name().isEmpty()); 2338 ASSERT(!variable->name().isEmpty());
2337 ASSERT(!variable->value().isEmpty()); 2339 ASSERT(!variable->value().isEmpty());
2338 state.style()->setVariable(variable->name(), variable->value()); 2340 state.style()->setVariable(variable->name(), variable->value());
2339 return; 2341 return;
2340 } 2342 }
2341 2343
2342 // Check lookup table for implementations and use when available. 2344 // Check lookup table for implementations and use when available.
2343 const PropertyHandler& handler = m_styleBuilder.propertyHandler(id); 2345 const PropertyHandler& handler = m_styleBuilder.propertyHandler(id);
2344 if (handler.isValid()) { 2346 if (handler.isValid()) {
2345 if (isInherit) 2347 if (isInherit)
2346 handler.applyInheritValue(id, this, state); 2348 handler.applyInheritValue(id, this, state);
2347 else if (isInitial) 2349 else if (isInitial)
2348 handler.applyInitialValue(id, this, state); 2350 handler.applyInitialValue(id, this, state);
2349 else 2351 else
2350 handler.applyValue(id, this, state, value); 2352 handler.applyValue(id, this, state, value);
2351 return; 2353 return;
2352 } 2354 }
2353 2355
2354 // Use the new StyleBuilder. 2356 // Use the new StyleBuilder.
2355 if (StyleBuilder::applyProperty(id, this, state, value, isInitial, isInherit )) 2357 if (StyleBuilder::applyProperty(id, this, state, value, isInitial, isInherit ))
2356 return; 2358 return;
2357 2359
2358 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0;
2359
2360 float zoomFactor = state.style()->effectiveZoom(); 2360 float zoomFactor = state.style()->effectiveZoom();
2361 2361
2362 // What follows is a list that maps the CSS properties into their correspond ing front-end 2362 // What follows is a list that maps the CSS properties into their correspond ing front-end
2363 // RenderStyle values. 2363 // RenderStyle values.
2364 switch (id) { 2364 switch (id) {
2365 // lists 2365 // lists
2366 case CSSPropertyContent: 2366 case CSSPropertyContent:
2367 // list of string, uri, counter, attr, i 2367 // list of string, uri, counter, attr, i
2368 { 2368 {
2369 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 i t is not. This 2369 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 i t is not. This
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 if (!currValue->isShadowValue()) 2597 if (!currValue->isShadowValue())
2598 continue; 2598 continue;
2599 ShadowValue* item = static_cast<ShadowValue*>(currValue); 2599 ShadowValue* item = static_cast<ShadowValue*>(currValue);
2600 int x = item->x->computeLength<int>(state.style(), state.rootElement Style(), zoomFactor); 2600 int x = item->x->computeLength<int>(state.style(), state.rootElement Style(), zoomFactor);
2601 int y = item->y->computeLength<int>(state.style(), state.rootElement Style(), zoomFactor); 2601 int y = item->y->computeLength<int>(state.style(), state.rootElement Style(), zoomFactor);
2602 int blur = item->blur ? item->blur->computeLength<int>(state.style() , state.rootElementStyle(), zoomFactor) : 0; 2602 int blur = item->blur ? item->blur->computeLength<int>(state.style() , state.rootElementStyle(), zoomFactor) : 0;
2603 int spread = item->spread ? item->spread->computeLength<int>(state.s tyle(), state.rootElementStyle(), zoomFactor) : 0; 2603 int spread = item->spread ? item->spread->computeLength<int>(state.s tyle(), state.rootElementStyle(), zoomFactor) : 0;
2604 ShadowStyle shadowStyle = item->style && item->style->getValueID() = = CSSValueInset ? Inset : Normal; 2604 ShadowStyle shadowStyle = item->style && item->style->getValueID() = = CSSValueInset ? Inset : Normal;
2605 Color color; 2605 Color color;
2606 if (item->color) 2606 if (item->color)
2607 color = m_state.resolveColorFromPrimitiveValue(item->color.get() ); 2607 color = m_state.document()->textLinkColors().colorFromPrimitiveV alue(item->color.get(), state.style()->visitedDependentColor(CSSPropertyColor));
2608 else if (state.style()) 2608 else if (state.style())
2609 color = state.style()->color(); 2609 color = state.style()->color();
2610 2610
2611 OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, color.isValid() ? color : Color::transparent)); 2611 OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, color.isValid() ? color : Color::transparent));
2612 if (id == CSSPropertyTextShadow) 2612 if (id == CSSPropertyTextShadow)
2613 state.style()->setTextShadow(shadowData.release(), i.index()); / / add to the list if this is not the first entry 2613 state.style()->setTextShadow(shadowData.release(), i.index()); / / add to the list if this is not the first entry
2614 else 2614 else
2615 state.style()->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry 2615 state.style()->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
2616 } 2616 }
2617 return; 2617 return;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 2714
2715 if (perspectiveValue >= 0.0f) 2715 if (perspectiveValue >= 0.0f)
2716 state.style()->setPerspective(perspectiveValue); 2716 state.style()->setPerspective(perspectiveValue);
2717 return; 2717 return;
2718 } 2718 }
2719 case CSSPropertyWebkitTapHighlightColor: { 2719 case CSSPropertyWebkitTapHighlightColor: {
2720 HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor); 2720 HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
2721 if (!primitiveValue) 2721 if (!primitiveValue)
2722 break; 2722 break;
2723 2723
2724 Color col = m_state.resolveColorFromPrimitiveValue(primitiveValue); 2724 Color col = m_state.document()->textLinkColors().colorFromPrimitiveValue (primitiveValue, state.style()->visitedDependentColor(CSSPropertyColor));
2725 state.style()->setTapHighlightColor(col); 2725 state.style()->setTapHighlightColor(col);
2726 return; 2726 return;
2727 } 2727 }
2728 case CSSPropertyInvalid: 2728 case CSSPropertyInvalid:
2729 return; 2729 return;
2730 // Directional properties are resolved by resolveDirectionAwareProperty() be fore the switch. 2730 // Directional properties are resolved by resolveDirectionAwareProperty() be fore the switch.
2731 case CSSPropertyWebkitBorderEndColor: 2731 case CSSPropertyWebkitBorderEndColor:
2732 case CSSPropertyWebkitBorderEndStyle: 2732 case CSSPropertyWebkitBorderEndStyle:
2733 case CSSPropertyWebkitBorderEndWidth: 2733 case CSSPropertyWebkitBorderEndWidth:
2734 case CSSPropertyWebkitBorderStartColor: 2734 case CSSPropertyWebkitBorderStartColor:
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
3417 if (element == element->document()->documentElement() && element->document() ->writingModeSetOnDocumentElement()) 3417 if (element == element->document()->documentElement() && element->document() ->writingModeSetOnDocumentElement())
3418 return false; 3418 return false;
3419 if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->uniqu e())) 3419 if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->uniqu e()))
3420 return false; 3420 return false;
3421 if (style->hasAppearance()) 3421 if (style->hasAppearance())
3422 return false; 3422 return false;
3423 if (style->zoom() != RenderStyle::initialZoom()) 3423 if (style->zoom() != RenderStyle::initialZoom())
3424 return false; 3424 return false;
3425 if (style->writingMode() != RenderStyle::initialWritingMode()) 3425 if (style->writingMode() != RenderStyle::initialWritingMode())
3426 return false; 3426 return false;
3427 if (style->hasCurrentColor())
3428 return false;
3427 // The cache assumes static knowledge about which properties are inherited. 3429 // The cache assumes static knowledge about which properties are inherited.
3428 if (parentStyle->hasExplicitlyInheritedProperties()) 3430 if (parentStyle->hasExplicitlyInheritedProperties())
3429 return false; 3431 return false;
3430 return true; 3432 return true;
3431 } 3433 }
3432 3434
3433 void CachedMatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn fo) const 3435 void CachedMatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn fo) const
3434 { 3436 {
3435 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); 3437 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
3436 info.addMember(matchedProperties, "matchedProperties"); 3438 info.addMember(matchedProperties, "matchedProperties");
3437 info.addMember(ranges, "ranges"); 3439 info.addMember(ranges, "ranges");
3438 info.addMember(renderStyle, "renderStyle"); 3440 info.addMember(renderStyle, "renderStyle");
3439 info.addMember(parentRenderStyle, "parentRenderStyle"); 3441 info.addMember(parentRenderStyle, "parentRenderStyle");
3440 } 3442 }
3441 3443
3442 } // namespace WebCore 3444 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FilterOperationResolver.cpp ('k') | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698