Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Unified Diff: Source/core/css/resolver/SharedStyleFinder.cpp

Issue 27033011: Fix readonly and type attribute selector incorrect style sharing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix for svg Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css/style-sharing-type-and-readonly-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/SharedStyleFinder.cpp
diff --git a/Source/core/css/resolver/SharedStyleFinder.cpp b/Source/core/css/resolver/SharedStyleFinder.cpp
index 2a6dd7bfdd1ad3efde859e98e8fac63b618bf54d..d76a4332a223f642d07e4fedd79f556b91c067a4 100644
--- a/Source/core/css/resolver/SharedStyleFinder.cpp
+++ b/Source/core/css/resolver/SharedStyleFinder.cpp
@@ -68,12 +68,6 @@ bool SharedStyleFinder::canShareStyleWithControl(const ElementResolveContext& co
HTMLInputElement* thisInputElement = toHTMLInputElement(element);
HTMLInputElement* otherInputElement = toHTMLInputElement(context.element());
- if (thisInputElement->elementData() != otherInputElement->elementData()) {
- if (thisInputElement->fastGetAttribute(typeAttr) != otherInputElement->fastGetAttribute(typeAttr))
- return false;
- if (thisInputElement->fastGetAttribute(readonlyAttr) != otherInputElement->fastGetAttribute(readonlyAttr))
- return false;
- }
if (thisInputElement->isAutofilled() != otherInputElement->isAutofilled())
return false;
@@ -124,6 +118,12 @@ static inline bool elementHasDirectionAuto(Element* element)
return element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto();
}
+static inline const AtomicString& typeAttributeValue(const Element* element)
+{
+ // type is animatable in SVG so we need to go down the slow path here.
+ return element->isSVGElement() ? element->getAttribute(typeAttr) : element->fastGetAttribute(typeAttr);
+}
+
bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(const ElementResolveContext& context, Element* sharingCandidate) const
{
if (context.element()->elementData() == sharingCandidate->elementData())
@@ -133,6 +133,13 @@ bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(con
if (context.element()->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr))
return false;
+ // These two checks must be here since RuleSet has a specail case to allow style sharing between elements
+ // with type and readonly attributes whereas other attribute selectors prevent sharing.
+ if (typeAttributeValue(context.element()) != typeAttributeValue(sharingCandidate))
+ return false;
+ if (context.element()->fastGetAttribute(readonlyAttr) != sharingCandidate->fastGetAttribute(readonlyAttr))
+ return false;
+
if (!m_elementAffectedByClassRules) {
if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCandidate->classNames()))
return false;
« no previous file with comments | « LayoutTests/fast/css/style-sharing-type-and-readonly-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698