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

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

Issue 23498013: Have FontBuilder::initForStyleResolve() take a Document reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/resolver/FontBuilder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 555 }
556 } 556 }
557 } 557 }
558 } 558 }
559 559
560 // Seamless iframes want to inherit their font from their parent iframe, so early return before setting the font. 560 // Seamless iframes want to inherit their font from their parent iframe, so early return before setting the font.
561 if (seamlessWithParent) 561 if (seamlessWithParent)
562 return documentStyle.release(); 562 return documentStyle.release();
563 563
564 FontBuilder fontBuilder; 564 FontBuilder fontBuilder;
565 fontBuilder.initForStyleResolve(&document, documentStyle.get(), document.isS VGDocument()); 565 fontBuilder.initForStyleResolve(document, documentStyle.get(), document.isSV GDocument());
566 fontBuilder.createFontForDocument(fontSelector, documentStyle.get()); 566 fontBuilder.createFontForDocument(fontSelector, documentStyle.get());
567 567
568 return documentStyle.release(); 568 return documentStyle.release();
569 } 569 }
570 570
571 // FIXME: This is duplicated with StyleAdjuster.cpp 571 // FIXME: This is duplicated with StyleAdjuster.cpp
572 // Perhaps this should move onto ElementResolveContext or even Element? 572 // Perhaps this should move onto ElementResolveContext or even Element?
573 static inline bool isAtShadowBoundary(const Element* element) 573 static inline bool isAtShadowBoundary(const Element* element)
574 { 574 {
575 if (!element) 575 if (!element)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 628 }
629 // contenteditable attribute (implemented by -webkit-user-modify) should 629 // contenteditable attribute (implemented by -webkit-user-modify) should
630 // be propagated from shadow host to distributed node. 630 // be propagated from shadow host to distributed node.
631 if (state.distributedToInsertionPoint()) { 631 if (state.distributedToInsertionPoint()) {
632 if (Element* parent = element->parentElement()) { 632 if (Element* parent = element->parentElement()) {
633 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) 633 if (RenderStyle* styleOfShadowHost = parent->renderStyle())
634 state.style()->setUserModify(styleOfShadowHost->userModify()); 634 state.style()->setUserModify(styleOfShadowHost->userModify());
635 } 635 }
636 } 636 }
637 637
638 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st ate.useSVGZoomRules()); 638 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules());
639 639
640 if (element->isLink()) { 640 if (element->isLink()) {
641 state.style()->setIsLink(true); 641 state.style()->setIsLink(true);
642 EInsideLink linkState = state.elementLinkState(); 642 EInsideLink linkState = state.elementLinkState();
643 if (linkState != NotInsideLink) { 643 if (linkState != NotInsideLink) {
644 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); 644 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited);
645 if (forceVisited) 645 if (forceVisited)
646 linkState = InsideVisitedLink; 646 linkState = InsideVisitedLink;
647 } 647 }
648 state.style()->setInsideLink(linkState); 648 state.style()->setInsideLink(linkState);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 MatchResult result; 699 MatchResult result;
700 if (keyframe->properties()) 700 if (keyframe->properties())
701 result.addMatchedProperties(keyframe->properties()); 701 result.addMatchedProperties(keyframe->properties());
702 702
703 ASSERT(!state.style()); 703 ASSERT(!state.style());
704 704
705 // Create the style 705 // Create the style
706 state.setStyle(RenderStyle::clone(elementStyle)); 706 state.setStyle(RenderStyle::clone(elementStyle));
707 state.setLineHeightValue(0); 707 state.setLineHeightValue(0);
708 708
709 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st ate.useSVGZoomRules()); 709 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules());
710 710
711 // We don't need to bother with !important. Since there is only ever one 711 // We don't need to bother with !important. Since there is only ever one
712 // decl, there's nothing to override. So just add the first properties. 712 // decl, there's nothing to override. So just add the first properties.
713 bool inheritedOnly = false; 713 bool inheritedOnly = false;
714 if (keyframe->properties()) { 714 if (keyframe->properties()) {
715 // FIXME: Can't keyframes contain variables? 715 // FIXME: Can't keyframes contain variables?
716 applyMatchedProperties<AnimationProperties>(state, result, false, 0, res ult.matchedProperties.size() - 1, inheritedOnly); 716 applyMatchedProperties<AnimationProperties>(state, result, false, 0, res ult.matchedProperties.size() - 1, inheritedOnly);
717 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 717 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
718 } 718 }
719 719
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 StyleResolverState state(document(), e, parentStyle); 918 StyleResolverState state(document(), e, parentStyle);
919 919
920 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { 920 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
921 state.setStyle(RenderStyle::create()); 921 state.setStyle(RenderStyle::create());
922 state.style()->inheritFrom(state.parentStyle()); 922 state.style()->inheritFrom(state.parentStyle());
923 } else { 923 } else {
924 state.setStyle(defaultStyleForElement()); 924 state.setStyle(defaultStyleForElement());
925 state.setParentStyle(RenderStyle::clone(state.style())); 925 state.setParentStyle(RenderStyle::clone(state.style()));
926 } 926 }
927 927
928 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st ate.useSVGZoomRules()); 928 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules());
929 929
930 // Since we don't use pseudo-elements in any of our quirk/print 930 // Since we don't use pseudo-elements in any of our quirk/print
931 // user agent rules, don't waste time walking those rules. 931 // user agent rules, don't waste time walking those rules.
932 932
933 { 933 {
934 // Check UA, user and author rules. 934 // Check UA, user and author rules.
935 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 935 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style());
936 collector.setPseudoStyleRequest(pseudoStyleRequest); 936 collector.setPseudoStyleRequest(pseudoStyleRequest);
937 937
938 matchUARules(collector); 938 matchUARules(collector);
(...skipping 28 matching lines...) Expand all
967 } 967 }
968 968
969 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) 969 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
970 { 970 {
971 resetDirectionAndWritingModeOnDocument(document()); 971 resetDirectionAndWritingModeOnDocument(document());
972 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. 972 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style.
973 973
974 state.setStyle(RenderStyle::create()); 974 state.setStyle(RenderStyle::create());
975 state.style()->inheritFrom(state.rootElementStyle()); 975 state.style()->inheritFrom(state.rootElementStyle());
976 976
977 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st ate.useSVGZoomRules()); 977 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules());
978 978
979 PageRuleCollector collector(state.elementContext(), pageIndex); 979 PageRuleCollector collector(state.elementContext(), pageIndex);
980 980
981 collector.matchPageRules(CSSDefaultStyleSheets::defaultPrintStyle); 981 collector.matchPageRules(CSSDefaultStyleSheets::defaultPrintStyle);
982 collector.matchPageRules(m_ruleSets.userStyle()); 982 collector.matchPageRules(m_ruleSets.userStyle());
983 983
984 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) 984 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document())
985 scopedResolver->matchPageRules(collector); 985 scopedResolver->matchPageRules(collector);
986 986
987 state.setLineHeightValue(0); 987 state.setLineHeightValue(0);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1033
1034 const Vector<StyleRuleViewport*>& viewportRules = rules->viewportRules(); 1034 const Vector<StyleRuleViewport*>& viewportRules = rules->viewportRules();
1035 for (size_t i = 0; i < viewportRules.size(); ++i) 1035 for (size_t i = 0; i < viewportRules.size(); ++i)
1036 viewportStyleResolver()->addViewportRule(viewportRules[i]); 1036 viewportStyleResolver()->addViewportRule(viewportRules[i]);
1037 } 1037 }
1038 1038
1039 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() 1039 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
1040 { 1040 {
1041 StyleResolverState state(document(), 0); 1041 StyleResolverState state(document(), 0);
1042 state.setStyle(RenderStyle::create()); 1042 state.setStyle(RenderStyle::create());
1043 state.fontBuilder().initForStyleResolve(&document(), state.style(), state.us eSVGZoomRules()); 1043 state.fontBuilder().initForStyleResolve(document(), state.style(), state.use SVGZoomRules());
1044 state.style()->setLineHeight(RenderStyle::initialLineHeight()); 1044 state.style()->setLineHeight(RenderStyle::initialLineHeight());
1045 state.setLineHeightValue(0); 1045 state.setLineHeightValue(0);
1046 state.fontBuilder().setInitial(state.style()->effectiveZoom()); 1046 state.fontBuilder().setInitial(state.style()->effectiveZoom());
1047 state.style()->font().update(fontSelector()); 1047 state.style()->font().update(fontSelector());
1048 return state.takeStyle(); 1048 return state.takeStyle();
1049 } 1049 }
1050 1050
1051 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) 1051 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
1052 { 1052 {
1053 ASSERT(textNode); 1053 ASSERT(textNode);
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 1479
1480 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro pertySet) 1480 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro pertySet)
1481 : property(id), value(propertySet.getPropertyCSSValue(id).get()) 1481 : property(id), value(propertySet.getPropertyCSSValue(id).get())
1482 { } 1482 { }
1483 1483
1484 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style) 1484 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style)
1485 { 1485 {
1486 StyleResolverState state(document(), 0, style); 1486 StyleResolverState state(document(), 0, style);
1487 state.setStyle(style); 1487 state.setStyle(style);
1488 1488
1489 state.fontBuilder().initForStyleResolve(&document(), style, state.useSVGZoom Rules()); 1489 state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomR ules());
1490 1490
1491 for (size_t i = 0; i < count; ++i) { 1491 for (size_t i = 0; i < count; ++i) {
1492 if (properties[i].value) { 1492 if (properties[i].value) {
1493 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, 1493 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call,
1494 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). 1494 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122).
1495 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height. 1495 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height.
1496 switch (properties[i].property) { 1496 switch (properties[i].property) {
1497 case CSSPropertyFontSize: 1497 case CSSPropertyFontSize:
1498 case CSSPropertyLineHeight: 1498 case CSSPropertyLineHeight:
1499 updateFont(state); 1499 updateFont(state);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1550 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1551 1551
1552 fprintf(stderr, "Total:\n"); 1552 fprintf(stderr, "Total:\n");
1553 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1553 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
1554 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); 1554 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1555 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1555 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1556 } 1556 }
1557 #endif 1557 #endif
1558 1558
1559 } // namespace WebCore 1559 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FontBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698