OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "core/dom/PostAttachCallbacks.h" | 24 #include "core/dom/PostAttachCallbacks.h" |
25 #include "core/html/HTMLImageLoader.h" | 25 #include "core/html/HTMLImageLoader.h" |
26 #include "core/html/PluginDocument.h" | 26 #include "core/html/PluginDocument.h" |
27 #include "core/loader/FrameLoader.h" | 27 #include "core/loader/FrameLoader.h" |
28 #include "core/loader/FrameLoaderClient.h" | 28 #include "core/loader/FrameLoaderClient.h" |
29 #include "core/frame/ContentSecurityPolicy.h" | 29 #include "core/frame/ContentSecurityPolicy.h" |
30 #include "core/frame/Frame.h" | 30 #include "core/frame/Frame.h" |
31 #include "core/page/Page.h" | 31 #include "core/page/Page.h" |
32 #include "core/page/Settings.h" | 32 #include "core/page/Settings.h" |
33 #include "platform/Logging.h" | 33 #include "platform/Logging.h" |
34 #include "core/platform/MIMETypeFromURL.h" | |
35 #include "core/platform/MIMETypeRegistry.h" | 34 #include "core/platform/MIMETypeRegistry.h" |
36 #include "core/platform/graphics/Image.h" | 35 #include "core/platform/graphics/Image.h" |
37 #include "core/plugins/PluginData.h" | 36 #include "core/plugins/PluginData.h" |
38 #include "core/rendering/RenderEmbeddedObject.h" | 37 #include "core/rendering/RenderEmbeddedObject.h" |
39 #include "core/rendering/RenderImage.h" | 38 #include "core/rendering/RenderImage.h" |
40 #include "platform/UserGestureIndicator.h" | 39 #include "platform/UserGestureIndicator.h" |
41 #include "weborigin/SecurityOrigin.h" | 40 #include "weborigin/SecurityOrigin.h" |
42 | 41 |
43 namespace WebCore { | 42 namespace WebCore { |
44 | 43 |
45 using namespace HTMLNames; | 44 using namespace HTMLNames; |
46 | 45 |
47 typedef Vector<RefPtr<HTMLPlugInImageElement> > HTMLPlugInImageElementList; | 46 typedef Vector<RefPtr<HTMLPlugInImageElement> > HTMLPlugInImageElementList; |
48 | 47 |
49 static const int sizingTinyDimensionThreshold = 40; | 48 static const int sizingTinyDimensionThreshold = 40; |
50 static const int sizingSmallWidthThreshold = 250; | 49 static const int sizingSmallWidthThreshold = 250; |
51 static const int sizingMediumWidthThreshold = 450; | 50 static const int sizingMediumWidthThreshold = 450; |
52 static const int sizingMediumHeightThreshold = 300; | 51 static const int sizingMediumHeightThreshold = 300; |
53 static const float sizingFullPageAreaRatioThreshold = 0.96; | 52 static const float sizingFullPageAreaRatioThreshold = 0.96; |
54 static const float autostartSoonAfterUserGestureThreshold = 5.0; | 53 static const float autostartSoonAfterUserGestureThreshold = 5.0; |
55 | 54 |
56 HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
ument& document, bool createdByParser, PreferPlugInsForImagesOption preferPlugIn
sForImagesOption) | 55 HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
ument& document, bool createdByParser, PreferPlugInsForImagesOption preferPlugIn
sForImagesOption) |
57 : HTMLPlugInElement(tagName, document) | 56 : HTMLPlugInElement(tagName, document, preferPlugInsForImagesOption) |
58 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay | 57 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay |
59 // widget updates until after all children are parsed. For HTMLEmbedElement | 58 // widget updates until after all children are parsed. For HTMLEmbedElement |
60 // this delay is unnecessary, but it is simpler to make both classes share | 59 // this delay is unnecessary, but it is simpler to make both classes share |
61 // the same codepath in this class. | 60 // the same codepath in this class. |
62 , m_needsWidgetUpdate(!createdByParser) | 61 , m_needsWidgetUpdate(!createdByParser) |
63 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) | |
64 , m_createdDuringUserGesture(UserGestureIndicator::processingUserGesture()) | 62 , m_createdDuringUserGesture(UserGestureIndicator::processingUserGesture()) |
65 { | 63 { |
66 setHasCustomStyleCallbacks(); | 64 setHasCustomStyleCallbacks(); |
67 } | 65 } |
68 | 66 |
69 HTMLPlugInImageElement::~HTMLPlugInImageElement() | 67 HTMLPlugInImageElement::~HTMLPlugInImageElement() |
70 { | 68 { |
71 } | 69 } |
72 | 70 |
73 void HTMLPlugInImageElement::setDisplayState(DisplayState state) | 71 void HTMLPlugInImageElement::setDisplayState(DisplayState state) |
74 { | 72 { |
75 HTMLPlugInElement::setDisplayState(state); | 73 HTMLPlugInElement::setDisplayState(state); |
76 } | 74 } |
77 | 75 |
78 RenderEmbeddedObject* HTMLPlugInImageElement::renderEmbeddedObject() const | 76 RenderEmbeddedObject* HTMLPlugInImageElement::renderEmbeddedObject() const |
79 { | 77 { |
80 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers | 78 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers |
81 // when using fallback content. | 79 // when using fallback content. |
82 if (!renderer() || !renderer()->isEmbeddedObject()) | 80 if (!renderer() || !renderer()->isEmbeddedObject()) |
83 return 0; | 81 return 0; |
84 return toRenderEmbeddedObject(renderer()); | 82 return toRenderEmbeddedObject(renderer()); |
85 } | 83 } |
86 | 84 |
87 bool HTMLPlugInImageElement::isImageType() | |
88 { | |
89 if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) | |
90 m_serviceType = mimeTypeFromDataURL(m_url); | |
91 | |
92 if (Frame* frame = document().frame()) { | |
93 KURL completedURL = document().completeURL(m_url); | |
94 return frame->loader()->client()->objectContentType(completedURL, m_serv
iceType, shouldPreferPlugInsForImages()) == ObjectContentImage; | |
95 } | |
96 | |
97 return Image::supportsType(m_serviceType); | |
98 } | |
99 | |
100 // We don't use m_url, as it may not be the final URL that the object loads, | 85 // We don't use m_url, as it may not be the final URL that the object loads, |
101 // depending on <param> values. | 86 // depending on <param> values. |
102 bool HTMLPlugInImageElement::allowedToLoadFrameURL(const String& url) | 87 bool HTMLPlugInImageElement::allowedToLoadFrameURL(const String& url) |
103 { | 88 { |
104 KURL completeURL = document().completeURL(url); | 89 KURL completeURL = document().completeURL(url); |
105 | 90 |
106 if (contentFrame() && protocolIsJavaScript(completeURL) | 91 if (contentFrame() && protocolIsJavaScript(completeURL) |
107 && !document().securityOrigin()->canAccess(contentDocument()->securityOr
igin())) | 92 && !document().securityOrigin()->canAccess(contentDocument()->securityOr
igin())) |
108 return false; | 93 return false; |
109 | 94 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); | 306 renderEmbeddedObject()->setPluginUnavailabilityReason(RenderEmbeddedObje
ct::PluginBlockedByContentSecurityPolicy); |
322 return false; | 307 return false; |
323 } | 308 } |
324 | 309 |
325 if (frame->loader() && !frame->loader()->mixedContentChecker()->canRunInsecu
reContent(document().securityOrigin(), url)) | 310 if (frame->loader() && !frame->loader()->mixedContentChecker()->canRunInsecu
reContent(document().securityOrigin(), url)) |
326 return false; | 311 return false; |
327 return true; | 312 return true; |
328 } | 313 } |
329 | 314 |
330 } // namespace WebCore | 315 } // namespace WebCore |
OLD | NEW |