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

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() const
157 {
158 ASSERT(m_innerNode);
159 HTMLImageElement* imageElement = nullptr;
160 if (isHTMLImageElement(m_innerNode)) {
161 imageElement = toHTMLImageElement(m_innerNode);
162 } else if (m_innerNode->isInShadowTree()) {
163 if (m_innerNode->containingShadowRoot()->type() == ShadowRoot::UserAgent ShadowRoot) {
164 if (isHTMLImageElement(m_innerNode->shadowHost()))
165 imageElement = toHTMLImageElement(m_innerNode->shadowHost());
166 }
167 }
168
169 if (!imageElement)
170 return nullptr;
171
172 HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement->fa stGetAttribute(usemapAttr));
173 if (!map)
174 return nullptr;
175
176 LayoutBox* box = toLayoutBox(layoutObject());
177 LayoutRect contentBox = box->contentBoxRect();
178 float scaleFactor = 1 / box->style()->effectiveZoom();
179 LayoutPoint location = localPoint();
180 location.scale(scaleFactor, scaleFactor);
181
182 return map->areaForPoint(location, contentBox.size());
183 }
184
156 void HitTestResult::setInnerNode(Node* n) 185 void HitTestResult::setInnerNode(Node* n)
157 { 186 {
158 m_innerPossiblyPseudoNode = n; 187 m_innerPossiblyPseudoNode = n;
159 if (n && n->isPseudoElement()) 188 if (n && n->isPseudoElement())
160 n = toPseudoElement(n)->findAssociatedNode(); 189 n = toPseudoElement(n)->findAssociatedNode();
161 m_innerNode = n; 190 m_innerNode = n;
191 if (HTMLAreaElement* area = imageAreaForImage())
192 m_innerNode = area;
162 } 193 }
163 194
164 void HitTestResult::setURLElement(Element* n) 195 void HitTestResult::setURLElement(Element* n)
165 { 196 {
166 m_innerURLElement = n; 197 m_innerURLElement = n;
167 } 198 }
168 199
169 void HitTestResult::setScrollbar(Scrollbar* s) 200 void HitTestResult::setScrollbar(Scrollbar* s)
170 { 201 {
171 m_scrollbar = s; 202 m_scrollbar = s;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 else if (isHTMLMapElement(m_innerNode)) 509 else if (isHTMLMapElement(m_innerNode))
479 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 510 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
480 511
481 if (!imageMapImageElement) 512 if (!imageMapImageElement)
482 return m_innerNode.get(); 513 return m_innerNode.get();
483 514
484 return imageMapImageElement; 515 return imageMapImageElement;
485 } 516 }
486 517
487 } // namespace blink 518 } // 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