summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLObjectElement.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/html/HTMLObjectElement.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/html/HTMLObjectElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLObjectElement.cpp190
1 files changed, 88 insertions, 102 deletions
diff --git a/Source/WebCore/html/HTMLObjectElement.cpp b/Source/WebCore/html/HTMLObjectElement.cpp
index b16928f66..222f99d43 100644
--- a/Source/WebCore/html/HTMLObjectElement.cpp
+++ b/Source/WebCore/html/HTMLObjectElement.cpp
@@ -55,8 +55,8 @@
#include <wtf/Ref.h>
#if PLATFORM(IOS)
-#include "DynamicLinkerSPI.h"
#include "RuntimeApplicationChecksIOS.h"
+#include "WebCoreSystemInterface.h"
#endif
namespace WebCore {
@@ -64,29 +64,29 @@ namespace WebCore {
using namespace HTMLNames;
inline HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser)
- : HTMLPlugInImageElement(tagName, document, createdByParser)
- , FormAssociatedElement(form)
+ : HTMLPlugInImageElement(tagName, document, createdByParser, ShouldNotPreferPlugInsForImages)
, m_docNamedItem(true)
, m_useFallbackContent(false)
{
ASSERT(hasTagName(objectTag));
+ setForm(form ? form : HTMLFormElement::findClosestFormAncestor(*this));
}
inline HTMLObjectElement::~HTMLObjectElement()
{
}
-Ref<HTMLObjectElement> HTMLObjectElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser)
+PassRefPtr<HTMLObjectElement> HTMLObjectElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser)
{
- return adoptRef(*new HTMLObjectElement(tagName, document, form, createdByParser));
+ return adoptRef(new HTMLObjectElement(tagName, document, form, createdByParser));
}
-RenderWidget* HTMLObjectElement::renderWidgetLoadingPlugin() const
+RenderWidget* HTMLObjectElement::renderWidgetForJSBindings() const
{
// Needs to load the plugin immediatedly because this function is called
// when JavaScript code accesses the plugin.
// FIXME: <rdar://16893708> Check if dispatching events here is safe.
- document().updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks::Synchronously);
+ document().updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksSynchronously);
return renderWidget(); // This will return 0 if the renderer is not a RenderWidget.
}
@@ -107,58 +107,58 @@ void HTMLObjectElement::collectStyleForPresentationAttribute(const QualifiedName
void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- bool invalidateRenderer = false;
-
if (name == formAttr)
formAttributeChanged();
else if (name == typeAttr) {
- m_serviceType = value.string().left(value.find(';')).convertToASCIILowercase();
- invalidateRenderer = !fastHasAttribute(classidAttr);
- setNeedsWidgetUpdate(true);
+ m_serviceType = value.lower();
+ size_t pos = m_serviceType.find(";");
+ if (pos != notFound)
+ m_serviceType = m_serviceType.left(pos);
+ if (renderer())
+ setNeedsWidgetUpdate(true);
} else if (name == dataAttr) {
m_url = stripLeadingAndTrailingHTMLSpaces(value);
document().updateStyleIfNeeded();
- if (isImageType() && renderer()) {
- if (!m_imageLoader)
- m_imageLoader = std::make_unique<HTMLImageLoader>(*this);
- m_imageLoader->updateFromElementIgnoringPreviousError();
+ if (renderer()) {
+ setNeedsWidgetUpdate(true);
+ if (isImageType()) {
+ if (!m_imageLoader)
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
+ m_imageLoader->updateFromElementIgnoringPreviousError();
+ }
}
- invalidateRenderer = !fastHasAttribute(classidAttr);
- setNeedsWidgetUpdate(true);
} else if (name == classidAttr) {
- invalidateRenderer = true;
- setNeedsWidgetUpdate(true);
- } else
+ m_classId = value;
+ if (renderer())
+ setNeedsWidgetUpdate(true);
+ } else if (name == onbeforeloadAttr)
+ setAttributeEventListener(eventNames().beforeloadEvent, name, value);
+ else
HTMLPlugInImageElement::parseAttribute(name, value);
-
- if (!invalidateRenderer || !inDocument() || !renderer())
- return;
-
- clearUseFallbackContent();
- setNeedsStyleRecalc(ReconstructRenderTree);
}
-static void mapDataParamToSrc(Vector<String>& paramNames, Vector<String>& paramValues)
+static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)
{
- // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP require "src" attribute).
- bool foundSrcParam = false;
- String dataParamValue;
- for (unsigned i = 0; i < paramNames.size(); ++i) {
- if (equalLettersIgnoringASCIICase(paramNames[i], "src"))
- foundSrcParam = true;
- else if (equalLettersIgnoringASCIICase(paramNames[i], "data"))
- dataParamValue = paramValues[i];
+ // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP
+ // require "src" attribute).
+ int srcIndex = -1, dataIndex = -1;
+ for (unsigned int i = 0; i < paramNames->size(); ++i) {
+ if (equalIgnoringCase((*paramNames)[i], "src"))
+ srcIndex = i;
+ else if (equalIgnoringCase((*paramNames)[i], "data"))
+ dataIndex = i;
}
- if (!foundSrcParam && !dataParamValue.isNull()) {
- paramNames.append(ASCIILiteral("src"));
- paramValues.append(WTFMove(dataParamValue));
+
+ if (srcIndex == -1 && dataIndex != -1) {
+ paramNames->append("src");
+ paramValues->append((*paramValues)[dataIndex]);
}
}
#if PLATFORM(IOS)
static bool shouldNotPerformURLAdjustment()
{
- static bool shouldNotPerformURLAdjustment = applicationIsNASAHD() && dyld_get_program_sdk_version() < DYLD_IOS_VERSION_5_0;
+ static bool shouldNotPerformURLAdjustment = applicationIsNASAHD() && !iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_5_0);
return shouldNotPerformURLAdjustment;
}
#endif
@@ -166,7 +166,7 @@ static bool shouldNotPerformURLAdjustment()
// FIXME: This function should not deal with url or serviceType!
void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
{
- HashSet<StringImpl*, ASCIICaseInsensitiveHash> uniqueParamNames;
+ HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
String urlParameter;
// Scan the PARAM children and store their name/value pairs.
@@ -181,12 +181,12 @@ void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<S
paramValues.append(param.value());
// FIXME: url adjustment does not belong in this function.
- if (url.isEmpty() && urlParameter.isEmpty() && (equalLettersIgnoringASCIICase(name, "src") || equalLettersIgnoringASCIICase(name, "movie") || equalLettersIgnoringASCIICase(name, "code") || equalLettersIgnoringASCIICase(name, "url")))
+ if (url.isEmpty() && urlParameter.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
urlParameter = stripLeadingAndTrailingHTMLSpaces(param.value());
// FIXME: serviceType calculation does not belong in this function.
- if (serviceType.isEmpty() && equalLettersIgnoringASCIICase(name, "type")) {
+ if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
serviceType = param.value();
- size_t pos = serviceType.find(';');
+ size_t pos = serviceType.find(";");
if (pos != notFound)
serviceType = serviceType.left(pos);
}
@@ -214,7 +214,7 @@ void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<S
}
}
- mapDataParamToSrc(paramNames, paramValues);
+ mapDataParamToSrc(&paramNames, &paramValues);
// HTML5 says that an object resource's URL is specified by the object's data
// attribute, not by a param element. However, for compatibility, allow the
@@ -227,7 +227,7 @@ void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<S
if (url.isEmpty() && !urlParameter.isEmpty()) {
SubframeLoader& loader = document().frame()->loader().subframeLoader();
- if (loader.resourceWillUsePlugin(urlParameter, serviceType))
+ if (loader.resourceWillUsePlugin(urlParameter, serviceType, shouldPreferPlugInsForImages()))
url = urlParameter;
}
}
@@ -237,10 +237,10 @@ bool HTMLObjectElement::hasFallbackContent() const
{
for (Node* child = firstChild(); child; child = child->nextSibling()) {
// Ignore whitespace-only text, and <param> tags, any other content is fallback content.
- if (is<Text>(*child)) {
- if (!downcast<Text>(*child).containsOnlyWhitespace())
+ if (child->isTextNode()) {
+ if (!toText(child)->containsOnlyWhitespace())
return true;
- } else if (!is<HTMLParamElement>(*child))
+ } else if (!child->hasTagName(paramTag))
return true;
}
return false;
@@ -254,24 +254,26 @@ bool HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk()
// 'generator' meta tag is present. Only apply this quirk if there is no
// fallback content, which ensures the quirk will disable itself if Wiki
// Server is updated to generate an alternate embed tag as fallback content.
-
if (!document().page()
|| !document().page()->settings().needsSiteSpecificQuirks()
|| hasFallbackContent()
- || !equalLettersIgnoringASCIICase(fastGetAttribute(classidAttr), "clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b"))
+ || !equalIgnoringCase(classId(), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"))
return false;
- for (auto& metaElement : descendantsOfType<HTMLMetaElement>(document())) {
- if (equalLettersIgnoringASCIICase(metaElement.name(), "generator") && metaElement.content().startsWith("Mac OS X Server Web Services Server", false))
+ RefPtr<NodeList> metaElements = document().getElementsByTagName(HTMLNames::metaTag.localName());
+ unsigned length = metaElements->length();
+ for (unsigned i = 0; i < length; ++i) {
+ HTMLMetaElement& metaElement = toHTMLMetaElement(*metaElements->item(i));
+ if (equalIgnoringCase(metaElement.name(), "generator") && metaElement.content().startsWith("Mac OS X Server Web Services Server", false))
return true;
}
-
+
return false;
}
bool HTMLObjectElement::hasValidClassId()
{
- if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && fastGetAttribute(classidAttr).startsWith("java:", false))
+ if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && classId().startsWith("java:", false))
return true;
if (shouldAllowQuickTimeClassIdQuirk())
@@ -279,7 +281,7 @@ bool HTMLObjectElement::hasValidClassId()
// HTML5 says that fallback content should be rendered if a non-empty
// classid is specified for which the UA can't find a suitable plug-in.
- return fastGetAttribute(classidAttr).isEmpty();
+ return classId().isEmpty();
}
// FIXME: This should be unified with HTMLEmbedElement::updateWidget and
@@ -336,12 +338,7 @@ Node::InsertionNotificationRequest HTMLObjectElement::insertedInto(ContainerNode
{
HTMLPlugInImageElement::insertedInto(insertionPoint);
FormAssociatedElement::insertedInto(insertionPoint);
- return InsertionShouldCallFinishedInsertingSubtree;
-}
-
-void HTMLObjectElement::finishedInsertingSubtree()
-{
- resetFormOwner();
+ return InsertionDone;
}
void HTMLObjectElement::removedFrom(ContainerNode& insertionPoint)
@@ -367,7 +364,7 @@ bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const
const AtomicString& HTMLObjectElement::imageSourceURL() const
{
- return fastGetAttribute(dataAttr);
+ return getAttribute(dataAttr);
}
void HTMLObjectElement::renderFallbackContent()
@@ -381,31 +378,29 @@ void HTMLObjectElement::renderFallbackContent()
setNeedsStyleRecalc(ReconstructRenderTree);
// Before we give up and use fallback content, check to see if this is a MIME type issue.
- auto* loader = imageLoader();
- if (loader && loader->image() && loader->image()->status() != CachedResource::LoadError) {
- m_serviceType = loader->image()->response().mimeType();
+ if (m_imageLoader && m_imageLoader->image() && m_imageLoader->image()->status() != CachedResource::LoadError) {
+ m_serviceType = m_imageLoader->image()->response().mimeType();
if (!isImageType()) {
// If we don't think we have an image type anymore, then clear the image from the loader.
- loader->clearImage();
+ m_imageLoader->setImage(0);
return;
}
}
m_useFallbackContent = true;
- // This was added to keep Acid 2 non-flaky. A style recalc is required to make fallback resources load.
- // Without forcing, this may happen after all the other resources have been loaded and the document is already
- // considered complete. FIXME: Would be better to address this with incrementLoadEventDelayCount instead
- // or disentangle loading from style entirely.
+ // This is here mainly to keep acid2 non-flaky. A style recalc is required to make fallback resources to load. Without forcing
+ // this may happen after all the other resources have been loaded and the document is already considered complete.
+ // FIXME: Disentangle fallback content handling from style recalcs.
document().updateStyleIfNeeded();
}
// FIXME: This should be removed, all callers are almost certainly wrong.
static bool isRecognizedTagName(const QualifiedName& tagName)
{
- static NeverDestroyed<HashSet<AtomicStringImpl*>> tagList;
- if (tagList.get().isEmpty()) {
- auto* tags = HTMLNames::getHTMLTags();
+ DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
+ if (tagList.isEmpty()) {
+ const QualifiedName* const * tags = HTMLNames::getHTMLTags();
for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) {
if (*tags[i] == bgsoundTag
|| *tags[i] == commandTag
@@ -419,10 +414,10 @@ static bool isRecognizedTagName(const QualifiedName& tagName)
// because that changes how we parse documents.
continue;
}
- tagList.get().add(tags[i]->localName().impl());
+ tagList.add(tags[i]->localName().impl());
}
}
- return tagList.get().contains(tagName.localName().impl());
+ return tagList.contains(tagName.localName().impl());
}
void HTMLObjectElement::updateDocNamedItem()
@@ -434,35 +429,35 @@ void HTMLObjectElement::updateDocNamedItem()
bool isNamedItem = true;
Node* child = firstChild();
while (child && isNamedItem) {
- if (is<Element>(*child)) {
- Element& element = downcast<Element>(*child);
+ if (child->isElementNode()) {
+ Element* element = toElement(child);
// FIXME: Use of isRecognizedTagName is almost certainly wrong here.
- if (isRecognizedTagName(element.tagQName()) && !element.hasTagName(paramTag))
+ if (isRecognizedTagName(element->tagQName()) && !element->hasTagName(paramTag))
isNamedItem = false;
- } else if (is<Text>(*child)) {
- if (!downcast<Text>(*child).containsOnlyWhitespace())
+ } else if (child->isTextNode()) {
+ if (!toText(child)->containsOnlyWhitespace())
isNamedItem = false;
} else
isNamedItem = false;
child = child->nextSibling();
}
- if (isNamedItem != wasNamedItem && inDocument() && is<HTMLDocument>(document())) {
- HTMLDocument& document = downcast<HTMLDocument>(this->document());
+ if (isNamedItem != wasNamedItem && inDocument() && document().isHTMLDocument()) {
+ HTMLDocument* document = toHTMLDocument(&this->document());
const AtomicString& id = getIdAttribute();
if (!id.isEmpty()) {
if (isNamedItem)
- document.addDocumentNamedItem(*id.impl(), *this);
+ document->addDocumentNamedItem(*id.impl(), *this);
else
- document.removeDocumentNamedItem(*id.impl(), *this);
+ document->removeDocumentNamedItem(*id.impl(), *this);
}
const AtomicString& name = getNameAttribute();
if (!name.isEmpty() && id != name) {
if (isNamedItem)
- document.addDocumentNamedItem(*name.impl(), *this);
+ document->addDocumentNamedItem(*name.impl(), *this);
else
- document.removeDocumentNamedItem(*name.impl(), *this);
+ document->removeDocumentNamedItem(*name.impl(), *this);
}
}
m_docNamedItem = isNamedItem;
@@ -474,10 +469,10 @@ bool HTMLObjectElement::containsJavaApplet() const
return true;
for (auto& child : childrenOfType<Element>(*this)) {
- if (child.hasTagName(paramTag) && equalLettersIgnoringASCIICase(child.getNameAttribute(), "type")
+ if (child.hasTagName(paramTag) && equalIgnoringCase(child.getNameAttribute(), "type")
&& MIMETypeRegistry::isJavaAppletMIMEType(child.getAttribute(valueAttr).string()))
return true;
- if (child.hasTagName(objectTag) && downcast<HTMLObjectElement>(child).containsJavaApplet())
+ if (child.hasTagName(objectTag) && toHTMLObjectElement(child).containsJavaApplet())
return true;
if (child.hasTagName(appletTag))
return true;
@@ -490,11 +485,11 @@ void HTMLObjectElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) cons
{
HTMLPlugInImageElement::addSubresourceAttributeURLs(urls);
- addSubresourceURL(urls, document().completeURL(fastGetAttribute(dataAttr)));
+ addSubresourceURL(urls, document().completeURL(getAttribute(dataAttr)));
// FIXME: Passing a string that starts with "#" to the completeURL function does
// not seem like it would work. The image element has similar but not identical code.
- const AtomicString& useMap = fastGetAttribute(usemapAttr);
+ const AtomicString& useMap = getAttribute(usemapAttr);
if (useMap.startsWith('#'))
addSubresourceURL(urls, document().completeURL(useMap));
}
@@ -511,10 +506,10 @@ bool HTMLObjectElement::appendFormData(FormDataList& encoding, bool)
return false;
Widget* widget = pluginWidget();
- if (!is<PluginViewBase>(widget))
+ if (!widget || !widget->isPluginViewBase())
return false;
String value;
- if (!downcast<PluginViewBase>(*widget).getFormValue(value))
+ if (!toPluginViewBase(widget)->getFormValue(value))
return false;
encoding.appendData(name(), value);
return true;
@@ -525,13 +520,4 @@ HTMLFormElement* HTMLObjectElement::virtualForm() const
return FormAssociatedElement::form();
}
-bool HTMLObjectElement::canContainRangeEndPoint() const
-{
- // Call through to HTMLElement because we need to skip HTMLPlugInElement
- // when calling through to the derived class since returns false unconditionally.
- // An object element with fallback content should basically be treated like
- // a generic HTML element.
- return m_useFallbackContent && HTMLElement::canContainRangeEndPoint();
-}
-
}