Move Node from ExceptionCode to ExceptionOr
https://bugs.webkit.org/show_bug.cgi?id=164515

Reviewed by Sam Weinig.

Source/WebCore:

* bindings/js/JSHTMLSelectElementCustom.cpp:
(WebCore::selectElementIndexSetter): Call remove instead of removeByIndex.
Was renamed now that there is no conflict.

* bindings/js/JSNodeCustom.cpp:
(WebCore::JSNode::insertBefore): Use ExceptionOr.
(WebCore::JSNode::replaceChild): Ditto.
(WebCore::JSNode::removeChild): Ditto.
(WebCore::JSNode::appendChild): Ditto.

* dom/Attr.cpp:
(WebCore::Attr::Attr): Take a reference.
(WebCore::Attr::create): Ditto.
(WebCore::Attr::createTextChild): Use a Ref.
(WebCore::Attr::setPrefix): Use ExceptionOr.
(WebCore::Attr::setNodeValue): Ditto.
(WebCore::Attr::attachToElement): Take a reference.
* dom/Attr.h: Updated for above. Also made setPrefix private.

* dom/CharacterData.cpp:
(WebCore::CharacterData::setNodeValue): Use ExceptionOr.
* dom/CharacterData.h: Updated for the above.

* dom/ContainerNode.cpp:
(WebCore::collectChildrenAndRemoveFromOldParent): Use ExceptionOr.
(WebCore::checkAcceptChild): Ditto.
(WebCore::checkAcceptChildGuaranteedNodeTypes): Ditto.
(WebCore::ContainerNode::ensurePreInsertionValidity): Ditto.
(WebCore::checkPreReplacementValidity): Ditto.
(WebCore::ContainerNode::insertBefore): Ditto.
(WebCore::ContainerNode::replaceChild): Ditto.
(WebCore::ContainerNode::removeChild): Ditto.
(WebCore::ContainerNode::appendChild): Ditto.
(WebCore::ContainerNode::appendChildWithoutPreInsertionValidityCheck): Ditto.
(WebCore::ContainerNode::cloneChildNodes): Ditto.
(WebCore::ContainerNode::append): Ditto.
(WebCore::ContainerNode::prepend): Ditto.
* dom/ContainerNode.h: Updated for above changes.

* dom/Document.cpp:
(WebCore::Document::setTitle): Removed unneeded ASSERT_NO_EXCEPTION.
(WebCore::Document::setBodyOrFrameset): Removed unneeded ignored
exception code.

* dom/Element.cpp:
(WebCore::Element::setPrefix): Use ExceptionOr.
(WebCore::Element::setAttributeNode): Updated for changes to Attr.
(WebCore::Element::setAttributeNodeNS): Ditto.
(WebCore::Element::setOuterHTML): Use ExceptionOr.
(WebCore::Element::ensureAttr): Updated for changes to Attr.
(WebCore::Element::insertAdjacent): Use ExceptionOr.
* dom/Element.h: Updated for above.

* dom/Node.cpp:
(WebCore::Node::setNodeValue): Use ExceptionOr.
(WebCore::Node::insertBefore): Ditto.
(WebCore::Node::replaceChild): Ditto.
(WebCore::Node::removeChild): Ditto.
(WebCore::Node::appendChild): Ditto.
(WebCore::Node::convertNodesOrStringsIntoNode): Ditto.
(WebCore::Node::before): Ditto.
(WebCore::Node::after): Ditto.
(WebCore::Node::replaceWith): Ditto.
(WebCore::Node::remove): Ditto.
(WebCore::Node::cloneNodeForBindings): Ditto.
(WebCore::Node::setPrefix): Ditto.
(WebCore::Node::checkSetPrefix): Ditto.
(WebCore::Node::setTextContent): Ditto.
* dom/Node.h: Updated for above.
* dom/Node.idl: Use non-legacy exceptions.

* dom/Range.cpp:
(WebCore::Range::processContents): Use ExceptionOr.
(WebCore::processContentsBetweenOffsets): Ditto.
(WebCore::processNodes): Ditto.
(WebCore::processAncestorsAndTheirSiblings): Ditto.
(WebCore::Range::insertNode): Ditto.
(WebCore::Range::surroundContents): Ditto.

* dom/Text.cpp:
(WebCore::Text::splitText): Use ExceptionOr.
(WebCore::Text::replaceWholeText): Removed unneeded IGNORE_EXCEPTION.

* editing/AppendNodeCommand.cpp:
(WebCore::AppendNodeCommand::doApply): Removed unneeded IGNORE_EXCEPTION.
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::insertNewDefaultParagraphElementAt): Ditto.

* editing/EditorCommand.cpp:
(WebCore::executeInsertNode): Use ExceptionOr.

* editing/InsertNodeBeforeCommand.cpp:
(WebCore::InsertNodeBeforeCommand::doApply): Removed unneeded IGNORE_EXCEPTION.
* editing/MergeIdenticalElementsCommand.cpp:
(WebCore::MergeIdenticalElementsCommand::doApply): Ditto.
(WebCore::MergeIdenticalElementsCommand::doUnapply): Use ExceptionOr.

* editing/RemoveNodeCommand.cpp:
(WebCore::RemoveNodeCommand::doUnapply): Removed unneeded IGNORE_EXCEPTION.
* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::swapInNodePreservingAttributesAndChildren): Removed unneeded
ASSERT_NO_EXCEPTION.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplacementFragment::removeNode): Ditto.
(WebCore::ReplacementFragment::insertNodeBefore): Ditto.
(WebCore::ReplacementFragment::insertFragmentForTestRendering): Ditto.
(WebCore::ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment): Ditto.
(WebCore::ReplaceSelectionCommand::insertAsListItems): Ditto.

* editing/SplitElementCommand.cpp:
(WebCore::SplitElementCommand::executeApply): Use ExceptionOr.
(WebCore::SplitElementCommand::doUnapply): Removed unneeded IGNORE_EXCEPTION.

* editing/SplitTextNodeCommand.cpp:
(WebCore::SplitTextNodeCommand::insertText1AndTrimText2): Use ExceptionOr.

* editing/WrapContentsInDummySpanCommand.cpp:
(WebCore::WrapContentsInDummySpanCommand::executeApply): Removed unneeded
IGNORE_EXCEPTION.
(WebCore::WrapContentsInDummySpanCommand::doUnapply): Ditto.

* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::styleForSelectionStart): Removed unneeded ASSERT_NO_EXCEPTION
and IGNORE_EXCEPTION.
* editing/htmlediting.cpp:
(WebCore::createTabSpanElement): Ditto.
* editing/markup.cpp:
(WebCore::fillContainerFromString): Ditto.
(WebCore::createFragmentFromText): Ditto.
(WebCore::removeElementFromFragmentPreservingChildren): Ditto.
(WebCore::replaceChildrenWithFragment): Use ExceptionOr.
(WebCore::replaceChildrenWithText): Ditto.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::WebContentReader::addFragment): Removed unneeded exception
ignoring code.
(WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto.
(WebCore::Editor::setTextAsChildOfElement): Ditto.

* html/ColorInputType.cpp:
(WebCore::ColorInputType::createShadowSubtree): Removed unneeded
ASSERT_NO_EXCEPTION.

* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::appendEntry): Removed unneeded
IGNORE_EXCEPTION.
(WebCore::FTPDirectoryDocumentParser::createTDForFilename): Ditto.
(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate): Ditto.
(WebCore::FTPDirectoryDocumentParser::createBasicDocument): Ditto.
* html/FileInputType.cpp:
(WebCore::FileInputType::createShadowSubtree): Ditto.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::setText): Removed unneeded ASSERT_NO_EXCEPTION.
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::didAddUserAgentShadowRoot): Ditto.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::textToFragment): Use ExceptionOr.
(WebCore::HTMLElement::setOuterText): Ditto.

* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::HTMLKeygenElement): Removed unneeded
ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::createMediaControls): Ditto.
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::didAddUserAgentShadowRoot): Ditto.
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::createForJSConstructor): Use ExceptionOr.
(WebCore::HTMLOptionElement::setText): Removed unneeded
ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.

* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::remove): Call remove, not removeByIndex,
since we were able to change the name.

* html/HTMLOutputElement.cpp:
(WebCore::HTMLOutputElement::setTextContentInternal): Removed unneeded
ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::didAddUserAgentShadowRoot): Ditto.
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::setText): Ditto.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::add): Use ExceptionOr.
(WebCore::HTMLSelectElement::remove): Renamed from removeByIndex since
there is no conflict with remove any more.
(WebCore::HTMLSelectElement::setOption): Call remove.
* html/HTMLSelectElement.h: Updated for above.
* html/HTMLSelectElement.idl: Got rid of ImplementedAs=removeByIndex.

* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::didAddUserAgentShadowRoot): Removed unneeded
ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::HTMLTableElement): Initialize data members in
class definition instead of here.
(WebCore::HTMLTableElement::caption): Simplified using childrenOfType.
(WebCore::HTMLTableElement::setCaption): Use ExceptionOr.
(WebCore::HTMLTableElement::setTHead): Ditto.
(WebCore::HTMLTableElement::setTFoot): Ditto.
(WebCore::HTMLTableElement::deleteTFoot): Removed unneeded ASSERT_NO_EXCEPTION
and IGNORE_EXCEPTION.
(WebCore::HTMLTableElement::createTBody): Ditto.
(WebCore::HTMLTableElement::deleteCaption): Ditto.
(WebCore::HTMLTableElement::insertRow): Use ExceptionOr.
* html/HTMLTableElement.h: Updated for above.

* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::insertCell): Use ExceptionOr.
(WebCore::HTMLTableRowElement::deleteCell): Ditto.
* html/HTMLTableSectionElement.cpp:
(WebCore::HTMLTableSectionElement::insertRow): Ditto.
(WebCore::HTMLTableSectionElement::deleteRow): Ditto.

* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::didAddUserAgentShadowRoot): Removed unneeded
ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
(WebCore::HTMLTextAreaElement::setDefaultValue): Ditto.
(WebCore::HTMLTextAreaElement::updatePlaceholderText): Ditto.
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setInnerTextValue): Ditto.
* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::setText): Ditto.
* html/MediaDocument.cpp:
(WebCore::MediaDocumentParser::createDocumentStructure): Ditto.
(WebCore::MediaDocument::replaceMediaElementTimerFired): Ditto.
* html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure): Ditto.
* html/RangeInputType.cpp:
(WebCore::RangeInputType::createShadowSubtree): Ditto.
* html/SearchInputType.cpp:
(WebCore::SearchInputType::createShadowSubtree): Ditto.
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::createShadowSubtree): Ditto.
(WebCore::TextFieldInputType::updatePlaceholderText): Ditto.
(WebCore::TextFieldInputType::createContainer): Ditto.
(WebCore::TextFieldInputType::createAutoFillButton): Ditto.
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::setMessageDOMAndStartTimer): Ditto.
(WebCore::ValidationMessage::buildBubbleTree): Ditto.
(WebCore::ValidationMessage::deleteBubbleTree): Ditto.
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Ditto.
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::createTextTrackDisplay): Ditto.

* html/shadow/MediaControlsApple.cpp:
(WebCore::MediaControlsApple::MediaControlsApple): Initialize data members
in class definition instead of here.
(WebCore::MediaControlsApple::tryCreateControls): Use ExceptionOr.
* html/shadow/MediaControlsApple.h: Updated for above.

* html/track/VTTCue.cpp:
(WebCore::VTTCue::copyWebVTTNodeToDOMTree): Removed unneeded ASSERT_NO_EXCEPTION
and IGNORE_EXCEPTION.
(WebCore::VTTCue::getDisplayTree): Ditto.
* html/track/VTTRegion.cpp:
(WebCore::VTTRegion::appendTextTrackCueBox): Ditto.

* inspector/DOMEditor.cpp: Use ExceptionOr in action classes.
(WebCore::DOMEditor::DOMEditor): Take a reference.
(WebCore::DOMEditor::insertBefore): Use ExceptionOr.
(WebCore::DOMEditor::removeChild): Ditto.
(WebCore::DOMEditor::setAttribute): Ditto.
(WebCore::DOMEditor::removeAttribute): Ditto.
(WebCore::DOMEditor::setOuterHTML): Ditto.
(WebCore::DOMEditor::replaceWholeText): Ditto.
(WebCore::DOMEditor::replaceChild): Ditto.
(WebCore::DOMEditor::setNodeValue): Ditto.
(WebCore::populateErrorString): Ditto.
* inspector/DOMEditor.h: Updated for above changes.

* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::patchDocument): Updated to use references,
to use ExceptionOr, and to use a struct without a constructor for Digest.
(WebCore::DOMPatchSupport::DOMPatchSupport): Ditto.
(WebCore::DOMPatchSupport::patchNode): Ditto.
(WebCore::DOMPatchSupport::innerPatchNode): Ditto.
(WebCore::DOMPatchSupport::diff): Ditto.
(WebCore::DOMPatchSupport::innerPatchChildren): Ditto.
(WebCore::DOMPatchSupport::createDigest): Ditto.
(WebCore::DOMPatchSupport::insertBeforeAndMarkAsUsed): Ditto.
(WebCore::DOMPatchSupport::removeChildAndMoveToNew): Ditto.
(WebCore::DOMPatchSupport::markNodeAsUsed): Ditto.
* inspector/DOMPatchSupport.h: Updated for above.

* inspector/InspectorCSSAgent.cpp: Use ExceptionOr in the action classes.
(WebCore::InspectorCSSAgent::getStyleSheetText): Use ExceptionOr.
(WebCore::InspectorCSSAgent::setStyleSheetText): Ditto.
(WebCore::InspectorCSSAgent::setStyleText): Ditto.
(WebCore::InspectorCSSAgent::setRuleSelector): Ditto.
(WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): Ditto.
(WebCore::InspectorCSSAgent::addRule): Ditto.
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::didCreateFrontendAndBackend): Ditto.
(WebCore::InspectorDOMAgent::setAttributeValue): Ditto.
(WebCore::InspectorDOMAgent::setAttributesAsText): Ditto.
(WebCore::InspectorDOMAgent::removeAttribute): Ditto.
(WebCore::InspectorDOMAgent::setOuterHTML): Ditto.
(WebCore::InspectorDOMAgent::setNodeValue): Ditto.
(WebCore::InspectorDOMAgent::undo): Ditto.
(WebCore::InspectorDOMAgent::redo): Ditto.

* inspector/InspectorHistory.cpp:
(WebCore::InspectorHistory::Action::Action): Moved to header.
(WebCore::InspectorHistory::Action::~Action): Ditto.
(WebCore::InspectorHistory::Action::toString): Ditto.
(WebCore::InspectorHistory::Action::isUndoableStateMark): Ditto.
(WebCore::InspectorHistory::Action::mergeId): Ditto.
(WebCore::InspectorHistory::Action::merge): Ditto.
(WebCore::InspectorHistory::InspectorHistory): Deleted.
(WebCore::InspectorHistory::~InspectorHistory): Deleted.
(WebCore::InspectorHistory::perform): Updated exception handling.
(WebCore::InspectorHistory::markUndoableState): Ditto.
(WebCore::InspectorHistory::undo): Ditto.
(WebCore::InspectorHistory::redo): Ditto.
* inspector/InspectorHistory.h: Updated for above.

* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::setDocumentContent): Use reference.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::text): Use ExceptionOr and renamed from
getText since this now has a return value.
(WebCore::InspectorStyle::populateAllProperties): Updated for above.
(WebCore::InspectorStyle::setText): Use ExceptionOr.
(WebCore::InspectorStyleSheet::setText): Ditto.
(WebCore::InspectorStyleSheet::ruleSelector): Ditto.
(WebCore::InspectorStyleSheet::setRuleSelector): Ditto.
(WebCore::InspectorStyleSheet::addRule): Ditto.
(WebCore::InspectorStyleSheet::deleteRule): Ditto.
(WebCore::InspectorStyleSheet::buildObjectForStyleSheet): Ditto.
(WebCore::InspectorStyleSheet::buildObjectForStyle): Ditto.
(WebCore::InspectorStyleSheet::setStyleText): Ditto.
(WebCore::InspectorStyleSheet::text): Use ExceptionOr and renamed.
(WebCore::InspectorStyleSheet::checkPageStyleSheet): Deleted.
Just wrote this code inline in each place this was called since it's
just a single null check.
(WebCore::InspectorStyleSheetForInlineStyle::text): Use ExceptionOr
and renamed.
(WebCore::InspectorStyleSheetForInlineStyle::setStyleText): Ditto.
(WebCore::InspectorStyle::getText): Deleted.
* inspector/InspectorStyleSheet.h: Updated for above changes.

* page/DragController.cpp:
(WebCore::documentFragmentFromDragData): Removed unneeded
ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
* page/ios/FrameIOS.mm:
(WebCore::Frame::initWithSimpleHTMLDocument): Ditto.
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::updateReferencedText): Ditto.
(WebCore::SVGTRefElement::detachTarget): Ditto.
* xml/XMLTreeViewer.cpp:
(WebCore::XMLTreeViewer::transformDocumentToTreeView): Ditto.

Source/WebKit/mac:

* DOM/DOMHTMLSelectElement.mm:
(-[DOMHTMLSelectElement remove:]): Call remove instead of removeByIndex
now that it was renamed.
* DOM/DOMNode.mm:
(-[DOMNode setNodeValue:]): Updated exception handling.
(-[DOMNode setPrefix:]): Ditto.
(-[DOMNode setTextContent:]): Ditto.
(-[DOMNode insertBefore:refChild:]): Ditto.
(-[DOMNode replaceChild:oldChild:]): Ditto.
(-[DOMNode removeChild:]): Ditto.
(-[DOMNode appendChild:]): Ditto.
(-[DOMNode cloneNode:]): Ditto.

Source/WebKit/win:

* DOMCoreClasses.cpp:
(DOMNode::insertBefore): Update exception handling.
(DOMNode::removeChild): Ditto.

Source/WebKit2:

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp:
(webkit_dom_html_select_element_remove): Updated exception handling.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp:
(webkit_dom_node_insert_before): Ditto.
(webkit_dom_node_replace_child): Ditto.
(webkit_dom_node_remove_child): Ditto.
(webkit_dom_node_append_child): Ditto.
(webkit_dom_node_clone_node_with_error): Ditto.
(webkit_dom_node_set_node_value): Ditto.
(webkit_dom_node_set_text_content): Ditto.
* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
(-[WKDOMNode insertNode:before:]): Ditto.
(-[WKDOMNode appendChild:]): Ditto.
(-[WKDOMNode removeChild:]): Ditto.

* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
(WebKit::PDFPlugin::PDFPlugin): Removed unneeded ASSERT_NO_EXCEPTION.
* WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm:
(WebKit::PDFPluginChoiceAnnotation::createAnnotationElement): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@208603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 0894f24..9d62ac6 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,368 @@
+2016-11-11  Darin Adler  <darin@apple.com>
+
+        Move Node from ExceptionCode to ExceptionOr
+        https://bugs.webkit.org/show_bug.cgi?id=164515
+
+        Reviewed by Sam Weinig.
+
+        * bindings/js/JSHTMLSelectElementCustom.cpp:
+        (WebCore::selectElementIndexSetter): Call remove instead of removeByIndex.
+        Was renamed now that there is no conflict.
+
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::JSNode::insertBefore): Use ExceptionOr.
+        (WebCore::JSNode::replaceChild): Ditto.
+        (WebCore::JSNode::removeChild): Ditto.
+        (WebCore::JSNode::appendChild): Ditto.
+
+        * dom/Attr.cpp:
+        (WebCore::Attr::Attr): Take a reference.
+        (WebCore::Attr::create): Ditto.
+        (WebCore::Attr::createTextChild): Use a Ref.
+        (WebCore::Attr::setPrefix): Use ExceptionOr.
+        (WebCore::Attr::setNodeValue): Ditto.
+        (WebCore::Attr::attachToElement): Take a reference.
+        * dom/Attr.h: Updated for above. Also made setPrefix private.
+
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::setNodeValue): Use ExceptionOr.
+        * dom/CharacterData.h: Updated for the above.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::collectChildrenAndRemoveFromOldParent): Use ExceptionOr.
+        (WebCore::checkAcceptChild): Ditto.
+        (WebCore::checkAcceptChildGuaranteedNodeTypes): Ditto.
+        (WebCore::ContainerNode::ensurePreInsertionValidity): Ditto.
+        (WebCore::checkPreReplacementValidity): Ditto.
+        (WebCore::ContainerNode::insertBefore): Ditto.
+        (WebCore::ContainerNode::replaceChild): Ditto.
+        (WebCore::ContainerNode::removeChild): Ditto.
+        (WebCore::ContainerNode::appendChild): Ditto.
+        (WebCore::ContainerNode::appendChildWithoutPreInsertionValidityCheck): Ditto.
+        (WebCore::ContainerNode::cloneChildNodes): Ditto.
+        (WebCore::ContainerNode::append): Ditto.
+        (WebCore::ContainerNode::prepend): Ditto.
+        * dom/ContainerNode.h: Updated for above changes.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setTitle): Removed unneeded ASSERT_NO_EXCEPTION.
+        (WebCore::Document::setBodyOrFrameset): Removed unneeded ignored
+        exception code.
+
+        * dom/Element.cpp:
+        (WebCore::Element::setPrefix): Use ExceptionOr.
+        (WebCore::Element::setAttributeNode): Updated for changes to Attr.
+        (WebCore::Element::setAttributeNodeNS): Ditto.
+        (WebCore::Element::setOuterHTML): Use ExceptionOr.
+        (WebCore::Element::ensureAttr): Updated for changes to Attr.
+        (WebCore::Element::insertAdjacent): Use ExceptionOr.
+        * dom/Element.h: Updated for above.
+
+        * dom/Node.cpp:
+        (WebCore::Node::setNodeValue): Use ExceptionOr.
+        (WebCore::Node::insertBefore): Ditto.
+        (WebCore::Node::replaceChild): Ditto.
+        (WebCore::Node::removeChild): Ditto.
+        (WebCore::Node::appendChild): Ditto.
+        (WebCore::Node::convertNodesOrStringsIntoNode): Ditto.
+        (WebCore::Node::before): Ditto.
+        (WebCore::Node::after): Ditto.
+        (WebCore::Node::replaceWith): Ditto.
+        (WebCore::Node::remove): Ditto.
+        (WebCore::Node::cloneNodeForBindings): Ditto.
+        (WebCore::Node::setPrefix): Ditto.
+        (WebCore::Node::checkSetPrefix): Ditto.
+        (WebCore::Node::setTextContent): Ditto.
+        * dom/Node.h: Updated for above.
+        * dom/Node.idl: Use non-legacy exceptions.
+
+        * dom/Range.cpp:
+        (WebCore::Range::processContents): Use ExceptionOr.
+        (WebCore::processContentsBetweenOffsets): Ditto.
+        (WebCore::processNodes): Ditto.
+        (WebCore::processAncestorsAndTheirSiblings): Ditto.
+        (WebCore::Range::insertNode): Ditto.
+        (WebCore::Range::surroundContents): Ditto.
+
+        * dom/Text.cpp:
+        (WebCore::Text::splitText): Use ExceptionOr.
+        (WebCore::Text::replaceWholeText): Removed unneeded IGNORE_EXCEPTION.
+
+        * editing/AppendNodeCommand.cpp:
+        (WebCore::AppendNodeCommand::doApply): Removed unneeded IGNORE_EXCEPTION.
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::insertNewDefaultParagraphElementAt): Ditto.
+
+        * editing/EditorCommand.cpp:
+        (WebCore::executeInsertNode): Use ExceptionOr.
+
+        * editing/InsertNodeBeforeCommand.cpp:
+        (WebCore::InsertNodeBeforeCommand::doApply): Removed unneeded IGNORE_EXCEPTION.
+        * editing/MergeIdenticalElementsCommand.cpp:
+        (WebCore::MergeIdenticalElementsCommand::doApply): Ditto.
+        (WebCore::MergeIdenticalElementsCommand::doUnapply): Use ExceptionOr.
+
+        * editing/RemoveNodeCommand.cpp:
+        (WebCore::RemoveNodeCommand::doUnapply): Removed unneeded IGNORE_EXCEPTION.
+        * editing/ReplaceNodeWithSpanCommand.cpp:
+        (WebCore::swapInNodePreservingAttributesAndChildren): Removed unneeded
+        ASSERT_NO_EXCEPTION.
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::removeNode): Ditto.
+        (WebCore::ReplacementFragment::insertNodeBefore): Ditto.
+        (WebCore::ReplacementFragment::insertFragmentForTestRendering): Ditto.
+        (WebCore::ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment): Ditto.
+        (WebCore::ReplaceSelectionCommand::insertAsListItems): Ditto.
+
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::executeApply): Use ExceptionOr.
+        (WebCore::SplitElementCommand::doUnapply): Removed unneeded IGNORE_EXCEPTION.
+
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::insertText1AndTrimText2): Use ExceptionOr.
+
+        * editing/WrapContentsInDummySpanCommand.cpp:
+        (WebCore::WrapContentsInDummySpanCommand::executeApply): Removed unneeded
+        IGNORE_EXCEPTION.
+        (WebCore::WrapContentsInDummySpanCommand::doUnapply): Ditto.
+
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::Editor::styleForSelectionStart): Removed unneeded ASSERT_NO_EXCEPTION
+        and IGNORE_EXCEPTION.
+        * editing/htmlediting.cpp:
+        (WebCore::createTabSpanElement): Ditto.
+        * editing/markup.cpp:
+        (WebCore::fillContainerFromString): Ditto.
+        (WebCore::createFragmentFromText): Ditto.
+        (WebCore::removeElementFromFragmentPreservingChildren): Ditto.
+        (WebCore::replaceChildrenWithFragment): Use ExceptionOr.
+        (WebCore::replaceChildrenWithText): Ditto.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::WebContentReader::addFragment): Removed unneeded exception
+        ignoring code.
+        (WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto.
+        (WebCore::Editor::setTextAsChildOfElement): Ditto.
+
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::createShadowSubtree): Removed unneeded
+        ASSERT_NO_EXCEPTION.
+
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::appendEntry): Removed unneeded
+        IGNORE_EXCEPTION.
+        (WebCore::FTPDirectoryDocumentParser::createTDForFilename): Ditto.
+        (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate): Ditto.
+        (WebCore::FTPDirectoryDocumentParser::createBasicDocument): Ditto.
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::createShadowSubtree): Ditto.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::setText): Removed unneeded ASSERT_NO_EXCEPTION.
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::HTMLDetailsElement::didAddUserAgentShadowRoot): Ditto.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::textToFragment): Use ExceptionOr.
+        (WebCore::HTMLElement::setOuterText): Ditto.
+
+        * html/HTMLKeygenElement.cpp:
+        (WebCore::HTMLKeygenElement::HTMLKeygenElement): Removed unneeded
+        ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::createMediaControls): Ditto.
+        * html/HTMLMeterElement.cpp:
+        (WebCore::HTMLMeterElement::didAddUserAgentShadowRoot): Ditto.
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::createForJSConstructor): Use ExceptionOr.
+        (WebCore::HTMLOptionElement::setText): Removed unneeded
+        ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
+
+        * html/HTMLOptionsCollection.cpp:
+        (WebCore::HTMLOptionsCollection::remove): Call remove, not removeByIndex,
+        since we were able to change the name.
+
+        * html/HTMLOutputElement.cpp:
+        (WebCore::HTMLOutputElement::setTextContentInternal): Removed unneeded
+        ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::didAddUserAgentShadowRoot): Ditto.
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::setText): Ditto.
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::add): Use ExceptionOr.
+        (WebCore::HTMLSelectElement::remove): Renamed from removeByIndex since
+        there is no conflict with remove any more.
+        (WebCore::HTMLSelectElement::setOption): Call remove.
+        * html/HTMLSelectElement.h: Updated for above.
+        * html/HTMLSelectElement.idl: Got rid of ImplementedAs=removeByIndex.
+
+        * html/HTMLSummaryElement.cpp:
+        (WebCore::HTMLSummaryElement::didAddUserAgentShadowRoot): Removed unneeded
+        ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::HTMLTableElement): Initialize data members in
+        class definition instead of here.
+        (WebCore::HTMLTableElement::caption): Simplified using childrenOfType.
+        (WebCore::HTMLTableElement::setCaption): Use ExceptionOr.
+        (WebCore::HTMLTableElement::setTHead): Ditto.
+        (WebCore::HTMLTableElement::setTFoot): Ditto.
+        (WebCore::HTMLTableElement::deleteTFoot): Removed unneeded ASSERT_NO_EXCEPTION
+        and IGNORE_EXCEPTION.
+        (WebCore::HTMLTableElement::createTBody): Ditto.
+        (WebCore::HTMLTableElement::deleteCaption): Ditto.
+        (WebCore::HTMLTableElement::insertRow): Use ExceptionOr.
+        * html/HTMLTableElement.h: Updated for above.
+
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::HTMLTableRowElement::insertCell): Use ExceptionOr.
+        (WebCore::HTMLTableRowElement::deleteCell): Ditto.
+        * html/HTMLTableSectionElement.cpp:
+        (WebCore::HTMLTableSectionElement::insertRow): Ditto.
+        (WebCore::HTMLTableSectionElement::deleteRow): Ditto.
+
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::didAddUserAgentShadowRoot): Removed unneeded
+        ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
+        (WebCore::HTMLTextAreaElement::setDefaultValue): Ditto.
+        (WebCore::HTMLTextAreaElement::updatePlaceholderText): Ditto.
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setInnerTextValue): Ditto.
+        * html/HTMLTitleElement.cpp:
+        (WebCore::HTMLTitleElement::setText): Ditto.
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocumentParser::createDocumentStructure): Ditto.
+        (WebCore::MediaDocument::replaceMediaElementTimerFired): Ditto.
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocumentParser::createDocumentStructure): Ditto.
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::createShadowSubtree): Ditto.
+        * html/SearchInputType.cpp:
+        (WebCore::SearchInputType::createShadowSubtree): Ditto.
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::createShadowSubtree): Ditto.
+        (WebCore::TextFieldInputType::updatePlaceholderText): Ditto.
+        (WebCore::TextFieldInputType::createContainer): Ditto.
+        (WebCore::TextFieldInputType::createAutoFillButton): Ditto.
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::setMessageDOMAndStartTimer): Ditto.
+        (WebCore::ValidationMessage::buildBubbleTree): Ditto.
+        (WebCore::ValidationMessage::deleteBubbleTree): Ditto.
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Ditto.
+        * html/shadow/MediaControls.cpp:
+        (WebCore::MediaControls::createTextTrackDisplay): Ditto.
+
+        * html/shadow/MediaControlsApple.cpp:
+        (WebCore::MediaControlsApple::MediaControlsApple): Initialize data members
+        in class definition instead of here.
+        (WebCore::MediaControlsApple::tryCreateControls): Use ExceptionOr.
+        * html/shadow/MediaControlsApple.h: Updated for above.
+
+        * html/track/VTTCue.cpp:
+        (WebCore::VTTCue::copyWebVTTNodeToDOMTree): Removed unneeded ASSERT_NO_EXCEPTION
+        and IGNORE_EXCEPTION.
+        (WebCore::VTTCue::getDisplayTree): Ditto.
+        * html/track/VTTRegion.cpp:
+        (WebCore::VTTRegion::appendTextTrackCueBox): Ditto.
+
+        * inspector/DOMEditor.cpp: Use ExceptionOr in action classes.
+        (WebCore::DOMEditor::DOMEditor): Take a reference.
+        (WebCore::DOMEditor::insertBefore): Use ExceptionOr.
+        (WebCore::DOMEditor::removeChild): Ditto.
+        (WebCore::DOMEditor::setAttribute): Ditto.
+        (WebCore::DOMEditor::removeAttribute): Ditto.
+        (WebCore::DOMEditor::setOuterHTML): Ditto.
+        (WebCore::DOMEditor::replaceWholeText): Ditto.
+        (WebCore::DOMEditor::replaceChild): Ditto.
+        (WebCore::DOMEditor::setNodeValue): Ditto.
+        (WebCore::populateErrorString): Ditto.
+        * inspector/DOMEditor.h: Updated for above changes.
+
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::patchDocument): Updated to use references,
+        to use ExceptionOr, and to use a struct without a constructor for Digest.
+        (WebCore::DOMPatchSupport::DOMPatchSupport): Ditto.
+        (WebCore::DOMPatchSupport::patchNode): Ditto.
+        (WebCore::DOMPatchSupport::innerPatchNode): Ditto.
+        (WebCore::DOMPatchSupport::diff): Ditto.
+        (WebCore::DOMPatchSupport::innerPatchChildren): Ditto.
+        (WebCore::DOMPatchSupport::createDigest): Ditto.
+        (WebCore::DOMPatchSupport::insertBeforeAndMarkAsUsed): Ditto.
+        (WebCore::DOMPatchSupport::removeChildAndMoveToNew): Ditto.
+        (WebCore::DOMPatchSupport::markNodeAsUsed): Ditto.
+        * inspector/DOMPatchSupport.h: Updated for above.
+
+        * inspector/InspectorCSSAgent.cpp: Use ExceptionOr in the action classes.
+        (WebCore::InspectorCSSAgent::getStyleSheetText): Use ExceptionOr.
+        (WebCore::InspectorCSSAgent::setStyleSheetText): Ditto.
+        (WebCore::InspectorCSSAgent::setStyleText): Ditto.
+        (WebCore::InspectorCSSAgent::setRuleSelector): Ditto.
+        (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): Ditto.
+        (WebCore::InspectorCSSAgent::addRule): Ditto.
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::didCreateFrontendAndBackend): Ditto.
+        (WebCore::InspectorDOMAgent::setAttributeValue): Ditto.
+        (WebCore::InspectorDOMAgent::setAttributesAsText): Ditto.
+        (WebCore::InspectorDOMAgent::removeAttribute): Ditto.
+        (WebCore::InspectorDOMAgent::setOuterHTML): Ditto.
+        (WebCore::InspectorDOMAgent::setNodeValue): Ditto.
+        (WebCore::InspectorDOMAgent::undo): Ditto.
+        (WebCore::InspectorDOMAgent::redo): Ditto.
+
+        * inspector/InspectorHistory.cpp:
+        (WebCore::InspectorHistory::Action::Action): Moved to header.
+        (WebCore::InspectorHistory::Action::~Action): Ditto.
+        (WebCore::InspectorHistory::Action::toString): Ditto.
+        (WebCore::InspectorHistory::Action::isUndoableStateMark): Ditto.
+        (WebCore::InspectorHistory::Action::mergeId): Ditto.
+        (WebCore::InspectorHistory::Action::merge): Ditto.
+        (WebCore::InspectorHistory::InspectorHistory): Deleted.
+        (WebCore::InspectorHistory::~InspectorHistory): Deleted.
+        (WebCore::InspectorHistory::perform): Updated exception handling.
+        (WebCore::InspectorHistory::markUndoableState): Ditto.
+        (WebCore::InspectorHistory::undo): Ditto.
+        (WebCore::InspectorHistory::redo): Ditto.
+        * inspector/InspectorHistory.h: Updated for above.
+
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::setDocumentContent): Use reference.
+
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::text): Use ExceptionOr and renamed from
+        getText since this now has a return value.
+        (WebCore::InspectorStyle::populateAllProperties): Updated for above.
+        (WebCore::InspectorStyle::setText): Use ExceptionOr.
+        (WebCore::InspectorStyleSheet::setText): Ditto.
+        (WebCore::InspectorStyleSheet::ruleSelector): Ditto.
+        (WebCore::InspectorStyleSheet::setRuleSelector): Ditto.
+        (WebCore::InspectorStyleSheet::addRule): Ditto.
+        (WebCore::InspectorStyleSheet::deleteRule): Ditto.
+        (WebCore::InspectorStyleSheet::buildObjectForStyleSheet): Ditto.
+        (WebCore::InspectorStyleSheet::buildObjectForStyle): Ditto.
+        (WebCore::InspectorStyleSheet::setStyleText): Ditto.
+        (WebCore::InspectorStyleSheet::text): Use ExceptionOr and renamed.
+        (WebCore::InspectorStyleSheet::checkPageStyleSheet): Deleted.
+        Just wrote this code inline in each place this was called since it's
+        just a single null check.
+        (WebCore::InspectorStyleSheetForInlineStyle::text): Use ExceptionOr
+        and renamed.
+        (WebCore::InspectorStyleSheetForInlineStyle::setStyleText): Ditto.
+        (WebCore::InspectorStyle::getText): Deleted.
+        * inspector/InspectorStyleSheet.h: Updated for above changes.
+
+        * page/DragController.cpp:
+        (WebCore::documentFragmentFromDragData): Removed unneeded
+        ASSERT_NO_EXCEPTION and IGNORE_EXCEPTION.
+        * page/ios/FrameIOS.mm:
+        (WebCore::Frame::initWithSimpleHTMLDocument): Ditto.
+        * svg/SVGTRefElement.cpp:
+        (WebCore::SVGTRefElement::updateReferencedText): Ditto.
+        (WebCore::SVGTRefElement::detachTarget): Ditto.
+        * xml/XMLTreeViewer.cpp:
+        (WebCore::XMLTreeViewer::transformDocumentToTreeView): Ditto.
+
 2016-11-10  Jiewen Tan  <jiewen_tan@apple.com>
 
         Rename CryptoKeyUsage to CryptoKeyUsageBitmap and CryptoKey::Usage to CryptoKeyUsage
diff --git a/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
index 2040c8e..9b0b81b 100644
--- a/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
+++ b/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
@@ -40,7 +40,7 @@
     auto throwScope = DECLARE_THROW_SCOPE(vm);
 
     if (value.isUndefinedOrNull()) {
-        element.removeByIndex(index);
+        element.remove(index);
         return;
     }
 
diff --git a/Source/WebCore/bindings/js/JSNodeCustom.cpp b/Source/WebCore/bindings/js/JSNodeCustom.cpp
index c8319ea..ad0e973 100644
--- a/Source/WebCore/bindings/js/JSNodeCustom.cpp
+++ b/Source/WebCore/bindings/js/JSNodeCustom.cpp
@@ -123,13 +123,7 @@
     if (UNLIKELY(!newChild))
         return JSValue::decode(throwArgumentTypeError(state, scope, 0, "node", "Node", "insertBefore", "Node"));
 
-    ExceptionCode ec = 0;
-    if (UNLIKELY(!wrapped().insertBefore(*newChild, JSNode::toWrapped(state.uncheckedArgument(1)), ec))) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    ASSERT(!ec);
+    propagateException(state, scope, wrapped().insertBefore(*newChild, JSNode::toWrapped(state.uncheckedArgument(1))));
     return newChildValue;
 }
 
@@ -150,13 +144,7 @@
         return JSValue::decode(throwArgumentTypeError(state, scope, 1, "child", "Node", "replaceChild", "Node"));
     }
 
-    ExceptionCode ec = 0;
-    if (UNLIKELY(!wrapped().replaceChild(*newChild, *oldChild, ec))) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    ASSERT(!ec);
+    propagateException(state, scope, wrapped().replaceChild(*newChild, *oldChild));
     return oldChildValue;
 }
 
@@ -170,13 +158,7 @@
     if (UNLIKELY(!child))
         return JSValue::decode(throwArgumentTypeError(state, scope, 0, "child", "Node", "removeChild", "Node"));
 
-    ExceptionCode ec = 0;
-    if (UNLIKELY(!wrapped().removeChild(*child, ec))) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    ASSERT(!ec);
+    propagateException(state, scope, wrapped().removeChild(*child));
     return childValue;
 }
 
@@ -190,13 +172,7 @@
     if (UNLIKELY(!newChild))
         return JSValue::decode(throwArgumentTypeError(state, scope, 0, "node", "Node", "appendChild", "Node"));
 
-    ExceptionCode ec = 0;
-    if (UNLIKELY(!wrapped().appendChild(*newChild, ec))) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
-
-    ASSERT(!ec);
+    propagateException(state, scope, wrapped().appendChild(*newChild));
     return newChildValue;
 }
 
diff --git a/Source/WebCore/dom/Attr.cpp b/Source/WebCore/dom/Attr.cpp
index 405e6d3..5432dc2 100644
--- a/Source/WebCore/dom/Attr.cpp
+++ b/Source/WebCore/dom/Attr.cpp
@@ -38,9 +38,9 @@
 
 using namespace HTMLNames;
 
-Attr::Attr(Element* element, const QualifiedName& name)
-    : ContainerNode(element->document())
-    , m_element(element)
+Attr::Attr(Element& element, const QualifiedName& name)
+    : ContainerNode(element.document())
+    , m_element(&element)
     , m_name(name)
 {
 }
@@ -52,7 +52,7 @@
 {
 }
 
-Ref<Attr> Attr::create(Element* element, const QualifiedName& name)
+Ref<Attr> Attr::create(Element& element, const QualifiedName& name)
 {
     Ref<Attr> attr = adoptRef(*new Attr(element, name));
     attr->createTextChild();
@@ -74,34 +74,31 @@
 {
     ASSERT(refCount());
     if (!value().isEmpty()) {
-        RefPtr<Text> textNode = document().createTextNode(value().string());
+        auto textNode = document().createTextNode(value().string());
 
         // This does everything appendChild() would do in this situation (assuming m_ignoreChildrenChanged was set),
         // but much more efficiently.
         textNode->setParentNode(this);
-        setFirstChild(textNode.get());
-        setLastChild(textNode.get());
+        setFirstChild(textNode.ptr());
+        setLastChild(textNode.ptr());
     }
 }
 
-void Attr::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
+ExceptionOr<void> Attr::setPrefix(const AtomicString& prefix)
 {
-    ec = 0;
-    checkSetPrefix(prefix, ec);
-    if (ec)
-        return;
+    auto result = checkSetPrefix(prefix);
+    if (result.hasException())
+        return result.releaseException();
 
-    if ((prefix == xmlnsAtom && namespaceURI() != XMLNSNames::xmlnsNamespaceURI)
-        || static_cast<Attr*>(this)->qualifiedName() == xmlnsAtom) {
-        ec = NAMESPACE_ERR;
-        return;
-    }
+    if ((prefix == xmlnsAtom && namespaceURI() != XMLNSNames::xmlnsNamespaceURI) || qualifiedName() == xmlnsAtom)
+        return Exception { NAMESPACE_ERR };
 
     const AtomicString& newPrefix = prefix.isEmpty() ? nullAtom : prefix;
-
     if (m_element)
         elementAttribute().setPrefix(newPrefix);
     m_name.setPrefix(newPrefix);
+
+    return { };
 }
 
 void Attr::setValue(const AtomicString& value)
@@ -125,16 +122,15 @@
     AtomicString oldValue = this->value();
     if (m_element)
         m_element->willModifyAttribute(qualifiedName(), oldValue, value);
-
     setValue(value);
-
     if (m_element)
         m_element->didModifyAttribute(qualifiedName(), oldValue, value);
 }
 
-void Attr::setNodeValue(const String& v, ExceptionCode&)
+ExceptionOr<void> Attr::setNodeValue(const String& value)
 {
-    setValueForBindings(v);
+    setValueForBindings(value);
+    return { };
 }
 
 Ref<Node> Attr::cloneNodeInternal(Document& targetDocument, CloningOperation)
@@ -212,10 +208,10 @@
     m_element = nullptr;
 }
 
-void Attr::attachToElement(Element* element)
+void Attr::attachToElement(Element& element)
 {
     ASSERT(!m_element);
-    m_element = element;
+    m_element = &element;
     m_standaloneValue = nullAtom;
 }
 
diff --git a/Source/WebCore/dom/Attr.h b/Source/WebCore/dom/Attr.h
index 7337f13..1b31126 100644
--- a/Source/WebCore/dom/Attr.h
+++ b/Source/WebCore/dom/Attr.h
@@ -41,7 +41,7 @@
 
 class Attr final : public ContainerNode {
 public:
-    static Ref<Attr> create(Element*, const QualifiedName&);
+    static Ref<Attr> create(Element&, const QualifiedName&);
     static Ref<Attr> create(Document&, const QualifiedName&, const AtomicString& value);
     virtual ~Attr();
 
@@ -60,32 +60,33 @@
 
     WEBCORE_EXPORT CSSStyleDeclaration* style();
 
-    void attachToElement(Element*);
+    void attachToElement(Element&);
     void detachFromElementWithValue(const AtomicString&);
 
     const AtomicString& namespaceURI() const final { return m_name.namespaceURI(); }
     const AtomicString& localName() const final { return m_name.localName(); }
     const AtomicString& prefix() const final { return m_name.prefix(); }
 
-    void setPrefix(const AtomicString&, ExceptionCode&) final;
-
 private:
-    Attr(Element*, const QualifiedName&);
+    Attr(Element&, const QualifiedName&);
     Attr(Document&, const QualifiedName&, const AtomicString& value);
 
     void createTextChild();
 
-    String nodeName() const override { return name(); }
-    NodeType nodeType() const override { return ATTRIBUTE_NODE; }
+    String nodeName() const final { return name(); }
+    NodeType nodeType() const final { return ATTRIBUTE_NODE; }
 
-    String nodeValue() const override { return value(); }
-    void setNodeValue(const String&, ExceptionCode&) override;
-    Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
+    String nodeValue() const final { return value(); }
+    ExceptionOr<void> setNodeValue(const String&) final;
 
-    bool isAttributeNode() const override { return true; }
-    bool childTypeAllowed(NodeType) const override;
+    ExceptionOr<void> setPrefix(const AtomicString&) final;
 
-    void childrenChanged(const ChildChange&) override;
+    Ref<Node> cloneNodeInternal(Document&, CloningOperation) final;
+
+    bool isAttributeNode() const final { return true; }
+    bool childTypeAllowed(NodeType) const final;
+
+    void childrenChanged(const ChildChange&) final;
 
     Attribute& elementAttribute();
 
diff --git a/Source/WebCore/dom/CharacterData.cpp b/Source/WebCore/dom/CharacterData.cpp
index ac83cb4..97fa45f 100644
--- a/Source/WebCore/dom/CharacterData.cpp
+++ b/Source/WebCore/dom/CharacterData.cpp
@@ -179,9 +179,10 @@
     return m_data.containsOnlyWhitespace();
 }
 
-void CharacterData::setNodeValue(const String& nodeValue, ExceptionCode&)
+ExceptionOr<void> CharacterData::setNodeValue(const String& nodeValue)
 {
     setData(nodeValue);
+    return { };
 }
 
 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength)
diff --git a/Source/WebCore/dom/CharacterData.h b/Source/WebCore/dom/CharacterData.h
index c0b2147..e4ad221e 100644
--- a/Source/WebCore/dom/CharacterData.h
+++ b/Source/WebCore/dom/CharacterData.h
@@ -62,7 +62,7 @@
 
 private:
     String nodeValue() const final;
-    void setNodeValue(const String&, ExceptionCode&) final;
+    ExceptionOr<void> setNodeValue(const String&) final;
     bool isCharacterDataNode() const final { return true; }
     int maxCharacterOffset() const final;
     bool offsetInCharacters() const final;
diff --git a/Source/WebCore/dom/ContainerNode.cpp b/Source/WebCore/dom/ContainerNode.cpp
index 85c594d..e882af0 100644
--- a/Source/WebCore/dom/ContainerNode.cpp
+++ b/Source/WebCore/dom/ContainerNode.cpp
@@ -74,17 +74,19 @@
 unsigned NoEventDispatchAssertion::s_count = 0;
 #endif
 
-static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionCode& ec)
+static ExceptionOr<void> collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes)
 {
     if (!is<DocumentFragment>(node)) {
         nodes.append(node);
-        if (ContainerNode* oldParent = node.parentNode())
-            oldParent->removeChild(node, ec);
-        return;
+        auto* oldParent = node.parentNode();
+        if (!oldParent)
+            return { };
+        return oldParent->removeChild(node);
     }
 
     getChildNodes(node, nodes);
     downcast<DocumentFragment>(node).removeChildren();
+    return { };
 }
 
 // FIXME: This function must get a new name.
@@ -178,97 +180,92 @@
         : newChild.contains(&newParent);
 }
 
-static inline ExceptionCode checkAcceptChild(ContainerNode& newParent, Node& newChild, const Node* refChild, Document::AcceptChildOperation operation)
+static inline ExceptionOr<void> checkAcceptChild(ContainerNode& newParent, Node& newChild, const Node* refChild, Document::AcceptChildOperation operation)
 {
     // Use common case fast path if possible.
     if ((newChild.isElementNode() || newChild.isTextNode()) && newParent.isElementNode()) {
         ASSERT(!newParent.isDocumentTypeNode());
         ASSERT(isChildTypeAllowed(newParent, newChild));
         if (containsConsideringHostElements(newChild, newParent))
-            return HIERARCHY_REQUEST_ERR;
+            return Exception { HIERARCHY_REQUEST_ERR };
         if (operation == Document::AcceptChildOperation::InsertOrAdd && refChild && refChild->parentNode() != &newParent)
-            return NOT_FOUND_ERR;
-        return 0;
+            return Exception { NOT_FOUND_ERR };
+        return { };
     }
 
     // This should never happen, but also protect release builds from tree corruption.
     ASSERT(!newChild.isPseudoElement());
     if (newChild.isPseudoElement())
-        return HIERARCHY_REQUEST_ERR;
+        return Exception { HIERARCHY_REQUEST_ERR };
 
     if (containsConsideringHostElements(newChild, newParent))
-        return HIERARCHY_REQUEST_ERR;
+        return Exception { HIERARCHY_REQUEST_ERR };
 
     if (operation == Document::AcceptChildOperation::InsertOrAdd && refChild && refChild->parentNode() != &newParent)
-        return NOT_FOUND_ERR;
+        return Exception { NOT_FOUND_ERR };
 
     if (is<Document>(newParent)) {
         if (!downcast<Document>(newParent).canAcceptChild(newChild, refChild, operation))
-            return HIERARCHY_REQUEST_ERR;
+            return Exception { HIERARCHY_REQUEST_ERR };
     } else if (!isChildTypeAllowed(newParent, newChild))
-        return HIERARCHY_REQUEST_ERR;
+        return Exception { HIERARCHY_REQUEST_ERR };
 
-    return 0;
+    return { };
 }
 
-static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode& newParent, Node& newChild, ExceptionCode& ec)
+static inline ExceptionOr<void> checkAcceptChildGuaranteedNodeTypes(ContainerNode& newParent, Node& newChild)
 {
     ASSERT(!newParent.isDocumentTypeNode());
     ASSERT(isChildTypeAllowed(newParent, newChild));
-    if (newChild.contains(&newParent)) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return false;
-    }
-
-    return true;
+    if (newChild.contains(&newParent))
+        return Exception { HIERARCHY_REQUEST_ERR };
+    return { };
 }
 
 // https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
-bool ContainerNode::ensurePreInsertionValidity(Node& newChild, Node* refChild, ExceptionCode& ec)
+ExceptionOr<void> ContainerNode::ensurePreInsertionValidity(Node& newChild, Node* refChild)
 {
-    ec = checkAcceptChild(*this, newChild, refChild, Document::AcceptChildOperation::InsertOrAdd);
-    return !ec;
+    return checkAcceptChild(*this, newChild, refChild, Document::AcceptChildOperation::InsertOrAdd);
 }
 
 // https://dom.spec.whatwg.org/#concept-node-replace
-static inline bool checkPreReplacementValidity(ContainerNode& newParent, Node& newChild, Node& oldChild, ExceptionCode& ec)
+static inline ExceptionOr<void> checkPreReplacementValidity(ContainerNode& newParent, Node& newChild, Node& oldChild)
 {
-    ec = checkAcceptChild(newParent, newChild, &oldChild, Document::AcceptChildOperation::Replace);
-    return !ec;
+    return checkAcceptChild(newParent, newChild, &oldChild, Document::AcceptChildOperation::Replace);
 }
 
-bool ContainerNode::insertBefore(Node& newChild, Node* refChild, ExceptionCode& ec)
+ExceptionOr<void> ContainerNode::insertBefore(Node& newChild, Node* refChild)
 {
     // Check that this node is not "floating".
     // If it is, it can be deleted as a side effect of sending mutation events.
     ASSERT(refCount() || parentOrShadowHostNode());
 
-    ec = 0;
-
     // Make sure adding the new child is OK.
-    if (!ensurePreInsertionValidity(newChild, refChild, ec))
-        return false;
+    auto validityCheckResult = ensurePreInsertionValidity(newChild, refChild);
+    if (validityCheckResult.hasException())
+        return validityCheckResult.releaseException();
 
     if (refChild == &newChild)
         refChild = newChild.nextSibling();
 
     // insertBefore(node, null) is equivalent to appendChild(node)
     if (!refChild)
-        return appendChildWithoutPreInsertionValidityCheck(newChild, ec);
+        return appendChildWithoutPreInsertionValidityCheck(newChild);
 
     Ref<ContainerNode> protectedThis(*this);
     Ref<Node> next(*refChild);
 
     NodeVector targets;
-    collectChildrenAndRemoveFromOldParent(newChild, targets, ec);
-    if (ec)
-        return false;
+    auto removeResult = collectChildrenAndRemoveFromOldParent(newChild, targets);
+    if (removeResult.hasException())
+        return removeResult.releaseException();
     if (targets.isEmpty())
-        return true;
+        return { };
 
     // We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
-    if (!checkAcceptChildGuaranteedNodeTypes(*this, newChild, ec))
-        return false;
+    auto checkAcceptResult = checkAcceptChildGuaranteedNodeTypes(*this, newChild);
+    if (checkAcceptResult.hasException())
+        return checkAcceptResult.releaseException();
 
     InspectorInstrumentation::willInsertDOMNode(document(), *this);
 
@@ -291,7 +288,7 @@
     }
 
     dispatchSubtreeModifiedEvent();
-    return true;
+    return { };
 }
 
 void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
@@ -383,7 +380,7 @@
     notifyChildInserted(newChild, ChildChangeSourceParser);
 }
 
-bool ContainerNode::replaceChild(Node& newChild, Node& oldChild, ExceptionCode& ec)
+ExceptionOr<void> ContainerNode::replaceChild(Node& newChild, Node& oldChild)
 {
     // Check that this node is not "floating".
     // If it is, it can be deleted as a side effect of sending mutation events.
@@ -391,17 +388,14 @@
 
     Ref<ContainerNode> protectedThis(*this);
 
-    ec = 0;
-
     // Make sure replacing the old child with the new is ok
-    if (!checkPreReplacementValidity(*this, newChild, oldChild, ec))
-        return false;
+    auto validityResult = checkPreReplacementValidity(*this, newChild, oldChild);
+    if (validityResult.hasException())
+        return validityResult.releaseException();
 
     // NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
-    if (oldChild.parentNode() != this) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    if (oldChild.parentNode() != this)
+        return Exception { NOT_FOUND_ERR };
 
     RefPtr<Node> refChild = oldChild.nextSibling();
     if (refChild.get() == &newChild)
@@ -410,14 +404,15 @@
     NodeVector targets;
     {
         ChildListMutationScope mutation(*this);
-        collectChildrenAndRemoveFromOldParent(newChild, targets, ec);
-        if (ec)
-            return false;
+        auto collectResult = collectChildrenAndRemoveFromOldParent(newChild, targets);
+        if (collectResult.hasException())
+            return collectResult.releaseException();
     }
 
-    // Does this one more time because collectChildrenAndRemoveFromOldParent() fires a MutationEvent.
-    if (!checkPreReplacementValidity(*this, newChild, oldChild, ec))
-        return false;
+    // Do this one more time because collectChildrenAndRemoveFromOldParent() fires a MutationEvent.
+    validityResult = checkPreReplacementValidity(*this, newChild, oldChild);
+    if (validityResult.hasException())
+        return validityResult.releaseException();
 
     // Remove the node we're replacing.
     Ref<Node> protectOldChild(oldChild);
@@ -426,13 +421,14 @@
 
     // If oldChild == newChild then oldChild no longer has a parent at this point.
     if (oldChild.parentNode()) {
-        removeChild(oldChild, ec);
-        if (ec)
-            return false;
+        auto removeResult = removeChild(oldChild);
+        if (removeResult.hasException())
+            return removeResult.releaseException();
 
         // Does this one more time because removeChild() fires a MutationEvent.
-        if (!checkPreReplacementValidity(*this, newChild, oldChild, ec))
-            return false;
+        validityResult = checkPreReplacementValidity(*this, newChild, oldChild);
+        if (validityResult.hasException())
+            return validityResult.releaseException();
     }
 
     InspectorInstrumentation::willInsertDOMNode(document(), *this);
@@ -462,7 +458,7 @@
     }
 
     dispatchSubtreeModifiedEvent();
-    return true;
+    return { };
 }
 
 static void willRemoveChild(ContainerNode& container, Node& child)
@@ -510,7 +506,7 @@
     disconnectSubframesIfNeeded(*this, RootAndDescendants);
 }
 
-bool ContainerNode::removeChild(Node& oldChild, ExceptionCode& ec)
+ExceptionOr<void> ContainerNode::removeChild(Node& oldChild)
 {
     // Check that this node is not "floating".
     // If it is, it can be deleted as a side effect of sending mutation events.
@@ -518,23 +514,17 @@
 
     Ref<ContainerNode> protectedThis(*this);
 
-    ec = 0;
-
     // NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
-    if (oldChild.parentNode() != this) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    if (oldChild.parentNode() != this)
+        return Exception { NOT_FOUND_ERR };
 
     Ref<Node> child(oldChild);
 
     willRemoveChild(*this, child);
 
     // Mutation events might have moved this child into a different parent.
-    if (child->parentNode() != this) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    if (child->parentNode() != this)
+        return Exception { NOT_FOUND_ERR };
 
     {
         WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
@@ -555,7 +545,7 @@
 
     dispatchSubtreeModifiedEvent();
 
-    return true;
+    return { };
 }
 
 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& oldChild)
@@ -639,36 +629,36 @@
     dispatchSubtreeModifiedEvent();
 }
 
-bool ContainerNode::appendChild(Node& newChild, ExceptionCode& ec)
+ExceptionOr<void> ContainerNode::appendChild(Node& newChild)
 {
     // Check that this node is not "floating".
     // If it is, it can be deleted as a side effect of sending mutation events.
     ASSERT(refCount() || parentOrShadowHostNode());
 
-    ec = 0;
-
     // Make sure adding the new child is ok
-    if (!ensurePreInsertionValidity(newChild, nullptr, ec))
-        return false;
+    auto validityCheckResult = ensurePreInsertionValidity(newChild, nullptr);
+    if (validityCheckResult.hasException())
+        return validityCheckResult.releaseException();
 
-    return appendChildWithoutPreInsertionValidityCheck(newChild, ec);
+    return appendChildWithoutPreInsertionValidityCheck(newChild);
 }
 
-bool ContainerNode::appendChildWithoutPreInsertionValidityCheck(Node& newChild, ExceptionCode& ec)
+ExceptionOr<void> ContainerNode::appendChildWithoutPreInsertionValidityCheck(Node& newChild)
 {
     Ref<ContainerNode> protectedThis(*this);
 
     NodeVector targets;
-    collectChildrenAndRemoveFromOldParent(newChild, targets, ec);
-    if (ec)
-        return false;
+    auto removeResult = collectChildrenAndRemoveFromOldParent(newChild, targets);
+    if (removeResult.hasException())
+        return removeResult.releaseException();
 
     if (targets.isEmpty())
-        return true;
+        return { };
 
     // We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
-    if (!checkAcceptChildGuaranteedNodeTypes(*this, newChild, ec))
-        return false;
+    auto nodeTypeResult = checkAcceptChildGuaranteedNodeTypes(*this, newChild);
+    if (nodeTypeResult.hasException())
+        return nodeTypeResult.releaseException();
 
     InspectorInstrumentation::willInsertDOMNode(document(), *this);
 
@@ -693,7 +683,7 @@
     }
 
     dispatchSubtreeModifiedEvent();
-    return true;
+    return { };
 }
 
 void ContainerNode::parserAppendChild(Node& newChild)
@@ -731,9 +721,7 @@
     Document& targetDocument = clone.document();
     for (Node* child = firstChild(); child && !ec; child = child->nextSibling()) {
         Ref<Node> clonedChild = child->cloneNodeInternal(targetDocument, CloningOperation::SelfWithTemplateContent);
-        clone.appendChild(clonedChild, ec);
-
-        if (!ec && is<ContainerNode>(*child))
+        if (!clone.appendChild(clonedChild).hasException() && is<ContainerNode>(*child))
             downcast<ContainerNode>(*child).cloneChildNodes(downcast<ContainerNode>(clonedChild.get()));
     }
 }
@@ -890,11 +878,7 @@
     if (!node)
         return { };
 
-    ExceptionCode ec = 0;
-    appendChild(*node, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return appendChild(*node);
 }
 
 ExceptionOr<void> ContainerNode::prepend(Vector<NodeOrString>&& vector)
@@ -907,11 +891,7 @@
     if (!node)
         return { };
 
-    ExceptionCode ec = 0;
-    insertBefore(*node, firstChild(), ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return insertBefore(*node, firstChild());
 }
 
 HTMLCollection* ContainerNode::cachedHTMLCollection(CollectionType type)
diff --git a/Source/WebCore/dom/ContainerNode.h b/Source/WebCore/dom/ContainerNode.h
index 2151507..83920b7 100644
--- a/Source/WebCore/dom/ContainerNode.h
+++ b/Source/WebCore/dom/ContainerNode.h
@@ -50,10 +50,10 @@
     WEBCORE_EXPORT unsigned countChildNodes() const;
     WEBCORE_EXPORT Node* traverseToChildAt(unsigned) const;
 
-    bool insertBefore(Node& newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
-    bool replaceChild(Node& newChild, Node& oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
-    WEBCORE_EXPORT bool removeChild(Node& child, ExceptionCode& = ASSERT_NO_EXCEPTION);
-    WEBCORE_EXPORT bool appendChild(Node& newChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    ExceptionOr<void> insertBefore(Node& newChild, Node* refChild);
+    ExceptionOr<void> replaceChild(Node& newChild, Node& oldChild);
+    WEBCORE_EXPORT ExceptionOr<void> removeChild(Node& child);
+    WEBCORE_EXPORT ExceptionOr<void> appendChild(Node& newChild);
 
     // These methods are only used during parsing.
     // They don't send DOM mutation events or handle reparenting.
@@ -102,7 +102,7 @@
     ExceptionOr<void> append(Vector<NodeOrString>&&);
     ExceptionOr<void> prepend(Vector<NodeOrString>&&);
 
-    bool ensurePreInsertionValidity(Node& newChild, Node* refChild, ExceptionCode&);
+    ExceptionOr<void> ensurePreInsertionValidity(Node& newChild, Node* refChild);
 
 protected:
     explicit ContainerNode(Document&, ConstructionType = CreateContainer);
@@ -117,7 +117,7 @@
 
 private:
     void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild);
-    bool appendChildWithoutPreInsertionValidityCheck(Node&, ExceptionCode&);
+    ExceptionOr<void> appendChildWithoutPreInsertionValidityCheck(Node&);
     void insertBeforeCommon(Node& nextChild, Node& oldChild);
     void appendChildCommon(Node&);
 
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 375f41c..d714172 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -1552,9 +1552,9 @@
     updateTitle(StringWithDirection(title, LTR));
 
     if (is<HTMLTitleElement>(m_titleElement.get()))
-        downcast<HTMLTitleElement>(*m_titleElement).setTextContent(title, ASSERT_NO_EXCEPTION);
+        downcast<HTMLTitleElement>(*m_titleElement).setTextContent(title);
     else if (is<SVGTitleElement>(m_titleElement.get()))
-        downcast<SVGTitleElement>(*m_titleElement).setTextContent(title, ASSERT_NO_EXCEPTION);
+        downcast<SVGTitleElement>(*m_titleElement).setTextContent(title);
 }
 
 void Document::updateTitleElement(Element* newTitleElement)
@@ -2561,14 +2561,9 @@
     if (!m_documentElement)
         return Exception { HIERARCHY_REQUEST_ERR };
 
-    ExceptionCode ec = 0;
     if (currentBody)
-        m_documentElement->replaceChild(*newBody, *currentBody, ec);
-    else
-        m_documentElement->appendChild(*newBody, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+        return m_documentElement->replaceChild(*newBody, *currentBody);
+    return m_documentElement->appendChild(*newBody);
 }
 
 Location* Document::location() const
diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
index 283c169..be05ffc 100644
--- a/Source/WebCore/dom/Element.cpp
+++ b/Source/WebCore/dom/Element.cpp
@@ -1584,14 +1584,14 @@
     return m_tagName.toString();
 }
 
-void Element::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
+ExceptionOr<void> Element::setPrefix(const AtomicString& prefix)
 {
-    ec = 0;
-    checkSetPrefix(prefix, ec);
-    if (ec)
-        return;
+    auto result = checkSetPrefix(prefix);
+    if (result.hasException())
+        return result.releaseException();
 
     m_tagName.setPrefix(prefix.isEmpty() ? nullAtom : prefix);
+    return { };
 }
 
 const AtomicString& Element::imageSourceURL() const
@@ -2124,7 +2124,7 @@
 
 ExceptionOr<RefPtr<Attr>> Element::setAttributeNode(Attr& attrNode)
 {
-    RefPtr<Attr> oldAttrNode = attrIfExists(attrNode.qualifiedName().localName(), shouldIgnoreAttributeCase(*this));
+    RefPtr<Attr> oldAttrNode = attrIfExists(attrNode.localName(), shouldIgnoreAttributeCase(*this));
     if (oldAttrNode.get() == &attrNode)
         return WTFMove(oldAttrNode);
 
@@ -2136,7 +2136,7 @@
     synchronizeAllAttributes();
     auto& elementData = ensureUniqueElementData();
 
-    auto existingAttributeIndex = elementData.findAttributeIndexByName(attrNode.qualifiedName().localName(), shouldIgnoreAttributeCase(*this));
+    auto existingAttributeIndex = elementData.findAttributeIndexByName(attrNode.localName(), shouldIgnoreAttributeCase(*this));
     if (existingAttributeIndex == ElementData::attributeNotFound)
         setAttributeInternal(elementData.findAttributeIndexByName(attrNode.qualifiedName()), attrNode.qualifiedName(), attrNode.value(), NotInSynchronizationOfLazyAttribute);
     else {
@@ -2154,7 +2154,7 @@
         }
     }
     if (attrNode.ownerElement() != this) {
-        attrNode.attachToElement(this);
+        attrNode.attachToElement(*this);
         treeScope().adoptIfNeeded(&attrNode);
         ensureAttrNodeListForElement(*this).append(&attrNode);
     }
@@ -2185,7 +2185,7 @@
 
     setAttributeInternal(index, attrNode.qualifiedName(), attrNode.value(), NotInSynchronizationOfLazyAttribute);
 
-    attrNode.attachToElement(this);
+    attrNode.attachToElement(*this);
     treeScope().adoptIfNeeded(&attrNode);
     ensureAttrNodeListForElement(*this).append(&attrNode);
 
@@ -2535,10 +2535,9 @@
     if (fragment.hasException())
         return fragment.releaseException();
 
-    ExceptionCode ec = 0;
-    parent->replaceChild(fragment.releaseReturnValue().get(), *this, ec);
-    if (ec)
-        return Exception { ec };
+    auto replaceResult = parent->replaceChild(fragment.releaseReturnValue().get(), *this);
+    if (replaceResult.hasException())
+        return replaceResult.releaseException();
 
     RefPtr<Node> node = next ? next->previousSibling() : nullptr;
     if (is<Text>(node.get())) {
@@ -3397,7 +3396,7 @@
     auto& attrNodeList = ensureAttrNodeListForElement(*this);
     RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name);
     if (!attrNode) {
-        attrNode = Attr::create(this, name);
+        attrNode = Attr::create(*this, name);
         treeScope().adoptIfNeeded(attrNode.get());
         attrNodeList.append(attrNode);
     }
@@ -3647,38 +3646,34 @@
         auto* parent = this->parentNode();
         if (!parent)
             return nullptr;
-        ExceptionCode ec = 0;
-        bool success = parent->insertBefore(newChild, this, ec);
-        if (ec)
-            return Exception { ec };
-        return success ? newChild.ptr() : nullptr;
+        auto result = parent->insertBefore(newChild, this);
+        if (result.hasException())
+            return result.releaseException();
+        return newChild.ptr();
     }
 
     if (equalLettersIgnoringASCIICase(where, "afterbegin")) {
-        ExceptionCode ec = 0;
-        bool success = insertBefore(newChild, firstChild(), ec);
-        if (ec)
-            return Exception { ec };
-        return success ? newChild.ptr() : nullptr;
+        auto result = insertBefore(newChild, firstChild());
+        if (result.hasException())
+            return result.releaseException();
+        return newChild.ptr();
     }
 
     if (equalLettersIgnoringASCIICase(where, "beforeend")) {
-        ExceptionCode ec = 0;
-        bool success = appendChild(newChild, ec);
-        if (ec)
-            return Exception { ec };
-        return success ? newChild.ptr() : nullptr;
+        auto result = appendChild(newChild);
+        if (result.hasException())
+            return result.releaseException();
+        return newChild.ptr();
     }
 
     if (equalLettersIgnoringASCIICase(where, "afterend")) {
         auto* parent = this->parentNode();
         if (!parent)
             return nullptr;
-        ExceptionCode ec = 0;
-        bool success = parent->insertBefore(newChild, nextSibling(), ec);
-        if (ec)
-            return Exception { ec };
-        return success ? newChild.ptr() : nullptr;
+        auto result = parent->insertBefore(newChild, nextSibling());
+        if (result.hasException())
+            return result.releaseException();
+        return newChild.ptr();
     }
 
     return Exception { SYNTAX_ERR };
diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h
index 5aded9e..8fa5922 100644
--- a/Source/WebCore/dom/Element.h
+++ b/Source/WebCore/dom/Element.h
@@ -218,7 +218,7 @@
     const AtomicString& prefix() const final { return m_tagName.prefix(); }
     const AtomicString& namespaceURI() const final { return m_tagName.namespaceURI(); }
 
-    void setPrefix(const AtomicString&, ExceptionCode&) final;
+    ExceptionOr<void> setPrefix(const AtomicString&) final;
 
     String nodeName() const override;
 
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 7dd96fc..844ce9a 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -361,9 +361,10 @@
     return String();
 }
 
-void Node::setNodeValue(const String& /*nodeValue*/, ExceptionCode&)
+ExceptionOr<void> Node::setNodeValue(const String&)
 {
     // By default, setting nodeValue has no effect.
+    return { };
 }
 
 RefPtr<NodeList> Node::childNodes()
@@ -399,40 +400,32 @@
     return ElementTraversal::nextSibling(*this);
 }
 
-bool Node::insertBefore(Node& newChild, Node* refChild, ExceptionCode& ec)
+ExceptionOr<void> Node::insertBefore(Node& newChild, Node* refChild)
 {
-    if (!is<ContainerNode>(*this)) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return false;
-    }
-    return downcast<ContainerNode>(*this).insertBefore(newChild, refChild, ec);
+    if (!is<ContainerNode>(*this))
+        return Exception { HIERARCHY_REQUEST_ERR };
+    return downcast<ContainerNode>(*this).insertBefore(newChild, refChild);
 }
 
-bool Node::replaceChild(Node& newChild, Node& oldChild, ExceptionCode& ec)
+ExceptionOr<void> Node::replaceChild(Node& newChild, Node& oldChild)
 {
-    if (!is<ContainerNode>(*this)) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return false;
-    }
-    return downcast<ContainerNode>(*this).replaceChild(newChild, oldChild, ec);
+    if (!is<ContainerNode>(*this))
+        return Exception { HIERARCHY_REQUEST_ERR };
+    return downcast<ContainerNode>(*this).replaceChild(newChild, oldChild);
 }
 
-bool Node::removeChild(Node& oldChild, ExceptionCode& ec)
+ExceptionOr<void> Node::removeChild(Node& oldChild)
 {
-    if (!is<ContainerNode>(*this)) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
-    return downcast<ContainerNode>(*this).removeChild(oldChild, ec);
+    if (!is<ContainerNode>(*this))
+        return Exception { NOT_FOUND_ERR };
+    return downcast<ContainerNode>(*this).removeChild(oldChild);
 }
 
-bool Node::appendChild(Node& newChild, ExceptionCode& ec)
+ExceptionOr<void> Node::appendChild(Node& newChild)
 {
-    if (!is<ContainerNode>(*this)) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return false;
-    }
-    return downcast<ContainerNode>(*this).appendChild(newChild, ec);
+    if (!is<ContainerNode>(*this))
+        return Exception { HIERARCHY_REQUEST_ERR };
+    return downcast<ContainerNode>(*this).appendChild(newChild);
 }
 
 static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<NodeOrString>& vector)
@@ -485,10 +478,9 @@
 
     auto nodeToReturn = DocumentFragment::create(document());
     for (auto& node : nodes) {
-        ExceptionCode ec = 0;
-        nodeToReturn->appendChild(node, ec);
-        if (ec)
-            return Exception { ec };
+        auto appendResult = nodeToReturn->appendChild(node);
+        if (appendResult.hasException())
+            return appendResult.releaseException();
     }
     return RefPtr<Node> { WTFMove(nodeToReturn) };
 }
@@ -514,11 +506,7 @@
     else
         viablePreviousSibling = parent->firstChild();
 
-    ExceptionCode ec = 0;
-    parent->insertBefore(*node, viablePreviousSibling.get(), ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return parent->insertBefore(*node, viablePreviousSibling.get());
 }
 
 ExceptionOr<void> Node::after(Vector<NodeOrString>&& nodeOrStringVector)
@@ -537,11 +525,7 @@
     if (!node)
         return { };
 
-    ExceptionCode ec = 0;
-    parent->insertBefore(*node, viableNextSibling.get(), ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return parent->insertBefore(*node, viableNextSibling.get());
 }
 
 ExceptionOr<void> Node::replaceWith(Vector<NodeOrString>&& nodeOrStringVector)
@@ -556,22 +540,15 @@
     auto result = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector));
     if (result.hasException())
         return result.releaseException();
-    auto node = result.releaseReturnValue();
 
     if (parentNode() == parent) {
-        if (node) {
-            ExceptionCode ec = 0;
-            parent->replaceChild(*node, *this, ec);
-            if (ec)
-                return Exception { ec };
-        } else
-            parent->removeChild(*this);
-    } else if (node) {
-        ExceptionCode ec = 0;
-        parent->insertBefore(*node, viableNextSibling.get(), ec);
-        if (ec)
-            return Exception { ec };
+        if (auto node = result.releaseReturnValue())
+            return parent->replaceChild(*node, *this);
+        return parent->removeChild(*this);
     }
+
+    if (auto node = result.releaseReturnValue())
+        return parent->insertBefore(*node, viableNextSibling.get());
     return { };
 }
 
@@ -580,11 +557,7 @@
     auto* parent = parentNode();
     if (!parent)
         return { };
-    ExceptionCode ec = 0;
-    parent->removeChild(*this, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return parent->removeChild(*this);
 }
 
 void Node::normalize()
@@ -641,12 +614,10 @@
     }
 }
 
-RefPtr<Node> Node::cloneNodeForBindings(bool deep, ExceptionCode& ec)
+ExceptionOr<Ref<Node>> Node::cloneNodeForBindings(bool deep)
 {
-    if (UNLIKELY(isShadowRoot())) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
+    if (UNLIKELY(isShadowRoot()))
+        return Exception { NOT_SUPPORTED_ERR };
     return cloneNode(deep);
 }
 
@@ -656,12 +627,12 @@
     return nullAtom;
 }
 
-void Node::setPrefix(const AtomicString& /*prefix*/, ExceptionCode& ec)
+ExceptionOr<void> Node::setPrefix(const AtomicString&)
 {
     // The spec says that for nodes other than elements and attributes, prefix is always null.
     // It does not say what to do when the user tries to set the prefix on another type of
     // node, however Mozilla throws a NAMESPACE_ERR exception.
-    ec = NAMESPACE_ERR;
+    return Exception { NAMESPACE_ERR };
 }
 
 const AtomicString& Node::localName() const
@@ -919,25 +890,25 @@
     rareData()->clearNodeLists();
 }
 
-void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec)
+ExceptionOr<void> Node::checkSetPrefix(const AtomicString& prefix)
 {
     // Perform error checking as required by spec for setting Node.prefix. Used by
     // Element::setPrefix() and Attr::setPrefix()
 
-    if (!prefix.isEmpty() && !Document::isValidName(prefix)) {
-        ec = INVALID_CHARACTER_ERR;
-        return;
-    }
+    if (!prefix.isEmpty() && !Document::isValidName(prefix))
+        return Exception { INVALID_CHARACTER_ERR };
 
     // FIXME: Raise NAMESPACE_ERR if prefix is malformed per the Namespaces in XML specification.
 
-    const AtomicString& nodeNamespaceURI = namespaceURI();
-    if ((nodeNamespaceURI.isEmpty() && !prefix.isEmpty())
-        || (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI)) {
-        ec = NAMESPACE_ERR;
-        return;
-    }
+    auto& namespaceURI = this->namespaceURI();
+    if (namespaceURI.isEmpty() && !prefix.isEmpty())
+        return Exception { NAMESPACE_ERR };
+    if (prefix == xmlAtom && namespaceURI != XMLNames::xmlNamespaceURI)
+        return Exception { NAMESPACE_ERR };
+
     // Attribute-specific checks are in Attr::setPrefix().
+
+    return { };
 }
 
 bool Node::isDescendantOf(const Node* other) const
@@ -1502,7 +1473,7 @@
     return isNullString ? String() : content.toString();
 }
 
-void Node::setTextContent(const String& text, ExceptionCode& ec)
+ExceptionOr<void> Node::setTextContent(const String& text)
 {           
     switch (nodeType()) {
     case ATTRIBUTE_NODE:
@@ -1510,23 +1481,23 @@
     case CDATA_SECTION_NODE:
     case COMMENT_NODE:
     case PROCESSING_INSTRUCTION_NODE:
-        setNodeValue(text, ec);
-        return;
+        return setNodeValue(text);
     case ELEMENT_NODE:
     case DOCUMENT_FRAGMENT_NODE: {
         auto container = makeRef(downcast<ContainerNode>(*this));
         ChildListMutationScope mutation(container);
         container->removeChildren();
-        if (!text.isEmpty())
-            container->appendChild(document().createTextNode(text), ec);
-        return;
+        if (text.isEmpty())
+            return { };
+        return container->appendChild(document().createTextNode(text));
     }
     case DOCUMENT_NODE:
     case DOCUMENT_TYPE_NODE:
         // Do nothing.
-        return;
+        return { };
     }
     ASSERT_NOT_REACHED();
+    return { };
 }
 
 bool Node::offsetInCharacters() const
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h
index 47f7121..e4df357 100644
--- a/Source/WebCore/dom/Node.h
+++ b/Source/WebCore/dom/Node.h
@@ -127,7 +127,7 @@
     bool hasTagName(const SVGQualifiedName&) const;
     virtual String nodeName() const = 0;
     virtual String nodeValue() const;
-    virtual void setNodeValue(const String&, ExceptionCode&);
+    virtual ExceptionOr<void> setNodeValue(const String&);
     virtual NodeType nodeType() const = 0;
     virtual size_t approximateMemoryCost() const { return sizeof(*this); }
     ContainerNode* parentNode() const;
@@ -151,13 +151,10 @@
     
     void getSubresourceURLs(ListHashSet<URL>&) const;
 
-    // These should all actually return a node, but this is only important for language bindings,
-    // which will already know and hold a ref on the right node to return. Returning bool allows
-    // these methods to be more efficient since they don't need to return a ref
-    WEBCORE_EXPORT bool insertBefore(Node& newChild, Node* refChild, ExceptionCode&);
-    WEBCORE_EXPORT bool replaceChild(Node& newChild, Node& oldChild, ExceptionCode&);
-    WEBCORE_EXPORT bool removeChild(Node& child, ExceptionCode&);
-    WEBCORE_EXPORT bool appendChild(Node& newChild, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> insertBefore(Node& newChild, Node* refChild);
+    WEBCORE_EXPORT ExceptionOr<void> replaceChild(Node& newChild, Node& oldChild);
+    WEBCORE_EXPORT ExceptionOr<void> removeChild(Node& child);
+    WEBCORE_EXPORT ExceptionOr<void> appendChild(Node& newChild);
 
     bool hasChildNodes() const { return firstChild(); }
 
@@ -168,12 +165,12 @@
     };
     virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) = 0;
     Ref<Node> cloneNode(bool deep) { return cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf); }
-    WEBCORE_EXPORT RefPtr<Node> cloneNodeForBindings(bool deep, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<Ref<Node>> cloneNodeForBindings(bool deep);
 
     virtual const AtomicString& localName() const;
     virtual const AtomicString& namespaceURI() const;
     virtual const AtomicString& prefix() const;
-    virtual void setPrefix(const AtomicString&, ExceptionCode&);
+    virtual ExceptionOr<void> setPrefix(const AtomicString&);
     WEBCORE_EXPORT void normalize();
 
     bool isSameNode(Node* other) const { return this == other; }
@@ -183,7 +180,7 @@
     WEBCORE_EXPORT const AtomicString& lookupNamespaceURI(const AtomicString& prefix) const;
 
     WEBCORE_EXPORT String textContent(bool convertBRsToNewlines = false) const;
-    WEBCORE_EXPORT void setTextContent(const String&, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setTextContent(const String&);
     
     Node* lastDescendant() const;
     Node* firstDescendant() const;
@@ -387,7 +384,7 @@
     unsigned countChildNodes() const;
     Node* traverseToChildAt(unsigned) const;
 
-    void checkSetPrefix(const AtomicString& prefix, ExceptionCode&);
+    ExceptionOr<void> checkSetPrefix(const AtomicString& prefix);
 
     WEBCORE_EXPORT bool isDescendantOf(const Node*) const;
     bool isDescendantOrShadowDescendantOf(const Node*) const;
diff --git a/Source/WebCore/dom/Node.idl b/Source/WebCore/dom/Node.idl
index 2f8a901..784a9ef 100644
--- a/Source/WebCore/dom/Node.idl
+++ b/Source/WebCore/dom/Node.idl
@@ -25,8 +25,7 @@
     JSCustomHeader,
     JSCustomMarkFunction,
     JSCustomPushEventHandlerScope,
-] interface Node : EventTarget
- {
+] interface Node : EventTarget {
     // NodeType
     const unsigned short ELEMENT_NODE = 1;
     const unsigned short ATTRIBUTE_NODE = 2;
@@ -43,8 +42,7 @@
 
     readonly attribute DOMString nodeName;
 
-    // FIXME: the spec says this can also raise on retrieval.
-    [CEReactions, SetterMayThrowLegacyException] attribute DOMString? nodeValue;
+    [CEReactions, SetterMayThrowException] attribute DOMString? nodeValue;
 
     [DOMJIT=Getter, CustomGetter] readonly attribute unsigned short nodeType;
     [DOMJIT=Getter] readonly attribute Node? parentNode;
@@ -55,21 +53,20 @@
     [DOMJIT=Getter] readonly attribute Node? nextSibling;
     [DOMJIT=Getter] readonly attribute Document? ownerDocument;
 
-    [CEReactions, Custom, MayThrowLegacyException] Node insertBefore(Node newChild, Node? refChild);
-    [CEReactions, Custom, MayThrowLegacyException] Node replaceChild(Node newChild, Node oldChild);
-    [CEReactions, Custom, MayThrowLegacyException] Node removeChild(Node oldChild);
-    [CEReactions, Custom, MayThrowLegacyException] Node appendChild(Node newChild);
+    [CEReactions, Custom, MayThrowException] Node insertBefore(Node newChild, Node? refChild);
+    [CEReactions, Custom, MayThrowException] Node replaceChild(Node newChild, Node oldChild);
+    [CEReactions, Custom, MayThrowException] Node removeChild(Node oldChild);
+    [CEReactions, Custom, MayThrowException] Node appendChild(Node newChild);
 
     boolean hasChildNodes();
 
-    [CEReactions, ImplementedAs=cloneNodeForBindings, MayThrowLegacyException, NewObject] Node cloneNode(optional boolean deep = false);
+    [CEReactions, ImplementedAs=cloneNodeForBindings, MayThrowException, NewObject] Node cloneNode(optional boolean deep = false);
 
     void normalize();
 
     readonly attribute USVString baseURI;
 
-    // FIXME: the spec says this can also raise on retrieval.
-    [CEReactions, SetterMayThrowLegacyException] attribute DOMString? textContent;
+    [CEReactions, SetterMayThrowException] attribute DOMString? textContent;
 
     boolean isSameNode(Node? other);
     boolean isEqualNode(Node? other);
@@ -97,5 +94,5 @@
 };
 
 dictionary GetRootNodeOptions {
-  boolean composed = false;
+    boolean composed = false;
 };
diff --git a/Source/WebCore/dom/Range.cpp b/Source/WebCore/dom/Range.cpp
index 61b8baf..ff15529 100644
--- a/Source/WebCore/dom/Range.cpp
+++ b/Source/WebCore/dom/Range.cpp
@@ -644,10 +644,9 @@
     // (or just delete the stuff in between)
 
     if ((action == Extract || action == Clone) && leftContents) {
-        ExceptionCode ec = 0;
-        fragment->appendChild(*leftContents, ec);
-        if (ec)
-            return Exception { ec };
+        auto result = fragment->appendChild(*leftContents);
+        if (result.hasException())
+            return result.releaseException();
     }
 
     if (processStart) {
@@ -660,10 +659,9 @@
     }
 
     if ((action == Extract || action == Clone) && rightContents) {
-        ExceptionCode ec = 0;
-        fragment->appendChild(*rightContents, ec);
-        if (ec)
-            return Exception { ec };
+        auto result = fragment->appendChild(*rightContents);
+        if (result.hasException())
+            return result.releaseException();
     }
 
     return WTFMove(fragment);
@@ -705,10 +703,9 @@
                 return deleteResult.releaseException();
             if (fragment) {
                 result = fragment;
-                ExceptionCode ec = 0;
-                result->appendChild(characters, ec);
-                if (ec)
-                    return Exception { ec };
+                auto appendResult = result->appendChild(characters);
+                if (appendResult.hasException())
+                    return appendResult.releaseException();
             } else
                 result = WTFMove(characters);
         }
@@ -727,10 +724,9 @@
             processingInstruction->setData(processingInstruction->data().substring(startOffset, endOffset - startOffset));
             if (fragment) {
                 result = fragment;
-                ExceptionCode ec = 0;
-                result->appendChild(processingInstruction, ec);
-                if (ec)
-                    return Exception { ec };
+                auto appendResult = result->appendChild(processingInstruction);
+                if (appendResult.hasException())
+                    return appendResult.releaseException();
             } else
                 result = WTFMove(processingInstruction);
         }
@@ -777,24 +773,21 @@
     for (auto& node : nodes) {
         switch (action) {
         case Range::Delete: {
-            ExceptionCode ec = 0;
-            oldContainer->removeChild(node, ec);
-            if (ec)
-                return Exception { ec };
+            auto result = oldContainer->removeChild(node);
+            if (result.hasException())
+                return result.releaseException();
             break;
         }
         case Range::Extract: {
-            ExceptionCode ec = 0;
-            newContainer->appendChild(node, ec); // will remove n from its parent
-            if (ec)
-                return Exception { ec };
+            auto result = newContainer->appendChild(node); // will remove node from its parent
+            if (result.hasException())
+                return result.releaseException();
             break;
         }
         case Range::Clone: {
-            ExceptionCode ec = 0;
-            newContainer->appendChild(node->cloneNode(true), ec);
-            if (ec)
-                return Exception { ec };
+            auto result = newContainer->appendChild(node->cloneNode(true));
+            if (result.hasException())
+                return result.releaseException();
             break;
         }
         }
@@ -818,10 +811,9 @@
         if (action == Range::Extract || action == Range::Clone) {
             auto clonedAncestor = ancestor->cloneNode(false); // Might have been removed already during mutation event.
             if (clonedContainer) {
-                ExceptionCode ec = 0;
-                clonedAncestor->appendChild(*clonedContainer, ec);
-                if (ec)
-                    return Exception { ec };
+                auto result = clonedAncestor->appendChild(*clonedContainer);
+                if (result.hasException())
+                    return result.releaseException();
             }
             clonedContainer = WTFMove(clonedAncestor);
         }
@@ -839,36 +831,31 @@
         for (auto& child : nodes) {
             switch (action) {
             case Range::Delete: {
-                ExceptionCode ec = 0;
-                ancestor->removeChild(child, ec);
-                if (ec)
-                    return Exception { ec };
+                auto result = ancestor->removeChild(child);
+                if (result.hasException())
+                    return result.releaseException();
                 break;
             }
             case Range::Extract: // will remove child from ancestor
                 if (direction == ProcessContentsForward) {
-                    ExceptionCode ec = 0;
-                    clonedContainer->appendChild(child, ec);
-                    if (ec)
-                        return Exception { ec };
+                    auto result = clonedContainer->appendChild(child);
+                    if (result.hasException())
+                        return result.releaseException();
                 } else {
-                    ExceptionCode ec = 0;
-                    clonedContainer->insertBefore(child, clonedContainer->firstChild(), ec);
-                    if (ec)
-                        return Exception { ec };
+                    auto result = clonedContainer->insertBefore(child, clonedContainer->firstChild());
+                    if (result.hasException())
+                        return result.releaseException();
                 }
                 break;
             case Range::Clone:
                 if (direction == ProcessContentsForward) {
-                    ExceptionCode ec = 0;
-                    clonedContainer->appendChild(child->cloneNode(true), ec);
-                    if (ec)
-                        return Exception { ec };
+                    auto result = clonedContainer->appendChild(child->cloneNode(true));
+                    if (result.hasException())
+                        return result.releaseException();
                 } else {
-                    ExceptionCode ec = 0;
-                    clonedContainer->insertBefore(child->cloneNode(true), clonedContainer->firstChild(), ec);
-                    if (ec)
-                        return Exception { ec };
+                    auto result = clonedContainer->insertBefore(child->cloneNode(true), clonedContainer->firstChild());
+                    if (result.hasException())
+                        return result.releaseException();
                 }
                 break;
             }
@@ -914,9 +901,9 @@
 
     Ref<ContainerNode> parent = downcast<ContainerNode>(*parentNode);
 
-    ExceptionCode ec = 0;
-    if (!parent->ensurePreInsertionValidity(node, referenceNode.get(), ec))
-        return Exception { ec };
+    auto result = parent->ensurePreInsertionValidity(node, referenceNode.get());
+    if (result.hasException())
+        return result.releaseException();
 
     EventQueueScope scope;
     if (startIsText) {
@@ -939,9 +926,9 @@
     else
         ++newOffset;
 
-    parent->insertBefore(node, referenceNode.get(), ec);
-    if (ec)
-        return Exception { ec };
+    auto insertResult = parent->insertBefore(node, referenceNode.get());
+    if (insertResult.hasException())
+        return insertResult.releaseException();
 
     if (collapsed())
         return setEnd(WTFMove(parent), newOffset);
@@ -1123,10 +1110,9 @@
 
     // Step 4: If newParent has children, replace all with null within newParent.
     while (auto* child = newParent.firstChild()) {
-        ExceptionCode ec = 0;
-        downcast<ContainerNode>(newParent).removeChild(*child, ec);
-        if (ec)
-            return Exception { ec };
+        auto result = downcast<ContainerNode>(newParent).removeChild(*child);
+        if (result.hasException())
+            return result.releaseException();
     }
 
     // Step 5: Insert newParent into context object.
@@ -1135,10 +1121,9 @@
         return insertResult.releaseException();
 
     // Step 6: Append fragment to newParent.
-    ExceptionCode ec = 0;
-    newParent.appendChild(fragment.releaseReturnValue(), ec);
-    if (ec)
-        return Exception { ec };
+    auto appendResult = newParent.appendChild(fragment.releaseReturnValue());
+    if (appendResult.hasException())
+        return appendResult.releaseException();
 
     // Step 7: Select newParent within context object.
     return selectNode(newParent);
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index 0e4c97a..4431a9e5 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -68,11 +68,10 @@
 
     dispatchModifiedEvent(oldData);
 
-    if (parentNode()) {
-        ExceptionCode ec = 0;
-        parentNode()->insertBefore(newText, nextSibling(), ec);
-        if (ec)
-            return Exception { ec };
+    if (auto* parent = parentNode()) {
+        auto insertResult = parent->insertBefore(newText, nextSibling());
+        if (insertResult.hasException())
+            return insertResult.releaseException();
     }
 
     document().textNodeSplit(this);
@@ -131,7 +130,7 @@
     for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) {
         Ref<Node> nodeToRemove(n.releaseNonNull());
         n = nodeToRemove->nextSibling();
-        parent->removeChild(WTFMove(nodeToRemove), IGNORE_EXCEPTION);
+        parent->removeChild(nodeToRemove);
     }
 
     if (this != endText) {
@@ -139,13 +138,13 @@
         for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTextNode() && n->parentNode() == parent;) {
             Ref<Node> nodeToRemove(n.releaseNonNull());
             n = nodeToRemove->nextSibling();
-            parent->removeChild(WTFMove(nodeToRemove), IGNORE_EXCEPTION);
+            parent->removeChild(nodeToRemove);
         }
     }
 
     if (newText.isEmpty()) {
         if (parent && parentNode() == parent)
-            parent->removeChild(*this, IGNORE_EXCEPTION);
+            parent->removeChild(*this);
         return nullptr;
     }
 
diff --git a/Source/WebCore/editing/AppendNodeCommand.cpp b/Source/WebCore/editing/AppendNodeCommand.cpp
index 04814ea..9ab07f5 100644
--- a/Source/WebCore/editing/AppendNodeCommand.cpp
+++ b/Source/WebCore/editing/AppendNodeCommand.cpp
@@ -51,7 +51,7 @@
     if (!m_parent->hasEditableStyle() && m_parent->renderer())
         return;
 
-    m_parent->appendChild(m_node, IGNORE_EXCEPTION);
+    m_parent->appendChild(m_node);
 }
 
 void AppendNodeCommand::doUnapply()
diff --git a/Source/WebCore/editing/CompositeEditCommand.cpp b/Source/WebCore/editing/CompositeEditCommand.cpp
index 04b5b0c..6e8d738 100644
--- a/Source/WebCore/editing/CompositeEditCommand.cpp
+++ b/Source/WebCore/editing/CompositeEditCommand.cpp
@@ -1161,7 +1161,7 @@
 Ref<HTMLElement> CompositeEditCommand::insertNewDefaultParagraphElementAt(const Position& position)
 {
     auto paragraphElement = createDefaultParagraphElement(document());
-    paragraphElement->appendChild(HTMLBRElement::create(document()), IGNORE_EXCEPTION);
+    paragraphElement->appendChild(HTMLBRElement::create(document()));
     insertNodeAt(paragraphElement.ptr(), position);
     return paragraphElement;
 }
diff --git a/Source/WebCore/editing/EditorCommand.cpp b/Source/WebCore/editing/EditorCommand.cpp
index cb2a5a0..1878a9f 100644
--- a/Source/WebCore/editing/EditorCommand.cpp
+++ b/Source/WebCore/editing/EditorCommand.cpp
@@ -166,9 +166,7 @@
 static bool executeInsertNode(Frame& frame, Ref<Node>&& content)
 {
     auto fragment = DocumentFragment::create(*frame.document());
-    ExceptionCode ec = 0;
-    fragment->appendChild(content, ec);
-    if (ec)
+    if (fragment->appendChild(content).hasException())
         return false;
     return executeInsertFragment(frame, WTFMove(fragment));
 }
diff --git a/Source/WebCore/editing/InsertNodeBeforeCommand.cpp b/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
index d4587da..3a74e44 100644
--- a/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
+++ b/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
@@ -55,7 +55,7 @@
         return;
     ASSERT(isEditableNode(*parent));
 
-    parent->insertBefore(*m_insertChild, m_refChild.get(), IGNORE_EXCEPTION);
+    parent->insertBefore(*m_insertChild, m_refChild.get());
 }
 
 void InsertNodeBeforeCommand::doUnapply()
diff --git a/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp b/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
index 55d172e..76c376f 100644
--- a/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
+++ b/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
@@ -52,7 +52,7 @@
         children.append(*child);
 
     for (auto& child : children)
-        m_element2->insertBefore(child, m_atChild.get(), IGNORE_EXCEPTION);
+        m_element2->insertBefore(child, m_atChild.get());
 
     m_element1->remove();
 }
@@ -64,14 +64,11 @@
 
     RefPtr<Node> atChild = WTFMove(m_atChild);
 
-    ContainerNode* parent = m_element2->parentNode();
+    auto* parent = m_element2->parentNode();
     if (!parent || !parent->hasEditableStyle())
         return;
 
-    ExceptionCode ec = 0;
-
-    parent->insertBefore(*m_element1, m_element2.get(), ec);
-    if (ec)
+    if (parent->insertBefore(*m_element1, m_element2.get()).hasException())
         return;
 
     Vector<Ref<Node>> children;
@@ -79,7 +76,7 @@
         children.append(*child);
 
     for (auto& child : children)
-        m_element1->appendChild(child, ec);
+        m_element1->appendChild(child);
 }
 
 #ifndef NDEBUG
diff --git a/Source/WebCore/editing/RemoveNodeCommand.cpp b/Source/WebCore/editing/RemoveNodeCommand.cpp
index 01e6ff4..8968027 100644
--- a/Source/WebCore/editing/RemoveNodeCommand.cpp
+++ b/Source/WebCore/editing/RemoveNodeCommand.cpp
@@ -62,7 +62,7 @@
     if (!parent || !parent->hasEditableStyle())
         return;
 
-    parent->insertBefore(m_node, refChild.get(), IGNORE_EXCEPTION);
+    parent->insertBefore(m_node, refChild.get());
 }
 
 #ifndef NDEBUG
diff --git a/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp b/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
index d70d46e..b96c3a6 100644
--- a/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
+++ b/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
@@ -53,10 +53,10 @@
     NodeVector children;
     getChildNodes(nodeToReplace, children);
     for (auto& child : children)
-        newNode.appendChild(child, ASSERT_NO_EXCEPTION);
+        newNode.appendChild(child);
 
-    parentNode->insertBefore(newNode, &nodeToReplace, ASSERT_NO_EXCEPTION);
-    parentNode->removeChild(nodeToReplace, ASSERT_NO_EXCEPTION);
+    parentNode->insertBefore(newNode, &nodeToReplace);
+    parentNode->removeChild(nodeToReplace);
 }
 
 void ReplaceNodeWithSpanCommand::doApply()
diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.cpp b/Source/WebCore/editing/ReplaceSelectionCommand.cpp
index 8f33866..e86004c 100644
--- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/Source/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -245,7 +245,7 @@
     if (!parent)
         return;
     
-    parent->removeChild(*node, ASSERT_NO_EXCEPTION);
+    parent->removeChild(*node);
 }
 
 void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
@@ -257,15 +257,15 @@
     if (!parent)
         return;
         
-    parent->insertBefore(*node, refNode, ASSERT_NO_EXCEPTION);
+    parent->insertBefore(*node, refNode);
 }
 
 Ref<HTMLElement> ReplacementFragment::insertFragmentForTestRendering(Node* rootEditableElement)
 {
     auto holder = createDefaultParagraphElement(document());
 
-    holder->appendChild(*m_fragment, ASSERT_NO_EXCEPTION);
-    rootEditableElement->appendChild(holder, ASSERT_NO_EXCEPTION);
+    holder->appendChild(*m_fragment);
+    rootEditableElement->appendChild(holder);
     document().updateLayoutIgnorePendingStylesheets();
 
     return holder;
@@ -277,8 +277,8 @@
         return;
     
     while (RefPtr<Node> node = holder->firstChild()) {
-        holder->removeChild(*node, ASSERT_NO_EXCEPTION);
-        m_fragment->appendChild(*node, ASSERT_NO_EXCEPTION);
+        holder->removeChild(*node);
+        m_fragment->appendChild(*node);
     }
 
     removeNode(holder);
@@ -1484,7 +1484,7 @@
     }
 
     while (RefPtr<Node> listItem = listElement->firstChild()) {
-        listElement->removeChild(*listItem, ASSERT_NO_EXCEPTION);
+        listElement->removeChild(*listItem);
         if (isStart || isMiddle) {
             insertNodeBefore(listItem, lastNode);
             insertedNodes.respondToNodeInsertion(listItem.get());
diff --git a/Source/WebCore/editing/SplitElementCommand.cpp b/Source/WebCore/editing/SplitElementCommand.cpp
index c328727..2d4e854 100644
--- a/Source/WebCore/editing/SplitElementCommand.cpp
+++ b/Source/WebCore/editing/SplitElementCommand.cpp
@@ -50,21 +50,18 @@
     Vector<Ref<Node>> children;
     for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->nextSibling())
         children.append(*node);
-    
-    ExceptionCode ec = 0;
-    
-    ContainerNode* parent = m_element2->parentNode();
+
+    auto* parent = m_element2->parentNode();
     if (!parent || !parent->hasEditableStyle())
         return;
-    parent->insertBefore(*m_element1, m_element2.get(), ec);
-    if (ec)
+    if (parent->insertBefore(*m_element1, m_element2.get()).hasException())
         return;
 
     // Delete id attribute from the second element because the same id cannot be used for more than one element
     m_element2->removeAttribute(HTMLNames::idAttr);
 
     for (auto& child : children)
-        m_element1->appendChild(child, ec);
+        m_element1->appendChild(child);
 }
     
 void SplitElementCommand::doApply()
@@ -86,7 +83,7 @@
     RefPtr<Node> refChild = m_element2->firstChild();
 
     for (auto& child : children)
-        m_element2->insertBefore(child, refChild.get(), IGNORE_EXCEPTION);
+        m_element2->insertBefore(child, refChild.get());
 
     // Recover the id attribute of the original element.
     const AtomicString& id = m_element1->getIdAttribute();
diff --git a/Source/WebCore/editing/SplitTextNodeCommand.cpp b/Source/WebCore/editing/SplitTextNodeCommand.cpp
index 7419be9..b0a4b21 100644
--- a/Source/WebCore/editing/SplitTextNodeCommand.cpp
+++ b/Source/WebCore/editing/SplitTextNodeCommand.cpp
@@ -97,9 +97,7 @@
 
 void SplitTextNodeCommand::insertText1AndTrimText2()
 {
-    ExceptionCode ec = 0;
-    m_text2->parentNode()->insertBefore(*m_text1, m_text2.get(), ec);
-    if (ec)
+    if (m_text2->parentNode()->insertBefore(*m_text1, m_text2.get()).hasException())
         return;
     m_text2->deleteData(0, m_offset);
 }
diff --git a/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp b/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
index a1ab245..f5314c3 100644
--- a/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
+++ b/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
@@ -44,9 +44,9 @@
         children.append(*child);
 
     for (auto& child : children)
-        m_dummySpan->appendChild(child, IGNORE_EXCEPTION);
+        m_dummySpan->appendChild(child);
 
-    m_element->appendChild(*m_dummySpan, IGNORE_EXCEPTION);
+    m_element->appendChild(*m_dummySpan);
 }
 
 void WrapContentsInDummySpanCommand::doApply()
@@ -66,7 +66,7 @@
         children.append(*child);
 
     for (auto& child : children)
-        m_element->appendChild(child, IGNORE_EXCEPTION);
+        m_element->appendChild(child);
 
     m_dummySpan->remove();
 }
diff --git a/Source/WebCore/editing/cocoa/EditorCocoa.mm b/Source/WebCore/editing/cocoa/EditorCocoa.mm
index bba814a..0e03b46 100644
--- a/Source/WebCore/editing/cocoa/EditorCocoa.mm
+++ b/Source/WebCore/editing/cocoa/EditorCocoa.mm
@@ -73,15 +73,11 @@
     String styleText = typingStyle->style()->asText() + " display: inline";
     styleElement->setAttribute(HTMLNames::styleAttr, styleText);
 
-    styleElement->appendChild(frame->document()->createEditingTextNode(emptyString()), ASSERT_NO_EXCEPTION);
+    styleElement->appendChild(frame->document()->createEditingTextNode(emptyString()));
 
-    ContainerNode* parentNode = position.deprecatedNode()->parentNode();
-
-    if (!parentNode->ensurePreInsertionValidity(styleElement.copyRef(), nullptr, IGNORE_EXCEPTION))
+    if (position.deprecatedNode()->parentNode()->appendChild(styleElement).hasException())
         return nullptr; 
 
-    parentNode->appendChild(styleElement, ASSERT_NO_EXCEPTION);
-
     nodeToRemove = styleElement.ptr();
 
     frame->document()->updateStyleIfNeeded();
diff --git a/Source/WebCore/editing/htmlediting.cpp b/Source/WebCore/editing/htmlediting.cpp
index bb1a8a6..68d94c6 100644
--- a/Source/WebCore/editing/htmlediting.cpp
+++ b/Source/WebCore/editing/htmlediting.cpp
@@ -935,7 +935,7 @@
     spanElement->setAttributeWithoutSynchronization(classAttr, AppleTabSpanClass);
     spanElement->setAttribute(styleAttr, "white-space:pre");
 
-    spanElement->appendChild(tabTextNode, ASSERT_NO_EXCEPTION);
+    spanElement->appendChild(tabTextNode);
 
     return spanElement;
 }
diff --git a/Source/WebCore/editing/ios/EditorIOS.mm b/Source/WebCore/editing/ios/EditorIOS.mm
index 8257278..279a379 100644
--- a/Source/WebCore/editing/ios/EditorIOS.mm
+++ b/Source/WebCore/editing/ios/EditorIOS.mm
@@ -375,10 +375,8 @@
 void Editor::WebContentReader::addFragment(RefPtr<DocumentFragment>&& newFragment)
 {
     if (fragment) {
-        if (newFragment && newFragment->firstChild()) {
-            ExceptionCode ec;
-            fragment->appendChild(*newFragment->firstChild(), ec);
-        }
+        if (newFragment && newFragment->firstChild())
+            fragment->appendChild(*newFragment->firstChild());
     } else
         fragment = WTFMove(newFragment);
 }
@@ -635,7 +633,6 @@
         return;
     }
 
-    ExceptionCode ec;
     RefPtr<Range> context = document().createRange();
     context->selectNodeContents(element);
 
@@ -643,7 +640,7 @@
     for (auto& interpretations : dictationPhrases)
         dictationPhrasesBuilder.append(interpretations[0]);
 
-    element.appendChild(createFragmentFromText(*context, dictationPhrasesBuilder.toString()), ec);
+    element.appendChild(createFragmentFromText(*context, dictationPhrasesBuilder.toString()));
 
     // We need a layout in order to add markers below.
     document().updateLayout();
@@ -712,7 +709,6 @@
         // FIXME: The element we're inserting into is often the body element. It seems strange to be removing it
         // (even if it is only temporary). ReplaceSelectionCommand doesn't bother doing this when it inserts
         // content, why should we here?
-        ExceptionCode ec;
         RefPtr<Node> parent = element.parentNode();
         RefPtr<Node> siblingAfter = element.nextSibling();
         if (parent)
@@ -720,14 +716,14 @@
 
         auto context = document().createRange();
         context->selectNodeContents(element);
-        element.appendChild(createFragmentFromText(context, text), ec);
+        element.appendChild(createFragmentFromText(context, text));
 
         // restore element to document
         if (parent) {
             if (siblingAfter)
-                parent->insertBefore(element, siblingAfter.get(), ec);
+                parent->insertBefore(element, siblingAfter.get());
             else
-                parent->appendChild(element, ec);
+                parent->appendChild(element);
         }
     }
 
diff --git a/Source/WebCore/editing/markup.cpp b/Source/WebCore/editing/markup.cpp
index ce6c96d..46da4e2 100644
--- a/Source/WebCore/editing/markup.cpp
+++ b/Source/WebCore/editing/markup.cpp
@@ -710,7 +710,7 @@
     Document& document = paragraph.document();
 
     if (string.isEmpty()) {
-        paragraph.appendChild(createBlockPlaceholderElement(document), ASSERT_NO_EXCEPTION);
+        paragraph.appendChild(createBlockPlaceholderElement(document));
         return;
     }
 
@@ -727,11 +727,11 @@
         // append the non-tab textual part
         if (!s.isEmpty()) {
             if (!tabText.isEmpty()) {
-                paragraph.appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
+                paragraph.appendChild(createTabSpanElement(document, tabText));
                 tabText = emptyString();
             }
             Ref<Node> textNode = document.createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
-            paragraph.appendChild(textNode, ASSERT_NO_EXCEPTION);
+            paragraph.appendChild(textNode);
         }
 
         // there is a tab after every entry, except the last entry
@@ -739,7 +739,7 @@
         if (i + 1 != numEntries)
             tabText.append('\t');
         else if (!tabText.isEmpty())
-            paragraph.appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
+            paragraph.appendChild(createTabSpanElement(document, tabText));
 
         first = false;
     }
@@ -792,11 +792,11 @@
     string.replace('\r', '\n');
 
     if (contextPreservesNewline(context)) {
-        fragment->appendChild(document.createTextNode(string), ASSERT_NO_EXCEPTION);
+        fragment->appendChild(document.createTextNode(string));
         if (string.endsWith('\n')) {
             auto element = HTMLBRElement::create(document);
             element->setAttributeWithoutSynchronization(classAttr, AppleInterchangeNewline);
-            fragment->appendChild(element, ASSERT_NO_EXCEPTION);
+            fragment->appendChild(element);
         }
         return fragment;
     }
@@ -838,7 +838,7 @@
                 element = createDefaultParagraphElement(document);
             fillContainerFromString(*element, s);
         }
-        fragment->appendChild(*element, ASSERT_NO_EXCEPTION);
+        fragment->appendChild(*element);
     }
     return fragment;
 }
@@ -942,10 +942,10 @@
     RefPtr<Node> nextChild;
     for (RefPtr<Node> child = element.firstChild(); child; child = nextChild) {
         nextChild = child->nextSibling();
-        element.removeChild(*child, ASSERT_NO_EXCEPTION);
-        fragment.insertBefore(*child, &element, ASSERT_NO_EXCEPTION);
+        element.removeChild(*child);
+        fragment.insertBefore(*child, &element);
     }
-    fragment.removeChild(element, ASSERT_NO_EXCEPTION);
+    fragment.removeChild(element);
 }
 
 ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element& element, const String& markup, ParserContentPolicy parserContentPolicy)
@@ -1018,19 +1018,11 @@
             return { };
         }
 
-        ExceptionCode ec = 0;
-        containerNode->replaceChild(fragment, *containerChild, ec);
-        if (ec)
-            return Exception { ec };
-        return { };
+        return containerNode->replaceChild(fragment, *containerChild);
     }
 
     containerNode->removeChildren();
-    ExceptionCode ec = 0;
-    containerNode->appendChild(fragment, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return containerNode->appendChild(fragment);
 }
 
 ExceptionOr<void> replaceChildrenWithText(ContainerNode& container, const String& text)
@@ -1045,20 +1037,11 @@
 
     auto textNode = Text::create(containerNode->document(), text);
 
-    if (hasOneChild(containerNode)) {
-        ExceptionCode ec = 0;
-        containerNode->replaceChild(textNode, *containerNode->firstChild(), ec);
-        if (ec)
-            return Exception { ec };
-        return { };
-    }
+    if (hasOneChild(containerNode))
+        return containerNode->replaceChild(textNode, *containerNode->firstChild());
 
     containerNode->removeChildren();
-    ExceptionCode ec = 0;
-    containerNode->appendChild(textNode, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return containerNode->appendChild(textNode);
 }
 
 }
diff --git a/Source/WebCore/html/ColorInputType.cpp b/Source/WebCore/html/ColorInputType.cpp
index 79bff1e..83704ee 100644
--- a/Source/WebCore/html/ColorInputType.cpp
+++ b/Source/WebCore/html/ColorInputType.cpp
@@ -127,8 +127,8 @@
     wrapperElement->setPseudo(AtomicString("-webkit-color-swatch-wrapper", AtomicString::ConstructFromLiteral));
     auto colorSwatch = HTMLDivElement::create(document);
     colorSwatch->setPseudo(AtomicString("-webkit-color-swatch", AtomicString::ConstructFromLiteral));
-    wrapperElement->appendChild(colorSwatch, ASSERT_NO_EXCEPTION);
-    element().userAgentShadowRoot()->appendChild(wrapperElement, ASSERT_NO_EXCEPTION);
+    wrapperElement->appendChild(colorSwatch);
+    element().userAgentShadowRoot()->appendChild(wrapperElement);
     
     updateColorSwatch();
 }
diff --git a/Source/WebCore/html/FTPDirectoryDocument.cpp b/Source/WebCore/html/FTPDirectoryDocument.cpp
index 2f75de0..8bbb0a4 100644
--- a/Source/WebCore/html/FTPDirectoryDocument.cpp
+++ b/Source/WebCore/html/FTPDirectoryDocument.cpp
@@ -105,26 +105,26 @@
     rowElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryEntryRow", AtomicString::ConstructFromLiteral));
 
     auto typeElement = document()->createElement(tdTag, false);
-    typeElement->appendChild(Text::create(*document(), String(&noBreakSpace, 1)), IGNORE_EXCEPTION);
+    typeElement->appendChild(Text::create(*document(), String(&noBreakSpace, 1)));
     if (isDirectory)
         typeElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryIcon ftpDirectoryTypeDirectory", AtomicString::ConstructFromLiteral));
     else
         typeElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryIcon ftpDirectoryTypeFile", AtomicString::ConstructFromLiteral));
-    rowElement->appendChild(typeElement, IGNORE_EXCEPTION);
+    rowElement->appendChild(typeElement);
 
     auto nameElement = createTDForFilename(filename);
     nameElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryFileName", AtomicString::ConstructFromLiteral));
-    rowElement->appendChild(nameElement, IGNORE_EXCEPTION);
+    rowElement->appendChild(nameElement);
 
     auto dateElement = document()->createElement(tdTag, false);
-    dateElement->appendChild(Text::create(*document(), date), IGNORE_EXCEPTION);
+    dateElement->appendChild(Text::create(*document(), date));
     dateElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryFileDate", AtomicString::ConstructFromLiteral));
-    rowElement->appendChild(dateElement, IGNORE_EXCEPTION);
+    rowElement->appendChild(dateElement);
 
     auto sizeElement = document()->createElement(tdTag, false);
-    sizeElement->appendChild(Text::create(*document(), size), IGNORE_EXCEPTION);
+    sizeElement->appendChild(Text::create(*document(), size));
     sizeElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryFileSize", AtomicString::ConstructFromLiteral));
-    rowElement->appendChild(sizeElement, IGNORE_EXCEPTION);
+    rowElement->appendChild(sizeElement);
 }
 
 Ref<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename)
@@ -137,10 +137,10 @@
 
     auto anchorElement = document()->createElement(aTag, false);
     anchorElement->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, fullURL);
-    anchorElement->appendChild(Text::create(*document(), filename), IGNORE_EXCEPTION);
+    anchorElement->appendChild(Text::create(*document(), filename));
 
     Ref<Element> tdElement = document()->createElement(tdTag, false);
-    tdElement->appendChild(anchorElement, IGNORE_EXCEPTION);
+    tdElement->appendChild(anchorElement);
 
     return tdElement;
 }
@@ -312,9 +312,9 @@
     // If that fails for some reason, cram it on the end of the document as a last
     // ditch effort
     if (auto* body = document()->bodyOrFrameset())
-        body->appendChild(*m_tableElement, IGNORE_EXCEPTION);
+        body->appendChild(*m_tableElement);
     else
-        document()->appendChild(*m_tableElement, IGNORE_EXCEPTION);
+        document()->appendChild(*m_tableElement);
 
     return true;
 }
@@ -327,14 +327,14 @@
 
     Ref<Element> bodyElement = document()->createElement(bodyTag, false);
 
-    document()->appendChild(bodyElement, IGNORE_EXCEPTION);
+    document()->appendChild(bodyElement);
 
     auto tableElement = document()->createElement(tableTag, false);
     m_tableElement = downcast<HTMLTableElement>(tableElement.ptr());
     m_tableElement->setAttributeWithoutSynchronization(HTMLNames::idAttr, AtomicString("ftpDirectoryTable", AtomicString::ConstructFromLiteral));
     m_tableElement->setAttribute(HTMLNames::styleAttr, AtomicString("width:100%", AtomicString::ConstructFromLiteral));
 
-    bodyElement->appendChild(tableElement, IGNORE_EXCEPTION);
+    bodyElement->appendChild(tableElement);
 
     document()->processViewport("width=device-width", ViewportArguments::ViewportMeta);
 }
diff --git a/Source/WebCore/html/FileInputType.cpp b/Source/WebCore/html/FileInputType.cpp
index 7f25613..63f0273 100644
--- a/Source/WebCore/html/FileInputType.cpp
+++ b/Source/WebCore/html/FileInputType.cpp
@@ -261,7 +261,7 @@
 void FileInputType::createShadowSubtree()
 {
     ASSERT(element().shadowRoot());
-    element().userAgentShadowRoot()->appendChild(element().multiple() ? UploadButtonElement::createForMultiple(element().document()): UploadButtonElement::create(element().document()), IGNORE_EXCEPTION);
+    element().userAgentShadowRoot()->appendChild(element().multiple() ? UploadButtonElement::createForMultiple(element().document()): UploadButtonElement::create(element().document()));
 }
 
 void FileInputType::disabledAttributeChanged()
diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp
index 16fac0e..46bd359 100644
--- a/Source/WebCore/html/HTMLAnchorElement.cpp
+++ b/Source/WebCore/html/HTMLAnchorElement.cpp
@@ -343,7 +343,7 @@
 
 void HTMLAnchorElement::setText(const String& text)
 {
-    setTextContent(text, ASSERT_NO_EXCEPTION);
+    setTextContent(text);
 }
 
 bool HTMLAnchorElement::isLiveLink() const
diff --git a/Source/WebCore/html/HTMLDetailsElement.cpp b/Source/WebCore/html/HTMLDetailsElement.cpp
index 6184dae..35c39e0 100644
--- a/Source/WebCore/html/HTMLDetailsElement.cpp
+++ b/Source/WebCore/html/HTMLDetailsElement.cpp
@@ -113,7 +113,7 @@
     m_summarySlot = summarySlot.ptr();
 
     auto defaultSummary = HTMLSummaryElement::create(summaryTag, document());
-    defaultSummary->appendChild(Text::create(document(), defaultDetailsSummaryText()), ASSERT_NO_EXCEPTION);
+    defaultSummary->appendChild(Text::create(document(), defaultDetailsSummaryText()));
     m_defaultSummary = defaultSummary.ptr();
 
     summarySlot->appendChild(defaultSummary);
diff --git a/Source/WebCore/html/HTMLElement.cpp b/Source/WebCore/html/HTMLElement.cpp
index b30d76a..ed38a1c 100644
--- a/Source/WebCore/html/HTMLElement.cpp
+++ b/Source/WebCore/html/HTMLElement.cpp
@@ -449,17 +449,16 @@
                 break;
         }
 
-        ExceptionCode ec = 0;
-        fragment->appendChild(Text::create(document(), text.substring(start, i - start)), ec);
-        if (ec)
-            return Exception { ec };
+        auto appendResult = fragment->appendChild(Text::create(document(), text.substring(start, i - start)));
+        if (appendResult.hasException())
+            return appendResult.releaseException();
 
         if (i == length)
             break;
 
-        fragment->appendChild(HTMLBRElement::create(document()), ec);
-        if (ec)
-            return Exception { ec };
+        appendResult = fragment->appendChild(HTMLBRElement::create(document()));
+        if (appendResult.hasException())
+            return appendResult.releaseException();
 
         // Make sure \r\n doesn't result in two line breaks.
         if (c == '\r' && i + 1 < length && text[i + 1] == '\n')
@@ -577,10 +576,9 @@
     if (!parentNode())
         return Exception { HIERARCHY_REQUEST_ERR };
 
-    ExceptionCode ec = 0;
-    parent->replaceChild(*newChild, *this, ec);
-    if (ec)
-        return Exception { ec };
+    auto replaceResult = parent->replaceChild(*newChild, *this);
+    if (replaceResult.hasException())
+        return replaceResult.releaseException();
 
     RefPtr<Node> node = next ? next->previousSibling() : nullptr;
     if (is<Text>(node.get())) {
diff --git a/Source/WebCore/html/HTMLKeygenElement.cpp b/Source/WebCore/html/HTMLKeygenElement.cpp
index 28f8638..f7212c5 100644
--- a/Source/WebCore/html/HTMLKeygenElement.cpp
+++ b/Source/WebCore/html/HTMLKeygenElement.cpp
@@ -77,11 +77,11 @@
     auto select = KeygenSelectElement::create(document);
     for (auto& key : keys) {
         auto option = HTMLOptionElement::create(document);
-        select->appendChild(option, IGNORE_EXCEPTION);
-        option->appendChild(Text::create(document, key), IGNORE_EXCEPTION);
+        select->appendChild(option);
+        option->appendChild(Text::create(document, key));
     }
 
-    ensureUserAgentShadowRoot().appendChild(select, IGNORE_EXCEPTION);
+    ensureUserAgentShadowRoot().appendChild(select);
 }
 
 Ref<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 7e6afbd4..4422b38 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -5786,7 +5786,7 @@
     if (isFullscreen())
         mediaControls->enteredFullscreen();
 
-    ensureUserAgentShadowRoot().appendChild(mediaControls, ASSERT_NO_EXCEPTION);
+    ensureUserAgentShadowRoot().appendChild(mediaControls);
 
     if (!controls() || !inDocument())
         mediaControls->hide();
diff --git a/Source/WebCore/html/HTMLMeterElement.cpp b/Source/WebCore/html/HTMLMeterElement.cpp
index 7e12e15..f545749 100644
--- a/Source/WebCore/html/HTMLMeterElement.cpp
+++ b/Source/WebCore/html/HTMLMeterElement.cpp
@@ -231,7 +231,7 @@
     static NeverDestroyed<String> shadowStyle(meterElementShadowUserAgentStyleSheet, String::ConstructFromLiteral);
 
     auto style = HTMLStyleElement::create(HTMLNames::styleTag, document(), false);
-    style->setTextContent(shadowStyle, IGNORE_EXCEPTION);
+    style->setTextContent(shadowStyle);
     root->appendChild(style);
 
     // Pseudos are set to allow author styling.
@@ -243,11 +243,11 @@
     auto bar = HTMLDivElement::create(document());
     bar->setIdAttribute("bar");
     bar->setPseudo("-webkit-meter-bar");
-    inner->appendChild(bar, ASSERT_NO_EXCEPTION);
+    inner->appendChild(bar);
 
     m_value = HTMLDivElement::create(document());
     m_value->setIdAttribute("value");
-    bar->appendChild(*m_value, ASSERT_NO_EXCEPTION);
+    bar->appendChild(*m_value);
 
     didElementStateChange();
 }
diff --git a/Source/WebCore/html/HTMLOptionElement.cpp b/Source/WebCore/html/HTMLOptionElement.cpp
index f10580c..b82a8b1 100644
--- a/Source/WebCore/html/HTMLOptionElement.cpp
+++ b/Source/WebCore/html/HTMLOptionElement.cpp
@@ -73,10 +73,9 @@
 
     auto text = Text::create(document, data.isNull() ? emptyString() : data);
 
-    ExceptionCode ec = 0;
-    element->appendChild(text, ec);
-    if (ec)
-        return Exception { ec };
+    auto appendResult = element->appendChild(text);
+    if (appendResult.hasException())
+        return appendResult.releaseException();
 
     if (!value.isNull())
         element->setValue(value);
@@ -127,7 +126,7 @@
         downcast<Text>(*child).setData(text);
     else {
         removeChildren();
-        appendChild(Text::create(document(), text), ASSERT_NO_EXCEPTION);
+        appendChild(Text::create(document(), text));
     }
     
     if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex)
diff --git a/Source/WebCore/html/HTMLOptionsCollection.cpp b/Source/WebCore/html/HTMLOptionsCollection.cpp
index a44e24d..c44edb8 100644
--- a/Source/WebCore/html/HTMLOptionsCollection.cpp
+++ b/Source/WebCore/html/HTMLOptionsCollection.cpp
@@ -43,7 +43,7 @@
 
 void HTMLOptionsCollection::remove(int index)
 {
-    selectElement().removeByIndex(index);
+    selectElement().remove(index);
 }
 
 void HTMLOptionsCollection::remove(HTMLOptionElement& option)
diff --git a/Source/WebCore/html/HTMLOutputElement.cpp b/Source/WebCore/html/HTMLOutputElement.cpp
index bbb9b7a..7222a9a 100644
--- a/Source/WebCore/html/HTMLOutputElement.cpp
+++ b/Source/WebCore/html/HTMLOutputElement.cpp
@@ -138,7 +138,7 @@
 {
     ASSERT(!m_isSetTextContentInProgress);
     m_isSetTextContentInProgress = true;
-    setTextContent(value, IGNORE_EXCEPTION);
+    setTextContent(value);
 }
 
 } // namespace
diff --git a/Source/WebCore/html/HTMLProgressElement.cpp b/Source/WebCore/html/HTMLProgressElement.cpp
index c860024..d5a6ef4 100644
--- a/Source/WebCore/html/HTMLProgressElement.cpp
+++ b/Source/WebCore/html/HTMLProgressElement.cpp
@@ -148,9 +148,9 @@
     auto value = ProgressValueElement::create(document());
     m_value = value.ptr();
     m_value->setWidthPercentage(HTMLProgressElement::IndeterminatePosition * 100);
-    bar->appendChild(value, ASSERT_NO_EXCEPTION);
+    bar->appendChild(value);
 
-    inner->appendChild(bar, ASSERT_NO_EXCEPTION);
+    inner->appendChild(bar);
 }
 
 bool HTMLProgressElement::shouldAppearIndeterminate() const
diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp
index 73777b0..edc27b9 100644
--- a/Source/WebCore/html/HTMLScriptElement.cpp
+++ b/Source/WebCore/html/HTMLScriptElement.cpp
@@ -82,7 +82,7 @@
 // https://html.spec.whatwg.org/multipage/scripting.html#dom-script-text
 void HTMLScriptElement::setText(const String& value)
 {
-    setTextContent(value, ASSERT_NO_EXCEPTION);
+    setTextContent(value);
 }
 
 void HTMLScriptElement::setAsync(bool async)
diff --git a/Source/WebCore/html/HTMLSelectElement.cpp b/Source/WebCore/html/HTMLSelectElement.cpp
index 6433042..cc166f6 100644
--- a/Source/WebCore/html/HTMLSelectElement.cpp
+++ b/Source/WebCore/html/HTMLSelectElement.cpp
@@ -233,14 +233,10 @@
     );
 
 
-    ExceptionCode ec = 0;
-    insertBefore(toInsert, beforeElement, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return insertBefore(toInsert, beforeElement);
 }
 
-void HTMLSelectElement::removeByIndex(int optionIndex)
+void HTMLSelectElement::remove(int optionIndex)
 {
     int listIndex = optionToListIndex(optionIndex);
     if (listIndex < 0)
@@ -444,7 +440,7 @@
         // Replace an existing entry?
     } else if (diff < 0) {
         before = item(index + 1);
-        removeByIndex(index);
+        remove(index);
     }
     // Finally add the new element.
     auto result = add(&option, HTMLElementOrInt { before.get() });
diff --git a/Source/WebCore/html/HTMLSelectElement.h b/Source/WebCore/html/HTMLSelectElement.h
index bee1dd3..7db155b 100644
--- a/Source/WebCore/html/HTMLSelectElement.h
+++ b/Source/WebCore/html/HTMLSelectElement.h
@@ -57,7 +57,7 @@
 
     using Node::remove;
     ExceptionOr<void> remove(HTMLOptionElement&);
-    WEBCORE_EXPORT void removeByIndex(int); // Should be remove(int) but that conflicts with Node::remove(ExceptionCode&).
+    WEBCORE_EXPORT void remove(int);
 
     WEBCORE_EXPORT String value() const;
     WEBCORE_EXPORT void setValue(const String&);
diff --git a/Source/WebCore/html/HTMLSelectElement.idl b/Source/WebCore/html/HTMLSelectElement.idl
index 957f13b..06bf06d 100644
--- a/Source/WebCore/html/HTMLSelectElement.idl
+++ b/Source/WebCore/html/HTMLSelectElement.idl
@@ -43,9 +43,8 @@
     [CEReactions, MayThrowException] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
 
     [MayThrowException] void remove(); // ChildNode overload
-    // FIXME: This overload is not in the specification and was dropped in Blink.
-    [CEReactions] void remove(HTMLOptionElement option);
-    [CEReactions, ImplementedAs=removeByIndex] void remove(long index);
+    [CEReactions] void remove(HTMLOptionElement option); // FIXME: This overload is not in the specification and was dropped in Blink
+    [CEReactions] void remove(long index);
 
     readonly attribute HTMLCollection selectedOptions;
     attribute long selectedIndex;
diff --git a/Source/WebCore/html/HTMLSummaryElement.cpp b/Source/WebCore/html/HTMLSummaryElement.cpp
index ffa4d80..fb1fb9c 100644
--- a/Source/WebCore/html/HTMLSummaryElement.cpp
+++ b/Source/WebCore/html/HTMLSummaryElement.cpp
@@ -57,7 +57,7 @@
 
 void HTMLSummaryElement::didAddUserAgentShadowRoot(ShadowRoot* root)
 {
-    root->appendChild(DetailsMarkerControl::create(document()), ASSERT_NO_EXCEPTION);
+    root->appendChild(DetailsMarkerControl::create(document()));
     root->appendChild(HTMLSlotElement::create(slotTag, document()));
 }
 
diff --git a/Source/WebCore/html/HTMLTableElement.cpp b/Source/WebCore/html/HTMLTableElement.cpp
index 892f3a6..c2bbae4 100644
--- a/Source/WebCore/html/HTMLTableElement.cpp
+++ b/Source/WebCore/html/HTMLTableElement.cpp
@@ -50,11 +50,6 @@
 
 HTMLTableElement::HTMLTableElement(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document)
-    , m_borderAttr(false)
-    , m_borderColorAttr(false)
-    , m_frameAttr(false)
-    , m_rulesAttr(UnsetRules)
-    , m_padding(1)
 {
     ASSERT(hasTagName(tableTag));
 }
@@ -71,23 +66,15 @@
 
 HTMLTableCaptionElement* HTMLTableElement::caption() const
 {
-    for (Node* child = firstChild(); child; child = child->nextSibling()) {
-        if (is<HTMLTableCaptionElement>(*child))
-            return downcast<HTMLTableCaptionElement>(child);
-    }
-    return nullptr;
+    return childrenOfType<HTMLTableCaptionElement>(const_cast<HTMLTableElement&>(*this)).first();
 }
 
 ExceptionOr<void> HTMLTableElement::setCaption(RefPtr<HTMLTableCaptionElement>&& newCaption)
 {
     deleteCaption();
-    if (newCaption) {
-        ExceptionCode ec = 0;
-        insertBefore(*newCaption, firstChild(), ec);
-        if (ec)
-            return Exception { ec };
-    }
-    return { };
+    if (!newCaption)
+        return { };
+    return insertBefore(*newCaption, firstChild());
 }
 
 HTMLTableSectionElement* HTMLTableElement::tHead() const
@@ -105,7 +92,6 @@
         return Exception { HIERARCHY_REQUEST_ERR };
 
     deleteTHead();
-
     if (!newHead)
         return { };
 
@@ -115,11 +101,7 @@
             break;
     }
 
-    ExceptionCode ec = 0;
-    insertBefore(*newHead, child, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return insertBefore(*newHead, child);
 }
 
 HTMLTableSectionElement* HTMLTableElement::tFoot() const
@@ -135,17 +117,10 @@
 {
     if (UNLIKELY(newFoot && !newFoot->hasTagName(tfootTag)))
         return Exception { HIERARCHY_REQUEST_ERR };
-
     deleteTFoot();
-
     if (!newFoot)
         return { };
-
-    ExceptionCode ec = 0;
-    appendChild(*newFoot, ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return appendChild(*newFoot);
 }
 
 Ref<HTMLTableSectionElement> HTMLTableElement::createTHead()
@@ -175,14 +150,14 @@
 void HTMLTableElement::deleteTFoot()
 {
     if (auto* foot = tFoot())
-        removeChild(*foot, IGNORE_EXCEPTION);
+        removeChild(*foot);
 }
 
 Ref<HTMLTableSectionElement> HTMLTableElement::createTBody()
 {
     auto body = HTMLTableSectionElement::create(tbodyTag, document());
     Node* referenceElement = lastBody() ? lastBody()->nextSibling() : nullptr;
-    insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION);
+    insertBefore(body, referenceElement);
     return body;
 }
 
@@ -198,7 +173,7 @@
 void HTMLTableElement::deleteCaption()
 {
     if (auto* caption = this->caption())
-        removeChild(*caption, IGNORE_EXCEPTION);
+        removeChild(*caption);
 }
 
 HTMLTableSectionElement* HTMLTableElement::lastBody() const
@@ -241,21 +216,19 @@
         if (!parent) {
             auto newBody = HTMLTableSectionElement::create(tbodyTag, document());
             auto newRow = HTMLTableRowElement::create(document());
-            ExceptionCode ec = 0;
-            newBody->appendChild(newRow, ec);
+            newBody->appendChild(newRow);
             // FIXME: Why ignore the exception if the first appendChild failed?
-            appendChild(newBody, ec);
-            if (ec)
-                return Exception { ec };
+            auto result = appendChild(newBody);
+            if (result.hasException())
+                return result.releaseException();
             return Ref<HTMLElement> { WTFMove(newRow) };
         }
     }
 
     auto newRow = HTMLTableRowElement::create(document());
-    ExceptionCode ec = 0;
-    parent->insertBefore(newRow, row.get(), ec);
-    if (ec)
-        return Exception { ec };
+    auto result = parent->insertBefore(newRow, row.get());
+    if (result.hasException())
+        return result.releaseException();
     return Ref<HTMLElement> { WTFMove(newRow) };
 }
 
diff --git a/Source/WebCore/html/HTMLTableElement.h b/Source/WebCore/html/HTMLTableElement.h
index b5ae724..2ea72e6 100644
--- a/Source/WebCore/html/HTMLTableElement.h
+++ b/Source/WebCore/html/HTMLTableElement.h
@@ -89,13 +89,11 @@
 
     HTMLTableSectionElement* lastBody() const;
 
-    bool m_borderAttr;          // Sets a precise border width and creates an outset border for the table and for its cells.
-    bool m_borderColorAttr;     // Overrides the outset border and makes it solid for the table and cells instead.
-    bool m_frameAttr;           // Implies a thin border width if no border is set and then a certain set of solid/hidden borders based off the value.
-    TableRules m_rulesAttr;     // Implies a thin border width, a collapsing border model, and all borders on the table becoming set to hidden (if frame/border
-                                // are present, to none otherwise).
-
-    unsigned short m_padding;
+    bool m_borderAttr { false }; // Sets a precise border width and creates an outset border for the table and for its cells.
+    bool m_borderColorAttr { false }; // Overrides the outset border and makes it solid for the table and cells instead.
+    bool m_frameAttr { false }; // Implies a thin border width if no border is set and then a certain set of solid/hidden borders based off the value.
+    TableRules m_rulesAttr { UnsetRules }; // Implies a thin border width, a collapsing border model, and all borders on the table becoming set to hidden (if frame/border are present, to none otherwise).
+    unsigned short m_padding { 1 };
     RefPtr<StyleProperties> m_sharedCellStyle;
 };
 
diff --git a/Source/WebCore/html/HTMLTableRowElement.cpp b/Source/WebCore/html/HTMLTableRowElement.cpp
index 342448c..0788f20 100644
--- a/Source/WebCore/html/HTMLTableRowElement.cpp
+++ b/Source/WebCore/html/HTMLTableRowElement.cpp
@@ -118,19 +118,13 @@
     if (index > numCells)
         return Exception { INDEX_SIZE_ERR };
     auto cell = HTMLTableCellElement::create(tdTag, document());
-    ExceptionCode ec = 0;
+    ExceptionOr<void> result;
     if (index < 0 || index >= numCells)
-        appendChild(cell, ec);
-    else {
-        Node* n;
-        if (index < 1)
-            n = firstChild();
-        else
-            n = children->item(index);
-        insertBefore(cell, n, ec);
-    }
-    if (ec)
-        return Exception { ec };
+        result = appendChild(cell);
+    else
+        result = insertBefore(cell, index < 1 ? firstChild() : children->item(index));
+    if (result.hasException())
+        return result.releaseException();
     return WTFMove(cell);
 }
 
@@ -145,11 +139,7 @@
     }
     if (index < 0 || index >= numCells)
         return Exception { INDEX_SIZE_ERR };
-    ExceptionCode ec = 0;
-    removeChild(*children->item(index), ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return removeChild(*children->item(index));
 }
 
 Ref<HTMLCollection> HTMLTableRowElement::cells()
diff --git a/Source/WebCore/html/HTMLTableSectionElement.cpp b/Source/WebCore/html/HTMLTableSectionElement.cpp
index 84f1062..1861b03 100644
--- a/Source/WebCore/html/HTMLTableSectionElement.cpp
+++ b/Source/WebCore/html/HTMLTableSectionElement.cpp
@@ -66,19 +66,13 @@
     if (index > numRows)
         return Exception { INDEX_SIZE_ERR };
     auto row = HTMLTableRowElement::create(trTag, document());
-    ExceptionCode ec = 0;
+    ExceptionOr<void> result;
     if (numRows == index || index == -1)
-        appendChild(row, ec);
-    else {
-        Node* n;
-        if (index < 1)
-            n = firstChild();
-        else
-            n = children->item(index);
-        insertBefore(row, n, ec);
-    }
-    if (ec)
-        return Exception { ec };
+        result = appendChild(row);
+    else
+        result = insertBefore(row, index < 1 ? firstChild() : children->item(index));
+    if (result.hasException())
+        return result.releaseException();
     return Ref<HTMLElement> { WTFMove(row) };
 }
 
@@ -93,11 +87,7 @@
     }
     if (index < 0 || index >= numRows)
         return Exception { INDEX_SIZE_ERR };
-    ExceptionCode ec = 0;
-    removeChild(*children->item(index), ec);
-    if (ec)
-        return Exception { ec };
-    return { };
+    return removeChild(*children->item(index));
 }
 
 int HTMLTableSectionElement::numRows() const
diff --git a/Source/WebCore/html/HTMLTextAreaElement.cpp b/Source/WebCore/html/HTMLTextAreaElement.cpp
index 1fdbc51..8b7fe4a 100644
--- a/Source/WebCore/html/HTMLTextAreaElement.cpp
+++ b/Source/WebCore/html/HTMLTextAreaElement.cpp
@@ -105,7 +105,7 @@
 
 void HTMLTextAreaElement::didAddUserAgentShadowRoot(ShadowRoot* root)
 {
-    root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO_EXCEPTION);
+    root->appendChild(TextControlInnerTextElement::create(document()));
     updateInnerTextElementEditability();
 }
 
@@ -416,14 +416,14 @@
         textNodes.append(*textNode);
 
     for (auto& textNode : textNodes)
-        removeChild(textNode.get(), IGNORE_EXCEPTION);
+        removeChild(textNode.get());
 
     // Normalize line endings.
     String value = defaultValue;
     value.replace("\r\n", "\n");
     value.replace('\r', '\n');
 
-    insertBefore(document().createTextNode(value), firstChild(), IGNORE_EXCEPTION);
+    insertBefore(document().createTextNode(value), firstChild());
 
     if (!m_isDirty)
         setNonDirtyValue(value);
@@ -546,7 +546,7 @@
     String placeholderText = strippedPlaceholder();
     if (placeholderText.isEmpty()) {
         if (m_placeholder) {
-            userAgentShadowRoot()->removeChild(*m_placeholder, ASSERT_NO_EXCEPTION);
+            userAgentShadowRoot()->removeChild(*m_placeholder);
             m_placeholder = nullptr;
         }
         return;
diff --git a/Source/WebCore/html/HTMLTextFormControlElement.cpp b/Source/WebCore/html/HTMLTextFormControlElement.cpp
index 622e5ad..7db914f 100644
--- a/Source/WebCore/html/HTMLTextFormControlElement.cpp
+++ b/Source/WebCore/html/HTMLTextFormControlElement.cpp
@@ -560,7 +560,7 @@
         innerText->setInnerText(value);
 
         if (value.endsWith('\n') || value.endsWith('\r'))
-            innerText->appendChild(HTMLBRElement::create(document()), ASSERT_NO_EXCEPTION);
+            innerText->appendChild(HTMLBRElement::create(document()));
 
 #if HAVE(ACCESSIBILITY) && PLATFORM(COCOA)
         if (textIsChanged && renderer()) {
diff --git a/Source/WebCore/html/HTMLTitleElement.cpp b/Source/WebCore/html/HTMLTitleElement.cpp
index c008d6a..7c81eab 100644
--- a/Source/WebCore/html/HTMLTitleElement.cpp
+++ b/Source/WebCore/html/HTMLTitleElement.cpp
@@ -94,7 +94,7 @@
 
 void HTMLTitleElement::setText(const String& value)
 {
-    setTextContent(value, ASSERT_NO_EXCEPTION);
+    setTextContent(value);
 }
 
 }
diff --git a/Source/WebCore/html/MediaDocument.cpp b/Source/WebCore/html/MediaDocument.cpp
index 5707bbf..6a970e2 100644
--- a/Source/WebCore/html/MediaDocument.cpp
+++ b/Source/WebCore/html/MediaDocument.cpp
@@ -81,7 +81,7 @@
 void MediaDocumentParser::createDocumentStructure()
 {
     auto rootElement = document()->createElement(htmlTag, false);
-    document()->appendChild(rootElement, IGNORE_EXCEPTION);
+    document()->appendChild(rootElement);
     document()->setCSSTarget(rootElement.ptr());
     downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
 
@@ -90,16 +90,16 @@
 
 #if PLATFORM(IOS)
     auto headElement = document()->createElement(headTag, false);
-    rootElement->appendChild(headElement, IGNORE_EXCEPTION);
+    rootElement->appendChild(headElement);
 
     auto metaElement = document()->createElement(metaTag, false);
     metaElement->setAttributeWithoutSynchronization(nameAttr, AtomicString("viewport", AtomicString::ConstructFromLiteral));
     metaElement->setAttributeWithoutSynchronization(contentAttr, AtomicString("width=device-width,initial-scale=1,user-scalable=no", AtomicString::ConstructFromLiteral));
-    headElement->appendChild(metaElement, IGNORE_EXCEPTION);
+    headElement->appendChild(metaElement);
 #endif
 
     auto body = document()->createElement(bodyTag, false);
-    rootElement->appendChild(body, IGNORE_EXCEPTION);
+    rootElement->appendChild(body);
 
     auto mediaElement = document()->createElement(videoTag, false);
 
@@ -123,8 +123,8 @@
     if (DocumentLoader* loader = document()->loader())
         source.setType(loader->responseMIMEType());
 
-    m_mediaElement->appendChild(sourceElement, IGNORE_EXCEPTION);
-    body->appendChild(mediaElement, IGNORE_EXCEPTION);
+    m_mediaElement->appendChild(sourceElement);
+    body->appendChild(mediaElement);
 
     Frame* frame = document()->frame();
     if (!frame)
@@ -255,7 +255,7 @@
         if (documentLoader)
             embedElement.setAttributeWithoutSynchronization(typeAttr, documentLoader->writer().mimeType());
 
-        videoElement->parentNode()->replaceChild(embedElement, *videoElement, IGNORE_EXCEPTION);
+        videoElement->parentNode()->replaceChild(embedElement, *videoElement);
     }
 }
 
diff --git a/Source/WebCore/html/PluginDocument.cpp b/Source/WebCore/html/PluginDocument.cpp
index 5437249..c439e6b 100644
--- a/Source/WebCore/html/PluginDocument.cpp
+++ b/Source/WebCore/html/PluginDocument.cpp
@@ -67,7 +67,7 @@
 void PluginDocumentParser::createDocumentStructure()
 {
     auto rootElement = document()->createElement(htmlTag, false);
-    document()->appendChild(rootElement, IGNORE_EXCEPTION);
+    document()->appendChild(rootElement);
     downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
 
     if (document()->frame())
@@ -87,7 +87,7 @@
     body->setAttribute(styleAttr, AtomicString("background-color: rgb(38,38,38)", AtomicString::ConstructFromLiteral));
 #endif
 
-    rootElement->appendChild(body, IGNORE_EXCEPTION);
+    rootElement->appendChild(body);
         
     auto embedElement = document()->createElement(embedTag, false);
         
@@ -105,7 +105,7 @@
 
     downcast<PluginDocument>(*document()).setPluginElement(m_embedElement);
 
-    body->appendChild(embedElement, IGNORE_EXCEPTION);
+    body->appendChild(embedElement);
 }
 
 void PluginDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
diff --git a/Source/WebCore/html/RangeInputType.cpp b/Source/WebCore/html/RangeInputType.cpp
index 634d7ec..90aed66 100644
--- a/Source/WebCore/html/RangeInputType.cpp
+++ b/Source/WebCore/html/RangeInputType.cpp
@@ -255,10 +255,10 @@
     Document& document = element().document();
     auto track = HTMLDivElement::create(document);
     track->setPseudo(AtomicString("-webkit-slider-runnable-track", AtomicString::ConstructFromLiteral));
-    track->appendChild(SliderThumbElement::create(document), IGNORE_EXCEPTION);
+    track->appendChild(SliderThumbElement::create(document));
     auto container = SliderContainerElement::create(document);
-    container->appendChild(track, IGNORE_EXCEPTION);
-    element().userAgentShadowRoot()->appendChild(container, IGNORE_EXCEPTION);
+    container->appendChild(track);
+    element().userAgentShadowRoot()->appendChild(container);
 }
 
 HTMLElement* RangeInputType::sliderTrackElement() const
diff --git a/Source/WebCore/html/SearchInputType.cpp b/Source/WebCore/html/SearchInputType.cpp
index 7b23216..f5d2bb9 100644
--- a/Source/WebCore/html/SearchInputType.cpp
+++ b/Source/WebCore/html/SearchInputType.cpp
@@ -110,11 +110,11 @@
     auto resultsButton = SearchFieldResultsButtonElement::create(element().document());
     m_resultsButton = resultsButton.ptr();
     updateResultButtonPseudoType(resultsButton.get(), element().maxResults());
-    container->insertBefore(resultsButton, textWrapper, IGNORE_EXCEPTION);
+    container->insertBefore(resultsButton, textWrapper);
 
     auto cancelButton = SearchFieldCancelButtonElement::create(element().document());
     m_cancelButton = cancelButton.ptr();
-    container->insertBefore(cancelButton, textWrapper->nextSibling(), IGNORE_EXCEPTION);
+    container->insertBefore(cancelButton, textWrapper->nextSibling());
 }
 
 HTMLElement* SearchInputType::resultsButtonElement() const
diff --git a/Source/WebCore/html/TextFieldInputType.cpp b/Source/WebCore/html/TextFieldInputType.cpp
index d7ad4e0..ee632ab 100644
--- a/Source/WebCore/html/TextFieldInputType.cpp
+++ b/Source/WebCore/html/TextFieldInputType.cpp
@@ -270,7 +270,7 @@
     m_innerText = TextControlInnerTextElement::create(document);
 
     if (!createsContainer) {
-        element().userAgentShadowRoot()->appendChild(*m_innerText, IGNORE_EXCEPTION);
+        element().userAgentShadowRoot()->appendChild(*m_innerText);
         updatePlaceholderText();
         return;
     }
@@ -280,7 +280,7 @@
 
     if (shouldHaveSpinButton) {
         m_innerSpinButton = SpinButtonElement::create(document, *this);
-        m_container->appendChild(*m_innerSpinButton, IGNORE_EXCEPTION);
+        m_container->appendChild(*m_innerSpinButton);
     }
 
     if (shouldHaveCapsLockIndicator) {
@@ -290,7 +290,7 @@
         bool shouldDrawCapsLockIndicator = this->shouldDrawCapsLockIndicator();
         m_capsLockIndicator->setInlineStyleProperty(CSSPropertyDisplay, shouldDrawCapsLockIndicator ? CSSValueBlock : CSSValueNone, true);
 
-        m_container->appendChild(*m_capsLockIndicator, IGNORE_EXCEPTION);
+        m_container->appendChild(*m_capsLockIndicator);
     }
 
     updateAutoFillButton();
@@ -500,14 +500,14 @@
     String placeholderText = element().strippedPlaceholder();
     if (placeholderText.isEmpty()) {
         if (m_placeholder) {
-            m_placeholder->parentNode()->removeChild(*m_placeholder, ASSERT_NO_EXCEPTION);
+            m_placeholder->parentNode()->removeChild(*m_placeholder);
             m_placeholder = nullptr;
         }
         return;
     }
     if (!m_placeholder) {
         m_placeholder = TextControlPlaceholderElement::create(element().document());
-        element().userAgentShadowRoot()->insertBefore(*m_placeholder, m_container ? m_container.get() : innerTextElement(), ASSERT_NO_EXCEPTION);        
+        element().userAgentShadowRoot()->insertBefore(*m_placeholder, m_container ? m_container.get() : innerTextElement());
     }
     m_placeholder->setInnerText(placeholderText);
 }
@@ -645,10 +645,10 @@
     m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral));
 
     m_innerBlock = TextControlInnerElement::create(element().document());
-    m_innerBlock->appendChild(*m_innerText, IGNORE_EXCEPTION);
-    m_container->appendChild(*m_innerBlock, IGNORE_EXCEPTION);
+    m_innerBlock->appendChild(*m_innerText);
+    m_container->appendChild(*m_innerBlock);
 
-    element().userAgentShadowRoot()->appendChild(*m_container, IGNORE_EXCEPTION);
+    element().userAgentShadowRoot()->appendChild(*m_container);
 }
 
 void TextFieldInputType::createAutoFillButton(AutoFillButtonType autoFillButtonType)
@@ -662,7 +662,7 @@
     m_autoFillButton->setPseudo(autoFillButtonTypeToAutoFillButtonPseudoClassName(autoFillButtonType));
     m_autoFillButton->setAttributeWithoutSynchronization(roleAttr, AtomicString("button", AtomicString::ConstructFromLiteral));
     m_autoFillButton->setAttributeWithoutSynchronization(aria_labelAttr, autoFillButtonTypeToAccessibilityLabel(autoFillButtonType));
-    m_container->appendChild(*m_autoFillButton, IGNORE_EXCEPTION);
+    m_container->appendChild(*m_autoFillButton);
 }
 
 void TextFieldInputType::updateAutoFillButton()
diff --git a/Source/WebCore/html/ValidationMessage.cpp b/Source/WebCore/html/ValidationMessage.cpp
index ab0c2f2..77abef0 100644
--- a/Source/WebCore/html/ValidationMessage.cpp
+++ b/Source/WebCore/html/ValidationMessage.cpp
@@ -133,9 +133,9 @@
     Document& document = m_messageHeading->document();
     for (unsigned i = 0; i < lines.size(); ++i) {
         if (i) {
-            m_messageBody->appendChild(Text::create(document, lines[i]), ASSERT_NO_EXCEPTION);
+            m_messageBody->appendChild(Text::create(document, lines[i]));
             if (i < lines.size() - 1)
-                m_messageBody->appendChild(HTMLBRElement::create(document), ASSERT_NO_EXCEPTION);
+                m_messageBody->appendChild(HTMLBRElement::create(document));
         } else
             m_messageHeading->setInnerText(lines[i]);
     }
@@ -188,7 +188,7 @@
     // Need to force position:absolute because RenderMenuList doesn't assume it
     // contains non-absolute or non-fixed renderers as children.
     m_bubble->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
-    shadowRoot.appendChild(*m_bubble, ASSERT_NO_EXCEPTION);
+    shadowRoot.appendChild(*m_bubble);
     document.updateLayout();
     adjustBubblePosition(m_element->renderer()->absoluteBoundingBoxRect(), m_bubble.get());
 
@@ -196,24 +196,24 @@
     clipper->setPseudo(AtomicString("-webkit-validation-bubble-arrow-clipper", AtomicString::ConstructFromLiteral));
     auto bubbleArrow = HTMLDivElement::create(document);
     bubbleArrow->setPseudo(AtomicString("-webkit-validation-bubble-arrow", AtomicString::ConstructFromLiteral));
-    clipper->appendChild(bubbleArrow, ASSERT_NO_EXCEPTION);
-    m_bubble->appendChild(clipper, ASSERT_NO_EXCEPTION);
+    clipper->appendChild(bubbleArrow);
+    m_bubble->appendChild(clipper);
 
     auto message = HTMLDivElement::create(document);
     message->setPseudo(AtomicString("-webkit-validation-bubble-message", AtomicString::ConstructFromLiteral));
     auto icon = HTMLDivElement::create(document);
     icon->setPseudo(AtomicString("-webkit-validation-bubble-icon", AtomicString::ConstructFromLiteral));
-    message->appendChild(icon, ASSERT_NO_EXCEPTION);
+    message->appendChild(icon);
     auto textBlock = HTMLDivElement::create(document);
     textBlock->setPseudo(AtomicString("-webkit-validation-bubble-text-block", AtomicString::ConstructFromLiteral));
     m_messageHeading = HTMLDivElement::create(document);
     m_messageHeading->setPseudo(AtomicString("-webkit-validation-bubble-heading", AtomicString::ConstructFromLiteral));
-    textBlock->appendChild(*m_messageHeading, ASSERT_NO_EXCEPTION);
+    textBlock->appendChild(*m_messageHeading);
     m_messageBody = HTMLDivElement::create(document);
     m_messageBody->setPseudo(AtomicString("-webkit-validation-bubble-body", AtomicString::ConstructFromLiteral));
-    textBlock->appendChild(*m_messageBody, ASSERT_NO_EXCEPTION);
-    message->appendChild(textBlock, ASSERT_NO_EXCEPTION);
-    m_bubble->appendChild(message, ASSERT_NO_EXCEPTION);
+    textBlock->appendChild(*m_messageBody);
+    message->appendChild(textBlock);
+    m_bubble->appendChild(message);
 
     setMessageDOMAndStartTimer();
 
@@ -245,7 +245,7 @@
     if (m_bubble) {
         m_messageHeading = nullptr;
         m_messageBody = nullptr;
-        m_element->userAgentShadowRoot()->removeChild(*m_bubble, ASSERT_NO_EXCEPTION);
+        m_element->userAgentShadowRoot()->removeChild(*m_bubble);
         m_bubble = nullptr;
     }
     m_message = String();
diff --git a/Source/WebCore/html/shadow/MediaControlElements.cpp b/Source/WebCore/html/shadow/MediaControlElements.cpp
index 642d1fb..0a90c6a 100644
--- a/Source/WebCore/html/shadow/MediaControlElements.cpp
+++ b/Source/WebCore/html/shadow/MediaControlElements.cpp
@@ -1181,7 +1181,7 @@
             // track cue region identifier, run the following substeps:
             if (displayBox->hasChildNodes() && !contains(displayBox.ptr())) {
                 // Note: the display tree of a cue is removed when the active flag of the cue is unset.
-                appendChild(displayBox, ASSERT_NO_EXCEPTION);
+                appendChild(displayBox);
                 cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
             }
         } else {
diff --git a/Source/WebCore/html/shadow/MediaControls.cpp b/Source/WebCore/html/shadow/MediaControls.cpp
index 6ff59c2..778c1f1 100644
--- a/Source/WebCore/html/shadow/MediaControls.cpp
+++ b/Source/WebCore/html/shadow/MediaControls.cpp
@@ -378,6 +378,7 @@
 }
 
 #if ENABLE(VIDEO_TRACK)
+
 void MediaControls::createTextTrackDisplay()
 {
     if (m_textDisplayContainer)
@@ -390,7 +391,7 @@
         m_textDisplayContainer->setMediaController(m_mediaController);
 
     // Insert it before the first controller element so it always displays behind the controls.
-    insertBefore(textDisplayContainer, m_panel, IGNORE_EXCEPTION);
+    insertBefore(textDisplayContainer, m_panel);
 }
 
 void MediaControls::showTextTrackDisplay()
@@ -421,6 +422,7 @@
     if (m_textDisplayContainer)
         m_textDisplayContainer->updateSizes(true);
 }
+
 #endif
 
 void MediaControls::setSliderVolume()
diff --git a/Source/WebCore/html/shadow/MediaControlsApple.cpp b/Source/WebCore/html/shadow/MediaControlsApple.cpp
index 12aa0ba..1219191 100644
--- a/Source/WebCore/html/shadow/MediaControlsApple.cpp
+++ b/Source/WebCore/html/shadow/MediaControlsApple.cpp
@@ -40,20 +40,6 @@
 
 MediaControlsApple::MediaControlsApple(Document& document)
     : MediaControls(document)
-    , m_rewindButton(0)
-    , m_returnToRealTimeButton(0)
-    , m_statusDisplay(0)
-    , m_timeRemainingDisplay(0)
-    , m_timelineContainer(0)
-    , m_seekBackButton(0)
-    , m_seekForwardButton(0)
-    , m_closedCaptionsTrackList(0)
-    , m_closedCaptionsContainer(0)
-    , m_volumeSliderMuteButton(0)
-    , m_volumeSliderContainer(0)
-    , m_fullScreenMinVolumeButton(0)
-    , m_fullScreenVolumeSlider(0)
-    , m_fullScreenMaxVolumeButton(0)
 {
 }
 
@@ -71,31 +57,25 @@
 
     auto panel = MediaControlPanelElement::create(document);
 
-    ExceptionCode ec;
-
     auto rewindButton = MediaControlRewindButtonElement::create(document);
     controls->m_rewindButton = rewindButton.ptr();
-    panel->appendChild(rewindButton, ec);
-    if (ec)
+    if (panel->appendChild(rewindButton).hasException())
         return nullptr;
 
     auto playButton = MediaControlPlayButtonElement::create(document);
     controls->m_playButton = playButton.ptr();
-    panel->appendChild(playButton, ec);
-    if (ec)
+    if (panel->appendChild(playButton).hasException())
         return nullptr;
 
     auto returnToRealtimeButton = MediaControlReturnToRealtimeButtonElement::create(document);
     controls->m_returnToRealTimeButton = returnToRealtimeButton.ptr();
-    panel->appendChild(returnToRealtimeButton, ec);
-    if (ec)
+    if (panel->appendChild(returnToRealtimeButton).hasException())
         return nullptr;
 
     if (document.page()->theme().usesMediaControlStatusDisplay()) {
         auto statusDisplay = MediaControlStatusDisplayElement::create(document);
         controls->m_statusDisplay = statusDisplay.ptr();
-        panel->appendChild(statusDisplay, ec);
-        if (ec)
+        if (panel->appendChild(statusDisplay).hasException())
             return nullptr;
     }
 
@@ -103,39 +83,33 @@
 
     auto currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(document);
     controls->m_currentTimeDisplay = currentTimeDisplay.ptr();
-    timelineContainer->appendChild(currentTimeDisplay, ec);
-    if (ec)
+    if (timelineContainer->appendChild(currentTimeDisplay).hasException())
         return nullptr;
 
     auto timeline = MediaControlTimelineElement::create(document, controls.ptr());
     controls->m_timeline = timeline.ptr();
-    timelineContainer->appendChild(timeline, ec);
-    if (ec)
+    if (timelineContainer->appendChild(timeline).hasException())
         return nullptr;
 
     auto timeRemainingDisplay = MediaControlTimeRemainingDisplayElement::create(document);
     controls->m_timeRemainingDisplay = timeRemainingDisplay.ptr();
-    timelineContainer->appendChild(timeRemainingDisplay, ec);
-    if (ec)
+    if (timelineContainer->appendChild(timeRemainingDisplay).hasException())
         return nullptr;
 
     controls->m_timelineContainer = timelineContainer.ptr();
-    panel->appendChild(timelineContainer, ec);
-    if (ec)
+    if (panel->appendChild(timelineContainer).hasException())
         return nullptr;
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto seekBackButton = MediaControlSeekBackButtonElement::create(document);
     controls->m_seekBackButton = seekBackButton.ptr();
-    panel->appendChild(seekBackButton, ec);
-    if (ec)
+    if (panel->appendChild(seekBackButton).hasException())
         return nullptr;
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto seekForwardButton = MediaControlSeekForwardButtonElement::create(document);
     controls->m_seekForwardButton = seekForwardButton.ptr();
-    panel->appendChild(seekForwardButton, ec);
-    if (ec)
+    if (panel->appendChild(seekForwardButton).hasException())
         return nullptr;
 
     if (document.page()->theme().supportsClosedCaptioning()) {
@@ -143,26 +117,23 @@
 
         auto closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document, controls.ptr());
         controls->m_closedCaptionsTrackList = closedCaptionsTrackList.ptr();
-        closedCaptionsContainer->appendChild(closedCaptionsTrackList, ec);
-        if (ec)
+        if (closedCaptionsContainer->appendChild(closedCaptionsTrackList).hasException())
             return nullptr;
 
         auto toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(document, controls.ptr());
         controls->m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.ptr();
-        panel->appendChild(toggleClosedCaptionsButton, ec);
-        if (ec)
+        if (panel->appendChild(toggleClosedCaptionsButton).hasException())
             return nullptr;
 
         controls->m_closedCaptionsContainer = closedCaptionsContainer.ptr();
-        controls->appendChild(closedCaptionsContainer, ec);
-        if (ec)
+        if (controls->appendChild(closedCaptionsContainer).hasException())
             return nullptr;
     }
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto fullScreenButton = MediaControlFullscreenButtonElement::create(document);
     controls->m_fullScreenButton = fullScreenButton.ptr();
-    panel->appendChild(fullScreenButton, ec);
+    panel->appendChild(fullScreenButton);
 
     // The mute button and the slider element should be in the same div.
     auto panelVolumeControlContainer = HTMLDivElement::create(document);
@@ -172,57 +143,47 @@
 
         auto slider = MediaControlPanelVolumeSliderElement::create(document);
         controls->m_volumeSlider = slider.ptr();
-        volumeSliderContainer->appendChild(slider, ec);
-        if (ec)
+        if (volumeSliderContainer->appendChild(slider).hasException())
             return nullptr;
 
         // This is a duplicate mute button, which is visible in some ports at the bottom of the volume bar.
         // It's important only when the volume bar is displayed below the controls.
         auto volumeSliderMuteButton = MediaControlVolumeSliderMuteButtonElement::create(document);
         controls->m_volumeSliderMuteButton = volumeSliderMuteButton.ptr();
-        volumeSliderContainer->appendChild(volumeSliderMuteButton, ec);
-
-        if (ec)
+        if (volumeSliderContainer->appendChild(volumeSliderMuteButton).hasException())
             return nullptr;
 
         controls->m_volumeSliderContainer = volumeSliderContainer.ptr();
-        panelVolumeControlContainer->appendChild(volumeSliderContainer, ec);
-        if (ec)
+        if (panelVolumeControlContainer->appendChild(volumeSliderContainer).hasException())
             return nullptr;
     }
 
     auto panelMuteButton = MediaControlPanelMuteButtonElement::create(document, controls.ptr());
     controls->m_panelMuteButton = panelMuteButton.ptr();
-    panelVolumeControlContainer->appendChild(panelMuteButton, ec);
-    if (ec)
+    if (panelVolumeControlContainer->appendChild(panelMuteButton).hasException())
         return nullptr;
 
-    panel->appendChild(panelVolumeControlContainer, ec);
-    if (ec)
+    if (panel->appendChild(panelVolumeControlContainer).hasException())
         return nullptr;
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto fullScreenMinVolumeButton = MediaControlFullscreenVolumeMinButtonElement::create(document);
     controls->m_fullScreenMinVolumeButton = fullScreenMinVolumeButton.ptr();
-    panel->appendChild(fullScreenMinVolumeButton, ec);
-    if (ec)
+    if (panel->appendChild(fullScreenMinVolumeButton).hasException())
         return nullptr;
 
     auto fullScreenVolumeSlider = MediaControlFullscreenVolumeSliderElement::create(document);
     controls->m_fullScreenVolumeSlider = fullScreenVolumeSlider.ptr();
-    panel->appendChild(fullScreenVolumeSlider, ec);
-    if (ec)
+    if (panel->appendChild(fullScreenVolumeSlider).hasException())
         return nullptr;
 
     auto fullScreenMaxVolumeButton = MediaControlFullscreenVolumeMaxButtonElement::create(document);
     controls->m_fullScreenMaxVolumeButton = fullScreenMaxVolumeButton.ptr();
-    panel->appendChild(fullScreenMaxVolumeButton, ec);
-    if (ec)
+    if (panel->appendChild(fullScreenMaxVolumeButton).hasException())
         return nullptr;
 
     controls->m_panel = panel.ptr();
-    controls->appendChild(panel, ec);
-    if (ec)
+    if (controls->appendChild(panel).hasException())
         return nullptr;
 
     return WTFMove(controls);
diff --git a/Source/WebCore/html/shadow/MediaControlsApple.h b/Source/WebCore/html/shadow/MediaControlsApple.h
index 6100433..31b2bc9 100644
--- a/Source/WebCore/html/shadow/MediaControlsApple.h
+++ b/Source/WebCore/html/shadow/MediaControlsApple.h
@@ -100,20 +100,20 @@
     void hideClosedCaptionTrackList();
     void setFullscreenSliderVolume();
 
-    MediaControlRewindButtonElement* m_rewindButton;
-    MediaControlReturnToRealtimeButtonElement* m_returnToRealTimeButton;
-    MediaControlStatusDisplayElement* m_statusDisplay;
-    MediaControlTimeRemainingDisplayElement* m_timeRemainingDisplay;
-    MediaControlTimelineContainerElement* m_timelineContainer;
-    MediaControlSeekBackButtonElement* m_seekBackButton;
-    MediaControlSeekForwardButtonElement* m_seekForwardButton;
-    MediaControlClosedCaptionsTrackListElement* m_closedCaptionsTrackList;
-    MediaControlClosedCaptionsContainerElement* m_closedCaptionsContainer;
-    MediaControlVolumeSliderMuteButtonElement* m_volumeSliderMuteButton;
-    MediaControlVolumeSliderContainerElement* m_volumeSliderContainer;
-    MediaControlFullscreenVolumeMinButtonElement* m_fullScreenMinVolumeButton;
-    MediaControlFullscreenVolumeSliderElement* m_fullScreenVolumeSlider;
-    MediaControlFullscreenVolumeMaxButtonElement* m_fullScreenMaxVolumeButton;
+    MediaControlRewindButtonElement* m_rewindButton { nullptr };
+    MediaControlReturnToRealtimeButtonElement* m_returnToRealTimeButton { nullptr };
+    MediaControlStatusDisplayElement* m_statusDisplay { nullptr };
+    MediaControlTimeRemainingDisplayElement* m_timeRemainingDisplay { nullptr };
+    MediaControlTimelineContainerElement* m_timelineContainer { nullptr };
+    MediaControlSeekBackButtonElement* m_seekBackButton { nullptr };
+    MediaControlSeekForwardButtonElement* m_seekForwardButton { nullptr };
+    MediaControlClosedCaptionsTrackListElement* m_closedCaptionsTrackList { nullptr };
+    MediaControlClosedCaptionsContainerElement* m_closedCaptionsContainer { nullptr };
+    MediaControlVolumeSliderMuteButtonElement* m_volumeSliderMuteButton { nullptr };
+    MediaControlVolumeSliderContainerElement* m_volumeSliderContainer { nullptr };
+    MediaControlFullscreenVolumeMinButtonElement* m_fullScreenMinVolumeButton { nullptr };
+    MediaControlFullscreenVolumeSliderElement* m_fullScreenVolumeSlider { nullptr };
+    MediaControlFullscreenVolumeMaxButtonElement* m_fullScreenMaxVolumeButton { nullptr };
     RefPtr<MediaControlsAppleEventListener> m_eventListener;
 };
 
diff --git a/Source/WebCore/html/track/VTTCue.cpp b/Source/WebCore/html/track/VTTCue.cpp
index 37e86f7..cb6cfe0 100644
--- a/Source/WebCore/html/track/VTTCue.cpp
+++ b/Source/WebCore/html/track/VTTCue.cpp
@@ -499,7 +499,7 @@
             clonedNode = downcast<WebVTTElement>(*node).createEquivalentHTMLElement(ownerDocument());
         else
             clonedNode = node->cloneNode(false);
-        parent->appendChild(*clonedNode, ASSERT_NO_EXCEPTION);
+        parent->appendChild(*clonedNode);
         if (is<ContainerNode>(*node))
             copyWebVTTNodeToDOMTree(downcast<ContainerNode>(node), downcast<ContainerNode>(clonedNode.get()));
     }
@@ -814,8 +814,8 @@
     m_cueHighlightBox->setPseudo(cueShadowPseudoId());
 
     m_cueBackdropBox->setPseudo(cueBackdropShadowPseudoId());
-    m_cueBackdropBox->appendChild(*m_cueHighlightBox, ASSERT_NO_EXCEPTION);
-    displayTree->appendChild(*m_cueBackdropBox, ASSERT_NO_EXCEPTION);
+    m_cueBackdropBox->appendChild(*m_cueHighlightBox);
+    displayTree->appendChild(*m_cueBackdropBox);
 
     // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
     // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
diff --git a/Source/WebCore/html/track/VTTRegion.cpp b/Source/WebCore/html/track/VTTRegion.cpp
index f3ba7f6..a1d582c 100644
--- a/Source/WebCore/html/track/VTTRegion.cpp
+++ b/Source/WebCore/html/track/VTTRegion.cpp
@@ -291,7 +291,7 @@
     if (m_cueContainer->contains(displayBox.ptr()))
         return;
 
-    m_cueContainer->appendChild(displayBox, ASSERT_NO_EXCEPTION);
+    m_cueContainer->appendChild(displayBox);
     displayLastTextTrackCueBox();
 }
 
diff --git a/Source/WebCore/inspector/DOMEditor.cpp b/Source/WebCore/inspector/DOMEditor.cpp
index 2c0cf3b..539282b 100644
--- a/Source/WebCore/inspector/DOMEditor.cpp
+++ b/Source/WebCore/inspector/DOMEditor.cpp
@@ -44,30 +44,30 @@
 
 namespace WebCore {
 
-class DOMEditor::RemoveChildAction : public InspectorHistory::Action {
+class DOMEditor::RemoveChildAction final : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(RemoveChildAction);
 public:
     RemoveChildAction(Node& parentNode, Node& node)
-        : InspectorHistory::Action("RemoveChild")
+        : Action("RemoveChild")
         , m_parentNode(parentNode)
         , m_node(node)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+    ExceptionOr<void> perform() final
     {
         m_anchorNode = m_node->nextSibling();
-        return redo(ec);
+        return redo();
     }
 
-    bool undo(ExceptionCode& ec) override
+    ExceptionOr<void> undo() final
     {
-        return m_parentNode->insertBefore(m_node, m_anchorNode.get(), ec);
+        return m_parentNode->insertBefore(m_node, m_anchorNode.get());
     }
 
-    bool redo(ExceptionCode& ec) override
+    ExceptionOr<void> redo() final
     {
-        return m_parentNode->removeChild(m_node, ec);
+        return m_parentNode->removeChild(m_node);
     }
 
 private:
@@ -76,383 +76,358 @@
     RefPtr<Node> m_anchorNode;
 };
 
-class DOMEditor::InsertBeforeAction : public InspectorHistory::Action {
-    WTF_MAKE_NONCOPYABLE(InsertBeforeAction);
+class DOMEditor::InsertBeforeAction final : public InspectorHistory::Action {
 public:
     InsertBeforeAction(Node& parentNode, Ref<Node>&& node, Node* anchorNode)
-        : InspectorHistory::Action("InsertBefore")
+        : Action("InsertBefore")
         , m_parentNode(parentNode)
         , m_node(WTFMove(node))
         , m_anchorNode(anchorNode)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+private:
+    ExceptionOr<void> perform() final
     {
         if (m_node->parentNode()) {
             m_removeChildAction = std::make_unique<RemoveChildAction>(*m_node->parentNode(), m_node);
-            if (!m_removeChildAction->perform(ec))
-                return false;
+            auto result = m_removeChildAction->perform();
+            if (result.hasException())
+                return result.releaseException();
         }
-        return m_parentNode->insertBefore(m_node, m_anchorNode.get(), ec);
+        return m_parentNode->insertBefore(m_node, m_anchorNode.get());
     }
 
-    bool undo(ExceptionCode& ec) override
+    ExceptionOr<void> undo() final
     {
-        if (!m_parentNode->removeChild(m_node, ec))
-            return false;
-        if (m_removeChildAction)
-            return m_removeChildAction->undo(ec);
-        return true;
+        auto result = m_parentNode->removeChild(m_node);
+        if (result.hasException())
+            return result.releaseException();
+        if (!m_removeChildAction)
+            return { };
+        return m_removeChildAction->undo();
     }
 
-    bool redo(ExceptionCode& ec) override
+    ExceptionOr<void> redo() final
     {
-        if (m_removeChildAction && !m_removeChildAction->redo(ec))
-            return false;
-        return m_parentNode->insertBefore(m_node, m_anchorNode.get(), ec);
+        if (m_removeChildAction) {
+            auto result = m_removeChildAction->redo();
+            if (result.hasException())
+                return result.releaseException();
+        }
+        return m_parentNode->insertBefore(m_node, m_anchorNode.get());
     }
 
-private:
     Ref<Node> m_parentNode;
     Ref<Node> m_node;
     RefPtr<Node> m_anchorNode;
     std::unique_ptr<RemoveChildAction> m_removeChildAction;
 };
 
-class DOMEditor::RemoveAttributeAction : public InspectorHistory::Action {
+class DOMEditor::RemoveAttributeAction final : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(RemoveAttributeAction);
 public:
-    RemoveAttributeAction(Element* element, const String& name)
-        : InspectorHistory::Action("RemoveAttribute")
+    RemoveAttributeAction(Element& element, const String& name)
+        : Action("RemoveAttribute")
         , m_element(element)
         , m_name(name)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+private:
+    ExceptionOr<void> perform() final
     {
         m_value = m_element->getAttribute(m_name);
-        return redo(ec);
+        return redo();
     }
 
-    bool undo(ExceptionCode& ec) override
+    ExceptionOr<void> undo() final
     {
-        auto result = m_element->setAttribute(m_name, m_value);
-        if (result.hasException())
-            ec = result.releaseException().code();
-        return true;
+        return m_element->setAttribute(m_name, m_value);
     }
 
-    bool redo(ExceptionCode&) override
+    ExceptionOr<void> redo() final
     {
         m_element->removeAttribute(m_name);
-        return true;
+        return { };
     }
 
-private:
-    RefPtr<Element> m_element;
+    Ref<Element> m_element;
     String m_name;
     String m_value;
 };
 
-class DOMEditor::SetAttributeAction : public InspectorHistory::Action {
+class DOMEditor::SetAttributeAction final : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(SetAttributeAction);
 public:
-    SetAttributeAction(Element* element, const String& name, const String& value)
-        : InspectorHistory::Action("SetAttribute")
+    SetAttributeAction(Element& element, const AtomicString& name, const AtomicString& value)
+        : Action("SetAttribute")
         , m_element(element)
         , m_name(name)
         , m_value(value)
-        , m_hadAttribute(false)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
-    {
-        m_hadAttribute = m_element->hasAttribute(m_name);
-        if (m_hadAttribute)
-            m_oldValue = m_element->getAttribute(m_name);
-        return redo(ec);
-    }
-
-    bool undo(ExceptionCode& ec) override
-    {
-        if (m_hadAttribute) {
-            auto result = m_element->setAttribute(m_name, m_oldValue);
-            if (result.hasException())
-                ec = result.releaseException().code();
-        } else
-            m_element->removeAttribute(m_name);
-        return true;
-    }
-
-    bool redo(ExceptionCode& ec) override
-    {
-        auto result = m_element->setAttribute(m_name, m_value);
-        if (result.hasException())
-            ec = result.releaseException().code();
-        return true;
-    }
-
 private:
-    RefPtr<Element> m_element;
-    String m_name;
-    String m_value;
-    bool m_hadAttribute;
-    String m_oldValue;
+    ExceptionOr<void> perform() final
+    {
+        m_oldValue = m_element->getAttribute(m_name);
+        return redo();
+    }
+
+    ExceptionOr<void> undo() final
+    {
+        if (m_oldValue.isNull()) {
+            m_element->removeAttribute(m_name);
+            return { };
+        }
+        return m_element->setAttribute(m_name, m_oldValue);
+    }
+
+    ExceptionOr<void> redo() final
+    {
+        return m_element->setAttribute(m_name, m_value);
+    }
+
+    Ref<Element> m_element;
+    AtomicString m_name;
+    AtomicString m_value;
+    AtomicString m_oldValue;
 };
 
-class DOMEditor::SetOuterHTMLAction : public InspectorHistory::Action {
-    WTF_MAKE_NONCOPYABLE(SetOuterHTMLAction);
+class DOMEditor::SetOuterHTMLAction final : public InspectorHistory::Action {
 public:
     SetOuterHTMLAction(Node& node, const String& html)
-        : InspectorHistory::Action("SetOuterHTML")
+        : Action("SetOuterHTML")
         , m_node(node)
         , m_nextSibling(node.nextSibling())
         , m_html(html)
-        , m_newNode(nullptr)
-        , m_history(std::make_unique<InspectorHistory>())
-        , m_domEditor(std::make_unique<DOMEditor>(m_history.get()))
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+    Node* newNode() const
     {
-        m_oldHTML = createMarkup(m_node.get());
-        DOMPatchSupport domPatchSupport(m_domEditor.get(), &m_node->document());
-        m_newNode = domPatchSupport.patchNode(m_node.get(), m_html, ec);
-        return !ec;
-    }
-
-    bool undo(ExceptionCode& ec) override
-    {
-        return m_history->undo(ec);
-    }
-
-    bool redo(ExceptionCode& ec) override
-    {
-        return m_history->redo(ec);
-    }
-
-    Node* newNode()
-    {
-        return m_newNode;
+        return m_newNode.get();
     }
 
 private:
+    ExceptionOr<void> perform() final
+    {
+        m_oldHTML = createMarkup(m_node.get());
+        auto result = DOMPatchSupport { m_domEditor, m_node->document() }.patchNode(m_node, m_html);
+        if (result.hasException())
+            return result.releaseException();
+        m_newNode = result.releaseReturnValue();
+        return { };
+    }
+
+    ExceptionOr<void> undo() final
+    {
+        return m_history.undo();
+    }
+
+    ExceptionOr<void> redo() final
+    {
+        return m_history.redo();
+    }
+
     Ref<Node> m_node;
     RefPtr<Node> m_nextSibling;
     String m_html;
     String m_oldHTML;
-    Node* m_newNode;
-    std::unique_ptr<InspectorHistory> m_history;
-    std::unique_ptr<DOMEditor> m_domEditor;
+    RefPtr<Node> m_newNode { nullptr };
+    InspectorHistory m_history;
+    DOMEditor m_domEditor { m_history };
 };
 
-class DOMEditor::ReplaceWholeTextAction : public InspectorHistory::Action {
+class DOMEditor::ReplaceWholeTextAction final : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction);
 public:
-    ReplaceWholeTextAction(Text* textNode, const String& text)
-        : InspectorHistory::Action("ReplaceWholeText")
+    ReplaceWholeTextAction(Text& textNode, const String& text)
+        : Action("ReplaceWholeText")
         , m_textNode(textNode)
         , m_text(text)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+private:
+    ExceptionOr<void> perform() final
     {
         m_oldText = m_textNode->wholeText();
-        return redo(ec);
+        return redo();
     }
 
-    bool undo(ExceptionCode&) override
+    ExceptionOr<void> undo() final
     {
         m_textNode->replaceWholeText(m_oldText);
-        return true;
+        return { };
     }
 
-    bool redo(ExceptionCode&) override
+    ExceptionOr<void> redo() final
     {
         m_textNode->replaceWholeText(m_text);
-        return true;
+        return { };
     }
 
-private:
-    RefPtr<Text> m_textNode;
+    Ref<Text> m_textNode;
     String m_text;
     String m_oldText;
 };
 
-class DOMEditor::ReplaceChildNodeAction : public InspectorHistory::Action {
+class DOMEditor::ReplaceChildNodeAction final: public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction);
 public:
     ReplaceChildNodeAction(Node& parentNode, Ref<Node>&& newNode, Node& oldNode)
-        : InspectorHistory::Action("ReplaceChildNode")
+        : Action("ReplaceChildNode")
         , m_parentNode(parentNode)
         , m_newNode(WTFMove(newNode))
         , m_oldNode(oldNode)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
-    {
-        return redo(ec);
-    }
-
-    bool undo(ExceptionCode& ec) override
-    {
-        return m_parentNode->replaceChild(m_oldNode, m_newNode.get(), ec);
-    }
-
-    bool redo(ExceptionCode& ec) override
-    {
-        return m_parentNode->replaceChild(m_newNode, m_oldNode, ec);
-    }
-
 private:
+    ExceptionOr<void> perform() final
+    {
+        return redo();
+    }
+
+    ExceptionOr<void> undo() final
+    {
+        return m_parentNode->replaceChild(m_oldNode, m_newNode);
+    }
+
+    ExceptionOr<void> redo() final
+    {
+        return m_parentNode->replaceChild(m_newNode, m_oldNode);
+    }
+
     Ref<Node> m_parentNode;
     Ref<Node> m_newNode;
     Ref<Node> m_oldNode;
 };
 
-class DOMEditor::SetNodeValueAction : public InspectorHistory::Action {
+class DOMEditor::SetNodeValueAction final : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(SetNodeValueAction);
 public:
-    SetNodeValueAction(Node* node, const String& value)
-        : InspectorHistory::Action("SetNodeValue")
+    SetNodeValueAction(Node& node, const String& value)
+        : Action("SetNodeValue")
         , m_node(node)
         , m_value(value)
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+private:
+    ExceptionOr<void> perform() final
     {
         m_oldValue = m_node->nodeValue();
-        return redo(ec);
+        return redo();
     }
 
-    bool undo(ExceptionCode& ec) override
+    ExceptionOr<void> undo() final
     {
-        m_node->setNodeValue(m_oldValue, ec);
-        return !ec;
+        return m_node->setNodeValue(m_oldValue);
     }
 
-    bool redo(ExceptionCode& ec) override
+    ExceptionOr<void> redo() final
     {
-        m_node->setNodeValue(m_value, ec);
-        return !ec;
+        return m_node->setNodeValue(m_value);
     }
 
-private:
-    RefPtr<Node> m_node;
+    Ref<Node> m_node;
     String m_value;
     String m_oldValue;
 };
 
-DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { }
-
-DOMEditor::~DOMEditor() { }
-
-bool DOMEditor::insertBefore(Node& parentNode, Ref<Node>&& node, Node* anchorNode, ExceptionCode& ec)
+DOMEditor::DOMEditor(InspectorHistory& history)
+    : m_history(history)
 {
-    return m_history->perform(std::make_unique<InsertBeforeAction>(parentNode, WTFMove(node), anchorNode), ec);
 }
 
-bool DOMEditor::removeChild(Node& parentNode, Node& node, ExceptionCode& ec)
+DOMEditor::~DOMEditor()
 {
-    return m_history->perform(std::make_unique<RemoveChildAction>(parentNode, node), ec);
 }
 
-bool DOMEditor::setAttribute(Element* element, const String& name, const String& value, ExceptionCode& ec)
+ExceptionOr<void> DOMEditor::insertBefore(Node& parentNode, Ref<Node>&& node, Node* anchorNode)
 {
-    return m_history->perform(std::make_unique<SetAttributeAction>(element, name, value), ec);
+    return m_history.perform(std::make_unique<InsertBeforeAction>(parentNode, WTFMove(node), anchorNode));
 }
 
-bool DOMEditor::removeAttribute(Element* element, const String& name, ExceptionCode& ec)
+ExceptionOr<void> DOMEditor::removeChild(Node& parentNode, Node& node)
 {
-    return m_history->perform(std::make_unique<RemoveAttributeAction>(element, name), ec);
+    return m_history.perform(std::make_unique<RemoveChildAction>(parentNode, node));
 }
 
-bool DOMEditor::setOuterHTML(Node& node, const String& html, Node** newNode, ExceptionCode& ec)
+ExceptionOr<void> DOMEditor::setAttribute(Element& element, const String& name, const String& value)
+{
+    return m_history.perform(std::make_unique<SetAttributeAction>(element, name, value));
+}
+
+ExceptionOr<void> DOMEditor::removeAttribute(Element& element, const String& name)
+{
+    return m_history.perform(std::make_unique<RemoveAttributeAction>(element, name));
+}
+
+ExceptionOr<void> DOMEditor::setOuterHTML(Node& node, const String& html, Node*& newNode)
 {
     auto action = std::make_unique<SetOuterHTMLAction>(node, html);
-    SetOuterHTMLAction* rawAction = action.get();
-    bool result = m_history->perform(WTFMove(action), ec);
-    if (result)
-        *newNode = rawAction->newNode();
+    auto& rawAction = *action;
+    auto result = m_history.perform(WTFMove(action));
+    if (!result.hasException())
+        newNode = rawAction.newNode();
     return result;
 }
 
-bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionCode& ec)
+ExceptionOr<void> DOMEditor::replaceWholeText(Text& textNode, const String& text)
 {
-    return m_history->perform(std::make_unique<ReplaceWholeTextAction>(textNode, text), ec);
+    return m_history.perform(std::make_unique<ReplaceWholeTextAction>(textNode, text));
 }
 
-bool DOMEditor::replaceChild(Node& parentNode, Ref<Node>&& newNode, Node& oldNode, ExceptionCode& ec)
+ExceptionOr<void> DOMEditor::replaceChild(Node& parentNode, Ref<Node>&& newNode, Node& oldNode)
 {
-    return m_history->perform(std::make_unique<ReplaceChildNodeAction>(parentNode, WTFMove(newNode), oldNode), ec);
+    return m_history.perform(std::make_unique<ReplaceChildNodeAction>(parentNode, WTFMove(newNode), oldNode));
 }
 
-bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionCode& ec)
+ExceptionOr<void> DOMEditor::setNodeValue(Node& node, const String& value)
 {
-    return m_history->perform(std::make_unique<SetNodeValueAction>(node, value), ec);
+    return m_history.perform(std::make_unique<SetNodeValueAction>(node, value));
 }
 
-static void populateErrorString(const ExceptionCode& ec, ErrorString& errorString)
+static bool populateErrorString(ExceptionOr<void>&& result, ErrorString& errorString)
 {
-    if (ec) {
-        ExceptionCodeDescription description(ec);
-        errorString = description.name;
-    }
+    if (!result.hasException())
+        return true;
+    errorString = ExceptionCodeDescription { result.releaseException().code() }.name;
+    return false;
 }
 
 bool DOMEditor::insertBefore(Node& parentNode, Ref<Node>&& node, Node* anchorNode, ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    bool result = insertBefore(parentNode, WTFMove(node), anchorNode, ec);
-    populateErrorString(ec, errorString);
-    return result;
+    return populateErrorString(insertBefore(parentNode, WTFMove(node), anchorNode), errorString);
 }
 
 bool DOMEditor::removeChild(Node& parentNode, Node& node, ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    bool result = removeChild(parentNode, node, ec);
-    populateErrorString(ec, errorString);
-    return result;
+    return populateErrorString(removeChild(parentNode, node), errorString);
 }
 
-bool DOMEditor::setAttribute(Element* element, const String& name, const String& value, ErrorString& errorString)
+bool DOMEditor::setAttribute(Element& element, const String& name, const String& value, ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    bool result = setAttribute(element, name, value, ec);
-    populateErrorString(ec, errorString);
-    return result;
+    return populateErrorString(setAttribute(element, name, value), errorString);
 }
 
-bool DOMEditor::removeAttribute(Element* element, const String& name, ErrorString& errorString)
+bool DOMEditor::removeAttribute(Element& element, const String& name, ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    bool result = removeAttribute(element, name, ec);
-    populateErrorString(ec, errorString);
-    return result;
+    return populateErrorString(removeAttribute(element, name), errorString);
 }
 
-bool DOMEditor::setOuterHTML(Node& node, const String& html, Node** newNode, ErrorString& errorString)
+bool DOMEditor::setOuterHTML(Node& node, const String& html, Node*& newNode, ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    bool result = setOuterHTML(node, html, newNode, ec);
-    populateErrorString(ec, errorString);
-    return result;
+    return populateErrorString(setOuterHTML(node, html, newNode), errorString);
 }
 
-bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString& errorString)
+bool DOMEditor::replaceWholeText(Text& textNode, const String& text, ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    bool result = replaceWholeText(textNode, text, ec);
-    populateErrorString(ec, errorString);
-    return result;
+    return populateErrorString(replaceWholeText(textNode, text), errorString);
 }
 
 } // namespace WebCore
diff --git a/Source/WebCore/inspector/DOMEditor.h b/Source/WebCore/inspector/DOMEditor.h
index 4c99eba..e95a936 100644
--- a/Source/WebCore/inspector/DOMEditor.h
+++ b/Source/WebCore/inspector/DOMEditor.h
@@ -30,9 +30,7 @@
 
 #pragma once
 
-#include "ExceptionCode.h"
-
-#include <wtf/text/WTFString.h>
+#include "ExceptionOr.h"
 
 namespace WebCore {
 
@@ -46,37 +44,37 @@
 class DOMEditor {
     WTF_MAKE_NONCOPYABLE(DOMEditor); WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit DOMEditor(InspectorHistory*);
+    explicit DOMEditor(InspectorHistory&);
     ~DOMEditor();
 
-    bool insertBefore(Node& parentNode, Ref<Node>&&, Node* anchorNode, ExceptionCode&);
-    bool removeChild(Node& parentNode, Node&, ExceptionCode&);
-    bool setAttribute(Element*, const String& name, const String& value, ExceptionCode&);
-    bool removeAttribute(Element*, const String& name, ExceptionCode&);
-    bool setOuterHTML(Node&, const String& html, Node** newNode, ExceptionCode&);
-    bool replaceWholeText(Text*, const String& text, ExceptionCode&);
-    bool replaceChild(Node& parentNode, Ref<Node>&& newNode, Node& oldNode, ExceptionCode&);
-    bool setNodeValue(Node* parentNode, const String& value, ExceptionCode&);
+    ExceptionOr<void> insertBefore(Node& parentNode, Ref<Node>&&, Node* anchorNode);
+    ExceptionOr<void> removeChild(Node& parentNode, Node&);
+    ExceptionOr<void> setAttribute(Element&, const String& name, const String& value);
+    ExceptionOr<void> removeAttribute(Element&, const String& name);
+    ExceptionOr<void> setOuterHTML(Node&, const String& html, Node*& newNode);
+    ExceptionOr<void> replaceWholeText(Text&, const String& text);
+    ExceptionOr<void> replaceChild(Node& parentNode, Ref<Node>&& newNode, Node& oldNode);
+    ExceptionOr<void> setNodeValue(Node& parentNode, const String& value);
 
     bool insertBefore(Node& parentNode, Ref<Node>&&, Node* anchorNode, ErrorString&);
     bool removeChild(Node& parentNode, Node&, ErrorString&);
-    bool setAttribute(Element*, const String& name, const String& value, ErrorString&);
-    bool removeAttribute(Element*, const String& name, ErrorString&);
-    bool setOuterHTML(Node&, const String& html, Node** newNode, ErrorString&);
-    bool replaceWholeText(Text*, const String& text, ErrorString&);
+    bool setAttribute(Element&, const String& name, const String& value, ErrorString&);
+    bool removeAttribute(Element&, const String& name, ErrorString&);
+    bool setOuterHTML(Node&, const String& html, Node*& newNode, ErrorString&);
+    bool replaceWholeText(Text&, const String& text, ErrorString&);
 
 private:
     class DOMAction;
-    class RemoveChildAction;
     class InsertBeforeAction;
     class RemoveAttributeAction;
-    class SetAttributeAction;
-    class SetOuterHTMLAction;
-    class ReplaceWholeTextAction;
+    class RemoveChildAction;
     class ReplaceChildNodeAction;
+    class ReplaceWholeTextAction;
+    class SetAttributeAction;
     class SetNodeValueAction;
+    class SetOuterHTMLAction;
 
-    InspectorHistory* m_history;
+    InspectorHistory& m_history;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/inspector/DOMPatchSupport.cpp b/Source/WebCore/inspector/DOMPatchSupport.cpp
index 61a65a2..caba858 100644
--- a/Source/WebCore/inspector/DOMPatchSupport.cpp
+++ b/Source/WebCore/inspector/DOMPatchSupport.cpp
@@ -59,38 +59,34 @@
 using HTMLNames::htmlTag;
 
 struct DOMPatchSupport::Digest {
-    explicit Digest(Node* node) : m_node(node) { }
-
-    String m_sha1;
-    String m_attrsSHA1;
-    Node* m_node;
-    Vector<std::unique_ptr<Digest>> m_children;
+    String sha1;
+    String attrsSHA1;
+    Node* node;
+    Vector<std::unique_ptr<Digest>> children;
 };
 
-void DOMPatchSupport::patchDocument(Document* document, const String& markup)
+void DOMPatchSupport::patchDocument(Document& document, const String& markup)
 {
     InspectorHistory history;
-    DOMEditor domEditor(&history);
-    DOMPatchSupport patchSupport(&domEditor, document);
+    DOMEditor domEditor { history };
+    DOMPatchSupport patchSupport(domEditor, document);
     patchSupport.patchDocument(markup);
 }
 
-DOMPatchSupport::DOMPatchSupport(DOMEditor* domEditor, Document* document)
+DOMPatchSupport::DOMPatchSupport(DOMEditor& domEditor, Document& document)
     : m_domEditor(domEditor)
     , m_document(document)
 {
 }
 
-DOMPatchSupport::~DOMPatchSupport() { }
-
 void DOMPatchSupport::patchDocument(const String& markup)
 {
     RefPtr<Document> newDocument;
-    if (m_document->isHTMLDocument())
+    if (m_document.isHTMLDocument())
         newDocument = HTMLDocument::create(nullptr, URL());
-    else if (m_document->isXHTMLDocument())
+    else if (m_document.isXHTMLDocument())
         newDocument = XMLDocument::createXHTML(nullptr, URL());
-    else if (m_document->isSVGDocument())
+    else if (m_document.isSVGDocument())
         newDocument = XMLDocument::create(nullptr, URL());
 
     ASSERT(newDocument);
@@ -103,17 +99,17 @@
     parser->finish();
     parser->detach();
 
-    std::unique_ptr<Digest> oldInfo = createDigest(m_document->documentElement(), nullptr);
-    std::unique_ptr<Digest> newInfo = createDigest(newDocument->documentElement(), &m_unusedNodesMap);
+    std::unique_ptr<Digest> oldInfo = createDigest(*m_document.documentElement(), nullptr);
+    std::unique_ptr<Digest> newInfo = createDigest(*newDocument->documentElement(), &m_unusedNodesMap);
 
-    if (!innerPatchNode(oldInfo.get(), newInfo.get(), IGNORE_EXCEPTION)) {
+    if (innerPatchNode(*oldInfo, *newInfo).hasException()) {
         // Fall back to rewrite.
-        m_document->write(markup);
-        m_document->close();
+        m_document.write(markup);
+        m_document.close();
     }
 }
 
-Node* DOMPatchSupport::patchNode(Node& node, const String& markup, ExceptionCode& ec)
+ExceptionOr<Node*> DOMPatchSupport::patchNode(Node& node, const String& markup)
 {
     // Don't parse <html> as a fragment.
     if (node.isDocumentNode() || (node.parentNode() && node.parentNode()->isDocumentNode())) {
@@ -123,84 +119,86 @@
 
     Node* previousSibling = node.previousSibling();
     // FIXME: This code should use one of createFragment* in markup.h
-    RefPtr<DocumentFragment> fragment = DocumentFragment::create(*m_document);
-    if (m_document->isHTMLDocument())
-        fragment->parseHTML(markup, node.parentElement() ? node.parentElement() : m_document->documentElement());
+    RefPtr<DocumentFragment> fragment = DocumentFragment::create(m_document);
+    if (m_document.isHTMLDocument())
+        fragment->parseHTML(markup, node.parentElement() ? node.parentElement() : m_document.documentElement());
     else
-        fragment->parseXML(markup, node.parentElement() ? node.parentElement() : m_document->documentElement());
+        fragment->parseXML(markup, node.parentElement() ? node.parentElement() : m_document.documentElement());
 
     // Compose the old list.
-    ContainerNode* parentNode = node.parentNode();
+    auto* parentNode = node.parentNode();
     Vector<std::unique_ptr<Digest>> oldList;
     for (Node* child = parentNode->firstChild(); child; child = child->nextSibling())
-        oldList.append(createDigest(child, nullptr));
+        oldList.append(createDigest(*child, nullptr));
 
     // Compose the new list.
     Vector<std::unique_ptr<Digest>> newList;
     for (Node* child = parentNode->firstChild(); child != &node; child = child->nextSibling())
-        newList.append(createDigest(child, nullptr));
+        newList.append(createDigest(*child, nullptr));
     for (Node* child = fragment->firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(headTag) && !child->firstChild() && !markup.containsIgnoringASCIICase("</head>"))
             continue; // HTML5 parser inserts empty <head> tag whenever it parses <body>
         if (child->hasTagName(bodyTag) && !child->firstChild() && !markup.containsIgnoringASCIICase("</body>"))
             continue; // HTML5 parser inserts empty <body> tag whenever it parses </head>
-        newList.append(createDigest(child, &m_unusedNodesMap));
+        newList.append(createDigest(*child, &m_unusedNodesMap));
     }
     for (Node* child = node.nextSibling(); child; child = child->nextSibling())
-        newList.append(createDigest(child, nullptr));
+        newList.append(createDigest(*child, nullptr));
 
-    if (!innerPatchChildren(parentNode, oldList, newList, ec)) {
+    if (innerPatchChildren(*parentNode, oldList, newList).hasException()) {
         // Fall back to total replace.
-        ec = 0;
-        if (!m_domEditor->replaceChild(*parentNode, *fragment, node, ec))
-            return nullptr;
+        auto result = m_domEditor.replaceChild(*parentNode, *fragment, node);
+        if (result.hasException())
+            return result.releaseException();
     }
     return previousSibling ? previousSibling->nextSibling() : parentNode->firstChild();
 }
 
-bool DOMPatchSupport::innerPatchNode(Digest* oldDigest, Digest* newDigest, ExceptionCode& ec)
+ExceptionOr<void> DOMPatchSupport::innerPatchNode(Digest& oldDigest, Digest& newDigest)
 {
-    if (oldDigest->m_sha1 == newDigest->m_sha1)
-        return true;
+    if (oldDigest.sha1 == newDigest.sha1)
+        return { };
 
-    Node* oldNode = oldDigest->m_node;
-    Node* newNode = newDigest->m_node;
+    auto& oldNode = *oldDigest.node;
+    auto& newNode = *newDigest.node;
 
-    if (newNode->nodeType() != oldNode->nodeType() || newNode->nodeName() != oldNode->nodeName())
-        return m_domEditor->replaceChild(*oldNode->parentNode(), *newNode, *oldNode, ec);
+    if (newNode.nodeType() != oldNode.nodeType() || newNode.nodeName() != oldNode.nodeName())
+        return m_domEditor.replaceChild(*oldNode.parentNode(), newNode, oldNode);
 
-    if (oldNode->nodeValue() != newNode->nodeValue()) {
-        if (!m_domEditor->setNodeValue(oldNode, newNode->nodeValue(), ec))
-            return false;
+    if (oldNode.nodeValue() != newNode.nodeValue()) {
+        auto result = m_domEditor.setNodeValue(oldNode, newNode.nodeValue());
+        if (result.hasException())
+            return result.releaseException();
     }
 
-    if (oldNode->nodeType() != Node::ELEMENT_NODE)
-        return true;
+    if (!is<Element>(oldNode))
+        return { };
 
     // Patch attributes
-    Element* oldElement = downcast<Element>(oldNode);
-    Element* newElement = downcast<Element>(newNode);
-    if (oldDigest->m_attrsSHA1 != newDigest->m_attrsSHA1) {
+    auto& oldElement = downcast<Element>(oldNode);
+    auto& newElement = downcast<Element>(newNode);
+    if (oldDigest.attrsSHA1 != newDigest.attrsSHA1) {
         // FIXME: Create a function in Element for removing all properties. Take in account whether did/willModifyAttribute are important.
-        if (oldElement->hasAttributesWithoutUpdate()) {
-            while (oldElement->attributeCount()) {
-                const Attribute& attribute = oldElement->attributeAt(0);
-                if (!m_domEditor->removeAttribute(oldElement, attribute.localName(), ec))
-                    return false;
+        if (oldElement.hasAttributesWithoutUpdate()) {
+            while (oldElement.attributeCount()) {
+                auto result = m_domEditor.removeAttribute(oldElement, oldElement.attributeAt(0).localName());
+                if (result.hasException())
+                    return result.releaseException();
             }
         }
 
         // FIXME: Create a function in Element for copying properties. cloneDataFromElement() is close but not enough for this case.
-        if (newElement->hasAttributesWithoutUpdate()) {
-            for (const Attribute& attribute : newElement->attributesIterator()) {
-                if (!m_domEditor->setAttribute(oldElement, attribute.name().localName(), attribute.value(), ec))
-                    return false;
+        if (newElement.hasAttributesWithoutUpdate()) {
+            for (auto& attribute : newElement.attributesIterator()) {
+                auto result = m_domEditor.setAttribute(oldElement, attribute.name().localName(), attribute.value());
+                if (result.hasException())
+                    return result.releaseException();
             }
         }
     }
 
-    bool result = innerPatchChildren(oldElement, oldDigest->m_children, newDigest->m_children, ec);
-    m_unusedNodesMap.remove(newDigest->m_sha1);
+    auto result = innerPatchChildren(oldElement, oldDigest.children, newDigest.children);
+    m_unusedNodesMap.remove(newDigest.sha1);
     return result;
 }
 
@@ -221,13 +219,13 @@
     }
 
     // Trim head and tail.
-    for (size_t i = 0; i < oldList.size() && i < newList.size() && oldList[i]->m_sha1 == newList[i]->m_sha1; ++i) {
+    for (size_t i = 0; i < oldList.size() && i < newList.size() && oldList[i]->sha1 == newList[i]->sha1; ++i) {
         oldMap[i].first = oldList[i].get();
         oldMap[i].second = i;
         newMap[i].first = newList[i].get();
         newMap[i].second = i;
     }
-    for (size_t i = 0; i < oldList.size() && i < newList.size() && oldList[oldList.size() - i - 1]->m_sha1 == newList[newList.size() - i - 1]->m_sha1; ++i) {
+    for (size_t i = 0; i < oldList.size() && i < newList.size() && oldList[oldList.size() - i - 1]->sha1 == newList[newList.size() - i - 1]->sha1; ++i) {
         size_t oldIndex = oldList.size() - i - 1;
         size_t newIndex = newList.size() - i - 1;
         oldMap[oldIndex].first = oldList[oldIndex].get();
@@ -240,26 +238,22 @@
     DiffTable newTable;
     DiffTable oldTable;
 
-    for (size_t i = 0; i < newList.size(); ++i) {
-        DiffTable::iterator it = newTable.add(newList[i]->m_sha1, Vector<size_t>()).iterator;
-        it->value.append(i);
-    }
+    for (size_t i = 0; i < newList.size(); ++i)
+        newTable.add(newList[i]->sha1, Vector<size_t>()).iterator->value.append(i);
 
-    for (size_t i = 0; i < oldList.size(); ++i) {
-        DiffTable::iterator it = oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).iterator;
-        it->value.append(i);
-    }
+    for (size_t i = 0; i < oldList.size(); ++i)
+        oldTable.add(oldList[i]->sha1, Vector<size_t>()).iterator->value.append(i);
 
-    for (DiffTable::iterator newIt = newTable.begin(); newIt != newTable.end(); ++newIt) {
-        if (newIt->value.size() != 1)
+    for (auto& newEntry : newTable) {
+        if (newEntry.value.size() != 1)
             continue;
 
-        DiffTable::iterator oldIt = oldTable.find(newIt->key);
+        auto oldIt = oldTable.find(newEntry.key);
         if (oldIt == oldTable.end() || oldIt->value.size() != 1)
             continue;
 
-        newMap[newIt->value[0]] = std::make_pair(newList[newIt->value[0]].get(), oldIt->value[0]);
-        oldMap[oldIt->value[0]] = std::make_pair(oldList[oldIt->value[0]].get(), newIt->value[0]);
+        newMap[newEntry.value[0]] = std::make_pair(newList[newEntry.value[0]].get(), oldIt->value[0]);
+        oldMap[oldIt->value[0]] = std::make_pair(oldList[oldIt->value[0]].get(), newEntry.value[0]);
     }
 
     for (size_t i = 0; newList.size() > 0 && i < newList.size() - 1; ++i) {
@@ -267,7 +261,7 @@
             continue;
 
         size_t j = newMap[i].second + 1;
-        if (j < oldMap.size() && !oldMap[j].first && newList[i + 1]->m_sha1 == oldList[j]->m_sha1) {
+        if (j < oldMap.size() && !oldMap[j].first && newList[i + 1]->sha1 == oldList[j]->sha1) {
             newMap[i + 1] = std::make_pair(newList[i + 1].get(), j);
             oldMap[j] = std::make_pair(oldList[j].get(), i + 1);
         }
@@ -278,7 +272,7 @@
             continue;
 
         size_t j = newMap[i].second - 1;
-        if (!oldMap[j].first && newList[i - 1]->m_sha1 == oldList[j]->m_sha1) {
+        if (!oldMap[j].first && newList[i - 1]->sha1 == oldList[j]->sha1) {
             newMap[i - 1] = std::make_pair(newList[i - 1].get(), j);
             oldMap[j] = std::make_pair(oldList[j].get(), i - 1);
         }
@@ -292,9 +286,9 @@
     return std::make_pair(oldMap, newMap);
 }
 
-bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector<std::unique_ptr<Digest>>& oldList, const Vector<std::unique_ptr<Digest>>& newList, ExceptionCode& ec)
+ExceptionOr<void> DOMPatchSupport::innerPatchChildren(ContainerNode& parentNode, const Vector<std::unique_ptr<Digest>>& oldList, const Vector<std::unique_ptr<Digest>>& newList)
 {
-    std::pair<ResultMap, ResultMap> resultMaps = diff(oldList, newList);
+    auto resultMaps = diff(oldList, newList);
     ResultMap& oldMap = resultMaps.first;
     ResultMap& newMap = resultMaps.second;
 
@@ -316,28 +310,30 @@
 
         // Always match <head> and <body> tags with each other - we can't remove them from the DOM
         // upon patching.
-        if (oldList[i]->m_node->hasTagName(headTag)) {
+        if (oldList[i]->node->hasTagName(headTag)) {
             oldHead = oldList[i].get();
             continue;
         }
-        if (oldList[i]->m_node->hasTagName(bodyTag)) {
+        if (oldList[i]->node->hasTagName(bodyTag)) {
             oldBody = oldList[i].get();
             continue;
         }
 
         // Check if this change is between stable nodes. If it is, consider it as "modified".
-        if (!m_unusedNodesMap.contains(oldList[i]->m_sha1) && (!i || oldMap[i - 1].first) && (i == oldMap.size() - 1 || oldMap[i + 1].first)) {
+        if (!m_unusedNodesMap.contains(oldList[i]->sha1) && (!i || oldMap[i - 1].first) && (i == oldMap.size() - 1 || oldMap[i + 1].first)) {
             size_t anchorCandidate = i ? oldMap[i - 1].second + 1 : 0;
             size_t anchorAfter = i == oldMap.size() - 1 ? anchorCandidate + 1 : oldMap[i + 1].second;
             if (anchorAfter - anchorCandidate == 1 && anchorCandidate < newList.size())
                 merges.set(newList[anchorCandidate].get(), oldList[i].get());
             else {
-                if (!removeChildAndMoveToNew(oldList[i].get(), ec))
-                    return false;
+                auto result = removeChildAndMoveToNew(*oldList[i]);
+                if (result.hasException())
+                    return result.releaseException();
             }
         } else {
-            if (!removeChildAndMoveToNew(oldList[i].get(), ec))
-                return false;
+            auto result = removeChildAndMoveToNew(*oldList[i]);
+            if (result.hasException())
+                return result.releaseException();
         }
     }
 
@@ -354,48 +350,50 @@
             continue;
         }
         usedOldOrdinals.add(oldOrdinal);
-        markNodeAsUsed(newMap[i].first);
+        markNodeAsUsed(*newMap[i].first);
     }
 
     // Mark <head> and <body> nodes for merge.
     if (oldHead || oldBody) {
         for (size_t i = 0; i < newList.size(); ++i) {
-            if (oldHead && newList[i]->m_node->hasTagName(headTag))
+            if (oldHead && newList[i]->node->hasTagName(headTag))
                 merges.set(newList[i].get(), oldHead);
-            if (oldBody && newList[i]->m_node->hasTagName(bodyTag))
+            if (oldBody && newList[i]->node->hasTagName(bodyTag))
                 merges.set(newList[i].get(), oldBody);
         }
     }
 
     // 2. Patch nodes marked for merge.
     for (auto& merge : merges) {
-        if (!innerPatchNode(merge.value, merge.key, ec))
-            return false;
+        auto result = innerPatchNode(*merge.value, *merge.key);
+        if (result.hasException())
+            return result.releaseException();
     }
 
     // 3. Insert missing nodes.
     for (size_t i = 0; i < newMap.size(); ++i) {
         if (newMap[i].first || merges.contains(newList[i].get()))
             continue;
-        if (!insertBeforeAndMarkAsUsed(*parentNode, *newList[i], parentNode->traverseToChildAt(i), ec))
-            return false;
+        auto result = insertBeforeAndMarkAsUsed(parentNode, *newList[i], parentNode.traverseToChildAt(i));
+        if (result.hasException())
+            return result.releaseException();
     }
 
     // 4. Then put all nodes that retained into their slots (sort by new index).
     for (size_t i = 0; i < oldMap.size(); ++i) {
         if (!oldMap[i].first)
             continue;
-        RefPtr<Node> node = oldMap[i].first->m_node;
-        Node* anchorNode = parentNode->traverseToChildAt(oldMap[i].second);
-        if (node.get() == anchorNode)
+        RefPtr<Node> node = oldMap[i].first->node;
+        auto* anchorNode = parentNode.traverseToChildAt(oldMap[i].second);
+        if (node == anchorNode)
             continue;
         if (node->hasTagName(bodyTag) || node->hasTagName(headTag))
             continue; // Never move head or body, move the rest of the nodes around them.
-
-        if (!m_domEditor->insertBefore(*parentNode, node.releaseNonNull(), anchorNode, ec))
-            return false;
+        auto result = m_domEditor.insertBefore(parentNode, node.releaseNonNull(), anchorNode);
+        if (result.hasException())
+            return result.releaseException();
     }
-    return true;
+    return { };
 }
 
 static void addStringToSHA1(SHA1& sha1, const String& string)
@@ -404,94 +402,98 @@
     sha1.addBytes(reinterpret_cast<const uint8_t*>(cString.data()), cString.length());
 }
 
-std::unique_ptr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node* node, UnusedNodesMap* unusedNodesMap)
+std::unique_ptr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node& node, UnusedNodesMap* unusedNodesMap)
 {
-    auto digest = std::make_unique<Digest>(node);
+    auto digest = std::make_unique<Digest>();
+    digest->node = &node;
     SHA1 sha1;
 
-    Node::NodeType nodeType = node->nodeType();
+    auto nodeType = node.nodeType();
     sha1.addBytes(reinterpret_cast<const uint8_t*>(&nodeType), sizeof(nodeType));
-    addStringToSHA1(sha1, node->nodeName());
-    addStringToSHA1(sha1, node->nodeValue());
+    addStringToSHA1(sha1, node.nodeName());
+    addStringToSHA1(sha1, node.nodeValue());
 
-    if (node->nodeType() == Node::ELEMENT_NODE) {
-        Node* child = node->firstChild();
+    if (node.nodeType() == Node::ELEMENT_NODE) {
+        Node* child = node.firstChild();
         while (child) {
-            std::unique_ptr<Digest> childInfo = createDigest(child, unusedNodesMap);
-            addStringToSHA1(sha1, childInfo->m_sha1);
+            std::unique_ptr<Digest> childInfo = createDigest(*child, unusedNodesMap);
+            addStringToSHA1(sha1, childInfo->sha1);
             child = child->nextSibling();
-            digest->m_children.append(WTFMove(childInfo));
+            digest->children.append(WTFMove(childInfo));
         }
-        Element* element = downcast<Element>(node);
+        auto& element = downcast<Element>(node);
 
-        if (element->hasAttributesWithoutUpdate()) {
+        if (element.hasAttributesWithoutUpdate()) {
             SHA1 attrsSHA1;
-            for (const Attribute& attribute : element->attributesIterator()) {
+            for (auto& attribute : element.attributesIterator()) {
                 addStringToSHA1(attrsSHA1, attribute.name().toString());
                 addStringToSHA1(attrsSHA1, attribute.value());
             }
             SHA1::Digest attrsHash;
             attrsSHA1.computeHash(attrsHash);
-            digest->m_attrsSHA1 = base64Encode(attrsHash.data(), 10);
-            addStringToSHA1(sha1, digest->m_attrsSHA1);
+            digest->attrsSHA1 = base64Encode(attrsHash.data(), 10);
+            addStringToSHA1(sha1, digest->attrsSHA1);
         }
     }
 
     SHA1::Digest hash;
     sha1.computeHash(hash);
-    digest->m_sha1 = base64Encode(hash.data(), 10);
+    digest->sha1 = base64Encode(hash.data(), 10);
     if (unusedNodesMap)
-        unusedNodesMap->add(digest->m_sha1, digest.get());
+        unusedNodesMap->add(digest->sha1, digest.get());
 
     return digest;
 }
 
-bool DOMPatchSupport::insertBeforeAndMarkAsUsed(ContainerNode& parentNode, Digest& digest, Node* anchor, ExceptionCode& ec)
+ExceptionOr<void> DOMPatchSupport::insertBeforeAndMarkAsUsed(ContainerNode& parentNode, Digest& digest, Node* anchor)
 {
-    ASSERT(digest.m_node);
-    bool result = m_domEditor->insertBefore(parentNode, *digest.m_node, anchor, ec);
-    markNodeAsUsed(&digest);
+    ASSERT(digest.node);
+    auto result = m_domEditor.insertBefore(parentNode, *digest.node, anchor);
+    markNodeAsUsed(digest);
     return result;
 }
 
-bool DOMPatchSupport::removeChildAndMoveToNew(Digest* oldDigest, ExceptionCode& ec)
+ExceptionOr<void> DOMPatchSupport::removeChildAndMoveToNew(Digest& oldDigest)
 {
-    RefPtr<Node> oldNode = oldDigest->m_node;
+    Ref<Node> oldNode = *oldDigest.node;
     ASSERT(oldNode->parentNode());
-    if (!m_domEditor->removeChild(*oldNode->parentNode(), *oldNode, ec))
-        return false;
+    auto result = m_domEditor.removeChild(*oldNode->parentNode(), oldNode);
+    if (result.hasException())
+        return result.releaseException();
 
     // Diff works within levels. In order not to lose the node identity when user
     // prepends his HTML with "<div>" (i.e. all nodes are shifted to the next nested level),
     // prior to dropping the original node on the floor, check whether new DOM has a digest
     // with matching sha1. If it does, replace it with the original DOM chunk. Chances are
     // high that it will get merged back into the original DOM during the further patching.
-    UnusedNodesMap::iterator it = m_unusedNodesMap.find(oldDigest->m_sha1);
+    auto it = m_unusedNodesMap.find(oldDigest.sha1);
     if (it != m_unusedNodesMap.end()) {
-        Digest* newDigest = it->value;
-        Node* newNode = newDigest->m_node;
-        if (!m_domEditor->replaceChild(*newNode->parentNode(), *oldNode, *newNode, ec))
-            return false;
-        newDigest->m_node = oldNode.get();
+        auto& newDigest = *it->value;
+        auto& newNode = *newDigest.node;
+        auto result = m_domEditor.replaceChild(*newNode.parentNode(), oldNode.get(), newNode);
+        if (result.hasException())
+            return result.releaseException();
+        newDigest.node = oldNode.ptr();
         markNodeAsUsed(newDigest);
-        return true;
+        return { };
     }
 
-    for (auto& child : oldDigest->m_children) {
-        if (!removeChildAndMoveToNew(child.get(), ec))
-            return false;
+    for (auto& child : oldDigest.children) {
+        auto result = removeChildAndMoveToNew(*child);
+        if (result.hasException())
+            return result.releaseException();
     }
-    return true;
+    return { };
 }
 
-void DOMPatchSupport::markNodeAsUsed(Digest* digest)
+void DOMPatchSupport::markNodeAsUsed(Digest& digest)
 {
     Deque<Digest*> queue;
-    queue.append(digest);
+    queue.append(&digest);
     while (!queue.isEmpty()) {
-        Digest* first = queue.takeFirst();
-        m_unusedNodesMap.remove(first->m_sha1);
-        for (auto& child : first->m_children)
+        auto& first = *queue.takeFirst();
+        m_unusedNodesMap.remove(first.sha1);
+        for (auto& child : first.children)
             queue.append(child.get());
     }
 }
diff --git a/Source/WebCore/inspector/DOMPatchSupport.h b/Source/WebCore/inspector/DOMPatchSupport.h
index 6e0147f..de927ad 100644
--- a/Source/WebCore/inspector/DOMPatchSupport.h
+++ b/Source/WebCore/inspector/DOMPatchSupport.h
@@ -30,10 +30,9 @@
 
 #pragma once
 
-#include "ExceptionCode.h"
+#include "ExceptionOr.h"
 #include <wtf/HashMap.h>
 #include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -43,34 +42,34 @@
 class Node;
 
 class DOMPatchSupport final {
-    WTF_MAKE_NONCOPYABLE(DOMPatchSupport);
 public:
-    static void patchDocument(Document*, const String& markup);
+    static void patchDocument(Document&, const String& markup);
 
-    DOMPatchSupport(DOMEditor*, Document*);
-    ~DOMPatchSupport();
+    DOMPatchSupport(DOMEditor&, Document&);
 
     void patchDocument(const String& markup);
-    Node* patchNode(Node&, const String& markup, ExceptionCode&);
+    ExceptionOr<Node*> patchNode(Node&, const String& markup);
 
 private:
     struct Digest;
-    typedef Vector<std::pair<Digest*, size_t>> ResultMap;
-    typedef HashMap<String, Digest*> UnusedNodesMap;
 
-    bool innerPatchNode(Digest* oldNode, Digest* newNode, ExceptionCode&);
+    using ResultMap = Vector<std::pair<Digest*, size_t>>;
+    using UnusedNodesMap = HashMap<String, Digest*>;
+
+    ExceptionOr<void> innerPatchNode(Digest& oldNode, Digest& newNode);
     std::pair<ResultMap, ResultMap> diff(const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren);
-    bool innerPatchChildren(ContainerNode*, const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren, ExceptionCode&);
-    std::unique_ptr<Digest> createDigest(Node*, UnusedNodesMap*);
-    bool insertBeforeAndMarkAsUsed(ContainerNode&, Digest&, Node* anchor, ExceptionCode&);
-    bool removeChildAndMoveToNew(Digest*, ExceptionCode&);
-    void markNodeAsUsed(Digest*);
+    ExceptionOr<void> innerPatchChildren(ContainerNode&, const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren);
+    std::unique_ptr<Digest> createDigest(Node&, UnusedNodesMap*);
+    ExceptionOr<void> insertBeforeAndMarkAsUsed(ContainerNode&, Digest&, Node* anchor);
+    ExceptionOr<void> removeChildAndMoveToNew(Digest&);
+    void markNodeAsUsed(Digest&);
+
 #ifdef DEBUG_DOM_PATCH_SUPPORT
     void dumpMap(const ResultMap&, const String& name);
 #endif
 
-    DOMEditor* m_domEditor;
-    Document* m_document;
+    DOMEditor& m_domEditor;
+    Document& m_document;
 
     UnusedNodesMap m_unusedNodesMap;
 };
diff --git a/Source/WebCore/inspector/InspectorCSSAgent.cpp b/Source/WebCore/inspector/InspectorCSSAgent.cpp
index 262ff9c..07f322c 100644
--- a/Source/WebCore/inspector/InspectorCSSAgent.cpp
+++ b/Source/WebCore/inspector/InspectorCSSAgent.cpp
@@ -175,32 +175,35 @@
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+private:
+    ExceptionOr<void> perform() final
     {
-        if (!m_styleSheet->getText(&m_oldText))
-            return false;
-        return redo(ec);
+        auto result = m_styleSheet->text();
+        if (result.hasException())
+            return result.releaseException();
+        m_oldText = result.releaseReturnValue();
+        return redo();
     }
 
-    bool undo(ExceptionCode& ec) override
+    ExceptionOr<void> undo() final
     {
-        if (m_styleSheet->setText(m_oldText, ec)) {
-            m_styleSheet->reparseStyleSheet(m_oldText);
-            return true;
-        }
-        return false;
+        auto result = m_styleSheet->setText(m_oldText);
+        if (result.hasException())
+            return result.releaseException();
+        m_styleSheet->reparseStyleSheet(m_oldText);
+        return { };
     }
 
-    bool redo(ExceptionCode& ec) override
+    ExceptionOr<void> redo() final
     {
-        if (m_styleSheet->setText(m_text, ec)) {
-            m_styleSheet->reparseStyleSheet(m_text);
-            return true;
-        }
-        return false;
+        auto result = m_styleSheet->setText(m_text);
+        if (result.hasException())
+            return result.releaseException();
+        m_styleSheet->reparseStyleSheet(m_text);
+        return { };
     }
 
-    String mergeId() override
+    String mergeId() final
     {
         return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().data());
     }
@@ -208,12 +211,9 @@
     void merge(std::unique_ptr<Action> action) override
     {
         ASSERT(action->mergeId() == mergeId());
-
-        SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(action.get());
-        m_text = other->m_text;
+        m_text = static_cast<SetStyleSheetTextAction&>(*action).m_text;
     }
 
-private:
     String m_text;
     String m_oldText;
 };
@@ -228,19 +228,19 @@
     {
     }
 
-    bool perform(ExceptionCode& ec) override
+    ExceptionOr<void> perform() override
     {
-        return redo(ec);
+        return redo();
     }
 
-    bool undo(ExceptionCode& ec) override
+    ExceptionOr<void> undo() override
     {
-        return m_styleSheet->setStyleText(m_cssId, m_oldText, nullptr, ec);
+        return m_styleSheet->setStyleText(m_cssId, m_oldText, nullptr);
     }
 
-    bool redo(ExceptionCode& ec) override
+    ExceptionOr<void> redo() override
     {
-        return m_styleSheet->setStyleText(m_cssId, m_text, &m_oldText, ec);
+        return m_styleSheet->setStyleText(m_cssId, m_text, &m_oldText);
     }
 
     String mergeId() override
@@ -273,25 +273,26 @@
     {
     }
 
-    bool perform(ExceptionCode& ec) override
-    {
-        m_oldSelector = m_styleSheet->ruleSelector(m_cssId, ec);
-        if (ec)
-            return false;
-        return redo(ec);
-    }
-
-    bool undo(ExceptionCode& ec) override
-    {
-        return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, ec);
-    }
-
-    bool redo(ExceptionCode& ec) override
-    {
-        return m_styleSheet->setRuleSelector(m_cssId, m_selector, ec);
-    }
-
 private:
+    ExceptionOr<void> perform() final
+    {
+        auto result = m_styleSheet->ruleSelector(m_cssId);
+        if (result.hasException())
+            return result.releaseException();
+        m_oldSelector = result.releaseReturnValue();
+        return redo();
+    }
+
+    ExceptionOr<void> undo() final
+    {
+        return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector);
+    }
+
+    ExceptionOr<void> redo() final
+    {
+        return m_styleSheet->setRuleSelector(m_cssId, m_selector);
+    }
+
     InspectorCSSId m_cssId;
     String m_selector;
     String m_oldSelector;
@@ -306,34 +307,33 @@
     {
     }
 
-    bool perform(ExceptionCode& ec) override
-    {
-        return redo(ec);
-    }
-
-    bool undo(ExceptionCode& ec) override
-    {
-        return m_styleSheet->deleteRule(m_newId, ec);
-    }
-
-    bool redo(ExceptionCode& ec) override
-    {
-        CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, ec);
-        if (ec)
-            return false;
-        m_newId = m_styleSheet->ruleId(cssStyleRule);
-        return true;
-    }
-
-    InspectorCSSId newRuleId() { return m_newId; }
+    InspectorCSSId newRuleId() const { return m_newId; }
 
 private:
+    ExceptionOr<void> perform() final
+    {
+        return redo();
+    }
+
+    ExceptionOr<void> undo() final
+    {
+        return m_styleSheet->deleteRule(m_newId);
+    }
+
+    ExceptionOr<void> redo() final
+    {
+        auto result = m_styleSheet->addRule(m_selector);
+        if (result.hasException())
+            return result.releaseException();
+        m_newId = m_styleSheet->ruleId(result.releaseReturnValue());
+        return { };
+    }
+
     InspectorCSSId m_newId;
     String m_selector;
     String m_oldSelector;
 };
 
-// static
 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule& rule)
 {
     if (!is<CSSStyleRule>(rule))
@@ -703,7 +703,9 @@
     if (!inspectorStyleSheet)
         return;
 
-    inspectorStyleSheet->getText(result);
+    auto text = inspectorStyleSheet->text();
+    if (!text.hasException())
+        *result = text.releaseReturnValue();
 }
 
 void InspectorCSSAgent::setStyleSheetText(ErrorString& errorString, const String& styleSheetId, const String& text)
@@ -712,9 +714,9 @@
     if (!inspectorStyleSheet)
         return;
 
-    ExceptionCode ec = 0;
-    m_domAgent->history()->perform(std::make_unique<SetStyleSheetTextAction>(inspectorStyleSheet, text), ec);
-    errorString = InspectorDOMAgent::toErrorString(ec);
+    auto result = m_domAgent->history()->perform(std::make_unique<SetStyleSheetTextAction>(inspectorStyleSheet, text));
+    if (result.hasException())
+        errorString = InspectorDOMAgent::toErrorString(result.releaseException());
 }
 
 void InspectorCSSAgent::setStyleText(ErrorString& errorString, const InspectorObject& fullStyleId, const String& text, RefPtr<Inspector::Protocol::CSS::CSSStyle>& result)
@@ -726,11 +728,13 @@
     if (!inspectorStyleSheet)
         return;
 
-    ExceptionCode ec = 0;
-    bool success = m_domAgent->history()->perform(std::make_unique<SetStyleTextAction>(inspectorStyleSheet, compoundId, text), ec);
-    if (success)
-        result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
-    errorString = InspectorDOMAgent::toErrorString(ec);
+    auto performResult = m_domAgent->history()->perform(std::make_unique<SetStyleTextAction>(inspectorStyleSheet, compoundId, text));
+    if (performResult.hasException()) {
+        errorString = InspectorDOMAgent::toErrorString(performResult.releaseException());
+        return;
+    }
+
+    result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
 }
 
 void InspectorCSSAgent::setRuleSelector(ErrorString& errorString, const InspectorObject& fullRuleId, const String& selector, RefPtr<Inspector::Protocol::CSS::CSSRule>& result)
@@ -742,12 +746,13 @@
     if (!inspectorStyleSheet)
         return;
 
-    ExceptionCode ec = 0;
-    bool success = m_domAgent->history()->perform(std::make_unique<SetRuleSelectorAction>(inspectorStyleSheet, compoundId, selector), ec);
+    auto performResult = m_domAgent->history()->perform(std::make_unique<SetRuleSelectorAction>(inspectorStyleSheet, compoundId, selector));
+    if (performResult.hasException()) {
+        errorString = InspectorDOMAgent::toErrorString(performResult.releaseException());
+        return;
+    }
 
-    if (success)
-        result = inspectorStyleSheet->buildObjectForRule(inspectorStyleSheet->ruleForId(compoundId), nullptr);
-    errorString = InspectorDOMAgent::toErrorString(ec);
+    result = inspectorStyleSheet->buildObjectForRule(inspectorStyleSheet->ruleForId(compoundId), nullptr);
 }
 
 void InspectorCSSAgent::createStyleSheet(ErrorString& errorString, const String& frameId, String* styleSheetId)
@@ -795,11 +800,10 @@
     // Set this flag, so when we create it, we put it into the via inspector map.
     m_creatingViaInspectorStyleSheet = true;
     InlineStyleOverrideScope overrideScope(document);
-    ExceptionCode ec = 0;
-    targetNode->appendChild(styleElement, ec);
+    auto appendResult = targetNode->appendChild(styleElement);
     document.styleScope().flushPendingUpdate();
     m_creatingViaInspectorStyleSheet = false;
-    if (ec)
+    if (appendResult.hasException())
         return nullptr;
 
     auto iterator = m_documentToInspectorStyleSheet.find(&document);
@@ -823,16 +827,15 @@
         return;
     }
 
-    ExceptionCode ec = 0;
     auto action = std::make_unique<AddRuleAction>(inspectorStyleSheet, selector);
-    AddRuleAction* rawAction = action.get();
-    bool success = m_domAgent->history()->perform(WTFMove(action), ec);
-    if (!success) {
-        errorString = InspectorDOMAgent::toErrorString(ec);
+    auto& rawAction = *action;
+    auto performResult = m_domAgent->history()->perform(WTFMove(action));
+    if (performResult.hasException()) {
+        errorString = InspectorDOMAgent::toErrorString(performResult.releaseException());
         return;
     }
 
-    InspectorCSSId ruleId = rawAction->newRuleId();
+    InspectorCSSId ruleId = rawAction.newRuleId();
     CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId);
     result = inspectorStyleSheet->buildObjectForRule(rule, nullptr);
 }
diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp
index d516a6a..a2acdbd 100644
--- a/Source/WebCore/inspector/InspectorDOMAgent.cpp
+++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp
@@ -231,7 +231,7 @@
 void InspectorDOMAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
 {
     m_history = std::make_unique<InspectorHistory>();
-    m_domEditor = std::make_unique<DOMEditor>(m_history.get());
+    m_domEditor = std::make_unique<DOMEditor>(*m_history);
 
     m_instrumentingAgents.setInspectorDOMAgent(this);
     m_document = m_pageAgent->mainFrame().document();
@@ -654,7 +654,7 @@
     if (!element)
         return;
 
-    m_domEditor->setAttribute(element, name, value, errorString);
+    m_domEditor->setAttribute(*element, name, value, errorString);
 }
 
 void InspectorDOMAgent::setAttributesAsText(ErrorString& errorString, int elementId, const String& text, const String* const name)
@@ -678,7 +678,7 @@
 
     Element* childElement = downcast<Element>(child);
     if (!childElement->hasAttributes() && name) {
-        m_domEditor->removeAttribute(element, *name, errorString);
+        m_domEditor->removeAttribute(*element, *name, errorString);
         return;
     }
 
@@ -686,12 +686,12 @@
     for (const Attribute& attribute : childElement->attributesIterator()) {
         // Add attribute pair
         foundOriginalAttribute = foundOriginalAttribute || (name && attribute.name().toString() == *name);
-        if (!m_domEditor->setAttribute(element, attribute.name().toString(), attribute.value(), errorString))
+        if (!m_domEditor->setAttribute(*element, attribute.name().toString(), attribute.value(), errorString))
             return;
     }
 
     if (!foundOriginalAttribute && name && !name->stripWhiteSpace().isEmpty())
-        m_domEditor->removeAttribute(element, *name, errorString);
+        m_domEditor->removeAttribute(*element, *name, errorString);
 }
 
 void InspectorDOMAgent::removeAttribute(ErrorString& errorString, int elementId, const String& name)
@@ -700,7 +700,7 @@
     if (!element)
         return;
 
-    m_domEditor->removeAttribute(element, name, errorString);
+    m_domEditor->removeAttribute(*element, name, errorString);
 }
 
 void InspectorDOMAgent::removeNode(ErrorString& errorString, int nodeId)
@@ -765,8 +765,7 @@
 void InspectorDOMAgent::setOuterHTML(ErrorString& errorString, int nodeId, const String& outerHTML)
 {
     if (!nodeId) {
-        DOMPatchSupport domPatchSupport(m_domEditor.get(), m_document.get());
-        domPatchSupport.patchDocument(outerHTML);
+        DOMPatchSupport { *m_domEditor, *m_document }.patchDocument(outerHTML);
         return;
     }
 
@@ -780,8 +779,8 @@
         return;
     }
 
-    Node* newNode = 0;
-    if (!m_domEditor->setOuterHTML(*node, outerHTML, &newNode, errorString))
+    Node* newNode = nullptr;
+    if (!m_domEditor->setOuterHTML(*node, outerHTML, newNode, errorString))
         return;
 
     if (!newNode) {
@@ -802,12 +801,12 @@
     if (!node)
         return;
 
-    if (node->nodeType() != Node::TEXT_NODE) {
+    if (!is<Text>(*node)) {
         errorString = ASCIILiteral("Can only set value of text nodes");
         return;
     }
 
-    m_domEditor->replaceWholeText(downcast<Text>(node), value, errorString);
+    m_domEditor->replaceWholeText(downcast<Text>(*node), value, errorString);
 }
 
 void InspectorDOMAgent::getEventListenersForNode(ErrorString& errorString, int nodeId, const String* objectGroup, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::DOM::EventListener>>& listenersArray)
@@ -1198,16 +1197,16 @@
 
 void InspectorDOMAgent::undo(ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    m_history->undo(ec);
-    errorString = toErrorString(ec);
+    auto result = m_history->undo();
+    if (result.hasException())
+        errorString = toErrorString(result.releaseException());
 }
 
 void InspectorDOMAgent::redo(ErrorString& errorString)
 {
-    ExceptionCode ec = 0;
-    m_history->redo(ec);
-    errorString = toErrorString(ec);
+    auto result = m_history->redo();
+    if (result.hasException())
+        errorString = toErrorString(result.releaseException());
 }
 
 void InspectorDOMAgent::markUndoableState(ErrorString&)
diff --git a/Source/WebCore/inspector/InspectorHistory.cpp b/Source/WebCore/inspector/InspectorHistory.cpp
index f701873..2c0816e 100644
--- a/Source/WebCore/inspector/InspectorHistory.cpp
+++ b/Source/WebCore/inspector/InspectorHistory.cpp
@@ -31,63 +31,29 @@
 #include "config.h"
 #include "InspectorHistory.h"
 
-#include "ExceptionCodePlaceholder.h"
 #include "Node.h"
 
 namespace WebCore {
 
-namespace {
-
 class UndoableStateMark : public InspectorHistory::Action {
 public:
-    UndoableStateMark() : InspectorHistory::Action("[UndoableState]") { }
+    UndoableStateMark()
+        : Action("[UndoableState]")
+    {
+    }
 
-    bool perform(ExceptionCode&) override { return true; }
-
-    bool undo(ExceptionCode&) override { return true; }
-
-    bool redo(ExceptionCode&) override { return true; }
-
-    bool isUndoableStateMark() override { return true; }
+private:
+    ExceptionOr<void> perform() final { return { }; }
+    ExceptionOr<void> undo() final { return { }; }
+    ExceptionOr<void> redo() final { return { }; }
+    bool isUndoableStateMark() final { return true; }
 };
 
-}
-
-InspectorHistory::Action::Action(const String& name) : m_name(name)
+ExceptionOr<void> InspectorHistory::perform(std::unique_ptr<Action> action)
 {
-}
-
-InspectorHistory::Action::~Action()
-{
-}
-
-String InspectorHistory::Action::toString()
-{
-    return m_name;
-}
-
-bool InspectorHistory::Action::isUndoableStateMark()
-{
-    return false;
-}
-
-String InspectorHistory::Action::mergeId()
-{
-    return emptyString();
-}
-
-void InspectorHistory::Action::merge(std::unique_ptr<Action>)
-{
-}
-
-InspectorHistory::InspectorHistory() : m_afterLastActionIndex(0) { }
-
-InspectorHistory::~InspectorHistory() { }
-
-bool InspectorHistory::perform(std::unique_ptr<Action> action, ExceptionCode& ec)
-{
-    if (!action->perform(ec))
-        return false;
+    auto performResult = action->perform();
+    if (performResult.hasException())
+        return performResult.releaseException();
 
     if (!action->mergeId().isEmpty() && m_afterLastActionIndex > 0 && action->mergeId() == m_history[m_afterLastActionIndex - 1]->mergeId())
         m_history[m_afterLastActionIndex - 1]->merge(WTFMove(action));
@@ -96,49 +62,51 @@
         m_history.append(WTFMove(action));
         ++m_afterLastActionIndex;
     }
-    return true;
+    return { };
 }
 
 void InspectorHistory::markUndoableState()
 {
-    perform(std::make_unique<UndoableStateMark>(), IGNORE_EXCEPTION);
+    perform(std::make_unique<UndoableStateMark>());
 }
 
-bool InspectorHistory::undo(ExceptionCode& ec)
+ExceptionOr<void> InspectorHistory::undo()
 {
     while (m_afterLastActionIndex > 0 && m_history[m_afterLastActionIndex - 1]->isUndoableStateMark())
         --m_afterLastActionIndex;
 
     while (m_afterLastActionIndex > 0) {
         Action* action = m_history[m_afterLastActionIndex - 1].get();
-        if (!action->undo(ec)) {
+        auto undoResult = action->undo();
+        if (undoResult.hasException()) {
             reset();
-            return false;
+            return undoResult.releaseException();
         }
         --m_afterLastActionIndex;
         if (action->isUndoableStateMark())
             break;
     }
 
-    return true;
+    return { };
 }
 
-bool InspectorHistory::redo(ExceptionCode& ec)
+ExceptionOr<void> InspectorHistory::redo()
 {
     while (m_afterLastActionIndex < m_history.size() && m_history[m_afterLastActionIndex]->isUndoableStateMark())
         ++m_afterLastActionIndex;
 
     while (m_afterLastActionIndex < m_history.size()) {
         Action* action = m_history[m_afterLastActionIndex].get();
-        if (!action->redo(ec)) {
+        auto redoResult = action->redo();
+        if (redoResult.hasException()) {
             reset();
-            return false;
+            return redoResult.releaseException();
         }
         ++m_afterLastActionIndex;
         if (action->isUndoableStateMark())
             break;
     }
-    return true;
+    return { };
 }
 
 void InspectorHistory::reset()
diff --git a/Source/WebCore/inspector/InspectorHistory.h b/Source/WebCore/inspector/InspectorHistory.h
index bb1ecf4..318fca3 100644
--- a/Source/WebCore/inspector/InspectorHistory.h
+++ b/Source/WebCore/inspector/InspectorHistory.h
@@ -30,9 +30,8 @@
 
 #pragma once
 
-#include "ExceptionCode.h"
+#include "ExceptionOr.h"
 #include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -42,36 +41,40 @@
     class Action {
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        Action(const String& name);
-        virtual ~Action();
-        virtual String toString();
+        explicit Action(const String& name)
+            : m_name { name }
+        {
+        }
 
-        virtual String mergeId();
-        virtual void merge(std::unique_ptr<Action>);
+        virtual ~Action() = default;
+        virtual String toString() { return m_name; }
 
-        virtual bool perform(ExceptionCode&) = 0;
+        virtual String mergeId() { return emptyString(); }
+        virtual void merge(std::unique_ptr<Action>) { };
 
-        virtual bool undo(ExceptionCode&) = 0;
-        virtual bool redo(ExceptionCode&) = 0;
+        virtual ExceptionOr<void> perform() = 0;
 
-        virtual bool isUndoableStateMark();
+        virtual ExceptionOr<void> undo() = 0;
+        virtual ExceptionOr<void> redo() = 0;
+
+        virtual bool isUndoableStateMark() { return false; }
+
     private:
         String m_name;
     };
 
-    InspectorHistory();
-    ~InspectorHistory();
+    InspectorHistory() = default;
 
-    bool perform(std::unique_ptr<Action>, ExceptionCode&);
+    ExceptionOr<void> perform(std::unique_ptr<Action>);
     void markUndoableState();
 
-    bool undo(ExceptionCode&);
-    bool redo(ExceptionCode&);
+    ExceptionOr<void> undo();
+    ExceptionOr<void> redo();
     void reset();
 
 private:
     Vector<std::unique_ptr<Action>> m_history;
-    size_t m_afterLastActionIndex;
+    size_t m_afterLastActionIndex { 0 };
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/inspector/InspectorPageAgent.cpp b/Source/WebCore/inspector/InspectorPageAgent.cpp
index a0a5ebe..6f3d8ad 100644
--- a/Source/WebCore/inspector/InspectorPageAgent.cpp
+++ b/Source/WebCore/inspector/InspectorPageAgent.cpp
@@ -671,7 +671,7 @@
         errorString = ASCIILiteral("No Document instance to set HTML for");
         return;
     }
-    DOMPatchSupport::patchDocument(document, html);
+    DOMPatchSupport::patchDocument(*document, html);
 }
 
 void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show)
diff --git a/Source/WebCore/inspector/InspectorStyleSheet.cpp b/Source/WebCore/inspector/InspectorStyleSheet.cpp
index c2a953f..f4d1bd5 100644
--- a/Source/WebCore/inspector/InspectorStyleSheet.cpp
+++ b/Source/WebCore/inspector/InspectorStyleSheet.cpp
@@ -328,21 +328,19 @@
     return result;
 }
 
-bool InspectorStyle::getText(String* result) const
+ExceptionOr<String> InspectorStyle::text() const
 {
     // Precondition: m_parentStyleSheet->ensureParsedDataReady() has been called successfully.
-    RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
+    auto sourceData = extractSourceData();
     if (!sourceData)
-        return false;
+        return Exception { NOT_FOUND_ERR };
 
-    String styleSheetText;
-    bool success = m_parentStyleSheet->getText(&styleSheetText);
-    if (!success)
-        return false;
+    auto result = m_parentStyleSheet->text();
+    if (result.hasException())
+        return result.releaseException();
 
-    SourceRange& bodyRange = sourceData->ruleBodyRange;
-    *result = styleSheetText.substring(bodyRange.start, bodyRange.end - bodyRange.start);
-    return true;
+    auto& bodyRange = sourceData->ruleBodyRange;
+    return result.releaseReturnValue().substring(bodyRange.start, bodyRange.end - bodyRange.start);
 }
 
 static String lowercasePropertyName(const String& name)
@@ -357,12 +355,12 @@
 {
     HashSet<String> sourcePropertyNames;
 
-    RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
-    Vector<CSSPropertySourceData>* sourcePropertyData = sourceData ? &(sourceData->styleSourceData->propertyData) : nullptr;
+    auto sourceData = extractSourceData();
+    auto* sourcePropertyData = sourceData ? &sourceData->styleSourceData->propertyData : nullptr;
     if (sourcePropertyData) {
-        String styleDeclaration;
-        bool isStyleTextKnown = getText(&styleDeclaration);
-        ASSERT_UNUSED(isStyleTextKnown, isStyleTextKnown);
+        auto styleDeclarationOrException = text();
+        ASSERT(!styleDeclarationOrException.hasException());
+        String styleDeclaration = styleDeclarationOrException.hasException() ? emptyString() : styleDeclarationOrException.releaseReturnValue();
         for (auto& sourceData : *sourcePropertyData) {
             InspectorStyleProperty p(sourceData, true, false);
             p.setRawTextFromStyleDeclaration(styleDeclaration);
@@ -390,7 +388,7 @@
     String previousPriority;
     String previousStatus;
     std::unique_ptr<Vector<size_t>> lineEndings(m_parentStyleSheet ? m_parentStyleSheet->lineEndings() : nullptr);
-    RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
+    auto sourceData = extractSourceData();
     unsigned ruleBodyRangeStart = sourceData ? sourceData->ruleBodyRange.start : 0;
 
     for (Vector<InspectorStyleProperty>::iterator it = properties.begin(), itEnd = properties.end(); it != itEnd; ++it) {
@@ -504,9 +502,9 @@
     return m_parentStyleSheet->ruleSourceDataFor(m_style.get());
 }
 
-bool InspectorStyle::setText(const String& text, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyle::setText(const String& text)
 {
-    return m_parentStyleSheet->setStyleText(m_style.get(), text, ec);
+    return m_parentStyleSheet->setStyleText(m_style.get(), text);
 }
 
 String InspectorStyle::shorthandValue(const String& shorthandProperty) const
@@ -614,26 +612,22 @@
     m_pageStyleSheet->clearHadRulesMutation();
 }
 
-bool InspectorStyleSheet::setText(const String& text, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyleSheet::setText(const String& text)
 {
-    if (!checkPageStyleSheet(ec))
-        return false;
-    if (!m_parsedStyleSheet)
-        return false;
+    if (!m_pageStyleSheet)
+        return Exception { NOT_SUPPORTED_ERR };
 
     m_parsedStyleSheet->setText(text);
     m_flatRules.clear();
 
-    return true;
+    return { };
 }
 
-String InspectorStyleSheet::ruleSelector(const InspectorCSSId& id, ExceptionCode& ec)
+ExceptionOr<String> InspectorStyleSheet::ruleSelector(const InspectorCSSId& id)
 {
     CSSStyleRule* rule = ruleForId(id);
-    if (!rule) {
-        ec = NOT_FOUND_ERR;
-        return emptyString();
-    }
+    if (!rule)
+        return Exception { NOT_FOUND_ERR };
     return rule->selectorText();
 }
 
@@ -644,71 +638,58 @@
     return selectorList.isValid();
 }
 
-bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String& selector, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String& selector)
 {
-    if (!checkPageStyleSheet(ec))
-        return false;
+    if (!m_pageStyleSheet)
+        return Exception { NOT_SUPPORTED_ERR };
 
     // If the selector is invalid, do not proceed any further.
-    if (!isValidSelectorListString(selector, m_pageStyleSheet->ownerDocument())) {
-        ec = SYNTAX_ERR;
-        return false;
-    }
+    if (!isValidSelectorListString(selector, m_pageStyleSheet->ownerDocument()))
+        return Exception { SYNTAX_ERR };
 
     CSSStyleRule* rule = ruleForId(id);
-    if (!rule) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    if (!rule)
+        return Exception { NOT_FOUND_ERR };
 
     CSSStyleSheet* styleSheet = rule->parentStyleSheet();
-    if (!styleSheet || !ensureParsedDataReady()) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    if (!styleSheet || !ensureParsedDataReady())
+        return Exception { NOT_FOUND_ERR };
 
     // If the stylesheet is already mutated at this point, that must mean that our data has been modified
     // elsewhere. This should never happen as ensureParsedDataReady would return false in that case.
     ASSERT(!styleSheetMutated());
 
     rule->setSelectorText(selector);
-    RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(&rule->style());
-    if (!sourceData) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    auto sourceData = ruleSourceDataFor(&rule->style());
+    if (!sourceData)
+        return Exception { NOT_FOUND_ERR };
 
     String sheetText = m_parsedStyleSheet->text();
     sheetText.replace(sourceData->ruleHeaderRange.start, sourceData->ruleHeaderRange.length(), selector);
     m_parsedStyleSheet->setText(sheetText);
     m_pageStyleSheet->clearHadRulesMutation();
     fireStyleSheetChanged();
-    return true;
+    return { };
 }
 
-CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode& ec)
+ExceptionOr<CSSStyleRule*> InspectorStyleSheet::addRule(const String& selector)
 {
-    if (!checkPageStyleSheet(ec))
-        return nullptr;
-    if (!isValidSelectorListString(selector, m_pageStyleSheet->ownerDocument())) {
-        ec = SYNTAX_ERR;
-        return nullptr;
-    }
+    if (!m_pageStyleSheet)
+        return Exception { NOT_SUPPORTED_ERR };
 
-    String text;
-    bool success = getText(&text);
-    if (!success) {
-        ec = NOT_FOUND_ERR;
-        return nullptr;
-    }
+    if (!isValidSelectorListString(selector, m_pageStyleSheet->ownerDocument()))
+        return Exception { SYNTAX_ERR };
+
+    auto text = this->text();
+    if (text.hasException())
+        return text.releaseException();
+
     StringBuilder styleSheetText;
-    styleSheetText.append(text);
+    styleSheetText.append(text.releaseReturnValue());
 
     auto addRuleResult = m_pageStyleSheet->addRule(selector, emptyString(), Nullopt);
-    if (addRuleResult.hasException()) {
-        ec = addRuleResult.releaseException().code();
-        return nullptr;
-    }
+    if (addRuleResult.hasException())
+        return addRuleResult.releaseException();
     ASSERT(m_pageStyleSheet->length());
     unsigned lastRuleIndex = m_pageStyleSheet->length() - 1;
     CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex);
@@ -719,8 +700,7 @@
         // What we just added has to be a CSSStyleRule - we cannot handle other types of rules yet.
         // If it is not a style rule, pretend we never touched the stylesheet.
         m_pageStyleSheet->deleteRule(lastRuleIndex);
-        ec = SYNTAX_ERR;
-        return nullptr;
+        return Exception { SYNTAX_ERR };
     }
 
     if (!styleSheetText.isEmpty())
@@ -729,47 +709,40 @@
     styleSheetText.append(selector);
     styleSheetText.appendLiteral(" {}");
     // Using setText() as this operation changes the stylesheet rule set.
-    setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION);
+    setText(styleSheetText.toString());
 
     fireStyleSheetChanged();
 
     return styleRule;
 }
 
-bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyleSheet::deleteRule(const InspectorCSSId& id)
 {
-    if (!checkPageStyleSheet(ec))
-        return false;
-    RefPtr<CSSStyleRule> rule = ruleForId(id);
-    if (!rule) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
-    CSSStyleSheet* styleSheet = rule->parentStyleSheet();
-    if (!styleSheet || !ensureParsedDataReady()) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    if (!m_pageStyleSheet)
+        return Exception { NOT_SUPPORTED_ERR };
 
-    RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(&rule->style());
-    if (!sourceData) {
-        ec = NOT_FOUND_ERR;
-        return false;
-    }
+    RefPtr<CSSStyleRule> rule = ruleForId(id);
+    if (!rule)
+        return Exception { NOT_FOUND_ERR };
+    CSSStyleSheet* styleSheet = rule->parentStyleSheet();
+    if (!styleSheet || !ensureParsedDataReady())
+        return Exception { NOT_FOUND_ERR };
+
+    auto sourceData = ruleSourceDataFor(&rule->style());
+    if (!sourceData)
+        return Exception { NOT_FOUND_ERR };
 
     auto deleteRuleResult = styleSheet->deleteRule(id.ordinal());
-    // |rule| MAY NOT be addressed after this line!
+    if (deleteRuleResult.hasException())
+        return deleteRuleResult.releaseException();
 
-    if (deleteRuleResult.hasException()) {
-        ec = deleteRuleResult.releaseException().code();
-        return false;
-    }
+    // |rule| MAY NOT be addressed after this!
 
     String sheetText = m_parsedStyleSheet->text();
     sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRange.end - sourceData->ruleHeaderRange.start + 1);
-    setText(sheetText, ASSERT_NO_EXCEPTION);
+    setText(sheetText);
     fireStyleSheetChanged();
-    return true;
+    return { };
 }
 
 CSSStyleRule* InspectorStyleSheet::ruleForId(const InspectorCSSId& id) const
@@ -795,10 +768,9 @@
         .setRules(buildArrayForRuleList(cssRuleList.get()))
         .release();
 
-    String styleSheetText;
-    bool success = getText(&styleSheetText);
-    if (success)
-        result->setText(styleSheetText);
+    auto styleSheetText = text();
+    if (!styleSheetText.hasException())
+        result->setText(styleSheetText.releaseReturnValue());
 
     return WTFMove(result);
 }
@@ -981,40 +953,40 @@
 
     // Style text cannot be retrieved without stylesheet, so set cssText here.
     if (sourceData) {
-        String sheetText;
-        bool success = getText(&sheetText);
-        if (success) {
-            const SourceRange& bodyRange = sourceData->ruleBodyRange;
-            result->setCssText(sheetText.substring(bodyRange.start, bodyRange.end - bodyRange.start));
+        auto sheetText = text();
+        if (!sheetText.hasException()) {
+            auto& bodyRange = sourceData->ruleBodyRange;
+            result->setCssText(sheetText.releaseReturnValue().substring(bodyRange.start, bodyRange.end - bodyRange.start));
         }
     }
 
     return result;
 }
 
-bool InspectorStyleSheet::setStyleText(const InspectorCSSId& id, const String& text, String* oldText, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyleSheet::setStyleText(const InspectorCSSId& id, const String& text, String* oldText)
 {
-    RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
-    if (!inspectorStyle) {
-        ec = NOT_FOUND_ERR;
-        return false;
+    auto inspectorStyle = inspectorStyleForId(id);
+    if (!inspectorStyle)
+        return Exception { NOT_FOUND_ERR };
+
+    if (oldText) {
+        auto result = inspectorStyle->text();
+        if (result.hasException())
+            return result.releaseException();
+        *oldText = result.releaseReturnValue();
     }
 
-    if (oldText && !inspectorStyle->getText(oldText))
-        return false;
-
-    bool success = inspectorStyle->setText(text, ec);
-    if (success)
+    auto result = inspectorStyle->setText(text);
+    if (!result.hasException())
         fireStyleSheetChanged();
-    return success;
+    return result;
 }
 
-bool InspectorStyleSheet::getText(String* result) const
+ExceptionOr<String> InspectorStyleSheet::text() const
 {
     if (!ensureText())
-        return false;
-    *result = m_parsedStyleSheet->text();
-    return true;
+        return Exception { NOT_FOUND_ERR };
+    return String { m_parsedStyleSheet->text() };
 }
 
 CSSStyleDeclaration* InspectorStyleSheet::styleForId(const InspectorCSSId& id) const
@@ -1079,15 +1051,6 @@
     return UINT_MAX;
 }
 
-bool InspectorStyleSheet::checkPageStyleSheet(ExceptionCode& ec) const
-{
-    if (!m_pageStyleSheet) {
-        ec = NOT_SUPPORTED_ERR;
-        return false;
-    }
-    return true;
-}
-
 bool InspectorStyleSheet::styleSheetMutated() const
 {
     return m_pageStyleSheet && m_pageStyleSheet->hadRulesMutation();
@@ -1137,30 +1100,28 @@
         collectFlatRules(asCSSRuleList(pageStyleSheet()), &m_flatRules);
 }
 
-bool InspectorStyleSheet::setStyleText(CSSStyleDeclaration* style, const String& text, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyleSheet::setStyleText(CSSStyleDeclaration* style, const String& text)
 {
     if (!m_pageStyleSheet)
-        return false;
+        return Exception { NOT_FOUND_ERR };
     if (!ensureParsedDataReady())
-        return false;
+        return Exception { NOT_FOUND_ERR };
 
     String patchedStyleSheetText;
     bool success = styleSheetTextWithChangedStyle(style, text, &patchedStyleSheetText);
     if (!success)
-        return false;
+        return Exception { NOT_FOUND_ERR };
 
     InspectorCSSId id = ruleOrStyleId(style);
     if (id.isEmpty())
-        return false;
+        return Exception { NOT_FOUND_ERR };
 
     auto setCssTextResult = style->setCssText(text);
-    if (setCssTextResult.hasException()) {
-        ec = setCssTextResult.releaseException().code();
-        return false;
-    }
+    if (setCssTextResult.hasException())
+        return setCssTextResult.releaseException();
 
     m_parsedStyleSheet->setText(patchedStyleSheetText);
-    return true;
+    return { };
 }
 
 bool InspectorStyleSheet::styleSheetTextWithChangedStyle(CSSStyleDeclaration* style, const String& newStyleText, String* result)
@@ -1285,17 +1246,16 @@
     m_ruleSourceData = nullptr;
 }
 
-bool InspectorStyleSheetForInlineStyle::getText(String* result) const
+ExceptionOr<String> InspectorStyleSheetForInlineStyle::text() const
 {
     if (!m_isStyleTextValid) {
         m_styleText = elementStyleText();
         m_isStyleTextValid = true;
     }
-    *result = m_styleText;
-    return true;
+    return String { m_styleText };
 }
 
-bool InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style, const String& text, ExceptionCode& ec)
+ExceptionOr<void> InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style, const String& text)
 {
     ASSERT_UNUSED(style, style == inlineStyle());
 
@@ -1308,8 +1268,7 @@
     m_isStyleTextValid = true;
     m_ruleSourceData = nullptr;
 
-    ec = 0;
-    return true;
+    return { };
 }
 
 std::unique_ptr<Vector<size_t>> InspectorStyleSheetForInlineStyle::lineEndings() const
diff --git a/Source/WebCore/inspector/InspectorStyleSheet.h b/Source/WebCore/inspector/InspectorStyleSheet.h
index 18282fd..468ca77 100644
--- a/Source/WebCore/inspector/InspectorStyleSheet.h
+++ b/Source/WebCore/inspector/InspectorStyleSheet.h
@@ -26,13 +26,10 @@
 
 #include "CSSPropertySourceData.h"
 #include "CSSStyleDeclaration.h"
-#include "ExceptionCode.h"
 #include <inspector/InspectorProtocolObjects.h>
 #include <inspector/InspectorValues.h>
 #include <wtf/HashMap.h>
-#include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
 
 class ParsedStyleSheet;
 
@@ -132,8 +129,8 @@
     RefPtr<Inspector::Protocol::CSS::CSSStyle> buildObjectForStyle() const;
     Ref<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSComputedStyleProperty>> buildArrayForComputedStyle() const;
 
-    bool getText(String* result) const;
-    bool setText(const String&, ExceptionCode&);
+    ExceptionOr<String> text() const;
+    ExceptionOr<void> setText(const String&);
 
 private:
     InspectorStyle(const InspectorCSSId& styleId, RefPtr<CSSStyleDeclaration>&&, InspectorStyleSheet* parentStyleSheet);
@@ -169,19 +166,19 @@
     String finalURL() const;
     CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); }
     void reparseStyleSheet(const String&);
-    bool setText(const String&, ExceptionCode&);
-    String ruleSelector(const InspectorCSSId&, ExceptionCode&);
-    bool setRuleSelector(const InspectorCSSId&, const String& selector, ExceptionCode&);
-    CSSStyleRule* addRule(const String& selector, ExceptionCode&);
-    bool deleteRule(const InspectorCSSId&, ExceptionCode&);
+    ExceptionOr<void> setText(const String&);
+    ExceptionOr<String> ruleSelector(const InspectorCSSId&);
+    ExceptionOr<void> setRuleSelector(const InspectorCSSId&, const String& selector);
+    ExceptionOr<CSSStyleRule*> addRule(const String& selector);
+    ExceptionOr<void> deleteRule(const InspectorCSSId&);
     CSSStyleRule* ruleForId(const InspectorCSSId&) const;
     RefPtr<Inspector::Protocol::CSS::CSSStyleSheetBody> buildObjectForStyleSheet();
     RefPtr<Inspector::Protocol::CSS::CSSStyleSheetHeader> buildObjectForStyleSheetInfo();
     RefPtr<Inspector::Protocol::CSS::CSSRule> buildObjectForRule(CSSStyleRule*, Element*);
     RefPtr<Inspector::Protocol::CSS::CSSStyle> buildObjectForStyle(CSSStyleDeclaration*);
-    bool setStyleText(const InspectorCSSId&, const String& text, String* oldText, ExceptionCode&);
+    ExceptionOr<void> setStyleText(const InspectorCSSId&, const String& text, String* oldText);
 
-    virtual bool getText(String* result) const;
+    virtual ExceptionOr<String> text() const;
     virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const;
     void fireStyleSheetChanged();
 
@@ -200,7 +197,7 @@
     virtual RefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&);
 
     // Also accessed by friend class InspectorStyle.
-    virtual bool setStyleText(CSSStyleDeclaration*, const String&, ExceptionCode&);
+    virtual ExceptionOr<void> setStyleText(CSSStyleDeclaration*, const String&);
     virtual std::unique_ptr<Vector<size_t>> lineEndings() const;
 
 private:
@@ -208,7 +205,6 @@
     friend class InspectorStyle;
 
     static void collectFlatRules(RefPtr<CSSRuleList>&&, CSSStyleRuleVector* result);
-    bool checkPageStyleSheet(ExceptionCode&) const;
     bool styleSheetMutated() const;
     bool ensureText() const;
     bool ensureSourceData();
@@ -236,21 +232,21 @@
     static Ref<InspectorStyleSheetForInlineStyle> create(InspectorPageAgent*, const String& id, RefPtr<Element>&&, Inspector::Protocol::CSS::StyleSheetOrigin, Listener*);
 
     void didModifyElementAttribute();
-    bool getText(String* result) const override;
-    CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const override { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); }
+    ExceptionOr<String> text() const final;
+    CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const final { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); }
 
 protected:
     InspectorStyleSheetForInlineStyle(InspectorPageAgent*, const String& id, RefPtr<Element>&&, Inspector::Protocol::CSS::StyleSheetOrigin, Listener*);
 
-    Document* ownerDocument() const override;
-    RefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const override { ASSERT_UNUSED(style, style == inlineStyle()); return m_ruleSourceData; }
-    unsigned ruleIndexByStyle(CSSStyleDeclaration*) const override { return 0; }
-    bool ensureParsedDataReady() override;
-    RefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&) override;
+    Document* ownerDocument() const final;
+    RefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const final { ASSERT_UNUSED(style, style == inlineStyle()); return m_ruleSourceData; }
+    unsigned ruleIndexByStyle(CSSStyleDeclaration*) const final { return 0; }
+    bool ensureParsedDataReady() final;
+    RefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&) final;
 
     // Also accessed by friend class InspectorStyle.
-    bool setStyleText(CSSStyleDeclaration*, const String&, ExceptionCode&) override;
-    std::unique_ptr<Vector<size_t>> lineEndings() const override;
+    ExceptionOr<void> setStyleText(CSSStyleDeclaration*, const String&) final;
+    std::unique_ptr<Vector<size_t>> lineEndings() const final;
 
 private:
     CSSStyleDeclaration* inlineStyle() const;
diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp
index 20d70ac..c314321 100644
--- a/Source/WebCore/page/DragController.cpp
+++ b/Source/WebCore/page/DragController.cpp
@@ -148,9 +148,9 @@
                     if (title.isEmpty())
                         title = url;
                 }
-                anchor->appendChild(document.createTextNode(title), IGNORE_EXCEPTION);
+                anchor->appendChild(document.createTextNode(title));
                 auto fragment = document.createDocumentFragment();
-                fragment->appendChild(anchor, IGNORE_EXCEPTION);
+                fragment->appendChild(anchor);
                 return WTFMove(fragment);
             }
         }
diff --git a/Source/WebCore/page/ios/FrameIOS.mm b/Source/WebCore/page/ios/FrameIOS.mm
index dda4e22..c3a4586 100644
--- a/Source/WebCore/page/ios/FrameIOS.mm
+++ b/Source/WebCore/page/ios/FrameIOS.mm
@@ -91,9 +91,8 @@
     if (!style.isEmpty())
         body->setAttribute(HTMLNames::styleAttr, style);
 
-    ExceptionCode ec;
-    rootElement->appendChild(body, ec);
-    document->appendChild(rootElement, ec);
+    rootElement->appendChild(body);
+    document->appendChild(rootElement);
 }
 
 const ViewportArguments& Frame::viewportArguments() const
diff --git a/Source/WebCore/svg/SVGTRefElement.cpp b/Source/WebCore/svg/SVGTRefElement.cpp
index 655018d..3d314d5 100644
--- a/Source/WebCore/svg/SVGTRefElement.cpp
+++ b/Source/WebCore/svg/SVGTRefElement.cpp
@@ -146,10 +146,10 @@
     ASSERT(shadowRoot());
     ShadowRoot* root = shadowRoot();
     if (!root->firstChild())
-        root->appendChild(Text::create(document(), textContent), ASSERT_NO_EXCEPTION);
+        root->appendChild(Text::create(document(), textContent));
     else {
         ASSERT(root->firstChild()->isTextNode());
-        root->firstChild()->setTextContent(textContent, ASSERT_NO_EXCEPTION);
+        root->firstChild()->setTextContent(textContent);
     }
 }
 
@@ -163,7 +163,7 @@
     ASSERT(shadowRoot());
     Node* container = shadowRoot()->firstChild();
     if (container)
-        container->setTextContent(emptyContent, IGNORE_EXCEPTION);
+        container->setTextContent(emptyContent);
 
     if (!inDocument())
         return;
diff --git a/Source/WebCore/xml/XMLTreeViewer.cpp b/Source/WebCore/xml/XMLTreeViewer.cpp
index ba312dd..6c10d6c 100644
--- a/Source/WebCore/xml/XMLTreeViewer.cpp
+++ b/Source/WebCore/xml/XMLTreeViewer.cpp
@@ -62,7 +62,7 @@
 
     String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
     auto text = m_document.createTextNode(cssString);
-    m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text, IGNORE_EXCEPTION);
+    m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text);
     m_document.styleScope().didChangeActiveStyleSheetCandidates();
 }
 
diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog
index dc2a829..4532d4e 100644
--- a/Source/WebKit/mac/ChangeLog
+++ b/Source/WebKit/mac/ChangeLog
@@ -1,3 +1,23 @@
+2016-11-11  Darin Adler  <darin@apple.com>
+
+        Move Node from ExceptionCode to ExceptionOr
+        https://bugs.webkit.org/show_bug.cgi?id=164515
+
+        Reviewed by Sam Weinig.
+
+        * DOM/DOMHTMLSelectElement.mm:
+        (-[DOMHTMLSelectElement remove:]): Call remove instead of removeByIndex
+        now that it was renamed.
+        * DOM/DOMNode.mm:
+        (-[DOMNode setNodeValue:]): Updated exception handling.
+        (-[DOMNode setPrefix:]): Ditto.
+        (-[DOMNode setTextContent:]): Ditto.
+        (-[DOMNode insertBefore:refChild:]): Ditto.
+        (-[DOMNode replaceChild:oldChild:]): Ditto.
+        (-[DOMNode removeChild:]): Ditto.
+        (-[DOMNode appendChild:]): Ditto.
+        (-[DOMNode cloneNode:]): Ditto.
+
 2016-11-11  Beth Dakin  <bdakin@apple.com>
 
         Get touch bar code building for open source builds
diff --git a/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm b/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm
index baac49a..b6eca96 100644
--- a/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm
+++ b/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm
@@ -202,7 +202,7 @@
 - (void)remove:(int)index
 {
     WebCore::JSMainThreadNullState state;
-    IMPL->removeByIndex(index);
+    IMPL->remove(index);
 }
 
 @end
diff --git a/Source/WebKit/mac/DOM/DOMNode.mm b/Source/WebKit/mac/DOM/DOMNode.mm
index f284f35..871c9e9 100644
--- a/Source/WebKit/mac/DOM/DOMNode.mm
+++ b/Source/WebKit/mac/DOM/DOMNode.mm
@@ -97,9 +97,7 @@
 - (void)setNodeValue:(NSString *)newNodeValue
 {
     JSMainThreadNullState state;
-    ExceptionCode ec = 0;
-    unwrap(*self).setNodeValue(newNodeValue, ec);
-    raiseOnDOMError(ec);
+    raiseOnDOMError(unwrap(*self).setNodeValue(newNodeValue));
 }
 
 - (unsigned short)nodeType
@@ -165,9 +163,7 @@
 - (void)setPrefix:(NSString *)newPrefix
 {
     JSMainThreadNullState state;
-    ExceptionCode ec = 0;
-    unwrap(*self).setPrefix(newPrefix, ec);
-    raiseOnDOMError(ec);
+    raiseOnDOMError(unwrap(*self).setPrefix(newPrefix));
 }
 
 - (NSString *)localName
@@ -197,9 +193,7 @@
 - (void)setTextContent:(NSString *)newTextContent
 {
     JSMainThreadNullState state;
-    ExceptionCode ec = 0;
-    unwrap(*self).setTextContent(newTextContent, ec);
-    raiseOnDOMError(ec);
+    raiseOnDOMError(unwrap(*self).setTextContent(newTextContent));
 }
 
 - (BOOL)isConnected
@@ -225,11 +219,8 @@
     JSMainThreadNullState state;
     if (!newChild)
         raiseTypeErrorException();
-    ExceptionCode ec = 0;
-    if (unwrap(*self).insertBefore(*core(newChild), core(refChild), ec))
-        return newChild;
-    raiseOnDOMError(ec);
-    return nil;
+    raiseOnDOMError(unwrap(*self).insertBefore(*core(newChild), core(refChild)));
+    return newChild;
 }
 
 - (DOMNode *)replaceChild:(DOMNode *)newChild oldChild:(DOMNode *)oldChild
@@ -239,11 +230,8 @@
         raiseTypeErrorException();
     if (!oldChild)
         raiseTypeErrorException();
-    ExceptionCode ec = 0;
-    if (unwrap(*self).replaceChild(*core(newChild), *core(oldChild), ec))
-        return oldChild;
-    raiseOnDOMError(ec);
-    return nil;
+    raiseOnDOMError(unwrap(*self).replaceChild(*core(newChild), *core(oldChild)));
+    return oldChild;
 }
 
 - (DOMNode *)removeChild:(DOMNode *)oldChild
@@ -251,11 +239,8 @@
     JSMainThreadNullState state;
     if (!oldChild)
         raiseTypeErrorException();
-    ExceptionCode ec = 0;
-    if (unwrap(*self).removeChild(*core(oldChild), ec))
-        return oldChild;
-    raiseOnDOMError(ec);
-    return nil;
+    raiseOnDOMError(unwrap(*self).removeChild(*core(oldChild)));
+    return oldChild;
 }
 
 - (DOMNode *)appendChild:(DOMNode *)newChild
@@ -263,11 +248,8 @@
     JSMainThreadNullState state;
     if (!newChild)
         raiseTypeErrorException();
-    ExceptionCode ec = 0;
-    if (unwrap(*self).appendChild(*core(newChild), ec))
-        return newChild;
-    raiseOnDOMError(ec);
-    return nil;
+    raiseOnDOMError(unwrap(*self).appendChild(*core(newChild)));
+    return newChild;
 }
 
 - (BOOL)hasChildNodes
@@ -279,10 +261,7 @@
 - (DOMNode *)cloneNode:(BOOL)deep
 {
     JSMainThreadNullState state;
-    ExceptionCode ec = 0;
-    DOMNode *result = kit(unwrap(*self).cloneNodeForBindings(deep, ec).get());
-    raiseOnDOMError(ec);
-    return result;
+    return kit(raiseOnDOMError(unwrap(*self).cloneNodeForBindings(deep)).ptr());
 }
 
 - (void)normalize
diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog
index 8fdaaae..92c68f5 100644
--- a/Source/WebKit/win/ChangeLog
+++ b/Source/WebKit/win/ChangeLog
@@ -1,3 +1,14 @@
+2016-11-11  Darin Adler  <darin@apple.com>
+
+        Move Node from ExceptionCode to ExceptionOr
+        https://bugs.webkit.org/show_bug.cgi?id=164515
+
+        Reviewed by Sam Weinig.
+
+        * DOMCoreClasses.cpp:
+        (DOMNode::insertBefore): Update exception handling.
+        (DOMNode::removeChild): Ditto.
+
 2016-10-14  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         MemoryPressureHandler shouldn't know how to release WebCore memory
diff --git a/Source/WebKit/win/DOMCoreClasses.cpp b/Source/WebKit/win/DOMCoreClasses.cpp
index afebf89..07862b1 100644
--- a/Source/WebKit/win/DOMCoreClasses.cpp
+++ b/Source/WebKit/win/DOMCoreClasses.cpp
@@ -250,8 +250,7 @@
 
     COMPtr<DOMNode> refChildNode(Query, refChild);
 
-    ExceptionCode ec;
-    if (!m_node->insertBefore(*newChildNode->node(), refChildNode ? refChildNode->node() : nullptr, ec))
+    if (m_node->insertBefore(*newChildNode->node(), refChildNode ? refChildNode->node() : nullptr).hasException())
         return E_FAIL;
 
     *result = newChild;
@@ -282,8 +281,7 @@
     if (!oldChildNode)
         return E_FAIL;
 
-    ExceptionCode ec;
-    if (!m_node->removeChild(*oldChildNode->node(), ec))
+    if (m_node->removeChild(*oldChildNode->node()).hasException())
         return E_FAIL;
 
     *result = oldChild;
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index f6be75e..f72618d 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,30 @@
+2016-11-11  Darin Adler  <darin@apple.com>
+
+        Move Node from ExceptionCode to ExceptionOr
+        https://bugs.webkit.org/show_bug.cgi?id=164515
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp:
+        (webkit_dom_html_select_element_remove): Updated exception handling.
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp:
+        (webkit_dom_node_insert_before): Ditto.
+        (webkit_dom_node_replace_child): Ditto.
+        (webkit_dom_node_remove_child): Ditto.
+        (webkit_dom_node_append_child): Ditto.
+        (webkit_dom_node_clone_node_with_error): Ditto.
+        (webkit_dom_node_set_node_value): Ditto.
+        (webkit_dom_node_set_text_content): Ditto.
+        * WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
+        (-[WKDOMNode insertNode:before:]): Ditto.
+        (-[WKDOMNode appendChild:]): Ditto.
+        (-[WKDOMNode removeChild:]): Ditto.
+
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
+        (WebKit::PDFPlugin::PDFPlugin): Removed unneeded ASSERT_NO_EXCEPTION.
+        * WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm:
+        (WebKit::PDFPluginChoiceAnnotation::createAnnotationElement): Ditto.
+
 2016-11-11  Megan Gardner  <megan_gardner@apple.com>
 
         [Cocoa] Support wide gamut for Drag Image UI
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp
index b95b641..fc15d83 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp
@@ -236,10 +236,9 @@
     WebCore::JSMainThreadNullState state;
     WebCore::Node* item = WebKit::core(self);
     WTF::String convertedValue = WTF::String::fromUTF8(value);
-    WebCore::ExceptionCode ec = 0;
-    item->setPrefix(convertedValue, ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->setPrefix(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);
     }
 }
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp
index f4b0ba6..e3fd353 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp
@@ -383,7 +383,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_if_fail(WEBKIT_DOM_IS_HTML_SELECT_ELEMENT(self));
     WebCore::HTMLSelectElement* item = WebKit::core(self);
-    item->removeByIndex(index);
+    item->remove(index);
 }
 
 gboolean webkit_dom_html_select_element_get_autofocus(WebKitDOMHTMLSelectElement* self)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp
index 27e7213..639445e 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp
@@ -370,14 +370,13 @@
     WebCore::Node* item = WebKit::core(self);
     WebCore::Node* convertedNewChild = WebKit::core(newChild);
     WebCore::Node* convertedRefChild = WebKit::core(refChild);
-    WebCore::ExceptionCode ec = 0;
-    bool ok = item->insertBefore(*convertedNewChild, convertedRefChild, ec);
-    if (ok)
-        return WebKit::kit(convertedNewChild);
-
-    WebCore::ExceptionCodeDescription ecdesc(ec);
-    g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
-    return 0;
+    auto result = item->insertBefore(*convertedNewChild, convertedRefChild);
+    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 newChild;
 }
 
 WebKitDOMNode* webkit_dom_node_replace_child(WebKitDOMNode* self, WebKitDOMNode* newChild, WebKitDOMNode* oldChild, GError** error)
@@ -390,14 +389,13 @@
     WebCore::Node* item = WebKit::core(self);
     WebCore::Node* convertedNewChild = WebKit::core(newChild);
     WebCore::Node* convertedOldChild = WebKit::core(oldChild);
-    WebCore::ExceptionCode ec = 0;
-    bool ok = item->replaceChild(*convertedNewChild, *convertedOldChild, ec);
-    if (ok)
-        return WebKit::kit(convertedOldChild);
-
-    WebCore::ExceptionCodeDescription ecdesc(ec);
-    g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
-    return 0;
+    auto result = item->replaceChild(*convertedNewChild, *convertedOldChild);
+    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 oldChild;
 }
 
 WebKitDOMNode* webkit_dom_node_remove_child(WebKitDOMNode* self, WebKitDOMNode* oldChild, GError** error)
@@ -408,14 +406,13 @@
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::Node* item = WebKit::core(self);
     WebCore::Node* convertedOldChild = WebKit::core(oldChild);
-    WebCore::ExceptionCode ec = 0;
-    bool ok = item->removeChild(*convertedOldChild, ec);
-    if (ok)
-        return WebKit::kit(convertedOldChild);
-
-    WebCore::ExceptionCodeDescription ecdesc(ec);
-    g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
-    return 0;
+    auto result = item->removeChild(*convertedOldChild);
+    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 oldChild;
 }
 
 WebKitDOMNode* webkit_dom_node_append_child(WebKitDOMNode* self, WebKitDOMNode* newChild, GError** error)
@@ -426,14 +423,13 @@
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::Node* item = WebKit::core(self);
     WebCore::Node* convertedNewChild = WebKit::core(newChild);
-    WebCore::ExceptionCode ec = 0;
-    bool ok = item->appendChild(*convertedNewChild, ec);
-    if (ok)
-        return WebKit::kit(convertedNewChild);
-
-    WebCore::ExceptionCodeDescription ecdesc(ec);
-    g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
-    return 0;
+    auto result = item->appendChild(*convertedNewChild);
+    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 newChild;
 }
 
 gboolean webkit_dom_node_has_child_nodes(WebKitDOMNode* self)
@@ -451,13 +447,13 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::Node* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->cloneNodeForBindings(deep, ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->cloneNodeForBindings(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());
 }
 
 void webkit_dom_node_normalize(WebKitDOMNode* self)
@@ -581,10 +577,9 @@
     g_return_if_fail(!error || !*error);
     WebCore::Node* item = WebKit::core(self);
     WTF::String convertedValue = WTF::String::fromUTF8(value);
-    WebCore::ExceptionCode ec = 0;
-    item->setNodeValue(convertedValue, ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->setNodeValue(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);
     }
 }
@@ -687,10 +682,9 @@
     g_return_if_fail(!error || !*error);
     WebCore::Node* item = WebKit::core(self);
     WTF::String convertedValue = WTF::String::fromUTF8(value);
-    WebCore::ExceptionCode ec = 0;
-    item->setTextContent(convertedValue, ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->setTextContent(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);
     }
 }
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
index 49b4cb9..fc3351f 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
@@ -58,9 +58,7 @@
     if (!node)
         return;
 
-    // FIXME: Do something about the exception.
-    WebCore::ExceptionCode ec;
-    _impl->insertBefore(*WebKit::toWebCoreNode(node), WebKit::toWebCoreNode(refNode), ec);
+    _impl->insertBefore(*WebKit::toWebCoreNode(node), WebKit::toWebCoreNode(refNode));
 }
 
 - (void)appendChild:(WKDOMNode *)node
@@ -68,9 +66,7 @@
     if (!node)
         return;
 
-    // FIXME: Do something about the exception.
-    WebCore::ExceptionCode ec;
-    _impl->appendChild(*WebKit::toWebCoreNode(node), ec);
+    _impl->appendChild(*WebKit::toWebCoreNode(node));
 }
 
 - (void)removeChild:(WKDOMNode *)node
@@ -78,9 +74,7 @@
     if (!node)
         return;
 
-    // FIXME: Do something about the exception.
-    WebCore::ExceptionCode ec;
-    _impl->removeChild(*WebKit::toWebCoreNode(node), ec);
+    _impl->removeChild(*WebKit::toWebCoreNode(node));
 }
 
 - (WKDOMDocument *)document
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm b/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm
index f9f339a..0639def 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm
@@ -526,7 +526,7 @@
         m_annotationContainer->setAttributeWithoutSynchronization(idAttr, AtomicString("annotationContainer", AtomicString::ConstructFromLiteral));
 
         auto annotationStyleElement = document->createElement(styleTag, false);
-        annotationStyleElement->setTextContent(annotationStyle, ASSERT_NO_EXCEPTION);
+        annotationStyleElement->setTextContent(annotationStyle);
 
         m_annotationContainer->appendChild(annotationStyleElement);
         document->bodyOrFrameset()->appendChild(*m_annotationContainer);
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm
index f46af16..2735032 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm
@@ -88,7 +88,7 @@
     for (NSString *choice in choices) {
         auto choiceOption = document.createElement(optionTag, false);
         choiceOption->setAttributeWithoutSynchronization(valueAttr, choice);
-        choiceOption->setTextContent(choice, ASSERT_NO_EXCEPTION);
+        choiceOption->setTextContent(choice);
 
         if (choice == selectedChoice)
             choiceOption->setAttributeWithoutSynchronization(selectedAttr, AtomicString("selected", AtomicString::ConstructFromLiteral));