| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 static StylePropertySet* rightToLeftDeclaration() | 101 static StylePropertySet* rightToLeftDeclaration() |
| 102 { | 102 { |
| 103 DEFINE_STATIC_LOCAL(RefPtr<MutableStylePropertySet>, rightToLeftDecl, (Mutab
leStylePropertySet::create())); | 103 DEFINE_STATIC_LOCAL(RefPtr<MutableStylePropertySet>, rightToLeftDecl, (Mutab
leStylePropertySet::create())); |
| 104 if (rightToLeftDecl->isEmpty()) | 104 if (rightToLeftDecl->isEmpty()) |
| 105 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 105 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
| 106 return rightToLeftDecl.get(); | 106 return rightToLeftDecl.get(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles) | 109 StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles) |
| 110 : m_document(document) | 110 : m_document(document) |
| 111 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) | 111 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) |
| 112 , m_fontSelector(CSSFontSelector::create(document)) | 112 , m_fontSelector(CSSFontSelector::create(&document)) |
| 113 , m_viewportStyleResolver(ViewportStyleResolver::create(document)) | 113 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
| 114 , m_styleResourceLoader(document->fetcher()) | 114 , m_styleResourceLoader(document.fetcher()) |
| 115 { | 115 { |
| 116 Element* root = document->documentElement(); | 116 Element* root = document.documentElement(); |
| 117 | 117 |
| 118 CSSDefaultStyleSheets::initDefaultStyle(root); | 118 CSSDefaultStyleSheets::initDefaultStyle(root); |
| 119 | 119 |
| 120 // construct document root element default style. this is needed | 120 // construct document root element default style. this is needed |
| 121 // to evaluate media queries that contain relative constraints, like "screen
and (max-width: 10em)" | 121 // to evaluate media queries that contain relative constraints, like "screen
and (max-width: 10em)" |
| 122 // This is here instead of constructor, because when constructor is run, | 122 // This is here instead of constructor, because when constructor is run, |
| 123 // document doesn't have documentElement | 123 // document doesn't have documentElement |
| 124 // NOTE: this assumes that element that gets passed to styleForElement -call | 124 // NOTE: this assumes that element that gets passed to styleForElement -call |
| 125 // is always from the document that owns the style selector | 125 // is always from the document that owns the style selector |
| 126 FrameView* view = document->view(); | 126 FrameView* view = document.view(); |
| 127 if (view) | 127 if (view) |
| 128 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType())); | 128 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType())); |
| 129 else | 129 else |
| 130 m_medium = adoptPtr(new MediaQueryEvaluator("all")); | 130 m_medium = adoptPtr(new MediaQueryEvaluator("all")); |
| 131 | 131 |
| 132 if (root) | 132 if (root) |
| 133 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc
hOnlyUserAgentRules); | 133 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc
hOnlyUserAgentRules); |
| 134 | 134 |
| 135 if (m_rootDefaultStyle && view) | 135 if (m_rootDefaultStyle && view) |
| 136 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->fra
me(), m_rootDefaultStyle.get())); | 136 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->fra
me(), m_rootDefaultStyle.get())); |
| 137 | 137 |
| 138 m_styleTree.clear(); | 138 m_styleTree.clear(); |
| 139 | 139 |
| 140 StyleSheetCollections* styleSheetCollection = document->styleSheetCollection
s(); | 140 StyleSheetCollections* styleSheetCollection = document.styleSheetCollections
(); |
| 141 m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this); | 141 m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this); |
| 142 | 142 |
| 143 #if ENABLE(SVG_FONTS) | 143 #if ENABLE(SVG_FONTS) |
| 144 if (document->svgExtensions()) { | 144 if (document.svgExtensions()) { |
| 145 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgE
xtensions()->svgFontFaceElements(); | 145 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx
tensions()->svgFontFaceElements(); |
| 146 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e
nd(); | 146 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e
nd(); |
| 147 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen
ts.begin(); it != end; ++it) | 147 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen
ts.begin(); it != end; ++it) |
| 148 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); | 148 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); |
| 149 } | 149 } |
| 150 #endif | 150 #endif |
| 151 | 151 |
| 152 styleSheetCollection->appendActiveAuthorStyleSheets(this); | 152 styleSheetCollection->appendActiveAuthorStyleSheets(this); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP
tr<CSSStyleSheet> >& styleSheets) | 155 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP
tr<CSSStyleSheet> >& styleSheets) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 168 ASSERT(resolver); | 168 ASSERT(resolver); |
| 169 resolver->addRulesFromSheet(sheet, *m_medium, this); | 169 resolver->addRulesFromSheet(sheet, *m_medium, this); |
| 170 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | 170 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void StyleResolver::finishAppendAuthorStyleSheets() | 174 void StyleResolver::finishAppendAuthorStyleSheets() |
| 175 { | 175 { |
| 176 collectFeatures(); | 176 collectFeatures(); |
| 177 | 177 |
| 178 if (document()->renderer() && document()->renderer()->style()) | 178 if (document().renderer() && document().renderer()->style()) |
| 179 document()->renderer()->style()->font().update(fontSelector()); | 179 document().renderer()->style()->font().update(fontSelector()); |
| 180 | 180 |
| 181 if (RuntimeEnabledFeatures::cssViewportEnabled()) | 181 if (RuntimeEnabledFeatures::cssViewportEnabled()) |
| 182 collectViewportRules(); | 182 collectViewportRules(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | 185 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) |
| 186 { | 186 { |
| 187 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.scopedStyleResolve
rFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 187 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.scopedStyleResolve
rFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
| 188 if (!resolver) | 188 if (!resolver) |
| 189 return; | 189 return; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return nullptr; | 228 return nullptr; |
| 229 OwnPtr<RuleSet> ruleSet = RuleSet::create(); | 229 OwnPtr<RuleSet> ruleSet = RuleSet::create(); |
| 230 for (size_t i = 0; i < size; ++i) | 230 for (size_t i = 0; i < size; ++i) |
| 231 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); | 231 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); |
| 232 return ruleSet.release(); | 232 return ruleSet.release(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void StyleResolver::collectFeatures() | 235 void StyleResolver::collectFeatures() |
| 236 { | 236 { |
| 237 m_features.clear(); | 237 m_features.clear(); |
| 238 m_ruleSets.collectFeaturesTo(m_features, document()->isViewSource()); | 238 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); |
| 239 m_styleTree.collectFeaturesTo(m_features); | 239 m_styleTree.collectFeaturesTo(m_features); |
| 240 | 240 |
| 241 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 241 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
| 242 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 242 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void StyleResolver::pushParentElement(Element* parent) | 245 void StyleResolver::pushParentElement(Element* parent) |
| 246 { | 246 { |
| 247 const ContainerNode* parentsParent = parent->parentOrShadowHostElement(); | 247 const ContainerNode* parentsParent = parent->parentOrShadowHostElement(); |
| 248 | 248 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 // First we match rules from the user agent sheet. | 416 // First we match rules from the user agent sheet. |
| 417 if (CSSDefaultStyleSheets::simpleDefaultStyleSheet) | 417 if (CSSDefaultStyleSheets::simpleDefaultStyleSheet) |
| 418 collector.matchedResult().isCacheable = false; | 418 collector.matchedResult().isCacheable = false; |
| 419 | 419 |
| 420 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") | 420 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") |
| 421 ? CSSDefaultStyleSheets::defaultPrintStyle : CSSDefaultStyleSheets::defa
ultStyle; | 421 ? CSSDefaultStyleSheets::defaultPrintStyle : CSSDefaultStyleSheets::defa
ultStyle; |
| 422 matchUARules(collector, userAgentStyleSheet); | 422 matchUARules(collector, userAgentStyleSheet); |
| 423 | 423 |
| 424 // In quirks mode, we match rules from the quirks user agent sheet. | 424 // In quirks mode, we match rules from the quirks user agent sheet. |
| 425 if (document()->inQuirksMode()) | 425 if (document().inQuirksMode()) |
| 426 matchUARules(collector, CSSDefaultStyleSheets::defaultQuirksStyle); | 426 matchUARules(collector, CSSDefaultStyleSheets::defaultQuirksStyle); |
| 427 | 427 |
| 428 // If document uses view source styles (in view source mode or in xml viewer
mode), then we match rules from the view source style sheet. | 428 // If document uses view source styles (in view source mode or in xml viewer
mode), then we match rules from the view source style sheet. |
| 429 if (document()->isViewSource()) | 429 if (document().isViewSource()) |
| 430 matchUARules(collector, CSSDefaultStyleSheets::viewSourceStyle()); | 430 matchUARules(collector, CSSDefaultStyleSheets::viewSourceStyle()); |
| 431 | 431 |
| 432 collector.setMatchingUARules(false); | 432 collector.setMatchingUARules(false); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void StyleResolver::matchUARules(ElementRuleCollector& collector, RuleSet* rules
) | 435 void StyleResolver::matchUARules(ElementRuleCollector& collector, RuleSet* rules
) |
| 436 { | 436 { |
| 437 collector.clearMatchedRules(); | 437 collector.clearMatchedRules(); |
| 438 collector.matchedResult().ranges.lastUARule = collector.matchedResult().matc
hedProperties.size() - 1; | 438 collector.matchedResult().ranges.lastUARule = collector.matchedResult().matc
hedProperties.size() - 1; |
| 439 | 439 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 bool StyleResolver::styleSharingCandidateMatchesRuleSet(const ElementResolveCont
ext& context, RenderStyle* style, RuleSet* ruleSet) | 494 bool StyleResolver::styleSharingCandidateMatchesRuleSet(const ElementResolveCont
ext& context, RenderStyle* style, RuleSet* ruleSet) |
| 495 { | 495 { |
| 496 if (!ruleSet) | 496 if (!ruleSet) |
| 497 return false; | 497 return false; |
| 498 | 498 |
| 499 ElementRuleCollector collector(context, m_selectorFilter, style); | 499 ElementRuleCollector collector(context, m_selectorFilter, style); |
| 500 return collector.hasAnyMatchingRules(ruleSet); | 500 return collector.hasAnyMatchingRules(ruleSet); |
| 501 } | 501 } |
| 502 | 502 |
| 503 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(const Document* document
, CSSFontSelector* fontSelector) | 503 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(const Document& document
, CSSFontSelector* fontSelector) |
| 504 { | 504 { |
| 505 const Frame* frame = document->frame(); | 505 const Frame* frame = document.frame(); |
| 506 | 506 |
| 507 // HTML5 states that seamless iframes should replace default CSS values | 507 // HTML5 states that seamless iframes should replace default CSS values |
| 508 // with values inherited from the containing iframe element. However, | 508 // with values inherited from the containing iframe element. However, |
| 509 // some values (such as the case of designMode = "on") still need to | 509 // some values (such as the case of designMode = "on") still need to |
| 510 // be set by this "document style". | 510 // be set by this "document style". |
| 511 RefPtr<RenderStyle> documentStyle = RenderStyle::create(); | 511 RefPtr<RenderStyle> documentStyle = RenderStyle::create(); |
| 512 bool seamlessWithParent = document->shouldDisplaySeamlesslyWithParent(); | 512 bool seamlessWithParent = document.shouldDisplaySeamlesslyWithParent(); |
| 513 if (seamlessWithParent) { | 513 if (seamlessWithParent) { |
| 514 RenderStyle* iframeStyle = document->seamlessParentIFrame()->renderStyle
(); | 514 RenderStyle* iframeStyle = document.seamlessParentIFrame()->renderStyle(
); |
| 515 if (iframeStyle) | 515 if (iframeStyle) |
| 516 documentStyle->inheritFrom(iframeStyle); | 516 documentStyle->inheritFrom(iframeStyle); |
| 517 } | 517 } |
| 518 | 518 |
| 519 // FIXME: It's not clear which values below we want to override in the seaml
ess case! | 519 // FIXME: It's not clear which values below we want to override in the seaml
ess case! |
| 520 documentStyle->setDisplay(BLOCK); | 520 documentStyle->setDisplay(BLOCK); |
| 521 if (!seamlessWithParent) { | 521 if (!seamlessWithParent) { |
| 522 documentStyle->setRTLOrdering(document->visuallyOrdered() ? VisualOrder
: LogicalOrder); | 522 documentStyle->setRTLOrdering(document.visuallyOrdered() ? VisualOrder :
LogicalOrder); |
| 523 documentStyle->setZoom(frame && !document->printing() ? frame->pageZoomF
actor() : 1); | 523 documentStyle->setZoom(frame && !document.printing() ? frame->pageZoomFa
ctor() : 1); |
| 524 documentStyle->setLocale(document->contentLanguage()); | 524 documentStyle->setLocale(document.contentLanguage()); |
| 525 } | 525 } |
| 526 // This overrides any -webkit-user-modify inherited from the parent iframe. | 526 // This overrides any -webkit-user-modify inherited from the parent iframe. |
| 527 documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ON
LY); | 527 documentStyle->setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONL
Y); |
| 528 | 528 |
| 529 Element* docElement = document->documentElement(); | 529 Element* docElement = document.documentElement(); |
| 530 RenderObject* docElementRenderer = docElement ? docElement->renderer() : 0; | 530 RenderObject* docElementRenderer = docElement ? docElement->renderer() : 0; |
| 531 if (docElementRenderer) { | 531 if (docElementRenderer) { |
| 532 // Use the direction and writing-mode of the body to set the | 532 // Use the direction and writing-mode of the body to set the |
| 533 // viewport's direction and writing-mode unless the property is set on t
he document element. | 533 // viewport's direction and writing-mode unless the property is set on t
he document element. |
| 534 // If there is no body, then use the document element. | 534 // If there is no body, then use the document element. |
| 535 RenderObject* bodyRenderer = document->body() ? document->body()->render
er() : 0; | 535 RenderObject* bodyRenderer = document.body() ? document.body()->renderer
() : 0; |
| 536 if (bodyRenderer && !document->writingModeSetOnDocumentElement()) | 536 if (bodyRenderer && !document.writingModeSetOnDocumentElement()) |
| 537 documentStyle->setWritingMode(bodyRenderer->style()->writingMode()); | 537 documentStyle->setWritingMode(bodyRenderer->style()->writingMode()); |
| 538 else | 538 else |
| 539 documentStyle->setWritingMode(docElementRenderer->style()->writingMo
de()); | 539 documentStyle->setWritingMode(docElementRenderer->style()->writingMo
de()); |
| 540 if (bodyRenderer && !document->directionSetOnDocumentElement()) | 540 if (bodyRenderer && !document.directionSetOnDocumentElement()) |
| 541 documentStyle->setDirection(bodyRenderer->style()->direction()); | 541 documentStyle->setDirection(bodyRenderer->style()->direction()); |
| 542 else | 542 else |
| 543 documentStyle->setDirection(docElementRenderer->style()->direction()
); | 543 documentStyle->setDirection(docElementRenderer->style()->direction()
); |
| 544 } | 544 } |
| 545 | 545 |
| 546 if (frame) { | 546 if (frame) { |
| 547 if (FrameView* frameView = frame->view()) { | 547 if (FrameView* frameView = frame->view()) { |
| 548 const Pagination& pagination = frameView->pagination(); | 548 const Pagination& pagination = frameView->pagination(); |
| 549 if (pagination.mode != Pagination::Unpaginated) { | 549 if (pagination.mode != Pagination::Unpaginated) { |
| 550 Pagination::setStylesForPaginationMode(pagination.mode, document
Style.get()); | 550 Pagination::setStylesForPaginationMode(pagination.mode, document
Style.get()); |
| 551 documentStyle->setColumnGap(pagination.gap); | 551 documentStyle->setColumnGap(pagination.gap); |
| 552 if (RenderView* view = document->renderView()) { | 552 if (RenderView* view = document.renderView()) { |
| 553 if (view->hasColumns()) | 553 if (view->hasColumns()) |
| 554 view->updateColumnInfoFromStyle(documentStyle.get()); | 554 view->updateColumnInfoFromStyle(documentStyle.get()); |
| 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.isS
VGDocument()); |
| 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) |
| 576 return false; | 576 return false; |
| 577 ContainerNode* parentNode = element->parentNode(); | 577 ContainerNode* parentNode = element->parentNode(); |
| 578 return parentNode && parentNode->isShadowRoot(); | 578 return parentNode && parentNode->isShadowRoot(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 static inline void resetDirectionAndWritingModeOnDocument(Document* document) | 581 static inline void resetDirectionAndWritingModeOnDocument(Document& document) |
| 582 { | 582 { |
| 583 document->setDirectionSetOnDocumentElement(false); | 583 document.setDirectionSetOnDocumentElement(false); |
| 584 document->setWritingModeSetOnDocumentElement(false); | 584 document.setWritingModeSetOnDocumentElement(false); |
| 585 } | 585 } |
| 586 | 586 |
| 587 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt
trValues, RuleFeatureSet& features) | 587 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt
trValues, RuleFeatureSet& features) |
| 588 { | 588 { |
| 589 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 589 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
| 590 features.attrsInRules.add(contentAttrValues[i].impl()); | 590 features.attrsInRules.add(contentAttrValues[i].impl()); |
| 591 } | 591 } |
| 592 | 592 |
| 593 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 593 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| 594 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) | 594 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) |
| 595 { | 595 { |
| 596 ASSERT(document()->frame()); | 596 ASSERT(document().frame()); |
| 597 ASSERT(documentSettings()); | 597 ASSERT(documentSettings()); |
| 598 | 598 |
| 599 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 599 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
| 600 // will vanish if a style recalc happens during loading. | 600 // will vanish if a style recalc happens during loading. |
| 601 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { | 601 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { |
| 602 if (!s_styleNotYetAvailable) { | 602 if (!s_styleNotYetAvailable) { |
| 603 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 603 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
| 604 s_styleNotYetAvailable->setDisplay(NONE); | 604 s_styleNotYetAvailable->setDisplay(NONE); |
| 605 s_styleNotYetAvailable->font().update(m_fontSelector); | 605 s_styleNotYetAvailable->font().update(m_fontSelector); |
| 606 } | 606 } |
| 607 element->document().setHasNodesWithPlaceholderStyle(); | 607 element->document().setHasNodesWithPlaceholderStyle(); |
| 608 return s_styleNotYetAvailable; | 608 return s_styleNotYetAvailable; |
| 609 } | 609 } |
| 610 | 610 |
| 611 if (element == document()->documentElement()) | 611 if (element == document().documentElement()) |
| 612 resetDirectionAndWritingModeOnDocument(document()); | 612 resetDirectionAndWritingModeOnDocument(document()); |
| 613 StyleResolverState state(document(), element, defaultParent, regionForStylin
g); | 613 StyleResolverState state(document(), element, defaultParent, regionForStylin
g); |
| 614 | 614 |
| 615 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoi
nt() && state.parentStyle()) { | 615 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoi
nt() && state.parentStyle()) { |
| 616 SharedStyleFinder styleFinder(m_features, m_siblingRuleSet.get(), m_unco
mmonAttributeRuleSet.get(), this); | 616 SharedStyleFinder styleFinder(m_features, m_siblingRuleSet.get(), m_unco
mmonAttributeRuleSet.get(), this); |
| 617 RefPtr<RenderStyle> sharedStyle = styleFinder.locateSharedStyle(state.el
ementContext(), state.style()); | 617 RefPtr<RenderStyle> sharedStyle = styleFinder.locateSharedStyle(state.el
ementContext(), state.style()); |
| 618 if (sharedStyle) | 618 if (sharedStyle) |
| 619 return sharedStyle.release(); | 619 return sharedStyle.release(); |
| 620 } | 620 } |
| 621 | 621 |
| 622 if (state.parentStyle()) { | 622 if (state.parentStyle()) { |
| 623 state.setStyle(RenderStyle::create()); | 623 state.setStyle(RenderStyle::create()); |
| 624 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); | 624 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
| 625 } else { | 625 } else { |
| 626 state.setStyle(defaultStyleForElement()); | 626 state.setStyle(defaultStyleForElement()); |
| 627 state.setParentStyle(RenderStyle::clone(state.style())); | 627 state.setParentStyle(RenderStyle::clone(state.style())); |
| 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(), sta
te.useSVGZoomRules()); | 638 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st
ate.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 13 matching lines...) Expand all Loading... |
| 662 if (matchingBehavior == MatchOnlyUserAgentRules) | 662 if (matchingBehavior == MatchOnlyUserAgentRules) |
| 663 matchUARules(collector); | 663 matchUARules(collector); |
| 664 else | 664 else |
| 665 matchAllRules(state, collector, m_matchAuthorAndUserStyles, matching
Behavior != MatchAllRulesExcludingSMIL); | 665 matchAllRules(state, collector, m_matchAuthorAndUserStyles, matching
Behavior != MatchAllRulesExcludingSMIL); |
| 666 | 666 |
| 667 applyMatchedProperties(state, collector.matchedResult()); | 667 applyMatchedProperties(state, collector.matchedResult()); |
| 668 | 668 |
| 669 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 669 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 670 } | 670 } |
| 671 { | 671 { |
| 672 StyleAdjuster adjuster(state.cachedUAStyle(), m_document->inQuirksMode()
); | 672 StyleAdjuster adjuster(state.cachedUAStyle(), m_document.inQuirksMode())
; |
| 673 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element); | 673 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element); |
| 674 } | 674 } |
| 675 document()->didAccessStyleResolver(); | 675 document().didAccessStyleResolver(); |
| 676 | 676 |
| 677 // FIXME: Shouldn't this be on RenderBody::styleDidChange? | 677 // FIXME: Shouldn't this be on RenderBody::styleDidChange? |
| 678 if (element->hasTagName(bodyTag)) | 678 if (element->hasTagName(bodyTag)) |
| 679 document()->textLinkColors().setTextColor(state.style()->visitedDependen
tColor(CSSPropertyColor)); | 679 document().textLinkColors().setTextColor(state.style()->visitedDependent
Color(CSSPropertyColor)); |
| 680 | 680 |
| 681 // If any changes to CSS Animations were detected, stash the update away for
application after the | 681 // If any changes to CSS Animations were detected, stash the update away for
application after the |
| 682 // render object is updated if we're in the appropriate scope. | 682 // render object is updated if we're in the appropriate scope. |
| 683 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() && state.animationUpda
te()) | 683 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() && state.animationUpda
te()) |
| 684 element->ensureActiveAnimations()->cssAnimations()->setPendingUpdate(sta
te.takeAnimationUpdate()); | 684 element->ensureActiveAnimations()->cssAnimations()->setPendingUpdate(sta
te.takeAnimationUpdate()); |
| 685 | 685 |
| 686 // Now return the style. | 686 // Now return the style. |
| 687 return state.takeStyle(); | 687 return state.takeStyle(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
Style* elementStyle, const StyleKeyframe* keyframe) | 690 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
Style* elementStyle, const StyleKeyframe* keyframe) |
| 691 { | 691 { |
| 692 ASSERT(document()->frame()); | 692 ASSERT(document().frame()); |
| 693 ASSERT(documentSettings()); | 693 ASSERT(documentSettings()); |
| 694 | 694 |
| 695 if (e == document()->documentElement()) | 695 if (e == document().documentElement()) |
| 696 resetDirectionAndWritingModeOnDocument(document()); | 696 resetDirectionAndWritingModeOnDocument(document()); |
| 697 StyleResolverState state(document(), e); | 697 StyleResolverState state(document(), e); |
| 698 | 698 |
| 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(), sta
te.useSVGZoomRules()); | 709 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st
ate.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 |
| 720 // If our font got dirtied, go ahead and update it now. | 720 // If our font got dirtied, go ahead and update it now. |
| 721 updateFont(state); | 721 updateFont(state); |
| 722 | 722 |
| 723 // Line-height is set when we are sure we decided on the font-size | 723 // Line-height is set when we are sure we decided on the font-size |
| 724 if (state.lineHeightValue()) | 724 if (state.lineHeightValue()) |
| 725 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | 725 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); |
| 726 | 726 |
| 727 // Now do rest of the properties. | 727 // Now do rest of the properties. |
| 728 if (keyframe->properties()) | 728 if (keyframe->properties()) |
| 729 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, r
esult.matchedProperties.size() - 1, inheritedOnly); | 729 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, r
esult.matchedProperties.size() - 1, inheritedOnly); |
| 730 | 730 |
| 731 // If our font got dirtied by one of the non-essential font props, | 731 // If our font got dirtied by one of the non-essential font props, |
| 732 // go ahead and update it a second time. | 732 // go ahead and update it a second time. |
| 733 updateFont(state); | 733 updateFont(state); |
| 734 | 734 |
| 735 // Start loading resources referenced by this style. | 735 // Start loading resources referenced by this style. |
| 736 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 736 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 737 | 737 |
| 738 document()->didAccessStyleResolver(); | 738 document().didAccessStyleResolver(); |
| 739 | 739 |
| 740 return state.takeStyle(); | 740 return state.takeStyle(); |
| 741 } | 741 } |
| 742 | 742 |
| 743 const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(const Element*
e, const StringImpl* animationName) | 743 const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(const Element*
e, const StringImpl* animationName) |
| 744 { | 744 { |
| 745 if (m_styleTree.hasOnlyScopedResolverForDocument()) | 745 if (m_styleTree.hasOnlyScopedResolverForDocument()) |
| 746 return m_styleTree.scopedStyleResolverForDocument()->keyframeStylesForAn
imation(animationName); | 746 return m_styleTree.scopedStyleResolverForDocument()->keyframeStylesForAn
imation(animationName); |
| 747 | 747 |
| 748 Vector<ScopedStyleResolver*, 8> stack; | 748 Vector<ScopedStyleResolver*, 8> stack; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 RefPtr<AnimatableValue> snapshotValue = CSSAnimatableValueFactory::creat
e(property, style); | 900 RefPtr<AnimatableValue> snapshotValue = CSSAnimatableValueFactory::creat
e(property, style); |
| 901 if (startNeedsValue) | 901 if (startNeedsValue) |
| 902 startKeyframe->setPropertyValue(property, snapshotValue.get()); | 902 startKeyframe->setPropertyValue(property, snapshotValue.get()); |
| 903 if (endNeedsValue) | 903 if (endNeedsValue) |
| 904 endKeyframe->setPropertyValue(property, snapshotValue.get()); | 904 endKeyframe->setPropertyValue(property, snapshotValue.get()); |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 | 907 |
| 908 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const P
seudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) | 908 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const P
seudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) |
| 909 { | 909 { |
| 910 ASSERT(document()->frame()); | 910 ASSERT(document().frame()); |
| 911 ASSERT(documentSettings()); | 911 ASSERT(documentSettings()); |
| 912 ASSERT(parentStyle); | 912 ASSERT(parentStyle); |
| 913 if (!e) | 913 if (!e) |
| 914 return 0; | 914 return 0; |
| 915 | 915 |
| 916 if (e == document()->documentElement()) | 916 if (e == document().documentElement()) |
| 917 resetDirectionAndWritingModeOnDocument(document()); | 917 resetDirectionAndWritingModeOnDocument(document()); |
| 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(), sta
te.useSVGZoomRules()); | 928 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st
ate.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); |
| 939 if (m_matchAuthorAndUserStyles) { | 939 if (m_matchAuthorAndUserStyles) { |
| 940 matchUserRules(collector, false); | 940 matchUserRules(collector, false); |
| 941 matchAuthorRules(state.element(), collector, false); | 941 matchAuthorRules(state.element(), collector, false); |
| 942 } | 942 } |
| 943 | 943 |
| 944 if (collector.matchedResult().matchedProperties.isEmpty()) | 944 if (collector.matchedResult().matchedProperties.isEmpty()) |
| 945 return 0; | 945 return 0; |
| 946 | 946 |
| 947 state.style()->setStyleType(pseudoStyleRequest.pseudoId); | 947 state.style()->setStyleType(pseudoStyleRequest.pseudoId); |
| 948 | 948 |
| 949 applyMatchedProperties(state, collector.matchedResult()); | 949 applyMatchedProperties(state, collector.matchedResult()); |
| 950 | 950 |
| 951 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 951 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 952 } | 952 } |
| 953 { | 953 { |
| 954 StyleAdjuster adjuster(state.cachedUAStyle(), m_document->inQuirksMode()
); | 954 StyleAdjuster adjuster(state.cachedUAStyle(), m_document.inQuirksMode())
; |
| 955 // FIXME: Passing 0 as the Element* introduces a lot of complexity | 955 // FIXME: Passing 0 as the Element* introduces a lot of complexity |
| 956 // in the adjustRenderStyle code. | 956 // in the adjustRenderStyle code. |
| 957 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), 0); | 957 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), 0); |
| 958 } | 958 } |
| 959 | 959 |
| 960 // Start loading resources referenced by this style. | 960 // Start loading resources referenced by this style. |
| 961 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 961 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 962 | 962 |
| 963 document()->didAccessStyleResolver(); | 963 document().didAccessStyleResolver(); |
| 964 | 964 |
| 965 // Now return the style. | 965 // Now return the style. |
| 966 return state.takeStyle(); | 966 return state.takeStyle(); |
| 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_ro
otElementStyle 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(), sta
te.useSVGZoomRules()); | 977 state.fontBuilder().initForStyleResolve(&state.document(), state.style(), st
ate.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 10 matching lines...) Expand all Loading... |
| 998 if (state.lineHeightValue()) | 998 if (state.lineHeightValue()) |
| 999 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | 999 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); |
| 1000 | 1000 |
| 1001 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); | 1001 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); |
| 1002 | 1002 |
| 1003 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 1003 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 1004 | 1004 |
| 1005 // Start loading resources referenced by this style. | 1005 // Start loading resources referenced by this style. |
| 1006 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 1006 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 1007 | 1007 |
| 1008 document()->didAccessStyleResolver(); | 1008 document().didAccessStyleResolver(); |
| 1009 | 1009 |
| 1010 // Now return the style. | 1010 // Now return the style. |
| 1011 return state.takeStyle(); | 1011 return state.takeStyle(); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 void StyleResolver::collectViewportRules() | 1014 void StyleResolver::collectViewportRules() |
| 1015 { | 1015 { |
| 1016 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled()); | 1016 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled()); |
| 1017 | 1017 |
| 1018 collectViewportRules(CSSDefaultStyleSheets::defaultStyle); | 1018 collectViewportRules(CSSDefaultStyleSheets::defaultStyle); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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.use
SVGZoomRules()); | 1043 state.fontBuilder().initForStyleResolve(&document(), state.style(), state.us
eSVGZoomRules()); |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned
rulesToInclude) | 1088 PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned
rulesToInclude) |
| 1089 { | 1089 { |
| 1090 return pseudoStyleRulesForElement(e, NOPSEUDO, rulesToInclude); | 1090 return pseudoStyleRulesForElement(e, NOPSEUDO, rulesToInclude); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps
eudoId pseudoId, unsigned rulesToInclude) | 1093 PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps
eudoId pseudoId, unsigned rulesToInclude) |
| 1094 { | 1094 { |
| 1095 if (!e || !e->document().haveStylesheetsLoaded()) | 1095 if (!e || !e->document().haveStylesheetsLoaded()) |
| 1096 return 0; | 1096 return 0; |
| 1097 | 1097 |
| 1098 if (e == document()->documentElement()) | 1098 if (e == document().documentElement()) |
| 1099 resetDirectionAndWritingModeOnDocument(document()); | 1099 resetDirectionAndWritingModeOnDocument(document()); |
| 1100 StyleResolverState state(document(), e); | 1100 StyleResolverState state(document(), e); |
| 1101 | 1101 |
| 1102 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1102 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 1103 collector.setMode(SelectorChecker::CollectingRules); | 1103 collector.setMode(SelectorChecker::CollectingRules); |
| 1104 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); | 1104 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); |
| 1105 | 1105 |
| 1106 if (rulesToInclude & UAAndUserCSSRules) { | 1106 if (rulesToInclude & UAAndUserCSSRules) { |
| 1107 // First we match rules from the user agent sheet. | 1107 // First we match rules from the user agent sheet. |
| 1108 matchUARules(collector); | 1108 matchUARules(collector); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.useSVGZoomR
ules()); | 1489 state.fontBuilder().initForStyleResolve(&document(), style, state.useSVGZoom
Rules()); |
| 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 Loading... |
| 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 |
| OLD | NEW |