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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "core/css/resolver/StyleResolverParentScope.h" | 49 #include "core/css/resolver/StyleResolverParentScope.h" |
| 50 #include "core/dom/Attr.h" | 50 #include "core/dom/Attr.h" |
| 51 #include "core/dom/CSSSelectorWatch.h" | 51 #include "core/dom/CSSSelectorWatch.h" |
| 52 #include "core/dom/ClientRect.h" | 52 #include "core/dom/ClientRect.h" |
| 53 #include "core/dom/ClientRectList.h" | 53 #include "core/dom/ClientRectList.h" |
| 54 #include "core/dom/DatasetDOMStringMap.h" | 54 #include "core/dom/DatasetDOMStringMap.h" |
| 55 #include "core/dom/ElementDataCache.h" | 55 #include "core/dom/ElementDataCache.h" |
| 56 #include "core/dom/ElementRareData.h" | 56 #include "core/dom/ElementRareData.h" |
| 57 #include "core/dom/ElementTraversal.h" | 57 #include "core/dom/ElementTraversal.h" |
| 58 #include "core/dom/ExceptionCode.h" | 58 #include "core/dom/ExceptionCode.h" |
| 59 #include "core/dom/FirstLetterPseudoElement.h" | |
| 59 #include "core/dom/Fullscreen.h" | 60 #include "core/dom/Fullscreen.h" |
| 60 #include "core/dom/MutationObserverInterestGroup.h" | 61 #include "core/dom/MutationObserverInterestGroup.h" |
| 61 #include "core/dom/MutationRecord.h" | 62 #include "core/dom/MutationRecord.h" |
| 62 #include "core/dom/NamedNodeMap.h" | 63 #include "core/dom/NamedNodeMap.h" |
| 63 #include "core/dom/NodeRenderStyle.h" | 64 #include "core/dom/NodeRenderStyle.h" |
| 64 #include "core/dom/PresentationAttributeStyle.h" | 65 #include "core/dom/PresentationAttributeStyle.h" |
| 65 #include "core/dom/PseudoElement.h" | 66 #include "core/dom/PseudoElement.h" |
| 66 #include "core/dom/RenderTreeBuilder.h" | 67 #include "core/dom/RenderTreeBuilder.h" |
| 67 #include "core/dom/ScriptableDocumentParser.h" | 68 #include "core/dom/ScriptableDocumentParser.h" |
| 68 #include "core/dom/SelectorQuery.h" | 69 #include "core/dom/SelectorQuery.h" |
| 70 #include "core/dom/StyleChangeReason.h" | |
| 69 #include "core/dom/StyleEngine.h" | 71 #include "core/dom/StyleEngine.h" |
| 70 #include "core/dom/Text.h" | 72 #include "core/dom/Text.h" |
| 71 #include "core/dom/custom/CustomElement.h" | 73 #include "core/dom/custom/CustomElement.h" |
| 72 #include "core/dom/custom/CustomElementRegistrationContext.h" | 74 #include "core/dom/custom/CustomElementRegistrationContext.h" |
| 73 #include "core/dom/shadow/InsertionPoint.h" | 75 #include "core/dom/shadow/InsertionPoint.h" |
| 74 #include "core/dom/shadow/ShadowRoot.h" | 76 #include "core/dom/shadow/ShadowRoot.h" |
| 75 #include "core/editing/FrameSelection.h" | 77 #include "core/editing/FrameSelection.h" |
| 76 #include "core/editing/TextIterator.h" | 78 #include "core/editing/TextIterator.h" |
| 77 #include "core/editing/htmlediting.h" | 79 #include "core/editing/htmlediting.h" |
| 78 #include "core/editing/markup.h" | 80 #include "core/editing/markup.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 96 #include "core/html/HTMLTableRowsCollection.h" | 98 #include "core/html/HTMLTableRowsCollection.h" |
| 97 #include "core/html/HTMLTemplateElement.h" | 99 #include "core/html/HTMLTemplateElement.h" |
| 98 #include "core/html/parser/HTMLParserIdioms.h" | 100 #include "core/html/parser/HTMLParserIdioms.h" |
| 99 #include "core/inspector/InspectorInstrumentation.h" | 101 #include "core/inspector/InspectorInstrumentation.h" |
| 100 #include "core/page/Chrome.h" | 102 #include "core/page/Chrome.h" |
| 101 #include "core/page/ChromeClient.h" | 103 #include "core/page/ChromeClient.h" |
| 102 #include "core/page/FocusController.h" | 104 #include "core/page/FocusController.h" |
| 103 #include "core/page/Page.h" | 105 #include "core/page/Page.h" |
| 104 #include "core/page/PointerLockController.h" | 106 #include "core/page/PointerLockController.h" |
| 105 #include "core/rendering/RenderLayer.h" | 107 #include "core/rendering/RenderLayer.h" |
| 108 #include "core/rendering/RenderTextFragment.h" | |
| 106 #include "core/rendering/RenderView.h" | 109 #include "core/rendering/RenderView.h" |
| 107 #include "core/rendering/compositing/RenderLayerCompositor.h" | 110 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 108 #include "core/svg/SVGDocumentExtensions.h" | 111 #include "core/svg/SVGDocumentExtensions.h" |
| 109 #include "core/svg/SVGElement.h" | 112 #include "core/svg/SVGElement.h" |
| 110 #include "platform/EventDispatchForbiddenScope.h" | 113 #include "platform/EventDispatchForbiddenScope.h" |
| 111 #include "platform/RuntimeEnabledFeatures.h" | 114 #include "platform/RuntimeEnabledFeatures.h" |
| 112 #include "platform/UserGestureIndicator.h" | 115 #include "platform/UserGestureIndicator.h" |
| 113 #include "platform/scroll/ScrollableArea.h" | 116 #include "platform/scroll/ScrollableArea.h" |
| 114 #include "wtf/BitVector.h" | 117 #include "wtf/BitVector.h" |
| 115 #include "wtf/HashFunctions.h" | 118 #include "wtf/HashFunctions.h" |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1339 | 1342 |
| 1340 // When a shadow root exists, it does the work of attaching the children. | 1343 // When a shadow root exists, it does the work of attaching the children. |
| 1341 if (ElementShadow* shadow = this->shadow()) | 1344 if (ElementShadow* shadow = this->shadow()) |
| 1342 shadow->attach(context); | 1345 shadow->attach(context); |
| 1343 | 1346 |
| 1344 ContainerNode::attach(context); | 1347 ContainerNode::attach(context); |
| 1345 | 1348 |
| 1346 createPseudoElementIfNeeded(AFTER); | 1349 createPseudoElementIfNeeded(AFTER); |
| 1347 createPseudoElementIfNeeded(BACKDROP); | 1350 createPseudoElementIfNeeded(BACKDROP); |
| 1348 | 1351 |
| 1352 // We create the first-letter element after the :before, :after and | |
| 1353 // children are attached because the first letter text could come | |
| 1354 // from any of them. | |
| 1355 createPseudoElementIfNeeded(FIRST_LETTER); | |
| 1356 | |
| 1349 if (hasRareData() && !renderer()) { | 1357 if (hasRareData() && !renderer()) { |
| 1350 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimat ions()) { | 1358 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimat ions()) { |
| 1351 activeAnimations->cssAnimations().cancel(); | 1359 activeAnimations->cssAnimations().cancel(); |
| 1352 activeAnimations->setAnimationStyleChange(false); | 1360 activeAnimations->setAnimationStyleChange(false); |
| 1353 } | 1361 } |
| 1354 } | 1362 } |
| 1355 } | 1363 } |
| 1356 | 1364 |
| 1357 void Element::detach(const AttachContext& context) | 1365 void Element::detach(const AttachContext& context) |
| 1358 { | 1366 { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1498 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { | 1506 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { |
| 1499 if (root->shouldCallRecalcStyle(change)) | 1507 if (root->shouldCallRecalcStyle(change)) |
| 1500 root->recalcStyle(change); | 1508 root->recalcStyle(change); |
| 1501 } | 1509 } |
| 1502 recalcChildStyle(change); | 1510 recalcChildStyle(change); |
| 1503 } | 1511 } |
| 1504 | 1512 |
| 1505 updatePseudoElement(AFTER, change); | 1513 updatePseudoElement(AFTER, change); |
| 1506 updatePseudoElement(BACKDROP, change); | 1514 updatePseudoElement(BACKDROP, change); |
| 1507 | 1515 |
| 1516 // If our children have changed then we need to force the first-letter | |
| 1517 // checks as we don't know if they effected the first letter or not. | |
| 1518 // This can be seen when a child transitions from floating to | |
| 1519 // non-floating we have to take it into account for the first letter. | |
| 1520 updatePseudoElement(FIRST_LETTER, childNeedsStyleRecalc() ? Force : chan ge); | |
| 1521 | |
| 1508 clearChildNeedsStyleRecalc(); | 1522 clearChildNeedsStyleRecalc(); |
| 1509 } | 1523 } |
| 1510 | 1524 |
| 1511 if (hasCustomStyleCallbacks()) | 1525 if (hasCustomStyleCallbacks()) |
| 1512 didRecalcStyle(change); | 1526 didRecalcStyle(change); |
| 1513 | 1527 |
| 1514 if (change == Reattach) | 1528 if (change == Reattach) |
| 1515 reattachWhitespaceSiblings(nextTextSibling); | 1529 reattachWhitespaceSiblings(nextTextSibling); |
| 1516 } | 1530 } |
| 1517 | 1531 |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2479 // attributes while we are iterating. | 2493 // attributes while we are iterating. |
| 2480 WillBeHeapVector<RefPtrWillBeMember<Attr> > attrNodesCopy(*attrNodes); | 2494 WillBeHeapVector<RefPtrWillBeMember<Attr> > attrNodesCopy(*attrNodes); |
| 2481 for (size_t i = 0; i < attrNodesCopy.size(); ++i) | 2495 for (size_t i = 0; i < attrNodesCopy.size(); ++i) |
| 2482 attrNodesCopy[i]->normalize(); | 2496 attrNodesCopy[i]->normalize(); |
| 2483 } | 2497 } |
| 2484 | 2498 |
| 2485 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) | 2499 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) |
| 2486 { | 2500 { |
| 2487 ASSERT(!needsStyleRecalc()); | 2501 ASSERT(!needsStyleRecalc()); |
| 2488 PseudoElement* element = pseudoElement(pseudoId); | 2502 PseudoElement* element = pseudoElement(pseudoId); |
| 2503 | |
| 2489 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { | 2504 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { |
| 2505 // If we're updating first letter, and the current first letter renderer | |
| 2506 // is not the same as the one we're currently using we need to re-create | |
| 2507 // the first letter renderer. | |
| 2508 if (pseudoId == FIRST_LETTER) { | |
| 2509 RenderObject* remainingTextRenderer = FirstLetterPseudoElement::firs tLetterTextRenderer(*element); | |
| 2510 if (!remainingTextRenderer || remainingTextRenderer != toFirstLetter PseudoElement(element)->remainingTextRenderer() | |
|
esprehn
2014/10/11 04:46:19
This feels like it should be a separate private me
dsinclair
2014/10/14 14:31:27
Done.
| |
| 2511 || toFirstLetterPseudoElement(element)->needsUpdate()) { | |
| 2512 // We have to clear out the old first letter here because when i t is | |
| 2513 // disposed it will set the original text back on the remaining text | |
| 2514 // renderer. If we dispose after creating the new one we will ge t | |
| 2515 // incorrect results due to setting the first letter back. | |
| 2516 if (remainingTextRenderer) | |
| 2517 element->reattach(); | |
| 2518 else | |
| 2519 elementRareData()->setPseudoElement(FIRST_LETTER, nullptr); | |
| 2520 return; | |
| 2521 } | |
| 2522 } | |
| 2490 | 2523 |
| 2491 // Need to clear the cached style if the PseudoElement wants a recalc so it | 2524 // Need to clear the cached style if the PseudoElement wants a recalc so it |
| 2492 // computes a new style. | 2525 // computes a new style. |
| 2493 if (element->needsStyleRecalc()) | 2526 if (element->needsStyleRecalc()) |
| 2494 renderer()->style()->removeCachedPseudoStyle(pseudoId); | 2527 renderer()->style()->removeCachedPseudoStyle(pseudoId); |
| 2495 | 2528 |
| 2496 // PseudoElement styles hang off their parent element's style so if we n eeded | 2529 // PseudoElement styles hang off their parent element's style so if we n eeded |
| 2497 // a style recalc we should Force one on the pseudo. | 2530 // a style recalc we should Force one on the pseudo. |
| 2498 // FIXME: We should figure out the right text sibling to pass. | 2531 // FIXME: We should figure out the right text sibling to pass. |
| 2499 element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 2532 element->recalcStyle(change == UpdatePseudoElements ? Force : change); |
| 2500 | 2533 |
| 2501 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed | 2534 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed |
| 2502 // is false, otherwise we could continously create and destroy PseudoEle ments | 2535 // is false, otherwise we could continuously create and destroy PseudoEl ements |
| 2503 // when RenderObject::isChildAllowed on our parent returns false for the | 2536 // when RenderObject::isChildAllowed on our parent returns false for the |
| 2504 // PseudoElement's renderer for each style recalc. | 2537 // PseudoElement's renderer for each style recalc. |
| 2505 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) | 2538 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) |
| 2506 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2539 elementRareData()->setPseudoElement(pseudoId, nullptr); |
| 2540 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) { | |
| 2541 // We have a first-letter pseudoElement, but we no longer should have on e. | |
|
esprehn
2014/10/11 04:46:19
This comment doesn't seem like it adds value.
dsinclair
2014/10/14 14:31:27
Done. (Assuming you meant just the first line.) I
| |
| 2542 // This can happen if we change to a float, for example. We need to clea nup the | |
| 2543 // first-letter pseudoElement and then fix the text of the original rema ining | |
| 2544 // text renderer. | |
| 2545 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l | |
| 2546 elementRareData()->setPseudoElement(pseudoId, nullptr); | |
| 2507 } else if (change >= UpdatePseudoElements) { | 2547 } else if (change >= UpdatePseudoElements) { |
| 2508 createPseudoElementIfNeeded(pseudoId); | 2548 createPseudoElementIfNeeded(pseudoId); |
| 2509 } | 2549 } |
| 2510 } | 2550 } |
| 2511 | 2551 |
| 2512 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) | 2552 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) |
| 2513 { | 2553 { |
| 2514 if (isPseudoElement()) | 2554 if (isPseudoElement()) |
| 2515 return; | 2555 return; |
| 2516 | 2556 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3262 return wrapper; | 3302 return wrapper; |
| 3263 | 3303 |
| 3264 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); | 3304 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); |
| 3265 | 3305 |
| 3266 wrapper->SetPrototype(binding->prototype()); | 3306 wrapper->SetPrototype(binding->prototype()); |
| 3267 | 3307 |
| 3268 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType , wrapper, isolate); | 3308 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType , wrapper, isolate); |
| 3269 } | 3309 } |
| 3270 | 3310 |
| 3271 } // namespace blink | 3311 } // namespace blink |
| OLD | NEW |