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

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

Issue 1274263003: Revert of Delete AuthorStyleInfo and move its data into ComputedStyle.RareNonInheritedData. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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/StyleResolver.h ('k') | Source/core/layout/LayoutTheme.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 /* 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 // Document::inheritHtmlAndBodyElementStyles. 471 // Document::inheritHtmlAndBodyElementStyles.
472 documentStyle->setDisplay(BLOCK); 472 documentStyle->setDisplay(BLOCK);
473 documentStyle->setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBloc ksOnWheelEvent); 473 documentStyle->setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBloc ksOnWheelEvent);
474 documentStyle->setPosition(AbsolutePosition); 474 documentStyle->setPosition(AbsolutePosition);
475 475
476 document.setupFontBuilder(*documentStyle); 476 document.setupFontBuilder(*documentStyle);
477 477
478 return documentStyle.release(); 478 return documentStyle.release();
479 } 479 }
480 480
481 AuthorStyleInfo StyleResolver::authorStyleInfo(StyleResolverState& state)
482 {
483 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle();
484
485 if (!cachedUAStyle)
486 return AuthorStyleInfo();
487
488 // Exclude background-repeat from comparison by resetting it.
489 FillLayer backgroundCopy = cachedUAStyle->backgroundLayers;
490 FillLayer backgroundLayersCopy = state.style()->backgroundLayers();
491 backgroundCopy.setRepeatX(NoRepeatFill);
492 backgroundCopy.setRepeatY(NoRepeatFill);
493 backgroundLayersCopy.setRepeatX(NoRepeatFill);
494 backgroundLayersCopy.setRepeatY(NoRepeatFill);
495
496 bool backgroundChanged = backgroundLayersCopy != backgroundCopy
497 || state.style()->backgroundColor() != cachedUAStyle->backgroundColor;
498 bool borderChanged = state.style()->border() != cachedUAStyle->border;
499
500 return AuthorStyleInfo(backgroundChanged, borderChanged);
501 }
502
481 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem ent) 503 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem ent)
482 { 504 {
483 StyleAdjuster adjuster(document().inQuirksMode()); 505 StyleAdjuster adjuster(document().inQuirksMode());
484 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element); 506 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element, authorStyleInfo(state));
485 } 507 }
486 508
487 // Start loading resources referenced by this style. 509 // Start loading resources referenced by this style.
488 void StyleResolver::loadPendingResources(StyleResolverState& state) 510 void StyleResolver::loadPendingResources(StyleResolverState& state)
489 { 511 {
490 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); 512 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources());
491 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); 513 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts();
492 } 514 }
493 515
494 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, 516 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior,
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly); 1339 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly);
1318 1340
1319 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl e. 1341 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl e.
1320 state.cacheUserAgentBorderAndBackground(); 1342 state.cacheUserAgentBorderAndBackground();
1321 1343
1322 // Now do the author and user normal priority properties and all the !import ant properties. 1344 // Now do the author and user normal priority properties and all the !import ant properties.
1323 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); 1345 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1324 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); 1346 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1325 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginUA(), matchResult.endUA(), applyInheritedOnly); 1347 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginUA(), matchResult.endUA(), applyInheritedOnly);
1326 1348
1327 if (state.style()->hasAppearance()) {
1328 // Populate if the cached UA border and background has been changed.
1329 state.style()->setHasAuthorBackground(hasAuthorBackground(state));
1330 state.style()->setHasAuthorBorder(hasAuthorBorder(state));
1331 }
1332
1333 loadPendingResources(state); 1349 loadPendingResources(state);
1334 1350
1335 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) { 1351 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) {
1336 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); 1352 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1);
1337 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult); 1353 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult);
1338 } 1354 }
1339 1355
1340 ASSERT(!state.fontBuilder().fontDirty()); 1356 ASSERT(!state.fontBuilder().fontDirty());
1341 } 1357 }
1342 1358
1343 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state)
1344 {
1345 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle();
1346 if (!cachedUAStyle)
1347 return false;
1348
1349 FillLayer oldFill = cachedUAStyle->backgroundLayers;
1350 FillLayer newFill = state.style()->backgroundLayers();
1351 // Exclude background-repeat from comparison by resetting it.
1352 oldFill.setRepeatX(NoRepeatFill);
1353 oldFill.setRepeatY(NoRepeatFill);
1354 newFill.setRepeatX(NoRepeatFill);
1355 newFill.setRepeatY(NoRepeatFill);
1356
1357 return (oldFill != newFill || cachedUAStyle->backgroundColor != state.style( )->backgroundColor());
1358 }
1359
1360 bool StyleResolver::hasAuthorBorder(const StyleResolverState& state)
1361 {
1362 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle();
1363 return cachedUAStyle && (cachedUAStyle->border != state.style()->border());
1364 }
1365
1366 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) 1359 void StyleResolver::applyCallbackSelectors(StyleResolverState& state)
1367 { 1360 {
1368 if (!m_watchedSelectorsRules) 1361 if (!m_watchedSelectorsRules)
1369 return; 1362 return;
1370 1363
1371 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 1364 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style());
1372 collector.setMode(SelectorChecker::CollectingStyleRules); 1365 collector.setMode(SelectorChecker::CollectingStyleRules);
1373 1366
1374 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); 1367 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true);
1375 collector.collectMatchingRules(matchRequest); 1368 collector.collectMatchingRules(matchRequest);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 visitor->trace(m_watchedSelectorsRules); 1439 visitor->trace(m_watchedSelectorsRules);
1447 visitor->trace(m_treeBoundaryCrossingRules); 1440 visitor->trace(m_treeBoundaryCrossingRules);
1448 visitor->trace(m_styleResourceLoader); 1441 visitor->trace(m_styleResourceLoader);
1449 visitor->trace(m_styleSharingLists); 1442 visitor->trace(m_styleSharingLists);
1450 visitor->trace(m_pendingStyleSheets); 1443 visitor->trace(m_pendingStyleSheets);
1451 visitor->trace(m_document); 1444 visitor->trace(m_document);
1452 #endif 1445 #endif
1453 } 1446 }
1454 1447
1455 } // namespace blink 1448 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/layout/LayoutTheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698