haikuwebkit/Source/WebCore/dom/Exception.h

66 lines
2.1 KiB
C
Raw Permalink Normal View History

Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
/*
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 "ExceptionCode.h"
#include <wtf/text/WTFString.h>
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
namespace WebCore {
class Exception {
public:
Have class Exception take String by value instead of a String&& https://bugs.webkit.org/show_bug.cgi?id=184360 Reviewed by Alexey Proskuryakov. For convenience support instantiating an Exception with either an lvalue String or rvalue String. Although it can be argued that having Exception take a String by value instead of String&& can lead to missed opportunities to WTFMove() a String object into Exception such mistakes are just that, missed opportunities. That is, correctness is not affected and we may perform an unnecessary ref/deref of the underlying StringImpl when instantiating an Exception. If such missed opportunities show up in profiles and such mistakes happen often then we can re-evaluate the decision to have Exception take a String by value. * Modules/cache/DOMCache.cpp: (WebCore::DOMCache::put): Simplify code now that Exception takes a String by value. * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::BodyLoader::didFail): Ditto. * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed): Move String into Exception to avoid an unnecessary ref/de-ref. (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed): Ditto. (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed): Ditto. * dom/Exception.h: (WebCore::Exception::Exception): Take String by value. Also use uniform initializer syntax. Canonical link: https://commits.webkit.org/199917@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230338 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-06 17:45:57 +00:00
explicit Exception(ExceptionCode, String = { });
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
ExceptionCode code() const { return m_code; }
const String& message() const { return m_message; }
Next step on moving to modern way to return DOM exceptions https://bugs.webkit.org/show_bug.cgi?id=163016 Reviewed by Ryosuke Niwa. Source/WebCore: * Modules/fetch/FetchRequest.idl: Added MayThrowException to initializeWith since it throws an exception. * bindings/js/JSCallbackData.cpp: (WebCore::JSCallbackData::invokeCallback): * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::invokeCallback): * bindings/js/JSCustomSQLStatementErrorCallback.cpp: (WebCore::JSSQLStatementErrorCallback::handleEvent): * bindings/js/JSCustomXPathNSResolver.cpp: (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI): * bindings/js/JSDOMBinding.cpp: (WebCore::reportException): (WebCore::reportCurrentException): * bindings/js/JSErrorHandler.cpp: (WebCore::JSErrorHandler::handleEvent): * bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::handleEvent): * bindings/js/JSMutationCallback.cpp: (WebCore::JSMutationCallback::call): * bindings/js/JSNodeFilterCustom.cpp: (WebCore::JSNodeFilter::acceptNode): * bindings/js/ScheduledAction.cpp: (WebCore::ScheduledAction::executeFunctionInContext): * bindings/js/ScriptController.cpp: (WebCore::ScriptController::evaluateInWorld): * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::evaluate): * inspector/PageScriptDebugServer.cpp: (WebCore::PageScriptDebugServer::reportException): Use JSC::Exception explicitly to avoid ambiguity with WebCore::Exception, or in some cases use auto instead. * bindings/js/JSDOMBinding.cpp: (WebCore::hasUnpairedSurrogate): Factored this inline function out of valueToUSVString for clarity. (WebCore::createDOMException): Removed unused TRY_TO_CREATE_EXCEPTION macro. (WebCore::propagateExceptionSlowPath): Added. (WebCore::propagateException): Added. (WebCore::setDOMException): Removed overload that takes an exception code and message string separately; no longer needed. * bindings/js/JSDOMBinding.h: Include the ExceptionOr header rather than forward declaring. Added more of the ExceptionOr handling functions; some just declared and not yet defined. Updated for changes to ExceptionOr interface. Removed the createDOMException function that takes only an exception code; not needed outside JSDOMBinding.cpp. * bindings/js/JSXMLHttpRequestCustom.cpp: (WebCore::JSXMLHttpRequest::send): Rewrote this to use ExceptionOr instead of ExceptionCode. Added some FIXMEs as well. (WebCore::JSXMLHttpRequest::responseText): Ditto. (WebCore::JSXMLHttpRequest::retrieveResponse): Ditto. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): Fixed if statements to follow WebKit coding style rather than using extra braces. Added call to propagateException for SetterMayThrowException. (GenerateSerializerFunction): Fixed if statements as above. (GenerateParametersCheck): Ditto. Also added call to propagateException for functions with void return type and MayThrowException. (GenerateReturnParameters): Tweaked coding style a bit. (addIterableProperties): Fixed if statements as above. (NativeToJSValue): Added code to handle various cases of GetterMayThrowException and MayThrowException. (GenerateConstructorDefinition): Used encodedJSValue() instead of JSValue::encode(JSValue()), a longer way to say the same thing. * bindings/scripts/IDLAttributes.txt: Added GetterMayThrowException, MayThrowException, and SetterMayThrowException. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestEventConstructor.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestGlobalObject.cpp: * bindings/scripts/test/JS/JSTestInterface.cpp: * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp: * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: * bindings/scripts/test/JS/JSTestNode.cpp: * bindings/scripts/test/JS/JSTestNondeterministic.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: * bindings/scripts/test/JS/JSTestTypedefs.cpp: * bindings/scripts/test/JS/JSattribute.cpp: Regenerated results. * bindings/scripts/test/TestObj.idl: Added some test cases. * dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocumentType): Tweaked formatting. (WebCore::DOMImplementation::createDocument): Ditto. * dom/DOMImplementation.idl: Added MayThrowException to two functions since I am abandoning, for now, the ability to throw exceptions without any extended attribute in the IDL file. This feature may return at some point if we figure out a way to do it for functions without return values as well as functions with. * dom/Document.cpp: (WebCore::Document::exitPointerLock): Rewrote to streamline logic. (WebCore::Document::pointerLockElement): Ditto. (WebCore::Document::inputCursor): Added. No need for this to be inlined. (WebCore::Document::setInputCursor): Changed to take Ref&&. (WebCore::Document::getSelection): Added. Moved here from TreeScope. * dom/Document.h: Updated for above changes. * dom/Document.idl: Tweaked formatting. * dom/Exception.h: Merged the two constructors into one with a default argument value, which should be equally efficient. Added releaseMessage function. Added assertion that this is only created for actual exceptions with non-zero ExceptionCode. Unlike ExceptionCode, which has a value of 0 which means no exception, we do not create an Exception if there is no exception. * dom/ExceptionOr.h: Renamed takeReturnValue to releaseReturnValue. Replaced exceptionCode and exceptionMessage with releaseException. Added ExceptionOr<void> specialization. * dom/TreeScope.cpp: (WebCore::TreeScope::~TreeScope): Removed code dealing with m_selection, which is now in Document. (WebCore::TreeScope::getSelection): Deleted. * dom/TreeScope.h: Removed DOMSelection. * page/DOMSelection.cpp: (WebCore::selectionShadowAncestor): Changed to take a reference rather than a guaranteed-non-null pointer. (WebCore::DOMSelection::DOMSelection): Changed to take a Frame& instead of of a TreeScope*. (WebCore::DOMSelection::clearTreeScope): Deleted. (WebCore::DOMSelection::isCollapsed): Updated call to selectionShadowAncestor. (WebCore::DOMSelection::type): Took out obsolete uneeeded comment. Got rid of case where this returns a null string. Use ASCIILiteral. (WebCore::DOMSelection::rangeCount): Streamlined code. (WebCore::DOMSelection::collapse): Removed redundant check of m_frame for null which is already handled by the isValidForPosition function. Removed non-helpful FIXME. (WebCore::DOMSelection::collapseToEnd): Changed to use ExceptionOr instead of ExceptionCode. (WebCore::DOMSelection::collapseToStart): Ditto. (WebCore::DOMSelection::setBaseAndExtent): Removed redundant check of m_frame for null which is already handled by the isValidForPosition function. Removed non-helpful FIXME. (WebCore::DOMSelection::setPosition): Ditto. (WebCore::DOMSelection::extend): Changed to use ExceptionOr instead of ExceptionCode. (WebCore::DOMSelection::getRangeAt): Ditto. (WebCore::DOMSelection::isValidForPosition): Changed to return false when m_frame is null rather than asserting is is non-null and having every caller check m_frame before calling this. * page/DOMSelection.h: Use #pragma once. Fix indentation. Removed unneeded comments. Use ExceptionOr rather than ExceptionCode. * page/DOMSelection.idl: Move from MayThrowLegacyException to MayThrowException. * page/DOMWindow.cpp: (WebCore::DOMWindow::resetDOMWindowProperties): Sorted properties alphabetically to make it more obvious if any are accidentally omitted or listed twice. (WebCore::DOMWindow::getSelection): Changed ownership so that the window owns the selection like all the other objects, rather than having it be owned by the document instead. * page/DOMWindow.h: Added m_selection, sorted all the other related properties alphabetically so it's easy to compare the list here with elsewhere. * replay/ReplayController.cpp: (WebCore::ReplayController::frameNavigated): Updated to call setInputCursor with a reference rather than a pointer. * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::responseText): Use ExceptionOr rather than ExceptionCode. (WebCore::XMLHttpRequest::responseXML): Ditto. (WebCore::XMLHttpRequest::setTimeout): Ditto. (WebCore::XMLHttpRequest::setResponseType): Ditto. (WebCore::XMLHttpRequest::setWithCredentials): Ditto. (WebCore::XMLHttpRequest::open): Ditto. (WebCore::XMLHttpRequest::prepareToSend): Changed to return an Optional<ExceptionOr> to reflect the three different states: an exception, a value to return without sending, or "continue with the send algorithm". The old code did this with a boolean plus an exception code. This sounds confusing but is easy to read at the call sites, so probably OK to keep. (WebCore::XMLHttpRequest::send): Use ExceptionOr rather than ExceptionCode. (WebCore::XMLHttpRequest::sendBytesData): Ditto. (WebCore::XMLHttpRequest::createRequest): Ditto. (WebCore::XMLHttpRequest::overrideMimeType): Ditto. (WebCore::XMLHttpRequest::setRequestHeader): Ditto. * xml/XMLHttpRequest.h: Updated for changes above. * xml/XMLHttpRequest.idl: Sorted interface extended attributes alphabetically. Changed from MayThrowLegacyException to MayThrowException. Source/WebKit/mac: * DOM/DOMDOMImplementation.mm: (-[DOMImplementation createDocumentType:publicId:systemId:]): Updated for name change from takeReturnValue to releaseReturnValue. (-[DOMImplementation createDocument:qualifiedName:doctype:]): Ditto. Source/WebKit2: * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp: (webkit_dom_dom_implementation_create_document_type): Updated for name change from takeReturnValue to releaseReturnValue. (webkit_dom_dom_implementation_create_document): Ditto. * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMSelection.cpp: (webkit_dom_dom_selection_collapse_to_end): Use ExceptionOr instead of ExceptionCode. (webkit_dom_dom_selection_collapse_to_start): Ditto. (webkit_dom_dom_selection_extend): Ditto. (webkit_dom_dom_selection_get_range_at): Ditto. Tools: * Scripts/do-webcore-rename: Add proposed name change of setDOMException to propagateException, since this function is primarily used to take an exception already effectively "thrown" by setting an ExceptionCode out argument and propagate it into the JavaScript engine's exception machinery. Canonical link: https://commits.webkit.org/181008@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-08 23:01:27 +00:00
String&& releaseMessage() { return WTFMove(m_message); }
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
Implement FileSystemDirectoryReader.readEntries() https://bugs.webkit.org/show_bug.cgi?id=176091 <rdar://problem/34168015> Reviewed by Andreas Kling. Source/WebCore: Tests: editing/pasteboard/datatransfer-items-drop-directoryReader-error.html editing/pasteboard/datatransfer-items-drop-directoryReader-root.html editing/pasteboard/datatransfer-items-drop-directoryReader.html * Modules/entriesapi/DOMFileSystem.cpp: (WebCore::ListedChild::isolatedCopy const): (WebCore::listDirectoryWithMetadata): (WebCore::toFileSystemEntries): (WebCore::DOMFileSystem::DOMFileSystem): (WebCore::DOMFileSystem::root): (WebCore::DOMFileSystem::fileAsEntry): (WebCore::DOMFileSystem::evaluatePath): (WebCore::DOMFileSystem::listDirectory): * Modules/entriesapi/DOMFileSystem.h: (WebCore::DOMFileSystem::createEntryForFile): * Modules/entriesapi/DOMFileSystem.idl: - Implement directory listing operation for supporting FileSystemDirectoryReader::readEntries(). - Implement evaluatePath() operation as per: - https://wicg.github.io/entries-api/#evaluate-a-path - DOMFileSystem should no longer hold a strong reference to the root entry and FileSystemEntry now holds a strong reference to the DOMFileSystem and this would create a cycle. * Modules/entriesapi/FileSystemDirectoryEntry.cpp: (WebCore::FileSystemDirectoryEntry::createReader): * Modules/entriesapi/FileSystemDirectoryEntry.h: * Modules/entriesapi/FileSystemDirectoryEntry.idl: Have createReader() take a ScriptExecutionContext, which is needed to construct a FileSystemDirectoryReader, now that FileSystemDirectoryReader is an ActiveDOMObject. * Modules/entriesapi/FileSystemDirectoryReader.cpp: (WebCore::FileSystemDirectoryReader::FileSystemDirectoryReader): (WebCore::FileSystemDirectoryReader::activeDOMObjectName const): (WebCore::FileSystemDirectoryReader::canSuspendForDocumentSuspension const): (WebCore::FileSystemDirectoryReader::readEntries): * Modules/entriesapi/FileSystemDirectoryReader.h: * Modules/entriesapi/FileSystemDirectoryReader.idl: Provide implementation for FileSystemDirectoryReader.readEntries() as per: - https://wicg.github.io/entries-api/#dom-filesystemdirectoryreader-readentries For the actual directory listing operation, we ask the DOMFileSystem, which is where all filesystem operations should live. Also made the FileSystemDirectoryReader an ActiveDOMObject to keep it and its wrapper alive while a file system operation is pending. * Modules/entriesapi/FileSystemEntry.cpp: (WebCore::FileSystemEntry::~FileSystemEntry): (WebCore::FileSystemEntry::filesystem const): * Modules/entriesapi/FileSystemEntry.h: Make FileSystemEntry keep a strong reference to its DOMFileSystem object. Previously, the DOMFileSystem was kept alive by the DataTransferItem but this was unsafe because FileSystemEntry may outlive the DataTransferItem. * dom/ActiveDOMObject.h: (WebCore::ActiveDOMObject::PendingActivity::PendingActivity): (WebCore::ActiveDOMObject::PendingActivity::~PendingActivity): (WebCore::ActiveDOMObject::makePendingActivity): Add PendingActivity / makePendingActivity() as a less error-prone replacement for setPendingActivity() / unsetPendingActivity(). * dom/DOMException.cpp: (WebCore::DOMException::create): * dom/DOMException.h: Add factory to construct a DOMException from an Exception. * dom/DataTransferItem.cpp: (WebCore::DataTransferItem::getAsEntry const): * dom/DataTransferItem.h: * dom/Exception.h: (WebCore::Exception::isolatedCopy const): * dom/ExceptionOr.h: Make ExceptionOr<> / Exception work with CrossThreadCopier for convenience. * html/FileListCreator.cpp: (WebCore::FileListCreator::FileListCreator): Use crossThreadCopy() instead of longer form. * platform/FileSystem.h: * platform/glib/FileSystemGlib.cpp: (WebCore::pathByAppendingComponents): * platform/posix/FileSystemPOSIX.cpp: (WebCore::pathByAppendingComponents): * platform/win/FileSystemWin.cpp: (WebCore::pathByAppendingComponents): Add pathByAppendingComponents() utility function, which is similar to pathByAppendingComponent() but supports appending multiple components in an efficient fashion. Source/WTF: * wtf/CrossThreadCopier.h: (WTF::crossThreadCopy): * wtf/CrossThreadTask.h: Move crossThreadCopy() from CrossThreadTask.h to CrossThreadCopier.h and add "using WTF::crossThreadCopy" statement to make it more easily usable from WebCore. LayoutTests: Add layout test coverage. * editing/editing.js: (moveMouseToCenterOfElement): (dragFilesOntoElement): * editing/pasteboard/datatransfer-items-drop-directoryReader-error-expected.txt: Added. * editing/pasteboard/datatransfer-items-drop-directoryReader-error.html: Added. * editing/pasteboard/datatransfer-items-drop-directoryReader-expected.txt: Added. * editing/pasteboard/datatransfer-items-drop-directoryReader-root-expected.txt: Added. * editing/pasteboard/datatransfer-items-drop-directoryReader-root.html: Added. * editing/pasteboard/datatransfer-items-drop-directoryReader.html: Added. * editing/pasteboard/datatransfer-items-drop-getAsEntry.html: * platform/wk2/TestExpectations: Canonical link: https://commits.webkit.org/192817@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-31 03:48:21 +00:00
Exception isolatedCopy() const
{
return Exception { m_code, m_message.isolatedCopy() };
}
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
private:
ExceptionCode m_code;
String m_message;
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
};
Fix exception handling in SQL database code, streamline and update code https://bugs.webkit.org/show_bug.cgi?id=164685 Reviewed by Sam Weinig. Source/WebCore: Removed some old abstraction layers that were no longer in use. For example, i n many cases, calls were going through DatabaseManager, which called through an abstract class AbstractDatabaseServer to a concrete class DatabaseServer, which then called through to DatabaseTracker. Clients now mostly just call DatabaseTracker directly. * CMakeLists.txt: Removed DatabaseServer.cpp and SQLTransactionClient.cpp. * Modules/webdatabase/AbstractDatabaseServer.h: Removed. * Modules/webdatabase/DOMWindowWebDatabase.cpp: (WebCore::DOMWindowWebDatabase::openDatabase): Use ExceptionOr instead of DatabaseError to communicate DOM exceptions from DatabaseManager. * Modules/webdatabase/Database.cpp: (WebCore::Database::Database): Use a reference instead of a RefPtr&& for database context. Use unsigned instead of unsigned long. Modernize code to use more initialization rather than assignment, to initialize scalar data members in the class definition, and to use HashMap::ensure. (WebCore::Database::databaseThread): Added. This class asserts that there is a thread in the constructor, and so it is useful to have a helper for all the other functions that assumes the thread is present and returns a reference rather than a pointer. (WebCore::Database::~Database): Updated since m_scriptExecutionContext is now a Ref instead of a RefPtr. (WebCore::Database::openAndVerifyVersion): Use ExceptionOr and databaseThread. (WebCore::Database::close): Use databaseThread. (WebCore::Database::performClose): Ditto. (WebCore::DoneCreatingDatabaseOnExitCaller::DoneCreatingDatabaseOnExitCaller): Use a reference. Removed unused m_openSuccceeded. (WebCore::DoneCreatingDatabaseOnExitCaller::~DoneCreatingDatabaseOnExitCaller): Use DatabaseTracker::singleton by its new name. (WebCore::DoneCreatingDatabaseOnExitCaller::setOpenSucceeded): Deleted. (WebCore::Database::performOpenAndVerify): Use ExceptionOr and update for above. (WebCore::Database::closeDatabase): Updated for name change. (WebCore::Database::scheduleTransaction): Updated for above, simplified and streamlined. (WebCore::Database::scheduleTransactionStep): Use databaseThread. (WebCore::Database::transactionClient): Deleted. This object is no longer needed. (WebCore::Database::transactionCoordinator): Use databaseThread. (WebCore::Database::markAsDeletedAndClose): Removed unnecessary null check for databaseThread, which can never be null. (WebCore::Database::estimatedSize): Use unsigned, not unsigned long. (WebCore::Database::disableAuthorizer): Removed assertion about RefPtr that is now a Ref and never could have been null. (WebCore::Database::enableAuthorizer): Ditto. (WebCore::Database::setAuthorizerPermissions): Ditto. (WebCore::Database::lastActionChangedDatabase): Ditto. (WebCore::Database::lastActionWasInsert): Ditto. (WebCore::Database::resetDeletes): Ditto. (WebCore::Database::hadDeletes): Ditto. (WebCore::Database::resetAuthorizer): Removed null check for a RefPtr that is now a Ref and never could have been null. (WebCore::Database::runTransaction): Simplified a bit. (WebCore::Database::tableNames): Use databaseThread. (WebCore::Database::securityOrigin): Changed to return a reference instead of a pointer because all the callers need it to do that. If called on the wrong thread, this will now do a RELEASE_ASSERT_NOT_REACHED. In the old code it would return a null pointer and then the caller would dereference it a moment later, so it would still be a crash. (WebCore::Database::maximumSize): Removed const since it's not really needed and the DatabaseTracker wants a non-const reference to this database. (WebCore::Database::didCommitWriteTransaction): Added. Moved this code here from SQLTransactionClient. There is no abstraction layer, so no reason to not have this code, quite comparable to the rest of the code in the class, here. I am assuming this served some more useful purpose back when we had a different back end for Chromium? (WebCore::Database::didExceedQuota): Ditto. * Modules/webdatabase/Database.h: Updated for above changes. Made some functions return references instead of pointers. Use Ref instead of RefPtr for some things that can never be null. * Modules/webdatabase/Database.idl: Added ImplementationLacksVTable because the Database class is not polymorphic. * Modules/webdatabase/DatabaseContext.cpp: (WebCore::DatabaseContext::DatabaseContext): Take a reference instead of a pointer. Moved data member initialization into class definition. Remove code that tries to do debug accounting and databasecontext registration and instead just make sure to keep the ScriptExecutionContext pointing at the DatabaseContext. (WebCore::DatabaseContext::~DatabaseContext): Ditto. (WebCore::DatabaseContext::stopDatabases): Ditto. * Modules/webdatabase/DatabaseContext.h: Updated for the above. Also used the scriptExecutionContext function inherited from the base class intead of adding our own, and added a existingDatabaseThread() function, letting us get at the database thread efficiently without creating a new one. * Modules/webdatabase/DatabaseError.h: Removed. We now use DOM exceptions directly instead of our own error enumeration that has to be translated to a DOM exception. * Modules/webdatabase/DatabaseManager.cpp: Moved the ProposedDatabase class here from the header file, and had it use references instead of pointers. (WebCore::DatabaseManager::DatabaseManager): Deleted. There was nothing left to initialize once the refactoring was done. (WebCore::DatabaseManager::initialize): Call DatabaseTracker directly instead of calling through m_server. (WebCore::DatabaseManager::setClient): Ditto. (WebCore::DatabaseManager::databaseDirectoryPath): Deleted. Callers will use the function in DatabaseTracker directly. (WebCore::DatabaseManager::setDatabaseDirectoryPath): Ditto. (WebCore::DatabaseManager::existingDatabaseContextFor): Deleted. Callers will use the ScriptExecutionContext::databaseContext function instead. (WebCore::DatabaseManager::databaseContext): Renamed from databaseContextFor. (WebCore::DatabaseManager::registerDatabaseContext): Deleted. (WebCore::DatabaseManager::unregisterDatabaseContext): Deleted. (WebCore::DatabaseManager::didConstructDatabaseContext): Deleted. (WebCore::DatabaseManager::didDestructDatabaseContext): Deleted. (WebCore::DatabaseManager::exceptionCodeForDatabaseError): Deleted. (WebCore::logOpenDatabaseError): Tweaked conditionals a bit. (WebCore::DatabaseManager::openDatabaseBackend): Use ExceptionOr. Changed to call tryToOpenDatabaseBackend function here in this class rather than using m_server. (WebCore::DatabaseManager::tryToOpenDatabaseBackend): Added. Moved here from the DatabaseServer class. (WebCore::DatabaseManager::addProposedDatabase): Take a reference. (WebCore::DatabaseManager::removeProposedDatabase): Ditto. (WebCore::DatabaseManager::openDatabase): Use ExceptionOr. (WebCore::DatabaseManager::hasOpenDatabases): Use ScriptContext::databaseContext directly instead of using helper functions in this class. (WebCore::DatabaseManager::stopDatabases): Ditto. (WebCore::DatabaseManager::fullPathForDatabase): Take a reference and also call DatabaseTracker directly instead of calling through m_server. (WebCore::DatabaseManager::hasEntryForOrigin): Deleted. Callers will use the function in DatabaseTracker directly. (WebCore::DatabaseManager::origins): Ditto. (WebCore::DatabaseManager::databaseNamesForOrigin): Ditto. (WebCore::DatabaseManager::detailsForNameAndOrigin): Call DatabaseTracker directly instead of calling through m_server. (WebCore::DatabaseManager::usageForOrigin): Deleted. Callers will use the function in DatabaseTracker directly. (WebCore::DatabaseManager::quotaForOrigin): Ditto. (WebCore::DatabaseManager::setQuota): Ditto. (WebCore::DatabaseManager::deleteAllDatabasesImmediately): Ditto. (WebCore::DatabaseManager::deleteOrigin): Ditto. (WebCore::DatabaseManager::deleteDatabase): Ditto. (WebCore::DatabaseManager::closeAllDatabases): Ditto. (WebCore::DatabaseManager::logErrorMessage): Take a reference. * Modules/webdatabase/DatabaseManager.h: Updated for changes above. * Modules/webdatabase/DatabaseManagerClient.h: Use references for security origins. Also changed #if for iOS so that other platforms can call the iOS-specific functions and they have inline empty bodies; lets us clean up call sites to not need conditionals. * Modules/webdatabase/DatabaseServer.cpp: Removed. * Modules/webdatabase/DatabaseServer.h: Removed. * Modules/webdatabase/DatabaseTask.cpp: (WebCore::isolatedCopy): Added. Helper functions for making isolated copies of exceptions, which can contain strings. (WebCore::DatabaseOpenTask::DatabaseOpenTask): Use ExceptionOr<void> instead of a DatabaseError, a String, and a success boolean. (WebCore::DatabaseOpenTask::doPerformTask): Updated to use ExceptoinOr. (WebCore::DatabaseTableNamesTask::DatabaseTableNamesTask): Renamed. (WebCore::DatabaseTableNamesTask::doPerformTask): Added a comment. * Modules/webdatabase/DatabaseTask.h: Updated for above changes. * Modules/webdatabase/DatabaseThread.cpp: (WebCore::DatabaseThread::DatabaseThread): Initialized data members in the class definition. Removed m_transactionClient. (WebCore::DatabaseThread::recordDatabaseOpen): Take a reference. (WebCore::DatabaseThread::recordDatabaseClosed): Ditto. (WebCore::DatabaseThread::scheduleTask): Use an rvalue reference. (WebCore::DatabaseThread::scheduleImmediateTask): Ditto. (WebCore::DatabaseThread::unscheduleDatabaseTasks): Use a lambda instead of a class for the same-database predicate. * Modules/webdatabase/DatabaseThread.h: Updated for above. * Modules/webdatabase/DatabaseTracker.cpp: (WebCore::isolatedCopy): Added. Helper for making an isolated copy of a vector of strings. (WebCore::DatabaseTracker::singleton): Renamed from tracker. (WebCore::DatabaseTracker::DatabaseTracker): Moved the code from setDatabaseDirectoryPath in here. (WebCore::DatabaseTracker::setDatabaseDirectoryPath): Deleted. (WebCore::DatabaseTracker::databaseDirectoryPath): Deleted. (WebCore::DatabaseTracker::hasAdequateQuotaForOrigin): Use ExceptionOr. (WebCore::DatabaseTracker::canEstablishDatabase): Ditto. (WebCore::DatabaseTracker::retryCanEstablishDatabase): Ditto. (WebCore::DatabaseTracker::hasEntryForOriginNoLock): Take a reference. (WebCore::DatabaseTracker::hasEntryForOrigin): Deleted. (WebCore::DatabaseTracker::hasEntryForDatabase): Take a reference. (WebCore::DatabaseTracker::maximumSize): Renamed from getMaxSizeForDatabase and changed to take a reference. (WebCore::DatabaseTracker::originPath): Take a reference. (WebCore::DatabaseTracker::fullPathForDatabaseNoLock): Ditto. (WebCore::DatabaseTracker::fullPathForDatabase): Ditto. (WebCore::DatabaseTracker::origins): Changed to use a return value instead of using an out argument. (WebCore::DatabaseTracker::databaseNamesNoLock): Ditto. Also renamed from databaseNamesForOriginNoLock. (WebCore::DatabaseTracker::databaseNames): Ditto. Also renamed from databaseNamesForOrigin. (WebCore::DatabaseTracker::detailsForNameAndOrigin): Take a reference. (WebCore::DatabaseTracker::setDatabaseDetails): Ditto. (WebCore::DatabaseTracker::doneCreatingDatabase): Ditto. (WebCore::DatabaseTracker::addOpenDatabase): Ditto. (WebCore::DatabaseTracker::removeOpenDatabase): Ditto. (WebCore::DatabaseTracker::getOpenDatabases): Deleted. (WebCore::DatabaseTracker::originLockFor): Take a reference. (WebCore::DatabaseTracker::deleteOriginLockFor): Take a reference. (WebCore::DatabaseTracker::usage): Renamed from usageForOrigin. Take a reference. (WebCore::DatabaseTracker::quotaNoLock): Renamed from quotaForOriginNoLock. Take a reference. (WebCore::DatabaseTracker::quota): Renamed from quatoForOrigin. Take a reference. (WebCore::DatabaseTracker::setQuota): Take a reference. (WebCore::DatabaseTracker::addDatabase): Ditto. (WebCore::DatabaseTracker::deleteAllDatabasesImmediately): Updated now that origins has a return value. (WebCore::DatabaseTracker::deleteDatabasesModifiedSince): Ditto. (WebCore::DatabaseTracker::deleteOrigin): Take a reference. (WebCore::DatabaseTracker::isDeletingDatabaseOrOriginFor): Ditto. (WebCore::DatabaseTracker::recordCreatingDatabase): Updated to take a reference, use unique_ptr, and use HashCountedSet. (WebCore::DatabaseTracker::doneCreatingDatabase): Ditto. (WebCore::DatabaseTracker::creatingDatabase): Ditto. (WebCore::DatabaseTracker::canDeleteDatabase): Take a reference. (WebCore::DatabaseTracker::recordDeletingDatabase): Updated to take a reference, and use unique_ptr. (WebCore::DatabaseTracker::doneDeletingDatabase): Ditto. (WebCore::DatabaseTracker::isDeletingDatabase): Ditto. (WebCore::DatabaseTracker::canDeleteOrigin): Take a reference. (WebCore::DatabaseTracker::isDeletingOrigin): Ditto. (WebCore::DatabaseTracker::recordDeletingOrigin): Ditto. (WebCore::DatabaseTracker::doneDeletingOrigin): Ditto. (WebCore::DatabaseTracker::deleteDatabase): Ditto. (WebCore::DatabaseTracker::deleteDatabaseFile): Ditto. (WebCore::DatabaseTracker::removeDeletedOpenedDatabases): Ditto. (WebCore::DatabaseTracker::scheduleNotifyDatabaseChanged): Ditto. (WebCore::DatabaseTracker::notifyDatabasesChanged): Ditto. * Modules/webdatabase/DatabaseTracker.h: Updated for above changes. * Modules/webdatabase/SQLStatement.cpp: (WebCore::SQLStatement::SQLStatement): Updated since Database::scriptExecutionContext now returns a reference. * Modules/webdatabase/SQLTransaction.cpp: (WebCore::SQLTransaction::SQLTransaction): Moved data member initialization to the calss definition. Also updated since Database::scriptExecutionContext now returns a reference. (WebCore::SQLTransaction::executeSQL): Use ExceptionOr. (WebCore::SQLTransaction::checkAndHandleClosedDatabase): Updated since databaseContext now returns a reference. (WebCore::SQLTransaction::deliverQuotaIncreaseCallback): Updated to call didExceedQuota on the database instead of the transaction client. (WebCore::SQLTransaction::postflightAndCommit): Updated to call didCommitWriteTransaction on the database instead of the transaction client. (WebCore::SQLTransaction::acquireOriginLock): Updated for name change of DatabaseTracker::tracker to DatbaseTracker::singleton. * Modules/webdatabase/SQLTransaction.h: Updated for above. * Modules/webdatabase/SQLTransaction.idl: Added MayThrowException to executeSql. Not technically needed since it's a custom binding. * Modules/webdatabase/SQLTransactionBackend.cpp: (WebCore::SQLTransactionBackend::doCleanup): Updated assertion to use Database::databaseThread. (WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown): Ditto. * Modules/webdatabase/SQLTransactionClient.cpp: Removed. * Modules/webdatabase/SQLTransactionClient.h: Removed. * Modules/webdatabase/SQLTransactionCoordinator.cpp: (WebCore::getDatabaseIdentifier): Updated to pass a reference. * WebCore.xcodeproj/project.pbxproj: Removed various deleted files. Also let Xcode change the whitespace on some lines. * bindings/js/JSSQLTransactionCustom.cpp: (WebCore::JSSQLTransaction::executeSql): Use ExceptionOr, specifically by using the propagateException function. * dom/ScriptExecutionContext.h: Added databaseContext function. Before, we had setDatabaseContext, but no way to inspect the pointer that was stored. * inspector/InspectorDatabaseAgent.cpp: Removed IGNORE_EXCEPTION in a call to executeSQL, which no longer has an ExceptionCode out argument. * loader/FrameLoader.cpp: (WebCore::FrameLoader::stopLoading): Pass a reference in the call to DatabaseManager::stopDatabases. Source/WebKit/mac: * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager origins]): Updated to use DatabaseTracker and pass a reference. (-[WebDatabaseManager databasesWithOrigin:]): Ditto. (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Pass reference, but continue to use DatabaseManager. (-[WebDatabaseManager deleteOrigin:]): Use DatabaseTracker and pass a reference. (-[WebDatabaseManager deleteDatabase:withOrigin:]): Ditto. * Storage/WebDatabaseManagerClient.h: Updated to take references. * Storage/WebDatabaseManagerClient.mm: (WebDatabaseManagerClient::WebDatabaseManagerClient): Initialize data members in the class definition. (DidModifyOriginData::dispatchToMainThread): Take references. (DidModifyOriginData::DidModifyOriginData): Ditto. (WebDatabaseManagerClient::dispatchDidModifyOrigin): Ditto. (WebDatabaseManagerClient::dispatchDidModifyDatabase): Ditto. (WebDatabaseManagerClient::dispatchDidAddNewOrigin): Ditto. Also use DatabaseTracker::singleton instead of tracker. * Storage/WebDatabaseQuotaManager.mm: (-[WebDatabaseQuotaManager initWithOrigin:]): Reject nil pointer argument. (-[WebDatabaseQuotaManager usage]): Use reference instead of pointer. (-[WebDatabaseQuotaManager quota]): Ditto. (-[WebDatabaseQuotaManager setQuota:]): Ditto. * WebCoreSupport/WebSecurityOrigin.mm: (-[WebSecurityOrigin initWithURL:]): Tweaked code a bit. (-[WebSecurityOrigin usage]): Use DatabaseTracker and pass a reference. (-[WebSecurityOrigin quota]): Ditto. (-[WebSecurityOrigin setQuota:]): Ditto. * WebView/WebFrame.mm: (-[WebFrame _cacheabilityDictionary]): Pass a reference. Source/WebKit/win: * WebDatabaseManager.cpp: (WebDatabaseManager::origins): Use DatabaseTracker. (WebDatabaseManager::databasesWithOrigin): Ditto. (WebDatabaseManager::detailsForDatabase): Use reference. (WebDatabaseManager::deleteAllDatabases): Use DatabaseTracker. (WebDatabaseManager::deleteOrigin): Ditto. (WebDatabaseManager::deleteDatabase): Ditto. (WebDatabaseManager::dispatchDidModifyOrigin): Use reference and DatabaseTracker. (WebDatabaseManager::setQuota): Ditto. (WebDatabaseManager::dispatchDidModifyDatabase): Ditto. * WebDatabaseManager.h: Updated client functions to take a reference. * WebSecurityOrigin.cpp: (WebSecurityOrigin::usage): Update to use DatabaseTracker. (WebSecurityOrigin::quota): Ditto. (WebSecurityOrigin::setQuota): Ditto. Source/WebKit2: * UIProcess/API/efl/ewk_database_manager.cpp: (EwkDatabaseManager::getDatabaseOrigins): Update for change to the DatabaseTracker::origins function. * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::fetchData): Use DatabaseTracker. (WebKit::WebsiteDataStore::removeData): Ditto. * WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundleSetDatabaseQuota): Ditto. * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::exceededDatabaseQuota): Ditto. * WebProcess/WebProcess.cpp: (WebKit::WebProcess::processWillSuspendImminently): Ditto. Canonical link: https://commits.webkit.org/182390@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-14 03:22:31 +00:00
Exception isolatedCopy(Exception&&);
Have class Exception take String by value instead of a String&& https://bugs.webkit.org/show_bug.cgi?id=184360 Reviewed by Alexey Proskuryakov. For convenience support instantiating an Exception with either an lvalue String or rvalue String. Although it can be argued that having Exception take a String by value instead of String&& can lead to missed opportunities to WTFMove() a String object into Exception such mistakes are just that, missed opportunities. That is, correctness is not affected and we may perform an unnecessary ref/deref of the underlying StringImpl when instantiating an Exception. If such missed opportunities show up in profiles and such mistakes happen often then we can re-evaluate the decision to have Exception take a String by value. * Modules/cache/DOMCache.cpp: (WebCore::DOMCache::put): Simplify code now that Exception takes a String by value. * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::BodyLoader::didFail): Ditto. * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed): Move String into Exception to avoid an unnecessary ref/de-ref. (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed): Ditto. (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed): Ditto. * dom/Exception.h: (WebCore::Exception::Exception): Take String by value. Also use uniform initializer syntax. Canonical link: https://commits.webkit.org/199917@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230338 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-06 17:45:57 +00:00
inline Exception::Exception(ExceptionCode code, String message)
: m_code { code }
, m_message { WTFMove(message) }
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
{
}
Fix exception handling in SQL database code, streamline and update code https://bugs.webkit.org/show_bug.cgi?id=164685 Reviewed by Sam Weinig. Source/WebCore: Removed some old abstraction layers that were no longer in use. For example, i n many cases, calls were going through DatabaseManager, which called through an abstract class AbstractDatabaseServer to a concrete class DatabaseServer, which then called through to DatabaseTracker. Clients now mostly just call DatabaseTracker directly. * CMakeLists.txt: Removed DatabaseServer.cpp and SQLTransactionClient.cpp. * Modules/webdatabase/AbstractDatabaseServer.h: Removed. * Modules/webdatabase/DOMWindowWebDatabase.cpp: (WebCore::DOMWindowWebDatabase::openDatabase): Use ExceptionOr instead of DatabaseError to communicate DOM exceptions from DatabaseManager. * Modules/webdatabase/Database.cpp: (WebCore::Database::Database): Use a reference instead of a RefPtr&& for database context. Use unsigned instead of unsigned long. Modernize code to use more initialization rather than assignment, to initialize scalar data members in the class definition, and to use HashMap::ensure. (WebCore::Database::databaseThread): Added. This class asserts that there is a thread in the constructor, and so it is useful to have a helper for all the other functions that assumes the thread is present and returns a reference rather than a pointer. (WebCore::Database::~Database): Updated since m_scriptExecutionContext is now a Ref instead of a RefPtr. (WebCore::Database::openAndVerifyVersion): Use ExceptionOr and databaseThread. (WebCore::Database::close): Use databaseThread. (WebCore::Database::performClose): Ditto. (WebCore::DoneCreatingDatabaseOnExitCaller::DoneCreatingDatabaseOnExitCaller): Use a reference. Removed unused m_openSuccceeded. (WebCore::DoneCreatingDatabaseOnExitCaller::~DoneCreatingDatabaseOnExitCaller): Use DatabaseTracker::singleton by its new name. (WebCore::DoneCreatingDatabaseOnExitCaller::setOpenSucceeded): Deleted. (WebCore::Database::performOpenAndVerify): Use ExceptionOr and update for above. (WebCore::Database::closeDatabase): Updated for name change. (WebCore::Database::scheduleTransaction): Updated for above, simplified and streamlined. (WebCore::Database::scheduleTransactionStep): Use databaseThread. (WebCore::Database::transactionClient): Deleted. This object is no longer needed. (WebCore::Database::transactionCoordinator): Use databaseThread. (WebCore::Database::markAsDeletedAndClose): Removed unnecessary null check for databaseThread, which can never be null. (WebCore::Database::estimatedSize): Use unsigned, not unsigned long. (WebCore::Database::disableAuthorizer): Removed assertion about RefPtr that is now a Ref and never could have been null. (WebCore::Database::enableAuthorizer): Ditto. (WebCore::Database::setAuthorizerPermissions): Ditto. (WebCore::Database::lastActionChangedDatabase): Ditto. (WebCore::Database::lastActionWasInsert): Ditto. (WebCore::Database::resetDeletes): Ditto. (WebCore::Database::hadDeletes): Ditto. (WebCore::Database::resetAuthorizer): Removed null check for a RefPtr that is now a Ref and never could have been null. (WebCore::Database::runTransaction): Simplified a bit. (WebCore::Database::tableNames): Use databaseThread. (WebCore::Database::securityOrigin): Changed to return a reference instead of a pointer because all the callers need it to do that. If called on the wrong thread, this will now do a RELEASE_ASSERT_NOT_REACHED. In the old code it would return a null pointer and then the caller would dereference it a moment later, so it would still be a crash. (WebCore::Database::maximumSize): Removed const since it's not really needed and the DatabaseTracker wants a non-const reference to this database. (WebCore::Database::didCommitWriteTransaction): Added. Moved this code here from SQLTransactionClient. There is no abstraction layer, so no reason to not have this code, quite comparable to the rest of the code in the class, here. I am assuming this served some more useful purpose back when we had a different back end for Chromium? (WebCore::Database::didExceedQuota): Ditto. * Modules/webdatabase/Database.h: Updated for above changes. Made some functions return references instead of pointers. Use Ref instead of RefPtr for some things that can never be null. * Modules/webdatabase/Database.idl: Added ImplementationLacksVTable because the Database class is not polymorphic. * Modules/webdatabase/DatabaseContext.cpp: (WebCore::DatabaseContext::DatabaseContext): Take a reference instead of a pointer. Moved data member initialization into class definition. Remove code that tries to do debug accounting and databasecontext registration and instead just make sure to keep the ScriptExecutionContext pointing at the DatabaseContext. (WebCore::DatabaseContext::~DatabaseContext): Ditto. (WebCore::DatabaseContext::stopDatabases): Ditto. * Modules/webdatabase/DatabaseContext.h: Updated for the above. Also used the scriptExecutionContext function inherited from the base class intead of adding our own, and added a existingDatabaseThread() function, letting us get at the database thread efficiently without creating a new one. * Modules/webdatabase/DatabaseError.h: Removed. We now use DOM exceptions directly instead of our own error enumeration that has to be translated to a DOM exception. * Modules/webdatabase/DatabaseManager.cpp: Moved the ProposedDatabase class here from the header file, and had it use references instead of pointers. (WebCore::DatabaseManager::DatabaseManager): Deleted. There was nothing left to initialize once the refactoring was done. (WebCore::DatabaseManager::initialize): Call DatabaseTracker directly instead of calling through m_server. (WebCore::DatabaseManager::setClient): Ditto. (WebCore::DatabaseManager::databaseDirectoryPath): Deleted. Callers will use the function in DatabaseTracker directly. (WebCore::DatabaseManager::setDatabaseDirectoryPath): Ditto. (WebCore::DatabaseManager::existingDatabaseContextFor): Deleted. Callers will use the ScriptExecutionContext::databaseContext function instead. (WebCore::DatabaseManager::databaseContext): Renamed from databaseContextFor. (WebCore::DatabaseManager::registerDatabaseContext): Deleted. (WebCore::DatabaseManager::unregisterDatabaseContext): Deleted. (WebCore::DatabaseManager::didConstructDatabaseContext): Deleted. (WebCore::DatabaseManager::didDestructDatabaseContext): Deleted. (WebCore::DatabaseManager::exceptionCodeForDatabaseError): Deleted. (WebCore::logOpenDatabaseError): Tweaked conditionals a bit. (WebCore::DatabaseManager::openDatabaseBackend): Use ExceptionOr. Changed to call tryToOpenDatabaseBackend function here in this class rather than using m_server. (WebCore::DatabaseManager::tryToOpenDatabaseBackend): Added. Moved here from the DatabaseServer class. (WebCore::DatabaseManager::addProposedDatabase): Take a reference. (WebCore::DatabaseManager::removeProposedDatabase): Ditto. (WebCore::DatabaseManager::openDatabase): Use ExceptionOr. (WebCore::DatabaseManager::hasOpenDatabases): Use ScriptContext::databaseContext directly instead of using helper functions in this class. (WebCore::DatabaseManager::stopDatabases): Ditto. (WebCore::DatabaseManager::fullPathForDatabase): Take a reference and also call DatabaseTracker directly instead of calling through m_server. (WebCore::DatabaseManager::hasEntryForOrigin): Deleted. Callers will use the function in DatabaseTracker directly. (WebCore::DatabaseManager::origins): Ditto. (WebCore::DatabaseManager::databaseNamesForOrigin): Ditto. (WebCore::DatabaseManager::detailsForNameAndOrigin): Call DatabaseTracker directly instead of calling through m_server. (WebCore::DatabaseManager::usageForOrigin): Deleted. Callers will use the function in DatabaseTracker directly. (WebCore::DatabaseManager::quotaForOrigin): Ditto. (WebCore::DatabaseManager::setQuota): Ditto. (WebCore::DatabaseManager::deleteAllDatabasesImmediately): Ditto. (WebCore::DatabaseManager::deleteOrigin): Ditto. (WebCore::DatabaseManager::deleteDatabase): Ditto. (WebCore::DatabaseManager::closeAllDatabases): Ditto. (WebCore::DatabaseManager::logErrorMessage): Take a reference. * Modules/webdatabase/DatabaseManager.h: Updated for changes above. * Modules/webdatabase/DatabaseManagerClient.h: Use references for security origins. Also changed #if for iOS so that other platforms can call the iOS-specific functions and they have inline empty bodies; lets us clean up call sites to not need conditionals. * Modules/webdatabase/DatabaseServer.cpp: Removed. * Modules/webdatabase/DatabaseServer.h: Removed. * Modules/webdatabase/DatabaseTask.cpp: (WebCore::isolatedCopy): Added. Helper functions for making isolated copies of exceptions, which can contain strings. (WebCore::DatabaseOpenTask::DatabaseOpenTask): Use ExceptionOr<void> instead of a DatabaseError, a String, and a success boolean. (WebCore::DatabaseOpenTask::doPerformTask): Updated to use ExceptoinOr. (WebCore::DatabaseTableNamesTask::DatabaseTableNamesTask): Renamed. (WebCore::DatabaseTableNamesTask::doPerformTask): Added a comment. * Modules/webdatabase/DatabaseTask.h: Updated for above changes. * Modules/webdatabase/DatabaseThread.cpp: (WebCore::DatabaseThread::DatabaseThread): Initialized data members in the class definition. Removed m_transactionClient. (WebCore::DatabaseThread::recordDatabaseOpen): Take a reference. (WebCore::DatabaseThread::recordDatabaseClosed): Ditto. (WebCore::DatabaseThread::scheduleTask): Use an rvalue reference. (WebCore::DatabaseThread::scheduleImmediateTask): Ditto. (WebCore::DatabaseThread::unscheduleDatabaseTasks): Use a lambda instead of a class for the same-database predicate. * Modules/webdatabase/DatabaseThread.h: Updated for above. * Modules/webdatabase/DatabaseTracker.cpp: (WebCore::isolatedCopy): Added. Helper for making an isolated copy of a vector of strings. (WebCore::DatabaseTracker::singleton): Renamed from tracker. (WebCore::DatabaseTracker::DatabaseTracker): Moved the code from setDatabaseDirectoryPath in here. (WebCore::DatabaseTracker::setDatabaseDirectoryPath): Deleted. (WebCore::DatabaseTracker::databaseDirectoryPath): Deleted. (WebCore::DatabaseTracker::hasAdequateQuotaForOrigin): Use ExceptionOr. (WebCore::DatabaseTracker::canEstablishDatabase): Ditto. (WebCore::DatabaseTracker::retryCanEstablishDatabase): Ditto. (WebCore::DatabaseTracker::hasEntryForOriginNoLock): Take a reference. (WebCore::DatabaseTracker::hasEntryForOrigin): Deleted. (WebCore::DatabaseTracker::hasEntryForDatabase): Take a reference. (WebCore::DatabaseTracker::maximumSize): Renamed from getMaxSizeForDatabase and changed to take a reference. (WebCore::DatabaseTracker::originPath): Take a reference. (WebCore::DatabaseTracker::fullPathForDatabaseNoLock): Ditto. (WebCore::DatabaseTracker::fullPathForDatabase): Ditto. (WebCore::DatabaseTracker::origins): Changed to use a return value instead of using an out argument. (WebCore::DatabaseTracker::databaseNamesNoLock): Ditto. Also renamed from databaseNamesForOriginNoLock. (WebCore::DatabaseTracker::databaseNames): Ditto. Also renamed from databaseNamesForOrigin. (WebCore::DatabaseTracker::detailsForNameAndOrigin): Take a reference. (WebCore::DatabaseTracker::setDatabaseDetails): Ditto. (WebCore::DatabaseTracker::doneCreatingDatabase): Ditto. (WebCore::DatabaseTracker::addOpenDatabase): Ditto. (WebCore::DatabaseTracker::removeOpenDatabase): Ditto. (WebCore::DatabaseTracker::getOpenDatabases): Deleted. (WebCore::DatabaseTracker::originLockFor): Take a reference. (WebCore::DatabaseTracker::deleteOriginLockFor): Take a reference. (WebCore::DatabaseTracker::usage): Renamed from usageForOrigin. Take a reference. (WebCore::DatabaseTracker::quotaNoLock): Renamed from quotaForOriginNoLock. Take a reference. (WebCore::DatabaseTracker::quota): Renamed from quatoForOrigin. Take a reference. (WebCore::DatabaseTracker::setQuota): Take a reference. (WebCore::DatabaseTracker::addDatabase): Ditto. (WebCore::DatabaseTracker::deleteAllDatabasesImmediately): Updated now that origins has a return value. (WebCore::DatabaseTracker::deleteDatabasesModifiedSince): Ditto. (WebCore::DatabaseTracker::deleteOrigin): Take a reference. (WebCore::DatabaseTracker::isDeletingDatabaseOrOriginFor): Ditto. (WebCore::DatabaseTracker::recordCreatingDatabase): Updated to take a reference, use unique_ptr, and use HashCountedSet. (WebCore::DatabaseTracker::doneCreatingDatabase): Ditto. (WebCore::DatabaseTracker::creatingDatabase): Ditto. (WebCore::DatabaseTracker::canDeleteDatabase): Take a reference. (WebCore::DatabaseTracker::recordDeletingDatabase): Updated to take a reference, and use unique_ptr. (WebCore::DatabaseTracker::doneDeletingDatabase): Ditto. (WebCore::DatabaseTracker::isDeletingDatabase): Ditto. (WebCore::DatabaseTracker::canDeleteOrigin): Take a reference. (WebCore::DatabaseTracker::isDeletingOrigin): Ditto. (WebCore::DatabaseTracker::recordDeletingOrigin): Ditto. (WebCore::DatabaseTracker::doneDeletingOrigin): Ditto. (WebCore::DatabaseTracker::deleteDatabase): Ditto. (WebCore::DatabaseTracker::deleteDatabaseFile): Ditto. (WebCore::DatabaseTracker::removeDeletedOpenedDatabases): Ditto. (WebCore::DatabaseTracker::scheduleNotifyDatabaseChanged): Ditto. (WebCore::DatabaseTracker::notifyDatabasesChanged): Ditto. * Modules/webdatabase/DatabaseTracker.h: Updated for above changes. * Modules/webdatabase/SQLStatement.cpp: (WebCore::SQLStatement::SQLStatement): Updated since Database::scriptExecutionContext now returns a reference. * Modules/webdatabase/SQLTransaction.cpp: (WebCore::SQLTransaction::SQLTransaction): Moved data member initialization to the calss definition. Also updated since Database::scriptExecutionContext now returns a reference. (WebCore::SQLTransaction::executeSQL): Use ExceptionOr. (WebCore::SQLTransaction::checkAndHandleClosedDatabase): Updated since databaseContext now returns a reference. (WebCore::SQLTransaction::deliverQuotaIncreaseCallback): Updated to call didExceedQuota on the database instead of the transaction client. (WebCore::SQLTransaction::postflightAndCommit): Updated to call didCommitWriteTransaction on the database instead of the transaction client. (WebCore::SQLTransaction::acquireOriginLock): Updated for name change of DatabaseTracker::tracker to DatbaseTracker::singleton. * Modules/webdatabase/SQLTransaction.h: Updated for above. * Modules/webdatabase/SQLTransaction.idl: Added MayThrowException to executeSql. Not technically needed since it's a custom binding. * Modules/webdatabase/SQLTransactionBackend.cpp: (WebCore::SQLTransactionBackend::doCleanup): Updated assertion to use Database::databaseThread. (WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown): Ditto. * Modules/webdatabase/SQLTransactionClient.cpp: Removed. * Modules/webdatabase/SQLTransactionClient.h: Removed. * Modules/webdatabase/SQLTransactionCoordinator.cpp: (WebCore::getDatabaseIdentifier): Updated to pass a reference. * WebCore.xcodeproj/project.pbxproj: Removed various deleted files. Also let Xcode change the whitespace on some lines. * bindings/js/JSSQLTransactionCustom.cpp: (WebCore::JSSQLTransaction::executeSql): Use ExceptionOr, specifically by using the propagateException function. * dom/ScriptExecutionContext.h: Added databaseContext function. Before, we had setDatabaseContext, but no way to inspect the pointer that was stored. * inspector/InspectorDatabaseAgent.cpp: Removed IGNORE_EXCEPTION in a call to executeSQL, which no longer has an ExceptionCode out argument. * loader/FrameLoader.cpp: (WebCore::FrameLoader::stopLoading): Pass a reference in the call to DatabaseManager::stopDatabases. Source/WebKit/mac: * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager origins]): Updated to use DatabaseTracker and pass a reference. (-[WebDatabaseManager databasesWithOrigin:]): Ditto. (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Pass reference, but continue to use DatabaseManager. (-[WebDatabaseManager deleteOrigin:]): Use DatabaseTracker and pass a reference. (-[WebDatabaseManager deleteDatabase:withOrigin:]): Ditto. * Storage/WebDatabaseManagerClient.h: Updated to take references. * Storage/WebDatabaseManagerClient.mm: (WebDatabaseManagerClient::WebDatabaseManagerClient): Initialize data members in the class definition. (DidModifyOriginData::dispatchToMainThread): Take references. (DidModifyOriginData::DidModifyOriginData): Ditto. (WebDatabaseManagerClient::dispatchDidModifyOrigin): Ditto. (WebDatabaseManagerClient::dispatchDidModifyDatabase): Ditto. (WebDatabaseManagerClient::dispatchDidAddNewOrigin): Ditto. Also use DatabaseTracker::singleton instead of tracker. * Storage/WebDatabaseQuotaManager.mm: (-[WebDatabaseQuotaManager initWithOrigin:]): Reject nil pointer argument. (-[WebDatabaseQuotaManager usage]): Use reference instead of pointer. (-[WebDatabaseQuotaManager quota]): Ditto. (-[WebDatabaseQuotaManager setQuota:]): Ditto. * WebCoreSupport/WebSecurityOrigin.mm: (-[WebSecurityOrigin initWithURL:]): Tweaked code a bit. (-[WebSecurityOrigin usage]): Use DatabaseTracker and pass a reference. (-[WebSecurityOrigin quota]): Ditto. (-[WebSecurityOrigin setQuota:]): Ditto. * WebView/WebFrame.mm: (-[WebFrame _cacheabilityDictionary]): Pass a reference. Source/WebKit/win: * WebDatabaseManager.cpp: (WebDatabaseManager::origins): Use DatabaseTracker. (WebDatabaseManager::databasesWithOrigin): Ditto. (WebDatabaseManager::detailsForDatabase): Use reference. (WebDatabaseManager::deleteAllDatabases): Use DatabaseTracker. (WebDatabaseManager::deleteOrigin): Ditto. (WebDatabaseManager::deleteDatabase): Ditto. (WebDatabaseManager::dispatchDidModifyOrigin): Use reference and DatabaseTracker. (WebDatabaseManager::setQuota): Ditto. (WebDatabaseManager::dispatchDidModifyDatabase): Ditto. * WebDatabaseManager.h: Updated client functions to take a reference. * WebSecurityOrigin.cpp: (WebSecurityOrigin::usage): Update to use DatabaseTracker. (WebSecurityOrigin::quota): Ditto. (WebSecurityOrigin::setQuota): Ditto. Source/WebKit2: * UIProcess/API/efl/ewk_database_manager.cpp: (EwkDatabaseManager::getDatabaseOrigins): Update for change to the DatabaseTracker::origins function. * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::fetchData): Use DatabaseTracker. (WebKit::WebsiteDataStore::removeData): Ditto. * WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundleSetDatabaseQuota): Ditto. * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::exceededDatabaseQuota): Ditto. * WebProcess/WebProcess.cpp: (WebKit::WebProcess::processWillSuspendImminently): Ditto. Canonical link: https://commits.webkit.org/182390@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-14 03:22:31 +00:00
inline Exception isolatedCopy(Exception&& value)
{
return Exception { value.code(), value.releaseMessage().isolatedCopy() };
}
Streamline DOMImplementation, and move it to our new DOM exception system https://bugs.webkit.org/show_bug.cgi?id=161295 Reviewed by Ryosuke Niwa. Source/WebCore: * 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. Source/WebKit/mac: * 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. Source/WebKit/win: * WebFrame.cpp: (WebFrame::canProvideDocumentSource): Updated to use isXMLMIMEType in its new location in MIMETypeRegistry instead of in DOMImplementation. Source/WebKit2: * 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. Canonical link: https://commits.webkit.org/179743@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-03 23:34:00 +00:00
}