Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1958093002: CONTINUED Make FrameSelection to hold non-canonicalized positions Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2017-01-16T20:04:35 Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 } 2481 }
2482 } 2482 }
2483 2483
2484 styleEngine().didDetach(); 2484 styleEngine().didDetach();
2485 2485
2486 frameHost()->eventHandlerRegistry().documentDetached(*this); 2486 frameHost()->eventHandlerRegistry().documentDetached(*this);
2487 2487
2488 // Since |Document| class has multiple |LifecycleNotifier| as base class, 2488 // Since |Document| class has multiple |LifecycleNotifier| as base class,
2489 // we need to have |static_cast<SynchronousMutationNotifier>| here. 2489 // we need to have |static_cast<SynchronousMutationNotifier>| here.
2490 static_cast<SynchronousMutationNotifier*>(this)->notifyContextDestroyed(); 2490 static_cast<SynchronousMutationNotifier*>(this)->notifyContextDestroyed();
2491 m_frame->selection().documentDetached(*this);
2492 2491
2493 // If this Document is associated with a live DocumentLoader, the 2492 // If this Document is associated with a live DocumentLoader, the
2494 // DocumentLoader will take care of clearing the FetchContext. Deferring 2493 // DocumentLoader will take care of clearing the FetchContext. Deferring
2495 // to the DocumentLoader when possible also prevents prematurely clearing 2494 // to the DocumentLoader when possible also prevents prematurely clearing
2496 // the context in the case where multiple Documents end up associated with 2495 // the context in the case where multiple Documents end up associated with
2497 // a single DocumentLoader (e.g., navigating to a javascript: url). 2496 // a single DocumentLoader (e.g., navigating to a javascript: url).
2498 if (!loader()) 2497 if (!loader())
2499 m_fetcher->clearContext(); 2498 m_fetcher->clearContext();
2500 // If this document is the master for an HTMLImportsController, sever that 2499 // If this document is the master for an HTMLImportsController, sever that
2501 // relationship. This ensures that we don't leave import loads in flight, 2500 // relationship. This ensures that we don't leave import loads in flight,
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
4210 EventDispatchForbiddenScope assertNoEventDispatch; 4209 EventDispatchForbiddenScope assertNoEventDispatch;
4211 for (Range* range : m_ranges) 4210 for (Range* range : m_ranges)
4212 range->nodeChildrenWillBeRemoved(container); 4211 range->nodeChildrenWillBeRemoved(container);
4213 4212
4214 for (NodeIterator* ni : m_nodeIterators) { 4213 for (NodeIterator* ni : m_nodeIterators) {
4215 for (Node& n : NodeTraversal::childrenOf(container)) 4214 for (Node& n : NodeTraversal::childrenOf(container))
4216 ni->nodeWillBeRemoved(n); 4215 ni->nodeWillBeRemoved(n);
4217 } 4216 }
4218 4217
4219 notifyNodeChildrenWillBeRemoved(container); 4218 notifyNodeChildrenWillBeRemoved(container);
4220 if (LocalFrame* frame = this->frame())
4221 frame->selection().nodeChildrenWillBeRemoved(container);
4222 4219
4223 if (containsV1ShadowTree()) { 4220 if (containsV1ShadowTree()) {
4224 for (Node& n : NodeTraversal::childrenOf(container)) 4221 for (Node& n : NodeTraversal::childrenOf(container))
4225 n.checkSlotChangeBeforeRemoved(); 4222 n.checkSlotChangeBeforeRemoved();
4226 } 4223 }
4227 } 4224 }
4228 4225
4229 void Document::nodeWillBeRemoved(Node& n) { 4226 void Document::nodeWillBeRemoved(Node& n) {
4230 for (NodeIterator* ni : m_nodeIterators) 4227 for (NodeIterator* ni : m_nodeIterators)
4231 ni->nodeWillBeRemoved(n); 4228 ni->nodeWillBeRemoved(n);
4232 4229
4233 for (Range* range : m_ranges) 4230 for (Range* range : m_ranges)
4234 range->nodeWillBeRemoved(n); 4231 range->nodeWillBeRemoved(n);
4235 4232
4236 notifyNodeWillBeRemoved(n); 4233 notifyNodeWillBeRemoved(n);
4237 4234
4238 if (LocalFrame* frame = this->frame()) {
4239 frame->selection().nodeWillBeRemoved(n);
4240 }
4241
4242 if (containsV1ShadowTree()) 4235 if (containsV1ShadowTree())
4243 n.checkSlotChangeBeforeRemoved(); 4236 n.checkSlotChangeBeforeRemoved();
4244 4237
4245 if (n.inActiveDocument() && n.isElementNode()) 4238 if (n.inActiveDocument() && n.isElementNode())
4246 styleEngine().elementWillBeRemoved(toElement(n)); 4239 styleEngine().elementWillBeRemoved(toElement(n));
4247 } 4240 }
4248 4241
4249 void Document::dataWillChange(const CharacterData& characterData) {
4250 if (LocalFrame* frame = this->frame())
4251 frame->selection().dataWillChange(characterData);
4252 }
4253
4254 void Document::didInsertText(Node* text, unsigned offset, unsigned length) { 4242 void Document::didInsertText(Node* text, unsigned offset, unsigned length) {
4255 for (Range* range : m_ranges) 4243 for (Range* range : m_ranges)
4256 range->didInsertText(text, offset, length); 4244 range->didInsertText(text, offset, length);
4257 4245
4258 m_markers->shiftMarkers(text, offset, length); 4246 m_markers->shiftMarkers(text, offset, length);
4259 } 4247 }
4260 4248
4261 void Document::didRemoveText(Node* text, unsigned offset, unsigned length) { 4249 void Document::didRemoveText(Node* text, unsigned offset, unsigned length) {
4262 for (Range* range : m_ranges) 4250 for (Range* range : m_ranges)
4263 range->didRemoveText(text, offset, length); 4251 range->didRemoveText(text, offset, length);
4264 4252
4265 m_markers->removeMarkers(text, offset, length); 4253 m_markers->removeMarkers(text, offset, length);
4266 m_markers->shiftMarkers(text, offset + length, 0 - length); 4254 m_markers->shiftMarkers(text, offset + length, 0 - length);
4267 } 4255 }
4268 4256
4269 void Document::didMergeTextNodes(Text& oldNode, unsigned offset) { 4257 void Document::didMergeTextNodes(const Text& mergedNode,
4258 const Text& nodeToBeRemoved,
4259 unsigned oldLength) {
4260 NodeWithIndex nodeToBeRemovedWithIndex(const_cast<Text&>(nodeToBeRemoved));
4270 if (!m_ranges.isEmpty()) { 4261 if (!m_ranges.isEmpty()) {
4271 NodeWithIndex oldNodeWithIndex(oldNode);
4272 for (Range* range : m_ranges) 4262 for (Range* range : m_ranges)
4273 range->didMergeTextNodes(oldNodeWithIndex, offset); 4263 range->didMergeTextNodes(nodeToBeRemovedWithIndex, oldLength);
4274 } 4264 }
4275 4265
4276 notifyMergeTextNodes(oldNode, offset); 4266 notifyMergeTextNodes(mergedNode, nodeToBeRemovedWithIndex, oldLength);
4277 if (m_frame)
4278 m_frame->selection().didMergeTextNodes(oldNode, offset);
4279 4267
4280 // FIXME: This should update markers for spelling and grammar checking. 4268 // FIXME: This should update markers for spelling and grammar checking.
4281 } 4269 }
4282 4270
4283 void Document::didSplitTextNode(const Text& oldNode) { 4271 void Document::didSplitTextNode(const Text& oldNode) {
4284 for (Range* range : m_ranges) 4272 for (Range* range : m_ranges)
4285 range->didSplitTextNode(oldNode); 4273 range->didSplitTextNode(oldNode);
4286 4274
4287 notifySplitTextNode(oldNode); 4275 notifySplitTextNode(oldNode);
4288 if (m_frame)
4289 m_frame->selection().didSplitTextNode(oldNode);
4290 4276
4291 // FIXME: This should update markers for spelling and grammar checking. 4277 // FIXME: This should update markers for spelling and grammar checking.
4292 } 4278 }
4293 4279
4294 void Document::setWindowAttributeEventListener(const AtomicString& eventType, 4280 void Document::setWindowAttributeEventListener(const AtomicString& eventType,
4295 EventListener* listener) { 4281 EventListener* listener) {
4296 LocalDOMWindow* domWindow = this->domWindow(); 4282 LocalDOMWindow* domWindow = this->domWindow();
4297 if (!domWindow) 4283 if (!domWindow)
4298 return; 4284 return;
4299 domWindow->setAttributeEventListener(eventType, listener); 4285 domWindow->setAttributeEventListener(eventType, listener);
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after
6515 } 6501 }
6516 6502
6517 void showLiveDocumentInstances() { 6503 void showLiveDocumentInstances() {
6518 WeakDocumentSet& set = liveDocumentSet(); 6504 WeakDocumentSet& set = liveDocumentSet();
6519 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6505 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6520 for (Document* document : set) 6506 for (Document* document : set)
6521 fprintf(stderr, "- Document %p URL: %s\n", document, 6507 fprintf(stderr, "- Document %p URL: %s\n", document,
6522 document->url().getString().utf8().data()); 6508 document->url().getString().utf8().data());
6523 } 6509 }
6524 #endif 6510 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/DocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698