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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return result.toString(); | 120 return result.toString(); |
121 } | 121 } |
122 | 122 |
123 size_t ImageDocumentParser::appendBytes(const char* data, size_t length) | 123 size_t ImageDocumentParser::appendBytes(const char* data, size_t length) |
124 { | 124 { |
125 if (!length) | 125 if (!length) |
126 return 0; | 126 return 0; |
127 | 127 |
128 Frame* frame = document()->frame(); | 128 Frame* frame = document()->frame(); |
129 Settings* settings = frame->settings(); | 129 Settings* settings = frame->settings(); |
130 if (!frame->loader()->client()->allowImage(!settings || settings->areImagesE
nabled(), document()->url())) | 130 if (!frame->loader().client()->allowImage(!settings || settings->areImagesEn
abled(), document()->url())) |
131 return 0; | 131 return 0; |
132 | 132 |
133 document()->cachedImage()->appendData(data, length); | 133 document()->cachedImage()->appendData(data, length); |
134 document()->imageUpdated(); | 134 document()->imageUpdated(); |
135 return 0; | 135 return 0; |
136 } | 136 } |
137 | 137 |
138 void ImageDocumentParser::finish() | 138 void ImageDocumentParser::finish() |
139 { | 139 { |
140 if (!isStopped() && document()->imageElement()) { | 140 if (!isStopped() && document()->imageElement()) { |
141 ImageResource* cachedImage = document()->cachedImage(); | 141 ImageResource* cachedImage = document()->cachedImage(); |
142 cachedImage->finish(); | 142 cachedImage->finish(); |
143 cachedImage->setResponse(document()->frame()->loader()->documentLoader()
->response()); | 143 cachedImage->setResponse(document()->frame()->loader().documentLoader()-
>response()); |
144 | 144 |
145 // Report the natural image size in the page title, regardless of zoom l
evel. | 145 // Report the natural image size in the page title, regardless of zoom l
evel. |
146 // At a zoom level of 1 the image is guaranteed to have an integer size. | 146 // At a zoom level of 1 the image is guaranteed to have an integer size. |
147 IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document
()->imageElement()->renderer(), 1.0f)); | 147 IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document
()->imageElement()->renderer(), 1.0f)); |
148 if (size.width()) { | 148 if (size.width()) { |
149 // Compute the title, we use the decoded filename of the resource, f
alling | 149 // Compute the title, we use the decoded filename of the resource, f
alling |
150 // back on the (decoded) hostname if there is no path. | 150 // back on the (decoded) hostname if there is no path. |
151 String fileName = decodeURLEscapeSequences(document()->url().lastPat
hComponent()); | 151 String fileName = decodeURLEscapeSequences(document()->url().lastPat
hComponent()); |
152 if (fileName.isEmpty()) | 152 if (fileName.isEmpty()) |
153 fileName = document()->url().host(); | 153 fileName = document()->url().host(); |
(...skipping 23 matching lines...) Expand all Loading... |
177 { | 177 { |
178 return ImageDocumentParser::create(this); | 178 return ImageDocumentParser::create(this); |
179 } | 179 } |
180 | 180 |
181 void ImageDocument::createDocumentStructure() | 181 void ImageDocument::createDocumentStructure() |
182 { | 182 { |
183 RefPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*this); | 183 RefPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*this); |
184 appendChild(rootElement); | 184 appendChild(rootElement); |
185 rootElement->insertedByParser(); | 185 rootElement->insertedByParser(); |
186 | 186 |
187 if (frame() && frame()->loader()) | 187 if (frame()) |
188 frame()->loader()->dispatchDocumentElementAvailable(); | 188 frame()->loader().dispatchDocumentElementAvailable(); |
189 | 189 |
190 RefPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this); | 190 RefPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this); |
191 RefPtr<HTMLMetaElement> meta = HTMLMetaElement::create(*this); | 191 RefPtr<HTMLMetaElement> meta = HTMLMetaElement::create(*this); |
192 meta->setAttribute(nameAttr, "viewport"); | 192 meta->setAttribute(nameAttr, "viewport"); |
193 meta->setAttribute(contentAttr, "width=device-width"); | 193 meta->setAttribute(contentAttr, "width=device-width"); |
194 head->appendChild(meta); | 194 head->appendChild(meta); |
195 | 195 |
196 RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this); | 196 RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this); |
197 body->setAttribute(styleAttr, "margin: 0px;"); | 197 body->setAttribute(styleAttr, "margin: 0px;"); |
198 | 198 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 384 } |
385 | 385 |
386 bool ImageEventListener::operator==(const EventListener& listener) | 386 bool ImageEventListener::operator==(const EventListener& listener) |
387 { | 387 { |
388 if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
&listener)) | 388 if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
&listener)) |
389 return m_doc == imageEventListener->m_doc; | 389 return m_doc == imageEventListener->m_doc; |
390 return false; | 390 return false; |
391 } | 391 } |
392 | 392 |
393 } | 393 } |
OLD | NEW |