Changeset 196560 in webkit
- Timestamp:
- Feb 14, 2016, 1:57:23 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 5 edited
-
CMakeLists.txt (modified) (1 diff)
-
ChangeLog (modified) (1 diff)
-
WebCore.vcxproj/WebCore.vcxproj (modified) (2 diffs)
-
WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
dom/Element.cpp (modified) (4 diffs)
-
style/ClassChangeInvalidation.cpp (added)
-
style/ClassChangeInvalidation.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r196510 r196560 2625 2625 storage/StorageNamespaceProvider.cpp 2626 2626 2627 style/ClassChangeInvalidation.cpp 2627 2628 style/InlineTextBoxStyle.cpp 2628 2629 style/RenderTreePosition.cpp -
trunk/Source/WebCore/ChangeLog
r196559 r196560 1 2016-02-13 Antti Koivisto <antti@apple.com> 2 3 Factor class change style invalidation code into a class 4 https://bugs.webkit.org/show_bug.cgi?id=154163 5 6 Reviewed by Andreas Kling. 7 8 Factor this piece of functionality out of Element and into ClassChangeInvalidation class. 9 10 * CMakeLists.txt: 11 * WebCore.vcxproj/WebCore.vcxproj: 12 * WebCore.xcodeproj/project.pbxproj: 13 * dom/Element.cpp: 14 (WebCore::classStringHasClassName): 15 (WebCore::Element::classAttributeChanged): 16 (WebCore::collectClasses): Deleted. 17 (WebCore::computeClassChange): Deleted. 18 (WebCore::invalidateStyleForClassChange): Deleted. 19 * style/ClassChangeInvalidation.cpp: Added. 20 (WebCore::Style::ClassChangeInvalidation::computeClassChange): 21 (WebCore::Style::ClassChangeInvalidation::invalidateStyle): 22 * style/ClassChangeInvalidation.h: Added. 23 (WebCore::Style::ClassChangeInvalidation::needsInvalidation): 24 (WebCore::Style::ClassChangeInvalidation::ClassChangeInvalidation): 25 (WebCore::Style::ClassChangeInvalidation::~ClassChangeInvalidation): 26 1 27 2016-02-13 Myles C. Maxfield <mmaxfield@apple.com> 2 28 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r196510 r196560 19254 19254 <ClCompile Include="..\storage\StorageMap.cpp" /> 19255 19255 <ClCompile Include="..\storage\StorageNamespaceProvider.cpp" /> 19256 <ClCompile Include="..\style\ClassChangeInvalidation.cpp" /> 19256 19257 <ClCompile Include="..\style\InlineTextBoxStyle.cpp" /> 19257 19258 <ClCompile Include="..\style\RenderTreePosition.cpp" /> … … 22821 22822 <ClInclude Include="..\storage\StorageNamespace.h" /> 22822 22823 <ClInclude Include="..\storage\StorageNamespaceProvider.h" /> 22824 <ClInclude Include="..\style\ClassChangeInvalidation.h" /> 22823 22825 <ClInclude Include="..\style\InlineTextBoxStyle.h" /> 22824 22826 <ClInclude Include="..\style\RenderTreePosition.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r196510 r196560 6622 6622 E4A007831B820EC8002C5A6E /* DataURLDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A007821B820EC8002C5A6E /* DataURLDecoder.h */; }; 6623 6623 E4A007851B820ED3002C5A6E /* DataURLDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */; }; 6624 E4A814D41C6DEC4000BF85AC /* ClassChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */; }; 6625 E4A814D61C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A814D51C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp */; }; 6624 6626 E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1517D1BB950009FB31 /* ElementIterator.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6625 6627 E4AE7C1A17D232350009FB31 /* ElementAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 14610 14612 E4A007821B820EC8002C5A6E /* DataURLDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataURLDecoder.h; sourceTree = "<group>"; }; 14611 14613 E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataURLDecoder.cpp; sourceTree = "<group>"; }; 14614 E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassChangeInvalidation.h; sourceTree = "<group>"; }; 14615 E4A814D51C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassChangeInvalidation.cpp; sourceTree = "<group>"; }; 14612 14616 E4AE7C1517D1BB950009FB31 /* ElementIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIterator.h; sourceTree = "<group>"; }; 14613 14617 E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementAncestorIterator.h; sourceTree = "<group>"; }; … … 23387 23391 isa = PBXGroup; 23388 23392 children = ( 23393 E4A814D51C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp */, 23394 E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */, 23389 23395 1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */, 23390 23396 1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */, … … 25942 25948 C5D4AA7A116BAFB60069CA93 /* GlyphMetricsMap.h in Headers */, 25943 25949 0873B86B136064EA00A522C2 /* GlyphPage.h in Headers */, 25950 E4A814D41C6DEC4000BF85AC /* ClassChangeInvalidation.h in Headers */, 25944 25951 BC53C5F50DA56B920021EB5D /* Gradient.h in Headers */, 25945 25952 B22279640D00BF220071B782 /* GradientAttributes.h in Headers */, … … 30219 30226 511EF2D117F0FDF100E4FA16 /* JSIDBObjectStoreCustom.cpp in Sources */, 30220 30227 511EF2C817F0FD3500E4FA16 /* JSIDBOpenDBRequest.cpp in Sources */, 30228 E4A814D61C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp in Sources */, 30221 30229 511EF2C917F0FD3500E4FA16 /* JSIDBRequest.cpp in Sources */, 30222 30230 511EF2CA17F0FD3500E4FA16 /* JSIDBTransaction.cpp in Sources */, -
trunk/Source/WebCore/dom/Element.cpp
r196473 r196560 32 32 #include "Chrome.h" 33 33 #include "ChromeClient.h" 34 #include "ClassChangeInvalidation.h" 34 35 #include "ClientRect.h" 35 36 #include "ClientRectList.h" … … 77 78 #include "SelectorQuery.h" 78 79 #include "Settings.h" 79 #include "StyleInvalidationAnalysis.h"80 80 #include "StyleProperties.h" 81 81 #include "StyleResolver.h" … … 1300 1300 } 1301 1301 1302 static Vector<AtomicStringImpl*, 4> collectClasses(const SpaceSplitString& classes)1303 {1304 Vector<AtomicStringImpl*, 4> result;1305 result.reserveCapacity(classes.size());1306 for (unsigned i = 0; i < classes.size(); ++i)1307 result.uncheckedAppend(classes[i].impl());1308 return result;1309 }1310 1311 struct ClassChange {1312 Vector<AtomicStringImpl*, 4> added;1313 Vector<AtomicStringImpl*, 4> removed;1314 };1315 1316 static ClassChange computeClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses)1317 {1318 ClassChange classChange;1319 1320 unsigned oldSize = oldClasses.size();1321 unsigned newSize = newClasses.size();1322 1323 if (!oldSize) {1324 classChange.added = collectClasses(newClasses);1325 return classChange;1326 }1327 if (!newSize) {1328 classChange.removed = collectClasses(oldClasses);1329 return classChange;1330 }1331 1332 BitVector remainingClassBits;1333 remainingClassBits.ensureSize(oldSize);1334 // Class vectors tend to be very short. This is faster than using a hash table.1335 for (unsigned i = 0; i < newSize; ++i) {1336 bool foundFromBoth = false;1337 for (unsigned j = 0; j < oldSize; ++j) {1338 if (newClasses[i] == oldClasses[j]) {1339 remainingClassBits.quickSet(j);1340 foundFromBoth = true;1341 }1342 }1343 if (foundFromBoth)1344 continue;1345 classChange.added.append(newClasses[i].impl());1346 }1347 for (unsigned i = 0; i < oldSize; ++i) {1348 // If the bit is not set the the corresponding class has been removed.1349 if (remainingClassBits.quickGet(i))1350 continue;1351 classChange.removed.append(oldClasses[i].impl());1352 }1353 1354 return classChange;1355 }1356 1357 static void invalidateStyleForClassChange(Element& element, const Vector<AtomicStringImpl*, 4>& changedClasses, const DocumentRuleSets& ruleSets)1358 {1359 Vector<AtomicStringImpl*, 4> changedClassesAffectingStyle;1360 for (auto* changedClass : changedClasses) {1361 if (ruleSets.features().classesInRules.contains(changedClass))1362 changedClassesAffectingStyle.append(changedClass);1363 };1364 1365 if (changedClassesAffectingStyle.isEmpty())1366 return;1367 1368 if (element.shadowRoot() && ruleSets.authorStyle()->hasShadowPseudoElementRules()) {1369 element.setNeedsStyleRecalc(FullStyleChange);1370 return;1371 }1372 1373 element.setNeedsStyleRecalc(InlineStyleChange);1374 1375 if (!element.firstElementChild())1376 return;1377 1378 for (auto* changedClass : changedClassesAffectingStyle) {1379 auto* ancestorClassRules = ruleSets.ancestorClassRules(changedClass);1380 if (!ancestorClassRules)1381 continue;1382 StyleInvalidationAnalysis invalidationAnalysis(*ancestorClassRules);1383 invalidationAnalysis.invalidateStyle(element);1384 }1385 }1386 1387 1302 void Element::classAttributeChanged(const AtomicString& newClassString) 1388 1303 { … … 1396 1311 auto oldClassNames = elementData()->classNames(); 1397 1312 auto newClassNames = newStringHasClasses ? SpaceSplitString(newClassString, shouldFoldCase) : SpaceSplitString(); 1398 1399 StyleResolver* styleResolver = document().styleResolverIfExists(); 1400 bool shouldInvalidateStyle = inRenderedDocument() && styleResolver && styleChangeType() < FullStyleChange; 1401 1402 ClassChange classChange; 1403 if (shouldInvalidateStyle) { 1404 classChange = computeClassChange(oldClassNames, newClassNames); 1405 if (!classChange.removed.isEmpty()) 1406 invalidateStyleForClassChange(*this, classChange.removed, styleResolver->ruleSets()); 1407 } 1408 1409 elementData()->setClassNames(newClassNames); 1410 1411 if (shouldInvalidateStyle) { 1412 if (!classChange.added.isEmpty()) 1413 invalidateStyleForClassChange(*this, classChange.added, styleResolver->ruleSets()); 1313 { 1314 Style::ClassChangeInvalidation styleInvalidation(*this, oldClassNames, newClassNames); 1315 elementData()->setClassNames(newClassNames); 1414 1316 } 1415 1317
Note:
See TracChangeset
for help on using the changeset viewer.