OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include <limits> | 49 #include <limits> |
50 | 50 |
51 using namespace std; | 51 using namespace std; |
52 | 52 |
53 namespace blink { | 53 namespace blink { |
54 | 54 |
55 using namespace HTMLNames; | 55 using namespace HTMLNames; |
56 | 56 |
57 class ImageEventListener : public EventListener { | 57 class ImageEventListener : public EventListener { |
58 public: | 58 public: |
59 static PassRefPtr<ImageEventListener> create(ImageDocument* document) { retu
rn adoptRef(new ImageEventListener(document)); } | 59 static PassRefPtrWillBeRawPtr<ImageEventListener> create(ImageDocument* docu
ment) |
| 60 { |
| 61 return adoptRefWillBeNoop(new ImageEventListener(document)); |
| 62 } |
60 static const ImageEventListener* cast(const EventListener* listener) | 63 static const ImageEventListener* cast(const EventListener* listener) |
61 { | 64 { |
62 return listener->type() == ImageEventListenerType | 65 return listener->type() == ImageEventListenerType |
63 ? static_cast<const ImageEventListener*>(listener) | 66 ? static_cast<const ImageEventListener*>(listener) |
64 : 0; | 67 : 0; |
65 } | 68 } |
66 | 69 |
67 virtual bool operator==(const EventListener& other); | 70 virtual bool operator==(const EventListener& other); |
68 | 71 |
| 72 DEFINE_INLINE_VIRTUAL_TRACE() |
| 73 { |
| 74 visitor->trace(m_doc); |
| 75 EventListener::trace(visitor); |
| 76 } |
| 77 |
69 private: | 78 private: |
70 ImageEventListener(ImageDocument* document) | 79 ImageEventListener(ImageDocument* document) |
71 : EventListener(ImageEventListenerType) | 80 : EventListener(ImageEventListenerType) |
72 , m_doc(document) | 81 , m_doc(document) |
73 { | 82 { |
74 } | 83 } |
75 | 84 |
76 virtual void handleEvent(ExecutionContext*, Event*); | 85 virtual void handleEvent(ExecutionContext*, Event*); |
77 | 86 |
78 ImageDocument* m_doc; | 87 RawPtrWillBeMember<ImageDocument> m_doc; |
79 }; | 88 }; |
80 | 89 |
81 class ImageDocumentParser : public RawDataDocumentParser { | 90 class ImageDocumentParser : public RawDataDocumentParser { |
82 public: | 91 public: |
83 static PassRefPtrWillBeRawPtr<ImageDocumentParser> create(ImageDocument* doc
ument) | 92 static PassRefPtrWillBeRawPtr<ImageDocumentParser> create(ImageDocument* doc
ument) |
84 { | 93 { |
85 return adoptRefWillBeNoop(new ImageDocumentParser(document)); | 94 return adoptRefWillBeNoop(new ImageDocumentParser(document)); |
86 } | 95 } |
87 | 96 |
88 ImageDocument* document() const | 97 ImageDocument* document() const |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 m_imageElement->setAttribute(styleAttr, "-webkit-user-select: none"); | 229 m_imageElement->setAttribute(styleAttr, "-webkit-user-select: none"); |
221 // If the image is multipart, we neglect to mention to the HTMLImageElement
that it's in an | 230 // If the image is multipart, we neglect to mention to the HTMLImageElement
that it's in an |
222 // ImageDocument, so that it requests the image normally. | 231 // ImageDocument, so that it requests the image normally. |
223 if (!loadingMultipartContent) | 232 if (!loadingMultipartContent) |
224 m_imageElement->setLoadingImageDocument(); | 233 m_imageElement->setLoadingImageDocument(); |
225 m_imageElement->setSrc(url().string()); | 234 m_imageElement->setSrc(url().string()); |
226 body->appendChild(m_imageElement.get()); | 235 body->appendChild(m_imageElement.get()); |
227 | 236 |
228 if (shouldShrinkToFit()) { | 237 if (shouldShrinkToFit()) { |
229 // Add event listeners | 238 // Add event listeners |
230 RefPtr<EventListener> listener = ImageEventListener::create(this); | 239 RefPtrWillBeRawPtr<EventListener> listener = ImageEventListener::create(
this); |
231 if (LocalDOMWindow* domWindow = this->domWindow()) | 240 if (LocalDOMWindow* domWindow = this->domWindow()) |
232 domWindow->addEventListener("resize", listener, false); | 241 domWindow->addEventListener("resize", listener, false); |
233 if (m_shrinkToFitMode == Desktop) | 242 if (m_shrinkToFitMode == Desktop) |
234 m_imageElement->addEventListener("click", listener.release(), false)
; | 243 m_imageElement->addEventListener("click", listener.release(), false)
; |
235 } | 244 } |
236 | 245 |
237 rootElement->appendChild(head); | 246 rootElement->appendChild(head); |
238 rootElement->appendChild(body); | 247 rootElement->appendChild(body); |
239 if (loadingMultipartContent) | 248 if (loadingMultipartContent) |
240 finishedParsing(); | 249 finishedParsing(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 } | 452 } |
444 | 453 |
445 bool ImageEventListener::operator==(const EventListener& listener) | 454 bool ImageEventListener::operator==(const EventListener& listener) |
446 { | 455 { |
447 if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
&listener)) | 456 if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
&listener)) |
448 return m_doc == imageEventListener->m_doc; | 457 return m_doc == imageEventListener->m_doc; |
449 return false; | 458 return false; |
450 } | 459 } |
451 | 460 |
452 } | 461 } |
OLD | NEW |