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

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

Issue 361173002: [wip] simplify -webkit-appearance adjust step (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update Created 6 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
« no previous file with comments | « Source/core/css/resolver/CascadedValues.h ('k') | Source/core/css/resolver/StyleAdjuster.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/resolver/CascadedValues.h" 6 #include "core/css/resolver/CascadedValues.h"
7 7
8 #include "core/css/CSSValuePool.h" 8 #include "core/css/CSSValuePool.h"
9 #include "core/css/StylePropertySet.h" 9 #include "core/css/StylePropertySet.h"
10 #include "core/css/resolver/MatchResult.h" 10 #include "core/css/resolver/MatchResult.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 ASSERT(!RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 237 ASSERT(!RuntimeEnabledFeatures::css3TextDecorationsEnabled());
238 return CSSPropertyTextDecorationLine; 238 return CSSPropertyTextDecorationLine;
239 // As per css3-text, word-wrap is an alias for overflow-wrap 239 // As per css3-text, word-wrap is an alias for overflow-wrap
240 case CSSPropertyWordWrap: 240 case CSSPropertyWordWrap:
241 return CSSPropertyOverflowWrap; 241 return CSSPropertyOverflowWrap;
242 default: 242 default:
243 return property; 243 return property;
244 } 244 }
245 } 245 }
246 246
247 CascadedValues::CascadedValues(StyleResolverState& state, const MatchResult& mat chResult, bool onlyAddUARules) 247 CascadedValues::CascadedValues(StyleResolverState& state, const MatchResult& mat chResult)
248 : m_state(state) 248 : m_state(state)
249 { 249 {
250 memset(m_values, 0, sizeof(m_values)); 250 memset(m_values, 0, sizeof(m_values));
251 memset(m_visitedLinkValues, 0, sizeof(m_visitedLinkValues)); 251 memset(m_visitedLinkValues, 0, sizeof(m_visitedLinkValues));
252 252
253 // The MatchResult has rules in UA - User - Author order, although we only 253 // The MatchResult has rules in UA - User - Author order, although we only
254 // use user rules for callback selectors. 254 // use user rules for callback selectors.
255 addMatchResult(matchResult, CSSPropertyDirection, CSSPropertyWebkitWritingMo de); 255 addMatchResult(matchResult, CSSPropertyDirection, CSSPropertyWebkitWritingMo de);
256 applyValues(CSSPropertyDirection, CSSPropertyWebkitWritingMode); 256 applyValues(CSSPropertyDirection, CSSPropertyWebkitWritingMode);
257 m_direction = state.style()->direction(); 257 m_direction = state.style()->direction();
258 m_writingMode = state.style()->writingMode(); 258 m_writingMode = state.style()->writingMode();
259 259
260 COMPILE_ASSERT(CSSPropertyColor == CSSPropertyWebkitWritingMode + 1, CSS_col or_is_after_super_high_priority); 260 COMPILE_ASSERT(CSSPropertyColor == CSSPropertyWebkitWritingMode + 1, CSS_col or_is_after_super_high_priority);
261 if (onlyAddUARules) { 261 addMatchResult(matchResult, CSSPropertyColor, convertToCSSPropertyID(lastCSS Property));
262 addMatchResultRange(matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, CSSPropertyColor, convertToCSSPropertyID(lastCSSP roperty)); 262 }
263 } else { 263
264 addMatchResult(matchResult, CSSPropertyColor, convertToCSSPropertyID(las tCSSProperty)); 264 CascadedValues::CascadedValues(StyleResolverState& state, const MatchResult& mat chResult, WebkitAppearanceConstructorType)
265 } 265 : m_state(state)
266 {
267 memset(m_values, 0, sizeof(m_values));
268 memset(m_visitedLinkValues, 0, sizeof(m_visitedLinkValues));
269 m_direction = state.style()->direction();
270 m_writingMode = state.style()->writingMode();
271 addMatchResultRange(matchResult, false, matchResult.ranges.firstUARule, matc hResult.ranges.lastUARule, CSSPropertyColor, convertToCSSPropertyID(lastCSSPrope rty));
266 } 272 }
267 273
268 void CascadedValues::addMatchResult(const MatchResult& matchResult, CSSPropertyI D firstId, CSSPropertyID lastId) 274 void CascadedValues::addMatchResult(const MatchResult& matchResult, CSSPropertyI D firstId, CSSPropertyID lastId)
269 { 275 {
270 addMatchResultRange(matchResult, false, 0, matchResult.matchedProperties.siz e() - 1, firstId, lastId); 276 addMatchResultRange(matchResult, false, 0, matchResult.matchedProperties.siz e() - 1, firstId, lastId);
271 addMatchResultRange(matchResult, true, matchResult.ranges.firstAuthorRule, m atchResult.ranges.lastAuthorRule, firstId, lastId); 277 addMatchResultRange(matchResult, true, matchResult.ranges.firstAuthorRule, m atchResult.ranges.lastAuthorRule, firstId, lastId);
272 addMatchResultRange(matchResult, true, matchResult.ranges.firstUARule, match Result.ranges.lastUARule, firstId, lastId); 278 addMatchResultRange(matchResult, true, matchResult.ranges.firstUARule, match Result.ranges.lastUARule, firstId, lastId);
273 } 279 }
274 280
275 void CascadedValues::addMatchResultRange(const MatchResult& matchResult, bool is Important, int firstIndex, int lastIndex, CSSPropertyID firstId, CSSPropertyID l astId) 281 void CascadedValues::addMatchResultRange(const MatchResult& matchResult, bool is Important, int firstIndex, int lastIndex, CSSPropertyID firstId, CSSPropertyID l astId)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 if (cascadedVisitedLinkValue(property)) { 387 if (cascadedVisitedLinkValue(property)) {
382 m_state.setApplyPropertyToRegularStyle(false); 388 m_state.setApplyPropertyToRegularStyle(false);
383 m_state.setApplyPropertyToVisitedLinkStyle(true); 389 m_state.setApplyPropertyToVisitedLinkStyle(true);
384 StyleBuilder::applyProperty(property, m_state, cascadedVisitedLinkVa lue(property)); 390 StyleBuilder::applyProperty(property, m_state, cascadedVisitedLinkVa lue(property));
385 m_state.setApplyPropertyToRegularStyle(true); 391 m_state.setApplyPropertyToRegularStyle(true);
386 m_state.setApplyPropertyToVisitedLinkStyle(false); 392 m_state.setApplyPropertyToVisitedLinkStyle(false);
387 } 393 }
388 } 394 }
389 } 395 }
390 396
397 bool CascadedValues::valuesUnchangedForWebkitAppearance(const MatchResult& match Result)
398 {
399 static const CSSPropertyID propertiesToCompare[] = {
400 CSSPropertyBorderBottomColor, CSSPropertyBorderBottomStyle, CSSPropertyB orderBottomWidth,
401 CSSPropertyBorderLeftColor, CSSPropertyBorderLeftStyle, CSSPropertyBorde rLeftWidth,
402 CSSPropertyBorderRightColor, CSSPropertyBorderRightStyle, CSSPropertyBor derRightWidth,
403 CSSPropertyBorderTopColor, CSSPropertyBorderTopStyle, CSSPropertyBorderT opWidth,
404 CSSPropertyBorderBottomLeftRadius, CSSPropertyBorderBottomRightRadius,
405 CSSPropertyBorderTopLeftRadius, CSSPropertyBorderTopRightRadius,
406 CSSPropertyBorderImageOutset, CSSPropertyBorderImageRepeat, CSSPropertyB orderImageSlice,
407 CSSPropertyBorderImageSource, CSSPropertyBorderImageWidth,
408 CSSPropertyBackgroundAttachment, CSSPropertyBackgroundBlendMode, CSSProp ertyBackgroundClip,
409 CSSPropertyBackgroundColor, CSSPropertyBackgroundImage, CSSPropertyBackg roundOrigin,
410 CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY, CSSPrope rtyBackgroundSize,
411 };
412 CascadedValues uaValues(m_state, matchResult, WebkitAppearanceConstructor);
413 for (size_t i = 0; i < WTF_ARRAY_LENGTH(propertiesToCompare); ++i) {
414 CSSPropertyID property = propertiesToCompare[i];
415 if (cascadedValue(property) != uaValues.cascadedValue(property))
416 return false;
417 }
418 return true;
419 }
420
391 } // namespace blink 421 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/CascadedValues.h ('k') | Source/core/css/resolver/StyleAdjuster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698