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

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

Issue 1094133004: Image maps should work for images with alt content (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/HitTestResult.h ('k') | Source/core/layout/LayoutBlock.cpp » ('j') | 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void HitTestResult::setToShadowHostIfInUserAgentShadowRoot() 146 void HitTestResult::setToShadowHostIfInUserAgentShadowRoot()
147 { 147 {
148 if (Node* node = innerNode()) { 148 if (Node* node = innerNode()) {
149 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { 149 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) {
150 if (containingShadowRoot->type() == ShadowRoot::UserAgentShadowRoot) 150 if (containingShadowRoot->type() == ShadowRoot::UserAgentShadowRoot)
151 setInnerNode(node->shadowHost()); 151 setInnerNode(node->shadowHost());
152 } 152 }
153 } 153 }
154 } 154 }
155 155
156 HTMLAreaElement* HitTestResult::imageAreaForImage()
pdr. 2015/04/26 02:59:15 Lets make this function const since it doesn't mod
157 {
158 HTMLImageElement* imageElement = nullptr;
pdr. 2015/04/26 02:59:15 Even though we check it all over, I don't think m_
159 if (isHTMLImageElement(innerNode()))
160 imageElement = toHTMLImageElement(innerNode());
161 else if (isHTMLImageElement(innerNode()->shadowHost()))
pdr. 2015/04/26 02:59:15 I think we need to limit this to user agent shadow
162 imageElement = toHTMLImageElement(innerNode()->shadowHost());
163
164 if (!imageElement)
165 return nullptr;
166
167 LayoutBox* box = toLayoutBox(layoutObject());
pdr. 2015/04/26 02:59:15 Nit: this can be moved inside the map conditional
168 LayoutRect contentBox = box->contentBoxRect();
169 float scaleFactor = 1 / box->style()->effectiveZoom();
170 LayoutPoint location = localPoint();
171 location.scale(scaleFactor, scaleFactor);
172
173 if (HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement ->fastGetAttribute(usemapAttr)))
174 return map->areaForPoint(location, contentBox.size());
175 return nullptr;
176 }
177
156 void HitTestResult::setInnerNode(Node* n) 178 void HitTestResult::setInnerNode(Node* n)
157 { 179 {
158 m_innerPossiblyPseudoNode = n; 180 m_innerPossiblyPseudoNode = n;
159 if (n && n->isPseudoElement()) 181 if (n && n->isPseudoElement())
160 n = toPseudoElement(n)->findAssociatedNode(); 182 n = toPseudoElement(n)->findAssociatedNode();
161 m_innerNode = n; 183 m_innerNode = n;
184 if (HTMLAreaElement* area = imageAreaForImage())
185 m_innerNode = area;
162 } 186 }
163 187
164 void HitTestResult::setURLElement(Element* n) 188 void HitTestResult::setURLElement(Element* n)
165 { 189 {
166 m_innerURLElement = n; 190 m_innerURLElement = n;
167 } 191 }
168 192
169 void HitTestResult::setScrollbar(Scrollbar* s) 193 void HitTestResult::setScrollbar(Scrollbar* s)
170 { 194 {
171 m_scrollbar = s; 195 m_scrollbar = s;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 else if (isHTMLMapElement(m_innerNode)) 502 else if (isHTMLMapElement(m_innerNode))
479 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 503 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
480 504
481 if (!imageMapImageElement) 505 if (!imageMapImageElement)
482 return m_innerNode.get(); 506 return m_innerNode.get();
483 507
484 return imageMapImageElement; 508 return imageMapImageElement;
485 } 509 }
486 510
487 } // namespace blink 511 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestResult.h ('k') | Source/core/layout/LayoutBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698