Commit c2cefd3a authored by akling@apple.com's avatar akling@apple.com

Don't create StyleResolvers just to invalidate them.

<http://webkit.org/b/115436>

Reviewed by Geoffrey Garen.

Source/WebCore:

Renamed Document::styleResolver() to ensureStyleResolver() so it's clear that it never returns null.
Removed a bunch of unnecessary null-checks I spotted while doing this.

Also fixed Element::willModifyAttribute() and FrameView::setFrameRect() to not create a StyleResolver
and immediately invalidate it in some cases.

* css/FontLoader.cpp:
(WebCore::FontLoader::loadFont):
(WebCore::FontLoader::checkFont):
(WebCore::FontLoader::resolveFontStyle):
* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::prepareEvaluator):
* css/StyleMedia.cpp:
(WebCore::StyleMedia::matchMedium):
* dom/Document.cpp:
(WebCore::Document::styleForElementIgnoringPendingStylesheets):
(WebCore::Document::styleForPage):
* dom/Document.h:
(WebCore::Document::ensureStyleResolver):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::combineCSSFeatureFlags):
(WebCore::DocumentStyleSheetCollection::resetCSSFeatureFlags):
(WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
* dom/Element.cpp:
(WebCore::StyleResolverParentPusher::push):
(WebCore::StyleResolverParentPusher::~StyleResolverParentPusher):
(WebCore::Element::styleForRenderer):
(WebCore::Element::recalcStyle):
(WebCore::Element::willModifyAttribute):
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::createRendererForTextIfNeeded):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::recalcStyle):
(WebCore::ShadowRoot::attach):
* dom/Text.cpp:
(WebCore::Text::recalcTextStyle):
* editing/EditingStyle.cpp:
(WebCore::styleFromMatchedRulesForElement):
* html/HTMLCanvasElement.cpp:
* html/HTMLCanvasElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::customStyleForRenderer):
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::updateNonRenderStyle):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::updateNonRenderStyle):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::customStyleForRenderer):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditElement::customStyleForRenderer):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getMatchedStylesForNode):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::getMatchedCSSRules):
* page/FrameView.cpp:
(WebCore::FrameView::setFrameRect):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::updateFromElement):
(WebCore::RenderListBox::paintItemForeground):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::fontSelector):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::getUncachedPseudoStyle):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::checkRegionStyle):
(WebCore::RenderRegion::computeStyleInRegion):
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::fontSelector):
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):
* svg/SVGElement.cpp:
(WebCore::SVGElement::customStyleForRenderer):
* svg/SVGElementRareData.h:
(WebCore::SVGElementRareData::overrideComputedStyle):

Source/WebKit/qt:

* Api/qwebelement.cpp:
(QWebElement::styleProperty):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0b0cde32
2013-04-30 Andreas Kling <akling@apple.com>
Don't create StyleResolvers just to invalidate them.
<http://webkit.org/b/115436>
Reviewed by Geoffrey Garen.
Renamed Document::styleResolver() to ensureStyleResolver() so it's clear that it never returns null.
Removed a bunch of unnecessary null-checks I spotted while doing this.
Also fixed Element::willModifyAttribute() and FrameView::setFrameRect() to not create a StyleResolver
and immediately invalidate it in some cases.
* css/FontLoader.cpp:
(WebCore::FontLoader::loadFont):
(WebCore::FontLoader::checkFont):
(WebCore::FontLoader::resolveFontStyle):
* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::prepareEvaluator):
* css/StyleMedia.cpp:
(WebCore::StyleMedia::matchMedium):
* dom/Document.cpp:
(WebCore::Document::styleForElementIgnoringPendingStylesheets):
(WebCore::Document::styleForPage):
* dom/Document.h:
(WebCore::Document::ensureStyleResolver):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::combineCSSFeatureFlags):
(WebCore::DocumentStyleSheetCollection::resetCSSFeatureFlags):
(WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
* dom/Element.cpp:
(WebCore::StyleResolverParentPusher::push):
(WebCore::StyleResolverParentPusher::~StyleResolverParentPusher):
(WebCore::Element::styleForRenderer):
(WebCore::Element::recalcStyle):
(WebCore::Element::willModifyAttribute):
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::createRendererForTextIfNeeded):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::recalcStyle):
(WebCore::ShadowRoot::attach):
* dom/Text.cpp:
(WebCore::Text::recalcTextStyle):
* editing/EditingStyle.cpp:
(WebCore::styleFromMatchedRulesForElement):
* html/HTMLCanvasElement.cpp:
* html/HTMLCanvasElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::customStyleForRenderer):
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::updateNonRenderStyle):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::updateNonRenderStyle):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::customStyleForRenderer):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditElement::customStyleForRenderer):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getMatchedStylesForNode):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::getMatchedCSSRules):
* page/FrameView.cpp:
(WebCore::FrameView::setFrameRect):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::updateFromElement):
(WebCore::RenderListBox::paintItemForeground):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::fontSelector):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::getUncachedPseudoStyle):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::checkRegionStyle):
(WebCore::RenderRegion::computeStyleInRegion):
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::fontSelector):
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):
* svg/SVGElement.cpp:
(WebCore::SVGElement::customStyleForRenderer):
* svg/SVGElementRareData.h:
(WebCore::SVGElementRareData::overrideComputedStyle):
2013-04-30 Simon Fraser <simon.fraser@apple.com>
Cap max CALayer tree depth to avoid crashes
......
......@@ -237,7 +237,7 @@ void FontLoader::loadFont(const Dictionary& params)
RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(params, font.family());
for (const FontFamily* f = &font.family(); f; f = f->next()) {
CSSSegmentedFontFace* face = m_document->styleResolver()->fontSelector()->getFontFace(font.fontDescription(), f->family());
CSSSegmentedFontFace* face = m_document->ensureStyleResolver()->fontSelector()->getFontFace(font.fontDescription(), f->family());
if (!face) {
if (callback)
callback->notifyError();
......@@ -254,7 +254,7 @@ bool FontLoader::checkFont(const String& fontString, const String&)
if (!resolveFontStyle(fontString, font))
return false;
for (const FontFamily* f = &font.family(); f; f = f->next()) {
CSSSegmentedFontFace* face = m_document->styleResolver()->fontSelector()->getFontFace(font.fontDescription(), f->family());
CSSSegmentedFontFace* face = m_document->ensureStyleResolver()->fontSelector()->getFontFace(font.fontDescription(), f->family());
if (!face || !face->checkFont())
return false;
}
......@@ -293,7 +293,7 @@ bool FontLoader::resolveFontStyle(const String& fontString, Font& font)
style->font().update(style->font().fontSelector());
// Now map the font property longhands into the style.
StyleResolver* styleResolver = m_document->styleResolver();
StyleResolver* styleResolver = m_document->ensureStyleResolver();
styleResolver->applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), style.get());
applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontStyle, parsedStyle);
applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontVariant, parsedStyle);
......
......@@ -84,9 +84,7 @@ PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const
if (!documentElement)
return nullptr;
StyleResolver* styleResolver = m_document->styleResolver();
if (!styleResolver)
return nullptr;
StyleResolver* styleResolver = m_document->ensureStyleResolver();
RefPtr<RenderStyle> rootStyle = styleResolver->styleForElement(documentElement, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules);
......
......@@ -60,9 +60,7 @@ bool StyleMedia::matchMedium(const String& query) const
if (!documentElement)
return false;
StyleResolver* styleResolver = document->styleResolver();
if (!styleResolver)
return false;
StyleResolver* styleResolver = document->ensureStyleResolver();
RefPtr<RenderStyle> rootStyle = styleResolver->styleForElement(documentElement, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules);
......
......@@ -1934,14 +1934,14 @@ PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
bool oldIgnore = m_ignorePendingStylesheets;
m_ignorePendingStylesheets = true;
RefPtr<RenderStyle> style = styleResolver()->styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : 0);
RefPtr<RenderStyle> style = ensureStyleResolver()->styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : 0);
m_ignorePendingStylesheets = oldIgnore;
return style.release();
}
PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex)
{
RefPtr<RenderStyle> style = styleResolver()->styleForPage(pageIndex);
RefPtr<RenderStyle> style = ensureStyleResolver()->styleForPage(pageIndex);
return style.release();
}
......
......@@ -449,7 +449,7 @@ public:
bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
StyleResolver* styleResolver()
StyleResolver* ensureStyleResolver()
{
if (!m_styleResolver)
createStyleResolver();
......
......@@ -86,7 +86,7 @@ DocumentStyleSheetCollection::~DocumentStyleSheetCollection()
void DocumentStyleSheetCollection::combineCSSFeatureFlags()
{
// Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/after).
StyleResolver* styleResolver = m_document->styleResolver();
StyleResolver* styleResolver = m_document->ensureStyleResolver();
m_usesSiblingRules = m_usesSiblingRules || styleResolver->usesSiblingRules();
m_usesFirstLineRules = m_usesFirstLineRules || styleResolver->usesFirstLineRules();
m_usesBeforeAfterRules = m_usesBeforeAfterRules || styleResolver->usesBeforeAfterRules();
......@@ -94,7 +94,7 @@ void DocumentStyleSheetCollection::combineCSSFeatureFlags()
void DocumentStyleSheetCollection::resetCSSFeatureFlags()
{
StyleResolver* styleResolver = m_document->styleResolver();
StyleResolver* styleResolver = m_document->ensureStyleResolver();
m_usesSiblingRules = styleResolver->usesSiblingRules();
m_usesFirstLineRules = styleResolver->usesFirstLineRules();
m_usesBeforeAfterRules = styleResolver->usesBeforeAfterRules();
......@@ -474,7 +474,7 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag
if (styleResolverUpdateType == Reconstruct)
m_document->clearStyleResolver();
else {
StyleResolver* styleResolver = m_document->styleResolver();
StyleResolver* styleResolver = m_document->ensureStyleResolver();
if (styleResolverUpdateType == Reset) {
styleResolver->ruleSets().resetAuthorStyle();
styleResolver->appendAuthorStyleSheets(0, activeCSSStyleSheets);
......
......@@ -112,7 +112,7 @@ public:
{
if (m_pushedStyleResolver)
return;
m_pushedStyleResolver = m_parent->document()->styleResolver();
m_pushedStyleResolver = m_parent->document()->ensureStyleResolver();
m_pushedStyleResolver->pushParentElement(m_parent);
}
~StyleResolverParentPusher()
......@@ -123,8 +123,8 @@ public:
// This tells us that our pushed style selector is in a bad state,
// so we should just bail out in that scenario.
ASSERT(m_pushedStyleResolver == m_parent->document()->styleResolver());
if (m_pushedStyleResolver != m_parent->document()->styleResolver())
ASSERT(m_pushedStyleResolver == m_parent->document()->ensureStyleResolver());
if (m_pushedStyleResolver != m_parent->document()->ensureStyleResolver())
return;
m_pushedStyleResolver->popParentElement(m_parent);
......@@ -1387,7 +1387,7 @@ PassRefPtr<RenderStyle> Element::styleForRenderer()
return style.release();
}
return document()->styleResolver()->styleForElement(this);
return document()->ensureStyleResolver()->styleForElement(this);
}
void Element::recalcStyle(StyleChange change)
......@@ -1440,7 +1440,8 @@ void Element::recalcStyle(StyleChange change)
// all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
if (document()->styleSheetCollection()->usesRemUnits() && document()->documentElement() == this && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {
// Cached RenderStyles may depend on the re units.
document()->styleResolver()->invalidateMatchedPropertiesCache();
if (StyleResolver* styleResolver = document()->styleResolverIfExists())
styleResolver->invalidateMatchedPropertiesCache();
change = Force;
}
......@@ -2721,7 +2722,7 @@ void Element::willModifyAttribute(const QualifiedName& name, const AtomicString&
}
if (oldValue != newValue) {
if (attached() && document()->styleResolver() && document()->styleResolver()->hasSelectorForAttribute(name.localName()))
if (attached() && document()->styleResolverIfExists() && document()->styleResolverIfExists()->hasSelectorForAttribute(name.localName()))
setNeedsStyleRecalc();
}
......
......@@ -297,7 +297,7 @@ void NodeRenderingContext::createRendererForTextIfNeeded()
Document* document = textNode->document();
if (resetStyleInheritance())
m_style = document->styleResolver()->defaultStyleForElement();
m_style = document->ensureStyleResolver()->defaultStyleForElement();
else
m_style = parentRenderer->style();
......
......@@ -134,7 +134,7 @@ void ShadowRoot::recalcStyle(StyleChange change)
// ShadowRoot doesn't support custom callbacks.
ASSERT(!hasCustomStyleCallbacks());
StyleResolver* styleResolver = document()->styleResolver();
StyleResolver* styleResolver = document()->ensureStyleResolver();
styleResolver->pushParentShadowRoot(this);
for (Node* child = firstChild(); child; child = child->nextSibling()) {
......@@ -174,7 +174,7 @@ void ShadowRoot::setResetStyleInheritance(bool value)
void ShadowRoot::attach()
{
StyleResolver* styleResolver = document()->styleResolver();
StyleResolver* styleResolver = document()->ensureStyleResolver();
styleResolver->pushParentShadowRoot(this);
DocumentFragment::attach();
styleResolver->popParentShadowRoot(this);
......
......@@ -286,7 +286,7 @@ void Text::recalcTextStyle(StyleChange change)
RenderText* renderer = toRenderText(this->renderer());
if (change != NoChange && renderer)
renderer->setStyle(document()->styleResolver()->styleForText(this));
renderer->setStyle(document()->ensureStyleResolver()->styleForText(this));
if (needsStyleRecalc()) {
if (renderer)
......
......@@ -1076,7 +1076,7 @@ void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
static PassRefPtr<MutableStylePropertySet> styleFromMatchedRulesForElement(Element* element, unsigned rulesToInclude)
{
RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create();
RefPtr<CSSRuleList> matchedRules = element->document()->styleResolver()->styleRulesForElement(element, rulesToInclude);
RefPtr<CSSRuleList> matchedRules = element->document()->ensureStyleResolver()->styleRulesForElement(element, rulesToInclude);
if (matchedRules) {
for (unsigned i = 0; i < matchedRules->length(); i++) {
if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE)
......
......@@ -478,11 +478,6 @@ SecurityOrigin* HTMLCanvasElement::securityOrigin() const
return document()->securityOrigin();
}
StyleResolver* HTMLCanvasElement::styleResolver()
{
return document()->styleResolver();
}
bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const
{
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
......
......@@ -124,8 +124,6 @@ public:
void setOriginTainted() { m_originClean = false; }
bool originClean() const { return m_originClean; }
StyleResolver* styleResolver();
AffineTransform baseTransform() const;
#if ENABLE(WEBGL)
......
......@@ -1972,7 +1972,7 @@ bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters&
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
{
return m_inputType->customStyleForRenderer(document()->styleResolver()->styleForElement(this));
return m_inputType->customStyleForRenderer(document()->ensureStyleResolver()->styleForElement(this));
}
#endif
......
......@@ -114,7 +114,7 @@ void HTMLOptGroupElement::detach()
void HTMLOptGroupElement::updateNonRenderStyle()
{
m_style = document()->styleResolver()->styleForElement(this);
m_style = document()->ensureStyleResolver()->styleForElement(this);
}
RenderStyle* HTMLOptGroupElement::nonRendererStyle() const
......
......@@ -312,7 +312,7 @@ void HTMLOptionElement::setLabel(const String& label)
void HTMLOptionElement::updateNonRenderStyle()
{
m_style = document()->styleResolver()->styleForElement(this);
m_style = document()->ensureStyleResolver()->styleForElement(this);
}
RenderStyle* HTMLOptionElement::nonRendererStyle() const
......
......@@ -293,7 +293,7 @@ void HTMLPlugInImageElement::documentDidResumeFromPageCache()
PassRefPtr<RenderStyle> HTMLPlugInImageElement::customStyleForRenderer()
{
if (!m_customStyleForPageCache)
return document()->styleResolver()->styleForElement(this);
return document()->ensureStyleResolver()->styleForElement(this);
return m_customStyleForPageCache;
}
......
......@@ -2063,7 +2063,7 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
newStyle->font().update(newStyle->font().fontSelector());
// Now map the font property longhands into the style.
StyleResolver* styleResolver = canvas()->styleResolver();
StyleResolver* styleResolver = canvas()->document()->ensureStyleResolver();
styleResolver->applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), newStyle.get());
styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get());
styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontVariant, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariant).get());
......
......@@ -498,7 +498,7 @@ PassRefPtr<RenderStyle> DateTimeEditElement::customStyleForRenderer()
{
// FIXME: This is a kind of layout. We might want to introduce new renderer.
FontCachePurgePreventer fontCachePurgePreventer;
RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
RefPtr<RenderStyle> originalStyle = document()->ensureStyleResolver()->styleForElement(this);
RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
float width = 0;
for (Node* child = fieldsWrapperElement()->firstChild(); child; child = child->nextSibling()) {
......
......@@ -734,7 +734,7 @@ void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int no
return;
// Matched rules.
StyleResolver* styleResolver = element->ownerDocument()->styleResolver();
StyleResolver* styleResolver = element->ownerDocument()->ensureStyleResolver();
RefPtr<CSSRuleList> matchedRules = styleResolver->styleRulesForElement(element, StyleResolver::AllCSSRules);
matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), styleResolver, element);
......@@ -759,7 +759,7 @@ void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int no
RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entries = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create();
Element* parentElement = element->parentElement();
while (parentElement) {
StyleResolver* parentStyleResolver = parentElement->ownerDocument()->styleResolver();
StyleResolver* parentStyleResolver = parentElement->ownerDocument()->ensureStyleResolver();
RefPtr<CSSRuleList> parentMatchedRules = parentStyleResolver->styleRulesForElement(parentElement, StyleResolver::AllCSSRules);
RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::CSS::InheritedStyleEntry::create()
.setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRules.get(), styleResolver, parentElement));
......
......@@ -1382,7 +1382,7 @@ PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const St
PseudoId pseudoId = CSSSelector::pseudoId(pseudoType);
return m_frame->document()->styleResolver()->pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);
return m_frame->document()->ensureStyleResolver()->pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);
}
PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromNodeToPage(Node* node, const WebKitPoint* p) const
......
......@@ -481,7 +481,7 @@ void FrameView::setFrameRect(const IntRect& newRect)
Document* document = m_frame ? m_frame->document() : 0;
// Viewport-dependent media queries may cause us to need completely different style information.
if (document && document->styleResolver() && document->styleResolver()->affectedByViewportChange()) {
if (document && document->styleResolverIfExists() && document->styleResolverIfExists()->affectedByViewportChange()) {
document->styleResolverChanged(DeferRecalcStyle);
InspectorInstrumentation::mediaQueryResultChanged(document);
}
......
......@@ -52,7 +52,7 @@ KeyframeAnimation::KeyframeAnimation(const Animation* animation, RenderObject* r
{
// Get the keyframe RenderStyles
if (m_object && m_object->node() && m_object->node()->isElementNode())
m_object->document()->styleResolver()->keyframeStylesForAnimation(toElement(m_object->node()), unanimatedStyle, m_keyframes);
m_object->document()->ensureStyleResolver()->keyframeStylesForAnimation(toElement(m_object->node()), unanimatedStyle, m_keyframes);
// Update the m_transformFunctionListValid flag based on whether the function lists in the keyframes match.
validateTransformFunctionList();
......
......@@ -131,7 +131,7 @@ void RenderListBox::updateFromElement()
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleResolver()->fontSelector());
itemFont.update(document()->ensureStyleResolver()->fontSelector());
}
if (!text.isEmpty()) {
......@@ -431,7 +431,7 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint&
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleResolver()->fontSelector());
itemFont.update(document()->ensureStyleResolver()->fontSelector());
}
// Draw the item text
......
......@@ -615,7 +615,7 @@ void RenderMenuList::setTextFromItem(unsigned listIndex)
FontSelector* RenderMenuList::fontSelector() const
{
return document()->styleResolver()->fontSelector();
return document()->ensureStyleResolver()->fontSelector();
}
}
......@@ -2768,12 +2768,12 @@ PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(const PseudoStyleRe
Element* element = toElement(n);
if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) {
RefPtr<RenderStyle> result = document()->styleResolver()->styleForElement(element, parentStyle, DisallowStyleSharing);
RefPtr<RenderStyle> result = document()->ensureStyleResolver()->styleForElement(element, parentStyle, DisallowStyleSharing);
result->setStyleType(FIRST_LINE_INHERITED);
return result.release();
}
return document()->styleResolver()->pseudoStyleForElement(element, pseudoStyleRequest, parentStyle);
return document()->ensureStyleResolver()->pseudoStyleForElement(element, pseudoStyleRequest, parentStyle);
}
static Color decorationColor(RenderStyle* style)
......
......@@ -195,7 +195,7 @@ void RenderRegion::checkRegionStyle()
// FIXME: Region styling doesn't work for pseudo elements.
if (node()) {
Element* regionElement = toElement(node());
customRegionStyle = view()->document()->styleResolver()->checkRegionStyle(regionElement);
customRegionStyle = view()->document()->ensureStyleResolver()->checkRegionStyle(regionElement);
}
setHasCustomRegionStyle(customRegionStyle);
m_flowThread->checkRegionsWithStyling();
......@@ -526,7 +526,7 @@ PassRefPtr<RenderStyle> RenderRegion::computeStyleInRegion(const RenderObject* o
// FIXME: Region styling fails for pseudo-elements because the renderers don't have a node.
Element* element = toElement(object->node());
RefPtr<RenderStyle> renderObjectRegionStyle = object->view()->document()->styleResolver()->styleForElement(element, 0, DisallowStyleSharing, MatchAllRules, this);
RefPtr<RenderStyle> renderObjectRegionStyle = object->view()->document()->ensureStyleResolver()->styleForElement(element, 0, DisallowStyleSharing, MatchAllRules, this);
return renderObjectRegionStyle.release();
}
......
......@@ -344,7 +344,7 @@ void RenderSearchField::setTextFromItem(unsigned listIndex)
FontSelector* RenderSearchField::fontSelector() const
{
return document()->styleResolver()->fontSelector();
return document()->ensureStyleResolver()->fontSelector();
}
HostWindow* RenderSearchField::hostWindow() const
......
......@@ -228,8 +228,7 @@ void RenderSVGInlineText::computeNewScaledFontForStyle(RenderObject* renderer, c
Document* document = renderer->document();
ASSERT(document);
StyleResolver* styleResolver = document->styleResolver();
ASSERT(styleResolver);
StyleResolver* styleResolver = document->ensureStyleResolver();
// Alter font-size to the right on-screen value to avoid scaling the glyphs themselves, except when GeometricPrecision is specified
scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFactor(renderer);
......
......@@ -596,7 +596,7 @@ void SVGElement::synchronizeSystemLanguage(SVGElement* contextElement)
PassRefPtr<RenderStyle> SVGElement::customStyleForRenderer()
{
if (!correspondingElement())
return document()->styleResolver()->styleForElement(this);
return document()->ensureStyleResolver()->styleForElement(this);
RenderStyle* style = 0;
if (Element* parent = parentOrShadowHostElement()) {
......@@ -604,7 +604,7 @@ PassRefPtr<RenderStyle> SVGElement::customStyleForRenderer()
style = renderer->style();
}
return document()->styleResolver()->styleForElement(correspondingElement(), style, DisallowStyleSharing);
return document()->ensureStyleResolver()->styleForElement(correspondingElement(), style, DisallowStyleSharing);
}
MutableStylePropertySet* SVGElement::animatedSMILStyleProperties() const
......
......@@ -95,7 +95,7 @@ public:
return 0;
if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) {
// The style computed here contains no CSS Animations/Transitions or SMIL induced rules - this is needed to compute the "base value" for the SMIL animation sandwhich model.
m_overrideComputedStyle = element->document()->styleResolver()->styleForElement(element, parentStyle, DisallowStyleSharing, MatchAllRulesExcludingSMIL);
m_overrideComputedStyle = element->document()->ensureStyleResolver()->styleForElement(element, parentStyle, DisallowStyleSharing, MatchAllRulesExcludingSMIL);
m_needsOverrideComputedStyleUpdate = false;
}
ASSERT(m_overrideComputedStyle);
......
......@@ -829,7 +829,7 @@ QString QWebElement::styleProperty(const QString &name, StyleResolveStrategy str
// declarations, as well as embedded and inline style declarations.
Document* doc = m_element->document();
if (RefPtr<CSSRuleList> rules = doc->styleResolver()->styleRulesForElement(m_element, StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules)) {
if (RefPtr<CSSRuleList> rules = doc->ensureStyleResolver()->styleRulesForElement(m_element, StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules)) {
for (int i = rules->length(); i > 0; --i) {
CSSStyleRule* rule = static_cast<CSSStyleRule*>(rules->item(i - 1));
......
2013-04-30 Andreas Kling <akling@apple.com>
Don't create StyleResolvers just to invalidate them.
<http://webkit.org/b/115436>
Reviewed by Geoffrey Garen.
* Api/qwebelement.cpp:
(QWebElement::styleProperty):
2013-04-25 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: ConsoleMessage should include line and column number where possible
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment