| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 StyleResourceLoader loader(m_document.fetcher()); | 188 StyleResourceLoader loader(m_document.fetcher()); |
| 189 loader.loadPendingResources(state.style(), state.elementStyleResources()); | 189 loader.loadPendingResources(state.style(), state.elementStyleResources()); |
| 190 m_document.styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 190 m_document.styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent) | 193 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent) |
| 194 { | 194 { |
| 195 ASSERT(m_document.frame()); | 195 ASSERT(m_document.frame()); |
| 196 ASSERT(m_document.settings()); | 196 ASSERT(m_document.settings()); |
| 197 | 197 |
| 198 if (element == m_document.documentElement()) | |
| 199 m_document.setDirectionSetOnDocumentElement(false); | |
| 200 StyleResolverState state(m_document, element, defaultParent); | 198 StyleResolverState state(m_document, element, defaultParent); |
| 201 | 199 |
| 202 if (state.parentStyle()) { | 200 if (state.parentStyle()) { |
| 203 SharedStyleFinder styleFinder(state.elementContext(), *this); | 201 SharedStyleFinder styleFinder(state.elementContext(), *this); |
| 204 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) | 202 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) |
| 205 return sharedStyle.release(); | 203 return sharedStyle.release(); |
| 206 } | 204 } |
| 207 | 205 |
| 208 if (state.parentStyle()) { | 206 if (state.parentStyle()) { |
| 209 state.setStyle(RenderStyle::create()); | 207 state.setStyle(RenderStyle::create()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 263 } |
| 266 | 264 |
| 267 PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
solverState& state, CSSPropertyID property, CSSValue& value) | 265 PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
solverState& state, CSSPropertyID property, CSSValue& value) |
| 268 { | 266 { |
| 269 StyleBuilder::applyProperty(property, state, &value); | 267 StyleBuilder::applyProperty(property, state, &value); |
| 270 return CSSAnimatableValueFactory::create(property, *state.style()); | 268 return CSSAnimatableValueFactory::create(property, *state.style()); |
| 271 } | 269 } |
| 272 | 270 |
| 273 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 271 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
| 274 { | 272 { |
| 275 StyleResolverState state(m_document, 0); | 273 StyleResolverState state(m_document, nullptr); |
| 276 state.setStyle(RenderStyle::create()); | 274 state.setStyle(RenderStyle::create()); |
| 277 state.fontBuilder().initForStyleResolve(m_document, state.style()); | 275 state.fontBuilder().initForStyleResolve(m_document, state.style()); |
| 278 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | 276 state.style()->setLineHeight(RenderStyle::initialLineHeight()); |
| 279 state.setLineHeightValue(0); | 277 state.setLineHeightValue(0); |
| 280 state.fontBuilder().setInitial(); | 278 state.fontBuilder().setInitial(); |
| 281 state.style()->font().update(m_document.styleEngine()->fontSelector()); | 279 state.style()->font().update(m_document.styleEngine()->fontSelector()); |
| 282 return state.takeStyle(); | 280 return state.takeStyle(); |
| 283 } | 281 } |
| 284 | 282 |
| 285 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 283 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 if (!m_styleResolverStats) | 569 if (!m_styleResolverStats) |
| 572 return; | 570 return; |
| 573 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty
leResolverStatsSequence, m_document.url().string().utf8().data()); | 571 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty
leResolverStatsSequence, m_document.url().string().utf8().data()); |
| 574 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 572 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
| 575 fprintf(stderr, "== Totals ==\n"); | 573 fprintf(stderr, "== Totals ==\n"); |
| 576 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 574 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
| 577 } | 575 } |
| 578 | 576 |
| 579 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) | 577 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) |
| 580 { | 578 { |
| 581 StyleResolverState state(m_document, m_document.documentElement(), style); | 579 StyleResolverState state(m_document, nullptr, style); |
| 582 state.setStyle(style); | 580 state.setStyle(style); |
| 583 | 581 |
| 584 state.fontBuilder().initForStyleResolve(m_document, style); | 582 state.fontBuilder().initForStyleResolve(m_document, style); |
| 585 | 583 |
| 586 for (size_t i = 0; i < count; ++i) { | 584 for (size_t i = 0; i < count; ++i) { |
| 587 if (properties[i].value) { | 585 if (properties[i].value) { |
| 588 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, | 586 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, |
| 589 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). | 587 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). |
| 590 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. | 588 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. |
| 591 switch (properties[i].property) { | 589 switch (properties[i].property) { |
| 592 case CSSPropertyFontSize: | 590 case CSSPropertyFontSize: |
| 593 case CSSPropertyLineHeight: | 591 case CSSPropertyLineHeight: |
| 594 updateFont(state); | 592 updateFont(state); |
| 595 break; | 593 break; |
| 596 default: | 594 default: |
| 597 break; | 595 break; |
| 598 } | 596 } |
| 599 StyleBuilder::applyProperty(properties[i].property, state, propertie
s[i].value); | 597 StyleBuilder::applyProperty(properties[i].property, state, propertie
s[i].value); |
| 600 } | 598 } |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 | 601 |
| 604 } // namespace blink | 602 } // namespace blink |
| OLD | NEW |