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 |
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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.beginUA(), matchResult.endUA(), applyInheritedOnly); | 1336 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.beginUA(), matchResult.endUA(), applyInheritedOnly); |
1315 | 1337 |
1316 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl
e. | 1338 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl
e. |
1317 state.cacheUserAgentBorderAndBackground(); | 1339 state.cacheUserAgentBorderAndBackground(); |
1318 | 1340 |
1319 // Now do the author and user normal priority properties and all the !import
ant properties. | 1341 // Now do the author and user normal priority properties and all the !import
ant properties. |
1320 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); | 1342 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
1321 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); | 1343 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
1322 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.beginUA(), matchResult.endUA(), applyInheritedOnly); | 1344 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.beginUA(), matchResult.endUA(), applyInheritedOnly); |
1323 | 1345 |
1324 if (state.style()->hasAppearance()) { | |
1325 // Populate if the cached UA border and background has been changed. | |
1326 state.style()->setHasAuthorBackground(hasAuthorBackground(state)); | |
1327 state.style()->setHasAuthorBorder(hasAuthorBorder(state)); | |
1328 } | |
1329 | |
1330 loadPendingResources(state); | 1346 loadPendingResources(state); |
1331 | 1347 |
1332 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, *state.style(), *state.parentStyle())) { | 1348 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, *state.style(), *state.parentStyle())) { |
1333 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); | 1349 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); |
1334 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache
Hash, matchResult); | 1350 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache
Hash, matchResult); |
1335 } | 1351 } |
1336 | 1352 |
1337 ASSERT(!state.fontBuilder().fontDirty()); | 1353 ASSERT(!state.fontBuilder().fontDirty()); |
1338 } | 1354 } |
1339 | 1355 |
1340 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) | |
1341 { | |
1342 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | |
1343 if (!cachedUAStyle) | |
1344 return false; | |
1345 | |
1346 FillLayer oldFill = cachedUAStyle->backgroundLayers; | |
1347 FillLayer newFill = state.style()->backgroundLayers(); | |
1348 // Exclude background-repeat from comparison by resetting it. | |
1349 oldFill.setRepeatX(NoRepeatFill); | |
1350 oldFill.setRepeatY(NoRepeatFill); | |
1351 newFill.setRepeatX(NoRepeatFill); | |
1352 newFill.setRepeatY(NoRepeatFill); | |
1353 | |
1354 return (oldFill != newFill || cachedUAStyle->backgroundColor != state.style(
)->backgroundColor()); | |
1355 } | |
1356 | |
1357 bool StyleResolver::hasAuthorBorder(const StyleResolverState& state) | |
1358 { | |
1359 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | |
1360 return cachedUAStyle && (cachedUAStyle->border != state.style()->border()); | |
1361 } | |
1362 | |
1363 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) | 1356 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) |
1364 { | 1357 { |
1365 if (!m_watchedSelectorsRules) | 1358 if (!m_watchedSelectorsRules) |
1366 return; | 1359 return; |
1367 | 1360 |
1368 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1361 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
1369 collector.setMode(SelectorChecker::CollectingStyleRules); | 1362 collector.setMode(SelectorChecker::CollectingStyleRules); |
1370 | 1363 |
1371 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); | 1364 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); |
1372 collector.collectMatchingRules(matchRequest); | 1365 collector.collectMatchingRules(matchRequest); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 visitor->trace(m_watchedSelectorsRules); | 1436 visitor->trace(m_watchedSelectorsRules); |
1444 visitor->trace(m_treeBoundaryCrossingRules); | 1437 visitor->trace(m_treeBoundaryCrossingRules); |
1445 visitor->trace(m_styleResourceLoader); | 1438 visitor->trace(m_styleResourceLoader); |
1446 visitor->trace(m_styleSharingLists); | 1439 visitor->trace(m_styleSharingLists); |
1447 visitor->trace(m_pendingStyleSheets); | 1440 visitor->trace(m_pendingStyleSheets); |
1448 visitor->trace(m_document); | 1441 visitor->trace(m_document); |
1449 #endif | 1442 #endif |
1450 } | 1443 } |
1451 | 1444 |
1452 } // namespace blink | 1445 } // namespace blink |
OLD | NEW |