| 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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 // m_fetcher. | 534 // m_fetcher. |
| 535 m_styleEngine = StyleEngine::create(*this); | 535 m_styleEngine = StyleEngine::create(*this); |
| 536 | 536 |
| 537 // The parent's parser should be suspended together with all the other | 537 // The parent's parser should be suspended together with all the other |
| 538 // objects, else this new Document would have a new ExecutionContext which | 538 // objects, else this new Document would have a new ExecutionContext which |
| 539 // suspended state would not match the one from the parent, and could start | 539 // suspended state would not match the one from the parent, and could start |
| 540 // loading resources ignoring the defersLoading flag. | 540 // loading resources ignoring the defersLoading flag. |
| 541 DCHECK(!parentDocument() || !parentDocument()->isContextSuspended()); | 541 DCHECK(!parentDocument() || !parentDocument()->isContextSuspended()); |
| 542 | 542 |
| 543 #ifndef NDEBUG | 543 #ifndef NDEBUG |
| 544 liveDocumentSet().add(this); | 544 liveDocumentSet().insert(this); |
| 545 #endif | 545 #endif |
| 546 } | 546 } |
| 547 | 547 |
| 548 Document::~Document() { | 548 Document::~Document() { |
| 549 DCHECK(layoutViewItem().isNull()); | 549 DCHECK(layoutViewItem().isNull()); |
| 550 DCHECK(!parentTreeScope()); | 550 DCHECK(!parentTreeScope()); |
| 551 // If a top document with a cache, verify that it was comprehensively | 551 // If a top document with a cache, verify that it was comprehensively |
| 552 // cleared during detach. | 552 // cleared during detach. |
| 553 DCHECK(!m_axObjectCache); | 553 DCHECK(!m_axObjectCache); |
| 554 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); | 554 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 void Document::setIsViewSource(bool isViewSource) { | 2323 void Document::setIsViewSource(bool isViewSource) { |
| 2324 m_isViewSource = isViewSource; | 2324 m_isViewSource = isViewSource; |
| 2325 if (!m_isViewSource) | 2325 if (!m_isViewSource) |
| 2326 return; | 2326 return; |
| 2327 | 2327 |
| 2328 setSecurityOrigin(SecurityOrigin::createUnique()); | 2328 setSecurityOrigin(SecurityOrigin::createUnique()); |
| 2329 didUpdateSecurityOrigin(); | 2329 didUpdateSecurityOrigin(); |
| 2330 } | 2330 } |
| 2331 | 2331 |
| 2332 void Document::scheduleUseShadowTreeUpdate(SVGUseElement& element) { | 2332 void Document::scheduleUseShadowTreeUpdate(SVGUseElement& element) { |
| 2333 m_useElementsNeedingUpdate.add(&element); | 2333 m_useElementsNeedingUpdate.insert(&element); |
| 2334 scheduleLayoutTreeUpdateIfNeeded(); | 2334 scheduleLayoutTreeUpdateIfNeeded(); |
| 2335 } | 2335 } |
| 2336 | 2336 |
| 2337 void Document::unscheduleUseShadowTreeUpdate(SVGUseElement& element) { | 2337 void Document::unscheduleUseShadowTreeUpdate(SVGUseElement& element) { |
| 2338 m_useElementsNeedingUpdate.remove(&element); | 2338 m_useElementsNeedingUpdate.remove(&element); |
| 2339 } | 2339 } |
| 2340 | 2340 |
| 2341 void Document::updateUseShadowTreesIfNeeded() { | 2341 void Document::updateUseShadowTreesIfNeeded() { |
| 2342 ScriptForbiddenScope forbidScript; | 2342 ScriptForbiddenScope forbidScript; |
| 2343 | 2343 |
| (...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4149 ScriptWrappableVisitor::writeBarrier( | 4149 ScriptWrappableVisitor::writeBarrier( |
| 4150 parent, static_cast<const HTMLCollection*>(list)); | 4150 parent, static_cast<const HTMLCollection*>(list)); |
| 4151 } else { | 4151 } else { |
| 4152 ScriptWrappableVisitor::writeBarrier( | 4152 ScriptWrappableVisitor::writeBarrier( |
| 4153 parent, static_cast<const LiveNodeList*>(list)); | 4153 parent, static_cast<const LiveNodeList*>(list)); |
| 4154 } | 4154 } |
| 4155 } | 4155 } |
| 4156 | 4156 |
| 4157 void Document::registerNodeList(const LiveNodeListBase* list) { | 4157 void Document::registerNodeList(const LiveNodeListBase* list) { |
| 4158 DCHECK(!m_nodeLists[list->invalidationType()].contains(list)); | 4158 DCHECK(!m_nodeLists[list->invalidationType()].contains(list)); |
| 4159 m_nodeLists[list->invalidationType()].add(list); | 4159 m_nodeLists[list->invalidationType()].insert(list); |
| 4160 liveNodeListBaseWriteBarrier(this, list); | 4160 liveNodeListBaseWriteBarrier(this, list); |
| 4161 if (list->isRootedAtTreeScope()) | 4161 if (list->isRootedAtTreeScope()) |
| 4162 m_listsInvalidatedAtDocument.add(list); | 4162 m_listsInvalidatedAtDocument.insert(list); |
| 4163 } | 4163 } |
| 4164 | 4164 |
| 4165 void Document::unregisterNodeList(const LiveNodeListBase* list) { | 4165 void Document::unregisterNodeList(const LiveNodeListBase* list) { |
| 4166 DCHECK(m_nodeLists[list->invalidationType()].contains(list)); | 4166 DCHECK(m_nodeLists[list->invalidationType()].contains(list)); |
| 4167 m_nodeLists[list->invalidationType()].remove(list); | 4167 m_nodeLists[list->invalidationType()].remove(list); |
| 4168 if (list->isRootedAtTreeScope()) { | 4168 if (list->isRootedAtTreeScope()) { |
| 4169 DCHECK(m_listsInvalidatedAtDocument.contains(list)); | 4169 DCHECK(m_listsInvalidatedAtDocument.contains(list)); |
| 4170 m_listsInvalidatedAtDocument.remove(list); | 4170 m_listsInvalidatedAtDocument.remove(list); |
| 4171 } | 4171 } |
| 4172 } | 4172 } |
| 4173 | 4173 |
| 4174 void Document::registerNodeListWithIdNameCache(const LiveNodeListBase* list) { | 4174 void Document::registerNodeListWithIdNameCache(const LiveNodeListBase* list) { |
| 4175 DCHECK(!m_nodeLists[InvalidateOnIdNameAttrChange].contains(list)); | 4175 DCHECK(!m_nodeLists[InvalidateOnIdNameAttrChange].contains(list)); |
| 4176 m_nodeLists[InvalidateOnIdNameAttrChange].add(list); | 4176 m_nodeLists[InvalidateOnIdNameAttrChange].insert(list); |
| 4177 liveNodeListBaseWriteBarrier(this, list); | 4177 liveNodeListBaseWriteBarrier(this, list); |
| 4178 } | 4178 } |
| 4179 | 4179 |
| 4180 void Document::unregisterNodeListWithIdNameCache(const LiveNodeListBase* list) { | 4180 void Document::unregisterNodeListWithIdNameCache(const LiveNodeListBase* list) { |
| 4181 DCHECK(m_nodeLists[InvalidateOnIdNameAttrChange].contains(list)); | 4181 DCHECK(m_nodeLists[InvalidateOnIdNameAttrChange].contains(list)); |
| 4182 m_nodeLists[InvalidateOnIdNameAttrChange].remove(list); | 4182 m_nodeLists[InvalidateOnIdNameAttrChange].remove(list); |
| 4183 } | 4183 } |
| 4184 | 4184 |
| 4185 void Document::attachNodeIterator(NodeIterator* ni) { | 4185 void Document::attachNodeIterator(NodeIterator* ni) { |
| 4186 m_nodeIterators.add(ni); | 4186 m_nodeIterators.insert(ni); |
| 4187 } | 4187 } |
| 4188 | 4188 |
| 4189 void Document::detachNodeIterator(NodeIterator* ni) { | 4189 void Document::detachNodeIterator(NodeIterator* ni) { |
| 4190 // The node iterator can be detached without having been attached if its root | 4190 // The node iterator can be detached without having been attached if its root |
| 4191 // node didn't have a document when the iterator was created, but has it now. | 4191 // node didn't have a document when the iterator was created, but has it now. |
| 4192 m_nodeIterators.remove(ni); | 4192 m_nodeIterators.remove(ni); |
| 4193 } | 4193 } |
| 4194 | 4194 |
| 4195 void Document::moveNodeIteratorsToNewDocument(Node& node, | 4195 void Document::moveNodeIteratorsToNewDocument(Node& node, |
| 4196 Document& newDocument) { | 4196 Document& newDocument) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4408 std::unique_ptr<ExecutionContextTask> task, | 4408 std::unique_ptr<ExecutionContextTask> task, |
| 4409 bool isInstrumented) { | 4409 bool isInstrumented) { |
| 4410 InspectorInstrumentation::AsyncTask asyncTask(this, task.get(), | 4410 InspectorInstrumentation::AsyncTask asyncTask(this, task.get(), |
| 4411 isInstrumented); | 4411 isInstrumented); |
| 4412 task->performTask(this); | 4412 task->performTask(this); |
| 4413 } | 4413 } |
| 4414 | 4414 |
| 4415 void Document::registerEventFactory( | 4415 void Document::registerEventFactory( |
| 4416 std::unique_ptr<EventFactoryBase> eventFactory) { | 4416 std::unique_ptr<EventFactoryBase> eventFactory) { |
| 4417 DCHECK(!eventFactories().contains(eventFactory.get())); | 4417 DCHECK(!eventFactories().contains(eventFactory.get())); |
| 4418 eventFactories().add(std::move(eventFactory)); | 4418 eventFactories().insert(std::move(eventFactory)); |
| 4419 } | 4419 } |
| 4420 | 4420 |
| 4421 Event* Document::createEvent(ExecutionContext* executionContext, | 4421 Event* Document::createEvent(ExecutionContext* executionContext, |
| 4422 const String& eventType, | 4422 const String& eventType, |
| 4423 ExceptionState& exceptionState) { | 4423 ExceptionState& exceptionState) { |
| 4424 Event* event = nullptr; | 4424 Event* event = nullptr; |
| 4425 for (const auto& factory : eventFactories()) { | 4425 for (const auto& factory : eventFactories()) { |
| 4426 event = factory->create(executionContext, eventType); | 4426 event = factory->create(executionContext, eventType); |
| 4427 if (event) { | 4427 if (event) { |
| 4428 // createEvent for TouchEvent should throw DOM exception if touch event | 4428 // createEvent for TouchEvent should throw DOM exception if touch event |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5615 Element* element = focusedElement(); | 5615 Element* element = focusedElement(); |
| 5616 if (!element) | 5616 if (!element) |
| 5617 return; | 5617 return; |
| 5618 updateStyleAndLayout(); | 5618 updateStyleAndLayout(); |
| 5619 if (element->isFocusable()) | 5619 if (element->isFocusable()) |
| 5620 element->updateFocusAppearance(SelectionBehaviorOnFocus::Restore); | 5620 element->updateFocusAppearance(SelectionBehaviorOnFocus::Restore); |
| 5621 } | 5621 } |
| 5622 | 5622 |
| 5623 void Document::attachRange(Range* range) { | 5623 void Document::attachRange(Range* range) { |
| 5624 DCHECK(!m_ranges.contains(range)); | 5624 DCHECK(!m_ranges.contains(range)); |
| 5625 m_ranges.add(range); | 5625 m_ranges.insert(range); |
| 5626 } | 5626 } |
| 5627 | 5627 |
| 5628 void Document::detachRange(Range* range) { | 5628 void Document::detachRange(Range* range) { |
| 5629 // We don't ASSERT m_ranges.contains(range) to allow us to call this | 5629 // We don't ASSERT m_ranges.contains(range) to allow us to call this |
| 5630 // unconditionally to fix: https://bugs.webkit.org/show_bug.cgi?id=26044 | 5630 // unconditionally to fix: https://bugs.webkit.org/show_bug.cgi?id=26044 |
| 5631 m_ranges.remove(range); | 5631 m_ranges.remove(range); |
| 5632 } | 5632 } |
| 5633 | 5633 |
| 5634 void Document::initDNSPrefetch() { | 5634 void Document::initDNSPrefetch() { |
| 5635 Settings* settings = this->settings(); | 5635 Settings* settings = this->settings(); |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6535 } | 6535 } |
| 6536 | 6536 |
| 6537 void showLiveDocumentInstances() { | 6537 void showLiveDocumentInstances() { |
| 6538 WeakDocumentSet& set = liveDocumentSet(); | 6538 WeakDocumentSet& set = liveDocumentSet(); |
| 6539 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6539 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6540 for (Document* document : set) | 6540 for (Document* document : set) |
| 6541 fprintf(stderr, "- Document %p URL: %s\n", document, | 6541 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6542 document->url().getString().utf8().data()); | 6542 document->url().getString().utf8().data()); |
| 6543 } | 6543 } |
| 6544 #endif | 6544 #endif |
| OLD | NEW |