Move all classes in the HTML directory from ExceptionCode to Exception
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 02:32:20 +0000 (02:32 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 02:32:20 +0000 (02:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163876

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

* web-platform-tests/url/url-setters-expected.txt: Updated for progressions that occurred
because setting the href attribute on a DOMURL object no longer modifies the URL as a side
effect in the cases where it throw an exception.

Source/WebCore:

* bindings/js/JSDOMBinding.cpp:
(WebCore::shouldAllowAccessToNode): Deleted.
(WebCore::BindingSecurity::shouldAllowAccessToFrame): Moved function into the
BindingSecurity namespace. Also changed arguments to references.
(WebCore::BindingSecurity::shouldAllowAccessToDOMWindow): Ditto.
(WebCore::BindingSecurity::shouldAllowAccessToNode): Changed argument type
from pointer to reference.

* bindings/js/JSDOMBinding.h: Removed top level shouldAllowAccessTo functions,
moving all of them into the BindingSecurity namespace. Changed BindingSecurity
from a class into a namespace. Added new checkSecurityForNode functions that
can be used directly to implement CheckSecurityForNode; they turn the node
into a null, which is no change in behavior from what bindings already did.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess): Changed argument
type for passed-in string to const String& instead of String&.
(WebCore::JSDOMWindow::getOwnPropertySlot): Updated for BindingSecurity changes.
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex): Ditto.
(WebCore::JSDOMWindow::put): Ditto.

* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::attributesFor3DContext): Renamed from get3DContextAttributes and
changed to use a return value instead of an out argument.
(WebCore::JSHTMLCanvasElement::getContext): Updated for the above.
(WebCore::JSHTMLCanvasElement::toDataURL): Rewrote to handle ExceptionOr
and also to use Optional<double> instead of const double*.

* bindings/js/JSHTMLFrameElementCustom.cpp:
(WebCore::JSHTMLFrameElement::setLocation): Moved the logic from
allowSettingJavascriptURL in here and updated for BindingSecurity changes.

* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::setLength): Use propagateException.
Also streamlined the code a bit.
(WebCore::JSHTMLOptionsCollection::indexSetter): Updated for new name and
argument types for selectElementIndexSetter.

* bindings/js/JSHTMLSelectElementCustom.cpp:
(WebCore::selectElementIndexSetter): Updated name and argument types and
to use propagateException.
(WebCore::JSHTMLSelectElement::indexSetter): Updated for above.
* bindings/js/JSHTMLSelectElementCustom.h: Ditto.

* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::getOwnPropertySlotDelegate): Updated for changes to
BindingSecurity.
(WebCore::JSLocation::putDelegate): Ditto. Also rearranged logic a bit.

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::canAccessFromCurrentOrigin): Updated for
changes to BindingSecurity.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Removed old support for CheckSecurityForNode.
(NativeToJSValue): Added new support for CheckSecurityForNode, which uses
the new checkSecurityForNode function, and works properly with ExceptionOr.

* bindings/scripts/test/JS/JSTestObj.cpp: Updated for change below.

* dom/ChildNode.idl: Move the remove function to non-legacy exception.
Needed now because this needs to match the one in HTMLSelectElement.

* dom/Element.cpp:
(WebCore::Element::dispatchMouseForceWillBegin): Refactored a little bit.
(WebCore::Element::mergeWithNextTextNode): Support ExceptionOr for remove.
(WebCore::Element::setOuterHTML): Support ExceptionOr for
createFragmentForInnerOuterHTML.
(WebCore::Element::setInnerHTML): Ditto.
(WebCore::Element::insertAdjacentHTML): Ditto.

* dom/Node.cpp:
(WebCore::Node::remove): Use ExceptionOr.
(WebCore::Node::normalize): Remove use of IGNORE_EXCEPTION.
* dom/Node.h: Use ExceptionOr for remove.

* dom/Range.cpp:
(WebCore::Range::insertNode): Updated for change to remove.
(WebCore::Range::createContextualFragment): Updated for change
to WebCore::createContextualFragment.

* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::setInnerHTML): Use ExceptionOr for
createFragmentForInnerOuterHTML and replaceChildrenWithFragment.

* editing/AppendNodeCommand.cpp:
(WebCore::AppendNodeCommand::doUnapply): Remove IGNORE_EXCEPTION.
* editing/InsertNodeBeforeCommand.cpp:
(WebCore::InsertNodeBeforeCommand::doUnapply): Ditto.
* editing/MergeIdenticalElementsCommand.cpp:
(WebCore::MergeIdenticalElementsCommand::doApply): Ditto.
* editing/RemoveNodeCommand.cpp:
(WebCore::RemoveNodeCommand::doApply): Ditto.
* editing/SplitElementCommand.cpp:
(WebCore::SplitElementCommand::doUnapply): Ditto.
* editing/SplitTextNodeCommand.cpp:
(WebCore::SplitTextNodeCommand::doUnapply): Ditto.
* editing/WrapContentsInDummySpanCommand.cpp:
(WebCore::WrapContentsInDummySpanCommand::doUnapply): Ditto.

* editing/Editor.cpp:
(WebCore::Editor::insertDictationPhrases): Deleted. Moved this
iOS-specific function to EditorIOS.mm.
(WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto.
(WebCore::Editor::confirmMarkedText): Ditto.
(WebCore::Editor::setTextAsChildOfElement): Ditto.
(WebCore::Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping): Ditto.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::fontForSelection): Remove ASSERT_NO_EXCEPTION.
(WebCore::Editor::fontAttributesForSelectionStart): Ditto.
(WebCore::Editor::insertDictationPhrases): Moved here from Editor.cpp.
(WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto. Also
updated code that used remove to not pass an ExceptionCode.
(WebCore::Editor::confirmMarkedText): Ditto.
(WebCore::Editor::setTextAsChildOfElement): Ditto.
(WebCore::Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping): Ditto.

* editing/mac/EditorMac.mm:
(WebCore::Editor::fontForSelection): Remove ASSERT_NO_EXCEPTION.
(WebCore::Editor::fontAttributesForSelectionStart): Ditto.

* editing/markup.cpp:
(WebCore::createFragmentForInnerOuterHTML): Use ExceptionOr.
(WebCore::createContextualFragment): Ditto.
(WebCore::replaceChildrenWithFragment): Ditto.
(WebCore::replaceChildrenWithText): Ditto.
* editing/markup.h: Updated for above changes.

* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateAppearance):
Removed ASSERT_NO_EXCEPTION.

* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::setValueAsDate): Use ExceptionOr.
(WebCore::BaseDateAndTimeInputType::setValueAsDecimal): Ditto.
* html/BaseDateAndTimeInputType.h: Updated for above changes.

* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setValueAsDate): Use ExceptionOr.
* html/DateTimeLocalInputType.h: Updated for above changes.

* html/DOMTokenList.cpp:
(WebCore::DOMTokenList::validateToken): Use ExceptionOr.
(WebCore::DOMTokenList::validateTokens): Ditto.
(WebCore::DOMTokenList::addInternal): Ditto.
(WebCore::DOMTokenList::add): Ditto.
(WebCore::DOMTokenList::removeInternal): Ditto.
(WebCore::DOMTokenList::remove): Ditto.
(WebCore::DOMTokenList::toggle): Ditto.
(WebCore::DOMTokenList::replace): Ditto.
(WebCore::DOMTokenList::supports): Ditto.
* html/DOMTokenList.h: Updated for above changes.
* html/DOMTokenList.idl: Use non-legacy exceptions.

* html/DOMURL.cpp:
(WebCore::DOMURL::DOMURL): Just take the two URL objects and let
the create functions do all the processing.
(WebCore::DOMURL::create): Use ExceptionOr, and move the processing
of the URLs here out of the constructors.
(WebCore::DOMURL::setHref): Use ExceptionOr.
* html/DOMURL.h: Updated for above changes.
* html/DOMURL.idl: Use non-legacy exceptions.

* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::appendEntry): Remove
IGNORE_EXCEPTION and use releaseReturnValue().

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::toDataURL): Use ExceptionOr.
* html/HTMLCanvasElement.h: Updated for above changes.
* html/HTMLCanvasElement.idl: Use non-legacy exception.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::textToFragment): Use ExceptionOr.
(WebCore::HTMLElement::setInnerText): Ditto.
(WebCore::HTMLElement::setOuterText): Ditto.
(WebCore::HTMLElement::setContentEditable): Ditto.
(WebCore::HTMLElement::translateAttributeMode): Deleted.
(WebCore::HTMLElement::translate): Moved the logic from the
translateAttributeMode function in here.
* html/HTMLElement.h: Updated for above changes.
* html/HTMLElement.idl: Use non-legacy exceptions.

* html/HTMLEmbedElement.idl: Use non-legacy exception.
* html/HTMLFrameElement.idl: Ditto.

* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::getSVGDocument): Use ExceptionOr.
* html/HTMLFrameOwnerElement.h: Updated for above.

* html/HTMLIFrameElement.idl: Use non-legacy exception.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::stepUp): Use ExceptionOr.
(WebCore::HTMLInputElement::stepDown): Ditto.
(WebCore::HTMLInputElement::setValue): Ditto.
(WebCore::HTMLInputElement::setValueAsDate): Ditto.
(WebCore::HTMLInputElement::setValueAsNumber): Ditto.
(WebCore::HTMLInputElement::setSize): Ditto.
(WebCore::HTMLInputElement::maxLengthAttributeChanged): Use the
new internalSetMaxLength function; old code relied on a setMaxLength
that was different from the one exposed to bindings.
(WebCore::HTMLInputElement::minLengthAttributeChanged): Ditto.
(WebCore::HTMLInputElement::setRangeText): Use ExceptionOr.
* html/HTMLInputElement.h: Updated for above changes. Also use
data member initialization for InputElementClickState instead of
a constructor.
* html/HTMLInputElement.idl: Use non-legacy exception.

* html/HTMLMarqueeElement.cpp:
(WebCore::HTMLMarqueeElement::setLoop): Use ExceptionOr.
(WebCore::HTMLMarqueeElement::renderMarquee): Tweaked.
* html/HTMLMarqueeElement.h: Updated for above changes.
* html/HTMLMarqueeElement.idl: Ditto.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::TrackGroup::TrackGroup):
Initialize most data members in class definition rather than
the constructor.
(WebCore::HTMLMediaElement::HTMLMediaElement): Ditto.
(WebCore::HTMLMediaElement::~HTMLMediaElement): Updated since
removeMediaElement now takes a reference.
(WebCore::HTMLMediaElement::updateActiveTextTrackCues): Use
a modern for loop to streamline code.
(WebCore::HTMLMediaElement::textTrackModeChanged): Updated since
track now returns a reference.
(WebCore::HTMLMediaElement::setCurrentTimeForBindings): Renamed
to prevent ambiguity with the other version that has slightly
different semantics and overloading and changed to use ExceptionOr.
(WebCore::HTMLMediaElement::playInternal): Updated to use reference.
(WebCore::HTMLMediaElement::setVolume): Use ExceptionOr.
(WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack): Take a
reference instead of a PassRefPtr.
(WebCore::HTMLMediaElement::mediaPlayerDidAddTextTrack): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidAddVideoTrack): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidRemoveAudioTrack): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidRemoveTextTrack): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidRemoveVideoTrack): Ditto.
(WebCore::HTMLMediaElement::addTextTrack): Use ExceptionOr.
(WebCore::HTMLMediaElement::didAddTextTrack): Use a reference.
(WebCore::HTMLMediaElement::didRemoveTextTrack): Ditto.
(WebCore::HTMLMediaElement::maxBufferedTime): Update to use different
interface to time ranges that does not need to deal with exceptions.
(WebCore::HTMLMediaElement::setController): Pass references.
(WebCore::HTMLMediaElement::outOfBandTrackSources): Use reference.
* html/HTMLMediaElement.h: Updated for above.
* html/HTMLMediaElement.idl: Use non-legacy exceptions.

* html/HTMLObjectElement.idl: Use non-legacy exception.

* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::createForJSConstructor): Use ExceptionOr.
* html/HTMLOptionElement.h: Updated for above change.
* html/HTMLOptionElement.idl: Use non-legacy exception.

* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::setLength): Use ExceptionOr.
* html/HTMLOptionsCollection.h: Updated for above change.
* html/HTMLOptionsCollection.idl: Use non-legacy exception.

* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::setValue): Removed non-finite handling
because that is now handled by the bindings.
(WebCore::HTMLProgressElement::setMax): Ditto.
* html/HTMLProgressElement.h: Updated for above.
* html/HTMLProgressElement.idl: Changed attributes to be double instead
of unrestricted double, and this was able to remove exceptions.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::removeByIndex): Drop IGNORE_EXCEPTION.
(WebCore::HTMLSelectElement::remove): Use ExceptionOr.
(WebCore::HTMLSelectElement::setOption): Ditto.
(WebCore::HTMLSelectElement::setLength): Ditto.
* html/HTMLSelectElement.h: Updated for above changes.
* html/HTMLSelectElement.idl: Use non-legacy exceptions.

* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::setCaption): Use ExceptionOr.
(WebCore::HTMLTableElement::setTHead): Ditto.
(WebCore::HTMLTableElement::setTFoot): Ditto.
(WebCore::HTMLTableElement::createTHead): Streamline a bit.
(WebCore::HTMLTableElement::deleteTHead): Ditto.
(WebCore::HTMLTableElement::createTFoot): Ditto.
(WebCore::HTMLTableElement::deleteTFoot): Ditto.
(WebCore::HTMLTableElement::createTBody): Ditto.
(WebCore::HTMLTableElement::createCaption): Ditto.
(WebCore::HTMLTableElement::insertRow): Use ExceptionOr.
(WebCore::HTMLTableElement::deleteRow): Ditto.
* html/HTMLTableElement.h: Updated for above changes.
* html/HTMLTableElement.idl: Use non-legacy exceptions.

* html/HTMLTableRowElement.cpp:
(WebCore::findTable): Added.
(WebCore::HTMLTableRowElement::rowIndex): Streamline a bit using the
findTable function above.
(WebCore::findRows): Added.
(WebCore::HTMLTableRowElement::sectionRowIndex): Streamline a bit using
the findRows function above.
(WebCore::HTMLTableRowElement::insertCell): Use ExceptionOr.
(WebCore::HTMLTableRowElement::deleteCell): Ditto.
(WebCore::HTMLTableRowElement::setCells): Deleted.
* html/HTMLTableRowElement.h: Updated for the above. The setCells function
was dead code.
* html/HTMLTableRowElement.idl: Use non-legacy exceptions.

* html/HTMLTableSectionElement.cpp:
(WebCore::HTMLTableSectionElement::additionalPresentationAttributeStyle):
Tweaked a bit to use early return.
(WebCore::HTMLTableSectionElement::insertRow): Use ExceptionOr.
(WebCore::HTMLTableSectionElement::deleteRow): Ditto.
(WebCore::HTMLTableSectionElement::numRows): Use childrenOfType.
(WebCore::HTMLTableSectionElement::align): Deleted.
(WebCore::HTMLTableSectionElement::setAlign): Deleted.
(WebCore::HTMLTableSectionElement::ch): Deleted.
(WebCore::HTMLTableSectionElement::setCh): Deleted.
(WebCore::HTMLTableSectionElement::chOff): Deleted.
(WebCore::HTMLTableSectionElement::setChOff): Deleted.
(WebCore::HTMLTableSectionElement::vAlign): Deleted.
(WebCore::HTMLTableSectionElement::setVAlign): Deleted.
* html/HTMLTableSectionElement.h: Updated for the above.
* html/HTMLTableSectionElement.idl: Use non-legacy exception.

* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::maxLengthAttributeChanged): Use the new
internalSetMaxLength function; old code relied on a setMaxLength
that was different from the one exposed to bindings.
(WebCore::HTMLTextAreaElement::minLengthAttributeChanged): Ditto.
(WebCore::HTMLTextAreaElement::updatePlaceholderText): Removed
ASSERT_NO_EXCEPTION.
* html/HTMLTextAreaElement.idl: Use non-legacy exceptions.

* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setRangeText): Use ExceptionOr.
(WebCore::HTMLTextFormControlElement::setInnerTextValue): Ditto.
(WebCore::HTMLTextFormControlElement::setMaxLength): Ditto.
(WebCore::HTMLTextFormControlElement::setMinLength): Ditto.
* html/HTMLTextFormControlElement.h: Updated for above changes.
Also renamed the setMin/MaxLength function overloads for internal use
to internSetMin/MaxLength and made them protected.

* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::~HTMLTrackElement): Call clearElement on the
track to break the connection. Before this was done as a side effect of
clearClient, but that is called in other cases where we do not want to
clear the link back to the track element.
(WebCore::HTMLTrackElement::insertedInto): Removed code that uses the
track function for its side effect of creating a track; no longer needed.
Rewrote this so it's more symmetric with removedFrom.
(WebCore::HTMLTrackElement::removedFrom): Pass reference. Also reordered
and removed an unnecessary check for null parent.
(WebCore::HTMLTrackElement::parseAttribute): Use track.
(WebCore::HTMLTrackElement::kind): Ditto.
(WebCore::HTMLTrackElement::track): Renamed ensureTrack to this. Also
removed the redundant code to call setTrackElement; we no longer change
the track element on a track until the track element is destroyed.
(WebCore::HTMLTrackElement::scheduleLoad): Use track.
(WebCore::HTMLTrackElement::loadTimerFired): Ditto.
(WebCore::HTMLTrackElement::setReadyState): Ditto.
(WebCore::HTMLTrackElement::readyState): Ditto.
(WebCore::HTMLTrackElement::mediaElement): Rearranged to use early return.
* html/HTMLTrackElement.h: Updated for above changes.

* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::webkitEnterFullscreen): Use ExceptionOr.
* html/HTMLVideoElement.h: Removed the functions used just for
capitalization reasons; that's now handled in the bindings.
* html/HTMLVideoElement.idl: Use non-legacy bindings and ImplementedAs.

* html/ImageData.cpp:
(WebCore::ImageData::create): Return ExceptionOr.
* html/ImageData.h: Updated for above changes.
* html/ImageData.idl: Use non-legacy exceptions.

* html/InputType.cpp:
(WebCore::InputType::setValueAsDate): Use ExceptionOr.
(WebCore::InputType::setValueAsDouble): Ditto.
(WebCore::InputType::setValueAsDecimal): Ditto.
(WebCore::InputType::applyStep): Ditto.
(WebCore::InputType::stepUp): Ditto.
(WebCore::InputType::stepUpFromRenderer): Removed IGNORE_EXCEPTION.
* html/InputType.h: Updated for the above.

* html/MediaController.cpp:
(MediaController::addMediaElement): Take a reference instead of a pointer.
(MediaController::removeMediaElement): Ditto.
(MediaController::containsMediaElement): Ditto.
(MediaController::setVolume): Use ExceptionOr.
(MediaController::bringElementUpToSpeed): Take a reference.
* html/MediaController.h: Updated for above changes. Also made lots of
function overrides private.
* html/MediaController.idl: Use non-legacy exception.

* html/MediaControllerInterface.h: Use ExceptionOr for setVolume.

* html/NumberInputType.cpp:
(WebCore::RealNumberRenderSize::max): Use aggregate initialization instead
of a constructor.
(WebCore::calculateRenderSize): Ditto.
(WebCore::NumberInputType::setValueAsDouble): Use ExceptionOr.
(WebCore::NumberInputType::setValueAsDecimal): Ditto.
* html/NumberInputType.h: Updated for above changes.

* html/RangeInputType.cpp:
(WebCore::RangeInputType::RangeInputType): Initialize scalar data member
in class definition instead of here.
(WebCore::RangeInputType::setValueAsDecimal): Use ExceptionOr.
(WebCore::RangeInputType::handleKeydownEvent): Removed IGNORE_EXCEPTION.
* html/RangeInputType.h: Updated for above changes.

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::updatePlaceholderText): Removed
ASSERT_NO_EXCEPTION.

* html/TimeRanges.cpp:
(WebCore::TimeRanges::start): Use ExceptionOr.
(WebCore::TimeRanges::end): Ditto.
* html/TimeRanges.h: Updated for the above.
* html/TimeRanges.idl: Use non-legacy exceptions.

* html/URLUtils.idl: Use non-legacy exception.

* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::setMessageDOMAndStartTimer): Removed
ASSERT_NO_EXCEPTION, IGNORE_EXCEPTION, and other exception-ignoring idioms.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTagForInBody): Ditto.
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::MediaControlVolumeSliderElement::defaultEventHandler): Ditto.
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlPanelElement::setPosition): Ditto.
(WebCore::MediaControlPanelElement::resetPosition): Ditto.
(WebCore::MediaControlStatusDisplayElement::update): Ditto.
(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Ditto.
(WebCore::MediaControlFullscreenVolumeMinButtonElement::defaultEventHandler): Ditto.
(WebCore::MediaControlFullscreenVolumeMaxButtonElement::defaultEventHandler): Ditto.
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::updateCurrentTimeDisplay): Ditto.
* html/shadow/MediaControlsApple.cpp:
(WebCore::MediaControlsApple::updateCurrentTimeDisplay): Ditto.

* html/track/LoadableTextTrack.cpp:
(WebCore::LoadableTextTrack::LoadableTextTrack): Take reference.
(WebCore::LoadableTextTrack::~LoadableTextTrack): Deleted.
(WebCore::LoadableTextTrack::clearClient): Deleted override. We no longer
want to clear m_trackElement when clearing the client.
(WebCore::LoadableTextTrack::setTrackElement): Deleted.
(WebCore::LoadableTextTrack::id): Changed to use
attributeWithoutSynchronization for better performance and idAttr instead
of a string constant.
* html/track/LoadableTextTrack.h: Updated for above changes. Added a new
clearElement function. Made the element and isDefault functions private.

* html/track/VTTCue.cpp:
(WebCore::VTTCue::~VTTCue): Removed ASSERT_NO_EXCEPTION, IGNORE_EXCEPTION,
and other exception-ignoring idioms.
(WebCore::VTTCue::removeDisplayTree): Ditto.
* html/track/VTTRegion.cpp:
(WebCore::VTTRegion::displayLastTextTrackCueBox): Ditto.
(WebCore::VTTRegion::willRemoveTextTrackCueBox): Ditto.

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::pushNodeByBackendIdToFrontend):
Rewrote to avoid multiplehash table lookups and added a FIXME about
the peculiar code here.
(WebCore::InspectorDOMAgent::resolveNode): Streamlined.
(WebCore::InspectorDOMAgent::nodeAsScriptValue): Use the new
checkSecurityForNode instead of the old shouldAllowAccessToNode.

* platform/graphics/ImageBuffer.h: Take Optional<double> instead of
const double* in toDataURL. Renamed ImageDataToDataURL to just dataURL.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::addAudioTrack): Take a reference instead of PassRefPtr.
(WebCore::MediaPlayer::removeAudioTrack): Ditto.
(WebCore::MediaPlayer::addTextTrack): Ditto.
(WebCore::MediaPlayer::removeTextTrack): Ditto.
(WebCore::MediaPlayer::addVideoTrack): Ditto.
(WebCore::MediaPlayer::removeVideoTrack): Ditto.
* platform/graphics/MediaPlayer.h: Updated for the above.

* platform/graphics/PlatformTimeRanges.h: Exported a couple of functions
that are now used in WebKit.

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::clearTextTracks): Use a modern for loop.
(WebCore::MediaPlayerPrivateAVFoundation::processNewAndRemovedTextTracks):
Fixed a bug that would cause this function to fail to process half the tracks.
Also updated for the change from PassRefPtr to references.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::determineChangedTracksFromNewTracksAndOldItems): Pass references.
(WebCore::MediaPlayerPrivateAVFoundationObjC::audioSourceProvider): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::processMetadataTrack): Ditto.
(WebCore::assetMetadataKeyNames): Tweaked formatting.
(WebCore::itemKVOProperties): Ditto.
(WebCore::playerKVOProperties): Ditto.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::updateTracksOfType): Pass references.

* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::toDataURL): Use Optional<double>

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::createBitmapImageAfterScalingIfNeeded): Use auto.
(WebCore::encodeImage): Ditto. Also renamed from CGImageEncodeToData.
(WebCore::dataURL): Ditto. Also renamed from CGImageToDataURL and from
ImageDataToDataURL.
(WebCore::ImageBuffer::toDataURL): Ditto.

* platform/graphics/efl/ImageBufferEfl.cpp:
(WebCore::encodeImageJPEG): Use Optional<double>
(WebCore::ImageBuffer::toDataURL): Ditto.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo): Pass
a reference instead of pointer.
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfText): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::processMpegTsSection): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::processTableOfContents): Ditto.

* platform/graphics/gtk/ImageBufferGtk.cpp:
(WebCore::encodeImage): Use Optional<double>
(WebCore::ImageBuffer::toDataURL): Ditto.

* platform/graphics/win/ImageBufferDirect2D.cpp:
(WebCore::ImageBuffer::toDataURL): Use Optional<double>

* platform/image-encoders/JPEGImageEncoder.cpp:
(WebCore::compressRGBABigEndianToJPEG): Use Optional<double>
* platform/image-encoders/JPEGImageEncoder.h: Ditto.

* platform/ios/WebPlaybackSessionInterfaceAVKit.mm:
(WebCore::WebPlaybackSessionInterfaceAVKit::seekableRangesChanged):
Updated for change to TimeRanges.

* platform/mac/WebVideoFullscreenHUDWindowController.mm:
(-[WebVideoFullscreenHUDWindowController setVolume:]): Removed IGNORE_EXCEPTION.
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::endElementNs): Ditto.

* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::paintMediaSliderTrack): Updated for changes to
the TimeRanges class.

Source/WebKit/mac:

* DOM/DOMCharacterData.mm:
(-[DOMCharacterData remove]): Updated exception handling.
* DOM/DOMDOMTokenList.mm:
(-[DOMDOMTokenList toggle:force:]): Ditto.
* DOM/DOMDocumentType.mm:
(-[DOMDocumentType remove]): Ditto.
* DOM/DOMElement.mm:
(-[DOMElement remove]): Ditto.
* DOM/DOMHTML.mm:
(-[DOMHTMLInputElement setValueAsNumberWithChangeEvent:]): Ditto.
* DOM/DOMHTMLCanvasElement.mm:
(-[DOMHTMLCanvasElement toDataURL:]): Ditto.
* DOM/DOMHTMLElement.mm:
(-[DOMHTMLElement setInnerText:]): Ditto.
(-[DOMHTMLElement setOuterText:]): Ditto.
(-[DOMHTMLElement setContentEditable:]): Ditto.
* DOM/DOMHTMLInputElement.mm:
(-[DOMHTMLInputElement setMaxLength:]): Ditto.
(-[DOMHTMLInputElement setValueAsDate:]): Ditto.
(-[DOMHTMLInputElement setValueAsNumber:]): Ditto.
(-[DOMHTMLInputElement stepUp:]): Ditto.
(-[DOMHTMLInputElement stepDown:]): Ditto.
(-[DOMHTMLInputElement setRangeText:]): Ditto.
(-[DOMHTMLInputElement setRangeText:start:end:selectionMode:]): Ditto.
* DOM/DOMHTMLMarqueeElement.mm:
(-[DOMHTMLMarqueeElement setLoop:]): Ditto.
* DOM/DOMHTMLMediaElement.mm:
(-[DOMHTMLMediaElement setCurrentTime:]): Ditto.
(-[DOMHTMLMediaElement setVolume:]): Ditto.
* DOM/DOMHTMLOptionsCollection.mm:
(-[DOMHTMLOptionsCollection setLength:]): Ditto.
* DOM/DOMHTMLTableElement.mm:
(-[DOMHTMLTableElement setCaption:]): Ditto.
(-[DOMHTMLTableElement setTHead:]): Ditto.
(-[DOMHTMLTableElement setTFoot:]): Ditto.
(-[DOMHTMLTableElement insertRow:]): Ditto.
(-[DOMHTMLTableElement deleteRow:]): Ditto.
* DOM/DOMHTMLTableRowElement.mm:
(-[DOMHTMLTableRowElement insertCell:]): Ditto.
(-[DOMHTMLTableRowElement deleteCell:]): Ditto.
* DOM/DOMHTMLTableSectionElement.mm:
(-[DOMHTMLTableSectionElement insertRow:]): Ditto.
(-[DOMHTMLTableSectionElement deleteRow:]): Ditto.
* DOM/DOMHTMLTextAreaElement.mm:
(-[DOMHTMLTextAreaElement setMaxLength:]): Ditto.
(-[DOMHTMLTextAreaElement setRangeText:]): Ditto.
(-[DOMHTMLTextAreaElement setRangeText:start:end:selectionMode:]): Ditto.
* DOM/DOMHTMLVideoElement.mm:
(-[DOMHTMLVideoElement webkitEnterFullscreen]): Ditto.
(-[DOMHTMLVideoElement webkitEnterFullScreen]): Changed to call the other named
version (lowercase S) instead of repeating the logic from that method.
(-[DOMHTMLVideoElement webkitExitFullScreen]): Ditto.
* DOM/DOMTimeRanges.mm:
(-[DOMTimeRanges start:]): Updated exception handling.
(-[DOMTimeRanges end:]): Ditto.

Source/WebKit/win:

* DOMHTMLClasses.cpp:
(DOMHTMLElement::setInnerText): Update exception handling.
* FullscreenVideoController.cpp:
(FullscreenVideoController::setVolume): Ditto.

Source/WebKit2:

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMTokenList.cpp:
(webkit_dom_dom_token_list_add): Updated exception handling.
(webkit_dom_dom_token_list_remove): Ditto.
(webkit_dom_dom_token_list_toggle): Ditto.
(webkit_dom_dom_token_list_replace): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElement.cpp:
(webkit_dom_element_remove): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLElement.cpp:
(webkit_dom_html_element_set_inner_text): Ditto.
(webkit_dom_html_element_set_outer_text): Ditto.
(webkit_dom_html_element_set_content_editable): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLInputElement.cpp:
(webkit_dom_html_input_element_set_max_length): Ditto.
(webkit_dom_html_input_element_set_size): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp:
(webkit_dom_html_select_element_set_length): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableElement.cpp:
(webkit_dom_html_table_element_insert_row): Ditto.
(webkit_dom_html_table_element_delete_row): Ditto.
(webkit_dom_html_table_element_set_caption): Ditto.
(webkit_dom_html_table_element_set_t_head): Ditto.
(webkit_dom_html_table_element_set_t_foot): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableRowElement.cpp:
(webkit_dom_html_table_row_element_insert_cell): Ditto.
(webkit_dom_html_table_row_element_delete_cell): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableSectionElement.cpp:
(webkit_dom_html_table_section_element_insert_row): Ditto.
(webkit_dom_html_table_section_element_delete_row): Ditto.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState): Removed ASSERT_NO_EXCEPTION.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setAssistedNodeValueAsNumber): Removed ASSERT_NO_EXCEPTION.

* WebProcess/cocoa/WebPlaybackSessionManager.mm:
(WebKit::WebPlaybackSessionManager::seekableRangesChanged):
Changed the code to use a different interface to TimeRange that does
not involve exceptions.

Tools:

* TestWebKitAPI/Tests/WebCore/TimeRanges.cpp:
(TestWebKitAPI::ToString): Updated for changes to the TimeRanges class.
(TestWebKitAPI::TEST): Ditto.

LayoutTests:

* fast/dom/DOMURL/set-href-attribute-hash-expected.txt:
* fast/dom/DOMURL/set-href-attribute-hash.html:
* fast/dom/DOMURL/set-href-attribute-hostname-expected.txt:
* fast/dom/DOMURL/set-href-attribute-hostname.html:
* fast/dom/DOMURL/set-href-attribute-pathname-expected.txt:
* fast/dom/DOMURL/set-href-attribute-pathname.html:
Updated these tests to expect that if you set href and it raises an exception,
then the URL does not change. The old expected results showed the exception being
raised but the URL being changed to the invalid href.

* fast/dom/HTMLProgressElement/script-tests/set-progress-properties.js:
* fast/dom/HTMLProgressElement/set-progress-properties-expected.txt:
Updated to expect a different exception, TypeError rather than NotSupportedError,
for non-finite values.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

188 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/DOMURL/set-href-attribute-hash-expected.txt
LayoutTests/fast/dom/DOMURL/set-href-attribute-hash.html
LayoutTests/fast/dom/DOMURL/set-href-attribute-hostname-expected.txt
LayoutTests/fast/dom/DOMURL/set-href-attribute-hostname.html
LayoutTests/fast/dom/DOMURL/set-href-attribute-pathname-expected.txt
LayoutTests/fast/dom/DOMURL/set-href-attribute-pathname.html
LayoutTests/fast/dom/HTMLProgressElement/script-tests/set-progress-properties.js
LayoutTests/fast/dom/HTMLProgressElement/set-progress-properties-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp
Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
Source/WebCore/bindings/js/JSHTMLSelectElementCustom.h
Source/WebCore/bindings/js/JSLocationCustom.cpp
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/dom/ChildNode.idl
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/editing/AppendNodeCommand.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/InsertNodeBeforeCommand.cpp
Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
Source/WebCore/editing/RemoveNodeCommand.cpp
Source/WebCore/editing/SplitElementCommand.cpp
Source/WebCore/editing/SplitTextNodeCommand.cpp
Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/editing/markup.h
Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp
Source/WebCore/html/BaseDateAndTimeInputType.cpp
Source/WebCore/html/BaseDateAndTimeInputType.h
Source/WebCore/html/DOMTokenList.cpp
Source/WebCore/html/DOMTokenList.h
Source/WebCore/html/DOMTokenList.idl
Source/WebCore/html/DOMURL.cpp
Source/WebCore/html/DOMURL.h
Source/WebCore/html/DOMURL.idl
Source/WebCore/html/DateTimeLocalInputType.cpp
Source/WebCore/html/DateTimeLocalInputType.h
Source/WebCore/html/FTPDirectoryDocument.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/html/HTMLCanvasElement.idl
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLElement.idl
Source/WebCore/html/HTMLEmbedElement.idl
Source/WebCore/html/HTMLFrameElement.idl
Source/WebCore/html/HTMLFrameOwnerElement.cpp
Source/WebCore/html/HTMLFrameOwnerElement.h
Source/WebCore/html/HTMLIFrameElement.idl
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLInputElement.idl
Source/WebCore/html/HTMLMarqueeElement.cpp
Source/WebCore/html/HTMLMarqueeElement.h
Source/WebCore/html/HTMLMarqueeElement.idl
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaElement.idl
Source/WebCore/html/HTMLObjectElement.idl
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLOptionElement.h
Source/WebCore/html/HTMLOptionElement.idl
Source/WebCore/html/HTMLOptionsCollection.cpp
Source/WebCore/html/HTMLOptionsCollection.h
Source/WebCore/html/HTMLOptionsCollection.idl
Source/WebCore/html/HTMLProgressElement.cpp
Source/WebCore/html/HTMLProgressElement.h
Source/WebCore/html/HTMLProgressElement.idl
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/HTMLSelectElement.h
Source/WebCore/html/HTMLSelectElement.idl
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTableElement.h
Source/WebCore/html/HTMLTableElement.idl
Source/WebCore/html/HTMLTableRowElement.cpp
Source/WebCore/html/HTMLTableRowElement.h
Source/WebCore/html/HTMLTableRowElement.idl
Source/WebCore/html/HTMLTableSectionElement.cpp
Source/WebCore/html/HTMLTableSectionElement.h
Source/WebCore/html/HTMLTableSectionElement.idl
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextAreaElement.idl
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/HTMLVideoElement.h
Source/WebCore/html/HTMLVideoElement.idl
Source/WebCore/html/ImageData.cpp
Source/WebCore/html/ImageData.h
Source/WebCore/html/ImageData.idl
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/MediaController.cpp
Source/WebCore/html/MediaController.h
Source/WebCore/html/MediaController.idl
Source/WebCore/html/MediaControllerInterface.h
Source/WebCore/html/NumberInputType.cpp
Source/WebCore/html/NumberInputType.h
Source/WebCore/html/RangeInputType.cpp
Source/WebCore/html/RangeInputType.h
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/TimeRanges.cpp
Source/WebCore/html/TimeRanges.h
Source/WebCore/html/TimeRanges.idl
Source/WebCore/html/URLUtils.idl
Source/WebCore/html/ValidationMessage.cpp
Source/WebCore/html/parser/HTMLTreeBuilder.cpp
Source/WebCore/html/shadow/MediaControlElementTypes.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControls.cpp
Source/WebCore/html/shadow/MediaControlsApple.cpp
Source/WebCore/html/track/LoadableTextTrack.cpp
Source/WebCore/html/track/LoadableTextTrack.h
Source/WebCore/html/track/VTTCue.cpp
Source/WebCore/html/track/VTTRegion.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/PlatformTimeRanges.h
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/efl/ImageBufferEfl.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp
Source/WebCore/platform/image-encoders/JPEGImageEncoder.cpp
Source/WebCore/platform/image-encoders/JPEGImageEncoder.h
Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm
Source/WebCore/platform/mac/WebVideoFullscreenHUDWindowController.mm
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/DOMCharacterData.mm
Source/WebKit/mac/DOM/DOMDOMTokenList.mm
Source/WebKit/mac/DOM/DOMDocumentType.mm
Source/WebKit/mac/DOM/DOMElement.mm
Source/WebKit/mac/DOM/DOMHTML.mm
Source/WebKit/mac/DOM/DOMHTMLCanvasElement.mm
Source/WebKit/mac/DOM/DOMHTMLElement.mm
Source/WebKit/mac/DOM/DOMHTMLInputElement.mm
Source/WebKit/mac/DOM/DOMHTMLMarqueeElement.mm
Source/WebKit/mac/DOM/DOMHTMLMediaElement.mm
Source/WebKit/mac/DOM/DOMHTMLOptionsCollection.mm
Source/WebKit/mac/DOM/DOMHTMLTableElement.mm
Source/WebKit/mac/DOM/DOMHTMLTableRowElement.mm
Source/WebKit/mac/DOM/DOMHTMLTableSectionElement.mm
Source/WebKit/mac/DOM/DOMHTMLTextAreaElement.mm
Source/WebKit/mac/DOM/DOMHTMLVideoElement.mm
Source/WebKit/mac/DOM/DOMTimeRanges.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMHTMLClasses.cpp
Source/WebKit/win/FullscreenVideoController.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMTokenList.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElement.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLElement.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLInputElement.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableElement.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableRowElement.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableSectionElement.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp

index ac898ab..78e734c 100644 (file)
@@ -1,3 +1,25 @@
+2016-10-28  Darin Adler  <darin@apple.com>
+
+        Move all classes in the HTML directory from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163876
+
+        Reviewed by Sam Weinig.
+
+        * fast/dom/DOMURL/set-href-attribute-hash-expected.txt:
+        * fast/dom/DOMURL/set-href-attribute-hash.html:
+        * fast/dom/DOMURL/set-href-attribute-hostname-expected.txt:
+        * fast/dom/DOMURL/set-href-attribute-hostname.html:
+        * fast/dom/DOMURL/set-href-attribute-pathname-expected.txt:
+        * fast/dom/DOMURL/set-href-attribute-pathname.html:
+        Updated these tests to expect that if you set href and it raises an exception,
+        then the URL does not change. The old expected results showed the exception being
+        raised but the URL being changed to the invalid href.
+
+        * fast/dom/HTMLProgressElement/script-tests/set-progress-properties.js:
+        * fast/dom/HTMLProgressElement/set-progress-properties-expected.txt:
+        Updated to expect a different exception, TypeError rather than NotSupportedError,
+        for non-finite values.
+
 2016-10-28  Jer Noble  <jer.noble@apple.com>
 
         WebAudio does not resume when moving from background to foreground tab.
index a14f68e..fd21d5f 100644 (file)
@@ -11,7 +11,7 @@ PASS a.href is 'file:///path/testurl.html#hash_value'
 PASS a.href is 'http://www.mydomain.com/path/testurl.html#hash?value'
 '#' in hash value, and illegal characters in hostname
 PASS a.href = "https://ww w.my\"d(){}|~om?ain#com/path/testurl.html#middle" threw exception TypeError: Type error.
-PASS a.href is 'https://ww w.my\"d(){}|~om?ain#com/path/testurl.html#middle'
+PASS a.href is 'http://www.mydomain.com/path/testurl.html#hash#value'
 Set hash to null
 PASS a.href is 'https://www.mydomain.com/path/testurl.html#null'
 Set hash to empty string
index c3ac684..d0ef472 100644 (file)
@@ -32,7 +32,7 @@ debug("'#' in hash value, and illegal characters in hostname");
 // with the URL API, assigning an invalid href throws
 shouldThrow('a.href = "https://ww w.my\\"d(){}|~om?ain#com/path/testurl.html#middle"');
 a.hash = "#hash#value";
-shouldBe("a.href", "'https://ww w.my\\\"d(){}|~om?ain#com/path/testurl.html#middle'");
+shouldBe("a.href", "'http://www.mydomain.com/path/testurl.html#hash#value'");
 
 debug("Set hash to null");
 a.href = "https://www.mydomain.com/path/testurl.html#middle";
index 2784bbc..f6a40c7 100644 (file)
@@ -17,7 +17,7 @@ Set hostname to URL with 2 colons
 PASS a.href is 'really:bad:url'
 Set a hostname that contains space in it
 PASS a.href = "http://www.my domain.com/path/" threw exception TypeError: Type error.
-PASS a.href is 'http://www.my domain.com/path/'
+PASS a.href is 'really:bad:url'
 Set hostname on a local file
 FAIL a.href should be c:/path/testurl.html. Was c://a/path/testurl.html.
 Set hostname to undefined
index 503686e..1b9ffdd 100644 (file)
@@ -58,7 +58,7 @@ shouldBe("a.href", "'really:bad:url'");
 debug("Set a hostname that contains space in it");
 shouldThrow('a.href = "http://www.my domain.com/path/"');
 a.hostname = "www.other domain.com";
-shouldBe("a.href", "'http://www.my domain.com/path/'");
+shouldBe("a.href", "'really:bad:url'");
 
 // IE8 throws an exception "The URL is invalid".
 try {
index 96ea17f..245afa9 100644 (file)
@@ -17,10 +17,10 @@ Set pathname to empty string
 PASS a.href is 'https://www.mydomain.com/?key=value'
 Set pathname that includes illegal characters to URL that contains illegal characters.
 PASS a.href = "https://www.my|d[]()omain.com/path/testurl.html?key=value" threw exception TypeError: Type error.
-PASS a.href is 'https://www.my|d[]()omain.com/path/testurl.html?key=value'
+PASS a.href is 'https://www.mydomain.com/p$a|th?key=value'
 Set pathname to URL that contains '@' in host
 PASS a.href = "http://w@#ww" threw exception TypeError: Type error.
-PASS a.href is 'http://w@#ww'
+PASS a.href is 'https://www.mydomain.com/path?key=value'
 Set pathname to a URL with non-hierarchical protocol
 PASS a.href is 'tel:+1800-555-1212'
 PASS successfullyParsed is true
index 6118eab..939bff6 100644 (file)
@@ -56,14 +56,14 @@ shouldBe("a.href", "'https://www.mydomain.com/?key=value'");
 debug("Set pathname that includes illegal characters to URL that contains illegal characters.");
 shouldThrow('a.href = "https://www.my|d[]()omain.com/path/testurl.html?key=value"');
 a.pathname = "p$a|th";
-shouldBe("a.href", "'https://www.my|d[]()omain.com/path/testurl.html?key=value'");
+shouldBe("a.href", "'https://www.mydomain.com/p$a|th?key=value'");
 
 // IE8 throws a security exception. Gecko parses this as a URL with an empty hostname.
 try {
 debug("Set pathname to URL that contains '@' in host");
 shouldThrow('a.href = "http://w@#ww"');
 a.pathname = "path";
-shouldBe("a.href", "'http://w@#ww'");
+shouldBe("a.href", "'https://www.mydomain.com/path?key=value'");
 } catch(e) {
 debug("Exception: " + e.description);
 }
index 70ba3b9..cdb49b3 100644 (file)
@@ -27,16 +27,16 @@ shouldBe('p.value', '0');
 shouldBe('p.position', '0');
 
 debug("Set invalid value, should throw");
-shouldThrow('p.value = "200A";', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrow('p.value = "200A";', '"TypeError: The provided value is non-finite"');
 
 debug("Set invalid max, should throw");
-shouldThrow('p.max = "max";', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrow('p.max = "max";', '"TypeError: The provided value is non-finite"');
 
 debug("Set max to Infinity, should throw");
-shouldThrow('p.max = Infinity;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrow('p.max = Infinity;', '"TypeError: The provided value is non-finite"');
 
 debug("Set value to NaN, should throw");
-shouldThrow('p.value = NaN;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrow('p.value = NaN;', '"TypeError: The provided value is non-finite"');
 
 debug("Set value to null and max to 0");
 p.value = null;
index 2902521..59ad3b3 100644 (file)
@@ -19,13 +19,13 @@ Set value less than zero
 PASS p.value is 0
 PASS p.position is 0
 Set invalid value, should throw
-PASS p.value = "200A"; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS p.value = "200A"; threw exception TypeError: The provided value is non-finite.
 Set invalid max, should throw
-PASS p.max = "max"; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS p.max = "max"; threw exception TypeError: The provided value is non-finite.
 Set max to Infinity, should throw
-PASS p.max = Infinity; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS p.max = Infinity; threw exception TypeError: The provided value is non-finite.
 Set value to NaN, should throw
-PASS p.value = NaN; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS p.value = NaN; threw exception TypeError: The provided value is non-finite.
 Set value to null and max to 0
 PASS p.value is 0
 PASS p.max is 1
index 4965311..2d7fbeb 100644 (file)
@@ -1,3 +1,14 @@
+2016-10-28  Darin Adler  <darin@apple.com>
+
+        Move all classes in the HTML directory from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163876
+
+        Reviewed by Sam Weinig.
+
+        * web-platform-tests/url/url-setters-expected.txt: Updated for progressions that occurred
+        because setting the href attribute on a DOMURL object no longer modifies the URL as a side
+        effect in the cases where it throw an exception.
+
 2016-10-28  Alex Christensen  <achristensen@webkit.org>
 
         Partially revert 207805 after resolution in URL spec issue 87
index c7b95be..261c5f0 100644 (file)
@@ -42,10 +42,10 @@ PASS <area>: Setting <http://example.net>.protocol = 'https:foo : bar' Stuff aft
 PASS URL: Setting <data:text/html,<p>Test>.protocol = 'view-source+data:foo : bar' Stuff after the first ':' is ignored 
 PASS <a>: Setting <data:text/html,<p>Test>.protocol = 'view-source+data:foo : bar' Stuff after the first ':' is ignored 
 PASS <area>: Setting <data:text/html,<p>Test>.protocol = 'view-source+data:foo : bar' Stuff after the first ':' is ignored 
-FAIL URL: Setting <file:///home/you/index.html>.username = 'me' No host means no username assert_equals: expected "file:///home/you/index.html" but got "file://me@/home/you/index.html"
+PASS URL: Setting <file:///home/you/index.html>.username = 'me' No host means no username 
 FAIL <a>: Setting <file:///home/you/index.html>.username = 'me' No host means no username assert_equals: expected "file:///home/you/index.html" but got "file://me@/home/you/index.html"
 FAIL <area>: Setting <file:///home/you/index.html>.username = 'me' No host means no username assert_equals: expected "file:///home/you/index.html" but got "file://me@/home/you/index.html"
-FAIL URL: Setting <unix:/run/foo.socket>.username = 'me' No host means no username assert_equals: expected "unix:/run/foo.socket" but got "unix://me@/run/foo.socket"
+PASS URL: Setting <unix:/run/foo.socket>.username = 'me' No host means no username 
 FAIL <a>: Setting <unix:/run/foo.socket>.username = 'me' No host means no username assert_equals: expected "unix:/run/foo.socket" but got "unix://me@/run/foo.socket"
 FAIL <area>: Setting <unix:/run/foo.socket>.username = 'me' No host means no username assert_equals: expected "unix:/run/foo.socket" but got "unix://me@/run/foo.socket"
 FAIL URL: Setting <mailto:you@example.net>.username = 'me' Cannot-be-a-base means no username assert_equals: expected "mailto:you@example.net" but got "mailto://me%40you@example.net"
@@ -72,10 +72,10 @@ PASS <area>: Setting <http://example.net>.username = '\0\ 1
 PASS URL: Setting <http://example.net>.username = '%c3%89té' Bytes already percent-encoded are left as-is. 
 PASS <a>: Setting <http://example.net>.username = '%c3%89té' Bytes already percent-encoded are left as-is. 
 PASS <area>: Setting <http://example.net>.username = '%c3%89té' Bytes already percent-encoded are left as-is. 
-FAIL URL: Setting <file:///home/me/index.html>.password = 'secret' No host means no password assert_equals: expected "file:///home/me/index.html" but got "file://:secret@/home/me/index.html"
+PASS URL: Setting <file:///home/me/index.html>.password = 'secret' No host means no password 
 FAIL <a>: Setting <file:///home/me/index.html>.password = 'secret' No host means no password assert_equals: expected "file:///home/me/index.html" but got "file://:secret@/home/me/index.html"
 FAIL <area>: Setting <file:///home/me/index.html>.password = 'secret' No host means no password assert_equals: expected "file:///home/me/index.html" but got "file://:secret@/home/me/index.html"
-FAIL URL: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password assert_equals: expected "unix:/run/foo.socket" but got "unix://:secret@/run/foo.socket"
+PASS URL: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password 
 FAIL <a>: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password assert_equals: expected "unix:/run/foo.socket" but got "unix://:secret@/run/foo.socket"
 FAIL <area>: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password assert_equals: expected "unix:/run/foo.socket" but got "unix://:secret@/run/foo.socket"
 FAIL URL: Setting <mailto:me@example.net>.password = 'secret' Cannot-be-a-base means no password assert_equals: expected "mailto:me@example.net" but got "mailto://:secret%40me@example.net"
@@ -129,7 +129,7 @@ PASS <area>: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a hos
 PASS URL: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized 
 PASS <a>: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized 
 PASS <area>: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized 
-FAIL URL: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://[:0/"
+FAIL URL: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://example.net/"
 FAIL <a>: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://[:0/"
 FAIL <area>: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized assert_equals: expected "http://[::1]:2/" but got "http://[:0/"
 PASS URL: Setting <http://example.net>.host = 'example.com:80' Default port number is removed 
@@ -165,7 +165,7 @@ FAIL <area>: Setting <http://example.net/path>.host = 'example.com\stuff' Stuff
 PASS URL: Setting <http://example.net/path>.host = 'example.com:8080\stuff' Stuff after a \ delimiter is ignored for special schemes 
 PASS <a>: Setting <http://example.net/path>.host = 'example.com:8080\stuff' Stuff after a \ delimiter is ignored for special schemes 
 PASS <area>: Setting <http://example.net/path>.host = 'example.com:8080\stuff' Stuff after a \ delimiter is ignored for special schemes 
-FAIL URL: Setting <view-source+http://example.net/path>.host = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain assert_equals: expected "view-source+http://example.net/path" but got "view-source+http://example.com\\stuff/path"
+PASS URL: Setting <view-source+http://example.net/path>.host = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain 
 FAIL <a>: Setting <view-source+http://example.net/path>.host = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain assert_equals: expected "view-source+http://example.net/path" but got "view-source+http://example.com\\stuff/path"
 FAIL <area>: Setting <view-source+http://example.net/path>.host = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain assert_equals: expected "view-source+http://example.net/path" but got "view-source+http://example.com\\stuff/path"
 PASS URL: Setting <view-source+http://example.net/path>.host = 'example.com:8080stuff2' Anything other than ASCII digit stops the port parser in a setter but is not an error 
@@ -180,7 +180,7 @@ PASS <area>: Setting <http://example.net/path>.host = 'example.com:8080+2' Anyth
 PASS URL: Setting <http://example.net/path>.host = 'example.com:65535' Port numbers are 16 bit integers 
 PASS <a>: Setting <http://example.net/path>.host = 'example.com:65535' Port numbers are 16 bit integers 
 PASS <area>: Setting <http://example.net/path>.host = 'example.com:65535' Port numbers are 16 bit integers 
-FAIL URL: Setting <http://example.net/path>.host = 'example.com:65536' Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though. assert_equals: expected "http://example.com/path" but got "http://example.com:65536/path"
+FAIL URL: Setting <http://example.net/path>.host = 'example.com:65536' Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though. assert_equals: expected "http://example.com/path" but got "http://example.net/path"
 FAIL <a>: Setting <http://example.net/path>.host = 'example.com:65536' Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though. assert_equals: expected "http://example.com/path" but got "http://example.com:65536/path"
 FAIL <area>: Setting <http://example.net/path>.host = 'example.com:65536' Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though. assert_equals: expected "http://example.com/path" but got "http://example.com:65536/path"
 PASS URL: Setting <mailto:me@example.net>.hostname = 'example.com' Cannot-be-a-base means no host 
@@ -225,7 +225,7 @@ FAIL <area>: Setting <http://example.net/path>.hostname = 'example.com#stuff' St
 FAIL URL: Setting <http://example.net/path>.hostname = 'example.com\stuff' Stuff after a \ delimiter is ignored for special schemes assert_equals: expected "http://example.com/path" but got "http://example.com/stuff/path"
 FAIL <a>: Setting <http://example.net/path>.hostname = 'example.com\stuff' Stuff after a \ delimiter is ignored for special schemes assert_equals: expected "http://example.com/path" but got "http://example.com/stuff/path"
 FAIL <area>: Setting <http://example.net/path>.hostname = 'example.com\stuff' Stuff after a \ delimiter is ignored for special schemes assert_equals: expected "http://example.com/path" but got "http://example.com/stuff/path"
-FAIL URL: Setting <view-source+http://example.net/path>.hostname = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain assert_equals: expected "view-source+http://example.net/path" but got "view-source+http://example.com\\stuff/path"
+PASS URL: Setting <view-source+http://example.net/path>.hostname = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain 
 FAIL <a>: Setting <view-source+http://example.net/path>.hostname = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain assert_equals: expected "view-source+http://example.net/path" but got "view-source+http://example.com\\stuff/path"
 FAIL <area>: Setting <view-source+http://example.net/path>.hostname = 'example.com\stuff' \ is not a delimiter for non-special schemes, and it’s invalid in a domain assert_equals: expected "view-source+http://example.net/path" but got "view-source+http://example.com\\stuff/path"
 PASS URL: Setting <http://example.net>.port = '8080' 
index ebeb3a4..3596894 100644 (file)
@@ -1,3 +1,558 @@
+2016-10-28  Darin Adler  <darin@apple.com>
+
+        Move all classes in the HTML directory from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163876
+
+        Reviewed by Sam Weinig.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::shouldAllowAccessToNode): Deleted.
+        (WebCore::BindingSecurity::shouldAllowAccessToFrame): Moved function into the
+        BindingSecurity namespace. Also changed arguments to references.
+        (WebCore::BindingSecurity::shouldAllowAccessToDOMWindow): Ditto.
+        (WebCore::BindingSecurity::shouldAllowAccessToNode): Changed argument type
+        from pointer to reference.
+
+        * bindings/js/JSDOMBinding.h: Removed top level shouldAllowAccessTo functions,
+        moving all of them into the BindingSecurity namespace. Changed BindingSecurity
+        from a class into a namespace. Added new checkSecurityForNode functions that
+        can be used directly to implement CheckSecurityForNode; they turn the node
+        into a null, which is no change in behavior from what bindings already did.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess): Changed argument
+        type for passed-in string to const String& instead of String&.
+        (WebCore::JSDOMWindow::getOwnPropertySlot): Updated for BindingSecurity changes.
+        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex): Ditto.
+        (WebCore::JSDOMWindow::put): Ditto.
+
+        * bindings/js/JSHTMLCanvasElementCustom.cpp:
+        (WebCore::attributesFor3DContext): Renamed from get3DContextAttributes and
+        changed to use a return value instead of an out argument.
+        (WebCore::JSHTMLCanvasElement::getContext): Updated for the above.
+        (WebCore::JSHTMLCanvasElement::toDataURL): Rewrote to handle ExceptionOr
+        and also to use Optional<double> instead of const double*.
+
+        * bindings/js/JSHTMLFrameElementCustom.cpp:
+        (WebCore::JSHTMLFrameElement::setLocation): Moved the logic from
+        allowSettingJavascriptURL in here and updated for BindingSecurity changes.
+
+        * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
+        (WebCore::JSHTMLOptionsCollection::setLength): Use propagateException.
+        Also streamlined the code a bit.
+        (WebCore::JSHTMLOptionsCollection::indexSetter): Updated for new name and
+        argument types for selectElementIndexSetter.
+
+        * bindings/js/JSHTMLSelectElementCustom.cpp:
+        (WebCore::selectElementIndexSetter): Updated name and argument types and
+        to use propagateException.
+        (WebCore::JSHTMLSelectElement::indexSetter): Updated for above.
+        * bindings/js/JSHTMLSelectElementCustom.h: Ditto.
+
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::getOwnPropertySlotDelegate): Updated for changes to
+        BindingSecurity.
+        (WebCore::JSLocation::putDelegate): Ditto. Also rearranged logic a bit.
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::canAccessFromCurrentOrigin): Updated for
+        changes to BindingSecurity.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation): Removed old support for CheckSecurityForNode.
+        (NativeToJSValue): Added new support for CheckSecurityForNode, which uses
+        the new checkSecurityForNode function, and works properly with ExceptionOr.
+
+        * bindings/scripts/test/JS/JSTestObj.cpp: Updated for change below.
+
+        * dom/ChildNode.idl: Move the remove function to non-legacy exception.
+        Needed now because this needs to match the one in HTMLSelectElement.
+
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchMouseForceWillBegin): Refactored a little bit.
+        (WebCore::Element::mergeWithNextTextNode): Support ExceptionOr for remove.
+        (WebCore::Element::setOuterHTML): Support ExceptionOr for
+        createFragmentForInnerOuterHTML.
+        (WebCore::Element::setInnerHTML): Ditto.
+        (WebCore::Element::insertAdjacentHTML): Ditto.
+
+        * dom/Node.cpp:
+        (WebCore::Node::remove): Use ExceptionOr.
+        (WebCore::Node::normalize): Remove use of IGNORE_EXCEPTION.
+        * dom/Node.h: Use ExceptionOr for remove.
+
+        * dom/Range.cpp:
+        (WebCore::Range::insertNode): Updated for change to remove.
+        (WebCore::Range::createContextualFragment): Updated for change
+        to WebCore::createContextualFragment.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::setInnerHTML): Use ExceptionOr for
+        createFragmentForInnerOuterHTML and replaceChildrenWithFragment.
+
+        * editing/AppendNodeCommand.cpp:
+        (WebCore::AppendNodeCommand::doUnapply): Remove IGNORE_EXCEPTION.
+        * editing/InsertNodeBeforeCommand.cpp:
+        (WebCore::InsertNodeBeforeCommand::doUnapply): Ditto.
+        * editing/MergeIdenticalElementsCommand.cpp:
+        (WebCore::MergeIdenticalElementsCommand::doApply): Ditto.
+        * editing/RemoveNodeCommand.cpp:
+        (WebCore::RemoveNodeCommand::doApply): Ditto.
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::doUnapply): Ditto.
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::doUnapply): Ditto.
+        * editing/WrapContentsInDummySpanCommand.cpp:
+        (WebCore::WrapContentsInDummySpanCommand::doUnapply): Ditto.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::insertDictationPhrases): Deleted. Moved this
+        iOS-specific function to EditorIOS.mm.
+        (WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto.
+        (WebCore::Editor::confirmMarkedText): Ditto.
+        (WebCore::Editor::setTextAsChildOfElement): Ditto.
+        (WebCore::Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping): Ditto.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::fontForSelection): Remove ASSERT_NO_EXCEPTION.
+        (WebCore::Editor::fontAttributesForSelectionStart): Ditto.
+        (WebCore::Editor::insertDictationPhrases): Moved here from Editor.cpp.
+        (WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto. Also
+        updated code that used remove to not pass an ExceptionCode.
+        (WebCore::Editor::confirmMarkedText): Ditto.
+        (WebCore::Editor::setTextAsChildOfElement): Ditto.
+        (WebCore::Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping): Ditto.
+
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::fontForSelection): Remove ASSERT_NO_EXCEPTION.
+        (WebCore::Editor::fontAttributesForSelectionStart): Ditto.
+
+        * editing/markup.cpp:
+        (WebCore::createFragmentForInnerOuterHTML): Use ExceptionOr.
+        (WebCore::createContextualFragment): Ditto.
+        (WebCore::replaceChildrenWithFragment): Ditto.
+        (WebCore::replaceChildrenWithText): Ditto.
+        * editing/markup.h: Updated for above changes.
+
+        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
+        (WebCore::BaseChooserOnlyDateAndTimeInputType::updateAppearance):
+        Removed ASSERT_NO_EXCEPTION.
+
+        * html/BaseDateAndTimeInputType.cpp:
+        (WebCore::BaseDateAndTimeInputType::setValueAsDate): Use ExceptionOr.
+        (WebCore::BaseDateAndTimeInputType::setValueAsDecimal): Ditto.
+        * html/BaseDateAndTimeInputType.h: Updated for above changes.
+
+        * html/DateTimeLocalInputType.cpp:
+        (WebCore::DateTimeLocalInputType::setValueAsDate): Use ExceptionOr.
+        * html/DateTimeLocalInputType.h: Updated for above changes.
+
+        * html/DOMTokenList.cpp:
+        (WebCore::DOMTokenList::validateToken): Use ExceptionOr.
+        (WebCore::DOMTokenList::validateTokens): Ditto.
+        (WebCore::DOMTokenList::addInternal): Ditto.
+        (WebCore::DOMTokenList::add): Ditto.
+        (WebCore::DOMTokenList::removeInternal): Ditto.
+        (WebCore::DOMTokenList::remove): Ditto.
+        (WebCore::DOMTokenList::toggle): Ditto.
+        (WebCore::DOMTokenList::replace): Ditto.
+        (WebCore::DOMTokenList::supports): Ditto.
+        * html/DOMTokenList.h: Updated for above changes.
+        * html/DOMTokenList.idl: Use non-legacy exceptions.
+
+        * html/DOMURL.cpp:
+        (WebCore::DOMURL::DOMURL): Just take the two URL objects and let
+        the create functions do all the processing.
+        (WebCore::DOMURL::create): Use ExceptionOr, and move the processing
+        of the URLs here out of the constructors.
+        (WebCore::DOMURL::setHref): Use ExceptionOr.
+        * html/DOMURL.h: Updated for above changes.
+        * html/DOMURL.idl: Use non-legacy exceptions.
+
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::appendEntry): Remove
+        IGNORE_EXCEPTION and use releaseReturnValue().
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::toDataURL): Use ExceptionOr.
+        * html/HTMLCanvasElement.h: Updated for above changes.
+        * html/HTMLCanvasElement.idl: Use non-legacy exception.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::textToFragment): Use ExceptionOr.
+        (WebCore::HTMLElement::setInnerText): Ditto.
+        (WebCore::HTMLElement::setOuterText): Ditto.
+        (WebCore::HTMLElement::setContentEditable): Ditto.
+        (WebCore::HTMLElement::translateAttributeMode): Deleted.
+        (WebCore::HTMLElement::translate): Moved the logic from the
+        translateAttributeMode function in here.
+        * html/HTMLElement.h: Updated for above changes.
+        * html/HTMLElement.idl: Use non-legacy exceptions.
+
+        * html/HTMLEmbedElement.idl: Use non-legacy exception.
+        * html/HTMLFrameElement.idl: Ditto.
+
+        * html/HTMLFrameOwnerElement.cpp:
+        (WebCore::HTMLFrameOwnerElement::getSVGDocument): Use ExceptionOr.
+        * html/HTMLFrameOwnerElement.h: Updated for above.
+
+        * html/HTMLIFrameElement.idl: Use non-legacy exception.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::stepUp): Use ExceptionOr.
+        (WebCore::HTMLInputElement::stepDown): Ditto.
+        (WebCore::HTMLInputElement::setValue): Ditto.
+        (WebCore::HTMLInputElement::setValueAsDate): Ditto.
+        (WebCore::HTMLInputElement::setValueAsNumber): Ditto.
+        (WebCore::HTMLInputElement::setSize): Ditto.
+        (WebCore::HTMLInputElement::maxLengthAttributeChanged): Use the
+        new internalSetMaxLength function; old code relied on a setMaxLength
+        that was different from the one exposed to bindings.
+        (WebCore::HTMLInputElement::minLengthAttributeChanged): Ditto.
+        (WebCore::HTMLInputElement::setRangeText): Use ExceptionOr.
+        * html/HTMLInputElement.h: Updated for above changes. Also use
+        data member initialization for InputElementClickState instead of
+        a constructor.
+        * html/HTMLInputElement.idl: Use non-legacy exception.
+
+        * html/HTMLMarqueeElement.cpp:
+        (WebCore::HTMLMarqueeElement::setLoop): Use ExceptionOr.
+        (WebCore::HTMLMarqueeElement::renderMarquee): Tweaked.
+        * html/HTMLMarqueeElement.h: Updated for above changes.
+        * html/HTMLMarqueeElement.idl: Ditto.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::TrackGroup::TrackGroup):
+        Initialize most data members in class definition rather than
+        the constructor.
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Ditto.
+        (WebCore::HTMLMediaElement::~HTMLMediaElement): Updated since
+        removeMediaElement now takes a reference.
+        (WebCore::HTMLMediaElement::updateActiveTextTrackCues): Use
+        a modern for loop to streamline code.
+        (WebCore::HTMLMediaElement::textTrackModeChanged): Updated since
+        track now returns a reference.
+        (WebCore::HTMLMediaElement::setCurrentTimeForBindings): Renamed
+        to prevent ambiguity with the other version that has slightly
+        different semantics and overloading and changed to use ExceptionOr.
+        (WebCore::HTMLMediaElement::playInternal): Updated to use reference.
+        (WebCore::HTMLMediaElement::setVolume): Use ExceptionOr.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack): Take a
+        reference instead of a PassRefPtr.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddVideoTrack): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidRemoveAudioTrack): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidRemoveTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidRemoveVideoTrack): Ditto.
+        (WebCore::HTMLMediaElement::addTextTrack): Use ExceptionOr.
+        (WebCore::HTMLMediaElement::didAddTextTrack): Use a reference.
+        (WebCore::HTMLMediaElement::didRemoveTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::maxBufferedTime): Update to use different
+        interface to time ranges that does not need to deal with exceptions.
+        (WebCore::HTMLMediaElement::setController): Pass references.
+        (WebCore::HTMLMediaElement::outOfBandTrackSources): Use reference.
+        * html/HTMLMediaElement.h: Updated for above.
+        * html/HTMLMediaElement.idl: Use non-legacy exceptions.
+
+        * html/HTMLObjectElement.idl: Use non-legacy exception.
+
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::createForJSConstructor): Use ExceptionOr.
+        * html/HTMLOptionElement.h: Updated for above change.
+        * html/HTMLOptionElement.idl: Use non-legacy exception.
+
+        * html/HTMLOptionsCollection.cpp:
+        (WebCore::HTMLOptionsCollection::setLength): Use ExceptionOr.
+        * html/HTMLOptionsCollection.h: Updated for above change.
+        * html/HTMLOptionsCollection.idl: Use non-legacy exception.
+
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::setValue): Removed non-finite handling
+        because that is now handled by the bindings.
+        (WebCore::HTMLProgressElement::setMax): Ditto.
+        * html/HTMLProgressElement.h: Updated for above.
+        * html/HTMLProgressElement.idl: Changed attributes to be double instead
+        of unrestricted double, and this was able to remove exceptions.
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::removeByIndex): Drop IGNORE_EXCEPTION.
+        (WebCore::HTMLSelectElement::remove): Use ExceptionOr.
+        (WebCore::HTMLSelectElement::setOption): Ditto.
+        (WebCore::HTMLSelectElement::setLength): Ditto.
+        * html/HTMLSelectElement.h: Updated for above changes.
+        * html/HTMLSelectElement.idl: Use non-legacy exceptions.
+
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::setCaption): Use ExceptionOr.
+        (WebCore::HTMLTableElement::setTHead): Ditto.
+        (WebCore::HTMLTableElement::setTFoot): Ditto.
+        (WebCore::HTMLTableElement::createTHead): Streamline a bit.
+        (WebCore::HTMLTableElement::deleteTHead): Ditto.
+        (WebCore::HTMLTableElement::createTFoot): Ditto.
+        (WebCore::HTMLTableElement::deleteTFoot): Ditto.
+        (WebCore::HTMLTableElement::createTBody): Ditto.
+        (WebCore::HTMLTableElement::createCaption): Ditto.
+        (WebCore::HTMLTableElement::insertRow): Use ExceptionOr.
+        (WebCore::HTMLTableElement::deleteRow): Ditto.
+        * html/HTMLTableElement.h: Updated for above changes.
+        * html/HTMLTableElement.idl: Use non-legacy exceptions.
+
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::findTable): Added.
+        (WebCore::HTMLTableRowElement::rowIndex): Streamline a bit using the
+        findTable function above.
+        (WebCore::findRows): Added.
+        (WebCore::HTMLTableRowElement::sectionRowIndex): Streamline a bit using
+        the findRows function above.
+        (WebCore::HTMLTableRowElement::insertCell): Use ExceptionOr.
+        (WebCore::HTMLTableRowElement::deleteCell): Ditto.
+        (WebCore::HTMLTableRowElement::setCells): Deleted.
+        * html/HTMLTableRowElement.h: Updated for the above. The setCells function
+        was dead code.
+        * html/HTMLTableRowElement.idl: Use non-legacy exceptions.
+
+        * html/HTMLTableSectionElement.cpp:
+        (WebCore::HTMLTableSectionElement::additionalPresentationAttributeStyle):
+        Tweaked a bit to use early return.
+        (WebCore::HTMLTableSectionElement::insertRow): Use ExceptionOr.
+        (WebCore::HTMLTableSectionElement::deleteRow): Ditto.
+        (WebCore::HTMLTableSectionElement::numRows): Use childrenOfType.
+        (WebCore::HTMLTableSectionElement::align): Deleted.
+        (WebCore::HTMLTableSectionElement::setAlign): Deleted.
+        (WebCore::HTMLTableSectionElement::ch): Deleted.
+        (WebCore::HTMLTableSectionElement::setCh): Deleted.
+        (WebCore::HTMLTableSectionElement::chOff): Deleted.
+        (WebCore::HTMLTableSectionElement::setChOff): Deleted.
+        (WebCore::HTMLTableSectionElement::vAlign): Deleted.
+        (WebCore::HTMLTableSectionElement::setVAlign): Deleted.
+        * html/HTMLTableSectionElement.h: Updated for the above.
+        * html/HTMLTableSectionElement.idl: Use non-legacy exception.
+
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::maxLengthAttributeChanged): Use the new
+        internalSetMaxLength function; old code relied on a setMaxLength
+        that was different from the one exposed to bindings.
+        (WebCore::HTMLTextAreaElement::minLengthAttributeChanged): Ditto.
+        (WebCore::HTMLTextAreaElement::updatePlaceholderText): Removed
+        ASSERT_NO_EXCEPTION.
+        * html/HTMLTextAreaElement.idl: Use non-legacy exceptions.
+
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setRangeText): Use ExceptionOr.
+        (WebCore::HTMLTextFormControlElement::setInnerTextValue): Ditto.
+        (WebCore::HTMLTextFormControlElement::setMaxLength): Ditto.
+        (WebCore::HTMLTextFormControlElement::setMinLength): Ditto.
+        * html/HTMLTextFormControlElement.h: Updated for above changes.
+        Also renamed the setMin/MaxLength function overloads for internal use
+        to internSetMin/MaxLength and made them protected.
+
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::~HTMLTrackElement): Call clearElement on the
+        track to break the connection. Before this was done as a side effect of
+        clearClient, but that is called in other cases where we do not want to
+        clear the link back to the track element.
+        (WebCore::HTMLTrackElement::insertedInto): Removed code that uses the
+        track function for its side effect of creating a track; no longer needed.
+        Rewrote this so it's more symmetric with removedFrom.
+        (WebCore::HTMLTrackElement::removedFrom): Pass reference. Also reordered
+        and removed an unnecessary check for null parent.
+        (WebCore::HTMLTrackElement::parseAttribute): Use track.
+        (WebCore::HTMLTrackElement::kind): Ditto.
+        (WebCore::HTMLTrackElement::track): Renamed ensureTrack to this. Also
+        removed the redundant code to call setTrackElement; we no longer change
+        the track element on a track until the track element is destroyed.
+        (WebCore::HTMLTrackElement::scheduleLoad): Use track.
+        (WebCore::HTMLTrackElement::loadTimerFired): Ditto.
+        (WebCore::HTMLTrackElement::setReadyState): Ditto.
+        (WebCore::HTMLTrackElement::readyState): Ditto.
+        (WebCore::HTMLTrackElement::mediaElement): Rearranged to use early return.
+        * html/HTMLTrackElement.h: Updated for above changes.
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::webkitEnterFullscreen): Use ExceptionOr.
+        * html/HTMLVideoElement.h: Removed the functions used just for
+        capitalization reasons; that's now handled in the bindings.
+        * html/HTMLVideoElement.idl: Use non-legacy bindings and ImplementedAs.
+
+        * html/ImageData.cpp:
+        (WebCore::ImageData::create): Return ExceptionOr.
+        * html/ImageData.h: Updated for above changes.
+        * html/ImageData.idl: Use non-legacy exceptions.
+
+        * html/InputType.cpp:
+        (WebCore::InputType::setValueAsDate): Use ExceptionOr.
+        (WebCore::InputType::setValueAsDouble): Ditto.
+        (WebCore::InputType::setValueAsDecimal): Ditto.
+        (WebCore::InputType::applyStep): Ditto.
+        (WebCore::InputType::stepUp): Ditto.
+        (WebCore::InputType::stepUpFromRenderer): Removed IGNORE_EXCEPTION.
+        * html/InputType.h: Updated for the above.
+
+        * html/MediaController.cpp:
+        (MediaController::addMediaElement): Take a reference instead of a pointer.
+        (MediaController::removeMediaElement): Ditto.
+        (MediaController::containsMediaElement): Ditto.
+        (MediaController::setVolume): Use ExceptionOr.
+        (MediaController::bringElementUpToSpeed): Take a reference.
+        * html/MediaController.h: Updated for above changes. Also made lots of
+        function overrides private.
+        * html/MediaController.idl: Use non-legacy exception.
+
+        * html/MediaControllerInterface.h: Use ExceptionOr for setVolume.
+
+        * html/NumberInputType.cpp:
+        (WebCore::RealNumberRenderSize::max): Use aggregate initialization instead
+        of a constructor.
+        (WebCore::calculateRenderSize): Ditto.
+        (WebCore::NumberInputType::setValueAsDouble): Use ExceptionOr.
+        (WebCore::NumberInputType::setValueAsDecimal): Ditto.
+        * html/NumberInputType.h: Updated for above changes.
+
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::RangeInputType): Initialize scalar data member
+        in class definition instead of here.
+        (WebCore::RangeInputType::setValueAsDecimal): Use ExceptionOr.
+        (WebCore::RangeInputType::handleKeydownEvent): Removed IGNORE_EXCEPTION.
+        * html/RangeInputType.h: Updated for above changes.
+
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::updatePlaceholderText): Removed
+        ASSERT_NO_EXCEPTION.
+
+        * html/TimeRanges.cpp:
+        (WebCore::TimeRanges::start): Use ExceptionOr.
+        (WebCore::TimeRanges::end): Ditto.
+        * html/TimeRanges.h: Updated for the above.
+        * html/TimeRanges.idl: Use non-legacy exceptions.
+
+        * html/URLUtils.idl: Use non-legacy exception.
+
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::setMessageDOMAndStartTimer): Removed
+        ASSERT_NO_EXCEPTION, IGNORE_EXCEPTION, and other exception-ignoring idioms.
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody): Ditto.
+        * html/shadow/MediaControlElementTypes.cpp:
+        (WebCore::MediaControlVolumeSliderElement::defaultEventHandler): Ditto.
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlPanelElement::setPosition): Ditto.
+        (WebCore::MediaControlPanelElement::resetPosition): Ditto.
+        (WebCore::MediaControlStatusDisplayElement::update): Ditto.
+        (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Ditto.
+        (WebCore::MediaControlFullscreenVolumeMinButtonElement::defaultEventHandler): Ditto.
+        (WebCore::MediaControlFullscreenVolumeMaxButtonElement::defaultEventHandler): Ditto.
+        * html/shadow/MediaControls.cpp:
+        (WebCore::MediaControls::updateCurrentTimeDisplay): Ditto.
+        * html/shadow/MediaControlsApple.cpp:
+        (WebCore::MediaControlsApple::updateCurrentTimeDisplay): Ditto.
+
+
+        * html/track/LoadableTextTrack.cpp:
+        (WebCore::LoadableTextTrack::LoadableTextTrack): Take reference.
+        (WebCore::LoadableTextTrack::~LoadableTextTrack): Deleted.
+        (WebCore::LoadableTextTrack::clearClient): Deleted override. We no longer
+        want to clear m_trackElement when clearing the client.
+        (WebCore::LoadableTextTrack::setTrackElement): Deleted.
+        (WebCore::LoadableTextTrack::id): Changed to use
+        attributeWithoutSynchronization for better performance and idAttr instead
+        of a string constant.
+        * html/track/LoadableTextTrack.h: Updated for above changes. Added a new
+        clearElement function. Made the element and isDefault functions private.
+
+        * html/track/VTTCue.cpp:
+        (WebCore::VTTCue::~VTTCue): Removed ASSERT_NO_EXCEPTION, IGNORE_EXCEPTION,
+        and other exception-ignoring idioms.
+        (WebCore::VTTCue::removeDisplayTree): Ditto.
+        * html/track/VTTRegion.cpp:
+        (WebCore::VTTRegion::displayLastTextTrackCueBox): Ditto.
+        (WebCore::VTTRegion::willRemoveTextTrackCueBox): Ditto.
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::pushNodeByBackendIdToFrontend):
+        Rewrote to avoid multiplehash table lookups and added a FIXME about
+        the peculiar code here.
+        (WebCore::InspectorDOMAgent::resolveNode): Streamlined.
+        (WebCore::InspectorDOMAgent::nodeAsScriptValue): Use the new
+        checkSecurityForNode instead of the old shouldAllowAccessToNode.
+
+        * platform/graphics/ImageBuffer.h: Take Optional<double> instead of
+        const double* in toDataURL. Renamed ImageDataToDataURL to just dataURL.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::addAudioTrack): Take a reference instead of PassRefPtr.
+        (WebCore::MediaPlayer::removeAudioTrack): Ditto.
+        (WebCore::MediaPlayer::addTextTrack): Ditto.
+        (WebCore::MediaPlayer::removeTextTrack): Ditto.
+        (WebCore::MediaPlayer::addVideoTrack): Ditto.
+        (WebCore::MediaPlayer::removeVideoTrack): Ditto.
+        * platform/graphics/MediaPlayer.h: Updated for the above.
+
+        * platform/graphics/PlatformTimeRanges.h: Exported a couple of functions
+        that are now used in WebKit.
+
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::clearTextTracks): Use a modern for loop.
+        (WebCore::MediaPlayerPrivateAVFoundation::processNewAndRemovedTextTracks):
+        Fixed a bug that would cause this function to fail to process half the tracks.
+        Also updated for the change from PassRefPtr to references.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::determineChangedTracksFromNewTracksAndOldItems): Pass references.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::audioSourceProvider): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::processMetadataTrack): Ditto.
+        (WebCore::assetMetadataKeyNames): Tweaked formatting.
+        (WebCore::itemKVOProperties): Ditto.
+        (WebCore::playerKVOProperties): Ditto.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::updateTracksOfType): Pass references.
+
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::toDataURL): Use Optional<double>
+
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::createBitmapImageAfterScalingIfNeeded): Use auto.
+        (WebCore::encodeImage): Ditto. Also renamed from CGImageEncodeToData.
+        (WebCore::dataURL): Ditto. Also renamed from CGImageToDataURL and from
+        ImageDataToDataURL.
+        (WebCore::ImageBuffer::toDataURL): Ditto.
+
+        * platform/graphics/efl/ImageBufferEfl.cpp:
+        (WebCore::encodeImageJPEG): Use Optional<double>
+        (WebCore::ImageBuffer::toDataURL): Ditto.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo): Pass
+        a reference instead of pointer.
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio): Ditto.
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfText): Ditto.
+        (WebCore::MediaPlayerPrivateGStreamer::processMpegTsSection): Ditto.
+        (WebCore::MediaPlayerPrivateGStreamer::processTableOfContents): Ditto.
+
+        * platform/graphics/gtk/ImageBufferGtk.cpp:
+        (WebCore::encodeImage): Use Optional<double>
+        (WebCore::ImageBuffer::toDataURL): Ditto.
+
+        * platform/graphics/win/ImageBufferDirect2D.cpp:
+        (WebCore::ImageBuffer::toDataURL): Use Optional<double>
+
+        * platform/image-encoders/JPEGImageEncoder.cpp:
+        (WebCore::compressRGBABigEndianToJPEG): Use Optional<double>
+        * platform/image-encoders/JPEGImageEncoder.h: Ditto.
+
+        * platform/ios/WebPlaybackSessionInterfaceAVKit.mm:
+        (WebCore::WebPlaybackSessionInterfaceAVKit::seekableRangesChanged):
+        Updated for change to TimeRanges.
+
+        * platform/mac/WebVideoFullscreenHUDWindowController.mm:
+        (-[WebVideoFullscreenHUDWindowController setVolume:]): Removed IGNORE_EXCEPTION.
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::endElementNs): Ditto.
+
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::paintMediaSliderTrack): Updated for changes to
+        the TimeRanges class.
+
 2016-10-28  Dave Hyatt  <hyatt@apple.com>
 
         [CSS Parser] Allow @font-face src descriptor's format function to contain identifiers
index 8ad08a7..8700d72 100644 (file)
@@ -346,31 +346,19 @@ bool hasIteratorMethod(JSC::ExecState& state, JSC::JSValue value)
     return !applyMethod.isUndefined();
 }
 
-bool shouldAllowAccessToNode(ExecState* exec, Node* node)
+bool BindingSecurity::shouldAllowAccessToFrame(ExecState& state, Frame& frame, String& message)
 {
-    return BindingSecurity::shouldAllowAccessToNode(exec, node);
-}
-
-bool shouldAllowAccessToFrame(ExecState* exec, Frame* target)
-{
-    return BindingSecurity::shouldAllowAccessToFrame(exec, target);
-}
-
-bool shouldAllowAccessToFrame(ExecState* exec, Frame* frame, String& message)
-{
-    if (!frame)
-        return false;
-    if (BindingSecurity::shouldAllowAccessToFrame(exec, frame, DoNotReportSecurityError))
+    if (BindingSecurity::shouldAllowAccessToFrame(&state, &frame, DoNotReportSecurityError))
         return true;
-    message = frame->document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(exec));
+    message = frame.document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(&state));
     return false;
 }
 
-bool shouldAllowAccessToDOMWindow(ExecState* exec, DOMWindow& target, String& message)
+bool BindingSecurity::shouldAllowAccessToDOMWindow(ExecState& state, DOMWindow& globalObject, String& message)
 {
-    if (BindingSecurity::shouldAllowAccessToDOMWindow(exec, target, DoNotReportSecurityError))
+    if (BindingSecurity::shouldAllowAccessToDOMWindow(&state, globalObject, DoNotReportSecurityError))
         return true;
-    message = target.crossDomainAccessErrorMessage(activeDOMWindow(exec));
+    message = globalObject.crossDomainAccessErrorMessage(activeDOMWindow(&state));
     return false;
 }
 
@@ -788,9 +776,9 @@ bool BindingSecurity::shouldAllowAccessToFrame(JSC::ExecState* state, Frame* tar
     return target && canAccessDocument(state, target->document(), reportingOption);
 }
 
-bool BindingSecurity::shouldAllowAccessToNode(JSC::ExecState* state, Node* target)
+bool BindingSecurity::shouldAllowAccessToNode(JSC::ExecState& state, Node* target)
 {
-    return target && canAccessDocument(state, &target->document(), LogSecurityError);
+    return !target || canAccessDocument(&state, &target->document(), LogSecurityError);
 }
     
 static EncodedJSValue throwTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const String& errorMessage)
index 9c3dab5..19dc9d8 100644 (file)
@@ -282,22 +282,15 @@ RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue);
 template<typename T, typename JSType> Vector<Ref<T>> toRefNativeArray(JSC::ExecState&, JSC::JSValue);
 WEBCORE_EXPORT bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
 
-bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
-bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*);
-bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, String& message);
-bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, String& message);
-
-enum SecurityReportingOption {
-    DoNotReportSecurityError,
-    LogSecurityError, // Legacy behavior.
-    ThrowSecurityError
-};
-
-class BindingSecurity {
-public:
-    static bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
-    static bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, SecurityReportingOption = LogSecurityError);
-    static bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, SecurityReportingOption = LogSecurityError);
+enum SecurityReportingOption { DoNotReportSecurityError, LogSecurityError, ThrowSecurityError };
+namespace BindingSecurity {
+    template<typename T> T* checkSecurityForNode(JSC::ExecState&, T*);
+    template<typename T> ExceptionOr<T*> checkSecurityForNode(JSC::ExecState&, ExceptionOr<T*>&&);
+    bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, SecurityReportingOption = LogSecurityError);
+    bool shouldAllowAccessToDOMWindow(JSC::ExecState&, DOMWindow&, String& message);
+    bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, SecurityReportingOption = LogSecurityError);
+    bool shouldAllowAccessToFrame(JSC::ExecState&, Frame&, String& message);
+    bool shouldAllowAccessToNode(JSC::ExecState&, Node*);
 };
 
 void printErrorMessageForFrame(Frame*, const String& message);
@@ -780,4 +773,16 @@ template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state,
     return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
 }
 
+template<typename T> inline T* BindingSecurity::checkSecurityForNode(JSC::ExecState& state, T* node)
+{
+    return shouldAllowAccessToNode(state, node) ? node : nullptr;
+}
+
+template<typename T> inline ExceptionOr<T*> BindingSecurity::checkSecurityForNode(JSC::ExecState& state, ExceptionOr<T*>&& value)
+{
+    if (value.hasException())
+        return WTFMove(value);
+    return checkSecurityForNode(state, value.releaseReturnValue());
+}
+
 } // namespace WebCore
index 8fc15e1..79d85d2 100644 (file)
@@ -73,7 +73,7 @@ static EncodedJSValue jsDOMWindowWebKit(ExecState* exec, EncodedJSValue thisValu
 }
 #endif
 
-static bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMWindow* thisObject, Frame* frame, ExecState* exec, PropertyName propertyName, PropertySlot& slot, String& errorMessage)
+static bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMWindow* thisObject, Frame* frame, ExecState* exec, PropertyName propertyName, PropertySlot& slot, const String& errorMessage)
 {
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -163,20 +163,20 @@ static bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMWindow* thisObjec
 // (1) indexed properties,
 // (2) regular own properties,
 // (3) named properties (in fact, these shouldn't be on the window, should be on the NPO).
-bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
     // (1) First, indexed properties.
     // Hand off all indexed access to getOwnPropertySlotByIndex, which supports the indexed getter.
     if (Optional<unsigned> index = parseIndex(propertyName))
-        return getOwnPropertySlotByIndex(object, exec, index.value(), slot);
+        return getOwnPropertySlotByIndex(object, state, index.value(), slot);
 
     auto* thisObject = jsCast<JSDOMWindow*>(object);
     auto* frame = thisObject->wrapped().frame();
 
     // Hand off all cross-domain/frameless access to jsDOMWindowGetOwnPropertySlotRestrictedAccess.
     String errorMessage;
-    if (!frame || !shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), errorMessage))
-        return jsDOMWindowGetOwnPropertySlotRestrictedAccess(thisObject, frame, exec, propertyName, slot, errorMessage);
+    if (!frame || !BindingSecurity::shouldAllowAccessToDOMWindow(*state, thisObject->wrapped(), errorMessage))
+        return jsDOMWindowGetOwnPropertySlotRestrictedAccess(thisObject, frame, state, propertyName, slot, errorMessage);
     
     // FIXME: this need more explanation.
     // (Particularly, is it correct that this exists here but not in getOwnPropertySlotByIndex?)
@@ -184,11 +184,11 @@ bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, Property
 
     // (2) Regular own properties.
     PropertySlot slotCopy = slot;
-    if (Base::getOwnPropertySlot(thisObject, exec, propertyName, slot)) {
+    if (Base::getOwnPropertySlot(thisObject, state, propertyName, slot)) {
         // Detect when we're getting the property 'showModalDialog', this is disabled, and has its original value.
-        bool isShowModalDialogAndShouldHide = propertyName == exec->propertyNames().showModalDialog
+        bool isShowModalDialogAndShouldHide = propertyName == state->propertyNames().showModalDialog
             && !DOMWindow::canShowModalDialog(frame)
-            && slot.isValue() && isHostFunction(slot.getValue(exec, propertyName), jsDOMWindowInstanceFunctionShowModalDialog);
+            && slot.isValue() && isHostFunction(slot.getValue(state, propertyName), jsDOMWindowInstanceFunctionShowModalDialog);
         // Unless we're in the showModalDialog special case, we're done.
         if (!isShowModalDialogAndShouldHide)
             return true;
@@ -196,7 +196,7 @@ bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, Property
     }
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
-    if (propertyName == exec->propertyNames().webkit && thisObject->wrapped().shouldHaveWebKitNamespaceForWorld(thisObject->world())) {
+    if (propertyName == state->propertyNames().webkit && thisObject->wrapped().shouldHaveWebKitNamespaceForWorld(thisObject->world())) {
         slot.setCacheableCustom(thisObject, DontDelete | ReadOnly, jsDOMWindowWebKit);
         return true;
     }
@@ -209,7 +209,7 @@ bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, Property
 // (1) indexed properties,
 // (2) regular own properties,
 // (3) named properties (in fact, these shouldn't be on the window, should be on the NPO).
-bool JSDOMWindow::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot)
+bool JSDOMWindow::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
 {
     auto* thisObject = jsCast<JSDOMWindow*>(object);
     auto* frame = thisObject->wrapped().frame();
@@ -220,22 +220,22 @@ bool JSDOMWindow::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, u
     // (1) First, indexed properties.
     // These are also allowed cross-orgin, so come before the access check.
     if (frame && index < frame->tree().scopedChildCount()) {
-        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, toJS(exec, frame->tree().scopedChild(index)->document()->domWindow()));
+        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, toJS(state, frame->tree().scopedChild(index)->document()->domWindow()));
         return true;
     }
 
     // Hand off all cross-domain/frameless access to jsDOMWindowGetOwnPropertySlotRestrictedAccess.
     String errorMessage;
-    if (!frame || !shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), errorMessage))
-        return jsDOMWindowGetOwnPropertySlotRestrictedAccess(thisObject, frame, exec, Identifier::from(exec, index), slot, errorMessage);
+    if (!frame || !BindingSecurity::shouldAllowAccessToDOMWindow(*state, thisObject->wrapped(), errorMessage))
+        return jsDOMWindowGetOwnPropertySlotRestrictedAccess(thisObject, frame, state, Identifier::from(state, index), slot, errorMessage);
 
     // (2) Regular own properties.
-    return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
+    return Base::getOwnPropertySlotByIndex(thisObject, state, index, slot);
 }
 
-bool JSDOMWindow::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
+bool JSDOMWindow::put(JSCell* cell, ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
 {
-    VM& vm = exec->vm();
+    VM& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     auto* thisObject = jsCast<JSDOMWindow*>(cell);
@@ -243,19 +243,19 @@ bool JSDOMWindow::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
         return false;
 
     String errorMessage;
-    if (!shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), errorMessage)) {
+    if (!BindingSecurity::shouldAllowAccessToDOMWindow(*state, thisObject->wrapped(), errorMessage)) {
         // We only allow setting "location" attribute cross-origin.
-        if (propertyName == exec->propertyNames().location) {
+        if (propertyName == state->propertyNames().location) {
             bool putResult = false;
-            if (lookupPut(exec, propertyName, thisObject, value, *s_info.staticPropHashTable, slot, putResult))
+            if (lookupPut(state, propertyName, thisObject, value, *s_info.staticPropHashTable, slot, putResult))
                 return putResult;
             return false;
         }
-        throwSecurityError(*exec, scope, errorMessage);
+        throwSecurityError(*state, scope, errorMessage);
         return false;
     }
 
-    return Base::put(thisObject, exec, propertyName, value, slot);
+    return Base::put(thisObject, state, propertyName, value, slot);
 }
 
 bool JSDOMWindow::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSValue value, bool shouldThrow)
index 41cb699..74e3eb3 100644 (file)
@@ -44,14 +44,12 @@ using namespace JSC;
 namespace WebCore {
 
 #if ENABLE(WEBGL)
-static void get3DContextAttributes(ExecState& state, RefPtr<CanvasContextAttributes>& attrs)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
 
+static RefPtr<CanvasContextAttributes> attributesFor3DContext(ExecState& state, ThrowScope& scope)
+{
     JSValue initializerValue = state.argument(1);
     if (initializerValue.isUndefinedOrNull())
-        return;
+        return nullptr;
     
     JSObject* initializerObject = initializerValue.toObject(&state);
     ASSERT_UNUSED(scope, !scope.exception());
@@ -67,8 +65,9 @@ static void get3DContextAttributes(ExecState& state, RefPtr<CanvasContextAttribu
     dictionary.tryGetProperty("preserveDrawingBuffer", graphicsAttrs.preserveDrawingBuffer);
     dictionary.tryGetProperty("preferLowPowerToHighPerformance", graphicsAttrs.preferLowPowerToHighPerformance);
 
-    attrs = WebGLContextAttributes::create(graphicsAttrs);
+    return WebGLContextAttributes::create(graphicsAttrs);
 }
+
 #endif
 
 JSValue JSHTMLCanvasElement::getContext(ExecState& state)
@@ -82,15 +81,16 @@ JSValue JSHTMLCanvasElement::getContext(ExecState& state)
     HTMLCanvasElement& canvas = wrapped();
     const String& contextId = state.uncheckedArgument(0).toWTFString(&state);
     
-    RefPtr<CanvasContextAttributes> attrs;
+    RefPtr<CanvasContextAttributes> attributes;
+
 #if ENABLE(WEBGL)
     if (HTMLCanvasElement::is3dType(contextId)) {
-        get3DContextAttributes(state, attrs);
+        attributes = attributesFor3DContext(state, scope);
         RETURN_IF_EXCEPTION(scope, JSValue());
     }
 #endif
     
-    CanvasRenderingContext* context = canvas.getContext(contextId, attrs.get());
+    auto* context = canvas.getContext(contextId, attributes.get());
     if (!context)
         return jsNull();
 
@@ -104,23 +104,25 @@ JSValue JSHTMLCanvasElement::getContext(ExecState& state)
 
 JSValue JSHTMLCanvasElement::toDataURL(ExecState& state)
 {
-    HTMLCanvasElement& canvas = wrapped();
-    ExceptionCode ec = 0;
+    VM& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
 
     auto type = convert<IDLNullable<IDLDOMString>>(state, state.argument(0));
-    double quality;
-    double* qualityPtr = 0;
-    if (state.argumentCount() > 1) {
-        JSValue v = state.uncheckedArgument(1);
-        if (v.isNumber()) {
-            quality = v.toNumber(&state);
-            qualityPtr = &quality;
-        }
+    RETURN_IF_EXCEPTION(scope, JSC::JSValue());
+
+    Optional<double> quality;
+    auto qualityValue = state.argument(1);
+    if (qualityValue.isNumber())
+        quality = qualityValue.toNumber(&state);
+
+    // We would use toJS<IDLString> here, but it uses jsStringWithCache and we historically
+    // did not cache here, presumably because results are likely to be differing long strings.
+    auto result = wrapped().toDataURL(type, quality);
+    if (result.hasException()) {
+        propagateException(state, scope, result.releaseException());
+        return { };
     }
-
-    JSValue result = JSC::jsString(&state, canvas.toDataURL(type, qualityPtr, ec));
-    setDOMException(&state, ec);
-    return result;
+    return jsString(&state, result.releaseReturnValue());
 }
 
 } // namespace WebCore
index dc29905..cdd9be6 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "Document.h"
 #include "HTMLFrameElement.h"
-#include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "JSDOMBinding.h"
 
@@ -39,27 +38,15 @@ using namespace JSC;
 
 namespace WebCore {
 
-using namespace HTMLNames;
-
-static inline bool allowSettingJavascriptURL(ExecState& state, HTMLFrameElement* imp, const String& value)
-{
-    if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value))) {
-        Document* contentDocument = imp->contentDocument();
-        if (contentDocument && !shouldAllowAccessToNode(&state, contentDocument))
-            return false;
-    }
-    return true;
-}
-
 void JSHTMLFrameElement::setLocation(ExecState& state, JSValue value)
 {
-    HTMLFrameElement& imp = wrapped();
+    HTMLFrameElement& element = wrapped();
     String locationValue = value.isNull() ? String() : value.toWTFString(&state);
-
-    if (!allowSettingJavascriptURL(state, &imp, locationValue))
-        return;
-
-    imp.setLocation(locationValue);
+    if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(locationValue))) {
+        if (!BindingSecurity::shouldAllowAccessToNode(state, element.contentDocument()))
+            return;
+    }
+    element.setLocation(locationValue);
 }
 
 } // namespace WebCore
index 0439b4b..e945f61 100644 (file)
@@ -54,29 +54,27 @@ void JSHTMLOptionsCollection::setLength(ExecState& state, JSValue value)
     CustomElementReactionStack customElementReactionStack;
 #endif
 
-    ExceptionCode ec = 0;
-    unsigned newLength = 0;
-    double lengthValue = value.toNumber(&state);
-    if (!std::isnan(lengthValue) && !std::isinf(lengthValue)) {
-        if (lengthValue < 0.0)
-            ec = INDEX_SIZE_ERR;
-        else if (lengthValue > static_cast<double>(UINT_MAX))
-            newLength = UINT_MAX;
-        else
-            newLength = static_cast<unsigned>(lengthValue);
-    }
-    if (!ec)
-        wrapped().setLength(newLength, ec);
-    setDOMException(&state, ec);
+    VM& vm = state.vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    double number = value.toNumber(&state);
+    RETURN_IF_EXCEPTION(throwScope, void());
+    unsigned length;
+    if (!std::isfinite(number))
+        length = 0;
+    else if (number < 0)
+        return setDOMException(&state, throwScope, INDEX_SIZE_ERR);
+    else
+        length = static_cast<unsigned>(std::min<double>(number, UINT_MAX));
+    propagateException(state, throwScope, wrapped().setLength(length));
 }
 
-void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue value)
+void JSHTMLOptionsCollection::indexSetter(ExecState* state, unsigned index, JSValue value)
 {
 #if ENABLE(CUSTOM_ELEMENTS)
     CustomElementReactionStack customElementReactionStack;
 #endif
 
-    selectIndexSetter(&wrapped().selectElement(), exec, index, value);
+    selectElementIndexSetter(*state, wrapped().selectElement(), index, value);
 }
 
 }
index 7348eeb..98b3a8b 100644 (file)
 #include "HTMLOptionElement.h"
 #include "HTMLSelectElement.h"
 #include "JSHTMLOptionElement.h"
+#include "JSHTMLSelectElement.h"
 
 namespace WebCore {
 
 using namespace JSC;
 using namespace HTMLNames;
 
-void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue value)
+void selectElementIndexSetter(JSC::ExecState& state, HTMLSelectElement& element, unsigned index, JSC::JSValue value)
 {
-    if (value.isUndefinedOrNull())
-        select->removeByIndex(index);
-    else {
-        ExceptionCode ec = 0;
-        HTMLOptionElement* option = JSHTMLOptionElement::toWrapped(value);
-        if (!option)
-            ec = TYPE_MISMATCH_ERR;
-        else
-            select->setOption(index, *option, ec);
-        setDOMException(exec, ec);
+    VM& vm = state.vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+    if (value.isUndefinedOrNull()) {
+        element.removeByIndex(index);
+        return;
+    }
+
+    auto* option = JSHTMLOptionElement::toWrapped(value);
+    if (!option) {
+        setDOMException(&state, throwScope, TYPE_MISMATCH_ERR);
+        return;
     }
+
+    propagateException(state, throwScope, element.setOption(index, *option));
 }
 
-void JSHTMLSelectElement::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
+void JSHTMLSelectElement::indexSetter(JSC::ExecState* state, unsigned index, JSC::JSValue value)
 {
 #if ENABLE(CUSTOM_ELEMENTS)
     CustomElementReactionStack customElementReactionStack;
 #endif
-    selectIndexSetter(&wrapped(), exec, index, value);
+
+    selectElementIndexSetter(*state, wrapped(), index, value);
 }
 
 }
index 8e2d523..e012bcc 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  
-#ifndef JSHTMLSelectElementCustom_h
-#define JSHTMLSelectElementCustom_h
+#pragma once
 
-#include "JSHTMLSelectElement.h"
+namespace JSC {
+class ExecState;
+class JSValue;
+}
 
 namespace WebCore {
 
-void selectIndexSetter(HTMLSelectElement*, JSC::ExecState*, unsigned index, JSC::JSValue);
+class HTMLSelectElement;
 
-}
+void selectElementIndexSetter(JSC::ExecState&, HTMLSelectElement&, unsigned index, JSC::JSValue);
 
-#endif
+}
index 7f3f5a4..a342584 100644 (file)
@@ -31,9 +31,9 @@ using namespace JSC;
 
 namespace WebCore {
 
-bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool JSLocation::getOwnPropertySlotDelegate(ExecState* state, PropertyName propertyName, PropertySlot& slot)
 {
-    VM& vm = exec->vm();
+    VM& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     Frame* frame = wrapped().frame();
@@ -48,53 +48,51 @@ bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, PropertyName proper
     // Our custom code is only needed to implement the Window cross-domain scheme, so if access is
     // allowed, return false so the normal lookup will take place.
     String message;
-    if (shouldAllowAccessToFrame(exec, frame, message))
+    if (BindingSecurity::shouldAllowAccessToFrame(*state, *frame, message))
         return false;
 
     // We only allow access to Location.replace() cross origin.
-    if (propertyName == exec->propertyNames().replace) {
+    if (propertyName == state->propertyNames().replace) {
         slot.setCustom(this, ReadOnly | DontEnum, nonCachingStaticFunctionGetter<jsLocationInstanceFunctionReplace, 1>);
         return true;
     }
 
     // Getting location.href cross origin needs to throw. However, getOwnPropertyDescriptor() needs to return
     // a descriptor that has a setter but no getter.
-    if (slot.internalMethodType() == PropertySlot::InternalMethodType::GetOwnProperty && propertyName == exec->propertyNames().href) {
+    if (slot.internalMethodType() == PropertySlot::InternalMethodType::GetOwnProperty && propertyName == state->propertyNames().href) {
         auto* entry = JSLocation::info()->staticPropHashTable->entry(propertyName);
         CustomGetterSetter* customGetterSetter = CustomGetterSetter::create(vm, nullptr, entry->propertyPutter());
         slot.setCustomGetterSetter(this, DontEnum | CustomAccessor, customGetterSetter);
         return true;
     }
 
-    throwSecurityError(*exec, scope, message);
+    throwSecurityError(*state, scope, message);
     slot.setUndefined();
     return true;
 }
 
-bool JSLocation::putDelegate(ExecState* exec, PropertyName propertyName, JSValue, PutPropertySlot&, bool& putResult)
+bool JSLocation::putDelegate(ExecState* state, PropertyName propertyName, JSValue, PutPropertySlot&, bool& putResult)
 {
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
     putResult = false;
+
     Frame* frame = wrapped().frame();
     if (!frame)
         return true;
 
-    if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
+    // Silently block access to toString and valueOf.
+    if (propertyName == state->propertyNames().toString || propertyName == state->propertyNames().valueOf)
         return true;
 
-    String errorMessage;
-    if (shouldAllowAccessToFrame(exec, frame, errorMessage))
+    // Always allow assigning to the whole location.
+    // However, alllowing assigning of pieces might inadvertently disclose parts of the original location.
+    // So fall through to the access check for those.
+    if (propertyName == state->propertyNames().href)
         return false;
 
-    // Cross-domain access to the location is allowed when assigning the whole location,
-    // but not when assigning the individual pieces, since that might inadvertently
-    // disclose other parts of the original location.
-    if (propertyName != exec->propertyNames().href) {
-        throwSecurityError(*exec, scope, errorMessage);
+    // Block access and throw if there is a security error.
+    if (!BindingSecurity::shouldAllowAccessToFrame(state, frame, ThrowSecurityError))
         return true;
-    }
+
     return false;
 }
 
index 9a20030..879e952 100644 (file)
@@ -298,14 +298,15 @@ bool ScriptController::processingUserGestureForMedia()
     return UserGestureIndicator::processingUserGestureForMedia();
 }
 
-bool ScriptController::canAccessFromCurrentOrigin(Frame *frame)
+bool ScriptController::canAccessFromCurrentOrigin(Frameframe)
 {
-    ExecState* exec = JSMainThreadExecState::currentState();
-    if (exec)
-        return shouldAllowAccessToFrame(exec, frame);
-    // If the current state is 0 we're in a call path where the DOM security 
-    // check doesn't apply (eg. parser).
-    return true;
+    ExecState* state = JSMainThreadExecState::currentState();
+
+    // If the current state is null we're in a call path where the DOM security check doesn't apply (eg. parser).
+    if (!state)
+        return true;
+
+    return BindingSecurity::shouldAllowAccessToFrame(state, frame);
 }
 
 void ScriptController::attachDebugger(JSC::Debugger* debugger)
index 4c9a7f0..0476e16 100644 (file)
@@ -3228,10 +3228,6 @@ sub GenerateImplementation
 
             if (HasCustomGetter($attribute->signature->extendedAttributes)) {
                 push(@implContent, "    return thisObject.$implGetterFunctionName(state);\n");
-            } elsif ($attribute->signature->extendedAttributes->{CheckSecurityForNode}) {
-                $implIncludes{"JSDOMBinding.h"} = 1;
-                push(@implContent, "    auto& impl = thisObject.wrapped();\n");
-                push(@implContent, "    return shouldAllowAccessToNode(&state, impl." . $attribute->signature->name . "()) ? " . NativeToJSValueUsingReferences($attribute->signature, 0, $interface, "impl.$implGetterFunctionName()", "thisObject") . " : jsNull();\n");
             } elsif ($type->name eq "EventHandler") {
                 $implIncludes{"EventNames.h"} = 1;
                 my $getter = $attribute->signature->extendedAttributes->{WindowEventHandler} ? "windowEventHandlerAttribute"
@@ -3839,12 +3835,6 @@ END
 
                     push(@implContent, "    ExceptionCode ec = 0;\n") if $mayThrowLegacyException;
 
-                    if ($function->signature->extendedAttributes->{CheckSecurityForNode}) {
-                        push(@implContent, "    if (!shouldAllowAccessToNode(state, impl." . $function->signature->name . "(" . ($mayThrowLegacyException ? "ec" : "") .")))\n");
-                        push(@implContent, "        return JSValue::encode(jsNull());\n");
-                        $implIncludes{"JSDOMBinding.h"} = 1;
-                    }
-
                     my ($functionString, $dummy) = GenerateParametersCheck(\@implContent, $function, $interface, $functionImplementationName, $svgPropertyType, $svgPropertyOrListPropertyType, $svgListPropertyType);
                     GenerateImplementationFunctionCall($function, $functionString, "    ", $svgPropertyType, $interface);
                 }
@@ -5482,6 +5472,8 @@ sub NativeToJSValue
         }
     }
 
+    $value = "BindingSecurity::checkSecurityForNode($stateReference, $value)" if $signature->extendedAttributes->{CheckSecurityForNode};
+
     my $functionName = "toJS";
     $functionName = "toJSNewlyCreated" if $signature->extendedAttributes->{NewObject};
 
index 129a24a..9e28f2a 100644 (file)
@@ -2954,7 +2954,8 @@ static inline JSValue jsTestObjContentDocumentGetter(ExecState& state, JSTestObj
     UNUSED_PARAM(throwScope);
     UNUSED_PARAM(state);
     auto& impl = thisObject.wrapped();
-    return shouldAllowAccessToNode(&state, impl.contentDocument()) ? toJS(&state, thisObject.globalObject(), impl.contentDocument()) : jsNull();
+    JSValue result = toJS(&state, thisObject.globalObject(), BindingSecurity::checkSecurityForNode(state, impl.contentDocument()));
+    return result;
 }
 
 static inline JSValue jsTestObjMutablePointGetter(ExecState&, JSTestObj&, ThrowScope& throwScope);
@@ -7578,9 +7579,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionGetSVGDocumentCaller
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
-    if (!shouldAllowAccessToNode(state, impl.getSVGDocument(ec)))
-        return JSValue::encode(jsNull());
-    JSValue result = toJS(state, castedThis->globalObject(), impl.getSVGDocument(ec));
+    JSValue result = toJS(state, castedThis->globalObject(), BindingSecurity::checkSecurityForNode(*state, impl.getSVGDocument(ec)));
 
     setDOMException(state, throwScope, ec);
     return JSValue::encode(result);
index ca1401a..fc5d85e 100644 (file)
@@ -25,5 +25,5 @@
     [CEReactions, Unscopable, MayThrowLegacyException] void before((Node or DOMString)... nodes);
     [CEReactions, Unscopable, MayThrowLegacyException] void after((Node or DOMString)... nodes);
     [CEReactions, Unscopable, MayThrowLegacyException] void replaceWith((Node or DOMString)... nodes);
-    [CEReactions, Unscopable, MayThrowLegacyException] void remove();
+    [CEReactions, Unscopable, MayThrowException] void remove();
 };
index e7922aa..bd79073 100644 (file)
@@ -2535,9 +2535,9 @@ void Element::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
     EventDispatcher::dispatchEvent(this, FocusEvent::create(eventNames().blurEvent, false, false, document().defaultView(), 0, WTFMove(newFocusedElement)));
 }
 
-#if ENABLE(MOUSE_FORCE_EVENTS)
 bool Element::dispatchMouseForceWillBegin()
 {
+#if ENABLE(MOUSE_FORCE_EVENTS)
     if (!document().hasListenerType(Document::FORCEWILLBEGIN_LISTENER))
         return false;
 
@@ -2545,32 +2545,29 @@ bool Element::dispatchMouseForceWillBegin()
     if (!frame)
         return false;
 
-    PlatformMouseEvent platformMouseEvent(frame->eventHandler().lastKnownMousePosition(), frame->eventHandler().lastKnownMouseGlobalPosition(), NoButton, PlatformEvent::NoType, 1, false, false, false, false, WTF::currentTime(), ForceAtClick, NoTap);
-    Ref<MouseEvent> mouseForceWillBeginEvent =  MouseEvent::create(eventNames().webkitmouseforcewillbeginEvent, document().defaultView(), platformMouseEvent, 0, nullptr);
+    PlatformMouseEvent platformMouseEvent { frame->eventHandler().lastKnownMousePosition(), frame->eventHandler().lastKnownMouseGlobalPosition(), NoButton, PlatformEvent::NoType, 1, false, false, false, false, WTF::currentTime(), ForceAtClick, NoTap };
+    auto mouseForceWillBeginEvent = MouseEvent::create(eventNames().webkitmouseforcewillbeginEvent, document().defaultView(), platformMouseEvent, 0, nullptr);
     mouseForceWillBeginEvent->setTarget(this);
     dispatchEvent(mouseForceWillBeginEvent);
 
     if (mouseForceWillBeginEvent->defaultHandled() || mouseForceWillBeginEvent->defaultPrevented())
         return true;
+#endif
+
     return false;
 }
-#else
-bool Element::dispatchMouseForceWillBegin()
-{
-    return false;
-}
-#endif // #if ENABLE(MOUSE_FORCE_EVENTS)
 
 void Element::mergeWithNextTextNode(Text& node, ExceptionCode& ec)
 {
-    Node* next = node.nextSibling();
+    auto* next = node.nextSibling();
     if (!is<Text>(next))
         return;
+    Ref<Text> textNext { downcast<Text>(*next) };
 
-    Ref<Text> textNode(node);
-    Ref<Text> textNext(downcast<Text>(*next));
-    textNode->appendData(textNext->data());
-    textNext->remove(ec);
+    node.appendData(textNext->data());
+    auto result = textNext->remove();
+    if (result.hasException())
+        ec = result.releaseException().code();
 }
 
 String Element::innerHTML() const
@@ -2594,11 +2591,13 @@ void Element::setOuterHTML(const String& html, ExceptionCode& ec)
     RefPtr<Node> prev = previousSibling();
     RefPtr<Node> next = nextSibling();
 
-    RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(*parent, html, AllowScriptingContent, ec);
-    if (ec)
+    auto fragment = createFragmentForInnerOuterHTML(*parent, html, AllowScriptingContent);
+    if (fragment.hasException()) {
+        ec = fragment.releaseException().code();
         return;
+    }
     
-    parent->replaceChild(*fragment, *this, ec);
+    parent->replaceChild(fragment.releaseReturnValue().get(), *this, ec);
     RefPtr<Node> node = next ? next->previousSibling() : nullptr;
     if (!ec && is<Text>(node.get()))
         mergeWithNextTextNode(downcast<Text>(*node), ec);
@@ -2609,14 +2608,21 @@ void Element::setOuterHTML(const String& html, ExceptionCode& ec)
 
 void Element::setInnerHTML(const String& html, ExceptionCode& ec)
 {
-    if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(*this, html, AllowScriptingContent, ec)) {
-        ContainerNode* container = this;
+    auto fragment = createFragmentForInnerOuterHTML(*this, html, AllowScriptingContent);
+    if (fragment.hasException()) {
+        ec = fragment.releaseException().code();
+        return;
+    }
 
-        if (is<HTMLTemplateElement>(*this))
-            container = &downcast<HTMLTemplateElement>(*this).content();
+    ContainerNode* container;
+    if (!is<HTMLTemplateElement>(*this))
+        container = this;
+    else
+        container = &downcast<HTMLTemplateElement>(*this).content();
 
-        replaceChildrenWithFragment(*container, fragment.releaseNonNull(), ec);
-    }
+    auto result = replaceChildrenWithFragment(*container, fragment.releaseReturnValue());
+    if (result.hasException())
+        ec = fragment.releaseException().code();
 }
 
 String Element::innerText()
@@ -3747,11 +3753,13 @@ void Element::insertAdjacentHTML(const String& where, const String& markup, Exce
     } else
         contextElement = downcast<Element>(contextNode);
     // Step 3.
-    RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(*contextElement, markup, AllowScriptingContent, ec);
-    if (!fragment)
+    auto fragment = createFragmentForInnerOuterHTML(*contextElement, markup, AllowScriptingContent);
+    if (fragment.hasException()) {
+        ec = fragment.releaseException().code();
         return;
+    }
     // Step 4.
-    insertAdjacent(where, fragment.releaseNonNull(), ec);
+    insertAdjacent(where, fragment.releaseReturnValue(), ec);
 }
 
 void Element::insertAdjacentText(const String& where, const String& text, ExceptionCode& ec)
index ef55df7..a00f9d3 100644 (file)
@@ -551,10 +551,16 @@ void Node::replaceWith(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode&
         parent->insertBefore(*node, viableNextSibling.get(), ec);
 }
 
-void Node::remove(ExceptionCode& ec)
+ExceptionOr<void> Node::remove()
 {
-    if (ContainerNode* parent = parentNode())
-        parent->removeChild(*this, ec);
+    auto* parent = parentNode();
+    if (!parent)
+        return { };
+    ExceptionCode ec = 0;
+    parent->removeChild(*this, ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
 void Node::normalize()
@@ -584,7 +590,7 @@ void Node::normalize()
         if (!text->length()) {
             // Care must be taken to get the next node before removing the current node.
             node = NodeTraversal::nextPostOrder(*node);
-            text->remove(IGNORE_EXCEPTION);
+            text->remove();
             continue;
         }
 
@@ -596,7 +602,7 @@ void Node::normalize()
 
             // Remove empty text nodes.
             if (!nextText->length()) {
-                nextText->remove(IGNORE_EXCEPTION);
+                nextText->remove();
                 continue;
             }
 
@@ -604,7 +610,7 @@ void Node::normalize()
             unsigned offset = text->length();
             text->appendData(nextText->data());
             document().textNodesMerged(nextText.get(), offset);
-            nextText->remove(IGNORE_EXCEPTION);
+            nextText->remove();
         }
 
         node = NodeTraversal::nextPostOrder(*node);
index ba7669c..ec85e0b 100644 (file)
 #pragma once
 
 #include "EventTarget.h"
-#include "URLHash.h"
+#include "ExceptionOr.h"
 #include "LayoutRect.h"
 #include "MutationObserver.h"
 #include "RenderStyleConstants.h"
 #include "StyleValidity.h"
 #include "TreeScope.h"
+#include "URLHash.h"
 #include <wtf/Forward.h>
 #include <wtf/ListHashSet.h>
 #include <wtf/MainThread.h>
@@ -195,7 +196,7 @@ public:
     void before(Vector<NodeOrString>&&, ExceptionCode&);
     void after(Vector<NodeOrString>&&, ExceptionCode&);
     void replaceWith(Vector<NodeOrString>&&, ExceptionCode&);
-    WEBCORE_EXPORT void remove(ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> remove();
 
     // Other methods (not part of DOM)
 
index 940e7fd..b0135cc 100644 (file)
@@ -853,9 +853,11 @@ void Range::insertNode(Ref<Node>&& node, ExceptionCode& ec)
     if (referenceNode == node.ptr())
         referenceNode = referenceNode->nextSibling();
 
-    node->remove(ec);
-    if (ec)
+    auto removeResult = node->remove();
+    if (removeResult.hasException()) {
+        ec = removeResult.releaseException().code();
         return;
+    }
 
     unsigned newOffset = referenceNode ? referenceNode->computeNodeIndex() : parent->countChildNodes();
     if (is<DocumentFragment>(node.get()))
@@ -918,7 +920,12 @@ RefPtr<DocumentFragment> Range::createContextualFragment(const String& markup, E
     if (!element || (is<HTMLDocument>(element->document()) && is<HTMLHtmlElement>(*element)))
         element = HTMLBodyElement::create(node.document());
 
-    return WebCore::createContextualFragment(*element, markup, AllowScriptingContentAndDoNotMarkAlreadyStarted, ec);
+    auto result = WebCore::createContextualFragment(*element, markup, AllowScriptingContentAndDoNotMarkAlreadyStarted);
+    if (result.hasException()) {
+        ec = result.releaseException().code();
+        return nullptr;
+    }
+    return result.releaseReturnValue();
 }
 
 
index dd03c68..399a787 100644 (file)
@@ -113,8 +113,14 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec)
         return;
     }
 
-    if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(*host(), markup, AllowScriptingContent, ec))
-        replaceChildrenWithFragment(*this, fragment.releaseNonNull(), ec);
+    auto fragment = createFragmentForInnerOuterHTML(*host(), markup, AllowScriptingContent);
+    if (fragment.hasException()) {
+        ec = fragment.releaseException().code();
+        return;
+    }
+    auto result = replaceChildrenWithFragment(*this, fragment.releaseReturnValue());
+    if (result.hasException())
+        ec = result.releaseException().code();
 }
 
 bool ShadowRoot::childTypeAllowed(NodeType type) const
index 1e19ce0..04814ea 100644 (file)
@@ -59,7 +59,7 @@ void AppendNodeCommand::doUnapply()
     if (!m_parent->hasEditableStyle())
         return;
 
-    m_node->remove(IGNORE_EXCEPTION);
+    m_node->remove();
 }
 
 #ifndef NDEBUG
index 8e8ed7b..57e6ca2 100644 (file)
 #include "markup.h"
 #include <wtf/unicode/CharacterNames.h>
 
-#if PLATFORM(IOS)
-#include "DictationCommandIOS.h"
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
-#endif
-
 #if PLATFORM(MAC)
 #include "ServicesOverlayController.h"
 #endif
@@ -241,17 +235,13 @@ bool Editor::handleTextEvent(TextEvent& event)
         return false;
 
     if (event.isPaste()) {
-        if (event.pastingFragment())
+        if (event.pastingFragment()) {
 #if PLATFORM(IOS)
-        {
             if (client()->performsTwoStepPaste(event.pastingFragment()))
                 return true;
 #endif
             replaceSelectionWithFragment(event.pastingFragment(), false, event.shouldSmartReplace(), event.shouldMatchStyle(), EditActionPaste, event.mailBlockquoteHandling());
-#if PLATFORM(IOS)
-        }
-#endif
-        else 
+        } else
             replaceSelectionWithText(event.data(), false, event.shouldSmartReplace(), EditActionPaste);
         return true;
     }
@@ -424,76 +414,6 @@ void Editor::clearText()
     ClearTextCommand::CreateAndApply(&m_frame);
 }
 
-#if PLATFORM(IOS)
-
-void Editor::insertDictationPhrases(Vector<Vector<String>>&& dictationPhrases, RetainPtr<id> metadata)
-{
-    if (m_frame.selection().isNone())
-        return;
-
-    if (dictationPhrases.isEmpty())
-        return;
-
-    applyCommand(DictationCommandIOS::create(document(), WTFMove(dictationPhrases), WTFMove(metadata)));
-}
-
-void Editor::setDictationPhrasesAsChildOfElement(const Vector<Vector<String>>& dictationPhrases, RetainPtr<id> metadata, Element& element)
-{
-    // Clear the composition.
-    clear();
-    
-    // Clear the Undo stack, since the operations that follow are not Undoable, and will corrupt the stack.  Some day
-    // we could make them Undoable, and let callers clear the Undo stack explicitly if they wish.
-    clearUndoRedoOperations();
-    
-    m_frame.selection().clear();
-    
-    element.removeChildren();
-    
-    if (dictationPhrases.isEmpty()) {
-        client()->respondToChangedContents();
-        return;
-    }
-    
-    ExceptionCode ec;    
-    RefPtr<Range> context = document().createRange();
-    context->selectNodeContents(element, ec);
-
-    StringBuilder dictationPhrasesBuilder;
-    for (auto& interpretations : dictationPhrases)
-        dictationPhrasesBuilder.append(interpretations[0]);
-
-    element.appendChild(createFragmentFromText(*context, dictationPhrasesBuilder.toString()), ec);
-
-    // We need a layout in order to add markers below.
-    document().updateLayout();
-
-    if (!element.firstChild()->isTextNode()) {
-        // Shouldn't happen.
-        ASSERT(element.firstChild()->isTextNode());
-        return;
-    }
-
-    Text& textNode = downcast<Text>(*element.firstChild());
-    int previousDictationPhraseStart = 0;
-    for (auto& interpretations : dictationPhrases) {
-        int dictationPhraseLength = interpretations[0].length();
-        int dictationPhraseEnd = previousDictationPhraseStart + dictationPhraseLength;
-        if (interpretations.size() > 1) {
-            auto dictationPhraseRange = Range::create(document(), &textNode, previousDictationPhraseStart, &textNode, dictationPhraseEnd);
-            document().markers().addDictationPhraseWithAlternativesMarker(dictationPhraseRange.ptr(), interpretations);
-        }
-        previousDictationPhraseStart = dictationPhraseEnd;
-    }
-
-    auto resultRange = Range::create(document(), &textNode, 0, &textNode, textNode.length());
-    document().markers().addDictationResultMarker(resultRange.ptr(), metadata);
-
-    client()->respondToChangedContents();
-}
-
-#endif
-
 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace)
 {
     Node* target = findEventTargetFromSelection();
@@ -616,85 +536,6 @@ RefPtr<Range> Editor::selectedRange()
     return m_frame.selection().toNormalizedRange();
 }
 
-#if PLATFORM(IOS)
-void Editor::confirmMarkedText()
-{
-    // FIXME: This is a hacky workaround for the keyboard calling this method too late -
-    // after the selection and focus have already changed.  See <rdar://problem/5975559>
-    Element* focused = document().focusedElement();
-    Node* composition = compositionNode();
-    
-    if (composition && focused && focused != composition && !composition->isDescendantOrShadowDescendantOf(focused)) {
-        cancelComposition();
-        document().setFocusedElement(focused);
-    } else
-        confirmComposition();
-}
-
-void Editor::setTextAsChildOfElement(const String& text, Element& element)
-{
-    // Clear the composition
-    clear();
-    
-    // Clear the Undo stack, since the operations that follow are not Undoable, and will corrupt the stack.  Some day
-    // we could make them Undoable, and let callers clear the Undo stack explicitly if they wish.
-    clearUndoRedoOperations();
-    
-    // If the element is empty already and we're not adding text, we can early return and avoid clearing/setting
-    // a selection at [0, 0] and the expense involved in creation VisiblePositions.
-    if (!element.firstChild() && text.isEmpty())
-        return;
-    
-    // As a side effect this function sets a caret selection after the inserted content.  Much of what 
-    // follows is more expensive if there is a selection, so clear it since it's going to change anyway.
-    m_frame.selection().clear();
-    
-    // clear out all current children of element
-    element.removeChildren();
-
-    if (text.length()) {
-        // insert new text
-        // remove element from tree while doing it
-        // 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)
-            element.remove(ec);
-            
-        auto context = document().createRange();
-        context->selectNodeContents(element, ec);
-        element.appendChild(createFragmentFromText(context, text), ec);
-    
-        // restore element to document
-        if (parent) {
-            if (siblingAfter)
-                parent->insertBefore(element, siblingAfter.get(), ec);
-            else
-                parent->appendChild(element, ec);
-        }
-    }
-
-    // set the selection to the end
-    VisibleSelection selection;
-
-    Position pos = createLegacyEditingPosition(&element, element.countChildNodes());
-
-    VisiblePosition visiblePos(pos, VP_DEFAULT_AFFINITY);
-    if (visiblePos.isNull())
-        return;
-
-    selection.setBase(visiblePos);
-    selection.setExtent(visiblePos);
-     
-    m_frame.selection().setSelection(selection);
-    
-    client()->respondToChangedContents();
-}
-#endif
-
 bool Editor::shouldDeleteRange(Range* range) const
 {
     if (!range || range->collapsed())
@@ -884,14 +725,6 @@ void Editor::clearLastEditCommand()
 {
     m_lastEditCommand = nullptr;
 }
-#if PLATFORM(IOS)
-// If the selection is adjusted from UIKit without closing the typing, the typing command may
-// have a stale selection.
-void Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping()
-{
-    TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping(&m_frame, m_frame.selection().selection());
-}
-#endif
 
 // Returns whether caller should continue with "the default processing", which is the same as 
 // the event handler NOT setting the return value to false
@@ -1497,6 +1330,7 @@ void Editor::copyURL(const URL& url, const String& title, Pasteboard& pasteboard
 }
 
 #if !PLATFORM(IOS)
+
 void Editor::copyImage(const HitTestResult& result)
 {
     Element* element = result.innerNonSharedElement();
@@ -1513,6 +1347,7 @@ void Editor::copyImage(const HitTestResult& result)
     Pasteboard::createForCopyAndPaste()->writeImage(*element, url, result.altDisplayString());
 #endif
 }
+
 #endif
 
 bool Editor::isContinuousSpellCheckingEnabled() const
@@ -2006,6 +1841,7 @@ void Editor::learnSpelling()
 }
 
 #if !PLATFORM(IOS)
+
 void Editor::advanceToNextMisspelling(bool startBeforeSelection)
 {
     // The basic approach is to search in two phases - from the selection end to the end of the doc, and
@@ -2181,6 +2017,7 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection)
         document().markers().addMarker(misspellingRange.get(), DocumentMarker::Spelling);
     }
 }
+
 #endif // !PLATFORM(IOS)
 
 String Editor::misspelledWordAtCaretOrRange(Node* clickedNode) const
index de653d6..d4587da 100644 (file)
@@ -63,7 +63,7 @@ void InsertNodeBeforeCommand::doUnapply()
     if (!isEditableNode(*m_insertChild))
         return;
 
-    m_insertChild->remove(IGNORE_EXCEPTION);
+    m_insertChild->remove();
 }
 
 #ifndef NDEBUG
index 6184de8..55d172e 100644 (file)
@@ -54,7 +54,7 @@ void MergeIdenticalElementsCommand::doApply()
     for (auto& child : children)
         m_element2->insertBefore(child, m_atChild.get(), IGNORE_EXCEPTION);
 
-    m_element1->remove(IGNORE_EXCEPTION);
+    m_element1->remove();
 }
 
 void MergeIdenticalElementsCommand::doUnapply()
index 95da884..01e6ff4 100644 (file)
@@ -52,7 +52,7 @@ void RemoveNodeCommand::doApply()
     m_parent = parent;
     m_refChild = m_node->nextSibling();
 
-    m_node->remove(IGNORE_EXCEPTION);
+    m_node->remove();
 }
 
 void RemoveNodeCommand::doUnapply()
index 9f989ce..c328727 100644 (file)
@@ -93,7 +93,7 @@ void SplitElementCommand::doUnapply()
     if (!id.isNull())
         m_element2->setIdAttribute(id);
 
-    m_element1->remove(IGNORE_EXCEPTION);
+    m_element1->remove();
 }
 
 void SplitElementCommand::doReapply()
index 6999139..a0b9c44 100644 (file)
@@ -77,7 +77,7 @@ void SplitTextNodeCommand::doUnapply()
     m_text2->insertData(0, prefixText, ASSERT_NO_EXCEPTION);
 
     document().markers().copyMarkers(m_text1.get(), 0, prefixText.length(), m_text2.get(), 0);
-    m_text1->remove(ASSERT_NO_EXCEPTION);
+    m_text1->remove();
 }
 
 void SplitTextNodeCommand::doReapply()
index 608a3c3..a1ab245 100644 (file)
@@ -68,7 +68,7 @@ void WrapContentsInDummySpanCommand::doUnapply()
     for (auto& child : children)
         m_element->appendChild(child, IGNORE_EXCEPTION);
 
-    m_dummySpan->remove(IGNORE_EXCEPTION);
+    m_dummySpan->remove();
 }
 
 void WrapContentsInDummySpanCommand::doReapply()
index 4afe13d..d18795b 100644 (file)
 #import "CachedImage.h"
 #import "CachedResourceLoader.h"
 #import "DataTransfer.h"
+#import "DictationCommandIOS.h"
 #import "DocumentFragment.h"
 #import "DocumentLoader.h"
+#import "DocumentMarkerController.h"
 #import "EditorClient.h"
 #import "FontCascade.h"
 #import "Frame.h"
@@ -60,6 +62,7 @@
 #import "markup.h"
 #import <MobileCoreServices/MobileCoreServices.h>
 #import <wtf/BlockObjCExceptions.h>
+#include <wtf/text/StringBuilder.h>
 
 SOFT_LINK_FRAMEWORK(AppSupport)
 SOFT_LINK(AppSupport, CPSharedResourcesDirectory, CFStringRef, (void), ())
@@ -173,7 +176,7 @@ const Font* Editor::fontForSelection(bool& hasMultipleFonts) const
         if (style) {
             result = &style->fontCascade().primaryFont();
             if (nodeToRemove)
-                nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+                nodeToRemove->remove();
         }
 
         return result;
@@ -219,7 +222,7 @@ NSDictionary* Editor::fontAttributesForSelectionStart() const
     getTextDecorationAttributesRespectingTypingStyle(*style, result);
 
     if (nodeToRemove)
-        nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+        nodeToRemove->remove();
     
     return result;
 }
@@ -603,4 +606,153 @@ void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributed
     }
 }
 
+void Editor::insertDictationPhrases(Vector<Vector<String>>&& dictationPhrases, RetainPtr<id> metadata)
+{
+    if (m_frame.selection().isNone())
+        return;
+
+    if (dictationPhrases.isEmpty())
+        return;
+
+    applyCommand(DictationCommandIOS::create(document(), WTFMove(dictationPhrases), WTFMove(metadata)));
+}
+
+void Editor::setDictationPhrasesAsChildOfElement(const Vector<Vector<String>>& dictationPhrases, RetainPtr<id> metadata, Element& element)
+{
+    // Clear the composition.
+    clear();
+
+    // Clear the Undo stack, since the operations that follow are not Undoable, and will corrupt the stack.
+    // Some day we could make them Undoable, and let callers clear the Undo stack explicitly if they wish.
+    clearUndoRedoOperations();
+
+    m_frame.selection().clear();
+
+    element.removeChildren();
+
+    if (dictationPhrases.isEmpty()) {
+        client()->respondToChangedContents();
+        return;
+    }
+
+    ExceptionCode ec;
+    RefPtr<Range> context = document().createRange();
+    context->selectNodeContents(element, ec);
+
+    StringBuilder dictationPhrasesBuilder;
+    for (auto& interpretations : dictationPhrases)
+        dictationPhrasesBuilder.append(interpretations[0]);
+
+    element.appendChild(createFragmentFromText(*context, dictationPhrasesBuilder.toString()), ec);
+
+    // We need a layout in order to add markers below.
+    document().updateLayout();
+
+    if (!element.firstChild()->isTextNode()) {
+        // Shouldn't happen.
+        ASSERT(element.firstChild()->isTextNode());
+        return;
+    }
+
+    Text& textNode = downcast<Text>(*element.firstChild());
+    int previousDictationPhraseStart = 0;
+    for (auto& interpretations : dictationPhrases) {
+        int dictationPhraseLength = interpretations[0].length();
+        int dictationPhraseEnd = previousDictationPhraseStart + dictationPhraseLength;
+        if (interpretations.size() > 1) {
+            auto dictationPhraseRange = Range::create(document(), &textNode, previousDictationPhraseStart, &textNode, dictationPhraseEnd);
+            document().markers().addDictationPhraseWithAlternativesMarker(dictationPhraseRange.ptr(), interpretations);
+        }
+        previousDictationPhraseStart = dictationPhraseEnd;
+    }
+
+    auto resultRange = Range::create(document(), &textNode, 0, &textNode, textNode.length());
+    document().markers().addDictationResultMarker(resultRange.ptr(), metadata);
+
+    client()->respondToChangedContents();
+}
+
+void Editor::confirmMarkedText()
+{
+    // FIXME: This is a hacky workaround for the keyboard calling this method too late -
+    // after the selection and focus have already changed. See <rdar://problem/5975559>.
+    Element* focused = document().focusedElement();
+    Node* composition = compositionNode();
+    if (composition && focused && focused != composition && !composition->isDescendantOrShadowDescendantOf(focused)) {
+        cancelComposition();
+        document().setFocusedElement(focused);
+    } else
+        confirmComposition();
+}
+
+void Editor::setTextAsChildOfElement(const String& text, Element& element)
+{
+    // Clear the composition
+    clear();
+
+    // Clear the Undo stack, since the operations that follow are not Undoable, and will corrupt the stack.
+    // Some day we could make them Undoable, and let callers clear the Undo stack explicitly if they wish.
+    clearUndoRedoOperations();
+
+    // If the element is empty already and we're not adding text, we can early return and avoid clearing/setting
+    // a selection at [0, 0] and the expense involved in creation VisiblePositions.
+    if (!element.firstChild() && text.isEmpty())
+        return;
+
+    // As a side effect this function sets a caret selection after the inserted content. Much of what
+    // follows is more expensive if there is a selection, so clear it since it's going to change anyway.
+    m_frame.selection().clear();
+
+    // clear out all current children of element
+    element.removeChildren();
+
+    if (text.length()) {
+        // insert new text
+        // remove element from tree while doing it
+        // 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)
+            element.remove();
+
+        auto context = document().createRange();
+        context->selectNodeContents(element, ec);
+        element.appendChild(createFragmentFromText(context, text), ec);
+
+        // restore element to document
+        if (parent) {
+            if (siblingAfter)
+                parent->insertBefore(element, siblingAfter.get(), ec);
+            else
+                parent->appendChild(element, ec);
+        }
+    }
+
+    // set the selection to the end
+    VisibleSelection selection;
+
+    Position pos = createLegacyEditingPosition(&element, element.countChildNodes());
+
+    VisiblePosition visiblePos(pos, VP_DEFAULT_AFFINITY);
+    if (visiblePos.isNull())
+        return;
+
+    selection.setBase(visiblePos);
+    selection.setExtent(visiblePos);
+
+    m_frame.selection().setSelection(selection);
+
+    client()->respondToChangedContents();
+}
+
+// If the selection is adjusted from UIKit without closing the typing, the typing command may
+// have a stale selection.
+void Editor::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping()
+{
+    TypingCommand::ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping(&m_frame, m_frame.selection().selection());
+}
+
 } // namespace WebCore
index 75db2eb..7b185ae 100644 (file)
@@ -114,7 +114,7 @@ const Font* Editor::fontForSelection(bool& hasMultipleFonts) const
         if (style) {
             result = &style->fontCascade().primaryFont();
             if (nodeToRemove)
-                nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+                nodeToRemove->remove();
         }
         return result;
     }
@@ -195,7 +195,7 @@ NSDictionary* Editor::fontAttributesForSelectionStart() const
     getTextDecorationAttributesRespectingTypingStyle(*style, result);
 
     if (nodeToRemove)
-        nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+        nodeToRemove->remove();
 
     return result;
 }
index 1eb72fd..343cc71 100644 (file)
@@ -881,24 +881,22 @@ String urlToMarkup(const URL& url, const String& title)
     return markup.toString();
 }
 
-RefPtr<DocumentFragment> createFragmentForInnerOuterHTML(Element& contextElement, const String& markup, ParserContentPolicy parserContentPolicy, ExceptionCode& ec)
+ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element& contextElement, const String& markup, ParserContentPolicy parserContentPolicy)
 {
-    Document* document = &contextElement.document();
+    auto* document = &contextElement.document();
     if (contextElement.hasTagName(templateTag))
         document = &document->ensureTemplateDocument();
-    RefPtr<DocumentFragment> fragment = DocumentFragment::create(*document);
+    auto fragment = DocumentFragment::create(*document);
 
     if (document->isHTMLDocument()) {
         fragment->parseHTML(markup, &contextElement, parserContentPolicy);
-        return fragment;
+        return WTFMove(fragment);
     }
 
     bool wasValid = fragment->parseXML(markup, &contextElement, parserContentPolicy);
-    if (!wasValid) {
-        ec = SYNTAX_ERR;
-        return nullptr;
-    }
-    return fragment;
+    if (!wasValid)
+        return Exception { SYNTAX_ERR };
+    return WTFMove(fragment);
 }
 
 RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document& outputDoc, const String& sourceString, const String& sourceMIMEType)
@@ -951,31 +949,29 @@ static void removeElementFromFragmentPreservingChildren(DocumentFragment& fragme
     fragment.removeChild(element, ASSERT_NO_EXCEPTION);
 }
 
-RefPtr<DocumentFragment> createContextualFragment(Element& element, const String& markup, ParserContentPolicy parserContentPolicy, ExceptionCode& ec)
+ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element& element, const String& markup, ParserContentPolicy parserContentPolicy)
 {
-    if (element.ieForbidsInsertHTML()) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
+    if (element.ieForbidsInsertHTML())
+        return Exception { NOT_SUPPORTED_ERR };
 
     if (element.hasTagName(colTag) || element.hasTagName(colgroupTag) || element.hasTagName(framesetTag)
-        || element.hasTagName(headTag) || element.hasTagName(styleTag) || element.hasTagName(titleTag)) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
+        || element.hasTagName(headTag) || element.hasTagName(styleTag) || element.hasTagName(titleTag))
+        return Exception { NOT_SUPPORTED_ERR };
 
-    RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(element, markup, parserContentPolicy, ec);
-    if (!fragment)
-        return nullptr;
+    auto result = createFragmentForInnerOuterHTML(element, markup, parserContentPolicy);
+    if (result.hasException())
+        return result.releaseException();
+
+    auto fragment = result.releaseReturnValue();
 
     // We need to pop <html> and <body> elements and remove <head> to
     // accommodate folks passing complete HTML documents to make the
     // child of an element.
-    auto toRemove = collectElementsToRemoveFromFragment(*fragment);
+    auto toRemove = collectElementsToRemoveFromFragment(fragment);
     for (auto& element : toRemove)
-        removeElementFromFragmentPreservingChildren(*fragment, element);
+        removeElementFromFragmentPreservingChildren(fragment, element);
 
-    return fragment;
+    return WTFMove(fragment);
 }
 
 static inline bool hasOneChild(ContainerNode& node)
@@ -1005,14 +1001,14 @@ static inline bool canUseSetDataOptimization(const Text& containerChild, const C
     return !authorScriptMayHaveReference && !mutationScope.canObserve() && !hasMutationEventListeners(containerChild.document());
 }
 
-void replaceChildrenWithFragment(ContainerNode& container, Ref<DocumentFragment>&& fragment, ExceptionCode& ec)
+ExceptionOr<void> replaceChildrenWithFragment(ContainerNode& container, Ref<DocumentFragment>&& fragment)
 {
     Ref<ContainerNode> containerNode(container);
     ChildListMutationScope mutation(containerNode);
 
     if (!fragment->firstChild()) {
         containerNode->removeChildren();
-        return;
+        return { };
     }
 
     auto* containerChild = containerNode->firstChild();
@@ -1020,36 +1016,50 @@ void replaceChildrenWithFragment(ContainerNode& container, Ref<DocumentFragment>
         if (is<Text>(*containerChild) && hasOneTextChild(fragment) && canUseSetDataOptimization(downcast<Text>(*containerChild), mutation)) {
             ASSERT(!fragment->firstChild()->refCount());
             downcast<Text>(*containerChild).setData(downcast<Text>(*fragment->firstChild()).data());
-            return;
+            return { };
         }
 
+        ExceptionCode ec = 0;
         containerNode->replaceChild(fragment, *containerChild, ec);
-        return;
+        if (ec)
+            return Exception { ec };
+        return { };
     }
 
     containerNode->removeChildren();
+    ExceptionCode ec = 0;
     containerNode->appendChild(fragment, ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
-void replaceChildrenWithText(ContainerNode& container, const String& text, ExceptionCode& ec)
+ExceptionOr<void> replaceChildrenWithText(ContainerNode& container, const String& text)
 {
     Ref<ContainerNode> containerNode(container);
     ChildListMutationScope mutation(containerNode);
 
     if (hasOneTextChild(containerNode)) {
         downcast<Text>(*containerNode->firstChild()).setData(text);
-        return;
+        return { };
     }
 
     auto textNode = Text::create(containerNode->document(), text);
 
     if (hasOneChild(containerNode)) {
+        ExceptionCode ec = 0;
         containerNode->replaceChild(textNode, *containerNode->firstChild(), ec);
-        return;
+        if (ec)
+            return Exception { ec };
+        return { };
     }
 
     containerNode->removeChildren();
+    ExceptionCode ec = 0;
     containerNode->appendChild(textNode, ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
 }
index 68067fd..3e85543 100644 (file)
@@ -23,9 +23,9 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef markup_h
-#define markup_h
+#pragma once
 
+#include "ExceptionOr.h"
 #include "FragmentScriptingPermission.h"
 #include "HTMLInterchange.h"
 #include <wtf/Forward.h>
@@ -51,16 +51,15 @@ enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerializatio
 
 WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text);
 WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent);
-RefPtr<DocumentFragment> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy, ExceptionCode&);
+ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy);
 RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document&, const String& sourceString, const String& sourceMIMEType);
-RefPtr<DocumentFragment> createContextualFragment(Element&, const String& markup, ParserContentPolicy, ExceptionCode&);
+ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element&, const String& markup, ParserContentPolicy);
 
 bool isPlainTextMarkup(Node*);
 
-// These methods are used by HTMLElement & ShadowRoot to replace the
-// children with respected fragment/text.
-void replaceChildrenWithFragment(ContainerNode&, Ref<DocumentFragment>&&, ExceptionCode&);
-void replaceChildrenWithText(ContainerNode&, const String&, ExceptionCode&);
+// These methods are used by HTMLElement & ShadowRoot to replace the children with respected fragment/text.
+ExceptionOr<void> replaceChildrenWithFragment(ContainerNode&, Ref<DocumentFragment>&&);
+ExceptionOr<void> replaceChildrenWithText(ContainerNode&, const String&);
 
 String createMarkup(const Range&, Vector<Node*>* = nullptr, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
 String createMarkup(const Node&, EChildrenOnly = IncludeNode, Vector<Node*>* = nullptr, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = nullptr, EFragmentSerialization = HTMLFragmentSerialization);
@@ -73,5 +72,3 @@ String urlToMarkup(const URL&, const String& title);
 String documentTypeString(const Document&);
 
 }
-
-#endif // markup_h
index f5446bd..ba080d4 100644 (file)
  */
 
 #include "config.h"
-#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
 #include "BaseChooserOnlyDateAndTimeInputType.h"
 
+#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
+
 #include "Chrome.h"
 #include "HTMLDivElement.h"
 #include "HTMLInputElement.h"
@@ -77,7 +78,7 @@ void BaseChooserOnlyDateAndTimeInputType::updateAppearance()
         // Need to put something to keep text baseline.
         displayValue = ASCIILiteral(" ");
     }
-    downcast<HTMLElement>(*node).setInnerText(displayValue, ASSERT_NO_EXCEPTION);
+    downcast<HTMLElement>(*node).setInnerText(displayValue);
 }
 
 void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
index e0031d0..36bdd69 100644 (file)
@@ -55,9 +55,10 @@ double BaseDateAndTimeInputType::valueAsDate() const
     return valueAsDouble();
 }
 
-void BaseDateAndTimeInputType::setValueAsDate(double value, ExceptionCode&) const
+ExceptionOr<void> BaseDateAndTimeInputType::setValueAsDate(double value) const
 {
     element().setValue(serializeWithMilliseconds(value));
+    return { };
 }
 
 double BaseDateAndTimeInputType::valueAsDouble() const
@@ -66,9 +67,10 @@ double BaseDateAndTimeInputType::valueAsDouble() const
     return value.isFinite() ? value.toDouble() : DateComponents::invalidMilliseconds();
 }
 
-void BaseDateAndTimeInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior, ExceptionCode&) const
+ExceptionOr<void> BaseDateAndTimeInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior) const
 {
     element().setValue(serialize(newValue), eventBehavior);
+    return { };
 }
 
 bool BaseDateAndTimeInputType::typeMismatchFor(const String& value) const
index a7b9ebe..6e15f5d 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef BaseDateAndTimeInputType_h
-#define BaseDateAndTimeInputType_h
+#pragma once
 
 #if ENABLE(DATE_AND_TIME_INPUT_TYPES)
+
 #include "DateComponents.h"
 #include "InputType.h"
 
@@ -60,9 +60,9 @@ private:
     virtual DateComponents::Type dateType() const = 0;
 #endif
     double valueAsDate() const override;
-    void setValueAsDate(double, ExceptionCode&) const override;
+    ExceptionOr<void> setValueAsDate(double) const override;
     double valueAsDouble() const override;
-    void setValueAsDecimal(const Decimal&, TextFieldEventBehavior, ExceptionCode&) const override;
+    ExceptionOr<void> setValueAsDecimal(const Decimal&, TextFieldEventBehavior) const override;
     bool typeMismatchFor(const String&) const override;
     bool typeMismatch() const override;
     bool valueMissing(const String&) const override;
@@ -76,5 +76,5 @@ private:
 };
 
 } // namespace WebCore
+
 #endif
-#endif // BaseDateAndTimeInputType_h
index a2ad083..ec7cc41 100644 (file)
@@ -48,28 +48,25 @@ static inline bool tokenContainsHTMLSpace(const String& token)
     return token.find(isHTMLSpace) != notFound;
 }
 
-bool DOMTokenList::validateToken(const String& token, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::validateToken(const String& token)
 {
-    if (token.isEmpty()) {
-        ec = SYNTAX_ERR;
-        return false;
-    }
+    if (token.isEmpty())
+        return Exception { SYNTAX_ERR };
 
-    if (tokenContainsHTMLSpace(token)) {
-        ec = INVALID_CHARACTER_ERR;
-        return false;
-    }
+    if (tokenContainsHTMLSpace(token))
+        return Exception { INVALID_CHARACTER_ERR };
 
-    return true;
+    return { };
 }
 
-bool DOMTokenList::validateTokens(const String* tokens, size_t length, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::validateTokens(const String* tokens, size_t length)
 {
     for (size_t i = 0; i < length; ++i) {
-        if (!validateToken(tokens[i], ec))
-            return false;
+        auto result = validateToken(tokens[i]);
+        if (result.hasException())
+            return result;
     }
-    return true;
+    return { };
 }
 
 bool DOMTokenList::contains(const AtomicString& token) const
@@ -77,16 +74,18 @@ bool DOMTokenList::contains(const AtomicString& token) const
     return tokens().contains(token);
 }
 
-inline void DOMTokenList::addInternal(const String* newTokens, size_t length, ExceptionCode& ec)
+inline ExceptionOr<void> DOMTokenList::addInternal(const String* newTokens, size_t length)
 {
     // This is usually called with a single token.
     Vector<AtomicString, 1> uniqueNewTokens;
     uniqueNewTokens.reserveInitialCapacity(length);
 
     auto& tokens = this->tokens();
+
     for (size_t i = 0; i < length; ++i) {
-        if (!validateToken(newTokens[i], ec))
-            return;
+        auto result = validateToken(newTokens[i]);
+        if (result.hasException())
+            return result;
         if (!tokens.contains(newTokens[i]) && !uniqueNewTokens.contains(newTokens[i]))
             uniqueNewTokens.uncheckedAppend(newTokens[i]);
     }
@@ -95,44 +94,50 @@ inline void DOMTokenList::addInternal(const String* newTokens, size_t length, Ex
         tokens.appendVector(uniqueNewTokens);
 
     updateAssociatedAttributeFromTokens();
+
+    return { };
 }
 
-void DOMTokenList::add(const Vector<String>& tokens, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::add(const Vector<String>& tokens)
 {
-    addInternal(tokens.data(), tokens.size(), ec);
+    return addInternal(tokens.data(), tokens.size());
 }
 
-void DOMTokenList::add(const WTF::AtomicString& token, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::add(const AtomicString& token)
 {
-    addInternal(&token.string(), 1, ec);
+    return addInternal(&token.string(), 1);
 }
 
-inline void DOMTokenList::removeInternal(const String* tokensToRemove, size_t length, ExceptionCode& ec)
+inline ExceptionOr<void> DOMTokenList::removeInternal(const String* tokensToRemove, size_t length)
 {
-    if (!validateTokens(tokensToRemove, length, ec))
-        return;
+    auto result = validateTokens(tokensToRemove, length);
+    if (result.hasException())
+        return result;
 
     auto& tokens = this->tokens();
     for (size_t i = 0; i < length; ++i)
         tokens.removeFirst(tokensToRemove[i]);
 
     updateAssociatedAttributeFromTokens();
+
+    return { };
 }
 
-void DOMTokenList::remove(const Vector<String>& tokens, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::remove(const Vector<String>& tokens)
 {
-    removeInternal(tokens.data(), tokens.size(), ec);
+    return removeInternal(tokens.data(), tokens.size());
 }
 
-void DOMTokenList::remove(const WTF::AtomicString& token, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::remove(const AtomicString& token)
 {
-    removeInternal(&token.string(), 1, ec);
+    return removeInternal(&token.string(), 1);
 }
 
-bool DOMTokenList::toggle(const AtomicString& token, Optional<bool> force, ExceptionCode& ec)
+ExceptionOr<bool> DOMTokenList::toggle(const AtomicString& token, Optional<bool> force)
 {
-    if (!validateToken(token, ec))
-        return false;
+    auto result = validateToken(token);
+    if (result.hasException())
+        return result.releaseException();
 
     auto& tokens = this->tokens();
 
@@ -153,22 +158,18 @@ bool DOMTokenList::toggle(const AtomicString& token, Optional<bool> force, Excep
     return true;
 }
 
-void DOMTokenList::replace(const AtomicString& token, const AtomicString& newToken, ExceptionCode& ec)
+ExceptionOr<void> DOMTokenList::replace(const AtomicString& token, const AtomicString& newToken)
 {
-    if (token.isEmpty() || newToken.isEmpty()) {
-        ec = SYNTAX_ERR;
-        return;
-    }
+    if (token.isEmpty() || newToken.isEmpty())
+        return Exception { SYNTAX_ERR };
 
-    if (tokenContainsHTMLSpace(token) || tokenContainsHTMLSpace(newToken)) {
-        ec = INVALID_CHARACTER_ERR;
-        return;
-    }
+    if (tokenContainsHTMLSpace(token) || tokenContainsHTMLSpace(newToken))
+        return Exception { INVALID_CHARACTER_ERR };
 
     auto& tokens = this->tokens();
     size_t index = tokens.find(token);
     if (index == notFound)
-        return;
+        return { };
 
     if (tokens.find(newToken) != notFound)
         tokens.remove(index);
@@ -176,15 +177,15 @@ void DOMTokenList::replace(const AtomicString& token, const AtomicString& newTok
         tokens[index] = newToken;
 
     updateAssociatedAttributeFromTokens();
+
+    return { };
 }
 
 // https://dom.spec.whatwg.org/#concept-domtokenlist-validation
-bool DOMTokenList::supports(StringView token, ExceptionCode& ec)
+ExceptionOr<bool> DOMTokenList::supports(StringView token)
 {
-    if (!m_isSupportedToken) {
-        ec = TypeError;
-        return false;
-    }
+    if (!m_isSupportedToken)
+        return Exception { TypeError };
     return m_isSupportedToken(token);
 }
 
index 8595803..9b987d9 100644 (file)
@@ -30,7 +30,7 @@
 namespace WebCore {
 
 class DOMTokenList {
-    WTF_MAKE_NONCOPYABLE(DOMTokenList); WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_FAST_ALLOCATED;
 public:
     DOMTokenList(Element&, const QualifiedName& attributeName, WTF::Function<bool(StringView)>&& isSupportedToken = { });
 
@@ -43,13 +43,13 @@ public:
     const AtomicString& item(unsigned index) const;
 
     WEBCORE_EXPORT bool contains(const AtomicString&) const;
-    void add(const Vector<String>&, ExceptionCode&);
-    void add(const AtomicString&, ExceptionCode&);
-    void remove(const Vector<String>&, ExceptionCode&);
-    void remove(const AtomicString&, ExceptionCode&);
-    WEBCORE_EXPORT bool toggle(const AtomicString&, Optional<bool> force, ExceptionCode&);
-    void replace(const AtomicString& token, const AtomicString& newToken, ExceptionCode&);
-    bool supports(StringView token, ExceptionCode&);
+    ExceptionOr<void> add(const Vector<String>&);
+    ExceptionOr<void> add(const AtomicString&);
+    ExceptionOr<void> remove(const Vector<String>&);
+    ExceptionOr<void> remove(const AtomicString&);
+    WEBCORE_EXPORT ExceptionOr<bool> toggle(const AtomicString&, Optional<bool> force);
+    ExceptionOr<void> replace(const AtomicString& token, const AtomicString& newToken);
+    ExceptionOr<bool> supports(StringView token);
 
     Element& element() const { return m_element; }
 
@@ -63,10 +63,10 @@ private:
     WEBCORE_EXPORT Vector<AtomicString>& tokens();
     const Vector<AtomicString>& tokens() const { return const_cast<DOMTokenList&>(*this).tokens(); }
 
-    static bool validateToken(const String&, ExceptionCode&);
-    static bool validateTokens(const String* tokens, size_t length, ExceptionCode&);
-    void addInternal(const String* tokens, size_t length, ExceptionCode&);
-    void removeInternal(const String* tokens, size_t length, ExceptionCode&);
+    static ExceptionOr<void> validateToken(const String&);
+    static ExceptionOr<void> validateTokens(const String* tokens, size_t length);
+    ExceptionOr<void> addInternal(const String* tokens, size_t length);
+    ExceptionOr<void> removeInternal(const String* tokens, size_t length);
 
     Element& m_element;
     const WebCore::QualifiedName& m_attributeName;
index 1b5e8b3..db99e93 100644 (file)
     readonly attribute unsigned long length;
     getter DOMString? item(unsigned long index);
     boolean contains(DOMString token);
-    [CEReactions, MayThrowLegacyException] void add(DOMString... tokens);
-    [CEReactions, MayThrowLegacyException] void remove(DOMString... tokens);
-    [CEReactions, MayThrowLegacyException] boolean toggle(DOMString token, optional boolean force);
-    [CEReactions, MayThrowLegacyException] void replace(DOMString token, DOMString newToken);
-    [MayThrowLegacyException] boolean supports(DOMString token);
+    [CEReactions, MayThrowException] void add(DOMString... tokens);
+    [CEReactions, MayThrowException] void remove(DOMString... tokens);
+    [CEReactions, MayThrowException] boolean toggle(DOMString token, optional boolean force);
+    [CEReactions, MayThrowException] void replace(DOMString token, DOMString newToken);
+    [MayThrowException] boolean supports(DOMString token);
 
     iterable<DOMString>;
 
index cb8e3a9..daf6052 100644 (file)
 #include "config.h"
 #include "DOMURL.h"
 
-#include "SecurityOrigin.h"
 #include "ActiveDOMObject.h"
 #include "Blob.h"
 #include "BlobURL.h"
+#include "ExceptionCode.h"
 #include "MemoryCache.h"
 #include "PublicURLManager.h"
 #include "ResourceRequest.h"
 #include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
 #include "URLSearchParams.h"
 #include <wtf/MainThread.h>
 
 namespace WebCore {
 
-Ref<DOMURL> DOMURL::create(const String& url, const String& base, ExceptionCode& ec)
-{
-    return adoptRef(*new DOMURL(url, base, ec));
-}
-
-Ref<DOMURL> DOMURL::create(const String& url, const DOMURL& base, ExceptionCode& ec)
+inline DOMURL::DOMURL(URL&& completeURL, URL&& baseURL)
+    : m_baseURL(WTFMove(baseURL))
+    , m_url(WTFMove(completeURL))
 {
-    return adoptRef(*new DOMURL(url, base, ec));
 }
 
-Ref<DOMURL> DOMURL::create(const String& url, ExceptionCode& ec)
+ExceptionOr<Ref<DOMURL>> DOMURL::create(const String& url, const String& base)
 {
-    return adoptRef(*new DOMURL(url, ec));
+    URL baseURL { URL { }, base };
+    if (!baseURL.isValid())
+        return Exception { TypeError };
+    URL completeURL { baseURL, url };
+    if (!completeURL.isValid())
+        return Exception { TypeError };
+    return adoptRef(*new DOMURL(WTFMove(completeURL), WTFMove(baseURL)));
 }
 
-inline DOMURL::DOMURL(const String& url, const String& base, ExceptionCode& ec)
-    : m_baseURL(URL(), base)
-    , m_url(m_baseURL, url)
+ExceptionOr<Ref<DOMURL>> DOMURL::create(const String& url, const DOMURL& base)
 {
-    if (!m_baseURL.isValid() || !m_url.isValid())
-        ec = TypeError;
+    return create(url, base.href());
 }
 
-inline DOMURL::DOMURL(const String& url, const DOMURL& base, ExceptionCode& ec)
-    : m_baseURL(base.href())
-    , m_url(m_baseURL, url)
+ExceptionOr<Ref<DOMURL>> DOMURL::create(const String& url)
 {
-    if (!m_baseURL.isValid() || !m_url.isValid())
-        ec = TypeError;
-}
-
-inline DOMURL::DOMURL(const String& url, ExceptionCode& ec)
-    : m_baseURL(blankURL())
-    , m_url(m_baseURL, url)
-{
-    if (!m_url.isValid())
-        ec = TypeError;
+    URL baseURL { blankURL() };
+    URL completeURL { baseURL, url };
+    if (!completeURL.isValid())
+        return Exception { TypeError };
+    return adoptRef(*new DOMURL(WTFMove(completeURL), WTFMove(baseURL)));
 }
 
 DOMURL::~DOMURL()
@@ -84,11 +77,15 @@ DOMURL::~DOMURL()
         m_searchParams->associatedURLDestroyed();
 }
 
-void DOMURL::setHref(const String& url)
+ExceptionOr<void> DOMURL::setHref(const String& url)
 {
-    m_url = URL(m_baseURL, url);
+    URL completeURL { m_baseURL, url };
+    if (!completeURL.isValid())
+        return Exception { TypeError };
+    m_url = WTFMove(completeURL);
     if (m_searchParams)
         m_searchParams->updateFromAssociatedURL();
+    return { };
 }
 
 void DOMURL::setQuery(const String& query)
@@ -96,13 +93,6 @@ void DOMURL::setQuery(const String& query)
     m_url.setQuery(query);
 }
 
-void DOMURL::setHref(const String& url, ExceptionCode& ec)
-{
-    setHref(url);
-    if (!m_url.isValid())
-        ec = TypeError;
-}
-
 String DOMURL::createObjectURL(ScriptExecutionContext& scriptExecutionContext, Blob& blob)
 {
     return createPublicURL(scriptExecutionContext, blob);
index b62ff09..10a7f70 100644 (file)
 
 #pragma once
 
-#include "ExceptionCode.h"
+#include "ExceptionOr.h"
 #include "URL.h"
 #include "URLUtils.h"
 #include <wtf/HashSet.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -42,14 +40,13 @@ class URLSearchParams;
 
 class DOMURL : public RefCounted<DOMURL>, public URLUtils<DOMURL> {
 public:
-    static Ref<DOMURL> create(const String& url, const String& base, ExceptionCode&);
-    static Ref<DOMURL> create(const String& url, const DOMURL& base, ExceptionCode&);
-    static Ref<DOMURL> create(const String& url, ExceptionCode&);
+    static ExceptionOr<Ref<DOMURL>> create(const String& url, const String& base);
+    static ExceptionOr<Ref<DOMURL>> create(const String& url, const DOMURL& base);
+    static ExceptionOr<Ref<DOMURL>> create(const String& url);
     ~DOMURL();
 
     URL href() const { return m_url; }
-    void setHref(const String& url);
-    void setHref(const String&, ExceptionCode&);
+    ExceptionOr<void> setHref(const String& url);
     void setQuery(const String&);
 
     URLSearchParams& searchParams();
@@ -58,10 +55,9 @@ public:
     static void revokeObjectURL(ScriptExecutionContext&, const String&);
 
     static String createPublicURL(ScriptExecutionContext&, URLRegistrable&);
+
 private:
-    DOMURL(const String& url, const String& base, ExceptionCode&);
-    DOMURL(const String& url, const DOMURL& base, ExceptionCode&);
-    DOMURL(const String& url, ExceptionCode&);
+    DOMURL(URL&& completeURL, URL&& baseURL);
 
     URL m_baseURL;
     URL m_url;
index add2918..51bb21f 100644 (file)
@@ -29,7 +29,7 @@
     Constructor(USVString url),
     Constructor(USVString url, USVString base),
     Constructor(USVString url, DOMURL base),
-    ConstructorMayThrowLegacyException,
+    ConstructorMayThrowException,
     JSGenerateToNativeObject,
     JSGenerateToJSObject,
     InterfaceName=URL,
index af758d5..bdc3857 100644 (file)
  */
 
 #include "config.h"
-#if ENABLE(INPUT_TYPE_DATETIMELOCAL)
 #include "DateTimeLocalInputType.h"
 
+#if ENABLE(INPUT_TYPE_DATETIMELOCAL)
+
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -61,10 +62,10 @@ double DateTimeLocalInputType::valueAsDate() const
     return DateComponents::invalidMilliseconds();
 }
 
-void DateTimeLocalInputType::setValueAsDate(double value, ExceptionCode& ec) const
+ExceptionOr<void> DateTimeLocalInputType::setValueAsDate(double value) const
 {
     // valueAsDate doesn't work for the datetime-local type according to the standard.
-    InputType::setValueAsDate(value, ec);
+    return InputType::setValueAsDate(value);
 }
 
 StepRange DateTimeLocalInputType::createStepRange(AnyStepHandling anyStepHandling) const
index 88c0b5b..7a086bc 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DateTimeLocalInputType_h
-#define DateTimeLocalInputType_h
+#pragma once
 
 #if ENABLE(INPUT_TYPE_DATETIMELOCAL)
+
 #include "BaseChooserOnlyDateAndTimeInputType.h"
 
 namespace WebCore {
@@ -41,17 +41,16 @@ public:
     explicit DateTimeLocalInputType(HTMLInputElement& element) : BaseChooserOnlyDateAndTimeInputType(element) { }
 
 private:
-    const AtomicString& formControlType() const override;
-    DateComponents::Type dateType() const override;
-    double valueAsDate() const override;
-    void setValueAsDate(double, ExceptionCode&) const override;
-    StepRange createStepRange(AnyStepHandling) const override;
-    bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const override;
-    bool setMillisecondToDateComponents(double, DateComponents*) const override;
-    bool isDateTimeLocalField() const override;
+    const AtomicString& formControlType() const final;
+    DateComponents::Type dateType() const final;
+    double valueAsDate() const final;
+    ExceptionOr<void> setValueAsDate(double) const final;
+    StepRange createStepRange(AnyStepHandling) const final;
+    bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const final;
+    bool setMillisecondToDateComponents(double, DateComponents*) const final;
+    bool isDateTimeLocalField() const final;
 };
 
 } // namespace WebCore
 
 #endif
-#endif // DateTimeLocalInputType_h
index dbd8c73..2f75de0 100644 (file)
@@ -101,7 +101,7 @@ FTPDirectoryDocumentParser::FTPDirectoryDocumentParser(HTMLDocument& document)
 
 void FTPDirectoryDocumentParser::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory)
 {
-    auto rowElement = m_tableElement->insertRow(-1, IGNORE_EXCEPTION);
+    auto rowElement = m_tableElement->insertRow(-1).releaseReturnValue();
     rowElement->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomicString("ftpDirectoryEntryRow", AtomicString::ConstructFromLiteral));
 
     auto typeElement = document()->createElement(tdTag, false);
index 500a196..0de5e72 100644 (file)
@@ -458,22 +458,20 @@ String HTMLCanvasElement::toEncodingMimeType(const String& mimeType)
     return mimeType.convertToASCIILowercase();
 }
 
-String HTMLCanvasElement::toDataURL(const String& mimeType, const double* quality, ExceptionCode& ec)
+ExceptionOr<String> HTMLCanvasElement::toDataURL(const String& mimeType, Optional<double> quality)
 {
-    if (!m_originClean) {
-        ec = SECURITY_ERR;
-        return String();
-    }
+    if (!m_originClean)
+        return Exception { SECURITY_ERR };
 
     if (m_size.isEmpty() || !buffer())
-        return ASCIILiteral("data:,");
+        return String { ASCIILiteral { "data:," } };
 
     String encodingMIMEType = toEncodingMimeType(mimeType);
 
 #if USE(CG)
     // Try to get ImageData first, as that may avoid lossy conversions.
     if (auto imageData = getImageData())
-        return ImageDataToDataURL(*imageData, encodingMIMEType, quality);
+        return dataURL(*imageData, encodingMIMEType, quality);
 #endif
 
     makeRenderingResultsAvailable();
index 44ae6a6..2f57405 100644 (file)
@@ -45,7 +45,7 @@ class ImageBuffer;
 class ImageData;
 
 namespace DisplayList {
-typedef unsigned AsTextFlags;
+using AsTextFlags = unsigned;
 }
 
 class CanvasObserver {
@@ -92,8 +92,8 @@ public:
 #endif
 
     static String toEncodingMimeType(const String& mimeType);
-    WEBCORE_EXPORT String toDataURL(const String& mimeType, const double* quality, ExceptionCode&);
-    String toDataURL(const String& mimeType, ExceptionCode& ec) { return toDataURL(mimeType, nullptr, ec); }
+    WEBCORE_EXPORT ExceptionOr<String> toDataURL(const String& mimeType, Optional<double> quality);
+    ExceptionOr<String> toDataURL(const String& mimeType) { return toDataURL(mimeType, Nullopt); }
 
     // Used for rendering
     void didDraw(const FloatRect&);
index fbaf05b..77a171e 100644 (file)
@@ -32,9 +32,8 @@
     attribute unsigned long width;
     attribute unsigned long height;
 
-    [Custom, MayThrowLegacyException] DOMString toDataURL(optional DOMString? type);
+    [Custom, MayThrowException] DOMString toDataURL(optional DOMString? type);
 
     // The custom binding is needed to handle context creation attributes.
     [Custom] any getContext(DOMString contextId, any... arguments);
 };
-
index 3f3bd87..9e06803 100644 (file)
@@ -435,10 +435,8 @@ void HTMLElement::parseAttribute(const QualifiedName& name, const AtomicString&
         setAttributeEventListener(eventName, name, value);
 }
 
-Ref<DocumentFragment> HTMLElement::textToFragment(const String& text, ExceptionCode& ec)
+ExceptionOr<Ref<DocumentFragment>> HTMLElement::textToFragment(const String& text)
 {
-    ec = 0;
-
     auto fragment = DocumentFragment::create(document());
 
     for (unsigned start = 0, length = text.length(); start < length; ) {
@@ -452,16 +450,17 @@ Ref<DocumentFragment> HTMLElement::textToFragment(const String& text, ExceptionC
                 break;
         }
 
+        ExceptionCode ec = 0;
         fragment->appendChild(Text::create(document(), text.substring(start, i - start)), ec);
         if (ec)
-            break;
+            return Exception { ec };
 
         if (i == length)
             break;
 
         fragment->appendChild(HTMLBRElement::create(document()), ec);
         if (ec)
-            break;
+            return Exception { ec };
 
         // Make sure \r\n doesn't result in two line breaks.
         if (c == '\r' && i + 1 < length && text[i + 1] == '\n')
@@ -470,7 +469,7 @@ Ref<DocumentFragment> HTMLElement::textToFragment(const String& text, ExceptionC
         start = i + 1; // Character after line break.
     }
 
-    return fragment;
+    return WTFMove(fragment);
 }
 
 static inline bool shouldProhibitSetInnerOuterText(const HTMLElement& element)
@@ -515,26 +514,21 @@ void HTMLElement::setDir(const AtomicString& value)
     setAttributeWithoutSynchronization(dirAttr, value);
 }
 
-void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
+ExceptionOr<void> HTMLElement::setInnerText(const String& text)
 {
-    if (ieForbidsInsertHTML()) {
-        ec = NO_MODIFICATION_ALLOWED_ERR;
-        return;
-    }
-    if (shouldProhibitSetInnerOuterText(*this)) {
-        ec = NO_MODIFICATION_ALLOWED_ERR;
-        return;
-    }
+    if (ieForbidsInsertHTML())
+        return Exception { NO_MODIFICATION_ALLOWED_ERR };
+    if (shouldProhibitSetInnerOuterText(*this))
+        return Exception { NO_MODIFICATION_ALLOWED_ERR };
 
     // FIXME: This doesn't take whitespace collapsing into account at all.
 
     if (!text.contains('\n') && !text.contains('\r')) {
         if (text.isEmpty()) {
             removeChildren();
-            return;
+            return { };
         }
-        replaceChildrenWithText(*this, text, ec);
-        return;
+        return replaceChildrenWithText(*this, text);
     }
 
     // FIXME: Do we need to be able to detect preserveNewline style even when there's no renderer?
@@ -542,63 +536,67 @@ void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
     // For example, for the contents of textarea elements that are display:none?
     auto r = renderer();
     if ((r && r->style().preserveNewline()) || (inDocument() && isTextControlInnerTextElement())) {
-        if (!text.contains('\r')) {
-            replaceChildrenWithText(*this, text, ec);
-            return;
-        }
+        if (!text.contains('\r'))
+            return replaceChildrenWithText(*this, text);
         String textWithConsistentLineBreaks = text;
         textWithConsistentLineBreaks.replace("\r\n", "\n");
         textWithConsistentLineBreaks.replace('\r', '\n');
-        replaceChildrenWithText(*this, textWithConsistentLineBreaks, ec);
-        return;
+        return replaceChildrenWithText(*this, textWithConsistentLineBreaks);
     }
 
     // Add text nodes and <br> elements.
-    ec = 0;
-    Ref<DocumentFragment> fragment = textToFragment(text, ec);
-    if (!ec)
-        replaceChildrenWithFragment(*this, WTFMove(fragment), ec);
+    auto fragment = textToFragment(text);
+    if (fragment.hasException())
+        return fragment.releaseException();
+    return replaceChildrenWithFragment(*this, fragment.releaseReturnValue());
 }
 
-void HTMLElement::setOuterText(const String& text, ExceptionCode& ec)
+ExceptionOr<void> HTMLElement::setOuterText(const String& text)
 {
-    if (ieForbidsInsertHTML()) {
-        ec = NO_MODIFICATION_ALLOWED_ERR;
-        return;
-    }
-    if (shouldProhibitSetInnerOuterText(*this)) {
-        ec = NO_MODIFICATION_ALLOWED_ERR;
-        return;
-    }
+    if (ieForbidsInsertHTML())
+        return Exception { NO_MODIFICATION_ALLOWED_ERR };
+    if (shouldProhibitSetInnerOuterText(*this))
+        return Exception { NO_MODIFICATION_ALLOWED_ERR };
 
     RefPtr<ContainerNode> parent = parentNode();
-    if (!parent) {
-        ec = NO_MODIFICATION_ALLOWED_ERR;
-        return;
-    }
+    if (!parent)
+        return Exception { NO_MODIFICATION_ALLOWED_ERR };
 
     RefPtr<Node> prev = previousSibling();
     RefPtr<Node> next = nextSibling();
     RefPtr<Node> newChild;
-    ec = 0;
-    
+
     // Convert text to fragment with <br> tags instead of linebreaks if needed.
-    if (text.contains('\r') || text.contains('\n'))
-        newChild = textToFragment(text, ec);
-    else
+    if (text.contains('\r') || text.contains('\n')) {
+        auto result = textToFragment(text);
+        if (result.hasException())
+            return result.releaseException();
+        newChild = result.releaseReturnValue();
+    } else
         newChild = Text::create(document(), text);
 
     if (!parentNode())
-        ec = HIERARCHY_REQUEST_ERR;
-    if (ec)
-        return;
+        return Exception { HIERARCHY_REQUEST_ERR };
+
+    ExceptionCode ec = 0;
     parent->replaceChild(*newChild, *this, ec);
+    if (ec)
+        return Exception { ec };
 
     RefPtr<Node> node = next ? next->previousSibling() : nullptr;
-    if (!ec && is<Text>(node.get()))
+    if (is<Text>(node.get())) {
+        ExceptionCode ec = 0;
         mergeWithNextTextNode(downcast<Text>(*node), ec);
-    if (!ec && is<Text>(prev.get()))
+        if (ec)
+            return Exception { ec };
+    }
+    if (is<Text>(prev.get())) {
+        ExceptionCode ec = 0;
         mergeWithNextTextNode(downcast<Text>(*prev), ec);
+        if (ec)
+            return Exception { ec };
+    }
+    return { };
 }
 
 void HTMLElement::applyAlignmentAttributeToStyle(const AtomicString& alignment, MutableStyleProperties& style)
@@ -661,7 +659,7 @@ String HTMLElement::contentEditable() const
     return ASCIILiteral("inherit");
 }
 
-void HTMLElement::setContentEditable(const String& enabled, ExceptionCode& ec)
+ExceptionOr<void> HTMLElement::setContentEditable(const String& enabled)
 {
     if (equalLettersIgnoringASCIICase(enabled, "true"))
         setAttributeWithoutSynchronization(contenteditableAttr, AtomicString("true", AtomicString::ConstructFromLiteral));
@@ -672,7 +670,8 @@ void HTMLElement::setContentEditable(const String& enabled, ExceptionCode& ec)
     else if (equalLettersIgnoringASCIICase(enabled, "inherit"))
         removeAttribute(contenteditableAttr);
     else
-        ec = SYNTAX_ERR;
+        return Exception { SYNTAX_ERR };
+    return { };
 }
 
 bool HTMLElement::draggable() const
@@ -721,30 +720,15 @@ int HTMLElement::tabIndex() const
     return -1;
 }
 
-TranslateAttributeMode HTMLElement::translateAttributeMode() const
-{
-    const AtomicString& value = attributeWithoutSynchronization(translateAttr);
-
-    if (value.isNull())
-        return TranslateAttributeInherit;
-    if (equalLettersIgnoringASCIICase(value, "yes") || value.isEmpty())
-        return TranslateAttributeYes;
-    if (equalLettersIgnoringASCIICase(value, "no"))
-        return TranslateAttributeNo;
-
-    return TranslateAttributeInherit;
-}
-
 bool HTMLElement::translate() const
 {
     for (auto& element : lineageOfType<HTMLElement>(*this)) {
-        TranslateAttributeMode mode = element.translateAttributeMode();
-        if (mode == TranslateAttributeInherit)
-            continue;
-        ASSERT(mode == TranslateAttributeYes || mode == TranslateAttributeNo);
-        return mode == TranslateAttributeYes;
+        const AtomicString& value = element.attributeWithoutSynchronization(translateAttr);
+        if (equalLettersIgnoringASCIICase(value, "yes") || (value.isEmpty() && !value.isNull()))
+            return true;
+        if (equalLettersIgnoringASCIICase(value, "no"))
+            return false;
     }
-
     // Default on the root element is translate=yes.
     return true;
 }
index 78600d4..62d4e3e 100644 (file)
@@ -20,8 +20,7 @@
  *
  */
 
-#ifndef HTMLElement_h
-#define HTMLElement_h
+#pragma once
 
 #include "StyledElement.h"
 
@@ -32,12 +31,6 @@ class FormNamedItem;
 class HTMLCollection;
 class HTMLFormElement;
 
-enum TranslateAttributeMode {
-    TranslateAttributeYes,
-    TranslateAttributeNo,
-    TranslateAttributeInherit
-};
-
 class HTMLElement : public StyledElement {
 public:
     static Ref<HTMLElement> create(const QualifiedName& tagName, Document&);
@@ -46,14 +39,14 @@ public:
 
     int tabIndex() const override;
 
-    WEBCORE_EXPORT void setInnerText(const String&, ExceptionCode&);
-    WEBCORE_EXPORT void setOuterText(const String&, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setInnerText(const String&);
+    WEBCORE_EXPORT ExceptionOr<void> setOuterText(const String&);
 
     virtual bool hasCustomFocusLogic() const;
     bool supportsFocus() const override;
 
     WEBCORE_EXPORT String contentEditable() const;
-    WEBCORE_EXPORT void setContentEditable(const String&, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setContentEditable(const String&);
 
     static Editability editabilityFromContentEditableAttr(const Node&);
 
@@ -128,15 +121,13 @@ private:
 
     virtual HTMLFormElement* virtualForm() const;
 
-    Ref<DocumentFragment> textToFragment(const String&, ExceptionCode&);
+    ExceptionOr<Ref<DocumentFragment>> textToFragment(const String&);
 
     void dirAttributeChanged(const AtomicString&);
     void adjustDirectionalityIfNeededAfterChildAttributeChanged(Element* child);
     void adjustDirectionalityIfNeededAfterChildrenChanged(Element* beforeChange, ChildChangeType);
     TextDirection directionality(Node** strongDirectionalityTextNode= 0) const;
 
-    TranslateAttributeMode translateAttributeMode() const;
-
     static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const table[], size_t tableSize);
     static EventHandlerNameMap createEventHandlerNameMap();
 };
@@ -164,5 +155,3 @@ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLElement)
 SPECIALIZE_TYPE_TRAITS_END()
 
 #include "HTMLElementTypeHelpers.h"
-
-#endif // HTMLElement_h
index dc337cb..19e1662 100644 (file)
@@ -22,9 +22,9 @@
 #if defined(ENABLE_CUSTOM_ELEMENTS) && ENABLE_CUSTOM_ELEMENTS
     CustomConstructor(),
 #endif
-    JSGenerateToNativeObject,
-    JSCustomPushEventHandlerScope,
     ExportMacro=WEBCORE_EXPORT,
+    JSCustomPushEventHandlerScope,
+    JSGenerateToNativeObject,
 ] interface HTMLElement : Element {
     [CEReactions, Reflect] attribute DOMString title;
     [CEReactions, Reflect] attribute DOMString lang;
     [CEReactions, Reflect] attribute boolean hidden;
     [CEReactions, Reflect] attribute DOMString accessKey;
 
-    [CEReactions, SetterMayThrowLegacyException, TreatNullAs=EmptyString] attribute DOMString innerText;
-    [CEReactions, SetterMayThrowLegacyException, TreatNullAs=EmptyString] attribute DOMString outerText;
+    [CEReactions, SetterMayThrowException, TreatNullAs=EmptyString] attribute DOMString innerText;
+    [CEReactions, SetterMayThrowException, TreatNullAs=EmptyString] attribute DOMString outerText;
 
-    [CEReactions, SetterMayThrowLegacyException] attribute DOMString contentEditable;
+    [CEReactions, SetterMayThrowException] attribute DOMString contentEditable;
     readonly attribute boolean isContentEditable;
 
     [CEReactions] attribute boolean spellcheck;
index a3d1b15..a50f735 100644 (file)
@@ -19,9 +19,9 @@
  */
 
 [
+    CustomCall,
     CustomNamedSetter,
     JSCustomGetOwnPropertySlotAndDescriptor,
-    CustomCall,
 ] interface HTMLEmbedElement : HTMLElement {
     [Reflect] attribute DOMString align;
     [Reflect] attribute DOMString height;
@@ -30,6 +30,5 @@
     [Reflect] attribute DOMString type;
     [Reflect] attribute DOMString width;
 
-    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
+    [CheckSecurityForNode, MayThrowException] Document getSVGDocument();
 };
-
index 34fb204..db006ff 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 interface HTMLFrameElement : HTMLElement {
-
     [Reflect] attribute DOMString frameBorder;
     [Reflect, URL] attribute USVString longDesc;
 
@@ -31,19 +30,15 @@ interface HTMLFrameElement : HTMLElement {
     [Reflect] attribute DOMString scrolling;
     [Reflect, URL] attribute USVString src;
 
-    // Introduced in DOM Level 2:
     [CheckSecurityForNode] readonly attribute Document contentDocument;
 
-    // Extensions
     readonly attribute DOMWindow contentWindow;
 
-    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
+    [CheckSecurityForNode, MayThrowException] Document getSVGDocument();
 
     // FIXME: No other browser has this attribute.
     [CustomSetter] attribute DOMString location;
 
     readonly attribute long width;
     readonly attribute long height;
-
 };
-
index f050b61..1f6fd7f 100644 (file)
@@ -112,14 +112,13 @@ bool HTMLFrameOwnerElement::isKeyboardFocusable(KeyboardEvent& event) const
     return m_contentFrame && HTMLElement::isKeyboardFocusable(event);
 }
 
-Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
+ExceptionOr<Document*> HTMLFrameOwnerElement::getSVGDocument() const
 {
-    Document* document = contentDocument();
+    auto* document = contentDocument();
     if (is<SVGDocument>(document))
-        return downcast<SVGDocument>(document);
+        return document;
     // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
-    ec = NOT_SUPPORTED_ERR;
-    return nullptr;
+    return Exception { NOT_SUPPORTED_ERR };
 }
 
 void HTMLFrameOwnerElement::scheduleinvalidateStyleAndLayerComposition()
index a4946d1..bfcc0ee 100644 (file)
@@ -49,7 +49,7 @@ public:
     // RenderElement when using fallback content.
     RenderWidget* renderWidget() const;
 
-    Document* getSVGDocument(ExceptionCode&) const;
+    ExceptionOr<Document*> getSVGDocument() const;
 
     virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
 
index 5ff8f4d..fc8d0ee 100644 (file)
@@ -35,12 +35,9 @@ interface HTMLIFrameElement : HTMLElement {
     [Reflect] attribute DOMString srcdoc;
     [Reflect] attribute DOMString width;
 
-    // Introduced in DOM Level 2:
     [CheckSecurityForNode] readonly attribute Document contentDocument;
 
-    // Extensions
     readonly attribute DOMWindow contentWindow;
 
-    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
+    [CheckSecurityForNode, MayThrowException] Document getSVGDocument();
 };
-
index d5a53b3..f403f23 100644 (file)
@@ -375,14 +375,14 @@ Optional<Decimal> HTMLInputElement::findClosestTickMarkValue(const Decimal& valu
 }
 #endif
 
-void HTMLInputElement::stepUp(int n, ExceptionCode& ec)
+ExceptionOr<void> HTMLInputElement::stepUp(int n)
 {
-    m_inputType->stepUp(n, ec);
+    return m_inputType->stepUp(n);
 }
 
-void HTMLInputElement::stepDown(int n, ExceptionCode& ec)
+ExceptionOr<void> HTMLInputElement::stepDown(int n)
 {
-    m_inputType->stepUp(-n, ec);
+    return m_inputType->stepUp(-n);
 }
 
 void HTMLInputElement::blur()
@@ -1018,19 +1018,13 @@ void HTMLInputElement::setEditingValue(const String& value)
     dispatchInputEvent();
 }
 
-void HTMLInputElement::setValue(const String& value, ExceptionCode& ec, TextFieldEventBehavior eventBehavior)
+ExceptionOr<void> HTMLInputElement::setValue(const String& value, TextFieldEventBehavior eventBehavior)
 {
-    if (isFileUpload() && !value.isEmpty()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
-    setValue(value.isNull() ? emptyString() : value, eventBehavior);
-}
+    if (isFileUpload() && !value.isEmpty())
+        return Exception { INVALID_STATE_ERR };
 
-void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior eventBehavior)
-{
     if (!m_inputType->canSetValue(value))
-        return;
+        return { };
 
     Ref<HTMLInputElement> protectedThis(*this);
     EventQueueScope scope;
@@ -1040,6 +1034,7 @@ void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior even
     setLastChangeWasNotUserEdit();
     setFormControlValueMatchesRenderer(false);
     m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior);
+    return { };
 }
 
 void HTMLInputElement::setValueInternal(const String& sanitizedValue, TextFieldEventBehavior eventBehavior)
@@ -1054,9 +1049,9 @@ double HTMLInputElement::valueAsDate() const
     return m_inputType->valueAsDate();
 }
 
-void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
+ExceptionOr<void> HTMLInputElement::setValueAsDate(double value)
 {
-    m_inputType->setValueAsDate(value, ec);
+    return m_inputType->setValueAsDate(value);
 }
 
 double HTMLInputElement::valueAsNumber() const
@@ -1064,13 +1059,11 @@ double HTMLInputElement::valueAsNumber() const
     return m_inputType->valueAsDouble();
 }
 
-void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec, TextFieldEventBehavior eventBehavior)
+ExceptionOr<void> HTMLInputElement::setValueAsNumber(double newValue, TextFieldEventBehavior eventBehavior)
 {
-    if (!std::isfinite(newValue)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
-    m_inputType->setValueAsDouble(newValue, eventBehavior, ec);
+    if (!std::isfinite(newValue))
+        return Exception { NOT_SUPPORTED_ERR };
+    return m_inputType->setValueAsDouble(newValue, eventBehavior);
 }
 
 void HTMLInputElement::setValueFromRenderer(const String& value)
@@ -1306,17 +1299,12 @@ bool HTMLInputElement::multiple() const
     return hasAttributeWithoutSynchronization(multipleAttr);
 }
 
-void HTMLInputElement::setSize(unsigned size)
-{
-    setUnsignedIntegralAttribute(sizeAttr, limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(size, defaultSize));
-}
-
-void HTMLInputElement::setSize(unsigned size, ExceptionCode& ec)
+ExceptionOr<void> HTMLInputElement::setSize(unsigned size)
 {
     if (!size)
-        ec = INDEX_SIZE_ERR;
-    else
-        setSize(size);
+        return Exception { INDEX_SIZE_ERR };
+    setUnsignedIntegralAttribute(sizeAttr, limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(size, defaultSize));
+    return { };
 }
 
 URL HTMLInputElement::src() const
@@ -1777,11 +1765,7 @@ bool HTMLInputElement::isEmptyValue() const
 void HTMLInputElement::maxLengthAttributeChanged(const AtomicString& newValue)
 {
     unsigned oldEffectiveMaxLength = effectiveMaxLength();
-    if (Optional<unsigned> maxLength = parseHTMLNonNegativeInteger(newValue))
-        setMaxLength(maxLength.value());
-    else
-        setMaxLength(-1);
-
+    internalSetMaxLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1));
     if (oldEffectiveMaxLength != effectiveMaxLength())
         updateValueIfNeeded();
 
@@ -1793,11 +1777,7 @@ void HTMLInputElement::maxLengthAttributeChanged(const AtomicString& newValue)
 void HTMLInputElement::minLengthAttributeChanged(const AtomicString& newValue)
 {
     int oldMinLength = minLength();
-    if (Optional<unsigned> minLength = parseHTMLNonNegativeInteger(newValue))
-        setMinLength(minLength.value());
-    else
-        setMinLength(-1);
-
+    internalSetMinLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1));
     if (oldMinLength != minLength())
         updateValueIfNeeded();
 
@@ -1932,24 +1912,20 @@ void ListAttributeTargetObserver::idTargetChanged()
 }
 #endif
 
-void HTMLInputElement::setRangeText(const String& replacement, ExceptionCode& ec)
+ExceptionOr<void> HTMLInputElement::setRangeText(const String& replacement)
 {
-    if (!m_inputType->supportsSelectionAPI()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (!m_inputType->supportsSelectionAPI())
+        return Exception { INVALID_STATE_ERR };
 
-    HTMLTextFormControlElement::setRangeText(replacement, ec);
+    return HTMLTextFormControlElement::setRangeText(replacement);
 }
 
-void HTMLInputElement::setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionCode& ec)
+ExceptionOr<void> HTMLInputElement::setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode)
 {
-    if (!m_inputType->supportsSelectionAPI()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (!m_inputType->supportsSelectionAPI())
+        return Exception { INVALID_STATE_ERR };
 
-    HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionMode, ec);
+    return HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionMode);
 }
 
 bool HTMLInputElement::shouldTruncateText(const RenderStyle& style) const
index 95eb2a4..3e05865 100644 (file)
@@ -22,8 +22,7 @@
  *
  */
 
-#ifndef HTMLInputElement_h
-#define HTMLInputElement_h
+#pragma once
 
 #include "FileChooser.h"
 #include "HTMLTextFormControlElement.h"
@@ -50,14 +49,9 @@ class URL;
 struct DateTimeChooserParameters;
 
 struct InputElementClickState {
-    InputElementClickState()
-        : stateful(false)
-        , checked(false)
-        , indeterminate(false)
-    { }
-    bool stateful;
-    bool checked;
-    bool indeterminate;
+    bool stateful { false };
+    bool checked { false };
+    bool indeterminate { false };
     RefPtr<HTMLInputElement> checkedRadioButton;
 };
 
@@ -94,11 +88,9 @@ public:
     Optional<Decimal> findClosestTickMarkValue(const Decimal&);
 #endif
 
-    // Implementations of HTMLInputElement::stepUp() and stepDown().
-    WEBCORE_EXPORT void stepUp(int, ExceptionCode&);
-    WEBCORE_EXPORT void stepDown(int, ExceptionCode&);
-    void stepUp(ExceptionCode& ec) { stepUp(1, ec); }
-    void stepDown(ExceptionCode& ec) { stepDown(1, ec); }
+    WEBCORE_EXPORT ExceptionOr<void> stepUp(int = 1);
+    WEBCORE_EXPORT ExceptionOr<void> stepDown(int = 1);
+
     // stepUp()/stepDown() for user-interaction.
     bool isSteppable() const;
 
@@ -173,8 +165,7 @@ public:
     WEBCORE_EXPORT void setType(const AtomicString&);
 
     WEBCORE_EXPORT String value() const final;
-    void setValue(const String&, ExceptionCode&, TextFieldEventBehavior = DispatchNoEvent);
-    WEBCORE_EXPORT void setValue(const String&, TextFieldEventBehavior = DispatchNoEvent);
+    WEBCORE_EXPORT ExceptionOr<void> setValue(const String&, TextFieldEventBehavior = DispatchNoEvent);
     WEBCORE_EXPORT void setValueForUser(const String&);
     // Checks if the specified string would be a valid value.
     // We should not call this for types with no string value such as CHECKBOX and RADIO.
@@ -191,10 +182,10 @@ public:
     WEBCORE_EXPORT void setEditingValue(const String&);
 
     WEBCORE_EXPORT double valueAsDate() const;
-    WEBCORE_EXPORT void setValueAsDate(double, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setValueAsDate(double);
 
     WEBCORE_EXPORT double valueAsNumber() const;
-    WEBCORE_EXPORT void setValueAsNumber(double, ExceptionCode&, TextFieldEventBehavior = DispatchNoEvent);
+    WEBCORE_EXPORT ExceptionOr<void> setValueAsNumber(double, TextFieldEventBehavior = DispatchNoEvent);
 
     String valueWithDefault() const;
 
@@ -232,8 +223,7 @@ public:
     String accept() const;
     WEBCORE_EXPORT String alt() const;
 
-    WEBCORE_EXPORT void setSize(unsigned);
-    void setSize(unsigned, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setSize(unsigned);
 
     URL src() const;
 
@@ -318,8 +308,8 @@ public:
     static Vector<FileChooserFileInfo> filesFromFileInputFormControlState(const FormControlState&);
 
     bool matchesReadWritePseudoClass() const final;
-    WEBCORE_EXPORT void setRangeText(const String& replacement, ExceptionCode&) final;
-    WEBCORE_EXPORT void setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionCode&) final;
+    WEBCORE_EXPORT ExceptionOr<void> setRangeText(const String& replacement) final;
+    WEBCORE_EXPORT ExceptionOr<void> setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode) final;
 
     HTMLImageLoader* imageLoader() { return m_imageLoader.get(); }
     HTMLImageLoader& ensureImageLoader();
@@ -469,5 +459,4 @@ private:
 #endif
 };
 
-} //namespace
-#endif
+}
index f54a845..26af00c 100644 (file)
@@ -44,8 +44,8 @@
     attribute boolean indeterminate;
     [Conditional=DATALIST_ELEMENT] readonly attribute HTMLElement list;
     [Reflect] attribute DOMString max;
-    [SetterMayThrowLegacyException] attribute long minLength;
-    [SetterMayThrowLegacyException] attribute long maxLength;
+    [SetterMayThrowException] attribute long minLength;
+    [SetterMayThrowException] attribute long maxLength;
     [Reflect] attribute DOMString min;
     [Reflect] attribute boolean multiple;
     [Reflect] attribute DOMString name;
     [Reflect] attribute DOMString placeholder;
     [Reflect] attribute boolean readOnly;
     [Reflect] attribute boolean required;
-    [SetterMayThrowLegacyException] attribute unsigned long size; // Changed string -> long -> unsigned long
+    [SetterMayThrowException] attribute unsigned long size;
     [Reflect, URL] attribute USVString src;
     [Reflect] attribute DOMString step;
     attribute DOMString type; // readonly dropped as part of DOM level 2
     attribute DOMString defaultValue;
     // See the discussion in https://bugs.webkit.org/show_bug.cgi?id=100085
-    [TreatNullAs=EmptyString, SetterMayThrowLegacyException] attribute DOMString value;
-    [SetterMayThrowLegacyException] attribute Date? valueAsDate;
-    [SetterMayThrowLegacyException] attribute unrestricted double valueAsNumber;
+    [TreatNullAs=EmptyString, SetterMayThrowException] attribute DOMString value;
+    [SetterMayThrowException] attribute Date? valueAsDate;
+    [SetterMayThrowException] attribute unrestricted double valueAsNumber;
 
-    [MayThrowLegacyException] void stepUp(optional long n = 1);
-    [MayThrowLegacyException] void stepDown(optional long n = 1);
+    [MayThrowException] void stepUp(optional long n = 1);
+    [MayThrowException] void stepDown(optional long n = 1);
 
     attribute unsigned long width;
     readonly attribute boolean willValidate;
     [Custom] attribute long selectionEnd;
     [Custom] attribute DOMString selectionDirection;
 
-    [MayThrowLegacyException] void setRangeText(DOMString replacement);
-    [MayThrowLegacyException] void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional DOMString selectionMode);
+    [MayThrowException] void setRangeText(DOMString replacement);
+    [MayThrowException] void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional DOMString selectionMode);
 
     [Custom] void setSelectionRange(long start, long end, optional DOMString direction);
 
-    // Non-standard attributes
     [Reflect] attribute DOMString align;
     [Reflect] attribute DOMString useMap;
     [Reflect] attribute boolean incremental;
index 9c8a2a9..baf71c2 100644 (file)
@@ -45,7 +45,7 @@ inline HTMLMarqueeElement::HTMLMarqueeElement(const QualifiedName& tagName, Docu
 
 Ref<HTMLMarqueeElement> HTMLMarqueeElement::create(const QualifiedName& tagName, Document& document)
 {
-    Ref<HTMLMarqueeElement> marqueeElement = adoptRef(*new HTMLMarqueeElement(tagName, document));
+    auto marqueeElement = adoptRef(*new HTMLMarqueeElement(tagName, document));
     marqueeElement->suspendIfNeeded();
     return marqueeElement;
 }
@@ -112,14 +112,14 @@ void HTMLMarqueeElement::collectStyleForPresentationAttribute(const QualifiedNam
 
 void HTMLMarqueeElement::start()
 {
-    if (RenderMarquee* marqueeRenderer = renderMarquee())
-        marqueeRenderer->start();
+    if (auto* renderer = renderMarquee())
+        renderer->start();
 }
 
 void HTMLMarqueeElement::stop()
 {
-    if (RenderMarquee* marqueeRenderer = renderMarquee())
-        marqueeRenderer->stop();
+    if (auto* renderer = renderMarquee())
+        renderer->stop();
 }
 
 unsigned HTMLMarqueeElement::scrollAmount() const
@@ -149,12 +149,12 @@ int HTMLMarqueeElement::loop() const
     return ok && loopValue > 0 ? loopValue : -1;
 }
     
-void HTMLMarqueeElement::setLoop(int loop, ExceptionCode& ec)
+ExceptionOr<void> HTMLMarqueeElement::setLoop(int loop)
 {
     if (loop <= 0 && loop != -1)
-        ec = INDEX_SIZE_ERR;
-    else
-        setIntegralAttribute(loopAttr, loop);
+        return Exception { INDEX_SIZE_ERR };
+    setIntegralAttribute(loopAttr, loop);
+    return { };
 }
 
 bool HTMLMarqueeElement::canSuspendForDocumentSuspension() const
@@ -176,9 +176,9 @@ void HTMLMarqueeElement::resume()
 
 RenderMarquee* HTMLMarqueeElement::renderMarquee() const
 {
-    if (renderer() && renderer()->hasLayer())
-        return renderBoxModelObject()->layer()->marquee();
-    return 0;
+    if (!renderer() || !renderer()->hasLayer())
+        return nullptr;
+    return renderBoxModelObject()->layer()->marquee();
 }
 
 } // namespace WebCore
index 62a777b..13b1472 100644 (file)
@@ -20,8 +20,7 @@
  *
  */
 
-#ifndef HTMLMarqueeElement_h
-#define HTMLMarqueeElement_h
+#pragma once
 
 #include "ActiveDOMObject.h"
 #include "HTMLElement.h"
@@ -36,8 +35,6 @@ public:
 
     int minimumDelay() const;
 
-    // DOM Functions
-
     WEBCORE_EXPORT void start();
     WEBCORE_EXPORT void stop() final;
     
@@ -51,7 +48,7 @@ public:
     
     // Loop count. -1 means loop indefinitely.
     WEBCORE_EXPORT int loop() const;
-    WEBCORE_EXPORT void setLoop(int, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setLoop(int);
     
 private:
     HTMLMarqueeElement(const QualifiedName&, Document&);
@@ -59,7 +56,6 @@ private:
     bool isPresentationAttribute(const QualifiedName&) const final;
     void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) final;
 
-    // ActiveDOMObject
     bool canSuspendForDocumentSuspension() const final;
     void suspend(ReasonForSuspension) final;
     void resume() final;
@@ -69,5 +65,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // HTMLMarqueeElement_h
index 6c70ca7..c76b459 100644 (file)
@@ -26,7 +26,7 @@ interface HTMLMarqueeElement : HTMLElement {
     [Reflect] attribute DOMString direction;
     [Reflect] attribute DOMString height;
     [Reflect] attribute unsigned long hspace;
-    [SetterMayThrowLegacyException] attribute long loop;
+    [SetterMayThrowException] attribute long loop;
     attribute unsigned long scrollAmount;
     attribute unsigned long scrollDelay;
     [Reflect] attribute boolean trueSpeed;
index 34952e5..b6f035f 100644 (file)
@@ -286,10 +286,7 @@ struct HTMLMediaElement::TrackGroup {
     enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, Other };
 
     TrackGroup(GroupKind kind)
-        : visibleTrack(0)
-        , defaultTrack(0)
-        , kind(kind)
-        , hasSrcLang(false)
+        : kind(kind)
     {
     }
 
@@ -297,7 +294,7 @@ struct HTMLMediaElement::TrackGroup {
     RefPtr<TextTrack> visibleTrack;
     RefPtr<TextTrack> defaultTrack;
     GroupKind kind;
-    bool hasSrcLang;
+    bool hasSrcLang { false };
 };
 
 HashSet<HTMLMediaElement*>& HTMLMediaElement::allMediaElements()
@@ -397,37 +394,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
     , m_scanTimer(*this, &HTMLMediaElement::scanTimerFired)
     , m_playbackControlsManagerBehaviorRestrictionsTimer(*this, &HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired)
     , m_seekToPlaybackPositionEndedTimer(*this, &HTMLMediaElement::seekToPlaybackPositionEndedTimerFired)
-    , m_playedTimeRanges()
     , m_asyncEventQueue(*this)
-    , m_requestedPlaybackRate(1)
-    , m_reportedPlaybackRate(1)
-    , m_defaultPlaybackRate(1)
-    , m_webkitPreservesPitch(true)
-    , m_networkState(NETWORK_EMPTY)
-    , m_readyState(HAVE_NOTHING)
-    , m_readyStateMaximum(HAVE_NOTHING)
-    , m_volume(1.0f)
-    , m_volumeInitialized(false)
-    , m_previousProgressTime(std::numeric_limits<double>::max())
-    , m_clockTimeAtLastUpdateEvent(0)
     , m_lastTimeUpdateEventMovieTime(MediaTime::positiveInfiniteTime())
-    , m_loadState(WaitingForSource)
-    , m_videoFullscreenMode(VideoFullscreenModeNone)
-#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-    , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
-#endif
-    , m_preload(MediaPlayer::Auto)
-    , m_displayMode(Unknown)
-    , m_processingMediaPlayerCallback(0)
-#if ENABLE(MEDIA_SOURCE)
-    , m_droppedVideoFrames(0)
-#endif
-    , m_clockTimeAtLastCachedTimeUpdate(0)
-    , m_minimumClockTimeToUpdateCachedTime(0)
-    , m_pendingActionFlags(0)
-    , m_actionAfterScan(Nothing)
-    , m_scanType(Scan)
-    , m_scanDirection(Forward)
     , m_firstTimePlaying(true)
     , m_playing(false)
     , m_isWaitingUntilMediaCanStart(false)
@@ -464,21 +432,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
     , m_tracksAreReady(true)
     , m_haveVisibleTextTrack(false)
     , m_processingPreferenceChange(false)
-    , m_lastTextTrackUpdateTime(MediaTime(-1, 1))
-    , m_captionDisplayMode(CaptionUserPreferences::Automatic)
-    , m_audioTracks(0)
-    , m_textTracks(0)
-    , m_videoTracks(0)
-    , m_ignoreTrackDisplayUpdate(0)
-#endif
-#if ENABLE(WEB_AUDIO)
-    , m_audioSourceNode(0)
 #endif
     , m_mediaSession(std::make_unique<MediaElementSession>(*this))
-    , m_reportedExtraMemoryCost(0)
-#if ENABLE(MEDIA_STREAM)
-    , m_mediaStreamSrcObject(nullptr)
-#endif
 {
     allMediaElements().add(this);
 
@@ -575,7 +530,7 @@ HTMLMediaElement::~HTMLMediaElement()
 #endif
 
     if (m_mediaController) {
-        m_mediaController->removeMediaElement(this);
+        m_mediaController->removeMediaElement(*this);
         m_mediaController = nullptr;
     }
 
@@ -584,7 +539,7 @@ HTMLMediaElement::~HTMLMediaElement()
 #endif
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
-    webkitSetMediaKeys(0);
+    webkitSetMediaKeys(nullptr);
 #endif
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
@@ -1460,7 +1415,7 @@ void HTMLMediaElement::loadResource(const URL& initialURL, ContentType& contentT
     // If the url should be loaded from the application cache, pass the url of the cached file
     // to the media engine.
     ApplicationCacheHost* cacheHost = frame->loader().documentLoader()->applicationCacheHost();
-    ApplicationCacheResource* resource = 0;
+    ApplicationCacheResource* resource = nullptr;
     if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceRequest(url), resource)) {
         // Resources that are not present in the manifest will always fail to load (at least, after the
         // cache has been primed the first time), making the testing of offline applications simpler.
@@ -1550,8 +1505,8 @@ void HTMLMediaElement::loadResource(const URL& initialURL, ContentType& contentT
 }
 
 #if ENABLE(VIDEO_TRACK)
-static bool trackIndexCompare(TextTrack* a,
-                              TextTrack* b)
+
+static bool trackIndexCompare(TextTrack* a, TextTrack* b)
 {
     return a->trackIndex() - b->trackIndex() < 0;
 }
@@ -1578,8 +1533,7 @@ static bool eventTimeCueCompare(const std::pair<MediaTime, TextTrackCue*>& a, co
 static bool compareCueInterval(const CueInterval& one, const CueInterval& two)
 {
     return one.data()->isOrderedBefore(two.data());
-};
-
+}
 
 void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
 {
@@ -1628,16 +1582,10 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
     // end times are less than or equal to the current playback position.
     // Otherwise, let missed cues be an empty list.
     if (lastTime >= MediaTime::zeroTime() && m_lastSeekTime < movieTime) {
-        CueList potentiallySkippedCues =
-            m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime));
-
-        for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) {
-            MediaTime cueStartTime = potentiallySkippedCues[i].low();
-            MediaTime cueEndTime = potentiallySkippedCues[i].high();
-
+        for (auto& cue : m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))) {
             // Consider cues that may have been missed since the last seek time.
-            if (cueStartTime > std::max(m_lastSeekTime, lastTime) && cueEndTime < movieTime)
-                missedCues.append(potentiallySkippedCues[i]);
+            if (cue.low() > std::max(m_lastSeekTime, lastTime) && cue.high() < movieTime)
+                missedCues.append(cue);
         }
     }
 
@@ -1709,8 +1657,7 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
     for (size_t i = 0; i < missedCuesSize; ++i) {
         // 9 - For each text track cue in missed cues, prepare an event named enter
         // for the TextTrackCue object with the text track cue start time.
-        eventTasks.append(std::make_pair(missedCues[i].data()->startMediaTime(),
-                                         missedCues[i].data()));
+        eventTasks.append({ missedCues[i].data()->startMediaTime(), missedCues[i].data() });
 
         // 10 - For each text track [...] in missed cues, prepare an event
         // named exit for the TextTrackCue object with the  with the later of
@@ -1722,7 +1669,7 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
         // affect sorting events before dispatch either, because the exit
         // event has the same time as the enter event.
         if (missedCues[i].data()->startMediaTime() < missedCues[i].data()->endMediaTime())
-            eventTasks.append(std::make_pair(missedCues[i].data()->endMediaTime(), missedCues[i].data()));
+            eventTasks.append({ missedCues[i].data()->endMediaTime(), missedCues[i].data() });
     }
 
     for (size_t i = 0; i < previousCuesSize; ++i) {
@@ -1730,8 +1677,7 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
         // track cue active flag set prepare an event named exit for the
         // TextTrackCue object with the text track cue end time.
         if (!currentCues.contains(previousCues[i]))
-            eventTasks.append(std::make_pair(previousCues[i].data()->endMediaTime(),
-                                             previousCues[i].data()));
+            eventTasks.append({ previousCues[i].data()->endMediaTime(), previousCues[i].data() });
     }
 
     for (size_t i = 0; i < currentCuesSize; ++i) {
@@ -1739,40 +1685,38 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
         // text track cue active flag set, prepare an event named enter for the
         // TextTrackCue object with the text track cue start time.
         if (!previousCues.contains(currentCues[i]))
-            eventTasks.append(std::make_pair(currentCues[i].data()->startMediaTime(),
-                                             currentCues[i].data()));
+            eventTasks.append({ currentCues[i].data()->startMediaTime(), currentCues[i].data() });
     }
 
     // 12 - Sort the tasks in events in ascending time order (tasks with earlier
     // times first).
     std::sort(eventTasks.begin(), eventTasks.end(), eventTimeCueCompare);
 
-    for (size_t i = 0; i < eventTasks.size(); ++i) {
-        if (!affectedTracks.contains(eventTasks[i].second->track()))
-            affectedTracks.append(eventTasks[i].second->track());
+    for (auto& eventTask : eventTasks) {
+        if (!affectedTracks.contains(eventTask.second->track()))
+            affectedTracks.append(eventTask.second->track());
 
         // 13 - Queue each task in events, in list order.
-        RefPtr<Event> event;
 
         // Each event in eventTasks may be either an enterEvent or an exitEvent,
         // depending on the time that is associated with the event. This
         // correctly identifies the type of the event, if the startTime is
         // less than the endTime in the cue.
-        if (eventTasks[i].second->startTime() >= eventTasks[i].second->endTime()) {
-            event = Event::create(eventNames().enterEvent, false, false);
-            event->setTarget(eventTasks[i].second);
-            m_asyncEventQueue.enqueueEvent(WTFMove(event));
-
-            event = Event::create(eventNames().exitEvent, false, false);
-            event->setTarget(eventTasks[i].second);
-            m_asyncEventQueue.enqueueEvent(WTFMove(event));
+        if (eventTask.second->startTime() >= eventTask.second->endTime()) {
+            auto enterEvent = Event::create(eventNames().enterEvent, false, false);
+            enterEvent->setTarget(eventTask.second);
+            m_asyncEventQueue.enqueueEvent(WTFMove(enterEvent));
+
+            auto exitEvent = Event::create(eventNames().exitEvent, false, false);
+            exitEvent->setTarget(eventTask.second);
+            m_asyncEventQueue.enqueueEvent(WTFMove(exitEvent));
         } else {
-            if (eventTasks[i].first == eventTasks[i].second->startMediaTime())
+            RefPtr<Event> event;
+            if (eventTask.first == eventTask.second->startMediaTime())
                 event = Event::create(eventNames().enterEvent, false, false);
             else
                 event = Event::create(eventNames().exitEvent, false, false);
-
-            event->setTarget(eventTasks[i].second);
+            event->setTarget(eventTask.second);
             m_asyncEventQueue.enqueueEvent(WTFMove(event));
         }
     }
@@ -1783,20 +1727,18 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
 
     // 15 - For each text track in affected tracks, in the list order, queue a
     // task to fire a simple event named cuechange at the TextTrack object, and, ...
-    for (size_t i = 0; i < affectedTracks.size(); ++i) {
-        RefPtr<Event> event = Event::create(eventNames().cuechangeEvent, false, false);
-        event->setTarget(affectedTracks[i]);
-
+    for (auto& affectedTrack : affectedTracks) {
+        auto event = Event::create(eventNames().cuechangeEvent, false, false);
+        event->setTarget(affectedTrack);
         m_asyncEventQueue.enqueueEvent(WTFMove(event));
 
         // ... if the text track has a corresponding track element, to then fire a
         // simple event named cuechange at the track element as well.
-        if (is<LoadableTextTrack>(*affectedTracks[i])) {
-            RefPtr<Event> event = Event::create(eventNames().cuechangeEvent, false, false);
-            HTMLTrackElement* trackElement = downcast<LoadableTextTrack>(*affectedTracks[i]).trackElement();
+        if (is<LoadableTextTrack>(*affectedTrack)) {
+            auto event = Event::create(eventNames().cuechangeEvent, false, false);
+            auto* trackElement = downcast<LoadableTextTrack>(*affectedTrack).trackElement();
             ASSERT(trackElement);
             event->setTarget(trackElement);
-            
             m_asyncEventQueue.enqueueEvent(WTFMove(event));
         }
     }
@@ -1863,7 +1805,7 @@ void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
     if (track->trackType() == TextTrack::TrackElement) {
         trackIsLoaded = false;
         for (auto& trackElement : childrenOfType<HTMLTrackElement>(*this)) {
-            if (trackElement.track() == track) {
+            if (&trackElement.track() == track) {
                 if (trackElement.readyState() == HTMLTrackElement::LOADING || trackElement.readyState() == HTMLTrackElement::LOADED)
                     trackIsLoaded = true;
                 break;
@@ -2477,7 +2419,7 @@ void HTMLMediaElement::webkitSetMediaKeys(WebKitMediaKeys* mediaKeys)
         return;
 
     if (m_mediaKeys)
-        m_mediaKeys->setMediaElement(0);
+        m_mediaKeys->setMediaElement(nullptr);
     m_mediaKeys = mediaKeys;
     if (m_mediaKeys)
         m_mediaKeys->setMediaElement(this);
@@ -2488,6 +2430,7 @@ void HTMLMediaElement::keyAdded()
     if (m_player)
         m_player->keyAdded();
 }
+
 #endif
 
 void HTMLMediaElement::progressEventTimerFired()
@@ -2884,16 +2827,12 @@ void HTMLMediaElement::setCurrentTime(const MediaTime& time)
     seekInternal(time);
 }
 
-void HTMLMediaElement::setCurrentTime(double time, ExceptionCode& ec)
+ExceptionOr<void> HTMLMediaElement::setCurrentTimeForBindings(double time)
 {
-    // On setting, if the media element has a current media controller, then the user agent must
-    // throw an InvalidStateError exception
-    if (m_mediaController) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
-
+    if (m_mediaController)
+        return Exception { INVALID_STATE_ERR };
     seek(MediaTime::createWithDouble(time));
+    return { };
 }
 
 double HTMLMediaElement::duration() const
@@ -3136,7 +3075,7 @@ bool HTMLMediaElement::playInternal()
         seekInternal(MediaTime::zeroTime());
 
     if (m_mediaController)
-        m_mediaController->bringElementUpToSpeed(this);
+        m_mediaController->bringElementUpToSpeed(*this);
 
     if (m_paused) {
         m_paused = false;
@@ -3274,23 +3213,23 @@ double HTMLMediaElement::volume() const
     return m_volume;
 }
 
-void HTMLMediaElement::setVolume(double vol, ExceptionCode& ec)
+ExceptionOr<void> HTMLMediaElement::setVolume(double volume)
 {
-    LOG(Media, "HTMLMediaElement::setVolume(%p) - %f", this, vol);
+    LOG(Media, "HTMLMediaElement::setVolume(%p) - %f", this, volume);
+
+    if (!(volume >= 0 && volume <= 1))
+        return Exception { INDEX_SIZE_ERR };
 
-    if (vol < 0.0f || vol > 1.0f) {
-        ec = INDEX_SIZE_ERR;
-        return;
-    }
-    
 #if !PLATFORM(IOS)
-    if (m_volume != vol) {
-        m_volume = vol;
-        m_volumeInitialized = true;
-        updateVolume();
-        scheduleEvent(eventNames().volumechangeEvent);
-    }
+    if (m_volume == volume)
+        return { };
+
+    m_volume = volume;
+    m_volumeInitialized = true;
+    updateVolume();
+    scheduleEvent(eventNames().volumechangeEvent);
 #endif
+    return { };
 }
 
 bool HTMLMediaElement::muted() const
@@ -3523,19 +3462,19 @@ double HTMLMediaElement::percentLoaded() const
 
 #if ENABLE(VIDEO_TRACK)
 
-void HTMLMediaElement::mediaPlayerDidAddAudioTrack(PassRefPtr<AudioTrackPrivate> prpTrack)
+void HTMLMediaElement::mediaPlayerDidAddAudioTrack(AudioTrackPrivate& track)
 {
     if (isPlaying() && !m_mediaSession->playbackPermitted(*this))
         pauseInternal();
 
-    addAudioTrack(AudioTrack::create(this, prpTrack));
+    addAudioTrack(AudioTrack::create(this, &track));
 }
 
-void HTMLMediaElement::mediaPlayerDidAddTextTrack(PassRefPtr<InbandTextTrackPrivate> prpTrack)
+void HTMLMediaElement::mediaPlayerDidAddTextTrack(InbandTextTrackPrivate& track)
 {
     // 4.8.10.12.2 Sourcing in-band text tracks
     // 1. Associate the relevant data with a new text track and its corresponding new TextTrack object.
-    RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(ActiveDOMObject::scriptExecutionContext(), this, prpTrack);
+    RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(ActiveDOMObject::scriptExecutionContext(), this, &track);
     textTrack->setMediaElement(this);
     
     // 2. Set the new text track's kind, label, and language based on the semantics of the relevant data,
@@ -3564,24 +3503,24 @@ void HTMLMediaElement::mediaPlayerDidAddTextTrack(PassRefPtr<InbandTextTrackPriv
     addTextTrack(textTrack.releaseNonNull());
 }
 
-void HTMLMediaElement::mediaPlayerDidAddVideoTrack(PassRefPtr<VideoTrackPrivate> prpTrack)
+void HTMLMediaElement::mediaPlayerDidAddVideoTrack(VideoTrackPrivate& track)
 {
-    addVideoTrack(VideoTrack::create(this, prpTrack));
+    addVideoTrack(VideoTrack::create(this, &track));
 }
 
-void HTMLMediaElement::mediaPlayerDidRemoveAudioTrack(PassRefPtr<AudioTrackPrivate> prpTrack)
+void HTMLMediaElement::mediaPlayerDidRemoveAudioTrack(AudioTrackPrivate& track)
 {
-    prpTrack->willBeRemoved();
+    track.willBeRemoved();
 }
 
-void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(PassRefPtr<InbandTextTrackPrivate> prpTrack)
+void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(InbandTextTrackPrivate& track)
 {
-    prpTrack->willBeRemoved();
+    track.willBeRemoved();
 }
 
-void HTMLMediaElement::mediaPlayerDidRemoveVideoTrack(PassRefPtr<VideoTrackPrivate> prpTrack)
+void HTMLMediaElement::mediaPlayerDidRemoveVideoTrack(VideoTrackPrivate& track)
 {
-    prpTrack->willBeRemoved();
+    track.willBeRemoved();
 }
 
 void HTMLMediaElement::closeCaptionTracksChanged()
@@ -3655,16 +3594,14 @@ void HTMLMediaElement::forgetResourceSpecificTracks()
         removeVideoTrack(*m_videoTracks->lastItem());
 }
 
-RefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const String& label, const String& language, ExceptionCode& ec)
+ExceptionOr<Ref<TextTrack>> HTMLMediaElement::addTextTrack(const String& kind, const String& label, const String& language)
 {
     // 4.8.10.12.4 Text track API
     // The addTextTrack(kind, label, language) method of media elements, when invoked, must run the following steps:
 
     // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps
-    if (!TextTrack::isValidKindKeyword(kind)) {
-        ec = TypeError;
-        return nullptr;
-    }
+    if (!TextTrack::isValidKindKeyword(kind))
+        return Exception { TypeError };
 
     // 2. If the label argument was omitted, let label be the empty string.
     // 3. If the language argument was omitted, let language be the empty string.
@@ -3713,20 +3650,16 @@ VideoTrackList& HTMLMediaElement::videoTracks()
     return *m_videoTracks;
 }
 
-void HTMLMediaElement::didAddTextTrack(HTMLTrackElement* trackElement)
+void HTMLMediaElement::didAddTextTrack(HTMLTrackElement& trackElement)
 {
-    ASSERT(trackElement->hasTagName(trackTag));
+    ASSERT(trackElement.hasTagName(trackTag));
 
     // 4.8.10.12.3 Sourcing out-of-band text tracks
     // When a track element's parent element changes and the new parent is a media element, 
     // then the user agent must add the track element's corresponding text track to the 
     // media element's list of text tracks ... [continues in TextTrackList::append]
-    RefPtr<TextTrack> textTrack = trackElement->track();
-    if (!textTrack)
-        return;
-    
-    addTextTrack(textTrack.releaseNonNull());
-    
+    addTextTrack(trackElement.track());
+
     // Do not schedule the track loading until parsing finishes so we don't start before all tracks
     // in the markup have been added.
     if (!m_parsingInProgress)
@@ -3736,22 +3669,20 @@ void HTMLMediaElement::didAddTextTrack(HTMLTrackElement* trackElement)
         mediaControls()->closedCaptionTracksChanged();
 }
 
-void HTMLMediaElement::didRemoveTextTrack(HTMLTrackElement* trackElement)
+void HTMLMediaElement::didRemoveTextTrack(HTMLTrackElement& trackElement)
 {
-    ASSERT(trackElement->hasTagName(trackTag));
+    ASSERT(trackElement.hasTagName(trackTag));
 
 #if !LOG_DISABLED
-    if (trackElement->hasTagName(trackTag)) {
-        URL url = trackElement->getNonEmptyURLAttribute(srcAttr);
+    if (trackElement.hasTagName(trackTag)) {
+        URL url = trackElement.getNonEmptyURLAttribute(srcAttr);
         LOG(Media, "HTMLMediaElement::didRemoveTrack(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
     }
 #endif
 
-    RefPtr<TextTrack> textTrack = trackElement->track();
-    if (!textTrack)
-        return;
-    
-    textTrack->setHasBeenConfigured(false);
+    auto& textTrack = trackElement.track();
+
+    textTrack.setHasBeenConfigured(false);
 
     if (!m_textTracks)
         return;
@@ -3760,11 +3691,9 @@ void HTMLMediaElement::didRemoveTextTrack(HTMLTrackElement* trackElement)
     // When a track element's parent element changes and the old parent was a media element, 
     // then the user agent must remove the track element's corresponding text track from the 
     // media element's list of text tracks.
-    removeTextTrack(*textTrack);
+    removeTextTrack(textTrack);
 
-    size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
-    if (index != notFound)
-        m_textTracksWhenResourceSelectionBegan.remove(index);
+    m_textTracksWhenResourceSelectionBegan.removeFirst(&textTrack);
 }
 
 void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
@@ -4212,7 +4141,7 @@ URL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* ke
         // A 'beforeload' event handler can mutate the DOM, so check to see if the source element is still a child node.
         if (node.parentNode() != this) {
             LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'beforeload' removed current element", this);
-            source = 0;
+            source = nullptr;
             goto CheckAgain;
         }
 
@@ -4703,12 +4632,11 @@ Ref<TimeRanges> HTMLMediaElement::buffered() const
 
 double HTMLMediaElement::maxBufferedTime() const
 {
-    RefPtr<TimeRanges> bufferedRanges = buffered();
+    auto bufferedRanges = buffered();
     unsigned numRanges = bufferedRanges->length();
     if (!numRanges)
         return 0;
-
-    return bufferedRanges->end(numRanges - 1, ASSERT_NO_EXCEPTION);
+    return bufferedRanges.get().ranges().end(numRanges - 1).toDouble();
 }
 
 Ref<TimeRanges> HTMLMediaElement::played()
@@ -6068,7 +5996,7 @@ void HTMLMediaElement::setMediaGroup(const String& group)
     // attribute is set, changed, or removed, the user agent must run the following steps:
     // 1. Let m [this] be the media element in question.
     // 2. Let m have no current media controller, if it currently has one.
-    setController(0);
+    setController(nullptr);
 
     // 3. If m's mediagroup attribute is being removed, then abort these steps.
     if (group.isEmpty())
@@ -6102,12 +6030,12 @@ MediaController* HTMLMediaElement::controller() const
 void HTMLMediaElement::setController(PassRefPtr<MediaController> controller)
 {
     if (m_mediaController)
-        m_mediaController->removeMediaElement(this);
+        m_mediaController->removeMediaElement(*this);
 
     m_mediaController = controller;
 
     if (m_mediaController)
-        m_mediaController->addMediaElement(this);
+        m_mediaController->addMediaElement(*this);
 
     if (hasMediaControls())
         mediaControls()->setMediaController(m_mediaController ? m_mediaController.get() : static_cast<MediaControllerInterface*>(this));
@@ -6268,7 +6196,7 @@ Vector<RefPtr<PlatformTextTrack>> HTMLMediaElement::outOfBandTrackSources()
         if (!isAllowedToLoadMediaURL(*this, url, trackElement.isInUserAgentShadowTree()))
             continue;
 
-        auto& track = *trackElement.track();
+        auto& track = trackElement.track();
         auto kind = track.kind();
 
         // FIXME: The switch statement below preserves existing behavior where we ignore chapters and metadata tracks.
index 6edc005..5aa95b9 100644 (file)
@@ -83,14 +83,12 @@ class URL;
 class VideoPlaybackQuality;
 class VideoTrackList;
 class VideoTrackPrivate;
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
 class WebKitMediaKeys;
-#endif
 
 #if ENABLE(VIDEO_TRACK)
-typedef PODIntervalTree<MediaTime, TextTrackCue*> CueIntervalTree;
-typedef CueIntervalTree::IntervalType CueInterval;
-typedef Vector<CueInterval> CueList;
+using CueIntervalTree = PODIntervalTree<MediaTime, TextTrackCue*>;
+using CueInterval = CueIntervalTree::IntervalType;
+using CueList = Vector<CueInterval>;
 #endif
 
 class HTMLMediaElement
@@ -192,8 +190,9 @@ public:
 // playback state
     WEBCORE_EXPORT double currentTime() const override;
     void setCurrentTime(double) override;
-    virtual void setCurrentTime(double, ExceptionCode&);
-    virtual double getStartDate() const;
+    double currentTimeForBindings() const { return currentTime(); }
+    WEBCORE_EXPORT ExceptionOr<void> setCurrentTimeForBindings(double);
+    WEBCORE_EXPORT double getStartDate() const;
     WEBCORE_EXPORT double duration() const override;
     WEBCORE_EXPORT bool paused() const override;
     double defaultPlaybackRate() const override;
@@ -261,7 +260,7 @@ public:
     WEBCORE_EXPORT bool controls() const;
     WEBCORE_EXPORT void setControls(bool);
     WEBCORE_EXPORT double volume() const override;
-    void setVolume(double, ExceptionCode&) override;
+    ExceptionOr<void> setVolume(double) override;
     WEBCORE_EXPORT bool muted() const override;
     WEBCORE_EXPORT void setMuted(bool) override;
 
@@ -278,7 +277,7 @@ public:
     double percentLoaded() const;
 
 #if ENABLE(VIDEO_TRACK)
-    RefPtr<TextTrack> addTextTrack(const String& kind, const String& label, const String& language, ExceptionCode&);
+    ExceptionOr<Ref<TextTrack>> addTextTrack(const String& kind, const String& label, const String& language);
 
     AudioTrackList& audioTracks();
     TextTrackList& textTracks();
@@ -296,18 +295,18 @@ public:
     void closeCaptionTracksChanged();
     void notifyMediaPlayerOfTextTrackChanges();
 
-    virtual void didAddTextTrack(HTMLTrackElement*);
-    virtual void didRemoveTextTrack(HTMLTrackElement*);
+    virtual void didAddTextTrack(HTMLTrackElement&);
+    virtual void didRemoveTextTrack(HTMLTrackElement&);
 
-    void mediaPlayerDidAddAudioTrack(PassRefPtr<AudioTrackPrivate>) override;
-    void mediaPlayerDidAddTextTrack(PassRefPtr<InbandTextTrackPrivate>) override;
-    void mediaPlayerDidAddVideoTrack(PassRefPtr<VideoTrackPrivate>) override;
-    void mediaPlayerDidRemoveAudioTrack(PassRefPtr<AudioTrackPrivate>) override;
-    void mediaPlayerDidRemoveTextTrack(PassRefPtr<InbandTextTrackPrivate>) override;
-    void mediaPlayerDidRemoveVideoTrack(PassRefPtr<VideoTrackPrivate>) override;
+    void mediaPlayerDidAddAudioTrack(AudioTrackPrivate&) final;
+    void mediaPlayerDidAddTextTrack(InbandTextTrackPrivate&) final;
+    void mediaPlayerDidAddVideoTrack(VideoTrackPrivate&) final;
+    void mediaPlayerDidRemoveAudioTrack(AudioTrackPrivate&) final;
+    void mediaPlayerDidRemoveTextTrack(InbandTextTrackPrivate&) final;
+    void mediaPlayerDidRemoveVideoTrack(VideoTrackPrivate&) final;
 
 #if ENABLE(AVF_CAPTIONS)
-    Vector<RefPtr<PlatformTextTrack>> outOfBandTrackSources() override;
+    Vector<RefPtr<PlatformTextTrack>> outOfBandTrackSources() final;
 #endif
 
     struct TrackGroup;
@@ -325,8 +324,9 @@ public:
     // AudioTrackClient
     void audioTrackEnabledChanged(AudioTrack*) override;
 
+    void textTrackReadyStateChanged(TextTrack*);
+
     // TextTrackClient
-    virtual void textTrackReadyStateChanged(TextTrack*);
     void textTrackKindChanged(TextTrack*) override;
     void textTrackModeChanged(TextTrack*) override;
     void textTrackAddCues(TextTrack*, const TextTrackCueList*) override;
@@ -823,13 +823,13 @@ private:
 
     Vector<PlayPromise> m_pendingPlayPromises;
 
-    double m_requestedPlaybackRate;
-    double m_reportedPlaybackRate;
-    double m_defaultPlaybackRate;
-    bool m_webkitPreservesPitch;
-    NetworkState m_networkState;
-    ReadyState m_readyState;
-    ReadyState m_readyStateMaximum;
+    double m_requestedPlaybackRate { 1 };
+    double m_reportedPlaybackRate { 1 };
+    double m_defaultPlaybackRate { 1 };
+    bool m_webkitPreservesPitch { true };
+    NetworkState m_networkState { NETWORK_EMPTY };
+    ReadyState m_readyState { HAVE_NOTHING };
+    ReadyState m_readyStateMaximum { HAVE_NOTHING };
     URL m_currentSrc;
 
     RefPtr<MediaError> m_error;
@@ -850,44 +850,44 @@ private:
     std::unique_ptr<PendingSeek> m_pendingSeek;
     SeekType m_pendingSeekType { NoSeek };
 
-    double m_volume;
-    bool m_volumeInitialized;
+    double m_volume { 1 };
+    bool m_volumeInitialized { false };
     MediaTime m_lastSeekTime;
     
-    double m_previousProgressTime;
+    double m_previousProgressTime { std::numeric_limits<double>::max() };
     double m_playbackStartedTime { 0 };
 
     // The last time a timeupdate event was sent (based on monotonic clock).
-    double m_clockTimeAtLastUpdateEvent;
+    double m_clockTimeAtLastUpdateEvent { 0 };
 
     // The last time a timeupdate event was sent in movie time.
     MediaTime m_lastTimeUpdateEventMovieTime;
     
     // Loading state.
     enum LoadState { WaitingForSource, LoadingFromSrcAttr, LoadingFromSourceElement };
-    LoadState m_loadState;
+    LoadState m_loadState { WaitingForSource };
     RefPtr<HTMLSourceElement> m_currentSourceNode;
     RefPtr<Node> m_nextChildNodeToConsider;
 
-    VideoFullscreenMode m_videoFullscreenMode;
+    VideoFullscreenMode m_videoFullscreenMode { VideoFullscreenModeNone };
     bool m_preparedForInline;
     std::function<void()> m_preparedForInlineCompletionHandler;
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     RetainPtr<PlatformLayer> m_videoFullscreenLayer;
     FloatRect m_videoFullscreenFrame;
-    MediaPlayerEnums::VideoGravity m_videoFullscreenGravity;
+    MediaPlayerEnums::VideoGravity m_videoFullscreenGravity { MediaPlayer::VideoGravityResizeAspect };
 #endif
 
     std::unique_ptr<MediaPlayer> m_player;
 
-    MediaPlayerEnums::Preload m_preload;
+    MediaPlayerEnums::Preload m_preload { MediaPlayer::Auto };
 
-    DisplayMode m_displayMode;
+    DisplayMode m_displayMode { Unknown };
 
     // Counter incremented while processing a callback from the media player, so we can avoid
     // calling the media engine recursively.
-    int m_processingMediaPlayerCallback;
+    int m_processingMediaPlayerCallback { 0 };
 
 #if ENABLE(MEDIA_SESSION)
     String m_kind;
@@ -898,27 +898,25 @@ private:
 
 #if ENABLE(MEDIA_SOURCE)
     RefPtr<MediaSource> m_mediaSource;
-    unsigned long m_droppedVideoFrames;
+    unsigned m_droppedVideoFrames { 0 };
 #endif
 
     mutable MediaTime m_cachedTime;
-    mutable double m_clockTimeAtLastCachedTimeUpdate;
-    mutable double m_minimumClockTimeToUpdateCachedTime;
+    mutable double m_clockTimeAtLastCachedTimeUpdate { 0 };
+    mutable double m_minimumClockTimeToUpdateCachedTime { 0 };
 
     MediaTime m_fragmentStartTime;
     MediaTime m_fragmentEndTime;
 
-    typedef unsigned PendingActionFlags;
-    PendingActionFlags m_pendingActionFlags;
+    using PendingActionFlags = unsigned;
+    PendingActionFlags m_pendingActionFlags { 0 };
 
-    enum ActionAfterScanType {
-        Nothing, Play, Pause
-    };
-    ActionAfterScanType m_actionAfterScan;
+    enum ActionAfterScanType { Nothing, Play, Pause };
+    ActionAfterScanType m_actionAfterScan { Nothing };
 
     enum ScanType { Seek, Scan };
-    ScanType m_scanType;
-    ScanDirection m_scanDirection;
+    ScanType m_scanType { Scan };
+    ScanDirection m_scanDirection { Forward };
 
     bool m_firstTimePlaying : 1;
     bool m_playing : 1;
@@ -971,9 +969,9 @@ private:
     bool m_processingPreferenceChange : 1;
 
     String m_subtitleTrackLanguage;
-    MediaTime m_lastTextTrackUpdateTime;
+    MediaTime m_lastTextTrackUpdateTime { -1, 1 };
 
-    CaptionUserPreferences::CaptionDisplayMode m_captionDisplayMode;
+    CaptionUserPreferences::CaptionDisplayMode m_captionDisplayMode { CaptionUserPreferences::Automatic };
 
     RefPtr<AudioTrackList> m_audioTracks;
     RefPtr<TextTrackList> m_textTracks;
@@ -983,7 +981,7 @@ private:
     CueIntervalTree m_cueTree;
 
     CueList m_currentlyActiveCues;
-    int m_ignoreTrackDisplayUpdate;
+    int m_ignoreTrackDisplayUpdate { 0 };
 
     bool m_requireCaptionPreferencesChangedCallbacks { false };
 #endif
@@ -992,7 +990,7 @@ private:
     // This is a weak reference, since m_audioSourceNode holds a reference to us.
     // The value is set just after the MediaElementAudioSourceNode is created.
     // The value is cleared in MediaElementAudioSourceNode::~MediaElementAudioSourceNode().
-    MediaElementAudioSourceNode* m_audioSourceNode;
+    MediaElementAudioSourceNode* m_audioSourceNode { nullptr };
 #endif
 
     String m_mediaGroup;
@@ -1009,7 +1007,7 @@ private:
 
     std::unique_ptr<MediaElementSession> m_mediaSession;
     PageActivityAssertionToken m_audioActivityToken;
-    size_t m_reportedExtraMemoryCost;
+    size_t m_reportedExtraMemoryCost { 0 };
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     friend class MediaControlsHost;
@@ -1029,11 +1027,10 @@ private:
 #endif
 };
 
-#if ENABLE(VIDEO_TRACK)
-#ifndef NDEBUG
+#if ENABLE(VIDEO_TRACK) && !defined(NDEBUG)
+
 // Template specialization required by PodIntervalTree in debug mode.
-template <>
-struct ValueToString<TextTrackCue*> {
+template <> struct ValueToString<TextTrackCue*> {
     static String string(TextTrackCue* const& cue)
     {
         String text;
@@ -1042,17 +1039,18 @@ struct ValueToString<TextTrackCue*> {
         return String::format("%p id=%s interval=%s-->%s cue=%s)", cue, cue->id().utf8().data(), toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data(), text.utf8().data());
     }
 };
-#endif
+
 #endif
 
 #ifndef NDEBUG
-template<>
-struct ValueToString<MediaTime> {
+
+template<> struct ValueToString<MediaTime> {
     static String string(const MediaTime& time)
     {
         return toString(time);
     }
 };
+
 #endif
 
 } // namespace WebCore
index e22366c..7de1e54 100644 (file)
@@ -60,7 +60,7 @@
     readonly attribute boolean seeking;
 
     // playback state
-    [SetterMayThrowLegacyException] attribute unrestricted double currentTime;
+    [ImplementedAs=currentTimeForBindings, SetterMayThrowException] attribute unrestricted double currentTime;
     readonly attribute unrestricted double duration;
     Date getStartDate();
     readonly attribute boolean paused;
@@ -77,7 +77,7 @@
 
     // controls
     attribute boolean controls;
-    [SetterMayThrowLegacyException] attribute double volume;
+    [SetterMayThrowException] attribute double volume;
     attribute boolean muted;
     [Reflect=muted] attribute boolean defaultMuted;
 
@@ -94,7 +94,7 @@
     [Conditional=LEGACY_ENCRYPTED_MEDIA] readonly attribute WebKitMediaKeys webkitKeys;
     [Conditional=LEGACY_ENCRYPTED_MEDIA] void webkitSetMediaKeys(WebKitMediaKeys? mediaKeys);
 
-    [Conditional=VIDEO_TRACK, MayThrowLegacyException] TextTrack addTextTrack(DOMString kind, optional DOMString label = "", optional DOMString language = "");
+    [Conditional=VIDEO_TRACK, MayThrowException] TextTrack addTextTrack(DOMString kind, optional DOMString label = "", optional DOMString language = "");
     [Conditional=VIDEO_TRACK] readonly attribute AudioTrackList audioTracks;
     [Conditional=VIDEO_TRACK] readonly attribute TextTrackList textTracks;
     [Conditional=VIDEO_TRACK] readonly attribute VideoTrackList videoTracks;
index 692b794..06e6416 100644 (file)
@@ -19,9 +19,9 @@
  */
 
 [
+    CustomCall,
     CustomNamedSetter,
     JSCustomGetOwnPropertySlotAndDescriptor,
-    CustomCall,
 ] interface HTMLObjectElement : HTMLElement {
     readonly attribute HTMLFormElement form;
     [Reflect] attribute DOMString code;
@@ -47,9 +47,7 @@
     [EnabledAtRuntime=InteractiveFormValidation] boolean reportValidity();
     void setCustomValidity(DOMString? error);
 
-    // Introduced in DOM Level 2:
     [CheckSecurityForNode] readonly attribute Document contentDocument;
 
-    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
+    [CheckSecurityForNode, MayThrowException] Document getSVGDocument();
 };
-
index 092a218..f10580c 100644 (file)
@@ -66,17 +66,17 @@ Ref<HTMLOptionElement> HTMLOptionElement::create(const QualifiedName& tagName, D
     return adoptRef(*new HTMLOptionElement(tagName, document));
 }
 
-RefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document& document, const String& data, const String& value,
-        bool defaultSelected, bool selected, ExceptionCode& ec)
+ExceptionOr<Ref<HTMLOptionElement>> HTMLOptionElement::createForJSConstructor(Document& document,
+    const String& data, const String& value, bool defaultSelected, bool selected)
 {
     Ref<HTMLOptionElement> element = adoptRef(*new HTMLOptionElement(optionTag, document));
 
     auto text = Text::create(document, data.isNull() ? emptyString() : data);
 
-    ec = 0;
+    ExceptionCode ec = 0;
     element->appendChild(text, ec);
     if (ec)
-        return nullptr;
+        return Exception { ec };
 
     if (!value.isNull())
         element->setValue(value);
index 39556a7..24e9054 100644 (file)
@@ -35,8 +35,7 @@ class HTMLOptionElement final : public HTMLElement {
 public:
     static Ref<HTMLOptionElement> create(Document&);
     static Ref<HTMLOptionElement> create(const QualifiedName&, Document&);
-    static RefPtr<HTMLOptionElement> createForJSConstructor(Document&, const String& data, const String& value,
-       bool defaultSelected, bool selected, ExceptionCode&);
+    static ExceptionOr<Ref<HTMLOptionElement>> createForJSConstructor(Document&, const String& data, const String& value, bool defaultSelected, bool selected);
 
     WEBCORE_EXPORT String text() const;
     void setText(const String&);
index 58dd197..6b71bd4 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 [
-    ConstructorMayThrowLegacyException,
+    ConstructorMayThrowException,
     JSGenerateToNativeObject,
     NamedConstructor=Option(optional DOMString data, optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false),
 ] interface HTMLOptionElement : HTMLElement {
index 459c826..a44e24d 100644 (file)
@@ -61,9 +61,9 @@ void HTMLOptionsCollection::setSelectedIndex(int index)
     selectElement().setSelectedIndex(index);
 }
 
-void HTMLOptionsCollection::setLength(unsigned length, ExceptionCode& ec)
+ExceptionOr<void> HTMLOptionsCollection::setLength(unsigned length)
 {
-    selectElement().setLength(length, ec);
+    return selectElement().setLength(length);
 }
 
 } //namespace
index cd42f26..5f5128d 100644 (file)
@@ -29,8 +29,6 @@
 
 namespace WebCore {
 
-typedef int ExceptionCode;
-
 class HTMLOptionsCollection final : public CachedHTMLCollection<HTMLOptionsCollection, CollectionTypeTraits<SelectOptions>::traversalType> {
 public:
     static Ref<HTMLOptionsCollection> create(HTMLSelectElement&, CollectionType);
@@ -50,7 +48,7 @@ public:
     WEBCORE_EXPORT int selectedIndex() const;
     WEBCORE_EXPORT void setSelectedIndex(int);
 
-    WEBCORE_EXPORT void setLength(unsigned, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setLength(unsigned);
 
     // For CachedHTMLCollection.
     bool elementMatches(Element&) const;
index 92c7bf6..67735e1 100644 (file)
     JSGenerateToNativeObject,
 ] interface HTMLOptionsCollection : HTMLCollection {
     attribute long selectedIndex;
-    [CEReactions, CustomSetter, SetterMayThrowLegacyException] attribute unsigned long length;
+    [CEReactions, CustomSetter, SetterMayThrowException] attribute unsigned long length;
 
     getter HTMLOptionElement? item(unsigned long index);
     getter HTMLOptionElement? namedItem(DOMString name);
 
     [CEReactions, MayThrowException] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
 
-    [CEReactions] void remove(long index);
-    // FIXME: This overload is not in the specification and has been dropped in Blink.
+    void remove(long index);
+
+    // FIXME: This overload is not in the specification and has been dropped from Blink.
     [CEReactions] void remove(HTMLOptionElement option);
 };
index 407665f..c860024 100644 (file)
@@ -98,12 +98,8 @@ double HTMLProgressElement::value() const
     return !std::isfinite(value) || value < 0 ? 0 : std::min(value, max());
 }
 
-void HTMLProgressElement::setValue(double value, ExceptionCode& ec)
+void HTMLProgressElement::setValue(double value)
 {
-    if (!std::isfinite(value)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(valueAttr, AtomicString::number(value >= 0 ? value : 0));
 }
 
@@ -113,12 +109,8 @@ double HTMLProgressElement::max() const
     return !std::isfinite(max) || max <= 0 ? 1 : max;
 }
 
-void HTMLProgressElement::setMax(double max, ExceptionCode& ec)
+void HTMLProgressElement::setMax(double max)
 {
-    if (!std::isfinite(max)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(maxAttr, AtomicString::number(max > 0 ? max : 1));
 }
 
index 1382320..bd33aa1 100644 (file)
@@ -18,8 +18,7 @@
  *
  */
 
-#ifndef HTMLProgressElement_h
-#define HTMLProgressElement_h
+#pragma once
 
 #include "LabelableElement.h"
 
@@ -36,15 +35,13 @@ public:
     static Ref<HTMLProgressElement> create(const QualifiedName&, Document&);
 
     double value() const;
-    void setValue(double, ExceptionCode&);
+    void setValue(double);
 
     double max() const;
-    void setMax(double, ExceptionCode&);
+    void setMax(double);
 
     double position() const;
 
-    bool canContainRangeEndPoint() const final { return false; }
-
 private:
     HTMLProgressElement(const QualifiedName&, Document&);
     virtual ~HTMLProgressElement();
@@ -64,9 +61,9 @@ private:
     void didAddUserAgentShadowRoot(ShadowRoot*) final;
     bool isDeterminate() const;
 
+    bool canContainRangeEndPoint() const final { return false; }
+
     ProgressValueElement* m_value;
 };
 
 } // namespace
-
-#endif
index 78d6383..b1cb05c 100644 (file)
@@ -18,9 +18,8 @@
  */
 
 interface HTMLProgressElement : HTMLElement {
-    [SetterMayThrowLegacyException] attribute  unrestricted double value;
-    [SetterMayThrowLegacyException] attribute  unrestricted double max;
-    readonly attribute  unrestricted double                position;
-    readonly attribute  NodeList              labels;
+    attribute double value;
+    attribute double max;
+    readonly attribute double position;
+    readonly attribute NodeList labels;
 };
-
index 4cab9e5..6433042 100644 (file)
@@ -246,15 +246,15 @@ void HTMLSelectElement::removeByIndex(int optionIndex)
     if (listIndex < 0)
         return;
 
-    listItems()[listIndex]->remove(IGNORE_EXCEPTION);
+    listItems()[listIndex]->remove();
 }
 
-void HTMLSelectElement::remove(HTMLOptionElement& option)
+ExceptionOr<void> HTMLSelectElement::remove(HTMLOptionElement& option)
 {
     if (option.ownerSelectElement() != this)
-        return;
+        return { };
 
-    option.remove(IGNORE_EXCEPTION);
+    return option.remove();
 }
 
 String HTMLSelectElement::value() const
@@ -430,34 +430,33 @@ HTMLOptionElement* HTMLSelectElement::item(unsigned index)
     return options()->item(index);
 }
 
-void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement& option, ExceptionCode& ec)
+ExceptionOr<void> HTMLSelectElement::setOption(unsigned index, HTMLOptionElement& option)
 {
-    ec = 0;
     if (index > maxSelectItems - 1)
         index = maxSelectItems - 1;
     int diff = index - length();
     RefPtr<HTMLOptionElement> before;
     // Out of array bounds? First insert empty dummies.
     if (diff > 0) {
-        setLength(index, ec);
+        auto result = setLength(index);
+        if (result.hasException())
+            return result;
         // Replace an existing entry?
     } else if (diff < 0) {
         before = item(index + 1);
         removeByIndex(index);
     }
     // Finally add the new element.
-    if (!ec) {
-        auto exception = add(&option, HTMLElementOrInt(before.get()));
-        if (exception.hasException())
-            ec = exception.releaseException().code();
-        if (diff >= 0 && option.selected())
-            optionSelectionStateChanged(option, true);
-    }
+    auto result = add(&option, HTMLElementOrInt { before.get() });
+    if (result.hasException())
+        return result;
+    if (diff >= 0 && option.selected())
+        optionSelectionStateChanged(option, true);
+    return { };
 }
 
-void HTMLSelectElement::setLength(unsigned newLength, ExceptionCode& ec)
+ExceptionOr<void> HTMLSelectElement::setLength(unsigned newLength)
 {
-    ec = 0;
     if (newLength > maxSelectItems)
         newLength = maxSelectItems;
     int diff = length() - newLength;
@@ -465,32 +464,31 @@ void HTMLSelectElement::setLength(unsigned newLength, ExceptionCode& ec)
     if (diff < 0) { // Add dummy elements.
         do {
             auto option = document().createElement(optionTag, false);
-            auto exception = add(downcast<HTMLOptionElement>(option.ptr()), Nullopt);
-            if (exception.hasException()) {
-                ec = exception.releaseException().code();
-                break;
-        }
+            auto result = add(downcast<HTMLOptionElement>(option.ptr()), Nullopt);
+            if (result.hasException())
+                return result;
         } while (++diff);
     } else {
         auto& items = listItems();
 
         // Removing children fires mutation events, which might mutate the DOM further, so we first copy out a list
         // of elements that we intend to remove then attempt to remove them one at a time.
-        Vector<Ref<Element>> itemsToRemove;
+        Vector<Ref<HTMLOptionElement>> itemsToRemove;
         size_t optionIndex = 0;
         for (auto& item : items) {
             if (is<HTMLOptionElement>(*item) && optionIndex++ >= newLength) {
                 ASSERT(item->parentNode());
-                itemsToRemove.append(*item);
+                itemsToRemove.append(downcast<HTMLOptionElement>(*item));
             }
         }
 
-        for (auto& item : itemsToRemove) {
-            if (item->parentNode())
-                item->parentNode()->removeChild(item.get(), ec);
-        }
+        // FIXME: Clients can detect what order we remove the options in; is it good to remove them in ascending order?
+        // FIXME: This ignores exceptions. A previous version passed through the exception only for the last item removed.
+        // What exception behavior do we want?
+        for (auto& item : itemsToRemove)
+            item->remove();
     }
-    updateValidity();
+    return { };
 }
 
 bool HTMLSelectElement::isRequiredFormControl() const
index 64504c3..bee1dd3 100644 (file)
@@ -56,7 +56,7 @@ public:
     WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before);
 
     using Node::remove;
-    void remove(HTMLOptionElement&);
+    ExceptionOr<void> remove(HTMLOptionElement&);
     WEBCORE_EXPORT void removeByIndex(int); // Should be remove(int) but that conflicts with Node::remove(ExceptionCode&).
 
     WEBCORE_EXPORT String value() const;
@@ -80,8 +80,8 @@ public:
 
     WEBCORE_EXPORT void setSize(unsigned);
 
-    void setOption(unsigned index, HTMLOptionElement&, ExceptionCode&);
-    void setLength(unsigned, ExceptionCode&);
+    ExceptionOr<void> setOption(unsigned index, HTMLOptionElement&);
+    ExceptionOr<void> setLength(unsigned);
 
     WEBCORE_EXPORT HTMLOptionElement* namedItem(const AtomicString& name);
     WEBCORE_EXPORT HTMLOptionElement* item(unsigned index);
index 465e5d3..957f13b 100644 (file)
     readonly attribute DOMString type;
 
     readonly attribute HTMLOptionsCollection options;
-    [CEReactions, SetterMayThrowLegacyException] attribute unsigned long length;
+    [CEReactions, SetterMayThrowException] attribute unsigned long length;
 
     getter HTMLOptionElement? item(unsigned long index);
     HTMLOptionElement? namedItem(DOMString name);
 
     [CEReactions, MayThrowException] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
 
-    [MayThrowLegacyException] void remove(); // ChildNode overload
+    [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);
index 97c1070..892f3a6 100644 (file)
@@ -78,11 +78,16 @@ HTMLTableCaptionElement* HTMLTableElement::caption() const
     return nullptr;
 }
 
-void HTMLTableElement::setCaption(RefPtr<HTMLTableCaptionElement>&& newCaption, ExceptionCode& ec)
+ExceptionOr<void> HTMLTableElement::setCaption(RefPtr<HTMLTableCaptionElement>&& newCaption)
 {
     deleteCaption();
-    if (newCaption)
+    if (newCaption) {
+        ExceptionCode ec = 0;
         insertBefore(*newCaption, firstChild(), ec);
+        if (ec)
+            return Exception { ec };
+    }
+    return { };
 }
 
 HTMLTableSectionElement* HTMLTableElement::tHead() const
@@ -94,17 +99,15 @@ HTMLTableSectionElement* HTMLTableElement::tHead() const
     return nullptr;
 }
 
-void HTMLTableElement::setTHead(RefPtr<HTMLTableSectionElement>&& newHead, ExceptionCode& ec)
+ExceptionOr<void> HTMLTableElement::setTHead(RefPtr<HTMLTableSectionElement>&& newHead)
 {
-    if (UNLIKELY(newHead && !newHead->hasTagName(theadTag))) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return;
-    }
+    if (UNLIKELY(newHead && !newHead->hasTagName(theadTag)))
+        return Exception { HIERARCHY_REQUEST_ERR };
 
     deleteTHead();
 
     if (!newHead)
-        return;
+        return { };
 
     Node* child;
     for (child = firstChild(); child; child = child->nextSibling()) {
@@ -112,7 +115,11 @@ void HTMLTableElement::setTHead(RefPtr<HTMLTableSectionElement>&& newHead, Excep
             break;
     }
 
+    ExceptionCode ec = 0;
     insertBefore(*newHead, child, ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
 HTMLTableSectionElement* HTMLTableElement::tFoot() const
@@ -124,54 +131,56 @@ HTMLTableSectionElement* HTMLTableElement::tFoot() const
     return nullptr;
 }
 
-void HTMLTableElement::setTFoot(RefPtr<HTMLTableSectionElement>&& newFoot, ExceptionCode& ec)
+ExceptionOr<void> HTMLTableElement::setTFoot(RefPtr<HTMLTableSectionElement>&& newFoot)
 {
-    if (UNLIKELY(newFoot && !newFoot->hasTagName(tfootTag))) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return;
-    }
+    if (UNLIKELY(newFoot && !newFoot->hasTagName(tfootTag)))
+        return Exception { HIERARCHY_REQUEST_ERR };
 
     deleteTFoot();
 
     if (!newFoot)
-        return;
+        return { };
 
+    ExceptionCode ec = 0;
     appendChild(*newFoot, ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
 Ref<HTMLTableSectionElement> HTMLTableElement::createTHead()
 {
-    if (HTMLTableSectionElement* existingHead = tHead())
+    if (auto* existingHead = tHead())
         return *existingHead;
-    Ref<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document());
-    setTHead(head.copyRef(), IGNORE_EXCEPTION);
+    auto head = HTMLTableSectionElement::create(theadTag, document());
+    setTHead(head.copyRef());
     return head;
 }
 
 void HTMLTableElement::deleteTHead()
 {
-    if (auto* tHead = this->tHead())
-        removeChild(*tHead, IGNORE_EXCEPTION);
+    if (auto* head = tHead())
+        removeChild(*head);
 }
 
 Ref<HTMLTableSectionElement> HTMLTableElement::createTFoot()
 {
-    if (HTMLTableSectionElement* existingFoot = tFoot())
+    if (auto* existingFoot = tFoot())
         return *existingFoot;
-    Ref<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document());
-    setTFoot(foot.copyRef(), IGNORE_EXCEPTION);
+    auto foot = HTMLTableSectionElement::create(tfootTag, document());
+    setTFoot(foot.copyRef());
     return foot;
 }
 
 void HTMLTableElement::deleteTFoot()
 {
-    if (auto* tFoot = this->tFoot())
-        removeChild(*tFoot, IGNORE_EXCEPTION);
+    if (auto* foot = tFoot())
+        removeChild(*foot, IGNORE_EXCEPTION);
 }
 
 Ref<HTMLTableSectionElement> HTMLTableElement::createTBody()
 {
-    Ref<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
+    auto body = HTMLTableSectionElement::create(tbodyTag, document());
     Node* referenceElement = lastBody() ? lastBody()->nextSibling() : nullptr;
     insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION);
     return body;
@@ -179,10 +188,10 @@ Ref<HTMLTableSectionElement> HTMLTableElement::createTBody()
 
 Ref<HTMLTableCaptionElement> HTMLTableElement::createCaption()
 {
-    if (HTMLTableCaptionElement* existingCaption = caption())
+    if (auto* existingCaption = caption())
         return *existingCaption;
-    Ref<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document());
-    setCaption(caption.copyRef(), IGNORE_EXCEPTION);
+    auto caption = HTMLTableCaptionElement::create(captionTag, document());
+    setCaption(caption.copyRef());
     return caption;
 }
 
@@ -201,27 +210,23 @@ HTMLTableSectionElement* HTMLTableElement::lastBody() const
     return nullptr;
 }
 
-RefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
+ExceptionOr<Ref<HTMLElement>> HTMLTableElement::insertRow(int index)
 {
-    if (index < -1) {
-        ec = INDEX_SIZE_ERR;
-        return 0;
-    }
+    if (index < -1)
+        return Exception { INDEX_SIZE_ERR };
 
     Ref<HTMLTableElement> protectedThis(*this);
 
-    RefPtr<HTMLTableRowElement> lastRow = 0;
-    RefPtr<HTMLTableRowElement> row = 0;
+    RefPtr<HTMLTableRowElement> lastRow;
+    RefPtr<HTMLTableRowElement> row;
     if (index == -1)
         lastRow = HTMLTableRowsCollection::lastRow(*this);
     else {
         for (int i = 0; i <= index; ++i) {
             row = HTMLTableRowsCollection::rowAfter(*this, lastRow.get());
             if (!row) {
-                if (i != index) {
-                    ec = INDEX_SIZE_ERR;
-                    return 0;
-                }
+                if (i != index)
+                    return Exception { INDEX_SIZE_ERR };
                 break;
             }
             lastRow = row;
@@ -236,36 +241,41 @@ RefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
         if (!parent) {
             auto newBody = HTMLTableSectionElement::create(tbodyTag, document());
             auto newRow = HTMLTableRowElement::create(document());
+            ExceptionCode ec = 0;
             newBody->appendChild(newRow, ec);
+            // FIXME: Why ignore the exception if the first appendChild failed?
             appendChild(newBody, ec);
-            return WTFMove(newRow);
+            if (ec)
+                return Exception { ec };
+            return Ref<HTMLElement> { WTFMove(newRow) };
         }
     }
 
     auto newRow = HTMLTableRowElement::create(document());
+    ExceptionCode ec = 0;
     parent->insertBefore(newRow, row.get(), ec);
-    return WTFMove(newRow);
+    if (ec)
+        return Exception { ec };
+    return Ref<HTMLElement> { WTFMove(newRow) };
 }
 
-void HTMLTableElement::deleteRow(int index, ExceptionCode& ec)
+ExceptionOr<void> HTMLTableElement::deleteRow(int index)
 {
     HTMLTableRowElement* row = nullptr;
     if (index == -1) {
         row = HTMLTableRowsCollection::lastRow(*this);
         if (!row)
-            return;
+            return { };
     } else {
         for (int i = 0; i <= index; ++i) {
             row = HTMLTableRowsCollection::rowAfter(*this, row);
             if (!row)
                 break;
         }
-        if (!row) {
-            ec = INDEX_SIZE_ERR;
-            return;
-        }
+        if (!row)
+            return Exception { INDEX_SIZE_ERR };
     }
-    row->remove(ec);
+    return row->remove();
 }
 
 static inline bool isTableCellAncestor(const Element& element)
index 5fae5ef..b5ae724 100644 (file)
@@ -40,13 +40,13 @@ public:
     static Ref<HTMLTableElement> create(const QualifiedName&, Document&);
 
     WEBCORE_EXPORT HTMLTableCaptionElement* caption() const;
-    WEBCORE_EXPORT void setCaption(RefPtr<HTMLTableCaptionElement>&&, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setCaption(RefPtr<HTMLTableCaptionElement>&&);
 
     WEBCORE_EXPORT HTMLTableSectionElement* tHead() const;
-    WEBCORE_EXPORT void setTHead(RefPtr<HTMLTableSectionElement>&&, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setTHead(RefPtr<HTMLTableSectionElement>&&);
 
     WEBCORE_EXPORT HTMLTableSectionElement* tFoot() const;
-    WEBCORE_EXPORT void setTFoot(RefPtr<HTMLTableSectionElement>&&, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<void> setTFoot(RefPtr<HTMLTableSectionElement>&&);
 
     WEBCORE_EXPORT Ref<HTMLTableSectionElement> createTHead();
     WEBCORE_EXPORT void deleteTHead();
@@ -55,9 +55,8 @@ public:
     WEBCORE_EXPORT Ref<HTMLTableSectionElement> createTBody();
     WEBCORE_EXPORT Ref<HTMLTableCaptionElement> createCaption();
     WEBCORE_EXPORT void deleteCaption();
-    RefPtr<HTMLElement> insertRow(ExceptionCode& ec) { return insertRow(-1, ec); }
-    WEBCORE_EXPORT RefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
-    WEBCORE_EXPORT void deleteRow(int index, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<Ref<HTMLElement>> insertRow(int index = -1);
+    WEBCORE_EXPORT ExceptionOr<void> deleteRow(int index);
 
     WEBCORE_EXPORT Ref<HTMLCollection> rows();
     WEBCORE_EXPORT Ref<HTMLCollection> tBodies();
index 6f80816..9891fec 100644 (file)
@@ -19,9 +19,9 @@
  */
 
 interface HTMLTableElement : HTMLElement {
-    [CEReactions, SetterMayThrowLegacyException] attribute HTMLTableCaptionElement? caption;
-    [CEReactions, SetterMayThrowLegacyException] attribute HTMLTableSectionElement? tHead;
-    [CEReactions, SetterMayThrowLegacyException] attribute HTMLTableSectionElement? tFoot;
+    [CEReactions, SetterMayThrowException] attribute HTMLTableCaptionElement? caption;
+    [CEReactions, SetterMayThrowException] attribute HTMLTableSectionElement? tHead;
+    [CEReactions, SetterMayThrowException] attribute HTMLTableSectionElement? tFoot;
 
     readonly attribute HTMLCollection rows;
     readonly attribute HTMLCollection tBodies;
@@ -45,7 +45,6 @@ interface HTMLTableElement : HTMLElement {
     HTMLElement createCaption();
     [CEReactions] void deleteCaption();
 
-    [MayThrowLegacyException] HTMLElement insertRow(optional long index = -1);
-    [CEReactions, MayThrowLegacyException] void deleteRow(long index);
+    [MayThrowException] HTMLElement insertRow(optional long index = -1);
+    [CEReactions, MayThrowException] void deleteRow(long index);
 };
-
index d803a17..342448c 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-HTMLTableRowElement::HTMLTableRowElement(const QualifiedName& tagName, Document& document)
+inline HTMLTableRowElement::HTMLTableRowElement(const QualifiedName& tagName, Document& document)
     : HTMLTablePartElement(tagName, document)
 {
     ASSERT(hasTagName(trTag));
@@ -55,21 +55,25 @@ Ref<HTMLTableRowElement> HTMLTableRowElement::create(const QualifiedName& tagNam
     return adoptRef(*new HTMLTableRowElement(tagName, document));
 }
 
+static inline HTMLTableElement* findTable(const HTMLTableRowElement& row)
+{
+    auto* parent = row.parentNode();
+    if (is<HTMLTableElement>(parent))
+        return downcast<HTMLTableElement>(parent);
+    if (is<HTMLTableSectionElement>(parent)) {
+        auto* grandparent = parent->parentNode();
+        if (is<HTMLTableElement>(grandparent))
+            return downcast<HTMLTableElement>(grandparent);
+    }
+    return nullptr;
+}
+
 int HTMLTableRowElement::rowIndex() const
 {
-    auto* parent = parentNode();
-    if (!parent)
+    auto* table = findTable(*this);
+    if (!table)
         return -1;
 
-    HTMLTableElement* table;
-    if (is<HTMLTableElement>(*parent))
-        table = downcast<HTMLTableElement>(parent);
-    else {
-        if (!is<HTMLTableSectionElement>(*parent) || !is<HTMLTableElement>(parent->parentNode()))
-            return -1;
-        table = downcast<HTMLTableElement>(parent->parentNode());
-    }
-
     auto rows = table->rows();
     unsigned length = rows->length();
     for (unsigned i = 0; i < length; ++i) {
@@ -80,18 +84,20 @@ int HTMLTableRowElement::rowIndex() const
     return -1;
 }
 
-int HTMLTableRowElement::sectionRowIndex() const
+static inline RefPtr<HTMLCollection> findRows(const HTMLTableRowElement& row)
 {
-    auto* parent = parentNode();
-    if (!parent)
-        return -1;
+    auto* parent = row.parentNode();
+    if (is<HTMLTableSectionElement>(parent))
+        return downcast<HTMLTableSectionElement>(*parent).rows();
+    if (is<HTMLTableElement>(parent))
+        return downcast<HTMLTableElement>(*parent).rows();
+    return nullptr;
+}
 
-    RefPtr<HTMLCollection> rows;
-    if (is<HTMLTableSectionElement>(*parent))
-        rows = downcast<HTMLTableSectionElement>(*parent).rows();
-    else if (is<HTMLTableElement>(*parent))
-        rows = downcast<HTMLTableElement>(*parent).rows();
-    else
+int HTMLTableRowElement::sectionRowIndex() const
+{
+    auto rows = findRows(*this);
+    if (!rows)
         return -1;
 
     unsigned length = rows->length();
@@ -103,16 +109,16 @@ int HTMLTableRowElement::sectionRowIndex() const
     return -1;
 }
 
-RefPtr<HTMLTableCellElement> HTMLTableRowElement::insertCell(int index, ExceptionCode& ec)
+ExceptionOr<Ref<HTMLTableCellElement>> HTMLTableRowElement::insertCell(int index)
 {
-    Ref<HTMLCollection> children = cells();
+    if (index < -1)
+        return Exception { INDEX_SIZE_ERR };
+    auto children = cells();
     int numCells = children->length();
-    if (index < -1 || index > numCells) {
-        ec = INDEX_SIZE_ERR;
-        return nullptr;
-    }
-
+    if (index > numCells)
+        return Exception { INDEX_SIZE_ERR };
     auto cell = HTMLTableCellElement::create(tdTag, document());
+    ExceptionCode ec = 0;
     if (index < 0 || index >= numCells)
         appendChild(cell, ec);
     else {
@@ -123,23 +129,27 @@ RefPtr<HTMLTableCellElement> HTMLTableRowElement::insertCell(int index, Exceptio
             n = children->item(index);
         insertBefore(cell, n, ec);
     }
+    if (ec)
+        return Exception { ec };
     return WTFMove(cell);
 }
 
-void HTMLTableRowElement::deleteCell(int index, ExceptionCode& ec)
+ExceptionOr<void> HTMLTableRowElement::deleteCell(int index)
 {
-    Ref<HTMLCollection> children = cells();
+    auto children = cells();
     int numCells = children->length();
     if (index == -1) {
         if (!numCells)
-            return;
-
+            return { };
         index = numCells - 1;
     }
-    if (index >= 0 && index < numCells)
-        HTMLElement::removeChild(*children->item(index), ec);
-    else
-        ec = INDEX_SIZE_ERR;
+    if (index < 0 || index >= numCells)
+        return Exception { INDEX_SIZE_ERR };
+    ExceptionCode ec = 0;
+    removeChild(*children->item(index), ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
 Ref<HTMLCollection> HTMLTableRowElement::cells()
@@ -147,9 +157,4 @@ Ref<HTMLCollection> HTMLTableRowElement::cells()
     return ensureRareData().ensureNodeLists().addCachedCollection<GenericCachedHTMLCollection<CollectionTypeTraits<TRCells>::traversalType>>(*this, TRCells);
 }
 
-void HTMLTableRowElement::setCells(HTMLCollection*, ExceptionCode& ec)
-{
-    ec = NO_MODIFICATION_ALLOWED_ERR;
-}
-
 }
index befd6ed..ad77d8a 100644 (file)
@@ -41,12 +41,10 @@ public:
     WEBCORE_EXPORT int sectionRowIndex() const;
     void setSectionRowIndex(int);
 
-    RefPtr<HTMLTableCellElement> insertCell(ExceptionCode& ec) { return insertCell(-1, ec); }
-    WEBCORE_EXPORT RefPtr<HTMLTableCellElement> insertCell(int index, ExceptionCode&);
-    WEBCORE_EXPORT void deleteCell(int index, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<Ref<HTMLTableCellElement>> insertCell(int index = -1);
+    WEBCORE_EXPORT ExceptionOr<void> deleteCell(int index);
 
     WEBCORE_EXPORT Ref<HTMLCollection> cells();
-    void setCells(HTMLCollection *, ExceptionCode&);
 
 private:
     HTMLTableRowElement(const QualifiedName&, Document&);
index b0d45ad..7d7d341 100644 (file)
@@ -27,7 +27,6 @@ interface HTMLTableRowElement : HTMLElement {
     [Reflect=char] attribute DOMString ch;
     [Reflect=charoff] attribute DOMString chOff;
     [Reflect] attribute DOMString vAlign;
-    [MayThrowLegacyException] HTMLElement insertCell(optional long index = -1);
-    [CEReactions, MayThrowLegacyException] void deleteCell(long index);
+    [MayThrowException] HTMLElement insertCell(optional long index = -1);
+    [CEReactions, MayThrowException] void deleteCell(long index);
 };
-
index e18101b..84f1062 100644 (file)
@@ -51,103 +51,59 @@ Ref<HTMLTableSectionElement> HTMLTableSectionElement::create(const QualifiedName
 
 const StyleProperties* HTMLTableSectionElement::additionalPresentationAttributeStyle() const
 {
-    if (HTMLTableElement* table = findParentTable())
-        return table->additionalGroupStyle(true);
-    return 0;
+    auto* table = findParentTable();
+    if (!table)
+        return nullptr;
+    return table->additionalGroupStyle(true);
 }
 
-// these functions are rather slow, since we need to get the row at
-// the index... but they aren't used during usual HTML parsing anyway
-RefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionCode& ec)
+ExceptionOr<Ref<HTMLElement>> HTMLTableSectionElement::insertRow(int index)
 {
-    RefPtr<HTMLTableRowElement> row;
-    Ref<HTMLCollection> children = rows();
+    if (index < -1)
+        return Exception { INDEX_SIZE_ERR };
+    auto children = rows();
     int numRows = children->length();
-    if (index < -1 || index > numRows)
-        ec = INDEX_SIZE_ERR; // per the DOM
+    if (index > numRows)
+        return Exception { INDEX_SIZE_ERR };
+    auto row = HTMLTableRowElement::create(trTag, document());
+    ExceptionCode ec = 0;
+    if (numRows == index || index == -1)
+        appendChild(row, ec);
     else {
-        row = HTMLTableRowElement::create(trTag, document());
-        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);
-        }
+        Node* n;
+        if (index < 1)
+            n = firstChild();
+        else
+            n = children->item(index);
+        insertBefore(row, n, ec);
     }
-    return row;
+    if (ec)
+        return Exception { ec };
+    return Ref<HTMLElement> { WTFMove(row) };
 }
 
-void HTMLTableSectionElement::deleteRow(int index, ExceptionCode& ec)
+ExceptionOr<void> HTMLTableSectionElement::deleteRow(int index)
 {
-    Ref<HTMLCollection> children = rows();
+    auto children = rows();
     int numRows = children->length();
     if (index == -1) {
         if (!numRows)
-            return;
-
+            return { };
         index = numRows - 1;
     }
-    if (index >= 0 && index < numRows)
-        HTMLElement::removeChild(*children->item(index), ec);
-    else
-        ec = INDEX_SIZE_ERR;
+    if (index < 0 || index >= numRows)
+        return Exception { INDEX_SIZE_ERR };
+    ExceptionCode ec = 0;
+    removeChild(*children->item(index), ec);
+    if (ec)
+        return Exception { ec };
+    return { };
 }
 
 int HTMLTableSectionElement::numRows() const
 {
-    int rows = 0;
-    const Node *n = firstChild();
-    while (n) {
-        if (n->hasTagName(trTag))
-            rows++;
-        n = n->nextSibling();
-    }
-
-    return rows;
-}
-
-const AtomicString& HTMLTableSectionElement::align() const
-{
-    return attributeWithoutSynchronization(alignAttr);
-}
-
-void HTMLTableSectionElement::setAlign(const AtomicString& value)
-{
-    setAttributeWithoutSynchronization(alignAttr, value);
-}
-
-const AtomicString& HTMLTableSectionElement::ch() const
-{
-    return attributeWithoutSynchronization(charAttr);
-}
-
-void HTMLTableSectionElement::setCh(const AtomicString& value)
-{
-    setAttributeWithoutSynchronization(charAttr, value);
-}
-
-const AtomicString& HTMLTableSectionElement::chOff() const
-{
-    return attributeWithoutSynchronization(charoffAttr);
-}
-
-void HTMLTableSectionElement::setChOff(const AtomicString& value)
-{
-    setAttributeWithoutSynchronization(charoffAttr, value);
-}
-
-const AtomicString& HTMLTableSectionElement::vAlign() const
-{
-    return attributeWithoutSynchronization(valignAttr);
-}
-
-void HTMLTableSectionElement::setVAlign(const AtomicString& value)
-{
-    setAttributeWithoutSynchronization(valignAttr, value);
+    auto rows = childrenOfType<HTMLTableRowElement>(*this);
+    return std::distance(rows.begin(), rows.end());
 }
 
 Ref<HTMLCollection> HTMLTableSectionElement::rows()
index 31b7bec..609ce76 100644 (file)
@@ -34,24 +34,11 @@ class HTMLTableSectionElement final : public HTMLTablePartElement {
 public:
     static Ref<HTMLTableSectionElement> create(const QualifiedName&, Document&);
 
-    RefPtr<HTMLElement> insertRow(ExceptionCode& ec) { return insertRow(-1, ec); }
-    WEBCORE_EXPORT RefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
-    WEBCORE_EXPORT void deleteRow(int index, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<Ref<HTMLElement>> insertRow(int index = -1);
+    WEBCORE_EXPORT ExceptionOr<void> deleteRow(int index);
 
     int numRows() const;
 
-    const AtomicString& align() const;
-    void setAlign(const AtomicString&);
-
-    const AtomicString& ch() const;
-    void setCh(const AtomicString&);
-
-    const AtomicString& chOff() const;
-    void setChOff(const AtomicString&);
-
-    const AtomicString& vAlign() const;
-    void setVAlign(const AtomicString&);
-
     WEBCORE_EXPORT Ref<HTMLCollection> rows();
 
 private:
index 54c5dc2..7b3cea8 100644 (file)
@@ -26,7 +26,6 @@
     [Reflect=charoff] attribute DOMString chOff;
     [Reflect] attribute DOMString vAlign;
     readonly attribute HTMLCollection rows;
-    [MayThrowLegacyException] HTMLElement insertRow(optional long index = -1);
-    [CEReactions, MayThrowLegacyException] void deleteRow(long index);
+    [MayThrowException] HTMLElement insertRow(optional long index = -1);
+    [CEReactions, MayThrowException] void deleteRow(long index);
 };
-
index 4fcfde9..1fdbc51 100644 (file)
@@ -205,21 +205,13 @@ void HTMLTextAreaElement::parseAttribute(const QualifiedName& name, const Atomic
 
 void HTMLTextAreaElement::maxLengthAttributeChanged(const AtomicString& newValue)
 {
-    if (Optional<unsigned> maxLength = parseHTMLNonNegativeInteger(newValue))
-        setMaxLength(maxLength.value());
-    else
-        setMaxLength(-1);
-
+    internalSetMaxLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1));
     updateValidity();
 }
 
 void HTMLTextAreaElement::minLengthAttributeChanged(const AtomicString& newValue)
 {
-    if (Optional<unsigned> minLength = parseHTMLNonNegativeInteger(newValue))
-        setMinLength(minLength.value());
-    else
-        setMinLength(-1);
-
+    internalSetMinLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1));
     updateValidity();
 }
 
@@ -563,7 +555,7 @@ void HTMLTextAreaElement::updatePlaceholderText()
         m_placeholder = TextControlPlaceholderElement::create(document());
         userAgentShadowRoot()->insertBefore(*m_placeholder, innerTextElement()->nextSibling());
     }
-    m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION);
+    m_placeholder->setInnerText(placeholderText);
 }
 
 bool HTMLTextAreaElement::willRespondToMouseClickEvents()
index e7ca969..181d700 100644 (file)
@@ -24,8 +24,8 @@ interface HTMLTextAreaElement : HTMLElement {
     [Reflect] attribute DOMString dirName;
     [Reflect] attribute boolean disabled;
     readonly attribute HTMLFormElement form;
-    [SetterMayThrowLegacyException] attribute long minLength;
-    [SetterMayThrowLegacyException] attribute long maxLength;
+    [SetterMayThrowException] attribute long minLength;
+    [SetterMayThrowException] attribute long maxLength;
     [Reflect] attribute DOMString name;
     [Reflect] attribute DOMString placeholder;
     [Reflect] attribute boolean readOnly;
@@ -53,19 +53,12 @@ interface HTMLTextAreaElement : HTMLElement {
     attribute long selectionEnd;
     attribute DOMString selectionDirection;
 
-    [MayThrowLegacyException] void setRangeText(DOMString replacement);
-    [MayThrowLegacyException] void setRangeText(DOMString replac