Chromium Code Reviews| 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. All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #include "core/animation/DocumentTimeline.h" | 37 #include "core/animation/DocumentTimeline.h" |
| 38 #include "core/animation/css/CSSAnimations.h" | 38 #include "core/animation/css/CSSAnimations.h" |
| 39 #include "core/css/CSSParser.h" | 39 #include "core/css/CSSParser.h" |
| 40 #include "core/css/CSSStyleSheet.h" | 40 #include "core/css/CSSStyleSheet.h" |
| 41 #include "core/css/CSSValuePool.h" | 41 #include "core/css/CSSValuePool.h" |
| 42 #include "core/css/PropertySetCSSStyleDeclaration.h" | 42 #include "core/css/PropertySetCSSStyleDeclaration.h" |
| 43 #include "core/css/StylePropertySet.h" | 43 #include "core/css/StylePropertySet.h" |
| 44 #include "core/css/resolver/StyleResolver.h" | 44 #include "core/css/resolver/StyleResolver.h" |
| 45 #include "core/dom/Attr.h" | 45 #include "core/dom/Attr.h" |
| 46 #include "core/dom/Attribute.h" | 46 #include "core/dom/Attribute.h" |
| 47 #include "core/dom/CSSSelectorWatch.h" | |
| 47 #include "core/dom/ClientRect.h" | 48 #include "core/dom/ClientRect.h" |
| 48 #include "core/dom/ClientRectList.h" | 49 #include "core/dom/ClientRectList.h" |
| 49 #include "core/dom/CustomElement.h" | 50 #include "core/dom/CustomElement.h" |
| 50 #include "core/dom/CustomElementRegistrationContext.h" | 51 #include "core/dom/CustomElementRegistrationContext.h" |
| 51 #include "core/dom/DatasetDOMStringMap.h" | 52 #include "core/dom/DatasetDOMStringMap.h" |
| 52 #include "core/dom/Document.h" | 53 #include "core/dom/Document.h" |
| 53 #include "core/dom/DocumentSharedObjectPool.h" | 54 #include "core/dom/DocumentSharedObjectPool.h" |
| 54 #include "core/dom/ElementRareData.h" | 55 #include "core/dom/ElementRareData.h" |
| 55 #include "core/dom/EventDispatcher.h" | 56 #include "core/dom/EventDispatcher.h" |
| 56 #include "core/dom/ExceptionCode.h" | 57 #include "core/dom/ExceptionCode.h" |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1319 if (hasRareData() && styleChangeType() == LazyAttachStyleChange) { | 1320 if (hasRareData() && styleChangeType() == LazyAttachStyleChange) { |
| 1320 ElementRareData* data = elementRareData(); | 1321 ElementRareData* data = elementRareData(); |
| 1321 data->clearComputedStyle(); | 1322 data->clearComputedStyle(); |
| 1322 data->resetDynamicRestyleObservations(); | 1323 data->resetDynamicRestyleObservations(); |
| 1323 if (!context.resolvedStyle) | 1324 if (!context.resolvedStyle) |
| 1324 data->resetStyleState(); | 1325 data->resetStyleState(); |
| 1325 } | 1326 } |
| 1326 | 1327 |
| 1327 NodeRenderingContext(this, context.resolvedStyle).createRendererForElementIf Needed(); | 1328 NodeRenderingContext(this, context.resolvedStyle).createRendererForElementIf Needed(); |
| 1328 | 1329 |
| 1330 updateCallbackSelectors(Add); | |
| 1331 | |
| 1329 createPseudoElementIfNeeded(BEFORE); | 1332 createPseudoElementIfNeeded(BEFORE); |
| 1330 | 1333 |
| 1331 // When a shadow root exists, it does the work of attaching the children. | 1334 // When a shadow root exists, it does the work of attaching the children. |
| 1332 if (ElementShadow* shadow = this->shadow()) { | 1335 if (ElementShadow* shadow = this->shadow()) { |
| 1333 parentPusher.push(); | 1336 parentPusher.push(); |
| 1334 shadow->attach(context); | 1337 shadow->attach(context); |
| 1335 } else if (firstChild()) | 1338 } else if (firstChild()) |
| 1336 parentPusher.push(); | 1339 parentPusher.push(); |
| 1337 | 1340 |
| 1338 ContainerNode::attach(context); | 1341 ContainerNode::attach(context); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1360 { | 1363 { |
| 1361 if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document ()->renderView()) | 1364 if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document ()->renderView()) |
| 1362 document()->renderView()->flowThreadController()->unregisterNamedFlowCon tentNode(this); | 1365 document()->renderView()->flowThreadController()->unregisterNamedFlowCon tentNode(this); |
| 1363 } | 1366 } |
| 1364 | 1367 |
| 1365 void Element::detach(const AttachContext& context) | 1368 void Element::detach(const AttachContext& context) |
| 1366 { | 1369 { |
| 1367 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; | 1370 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; |
| 1368 unregisterNamedFlowContentNode(); | 1371 unregisterNamedFlowContentNode(); |
| 1369 cancelFocusAppearanceUpdate(); | 1372 cancelFocusAppearanceUpdate(); |
| 1373 updateCallbackSelectors(Remove); | |
| 1370 if (hasRareData()) { | 1374 if (hasRareData()) { |
| 1371 ElementRareData* data = elementRareData(); | 1375 ElementRareData* data = elementRareData(); |
| 1372 data->setPseudoElement(BEFORE, 0); | 1376 data->setPseudoElement(BEFORE, 0); |
| 1373 data->setPseudoElement(AFTER, 0); | 1377 data->setPseudoElement(AFTER, 0); |
| 1374 data->setPseudoElement(BACKDROP, 0); | 1378 data->setPseudoElement(BACKDROP, 0); |
| 1375 data->clearComputedStyle(); | 1379 data->clearComputedStyle(); |
| 1376 data->resetDynamicRestyleObservations(); | 1380 data->resetDynamicRestyleObservations(); |
| 1377 data->setIsInsideRegion(false); | 1381 data->setIsInsideRegion(false); |
| 1378 | 1382 |
| 1379 // Only clear the style state if we're not going to reuse the style from recalcStyle. | 1383 // Only clear the style state if we're not going to reuse the style from recalcStyle. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 return document()->styleResolver()->styleForElement(this); | 1447 return document()->styleResolver()->styleForElement(this); |
| 1444 } | 1448 } |
| 1445 | 1449 |
| 1446 bool Element::recalcStyle(StyleChange change) | 1450 bool Element::recalcStyle(StyleChange change) |
| 1447 { | 1451 { |
| 1448 ASSERT(document()->inStyleRecalc()); | 1452 ASSERT(document()->inStyleRecalc()); |
| 1449 | 1453 |
| 1450 if (hasCustomStyleCallbacks()) | 1454 if (hasCustomStyleCallbacks()) |
| 1451 willRecalcStyle(change); | 1455 willRecalcStyle(change); |
| 1452 | 1456 |
| 1457 class SelectorWatchUpdater { | |
|
esprehn
2013/09/04 06:08:28
Don't put classes inside methods. This needs to be
Jeffrey Yasskin
2013/09/12 22:09:59
It's no longer necessary. :)
| |
| 1458 public: | |
| 1459 SelectorWatchUpdater(Element* element) | |
| 1460 : m_element(element) | |
| 1461 { | |
| 1462 m_element->updateCallbackSelectors(Remove); | |
|
esprehn
2013/09/04 06:08:28
This is not right, why are you removing and adding
Jeffrey Yasskin
2013/09/12 22:09:59
Yep, using recalcOwnStyle() cleaned this up a lot.
| |
| 1463 } | |
| 1464 | |
| 1465 ~SelectorWatchUpdater() | |
| 1466 { | |
| 1467 m_element->updateCallbackSelectors(Add); | |
| 1468 } | |
| 1469 | |
| 1470 private: | |
| 1471 Element* const m_element; | |
| 1472 }; | |
| 1473 SelectorWatchUpdater watchUpdater(this); | |
| 1474 | |
| 1453 if (hasRareData() && (change > NoChange || needsStyleRecalc())) { | 1475 if (hasRareData() && (change > NoChange || needsStyleRecalc())) { |
| 1454 ElementRareData* data = elementRareData(); | 1476 ElementRareData* data = elementRareData(); |
| 1455 data->resetStyleState(); | 1477 data->resetStyleState(); |
| 1456 data->clearComputedStyle(); | 1478 data->clearComputedStyle(); |
| 1457 } | 1479 } |
| 1458 | 1480 |
| 1459 // Active InsertionPoints have no renderers so they never need to go through a recalc. | 1481 // Active InsertionPoints have no renderers so they never need to go through a recalc. |
| 1460 if ((change >= Inherit || needsStyleRecalc()) && parentRenderStyle() && !isA ctiveInsertionPoint(this)) | 1482 if ((change >= Inherit || needsStyleRecalc()) && parentRenderStyle() && !isA ctiveInsertionPoint(this)) |
| 1461 change = recalcOwnStyle(change); | 1483 change = recalcOwnStyle(change); |
| 1462 | 1484 |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2428 } | 2450 } |
| 2429 | 2451 |
| 2430 void Element::cancelFocusAppearanceUpdate() | 2452 void Element::cancelFocusAppearanceUpdate() |
| 2431 { | 2453 { |
| 2432 if (hasRareData()) | 2454 if (hasRareData()) |
| 2433 elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); | 2455 elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); |
| 2434 if (document()->focusedElement() == this) | 2456 if (document()->focusedElement() == this) |
| 2435 document()->cancelFocusAppearanceUpdate(); | 2457 document()->cancelFocusAppearanceUpdate(); |
| 2436 } | 2458 } |
| 2437 | 2459 |
| 2460 void Element::updateCallbackSelectors(AddOrRemove addOrRemove) | |
| 2461 { | |
| 2462 if (!renderStyle()) | |
| 2463 return; | |
|
esprehn
2013/09/04 06:08:28
Don't call RenderStyle repeatedly, you want to cal
Jeffrey Yasskin
2013/09/12 22:09:59
Obsolete. :)
| |
| 2464 const Vector<String>& callbackSelectors = renderStyle()->callbackSelectors() ; | |
| 2465 if (callbackSelectors.isEmpty()) | |
|
esprehn
2013/09/04 06:08:28
The check should be outside the function call sinc
Jeffrey Yasskin
2013/09/12 22:09:59
Done.
| |
| 2466 return; | |
| 2467 | |
| 2468 CSSSelectorWatch* selectorWatch = CSSSelectorWatch::from(document()); | |
| 2469 switch (addOrRemove) { | |
| 2470 case Add: { | |
| 2471 ElementRareData* rareData = ensureElementRareData(); | |
| 2472 if (!rareData->renderStyleWatchedSelectorsRepresentedInSelectorWatch()) { | |
| 2473 selectorWatch->addSelectorMatches(callbackSelectors); | |
| 2474 rareData->setRenderStyleWatchedSelectorsRepresentedInSelectorWatch(t rue); | |
| 2475 } | |
| 2476 break; | |
|
esprehn
2013/09/04 06:08:28
These should be two separate methods and get rid o
Jeffrey Yasskin
2013/09/12 22:09:59
Refactored away.
| |
| 2477 } | |
| 2478 case Remove: | |
| 2479 if (hasRareData() && elementRareData()->renderStyleWatchedSelectorsRepre sentedInSelectorWatch()) { | |
| 2480 selectorWatch->removeSelectorMatches(callbackSelectors); | |
| 2481 elementRareData()->setRenderStyleWatchedSelectorsRepresentedInSelect orWatch(false); | |
| 2482 } | |
| 2483 break; | |
| 2484 } | |
| 2485 } | |
| 2486 | |
| 2438 void Element::normalizeAttributes() | 2487 void Element::normalizeAttributes() |
| 2439 { | 2488 { |
| 2440 if (!hasAttributes()) | 2489 if (!hasAttributes()) |
| 2441 return; | 2490 return; |
| 2442 for (unsigned i = 0; i < attributeCount(); ++i) { | 2491 for (unsigned i = 0; i < attributeCount(); ++i) { |
| 2443 if (RefPtr<Attr> attr = attrIfExists(attributeItem(i)->name())) | 2492 if (RefPtr<Attr> attr = attrIfExists(attributeItem(i)->name())) |
| 2444 attr->normalize(); | 2493 attr->normalize(); |
| 2445 } | 2494 } |
| 2446 } | 2495 } |
| 2447 | 2496 |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3634 return 0; | 3683 return 0; |
| 3635 } | 3684 } |
| 3636 | 3685 |
| 3637 Attribute* UniqueElementData::attributeItem(unsigned index) | 3686 Attribute* UniqueElementData::attributeItem(unsigned index) |
| 3638 { | 3687 { |
| 3639 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); | 3688 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); |
| 3640 return &m_attributeVector.at(index); | 3689 return &m_attributeVector.at(index); |
| 3641 } | 3690 } |
| 3642 | 3691 |
| 3643 } // namespace WebCore | 3692 } // namespace WebCore |
| OLD | NEW |