Diff
Modified: trunk/LayoutTests/ChangeLog (163474 => 163475)
--- trunk/LayoutTests/ChangeLog 2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/LayoutTests/ChangeLog 2014-02-05 21:50:55 UTC (rev 163475)
@@ -1,3 +1,13 @@
+2014-02-05 Antti Koivisto <[email protected]>
+
+ ElementRuleCollector should not use StyleResolver::State
+ https://bugs.webkit.org/show_bug.cgi?id=128247
+
+ Reviewed by Andreas Kling.
+
+ * platform/mac/fast/parser/xhtml-alternate-entities-expected.png:
+ * platform/mac/fast/parser/xhtml-alternate-entities-expected.txt: This is a progression.
+
2014-02-05 Yuki Sekiguchi <[email protected]>
Ruby base oddly justify its text when the text is ideograph and it contains <br> on Mac.
Modified: trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.png
(Binary files differ)
Modified: trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt (163474 => 163475)
--- trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt 2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt 2014-02-05 21:50:55 UTC (rev 163475)
@@ -18,7 +18,7 @@
RenderText {#text} at (0,0) size 0x0
RenderText {#text} at (0,0) size 0x0
RenderText {#text} at (0,0) size 0x0
- RenderInline {p} at (0,0) size 489x18
+ RenderInline {p} at (0,0) size 489x18 [color=#FF0000]
RenderInline {font} at (0,0) size 489x18
RenderText {#text} at (0,0) size 489x18
text run at (0,0) width 263: "This should be the only line on this page. "
Modified: trunk/Source/WebCore/ChangeLog (163474 => 163475)
--- trunk/Source/WebCore/ChangeLog 2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/ChangeLog 2014-02-05 21:50:55 UTC (rev 163475)
@@ -1,3 +1,25 @@
+2014-02-05 Antti Koivisto <[email protected]>
+
+ ElementRuleCollector should not use StyleResolver::State
+ https://bugs.webkit.org/show_bug.cgi?id=128247
+
+ Reviewed by Andreas Kling.
+
+ Make ElementRuleCollector more reusable.
+
+ * css/ElementRuleCollector.cpp:
+ (WebCore::ElementRuleCollector::collectMatchingRules):
+ (WebCore::ElementRuleCollector::sortAndTransferMatchedRules):
+ (WebCore::ElementRuleCollector::matchAuthorRules):
+ (WebCore::ElementRuleCollector::matchUARules):
+ (WebCore::ElementRuleCollector::ruleMatches):
+ (WebCore::ElementRuleCollector::collectMatchingRulesForList):
+ (WebCore::ElementRuleCollector::matchAllRules):
+ * css/ElementRuleCollector.h:
+ (WebCore::ElementRuleCollector::ElementRuleCollector):
+
+ Pass the objects that are actually needed rather than the entire State.
+
2014-02-05 Brent Fulgham <[email protected]>
[Mac] Correct copy/paste error in scrolling code.
Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (163474 => 163475)
--- trunk/Source/WebCore/css/ElementRuleCollector.cpp 2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp 2014-02-05 21:50:55 UTC (rev 163475)
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 2004-2005 Allan Sandfeld Jensen ([email protected])
* Copyright (C) 2006, 2007 Nicholas Shanks ([email protected])
- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alexey Proskuryakov <[email protected]>
* Copyright (C) 2007, 2008 Eric Seidel <[email protected]>
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
@@ -145,19 +145,13 @@
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
{
ASSERT(matchRequest.ruleSet);
- ASSERT(m_state.element());
- const StyleResolver::State& state = m_state;
- Element* element = state.element();
- const StyledElement* styledElement = state.styledElement();
- const AtomicString& pseudoId = element->shadowPseudoId();
- if (!pseudoId.isEmpty()) {
- ASSERT(styledElement);
+ const AtomicString& pseudoId = m_element.shadowPseudoId();
+ if (!pseudoId.isEmpty())
collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange);
- }
#if ENABLE(VIDEO_TRACK)
- if (element->isWebVTTElement())
+ if (m_element.isWebVTTElement())
collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange);
#endif
// Check whether other types of rules are applicable in the current tree scope. Criteria for this:
@@ -165,23 +159,23 @@
// b) the tree scope allows author rules
// c) the rules comes from a scoped style sheet within the same tree scope
if (!MatchingUARulesScope::isMatchingUARules()
- && !element->treeScope().applyAuthorStyles())
+ && !m_element.treeScope().applyAuthorStyles())
return;
// We need to collect the rules for id, class, tag, and everything else into a buffer and
// then sort the buffer.
- if (element->hasID())
- collectMatchingRulesForList(matchRequest.ruleSet->idRules(element->idForStyleResolution().impl()), matchRequest, ruleRange);
- if (styledElement && styledElement->hasClass()) {
- for (size_t i = 0; i < styledElement->classNames().size(); ++i)
- collectMatchingRulesForList(matchRequest.ruleSet->classRules(styledElement->classNames()[i].impl()), matchRequest, ruleRange);
+ if (m_element.hasID())
+ collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element.idForStyleResolution().impl()), matchRequest, ruleRange);
+ if (m_element.hasClass()) {
+ for (size_t i = 0; i < m_element.classNames().size(); ++i)
+ collectMatchingRulesForList(matchRequest.ruleSet->classRules(m_element.classNames()[i].impl()), matchRequest, ruleRange);
}
- if (element->isLink())
+ if (m_element.isLink())
collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange);
- if (SelectorChecker::matchesFocusPseudoClass(element))
+ if (SelectorChecker::matchesFocusPseudoClass(&m_element))
collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange);
- collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element->localName().impl()), matchRequest, ruleRange);
+ collectMatchingRulesForList(matchRequest.ruleSet->tagRules(m_element.localName().impl()), matchRequest, ruleRange);
collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest, ruleRange);
}
@@ -203,8 +197,6 @@
void ElementRuleCollector::sortAndTransferMatchedRules()
{
- const StyleResolver::State& state = m_state;
-
if (!m_matchedRules || m_matchedRules->isEmpty())
return;
@@ -219,8 +211,8 @@
// Now transfer the set of matched rules over to our list of declarations.
for (unsigned i = 0; i < matchedRules.size(); i++) {
- if (state.style() && matchedRules[i]->containsUncommonAttributeSelector())
- state.style()->setUnique();
+ if (m_style && matchedRules[i]->containsUncommonAttributeSelector())
+ m_style->setUnique();
m_result.addMatchedProperties(matchedRules[i]->rule()->properties(), matchedRules[i]->rule(), matchedRules[i]->linkMatchType(), matchedRules[i]->propertyWhitelistType(MatchingUARulesScope::isMatchingUARules()));
}
}
@@ -230,9 +222,6 @@
clearMatchedRules();
m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1;
- if (!m_state.element())
- return;
-
// Match global author rules.
MatchRequest matchRequest(m_ruleSets.authorStyle(), includeEmptyRules);
StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange();
@@ -270,11 +259,11 @@
matchUARules(userAgentStyleSheet);
// In quirks mode, we match rules from the quirks user agent sheet.
- if (document().inQuirksMode())
+ if (m_element.document().inQuirksMode())
matchUARules(CSSDefaultStyleSheets::defaultQuirksStyle);
// 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.
- if (document().isViewSource())
+ if (m_element.document().isViewSource())
matchUARules(CSSDefaultStyleSheets::viewSourceStyle());
}
@@ -291,8 +280,6 @@
inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, PseudoId& dynamicPseudo)
{
- const StyleResolver::State& state = m_state;
-
bool fastCheckableSelector = ruleData.hasFastCheckableSelector();
if (fastCheckableSelector) {
// We know this selector does not include any pseudo elements.
@@ -300,7 +287,7 @@
return false;
// We know a sufficiently simple single part selector matches simply because we found it from the rule hash.
// This is limited to HTML only so we don't need to check the namespace.
- if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && state.element()->isHTMLElement()) {
+ if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && m_element.isHTMLElement()) {
if (!ruleData.hasMultipartSelector())
return true;
}
@@ -309,7 +296,7 @@
#if ENABLE(CSS_SELECTOR_JIT)
void* compiledSelectorChecker = ruleData.compiledSelectorCodeRef().code().executableAddress();
if (!compiledSelectorChecker && ruleData.compilationStatus() == SelectorCompilationStatus::NotCompiled) {
- JSC::VM* vm = document().scriptExecutionContext()->vm();
+ JSC::VM* vm = m_element.document().scriptExecutionContext()->vm();
SelectorCompilationStatus compilationStatus;
JSC::MacroAssemblerCodeRef compiledSelectorCodeRef;
compilationStatus = SelectorCompiler::compileSelector(ruleData.selector(), vm, compiledSelectorCodeRef);
@@ -323,22 +310,22 @@
if (ruleData.compilationStatus() == SelectorCompilationStatus::SimpleSelectorChecker) {
SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, ruleData.compilationStatus());
- return selectorChecker(state.element());
+ return selectorChecker(&m_element);
}
ASSERT(ruleData.compilationStatus() == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
SelectorCompiler::SelectorCheckerWithCheckingContext selectorChecker = SelectorCompiler::selectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, ruleData.compilationStatus());
SelectorCompiler::CheckingContext context;
- context.elementStyle = state.style();
+ context.elementStyle = m_style;
context.resolvingMode = m_mode;
- return selectorChecker(state.element(), &context);
+ return selectorChecker(&m_element, &context);
}
#endif // ENABLE(CSS_SELECTOR_JIT)
if (fastCheckableSelector) {
- if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(state.element(), ruleData.selector()->tagQName()))
+ if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(&m_element, ruleData.selector()->tagQName()))
return false;
- SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), state.element());
+ SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), &m_element);
if (!selectorCheckerFastPath.matchesRightmostAttributeSelector())
return false;
@@ -346,9 +333,9 @@
}
// Slow path.
- SelectorChecker selectorChecker(document(), m_mode);
- SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element(), SelectorChecker::VisitedMatchEnabled);
- context.elementStyle = state.style();
+ SelectorChecker selectorChecker(m_element.document(), m_mode);
+ SelectorChecker::SelectorCheckingContext context(ruleData.selector(), &m_element, SelectorChecker::VisitedMatchEnabled);
+ context.elementStyle = m_style;
context.pseudoId = m_pseudoStyleRequest.pseudoId;
context.scrollbar = m_pseudoStyleRequest.scrollbar;
context.scrollbarPart = m_pseudoStyleRequest.scrollbarPart;
@@ -364,8 +351,6 @@
if (!rules)
return;
- const StyleResolver::State& state = m_state;
-
for (unsigned i = 0, size = rules->size(); i < size; ++i) {
const RuleData& ruleData = rules->data()[i];
if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes()))
@@ -392,8 +377,8 @@
if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) {
if (m_mode == SelectorChecker::CollectingRules)
continue;
- if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
- state.style()->setHasPseudoStyle(dynamicPseudo);
+ if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID && m_style)
+ m_style->setHasPseudoStyle(dynamicPseudo);
} else {
// Update our first/last rule indices in the matched rules array.
++ruleRange.lastRuleIndex;
@@ -430,17 +415,18 @@
matchUserRules(false);
// Now check author rules, beginning first with presentational attributes mapped from HTML.
- if (m_state.styledElement()) {
- addElementStyleProperties(m_state.styledElement()->presentationAttributeStyle());
+ if (m_element.isStyledElement()) {
+ StyledElement& styledElement = toStyledElement(m_element);
+ addElementStyleProperties(styledElement.presentationAttributeStyle());
// Now we check additional mapped declarations.
// Tables and table cells share an additional mapped rule that must be applied
// after all attributes, since their mapped style depends on the values of multiple attributes.
- addElementStyleProperties(m_state.styledElement()->additionalPresentationAttributeStyle());
+ addElementStyleProperties(styledElement.additionalPresentationAttributeStyle());
- if (m_state.styledElement()->isHTMLElement()) {
+ if (styledElement.isHTMLElement()) {
bool isAuto;
- TextDirection textDirection = toHTMLElement(m_state.styledElement())->directionalityIfhasDirAutoAttribute(isAuto);
+ TextDirection textDirection = toHTMLElement(styledElement).directionalityIfhasDirAutoAttribute(isAuto);
if (isAuto)
m_result.addMatchedProperties(textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
}
@@ -450,18 +436,21 @@
if (matchAuthorAndUserStyles)
matchAuthorRules(false);
- // Now check our inline style attribute.
- if (matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->inlineStyle()) {
- // Inline style is immutable as long as there is no CSSOM wrapper.
- // FIXME: Media control shadow trees seem to have problems with caching.
- bool isInlineStyleCacheable = !m_state.styledElement()->inlineStyle()->isMutable() && !m_state.styledElement()->isInShadowTree();
- // FIXME: Constify.
- addElementStyleProperties(m_state.styledElement()->inlineStyle(), isInlineStyleCacheable);
- }
+ if (matchAuthorAndUserStyles && m_element.isStyledElement()) {
+ StyledElement& styledElement = toStyledElement(m_element);
+ // Now check our inline style attribute.
+ if (styledElement.inlineStyle()) {
+ // Inline style is immutable as long as there is no CSSOM wrapper.
+ // FIXME: Media control shadow trees seem to have problems with caching.
+ bool isInlineStyleCacheable = !styledElement.inlineStyle()->isMutable() && !styledElement.isInShadowTree();
+ // FIXME: Constify.
+ addElementStyleProperties(styledElement.inlineStyle(), isInlineStyleCacheable);
+ }
- // Now check SMIL animation override style.
- if (includeSMILProperties && matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->isSVGElement())
- addElementStyleProperties(toSVGElement(m_state.styledElement())->animatedSMILStyleProperties(), false /* isCacheable */);
+ // Now check SMIL animation override style.
+ if (includeSMILProperties && styledElement.isSVGElement())
+ addElementStyleProperties(toSVGElement(styledElement).animatedSMILStyleProperties(), false /* isCacheable */);
+ }
}
bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet)
Modified: trunk/Source/WebCore/css/ElementRuleCollector.h (163474 => 163475)
--- trunk/Source/WebCore/css/ElementRuleCollector.h 2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/css/ElementRuleCollector.h 2014-02-05 21:50:55 UTC (rev 163475)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999 Lars Knoll ([email protected])
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -40,16 +40,17 @@
class ElementRuleCollector {
public:
- ElementRuleCollector(StyleResolver* styleResolver, const StyleResolver::State& state)
- : m_state(state)
- , m_ruleSets(styleResolver->ruleSets())
- , m_selectorFilter(styleResolver->selectorFilter())
+ ElementRuleCollector(Element& element, RenderStyle* style, const DocumentRuleSets& ruleSets, const SelectorFilter& selectorFilter)
+ : m_element(element)
+ , m_style(style)
+ , m_ruleSets(ruleSets)
+ , m_selectorFilter(selectorFilter)
, m_isPrintStyle(false)
, m_regionForStyling(0)
, m_pseudoStyleRequest(NOPSEUDO)
, m_sameOriginOnly(false)
, m_mode(SelectorChecker::ResolvingStyle)
- , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(state.parentNode()))
+ , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(element.parentNode()))
{
}
@@ -70,7 +71,6 @@
const Vector<RefPtr<StyleRuleBase>>& matchedRuleList() const;
private:
- Document& document() { return m_state.document(); }
void addElementStyleProperties(const StyleProperties*, bool isCacheable = true);
void matchUARules(RuleSet*);
@@ -86,9 +86,10 @@
void addMatchedRule(const RuleData*);
void clearMatchedRules();
- const StyleResolver::State& m_state;
- DocumentRuleSets& m_ruleSets;
- SelectorFilter& m_selectorFilter;
+ Element& m_element;
+ RenderStyle* m_style;
+ const DocumentRuleSets& m_ruleSets;
+ const SelectorFilter& m_selectorFilter;
bool m_isPrintStyle;
RenderRegion* m_regionForStyling;
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (163474 => 163475)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-02-05 21:50:55 UTC (rev 163475)
@@ -486,7 +486,7 @@
if (!ruleSet)
return false;
- ElementRuleCollector collector(this, m_state);
+ ElementRuleCollector collector(*m_state.element(), m_state.style(), m_ruleSets, m_selectorFilter);
return collector.hasAnyMatchingRules(ruleSet);
}
@@ -796,7 +796,7 @@
if (needsCollection)
m_ruleSets.collectFeatures(document().isViewSource());
- ElementRuleCollector collector(this, state);
+ ElementRuleCollector collector(*element, state.style(), m_ruleSets, m_selectorFilter);
collector.setRegionForStyling(regionForStyling);
collector.setMedium(m_medium.get());
@@ -939,17 +939,17 @@
}
}
-PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)
+PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, const PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)
{
ASSERT(parentStyle);
- if (!e)
+ if (!element)
return 0;
State& state = m_state;
- initElement(e);
+ initElement(element);
- state.initForStyleResolve(document(), e, parentStyle);
+ state.initForStyleResolve(document(), element, parentStyle);
if (m_state.parentStyle()) {
state.setStyle(RenderStyle::create());
@@ -963,7 +963,7 @@
// those rules.
// Check UA, user and author rules.
- ElementRuleCollector collector(this, state);
+ ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_selectorFilter);
collector.setPseudoStyleRequest(pseudoStyleRequest);
collector.setMedium(m_medium.get());
collector.matchUARules();
@@ -978,7 +978,7 @@
state.style()->setStyleType(pseudoStyleRequest.pseudoId);
- applyMatchedProperties(collector.matchedResult(), e);
+ applyMatchedProperties(collector.matchedResult(), element);
// Clean up our style object's display and text decorations (among other fixups).
adjustRenderStyle(*state.style(), *m_state.parentStyle(), 0);
@@ -1452,15 +1452,15 @@
return pseudoStyleRulesForElement(e, NOPSEUDO, rulesToInclude);
}
-Vector<RefPtr<StyleRuleBase>> StyleResolver::pseudoStyleRulesForElement(Element* e, PseudoId pseudoId, unsigned rulesToInclude)
+Vector<RefPtr<StyleRuleBase>> StyleResolver::pseudoStyleRulesForElement(Element* element, PseudoId pseudoId, unsigned rulesToInclude)
{
- if (!e || !e->document().haveStylesheetsLoaded())
+ if (!element || !element->document().haveStylesheetsLoaded())
return Vector<RefPtr<StyleRuleBase>>();
- initElement(e);
- m_state.initForStyleResolve(document(), e, 0);
+ initElement(element);
+ m_state.initForStyleResolve(document(), element, 0);
- ElementRuleCollector collector(this, m_state);
+ ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_selectorFilter);
collector.setMode(SelectorChecker::CollectingRules);
collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
collector.setMedium(m_medium.get());