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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 #include "core/dom/ContextFeatures.h" | 64 #include "core/dom/ContextFeatures.h" |
65 #include "core/dom/DOMImplementation.h" | 65 #include "core/dom/DOMImplementation.h" |
66 #include "core/dom/DocumentFragment.h" | 66 #include "core/dom/DocumentFragment.h" |
67 #include "core/dom/DocumentLifecycleNotifier.h" | 67 #include "core/dom/DocumentLifecycleNotifier.h" |
68 #include "core/dom/DocumentLifecycleObserver.h" | 68 #include "core/dom/DocumentLifecycleObserver.h" |
69 #include "core/dom/DocumentMarkerController.h" | 69 #include "core/dom/DocumentMarkerController.h" |
70 #include "core/dom/DocumentType.h" | 70 #include "core/dom/DocumentType.h" |
71 #include "core/dom/Element.h" | 71 #include "core/dom/Element.h" |
72 #include "core/dom/ElementDataCache.h" | 72 #include "core/dom/ElementDataCache.h" |
73 #include "core/dom/ElementTraversal.h" | 73 #include "core/dom/ElementTraversal.h" |
74 #include "core/dom/EventHandlerRegistry.h" | |
74 #include "core/dom/ExceptionCode.h" | 75 #include "core/dom/ExceptionCode.h" |
75 #include "core/dom/ExecutionContextTask.h" | 76 #include "core/dom/ExecutionContextTask.h" |
76 #include "core/dom/MainThreadTaskRunner.h" | 77 #include "core/dom/MainThreadTaskRunner.h" |
77 #include "core/dom/MutationObserver.h" | 78 #include "core/dom/MutationObserver.h" |
78 #include "core/dom/NodeChildRemovalTracker.h" | 79 #include "core/dom/NodeChildRemovalTracker.h" |
79 #include "core/dom/NodeFilter.h" | 80 #include "core/dom/NodeFilter.h" |
80 #include "core/dom/NodeIterator.h" | 81 #include "core/dom/NodeIterator.h" |
81 #include "core/dom/NodeRareData.h" | 82 #include "core/dom/NodeRareData.h" |
82 #include "core/dom/NodeRenderStyle.h" | 83 #include "core/dom/NodeRenderStyle.h" |
83 #include "core/dom/NodeRenderingTraversal.h" | 84 #include "core/dom/NodeRenderingTraversal.h" |
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2085 m_renderView->setStyle(StyleResolver::styleForDocument(*this)); | 2086 m_renderView->setStyle(StyleResolver::styleForDocument(*this)); |
2086 view()->updateCompositingLayersAfterStyleChange(); | 2087 view()->updateCompositingLayersAfterStyleChange(); |
2087 | 2088 |
2088 ContainerNode::attach(context); | 2089 ContainerNode::attach(context); |
2089 | 2090 |
2090 // FastTextAutosizer can't update render view info while the Document is det ached, so update now in case anything changed. | 2091 // FastTextAutosizer can't update render view info while the Document is det ached, so update now in case anything changed. |
2091 if (FastTextAutosizer* textAutosizer = fastTextAutosizer()) | 2092 if (FastTextAutosizer* textAutosizer = fastTextAutosizer()) |
2092 textAutosizer->updatePageInfo(); | 2093 textAutosizer->updatePageInfo(); |
2093 | 2094 |
2094 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); | 2095 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); |
2096 lifecycleNotifier().notifyDocumentWasAttached(); | |
2095 } | 2097 } |
2096 | 2098 |
2097 void Document::detach(const AttachContext& context) | 2099 void Document::detach(const AttachContext& context) |
2098 { | 2100 { |
2099 ASSERT(isActive()); | 2101 ASSERT(isActive()); |
2100 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); | 2102 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); |
2103 lifecycleNotifier().notifyWillDetachDocument(); | |
abarth-chromium
2014/04/10 21:25:58
Typically folks who want this notification impleme
Sami
2014/04/11 16:46:53
Thanks for the hint. That looks perfect.
| |
2101 | 2104 |
2102 if (page()) | 2105 if (page()) |
2103 page()->documentDetached(this); | 2106 page()->documentDetached(this); |
2104 InspectorInstrumentation::documentDetached(this); | 2107 InspectorInstrumentation::documentDetached(this); |
2105 | 2108 |
2106 if (m_frame->loader().client()->sharedWorkerRepositoryClient()) | 2109 if (m_frame->loader().client()->sharedWorkerRepositoryClient()) |
2107 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this); | 2110 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this); |
2108 | 2111 |
2109 if (this == topDocument()) | 2112 if (this == topDocument()) |
2110 clearAXObjectCache(); | 2113 clearAXObjectCache(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2144 m_activeHoverElement = nullptr; | 2147 m_activeHoverElement = nullptr; |
2145 m_autofocusElement = nullptr; | 2148 m_autofocusElement = nullptr; |
2146 | 2149 |
2147 ContainerNode::detach(context); | 2150 ContainerNode::detach(context); |
2148 | 2151 |
2149 m_styleEngine->didDetach(); | 2152 m_styleEngine->didDetach(); |
2150 | 2153 |
2151 if (renderView) | 2154 if (renderView) |
2152 renderView->destroy(); | 2155 renderView->destroy(); |
2153 | 2156 |
2154 if (Document* parentDoc = parentDocument()) | |
2155 parentDoc->didClearTouchEventHandlers(this); | |
2156 | |
2157 // This is required, as our LocalFrame might delete itself as soon as it det aches | 2157 // This is required, as our LocalFrame might delete itself as soon as it det aches |
2158 // us. However, this violates Node::detach() semantics, as it's never | 2158 // us. However, this violates Node::detach() semantics, as it's never |
2159 // possible to re-attach. Eventually Document::detach() should be renamed, | 2159 // possible to re-attach. Eventually Document::detach() should be renamed, |
2160 // or this setting of the frame to 0 could be made explicit in each of the | 2160 // or this setting of the frame to 0 could be made explicit in each of the |
2161 // callers of Document::detach(). | 2161 // callers of Document::detach(). |
2162 m_frame = 0; | 2162 m_frame = 0; |
2163 | 2163 |
2164 if (m_mediaQueryMatcher) | 2164 if (m_mediaQueryMatcher) |
2165 m_mediaQueryMatcher->documentDestroyed(); | 2165 m_mediaQueryMatcher->documentDestroyed(); |
2166 | 2166 |
(...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5017 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 | 5017 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 |
5018 LocalFrame* frame = window ? window->frame() : this->frame(); | 5018 LocalFrame* frame = window ? window->frame() : this->frame(); |
5019 return Touch::create(frame, target, identifier, screenX, screenY, pageX, pag eY, radiusX, radiusY, rotationAngle, force); | 5019 return Touch::create(frame, target, identifier, screenX, screenY, pageX, pag eY, radiusX, radiusY, rotationAngle, force); |
5020 } | 5020 } |
5021 | 5021 |
5022 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const | 5022 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const |
5023 { | 5023 { |
5024 return TouchList::create(touches); | 5024 return TouchList::create(touches); |
5025 } | 5025 } |
5026 | 5026 |
5027 void Document::didAddTouchEventHandler(Node* handler) | |
5028 { | |
5029 // The node should either be in this document, or be the Document node of a child | |
5030 // of this document. | |
5031 ASSERT(&handler->document() == this | |
5032 || (handler->isDocumentNode() && toDocument(handler)->parentDocument() = = this)); | |
5033 if (!m_touchEventTargets.get()) | |
5034 m_touchEventTargets = adoptPtr(new TouchEventTargetSet); | |
5035 bool isFirstHandler = m_touchEventTargets->isEmpty(); | |
5036 | |
5037 if (!m_touchEventTargets->add(handler).isNewEntry) { | |
5038 // Just incremented refcount, no real change. | |
5039 // If this is a child document node, then the count should never go abov e 1. | |
5040 ASSERT(!handler->isDocumentNode() || &handler->document() == this); | |
5041 return; | |
5042 } | |
5043 | |
5044 if (isFirstHandler) { | |
5045 if (Document* parent = parentDocument()) { | |
5046 parent->didAddTouchEventHandler(this); | |
5047 } else { | |
5048 // This is the first touch handler on the whole page. | |
5049 if (FrameHost* frameHost = this->frameHost()) | |
5050 frameHost->chrome().client().needTouchEvents(true); | |
5051 } | |
5052 } | |
5053 | |
5054 // When we're all done with all frames, ensure touch hit rects are marked as dirty. | |
5055 if (!handler->isDocumentNode() || handler == this) { | |
5056 if (Page* page = this->page()) { | |
5057 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator()) | |
5058 scrollingCoordinator->touchEventTargetRectsDidChange(); | |
5059 } | |
5060 } | |
5061 } | |
5062 | |
5063 void Document::didRemoveTouchEventHandler(Node* handler, bool clearAll) | |
5064 { | |
5065 // Note that we can't assert that |handler| is in this document because it m ight be in | |
5066 // the process of moving out of it. | |
5067 ASSERT(clearAll || m_touchEventTargets->contains(handler)); | |
5068 if (!m_touchEventTargets.get()) | |
5069 return; | |
5070 | |
5071 if (clearAll) { | |
5072 if (!m_touchEventTargets->contains(handler)) | |
5073 return; | |
5074 m_touchEventTargets->removeAll(handler); | |
5075 } else { | |
5076 if (!m_touchEventTargets->remove(handler)) | |
5077 // Just decremented refcount, no real update. | |
5078 return; | |
5079 } | |
5080 | |
5081 if (m_touchEventTargets->isEmpty()) { | |
5082 if (Document* parent = parentDocument()) { | |
5083 // This was the last handler in this document, update the parent doc ument too. | |
5084 parent->didRemoveTouchEventHandler(this, clearAll); | |
5085 } else { | |
5086 // We just removed the last touch handler on the whole page. | |
5087 if (FrameHost* frameHost = this->frameHost()) | |
5088 frameHost->chrome().client().needTouchEvents(false); | |
5089 } | |
5090 } | |
5091 | |
5092 // When we're all done with all frames, ensure touch hit rects are marked as dirty. | |
5093 if (!handler->isDocumentNode() || handler == this) { | |
5094 if (Page* page = this->page()) { | |
5095 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator()) | |
5096 scrollingCoordinator->touchEventTargetRectsDidChange(); | |
5097 } | |
5098 } | |
5099 } | |
5100 | |
5101 DocumentLoader* Document::loader() const | 5027 DocumentLoader* Document::loader() const |
5102 { | 5028 { |
5103 if (!m_frame) | 5029 if (!m_frame) |
5104 return 0; | 5030 return 0; |
5105 | 5031 |
5106 DocumentLoader* loader = m_frame->loader().documentLoader(); | 5032 DocumentLoader* loader = m_frame->loader().documentLoader(); |
5107 if (!loader) | 5033 if (!loader) |
5108 return 0; | 5034 return 0; |
5109 | 5035 |
5110 if (m_frame->document() != this) | 5036 if (m_frame->document() != this) |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5521 } | 5447 } |
5522 | 5448 |
5523 void Document::invalidateNodeListCaches(const QualifiedName* attrName) | 5449 void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
5524 { | 5450 { |
5525 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); | 5451 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); |
5526 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) | 5452 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) |
5527 (*it)->invalidateCache(attrName); | 5453 (*it)->invalidateCache(attrName); |
5528 } | 5454 } |
5529 | 5455 |
5530 } // namespace WebCore | 5456 } // namespace WebCore |
OLD | NEW |