Chromium Code Reviews| 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 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2083 m_renderView->setStyle(StyleResolver::styleForDocument(*this)); | 2084 m_renderView->setStyle(StyleResolver::styleForDocument(*this)); |
| 2084 view()->updateCompositingLayersAfterStyleChange(); | 2085 view()->updateCompositingLayersAfterStyleChange(); |
| 2085 | 2086 |
| 2086 ContainerNode::attach(context); | 2087 ContainerNode::attach(context); |
| 2087 | 2088 |
| 2088 // FastTextAutosizer can't update render view info while the Document is det ached, so update now in case anything changed. | 2089 // FastTextAutosizer can't update render view info while the Document is det ached, so update now in case anything changed. |
| 2089 if (FastTextAutosizer* textAutosizer = fastTextAutosizer()) | 2090 if (FastTextAutosizer* textAutosizer = fastTextAutosizer()) |
| 2090 textAutosizer->updatePageInfo(); | 2091 textAutosizer->updatePageInfo(); |
| 2091 | 2092 |
| 2092 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); | 2093 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); |
| 2094 lifecycleNotifier().notifyDocumentWasAttached(); | |
| 2093 } | 2095 } |
| 2094 | 2096 |
| 2095 void Document::detach(const AttachContext& context) | 2097 void Document::detach(const AttachContext& context) |
| 2096 { | 2098 { |
| 2097 ASSERT(isActive()); | 2099 ASSERT(isActive()); |
| 2098 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); | 2100 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); |
| 2101 lifecycleNotifier().notifyWillDetachDocument(); | |
| 2099 | 2102 |
| 2100 if (page()) | 2103 if (page()) |
| 2101 page()->documentDetached(this); | 2104 page()->documentDetached(this); |
| 2102 InspectorInstrumentation::documentDetached(this); | 2105 InspectorInstrumentation::documentDetached(this); |
| 2103 | 2106 |
| 2104 if (m_frame->loader().client()->sharedWorkerRepositoryClient()) | 2107 if (m_frame->loader().client()->sharedWorkerRepositoryClient()) |
| 2105 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this); | 2108 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this); |
| 2106 | 2109 |
| 2107 if (this == topDocument()) | 2110 if (this == topDocument()) |
| 2108 clearAXObjectCache(); | 2111 clearAXObjectCache(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2142 m_activeHoverElement = nullptr; | 2145 m_activeHoverElement = nullptr; |
| 2143 m_autofocusElement = nullptr; | 2146 m_autofocusElement = nullptr; |
| 2144 | 2147 |
| 2145 ContainerNode::detach(context); | 2148 ContainerNode::detach(context); |
| 2146 | 2149 |
| 2147 m_styleEngine->didDetach(); | 2150 m_styleEngine->didDetach(); |
| 2148 | 2151 |
| 2149 if (renderView) | 2152 if (renderView) |
| 2150 renderView->destroy(); | 2153 renderView->destroy(); |
| 2151 | 2154 |
| 2152 if (Document* parentDoc = parentDocument()) | |
| 2153 parentDoc->didClearTouchEventHandlers(this); | |
| 2154 | |
| 2155 // This is required, as our LocalFrame might delete itself as soon as it det aches | 2155 // This is required, as our LocalFrame might delete itself as soon as it det aches |
| 2156 // us. However, this violates Node::detach() semantics, as it's never | 2156 // us. However, this violates Node::detach() semantics, as it's never |
| 2157 // possible to re-attach. Eventually Document::detach() should be renamed, | 2157 // possible to re-attach. Eventually Document::detach() should be renamed, |
| 2158 // or this setting of the frame to 0 could be made explicit in each of the | 2158 // or this setting of the frame to 0 could be made explicit in each of the |
| 2159 // callers of Document::detach(). | 2159 // callers of Document::detach(). |
| 2160 m_frame = 0; | 2160 m_frame = 0; |
| 2161 | 2161 |
| 2162 if (m_mediaQueryMatcher) | 2162 if (m_mediaQueryMatcher) |
| 2163 m_mediaQueryMatcher->documentDestroyed(); | 2163 m_mediaQueryMatcher->documentDestroyed(); |
| 2164 | 2164 |
| (...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5015 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 | 5015 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 |
| 5016 LocalFrame* frame = window ? window->frame() : this->frame(); | 5016 LocalFrame* frame = window ? window->frame() : this->frame(); |
| 5017 return Touch::create(frame, target, identifier, screenX, screenY, pageX, pag eY, radiusX, radiusY, rotationAngle, force); | 5017 return Touch::create(frame, target, identifier, screenX, screenY, pageX, pag eY, radiusX, radiusY, rotationAngle, force); |
| 5018 } | 5018 } |
| 5019 | 5019 |
| 5020 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const | 5020 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const |
| 5021 { | 5021 { |
| 5022 return TouchList::create(touches); | 5022 return TouchList::create(touches); |
| 5023 } | 5023 } |
| 5024 | 5024 |
| 5025 void Document::didAddTouchEventHandler(Node* handler) | 5025 void Document::resetLastHandledUserGestureTimestamp() |
|
Rick Byers
2014/04/04 20:12:27
ditto
Sami
2014/04/07 14:56:49
Done.
| |
| 5026 { | 5026 { |
| 5027 // The node should either be in this document, or be the Document node of a child | 5027 m_lastHandledUserGestureTimestamp = currentTime(); |
| 5028 // of this document. | |
| 5029 ASSERT(&handler->document() == this | |
| 5030 || (handler->isDocumentNode() && toDocument(handler)->parentDocument() = = this)); | |
| 5031 if (!m_touchEventTargets.get()) | |
| 5032 m_touchEventTargets = adoptPtr(new TouchEventTargetSet); | |
| 5033 bool isFirstHandler = m_touchEventTargets->isEmpty(); | |
| 5034 | |
| 5035 if (!m_touchEventTargets->add(handler).isNewEntry) { | |
| 5036 // Just incremented refcount, no real change. | |
| 5037 // If this is a child document node, then the count should never go abov e 1. | |
| 5038 ASSERT(!handler->isDocumentNode() || &handler->document() == this); | |
| 5039 return; | |
| 5040 } | |
| 5041 | |
| 5042 if (isFirstHandler) { | |
| 5043 if (Document* parent = parentDocument()) { | |
| 5044 parent->didAddTouchEventHandler(this); | |
| 5045 } else { | |
| 5046 // This is the first touch handler on the whole page. | |
| 5047 if (FrameHost* frameHost = this->frameHost()) | |
| 5048 frameHost->chrome().client().needTouchEvents(true); | |
| 5049 } | |
| 5050 } | |
| 5051 | |
| 5052 // When we're all done with all frames, ensure touch hit rects are marked as dirty. | |
| 5053 if (!handler->isDocumentNode() || handler == this) { | |
| 5054 if (Page* page = this->page()) { | |
| 5055 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator()) | |
| 5056 scrollingCoordinator->touchEventTargetRectsDidChange(); | |
| 5057 } | |
| 5058 } | |
| 5059 } | |
| 5060 | |
| 5061 void Document::didRemoveTouchEventHandler(Node* handler, bool clearAll) | |
| 5062 { | |
| 5063 // Note that we can't assert that |handler| is in this document because it m ight be in | |
| 5064 // the process of moving out of it. | |
| 5065 ASSERT(clearAll || m_touchEventTargets->contains(handler)); | |
| 5066 if (!m_touchEventTargets.get()) | |
| 5067 return; | |
| 5068 | |
| 5069 if (clearAll) { | |
| 5070 if (!m_touchEventTargets->contains(handler)) | |
| 5071 return; | |
| 5072 m_touchEventTargets->removeAll(handler); | |
| 5073 } else { | |
| 5074 if (!m_touchEventTargets->remove(handler)) | |
| 5075 // Just decremented refcount, no real update. | |
| 5076 return; | |
| 5077 } | |
| 5078 | |
| 5079 if (m_touchEventTargets->isEmpty()) { | |
| 5080 if (Document* parent = parentDocument()) { | |
| 5081 // This was the last handler in this document, update the parent doc ument too. | |
| 5082 parent->didRemoveTouchEventHandler(this, clearAll); | |
| 5083 } else { | |
| 5084 // We just removed the last touch handler on the whole page. | |
| 5085 if (FrameHost* frameHost = this->frameHost()) | |
| 5086 frameHost->chrome().client().needTouchEvents(false); | |
| 5087 } | |
| 5088 } | |
| 5089 | |
| 5090 // When we're all done with all frames, ensure touch hit rects are marked as dirty. | |
| 5091 if (!handler->isDocumentNode() || handler == this) { | |
| 5092 if (Page* page = this->page()) { | |
| 5093 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator()) | |
| 5094 scrollingCoordinator->touchEventTargetRectsDidChange(); | |
| 5095 } | |
| 5096 } | |
| 5097 } | 5028 } |
| 5098 | 5029 |
| 5099 DocumentLoader* Document::loader() const | 5030 DocumentLoader* Document::loader() const |
| 5100 { | 5031 { |
| 5101 if (!m_frame) | 5032 if (!m_frame) |
| 5102 return 0; | 5033 return 0; |
| 5103 | 5034 |
| 5104 DocumentLoader* loader = m_frame->loader().documentLoader(); | 5035 DocumentLoader* loader = m_frame->loader().documentLoader(); |
| 5105 if (!loader) | 5036 if (!loader) |
| 5106 return 0; | 5037 return 0; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5519 } | 5450 } |
| 5520 | 5451 |
| 5521 void Document::invalidateNodeListCaches(const QualifiedName* attrName) | 5452 void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
| 5522 { | 5453 { |
| 5523 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); | 5454 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); |
| 5524 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) | 5455 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) |
| 5525 (*it)->invalidateCache(attrName); | 5456 (*it)->invalidateCache(attrName); |
| 5526 } | 5457 } |
| 5527 | 5458 |
| 5528 } // namespace WebCore | 5459 } // namespace WebCore |
| OLD | NEW |