| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // Start loading resources referenced by this style. | 532 // Start loading resources referenced by this style. |
| 533 void StyleResolver::loadPendingResources(StyleResolverState& state) | 533 void StyleResolver::loadPendingResources(StyleResolverState& state) |
| 534 { | 534 { |
| 535 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 535 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 536 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 536 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 539 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| 540 RuleMatchingBehavior matchingBehavior) | 540 RuleMatchingBehavior matchingBehavior) |
| 541 { | 541 { |
| 542 ASSERT(element); |
| 542 ASSERT(document().frame()); | 543 ASSERT(document().frame()); |
| 543 ASSERT(document().settings()); | 544 ASSERT(document().settings()); |
| 544 ASSERT(!hasPendingAuthorStyleSheets()); | 545 ASSERT(!hasPendingAuthorStyleSheets()); |
| 545 ASSERT(!m_needCollectFeatures); | 546 ASSERT(!m_needCollectFeatures); |
| 546 | 547 |
| 547 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 548 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
| 548 // will vanish if a style recalc happens during loading. | 549 // will vanish if a style recalc happens during loading. |
| 549 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { | 550 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { |
| 550 if (!s_styleNotYetAvailable) { | 551 if (!s_styleNotYetAvailable) { |
| 551 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 552 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest
.pseudoId)) | 855 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest
.pseudoId)) |
| 855 setAnimationUpdateIfNeeded(state, *pseudoElement); | 856 setAnimationUpdateIfNeeded(state, *pseudoElement); |
| 856 | 857 |
| 857 // Now return the style. | 858 // Now return the style. |
| 858 return state.takeStyle(); | 859 return state.takeStyle(); |
| 859 } | 860 } |
| 860 | 861 |
| 861 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) | 862 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) |
| 862 { | 863 { |
| 863 ASSERT(!hasPendingAuthorStyleSheets()); | 864 ASSERT(!hasPendingAuthorStyleSheets()); |
| 865 ASSERT(document().documentElement()); |
| 864 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. | 866 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. |
| 865 | 867 |
| 866 RefPtr<RenderStyle> style = RenderStyle::create(); | 868 RefPtr<RenderStyle> style = RenderStyle::create(); |
| 867 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().renderStyle(); | 869 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().renderStyle(); |
| 868 ASSERT(rootElementStyle); | 870 ASSERT(rootElementStyle); |
| 869 style->inheritFrom(rootElementStyle); | 871 style->inheritFrom(rootElementStyle); |
| 870 state.setStyle(style.release()); | 872 state.setStyle(style.release()); |
| 871 | 873 |
| 872 PageRuleCollector collector(rootElementStyle, pageIndex); | 874 PageRuleCollector collector(rootElementStyle, pageIndex); |
| 873 | 875 |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 if (!m_styleResolverStats) | 1551 if (!m_styleResolverStats) |
| 1550 return; | 1552 return; |
| 1551 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty
leResolverStatsSequence, document().url().string().utf8().data()); | 1553 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty
leResolverStatsSequence, document().url().string().utf8().data()); |
| 1552 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 1554 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
| 1553 fprintf(stderr, "== Totals ==\n"); | 1555 fprintf(stderr, "== Totals ==\n"); |
| 1554 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 1556 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
| 1555 } | 1557 } |
| 1556 | 1558 |
| 1557 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) | 1559 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) |
| 1558 { | 1560 { |
| 1561 ASSERT(document().documentElement()); |
| 1559 StyleResolverState state(document(), document().documentElement(), style); | 1562 StyleResolverState state(document(), document().documentElement(), style); |
| 1560 state.setStyle(style); | 1563 state.setStyle(style); |
| 1561 | 1564 |
| 1562 for (size_t i = 0; i < count; ++i) { | 1565 for (size_t i = 0; i < count; ++i) { |
| 1563 if (properties[i].value) { | 1566 if (properties[i].value) { |
| 1564 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, | 1567 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, |
| 1565 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). | 1568 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). |
| 1566 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. | 1569 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. |
| 1567 switch (properties[i].property) { | 1570 switch (properties[i].property) { |
| 1568 case CSSPropertyFontSize: | 1571 case CSSPropertyFontSize: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 visitor->trace(m_uncommonAttributeRuleSet); | 1607 visitor->trace(m_uncommonAttributeRuleSet); |
| 1605 visitor->trace(m_watchedSelectorsRules); | 1608 visitor->trace(m_watchedSelectorsRules); |
| 1606 visitor->trace(m_treeBoundaryCrossingRules); | 1609 visitor->trace(m_treeBoundaryCrossingRules); |
| 1607 visitor->trace(m_styleSharingLists); | 1610 visitor->trace(m_styleSharingLists); |
| 1608 visitor->trace(m_pendingStyleSheets); | 1611 visitor->trace(m_pendingStyleSheets); |
| 1609 visitor->trace(m_document); | 1612 visitor->trace(m_document); |
| 1610 #endif | 1613 #endif |
| 1611 } | 1614 } |
| 1612 | 1615 |
| 1613 } // namespace blink | 1616 } // namespace blink |
| OLD | NEW |