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, the non- inherited values are copied from | |
Timothy Loh
2015/08/25 08:08:20
This comment took me a couple of reads to get, may
meade_UTC10
2015/08/25 08:22:51
The comment about what happens in cacheUserAgentBo
| |
1399 // the cache, and cacheUserAgentBorderAndBackground caches those. In tha t case, hasAuthorBackground/Border | |
1400 // compares the final style with itself and returns the wrong result, bu t | |
1401 // state.style().hasAuthorBackground has already been calculated and cac hed, so it's ok not to do this | |
1402 // check again. | |
1403 state.style()->setHasAuthorBackground(hasAuthorBackground(state)); | |
1404 state.style()->setHasAuthorBorder(hasAuthorBorder(state)); | |
1405 } | |
1406 | |
1418 loadPendingResources(state); | 1407 loadPendingResources(state); |
1419 | 1408 |
1420 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) { | 1409 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) { |
1421 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); | 1410 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); |
1422 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult.matchedProperties()); | 1411 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult.matchedProperties()); |
1423 } | 1412 } |
1424 | 1413 |
1425 ASSERT(!state.fontBuilder().fontDirty()); | 1414 ASSERT(!state.fontBuilder().fontDirty()); |
1426 } | 1415 } |
1427 | 1416 |
1417 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) | |
1418 { | |
1419 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | |
1420 if (!cachedUAStyle) | |
1421 return false; | |
1422 | |
1423 FillLayer oldFill = cachedUAStyle->backgroundLayers; | |
1424 FillLayer newFill = state.style()->backgroundLayers(); | |
1425 // Exclude background-repeat from comparison by resetting it. | |
1426 oldFill.setRepeatX(NoRepeatFill); | |
1427 oldFill.setRepeatY(NoRepeatFill); | |
1428 newFill.setRepeatX(NoRepeatFill); | |
1429 newFill.setRepeatY(NoRepeatFill); | |
1430 | |
1431 return (oldFill != newFill || cachedUAStyle->backgroundColor != state.style( )->backgroundColor()); | |
1432 } | |
1433 | |
1434 bool StyleResolver::hasAuthorBorder(const StyleResolverState& state) | |
1435 { | |
1436 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | |
1437 return cachedUAStyle && (cachedUAStyle->border != state.style()->border()); | |
1438 } | |
1439 | |
1428 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) | 1440 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) |
1429 { | 1441 { |
1430 if (!m_watchedSelectorsRules) | 1442 if (!m_watchedSelectorsRules) |
1431 return; | 1443 return; |
1432 | 1444 |
1433 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); | 1445 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); |
1434 collector.setMode(SelectorChecker::CollectingStyleRules); | 1446 collector.setMode(SelectorChecker::CollectingStyleRules); |
1435 | 1447 |
1436 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); | 1448 MatchRequest matchRequest(m_watchedSelectorsRules.get(), true); |
1437 collector.collectMatchingRules(matchRequest); | 1449 collector.collectMatchingRules(matchRequest); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1508 visitor->trace(m_watchedSelectorsRules); | 1520 visitor->trace(m_watchedSelectorsRules); |
1509 visitor->trace(m_treeBoundaryCrossingScopes); | 1521 visitor->trace(m_treeBoundaryCrossingScopes); |
1510 visitor->trace(m_styleResourceLoader); | 1522 visitor->trace(m_styleResourceLoader); |
1511 visitor->trace(m_styleSharingLists); | 1523 visitor->trace(m_styleSharingLists); |
1512 visitor->trace(m_pendingStyleSheets); | 1524 visitor->trace(m_pendingStyleSheets); |
1513 visitor->trace(m_document); | 1525 visitor->trace(m_document); |
1514 #endif | 1526 #endif |
1515 } | 1527 } |
1516 | 1528 |
1517 } // namespace blink | 1529 } // namespace blink |
OLD | NEW |