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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include "core/css/CSSKeyframesRule.h" | 46 #include "core/css/CSSKeyframesRule.h" |
| 47 #include "core/css/CSSLineBoxContainValue.h" | 47 #include "core/css/CSSLineBoxContainValue.h" |
| 48 #include "core/css/CSSParser.h" | 48 #include "core/css/CSSParser.h" |
| 49 #include "core/css/CSSPrimitiveValueMappings.h" | 49 #include "core/css/CSSPrimitiveValueMappings.h" |
| 50 #include "core/css/CSSReflectValue.h" | 50 #include "core/css/CSSReflectValue.h" |
| 51 #include "core/css/CSSSVGDocumentValue.h" | 51 #include "core/css/CSSSVGDocumentValue.h" |
| 52 #include "core/css/CSSSelector.h" | 52 #include "core/css/CSSSelector.h" |
| 53 #include "core/css/CSSSelectorList.h" | 53 #include "core/css/CSSSelectorList.h" |
| 54 #include "core/css/CSSStyleRule.h" | 54 #include "core/css/CSSStyleRule.h" |
| 55 #include "core/css/CSSValueList.h" | 55 #include "core/css/CSSValueList.h" |
| 56 #include "core/css/CSSValuePool.h" | |
| 56 #include "core/css/CSSVariableValue.h" | 57 #include "core/css/CSSVariableValue.h" |
| 57 #include "core/css/ElementRuleCollector.h" | 58 #include "core/css/ElementRuleCollector.h" |
| 58 #include "core/css/FontFeatureValue.h" | 59 #include "core/css/FontFeatureValue.h" |
| 59 #include "core/css/FontSize.h" | 60 #include "core/css/FontSize.h" |
| 60 #include "core/css/MediaQueryEvaluator.h" | 61 #include "core/css/MediaQueryEvaluator.h" |
| 61 #include "core/css/PageRuleCollector.h" | 62 #include "core/css/PageRuleCollector.h" |
| 62 #include "core/css/Pair.h" | 63 #include "core/css/Pair.h" |
| 63 #include "core/css/RuleSet.h" | 64 #include "core/css/RuleSet.h" |
| 64 #include "core/css/StylePropertySet.h" | 65 #include "core/css/StylePropertySet.h" |
| 65 #include "core/css/StylePropertyShorthand.h" | 66 #include "core/css/StylePropertyShorthand.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 80 #include "core/dom/WebCoreMemoryInstrumentation.h" | 81 #include "core/dom/WebCoreMemoryInstrumentation.h" |
| 81 #include "core/dom/shadow/ShadowRoot.h" | 82 #include "core/dom/shadow/ShadowRoot.h" |
| 82 #include "core/html/HTMLHtmlElement.h" | 83 #include "core/html/HTMLHtmlElement.h" |
| 83 #include "core/html/HTMLIFrameElement.h" | 84 #include "core/html/HTMLIFrameElement.h" |
| 84 #include "core/inspector/InspectorInstrumentation.h" | 85 #include "core/inspector/InspectorInstrumentation.h" |
| 85 #include "core/loader/cache/CachedDocument.h" | 86 #include "core/loader/cache/CachedDocument.h" |
| 86 #include "core/loader/cache/CachedSVGDocumentReference.h" | 87 #include "core/loader/cache/CachedSVGDocumentReference.h" |
| 87 #include "core/page/Frame.h" | 88 #include "core/page/Frame.h" |
| 88 #include "core/page/FrameView.h" | 89 #include "core/page/FrameView.h" |
| 89 #include "core/page/Page.h" | 90 #include "core/page/Page.h" |
| 91 #include "core/page/PageGroup.h" | |
| 90 #include "core/page/Settings.h" | 92 #include "core/page/Settings.h" |
| 93 #include "core/page/UserStyleSheet.h" | |
| 91 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h" | 94 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h" |
| 92 #include "core/platform/text/LocaleToScriptMapping.h" | 95 #include "core/platform/text/LocaleToScriptMapping.h" |
| 93 #include "core/rendering/RenderView.h" | 96 #include "core/rendering/RenderView.h" |
| 94 #include "core/rendering/style/KeyframeList.h" | 97 #include "core/rendering/style/KeyframeList.h" |
| 95 #include "core/rendering/style/StyleCustomFilterProgramCache.h" | 98 #include "core/rendering/style/StyleCustomFilterProgramCache.h" |
| 96 #include "core/svg/SVGDocumentExtensions.h" | 99 #include "core/svg/SVGDocumentExtensions.h" |
| 97 #include "core/svg/SVGElement.h" | 100 #include "core/svg/SVGElement.h" |
| 98 #include "core/svg/SVGFontFaceElement.h" | 101 #include "core/svg/SVGFontFaceElement.h" |
| 99 #include "wtf/MemoryInstrumentationHashMap.h" | 102 #include "wtf/MemoryInstrumentationHashMap.h" |
| 100 #include "wtf/MemoryInstrumentationVector.h" | 103 #include "wtf/MemoryInstrumentationVector.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 m_medium = adoptPtr(new MediaQueryEvaluator("all")); | 160 m_medium = adoptPtr(new MediaQueryEvaluator("all")); |
| 158 | 161 |
| 159 if (root) | 162 if (root) |
| 160 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc hOnlyUserAgentRules); | 163 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc hOnlyUserAgentRules); |
| 161 | 164 |
| 162 if (m_rootDefaultStyle && view) | 165 if (m_rootDefaultStyle && view) |
| 163 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->fra me(), m_rootDefaultStyle.get())); | 166 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->fra me(), m_rootDefaultStyle.get())); |
| 164 | 167 |
| 165 m_styleTree.clear(); | 168 m_styleTree.clear(); |
| 166 | 169 |
| 170 if (document->isXHTMLMobileProfile()) { | |
| 171 Vector<String> whitelist; | |
| 172 whitelist.append(document->url()); | |
| 173 static const char* sheet = "@viewport{-internal-priority:1;width:auto;he ight:auto;zoom:1;}"; | |
| 174 document->page()->group().addUserStyleSheet(sheet, KURL(), whitelist, Ve ctor<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocumen ts); | |
| 175 } | |
| 176 | |
| 167 DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCol lection(); | 177 DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCol lection(); |
| 168 m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this); | 178 m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this); |
| 169 | 179 |
| 170 #if ENABLE(SVG_FONTS) | 180 #if ENABLE(SVG_FONTS) |
| 171 if (document->svgExtensions()) { | 181 if (document->svgExtensions()) { |
| 172 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgE xtensions()->svgFontFaceElements(); | 182 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgE xtensions()->svgFontFaceElements(); |
| 173 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e nd(); | 183 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e nd(); |
| 174 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen ts.begin(); it != end; ++it) | 184 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen ts.begin(); it != end; ++it) |
| 175 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); | 185 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); |
| 176 } | 186 } |
| 177 #endif | 187 #endif |
| 178 | 188 |
| 179 // FIXME: Stylesheet candidate nodes are sorted in document order, but scopi ng nodes are not sorted. | 189 // FIXME: Stylesheet candidate nodes are sorted in document order, but scopi ng nodes are not sorted. |
| 180 appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets()); | 190 appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets()); |
| 181 } | 191 } |
| 182 | 192 |
| 183 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) | 193 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) |
| 184 { | 194 { |
| 185 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver | 195 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver |
| 186 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. | 196 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. |
| 187 unsigned size = styleSheets.size(); | 197 unsigned size = styleSheets.size(); |
| 188 for (unsigned i = firstNew; i < size; ++i) { | 198 for (unsigned i = firstNew; i < size; ++i) { |
| 189 CSSStyleSheet* cssSheet = styleSheets[i].get(); | 199 CSSStyleSheet* cssSheet = styleSheets[i].get(); |
| 200 | |
| 190 ASSERT(!cssSheet->disabled()); | 201 ASSERT(!cssSheet->disabled()); |
| 191 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , this)) | 202 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , this)) |
| 192 continue; | 203 continue; |
| 193 | 204 |
| 194 StyleSheetContents* sheet = cssSheet->contents(); | 205 StyleSheetContents* sheet = cssSheet->contents(); |
| 195 ScopedStyleResolver* resolver = ensureScopedStyleResolver(ScopedStyleRes olver::scopingNodeFor(cssSheet)); | 206 ScopedStyleResolver* resolver = ensureScopedStyleResolver(ScopedStyleRes olver::scopingNodeFor(cssSheet)); |
| 196 ASSERT(resolver); | 207 ASSERT(resolver); |
| 197 resolver->addRulesFromSheet(sheet, *m_medium, this); | 208 resolver->addRulesFromSheet(sheet, *m_medium, this); |
| 198 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | 209 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); |
| 199 } | 210 } |
| 200 | 211 |
| 201 collectFeatures(); | 212 collectFeatures(); |
| 202 | 213 |
| 203 if (document()->renderer() && document()->renderer()->style()) | 214 if (document()->renderer() && document()->renderer()->style()) |
| 204 document()->renderer()->style()->font().update(fontSelector()); | 215 document()->renderer()->style()->font().update(fontSelector()); |
| 205 | 216 |
| 206 if (RuntimeEnabledFeatures::cssViewportEnabled()) | 217 collectViewportRules(); |
| 207 collectViewportRules(); | |
| 208 } | 218 } |
| 209 | 219 |
| 210 void StyleResolver::resetAuthorStyle() | 220 void StyleResolver::resetAuthorStyle() |
| 211 { | 221 { |
| 212 m_styleTree.clear(); | 222 m_styleTree.clear(); |
| 213 } | 223 } |
| 214 | 224 |
| 215 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | 225 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) |
| 216 { | 226 { |
| 217 m_styleTree.clear(); | 227 m_styleTree.clear(); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | 937 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); |
| 928 | 938 |
| 929 document()->didAccessStyleResolver(); | 939 document()->didAccessStyleResolver(); |
| 930 | 940 |
| 931 // Now return the style. | 941 // Now return the style. |
| 932 return state.takeStyle(); | 942 return state.takeStyle(); |
| 933 } | 943 } |
| 934 | 944 |
| 935 void StyleResolver::collectViewportRules() | 945 void StyleResolver::collectViewportRules() |
| 936 { | 946 { |
| 937 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled()); | |
| 938 | |
| 939 collectViewportRules(CSSDefaultStyleSheets::defaultStyle); | 947 collectViewportRules(CSSDefaultStyleSheets::defaultStyle); |
| 940 if (m_ruleSets.userStyle()) | 948 if (m_ruleSets.userStyle()) |
| 941 collectViewportRules(m_ruleSets.userStyle()); | 949 collectViewportRules(m_ruleSets.userStyle()); |
| 942 | 950 |
| 951 // OK to collect here for viewport meta etc, only the parser doesn't allow a ddition | |
| 952 // of @viewport with the runtime check. | |
| 943 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) | 953 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) |
| 944 scopedResolver->collectViewportRulesTo(this); | 954 scopedResolver->collectViewportRulesTo(this); |
| 945 | 955 |
| 946 viewportStyleResolver()->resolve(); | 956 viewportStyleResolver()->resolve(); |
| 947 } | 957 } |
| 948 | 958 |
| 949 void StyleResolver::collectViewportRules(RuleSet* rules) | 959 void StyleResolver::collectViewportRules(RuleSet* rules) |
| 950 { | 960 { |
| 951 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled()); | |
| 952 | |
| 953 rules->compactRulesIfNeeded(); | 961 rules->compactRulesIfNeeded(); |
| 954 | 962 |
| 955 const Vector<StyleRuleViewport*>& viewportRules = rules->viewportRules(); | 963 const Vector<StyleRuleViewport*>& viewportRules = rules->viewportRules(); |
| 956 for (size_t i = 0; i < viewportRules.size(); ++i) | 964 for (size_t i = 0; i < viewportRules.size(); ++i) |
| 957 viewportStyleResolver()->addViewportRule(viewportRules[i]); | 965 viewportStyleResolver()->addViewportRule(viewportRules[i]); |
| 958 } | 966 } |
| 959 | 967 |
| 960 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 968 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
| 961 { | 969 { |
| 962 m_state.setStyle(RenderStyle::create()); | 970 m_state.setStyle(RenderStyle::create()); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1477 m_viewportDependentMediaQueryResults.append(adoptPtr(new MediaQueryResult(*e xpr, result))); | 1485 m_viewportDependentMediaQueryResults.append(adoptPtr(new MediaQueryResult(*e xpr, result))); |
| 1478 } | 1486 } |
| 1479 | 1487 |
| 1480 bool StyleResolver::affectedByViewportChange() const | 1488 bool StyleResolver::affectedByViewportChange() const |
| 1481 { | 1489 { |
| 1482 unsigned s = m_viewportDependentMediaQueryResults.size(); | 1490 unsigned s = m_viewportDependentMediaQueryResults.size(); |
| 1483 for (unsigned i = 0; i < s; i++) { | 1491 for (unsigned i = 0; i < s; i++) { |
| 1484 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1492 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1485 return true; | 1493 return true; |
| 1486 } | 1494 } |
| 1487 return false; | 1495 |
| 1496 return m_viewportStyleResolver->affectedByViewportChange(); | |
|
Mikhail
2013/07/19 12:56:21
This is causing dead loop if having '%' values of
| |
| 1488 } | 1497 } |
| 1489 | 1498 |
| 1490 void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 1499 void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| 1491 { | 1500 { |
| 1492 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | 1501 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); |
| 1493 info.addMember(m_ruleSets, "ruleSets"); | 1502 info.addMember(m_ruleSets, "ruleSets"); |
| 1494 info.addMember(m_matchedPropertiesCache, "matchedPropertiesCache"); | 1503 info.addMember(m_matchedPropertiesCache, "matchedPropertiesCache"); |
| 1495 | 1504 |
| 1496 info.addMember(m_medium, "medium"); | 1505 info.addMember(m_medium, "medium"); |
| 1497 info.addMember(m_rootDefaultStyle, "rootDefaultStyle"); | 1506 info.addMember(m_rootDefaultStyle, "rootDefaultStyle"); |
| 1498 info.addMember(m_document, "document"); | 1507 info.addMember(m_document, "document"); |
| 1499 | 1508 |
| 1500 info.addMember(m_fontSelector, "fontSelector"); | 1509 info.addMember(m_fontSelector, "fontSelector"); |
| 1501 info.addMember(m_viewportDependentMediaQueryResults, "viewportDependentMedia QueryResults"); | 1510 info.addMember(m_viewportDependentMediaQueryResults, "viewportDependentMedia QueryResults"); |
| 1502 info.addMember(m_inspectorCSSOMWrappers); | 1511 info.addMember(m_inspectorCSSOMWrappers); |
| 1503 | 1512 |
| 1504 info.addMember(m_styleTree, "scopedStyleTree"); | 1513 info.addMember(m_styleTree, "scopedStyleTree"); |
| 1505 info.addMember(m_state, "state"); | 1514 info.addMember(m_state, "state"); |
| 1506 | 1515 |
| 1507 // FIXME: move this to a place where it would be called only once? | 1516 // FIXME: move this to a place where it would be called only once? |
| 1508 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle"); | 1517 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle"); |
| 1509 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e"); | 1518 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e"); |
| 1510 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle, "defaultPrintStyle" ); | 1519 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle, "defaultPrintStyle" ); |
| 1511 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle"); | 1520 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle"); |
| 1512 } | 1521 } |
| 1513 | 1522 |
| 1514 } // namespace WebCore | 1523 } // namespace WebCore |
| OLD | NEW |