Diff
Modified: trunk/Source/WebCore/ChangeLog (208143 => 208144)
--- trunk/Source/WebCore/ChangeLog 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/ChangeLog 2016-10-31 15:49:34 UTC (rev 208144)
@@ -1,3 +1,80 @@
+2016-10-31 Darin Adler <[email protected]>
+
+ Convert Document from ExceptionCode to Exception
+ https://bugs.webkit.org/show_bug.cgi?id=164212
+
+ Reviewed by Alex Christensen.
+
+ * Modules/websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::processBuffer): Removed IGNORE_EXCEPTION.
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::takeAllChildrenFrom): Use releaseReturnValue
+ instead of ASSERT_NO_EXCEPTION.
+ (WebCore::ContainerNode::parserInsertBefore): Removed ASSERT_NO_EXCEPTION.
+ (WebCore::ContainerNode::parserAppendChild): Ditto.
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createDocumentType): Updated for new
+ exception handling.
+ (WebCore::DOMImplementation::createDocument): Ditto.
+
+ * dom/Document.cpp:
+ (WebCore::createHTMLElementWithNameValidation): Return ExceptionOr.
+ (WebCore::Document::createElementForBindings): Ditto.
+ (WebCore::Document::createCDATASection): Ditto.
+ (WebCore::Document::createProcessingInstruction): Ditto.
+ (WebCore::Document::importNode): Ditto.
+ (WebCore::Document::adoptNode): Ditto.
+ (WebCore::Document::createElementNS): Ditto.
+ (WebCore::Document::setXMLVersion): Ditto.
+ (WebCore::Document::setBodyOrFrameset): Ditto.
+ (WebCore::Document::processHttpEquiv): Ditto.
+ (WebCore::Document::createEvent): Ditto.
+ (WebCore::Document::cookie): Ditto.
+ (WebCore::Document::setCookie): Ditto.
+ (WebCore::Document::setDomain): Ditto.
+ (WebCore::Document::parseQualifiedName): Ditto. Also added an overload
+ that constructs a QualifiedName directly that most call sites can use.
+ (WebCore::Document::createAttribute): Return ExceptionOr.
+ (WebCore::Document::createAttributeNS): Ditto.
+ (WebCore::Document::createTouch): Removed unneeded ExceptionCode&.
+ * dom/Document.h: Updated for above.
+ * dom/Document.idl: Use non-legacy exceptions. Removed exception
+ entirely from createTouch.
+
+ * dom/Element.cpp:
+ (WebCore::Element::parseAttributeName): Updated to use the new
+ Document::parseQualifiedName.
+ * editing/EditorCommand.cpp:
+ (WebCore::executeFormatBlock): Ditto.
+
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::setNodeName): Updated for the new
+ exception handling.
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::getCookies): Ditto.
+
+ * page/ios/FrameIOS.mm:
+ (WebCore::Frame::initWithSimpleHTMLDocument): Use the
+ HTMLHtmlElement::create and HTMLBodyElement::create instead of using
+ createElementNS to make the simple document.
+
+ * svg/animation/SVGSMILElement.cpp:
+ (WebCore::SVGSMILElement::constructAttributeName): Renamed, made this
+ a member function, updated to use the new Document::parseQualifiedName,
+ and also moved the code to get the attribute in here.
+ (WebCore::SVGSMILElement::constructAttributeName): Added. Helper function
+ for the two places we update the attribute name from attributeNameAttr.
+ (WebCore::SVGSMILElement::insertedInto): Use updateAttributeName.
+ (WebCore::SVGSMILElement::svgAttributeChanged): Ditto.
+ * svg/animation/SVGSMILElement.h: Updated for the above.
+
+ * xml/parser/XMLDocumentParserLibxml2.cpp:
+ (WebCore::XMLDocumentParser::processingInstruction): Updated to understand
+ ExceptionOr rather than an out argument.
+ (WebCore::XMLDocumentParser::startDocument): Removed ASSERT_NO_EXCEPTION.
+
2016-10-31 Wenson Hsieh <[email protected]>
Holding down a key to choose an accented character should fire "insertReplacementText" input events
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (208143 => 208144)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -446,7 +446,7 @@
if (!m_handshake->serverSetCookie().isEmpty()) {
if (m_document && cookiesEnabled(*m_document)) {
// Exception (for sandboxed documents) ignored.
- m_document->setCookie(m_handshake->serverSetCookie(), IGNORE_EXCEPTION);
+ m_document->setCookie(m_handshake->serverSetCookie());
}
}
// FIXME: handle set-cookie2.
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (208143 => 208144)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -137,7 +137,7 @@
destroyRenderTreeIfNeeded(child);
// FIXME: We need a no mutation event version of adoptNode.
- RefPtr<Node> adoptedChild = document().adoptNode(child, ASSERT_NO_EXCEPTION);
+ RefPtr<Node> adoptedChild = document().adoptNode(child).releaseReturnValue();
parserAppendChild(*adoptedChild);
// FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
// (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
@@ -374,7 +374,7 @@
return;
if (&document() != &newChild.document())
- document().adoptNode(newChild, ASSERT_NO_EXCEPTION);
+ document().adoptNode(newChild);
insertBeforeCommon(nextChild, newChild);
@@ -703,7 +703,7 @@
ASSERT(!hasTagName(HTMLNames::templateTag));
if (&document() != &newChild.document())
- document().adoptNode(newChild, ASSERT_NO_EXCEPTION);
+ document().adoptNode(newChild);
{
NoEventDispatchAssertion assertNoEventDispatch;
Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (208143 => 208144)
--- trunk/Source/WebCore/dom/DOMImplementation.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -92,13 +92,9 @@
ExceptionOr<Ref<DocumentType>> DOMImplementation::createDocumentType(const String& qualifiedName, const String& publicId, const String& systemId)
{
- ExceptionCode ec = 0;
- String prefix;
- String localName;
- Document::parseQualifiedName(qualifiedName, prefix, localName, ec);
- if (ec)
- return Exception { ec };
-
+ auto parseResult = Document::parseQualifiedName(qualifiedName);
+ if (parseResult.hasException())
+ return parseResult.releaseException();
return DocumentType::create(m_document, qualifiedName, publicId, systemId);
}
@@ -119,10 +115,10 @@
RefPtr<Element> documentElement;
if (!qualifiedName.isEmpty()) {
- ExceptionCode ec = 0;
- documentElement = document->createElementNS(namespaceURI, qualifiedName, ec);
- if (ec)
- return Exception { ec };
+ auto result = document->createElementNS(namespaceURI, qualifiedName);
+ if (result.hasException())
+ return result.releaseException();
+ documentElement = result.releaseReturnValue();
}
if (documentType)
Modified: trunk/Source/WebCore/dom/Document.cpp (208143 => 208144)
--- trunk/Source/WebCore/dom/Document.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -880,11 +880,11 @@
#endif
-static RefPtr<Element> createHTMLElementWithNameValidation(Document& document, const AtomicString& localName, ExceptionCode& ec)
+static ExceptionOr<Ref<Element>> createHTMLElementWithNameValidation(Document& document, const AtomicString& localName)
{
auto element = HTMLElementFactory::createKnownElement(localName, document);
if (LIKELY(element))
- return element;
+ return Ref<Element> { element.releaseNonNull() };
#if ENABLE(CUSTOM_ELEMENTS)
if (auto* window = document.domWindow()) {
@@ -896,33 +896,29 @@
}
#endif
- if (UNLIKELY(!Document::isValidName(localName))) {
- ec = INVALID_CHARACTER_ERR;
- return nullptr;
- }
+ if (UNLIKELY(!Document::isValidName(localName)))
+ return Exception { INVALID_CHARACTER_ERR };
- QualifiedName qualifiedName(nullAtom, localName, xhtmlNamespaceURI);
+ QualifiedName qualifiedName { nullAtom, localName, xhtmlNamespaceURI };
#if ENABLE(CUSTOM_ELEMENTS)
if (auto element = createUpgradeCandidateElement(document, qualifiedName))
- return WTFMove(element);
+ return Ref<Element> { element.releaseNonNull() };
#endif
- return HTMLUnknownElement::create(qualifiedName, document);
+ return Ref<Element> { HTMLUnknownElement::create(qualifiedName, document) };
}
-RefPtr<Element> Document::createElementForBindings(const AtomicString& name, ExceptionCode& ec)
+ExceptionOr<Ref<Element>> Document::createElementForBindings(const AtomicString& name)
{
if (isHTMLDocument())
- return createHTMLElementWithNameValidation(*this, name.convertToASCIILowercase(), ec);
+ return createHTMLElementWithNameValidation(*this, name.convertToASCIILowercase());
if (isXHTMLDocument())
- return createHTMLElementWithNameValidation(*this, name, ec);
+ return createHTMLElementWithNameValidation(*this, name);
- if (!isValidName(name)) {
- ec = INVALID_CHARACTER_ERR;
- return nullptr;
- }
+ if (!isValidName(name))
+ return Exception { INVALID_CHARACTER_ERR };
return createElement(QualifiedName(nullAtom, name, nullAtom), false);
}
@@ -942,26 +938,20 @@
return Comment::create(*this, data);
}
-RefPtr<CDATASection> Document::createCDATASection(const String& data, ExceptionCode& ec)
+ExceptionOr<Ref<CDATASection>> Document::createCDATASection(const String& data)
{
- if (isHTMLDocument()) {
- ec = NOT_SUPPORTED_ERR;
- return nullptr;
- }
+ if (isHTMLDocument())
+ return Exception { NOT_SUPPORTED_ERR };
return CDATASection::create(*this, data);
}
-RefPtr<ProcessingInstruction> Document::createProcessingInstruction(const String& target, const String& data, ExceptionCode& ec)
+ExceptionOr<Ref<ProcessingInstruction>> Document::createProcessingInstruction(const String& target, const String& data)
{
- if (!isValidName(target)) {
- ec = INVALID_CHARACTER_ERR;
- return nullptr;
- }
+ if (!isValidName(target))
+ return Exception { INVALID_CHARACTER_ERR };
- if (data.contains("?>")) {
- ec = INVALID_CHARACTER_ERR;
- return nullptr;
- }
+ if (data.contains("?>"))
+ return Exception { INVALID_CHARACTER_ERR };
return ProcessingInstruction::create(*this, target, data);
}
@@ -977,7 +967,7 @@
return *propertySet->ensureCSSStyleDeclaration();
}
-RefPtr<Node> Document::importNode(Node& nodeToImport, bool deep, ExceptionCode& ec)
+ExceptionOr<Ref<Node>> Document::importNode(Node& nodeToImport, bool deep)
{
switch (nodeToImport.nodeType()) {
case DOCUMENT_FRAGMENT_NODE:
@@ -993,7 +983,7 @@
case ATTRIBUTE_NODE:
// FIXME: This will "Attr::normalize" child nodes of Attr.
- return Attr::create(*this, QualifiedName(nullAtom, downcast<Attr>(nodeToImport).name(), nullAtom), downcast<Attr>(nodeToImport).value());
+ return Ref<Node> { Attr::create(*this, QualifiedName(nullAtom, downcast<Attr>(nodeToImport).name(), nullAtom), downcast<Attr>(nodeToImport).value()) };
case DOCUMENT_NODE: // Can't import a document into another document.
case DOCUMENT_TYPE_NODE: // FIXME: Support cloning a DocumentType node per DOM4.
@@ -1000,27 +990,23 @@
break;
}
- ec = NOT_SUPPORTED_ERR;
- return nullptr;
+ return Exception { NOT_SUPPORTED_ERR };
}
-RefPtr<Node> Document::adoptNode(Node& source, ExceptionCode& ec)
+ExceptionOr<Ref<Node>> Document::adoptNode(Node& source)
{
EventQueueScope scope;
switch (source.nodeType()) {
case DOCUMENT_NODE:
- ec = NOT_SUPPORTED_ERR;
- return nullptr;
+ return Exception { NOT_SUPPORTED_ERR };
case ATTRIBUTE_NODE: {
auto& attr = downcast<Attr>(source);
if (auto* element = attr.ownerElement()) {
auto result = element->removeAttributeNode(attr);
- if (result.hasException()) {
- ec = result.releaseException().code();
- // FIXME: Why fall through here instead of returning early?
- }
+ if (result.hasException())
+ return result.releaseException();
}
break;
}
@@ -1027,26 +1013,21 @@
default:
if (source.isShadowRoot()) {
// ShadowRoot cannot disconnect itself from the host node.
- ec = HIERARCHY_REQUEST_ERR;
- return nullptr;
+ return Exception { HIERARCHY_REQUEST_ERR };
}
if (is<HTMLFrameOwnerElement>(source)) {
auto& frameOwnerElement = downcast<HTMLFrameOwnerElement>(source);
- if (frame() && frame()->tree().isDescendantOf(frameOwnerElement.contentFrame())) {
- ec = HIERARCHY_REQUEST_ERR;
- return nullptr;
- }
+ if (frame() && frame()->tree().isDescendantOf(frameOwnerElement.contentFrame()))
+ return Exception { HIERARCHY_REQUEST_ERR };
}
auto result = source.remove();
- if (result.hasException()) {
- ec = result.releaseException().code();
- return nullptr;
- }
+ if (result.hasException())
+ return result.releaseException();
}
adoptIfNeeded(&source);
- return &source;
+ return Ref<Node> { source };
}
bool Document::hasValidNamespaceForElements(const QualifiedName& qName)
@@ -1182,19 +1163,15 @@
return *m_namedFlows;
}
-RefPtr<Element> Document::createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode& ec)
+ExceptionOr<Ref<Element>> Document::createElementNS(const AtomicString& namespaceURI, const String& qualifiedName)
{
- String prefix, localName;
- if (!parseQualifiedName(qualifiedName, prefix, localName, ec))
- return nullptr;
-
- QualifiedName qName(prefix, localName, namespaceURI);
- if (!hasValidNamespaceForElements(qName)) {
- ec = NAMESPACE_ERR;
- return nullptr;
- }
-
- return createElement(qName, false);
+ auto parseResult = parseQualifiedName(namespaceURI, qualifiedName);
+ if (parseResult.hasException())
+ return parseResult.releaseException();
+ QualifiedName parsedName { parseResult.releaseReturnValue() };
+ if (!hasValidNamespaceForElements(parsedName))
+ return Exception { NAMESPACE_ERR };
+ return createElement(parsedName, false);
}
String Document::readyState() const
@@ -1362,14 +1339,13 @@
m_styleScope->didChangeStyleSheetEnvironment();
}
-void Document::setXMLVersion(const String& version, ExceptionCode& ec)
+ExceptionOr<void> Document::setXMLVersion(const String& version)
{
- if (!XMLDocumentParser::supportsXMLVersion(version)) {
- ec = NOT_SUPPORTED_ERR;
- return;
- }
+ if (!XMLDocumentParser::supportsXMLVersion(version))
+ return Exception { NOT_SUPPORTED_ERR };
m_xmlVersion = version;
+ return { };
}
void Document::setXMLStandalone(bool standalone)
@@ -2585,28 +2561,26 @@
return nullptr;
}
-void Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody, ExceptionCode& ec)
+ExceptionOr<void> Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody)
{
- if (!is<HTMLBodyElement>(newBody.get()) && !is<HTMLFrameSetElement>(newBody.get())) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
+ if (!is<HTMLBodyElement>(newBody.get()) && !is<HTMLFrameSetElement>(newBody.get()))
+ return Exception { HIERARCHY_REQUEST_ERR };
auto* currentBody = bodyOrFrameset();
if (newBody == currentBody)
- return;
+ return { };
- if (currentBody) {
- documentElement()->replaceChild(*newBody, *currentBody, ec);
- return;
- }
+ if (!m_documentElement)
+ return Exception { HIERARCHY_REQUEST_ERR };
- if (!documentElement()) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
-
- documentElement()->appendChild(*newBody, ec);
+ ExceptionCode ec = 0;
+ if (currentBody)
+ m_documentElement->replaceChild(*newBody, *currentBody, ec);
+ else
+ m_documentElement->appendChild(*newBody, ec);
+ if (ec)
+ return Exception { ec };
+ return { };
}
Location* Document::location() const
@@ -3194,7 +3168,7 @@
// FIXME: make setCookie work on XML documents too; e.g. in case of <html:meta .....>
if (is<HTMLDocument>(*this)) {
// Exception (for sandboxed documents) ignored.
- downcast<HTMLDocument>(*this).setCookie(content, IGNORE_EXCEPTION);
+ downcast<HTMLDocument>(*this).setCookie(content);
}
break;
@@ -4130,7 +4104,7 @@
m_eventQueue.enqueueEvent(WTFMove(event));
}
-RefPtr<Event> Document::createEvent(const String& type, ExceptionCode& ec)
+ExceptionOr<Ref<Event>> Document::createEvent(const String& type)
{
// Please do *not* add new event classes to this function unless they are
// required for compatibility of some actual legacy web content.
@@ -4142,23 +4116,23 @@
// <https://dom.spec.whatwg.org/#dom-document-createevent>.
if (equalLettersIgnoringASCIICase(type, "customevent"))
- return CustomEvent::create();
+ return Ref<Event> { CustomEvent::create() };
if (equalLettersIgnoringASCIICase(type, "event") || equalLettersIgnoringASCIICase(type, "events") || equalLettersIgnoringASCIICase(type, "htmlevents"))
return Event::createForBindings();
if (equalLettersIgnoringASCIICase(type, "keyboardevent") || equalLettersIgnoringASCIICase(type, "keyboardevents"))
- return KeyboardEvent::createForBindings();
+ return Ref<Event> { KeyboardEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "messageevent"))
- return MessageEvent::createForBindings();
+ return Ref<Event> { MessageEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "mouseevent") || equalLettersIgnoringASCIICase(type, "mouseevents"))
- return MouseEvent::createForBindings();
+ return Ref<Event> { MouseEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "uievent") || equalLettersIgnoringASCIICase(type, "uievents"))
- return UIEvent::createForBindings();
+ return Ref<Event> { UIEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "popstateevent"))
- return PopStateEvent::createForBindings();
+ return Ref<Event> { PopStateEvent::createForBindings() };
#if ENABLE(TOUCH_EVENTS)
if (equalLettersIgnoringASCIICase(type, "touchevent"))
- return TouchEvent::createForBindings();
+ return Ref<Event> { TouchEvent::createForBindings() };
#endif
// The following string comes from the SVG specifications
@@ -4168,7 +4142,7 @@
// there is no practical value in this feature.
if (equalLettersIgnoringASCIICase(type, "svgzoomevents"))
- return SVGZoomEvent::createForBindings();
+ return Ref<Event> { SVGZoomEvent::createForBindings() };
// The following strings are for event classes where WebKit supplies an init function.
// These strings are not part of the DOM specification and we would like to eliminate them.
@@ -4178,29 +4152,28 @@
// both the string and the corresponding init function for that class.
if (equalLettersIgnoringASCIICase(type, "compositionevent"))
- return CompositionEvent::createForBindings();
+ return Ref<Event> { CompositionEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "hashchangeevent"))
- return HashChangeEvent::createForBindings();
+ return Ref<Event> { HashChangeEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "mutationevent") || equalLettersIgnoringASCIICase(type, "mutationevents"))
- return MutationEvent::createForBindings();
+ return Ref<Event> { MutationEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "overflowevent"))
- return OverflowEvent::createForBindings();
+ return Ref<Event> { OverflowEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "storageevent"))
- return StorageEvent::createForBindings();
+ return Ref<Event> { StorageEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "textevent"))
- return TextEvent::createForBindings();
+ return Ref<Event> { TextEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "wheelevent"))
- return WheelEvent::createForBindings();
+ return Ref<Event> { WheelEvent::createForBindings() };
#if ENABLE(DEVICE_ORIENTATION)
if (equalLettersIgnoringASCIICase(type, "devicemotionevent"))
- return DeviceMotionEvent::createForBindings();
+ return Ref<Event> { DeviceMotionEvent::createForBindings() };
if (equalLettersIgnoringASCIICase(type, "deviceorientationevent"))
- return DeviceOrientationEvent::createForBindings();
+ return Ref<Event> { DeviceOrientationEvent::createForBindings() };
#endif
- ec = NOT_SUPPORTED_ERR;
- return nullptr;
+ return Exception { NOT_SUPPORTED_ERR };
}
bool Document::hasListenerTypeForEventType(PlatformEvent::Type eventType) const
@@ -4269,7 +4242,7 @@
return frame()->ownerElement();
}
-String Document::cookie(ExceptionCode& ec)
+ExceptionOr<String> Document::cookie()
{
if (page() && !page()->settings().cookieEnabled())
return String();
@@ -4278,10 +4251,8 @@
// INVALID_STATE_ERR exception on getting if the Document has no
// browsing context.
- if (!securityOrigin()->canAccessCookies()) {
- ec = SECURITY_ERR;
- return String();
- }
+ if (!securityOrigin()->canAccessCookies())
+ return Exception { SECURITY_ERR };
URL cookieURL = this->cookieURL();
if (cookieURL.isEmpty())
@@ -4290,29 +4261,28 @@
if (!isDOMCookieCacheValid())
setCachedDOMCookies(cookies(*this, cookieURL));
- return cachedDOMCookies();
+ return String { cachedDOMCookies() };
}
-void Document::setCookie(const String& value, ExceptionCode& ec)
+ExceptionOr<void> Document::setCookie(const String& value)
{
if (page() && !page()->settings().cookieEnabled())
- return;
+ return { };
// FIXME: The HTML5 DOM spec states that this attribute can raise an
// INVALID_STATE_ERR exception on setting if the Document has no
// browsing context.
- if (!securityOrigin()->canAccessCookies()) {
- ec = SECURITY_ERR;
- return;
- }
+ if (!securityOrigin()->canAccessCookies())
+ return Exception { SECURITY_ERR };
URL cookieURL = this->cookieURL();
if (cookieURL.isEmpty())
- return;
+ return { };
invalidateDOMCookieCache();
setCookies(*this, cookieURL, value);
+ return { };
}
String Document::referrer() const
@@ -4332,12 +4302,10 @@
return securityOrigin()->domain();
}
-void Document::setDomain(const String& newDomain, ExceptionCode& ec)
+ExceptionOr<void> Document::setDomain(const String& newDomain)
{
- if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()->protocol())) {
- ec = SECURITY_ERR;
- return;
- }
+ if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()->protocol()))
+ return Exception { SECURITY_ERR };
// Both NS and IE specify that changing the domain is only allowed when
// the new domain is a suffix of the old domain.
@@ -4344,6 +4312,8 @@
// FIXME: We should add logging indicating why a domain was not allowed.
+ String oldDomain = domain();
+
// If the new domain is the same as the old domain, still call
// securityOrigin()->setDomainForDOM. This will change the
// security check behavior. For example, if a page loaded on port 8000
@@ -4350,42 +4320,29 @@
// assigns its current domain using document.domain, the page will
// allow other pages loaded on different ports in the same domain that
// have also assigned to access this page.
- if (equalIgnoringASCIICase(domain(), newDomain)) {
+ if (equalIgnoringASCIICase(oldDomain, newDomain)) {
securityOrigin()->setDomainFromDOM(newDomain);
- return;
+ return { };
}
- int oldLength = domain().length();
- int newLength = newDomain.length();
// e.g. newDomain = webkit.org (10) and domain() = www.webkit.org (14)
- if (newLength >= oldLength) {
- ec = SECURITY_ERR;
- return;
- }
+ unsigned oldLength = oldDomain.length();
+ unsigned newLength = newDomain.length();
+ if (newLength >= oldLength)
+ return Exception { SECURITY_ERR };
- OriginAccessEntry::IPAddressSetting ipAddressSetting = settings() && settings()->treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : OriginAccessEntry::TreatIPAddressAsIPAddress;
- OriginAccessEntry accessEntry(securityOrigin()->protocol(), newDomain, OriginAccessEntry::AllowSubdomains, ipAddressSetting);
- if (!accessEntry.matchesOrigin(*securityOrigin())) {
- ec = SECURITY_ERR;
- return;
- }
+ auto ipAddressSetting = settings() && settings()->treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : OriginAccessEntry::TreatIPAddressAsIPAddress;
+ OriginAccessEntry accessEntry { securityOrigin()->protocol(), newDomain, OriginAccessEntry::AllowSubdomains, ipAddressSetting };
+ if (!accessEntry.matchesOrigin(*securityOrigin()))
+ return Exception { SECURITY_ERR };
- String test = domain();
- // Check that it's a subdomain, not e.g. "ebkit.org"
- if (test[oldLength - newLength - 1] != '.') {
- ec = SECURITY_ERR;
- return;
- }
+ if (oldDomain[oldLength - newLength - 1] != '.')
+ return Exception { SECURITY_ERR };
+ if (StringView { oldDomain }.substring(oldLength - newLength) != newDomain)
+ return Exception { SECURITY_ERR };
- // Now test is "webkit.org" from domain()
- // and we check that it's the same thing as newDomain
- test.remove(0, oldLength - newLength);
- if (test != newDomain) {
- ec = SECURITY_ERR;
- return;
- }
-
securityOrigin()->setDomainFromDOM(newDomain);
+ return { };
}
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
@@ -4495,64 +4452,54 @@
return isValidNameNonASCII(characters, length);
}
-bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode& ec)
+ExceptionOr<std::pair<AtomicString, AtomicString>> Document::parseQualifiedName(const String& qualifiedName)
{
unsigned length = qualifiedName.length();
- if (!length) {
- ec = INVALID_CHARACTER_ERR;
- return false;
- }
+ if (!length)
+ return Exception { INVALID_CHARACTER_ERR };
bool nameStart = true;
bool sawColon = false;
- int colonPos = 0;
+ unsigned colonPosition = 0;
- for (unsigned i = 0; i < length;) {
+ for (unsigned i = 0; i < length; ) {
UChar32 c;
U16_NEXT(qualifiedName, i, length, c)
if (c == ':') {
- if (sawColon) {
- ec = NAMESPACE_ERR;
- return false; // multiple colons: not allowed
- }
+ if (sawColon)
+ return Exception { NAMESPACE_ERR };
nameStart = true;
sawColon = true;
- colonPos = i - 1;
+ colonPosition = i - 1;
} else if (nameStart) {
- if (!isValidNameStart(c)) {
- ec = INVALID_CHARACTER_ERR;
- return false;
- }
+ if (!isValidNameStart(c))
+ return Exception { INVALID_CHARACTER_ERR };
nameStart = false;
} else {
- if (!isValidNamePart(c)) {
- ec = INVALID_CHARACTER_ERR;
- return false;
- }
+ if (!isValidNamePart(c))
+ return Exception { INVALID_CHARACTER_ERR };
}
}
- if (!sawColon) {
- prefix = String();
- localName = qualifiedName;
- } else {
- prefix = qualifiedName.substring(0, colonPos);
- if (prefix.isEmpty()) {
- ec = NAMESPACE_ERR;
- return false;
- }
- localName = qualifiedName.substring(colonPos + 1);
- }
+ if (!sawColon)
+ return std::pair<AtomicString, AtomicString> { { }, { qualifiedName } };
- if (localName.isEmpty()) {
- ec = NAMESPACE_ERR;
- return false;
- }
+ if (!colonPosition || length - colonPosition <= 1)
+ return Exception { NAMESPACE_ERR };
- return true;
+ return std::pair<AtomicString, AtomicString> { StringView { qualifiedName }.substring(0, colonPosition).toAtomicString(), StringView { qualifiedName }.substring(colonPosition + 1).toAtomicString() };
}
+ExceptionOr<QualifiedName> Document::parseQualifiedName(const AtomicString& namespaceURI, const String& qualifiedName)
+{
+ auto parseResult = parseQualifiedName(qualifiedName);
+ if (parseResult.hasException())
+ return parseResult.releaseException();
+ auto parsedPieces = parseResult.releaseReturnValue();
+ return QualifiedName { parsedPieces.first, parsedPieces.second, namespaceURI };
+}
+
void Document::setDecoder(RefPtr<TextResourceDecoder>&& decoder)
{
m_decoder = WTFMove(decoder);
@@ -4953,25 +4900,20 @@
return *document;
}
-RefPtr<Attr> Document::createAttribute(const String& name, ExceptionCode& ec)
+ExceptionOr<Ref<Attr>> Document::createAttribute(const String& name)
{
- return createAttributeNS(String(), isHTMLDocument() ? name.convertToASCIILowercase() : name, ec, true);
+ return createAttributeNS({ }, isHTMLDocument() ? name.convertToASCIILowercase() : name, true);
}
-RefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode& ec, bool shouldIgnoreNamespaceChecks)
+ExceptionOr<Ref<Attr>> Document::createAttributeNS(const AtomicString& namespaceURI, const String& qualifiedName, bool shouldIgnoreNamespaceChecks)
{
- String prefix, localName;
- if (!parseQualifiedName(qualifiedName, prefix, localName, ec))
- return nullptr;
-
- QualifiedName qName(prefix, localName, namespaceURI);
-
- if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) {
- ec = NAMESPACE_ERR;
- return nullptr;
- }
-
- return Attr::create(*this, qName, emptyString());
+ auto parseResult = parseQualifiedName(namespaceURI, qualifiedName);
+ if (parseResult.hasException())
+ return parseResult.releaseException();
+ QualifiedName parsedName { parseResult.releaseReturnValue() };
+ if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(parsedName))
+ return Exception { NAMESPACE_ERR };
+ return Attr::create(*this, parsedName, emptyString());
}
const SVGDocumentExtensions* Document::svgExtensions()
@@ -6244,7 +6186,7 @@
#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
-RefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force, ExceptionCode&) const
+Ref<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force) const
{
// FIXME: It's not clear from the documentation at
// http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
Modified: trunk/Source/WebCore/dom/Document.h (208143 => 208144)
--- trunk/Source/WebCore/dom/Document.h 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/dom/Document.h 2016-10-31 15:49:34 UTC (rev 208144)
@@ -376,16 +376,16 @@
bool hasManifest() const;
- WEBCORE_EXPORT RefPtr<Element> createElementForBindings(const AtomicString& tagName, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementForBindings(const AtomicString& tagName);
WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
WEBCORE_EXPORT Ref<Text> createTextNode(const String& data);
WEBCORE_EXPORT Ref<Comment> createComment(const String& data);
- WEBCORE_EXPORT RefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
- WEBCORE_EXPORT RefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
- WEBCORE_EXPORT RefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
- WEBCORE_EXPORT RefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
- WEBCORE_EXPORT RefPtr<Node> importNode(Node& nodeToImport, bool deep, ExceptionCode&);
- WEBCORE_EXPORT RefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<Ref<CDATASection>> createCDATASection(const String& data);
+ WEBCORE_EXPORT ExceptionOr<Ref<ProcessingInstruction>> createProcessingInstruction(const String& target, const String& data);
+ WEBCORE_EXPORT ExceptionOr<Ref<Attr>> createAttribute(const String& name);
+ WEBCORE_EXPORT ExceptionOr<Ref<Attr>> createAttributeNS(const AtomicString& namespaceURI, const String& qualifiedName, bool shouldIgnoreNamespaceChecks = false);
+ WEBCORE_EXPORT ExceptionOr<Ref<Node>> importNode(Node& nodeToImport, bool deep);
+ WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementNS(const AtomicString& namespaceURI, const String& qualifiedName);
WEBCORE_EXPORT Ref<Element> createElement(const QualifiedName&, bool createdByParser);
static CustomElementNameValidationStatus validateCustomElementName(const AtomicString&);
@@ -434,7 +434,7 @@
bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
- WEBCORE_EXPORT void setXMLVersion(const String&, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<void> setXMLVersion(const String&);
WEBCORE_EXPORT void setXMLStandalone(bool);
void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
@@ -453,7 +453,7 @@
void setTimerThrottlingEnabled(bool);
bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
- WEBCORE_EXPORT RefPtr<Node> adoptNode(Node& source, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<Ref<Node>> adoptNode(Node& source);
WEBCORE_EXPORT Ref<HTMLCollection> images();
WEBCORE_EXPORT Ref<HTMLCollection> embeds();
@@ -773,7 +773,7 @@
WEBCORE_EXPORT void dispatchWindowEvent(Event&, EventTarget* = nullptr);
void dispatchWindowLoadEvent();
- WEBCORE_EXPORT RefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<Ref<Event>> createEvent(const String& eventType);
// keep track of what types of event listeners are registered, so we don't
// dispatch events unnecessarily
@@ -842,8 +842,8 @@
void titleElementRemoved(Element& titleElement);
void titleElementTextChanged(Element& titleElement);
- WEBCORE_EXPORT String cookie(ExceptionCode&);
- WEBCORE_EXPORT void setCookie(const String&, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<String> cookie();
+ WEBCORE_EXPORT ExceptionOr<void> setCookie(const String&);
WEBCORE_EXPORT String referrer() const;
@@ -850,7 +850,7 @@
WEBCORE_EXPORT String origin() const;
WEBCORE_EXPORT String domain() const;
- void setDomain(const String& newDomain, ExceptionCode&);
+ ExceptionOr<void> setDomain(const String& newDomain);
WEBCORE_EXPORT String lastModified();
@@ -887,8 +887,9 @@
// The following breaks a qualified name into a prefix and a local name.
// It also does a validity check, and returns false if the qualified name
- // is invalid. It also sets ExceptionCode when name is invalid.
- static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
+ // is invalid. It also sets ExceptionCode when name is invalid.
+ static ExceptionOr<std::pair<AtomicString, AtomicString>> parseQualifiedName(const String& qualifiedName);
+ static ExceptionOr<QualifiedName> parseQualifiedName(const AtomicString& namespaceURI, const String& qualifiedName);
// Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
static bool hasValidNamespaceForElements(const QualifiedName&);
@@ -896,7 +897,7 @@
HTMLBodyElement* body() const;
WEBCORE_EXPORT HTMLElement* bodyOrFrameset() const;
- WEBCORE_EXPORT void setBodyOrFrameset(RefPtr<HTMLElement>&&, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<void> setBodyOrFrameset(RefPtr<HTMLElement>&&);
Location* location() const;
@@ -1133,7 +1134,7 @@
#if ENABLE(IOS_TOUCH_EVENTS)
#include <WebKitAdditions/DocumentIOS.h>
#elif ENABLE(TOUCH_EVENTS)
- RefPtr<Touch> createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force, ExceptionCode&) const;
+ Ref<Touch> createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force) const;
#endif
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
Modified: trunk/Source/WebCore/dom/Document.idl (208143 => 208144)
--- trunk/Source/WebCore/dom/Document.idl 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/dom/Document.idl 2016-10-31 15:49:34 UTC (rev 208144)
@@ -31,21 +31,21 @@
readonly attribute DOMImplementation implementation;
[DOMJIT] readonly attribute Element? documentElement;
- [NewObject, MayThrowLegacyException, ImplementedAs=createElementForBindings] Element createElement(DOMString tagName);
+ [NewObject, MayThrowException, ImplementedAs=createElementForBindings] Element createElement(DOMString tagName);
[NewObject] DocumentFragment createDocumentFragment();
[NewObject] Text createTextNode(DOMString data);
[NewObject] Comment createComment(DOMString data);
- [NewObject, MayThrowLegacyException] CDATASection createCDATASection(DOMString data);
- [NewObject, MayThrowLegacyException] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
- [NewObject, MayThrowLegacyException] Attr createAttribute(DOMString name);
+ [NewObject, MayThrowException] CDATASection createCDATASection(DOMString data);
+ [NewObject, MayThrowException] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
+ [NewObject, MayThrowException] Attr createAttribute(DOMString name);
HTMLCollection getElementsByTagName(DOMString tagname);
- [CEReactions, MayThrowLegacyException, NewObject] Node importNode(Node importedNode, optional boolean deep = false);
+ [CEReactions, MayThrowException, NewObject] Node importNode(Node importedNode, optional boolean deep = false);
- [NewObject, MayThrowLegacyException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName);
- [NewObject, MayThrowLegacyException] Attr createAttributeNS(DOMString? namespaceURI, DOMString qualifiedName);
+ [NewObject, MayThrowException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName);
+ [NewObject, MayThrowException] Attr createAttributeNS(DOMString? namespaceURI, DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespaceURI, DOMString localName);
@@ -52,14 +52,14 @@
[ImplementedAs=characterSetWithUTF8Fallback] readonly attribute DOMString inputEncoding;
readonly attribute DOMString? xmlEncoding;
- [SetterMayThrowLegacyException] attribute DOMString? xmlVersion;
+ [SetterMayThrowException] attribute DOMString? xmlVersion;
attribute boolean xmlStandalone;
- [CEReactions, MayThrowLegacyException] Node adoptNode(Node source);
+ [CEReactions, MayThrowException] Node adoptNode(Node source);
[ImplementedAs=urlForBindings] readonly attribute USVString documentURI;
- [MayThrowLegacyException, NewObject] Event createEvent(DOMString eventType);
+ [MayThrowException, NewObject] Event createEvent(DOMString eventType);
[NewObject] Range createRange();
@@ -96,12 +96,12 @@
attribute DOMString designMode;
readonly attribute USVString referrer;
- [SetterMayThrowLegacyException] attribute USVString domain;
+ [SetterMayThrowException] attribute USVString domain;
[ImplementedAs=urlForBindings] readonly attribute USVString URL;
- [GetterMayThrowLegacyException, SetterMayThrowLegacyException] attribute USVString cookie;
+ [GetterMayThrowException, SetterMayThrowException] attribute USVString cookie;
- [CEReactions, ImplementedAs=bodyOrFrameset, SetterMayThrowLegacyException] attribute HTMLElement? body;
+ [CEReactions, ImplementedAs=bodyOrFrameset, SetterMayThrowException] attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
readonly attribute HTMLCollection images;
@@ -162,7 +162,7 @@
#if defined(ENABLE_IOS_TOUCH_EVENTS) && ENABLE_IOS_TOUCH_EVENTS
#include <WebKitAdditions/DocumentIOS.idl>
#elif defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
- [NewObject, MayThrowLegacyException] Touch createTouch(optional DOMWindow? window = null, optional EventTarget? target = null,
+ [NewObject] Touch createTouch(optional DOMWindow? window = null, optional EventTarget? target = null,
optional long identifier = 0,
optional long pageX = 0, optional long pageY = 0, optional long screenX = 0, optional long screenY = 0,
optional long webkitRadiusX = 0, optional long webkitRadiusY = 0,
Modified: trunk/Source/WebCore/dom/Element.cpp (208143 => 208144)
--- trunk/Source/WebCore/dom/Element.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/dom/Element.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -2228,18 +2228,13 @@
ExceptionOr<QualifiedName> Element::parseAttributeName(const AtomicString& namespaceURI, const AtomicString& qualifiedName)
{
- ExceptionCode ec = 0;
- String prefix, localName;
- if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec))
- return Exception { ec };
- ASSERT(!ec);
-
- QualifiedName result { prefix, localName, namespaceURI };
-
- if (!Document::hasValidNamespaceForAttributes(result))
+ auto parseResult = Document::parseQualifiedName(namespaceURI, qualifiedName);
+ if (parseResult.hasException())
+ return parseResult.releaseException();
+ QualifiedName parsedAttributeName { parseResult.releaseReturnValue() };
+ if (!Document::hasValidNamespaceForAttributes(parsedAttributeName))
return Exception { NAMESPACE_ERR };
-
- return WTFMove(result);
+ return WTFMove(parsedAttributeName);
}
ExceptionOr<void> Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value)
Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (208143 => 208144)
--- trunk/Source/WebCore/editing/EditorCommand.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -412,14 +412,13 @@
if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
tagName = tagName.substring(1, tagName.length() - 2);
- String localName, prefix;
- if (!Document::parseQualifiedName(tagName, prefix, localName, IGNORE_EXCEPTION))
+ auto qualifiedTagName = Document::parseQualifiedName(xhtmlNamespaceURI, tagName);
+ if (qualifiedTagName.hasException())
return false;
- QualifiedName qualifiedTagName(prefix, localName, xhtmlNamespaceURI);
ASSERT(frame.document());
- RefPtr<FormatBlockCommand> command = FormatBlockCommand::create(*frame.document(), qualifiedTagName);
- applyCommand(command);
+ auto command = FormatBlockCommand::create(*frame.document(), qualifiedTagName.releaseReturnValue());
+ applyCommand(command.copyRef());
return command->didApply();
}
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (208143 => 208144)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -728,10 +728,10 @@
if (!is<Element>(oldNode.get()))
return;
- ExceptionCode ec = 0;
- auto newElement = oldNode->document().createElementForBindings(tagName, ec);
- if (ec)
+ auto createElementResult = oldNode->document().createElementForBindings(tagName);
+ if (createElementResult.hasException())
return;
+ auto newElement = createElementResult.releaseReturnValue();
// Copy over the original node's attributes.
newElement->cloneAttributesFromElement(downcast<Element>(*oldNode));
@@ -739,18 +739,18 @@
// Copy over the original node's children.
RefPtr<Node> child;
while ((child = oldNode->firstChild())) {
- if (!m_domEditor->insertBefore(*newElement, *child, 0, errorString))
+ if (!m_domEditor->insertBefore(newElement, *child, 0, errorString))
return;
}
// Replace the old node with the new node
RefPtr<ContainerNode> parent = oldNode->parentNode();
- if (!m_domEditor->insertBefore(*parent, *newElement, oldNode->nextSibling(), errorString))
+ if (!m_domEditor->insertBefore(*parent, newElement.copyRef(), oldNode->nextSibling(), errorString))
return;
if (!m_domEditor->removeChild(*parent, *oldNode, errorString))
return;
- *newId = pushNodePathToFrontend(newElement.get());
+ *newId = pushNodePathToFrontend(newElement.ptr());
if (m_childrenRequested.contains(nodeId))
pushChildNodesToFrontend(*newId);
}
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (208143 => 208144)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -527,7 +527,7 @@
// FIXME: We need duplication checking for the String representation of cookies.
// Exceptions are thrown by cookie() in sandboxed frames. That won't happen here
// because "document" is the document of the main frame of the page.
- stringCookiesList.append(document->cookie(ASSERT_NO_EXCEPTION));
+ stringCookiesList.append(document->cookie().releaseReturnValue());
} else {
for (auto& cookie : docCookiesList) {
if (!rawCookiesList.contains(cookie))
Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (208143 => 208144)
--- trunk/Source/WebCore/page/ios/FrameIOS.mm 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm 2016-10-31 15:49:34 UTC (rev 208144)
@@ -39,8 +39,9 @@
#import "FrameSelection.h"
#import "FrameView.h"
#import "HTMLAreaElement.h"
+#import "HTMLBodyElement.h"
#import "HTMLDocument.h"
-#import "HTMLElement.h"
+#import "HTMLHtmlElement.h"
#import "HTMLNames.h"
#import "HTMLObjectElement.h"
#import "HitTestRequest.h"
@@ -84,15 +85,15 @@
document->createDOMWindow();
setDocument(document);
- ExceptionCode ec;
- auto rootElement = document->createElementNS(xhtmlNamespaceURI, ASCIILiteral("html"), ec);
+ auto rootElement = HTMLHtmlElement::create(*document);
- auto body = document->createElementNS(xhtmlNamespaceURI, ASCIILiteral("body"), ec);
+ auto body = HTMLBodyElement::create(*document);
if (!style.isEmpty())
body->setAttribute(HTMLNames::styleAttr, style);
- rootElement->appendChild(*body, ec);
- document->appendChild(*rootElement, ec);
+ ExceptionCode ec;
+ rootElement->appendChild(body, ec);
+ document->appendChild(rootElement, ec);
}
const ViewportArguments& Frame::viewportArguments() const
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (208143 => 208144)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -207,26 +207,30 @@
}
}
-static inline QualifiedName constructQualifiedName(const SVGElement* svgElement, const String& attributeName)
+inline QualifiedName SVGSMILElement::constructAttributeName() const
{
- ASSERT(svgElement);
- if (attributeName.isEmpty())
+ auto parseResult = Document::parseQualifiedName(attributeWithoutSynchronization(SVGNames::attributeNameAttr));
+ if (parseResult.hasException())
return anyQName();
- if (!attributeName.contains(':'))
- return QualifiedName(nullAtom, attributeName, nullAtom);
-
- String prefix;
- String localName;
- if (!Document::parseQualifiedName(attributeName, prefix, localName, IGNORE_EXCEPTION))
- return anyQName();
-
- String namespaceURI = svgElement->lookupNamespaceURI(prefix);
+
+ AtomicString prefix, localName;
+ std::tie(prefix, localName) = parseResult.releaseReturnValue();
+
+ if (prefix.isNull())
+ return { nullAtom, localName, nullAtom };
+
+ auto namespaceURI = lookupNamespaceURI(prefix);
if (namespaceURI.isEmpty())
return anyQName();
-
- return QualifiedName(nullAtom, localName, namespaceURI);
+
+ return { nullAtom, localName, namespaceURI };
}
+inline void SVGSMILElement::updateAttributeName()
+{
+ setAttributeName(constructAttributeName());
+}
+
static inline void clearTimesWithDynamicOrigins(Vector<SMILTimeWithOrigin>& timeList)
{
timeList.removeAllMatching([] (const SMILTimeWithOrigin& time) {
@@ -258,7 +262,8 @@
// Verify we are not in <use> instance tree.
ASSERT(!isInShadowTree());
- setAttributeName(constructQualifiedName(this, attributeWithoutSynchronization(SVGNames::attributeNameAttr)));
+ updateAttributeName();
+
SVGSVGElement* owner = ownerSVGElement();
if (!owner)
return InsertionDone;
@@ -514,7 +519,7 @@
else if (attrName == SVGNames::maxAttr)
m_cachedMax = invalidCachedTime;
else if (attrName == SVGNames::attributeNameAttr)
- setAttributeName(constructQualifiedName(this, attributeWithoutSynchronization(SVGNames::attributeNameAttr)));
+ updateAttributeName();
else if (attrName.matches(XLinkNames::hrefAttr)) {
InstanceInvalidationGuard guard(*this);
buildPendingResource();
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (208143 => 208144)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2016-10-31 15:49:34 UTC (rev 208144)
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SVGSMILElement_h
-#define SVGSMILElement_h
+#pragma once
#include "SMILTime.h"
#include "SVGElement.h"
@@ -32,13 +31,13 @@
namespace WebCore {
+class ConditionEventListener;
+class SMILTimeContainer;
class SVGSMILElement;
template<typename T> class EventSender;
-typedef EventSender<SVGSMILElement> SMILEventSender;
-class ConditionEventListener;
-class SMILTimeContainer;
+using SMILEventSender = EventSender<SVGSMILElement>;
// This class implements SMIL interval timing model as needed for SVG animation.
class SVGSMILElement : public SVGElement {
@@ -62,19 +61,10 @@
void beginByLinkActivation();
- enum Restart {
- RestartAlways,
- RestartWhenNotActive,
- RestartNever
- };
-
+ enum Restart { RestartAlways, RestartWhenNotActive, RestartNever };
Restart restart() const;
- enum FillMode {
- FillRemove,
- FillFreeze
- };
-
+ enum FillMode { FillRemove, FillFreeze };
FillMode fill() const;
SMILTime dur() const;
@@ -141,9 +131,10 @@
virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
static bool isSupportedAttribute(const QualifiedName&);
+ QualifiedName constructAttributeName() const;
+ void updateAttributeName();
enum BeginOrEnd { Begin, End };
-
SMILTime findInstanceTime(BeginOrEnd, SMILTime minimumTime, bool equalsMinimumOK) const;
void resolveFirstInterval();
void resolveNextInterval(bool notifyDependents);
@@ -157,12 +148,7 @@
// This represents conditions on elements begin or end list that need to be resolved on runtime
// for example <animate begin="otherElement.begin + 8s; button.click" ... />
struct Condition {
- enum Type {
- EventBase,
- Syncbase,
- AccessKey
- };
-
+ enum Type { EventBase, Syncbase, AccessKey };
Condition(Type, BeginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats = -1);
Type m_type;
BeginOrEnd m_beginOrEnd;
@@ -169,7 +155,7 @@
String m_baseID;
String m_name;
SMILTime m_offset;
- int m_repeats;
+ int m_repeats { -1 };
RefPtr<Element> m_syncbase;
RefPtr<ConditionEventListener> m_eventListener;
};
@@ -183,24 +169,13 @@
void handleConditionEvent(Event*, Condition*);
// Syncbase timing
- enum NewOrExistingInterval {
- NewInterval,
- ExistingInterval
- };
-
+ enum NewOrExistingInterval { NewInterval, ExistingInterval };
void notifyDependentsIntervalChanged(NewOrExistingInterval);
void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval);
void addTimeDependent(SVGSMILElement*);
void removeTimeDependent(SVGSMILElement*);
- enum ActiveState {
- Inactive,
- Active,
- Frozen
- };
-
- QualifiedName m_attributeName;
-
+ enum ActiveState { Inactive, Active, Frozen };
ActiveState determineActiveState(SMILTime elapsed) const;
float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat) const;
SMILTime calculateNextProgressTime(SMILTime elapsed) const;
@@ -207,6 +182,8 @@
bool isSMILElement() const final { return true; }
+ QualifiedName m_attributeName;
+
SVGElement* m_targetElement;
Vector<Condition> m_conditions;
@@ -215,8 +192,7 @@
bool m_isWaitingForFirstInterval;
- typedef HashSet<SVGSMILElement*> TimeDependentSet;
- TimeDependentSet m_timeDependents;
+ HashSet<SVGSMILElement*> m_timeDependents;
// Instance time lists
Vector<SMILTimeWithOrigin> m_beginTimes;
@@ -252,5 +228,3 @@
static bool isType(const WebCore::SVGElement& element) { return element.isSMILElement(); }
static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-
-#endif // SVGSMILElement_h
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (208143 => 208144)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -1000,12 +1000,10 @@
if (!updateLeafTextNode())
return;
- // ### handle exceptions
- ExceptionCode ec = 0;
- Ref<ProcessingInstruction> pi = *m_currentNode->document().createProcessingInstruction(
- toString(target), toString(data), ec);
- if (ec)
+ auto result = m_currentNode->document().createProcessingInstruction(toString(target), toString(data));
+ if (result.hasException())
return;
+ auto pi = result.releaseReturnValue();
pi->setCreatedByParser(true);
@@ -1015,6 +1013,7 @@
if (pi->isCSS())
m_sawCSS = true;
+
#if ENABLE(XSLT)
m_sawXSLTransform = !m_sawFirstElement && pi->isXSL();
if (m_sawXSLTransform && !document()->transformSourceDocument())
@@ -1070,7 +1069,7 @@
}
if (version)
- document()->setXMLVersion(toString(version), ASSERT_NO_EXCEPTION);
+ document()->setXMLVersion(toString(version));
if (standalone != StandaloneUnspecified)
document()->setXMLStandalone(standaloneInfo == StandaloneYes);
if (encoding)
Modified: trunk/Source/WebKit/mac/ChangeLog (208143 => 208144)
--- trunk/Source/WebKit/mac/ChangeLog 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-10-31 15:49:34 UTC (rev 208144)
@@ -1,3 +1,27 @@
+2016-10-31 Darin Adler <[email protected]>
+
+ Convert Document from ExceptionCode to Exception
+ https://bugs.webkit.org/show_bug.cgi?id=164212
+
+ Reviewed by Alex Christensen.
+
+ * DOM/DOMDocument.mm:
+ (-[DOMDocument setXmlVersion:]): Updated exception handling.
+ (-[DOMDocument cookie]): Ditto.
+ (-[DOMDocument setCookie:]): Ditto.
+ (-[DOMDocument setBody:]): Ditto.
+ (-[DOMDocument createElement:]): Ditto.
+ (-[DOMDocument createCDATASection:]): Ditto.
+ (-[DOMDocument createProcessingInstruction:data:]): Ditto.
+ (-[DOMDocument createAttribute:]): Ditto.
+ (-[DOMDocument createEntityReference:]): Ditto.
+ (-[DOMDocument importNode:deep:]): Ditto.
+ (-[DOMDocument createElementNS:qualifiedName:]): Ditto.
+ (-[DOMDocument createAttributeNS:qualifiedName:]): Ditto.
+ (-[DOMDocument getElementsByTagNameNS:localName:]): Ditto.
+ (-[DOMDocument adoptNode:]): Ditto.
+ (-[DOMDocument createEvent:]): Ditto.
+
2016-10-30 Darin Adler <[email protected]>
Move Element, NamedNodeMap, and DOMStringMap from ExceptionCode to Exception
Modified: trunk/Source/WebKit/mac/DOM/DOMDocument.mm (208143 => 208144)
--- trunk/Source/WebKit/mac/DOM/DOMDocument.mm 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit/mac/DOM/DOMDocument.mm 2016-10-31 15:49:34 UTC (rev 208144)
@@ -132,9 +132,7 @@
- (void)setXmlVersion:(NSString *)newXmlVersion
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- IMPL->setXMLVersion(newXmlVersion, ec);
- raiseOnDOMError(ec);
+ raiseOnDOMError(IMPL->setXMLVersion(newXmlVersion));
}
- (BOOL)xmlStandalone
@@ -224,18 +222,13 @@
- (NSString *)cookie
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- NSString *result = IMPL->cookie(ec);
- raiseOnDOMError(ec);
- return result;
+ return raiseOnDOMError(IMPL->cookie());
}
- (void)setCookie:(NSString *)newCookie
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- IMPL->setCookie(newCookie, ec);
- raiseOnDOMError(ec);
+ raiseOnDOMError(IMPL->setCookie(newCookie));
}
- (DOMHTMLElement *)body
@@ -247,11 +240,7 @@
- (void)setBody:(DOMHTMLElement *)newBody
{
WebCore::JSMainThreadNullState state;
- ASSERT(newBody);
-
- WebCore::ExceptionCode ec = 0;
- IMPL->setBodyOrFrameset(core(newBody), ec);
- raiseOnDOMError(ec);
+ raiseOnDOMError(IMPL->setBodyOrFrameset(core(newBody)));
}
- (DOMHTMLHeadElement *)head
@@ -356,6 +345,7 @@
}
#if ENABLE(FULLSCREEN_API)
+
- (BOOL)webkitIsFullScreen
{
WebCore::JSMainThreadNullState state;
@@ -385,14 +375,17 @@
WebCore::JSMainThreadNullState state;
return kit(WTF::getPtr(IMPL->webkitFullscreenElement()));
}
+
#endif
#if ENABLE(POINTER_LOCK)
+
- (DOMElement *)pointerLockElement
{
WebCore::JSMainThreadNullState state;
return kit(WTF::getPtr(IMPL->pointerLockElement()));
}
+
#endif
- (NSString *)visibilityState
@@ -452,10 +445,7 @@
- (DOMElement *)createElement:(NSString *)tagName
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMElement *result = kit(WTF::getPtr(IMPL->createElementForBindings(tagName, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createElementForBindings(tagName)).ptr());
}
- (DOMDocumentFragment *)createDocumentFragment
@@ -479,36 +469,25 @@
- (DOMCDATASection *)createCDATASection:(NSString *)data
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMCDATASection *result = kit(WTF::getPtr(IMPL->createCDATASection(data, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createCDATASection(data)).ptr());
}
- (DOMProcessingInstruction *)createProcessingInstruction:(NSString *)target data:(NSString *)data
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMProcessingInstruction *result = kit(WTF::getPtr(IMPL->createProcessingInstruction(target, data, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createProcessingInstruction(target, data)).ptr());
}
- (DOMAttr *)createAttribute:(NSString *)name
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMAttr *result = kit(WTF::getPtr(IMPL->createAttribute(name, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createAttribute(name)).ptr());
}
- (DOMEntityReference *)createEntityReference:(NSString *)name
{
UNUSED_PARAM(name);
-
- raiseOnDOMError(WebCore::NOT_SUPPORTED_ERR);
- return nil;
+ raiseDOMException(WebCore::NOT_SUPPORTED_ERR);
}
- (DOMNodeList *)getElementsByTagName:(NSString *)tagname
@@ -525,28 +504,19 @@
WebCore::JSMainThreadNullState state;
if (!importedNode)
raiseTypeErrorException();
- WebCore::ExceptionCode ec = 0;
- DOMNode *result = kit(WTF::getPtr(IMPL->importNode(*core(importedNode), deep, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->importNode(*core(importedNode), deep)).ptr());
}
- (DOMElement *)createElementNS:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMElement *result = kit(WTF::getPtr(IMPL->createElementNS(namespaceURI, qualifiedName, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createElementNS(namespaceURI, qualifiedName)).ptr());
}
- (DOMAttr *)createAttributeNS:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMAttr *result = kit(WTF::getPtr(IMPL->createAttributeNS(namespaceURI, qualifiedName, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createAttributeNS(namespaceURI, qualifiedName)).ptr());
}
- (DOMNodeList *)getElementsByTagNameNS:(NSString *)namespaceURI localName:(NSString *)localName
@@ -553,7 +523,6 @@
{
if (!localName)
return nullptr;
-
WebCore::JSMainThreadNullState state;
return kit(static_cast<WebCore::NodeList*>(WTF::getPtr(IMPL->getElementsByTagNameNS(namespaceURI, localName))));
}
@@ -563,19 +532,13 @@
WebCore::JSMainThreadNullState state;
if (!source)
raiseTypeErrorException();
- WebCore::ExceptionCode ec = 0;
- DOMNode *result = kit(WTF::getPtr(IMPL->adoptNode(*core(source), ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->adoptNode(*core(source))).ptr());
}
- (DOMEvent *)createEvent:(NSString *)eventType
{
WebCore::JSMainThreadNullState state;
- WebCore::ExceptionCode ec = 0;
- DOMEvent *result = kit(WTF::getPtr(IMPL->createEvent(eventType, ec)));
- raiseOnDOMError(ec);
- return result;
+ return kit(raiseOnDOMError(IMPL->createEvent(eventType)).ptr());
}
- (DOMRange *)createRange
Modified: trunk/Source/WebKit/win/ChangeLog (208143 => 208144)
--- trunk/Source/WebKit/win/ChangeLog 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit/win/ChangeLog 2016-10-31 15:49:34 UTC (rev 208144)
@@ -1,3 +1,14 @@
+2016-10-31 Darin Adler <[email protected]>
+
+ Convert Document from ExceptionCode to Exception
+ https://bugs.webkit.org/show_bug.cgi?id=164212
+
+ Reviewed by Alex Christensen.
+
+ * DOMCoreClasses.cpp:
+ (DOMDocument::createElement): Updated exception handling.
+ (DOMDocument::createEvent): Ditto.
+
2016-10-30 Darin Adler <[email protected]>
Move Element, NamedNodeMap, and DOMStringMap from ExceptionCode to Exception
Modified: trunk/Source/WebKit/win/DOMCoreClasses.cpp (208143 => 208144)
--- trunk/Source/WebKit/win/DOMCoreClasses.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit/win/DOMCoreClasses.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -639,9 +639,11 @@
return E_FAIL;
String tagNameString(tagName);
- ExceptionCode ec;
- *result = DOMElement::createInstance(m_document->createElementForBindings(tagNameString, ec).get());
- return *result ? S_OK : E_FAIL;
+ auto createElementResult = m_document->createElementForBindings(tagNameString);
+ if (createElementResult.hasException())
+ return E_FAIL;
+ *result = DOMElement::createInstance(createElementResult.releaseReturnValue().ptr());
+ return S_OK;
}
HRESULT DOMDocument::createDocumentFragment(_COM_Outptr_opt_ IDOMDocumentFragment** result)
@@ -818,8 +820,11 @@
String eventTypeString(eventType, SysStringLen(eventType));
WebCore::ExceptionCode ec = 0;
- *result = DOMEvent::createInstance(m_document->createEvent(eventTypeString, ec));
- return *result ? S_OK : E_FAIL;
+ auto createEventResult = m_document->createEvent(eventTypeString);
+ if (createEventResult.hasException())
+ return E_FAIL;
+ *result = DOMEvent::createInstance(createEventResult.releaseReturnValue());
+ return S_OK;
}
// DOMDocument - DOMDocument --------------------------------------------------
Modified: trunk/Source/WebKit2/ChangeLog (208143 => 208144)
--- trunk/Source/WebKit2/ChangeLog 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-31 15:49:34 UTC (rev 208144)
@@ -1,3 +1,27 @@
+2016-10-31 Darin Adler <[email protected]>
+
+ Convert Document from ExceptionCode to Exception
+ https://bugs.webkit.org/show_bug.cgi?id=164212
+
+ Reviewed by Alex Christensen.
+
+ * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp:
+ (webkit_dom_document_create_element): Updated exception handling.
+ (webkit_dom_document_create_cdata_section): Ditto.
+ (webkit_dom_document_create_processing_instruction): Ditto.
+ (webkit_dom_document_create_attribute): Ditto.
+ (webkit_dom_document_import_node): Ditto.
+ (webkit_dom_document_create_element_ns): Ditto.
+ (webkit_dom_document_create_attribute_ns): Ditto.
+ (webkit_dom_document_adopt_node): Ditto.
+ (webkit_dom_document_create_event): Ditto.
+ (webkit_dom_document_set_xml_version): Ditto.
+ (webkit_dom_document_get_cookie): Ditto.
+ (webkit_dom_document_set_cookie): Ditto.
+ (webkit_dom_document_set_body): Ditto.
+ * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm:
+ (-[WKDOMDocument createElement:]): Ditto.
+
2016-10-31 Wenson Hsieh <[email protected]>
Holding down a key to choose an accented character should fire "insertReplacementText" input events
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp (208143 => 208144)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp 2016-10-31 15:49:34 UTC (rev 208144)
@@ -906,13 +906,13 @@
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
WTF::String convertedTagName = WTF::String::fromUTF8(tagName);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->createElementForBindings(convertedTagName, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createElementForBindings(convertedTagName);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMDocumentFragment* webkit_dom_document_create_document_fragment(WebKitDOMDocument* self)
@@ -954,13 +954,13 @@
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
WTF::String convertedData = WTF::String::fromUTF8(data);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::CDATASection> gobjectResult = WTF::getPtr(item->createCDATASection(convertedData, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createCDATASection(convertedData);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMProcessingInstruction* webkit_dom_document_create_processing_instruction(WebKitDOMDocument* self, const gchar* target, const gchar* data, GError** error)
@@ -973,13 +973,13 @@
WebCore::Document* item = WebKit::core(self);
WTF::String convertedTarget = WTF::String::fromUTF8(target);
WTF::String convertedData = WTF::String::fromUTF8(data);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::ProcessingInstruction> gobjectResult = WTF::getPtr(item->createProcessingInstruction(convertedTarget, convertedData, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createProcessingInstruction(convertedTarget, convertedData);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMAttr* webkit_dom_document_create_attribute(WebKitDOMDocument* self, const gchar* name, GError** error)
@@ -990,13 +990,13 @@
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
WTF::String convertedName = WTF::String::fromUTF8(name);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Attr> gobjectResult = WTF::getPtr(item->createAttribute(convertedName, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createAttribute(convertedName);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMHTMLCollection* webkit_dom_document_get_elements_by_tag_name_as_html_collection(WebKitDOMDocument* self, const gchar* tagname)
@@ -1018,13 +1018,13 @@
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
WebCore::Node* convertedImportedNode = WebKit::core(importedNode);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->importNode(*convertedImportedNode, deep, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->importNode(*convertedImportedNode, deep);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMElement* webkit_dom_document_create_element_ns(WebKitDOMDocument* self, const gchar* namespaceURI, const gchar* qualifiedName, GError** error)
@@ -1036,13 +1036,13 @@
WebCore::Document* item = WebKit::core(self);
WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->createElementNS(convertedNamespaceURI, convertedQualifiedName, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createElementNS(convertedNamespaceURI, convertedQualifiedName);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMAttr* webkit_dom_document_create_attribute_ns(WebKitDOMDocument* self, const gchar* namespaceURI, const gchar* qualifiedName, GError** error)
@@ -1054,13 +1054,13 @@
WebCore::Document* item = WebKit::core(self);
WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Attr> gobjectResult = WTF::getPtr(item->createAttributeNS(convertedNamespaceURI, convertedQualifiedName, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createAttributeNS(convertedNamespaceURI, convertedQualifiedName);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMHTMLCollection* webkit_dom_document_get_elements_by_tag_name_ns_as_html_collection(WebKitDOMDocument* self, const gchar* namespaceURI, const gchar* localName)
@@ -1084,13 +1084,13 @@
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
WebCore::Node* convertedSource = WebKit::core(source);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->adoptNode(*convertedSource, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->adoptNode(*convertedSource);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMEvent* webkit_dom_document_create_event(WebKitDOMDocument* self, const gchar* eventType, GError** error)
@@ -1101,13 +1101,13 @@
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
WTF::String convertedEventType = WTF::String::fromUTF8(eventType);
- WebCore::ExceptionCode ec = 0;
- RefPtr<WebCore::Event> gobjectResult = WTF::getPtr(item->createEvent(convertedEventType, ec));
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->createEvent(convertedEventType);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ return nullptr;
}
- return WebKit::kit(gobjectResult.get());
+ return WebKit::kit(result.releaseReturnValue().ptr());
}
WebKitDOMRange* webkit_dom_document_create_range(WebKitDOMDocument* self)
@@ -1474,10 +1474,9 @@
g_return_if_fail(!error || !*error);
WebCore::Document* item = WebKit::core(self);
WTF::String convertedValue = WTF::String::fromUTF8(value);
- WebCore::ExceptionCode ec = 0;
- item->setXMLVersion(convertedValue, ec);
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->setXMLVersion(convertedValue);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
}
}
@@ -1635,9 +1634,10 @@
g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
g_return_val_if_fail(!error || !*error, 0);
WebCore::Document* item = WebKit::core(self);
- WebCore::ExceptionCode ec = 0;
- gchar* result = convertToUTF8String(item->cookie(ec));
- return result;
+ auto result = item->cookie();
+ if (result.hasException())
+ return nullptr;
+ return convertToUTF8String(result.releaseReturnValue());
}
void webkit_dom_document_set_cookie(WebKitDOMDocument* self, const gchar* value, GError** error)
@@ -1648,10 +1648,9 @@
g_return_if_fail(!error || !*error);
WebCore::Document* item = WebKit::core(self);
WTF::String convertedValue = WTF::String::fromUTF8(value);
- WebCore::ExceptionCode ec = 0;
- item->setCookie(convertedValue, ec);
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->setCookie(convertedValue);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
}
}
@@ -1673,10 +1672,9 @@
g_return_if_fail(!error || !*error);
WebCore::Document* item = WebKit::core(self);
WebCore::HTMLElement* convertedValue = WebKit::core(value);
- WebCore::ExceptionCode ec = 0;
- item->setBodyOrFrameset(convertedValue, ec);
- if (ec) {
- WebCore::ExceptionCodeDescription ecdesc(ec);
+ auto result = item->setBodyOrFrameset(convertedValue);
+ if (result.hasException()) {
+ WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
}
}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm (208143 => 208144)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm 2016-10-31 15:12:00 UTC (rev 208143)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm 2016-10-31 15:49:34 UTC (rev 208144)
@@ -38,8 +38,10 @@
- (WKDOMElement *)createElement:(NSString *)tagName
{
// FIXME: Do something about the exception.
- WebCore::ExceptionCode ec = 0;
- return WebKit::toWKDOMElement(downcast<WebCore::Document>(*_impl).createElementForBindings(tagName, ec).get());
+ auto result = downcast<WebCore::Document>(*_impl).createElementForBindings(tagName);
+ if (result.hasException())
+ return nil;
+ return WebKit::toWKDOMElement(result.releaseReturnValue().ptr());
}
- (WKDOMText *)createTextNode:(NSString *)data