Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 503 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem ent) | 481 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem ent) |
| 504 { | 482 { |
| 505 StyleAdjuster adjuster(document().inQuirksMode()); | 483 StyleAdjuster adjuster(document().inQuirksMode()); |
| 506 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element, authorStyleInfo(state)); | 484 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element); |
| 507 } | 485 } |
| 508 | 486 |
| 509 // Start loading resources referenced by this style. | 487 // Start loading resources referenced by this style. |
| 510 void StyleResolver::loadPendingResources(StyleResolverState& state) | 488 void StyleResolver::loadPendingResources(StyleResolverState& state) |
| 511 { | 489 { |
| 512 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | 490 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); |
| 513 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); | 491 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); |
| 514 } | 492 } |
| 515 | 493 |
| 516 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, | 494 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1328 // If our font got dirtied, go ahead and update it now. | 1306 // If our font got dirtied, go ahead and update it now. |
| 1329 updateFont(state); | 1307 updateFont(state); |
| 1330 | 1308 |
| 1331 // Many properties depend on the font. If it changes we just apply all prope rties. | 1309 // Many properties depend on the font. If it changes we just apply all prope rties. |
| 1332 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->fontD escription() != state.style()->fontDescription()) | 1310 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->fontD escription() != state.style()->fontDescription()) |
| 1333 applyInheritedOnly = false; | 1311 applyInheritedOnly = false; |
| 1334 | 1312 |
| 1335 // Now do the normal priority UA properties. | 1313 // Now do the normal priority UA properties. |
| 1336 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly); | 1314 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly); |
| 1337 | 1315 |
| 1338 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl e. | 1316 // Make a copy of the current UA border and background so we can compare aft er matching other properties. |
|
Timothy Loh
2015/07/29 03:37:07
Can we just keep using CachedUAStyle and only crea
meade_UTC10
2015/07/30 05:38:17
Done.
| |
| 1339 state.cacheUserAgentBorderAndBackground(); | 1317 FillLayer uaBgFill = state.style()->backgroundLayers(); |
| 1318 StyleColor uaBgColor = state.style()->backgroundColor(); | |
| 1319 BorderData uaBorder = state.style()->border(); | |
| 1340 | 1320 |
| 1341 // Now do the author and user normal priority properties and all the !import ant properties. | 1321 // Now do the author and user normal priority properties and all the !import ant properties. |
| 1342 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); | 1322 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
| 1343 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); | 1323 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
| 1344 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginUA(), matchResult.endUA(), applyInheritedOnly); | 1324 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginUA(), matchResult.endUA(), applyInheritedOnly); |
| 1345 | 1325 |
| 1326 // Compare the saved UA bg and border. | |
| 1327 state.style()->setHasAuthorBackground(backgroundChanged(uaBgFill, uaBgColor, state)); | |
| 1328 state.style()->setHasAuthorBorder(uaBorder != state.style()->border()); | |
| 1329 | |
| 1346 loadPendingResources(state); | 1330 loadPendingResources(state); |
| 1347 | 1331 |
| 1348 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) { | 1332 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) { |
| 1349 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); | 1333 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); |
| 1350 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult); | 1334 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult); |
| 1351 } | 1335 } |
| 1352 | 1336 |
| 1353 ASSERT(!state.fontBuilder().fontDirty()); | 1337 ASSERT(!state.fontBuilder().fontDirty()); |
| 1354 } | 1338 } |
| 1355 | 1339 |
| 1340 bool StyleResolver::backgroundChanged(const FillLayer& oldLayer, const StyleColo r& oldColor, const StyleResolverState& state) | |
| 1341 { | |
| 1342 FillLayer oldFill = oldLayer; | |
| 1343 FillLayer newFill = state.style()->backgroundLayers(); | |
| 1344 // Exclude background-repeat from comparison by resetting it. | |
| 1345 oldFill.setRepeatX(NoRepeatFill); | |
| 1346 oldFill.setRepeatY(NoRepeatFill); | |
| 1347 newFill.setRepeatX(NoRepeatFill); | |
| 1348 newFill.setRepeatY(NoRepeatFill); | |
| 1349 | |
| 1350 return (oldFill != newFill || oldColor != state.style()->backgroundColor()); | |
| 1351 } | |
| 1352 | |
| 1356 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) | 1353 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) |
| 1357 { | 1354 { |
| 1358 if (!m_watchedSelectorsRules) | 1355 if (!m_watchedSelectorsRules) |
| 1359 return; | 1356 return; |
| 1360 | 1357 |
| 1361 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); | 1358 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); |
| 1362 collector.setMode(SelectorChecker::CollectingStyleRules); | 1359 collector.setMode(SelectorChecker::CollectingStyleRules); |
| 1363 | 1360 |
| 1364 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); | 1361 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); |
| 1365 collector.collectMatchingRules(matchRequest); | 1362 collector.collectMatchingRules(matchRequest); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 visitor->trace(m_watchedSelectorsRules); | 1433 visitor->trace(m_watchedSelectorsRules); |
| 1437 visitor->trace(m_treeBoundaryCrossingRules); | 1434 visitor->trace(m_treeBoundaryCrossingRules); |
| 1438 visitor->trace(m_styleResourceLoader); | 1435 visitor->trace(m_styleResourceLoader); |
| 1439 visitor->trace(m_styleSharingLists); | 1436 visitor->trace(m_styleSharingLists); |
| 1440 visitor->trace(m_pendingStyleSheets); | 1437 visitor->trace(m_pendingStyleSheets); |
| 1441 visitor->trace(m_document); | 1438 visitor->trace(m_document); |
| 1442 #endif | 1439 #endif |
| 1443 } | 1440 } |
| 1444 | 1441 |
| 1445 } // namespace blink | 1442 } // namespace blink |
| OLD | NEW |