| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 
| 3  *           (C) 1999 Antti Koivisto (koivisto@kde.org) | 3  *           (C) 1999 Antti Koivisto (koivisto@kde.org) | 
| 4  *           (C) 2001 Peter Kelly (pmk@post.com) | 4  *           (C) 2001 Peter Kelly (pmk@post.com) | 
| 5  *           (C) 2001 Dirk Mueller (mueller@kde.org) | 5  *           (C) 2001 Dirk Mueller (mueller@kde.org) | 
| 6  *           (C) 2007 David Smith (catfish.man@gmail.com) | 6  *           (C) 2007 David Smith (catfish.man@gmail.com) | 
| 7  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. | 7  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. | 
| 8  * All rights reserved. | 8  * All rights reserved. | 
| 9  *           (C) 2007 Eric Seidel (eric@webkit.org) | 9  *           (C) 2007 Eric Seidel (eric@webkit.org) | 
| 10  * | 10  * | 
| (...skipping 3243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3254   PseudoElement* element = pseudoElement(pseudoId); | 3254   PseudoElement* element = pseudoElement(pseudoId); | 
| 3255 | 3255 | 
| 3256   if (element && (change == UpdatePseudoElements || | 3256   if (element && (change == UpdatePseudoElements || | 
| 3257                   element->shouldCallRecalcStyle(change))) { | 3257                   element->shouldCallRecalcStyle(change))) { | 
| 3258     if (pseudoId == PseudoIdFirstLetter && updateFirstLetter(element)) | 3258     if (pseudoId == PseudoIdFirstLetter && updateFirstLetter(element)) | 
| 3259       return; | 3259       return; | 
| 3260 | 3260 | 
| 3261     // Need to clear the cached style if the PseudoElement wants a recalc so it | 3261     // Need to clear the cached style if the PseudoElement wants a recalc so it | 
| 3262     // computes a new style. | 3262     // computes a new style. | 
| 3263     if (element->needsStyleRecalc()) | 3263     if (element->needsStyleRecalc()) | 
| 3264       layoutObject()->mutableStyle()->removeCachedPseudoStyle(pseudoId); | 3264       mutableComputedStyle()->removeCachedPseudoStyle(pseudoId); | 
| 3265 | 3265 | 
| 3266     // PseudoElement styles hang off their parent element's style so if we | 3266     // PseudoElement styles hang off their parent element's style so if we | 
| 3267     // needed a style recalc we should Force one on the pseudo.  FIXME: We | 3267     // needed a style recalc we should Force one on the pseudo.  FIXME: We | 
| 3268     // should figure out the right text sibling to pass. | 3268     // should figure out the right text sibling to pass. | 
| 3269     element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 3269     element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 
| 3270 | 3270 | 
| 3271     // Wait until our parent is not displayed or | 3271     // Wait until our parent is not displayed or | 
| 3272     // pseudoElementLayoutObjectIsNeeded is false, otherwise we could | 3272     // pseudoElementLayoutObjectIsNeeded is false, otherwise we could | 
| 3273     // continuously create and destroy PseudoElements when | 3273     // continuously create and destroy PseudoElements when | 
| 3274     // LayoutObject::isChildAllowed on our parent returns false for the | 3274     // LayoutObject::isChildAllowed on our parent returns false for the | 
| 3275     // PseudoElement's layoutObject for each style recalc. | 3275     // PseudoElement's layoutObject for each style recalc. | 
| 3276     if (!layoutObject() || | 3276     if (!layoutObject() || !pseudoElementLayoutObjectIsNeeded( | 
| 3277         !pseudoElementLayoutObjectIsNeeded( | 3277                                pseudoStyle(PseudoStyleRequest(pseudoId)))) | 
| 3278             layoutObject()->getCachedPseudoStyle(pseudoId))) |  | 
| 3279       elementRareData()->setPseudoElement(pseudoId, nullptr); | 3278       elementRareData()->setPseudoElement(pseudoId, nullptr); | 
| 3280   } else if (pseudoId == PseudoIdFirstLetter && element && | 3279   } else if (pseudoId == PseudoIdFirstLetter && element && | 
| 3281              change >= UpdatePseudoElements && | 3280              change >= UpdatePseudoElements && | 
| 3282              !FirstLetterPseudoElement::firstLetterTextLayoutObject(*element)) { | 3281              !FirstLetterPseudoElement::firstLetterTextLayoutObject(*element)) { | 
| 3283     // This can happen if we change to a float, for example. We need to cleanup | 3282     // This can happen if we change to a float, for example. We need to cleanup | 
| 3284     // the first-letter pseudoElement and then fix the text of the original | 3283     // the first-letter pseudoElement and then fix the text of the original | 
| 3285     // remaining text layoutObject.  This can be seen in Test 7 of | 3284     // remaining text layoutObject.  This can be seen in Test 7 of | 
| 3286     // fast/css/first-letter-removed-added.html | 3285     // fast/css/first-letter-removed-added.html | 
| 3287     elementRareData()->setPseudoElement(pseudoId, nullptr); | 3286     elementRareData()->setPseudoElement(pseudoId, nullptr); | 
| 3288   } else if (change >= UpdatePseudoElements) { | 3287   } else if (change >= UpdatePseudoElements) { | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3337 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const { | 3336 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const { | 
| 3338   return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr; | 3337   return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr; | 
| 3339 } | 3338 } | 
| 3340 | 3339 | 
| 3341 LayoutObject* Element::pseudoElementLayoutObject(PseudoId pseudoId) const { | 3340 LayoutObject* Element::pseudoElementLayoutObject(PseudoId pseudoId) const { | 
| 3342   if (PseudoElement* element = pseudoElement(pseudoId)) | 3341   if (PseudoElement* element = pseudoElement(pseudoId)) | 
| 3343     return element->layoutObject(); | 3342     return element->layoutObject(); | 
| 3344   return nullptr; | 3343   return nullptr; | 
| 3345 } | 3344 } | 
| 3346 | 3345 | 
|  | 3346 ComputedStyle* Element::pseudoStyle(const PseudoStyleRequest& request, | 
|  | 3347                                     const ComputedStyle* parentStyle) { | 
|  | 3348   ComputedStyle* style = mutableComputedStyle(); | 
|  | 3349 | 
|  | 3350   if (!style || (request.pseudoId < FirstInternalPseudoId && | 
|  | 3351                  !style->hasPseudoStyle(request.pseudoId))) { | 
|  | 3352     return nullptr; | 
|  | 3353   } | 
|  | 3354 | 
|  | 3355   if (ComputedStyle* cached = style->getCachedPseudoStyle(request.pseudoId)) | 
|  | 3356     return cached; | 
|  | 3357 | 
|  | 3358   RefPtr<ComputedStyle> result = getUncachedPseudoStyle(request, parentStyle); | 
|  | 3359   if (result) | 
|  | 3360     return style->addCachedPseudoStyle(result.release()); | 
|  | 3361   return nullptr; | 
|  | 3362 } | 
|  | 3363 | 
|  | 3364 PassRefPtr<ComputedStyle> Element::getUncachedPseudoStyle( | 
|  | 3365     const PseudoStyleRequest& request, | 
|  | 3366     const ComputedStyle* parentStyle) { | 
|  | 3367   const ComputedStyle* style = computedStyle(); | 
|  | 3368   const bool isBeforeOrAfter = | 
|  | 3369       request.pseudoId == PseudoIdBefore || request.pseudoId == PseudoIdAfter; | 
|  | 3370 | 
|  | 3371   DCHECK(style); | 
|  | 3372   DCHECK(!parentStyle || !isBeforeOrAfter); | 
|  | 3373 | 
|  | 3374   if (isBeforeOrAfter) { | 
|  | 3375     LayoutObject* parentLayoutObject = layoutObject(); | 
|  | 3376     if (!parentLayoutObject && hasDisplayContentsStyle()) { | 
|  | 3377       parentLayoutObject = | 
|  | 3378           LayoutTreeBuilderTraversal::parentLayoutObject(*this); | 
|  | 3379     } | 
|  | 3380     if (!parentLayoutObject) | 
|  | 3381       return nullptr; | 
|  | 3382     return document().ensureStyleResolver().pseudoStyleForElement( | 
|  | 3383         this, request, style, parentLayoutObject->style()); | 
|  | 3384   } | 
|  | 3385 | 
|  | 3386   if (!layoutObject()) | 
|  | 3387     return nullptr; | 
|  | 3388 | 
|  | 3389   if (!parentStyle) | 
|  | 3390     parentStyle = style; | 
|  | 3391 | 
|  | 3392   if (request.pseudoId == PseudoIdFirstLineInherited) { | 
|  | 3393     RefPtr<ComputedStyle> result = | 
|  | 3394         document().ensureStyleResolver().styleForElement( | 
|  | 3395             this, parentStyle, parentStyle, DisallowStyleSharing); | 
|  | 3396     result->setStyleType(PseudoIdFirstLineInherited); | 
|  | 3397     return result.release(); | 
|  | 3398   } | 
|  | 3399 | 
|  | 3400   return document().ensureStyleResolver().pseudoStyleForElement( | 
|  | 3401       this, request, parentStyle, parentStyle); | 
|  | 3402 } | 
|  | 3403 | 
| 3347 bool Element::matches(const AtomicString& selectors, | 3404 bool Element::matches(const AtomicString& selectors, | 
| 3348                       ExceptionState& exceptionState) { | 3405                       ExceptionState& exceptionState) { | 
| 3349   SelectorQuery* selectorQuery = document().selectorQueryCache().add( | 3406   SelectorQuery* selectorQuery = document().selectorQueryCache().add( | 
| 3350       selectors, document(), exceptionState); | 3407       selectors, document(), exceptionState); | 
| 3351   if (!selectorQuery) | 3408   if (!selectorQuery) | 
| 3352     return false; | 3409     return false; | 
| 3353   return selectorQuery->matches(*this); | 3410   return selectorQuery->matches(*this); | 
| 3354 } | 3411 } | 
| 3355 | 3412 | 
| 3356 Element* Element::closest(const AtomicString& selectors, | 3413 Element* Element::closest(const AtomicString& selectors, | 
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4171 } | 4228 } | 
| 4172 | 4229 | 
| 4173 DEFINE_TRACE_WRAPPERS(Element) { | 4230 DEFINE_TRACE_WRAPPERS(Element) { | 
| 4174   if (hasRareData()) { | 4231   if (hasRareData()) { | 
| 4175     visitor->traceWrappers(elementRareData()); | 4232     visitor->traceWrappers(elementRareData()); | 
| 4176   } | 4233   } | 
| 4177   ContainerNode::traceWrappers(visitor); | 4234   ContainerNode::traceWrappers(visitor); | 
| 4178 } | 4235 } | 
| 4179 | 4236 | 
| 4180 }  // namespace blink | 4237 }  // namespace blink | 
| OLD | NEW | 
|---|