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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return parentElement->hasFlagsSetDuringStylingOfChildren(); | 61 return parentElement->hasFlagsSetDuringStylingOfChildren(); |
62 } | 62 } |
63 | 63 |
64 bool SharedStyleFinder::canShareStyleWithControl(const ElementResolveContext& co
ntext, Element* element) const | 64 bool SharedStyleFinder::canShareStyleWithControl(const ElementResolveContext& co
ntext, Element* element) const |
65 { | 65 { |
66 if (!element->hasTagName(inputTag) || !context.element()->hasTagName(inputTa
g)) | 66 if (!element->hasTagName(inputTag) || !context.element()->hasTagName(inputTa
g)) |
67 return false; | 67 return false; |
68 | 68 |
69 HTMLInputElement* thisInputElement = toHTMLInputElement(element); | 69 HTMLInputElement* thisInputElement = toHTMLInputElement(element); |
70 HTMLInputElement* otherInputElement = toHTMLInputElement(context.element()); | 70 HTMLInputElement* otherInputElement = toHTMLInputElement(context.element()); |
71 if (thisInputElement->elementData() != otherInputElement->elementData()) { | |
72 if (thisInputElement->fastGetAttribute(typeAttr) != otherInputElement->f
astGetAttribute(typeAttr)) | |
73 return false; | |
74 if (thisInputElement->fastGetAttribute(readonlyAttr) != otherInputElemen
t->fastGetAttribute(readonlyAttr)) | |
75 return false; | |
76 } | |
77 | 71 |
78 if (thisInputElement->isAutofilled() != otherInputElement->isAutofilled()) | 72 if (thisInputElement->isAutofilled() != otherInputElement->isAutofilled()) |
79 return false; | 73 return false; |
80 if (thisInputElement->shouldAppearChecked() != otherInputElement->shouldAppe
arChecked()) | 74 if (thisInputElement->shouldAppearChecked() != otherInputElement->shouldAppe
arChecked()) |
81 return false; | 75 return false; |
82 if (thisInputElement->shouldAppearIndeterminate() != otherInputElement->shou
ldAppearIndeterminate()) | 76 if (thisInputElement->shouldAppearIndeterminate() != otherInputElement->shou
ldAppearIndeterminate()) |
83 return false; | 77 return false; |
84 if (thisInputElement->isRequired() != otherInputElement->isRequired()) | 78 if (thisInputElement->isRequired() != otherInputElement->isRequired()) |
85 return false; | 79 return false; |
86 | 80 |
(...skipping 30 matching lines...) Expand all Loading... |
117 } | 111 } |
118 return false; | 112 return false; |
119 } | 113 } |
120 | 114 |
121 static inline bool elementHasDirectionAuto(Element* element) | 115 static inline bool elementHasDirectionAuto(Element* element) |
122 { | 116 { |
123 // FIXME: This line is surprisingly hot, we may wish to inline hasDirectionA
uto into StyleResolver. | 117 // FIXME: This line is surprisingly hot, we may wish to inline hasDirectionA
uto into StyleResolver. |
124 return element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto(
); | 118 return element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto(
); |
125 } | 119 } |
126 | 120 |
| 121 static inline const AtomicString& typeAttributeValue(const Element* element) |
| 122 { |
| 123 // type is animatable in SVG so we need to go down the slow path here. |
| 124 return element->isSVGElement() ? element->getAttribute(typeAttr) : element->
fastGetAttribute(typeAttr); |
| 125 } |
| 126 |
127 bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(con
st ElementResolveContext& context, Element* sharingCandidate) const | 127 bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(con
st ElementResolveContext& context, Element* sharingCandidate) const |
128 { | 128 { |
129 if (context.element()->elementData() == sharingCandidate->elementData()) | 129 if (context.element()->elementData() == sharingCandidate->elementData()) |
130 return true; | 130 return true; |
131 if (context.element()->fastGetAttribute(XMLNames::langAttr) != sharingCandid
ate->fastGetAttribute(XMLNames::langAttr)) | 131 if (context.element()->fastGetAttribute(XMLNames::langAttr) != sharingCandid
ate->fastGetAttribute(XMLNames::langAttr)) |
132 return false; | 132 return false; |
133 if (context.element()->fastGetAttribute(langAttr) != sharingCandidate->fastG
etAttribute(langAttr)) | 133 if (context.element()->fastGetAttribute(langAttr) != sharingCandidate->fastG
etAttribute(langAttr)) |
134 return false; | 134 return false; |
135 | 135 |
| 136 // These two checks must be here since RuleSet has a specail case to allow s
tyle sharing between elements |
| 137 // with type and readonly attributes whereas other attribute selectors preve
nt sharing. |
| 138 if (typeAttributeValue(context.element()) != typeAttributeValue(sharingCandi
date)) |
| 139 return false; |
| 140 if (context.element()->fastGetAttribute(readonlyAttr) != sharingCandidate->f
astGetAttribute(readonlyAttr)) |
| 141 return false; |
| 142 |
136 if (!m_elementAffectedByClassRules) { | 143 if (!m_elementAffectedByClassRules) { |
137 if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCan
didate->classNames())) | 144 if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCan
didate->classNames())) |
138 return false; | 145 return false; |
139 } else if (sharingCandidate->hasClass()) { | 146 } else if (sharingCandidate->hasClass()) { |
140 // SVG elements require a (slow!) getAttribute comparision because "clas
s" is an animatable attribute for SVG. | 147 // SVG elements require a (slow!) getAttribute comparision because "clas
s" is an animatable attribute for SVG. |
141 if (context.element()->isSVGElement()) { | 148 if (context.element()->isSVGElement()) { |
142 if (context.element()->getAttribute(classAttr) != sharingCandidate->
getAttribute(classAttr)) | 149 if (context.element()->getAttribute(classAttr) != sharingCandidate->
getAttribute(classAttr)) |
143 return false; | 150 return false; |
144 } else if (context.element()->classNames() != sharingCandidate->classNam
es()) { | 151 } else if (context.element()->classNames() != sharingCandidate->classNam
es()) { |
145 return false; | 152 return false; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 if (matchesRuleSet(context, m_siblingRuleSet) || matchesRuleSet(context, m_u
ncommonAttributeRuleSet)) | 348 if (matchesRuleSet(context, m_siblingRuleSet) || matchesRuleSet(context, m_u
ncommonAttributeRuleSet)) |
342 return 0; | 349 return 0; |
343 // Tracking child index requires unique style for each node. This may get se
t by the sibling rule match above. | 350 // Tracking child index requires unique style for each node. This may get se
t by the sibling rule match above. |
344 if (parentElementPreventsSharing(context.element()->parentElement())) | 351 if (parentElementPreventsSharing(context.element()->parentElement())) |
345 return 0; | 352 return 0; |
346 STYLE_STATS_ADD_STYLE_SHARED(); | 353 STYLE_STATS_ADD_STYLE_SHARED(); |
347 return shareElement->renderStyle(); | 354 return shareElement->renderStyle(); |
348 } | 355 } |
349 | 356 |
350 } | 357 } |
OLD | NEW |