Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 715633006: Remove FontDescriptionChangeScope, and let FontBuilder partially apply values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: IsSetFlag -> PropertySetFlag. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 else 707 else
708 style = RenderStyle::create(); 708 style = RenderStyle::create();
709 StyleResolverState state(element.document(), &element); 709 StyleResolverState state(element.document(), &element);
710 state.setStyle(style); 710 state.setStyle(style);
711 return createAnimatableValueSnapshot(state, property, value); 711 return createAnimatableValueSnapshot(state, property, value);
712 } 712 }
713 713
714 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) 714 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value)
715 { 715 {
716 StyleBuilder::applyProperty(property, state, &value); 716 StyleBuilder::applyProperty(property, state, &value);
717 state.fontBuilder().createFont(state.document().styleEngine()->fontSelector( ), state.style(), state.parentStyle()); 717 state.fontBuilder().createFont(state.document().styleEngine()->fontSelector( ), state.style());
718 return CSSAnimatableValueFactory::create(property, *state.style()); 718 return CSSAnimatableValueFactory::create(property, *state.style());
719 } 719 }
720 720
721 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId) 721 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId)
722 { 722 {
723 if (pseudoId == FIRST_LETTER) 723 if (pseudoId == FIRST_LETTER)
724 return FirstLetterPseudoElement::create(parent); 724 return FirstLetterPseudoElement::create(parent);
725 return PseudoElement::create(parent, pseudoId); 725 return PseudoElement::create(parent, pseudoId);
726 } 726 }
727 727
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 scopedResolver->collectViewportRulesTo(this); 910 scopedResolver->collectViewportRulesTo(this);
911 911
912 viewportStyleResolver()->resolve(); 912 viewportStyleResolver()->resolve();
913 } 913 }
914 914
915 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() 915 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
916 { 916 {
917 RefPtr<RenderStyle> style = RenderStyle::create(); 917 RefPtr<RenderStyle> style = RenderStyle::create();
918 FontBuilder fontBuilder(document()); 918 FontBuilder fontBuilder(document());
919 fontBuilder.setInitial(style->effectiveZoom()); 919 fontBuilder.setInitial(style->effectiveZoom());
920 fontBuilder.createFont(document().styleEngine()->fontSelector(), style.get() , nullptr); 920 fontBuilder.createFont(document().styleEngine()->fontSelector(), style.get() );
921 return style.release(); 921 return style.release();
922 } 922 }
923 923
924 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) 924 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
925 { 925 {
926 ASSERT(textNode); 926 ASSERT(textNode);
927 927
928 Node* parentNode = NodeRenderingTraversal::parent(*textNode); 928 Node* parentNode = NodeRenderingTraversal::parent(*textNode);
929 if (!parentNode || !parentNode->renderStyle()) 929 if (!parentNode || !parentNode->renderStyle())
930 return defaultStyleForElement(); 930 return defaultStyleForElement();
931 return parentNode->renderStyle(); 931 return parentNode->renderStyle();
932 } 932 }
933 933
934 void StyleResolver::updateFont(StyleResolverState& state) 934 void StyleResolver::updateFont(StyleResolverState& state)
935 { 935 {
936 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.style(), state.parentStyle()); 936 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.style());
937 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl e(), state.rootElementStyle())); 937 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl e(), state.rootElementStyle()));
938 state.setConversionZoom(state.style()->effectiveZoom()); 938 state.setConversionZoom(state.style()->effectiveZoom());
939 } 939 }
940 940
941 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) 941 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude)
942 { 942 {
943 ASSERT(element); 943 ASSERT(element);
944 StyleResolverState state(document(), element); 944 StyleResolverState state(document(), element);
945 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 945 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style());
946 collector.setMode(SelectorChecker::CollectingStyleRules); 946 collector.setMode(SelectorChecker::CollectingStyleRules);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t); 1356 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t);
1357 1357
1358 EInsideLink linkStatus = state.style()->insideLink(); 1358 EInsideLink linkStatus = state.style()->insideLink();
1359 // If the cache item parent style has identical inherited properties to the current parent style then the 1359 // If the cache item parent style has identical inherited properties to the current parent style then the
1360 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done. 1360 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done.
1361 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); 1361 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( ));
1362 1362
1363 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. 1363 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it.
1364 state.style()->setInsideLink(linkStatus); 1364 state.style()->setInsideLink(linkStatus);
1365 1365
1366 state.fontBuilder().setFontDescription(state.style()->fontDescriptio n());
1367
1368 updateFont(state); 1366 updateFont(state);
1369 1367
1370 return; 1368 return;
1371 } 1369 }
1372 applyInheritedOnly = true; 1370 applyInheritedOnly = true;
1373 } 1371 }
1374 1372
1375 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1373 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1376 // high-priority properties first, i.e., those properties that other propert ies depend on. 1374 // high-priority properties first, i.e., those properties that other propert ies depend on.
1377 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1375 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1378 // and (4) normal important. 1376 // and (4) normal important.
1379 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, 0, m atchResult.matchedProperties.size() - 1, applyInheritedOnly); 1377 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, 0, m atchResult.matchedProperties.size() - 1, applyInheritedOnly);
1380 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherited Only); 1378 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherited Only);
1381 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1379 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1382 1380
1383 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1381 if (UNLIKELY(isSVGForeignObjectElement(element))) {
1384 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. 1382 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again.
1385 // 1383 //
1386 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the 1384 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the
1387 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority , along with other font-related 1385 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority , along with other font-related
1388 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the 1386 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the
1389 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll 1387 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll
1390 // need to find another way of handling the SVG zoom model. 1388 // need to find another way of handling the SVG zoom model.
1391 state.setEffectiveZoom(RenderStyle::initialZoom()); 1389 state.setEffectiveZoom(RenderStyle::initialZoom());
1392 } 1390 }
1393 1391
1394 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { 1392 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) {
1395 state.fontBuilder().setFontDirty(true); 1393 state.fontBuilder().didChangeEffectiveZoom();
1396 applyInheritedOnly = false; 1394 applyInheritedOnly = false;
1397 } 1395 }
1398 1396
1399 // If our font got dirtied, go ahead and update it now. 1397 // If our font got dirtied, go ahead and update it now.
1400 updateFont(state); 1398 updateFont(state);
1401 1399
1402 // Many properties depend on the font. If it changes we just apply all prope rties. 1400 // Many properties depend on the font. If it changes we just apply all prope rties.
1403 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) 1401 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription())
1404 applyInheritedOnly = false; 1402 applyInheritedOnly = false;
1405 1403
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 visitor->trace(m_uncommonAttributeRuleSet); 1525 visitor->trace(m_uncommonAttributeRuleSet);
1528 visitor->trace(m_watchedSelectorsRules); 1526 visitor->trace(m_watchedSelectorsRules);
1529 visitor->trace(m_treeBoundaryCrossingRules); 1527 visitor->trace(m_treeBoundaryCrossingRules);
1530 visitor->trace(m_styleSharingLists); 1528 visitor->trace(m_styleSharingLists);
1531 visitor->trace(m_pendingStyleSheets); 1529 visitor->trace(m_pendingStyleSheets);
1532 visitor->trace(m_document); 1530 visitor->trace(m_document);
1533 #endif 1531 #endif
1534 } 1532 }
1535 1533
1536 } // namespace blink 1534 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FontBuilderTest.cpp ('k') | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698