| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 160 } | 160 } | 
| 161 | 161 | 
| 162 PassRefPtr<DocumentParser> ImageDocument::createParser() | 162 PassRefPtr<DocumentParser> ImageDocument::createParser() | 
| 163 { | 163 { | 
| 164     return ImageDocumentParser::create(this); | 164     return ImageDocumentParser::create(this); | 
| 165 } | 165 } | 
| 166 | 166 | 
| 167 void ImageDocument::createDocumentStructure() | 167 void ImageDocument::createDocumentStructure() | 
| 168 { | 168 { | 
| 169     RefPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(this); | 169     RefPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(this); | 
| 170     appendChild(rootElement, ASSERT_NO_EXCEPTION_STATE, AttachLazily); | 170     appendChild(rootElement, ASSERT_NO_EXCEPTION, AttachLazily); | 
| 171     rootElement->insertedByParser(); | 171     rootElement->insertedByParser(); | 
| 172 | 172 | 
| 173     if (frame() && frame()->loader()) | 173     if (frame() && frame()->loader()) | 
| 174         frame()->loader()->dispatchDocumentElementAvailable(); | 174         frame()->loader()->dispatchDocumentElementAvailable(); | 
| 175 | 175 | 
| 176     RefPtr<HTMLHeadElement> head = HTMLHeadElement::create(this); | 176     RefPtr<HTMLHeadElement> head = HTMLHeadElement::create(this); | 
| 177     RefPtr<HTMLMetaElement> meta = HTMLMetaElement::create(this); | 177     RefPtr<HTMLMetaElement> meta = HTMLMetaElement::create(this); | 
| 178     meta->setAttribute(nameAttr, "viewport"); | 178     meta->setAttribute(nameAttr, "viewport"); | 
| 179     meta->setAttribute(contentAttr, "width=device-width"); | 179     meta->setAttribute(contentAttr, "width=device-width"); | 
| 180     head->appendChild(meta, ASSERT_NO_EXCEPTION_STATE, AttachLazily); | 180     head->appendChild(meta, ASSERT_NO_EXCEPTION, AttachLazily); | 
| 181 | 181 | 
| 182     RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(this); | 182     RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(this); | 
| 183     body->setAttribute(styleAttr, "margin: 0px;"); | 183     body->setAttribute(styleAttr, "margin: 0px;"); | 
| 184 | 184 | 
| 185     m_imageElement = HTMLImageElement::create(this); | 185     m_imageElement = HTMLImageElement::create(this); | 
| 186     m_imageElement->setAttribute(styleAttr, "-webkit-user-select: none"); | 186     m_imageElement->setAttribute(styleAttr, "-webkit-user-select: none"); | 
| 187     m_imageElement->setLoadManually(true); | 187     m_imageElement->setLoadManually(true); | 
| 188     m_imageElement->setSrc(url().string()); | 188     m_imageElement->setSrc(url().string()); | 
| 189     body->appendChild(m_imageElement.get(), ASSERT_NO_EXCEPTION_STATE, AttachLaz
     ily); | 189     body->appendChild(m_imageElement.get(), ASSERT_NO_EXCEPTION, AttachLazily); | 
| 190 | 190 | 
| 191     if (shouldShrinkToFit()) { | 191     if (shouldShrinkToFit()) { | 
| 192         // Add event listeners | 192         // Add event listeners | 
| 193         RefPtr<EventListener> listener = ImageEventListener::create(this); | 193         RefPtr<EventListener> listener = ImageEventListener::create(this); | 
| 194         if (DOMWindow* domWindow = this->domWindow()) | 194         if (DOMWindow* domWindow = this->domWindow()) | 
| 195             domWindow->addEventListener("resize", listener, false); | 195             domWindow->addEventListener("resize", listener, false); | 
| 196         m_imageElement->addEventListener("click", listener.release(), false); | 196         m_imageElement->addEventListener("click", listener.release(), false); | 
| 197     } | 197     } | 
| 198 | 198 | 
| 199     rootElement->appendChild(head, ASSERT_NO_EXCEPTION_STATE, AttachLazily); | 199     rootElement->appendChild(head, ASSERT_NO_EXCEPTION, AttachLazily); | 
| 200     rootElement->appendChild(body, ASSERT_NO_EXCEPTION_STATE, AttachLazily); | 200     rootElement->appendChild(body, ASSERT_NO_EXCEPTION, AttachLazily); | 
| 201 } | 201 } | 
| 202 | 202 | 
| 203 float ImageDocument::scale() const | 203 float ImageDocument::scale() const | 
| 204 { | 204 { | 
| 205     if (!m_imageElement || m_imageElement->document() != this) | 205     if (!m_imageElement || m_imageElement->document() != this) | 
| 206         return 1.0f; | 206         return 1.0f; | 
| 207 | 207 | 
| 208     FrameView* view = frame()->view(); | 208     FrameView* view = frame()->view(); | 
| 209     if (!view) | 209     if (!view) | 
| 210         return 1; | 210         return 1; | 
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 371 } | 371 } | 
| 372 | 372 | 
| 373 bool ImageEventListener::operator==(const EventListener& listener) | 373 bool ImageEventListener::operator==(const EventListener& listener) | 
| 374 { | 374 { | 
| 375     if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
     &listener)) | 375     if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
     &listener)) | 
| 376         return m_doc == imageEventListener->m_doc; | 376         return m_doc == imageEventListener->m_doc; | 
| 377     return false; | 377     return false; | 
| 378 } | 378 } | 
| 379 | 379 | 
| 380 } | 380 } | 
| OLD | NEW | 
|---|