Diff
Modified: trunk/Source/WebCore/ChangeLog (205410 => 205411)
--- trunk/Source/WebCore/ChangeLog 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/ChangeLog 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,3 +1,97 @@
+2016-09-03 Darin Adler <[email protected]>
+
+ Streamline DOMImplementation, and move it to our new DOM exception system
+ https://bugs.webkit.org/show_bug.cgi?id=161295
+
+ Reviewed by Ryosuke Niwa.
+
+ * WebCore.xcodeproj/project.pbxproj: Added new headers to project.
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::toJS): Added an overload for ExceptionOr<>; this handles the
+ exception case here so it doesn't need to be handled in generated code
+ for the binding. Implemented here so that ExceptionOr.h does not know
+ about bindings. But since this is a template, it will only compile when
+ instantiated and there is no need to include ExceptionOr.h and indirectly
+ the Variant.h header in this header.
+ (WebCore::toJSNewlyCreated): Ditto.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateCallbackImplementation): Refer to JSC::Exception with explicit
+ namespace to avoid ambiguity with WebCore::Exception.
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createDocumentType): Changed to return
+ ExceptionOr.
+ (WebCore::createXMLDocument): Added. Helper used in createDocument.
+ (WebCore::DOMImplementation::getInterface): Deleted. This was unused.
+ (WebCore::DOMImplementation::createDocument): Changed to return
+ ExceptionOr.
+ (WebCore::DOMImplementation::createCSSStyleSheet): Removed the unused
+ ExceptionCode out argument.
+ (WebCore::isValidXMLMIMETypeChar): Deleted. Moved to MIMETypeRegistry.
+ (WebCore::DOMImplementation::isXMLMIMEType): Ditto.
+ (WebCore::DOMImplementation::isTextMIMEType): Ditto.
+
+ * dom/DOMImplementation.h: Changed functions as described above to
+ return ExceptionOr values. Also removed unused getInterface function,
+ and isXMLMIMEType and isTextMIMEType, which both moved to the
+ MIMETypeRegistry class alongside all the other similar MIME type
+ functions.
+
+ * dom/DOMImplementation.idl: Reorganized this to match the IDL files
+ in the specifications a little better. Also removed [RaisesException]
+ since that is only needed for the old legacy ExceptionCode& style.
+
+ * dom/Document.cpp:
+ (WebCore::Document::setXMLVersion): Removed call to the
+ DOMImplementation::hasFeature function since the values passed in
+ unconditionally result in the return value "true". This is left over
+ either from specification language, or from an ancient version of this
+ code that worked in a "no XML supported" mode.
+ (WebCore::Document::setXMLStandalone): Ditto.
+
+ * dom/Document.h: Removed the ExceptionCode& out argument from setXMLStandalone.
+ * dom/Document.idl: Removed [SetterRaisesException] from xmlStandalone.
+
+ * dom/Exception.h: Added.
+ * dom/ExceptionOr.h: Added.
+
+ * html/HTMLTemplateElement.cpp: Removed unneeded include of DOMImplementation.h.
+
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::createXHRTextDecoder): Use isXMLMIMEType in its new location in
+ MIMETypeRegistry.
+ * inspector/NetworkResourcesData.cpp:
+ (WebCore::createOtherResourceTextDecoder): Ditto.
+
+ * loader/FrameLoader.cpp: Removed unneeded include of DOMImplementation.h.
+
+ * loader/TextResourceDecoder.cpp:
+ (WebCore::TextResourceDecoder::determineContentType): Use isXMLMIMEType in its
+ new location in MIMETypeRegistry.
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::isTextMIMEType): Added. Moved here from
+ DOMImplementation.
+ (WebCore::isValidXMLMIMETypeChar): Ditto.
+ (WebCore::MIMETypeRegistry::isXMLMIMEType): Ditto.
+
+ * platform/MIMETypeRegistry.h: Added isXMLMIMEType and isTextMIMEType.
+ Made isUnsupportedTextMIMEType private.
+
+ * svg/SVGElement.cpp:
+ (WebCore::SVGElement::isSupported): Deleted. This function was never called.
+ * svg/SVGElement.h: Updated for the above change.
+
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::responseIsXML): Use isXMLMIMEType in its new
+ location in MIMETypeRegistry.
+
+ * xml/parser/XMLDocumentParserLibxml2.cpp:
+ (WebCore::XMLDocumentParser::startDocument): Updated since setXMLStandalone
+ no longer can raise an exception.
+
2016-09-03 Ryosuke Niwa <[email protected]>
Unbreak customElements.whenDefined after r205383 with a crash fix
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205410 => 205411)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-03 23:34:00 UTC (rev 205411)
@@ -3275,6 +3275,8 @@
93C4F6EB1108F9A50099D0DB /* AccessibilityScrollbar.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C4F6E91108F9A50099D0DB /* AccessibilityScrollbar.h */; };
93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CCF0260AF6C52900018E89 /* NavigationAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
93CCF0600AF6CA7600018E89 /* NavigationAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93CCF05F0AF6CA7600018E89 /* NavigationAction.cpp */; };
+ 93D196311D6CAB7600FC7E47 /* ExceptionOr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93D196301D6CAB7600FC7E47 /* ExceptionOr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 93D196331D6CAB8200FC7E47 /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = 93D196321D6CAB8200FC7E47 /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; };
93D4379F1D57B15300AB85EA /* JSMainThreadExecState.h in Headers */ = {isa = PBXBuildFile; fileRef = 8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */; settings = {ATTRIBUTES = (Private, ); }; };
93D437A01D57B19A00AB85EA /* CustomElementReactionQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B56C9A81C89312800C456DF /* CustomElementReactionQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
93D437A11D57B3F400AB85EA /* ElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = ADE11F4A18D8311B0078983B /* ElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10437,6 +10439,8 @@
93CA4CA209DF93FA00DF8677 /* svg.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = svg.css; sourceTree = "<group>"; };
93CCF0260AF6C52900018E89 /* NavigationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationAction.h; sourceTree = "<group>"; };
93CCF05F0AF6CA7600018E89 /* NavigationAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationAction.cpp; sourceTree = "<group>"; };
+ 93D196301D6CAB7600FC7E47 /* ExceptionOr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionOr.h; sourceTree = "<group>"; };
+ 93D196321D6CAB8200FC7E47 /* Exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exception.h; sourceTree = "<group>"; };
93D9D53B0DA27E180077216C /* RangeBoundaryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangeBoundaryPoint.h; sourceTree = "<group>"; };
93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoader.cpp; sourceTree = "<group>"; };
93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePlugInStreamLoader.cpp; sourceTree = "<group>"; };
@@ -22996,11 +23000,13 @@
E12EDB7A0B308A78002704B6 /* EventTarget.h */,
85AFA7420AAF298400E84305 /* EventTarget.idl */,
CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */,
+ 93D196321D6CAB8200FC7E47 /* Exception.h */,
BC60D8F00D2A11E000B9918F /* ExceptionBase.cpp */,
BC60D8F10D2A11E000B9918F /* ExceptionBase.h */,
935FBCF109BA143B00E230B1 /* ExceptionCode.h */,
A7CACDB013CE875B00BBBE3F /* ExceptionCodePlaceholder.cpp */,
A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */,
+ 93D196301D6CAB7600FC7E47 /* ExceptionOr.h */,
E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */,
E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */,
B6D9D23414EABD260090D75E /* FocusEvent.cpp */,
@@ -25598,6 +25604,7 @@
078E093917D16B2C00420AA1 /* MediaStreamCreationClient.h in Headers */,
078E091617D14D1C00420AA1 /* MediaStreamEvent.h in Headers */,
078E093717D16B2C00420AA1 /* MediaStreamPrivate.h in Headers */,
+ 93D196331D6CAB8200FC7E47 /* Exception.h in Headers */,
078E091717D14D1C00420AA1 /* MediaStreamRegistry.h in Headers */,
078E091817D14D1C00420AA1 /* MediaStreamTrack.h in Headers */,
078E091917D14D1C00420AA1 /* MediaStreamTrackEvent.h in Headers */,
@@ -26668,6 +26675,7 @@
B2227AD70D00BF220071B782 /* SVGTransform.h in Headers */,
B2227ADA0D00BF220071B782 /* SVGTransformable.h in Headers */,
B2227ADD0D00BF220071B782 /* SVGTransformDistance.h in Headers */,
+ 93D196311D6CAB7600FC7E47 /* ExceptionOr.h in Headers */,
B2227ADF0D00BF220071B782 /* SVGTransformList.h in Headers */,
08C7136E128956A3001B107E /* SVGTransformListPropertyTearOff.h in Headers */,
B2227AE20D00BF220071B782 /* SVGTRefElement.h in Headers */,
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (205410 => 205411)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -23,9 +23,9 @@
#pragma once
+#include "DOMWrapperWorld.h"
#include "JSDOMGlobalObject.h"
#include "JSDOMWrapper.h"
-#include "DOMWrapperWorld.h"
#include "ScriptWrappable.h"
#include "ScriptWrappableInlines.h"
#include "WebCoreTypedArrayController.h"
@@ -69,8 +69,10 @@
struct ExceptionCodeWithMessage;
-typedef int ExceptionCode;
+template<typename> class ExceptionOr;
+using ExceptionCode = int;
+
struct ExceptionDetails {
String message;
int lineNumber { 0 };
@@ -186,6 +188,9 @@
WEBCORE_EXPORT void setDOMException(JSC::ExecState*, ExceptionCode);
void setDOMException(JSC::ExecState*, const ExceptionCodeWithMessage&);
+template<typename T> inline JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ExceptionOr<T>&&);
+template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, ExceptionOr<T>&&);
+
JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
JSC::JSValue jsStringOrNull(JSC::ExecState*, const String&); // null if the string is null
@@ -808,4 +813,23 @@
return optionalNumber ? JSC::jsNumber(optionalNumber.value()) : JSC::jsNull();
}
+template<typename T> inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ExceptionOr<T>&& value)
+{
+ if (UNLIKELY(value.hasException())) {
+ setDOMException(state, value.exceptionCode());
+ return JSC::jsUndefined();
+ }
+ return toJS(state, globalObject, value.takeReturnValue());
+}
+
+template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ExceptionOr<T>&& value)
+{
+ // FIXME: It's really annoying to have two of these functions. Should find a way to combine toJS and toJSNewlyCreated.
+ if (UNLIKELY(value.hasException())) {
+ setDOMException(state, value.exceptionCode());
+ return JSC::jsUndefined();
+ }
+ return toJSNewlyCreated(state, globalObject, value.takeReturnValue());
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (205410 => 205411)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-09-03 23:34:00 UTC (rev 205411)
@@ -4341,7 +4341,7 @@
push(@implContent, " args.append(" . NativeToJSValue($param, 1, $interface, $paramName, "m_data") . ");\n");
}
- push(@implContent, "\n NakedPtr<Exception> returnedException;\n");
+ push(@implContent, "\n NakedPtr<JSC::Exception> returnedException;\n");
my $propertyToLookup = "Identifier::fromString(state, \"${functionName}\")";
my $invokeMethod = "JSCallbackData::CallbackType::FunctionOrObject";
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp (205410 => 205411)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -108,7 +108,7 @@
ExecState* state = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(state, "callbackWithNoParam"), returnedException);
if (returnedException)
reportException(state, returnedException);
@@ -128,7 +128,7 @@
MarkedArgumentBuffer args;
args.append(toJS(state, m_data->globalObject(), arrayParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(state, "callbackWithArrayParam"), returnedException);
if (returnedException)
reportException(state, returnedException);
@@ -149,7 +149,7 @@
args.append(srzParam ? srzParam->deserialize(state, m_data->globalObject(), 0) : jsNull());
args.append(jsStringWithCache(state, strArg));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(state, "callbackWithSerializedScriptValueParam"), returnedException);
if (returnedException)
reportException(state, returnedException);
@@ -169,7 +169,7 @@
MarkedArgumentBuffer args;
args.append(toJS(state, m_data->globalObject(), listParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(state, "callbackWithStringList"), returnedException);
if (returnedException)
reportException(state, returnedException);
@@ -189,7 +189,7 @@
MarkedArgumentBuffer args;
args.append(jsBoolean(boolParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(state, "callbackWithBoolean"), returnedException);
if (returnedException)
reportException(state, returnedException);
@@ -210,7 +210,7 @@
args.append(jsNumber(longParam));
args.append(toJS(state, m_data->globalObject(), testNodeParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(state, "callbackRequiresThisToPass"), returnedException);
if (returnedException)
reportException(state, returnedException);
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp (205410 => 205411)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -72,7 +72,7 @@
ExecState* state = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
UNUSED_PARAM(state);
m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
if (returnedException)
@@ -93,7 +93,7 @@
MarkedArgumentBuffer args;
args.append(toJS(state, m_data->globalObject(), arrayParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
UNUSED_PARAM(state);
m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
if (returnedException)
@@ -115,7 +115,7 @@
args.append(srzParam ? srzParam->deserialize(state, m_data->globalObject(), 0) : jsNull());
args.append(jsStringWithCache(state, strArg));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
UNUSED_PARAM(state);
m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
if (returnedException)
@@ -136,7 +136,7 @@
MarkedArgumentBuffer args;
args.append(toJS(state, m_data->globalObject(), listParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
UNUSED_PARAM(state);
m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
if (returnedException)
@@ -157,7 +157,7 @@
MarkedArgumentBuffer args;
args.append(jsBoolean(boolParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
UNUSED_PARAM(state);
m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
if (returnedException)
@@ -179,7 +179,7 @@
args.append(jsNumber(longParam));
args.append(toJS(state, m_data->globalObject(), testNodeParam));
- NakedPtr<Exception> returnedException;
+ NakedPtr<JSC::Exception> returnedException;
UNUSED_PARAM(state);
m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
if (returnedException)
Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (205410 => 205411)
--- trunk/Source/WebCore/dom/DOMImplementation.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -25,25 +25,25 @@
#include "config.h"
#include "DOMImplementation.h"
+#include "CSSStyleSheet.h"
#include "ContentType.h"
-#include "CSSStyleSheet.h"
#include "DocumentType.h"
#include "Element.h"
#include "ExceptionCode.h"
+#include "FTPDirectoryDocument.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
-#include "FTPDirectoryDocument.h"
#include "HTMLDocument.h"
#include "HTMLHeadElement.h"
#include "HTMLTitleElement.h"
#include "Image.h"
#include "ImageDocument.h"
+#include "MIMETypeRegistry.h"
#include "MainFrame.h"
#include "MediaDocument.h"
+#include "MediaList.h"
#include "MediaPlayer.h"
-#include "MediaList.h"
-#include "MIMETypeRegistry.h"
#include "Page.h"
#include "PluginData.h"
#include "PluginDocument.h"
@@ -73,6 +73,7 @@
}
#if ENABLE(VIDEO)
+
class DOMImplementationSupportsTypeClient : public MediaPlayerSupportsTypeClient {
public:
DOMImplementationSupportsTypeClient(bool needsHacks, const String& host)
@@ -88,6 +89,7 @@
bool m_needsHacks;
String m_host;
};
+
#endif
static bool isSupportedSVG10Feature(const String& feature, const String& version)
@@ -207,103 +209,58 @@
return true;
}
-RefPtr<DocumentType> DOMImplementation::createDocumentType(const String& qualifiedName,
- const String& publicId, const String& systemId, ExceptionCode& ec)
+ExceptionOr<Ref<DocumentType>> DOMImplementation::createDocumentType(const String& qualifiedName, const String& publicId, const String& systemId)
{
- String prefix, localName;
- if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec))
- return 0;
+ ExceptionCode ec = 0;
+ String prefix;
+ String localName;
+ Document::parseQualifiedName(qualifiedName, prefix, localName, ec);
+ if (ec)
+ return Exception(ec);
return DocumentType::create(m_document, qualifiedName, publicId, systemId);
}
-DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/)
+static inline Ref<XMLDocument> createXMLDocument(const String& namespaceURI)
{
- return 0;
+ if (namespaceURI == SVGNames::svgNamespaceURI)
+ return SVGDocument::create(nullptr, URL());
+ if (namespaceURI == HTMLNames::xhtmlNamespaceURI)
+ return XMLDocument::createXHTML(nullptr, URL());
+ return XMLDocument::create(nullptr, URL());
}
-RefPtr<XMLDocument> DOMImplementation::createDocument(const String& namespaceURI,
- const String& qualifiedName, DocumentType* doctype, ExceptionCode& ec)
+ExceptionOr<Ref<XMLDocument>> DOMImplementation::createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType* documentType)
{
- RefPtr<XMLDocument> doc;
- if (namespaceURI == SVGNames::svgNamespaceURI)
- doc = SVGDocument::create(0, URL());
- else if (namespaceURI == HTMLNames::xhtmlNamespaceURI)
- doc = XMLDocument::createXHTML(0, URL());
- else
- doc = XMLDocument::create(0, URL());
+ auto document = createXMLDocument(namespaceURI);
- doc->setSecurityOriginPolicy(m_document.securityOriginPolicy());
+ document->setSecurityOriginPolicy(m_document.securityOriginPolicy());
- RefPtr<Node> documentElement;
+ RefPtr<Element> documentElement;
if (!qualifiedName.isEmpty()) {
- documentElement = doc->createElementNS(namespaceURI, qualifiedName, ec);
+ ExceptionCode ec = 0;
+ documentElement = document->createElementNS(namespaceURI, qualifiedName, ec);
if (ec)
- return nullptr;
+ return Exception(ec);
}
- if (doctype)
- doc->appendChild(*doctype);
+ if (documentType)
+ document->appendChild(*documentType);
if (documentElement)
- doc->appendChild(*documentElement);
+ document->appendChild(*documentElement);
- return doc;
+ return WTFMove(document);
}
-Ref<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode&)
+Ref<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media)
{
// FIXME: Title should be set.
// FIXME: Media could have wrong syntax, in which case we should generate an exception.
- Ref<CSSStyleSheet> sheet = CSSStyleSheet::create(StyleSheetContents::create());
+ auto sheet = CSSStyleSheet::create(StyleSheetContents::create());
sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
return sheet;
}
-static inline bool isValidXMLMIMETypeChar(UChar c)
-{
- // Valid characters per RFCs 3023 and 2045:
- // 0-9a-zA-Z_-+~!$^{}|.%'`#&*
- return isASCIIAlphanumeric(c) || c == '!' || c == '#' || c == '$' || c == '%' || c == '&' || c == '\'' || c == '*' || c == '+'
- || c == '-' || c == '.' || c == '^' || c == '_' || c == '`' || c == '{' || c == '|' || c == '}' || c == '~';
-}
-
-bool DOMImplementation::isXMLMIMEType(const String& mimeType)
-{
- // FIXME: Can we move this logic to MIMETypeRegistry and have this just be a single function call?
-
- if (equalLettersIgnoringASCIICase(mimeType, "text/xml") || equalLettersIgnoringASCIICase(mimeType, "application/xml") || equalLettersIgnoringASCIICase(mimeType, "text/xsl"))
- return true;
-
- if (!mimeType.endsWith("+xml", false))
- return false;
-
- size_t slashPosition = mimeType.find('/');
- // Take into account the '+xml' ending of mimeType.
- if (slashPosition == notFound || !slashPosition || slashPosition == mimeType.length() - 5)
- return false;
-
- // Again, mimeType ends with '+xml', no need to check the validity of that substring.
- size_t mimeLength = mimeType.length();
- for (size_t i = 0; i < mimeLength - 4; ++i) {
- if (!isValidXMLMIMETypeChar(mimeType[i]) && i != slashPosition)
- return false;
- }
-
- return true;
-}
-
-bool DOMImplementation::isTextMIMEType(const String& mimeType)
-{
- // FIXME: Can we move this logic to MIMETypeRegistry and have this just be a single function call?
-
- return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType)
- || equalLettersIgnoringASCIICase(mimeType, "application/json") // Render JSON as text/plain.
- || (mimeType.startsWith("text/", false)
- && !equalLettersIgnoringASCIICase(mimeType, "text/html")
- && !equalLettersIgnoringASCIICase(mimeType, "text/xml")
- && !equalLettersIgnoringASCIICase(mimeType, "text/xsl"));
-}
-
Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
{
auto document = HTMLDocument::create(nullptr, URL());
@@ -321,6 +278,9 @@
Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
{
+ // FIXME: Confusing to have this here with public DOM APIs for creating documents. This is different enough that it should perhaps be moved.
+ // FIXME: This function is doing case insensitive comparisons on MIME types. Should do equalLettersIgnoringASCIICase instead.
+
// Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
if (type == "text/html")
return HTMLDocument::create(frame, url);
@@ -338,7 +298,7 @@
return ImageDocument::create(*frame, url);
PluginData* pluginData = nullptr;
- PluginData::AllowedPluginTypes allowedPluginTypes = PluginData::OnlyApplicationPlugins;
+ auto allowedPluginTypes = PluginData::OnlyApplicationPlugins;
if (frame && frame->page()) {
if (frame->loader().subframeLoader().allowPlugins())
allowedPluginTypes = PluginData::AllPlugins;
@@ -369,13 +329,13 @@
// and also serves as an optimization to prevent loading the plug-in database in the common case.
if (type != "text/plain" && ((pluginData && pluginData->supportsWebVisibleMimeType(type, allowedPluginTypes)) || (frame && frame->loader().client().shouldAlwaysUsePluginDocument(type))))
return PluginDocument::create(frame, url);
- if (isTextMIMEType(type))
+ if (MIMETypeRegistry::isTextMIMEType(type))
return TextDocument::create(frame, url);
if (type == "image/svg+xml")
return SVGDocument::create(frame, url);
- if (isXMLMIMEType(type))
+ if (MIMETypeRegistry::isXMLMIMEType(type))
return XMLDocument::create(frame, url);
return HTMLDocument::create(frame, url);
Modified: trunk/Source/WebCore/dom/DOMImplementation.h (205410 => 205411)
--- trunk/Source/WebCore/dom/DOMImplementation.h 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/dom/DOMImplementation.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,6 +23,7 @@
#pragma once
+#include "ExceptionOr.h"
#include "XMLDocument.h"
namespace WebCore {
@@ -36,25 +37,14 @@
void deref() { m_document.deref(); }
Document& document() { return m_document; }
- // DOM methods & attributes for DOMImplementation
+ WEBCORE_EXPORT ExceptionOr<Ref<DocumentType>> createDocumentType(const String& qualifiedName, const String& publicId, const String& systemId);
+ WEBCORE_EXPORT ExceptionOr<Ref<XMLDocument>> createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType*);
+ WEBCORE_EXPORT Ref<HTMLDocument> createHTMLDocument(const String& title);
WEBCORE_EXPORT static bool hasFeature(const String& feature, const String& version);
- WEBCORE_EXPORT RefPtr<DocumentType> createDocumentType(const String& qualifiedName, const String& publicId, const String& systemId, ExceptionCode&);
- WEBCORE_EXPORT RefPtr<XMLDocument> createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType*, ExceptionCode&);
+ WEBCORE_EXPORT static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media);
- DOMImplementation* getInterface(const String& feature);
-
- // From the DOMImplementationCSS interface
- WEBCORE_EXPORT static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media, ExceptionCode&);
-
- // From the HTMLDOMImplementation interface
- WEBCORE_EXPORT Ref<HTMLDocument> createHTMLDocument(const String& title);
-
- // Other methods (not part of DOM)
static Ref<Document> createDocument(const String& MIMEType, Frame*, const URL&);
- WEBCORE_EXPORT static bool isXMLMIMEType(const String& MIMEType);
- WEBCORE_EXPORT static bool isTextMIMEType(const String& MIMEType);
-
private:
Document& m_document;
};
Modified: trunk/Source/WebCore/dom/DOMImplementation.idl (205410 => 205411)
--- trunk/Source/WebCore/dom/DOMImplementation.idl 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/dom/DOMImplementation.idl 2016-09-03 23:34:00 UTC (rev 205411)
@@ -23,15 +23,14 @@
GenerateIsReachable=ImplDocument,
ImplementationLacksVTable,
] interface DOMImplementation {
+ [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
+ [NewObject] XMLDocument createDocument(DOMString? namespaceURI, [TreatNullAs=EmptyString] DOMString qualifiedName, optional DocumentType? doctype = null);
+ [NewObject] HTMLDocument createHTMLDocument(optional DOMString title);
+
+ // FIXME: Latest DOM specification says this should ignore all arguments and always return true.
// FIXME: Using "undefined" as default parameter value is wrong.
boolean hasFeature(optional DOMString feature = "undefined", [TreatNullAs=EmptyString] optional DOMString version = "undefined");
- [RaisesException, NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
-
- [NewObject, RaisesException] XMLDocument createDocument(DOMString? namespaceURI, [TreatNullAs=EmptyString] DOMString qualifiedName, optional DocumentType? doctype = null);
-
// FIXME: Using "undefined" as default parameter value is wrong.
- [RaisesException] CSSStyleSheet createCSSStyleSheet(optional DOMString title = "undefined", optional DOMString media = "undefined");
-
- [NewObject] HTMLDocument createHTMLDocument(optional DOMString title);
+ CSSStyleSheet createCSSStyleSheet(optional DOMString title = "undefined", optional DOMString media = "undefined");
};
Modified: trunk/Source/WebCore/dom/Document.cpp (205410 => 205411)
--- trunk/Source/WebCore/dom/Document.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1373,11 +1373,6 @@
void Document::setXMLVersion(const String& version, ExceptionCode& ec)
{
- if (!implementation().hasFeature("XML", String())) {
- ec = NOT_SUPPORTED_ERR;
- return;
- }
-
if (!XMLDocumentParser::supportsXMLVersion(version)) {
ec = NOT_SUPPORTED_ERR;
return;
@@ -1386,13 +1381,8 @@
m_xmlVersion = version;
}
-void Document::setXMLStandalone(bool standalone, ExceptionCode& ec)
+void Document::setXMLStandalone(bool standalone)
{
- if (!implementation().hasFeature("XML", String())) {
- ec = NOT_SUPPORTED_ERR;
- return;
- }
-
m_xmlStandalone = standalone ? Standalone : NotStandalone;
}
Modified: trunk/Source/WebCore/dom/Document.h (205410 => 205411)
--- trunk/Source/WebCore/dom/Document.h 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/dom/Document.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -442,7 +442,7 @@
void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
WEBCORE_EXPORT void setXMLVersion(const String&, ExceptionCode&);
- WEBCORE_EXPORT void setXMLStandalone(bool, ExceptionCode&);
+ WEBCORE_EXPORT void setXMLStandalone(bool);
void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
String documentURI() const { return m_documentURI; }
Modified: trunk/Source/WebCore/dom/Document.idl (205410 => 205411)
--- trunk/Source/WebCore/dom/Document.idl 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/dom/Document.idl 2016-09-03 23:34:00 UTC (rev 205411)
@@ -53,7 +53,7 @@
readonly attribute DOMString? xmlEncoding;
[SetterRaisesException] attribute DOMString? xmlVersion;
- [SetterRaisesException] attribute boolean xmlStandalone;
+ attribute boolean xmlStandalone;
[RaisesException] Node adoptNode(Node source);
Added: trunk/Source/WebCore/dom/Exception.h (0 => 205411)
--- trunk/Source/WebCore/dom/Exception.h (rev 0)
+++ trunk/Source/WebCore/dom/Exception.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -0,0 +1,53 @@
+/*
+
+Copyright (C) 2016 Apple Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#pragma once
+
+namespace WebCore {
+
+using ExceptionCode = int;
+
+class Exception {
+public:
+ explicit Exception(ExceptionCode);
+
+ WEBCORE_EXPORT ExceptionCode code() const;
+
+private:
+ ExceptionCode m_code;
+};
+
+inline Exception::Exception(ExceptionCode code)
+ : m_code(code)
+{
+}
+
+inline ExceptionCode Exception::code() const
+{
+ return m_code;
+}
+
+}
Added: trunk/Source/WebCore/dom/ExceptionOr.h (0 => 205411)
--- trunk/Source/WebCore/dom/ExceptionOr.h (rev 0)
+++ trunk/Source/WebCore/dom/ExceptionOr.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -0,0 +1,72 @@
+/*
+
+Copyright (C) 2016 Apple Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#pragma once
+
+#include "Exception.h"
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+template<typename ReturnType> class ExceptionOr {
+public:
+ ExceptionOr(Exception&&);
+ ExceptionOr(ReturnType&&);
+
+ bool hasException() const;
+ ExceptionCode exceptionCode() const;
+ ReturnType&& takeReturnValue();
+
+private:
+ std::experimental::variant<Exception, ReturnType> m_value;
+};
+
+template<typename ReturnType> inline ExceptionOr<ReturnType>::ExceptionOr(Exception&& exception)
+ : m_value(WTFMove(exception))
+{
+}
+
+template<typename ReturnType> inline ExceptionOr<ReturnType>::ExceptionOr(ReturnType&& returnValue)
+ : m_value(WTFMove(returnValue))
+{
+}
+
+template<typename ReturnType> inline bool ExceptionOr<ReturnType>::hasException() const
+{
+ return std::experimental::holds_alternative<Exception>(m_value);
+}
+
+template<typename ReturnType> inline ExceptionCode ExceptionOr<ReturnType>::exceptionCode() const
+{
+ return std::experimental::get<Exception>(m_value).code();
+}
+
+template<typename ReturnType> inline ReturnType&& ExceptionOr<ReturnType>::takeReturnValue()
+{
+ return std::experimental::get<ReturnType>(WTFMove(m_value));
+}
+
+}
Modified: trunk/Source/WebCore/html/HTMLTemplateElement.cpp (205410 => 205411)
--- trunk/Source/WebCore/html/HTMLTemplateElement.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/html/HTMLTemplateElement.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -29,10 +29,8 @@
*/
#include "config.h"
-
#include "HTMLTemplateElement.h"
-#include "DOMImplementation.h"
#include "DocumentFragment.h"
#include "HTMLDocument.h"
#include "TemplateContentDocumentFragment.h"
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (205410 => 205411)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -40,7 +40,6 @@
#include "CachedScript.h"
#include "Cookie.h"
#include "CookieJar.h"
-#include "DOMImplementation.h"
#include "DOMPatchSupport.h"
#include "DOMWrapperWorld.h"
#include "Document.h"
@@ -59,6 +58,7 @@
#include "InspectorOverlay.h"
#include "InspectorTimelineAgent.h"
#include "InstrumentingAgents.h"
+#include "MIMETypeRegistry.h"
#include "MainFrame.h"
#include "MemoryCache.h"
#include "Page.h"
@@ -128,7 +128,7 @@
RefPtr<TextResourceDecoder> decoder;
if (!textEncodingName.isEmpty())
decoder = TextResourceDecoder::create("text/plain", textEncodingName);
- else if (DOMImplementation::isXMLMIMEType(mimeType)) {
+ else if (MIMETypeRegistry::isXMLMIMEType(mimeType)) {
decoder = TextResourceDecoder::create("application/xml");
decoder->useLenientXMLDecoding();
} else if (equalLettersIgnoringASCIICase(mimeType, "text/html"))
Modified: trunk/Source/WebCore/inspector/NetworkResourcesData.cpp (205410 => 205411)
--- trunk/Source/WebCore/inspector/NetworkResourcesData.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/inspector/NetworkResourcesData.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -30,24 +30,18 @@
#include "NetworkResourcesData.h"
#include "CachedResource.h"
-#include "DOMImplementation.h"
+#include "MIMETypeRegistry.h"
#include "ResourceResponse.h"
#include "SharedBuffer.h"
#include "TextResourceDecoder.h"
-namespace {
-// 100MB
-static const size_t maximumResourcesContentSize = 100 * 1000 * 1000;
-
-// 10MB
-static const size_t maximumSingleResourceContentSize = 10 * 1000 * 1000;
-}
-
using namespace Inspector;
namespace WebCore {
-// ResourceData
+static const size_t maximumResourcesContentSize = 100 * 1000 * 1000; // 100MB
+static const size_t maximumSingleResourceContentSize = 10 * 1000 * 1000; // 10MB
+
NetworkResourcesData::ResourceData::ResourceData(const String& requestId, const String& loaderId)
: m_requestId(requestId)
, m_loaderId(loaderId)
@@ -117,7 +111,6 @@
return contentSizeInBytes(m_content) - dataLength;
}
-// NetworkResourcesData
NetworkResourcesData::NetworkResourcesData()
: m_contentSize(0)
, m_maximumResourcesContentSize(maximumResourcesContentSize)
@@ -141,7 +134,7 @@
RefPtr<TextResourceDecoder> decoder;
if (!textEncodingName.isEmpty())
decoder = TextResourceDecoder::create("text/plain", textEncodingName);
- else if (DOMImplementation::isXMLMIMEType(mimeType)) {
+ else if (MIMETypeRegistry::isXMLMIMEType(mimeType)) {
decoder = TextResourceDecoder::create("application/xml");
decoder->useLenientXMLDecoding();
} else if (equalLettersIgnoringASCIICase(mimeType, "text/html"))
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (205410 => 205411)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -45,7 +45,6 @@
#include "ChromeClient.h"
#include "ContentFilter.h"
#include "ContentSecurityPolicy.h"
-#include "DOMImplementation.h"
#include "DOMWindow.h"
#include "DatabaseManager.h"
#include "DiagnosticLoggingClient.h"
Modified: trunk/Source/WebCore/loader/TextResourceDecoder.cpp (205410 => 205411)
--- trunk/Source/WebCore/loader/TextResourceDecoder.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/loader/TextResourceDecoder.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -23,9 +23,9 @@
#include "config.h"
#include "TextResourceDecoder.h"
-#include "DOMImplementation.h"
#include "HTMLMetaCharsetParser.h"
#include "HTMLNames.h"
+#include "MIMETypeRegistry.h"
#include "TextCodec.h"
#include "TextEncoding.h"
#include "TextEncodingDetector.h"
@@ -306,7 +306,7 @@
return CSS;
if (equalLettersIgnoringASCIICase(mimeType, "text/html"))
return HTML;
- if (DOMImplementation::isXMLMIMEType(mimeType))
+ if (MIMETypeRegistry::isXMLMIMEType(mimeType))
return XML;
return PlainText;
}
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (205410 => 205411)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
*
* Redistribution and use in source and binary forms, with or without
@@ -29,21 +29,22 @@
#include "MediaPlayer.h"
#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
#include <wtf/MainThread.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
-#include <wtf/text/StringHash.h>
#if USE(CG)
#include "ImageSourceCG.h"
-#if !PLATFORM(IOS)
+#include <wtf/RetainPtr.h>
+#endif
+
+#if USE(CG) && !PLATFORM(IOS)
#include <ApplicationServices/ApplicationServices.h>
-#else
+#endif
+
+#if PLATFORM(IOS)
#include <ImageIO/CGImageDestination.h>
#endif
-#include <wtf/RetainPtr.h>
-#endif
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
#include "ArchiveFactory.h"
@@ -542,6 +543,47 @@
return unsupportedTextMIMETypes->contains(mimeType);
}
+bool MIMETypeRegistry::isTextMIMEType(const String& mimeType)
+{
+ return isSupportedJavaScriptMIMEType(mimeType)
+ || equalLettersIgnoringASCIICase(mimeType, "application/json") // Render JSON as text/plain.
+ || (mimeType.startsWith("text/", false)
+ && !equalLettersIgnoringASCIICase(mimeType, "text/html")
+ && !equalLettersIgnoringASCIICase(mimeType, "text/xml")
+ && !equalLettersIgnoringASCIICase(mimeType, "text/xsl"));
+}
+
+
+static inline bool isValidXMLMIMETypeChar(UChar c)
+{
+ // Valid characters per RFCs 3023 and 2045: 0-9a-zA-Z_-+~!$^{}|.%'`#&*
+ return isASCIIAlphanumeric(c) || c == '!' || c == '#' || c == '$' || c == '%' || c == '&' || c == '\'' || c == '*' || c == '+'
+ || c == '-' || c == '.' || c == '^' || c == '_' || c == '`' || c == '{' || c == '|' || c == '}' || c == '~';
+}
+
+bool MIMETypeRegistry::isXMLMIMEType(const String& mimeType)
+{
+ if (equalLettersIgnoringASCIICase(mimeType, "text/xml") || equalLettersIgnoringASCIICase(mimeType, "application/xml") || equalLettersIgnoringASCIICase(mimeType, "text/xsl"))
+ return true;
+
+ if (!mimeType.endsWith("+xml", false))
+ return false;
+
+ size_t slashPosition = mimeType.find('/');
+ // Take into account the '+xml' ending of mimeType.
+ if (slashPosition == notFound || !slashPosition || slashPosition == mimeType.length() - 5)
+ return false;
+
+ // Again, mimeType ends with '+xml', no need to check the validity of that substring.
+ size_t mimeLength = mimeType.length();
+ for (size_t i = 0; i < mimeLength - 4; ++i) {
+ if (!isValidXMLMIMETypeChar(mimeType[i]) && i != slashPosition)
+ return false;
+ }
+
+ return true;
+}
+
bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType)
{
// Since this set is very limited and is likely to remain so we won't bother with the overhead
@@ -577,7 +619,7 @@
return true;
if (mimeType.startsWith("text/", false))
- return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType);
+ return !isUnsupportedTextMIMEType(mimeType);
return false;
}
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (205410 => 205411)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -23,13 +23,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MIMETypeRegistry_h
-#define MIMETypeRegistry_h
+#pragma once
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -60,16 +58,12 @@
static bool isSupportedJavaScriptMIMEType(const String& mimeType);
// Check to see if a non-image MIME type is suitable for being loaded as a
- // document in a frame. Includes supported _javascript_ MIME types.
+ // document in a frame. Includes supported _javascript_ MIME types.
WEBCORE_EXPORT static bool isSupportedNonImageMIMEType(const String& mimeType);
// Check to see if a MIME type is suitable for being loaded using <video> and <audio>.
WEBCORE_EXPORT static bool isSupportedMediaMIMEType(const String& mimeType);
- // Check to see if the MIME type is not suitable for being loaded as a text
- // document in a frame. Only valid for MIME types begining with "text/".
- static bool isUnsupportedTextMIMEType(const String& mimeType);
-
// Check to see if a MIME type is a valid Java applet mime type.
WEBCORE_EXPORT static bool isJavaAppletMIMEType(const String& mimeType);
@@ -86,6 +80,15 @@
// "text/" and isUnsupportedTextMIMEType() returns false.
WEBCORE_EXPORT static bool canShowMIMEType(const String& mimeType);
+ // Check to see if a MIME type is one where an XML document should be created
+ // rather than an HTML document.
+ WEBCORE_EXPORT static bool isXMLMIMEType(const String& mimeType);
+
+ // Used in page load algorithm to decide whether to display as a text
+ // document in a frame. Not a good idea to use elsewhere, because that code
+ // makes this test is after many other tests are done on the MIME type.
+ WEBCORE_EXPORT static bool isTextMIMEType(const String& mimeType);
+
// FIXME: WebKit coding style says we should not have the word "get" in the names of these functions.
// FIXME: Would be nice to find a way to avoid exposing these sets, even worse exposing non-const references.
WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypes();
@@ -100,10 +103,13 @@
// FIXME: WebKit coding style says we should not have the word "get" in the name of this function.
// FIXME: Unclear what the concept of a normalized MIME type is; currently it's a platform-specific notion.
static String getNormalizedMIMEType(const String&);
+
+private:
+ // Check to see if the MIME type is not suitable for being loaded as a text
+ // document in a frame. Only valid for MIME types begining with "text/".
+ static bool isUnsupportedTextMIMEType(const String& mimeType);
};
const String& defaultMIMEType();
} // namespace WebCore
-
-#endif // MIMETypeRegistry_h
Modified: trunk/Source/WebCore/svg/SVGElement.cpp (205410 => 205411)
--- trunk/Source/WebCore/svg/SVGElement.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/svg/SVGElement.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -27,7 +27,6 @@
#include "SVGElement.h"
#include "CSSParser.h"
-#include "DOMImplementation.h"
#include "Document.h"
#include "ElementIterator.h"
#include "Event.h"
@@ -362,11 +361,6 @@
ASSERT_NOT_REACHED();
}
-bool SVGElement::isSupported(StringImpl* feature, StringImpl* version) const
-{
- return DOMImplementation::hasFeature(feature, version);
-}
-
void SVGElement::removedFrom(ContainerNode& rootParent)
{
bool wasInDocument = rootParent.inDocument();
Modified: trunk/Source/WebCore/svg/SVGElement.h (205410 => 205411)
--- trunk/Source/WebCore/svg/SVGElement.h 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/svg/SVGElement.h 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <[email protected]>
* Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <[email protected]>
- * Copyright (C) 2009, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2016 Apple Inc. All rights reserved.
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -20,10 +20,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef SVGElement_h
-#define SVGElement_h
+#pragma once
-#include "CSSPropertyNames.h"
#include "SVGAnimatedString.h"
#include "SVGLangSpace.h"
#include "SVGLocatable.h"
@@ -31,7 +29,6 @@
#include "SVGParsingError.h"
#include "SVGPropertyInfo.h"
#include "StyledElement.h"
-#include "Timer.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
@@ -86,7 +83,7 @@
void svgLoadEventTimerFired();
virtual Timer* svgLoadEventTimer();
- virtual AffineTransform* supplementalTransform() { return 0; }
+ virtual AffineTransform* supplementalTransform() { return nullptr; }
void invalidateSVGAttributes() { ensureUniqueElementData().setAnimatedSVGAttributesAreDirty(true); }
void invalidateSVGPresentationAttributeStyle()
@@ -180,8 +177,6 @@
private:
const RenderStyle* computedStyle(PseudoId = NOPSEUDO) final;
- virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
-
virtual void clearTarget() { }
void buildPendingResourcesIfNeeded();
@@ -264,5 +259,3 @@
SPECIALIZE_TYPE_TRAITS_END()
#include "SVGElementTypeHelpers.h"
-
-#endif
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (205410 => 205411)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -28,7 +28,6 @@
#include "ContentSecurityPolicy.h"
#include "CrossOriginAccessControl.h"
#include "DOMFormData.h"
-#include "DOMImplementation.h"
#include "Event.h"
#include "EventNames.h"
#include "ExceptionCode.h"
@@ -39,6 +38,7 @@
#include "InspectorInstrumentation.h"
#include "JSDOMBinding.h"
#include "JSDOMWindow.h"
+#include "MIMETypeRegistry.h"
#include "MemoryCache.h"
#include "ParsedContentType.h"
#include "ResourceError.h"
@@ -59,7 +59,6 @@
#include <runtime/ArrayBufferView.h>
#include <runtime/JSCInlines.h>
#include <runtime/JSLock.h>
-#include <wtf/Ref.h>
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
@@ -935,7 +934,7 @@
bool XMLHttpRequest::responseIsXML() const
{
- return DOMImplementation::isXMLMIMEType(responseMIMEType());
+ return MIMETypeRegistry::isXMLMIMEType(responseMIMEType());
}
int XMLHttpRequest::status() const
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (205410 => 205411)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1064,7 +1064,7 @@
if (version)
document()->setXMLVersion(toString(version), ASSERT_NO_EXCEPTION);
if (standalone != StandaloneUnspecified)
- document()->setXMLStandalone(standaloneInfo == StandaloneYes, ASSERT_NO_EXCEPTION);
+ document()->setXMLStandalone(standaloneInfo == StandaloneYes);
if (encoding)
document()->setXMLEncoding(toString(encoding));
document()->setHasXMLDeclaration(true);
Modified: trunk/Source/WebKit/mac/ChangeLog (205410 => 205411)
--- trunk/Source/WebKit/mac/ChangeLog 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,3 +1,35 @@
+2016-09-03 Darin Adler <[email protected]>
+
+ Streamline DOMImplementation, and move it to our new DOM exception system
+ https://bugs.webkit.org/show_bug.cgi?id=161295
+
+ Reviewed by Ryosuke Niwa.
+
+ * DOM/DOMDOMImplementation.mm:
+ (unwrap): Added. Use this instead of the IMPL macro.
+ (-[DOMImplementation dealloc]): Updated to use unwrap.
+ (-[DOMImplementation hasFeature:version:]): Ditto.
+ (-[DOMImplementation createDocumentType:publicId:systemId:]): Updated to work with
+ ExceptionOr.
+ (-[DOMImplementation createDocument:qualifiedName:doctype:]): Ditto.
+ (-[DOMImplementation createCSSStyleSheet:media:]): Removed exception logic since
+ this function can no longer raise an exception.
+ (-[DOMImplementation createHTMLDocument:]): Updated to use unwrap.
+ (-[DOMImplementation hasFeature::]): Changed to call the non-deprecated version
+ rather than duplicating its implementation. Also moved into the category as defined
+ in the header.
+ (-[DOMImplementation createDocumentType:::]): Ditto.
+ (-[DOMImplementation createDocument:::]): Ditto.
+ (-[DOMImplementation createCSSStyleSheet::]): Ditto.
+
+ * DOM/DOMDocument.mm: Removed unneeded include of DOMImplementation.h.
+ (-[DOMDocument setXmlStandalone:]): Updated since setXMLStandalone no longer can
+ raise an exception.
+
+ * WebView/WebFrame.mm:
+ (-[WebFrame _canProvideDocumentSource]): Updated to use isTextMIMEType in its new
+ location in MIMETypeRegistry instead of in DOMImplementation.
+
2016-09-03 Brian Weinstein <[email protected]>
Implement a stub version of FrameLoaderClient::shouldUseContentExtensionsForURL.
Modified: trunk/Source/WebKit/mac/DOM/DOMDOMImplementation.mm (205410 => 205411)
--- trunk/Source/WebKit/mac/DOM/DOMDOMImplementation.mm 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit/mac/DOM/DOMDOMImplementation.mm 2016-09-03 23:34:00 UTC (rev 205411)
@@ -30,32 +30,29 @@
#import "DOMDocumentTypeInternal.h"
#import "DOMHTMLDocumentInternal.h"
#import "DOMInternal.h"
-#import "DOMNodeInternal.h"
#import "ExceptionHandlers.h"
#import <WebCore/CSSStyleSheet.h>
#import <WebCore/DOMImplementation.h>
-#import <WebCore/Document.h>
#import <WebCore/DocumentType.h>
#import <WebCore/HTMLDocument.h>
#import <WebCore/JSMainThreadExecState.h>
#import <WebCore/ThreadCheck.h>
-#import <WebCore/URL.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebCore/WebScriptObjectPrivate.h>
-#import <WebCore/XMLDocument.h>
-#import <wtf/GetPtr.h>
-#define IMPL reinterpret_cast<WebCore::DOMImplementation*>(_internal)
-
@implementation DOMImplementation
+static inline WebCore::DOMImplementation& unwrap(DOMImplementation& wrapper)
+{
+ return *reinterpret_cast<WebCore::DOMImplementation*>(wrapper._internal);
+}
+
- (void)dealloc
{
if (WebCoreObjCScheduleDeallocateOnMainThread([DOMImplementation class], self))
return;
-
if (_internal)
- IMPL->deref();
+ unwrap(*self).deref();
[super dealloc];
}
@@ -62,73 +59,61 @@
- (BOOL)hasFeature:(NSString *)feature version:(NSString *)version
{
WebCore::JSMainThreadNullState state;
- return IMPL->hasFeature(feature, version);
+ return unwrap(*self).hasFeature(feature, version);
}
-- (BOOL)hasFeature:(NSString *)feature :(NSString *)version
+- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName publicId:(NSString *)publicId systemId:(NSString *)systemId
{
WebCore::JSMainThreadNullState state;
- return IMPL->hasFeature(feature, version);
+ auto result = unwrap(*self).createDocumentType(qualifiedName, publicId, systemId);
+ if (result.hasException())
+ raiseDOMException(result.exceptionCode());
+ return kit(result.takeReturnValue().ptr());
}
-- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName publicId:(NSString *)publicId systemId:(NSString *)systemId
+- (DOMDocument *)createDocument:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName doctype:(DOMDocumentType *)doctype
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMDocumentType *result = kit(WTF::getPtr(IMPL->createDocumentType(qualifiedName, publicId, systemId, ec)));
- raiseOnDOMError(ec);
- return result;
+ auto result = unwrap(*self).createDocument(namespaceURI, qualifiedName, core(doctype));
+ if (result.hasException())
+ raiseDOMException(result.exceptionCode());
+ return kit(result.takeReturnValue().ptr());
}
-- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName :(NSString *)publicId :(NSString *)systemId
+- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title media:(NSString *)media
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMDocumentType *result = kit(WTF::getPtr(IMPL->createDocumentType(qualifiedName, publicId, systemId, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(unwrap(*self).createCSSStyleSheet(title, media).ptr());
}
-- (DOMDocument *)createDocument:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName doctype:(DOMDocumentType *)doctype
+- (DOMHTMLDocument *)createHTMLDocument:(NSString *)title
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMDocument *result = kit(WTF::getPtr(IMPL->createDocument(namespaceURI, qualifiedName, core(doctype), ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(unwrap(*self).createHTMLDocument(title).ptr());
}
-- (DOMDocument *)createDocument:(NSString *)namespaceURI :(NSString *)qualifiedName :(DOMDocumentType *)doctype
+@end
+
+@implementation DOMImplementation (DOMImplementationDeprecated)
+
+- (BOOL)hasFeature:(NSString *)feature :(NSString *)version
{
- WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMDocument *result = kit(WTF::getPtr(IMPL->createDocument(namespaceURI, qualifiedName, core(doctype), ec)));
- raiseOnDOMError(ec);
- return result;
+ return [self hasFeature:feature version:version];
}
-- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title media:(NSString *)media
+- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName :(NSString *)publicId :(NSString *)systemId
{
- WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMCSSStyleSheet *result = kit(WTF::getPtr(IMPL->createCSSStyleSheet(title, media, ec)));
- raiseOnDOMError(ec);
- return result;
+ return [self createDocumentType:qualifiedName publicId:publicId systemId:systemId];
}
-- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title :(NSString *)media
+- (DOMDocument *)createDocument:(NSString *)namespaceURI :(NSString *)qualifiedName :(DOMDocumentType *)doctype
{
- WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMCSSStyleSheet *result = kit(WTF::getPtr(IMPL->createCSSStyleSheet(title, media, ec)));
- raiseOnDOMError(ec);
- return result;
+ return [self createDocument:namespaceURI qualifiedName:qualifiedName doctype:doctype];
}
-- (DOMHTMLDocument *)createHTMLDocument:(NSString *)title
+- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title :(NSString *)media
{
- WebCore::JSMainThreadNullState state;
- return kit(WTF::getPtr(IMPL->createHTMLDocument(title)));
+ return [self createCSSStyleSheet:title media:media];
}
@end
Modified: trunk/Source/WebKit/mac/DOM/DOMDocument.mm (205410 => 205411)
--- trunk/Source/WebKit/mac/DOM/DOMDocument.mm 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit/mac/DOM/DOMDocument.mm 2016-09-03 23:34:00 UTC (rev 205411)
@@ -46,7 +46,6 @@
#import "DOMHTMLElementInternal.h"
#import "DOMHTMLHeadElementInternal.h"
#import "DOMHTMLScriptElementInternal.h"
-#import <WebCore/DOMImplementation.h>
#import "DOMInternal.h"
#import "DOMNodeInternal.h"
#import "DOMNodeIteratorInternal.h"
@@ -147,9 +146,7 @@
- (void)setXmlStandalone:(BOOL)newXmlStandalone
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- IMPL->setXMLStandalone(newXmlStandalone, ec);
- raiseOnDOMError(ec);
+ IMPL->setXMLStandalone(newXmlStandalone);
}
- (NSString *)documentURI
Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (205410 => 205411)
--- trunk/Source/WebKit/mac/WebView/WebFrame.mm 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm 2016-09-03 23:34:00 UTC (rev 205411)
@@ -61,7 +61,6 @@
#import <WebCore/CachedResourceLoader.h>
#import <WebCore/Chrome.h>
#import <WebCore/ColorMac.h>
-#import <WebCore/DOMImplementation.h>
#import <WebCore/DatabaseManager.h>
#import <WebCore/DocumentFragment.h>
#import <WebCore/DocumentLoader.h>
@@ -80,6 +79,7 @@
#import <WebCore/HitTestResult.h>
#import <WebCore/JSNode.h>
#import <WebCore/LegacyWebArchive.h>
+#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/MainFrame.h>
#import <WebCore/Page.h>
#import <WebCore/PlatformEventFactoryMac.h>
@@ -101,9 +101,9 @@
#import <WebCore/markup.h>
#import <WebKitSystemInterface.h>
#import <bindings/ScriptValue.h>
+#import <runtime/JSCJSValue.h>
#import <runtime/JSLock.h>
#import <runtime/JSObject.h>
-#import <runtime/JSCJSValue.h>
#import <wtf/CurrentTime.h>
#if PLATFORM(IOS)
@@ -111,7 +111,6 @@
#import "WebResource.h"
#import "WebUIKitDelegate.h"
#import <WebCore/Document.h>
-#import <WebCore/Editor.h>
#import <WebCore/EditorClient.h>
#import <WebCore/FocusController.h>
#import <WebCore/Font.h>
@@ -988,7 +987,7 @@
String mimeType = frame->document()->loader()->writer().mimeType();
PluginData* pluginData = frame->page() ? &frame->page()->pluginData() : 0;
- if (WebCore::DOMImplementation::isTextMIMEType(mimeType)
+ if (WebCore::MIMETypeRegistry::isTextMIMEType(mimeType)
|| Image::supportsType(mimeType)
|| (pluginData && pluginData->supportsWebVisibleMimeType(mimeType, PluginData::AllPlugins) && frame->loader().subframeLoader().allowPlugins())
|| (pluginData && pluginData->supportsWebVisibleMimeType(mimeType, PluginData::OnlyApplicationPlugins)))
Modified: trunk/Source/WebKit/win/ChangeLog (205410 => 205411)
--- trunk/Source/WebKit/win/ChangeLog 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit/win/ChangeLog 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,3 +1,14 @@
+2016-09-03 Darin Adler <[email protected]>
+
+ Streamline DOMImplementation, and move it to our new DOM exception system
+ https://bugs.webkit.org/show_bug.cgi?id=161295
+
+ Reviewed by Ryosuke Niwa.
+
+ * WebFrame.cpp:
+ (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new
+ location in MIMETypeRegistry instead of in DOMImplementation.
+
2016-09-02 Ryosuke Niwa <[email protected]>
Build fix attempt after r205381.
Modified: trunk/Source/WebKit/win/WebFrame.cpp (205410 => 205411)
--- trunk/Source/WebKit/win/WebFrame.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit/win/WebFrame.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -59,7 +59,6 @@
#include <WebCore/Document.h>
#include <WebCore/DocumentLoader.h>
#include <WebCore/DocumentMarkerController.h>
-#include <WebCore/DOMImplementation.h>
#include <WebCore/DOMWindow.h>
#include <WebCore/Editor.h>
#include <WebCore/Event.h>
@@ -81,6 +80,7 @@
#include <WebCore/HTMLPlugInElement.h>
#include <WebCore/JSDOMWindow.h>
#include <WebCore/KeyboardEvent.h>
+#include <WebCore/MIMETypeRegistry.h>
#include <WebCore/MainFrame.h>
#include <WebCore/MouseRelatedEvent.h>
#include <WebCore/NotImplemented.h>
@@ -1385,7 +1385,7 @@
BString mimeTypeBStr;
if (SUCCEEDED(urlResponse->MIMEType(&mimeTypeBStr))) {
String mimeType(mimeTypeBStr, SysStringLen(mimeTypeBStr));
- *result = mimeType == "text/html" || WebCore::DOMImplementation::isXMLMIMEType(mimeType);
+ *result = mimeType == "text/html" || WebCore::MIMETypeRegistry::isXMLMIMEType(mimeType);
}
}
return hr;
Modified: trunk/Source/WebKit2/ChangeLog (205410 => 205411)
--- trunk/Source/WebKit2/ChangeLog 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,3 +1,16 @@
+2016-09-03 Darin Adler <[email protected]>
+
+ Streamline DOMImplementation, and move it to our new DOM exception system
+ https://bugs.webkit.org/show_bug.cgi?id=161295
+
+ Reviewed by Ryosuke Niwa.
+
+ * UIProcess/WebFrameProxy.cpp:
+ (WebKit::WebFrameProxy::isDisplayingMarkupDocument): Use isXMLMIMEType in its
+ new location in MIMETypeRegistry rather than in DOMImplementation.
+ (WebKit::WebFrameProxy::isDisplayingPDFDocument): Removed unneeded redundant
+ check for empty string, already done by MIMETypeRegistry.
+
2016-09-03 Brian Weinstein <[email protected]>
Implement WebFrameLoaderClient::shouldUseContentExtensionsForURL and consult the InjectedBundlePageLoaderClient.
@@ -20,6 +33,16 @@
or not we should use content extensions for this URL.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+ * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp:
+ (webkit_dom_dom_implementation_create_document_type): Updated to work with ExceptionOr.
+ (webkit_dom_dom_implementation_create_document): Updated to work with ExceptionOr.
+ (webkit_dom_dom_implementation_create_css_style_sheet): Updated since this function
+ can no longer raise an exception.
+
+ * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp:
+ (webkit_dom_document_set_xml_standalone): Updated since this function can no longer
+ raise an exception.
+
2016-09-03 Joseph Pecoraro <[email protected]>
Web Inspector: Move WebKit2 WebInspector files to #pragma once
Modified: trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp (205410 => 205411)
--- trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -32,7 +32,6 @@
#include "WebPageMessages.h"
#include "WebPageProxy.h"
#include "WebProcessPool.h"
-#include <WebCore/DOMImplementation.h>
#include <WebCore/Image.h>
#include <WebCore/MIMETypeRegistry.h>
#include <stdio.h>
@@ -117,15 +116,13 @@
bool WebFrameProxy::isDisplayingMarkupDocument() const
{
- // FIXME: This check should be moved to somewhere in WebCore.
- return m_MIMEType == "text/html" || m_MIMEType == "image/svg+xml" || m_MIMEType == "application/x-webarchive" || DOMImplementation::isXMLMIMEType(m_MIMEType);
+ // FIXME: This should be a call to a single MIMETypeRegistry function; adding a new one if needed.
+ // FIXME: This is doing case sensitive comparisons on MIME types, should be using ASCII case insensitive instead.
+ return m_MIMEType == "text/html" || m_MIMEType == "image/svg+xml" || m_MIMEType == "application/x-webarchive" || MIMETypeRegistry::isXMLMIMEType(m_MIMEType);
}
bool WebFrameProxy::isDisplayingPDFDocument() const
{
- if (m_MIMEType.isEmpty())
- return false;
-
return MIMETypeRegistry::isPDFOrPostScriptMIMEType(m_MIMEType);
}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp (205410 => 205411)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,6 +1,5 @@
/*
* This file is part of the WebKit open source project.
- * This file has been generated by generate-bindings.pl. DO NOT MODIFY!
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,12 +20,8 @@
#include "config.h"
#include "WebKitDOMDOMImplementation.h"
-#include <WebCore/CSSImportRule.h>
+#include "ConvertToUTF8String.h"
#include "DOMObjectCache.h"
-#include <WebCore/Document.h>
-#include <WebCore/ExceptionCode.h>
-#include <WebCore/ExceptionCodeDescription.h>
-#include <WebCore/JSMainThreadExecState.h>
#include "WebKitDOMCSSStyleSheetPrivate.h"
#include "WebKitDOMDOMImplementationPrivate.h"
#include "WebKitDOMDocumentPrivate.h"
@@ -33,7 +28,11 @@
#include "WebKitDOMDocumentTypePrivate.h"
#include "WebKitDOMHTMLDocumentPrivate.h"
#include "WebKitDOMPrivate.h"
-#include "ConvertToUTF8String.h"
+#include <WebCore/CSSImportRule.h>
+#include <WebCore/Document.h>
+#include <WebCore/ExceptionCode.h>
+#include <WebCore/ExceptionCodeDescription.h>
+#include <WebCore/JSMainThreadExecState.h>
#include <wtf/GetPtr.h>
#include <wtf/RefPtr.h>
@@ -131,13 +130,12 @@
WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
WTF::String convertedPublicId = WTF::String::fromUTF8(publicId);
WTF::String convertedSystemId = WTF::String::fromUTF8(systemId);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::DocumentType> gobjectResult = WTF::getPtr(item->createDocumentType(convertedQualifiedName, convertedPublicId, convertedSystemId, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createDocumentType(convertedQualifiedName, convertedPublicId, convertedSystemId);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.exceptionCode());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.takeReturnValue().ptr());
}
WebKitDOMDocument* webkit_dom_dom_implementation_create_document(WebKitDOMDOMImplementation* self, const gchar* namespaceURI, const gchar* qualifiedName, WebKitDOMDocumentType* doctype, GError** error)
@@ -151,13 +149,12 @@
WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
WebCore::DocumentType* convertedDoctype = WebKit::core(doctype);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Document> gobjectResult = WTF::getPtr(item->createDocument(convertedNamespaceURI, convertedQualifiedName, convertedDoctype, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createDocument(convertedNamespaceURI, convertedQualifiedName, convertedDoctype);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.exceptionCode());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.takeReturnValue().ptr());
}
WebKitDOMCSSStyleSheet* webkit_dom_dom_implementation_create_css_style_sheet(WebKitDOMDOMImplementation* self, const gchar* title, const gchar* media, GError** error)
@@ -170,12 +167,7 @@
WebCore::DOMImplementation* item = WebKit::core(self);
WTF::String convertedTitle = WTF::String::fromUTF8(title);
WTF::String convertedMedia = WTF::String::fromUTF8(media);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::CSSStyleSheet> gobjectResult = WTF::getPtr(item->createCSSStyleSheet(convertedTitle, convertedMedia, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
- g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
- }
+ RefPtr<WebCore::CSSStyleSheet> gobjectResult = WTF::getPtr(item->createCSSStyleSheet(convertedTitle, convertedMedia));
return WebKit::kit(gobjectResult.get());
}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp (205410 => 205411)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp 2016-09-03 23:25:47 UTC (rev 205410)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp 2016-09-03 23:34:00 UTC (rev 205411)
@@ -1,6 +1,5 @@
/*
* This file is part of the WebKit open source project.
- * This file has been generated by generate-bindings.pl. DO NOT MODIFY!
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,13 +20,9 @@
#include "config.h"
#include "WebKitDOMDocument.h"
-#include <WebCore/CSSImportRule.h>
+#include "ConvertToUTF8String.h"
#include "DOMObjectCache.h"
-#include <WebCore/Document.h>
-#include <WebCore/ExceptionCode.h>
-#include <WebCore/ExceptionCodeDescription.h>
#include "GObjectEventListener.h"
-#include <WebCore/JSMainThreadExecState.h>
#include "WebKitDOMAttrPrivate.h"
#include "WebKitDOMCDATASectionPrivate.h"
#include "WebKitDOMCSSStyleDeclarationPrivate.h"
@@ -37,6 +32,7 @@
#include "WebKitDOMDocumentFragmentPrivate.h"
#include "WebKitDOMDocumentPrivate.h"
#include "WebKitDOMDocumentTypePrivate.h"
+#include "WebKitDOMDocumentUnstable.h"
#include "WebKitDOMElementPrivate.h"
#include "WebKitDOMEventPrivate.h"
#include "WebKitDOMEventTarget.h"
@@ -57,8 +53,11 @@
#include "WebKitDOMXPathExpressionPrivate.h"
#include "WebKitDOMXPathNSResolverPrivate.h"
#include "WebKitDOMXPathResultPrivate.h"
-#include "ConvertToUTF8String.h"
-#include "WebKitDOMDocumentUnstable.h"
+#include <WebCore/CSSImportRule.h>
+#include <WebCore/Document.h>
+#include <WebCore/ExceptionCode.h>
+#include <WebCore/ExceptionCodeDescription.h>
+#include <WebCore/JSMainThreadExecState.h>
#include <wtf/GetPtr.h>
#include <wtf/RefPtr.h>
@@ -1497,13 +1496,7 @@
WebCore::JSMainThreadNullState state;
g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
g_return_if_fail(!error || !*error);
- WebCore::Document* item = WebKit::core(self);
- WebCore::ExceptionCode ec = 0;
- item->setXMLStandalone(value, ec);
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
- g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
- }
+ WebKit::core(self)->setXMLStandalone(value);
}
gchar* webkit_dom_document_get_document_uri(WebKitDOMDocument* self)