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 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 570 |
571 #if !ENABLE(OILPAN) | 571 #if !ENABLE(OILPAN) |
572 void Document::dispose() | 572 void Document::dispose() |
573 { | 573 { |
574 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); | 574 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); |
575 | 575 |
576 // We must make sure not to be retaining any of our children through | 576 // We must make sure not to be retaining any of our children through |
577 // these extra pointers or we will create a reference cycle. | 577 // these extra pointers or we will create a reference cycle. |
578 m_docType = nullptr; | 578 m_docType = nullptr; |
579 m_focusedElement = nullptr; | 579 m_focusedElement = nullptr; |
| 580 m_sequentialFocusNavigationStartingPoint = nullptr; |
580 m_hoverNode = nullptr; | 581 m_hoverNode = nullptr; |
581 m_activeHoverElement = nullptr; | 582 m_activeHoverElement = nullptr; |
582 m_titleElement = nullptr; | 583 m_titleElement = nullptr; |
583 m_documentElement = nullptr; | 584 m_documentElement = nullptr; |
584 m_contextFeatures = ContextFeatures::defaultSwitch(); | 585 m_contextFeatures = ContextFeatures::defaultSwitch(); |
585 m_userActionElements.documentDidRemoveLastRef(); | 586 m_userActionElements.documentDidRemoveLastRef(); |
586 m_associatedFormControls.clear(); | 587 m_associatedFormControls.clear(); |
587 | 588 |
588 m_scriptRunner->dispose(); | 589 m_scriptRunner->dispose(); |
589 detachParser(); | 590 detachParser(); |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 m_hoverNode = nullptr; | 2238 m_hoverNode = nullptr; |
2238 m_activeHoverElement = nullptr; | 2239 m_activeHoverElement = nullptr; |
2239 m_autofocusElement = nullptr; | 2240 m_autofocusElement = nullptr; |
2240 | 2241 |
2241 if (m_focusedElement.get()) { | 2242 if (m_focusedElement.get()) { |
2242 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; | 2243 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; |
2243 m_focusedElement = nullptr; | 2244 m_focusedElement = nullptr; |
2244 if (frameHost()) | 2245 if (frameHost()) |
2245 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get
(), nullptr); | 2246 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get
(), nullptr); |
2246 } | 2247 } |
| 2248 m_sequentialFocusNavigationStartingPoint = nullptr; |
2247 | 2249 |
2248 if (this == &axObjectCacheOwner()) | 2250 if (this == &axObjectCacheOwner()) |
2249 clearAXObjectCache(); | 2251 clearAXObjectCache(); |
2250 | 2252 |
2251 m_layoutView = nullptr; | 2253 m_layoutView = nullptr; |
2252 ContainerNode::detach(context); | 2254 ContainerNode::detach(context); |
2253 | 2255 |
2254 if (this != &axObjectCacheOwner()) { | 2256 if (this != &axObjectCacheOwner()) { |
2255 if (AXObjectCache* cache = existingAXObjectCache()) { | 2257 if (AXObjectCache* cache = existingAXObjectCache()) { |
2256 // Documents that are not a root document use the AXObjectCache in | 2258 // Documents that are not a root document use the AXObjectCache in |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3625 if (newFocusedElement) | 3627 if (newFocusedElement) |
3626 updateLayoutTreeForNodeIfNeeded(newFocusedElement.get()); | 3628 updateLayoutTreeForNodeIfNeeded(newFocusedElement.get()); |
3627 if (newFocusedElement && newFocusedElement->isFocusable()) { | 3629 if (newFocusedElement && newFocusedElement->isFocusable()) { |
3628 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { | 3630 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { |
3629 // delegate blocks focus change | 3631 // delegate blocks focus change |
3630 focusChangeBlocked = true; | 3632 focusChangeBlocked = true; |
3631 goto SetFocusedElementDone; | 3633 goto SetFocusedElementDone; |
3632 } | 3634 } |
3633 // Set focus on the new node | 3635 // Set focus on the new node |
3634 m_focusedElement = newFocusedElement; | 3636 m_focusedElement = newFocusedElement; |
| 3637 setSequentialFocusNavigationStartingPoint(m_focusedElement.get()); |
3635 | 3638 |
3636 m_focusedElement->setFocus(true); | 3639 m_focusedElement->setFocus(true); |
3637 // Element::setFocus for frames can dispatch events. | 3640 // Element::setFocus for frames can dispatch events. |
3638 if (m_focusedElement != newFocusedElement) { | 3641 if (m_focusedElement != newFocusedElement) { |
3639 focusChangeBlocked = true; | 3642 focusChangeBlocked = true; |
3640 goto SetFocusedElementDone; | 3643 goto SetFocusedElementDone; |
3641 } | 3644 } |
3642 cancelFocusAppearanceUpdate(); | 3645 cancelFocusAppearanceUpdate(); |
3643 m_focusedElement->updateFocusAppearance(params.selectionBehavior); | 3646 m_focusedElement->updateFocusAppearance(params.selectionBehavior); |
3644 | 3647 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3708 if (LocalFrame* frame = this->frame()) | 3711 if (LocalFrame* frame = this->frame()) |
3709 frame->selection().didChangeFocus(); | 3712 frame->selection().didChangeFocus(); |
3710 return !focusChangeBlocked; | 3713 return !focusChangeBlocked; |
3711 } | 3714 } |
3712 | 3715 |
3713 void Document::clearFocusedElement() | 3716 void Document::clearFocusedElement() |
3714 { | 3717 { |
3715 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, WebFo
cusTypeNone, nullptr)); | 3718 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, WebFo
cusTypeNone, nullptr)); |
3716 } | 3719 } |
3717 | 3720 |
| 3721 void Document::setSequentialFocusNavigationStartingPoint(Node* node) |
| 3722 { |
| 3723 if (!node) { |
| 3724 m_sequentialFocusNavigationStartingPoint = nullptr; |
| 3725 return; |
| 3726 } |
| 3727 ASSERT(node->document() == this); |
| 3728 if (!m_sequentialFocusNavigationStartingPoint) |
| 3729 m_sequentialFocusNavigationStartingPoint = Range::create(*this); |
| 3730 m_sequentialFocusNavigationStartingPoint->selectNodeContents(node->isElement
Node() ? node : node->parentOrShadowHostElement(), ASSERT_NO_EXCEPTION); |
| 3731 } |
| 3732 |
| 3733 Element* Document::sequentialFocusNavigationStartingPoint(WebFocusType type) con
st |
| 3734 { |
| 3735 if (m_focusedElement) |
| 3736 return m_focusedElement.get(); |
| 3737 if (!m_sequentialFocusNavigationStartingPoint) |
| 3738 return nullptr; |
| 3739 if (!m_sequentialFocusNavigationStartingPoint->collapsed()) { |
| 3740 Node* node = m_sequentialFocusNavigationStartingPoint->startContainer(); |
| 3741 ASSERT(node == m_sequentialFocusNavigationStartingPoint->endContainer())
; |
| 3742 return node->isElementNode() ? toElement(node) : node->parentOrShadowHos
tElement(); |
| 3743 } |
| 3744 |
| 3745 // Range::selectNodeContents didn't select contents because the element had |
| 3746 // no children. |
| 3747 if (m_sequentialFocusNavigationStartingPoint->startContainer()->isElementNod
e() |
| 3748 && !m_sequentialFocusNavigationStartingPoint->startContainer()->hasChild
ren() |
| 3749 && m_sequentialFocusNavigationStartingPoint->startOffset() == 0) |
| 3750 return toElement(m_sequentialFocusNavigationStartingPoint->startContaine
r()); |
| 3751 |
| 3752 // A node selected by Range::selectNodeContents was removed from the |
| 3753 // document tree. |
| 3754 if (Node* nextNode = m_sequentialFocusNavigationStartingPoint->firstNode())
{ |
| 3755 if (type == WebFocusTypeForward) |
| 3756 return ElementTraversal::previous(*nextNode); |
| 3757 if (nextNode->isElementNode()) |
| 3758 return toElement(nextNode); |
| 3759 return ElementTraversal::next(*nextNode); |
| 3760 } |
| 3761 return nullptr; |
| 3762 } |
| 3763 |
3718 void Document::setCSSTarget(Element* newTarget) | 3764 void Document::setCSSTarget(Element* newTarget) |
3719 { | 3765 { |
3720 if (m_cssTarget) | 3766 if (m_cssTarget) |
3721 m_cssTarget->pseudoStateChanged(CSSSelector::PseudoTarget); | 3767 m_cssTarget->pseudoStateChanged(CSSSelector::PseudoTarget); |
3722 m_cssTarget = newTarget; | 3768 m_cssTarget = newTarget; |
3723 if (m_cssTarget) | 3769 if (m_cssTarget) |
3724 m_cssTarget->pseudoStateChanged(CSSSelector::PseudoTarget); | 3770 m_cssTarget->pseudoStateChanged(CSSSelector::PseudoTarget); |
3725 } | 3771 } |
3726 | 3772 |
3727 void Document::registerNodeList(const LiveNodeListBase* list) | 3773 void Document::registerNodeList(const LiveNodeListBase* list) |
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5873 } | 5919 } |
5874 | 5920 |
5875 DEFINE_TRACE(Document) | 5921 DEFINE_TRACE(Document) |
5876 { | 5922 { |
5877 #if ENABLE(OILPAN) | 5923 #if ENABLE(OILPAN) |
5878 visitor->trace(m_importsController); | 5924 visitor->trace(m_importsController); |
5879 visitor->trace(m_docType); | 5925 visitor->trace(m_docType); |
5880 visitor->trace(m_implementation); | 5926 visitor->trace(m_implementation); |
5881 visitor->trace(m_autofocusElement); | 5927 visitor->trace(m_autofocusElement); |
5882 visitor->trace(m_focusedElement); | 5928 visitor->trace(m_focusedElement); |
| 5929 visitor->trace(m_sequentialFocusNavigationStartingPoint); |
5883 visitor->trace(m_hoverNode); | 5930 visitor->trace(m_hoverNode); |
5884 visitor->trace(m_activeHoverElement); | 5931 visitor->trace(m_activeHoverElement); |
5885 visitor->trace(m_documentElement); | 5932 visitor->trace(m_documentElement); |
5886 visitor->trace(m_titleElement); | 5933 visitor->trace(m_titleElement); |
5887 visitor->trace(m_axObjectCache); | 5934 visitor->trace(m_axObjectCache); |
5888 visitor->trace(m_markers); | 5935 visitor->trace(m_markers); |
5889 visitor->trace(m_cssTarget); | 5936 visitor->trace(m_cssTarget); |
5890 visitor->trace(m_currentScriptStack); | 5937 visitor->trace(m_currentScriptStack); |
5891 visitor->trace(m_scriptRunner); | 5938 visitor->trace(m_scriptRunner); |
5892 visitor->trace(m_listsInvalidatedAtDocument); | 5939 visitor->trace(m_listsInvalidatedAtDocument); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5945 #ifndef NDEBUG | 5992 #ifndef NDEBUG |
5946 using namespace blink; | 5993 using namespace blink; |
5947 void showLiveDocumentInstances() | 5994 void showLiveDocumentInstances() |
5948 { | 5995 { |
5949 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5996 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5950 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5997 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5951 for (Document* document : set) | 5998 for (Document* document : set) |
5952 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5999 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5953 } | 6000 } |
5954 #endif | 6001 #endif |
OLD | NEW |