Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 } | 188 } |
| 189 | 189 |
| 190 return 0; | 190 return 0; |
| 191 } | 191 } |
| 192 | 192 |
| 193 void HTMLCanvasElement::didDraw(const FloatRect& rect) | 193 void HTMLCanvasElement::didDraw(const FloatRect& rect) |
| 194 { | 194 { |
| 195 clearCopiedImage(); | 195 clearCopiedImage(); |
| 196 | 196 |
| 197 if (RenderBox* ro = renderBox()) { | 197 if (RenderBox* ro = renderBox()) { |
| 198 FloatRect destRect = ro->contentBoxRect(); | 198 FloatRect srcRect(0, 0, size().width(), size().height()); |
| 199 FloatRect r = mapRect(rect, FloatRect(0, 0, size().width(), size().heigh t()), destRect); | 199 FloatRect r = rect; |
| 200 r.intersect(destRect); | 200 r.intersect(srcRect); |
| 201 if (r.isEmpty() || m_dirtyRect.contains(r)) | 201 if (r.isEmpty() || m_dirtyRect.contains(r)) |
| 202 return; | 202 return; |
| 203 m_dirtyRect.unite(r); | |
| 204 FloatRect mappedDirtyRect = mapRect(r, srcRect, ro->contentBoxRect()); | |
|
Justin Novosad
2014/07/17 15:13:24
The change to this function does not actually fix
| |
| 203 | 205 |
| 204 m_dirtyRect.unite(r); | 206 ro->invalidatePaintRectangle(enclosingIntRect(mappedDirtyRect)); |
| 205 ro->invalidatePaintRectangle(enclosingIntRect(m_dirtyRect)); | |
| 206 } | 207 } |
| 207 | 208 |
| 208 notifyObserversCanvasChanged(rect); | 209 notifyObserversCanvasChanged(rect); |
| 209 } | 210 } |
| 210 | 211 |
| 212 void HTMLCanvasElement::didPresent() | |
| 213 { | |
| 214 // Canvas was presented externally (without going through paint()) | |
| 215 m_dirtyRect = FloatRect(); | |
| 216 } | |
| 217 | |
| 211 void HTMLCanvasElement::notifyObserversCanvasChanged(const FloatRect& rect) | 218 void HTMLCanvasElement::notifyObserversCanvasChanged(const FloatRect& rect) |
| 212 { | 219 { |
| 213 WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator end = m _observers.end(); | 220 WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator end = m _observers.end(); |
| 214 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator it = m_observers.begin(); it != end; ++it) | 221 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator it = m_observers.begin(); it != end; ++it) |
| 215 (*it)->canvasChanged(this, rect); | 222 (*it)->canvasChanged(this, rect); |
| 216 } | 223 } |
| 217 | 224 |
| 218 void HTMLCanvasElement::reset() | 225 void HTMLCanvasElement::reset() |
| 219 { | 226 { |
| 220 if (m_ignoreReset) | 227 if (m_ignoreReset) |
| 221 return; | 228 return; |
| 222 | 229 |
| 230 m_dirtyRect = FloatRect(); | |
| 231 | |
| 223 bool ok; | 232 bool ok; |
| 224 bool hadImageBuffer = hasImageBuffer(); | 233 bool hadImageBuffer = hasImageBuffer(); |
| 225 | 234 |
| 226 int w = getAttribute(widthAttr).toInt(&ok); | 235 int w = getAttribute(widthAttr).toInt(&ok); |
| 227 if (!ok || w < 0) | 236 if (!ok || w < 0) |
| 228 w = DefaultWidth; | 237 w = DefaultWidth; |
| 229 | 238 |
| 230 int h = getAttribute(heightAttr).toInt(&ok); | 239 int h = getAttribute(heightAttr).toInt(&ok); |
| 231 if (!ok || h < 0) | 240 if (!ok || h < 0) |
| 232 h = DefaultHeight; | 241 h = DefaultHeight; |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 { | 701 { |
| 693 return !originClean(); | 702 return !originClean(); |
| 694 } | 703 } |
| 695 | 704 |
| 696 FloatSize HTMLCanvasElement::sourceSize() const | 705 FloatSize HTMLCanvasElement::sourceSize() const |
| 697 { | 706 { |
| 698 return FloatSize(width(), height()); | 707 return FloatSize(width(), height()); |
| 699 } | 708 } |
| 700 | 709 |
| 701 } | 710 } |
| OLD | NEW |