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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 ContainerNode::attach(context); | 1337 ContainerNode::attach(context); |
1338 | 1338 |
1339 createPseudoElementIfNeeded(AFTER); | 1339 createPseudoElementIfNeeded(AFTER); |
1340 createPseudoElementIfNeeded(BACKDROP); | 1340 createPseudoElementIfNeeded(BACKDROP); |
1341 | 1341 |
1342 // We create the first-letter element after the :before, :after and | 1342 // We create the first-letter element after the :before, :after and |
1343 // children are attached because the first letter text could come | 1343 // children are attached because the first letter text could come |
1344 // from any of them. | 1344 // from any of them. |
1345 createPseudoElementIfNeeded(FIRST_LETTER); | 1345 createPseudoElementIfNeeded(FIRST_LETTER); |
1346 | 1346 |
1347 // The marker has to come after the other content, including the BEFORE pseu do | |
1348 // element so make sure we create it last. | |
1349 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) | |
1350 createPseudoElementIfNeeded(MARKER); | |
1351 | |
1347 if (hasRareData() && !renderer()) { | 1352 if (hasRareData() && !renderer()) { |
1348 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimat ions()) { | 1353 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimat ions()) { |
1349 activeAnimations->cssAnimations().cancel(); | 1354 activeAnimations->cssAnimations().cancel(); |
1350 activeAnimations->setAnimationStyleChange(false); | 1355 activeAnimations->setAnimationStyleChange(false); |
1351 } | 1356 } |
1352 } | 1357 } |
1358 | |
1359 // If our parent has a marker pseudo element we need to inform them that we | |
1360 // were attached as they may need to move the list marker. | |
Julien - ping for review
2014/12/05 19:44:03
Move the list maker? Usually moving renderers is a
dsinclair
2015/01/23 20:46:36
Yea, it sucks but we still have to do it. It's pos
| |
1361 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled() && parentNode() && parentNode()->isElementNode()) { | |
1362 if (PseudoElement* pseudoElement = toElement(parentNode())->pseudoElemen t(MARKER)) { | |
1363 bool neededRecalc = pseudoElement->needsStyleRecalc(); | |
1364 pseudoElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReas onForTracing::create(StyleChangeReason::PseudoClass)); | |
1365 | |
1366 // If style recalc is currently executing, and we have already been recalc'd | |
1367 // we need to tell our parent to do the recalc again because we need to | |
1368 // re-initialize the first letter state. This can happen for things like | |
1369 // RenderQuote where quotes processed later can effect things alread y styled. | |
1370 if (document().inStyleRecalc() && !neededRecalc) | |
1371 pseudoElement->recalcStyle(UpdatePseudoElements); | |
1372 } | |
1373 } | |
1353 } | 1374 } |
1354 | 1375 |
1355 void Element::detach(const AttachContext& context) | 1376 void Element::detach(const AttachContext& context) |
1356 { | 1377 { |
1357 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1378 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
1358 cancelFocusAppearanceUpdate(); | 1379 cancelFocusAppearanceUpdate(); |
1359 removeCallbackSelectors(); | 1380 removeCallbackSelectors(); |
1360 if (hasRareData()) { | 1381 if (hasRareData()) { |
1361 ElementRareData* data = elementRareData(); | 1382 ElementRareData* data = elementRareData(); |
1362 data->clearPseudoElements(); | 1383 data->clearPseudoElements(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1499 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { | 1520 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { |
1500 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { | 1521 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { |
1501 if (root->shouldCallRecalcStyle(change)) | 1522 if (root->shouldCallRecalcStyle(change)) |
1502 root->recalcStyle(change); | 1523 root->recalcStyle(change); |
1503 } | 1524 } |
1504 recalcChildStyle(change); | 1525 recalcChildStyle(change); |
1505 } | 1526 } |
1506 | 1527 |
1507 updatePseudoElement(AFTER, change); | 1528 updatePseudoElement(AFTER, change); |
1508 updatePseudoElement(BACKDROP, change); | 1529 updatePseudoElement(BACKDROP, change); |
1530 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) | |
1531 updatePseudoElement(MARKER, change); | |
1509 | 1532 |
1510 // If our children have changed then we need to force the first-letter | 1533 // If our children have changed then we need to force the first-letter |
1511 // checks as we don't know if they effected the first letter or not. | 1534 // checks as we don't know if they effected the first letter or not. |
1512 // This can be seen when a child transitions from floating to | 1535 // This can be seen when a child transitions from floating to |
1513 // non-floating we have to take it into account for the first letter. | 1536 // non-floating we have to take it into account for the first letter. |
1514 updatePseudoElement(FIRST_LETTER, childNeedsStyleRecalc() ? Force : chan ge); | 1537 updatePseudoElement(FIRST_LETTER, childNeedsStyleRecalc() ? Force : chan ge); |
1515 | 1538 |
1516 clearChildNeedsStyleRecalc(); | 1539 clearChildNeedsStyleRecalc(); |
1517 } | 1540 } |
1518 | 1541 |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2506 | 2529 |
2507 // PseudoElement styles hang off their parent element's style so if we n eeded | 2530 // PseudoElement styles hang off their parent element's style so if we n eeded |
2508 // a style recalc we should Force one on the pseudo. | 2531 // a style recalc we should Force one on the pseudo. |
2509 // FIXME: We should figure out the right text sibling to pass. | 2532 // FIXME: We should figure out the right text sibling to pass. |
2510 element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 2533 element->recalcStyle(change == UpdatePseudoElements ? Force : change); |
2511 | 2534 |
2512 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed | 2535 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed |
2513 // is false, otherwise we could continuously create and destroy PseudoEl ements | 2536 // is false, otherwise we could continuously create and destroy PseudoEl ements |
2514 // when RenderObject::isChildAllowed on our parent returns false for the | 2537 // when RenderObject::isChildAllowed on our parent returns false for the |
2515 // PseudoElement's renderer for each style recalc. | 2538 // PseudoElement's renderer for each style recalc. |
2516 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) | 2539 if (!renderer() || |
2540 (!pseudoElementRendererIsNeeded(renderer()->getCachedPseudoStyle(pse udoId)) && (pseudoId == MARKER && renderer()->style()->display() != LIST_ITEM))) | |
2517 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2541 elementRareData()->setPseudoElement(pseudoId, nullptr); |
2518 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) { | 2542 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) { |
2519 // This can happen if we change to a float, for example. We need to clea nup the | 2543 // This can happen if we change to a float, for example. We need to clea nup the |
2520 // first-letter pseudoElement and then fix the text of the original rema ining | 2544 // first-letter pseudoElement and then fix the text of the original rema ining |
2521 // text renderer. | 2545 // text renderer. |
2522 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l | 2546 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l |
2523 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2547 elementRareData()->setPseudoElement(pseudoId, nullptr); |
2524 } else if (change >= UpdatePseudoElements) { | 2548 } else if (change >= UpdatePseudoElements) { |
2525 createPseudoElementIfNeeded(pseudoId); | 2549 createPseudoElementIfNeeded(pseudoId); |
2526 } | 2550 } |
(...skipping 15 matching lines...) Expand all Loading... | |
2542 element->reattach(); | 2566 element->reattach(); |
2543 else | 2567 else |
2544 elementRareData()->setPseudoElement(FIRST_LETTER, nullptr); | 2568 elementRareData()->setPseudoElement(FIRST_LETTER, nullptr); |
2545 return true; | 2569 return true; |
2546 } | 2570 } |
2547 return false; | 2571 return false; |
2548 } | 2572 } |
2549 | 2573 |
2550 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) | 2574 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) |
2551 { | 2575 { |
2552 if (isPseudoElement()) | 2576 if (isPseudoElement() && (pseudoId != MARKER || isMarkerPseudoElement())) |
2553 return; | 2577 return; |
2554 | 2578 |
2555 // Document::ensureStyleResolver is not inlined and shows up on profiles, av oid it here. | 2579 // Document::ensureStyleResolver is not inlined and shows up on profiles, av oid it here. |
2556 StyleEngine* engine = document().styleEngine(); | 2580 StyleEngine* engine = document().styleEngine(); |
2557 RefPtrWillBeRawPtr<PseudoElement> element = engine->ensureResolver().createP seudoElementIfNeeded(*this, pseudoId); | 2581 RefPtrWillBeRawPtr<PseudoElement> element = engine->ensureResolver().createP seudoElementIfNeeded(*this, pseudoId); |
2558 if (!element) | 2582 if (!element) |
2559 return; | 2583 return; |
2560 | |
2561 if (pseudoId == BACKDROP) | 2584 if (pseudoId == BACKDROP) |
2562 document().addToTopLayer(element.get(), this); | 2585 document().addToTopLayer(element.get(), this); |
2586 | |
2563 element->insertedInto(this); | 2587 element->insertedInto(this); |
2564 element->attach(); | 2588 element->attach(); |
2565 | 2589 |
2566 InspectorInstrumentation::pseudoElementCreated(element.get()); | 2590 InspectorInstrumentation::pseudoElementCreated(element.get()); |
2567 | 2591 |
2568 ensureElementRareData().setPseudoElement(pseudoId, element.release()); | 2592 ensureElementRareData().setPseudoElement(pseudoId, element.release()); |
2569 } | 2593 } |
2570 | 2594 |
2571 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const | 2595 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const |
2572 { | 2596 { |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3306 return wrapper; | 3330 return wrapper; |
3307 | 3331 |
3308 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); | 3332 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); |
3309 | 3333 |
3310 wrapper->SetPrototype(binding->prototype()); | 3334 wrapper->SetPrototype(binding->prototype()); |
3311 | 3335 |
3312 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperType, wrapper); | 3336 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperType, wrapper); |
3313 } | 3337 } |
3314 | 3338 |
3315 } // namespace blink | 3339 } // namespace blink |
OLD | NEW |