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 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1341 | 1344 |
1342 // When a shadow root exists, it does the work of attaching the children. | 1345 // When a shadow root exists, it does the work of attaching the children. |
1343 if (ElementShadow* shadow = this->shadow()) | 1346 if (ElementShadow* shadow = this->shadow()) |
1344 shadow->attach(context); | 1347 shadow->attach(context); |
1345 | 1348 |
1346 ContainerNode::attach(context); | 1349 ContainerNode::attach(context); |
1347 | 1350 |
1348 createPseudoElementIfNeeded(AFTER); | 1351 createPseudoElementIfNeeded(AFTER); |
1349 createPseudoElementIfNeeded(BACKDROP); | 1352 createPseudoElementIfNeeded(BACKDROP); |
1350 | 1353 |
1354 // We create the first-letter element after the :before, :after and | |
1355 // children are attached because the first letter text could come | |
1356 // from any of them. | |
1357 createPseudoElementIfNeeded(FIRST_LETTER); | |
1358 | |
1351 if (hasRareData() && !renderer()) { | 1359 if (hasRareData() && !renderer()) { |
1352 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimat ions()) { | 1360 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimat ions()) { |
1353 activeAnimations->cssAnimations().cancel(); | 1361 activeAnimations->cssAnimations().cancel(); |
1354 activeAnimations->setAnimationStyleChange(false); | 1362 activeAnimations->setAnimationStyleChange(false); |
1355 } | 1363 } |
1356 } | 1364 } |
1357 } | 1365 } |
1358 | 1366 |
1359 void Element::detach(const AttachContext& context) | 1367 void Element::detach(const AttachContext& context) |
1360 { | 1368 { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { | 1508 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { |
1501 if (root->shouldCallRecalcStyle(change)) | 1509 if (root->shouldCallRecalcStyle(change)) |
1502 root->recalcStyle(change); | 1510 root->recalcStyle(change); |
1503 } | 1511 } |
1504 recalcChildStyle(change); | 1512 recalcChildStyle(change); |
1505 } | 1513 } |
1506 | 1514 |
1507 updatePseudoElement(AFTER, change); | 1515 updatePseudoElement(AFTER, change); |
1508 updatePseudoElement(BACKDROP, change); | 1516 updatePseudoElement(BACKDROP, change); |
1509 | 1517 |
1518 // If our children have changed then we need to force the first-letter | |
1519 // checks as we don't know if they effected the first letter or not. | |
1520 // This can be seen when a child transitions from floating to | |
1521 // non-floating we have to take it into account for the first letter. | |
1522 updatePseudoElement(FIRST_LETTER, childNeedsStyleRecalc() ? Force : chan ge); | |
1523 | |
1510 clearChildNeedsStyleRecalc(); | 1524 clearChildNeedsStyleRecalc(); |
1511 } | 1525 } |
1512 | 1526 |
1513 if (hasCustomStyleCallbacks()) | 1527 if (hasCustomStyleCallbacks()) |
1514 didRecalcStyle(change); | 1528 didRecalcStyle(change); |
1515 | 1529 |
1516 if (change == Reattach) | 1530 if (change == Reattach) |
1517 reattachWhitespaceSiblings(nextTextSibling); | 1531 reattachWhitespaceSiblings(nextTextSibling); |
1518 } | 1532 } |
1519 | 1533 |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2481 // attributes while we are iterating. | 2495 // attributes while we are iterating. |
2482 WillBeHeapVector<RefPtrWillBeMember<Attr> > attrNodesCopy(*attrNodes); | 2496 WillBeHeapVector<RefPtrWillBeMember<Attr> > attrNodesCopy(*attrNodes); |
2483 for (size_t i = 0; i < attrNodesCopy.size(); ++i) | 2497 for (size_t i = 0; i < attrNodesCopy.size(); ++i) |
2484 attrNodesCopy[i]->normalize(); | 2498 attrNodesCopy[i]->normalize(); |
2485 } | 2499 } |
2486 | 2500 |
2487 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) | 2501 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) |
2488 { | 2502 { |
2489 ASSERT(!needsStyleRecalc()); | 2503 ASSERT(!needsStyleRecalc()); |
2490 PseudoElement* element = pseudoElement(pseudoId); | 2504 PseudoElement* element = pseudoElement(pseudoId); |
2505 | |
2491 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { | 2506 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { |
2507 // If we're updating first letter, and the current first letter renderer | |
2508 // is not the same as the one we're currently using we need to re-create | |
2509 // the first letter renderer. | |
2510 if (pseudoId == FIRST_LETTER) { | |
2511 RenderObject* remainingTextRenderer = FirstLetterPseudoElement::firs tLetterTextRenderer(*element); | |
2512 if (!remainingTextRenderer || remainingTextRenderer != toFirstLetter PseudoElement(element)->remainingTextRenderer() | |
Julien - ping for review
2014/10/06 17:47:32
Wouldn't |element| be an arbitrary Element and not
Julien - ping for review
2014/10/06 20:11:45
Actually nevermind, I thought |element| == this.
dsinclair
2014/10/07 19:36:20
Right, it has to be otherwise something has gone v
| |
2513 || toFirstLetterPseudoElement(element)->isStale()) { | |
2514 // We have to clear out the old first letter here because when i t is | |
2515 // disposed it will set the original text back on the remaining text | |
2516 // renderer. If we dispose after creating the new one we will ge t | |
2517 // incorrect results due to setting the first letter back. | |
2518 elementRareData()->setPseudoElement(FIRST_LETTER, nullptr); | |
2519 createPseudoElementIfNeeded(pseudoId); | |
esprehn
2014/10/07 00:17:40
You should just reattach the first letter PseudoEl
dsinclair
2014/10/07 19:36:20
Done.
I was using FirstLetterPseudoElement::dispo
| |
2520 return; | |
2521 } | |
2522 } | |
2492 | 2523 |
2493 // 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 |
2494 // computes a new style. | 2525 // computes a new style. |
2495 if (element->needsStyleRecalc()) | 2526 if (element->needsStyleRecalc()) |
2496 renderer()->style()->removeCachedPseudoStyle(pseudoId); | 2527 renderer()->style()->removeCachedPseudoStyle(pseudoId); |
2497 | 2528 |
2498 // 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 |
2499 // a style recalc we should Force one on the pseudo. | 2530 // a style recalc we should Force one on the pseudo. |
2500 // FIXME: We should figure out the right text sibling to pass. | 2531 // FIXME: We should figure out the right text sibling to pass. |
2501 element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 2532 element->recalcStyle(change == UpdatePseudoElements ? Force : change); |
2502 | 2533 |
2503 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed | 2534 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed |
2504 // is false, otherwise we could continously create and destroy PseudoEle ments | 2535 // is false, otherwise we could continuously create and destroy PseudoEl ements |
2505 // when RenderObject::isChildAllowed on our parent returns false for the | 2536 // when RenderObject::isChildAllowed on our parent returns false for the |
2506 // PseudoElement's renderer for each style recalc. | 2537 // PseudoElement's renderer for each style recalc. |
2507 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) | 2538 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) |
2508 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2539 elementRareData()->setPseudoElement(pseudoId, nullptr); |
2509 } else if (change >= UpdatePseudoElements) { | 2540 } else if (change >= UpdatePseudoElements) { |
2510 createPseudoElementIfNeeded(pseudoId); | 2541 // We have a first-letter pseudoElement, but we no longer should have on e. |
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 if (pseudoId == FIRST_LETTER && element && !FirstLetterPseudoElement::fi rstLetterTextRenderer(*element)) | |
2547 elementRareData()->setPseudoElement(pseudoId, nullptr); | |
esprehn
2014/10/07 00:17:40
This is in the wrong side of the branch. You shoul
dsinclair
2014/10/07 19:36:20
Done? I wasn't quite sure what you meant with the
| |
2548 else | |
2549 createPseudoElementIfNeeded(pseudoId); | |
2511 } | 2550 } |
2512 } | 2551 } |
2513 | 2552 |
2514 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) | 2553 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) |
2515 { | 2554 { |
2516 if (isPseudoElement()) | 2555 if (isPseudoElement()) |
2517 return; | 2556 return; |
2518 | 2557 |
2519 // Document::ensureStyleResolver is not inlined and shows up on profiles, av oid it here. | 2558 // Document::ensureStyleResolver is not inlined and shows up on profiles, av oid it here. |
2520 StyleEngine* engine = document().styleEngine(); | 2559 StyleEngine* engine = document().styleEngine(); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3264 return wrapper; | 3303 return wrapper; |
3265 | 3304 |
3266 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); | 3305 CustomElementBinding* binding = perContextData->customElementBinding(customE lementDefinition()); |
3267 | 3306 |
3268 wrapper->SetPrototype(binding->prototype()); | 3307 wrapper->SetPrototype(binding->prototype()); |
3269 | 3308 |
3270 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType , wrapper, isolate); | 3309 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType , wrapper, isolate); |
3271 } | 3310 } |
3272 | 3311 |
3273 } // namespace blink | 3312 } // namespace blink |
OLD | NEW |