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

Side by Side Diff: third_party/WebKit/Source/core/layout/HitTestResult.cpp

Issue 2770123003: Replace ASSERT with DCHECK in core/layout/ excluding subdirs (Closed)
Patch Set: Split some DCHECKs and add DCHECK_ops wherever possible Created 3 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) 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 shadowHost = &containingShadowRoot->host(); 185 shadowHost = &containingShadowRoot->host();
186 containingShadowRoot = shadowHost->containingShadowRoot(); 186 containingShadowRoot = shadowHost->containingShadowRoot();
187 setInnerNode(node->ownerShadowHost()); 187 setInnerNode(node->ownerShadowHost());
188 } 188 }
189 189
190 if (shadowHost) 190 if (shadowHost)
191 setInnerNode(shadowHost); 191 setInnerNode(shadowHost);
192 } 192 }
193 193
194 HTMLAreaElement* HitTestResult::imageAreaForImage() const { 194 HTMLAreaElement* HitTestResult::imageAreaForImage() const {
195 ASSERT(m_innerNode); 195 DCHECK(m_innerNode);
196 HTMLImageElement* imageElement = nullptr; 196 HTMLImageElement* imageElement = nullptr;
197 if (isHTMLImageElement(m_innerNode)) { 197 if (isHTMLImageElement(m_innerNode)) {
198 imageElement = toHTMLImageElement(m_innerNode); 198 imageElement = toHTMLImageElement(m_innerNode);
199 } else if (m_innerNode->isInShadowTree()) { 199 } else if (m_innerNode->isInShadowTree()) {
200 if (m_innerNode->containingShadowRoot()->type() == 200 if (m_innerNode->containingShadowRoot()->type() ==
201 ShadowRootType::UserAgent) { 201 ShadowRootType::UserAgent) {
202 if (isHTMLImageElement(m_innerNode->ownerShadowHost())) 202 if (isHTMLImageElement(m_innerNode->ownerShadowHost()))
203 imageElement = toHTMLImageElement(m_innerNode->ownerShadowHost()); 203 imageElement = toHTMLImageElement(m_innerNode->ownerShadowHost());
204 } 204 }
205 } 205 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 mutableListBasedTestResult().insert(node); 433 mutableListBasedTestResult().insert(node);
434 434
435 if (hitTestRequest().penetratingList()) 435 if (hitTestRequest().penetratingList())
436 return ContinueHitTesting; 436 return ContinueHitTesting;
437 437
438 return region.contains(location.boundingBox()) ? StopHitTesting 438 return region.contains(location.boundingBox()) ? StopHitTesting
439 : ContinueHitTesting; 439 : ContinueHitTesting;
440 } 440 }
441 441
442 void HitTestResult::append(const HitTestResult& other) { 442 void HitTestResult::append(const HitTestResult& other) {
443 ASSERT(hitTestRequest().listBased()); 443 DCHECK(hitTestRequest().listBased());
444 444
445 if (!m_scrollbar && other.scrollbar()) { 445 if (!m_scrollbar && other.scrollbar()) {
446 setScrollbar(other.scrollbar()); 446 setScrollbar(other.scrollbar());
447 } 447 }
448 448
449 if (!m_innerNode && other.innerNode()) { 449 if (!m_innerNode && other.innerNode()) {
450 m_innerNode = other.innerNode(); 450 m_innerNode = other.innerNode();
451 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); 451 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode();
452 m_localPoint = other.localPoint(); 452 m_localPoint = other.localPoint();
453 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; 453 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame;
(...skipping 19 matching lines...) Expand all
473 473
474 HitTestResult::NodeSet& HitTestResult::mutableListBasedTestResult() { 474 HitTestResult::NodeSet& HitTestResult::mutableListBasedTestResult() {
475 if (!m_listBasedTestResult) 475 if (!m_listBasedTestResult)
476 m_listBasedTestResult = new NodeSet; 476 m_listBasedTestResult = new NodeSet;
477 return *m_listBasedTestResult; 477 return *m_listBasedTestResult;
478 } 478 }
479 479
480 void HitTestResult::resolveRectBasedTest( 480 void HitTestResult::resolveRectBasedTest(
481 Node* resolvedInnerNode, 481 Node* resolvedInnerNode,
482 const LayoutPoint& resolvedPointInMainFrame) { 482 const LayoutPoint& resolvedPointInMainFrame) {
483 ASSERT(isRectBasedTest()); 483 DCHECK(isRectBasedTest());
484 ASSERT(m_hitTestLocation.containsPoint(FloatPoint(resolvedPointInMainFrame))); 484 DCHECK(m_hitTestLocation.containsPoint(FloatPoint(resolvedPointInMainFrame)));
485 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame); 485 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame);
486 m_pointInInnerNodeFrame = resolvedPointInMainFrame; 486 m_pointInInnerNodeFrame = resolvedPointInMainFrame;
487 m_innerNode = nullptr; 487 m_innerNode = nullptr;
488 m_innerPossiblyPseudoNode = nullptr; 488 m_innerPossiblyPseudoNode = nullptr;
489 m_listBasedTestResult = nullptr; 489 m_listBasedTestResult = nullptr;
490 490
491 // Update the HitTestResult as if the supplied node had been hit in normal 491 // Update the HitTestResult as if the supplied node had been hit in normal
492 // point-based hit-test. 492 // point-based hit-test.
493 // Note that we don't know the local point after a rect-based hit-test, but we 493 // Note that we don't know the local point after a rect-based hit-test, but we
494 // never use it so shouldn't bother with the cost of computing it. 494 // never use it so shouldn't bother with the cost of computing it.
495 resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint()); 495 resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint());
496 ASSERT(!isRectBasedTest()); 496 DCHECK(!isRectBasedTest());
497 } 497 }
498 498
499 Element* HitTestResult::innerElement() const { 499 Element* HitTestResult::innerElement() const {
500 for (Node* node = m_innerNode.get(); node; 500 for (Node* node = m_innerNode.get(); node;
501 node = FlatTreeTraversal::parent(*node)) { 501 node = FlatTreeTraversal::parent(*node)) {
502 if (node->isElementNode()) 502 if (node->isElementNode())
503 return toElement(node); 503 return toElement(node);
504 } 504 }
505 505
506 return nullptr; 506 return nullptr;
507 } 507 }
508 508
509 Node* HitTestResult::innerNodeOrImageMapImage() const { 509 Node* HitTestResult::innerNodeOrImageMapImage() const {
510 if (!m_innerNode) 510 if (!m_innerNode)
511 return nullptr; 511 return nullptr;
512 512
513 HTMLImageElement* imageMapImageElement = nullptr; 513 HTMLImageElement* imageMapImageElement = nullptr;
514 if (isHTMLAreaElement(m_innerNode)) 514 if (isHTMLAreaElement(m_innerNode))
515 imageMapImageElement = toHTMLAreaElement(m_innerNode)->imageElement(); 515 imageMapImageElement = toHTMLAreaElement(m_innerNode)->imageElement();
516 else if (isHTMLMapElement(m_innerNode)) 516 else if (isHTMLMapElement(m_innerNode))
517 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 517 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
518 518
519 if (!imageMapImageElement) 519 if (!imageMapImageElement)
520 return m_innerNode.get(); 520 return m_innerNode.get();
521 521
522 return imageMapImageElement; 522 return imageMapImageElement;
523 } 523 }
524 524
525 } // namespace blink 525 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698