| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // so that the common case doesn't need to create a new ComputedStyle in | 523 // so that the common case doesn't need to create a new ComputedStyle in |
| 524 // Document::inheritHtmlAndBodyElementStyles. | 524 // Document::inheritHtmlAndBodyElementStyles. |
| 525 documentStyle->setDisplay(BLOCK); | 525 documentStyle->setDisplay(BLOCK); |
| 526 documentStyle->setPosition(AbsolutePosition); | 526 documentStyle->setPosition(AbsolutePosition); |
| 527 | 527 |
| 528 document.setupFontBuilder(*documentStyle); | 528 document.setupFontBuilder(*documentStyle); |
| 529 | 529 |
| 530 return documentStyle.release(); | 530 return documentStyle.release(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 AuthorStyleInfo StyleResolver::authorStyleInfo(StyleResolverState& state) | |
| 534 { | |
| 535 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | |
| 536 | |
| 537 if (!cachedUAStyle) | |
| 538 return AuthorStyleInfo(); | |
| 539 | |
| 540 // Exclude background-repeat from comparison by resetting it. | |
| 541 FillLayer backgroundCopy = cachedUAStyle->backgroundLayers; | |
| 542 FillLayer backgroundLayersCopy = state.style()->backgroundLayers(); | |
| 543 backgroundCopy.setRepeatX(NoRepeatFill); | |
| 544 backgroundCopy.setRepeatY(NoRepeatFill); | |
| 545 backgroundLayersCopy.setRepeatX(NoRepeatFill); | |
| 546 backgroundLayersCopy.setRepeatY(NoRepeatFill); | |
| 547 | |
| 548 bool backgroundChanged = backgroundLayersCopy != backgroundCopy | |
| 549 || state.style()->backgroundColor() != cachedUAStyle->backgroundColor; | |
| 550 bool borderChanged = state.style()->border() != cachedUAStyle->border; | |
| 551 | |
| 552 return AuthorStyleInfo(backgroundChanged, borderChanged); | |
| 553 } | |
| 554 | |
| 555 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem
ent) | 533 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem
ent) |
| 556 { | 534 { |
| 557 StyleAdjuster adjuster(document().inQuirksMode()); | 535 StyleAdjuster adjuster(document().inQuirksMode()); |
| 558 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(),
element, authorStyleInfo(state)); | 536 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(),
element); |
| 559 } | 537 } |
| 560 | 538 |
| 561 // Start loading resources referenced by this style. | 539 // Start loading resources referenced by this style. |
| 562 void StyleResolver::loadPendingResources(StyleResolverState& state) | 540 void StyleResolver::loadPendingResources(StyleResolverState& state) |
| 563 { | 541 { |
| 564 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 542 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 565 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); | 543 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); |
| 566 } | 544 } |
| 567 | 545 |
| 568 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const
ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, | 546 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const
ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 | 1386 |
| 1409 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl
e. | 1387 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl
e. |
| 1410 state.cacheUserAgentBorderAndBackground(); | 1388 state.cacheUserAgentBorderAndBackground(); |
| 1411 | 1389 |
| 1412 // Now do the author and user normal priority properties and all the !import
ant properties. | 1390 // Now do the author and user normal priority properties and all the !import
ant properties. |
| 1413 applyMatchedProperties<LowPropertyPriority>(state, matchResult.authorRules()
, false, applyInheritedOnly); | 1391 applyMatchedProperties<LowPropertyPriority>(state, matchResult.authorRules()
, false, applyInheritedOnly); |
| 1414 for (auto range : ImportantAuthorRanges(matchResult)) | 1392 for (auto range : ImportantAuthorRanges(matchResult)) |
| 1415 applyMatchedProperties<LowPropertyPriority>(state, range, true, applyInh
eritedOnly); | 1393 applyMatchedProperties<LowPropertyPriority>(state, range, true, applyInh
eritedOnly); |
| 1416 applyMatchedProperties<LowPropertyPriority>(state, matchResult.uaRules(), tr
ue, applyInheritedOnly); | 1394 applyMatchedProperties<LowPropertyPriority>(state, matchResult.uaRules(), tr
ue, applyInheritedOnly); |
| 1417 | 1395 |
| 1396 if (state.style()->hasAppearance() && !applyInheritedOnly) { |
| 1397 // Check whether the final border and background differs from the cached
UA ones. |
| 1398 // When there is a partial match in the MatchedPropertiesCache, these fl
ags will already be set correctly |
| 1399 // and the value stored in cacheUserAgentBorderAndBackground is incorrec
t, so doing this check again |
| 1400 // would give the wrong answer. |
| 1401 state.style()->setHasAuthorBackground(hasAuthorBackground(state)); |
| 1402 state.style()->setHasAuthorBorder(hasAuthorBorder(state)); |
| 1403 } |
| 1404 |
| 1418 loadPendingResources(state); | 1405 loadPendingResources(state); |
| 1419 | 1406 |
| 1420 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, *state.style(), *state.parentStyle())) { | 1407 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, *state.style(), *state.parentStyle())) { |
| 1421 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); | 1408 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); |
| 1422 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache
Hash, matchResult.matchedProperties()); | 1409 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache
Hash, matchResult.matchedProperties()); |
| 1423 } | 1410 } |
| 1424 | 1411 |
| 1425 ASSERT(!state.fontBuilder().fontDirty()); | 1412 ASSERT(!state.fontBuilder().fontDirty()); |
| 1426 } | 1413 } |
| 1427 | 1414 |
| 1415 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) |
| 1416 { |
| 1417 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); |
| 1418 if (!cachedUAStyle) |
| 1419 return false; |
| 1420 |
| 1421 FillLayer oldFill = cachedUAStyle->backgroundLayers; |
| 1422 FillLayer newFill = state.style()->backgroundLayers(); |
| 1423 // Exclude background-repeat from comparison by resetting it. |
| 1424 oldFill.setRepeatX(NoRepeatFill); |
| 1425 oldFill.setRepeatY(NoRepeatFill); |
| 1426 newFill.setRepeatX(NoRepeatFill); |
| 1427 newFill.setRepeatY(NoRepeatFill); |
| 1428 |
| 1429 return (oldFill != newFill || cachedUAStyle->backgroundColor != state.style(
)->backgroundColor()); |
| 1430 } |
| 1431 |
| 1432 bool StyleResolver::hasAuthorBorder(const StyleResolverState& state) |
| 1433 { |
| 1434 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); |
| 1435 return cachedUAStyle && (cachedUAStyle->border != state.style()->border()); |
| 1436 } |
| 1437 |
| 1428 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) | 1438 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) |
| 1429 { | 1439 { |
| 1430 if (!m_watchedSelectorsRules) | 1440 if (!m_watchedSelectorsRules) |
| 1431 return; | 1441 return; |
| 1432 | 1442 |
| 1433 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1443 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 1434 collector.setMode(SelectorChecker::CollectingStyleRules); | 1444 collector.setMode(SelectorChecker::CollectingStyleRules); |
| 1435 | 1445 |
| 1436 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); | 1446 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); |
| 1437 collector.collectMatchingRules(matchRequest); | 1447 collector.collectMatchingRules(matchRequest); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 visitor->trace(m_watchedSelectorsRules); | 1518 visitor->trace(m_watchedSelectorsRules); |
| 1509 visitor->trace(m_treeBoundaryCrossingScopes); | 1519 visitor->trace(m_treeBoundaryCrossingScopes); |
| 1510 visitor->trace(m_styleResourceLoader); | 1520 visitor->trace(m_styleResourceLoader); |
| 1511 visitor->trace(m_styleSharingLists); | 1521 visitor->trace(m_styleSharingLists); |
| 1512 visitor->trace(m_pendingStyleSheets); | 1522 visitor->trace(m_pendingStyleSheets); |
| 1513 visitor->trace(m_document); | 1523 visitor->trace(m_document); |
| 1514 #endif | 1524 #endif |
| 1515 } | 1525 } |
| 1516 | 1526 |
| 1517 } // namespace blink | 1527 } // namespace blink |
| OLD | NEW |