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

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

Issue 308123010: Trigger computation of font size when crossing foreignObject boundary (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove use of useSVGZoomRules in FontBuilder and add a forced mode for when crossing the foreignObj… Created 6 years, 6 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } 644 }
645 // contenteditable attribute (implemented by -webkit-user-modify) should 645 // contenteditable attribute (implemented by -webkit-user-modify) should
646 // be propagated from shadow host to distributed node. 646 // be propagated from shadow host to distributed node.
647 if (state.distributedToInsertionPoint()) { 647 if (state.distributedToInsertionPoint()) {
648 if (Element* parent = element->parentElement()) { 648 if (Element* parent = element->parentElement()) {
649 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) 649 if (RenderStyle* styleOfShadowHost = parent->renderStyle())
650 state.style()->setUserModify(styleOfShadowHost->userModify()); 650 state.style()->setUserModify(styleOfShadowHost->userModify());
651 } 651 }
652 } 652 }
653 653
654 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 654 if (UNLIKELY(isSVGForeignObjectElement(element))) {
655 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should
656 // not be scaled again.
657 state.style()->setEffectiveZoom(RenderStyle::initialZoom());
davve 2014/06/04 08:04:24 If I use the StyleResolverState to set effective z
658
659 // Always rebuild font. We cannot inherit the font when crossing svg -> html border because
660 // of the forced zoom factor.
661 state.fontBuilder().initForStyleResolve(state.document(), state.style(), FontBuilder::AlwaysBuildFont);
662 } else {
663 state.fontBuilder().initForStyleResolve(state.document(), state.style(), FontBuilder::OnlyBuildFontOnChange);
pdr. 2014/06/03 16:40:46 Is the last parameter necessary?
664 }
655 665
656 if (element->isLink()) { 666 if (element->isLink()) {
657 state.style()->setIsLink(true); 667 state.style()->setIsLink(true);
658 EInsideLink linkState = state.elementLinkState(); 668 EInsideLink linkState = state.elementLinkState();
659 if (linkState != NotInsideLink) { 669 if (linkState != NotInsideLink) {
660 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); 670 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited);
661 if (forceVisited) 671 if (forceVisited)
662 linkState = InsideVisitedLink; 672 linkState = InsideVisitedLink;
663 } 673 }
664 state.style()->setInsideLink(linkState); 674 state.style()->setInsideLink(linkState);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 722
713 MatchResult result; 723 MatchResult result;
714 result.addMatchedProperties(&keyframe->properties()); 724 result.addMatchedProperties(&keyframe->properties());
715 725
716 ASSERT(!state.style()); 726 ASSERT(!state.style());
717 727
718 // Create the style 728 // Create the style
719 state.setStyle(RenderStyle::clone(&elementStyle)); 729 state.setStyle(RenderStyle::clone(&elementStyle));
720 state.setLineHeightValue(0); 730 state.setLineHeightValue(0);
721 731
722 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 732 state.fontBuilder().initForStyleResolve(state.document(), state.style());
723 733
724 // We don't need to bother with !important. Since there is only ever one 734 // We don't need to bother with !important. Since there is only ever one
725 // decl, there's nothing to override. So just add the first properties. 735 // decl, there's nothing to override. So just add the first properties.
726 // We also don't need to bother with animation properties since the only 736 // We also don't need to bother with animation properties since the only
727 // relevant one is animation-timing-function and we special-case that in 737 // relevant one is animation-timing-function and we special-case that in
728 // CSSAnimations.cpp 738 // CSSAnimations.cpp
729 bool inheritedOnly = false; 739 bool inheritedOnly = false;
730 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); 740 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly);
731 741
732 // If our font got dirtied, go ahead and update it now. 742 // If our font got dirtied, go ahead and update it now.
(...skipping 26 matching lines...) Expand all
759 style = RenderStyle::clone(element.renderStyle()); 769 style = RenderStyle::clone(element.renderStyle());
760 else 770 else
761 style = RenderStyle::create(); 771 style = RenderStyle::create();
762 return createAnimatableValueSnapshot(element, property, value, *style); 772 return createAnimatableValueSnapshot(element, property, value, *style);
763 } 773 }
764 774
765 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, CSSPropertyID property, CSSValue& value, RenderStyle& sty le) 775 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, CSSPropertyID property, CSSValue& value, RenderStyle& sty le)
766 { 776 {
767 StyleResolverState state(element.document(), &element); 777 StyleResolverState state(element.document(), &element);
768 state.setStyle(&style); 778 state.setStyle(&style);
769 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 779 state.fontBuilder().initForStyleResolve(state.document(), state.style());
770 StyleBuilder::applyProperty(property, state, &value); 780 StyleBuilder::applyProperty(property, state, &value);
771 return CSSAnimatableValueFactory::create(property, style); 781 return CSSAnimatableValueFactory::create(property, style);
772 } 782 }
773 783
774 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) 784 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId)
775 { 785 {
776 RenderObject* parentRenderer = parent.renderer(); 786 RenderObject* parentRenderer = parent.renderer();
777 if (!parentRenderer) 787 if (!parentRenderer)
778 return nullptr; 788 return nullptr;
779 789
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 StyleResolverParentScope::ensureParentStackIsPushed(); 830 StyleResolverParentScope::ensureParentStackIsPushed();
821 831
822 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { 832 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
823 state.setStyle(RenderStyle::create()); 833 state.setStyle(RenderStyle::create());
824 state.style()->inheritFrom(state.parentStyle()); 834 state.style()->inheritFrom(state.parentStyle());
825 } else { 835 } else {
826 state.setStyle(defaultStyleForElement()); 836 state.setStyle(defaultStyleForElement());
827 state.setParentStyle(RenderStyle::clone(state.style())); 837 state.setParentStyle(RenderStyle::clone(state.style()));
828 } 838 }
829 839
830 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 840 state.fontBuilder().initForStyleResolve(state.document(), state.style());
831 841
832 // Since we don't use pseudo-elements in any of our quirk/print 842 // Since we don't use pseudo-elements in any of our quirk/print
833 // user agent rules, don't waste time walking those rules. 843 // user agent rules, don't waste time walking those rules.
834 844
835 { 845 {
836 // Check UA, user and author rules. 846 // Check UA, user and author rules.
837 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); 847 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
838 collector.setPseudoStyleRequest(pseudoStyleRequest); 848 collector.setPseudoStyleRequest(pseudoStyleRequest);
839 849
840 matchUARules(collector); 850 matchUARules(collector);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 { 899 {
890 ASSERT(!hasPendingAuthorStyleSheets()); 900 ASSERT(!hasPendingAuthorStyleSheets());
891 resetDirectionAndWritingModeOnDocument(document()); 901 resetDirectionAndWritingModeOnDocument(document());
892 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. 902 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style.
893 903
894 state.setStyle(RenderStyle::create()); 904 state.setStyle(RenderStyle::create());
895 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); 905 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle();
896 ASSERT(rootElementStyle); 906 ASSERT(rootElementStyle);
897 state.style()->inheritFrom(rootElementStyle); 907 state.style()->inheritFrom(rootElementStyle);
898 908
899 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 909 state.fontBuilder().initForStyleResolve(state.document(), state.style());
900 910
901 PageRuleCollector collector(rootElementStyle, pageIndex); 911 PageRuleCollector collector(rootElementStyle, pageIndex);
902 912
903 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); 913 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ());
904 914
905 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) 915 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document())
906 scopedResolver->matchPageRules(collector); 916 scopedResolver->matchPageRules(collector);
907 917
908 state.setLineHeightValue(0); 918 state.setLineHeightValue(0);
909 bool inheritedOnly = false; 919 bool inheritedOnly = false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) 954 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document())
945 scopedResolver->collectViewportRulesTo(this); 955 scopedResolver->collectViewportRulesTo(this);
946 956
947 viewportStyleResolver()->resolve(); 957 viewportStyleResolver()->resolve();
948 } 958 }
949 959
950 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() 960 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
951 { 961 {
952 StyleResolverState state(document(), 0); 962 StyleResolverState state(document(), 0);
953 state.setStyle(RenderStyle::create()); 963 state.setStyle(RenderStyle::create());
954 state.fontBuilder().initForStyleResolve(document(), state.style(), state.use SVGZoomRules()); 964 state.fontBuilder().initForStyleResolve(document(), state.style());
955 state.style()->setLineHeight(RenderStyle::initialLineHeight()); 965 state.style()->setLineHeight(RenderStyle::initialLineHeight());
956 state.setLineHeightValue(0); 966 state.setLineHeightValue(0);
957 state.fontBuilder().setInitial(state.style()->effectiveZoom()); 967 state.fontBuilder().setInitial(state.style()->effectiveZoom());
958 state.style()->font().update(document().styleEngine()->fontSelector()); 968 state.style()->font().update(document().styleEngine()->fontSelector());
959 return state.takeStyle(); 969 return state.takeStyle();
960 } 970 }
961 971
962 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) 972 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
963 { 973 {
964 ASSERT(textNode); 974 ASSERT(textNode);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); 1463 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data());
1454 fprintf(stderr, "== Totals ==\n"); 1464 fprintf(stderr, "== Totals ==\n");
1455 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); 1465 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data());
1456 } 1466 }
1457 1467
1458 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style) 1468 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style)
1459 { 1469 {
1460 StyleResolverState state(document(), document().documentElement(), style); 1470 StyleResolverState state(document(), document().documentElement(), style);
1461 state.setStyle(style); 1471 state.setStyle(style);
1462 1472
1463 state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomR ules()); 1473 state.fontBuilder().initForStyleResolve(document(), style);
1464 1474
1465 for (size_t i = 0; i < count; ++i) { 1475 for (size_t i = 0; i < count; ++i) {
1466 if (properties[i].value) { 1476 if (properties[i].value) {
1467 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, 1477 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call,
1468 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). 1478 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122).
1469 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height. 1479 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height.
1470 switch (properties[i].property) { 1480 switch (properties[i].property) {
1471 case CSSPropertyFontSize: 1481 case CSSPropertyFontSize:
1472 case CSSPropertyLineHeight: 1482 case CSSPropertyLineHeight:
1473 updateFont(state); 1483 updateFont(state);
(...skipping 29 matching lines...) Expand all
1503 visitor->trace(m_features); 1513 visitor->trace(m_features);
1504 visitor->trace(m_siblingRuleSet); 1514 visitor->trace(m_siblingRuleSet);
1505 visitor->trace(m_uncommonAttributeRuleSet); 1515 visitor->trace(m_uncommonAttributeRuleSet);
1506 visitor->trace(m_watchedSelectorsRules); 1516 visitor->trace(m_watchedSelectorsRules);
1507 visitor->trace(m_treeBoundaryCrossingRules); 1517 visitor->trace(m_treeBoundaryCrossingRules);
1508 visitor->trace(m_pendingStyleSheets); 1518 visitor->trace(m_pendingStyleSheets);
1509 CSSFontSelectorClient::trace(visitor); 1519 CSSFontSelectorClient::trace(visitor);
1510 } 1520 }
1511 1521
1512 } // namespace WebCore 1522 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698