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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 Element* TreeScope::getElementById(const AtomicString& elementId) const 162 Element* TreeScope::getElementById(const AtomicString& elementId) const
163 { 163 {
164 if (elementId.isEmpty()) 164 if (elementId.isEmpty())
165 return 0; 165 return 0;
166 if (!m_elementsById) 166 if (!m_elementsById)
167 return 0; 167 return 0;
168 return m_elementsById->getElementById(elementId, this); 168 return m_elementsById->getElementById(elementId, this);
169 } 169 }
170 170
171 const WillBeHeapVector<RawPtrWillBeMember<Element>>& TreeScope::getAllElementsBy Id(const AtomicString& elementId) const 171 const HeapVector<Member<Element>>& TreeScope::getAllElementsById(const AtomicStr ing& elementId) const
172 { 172 {
173 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<Element>>>, emptyVector, (adoptPtrWillBeNoop(new WillBeHeapVector<RawPtrWillB eMember<Element>>()))); 173 DEFINE_STATIC_LOCAL(Persistent<HeapVector<Member<Element>>>, emptyVector, (n ew HeapVector<Member<Element>>()));
174 if (elementId.isEmpty()) 174 if (elementId.isEmpty())
175 return *emptyVector; 175 return *emptyVector;
176 if (!m_elementsById) 176 if (!m_elementsById)
177 return *emptyVector; 177 return *emptyVector;
178 return m_elementsById->getAllElementsById(elementId, this); 178 return m_elementsById->getAllElementsById(elementId, this);
179 } 179 }
180 180
181 void TreeScope::addElementById(const AtomicString& elementId, Element* element) 181 void TreeScope::addElementById(const AtomicString& elementId, Element* element)
182 { 182 {
183 if (!m_elementsById) 183 if (!m_elementsById)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return 0; 287 return 0;
288 if (node->isPseudoElement() || node->isTextNode()) 288 if (node->isPseudoElement() || node->isTextNode())
289 node = node->parentOrShadowHostNode(); 289 node = node->parentOrShadowHostNode();
290 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); 290 ASSERT(!node || node->isElementNode() || node->isShadowRoot());
291 node = ancestorInThisScope(node); 291 node = ancestorInThisScope(node);
292 if (!node || !node->isElementNode()) 292 if (!node || !node->isElementNode())
293 return 0; 293 return 0;
294 return toElement(node); 294 return toElement(node);
295 } 295 }
296 296
297 WillBeHeapVector<RawPtrWillBeMember<Element>> TreeScope::elementsFromHitTestResu lt(HitTestResult& result) const 297 HeapVector<Member<Element>> TreeScope::elementsFromHitTestResult(HitTestResult& result) const
298 { 298 {
299 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; 299 HeapVector<Member<Element>> elements;
300 300
301 Node* lastNode = nullptr; 301 Node* lastNode = nullptr;
302 for (const auto rectBasedNode : result.listBasedTestResult()) { 302 for (const auto rectBasedNode : result.listBasedTestResult()) {
303 Node* node = rectBasedNode.get(); 303 Node* node = rectBasedNode.get();
304 if (!node || !node->isElementNode() || node->isDocumentNode()) 304 if (!node || !node->isElementNode() || node->isDocumentNode())
305 continue; 305 continue;
306 306
307 if (node->isPseudoElement() || node->isTextNode()) 307 if (node->isPseudoElement() || node->isTextNode())
308 node = node->parentOrShadowHostNode(); 308 node = node->parentOrShadowHostNode();
309 node = ancestorInThisScope(node); 309 node = ancestorInThisScope(node);
(...skipping 12 matching lines...) Expand all
322 if (rootNode().isDocumentNode()) { 322 if (rootNode().isDocumentNode()) {
323 if (Element* rootElement = toDocument(rootNode()).documentElement()) { 323 if (Element* rootElement = toDocument(rootNode()).documentElement()) {
324 if (elements.isEmpty() || elements.last() != rootElement) 324 if (elements.isEmpty() || elements.last() != rootElement)
325 elements.append(rootElement); 325 elements.append(rootElement);
326 } 326 }
327 } 327 }
328 328
329 return elements; 329 return elements;
330 } 330 }
331 331
332 WillBeHeapVector<RawPtrWillBeMember<Element>> TreeScope::elementsFromPoint(int x , int y) const 332 HeapVector<Member<Element>> TreeScope::elementsFromPoint(int x, int y) const
333 { 333 {
334 Document& document = rootNode().document(); 334 Document& document = rootNode().document();
335 IntPoint hitPoint(x, y); 335 IntPoint hitPoint(x, y);
336 if (!pointWithScrollAndZoomIfPossible(document, hitPoint)) 336 if (!pointWithScrollAndZoomIfPossible(document, hitPoint))
337 return WillBeHeapVector<RawPtrWillBeMember<Element>>(); 337 return HeapVector<Member<Element>>();
338 338
339 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::ListBased | HitTestRequest::PenetratingList); 339 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::ListBased | HitTestRequest::PenetratingList);
340 HitTestResult result(request, hitPoint); 340 HitTestResult result(request, hitPoint);
341 document.layoutView()->hitTest(result); 341 document.layoutView()->hitTest(result);
342 342
343 return elementsFromHitTestResult(result); 343 return elementsFromHitTestResult(result);
344 } 344 }
345 345
346 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement * element) 346 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement * element)
347 { 347 {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 Element* TreeScope::adjustedFocusedElement() const 423 Element* TreeScope::adjustedFocusedElement() const
424 { 424 {
425 Document& document = rootNode().document(); 425 Document& document = rootNode().document();
426 Element* element = document.focusedElement(); 426 Element* element = document.focusedElement();
427 if (!element && document.page()) 427 if (!element && document.page())
428 element = document.page()->focusController().focusedFrameOwnerElement(*d ocument.frame()); 428 element = document.page()->focusController().focusedFrameOwnerElement(*d ocument.frame());
429 if (!element) 429 if (!element)
430 return 0; 430 return 0;
431 431
432 OwnPtrWillBeRawPtr<EventPath> eventPath = adoptPtrWillBeNoop(new EventPath(* element)); 432 RawPtr<EventPath> eventPath = new EventPath(*element);
433 for (size_t i = 0; i < eventPath->size(); ++i) { 433 for (size_t i = 0; i < eventPath->size(); ++i) {
434 if (eventPath->at(i).node() == rootNode()) { 434 if (eventPath->at(i).node() == rootNode()) {
435 // eventPath->at(i).target() is one of the followings: 435 // eventPath->at(i).target() is one of the followings:
436 // - InsertionPoint 436 // - InsertionPoint
437 // - shadow host 437 // - shadow host
438 // - Document::focusedElement() 438 // - Document::focusedElement()
439 // So, it's safe to do toElement(). 439 // So, it's safe to do toElement().
440 return toElement(eventPath->at(i).target()->toNode()); 440 return toElement(eventPath->at(i).target()->toNode());
441 } 441 }
442 } 442 }
443 return 0; 443 return 0;
444 } 444 }
445 445
446 unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const 446 unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const
447 { 447 {
448 if (otherScope == this) 448 if (otherScope == this)
449 return Node::DOCUMENT_POSITION_EQUIVALENT; 449 return Node::DOCUMENT_POSITION_EQUIVALENT;
450 450
451 WillBeHeapVector<RawPtrWillBeMember<const TreeScope>, 16> chain1; 451 HeapVector<Member<const TreeScope>, 16> chain1;
452 WillBeHeapVector<RawPtrWillBeMember<const TreeScope>, 16> chain2; 452 HeapVector<Member<const TreeScope>, 16> chain2;
453 const TreeScope* current; 453 const TreeScope* current;
454 for (current = this; current; current = current->parentTreeScope()) 454 for (current = this; current; current = current->parentTreeScope())
455 chain1.append(current); 455 chain1.append(current);
456 for (current = &otherScope; current; current = current->parentTreeScope()) 456 for (current = &otherScope; current; current = current->parentTreeScope())
457 chain2.append(current); 457 chain2.append(current);
458 458
459 unsigned index1 = chain1.size(); 459 unsigned index1 = chain1.size();
460 unsigned index2 = chain2.size(); 460 unsigned index2 = chain2.size();
461 if (chain1[index1 - 1] != chain2[index2 - 1]) 461 if (chain1[index1 - 1] != chain2[index2 - 1])
462 return Node::DOCUMENT_POSITION_DISCONNECTED | Node::DOCUMENT_POSITION_IM PLEMENTATION_SPECIFIC; 462 return Node::DOCUMENT_POSITION_DISCONNECTED | Node::DOCUMENT_POSITION_IM PLEMENTATION_SPECIFIC;
(...skipping 18 matching lines...) Expand all
481 481
482 // There was no difference between the two parent chains, i.e., one was a su bset of the other. The shorter 482 // There was no difference between the two parent chains, i.e., one was a su bset of the other. The shorter
483 // chain is the ancestor. 483 // chain is the ancestor.
484 return index1 < index2 ? 484 return index1 < index2 ?
485 Node::DOCUMENT_POSITION_FOLLOWING | Node::DOCUMENT_POSITION_CONTAINED_BY : 485 Node::DOCUMENT_POSITION_FOLLOWING | Node::DOCUMENT_POSITION_CONTAINED_BY :
486 Node::DOCUMENT_POSITION_PRECEDING | Node::DOCUMENT_POSITION_CONTAINS; 486 Node::DOCUMENT_POSITION_PRECEDING | Node::DOCUMENT_POSITION_CONTAINS;
487 } 487 }
488 488
489 const TreeScope* TreeScope::commonAncestorTreeScope(const TreeScope& other) cons t 489 const TreeScope* TreeScope::commonAncestorTreeScope(const TreeScope& other) cons t
490 { 490 {
491 WillBeHeapVector<RawPtrWillBeMember<const TreeScope>, 16> thisChain; 491 HeapVector<Member<const TreeScope>, 16> thisChain;
492 for (const TreeScope* tree = this; tree; tree = tree->parentTreeScope()) 492 for (const TreeScope* tree = this; tree; tree = tree->parentTreeScope())
493 thisChain.append(tree); 493 thisChain.append(tree);
494 494
495 WillBeHeapVector<RawPtrWillBeMember<const TreeScope>, 16> otherChain; 495 HeapVector<Member<const TreeScope>, 16> otherChain;
496 for (const TreeScope* tree = &other; tree; tree = tree->parentTreeScope()) 496 for (const TreeScope* tree = &other; tree; tree = tree->parentTreeScope())
497 otherChain.append(tree); 497 otherChain.append(tree);
498 498
499 // Keep popping out the last elements of these chains until a mismatched pai r is found. If |this| and |other| 499 // Keep popping out the last elements of these chains until a mismatched pai r is found. If |this| and |other|
500 // belong to different documents, null will be returned. 500 // belong to different documents, null will be returned.
501 const TreeScope* lastAncestor = nullptr; 501 const TreeScope* lastAncestor = nullptr;
502 while (!thisChain.isEmpty() && !otherChain.isEmpty() && thisChain.last() == otherChain.last()) { 502 while (!thisChain.isEmpty() && !otherChain.isEmpty() && thisChain.last() == otherChain.last()) {
503 lastAncestor = thisChain.last(); 503 lastAncestor = thisChain.last();
504 thisChain.removeLast(); 504 thisChain.removeLast();
505 otherChain.removeLast(); 505 otherChain.removeLast();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 visitor->trace(m_idTargetObserverRegistry); 576 visitor->trace(m_idTargetObserverRegistry);
577 visitor->trace(m_selection); 577 visitor->trace(m_selection);
578 visitor->trace(m_elementsById); 578 visitor->trace(m_elementsById);
579 visitor->trace(m_imageMapsByName); 579 visitor->trace(m_imageMapsByName);
580 visitor->trace(m_labelsByForAttribute); 580 visitor->trace(m_labelsByForAttribute);
581 visitor->trace(m_scopedStyleResolver); 581 visitor->trace(m_scopedStyleResolver);
582 visitor->trace(m_radioButtonGroupScope); 582 visitor->trace(m_radioButtonGroupScope);
583 } 583 }
584 584
585 } // namespace blink 585 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/TreeScope.h ('k') | third_party/WebKit/Source/core/dom/TreeScopeAdopter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698