| 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/FirstLetterHelper.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))) { |
| 2490 | 2505 |
| 2506 // If we're updating first letter, and the current first letter renderer |
| 2507 // is not the same as the one we're currently using we need to re-create |
| 2508 // the first letter renderer. |
| 2509 if (pseudoId == FIRST_LETTER && FirstLetterHelper::firstLetterTextRender
er(*element) != element->remainingTextRenderer()) { |
| 2510 elementRareData()->setPseudoElement(pseudoId, nullptr); |
| 2511 createPseudoElementIfNeeded(pseudoId); |
| 2512 return; |
| 2513 } |
| 2514 |
| 2491 // Need to clear the cached style if the PseudoElement wants a recalc so
it | 2515 // Need to clear the cached style if the PseudoElement wants a recalc so
it |
| 2492 // computes a new style. | 2516 // computes a new style. |
| 2493 if (element->needsStyleRecalc()) | 2517 if (element->needsStyleRecalc()) |
| 2494 renderer()->style()->removeCachedPseudoStyle(pseudoId); | 2518 renderer()->style()->removeCachedPseudoStyle(pseudoId); |
| 2495 | 2519 |
| 2496 // PseudoElement styles hang off their parent element's style so if we n
eeded | 2520 // 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. | 2521 // a style recalc we should Force one on the pseudo. |
| 2498 // FIXME: We should figure out the right text sibling to pass. | 2522 // FIXME: We should figure out the right text sibling to pass. |
| 2499 element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 2523 element->recalcStyle(change == UpdatePseudoElements ? Force : change); |
| 2500 | 2524 |
| 2501 // Wait until our parent is not displayed or pseudoElementRendererIsNeed
ed | 2525 // Wait until our parent is not displayed or pseudoElementRendererIsNeed
ed |
| 2502 // is false, otherwise we could continously create and destroy PseudoEle
ments | 2526 // is false, otherwise we could continuously create and destroy PseudoEl
ements |
| 2503 // when RenderObject::isChildAllowed on our parent returns false for the | 2527 // when RenderObject::isChildAllowed on our parent returns false for the |
| 2504 // PseudoElement's renderer for each style recalc. | 2528 // PseudoElement's renderer for each style recalc. |
| 2505 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP
seudoStyle(pseudoId))) | 2529 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP
seudoStyle(pseudoId))) |
| 2506 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2530 elementRareData()->setPseudoElement(pseudoId, nullptr); |
| 2507 } else if (change >= UpdatePseudoElements) { | 2531 } else if (change >= UpdatePseudoElements) { |
| 2508 createPseudoElementIfNeeded(pseudoId); | 2532 // We have a first-letter pseudoElement, but we no longer should have on
e. |
| 2533 // This can happen if we change to a float, for example. We need to clea
nup the |
| 2534 // first-letter pseudoElement and then fix the text of the original rema
ining |
| 2535 // text renderer. |
| 2536 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm
l |
| 2537 if (pseudoId == FIRST_LETTER && element && !FirstLetterHelper::firstLett
erTextRenderer(*element)) |
| 2538 elementRareData()->setPseudoElement(pseudoId, nullptr); |
| 2539 else |
| 2540 createPseudoElementIfNeeded(pseudoId); |
| 2509 } | 2541 } |
| 2510 } | 2542 } |
| 2511 | 2543 |
| 2512 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) | 2544 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) |
| 2513 { | 2545 { |
| 2514 if (isPseudoElement()) | 2546 if (isPseudoElement()) |
| 2515 return; | 2547 return; |
| 2516 | 2548 |
| 2517 // Document::ensureStyleResolver is not inlined and shows up on profiles, av
oid it here. | 2549 // Document::ensureStyleResolver is not inlined and shows up on profiles, av
oid it here. |
| 2518 StyleEngine* engine = document().styleEngine(); | 2550 StyleEngine* engine = document().styleEngine(); |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3261 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, wrapperType, toScriptWrappableBase(), isolate); | 3293 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, wrapperType, toScriptWrappableBase(), isolate); |
| 3262 if (wrapper.IsEmpty()) | 3294 if (wrapper.IsEmpty()) |
| 3263 return v8::Handle<v8::Object>(); | 3295 return v8::Handle<v8::Object>(); |
| 3264 | 3296 |
| 3265 wrapper->SetPrototype(binding->prototype()); | 3297 wrapper->SetPrototype(binding->prototype()); |
| 3266 | 3298 |
| 3267 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType
, wrapper, isolate); | 3299 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType
, wrapper, isolate); |
| 3268 } | 3300 } |
| 3269 | 3301 |
| 3270 } // namespace blink | 3302 } // namespace blink |
| OLD | NEW |