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

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

Issue 1119813002: Use the correct node when hit testing on an image map (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/replaced/image-map-alt-content-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 HTMLImageElement* imageElement = nullptr; 159 HTMLImageElement* imageElement = nullptr;
160 if (isHTMLImageElement(m_innerNode)) { 160 if (isHTMLImageElement(m_innerNode)) {
161 imageElement = toHTMLImageElement(m_innerNode); 161 imageElement = toHTMLImageElement(m_innerNode);
162 } else if (m_innerNode->isInShadowTree()) { 162 } else if (m_innerNode->isInShadowTree()) {
163 if (m_innerNode->containingShadowRoot()->type() == ShadowRoot::UserAgent ShadowRoot) { 163 if (m_innerNode->containingShadowRoot()->type() == ShadowRoot::UserAgent ShadowRoot) {
164 if (isHTMLImageElement(m_innerNode->shadowHost())) 164 if (isHTMLImageElement(m_innerNode->shadowHost()))
165 imageElement = toHTMLImageElement(m_innerNode->shadowHost()); 165 imageElement = toHTMLImageElement(m_innerNode->shadowHost());
166 } 166 }
167 } 167 }
168 168
169 if (!imageElement) 169 if (!imageElement || !imageElement->layoutObject())
170 return nullptr; 170 return nullptr;
171 171
172 HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement->fa stGetAttribute(usemapAttr)); 172 HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement->fa stGetAttribute(usemapAttr));
173 if (!map) 173 if (!map)
174 return nullptr; 174 return nullptr;
175 175
176 LayoutBox* box = toLayoutBox(layoutObject()); 176 LayoutBox* box = toLayoutBox(imageElement->layoutObject());
177 LayoutRect contentBox = box->contentBoxRect(); 177 LayoutRect contentBox = box->contentBoxRect();
178 float scaleFactor = 1 / box->style()->effectiveZoom(); 178 float scaleFactor = 1 / box->style()->effectiveZoom();
179 LayoutPoint location = localPoint(); 179 LayoutPoint location = localPoint();
180 location.scale(scaleFactor, scaleFactor); 180 location.scale(scaleFactor, scaleFactor);
181 181
182 return map->areaForPoint(location, contentBox.size()); 182 return map->areaForPoint(location, contentBox.size());
183 } 183 }
184 184
185 void HitTestResult::setInnerNode(Node* n) 185 void HitTestResult::setInnerNode(Node* n)
186 { 186 {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 else if (isHTMLMapElement(m_innerNode)) 509 else if (isHTMLMapElement(m_innerNode))
510 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 510 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
511 511
512 if (!imageMapImageElement) 512 if (!imageMapImageElement)
513 return m_innerNode.get(); 513 return m_innerNode.get();
514 514
515 return imageMapImageElement; 515 return imageMapImageElement;
516 } 516 }
517 517
518 } // namespace blink 518 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/replaced/image-map-alt-content-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698