Changeset 77313 in webkit
- Timestamp:
- Feb 1, 2011 2:49:01 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r77311 r77313 1 2011-02-01 Darin Adler <darin@apple.com> 2 3 Reviewed by Chris Fleizach. 4 5 REGRESSION: Removing focus from area element causes unwanted scrolling 6 https://bugs.webkit.org/show_bug.cgi?id=50169 7 8 * fast/images/imagemap-scroll-expected.txt: Added. 9 * fast/images/imagemap-scroll.html: Added. 10 1 11 2011-02-01 Zhenyao Mo <zmo@google.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r77311 r77313 1 2011-02-01 Darin Adler <darin@apple.com> 2 3 Reviewed by Chris Fleizach. 4 5 REGRESSION: Removing focus from area element causes unwanted scrolling 6 https://bugs.webkit.org/show_bug.cgi?id=50169 7 8 Test: fast/images/imagemap-scroll.html 9 10 * html/HTMLAreaElement.cpp: 11 (WebCore::HTMLAreaElement::setFocus): Added override. Calls the new 12 RenderImage::areaElementFocusChanged function. 13 (WebCore::HTMLAreaElement::updateFocusAppearance): Removed the code 14 here that calls setNeedsLayout on the image's renderer. This was an 15 attempt to cause repaint of the renderer, but this function does not 16 need to do that. Also changed this to use the imageElement function 17 to avoid repeating code. 18 19 * html/HTMLAreaElement.h: Updated for above changes. 20 21 * rendering/RenderImage.cpp: 22 (WebCore::RenderImage::paint): Updated for name change. 23 (WebCore::RenderImage::paintAreaElementFocusRing): Renamed this from 24 paintFocusRing, because it only paints area focus rings, and should 25 not be confused with paintFocusRing functions in other classes. Also 26 removed the unused style argument. Removed the code that used an 27 HTMLCollection to see if the focused area element is for this image 28 and instead just call imageElement on the area element. 29 (WebCore::RenderImage::areaElementFocusChanged): Added. Calls repaint. 30 31 * rendering/RenderImage.h: Added a public areaElementFocusChanged 32 function for HTMLAreaElement to call. Made the paintFocusRing function 33 private, renamed it to paintAreaElementFocusRing, and removed its 34 unused style argument. 35 1 36 2011-02-01 Patrick Gansterer <paroga@webkit.org> 2 37 -
trunk/Source/WebCore/html/HTMLAreaElement.cpp
r76170 r77313 2 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.4 * Copyright (C) 2004, 2005, 2006, 2009, 2011 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 31 31 #include "HitTestResult.h" 32 32 #include "Path.h" 33 #include "Render Object.h"33 #include "RenderImage.h" 34 34 35 35 using namespace std; … … 197 197 } 198 198 199 void HTMLAreaElement::dispatchBlurEvent() 200 { 201 HTMLAnchorElement::dispatchBlurEvent(); 202 203 // On a blur, we might need to remove our focus rings by repainting. 204 updateFocusAppearance(false); 199 void HTMLAreaElement::setFocus(bool shouldBeFocused) 200 { 201 if (focused() == shouldBeFocused) 202 return; 203 204 HTMLAnchorElement::setFocus(shouldBeFocused); 205 206 HTMLImageElement* imageElement = this->imageElement(); 207 if (!imageElement) 208 return; 209 210 RenderObject* renderer = imageElement->renderer(); 211 if (!renderer || !renderer->isImage()) 212 return; 213 214 toRenderImage(renderer)->areaElementFocusChanged(this); 205 215 } 206 216 … … 209 219 if (!isFocusable()) 210 220 return; 211 212 ContainerNode* parent = parentNode(); 213 if (!parent || !parent->hasTagName(mapTag)) 214 return; 215 216 HTMLImageElement* imageElement = static_cast<HTMLMapElement*>(parent)->imageElement(); 221 222 HTMLImageElement* imageElement = this->imageElement(); 217 223 if (!imageElement) 218 224 return; 219 220 // This will handle scrolling to the image if necessary. 225 221 226 imageElement->updateFocusAppearance(restorePreviousSelection); 222 223 RenderObject* imageRenderer = imageElement->renderer();224 if (imageRenderer)225 imageRenderer->setNeedsLayout(true);226 227 } 227 228 -
trunk/Source/WebCore/html/HTMLAreaElement.h
r69237 r77313 2 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved.4 * Copyright (C) 2004, 2008, 2009, 2011 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 58 58 virtual bool isFocusable() const; 59 59 virtual void updateFocusAppearance(bool /*restorePreviousSelection*/); 60 virtual void dispatchBlurEvent();60 virtual void setFocus(bool); 61 61 62 62 enum Shape { Default, Poly, Rect, Circle, Unknown }; -
trunk/Source/WebCore/rendering/RenderImage.cpp
r76866 r77313 5 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 6 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 8 8 * Copyright (C) 2010 Google Inc. All rights reserved. 9 9 * … … 31 31 #include "GraphicsContext.h" 32 32 #include "HTMLAreaElement.h" 33 #include "HTMLCollection.h"34 33 #include "HTMLImageElement.h" 35 34 #include "HTMLInputElement.h" … … 39 38 #include "Page.h" 40 39 #include "RenderLayer.h" 41 #include "RenderTheme.h"42 40 #include "RenderView.h" 43 41 #include "SelectionController.h" 44 42 #include "TextRun.h" 45 #include <wtf/CurrentTime.h>46 43 #include <wtf/UnusedParam.h> 47 44 … … 325 322 326 323 if (paintInfo.phase == PaintPhaseOutline) 327 paint FocusRing(paintInfo, style());324 paintAreaElementFocusRing(paintInfo); 328 325 } 329 326 330 void RenderImage::paintFocusRing(PaintInfo& paintInfo, const RenderStyle*) 331 { 332 // Don't draw focus rings if printing. 333 if (document()->printing() || !frame()->selection()->isFocusedAndActive()) 327 void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo) 328 { 329 Document* document = this->document(); 330 331 if (document->printing() || !document->frame()->selection()->isFocusedAndActive()) 334 332 return; 335 333 … … 337 335 return; 338 336 339 HTMLMapElement* mapElement = imageMap();340 if (!mapElement)341 return;342 343 Document* document = mapElement->document();344 if (!document)345 return;346 347 337 Node* focusedNode = document->focusedNode(); 348 if (!focusedNode) 349 return; 350 351 RefPtr<HTMLCollection> areas = mapElement->areas(); 352 unsigned numAreas = areas->length(); 353 354 // FIXME: Clip the paths to the image bounding box. 355 for (unsigned k = 0; k < numAreas; ++k) { 356 HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(areas->item(k)); 357 if (focusedNode != areaElement) 358 continue; 359 360 RenderStyle* styleToUse = areaElement->computedStyle(); 361 if (theme()->supportsFocusRing(styleToUse)) 362 return; // The theme draws the focus ring. 363 paintInfo.context->drawFocusRing(areaElement->getPath(this), styleToUse->outlineWidth(), styleToUse->outlineOffset(), styleToUse->visitedDependentColor(CSSPropertyOutlineColor)); 364 break; 365 } 366 } 367 338 if (!focusedNode || !focusedNode->hasTagName(areaTag)) 339 return; 340 341 HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(focusedNode); 342 if (areaElement->imageElement() != node()) 343 return; 344 345 // Even if the theme handles focus ring drawing for entire elements, it won't do it for 346 // an area within an image, so we don't call RenderTheme::supportsFocusRing here. 347 348 Path path = areaElement->getPath(this); 349 if (path.isEmpty()) 350 return; 351 352 // FIXME: Do we need additional code to clip the path to the image's bounding box? 353 354 RenderStyle* areaElementStyle = areaElement->computedStyle(); 355 paintInfo.context->drawFocusRing(path, areaElementStyle->outlineWidth(), areaElementStyle->outlineOffset(), 356 areaElementStyle->visitedDependentColor(CSSPropertyOutlineColor)); 357 } 358 359 void RenderImage::areaElementFocusChanged(HTMLAreaElement* element) 360 { 361 ASSERT_UNUSED(element, element->imageElement() == node()); 362 363 // It would be more efficient to only repaint the focus ring rectangle 364 // for the passed-in area element. That would require adding functions 365 // to the area element class. 366 repaint(); 367 } 368 368 369 void RenderImage::paintIntoRect(GraphicsContext* context, const IntRect& rect) 369 370 { -
trunk/Source/WebCore/rendering/RenderImage.h
r72528 r77313 4 4 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 5 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 31 31 namespace WebCore { 32 32 33 class HTMLAreaElement; 33 34 class HTMLMapElement; 34 35 … … 49 50 50 51 HTMLMapElement* imageMap() const; 52 void areaElementFocusChanged(HTMLAreaElement*); 51 53 52 54 void highQualityRepaintTimerFired(Timer<RenderImage>*); … … 58 60 59 61 virtual void paintIntoRect(GraphicsContext*, const IntRect&); 60 void paintFocusRing(PaintInfo&, const RenderStyle*);61 62 virtual void paint(PaintInfo&, int tx, int ty); 62 63 … … 92 93 int calcAspectRatioLogicalHeight() const; 93 94 95 void paintAreaElementFocusRing(PaintInfo&); 96 94 97 // Text to display as long as the image isn't available. 95 98 String m_altText;
Note: See TracChangeset
for help on using the changeset viewer.