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

Side by Side Diff: Source/core/layout/LayoutImage.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/LayoutBlock.cpp ('k') | Source/core/layout/LayoutInline.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 { 289 {
290 HTMLImageElement* i = isHTMLImageElement(node()) ? toHTMLImageElement(node() ) : 0; 290 HTMLImageElement* i = isHTMLImageElement(node()) ? toHTMLImageElement(node() ) : 0;
291 return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0; 291 return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0;
292 } 292 }
293 293
294 bool LayoutImage::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca tionInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestActi on) 294 bool LayoutImage::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca tionInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestActi on)
295 { 295 {
296 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation()); 296 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation());
297 bool inside = LayoutReplaced::nodeAtPoint(tempResult, locationInContainer, a ccumulatedOffset, hitTestAction); 297 bool inside = LayoutReplaced::nodeAtPoint(tempResult, locationInContainer, a ccumulatedOffset, hitTestAction);
298 298
299 if (tempResult.innerNode() && node()) {
300 if (HTMLMapElement* map = imageMap()) {
301 LayoutRect contentBox = contentBoxRect();
302 float scaleFactor = 1 / style()->effectiveZoom();
303 LayoutPoint location = locationInContainer.point() - toLayoutSize(ac cumulatedOffset) - locationOffset() - toLayoutSize(contentBox.location());
304 location.scale(scaleFactor, scaleFactor);
305
306 if (HTMLAreaElement* area = map->areaForPoint(location, contentBox.s ize())) {
307 tempResult.setInnerNode(area);
308 tempResult.setURLElement(area);
309 }
310 }
311 }
312
313 if (!inside && result.hitTestRequest().listBased()) 299 if (!inside && result.hitTestRequest().listBased())
314 result.append(tempResult); 300 result.append(tempResult);
315 if (inside) 301 if (inside)
316 result = tempResult; 302 result = tempResult;
317 return inside; 303 return inside;
318 } 304 }
319 305
320 void LayoutImage::layout() 306 void LayoutImage::layout()
321 { 307 {
322 LayoutReplaced::layout(); 308 LayoutReplaced::layout();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return 0; 373 return 0;
388 374
389 ImageResource* cachedImage = m_imageResource->cachedImage(); 375 ImageResource* cachedImage = m_imageResource->cachedImage();
390 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 376 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
391 return toSVGImage(cachedImage->image())->embeddedContentBox(); 377 return toSVGImage(cachedImage->image())->embeddedContentBox();
392 378
393 return 0; 379 return 0;
394 } 380 }
395 381
396 } // namespace blink 382 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlock.cpp ('k') | Source/core/layout/LayoutInline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698