| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 
| 3  *           (C) 1999 Antti Koivisto (koivisto@kde.org) | 3  *           (C) 1999 Antti Koivisto (koivisto@kde.org) | 
| 4  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 
| 5  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights | 5  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights | 
| 6  * reserved. | 6  * reserved. | 
| 7  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 
| 8  * | 8  * | 
| 9  * This library is free software; you can redistribute it and/or | 9  * This library is free software; you can redistribute it and/or | 
| 10  * modify it under the terms of the GNU Library General Public | 10  * modify it under the terms of the GNU Library General Public | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 141 | 141 | 
| 142   if (src_index == -1 && data_index != -1) { | 142   if (src_index == -1 && data_index != -1) { | 
| 143     param_names->push_back("src"); | 143     param_names->push_back("src"); | 
| 144     param_values->push_back((*param_values)[data_index]); | 144     param_values->push_back((*param_values)[data_index]); | 
| 145   } | 145   } | 
| 146 } | 146 } | 
| 147 | 147 | 
| 148 // TODO(schenney): crbug.com/572908 This function should not deal with url or | 148 // TODO(schenney): crbug.com/572908 This function should not deal with url or | 
| 149 // serviceType! | 149 // serviceType! | 
| 150 void HTMLObjectElement::ParametersForPlugin(Vector<String>& param_names, | 150 void HTMLObjectElement::ParametersForPlugin(Vector<String>& param_names, | 
| 151                                             Vector<String>& param_values) { | 151                                             Vector<String>& param_values, | 
|  | 152                                             String& url, | 
|  | 153                                             String& service_type) { | 
| 152   HashSet<StringImpl*, CaseFoldingHash> unique_param_names; | 154   HashSet<StringImpl*, CaseFoldingHash> unique_param_names; | 
|  | 155   String url_parameter; | 
| 153 | 156 | 
| 154   // Scan the PARAM children and store their name/value pairs. | 157   // Scan the PARAM children and store their name/value pairs. | 
| 155   // Get the URL and type from the params if we don't already have them. | 158   // Get the URL and type from the params if we don't already have them. | 
| 156   for (HTMLParamElement* p = Traversal<HTMLParamElement>::FirstChild(*this); p; | 159   for (HTMLParamElement* p = Traversal<HTMLParamElement>::FirstChild(*this); p; | 
| 157        p = Traversal<HTMLParamElement>::NextSibling(*p)) { | 160        p = Traversal<HTMLParamElement>::NextSibling(*p)) { | 
| 158     String name = p->GetName(); | 161     String name = p->GetName(); | 
| 159     if (name.IsEmpty()) | 162     if (name.IsEmpty()) | 
| 160       continue; | 163       continue; | 
| 161 | 164 | 
| 162     unique_param_names.insert(name.Impl()); | 165     unique_param_names.insert(name.Impl()); | 
| 163     param_names.push_back(p->GetName()); | 166     param_names.push_back(p->GetName()); | 
| 164     param_values.push_back(p->Value()); | 167     param_values.push_back(p->Value()); | 
| 165 | 168 | 
| 166     // TODO(schenney): crbug.com/572908 url adjustment does not belong in this | 169     // TODO(schenney): crbug.com/572908 url adjustment does not belong in this | 
| 167     // function. | 170     // function. | 
| 168     // HTML5 says that an object resource's URL is specified by the object's | 171     if (url.IsEmpty() && url_parameter.IsEmpty() && | 
| 169     // data attribute, not by a param element. However, for compatibility, allow | 172         (DeprecatedEqualIgnoringCase(name, "src") || | 
| 170     // the resource's URL to be given by a param named "src", "movie", "code" or | 173          DeprecatedEqualIgnoringCase(name, "movie") || | 
| 171     // "url" if we know that resource points to a plugin. | 174          DeprecatedEqualIgnoringCase(name, "code") || | 
| 172     if (url_.IsEmpty() && (DeprecatedEqualIgnoringCase(name, "src") || | 175          DeprecatedEqualIgnoringCase(name, "url"))) | 
| 173                            DeprecatedEqualIgnoringCase(name, "movie") || | 176       url_parameter = StripLeadingAndTrailingHTMLSpaces(p->Value()); | 
| 174                            DeprecatedEqualIgnoringCase(name, "code") || |  | 
| 175                            DeprecatedEqualIgnoringCase(name, "url"))) { |  | 
| 176       url_ = StripLeadingAndTrailingHTMLSpaces(p->Value()); |  | 
| 177     } |  | 
| 178     // TODO(schenney): crbug.com/572908 serviceType calculation does not belong | 177     // TODO(schenney): crbug.com/572908 serviceType calculation does not belong | 
| 179     // in this function. | 178     // in this function. | 
| 180     if (service_type_.IsEmpty() && DeprecatedEqualIgnoringCase(name, "type")) { | 179     if (service_type.IsEmpty() && DeprecatedEqualIgnoringCase(name, "type")) { | 
| 181       size_t pos = p->Value().Find(";"); | 180       service_type = p->Value(); | 
|  | 181       size_t pos = service_type.Find(";"); | 
| 182       if (pos != kNotFound) | 182       if (pos != kNotFound) | 
| 183         service_type_ = p->Value().GetString().Left(pos); | 183         service_type = service_type.Left(pos); | 
| 184     } | 184     } | 
| 185   } | 185   } | 
| 186 | 186 | 
|  | 187   // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE | 
|  | 188   // attribute in the tag points to the Java plugin itself (an ActiveX | 
|  | 189   // component) while the actual applet CODEBASE is in a PARAM tag. See | 
|  | 190   // <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means we | 
|  | 191   // have to explicitly suppress the tag's CODEBASE attribute if there is none | 
|  | 192   // in a PARAM, else our Java plugin will misinterpret it. [4004531] | 
|  | 193   String codebase; | 
|  | 194   if (MIMETypeRegistry::IsJavaAppletMIMEType(service_type)) { | 
|  | 195     codebase = "codebase"; | 
|  | 196     unique_param_names.insert( | 
|  | 197         codebase.Impl());  // pretend we found it in a PARAM already | 
|  | 198   } | 
|  | 199 | 
| 187   // Turn the attributes of the <object> element into arrays, but don't override | 200   // Turn the attributes of the <object> element into arrays, but don't override | 
| 188   // <param> values. | 201   // <param> values. | 
| 189   AttributeCollection attributes = this->Attributes(); | 202   AttributeCollection attributes = this->Attributes(); | 
| 190   for (const Attribute& attribute : attributes) { | 203   for (const Attribute& attribute : attributes) { | 
| 191     const AtomicString& name = attribute.GetName().LocalName(); | 204     const AtomicString& name = attribute.GetName().LocalName(); | 
| 192     if (!unique_param_names.Contains(name.Impl())) { | 205     if (!unique_param_names.Contains(name.Impl())) { | 
| 193       param_names.push_back(name.GetString()); | 206       param_names.push_back(name.GetString()); | 
| 194       param_values.push_back(attribute.Value().GetString()); | 207       param_values.push_back(attribute.Value().GetString()); | 
| 195     } | 208     } | 
| 196   } | 209   } | 
| 197 | 210 | 
| 198   MapDataParamToSrc(¶m_names, ¶m_values); | 211   MapDataParamToSrc(¶m_names, ¶m_values); | 
|  | 212 | 
|  | 213   // HTML5 says that an object resource's URL is specified by the object's data | 
|  | 214   // attribute, not by a param element. However, for compatibility, allow the | 
|  | 215   // resource's URL to be given by a param named "src", "movie", "code" or "url" | 
|  | 216   // if we know that resource points to a plugin. | 
|  | 217   if (url.IsEmpty() && !url_parameter.IsEmpty()) { | 
|  | 218     KURL completed_url = GetDocument().CompleteURL(url_parameter); | 
|  | 219     bool use_fallback; | 
|  | 220     if (ShouldUsePlugin(completed_url, service_type, false, use_fallback)) | 
|  | 221       url = url_parameter; | 
|  | 222   } | 
| 199 } | 223 } | 
| 200 | 224 | 
| 201 bool HTMLObjectElement::HasFallbackContent() const { | 225 bool HTMLObjectElement::HasFallbackContent() const { | 
| 202   for (Node* child = firstChild(); child; child = child->nextSibling()) { | 226   for (Node* child = firstChild(); child; child = child->nextSibling()) { | 
| 203     // Ignore whitespace-only text, and <param> tags, any other content is | 227     // Ignore whitespace-only text, and <param> tags, any other content is | 
| 204     // fallback content. | 228     // fallback content. | 
| 205     if (child->IsTextNode()) { | 229     if (child->IsTextNode()) { | 
| 206       if (!ToText(child)->ContainsOnlyWhitespace()) | 230       if (!ToText(child)->ContainsOnlyWhitespace()) | 
| 207         return true; | 231         return true; | 
| 208     } else if (!isHTMLParamElement(*child)) { | 232     } else if (!isHTMLParamElement(*child)) { | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 261   } | 285   } | 
| 262 | 286 | 
| 263   // TODO(schenney): crbug.com/572908 I'm not sure it's ever possible to get | 287   // TODO(schenney): crbug.com/572908 I'm not sure it's ever possible to get | 
| 264   // into updateWidget during a removal, but just in case we should avoid | 288   // into updateWidget during a removal, but just in case we should avoid | 
| 265   // loading the frame to prevent security bugs. | 289   // loading the frame to prevent security bugs. | 
| 266   if (!SubframeLoadingDisabler::CanLoadFrame(*this)) { | 290   if (!SubframeLoadingDisabler::CanLoadFrame(*this)) { | 
| 267     DispatchErrorEvent(); | 291     DispatchErrorEvent(); | 
| 268     return; | 292     return; | 
| 269   } | 293   } | 
| 270 | 294 | 
|  | 295   String url = this->Url(); | 
|  | 296   String service_type = service_type_; | 
|  | 297 | 
| 271   // TODO(schenney): crbug.com/572908 These should be joined into a | 298   // TODO(schenney): crbug.com/572908 These should be joined into a | 
| 272   // PluginParameters class. | 299   // PluginParameters class. | 
| 273   Vector<String> param_names; | 300   Vector<String> param_names; | 
| 274   Vector<String> param_values; | 301   Vector<String> param_values; | 
| 275   ParametersForPlugin(param_names, param_values); | 302   ParametersForPlugin(param_names, param_values, url, service_type); | 
| 276 | 303 | 
| 277   // Note: url is modified above by parametersForPlugin. | 304   // Note: url is modified above by parametersForPlugin. | 
| 278   if (!AllowedToLoadFrameURL(url_)) { | 305   if (!AllowedToLoadFrameURL(url)) { | 
| 279     DispatchErrorEvent(); | 306     DispatchErrorEvent(); | 
| 280     return; | 307     return; | 
| 281   } | 308   } | 
| 282 | 309 | 
| 283   // TODO(schenney): crbug.com/572908 Is it possible to get here without a | 310   // TODO(schenney): crbug.com/572908 Is it possible to get here without a | 
| 284   // layoutObject now that we don't have beforeload events? | 311   // layoutObject now that we don't have beforeload events? | 
| 285   if (!GetLayoutObject()) | 312   if (!GetLayoutObject()) | 
| 286     return; | 313     return; | 
| 287 | 314 | 
| 288   // Overwrites the URL and MIME type of a Flash embed to use an HTML5 embed. | 315   // Overwrites the URL and MIME type of a Flash embed to use an HTML5 embed. | 
| 289   KURL overriden_url = | 316   KURL overriden_url = | 
| 290       GetDocument().GetFrame()->Loader().Client()->OverrideFlashEmbedWithHTML( | 317       GetDocument().GetFrame()->Loader().Client()->OverrideFlashEmbedWithHTML( | 
| 291           GetDocument().CompleteURL(url_)); | 318           GetDocument().CompleteURL(url_)); | 
| 292   if (!overriden_url.IsEmpty()) { | 319   if (!overriden_url.IsEmpty()) { | 
| 293     url_ = overriden_url.GetString(); | 320     url = url_ = overriden_url.GetString(); | 
| 294     service_type_ = "text/html"; | 321     service_type = service_type_ = "text/html"; | 
| 295   } | 322   } | 
| 296 | 323 | 
| 297   if (!HasValidClassId() || !RequestObject(param_names, param_values)) { | 324   if (!HasValidClassId() || | 
| 298     if (!url_.IsEmpty()) | 325       !RequestObject(url, service_type, param_names, param_values)) { | 
|  | 326     if (!url.IsEmpty()) | 
| 299       DispatchErrorEvent(); | 327       DispatchErrorEvent(); | 
| 300     if (HasFallbackContent()) | 328     if (HasFallbackContent()) | 
| 301       RenderFallbackContent(); | 329       RenderFallbackContent(); | 
| 302   } else { | 330   } else { | 
| 303     if (IsErrorplaceholder()) | 331     if (IsErrorplaceholder()) | 
| 304       DispatchErrorEvent(); | 332       DispatchErrorEvent(); | 
| 305   } | 333   } | 
| 306 } | 334 } | 
| 307 | 335 | 
| 308 Node::InsertionNotificationRequest HTMLObjectElement::InsertedInto( | 336 Node::InsertionNotificationRequest HTMLObjectElement::InsertedInto( | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 437 | 465 | 
| 438 bool HTMLObjectElement::WillUseFallbackContentAtLayout() const { | 466 bool HTMLObjectElement::WillUseFallbackContentAtLayout() const { | 
| 439   return !HasValidClassId() && HasFallbackContent(); | 467   return !HasValidClassId() && HasFallbackContent(); | 
| 440 } | 468 } | 
| 441 | 469 | 
| 442 void HTMLObjectElement::AssociateWith(HTMLFormElement* form) { | 470 void HTMLObjectElement::AssociateWith(HTMLFormElement* form) { | 
| 443   AssociateByParser(form); | 471   AssociateByParser(form); | 
| 444 }; | 472 }; | 
| 445 | 473 | 
| 446 }  // namespace blink | 474 }  // namespace blink | 
| OLD | NEW | 
|---|