| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "core/dom/CSSSelectorWatch.h" | 52 #include "core/dom/CSSSelectorWatch.h" |
| 53 #include "core/dom/ClientRect.h" | 53 #include "core/dom/ClientRect.h" |
| 54 #include "core/dom/ClientRectList.h" | 54 #include "core/dom/ClientRectList.h" |
| 55 #include "core/dom/DatasetDOMStringMap.h" | 55 #include "core/dom/DatasetDOMStringMap.h" |
| 56 #include "core/dom/ElementDataCache.h" | 56 #include "core/dom/ElementDataCache.h" |
| 57 #include "core/dom/ElementRareData.h" | 57 #include "core/dom/ElementRareData.h" |
| 58 #include "core/dom/ElementTraversal.h" | 58 #include "core/dom/ElementTraversal.h" |
| 59 #include "core/dom/ExceptionCode.h" | 59 #include "core/dom/ExceptionCode.h" |
| 60 #include "core/dom/FirstLetterPseudoElement.h" | 60 #include "core/dom/FirstLetterPseudoElement.h" |
| 61 #include "core/dom/Fullscreen.h" | 61 #include "core/dom/Fullscreen.h" |
| 62 #include "core/dom/IntersectionObserver.h" |
| 63 #include "core/dom/IntersectionObserverRegistry.h" |
| 62 #include "core/dom/LayoutTreeBuilder.h" | 64 #include "core/dom/LayoutTreeBuilder.h" |
| 63 #include "core/dom/MutationObserverInterestGroup.h" | 65 #include "core/dom/MutationObserverInterestGroup.h" |
| 64 #include "core/dom/MutationRecord.h" | 66 #include "core/dom/MutationRecord.h" |
| 65 #include "core/dom/NamedNodeMap.h" | 67 #include "core/dom/NamedNodeMap.h" |
| 66 #include "core/dom/NodeComputedStyle.h" | 68 #include "core/dom/NodeComputedStyle.h" |
| 67 #include "core/dom/PresentationAttributeStyle.h" | 69 #include "core/dom/PresentationAttributeStyle.h" |
| 68 #include "core/dom/PseudoElement.h" | 70 #include "core/dom/PseudoElement.h" |
| 69 #include "core/dom/ScriptableDocumentParser.h" | 71 #include "core/dom/ScriptableDocumentParser.h" |
| 70 #include "core/dom/SelectorQuery.h" | 72 #include "core/dom/SelectorQuery.h" |
| 71 #include "core/dom/StyleChangeReason.h" | 73 #include "core/dom/StyleChangeReason.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 98 #include "core/html/HTMLElement.h" | 100 #include "core/html/HTMLElement.h" |
| 99 #include "core/html/HTMLFormControlsCollection.h" | 101 #include "core/html/HTMLFormControlsCollection.h" |
| 100 #include "core/html/HTMLFrameElementBase.h" | 102 #include "core/html/HTMLFrameElementBase.h" |
| 101 #include "core/html/HTMLFrameOwnerElement.h" | 103 #include "core/html/HTMLFrameOwnerElement.h" |
| 102 #include "core/html/HTMLOptionsCollection.h" | 104 #include "core/html/HTMLOptionsCollection.h" |
| 103 #include "core/html/HTMLPlugInElement.h" | 105 #include "core/html/HTMLPlugInElement.h" |
| 104 #include "core/html/HTMLTableRowsCollection.h" | 106 #include "core/html/HTMLTableRowsCollection.h" |
| 105 #include "core/html/HTMLTemplateElement.h" | 107 #include "core/html/HTMLTemplateElement.h" |
| 106 #include "core/html/parser/HTMLParserIdioms.h" | 108 #include "core/html/parser/HTMLParserIdioms.h" |
| 107 #include "core/inspector/InspectorInstrumentation.h" | 109 #include "core/inspector/InspectorInstrumentation.h" |
| 110 #include "core/layout/LayoutInline.h" |
| 111 #include "core/layout/LayoutPart.h" |
| 108 #include "core/layout/LayoutTextFragment.h" | 112 #include "core/layout/LayoutTextFragment.h" |
| 109 #include "core/layout/LayoutView.h" | 113 #include "core/layout/LayoutView.h" |
| 110 #include "core/loader/DocumentLoader.h" | 114 #include "core/loader/DocumentLoader.h" |
| 111 #include "core/page/ChromeClient.h" | 115 #include "core/page/ChromeClient.h" |
| 112 #include "core/page/FocusController.h" | 116 #include "core/page/FocusController.h" |
| 113 #include "core/page/Page.h" | 117 #include "core/page/Page.h" |
| 114 #include "core/page/PointerLockController.h" | 118 #include "core/page/PointerLockController.h" |
| 115 #include "core/page/SpatialNavigation.h" | 119 #include "core/page/SpatialNavigation.h" |
| 116 #include "core/page/scrolling/ScrollCustomizationCallbacks.h" | 120 #include "core/page/scrolling/ScrollCustomizationCallbacks.h" |
| 117 #include "core/page/scrolling/ScrollState.h" | 121 #include "core/page/scrolling/ScrollState.h" |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 ContainerNode::insertedInto(insertionPoint); | 1446 ContainerNode::insertedInto(insertionPoint); |
| 1443 | 1447 |
| 1444 if (containsFullScreenElement() && parentElement() && !parentElement()->cont
ainsFullScreenElement()) | 1448 if (containsFullScreenElement() && parentElement() && !parentElement()->cont
ainsFullScreenElement()) |
| 1445 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); | 1449 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); |
| 1446 | 1450 |
| 1447 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); | 1451 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); |
| 1448 | 1452 |
| 1449 if (!insertionPoint->isInTreeScope()) | 1453 if (!insertionPoint->isInTreeScope()) |
| 1450 return InsertionDone; | 1454 return InsertionDone; |
| 1451 | 1455 |
| 1452 if (hasRareData()) | 1456 if (hasRareData()) { |
| 1453 elementRareData()->clearClassListValueForQuirksMode(); | 1457 ElementRareData* rareData = elementRareData(); |
| 1458 rareData->clearClassListValueForQuirksMode(); |
| 1459 if (rareData->hasIntersectionObserver()) { |
| 1460 IntersectionObserverRegistry* registry = document().intersectionObse
rverRegistry(); |
| 1461 for (auto& observer: rareData->intersectionObservers()) { |
| 1462 registry->addTrackedObserver(*observer); |
| 1463 observer->setActive(true); |
| 1464 } |
| 1465 } |
| 1466 if (rareData->hasIntersectionObservation()) { |
| 1467 for (auto& observation: rareData->intersectionObservations()) |
| 1468 observation->setActive(observation->observer()->isDescendantOfRo
ot(this)); |
| 1469 } |
| 1470 } |
| 1454 | 1471 |
| 1455 if (isUpgradedCustomElement() && inDocument()) | 1472 if (isUpgradedCustomElement() && inDocument()) |
| 1456 CustomElement::didAttach(this, document()); | 1473 CustomElement::didAttach(this, document()); |
| 1457 | 1474 |
| 1458 TreeScope& scope = insertionPoint->treeScope(); | 1475 TreeScope& scope = insertionPoint->treeScope(); |
| 1459 if (scope != treeScope()) | 1476 if (scope != treeScope()) |
| 1460 return InsertionDone; | 1477 return InsertionDone; |
| 1461 | 1478 |
| 1462 const AtomicString& idValue = getIdAttribute(); | 1479 const AtomicString& idValue = getIdAttribute(); |
| 1463 if (!idValue.isNull()) | 1480 if (!idValue.isNull()) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 | 1538 |
| 1522 clearElementFlag(IsInCanvasSubtree); | 1539 clearElementFlag(IsInCanvasSubtree); |
| 1523 | 1540 |
| 1524 if (hasRareData()) { | 1541 if (hasRareData()) { |
| 1525 ElementRareData* data = elementRareData(); | 1542 ElementRareData* data = elementRareData(); |
| 1526 | 1543 |
| 1527 data->clearRestyleFlags(); | 1544 data->clearRestyleFlags(); |
| 1528 | 1545 |
| 1529 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1546 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
| 1530 elementAnimations->cssAnimations().cancel(); | 1547 elementAnimations->cssAnimations().cancel(); |
| 1548 |
| 1549 if (data->hasIntersectionObserver()) { |
| 1550 document().intersectionObserverRegistry()->removeTrackedObserversFor
Root(this); |
| 1551 data->deactivateAllIntersectionObservers(); |
| 1552 } |
| 1553 data->deactivateAllIntersectionObservations(); |
| 1531 } | 1554 } |
| 1532 } | 1555 } |
| 1533 | 1556 |
| 1534 void Element::attach(const AttachContext& context) | 1557 void Element::attach(const AttachContext& context) |
| 1535 { | 1558 { |
| 1536 ASSERT(document().inStyleRecalc()); | 1559 ASSERT(document().inStyleRecalc()); |
| 1537 | 1560 |
| 1538 // We've already been through detach when doing an attach, but we might | 1561 // We've already been through detach when doing an attach, but we might |
| 1539 // need to clear any state that's been added since then. | 1562 // need to clear any state that's been added since then. |
| 1540 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { | 1563 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { |
| (...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3554 return false; | 3577 return false; |
| 3555 if (isHTMLElement() && toHTMLElement(this)->hasDirectionAuto()) | 3578 if (isHTMLElement() && toHTMLElement(this)->hasDirectionAuto()) |
| 3556 return false; | 3579 return false; |
| 3557 if (hasAnimations()) | 3580 if (hasAnimations()) |
| 3558 return false; | 3581 return false; |
| 3559 if (Fullscreen::isActiveFullScreenElement(*this)) | 3582 if (Fullscreen::isActiveFullScreenElement(*this)) |
| 3560 return false; | 3583 return false; |
| 3561 return true; | 3584 return true; |
| 3562 } | 3585 } |
| 3563 | 3586 |
| 3587 WeakPtrWillBeRawPtr<Element> Element::createWeakPtr() |
| 3588 { |
| 3589 #if ENABLE(OILPAN) |
| 3590 return this; |
| 3591 #else |
| 3592 return ensureElementRareData().createWeakPtr(this); |
| 3593 #endif |
| 3594 } |
| 3595 |
| 3596 void Element::addIntersectionObservation(IntersectionObservation& observation) |
| 3597 { |
| 3598 ensureElementRareData().intersectionObservations().add(&observation); |
| 3599 } |
| 3600 |
| 3601 void Element::removeIntersectionObservation(IntersectionObservation& observation
) |
| 3602 { |
| 3603 if (!hasRareData() || !elementRareData()->hasIntersectionObservation()) |
| 3604 return; |
| 3605 elementRareData()->intersectionObservations().remove(&observation); |
| 3606 } |
| 3607 |
| 3608 bool Element::computeIntersection(Element* root, LayoutRect& targetRect, LayoutR
ect& rootRect, LayoutRect& intersectionRect) |
| 3609 { |
| 3610 // TODO: support zero-size targetRect |
| 3611 intersectionRect = targetRect = toLayoutBoxModelObject(layoutObject())->visu
alOverflowRect(); |
| 3612 if (!computeElementIntersection(root, targetRect, intersectionRect)) |
| 3613 return false; |
| 3614 |
| 3615 LayoutObject* rootLayoutObject = root->layoutObject(); |
| 3616 rootRect = toLayoutBoxModelObject(rootLayoutObject)->visualOverflowRect(); |
| 3617 |
| 3618 // Adjust all rects from root coordinates to document coordinates. |
| 3619 rootRect = LayoutRect(rootLayoutObject->localToAbsoluteQuad(FloatQuad(FloatR
ect(rootRect))).boundingBox()); |
| 3620 targetRect = LayoutRect(rootLayoutObject->localToAbsoluteQuad(FloatQuad(Floa
tRect(targetRect))).boundingBox()); |
| 3621 intersectionRect = LayoutRect(rootLayoutObject->localToAbsoluteQuad(FloatQua
d(FloatRect(intersectionRect))).boundingBox()); |
| 3622 |
| 3623 return true; |
| 3624 } |
| 3625 |
| 3626 bool Element::computeElementIntersection(Element* root, LayoutRect& targetRect,
LayoutRect& intersectionRect) |
| 3627 { |
| 3628 // TODO: mapRectToPaintInvalidationBacking probably doesn't do exactly the c
lipping we want, |
| 3629 // and it doesn't support rootMargin at all. |
| 3630 // TODO: Support SVG |
| 3631 if (root == this) |
| 3632 return true; |
| 3633 Element* target = this; |
| 3634 while (&target->document() != &root->document()) { |
| 3635 target = target->computeFrameIntersection(targetRect, intersectionRect); |
| 3636 if (!target) |
| 3637 return false; |
| 3638 // TODO: adjust for border, padding, scrollbars, writing mode. |
| 3639 } |
| 3640 ASSERT(target->isDescendantOf(root)); |
| 3641 |
| 3642 bool rootIsDocumentElement = (root == root->document().documentElement()); |
| 3643 LayoutObject* rootLayoutObject = rootIsDocumentElement ? root->document().la
youtView() : root->layoutObject(); |
| 3644 if (!rootLayoutObject->isBoxModelObject()) |
| 3645 return false; |
| 3646 target->layoutObject()->mapRectToPaintInvalidationBacking(toLayoutBoxModelOb
ject(rootLayoutObject), intersectionRect, nullptr); |
| 3647 targetRect = LayoutRect(target->layoutObject()->localToContainerQuad(FloatQu
ad(FloatRect(targetRect)), toLayoutBoxModelObject(rootLayoutObject)).boundingBox
()); |
| 3648 if (rootIsDocumentElement) |
| 3649 root->computeFrameIntersection(targetRect, intersectionRect); |
| 3650 |
| 3651 return true; |
| 3652 } |
| 3653 |
| 3654 Element* Element::computeFrameIntersection(LayoutRect& targetRect, LayoutRect& i
ntersectionRect) |
| 3655 { |
| 3656 if (!computeElementIntersection(document().documentElement(), targetRect, in
tersectionRect)) |
| 3657 return nullptr; |
| 3658 FrameView* frameView = document().view(); |
| 3659 ASSERT(frameView); |
| 3660 |
| 3661 // Until root layer scrolling is finished, we need to clip to the visible co
ntent area of the FrameView. |
| 3662 intersectionRect.moveBy(LayoutPoint(-frameView->scrollPosition())); |
| 3663 LayoutRect frameClipRect(LayoutPoint(), LayoutSize(frameView->visibleConten
tSize())); |
| 3664 intersectionRect.intersect(frameClipRect); |
| 3665 |
| 3666 LocalFrame* frame = document().frame(); |
| 3667 ASSERT(frame); |
| 3668 LayoutObject* frameOwner = frame->ownerLayoutObject(); |
| 3669 if (!frameOwner) |
| 3670 return nullptr; |
| 3671 return toElement(frameOwner->node()); |
| 3672 } |
| 3673 |
| 3564 DEFINE_TRACE(Element) | 3674 DEFINE_TRACE(Element) |
| 3565 { | 3675 { |
| 3566 #if ENABLE(OILPAN) | 3676 #if ENABLE(OILPAN) |
| 3567 if (hasRareData()) | 3677 if (hasRareData()) |
| 3568 visitor->trace(elementRareData()); | 3678 visitor->trace(elementRareData()); |
| 3569 visitor->trace(m_elementData); | 3679 visitor->trace(m_elementData); |
| 3570 #endif | 3680 #endif |
| 3571 ContainerNode::trace(visitor); | 3681 ContainerNode::trace(visitor); |
| 3572 } | 3682 } |
| 3573 | 3683 |
| 3574 } // namespace blink | 3684 } // namespace blink |
| OLD | NEW |