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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/HitTestResult.h ('k') | Source/core/layout/LayoutBlock.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/HitTestResult.cpp
diff --git a/Source/core/layout/HitTestResult.cpp b/Source/core/layout/HitTestResult.cpp
index 67ff7574695ae358d378b24caf21c635c7a567a9..1b8e0352cc63c2d58a4668f3cad5cfdde35837d0 100644
--- a/Source/core/layout/HitTestResult.cpp
+++ b/Source/core/layout/HitTestResult.cpp
@@ -153,12 +153,36 @@ void HitTestResult::setToShadowHostIfInUserAgentShadowRoot()
}
}
+HTMLAreaElement* HitTestResult::imageAreaForImage()
pdr. 2015/04/26 02:59:15 Lets make this function const since it doesn't mod
+{
+ HTMLImageElement* imageElement = nullptr;
pdr. 2015/04/26 02:59:15 Even though we check it all over, I don't think m_
+ if (isHTMLImageElement(innerNode()))
+ imageElement = toHTMLImageElement(innerNode());
+ else if (isHTMLImageElement(innerNode()->shadowHost()))
pdr. 2015/04/26 02:59:15 I think we need to limit this to user agent shadow
+ imageElement = toHTMLImageElement(innerNode()->shadowHost());
+
+ if (!imageElement)
+ return nullptr;
+
+ LayoutBox* box = toLayoutBox(layoutObject());
pdr. 2015/04/26 02:59:15 Nit: this can be moved inside the map conditional
+ LayoutRect contentBox = box->contentBoxRect();
+ float scaleFactor = 1 / box->style()->effectiveZoom();
+ LayoutPoint location = localPoint();
+ location.scale(scaleFactor, scaleFactor);
+
+ if (HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement->fastGetAttribute(usemapAttr)))
+ return map->areaForPoint(location, contentBox.size());
+ return nullptr;
+}
+
void HitTestResult::setInnerNode(Node* n)
{
m_innerPossiblyPseudoNode = n;
if (n && n->isPseudoElement())
n = toPseudoElement(n)->findAssociatedNode();
m_innerNode = n;
+ if (HTMLAreaElement* area = imageAreaForImage())
+ m_innerNode = area;
}
void HitTestResult::setURLElement(Element* n)
« 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