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

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: Fix size/family ordering. Created 6 years 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 else 698 else
699 style = RenderStyle::create(); 699 style = RenderStyle::create();
700 StyleResolverState state(element.document(), &element); 700 StyleResolverState state(element.document(), &element);
701 state.setStyle(style); 701 state.setStyle(style);
702 return createAnimatableValueSnapshot(state, property, value); 702 return createAnimatableValueSnapshot(state, property, value);
703 } 703 }
704 704
705 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) 705 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value)
706 { 706 {
707 StyleBuilder::applyProperty(property, state, &value); 707 StyleBuilder::applyProperty(property, state, &value);
708 state.fontBuilder().createFont(state.document().styleEngine()->fontSelector( ), state.style(), state.parentStyle()); 708 state.fontBuilder().createFont(state.document().styleEngine()->fontSelector( ), state.style());
709 return CSSAnimatableValueFactory::create(property, *state.style()); 709 return CSSAnimatableValueFactory::create(property, *state.style());
710 } 710 }
711 711
712 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId) 712 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId)
713 { 713 {
714 if (pseudoId == FIRST_LETTER) 714 if (pseudoId == FIRST_LETTER)
715 return FirstLetterPseudoElement::create(parent); 715 return FirstLetterPseudoElement::create(parent);
716 return PseudoElement::create(parent, pseudoId); 716 return PseudoElement::create(parent, pseudoId);
717 } 717 }
718 718
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 scopedResolver->collectViewportRulesTo(this); 901 scopedResolver->collectViewportRulesTo(this);
902 902
903 viewportStyleResolver()->resolve(); 903 viewportStyleResolver()->resolve();
904 } 904 }
905 905
906 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() 906 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
907 { 907 {
908 RefPtr<RenderStyle> style = RenderStyle::create(); 908 RefPtr<RenderStyle> style = RenderStyle::create();
909 FontBuilder fontBuilder(document()); 909 FontBuilder fontBuilder(document());
910 fontBuilder.setInitial(style->effectiveZoom()); 910 fontBuilder.setInitial(style->effectiveZoom());
911 fontBuilder.createFont(document().styleEngine()->fontSelector(), style.get() , nullptr); 911 fontBuilder.createFont(document().styleEngine()->fontSelector(), style.get() );
912 return style.release(); 912 return style.release();
913 } 913 }
914 914
915 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) 915 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
916 { 916 {
917 ASSERT(textNode); 917 ASSERT(textNode);
918 918
919 Node* parentNode = NodeRenderingTraversal::parent(*textNode); 919 Node* parentNode = NodeRenderingTraversal::parent(*textNode);
920 if (!parentNode || !parentNode->renderStyle()) 920 if (!parentNode || !parentNode->renderStyle())
921 return defaultStyleForElement(); 921 return defaultStyleForElement();
922 return parentNode->renderStyle(); 922 return parentNode->renderStyle();
923 } 923 }
924 924
925 void StyleResolver::updateFont(StyleResolverState& state) 925 void StyleResolver::updateFont(StyleResolverState& state)
926 { 926 {
927 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.style(), state.parentStyle()); 927 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.style());
928 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl e(), state.rootElementStyle())); 928 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl e(), state.rootElementStyle()));
929 state.setConversionZoom(state.style()->effectiveZoom()); 929 state.setConversionZoom(state.style()->effectiveZoom());
930 } 930 }
931 931
932 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) 932 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude)
933 { 933 {
934 ASSERT(element); 934 ASSERT(element);
935 StyleResolverState state(document(), element); 935 StyleResolverState state(document(), element);
936 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 936 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style());
937 collector.setMode(SelectorChecker::CollectingStyleRules); 937 collector.setMode(SelectorChecker::CollectingStyleRules);
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t); 1431 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t);
1432 1432
1433 EInsideLink linkStatus = state.style()->insideLink(); 1433 EInsideLink linkStatus = state.style()->insideLink();
1434 // If the cache item parent style has identical inherited properties to the current parent style then the 1434 // If the cache item parent style has identical inherited properties to the current parent style then the
1435 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done. 1435 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done.
1436 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); 1436 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( ));
1437 1437
1438 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. 1438 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it.
1439 state.style()->setInsideLink(linkStatus); 1439 state.style()->setInsideLink(linkStatus);
1440 1440
1441 state.fontBuilder().setFontDescription(state.style()->fontDescriptio n());
1442
1443 updateFont(state); 1441 updateFont(state);
1444 1442
1445 return; 1443 return;
1446 } 1444 }
1447 applyInheritedOnly = true; 1445 applyInheritedOnly = true;
1448 } 1446 }
1449 1447
1450 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1448 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1451 // high-priority properties first, i.e., those properties that other propert ies depend on. 1449 // high-priority properties first, i.e., those properties that other propert ies depend on.
1452 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1450 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1453 // and (4) normal important. 1451 // and (4) normal important.
1454 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 1452 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
1455 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); 1453 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly);
1456 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1454 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1457 1455
1458 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1456 if (UNLIKELY(isSVGForeignObjectElement(element))) {
1459 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. 1457 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again.
1460 // 1458 //
1461 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the 1459 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the
1462 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related 1460 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related
1463 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the 1461 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the
1464 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll 1462 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll
1465 // need to find another way of handling the SVG zoom model. 1463 // need to find another way of handling the SVG zoom model.
1466 state.setEffectiveZoom(RenderStyle::initialZoom()); 1464 state.setEffectiveZoom(RenderStyle::initialZoom());
1467 } 1465 }
1468 1466
1469 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { 1467 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) {
1470 state.fontBuilder().setFontDirty(true); 1468 state.fontBuilder().didChangeEffectiveZoom(true);
1471 applyInheritedOnly = false; 1469 applyInheritedOnly = false;
1472 } 1470 }
1473 1471
1474 // If our font got dirtied, go ahead and update it now. 1472 // If our font got dirtied, go ahead and update it now.
1475 updateFont(state); 1473 updateFont(state);
1476 1474
1477 // Many properties depend on the font. If it changes we just apply all prope rties. 1475 // Many properties depend on the font. If it changes we just apply all prope rties.
1478 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) 1476 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription())
1479 applyInheritedOnly = false; 1477 applyInheritedOnly = false;
1480 1478
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 visitor->trace(m_uncommonAttributeRuleSet); 1600 visitor->trace(m_uncommonAttributeRuleSet);
1603 visitor->trace(m_watchedSelectorsRules); 1601 visitor->trace(m_watchedSelectorsRules);
1604 visitor->trace(m_treeBoundaryCrossingRules); 1602 visitor->trace(m_treeBoundaryCrossingRules);
1605 visitor->trace(m_styleSharingLists); 1603 visitor->trace(m_styleSharingLists);
1606 visitor->trace(m_pendingStyleSheets); 1604 visitor->trace(m_pendingStyleSheets);
1607 visitor->trace(m_document); 1605 visitor->trace(m_document);
1608 #endif 1606 #endif
1609 } 1607 }
1610 1608
1611 } // namespace blink 1609 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698