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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 // important rules, but this currently happens here as we require adjustment
to have happened | 724 // important rules, but this currently happens here as we require adjustment
to have happened |
725 // before deciding which properties to transition. | 725 // before deciding which properties to transition. |
726 applyAnimatedProperties(state, element); | 726 applyAnimatedProperties(state, element); |
727 | 727 |
728 // FIXME: Shouldn't this be on RenderBody::styleDidChange? | 728 // FIXME: Shouldn't this be on RenderBody::styleDidChange? |
729 if (element->hasTagName(bodyTag)) | 729 if (element->hasTagName(bodyTag)) |
730 document().textLinkColors().setTextColor(state.style()->color()); | 730 document().textLinkColors().setTextColor(state.style()->color()); |
731 | 731 |
732 setAnimationUpdateIfNeeded(state, *element); | 732 setAnimationUpdateIfNeeded(state, *element); |
733 | 733 |
| 734 if (state.style()->hasViewportUnits()) |
| 735 document().setHasViewportUnits(); |
| 736 |
734 // Now return the style. | 737 // Now return the style. |
735 return state.takeStyle(); | 738 return state.takeStyle(); |
736 } | 739 } |
737 | 740 |
738 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* element, const
RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra
me, const AtomicString& animationName) | 741 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* element, const
RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra
me, const AtomicString& animationName) |
739 { | 742 { |
740 ASSERT(document().frame()); | 743 ASSERT(document().frame()); |
741 ASSERT(documentSettings()); | 744 ASSERT(documentSettings()); |
742 ASSERT(!hasPendingAuthorStyleSheets()); | 745 ASSERT(!hasPendingAuthorStyleSheets()); |
743 | 746 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before | 936 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before |
934 // important rules, but this currently happens here as we require adjustment
to have happened | 937 // important rules, but this currently happens here as we require adjustment
to have happened |
935 // before deciding which properties to transition. | 938 // before deciding which properties to transition. |
936 applyAnimatedProperties(state, element->pseudoElement(pseudoStyleRequest.pse
udoId)); | 939 applyAnimatedProperties(state, element->pseudoElement(pseudoStyleRequest.pse
udoId)); |
937 | 940 |
938 didAccess(); | 941 didAccess(); |
939 | 942 |
940 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest
.pseudoId)) | 943 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest
.pseudoId)) |
941 setAnimationUpdateIfNeeded(state, *pseudoElement); | 944 setAnimationUpdateIfNeeded(state, *pseudoElement); |
942 | 945 |
| 946 if (state.style()->hasViewportUnits()) |
| 947 document().setHasViewportUnits(); |
| 948 |
943 // Now return the style. | 949 // Now return the style. |
944 return state.takeStyle(); | 950 return state.takeStyle(); |
945 } | 951 } |
946 | 952 |
947 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) | 953 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) |
948 { | 954 { |
949 ASSERT(!hasPendingAuthorStyleSheets()); | 955 ASSERT(!hasPendingAuthorStyleSheets()); |
950 resetDirectionAndWritingModeOnDocument(document()); | 956 resetDirectionAndWritingModeOnDocument(document()); |
951 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. | 957 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. |
952 | 958 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) { | 1044 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) { |
1039 if (scopedResolver->checkRegionStyle(regionElement)) | 1045 if (scopedResolver->checkRegionStyle(regionElement)) |
1040 return true; | 1046 return true; |
1041 } | 1047 } |
1042 return false; | 1048 return false; |
1043 } | 1049 } |
1044 | 1050 |
1045 void StyleResolver::updateFont(StyleResolverState& state) | 1051 void StyleResolver::updateFont(StyleResolverState& state) |
1046 { | 1052 { |
1047 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.parentStyle(), state.style()); | 1053 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.parentStyle(), state.style()); |
| 1054 if (state.fontBuilder().fontSizeHasViewportUnits()) |
| 1055 state.style()->setHasViewportUnits(); |
1048 } | 1056 } |
1049 | 1057 |
1050 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) | 1058 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) |
1051 { | 1059 { |
1052 ASSERT(element); | 1060 ASSERT(element); |
1053 StyleResolverState state(document(), element); | 1061 StyleResolverState state(document(), element); |
1054 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1062 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
1055 collector.setMode(SelectorChecker::CollectingStyleRules); | 1063 collector.setMode(SelectorChecker::CollectingStyleRules); |
1056 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); | 1064 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); |
1057 return collector.matchedStyleRuleList(); | 1065 return collector.matchedStyleRuleList(); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties
, unsigned size) | 1294 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties
, unsigned size) |
1287 { | 1295 { |
1288 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size
); | 1296 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size
); |
1289 } | 1297 } |
1290 | 1298 |
1291 void StyleResolver::invalidateMatchedPropertiesCache() | 1299 void StyleResolver::invalidateMatchedPropertiesCache() |
1292 { | 1300 { |
1293 m_matchedPropertiesCache.clear(); | 1301 m_matchedPropertiesCache.clear(); |
1294 } | 1302 } |
1295 | 1303 |
| 1304 void StyleResolver::notifyResizeForViewportUnits() |
| 1305 { |
| 1306 collectViewportRules(); |
| 1307 m_matchedPropertiesCache.clearViewportDependent(); |
| 1308 } |
| 1309 |
1296 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult) | 1310 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult) |
1297 { | 1311 { |
1298 const Element* element = state.element(); | 1312 const Element* element = state.element(); |
1299 ASSERT(element); | 1313 ASSERT(element); |
1300 | 1314 |
1301 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyApply); | 1315 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyApply); |
1302 | 1316 |
1303 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(
matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; | 1317 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(
matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; |
1304 bool applyInheritedOnly = false; | 1318 bool applyInheritedOnly = false; |
1305 const CachedMatchedProperties* cachedMatchedProperties = 0; | 1319 const CachedMatchedProperties* cachedMatchedProperties = 0; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 } | 1465 } |
1452 } | 1466 } |
1453 } | 1467 } |
1454 | 1468 |
1455 void StyleResolver::addMediaQueryResults(const MediaQueryResultList& list) | 1469 void StyleResolver::addMediaQueryResults(const MediaQueryResultList& list) |
1456 { | 1470 { |
1457 for (size_t i = 0; i < list.size(); ++i) | 1471 for (size_t i = 0; i < list.size(); ++i) |
1458 m_viewportDependentMediaQueryResults.append(list[i]); | 1472 m_viewportDependentMediaQueryResults.append(list[i]); |
1459 } | 1473 } |
1460 | 1474 |
1461 bool StyleResolver::affectedByViewportChange() const | 1475 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
1462 { | 1476 { |
1463 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1477 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
1464 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1478 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
1465 return true; | 1479 return true; |
1466 } | 1480 } |
1467 return false; | 1481 return false; |
1468 } | 1482 } |
1469 | 1483 |
1470 } // namespace WebCore | 1484 } // namespace WebCore |
OLD | NEW |