Changeset 251644 in webkit
- Timestamp:
- Oct 27, 2019, 3:12:20 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
css/StyleResolver.cpp (modified) (8 diffs)
-
style/PropertyCascade.cpp (modified) (6 diffs)
-
style/PropertyCascade.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251643 r251644 1 2019-10-27 Antti Koivisto <antti@apple.com> 2 3 Move resolving direction and writing mode to PropertyCascade 4 https://bugs.webkit.org/show_bug.cgi?id=203471 5 Reviewed by Zalan Bujtas. 6 7 Simplify PropertyCascade call sites. 8 9 * css/StyleResolver.cpp: 10 (WebCore::StyleResolver::styleForKeyframe): 11 (WebCore::StyleResolver::styleForPage): 12 (WebCore::StyleResolver::applyMatchedProperties): 13 (WebCore::StyleResolver::applyPropertyToCurrentStyle): 14 (WebCore::extractDirectionAndWritingMode): Deleted. 15 * style/PropertyCascade.cpp: 16 (WebCore::Style::PropertyCascade::PropertyCascade): 17 18 Add copying constructor that avoids re-resolving directions. 19 20 (WebCore::Style::PropertyCascade::buildCascade): 21 22 Factor into a function. 23 24 (WebCore::Style::PropertyCascade::propertyCascadeForRollback): 25 (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode): 26 27 The code moves here. 28 29 * style/PropertyCascade.h: 30 1 31 2019-10-27 Claudio Saavedra <csaavedra@igalia.com> 2 32 -
trunk/Source/WebCore/css/StyleResolver.cpp
r251636 r251644 119 119 static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1); 120 120 121 static void extractDirectionAndWritingMode(const RenderStyle&, const MatchResult&, TextDirection&, WritingMode&);122 123 121 inline void StyleResolver::State::cacheBorderAndBackground() 124 122 { … … 367 365 state.setParentStyle(RenderStyle::clonePtr(*elementStyle)); 368 366 369 TextDirection direction; 370 WritingMode writingMode; 371 extractDirectionAndWritingMode(*state.style(), result, direction, writingMode); 372 373 Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author }, direction, writingMode); 367 Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author }); 374 368 375 369 cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty); … … 571 565 auto& result = collector.matchResult(); 572 566 573 TextDirection direction; 574 WritingMode writingMode; 575 extractDirectionAndWritingMode(*m_state.style(), result, direction, writingMode); 576 577 Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author }, direction, writingMode); 567 Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author }); 578 568 579 569 cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty); … … 1305 1295 } 1306 1296 1307 void extractDirectionAndWritingMode(const RenderStyle& style, const MatchResult& matchResult, TextDirection& direction, WritingMode& writingMode)1308 {1309 direction = style.direction();1310 writingMode = style.writingMode();1311 1312 bool hadImportantWritingMode = false;1313 bool hadImportantDirection = false;1314 1315 for (auto* matchedDeclarations : { &matchResult.userAgentDeclarations, &matchResult.userDeclarations, &matchResult.authorDeclarations }) {1316 for (const auto& matchedProperties : *matchedDeclarations) {1317 for (unsigned i = 0, count = matchedProperties.properties->propertyCount(); i < count; ++i) {1318 auto property = matchedProperties.properties->propertyAt(i);1319 if (!property.value()->isPrimitiveValue())1320 continue;1321 switch (property.id()) {1322 case CSSPropertyWritingMode:1323 if (!hadImportantWritingMode || property.isImportant()) {1324 writingMode = downcast<CSSPrimitiveValue>(*property.value());1325 hadImportantWritingMode = property.isImportant();1326 }1327 break;1328 case CSSPropertyDirection:1329 if (!hadImportantDirection || property.isImportant()) {1330 direction = downcast<CSSPrimitiveValue>(*property.value());1331 hadImportantDirection = property.isImportant();1332 }1333 break;1334 default:1335 break;1336 }1337 }1338 }1339 }1340 }1341 1342 1297 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element& element, ShouldUseMatchedPropertiesCache shouldUseMatchedPropertiesCache) 1343 1298 { … … 1366 1321 } 1367 1322 1368 // Directional properties (*-before/after) are aliases that depend on the TextDirection and WritingMode.1369 // These must be resolved before we can begin the property cascade.1370 TextDirection direction;1371 WritingMode writingMode;1372 extractDirectionAndWritingMode(*state.style(), matchResult, direction, writingMode);1373 1374 1323 if (elementTypeHasAppearanceFromUAStyle(*state.element())) { 1375 1324 // FIXME: This is such a hack. … … 1377 1326 // If so, we cache the border and background styles so that RenderTheme::adjustStyle() 1378 1327 // can look at them later to figure out if this is a styled form control or not. 1379 Style::PropertyCascade cascade(*this, matchResult, { Style::CascadeLevel::UserAgent }, direction, writingMode,includedProperties);1328 Style::PropertyCascade cascade(*this, matchResult, { Style::CascadeLevel::UserAgent }, includedProperties); 1380 1329 1381 1330 cascade.applyProperties(CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition); … … 1400 1349 } 1401 1350 1402 Style::PropertyCascade cascade(*this, matchResult, Style::allCascadeLevels(), direction, writingMode,includedProperties);1351 Style::PropertyCascade cascade(*this, matchResult, Style::allCascadeLevels(), includedProperties); 1403 1352 1404 1353 cascade.applyProperties(CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition); … … 1455 1404 return; 1456 1405 MatchResult matchResult; 1457 Style::PropertyCascade cascade(*this, matchResult, { } , { }, { });1406 Style::PropertyCascade cascade(*this, matchResult, { }); 1458 1407 if (value) 1459 1408 cascade.applyProperty(id, *value); -
trunk/Source/WebCore/style/PropertyCascade.cpp
r251636 r251644 28 28 29 29 #include "CSSPaintImageValue.h" 30 #include "CSSPrimitiveValueMappings.h" 30 31 #include "CSSValuePool.h" 31 32 #include "PaintWorkletGlobalScope.h" … … 173 174 #endif 174 175 175 PropertyCascade::PropertyCascade(StyleResolver& styleResolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, TextDirection direction, WritingMode writingMode,IncludedProperties includedProperties)176 PropertyCascade::PropertyCascade(StyleResolver& styleResolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, IncludedProperties includedProperties) 176 177 : m_styleResolver(styleResolver) 177 178 , m_matchResult(matchResult) 178 179 , m_includedProperties(includedProperties) 179 , m_direction(direction) 180 , m_writingMode(writingMode) 180 { 181 // Directional properties (*-before/after) are aliases that depend on the TextDirection and WritingMode. 182 // These must be resolved before we can begin building the property cascade. 183 resolveDirectionAndWritingMode(); 184 185 buildCascade(cascadeLevels); 186 } 187 188 PropertyCascade::PropertyCascade(const PropertyCascade& parent, OptionSet<CascadeLevel> cascadeLevels) 189 : m_styleResolver(parent.m_styleResolver) 190 , m_matchResult(parent.m_matchResult) 191 , m_includedProperties(parent.m_includedProperties) 192 , m_direction(parent.m_direction) 193 , m_writingMode(parent.m_writingMode) 194 { 195 buildCascade(cascadeLevels); 196 } 197 198 PropertyCascade::~PropertyCascade() = default; 199 200 void PropertyCascade::buildCascade(OptionSet<CascadeLevel> cascadeLevels) 181 201 { 182 202 OptionSet<CascadeLevel> cascadeLevelsWithImportant; … … 194 214 } 195 215 } 196 197 PropertyCascade::~PropertyCascade() = default;198 216 199 217 void PropertyCascade::setPropertyInternal(Property& property, CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel, ScopeOrdinal styleScopeOrdinal) … … 491 509 if (!m_authorRollbackCascade) { 492 510 auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent, CascadeLevel::User }; 493 m_authorRollbackCascade = makeUnique<const PropertyCascade>( m_styleResolver, m_matchResult, cascadeLevels, m_direction, m_writingMode, m_includedProperties);511 m_authorRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels); 494 512 } 495 513 return m_authorRollbackCascade.get(); … … 498 516 if (!m_userRollbackCascade) { 499 517 auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent }; 500 m_userRollbackCascade = makeUnique<const PropertyCascade>( m_styleResolver, m_matchResult, cascadeLevels, m_direction, m_writingMode, m_includedProperties);518 m_userRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels); 501 519 } 502 520 return m_userRollbackCascade.get(); … … 651 669 } 652 670 653 } 654 } 671 void PropertyCascade::resolveDirectionAndWritingMode() 672 { 673 auto& style = *m_styleResolver.style(); 674 675 m_direction = style.direction(); 676 m_writingMode = style.writingMode(); 677 678 bool hadImportantWritingMode = false; 679 bool hadImportantDirection = false; 680 681 for (auto cascadeLevel : { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }) { 682 for (const auto& matchedProperties : declarationsForCascadeLevel(m_matchResult, cascadeLevel)) { 683 for (unsigned i = 0, count = matchedProperties.properties->propertyCount(); i < count; ++i) { 684 auto property = matchedProperties.properties->propertyAt(i); 685 if (!property.value()->isPrimitiveValue()) 686 continue; 687 switch (property.id()) { 688 case CSSPropertyWritingMode: 689 if (!hadImportantWritingMode || property.isImportant()) { 690 m_writingMode = downcast<CSSPrimitiveValue>(*property.value()); 691 hadImportantWritingMode = property.isImportant(); 692 } 693 break; 694 case CSSPropertyDirection: 695 if (!hadImportantDirection || property.isImportant()) { 696 m_direction = downcast<CSSPrimitiveValue>(*property.value()); 697 hadImportantDirection = property.isImportant(); 698 } 699 break; 700 default: 701 break; 702 } 703 } 704 } 705 } 706 } 707 708 } 709 } -
trunk/Source/WebCore/style/PropertyCascade.h
r251636 r251644 48 48 public: 49 49 enum IncludedProperties { All, InheritedOnly }; 50 PropertyCascade(StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, TextDirection, WritingMode, IncludedProperties = IncludedProperties::All); 50 PropertyCascade(StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, IncludedProperties = IncludedProperties::All); 51 PropertyCascade(const PropertyCascade&, OptionSet<CascadeLevel>); 52 51 53 ~PropertyCascade(); 52 54 … … 75 77 76 78 private: 79 void buildCascade(OptionSet<CascadeLevel>); 77 80 bool addNormalMatches(CascadeLevel); 78 81 void addImportantMatches(CascadeLevel); … … 93 96 RefPtr<CSSValue> resolvedVariableValue(CSSPropertyID, const CSSValue&); 94 97 98 void resolveDirectionAndWritingMode(); 99 95 100 StyleResolver& m_styleResolver; 96 101 97 102 const MatchResult& m_matchResult; 98 103 const IncludedProperties m_includedProperties; 99 const TextDirection m_direction; 100 const WritingMode m_writingMode; 104 105 TextDirection m_direction; 106 WritingMode m_writingMode; 101 107 102 108 Property m_properties[numCSSProperties + 2];
Note:
See TracChangeset
for help on using the changeset viewer.