Changeset 207720 in webkit


Ignore:
Timestamp:
Oct 22, 2016 6:05:07 PM (8 years ago)
Author:
Darin Adler
Message:

Move HTML canvas and tracks from ExceptionCode to Exception
https://bugs.webkit.org/show_bug.cgi?id=163853

Reviewed by Chris Dumez.

Source/WebCore:

  • WebCore.xcodeproj/project.pbxproj: Added CanvasPath.idl.
  • bindings/js/JSWebGL2RenderingContextCustom.cpp: Tweaked a bit.
  • bindings/js/JSWebGLRenderingContextBaseCustom.cpp:

(WebCore::JSWebGLRenderingContextBase::getExtension): Tweaked a bit.
(WebCore::JSWebGLRenderingContextBase::getFramebufferAttachmentParameter):
Removed unneeded exception handling.
(WebCore::JSWebGLRenderingContextBase::getParameter): Ditto.
(WebCore::JSWebGLRenderingContextBase::getProgramParameter): Ditto.
(WebCore::JSWebGLRenderingContextBase::getShaderParameter): Ditto.
(WebCore::JSWebGLRenderingContextBase::getSupportedExtensions): Use a
modern for loop.
(WebCore::JSWebGLRenderingContextBase::getUniform): Removed unneeded
exception handling.

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::getContext): Pass a reference.
(WebCore::HTMLCanvasElement::reset): Use is<CanvasRenderingContext2D>.
(WebCore::HTMLCanvasElement::setUsesDisplayListDrawing): Ditto.
(WebCore::HTMLCanvasElement::setTracksDisplayListReplay) Ditto.:
(WebCore::HTMLCanvasElement::displayListAsText): Ditto.
(WebCore::HTMLCanvasElement::replayDisplayListAsText): Ditto.
(WebCore::HTMLCanvasElement::clearImageBuffer): Ditto.

  • html/canvas/CanvasGradient.cpp:

(WebCore::CanvasGradient::CanvasGradient): Streamlined.
(WebCore::CanvasGradient::addColorStop): Use ExceptionOr.

  • html/canvas/CanvasGradient.h: Updated for above changes.
  • html/canvas/CanvasGradient.idl: Use non-legacy exception.
  • html/canvas/CanvasPath.cpp:

(WebCore::CanvasPath::arcTo): Use ExceptionOr.
(WebCore::CanvasPath::arc): Ditto.
(WebCore::CanvasPath::ellipse): Ditto.

  • html/canvas/CanvasPath.h: Updated for above changes.
  • html/canvas/CanvasPath.idl: Use non-legacy exceptions.
  • html/canvas/CanvasPattern.cpp:

(WebCore::CanvasPattern::create): Use Ref&&.
(WebCore::CanvasPattern::CanvasPattern): Ditto.
(WebCore::CanvasPattern::parseRepetitionType): Return a boolean
instead of using an ExceptionCode.

  • html/canvas/CanvasPattern.h: Updated for above changes.
  • html/canvas/CanvasRenderingContext.cpp:

(CanvasRenderingContext::wouldTaintOrigin): Reordered function so
that it's safe to call it on an image element without a cached
image, or a cached image without an underlying image.

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
Take a reference.
(WebCore::CanvasRenderingContext2D::drawImage): Use ExceptionOr.
(WebCore::CanvasRenderingContext2D::drawImageFromRect): Ditto.
(WebCore::CanvasRenderingContext2D::createLinearGradient): Ditto.
(WebCore::CanvasRenderingContext2D::createRadialGradient): Ditto.
(WebCore::CanvasRenderingContext2D::createPattern): Ditto.
(WebCore::CanvasRenderingContext2D::createImageData): Ditto.
(WebCore::CanvasRenderingContext2D::getImageData): Ditto.
(WebCore::CanvasRenderingContext2D::webkitGetImageDataHD): Ditto.
(WebCore::CanvasRenderingContext2D::putImageData): Removed unneeded
ExceptionCode because this does not throw exceptions; the only one
was for non-finite numeric values but this is now handled by bindings.
(WebCore::CanvasRenderingContext2D::webkitPutImageDataHD): Ditto.

  • html/canvas/CanvasRenderingContext2D.h: Updated for above.
  • html/canvas/CanvasRenderingContext2D.idl: Use non-legacy exceptions

and removed exceptions entirely in other cases.

  • html/canvas/OESVertexArrayObject.cpp:

(WebCore::OESVertexArrayObject::OESVertexArrayObject): Take a reference.
(WebCore::OESVertexArrayObject::~OESVertexArrayObject): Deleted.
(WebCore::OESVertexArrayObject::isVertexArrayOES): Use && instead of
multiple return statements.
(WebCore::OESVertexArrayObject::bindVertexArrayOES): Removed unneeded
ExceptionCode since this does not throw an exception.

  • html/canvas/OESVertexArrayObject.h: Updated for above.
  • html/canvas/OESVertexArrayObject.idl: Removed unneeded exception.
  • html/canvas/WebGL2RenderingContext.cpp:

(WebCore::WebGL2RenderingContext::getFramebufferAttachmentParameter):
Removed unneeded ExceptionCode since this does not throw an exception.
(WebCore::WebGL2RenderingContext::texSubImage2DBase): Ditto.
(WebCore::WebGL2RenderingContext::texSubImage2DImpl): Ditto.
(WebCore::WebGL2RenderingContext::texSubImage2D): Removed unneeded
ExceptionCode for some overloads, for the others, use ExceptionOr
for the security exception. Moved security exception code here from
the validate functions.
(WebCore::WebGL2RenderingContext::validateTexFuncParameters): Removed
unneeded ExceptionCode.
(WebCore::WebGL2RenderingContext::getParameter): Ditto.

  • html/canvas/WebGL2RenderingContext.h: Updated for above.
  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::getExtension): Pass a reference.
(WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter):
Remvoed unneeded ExceptionCode since this does not throw an exception.
(WebCore::WebGLRenderingContext::texSubImage2DBase): Ditto.
(WebCore::WebGLRenderingContext::texSubImage2DImpl): Ditto.
(WebCore::WebGLRenderingContext::texSubImage2D): Removed unneeded
ExceptionCode for some overloads, for the others, use ExceptionOr
for the security exception. Moved security exception code here from
the validate functions.
(WebCore::WebGLRenderingContext::getParameter): Removed unneeded
ExceptionCode.

  • html/canvas/WebGLRenderingContext.h: Updated for above changes.
  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::texImage2DBase):
Remvoed unneeded ExceptionCode since this does not throw an exception.
(WebCore::WebGLRenderingContextBase::texImage2DImpl): Ditto.
(WebCore::WebGLRenderingContextBase::texImage2D): Removed unneeded
ExceptionCode for some overloads, for the others, use ExceptionOr
for the security exception. Moved security exception code here from
the validate functions.
(WebCore::WebGLRenderingContextBase::validateHTMLImageElement):
Moved the security exception out of here to the call sites.
(WebCore::WebGLRenderingContextBase::validateHTMLCanvasElement): Ditto.
(WebCore::WebGLRenderingContextBase::validateHTMLVideoElement): Ditto.

  • html/canvas/WebGLRenderingContextBase.h: Updated for above changes.
  • html/canvas/WebGLRenderingContextBase.idl: Use non-legacy exceptions

in some cases and no exceptions at all in many others.

  • html/shadow/MediaControlElements.cpp:

(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
Use a reference instead of a pointer.

  • html/track/DataCue.h: Use pragma once.
  • html/track/DataCue.idl: Use non-legacy exception for constructor

attribute, even though it is custom and so it has no effect.

  • html/track/InbandDataTextTrack.cpp:

(WebCore::InbandDataTextTrack::create): Use RefPtr&&.
(WebCore::InbandDataTextTrack::InbandDataTextTrack): Ditto.
(WebCore::InbandDataTextTrack::addDataCue): Stop using
ASSERT_NO_EXCEPTION.
(WebCore::InbandDataTextTrack::removeDataCue): Stop using
IGNORE_EXCEPTION.
(WebCore::InbandDataTextTrack::removeCue): Use ExceptionOr.
Also use remove instead of find/remove.

  • html/track/InbandDataTextTrack.h: Updated for above changes.
  • html/track/InbandGenericTextTrack.cpp:

(WebCore::GenericTextTrackCueMap::GenericTextTrackCueMap): Deleted.
(WebCore::GenericTextTrackCueMap::~GenericTextTrackCueMap): Deleted.
(WebCore::GenericTextTrackCueMap::add): Take references intead of
pointers.
(WebCore::GenericTextTrackCueMap::find): Ditto. Also use get
instead of find.
(WebCore::GenericTextTrackCueMap::remove): Ditto. Also use take
instead of double hashing to both find and remove.
(WebCore::InbandGenericTextTrack::updateCueFromCueData): Stop using
IGNORE_EXCEPTION. Also got rid of code that is converting a double
to a long and then back to a double by using lround. Instead just
use std::round, which keeps it a double. But also, why does this need
to round?!
(WebCore::InbandGenericTextTrack::addGenericCue): Updated to use
reference to work with m_cueMap.
(WebCore::InbandGenericTextTrack::updateGenericCue): Ditto.
(WebCore::InbandGenericTextTrack::removeGenericCue): Ditto.
(WebCore::InbandGenericTextTrack::removeCue): Use ExceptionOr.
(WebCore::InbandGenericTextTrack::newCuesParsed): Removed
ASSERT_NO_EXCEPTION.

  • html/track/InbandGenericTextTrack.h: Updated for above changes.
  • html/track/InbandWebVTTTextTrack.cpp:

(WebCore::InbandWebVTTTextTrack::newCuesParsed): Removed
ASSERT_NO_EXCEPTION.

  • html/track/TextTrack.cpp:

(WebCore::TextTrack::addCue): Use ExcepctionOr.
(WebCore::TextTrack::removeCue): Ditto.
(WebCore::TextTrack::addRegion): Ditto.
(WebCore::TextTrack::removeRegion): Ditto.

  • html/track/TextTrack.h: Updated for above changes.
  • html/track/TextTrack.idl: Ditto.
  • html/track/TextTrackCue.cpp:

(WebCore::TextTrackCue::cueShadowPseudoId): Moved this here
since it does not need to be inlined in the header.
(WebCore::TextTrackCue::~TextTrackCue): Deleted.
(WebCore::TextTrackCue::setStartTime): Removed ExceptionCode&
since the exceptions were for non-finite values, but this is
now handled by the bindings.
(WebCore::TextTrackCue::setEndTime): Ditto.

  • html/track/TextTrackCue.h: Updated for the above.
  • html/track/TextTrackCue.idl: Removed SetterMayThrowLegacyException

and made startTime and endTime be double rather than unrestricted double.

  • html/track/TextTrackCueGeneric.cpp:

(WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
Use a reference instead of a pointer.
(WebCore::TextTrackCueGeneric::TextTrackCueGeneric): Initialize
m_defaultPosition in the class definition instead of here.
(WebCore::TextTrackCueGeneric::createDisplayTree): Return a Ref.
(WebCore::TextTrackCueGeneric::setLine): Use ExceptionOr.
(WebCore::TextTrackCueGeneric::setPosition): Ditto.
(WebCore::TextTrackCueGeneric::setFontSize): Updated since
displayTreeInternal() now returns a reference.

  • html/track/TextTrackCueGeneric.h: Updated for above changes.

Also fixed some arguument types and made some more things private.

  • html/track/VTTCue.cpp:

(WebCore::VTTCue::createDisplayTree): Return a Ref.
(WebCore::VTTCue::displayTreeInternal): Return a reference.
(WebCore::VTTCue::setVertical): Use ExceptionOr.
(WebCore::VTTCue::setLine): Ditto.
(WebCore::VTTCue::setPosition): Ditto.
(WebCore::VTTCue::setSize): Ditto.
(WebCore::VTTCue::setAlign): Ditto.
(WebCore::VTTCue::getDisplayTree): Return a reference.
(WebCore::VTTCue::removeDisplayTree): Updated since
displayTreeInternal returns a reference.
(WebCore::VTTCue::setFontSize): Ditto.

  • html/track/VTTCue.h: Updated for the above.
  • html/track/VTTCue.idl: Use non-legacy exceptions and also

restricted doubles.

  • html/track/VTTRegion.cpp:

(WebCore::VTTRegion::VTTRegion): Moved default values all into
the class definition.
(WebCore::VTTRegion::setWidth): Removed the check for non-finite
since the bindings now handle that. Use ExcpetionOr.
(WebCore::VTTRegion::setHeight): Ditto.
(WebCore::VTTRegion::setRegionAnchorX): Ditto.
(WebCore::VTTRegion::setRegionAnchorY): Ditto.
(WebCore::VTTRegion::setViewportAnchorX): Ditto.
(WebCore::VTTRegion::setViewportAnchorY): Ditto.
(WebCore::upKeyword): Added. Shared by the code below.
(WebCore::VTTRegion::scroll): Rewrote to be simpler.
(WebCore::VTTRegion::setScroll): Rewrote to be simpler.
(WebCore::VTTRegion::updateParametersFromRegion): Read and
write data members directly to avoid awkward code that is otherwise
required just to copy from one object to the other. Also take a
const& instead of a pointer for the thing to update from.
(WebCore::VTTRegion::parseSettingValue): Use upKeyword.
(WebCore::VTTRegion::appendTextTrackCueBox): Take a Ref&&.
(WebCore::VTTRegion::getDisplayTree): Do the downcast to Document
here instead of using the helper function.
(WebCore::VTTRegion::prepareRegionDisplayTree): Ditto.

  • html/track/VTTRegion.h: Updated for the above.
  • html/track/VTTRegion.idl: Use non-legacy exceptions and also

use restricted dobules, not unrestricted.

LayoutTests:

  • media/track/regions-webvtt/vtt-region-constructor-expected.txt:

Change expectations to expect the more specific TypeError message
that the bindings generate as opposed to the generic ones that the
WebVTT DOM code was generating before.

Location:
trunk
Files:
51 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207718 r207720  
     12016-10-22  Darin Adler  <darin@apple.com>
     2
     3        Move HTML canvas and tracks from ExceptionCode to Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=163853
     5
     6        Reviewed by Chris Dumez.
     7
     8        * media/track/regions-webvtt/vtt-region-constructor-expected.txt:
     9        Change expectations to expect the more specific TypeError message
     10        that the bindings generate as opposed to the generic ones that the
     11        WebVTT DOM code was generating before.
     12
    1132016-10-22  Michael Catanzaro  <mcatanzaro@igalia.com>
    214
  • trunk/LayoutTests/media/track/regions-webvtt/vtt-region-constructor-expected.txt

    r203333 r207720  
    5454Invalid percentage value: -Infinity
    5555RUN(region.viewportAnchorX = invalidPercentageValues[index])
    56 TypeError: Type error
     56TypeError: The provided value is non-finite
    5757EXPECTED (region.viewportAnchorX == '0') OK
    5858RUN(region.viewportAnchorY = invalidPercentageValues[index])
    59 TypeError: Type error
     59TypeError: The provided value is non-finite
    6060EXPECTED (region.viewportAnchorY == '100') OK
    6161RUN(region.regionAnchorX = invalidPercentageValues[index])
    62 TypeError: Type error
     62TypeError: The provided value is non-finite
    6363EXPECTED (region.regionAnchorX == '0') OK
    6464RUN(region.regionAnchorY = invalidPercentageValues[index])
    65 TypeError: Type error
     65TypeError: The provided value is non-finite
    6666EXPECTED (region.regionAnchorY == '100') OK
    6767RUN(region.width = invalidPercentageValues[index])
    68 TypeError: Type error
     68TypeError: The provided value is non-finite
    6969EXPECTED (region.width == '100') OK
    7070
    7171Invalid percentage value: Infinity
    7272RUN(region.viewportAnchorX = invalidPercentageValues[index])
    73 TypeError: Type error
     73TypeError: The provided value is non-finite
    7474EXPECTED (region.viewportAnchorX == '0') OK
    7575RUN(region.viewportAnchorY = invalidPercentageValues[index])
    76 TypeError: Type error
     76TypeError: The provided value is non-finite
    7777EXPECTED (region.viewportAnchorY == '100') OK
    7878RUN(region.regionAnchorX = invalidPercentageValues[index])
    79 TypeError: Type error
     79TypeError: The provided value is non-finite
    8080EXPECTED (region.regionAnchorX == '0') OK
    8181RUN(region.regionAnchorY = invalidPercentageValues[index])
    82 TypeError: Type error
     82TypeError: The provided value is non-finite
    8383EXPECTED (region.regionAnchorY == '100') OK
    8484RUN(region.width = invalidPercentageValues[index])
    85 TypeError: Type error
     85TypeError: The provided value is non-finite
    8686EXPECTED (region.width == '100') OK
    8787
    8888Invalid percentage value: NaN
    8989RUN(region.viewportAnchorX = invalidPercentageValues[index])
    90 TypeError: Type error
     90TypeError: The provided value is non-finite
    9191EXPECTED (region.viewportAnchorX == '0') OK
    9292RUN(region.viewportAnchorY = invalidPercentageValues[index])
    93 TypeError: Type error
     93TypeError: The provided value is non-finite
    9494EXPECTED (region.viewportAnchorY == '100') OK
    9595RUN(region.regionAnchorX = invalidPercentageValues[index])
    96 TypeError: Type error
     96TypeError: The provided value is non-finite
    9797EXPECTED (region.regionAnchorX == '0') OK
    9898RUN(region.regionAnchorY = invalidPercentageValues[index])
    99 TypeError: Type error
     99TypeError: The provided value is non-finite
    100100EXPECTED (region.regionAnchorY == '100') OK
    101101RUN(region.width = invalidPercentageValues[index])
    102 TypeError: Type error
     102TypeError: The provided value is non-finite
    103103EXPECTED (region.width == '100') OK
    104104RUN(region.height = -1)
  • trunk/Source/WebCore/ChangeLog

    r207719 r207720  
     12016-10-22  Darin Adler  <darin@apple.com>
     2
     3        Move HTML canvas and tracks from ExceptionCode to Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=163853
     5
     6        Reviewed by Chris Dumez.
     7
     8        * WebCore.xcodeproj/project.pbxproj: Added CanvasPath.idl.
     9
     10        * bindings/js/JSWebGL2RenderingContextCustom.cpp: Tweaked a bit.
     11
     12        * bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
     13        (WebCore::JSWebGLRenderingContextBase::getExtension): Tweaked a bit.
     14        (WebCore::JSWebGLRenderingContextBase::getFramebufferAttachmentParameter):
     15        Removed unneeded exception handling.
     16        (WebCore::JSWebGLRenderingContextBase::getParameter): Ditto.
     17        (WebCore::JSWebGLRenderingContextBase::getProgramParameter): Ditto.
     18        (WebCore::JSWebGLRenderingContextBase::getShaderParameter): Ditto.
     19        (WebCore::JSWebGLRenderingContextBase::getSupportedExtensions): Use a
     20        modern for loop.
     21        (WebCore::JSWebGLRenderingContextBase::getUniform): Removed unneeded
     22        exception handling.
     23
     24        * html/HTMLCanvasElement.cpp:
     25        (WebCore::HTMLCanvasElement::getContext): Pass a reference.
     26        (WebCore::HTMLCanvasElement::reset): Use is<CanvasRenderingContext2D>.
     27        (WebCore::HTMLCanvasElement::setUsesDisplayListDrawing): Ditto.
     28        (WebCore::HTMLCanvasElement::setTracksDisplayListReplay) Ditto.:
     29        (WebCore::HTMLCanvasElement::displayListAsText): Ditto.
     30        (WebCore::HTMLCanvasElement::replayDisplayListAsText): Ditto.
     31        (WebCore::HTMLCanvasElement::clearImageBuffer): Ditto.
     32
     33        * html/canvas/CanvasGradient.cpp:
     34        (WebCore::CanvasGradient::CanvasGradient): Streamlined.
     35        (WebCore::CanvasGradient::addColorStop): Use ExceptionOr.
     36        * html/canvas/CanvasGradient.h: Updated for above changes.
     37        * html/canvas/CanvasGradient.idl: Use non-legacy exception.
     38
     39        * html/canvas/CanvasPath.cpp:
     40        (WebCore::CanvasPath::arcTo): Use ExceptionOr.
     41        (WebCore::CanvasPath::arc): Ditto.
     42        (WebCore::CanvasPath::ellipse): Ditto.
     43        * html/canvas/CanvasPath.h: Updated for above changes.
     44        * html/canvas/CanvasPath.idl: Use non-legacy exceptions.
     45
     46        * html/canvas/CanvasPattern.cpp:
     47        (WebCore::CanvasPattern::create): Use Ref&&.
     48        (WebCore::CanvasPattern::CanvasPattern): Ditto.
     49        (WebCore::CanvasPattern::parseRepetitionType): Return a boolean
     50        instead of using an ExceptionCode.
     51        * html/canvas/CanvasPattern.h: Updated for above changes.
     52
     53        * html/canvas/CanvasRenderingContext.cpp:
     54        (CanvasRenderingContext::wouldTaintOrigin): Reordered function so
     55        that it's safe to call it on an image element without a cached
     56        image, or a cached image without an underlying image.
     57
     58        * html/canvas/CanvasRenderingContext2D.cpp:
     59        (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
     60        Take a reference.
     61        (WebCore::CanvasRenderingContext2D::drawImage): Use ExceptionOr.
     62        (WebCore::CanvasRenderingContext2D::drawImageFromRect): Ditto.
     63        (WebCore::CanvasRenderingContext2D::createLinearGradient): Ditto.
     64        (WebCore::CanvasRenderingContext2D::createRadialGradient): Ditto.
     65        (WebCore::CanvasRenderingContext2D::createPattern): Ditto.
     66        (WebCore::CanvasRenderingContext2D::createImageData): Ditto.
     67        (WebCore::CanvasRenderingContext2D::getImageData): Ditto.
     68        (WebCore::CanvasRenderingContext2D::webkitGetImageDataHD): Ditto.
     69        (WebCore::CanvasRenderingContext2D::putImageData): Removed unneeded
     70        ExceptionCode because this does not throw exceptions; the only one
     71        was for non-finite numeric values but this is now handled by bindings.
     72        (WebCore::CanvasRenderingContext2D::webkitPutImageDataHD): Ditto.
     73        * html/canvas/CanvasRenderingContext2D.h: Updated for above.
     74        * html/canvas/CanvasRenderingContext2D.idl: Use non-legacy exceptions
     75        and removed exceptions entirely in other cases.
     76
     77        * html/canvas/OESVertexArrayObject.cpp:
     78        (WebCore::OESVertexArrayObject::OESVertexArrayObject): Take a reference.
     79        (WebCore::OESVertexArrayObject::~OESVertexArrayObject): Deleted.
     80        (WebCore::OESVertexArrayObject::isVertexArrayOES): Use && instead of
     81        multiple return statements.
     82        (WebCore::OESVertexArrayObject::bindVertexArrayOES): Removed unneeded
     83        ExceptionCode since this does not throw an exception.
     84        * html/canvas/OESVertexArrayObject.h: Updated for above.
     85        * html/canvas/OESVertexArrayObject.idl: Removed unneeded exception.
     86
     87        * html/canvas/WebGL2RenderingContext.cpp:
     88        (WebCore::WebGL2RenderingContext::getFramebufferAttachmentParameter):
     89        Removed unneeded ExceptionCode since this does not throw an exception.
     90        (WebCore::WebGL2RenderingContext::texSubImage2DBase): Ditto.
     91        (WebCore::WebGL2RenderingContext::texSubImage2DImpl): Ditto.
     92        (WebCore::WebGL2RenderingContext::texSubImage2D): Removed unneeded
     93        ExceptionCode for some overloads, for the others, use ExceptionOr
     94        for the security exception. Moved security exception code here from
     95        the validate functions.
     96        (WebCore::WebGL2RenderingContext::validateTexFuncParameters): Removed
     97        unneeded ExceptionCode.
     98        (WebCore::WebGL2RenderingContext::getParameter): Ditto.
     99        * html/canvas/WebGL2RenderingContext.h: Updated for above.
     100
     101        * html/canvas/WebGLRenderingContext.cpp:
     102        (WebCore::WebGLRenderingContext::getExtension): Pass a reference.
     103        (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter):
     104        Remvoed unneeded ExceptionCode since this does not throw an exception.
     105        (WebCore::WebGLRenderingContext::texSubImage2DBase): Ditto.
     106        (WebCore::WebGLRenderingContext::texSubImage2DImpl): Ditto.
     107        (WebCore::WebGLRenderingContext::texSubImage2D): Removed unneeded
     108        ExceptionCode for some overloads, for the others, use ExceptionOr
     109        for the security exception. Moved security exception code here from
     110        the validate functions.
     111        (WebCore::WebGLRenderingContext::getParameter): Removed unneeded
     112        ExceptionCode.
     113        * html/canvas/WebGLRenderingContext.h: Updated for above changes.
     114
     115        * html/canvas/WebGLRenderingContextBase.cpp:
     116        (WebCore::WebGLRenderingContextBase::texImage2DBase):
     117        Remvoed unneeded ExceptionCode since this does not throw an exception.
     118        (WebCore::WebGLRenderingContextBase::texImage2DImpl): Ditto.
     119        (WebCore::WebGLRenderingContextBase::texImage2D): Removed unneeded
     120        ExceptionCode for some overloads, for the others, use ExceptionOr
     121        for the security exception. Moved security exception code here from
     122        the validate functions.
     123        (WebCore::WebGLRenderingContextBase::validateHTMLImageElement):
     124        Moved the security exception out of here to the call sites.
     125        (WebCore::WebGLRenderingContextBase::validateHTMLCanvasElement): Ditto.
     126        (WebCore::WebGLRenderingContextBase::validateHTMLVideoElement): Ditto.
     127        * html/canvas/WebGLRenderingContextBase.h: Updated for above changes.
     128        * html/canvas/WebGLRenderingContextBase.idl: Use non-legacy exceptions
     129        in some cases and no exceptions at all in many others.
     130
     131        * html/shadow/MediaControlElements.cpp:
     132        (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
     133        Use a reference instead of a pointer.
     134
     135        * html/track/DataCue.h: Use pragma once.
     136        * html/track/DataCue.idl: Use non-legacy exception for constructor
     137        attribute, even though it is custom and so it has no effect.
     138
     139        * html/track/InbandDataTextTrack.cpp:
     140        (WebCore::InbandDataTextTrack::create): Use RefPtr&&.
     141        (WebCore::InbandDataTextTrack::InbandDataTextTrack): Ditto.
     142        (WebCore::InbandDataTextTrack::addDataCue): Stop using
     143        ASSERT_NO_EXCEPTION.
     144        (WebCore::InbandDataTextTrack::removeDataCue): Stop using
     145        IGNORE_EXCEPTION.
     146        (WebCore::InbandDataTextTrack::removeCue): Use ExceptionOr.
     147        Also use remove instead of find/remove.
     148        * html/track/InbandDataTextTrack.h: Updated for above changes.
     149
     150        * html/track/InbandGenericTextTrack.cpp:
     151        (WebCore::GenericTextTrackCueMap::GenericTextTrackCueMap): Deleted.
     152        (WebCore::GenericTextTrackCueMap::~GenericTextTrackCueMap): Deleted.
     153        (WebCore::GenericTextTrackCueMap::add): Take references intead of
     154        pointers.
     155        (WebCore::GenericTextTrackCueMap::find): Ditto. Also use get
     156        instead of find.
     157        (WebCore::GenericTextTrackCueMap::remove): Ditto. Also use take
     158        instead of double hashing to both find and remove.
     159        (WebCore::InbandGenericTextTrack::updateCueFromCueData): Stop using
     160        IGNORE_EXCEPTION. Also got rid of code that is converting a double
     161        to a long and then back to a double by using lround. Instead just
     162        use std::round, which keeps it a double. But also, why does this need
     163        to round?!
     164        (WebCore::InbandGenericTextTrack::addGenericCue): Updated to use
     165        reference to work with m_cueMap.
     166        (WebCore::InbandGenericTextTrack::updateGenericCue): Ditto.
     167        (WebCore::InbandGenericTextTrack::removeGenericCue): Ditto.
     168        (WebCore::InbandGenericTextTrack::removeCue): Use ExceptionOr.
     169        (WebCore::InbandGenericTextTrack::newCuesParsed): Removed
     170        ASSERT_NO_EXCEPTION.
     171        * html/track/InbandGenericTextTrack.h: Updated for above changes.
     172
     173        * html/track/InbandWebVTTTextTrack.cpp:
     174        (WebCore::InbandWebVTTTextTrack::newCuesParsed): Removed
     175        ASSERT_NO_EXCEPTION.
     176
     177        * html/track/TextTrack.cpp:
     178        (WebCore::TextTrack::addCue): Use ExcepctionOr.
     179        (WebCore::TextTrack::removeCue): Ditto.
     180        (WebCore::TextTrack::addRegion): Ditto.
     181        (WebCore::TextTrack::removeRegion): Ditto.
     182        * html/track/TextTrack.h: Updated for above changes.
     183        * html/track/TextTrack.idl: Ditto.
     184
     185        * html/track/TextTrackCue.cpp:
     186        (WebCore::TextTrackCue::cueShadowPseudoId): Moved this here
     187        since it does not need to be inlined in the header.
     188        (WebCore::TextTrackCue::~TextTrackCue): Deleted.
     189        (WebCore::TextTrackCue::setStartTime): Removed ExceptionCode&
     190        since the exceptions were for non-finite values, but this is
     191        now handled by the bindings.
     192        (WebCore::TextTrackCue::setEndTime): Ditto.
     193        * html/track/TextTrackCue.h: Updated for the above.
     194        * html/track/TextTrackCue.idl: Removed SetterMayThrowLegacyException
     195        and made startTime and endTime be double rather than unrestricted double.
     196
     197        * html/track/TextTrackCueGeneric.cpp:
     198        (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
     199        Use a reference instead of a pointer.
     200        (WebCore::TextTrackCueGeneric::TextTrackCueGeneric): Initialize
     201        m_defaultPosition in the class definition instead of here.
     202        (WebCore::TextTrackCueGeneric::createDisplayTree): Return a Ref.
     203        (WebCore::TextTrackCueGeneric::setLine): Use ExceptionOr.
     204        (WebCore::TextTrackCueGeneric::setPosition): Ditto.
     205        (WebCore::TextTrackCueGeneric::setFontSize): Updated since
     206        displayTreeInternal() now returns a reference.
     207        * html/track/TextTrackCueGeneric.h: Updated for above changes.
     208        Also fixed some arguument types and made some more things private.
     209
     210        * html/track/VTTCue.cpp:
     211        (WebCore::VTTCue::createDisplayTree): Return a Ref.
     212        (WebCore::VTTCue::displayTreeInternal): Return a reference.
     213        (WebCore::VTTCue::setVertical): Use ExceptionOr.
     214        (WebCore::VTTCue::setLine): Ditto.
     215        (WebCore::VTTCue::setPosition): Ditto.
     216        (WebCore::VTTCue::setSize): Ditto.
     217        (WebCore::VTTCue::setAlign): Ditto.
     218        (WebCore::VTTCue::getDisplayTree): Return a reference.
     219        (WebCore::VTTCue::removeDisplayTree): Updated since
     220        displayTreeInternal returns a reference.
     221        (WebCore::VTTCue::setFontSize): Ditto.
     222        * html/track/VTTCue.h: Updated for the above.
     223        * html/track/VTTCue.idl: Use non-legacy exceptions and also
     224        restricted doubles.
     225
     226        * html/track/VTTRegion.cpp:
     227        (WebCore::VTTRegion::VTTRegion): Moved default values all into
     228        the class definition.
     229        (WebCore::VTTRegion::setWidth): Removed the check for non-finite
     230        since the bindings now handle that. Use ExcpetionOr.
     231        (WebCore::VTTRegion::setHeight): Ditto.
     232        (WebCore::VTTRegion::setRegionAnchorX): Ditto.
     233        (WebCore::VTTRegion::setRegionAnchorY): Ditto.
     234        (WebCore::VTTRegion::setViewportAnchorX): Ditto.
     235        (WebCore::VTTRegion::setViewportAnchorY): Ditto.
     236        (WebCore::upKeyword): Added. Shared by the code below.
     237        (WebCore::VTTRegion::scroll): Rewrote to be simpler.
     238        (WebCore::VTTRegion::setScroll): Rewrote to be simpler.
     239        (WebCore::VTTRegion::updateParametersFromRegion): Read and
     240        write data members directly to avoid awkward code that is otherwise
     241        required just to copy from one object to the other. Also take a
     242        const& instead of a pointer for the thing to update from.
     243        (WebCore::VTTRegion::parseSettingValue): Use upKeyword.
     244        (WebCore::VTTRegion::appendTextTrackCueBox): Take a Ref&&.
     245        (WebCore::VTTRegion::getDisplayTree): Do the downcast to Document
     246        here instead of using the helper function.
     247        (WebCore::VTTRegion::prepareRegionDisplayTree): Ditto.
     248        * html/track/VTTRegion.h: Updated for the above.
     249        * html/track/VTTRegion.idl: Use non-legacy exceptions and also
     250        use restricted dobules, not unrestricted.
     251
    12522016-10-22  Chris Dumez  <cdumez@apple.com>
    2253
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r207716 r207720  
    1064410644                935FBCF109BA143B00E230B1 /* ExceptionCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCode.h; sourceTree = "<group>"; };
    1064510645                9362640A0DE1137D009D5A00 /* CSSReflectionDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSReflectionDirection.h; sourceTree = "<group>"; };
     10646                936B21F41DBBF8300052E117 /* CanvasPath.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CanvasPath.idl; sourceTree = "<group>"; };
    1064610647                936DD03A09CEAC270056AE8C /* Range.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Range.idl; sourceTree = "<group>"; };
    1064710648                9370918C1416D86B00477333 /* textAreaResizeCorner@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "textAreaResizeCorner@2x.png"; sourceTree = "<group>"; };
     
    1643516436                                4671E0631D67A57B00C6B497 /* CanvasPath.cpp */,
    1643616437                                4671E0641D67A57B00C6B497 /* CanvasPath.h */,
     16438                                936B21F41DBBF8300052E117 /* CanvasPath.idl */,
    1643716439                                49484FB6102CF23C00187DD3 /* CanvasPattern.cpp */,
    1643816440                                49484FB7102CF23C00187DD3 /* CanvasPattern.h */,
  • trunk/Source/WebCore/bindings/js/JSWebGL2RenderingContextCustom.cpp

    r206386 r207720  
    2525
    2626#include "config.h"
     27#include "JSWebGL2RenderingContext.h"
    2728
    2829#if ENABLE(WEBGL) && ENABLE(WEBGL2)
    29 #include "JSWebGL2RenderingContext.h"
    3030
    3131#include <heap/HeapInlines.h>
     
    3838namespace WebCore {
    3939
    40 static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info)
     40// FIXME: There is a duplicate version of this function in JSWebGLRenderingContextBaseCustom.cpp,
     41// but it is not exactly the same! We should merge these.
     42static JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info)
    4143{
    4244    switch (info.getType()) {
     
    4547    case WebGLGetInfo::kTypeBoolArray: {
    4648        MarkedArgumentBuffer list;
    47         const auto& values = info.getBoolArray();
    48         for (const auto& value : values)
     49        for (auto& value : info.getBoolArray())
    4950            list.append(jsBoolean(value));
    50         return constructArray(exec, 0, globalObject, list);
     51        return constructArray(state, 0, globalObject, list);
    5152    }
    5253    case WebGLGetInfo::kTypeFloat:
     
    5758        return jsNull();
    5859    case WebGLGetInfo::kTypeString:
    59         return jsStringWithCache(exec, info.getString());
     60        return jsStringWithCache(state, info.getString());
    6061    case WebGLGetInfo::kTypeUnsignedInt:
    6162        return jsNumber(info.getUnsignedInt());
     
    7374}
    7475
    75 JSValue JSWebGL2RenderingContext::getInternalformatParameter(ExecState& exec)
     76JSValue JSWebGL2RenderingContext::getInternalformatParameter(ExecState&)
    7677{
    77     UNUSED_PARAM(exec);
    7878    return jsUndefined();
    7979}
    8080
    81 JSValue JSWebGL2RenderingContext::getQueryParameter(ExecState& exec)
     81JSValue JSWebGL2RenderingContext::getQueryParameter(ExecState&)
    8282{
    83     UNUSED_PARAM(exec);
    8483    return jsUndefined();
    8584}
    8685
    87 JSValue JSWebGL2RenderingContext::getSamplerParameter(ExecState& exec)
     86JSValue JSWebGL2RenderingContext::getSamplerParameter(ExecState&)
    8887{
    89     UNUSED_PARAM(exec);
    9088    return jsUndefined();
    9189}
    9290
    93 JSValue JSWebGL2RenderingContext::getSyncParameter(ExecState& exec)
     91JSValue JSWebGL2RenderingContext::getSyncParameter(ExecState&)
    9492{
    95     UNUSED_PARAM(exec);
    9693    return jsUndefined();
    9794}
    9895
    99 JSValue JSWebGL2RenderingContext::getIndexedParameter(ExecState& exec)
     96JSValue JSWebGL2RenderingContext::getIndexedParameter(ExecState& state)
    10097{
    101     VM& vm = exec.vm();
     98    VM& vm = state.vm();
    10299    auto scope = DECLARE_THROW_SCOPE(vm);
    103100
    104     if (exec.argumentCount() != 2)
    105         return throwException(&exec, scope, createNotEnoughArgumentsError(&exec));
     101    if (state.argumentCount() < 2)
     102        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    106103
    107     WebGL2RenderingContext& context = wrapped();
    108     unsigned pname = exec.uncheckedArgument(0).toInt32(&exec);
     104    unsigned pname = state.uncheckedArgument(0).toInt32(&state);
    109105    RETURN_IF_EXCEPTION(scope, JSValue());
    110     unsigned index = exec.uncheckedArgument(1).toInt32(&exec);
     106    unsigned index = state.uncheckedArgument(1).toInt32(&state);
    111107    RETURN_IF_EXCEPTION(scope, JSValue());
    112     WebGLGetInfo info = context.getIndexedParameter(pname, index);
    113     return toJS(&exec, globalObject(), info);
     108    return toJS(&state, globalObject(), wrapped().getIndexedParameter(pname, index));
    114109}
    115110
    116 JSValue JSWebGL2RenderingContext::getActiveUniformBlockParameter(ExecState& exec)
     111JSValue JSWebGL2RenderingContext::getActiveUniformBlockParameter(ExecState&)
    117112{
    118     UNUSED_PARAM(exec);
    119113    return jsUndefined();
    120114}
    121115
    122 JSValue JSWebGL2RenderingContext::getActiveUniformBlockName(ExecState& exec)
     116JSValue JSWebGL2RenderingContext::getActiveUniformBlockName(ExecState&)
    123117{
    124     UNUSED_PARAM(exec);
    125118    return jsUndefined();
    126119}
    127 
    128120
    129121} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp

    r207644 r207720  
    2525
    2626#include "config.h"
     27#include "JSWebGLRenderingContextBase.h"
    2728
    2829#if ENABLE(WEBGL)
    29 #include "JSWebGLRenderingContextBase.h"
    3030
    3131#include "ANGLEInstancedArrays.h"
     
    131131}
    132132   
     133// FIXME: There is a duplicate version of this function in JSWebGL2RenderingContextCustom.cpp,
     134// but it is not exactly the same! We should merge these.
    133135static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info)
    134136{
     
    138140    case WebGLGetInfo::kTypeBoolArray: {
    139141        MarkedArgumentBuffer list;
    140         const Vector<bool>& value = info.getBoolArray();
    141         for (size_t ii = 0; ii < value.size(); ++ii)
    142             list.append(jsBoolean(value[ii]));
     142        for (auto& value : info.getBoolArray())
     143            list.append(jsBoolean(value));
    143144        return constructArray(exec, 0, globalObject, list);
    144145    }
     
    185186}
    186187
    187 enum ObjectType {
    188     kBuffer, kRenderbuffer, kTexture, kVertexAttrib
    189 };
     188enum ObjectType { kBuffer, kRenderbuffer, kTexture, kVertexAttrib };
    190189
    191190static JSValue getObjectParameter(JSWebGLRenderingContextBase* obj, ExecState& state, ObjectType objectType)
     
    332331        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    333332   
    334     WebGLRenderingContextBase& context = wrapped();
    335     const String name = state.uncheckedArgument(0).toString(&state)->value(&state);
    336     RETURN_IF_EXCEPTION(scope, JSValue());
    337     WebGLExtension* extension = context.getExtension(name);
    338     return toJS(&state, globalObject(), extension);
     333    String name = state.uncheckedArgument(0).toWTFString(&state);
     334    RETURN_IF_EXCEPTION(scope, JSValue());
     335    return toJS(&state, globalObject(), wrapped().getExtension(name));
    339336}
    340337
     
    352349        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    353350   
    354     ExceptionCode ec = 0;
    355     WebGLRenderingContextBase& context = wrapped();
    356351    unsigned target = state.uncheckedArgument(0).toInt32(&state);
    357352    RETURN_IF_EXCEPTION(scope, JSValue());
     
    360355    unsigned pname = state.uncheckedArgument(2).toInt32(&state);
    361356    RETURN_IF_EXCEPTION(scope, JSValue());
    362     WebGLGetInfo info = context.getFramebufferAttachmentParameter(target, attachment, pname, ec);
    363     if (ec) {
    364         setDOMException(&state, ec);
    365         return jsUndefined();
    366     }
    367     return toJS(&state, globalObject(), info);
     357    return toJS(&state, globalObject(), wrapped().getFramebufferAttachmentParameter(target, attachment, pname));
    368358}
    369359
     
    376366        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    377367   
    378     ExceptionCode ec = 0;
    379     WebGLRenderingContextBase& context = wrapped();
    380368    unsigned pname = state.uncheckedArgument(0).toInt32(&state);
    381369    RETURN_IF_EXCEPTION(scope, JSValue());
    382     WebGLGetInfo info = context.getParameter(pname, ec);
    383     if (ec) {
    384         setDOMException(&state, ec);
    385         return jsUndefined();
    386     }
    387     return toJS(&state, globalObject(), info);
     370    return toJS(&state, globalObject(), wrapped().getParameter(pname));
    388371}
    389372
     
    396379        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    397380   
    398     ExceptionCode ec = 0;
    399     WebGLRenderingContextBase& context = wrapped();
    400381    WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
    401382    if (!program && !state.uncheckedArgument(0).isUndefinedOrNull())
     
    403384    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
    404385    RETURN_IF_EXCEPTION(scope, JSValue());
    405     WebGLGetInfo info = context.getProgramParameter(program, pname);
    406     if (ec) {
    407         setDOMException(&state, ec);
    408         return jsUndefined();
    409     }
    410     return toJS(&state, globalObject(), info);
     386    return toJS(&state, globalObject(), wrapped().getProgramParameter(program, pname));
    411387}
    412388
     
    424400        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    425401   
    426     ExceptionCode ec = 0;
    427     WebGLRenderingContextBase& context = wrapped();
    428402    if (!state.uncheckedArgument(0).isUndefinedOrNull() && !state.uncheckedArgument(0).inherits(JSWebGLShader::info()))
    429403        return throwTypeError(&state, scope);
     
    431405    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
    432406    RETURN_IF_EXCEPTION(scope, JSValue());
    433     WebGLGetInfo info = context.getShaderParameter(shader, pname);
    434     if (ec) {
    435         setDOMException(&state, ec);
    436         return jsUndefined();
    437     }
    438     return toJS(&state, globalObject(), info);
     407    return toJS(&state, globalObject(), wrapped().getShaderParameter(shader, pname));
    439408}
    440409
     
    444413    if (context.isContextLost())
    445414        return jsNull();
    446     Vector<String> value = context.getSupportedExtensions();
    447415    MarkedArgumentBuffer list;
    448     for (size_t ii = 0; ii < value.size(); ++ii)
    449         list.append(jsStringWithCache(&state, value[ii]));
     416    for (auto& extension : context.getSupportedExtensions())
     417        list.append(jsStringWithCache(&state, extension));
    450418    return constructArray(&state, 0, globalObject(), list);
    451419}
     
    464432        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    465433   
    466     ExceptionCode ec = 0;
    467     WebGLRenderingContextBase& context = wrapped();
    468434    WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
    469435    if (!program && !state.uncheckedArgument(0).isUndefinedOrNull())
     
    472438    if (!location && !state.uncheckedArgument(1).isUndefinedOrNull())
    473439        return throwTypeError(&state, scope);
    474     WebGLGetInfo info = context.getUniform(program, location);
    475     if (ec) {
    476         setDOMException(&state, ec);
    477         return jsUndefined();
    478     }
    479     return toJS(&state, globalObject(), info);
     440    return toJS(&state, globalObject(), wrapped().getUniform(program, location));
    480441}
    481442
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r207458 r207720  
    229229            }
    230230
    231             m_context = std::make_unique<CanvasRenderingContext2D>(this, document().inQuirksMode(), usesDashboardCompatibilityMode);
     231            m_context = std::make_unique<CanvasRenderingContext2D>(*this, document().inQuirksMode(), usesDashboardCompatibilityMode);
    232232
    233233            downcast<CanvasRenderingContext2D>(*m_context).setUsesDisplayListDrawing(m_usesDisplayListDrawing);
     
    323323    }
    324324
    325     if (m_context && m_context->is2d()) {
    326         CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
    327         context2D->reset();
    328     }
     325    if (is<CanvasRenderingContext2D>(m_context.get()))
     326        downcast<CanvasRenderingContext2D>(*m_context).reset();
    329327
    330328    IntSize oldSize = size();
     
    578576    m_usesDisplayListDrawing = usesDisplayListDrawing;
    579577
    580     if (m_context && is<CanvasRenderingContext2D>(*m_context))
     578    if (is<CanvasRenderingContext2D>(m_context.get()))
    581579        downcast<CanvasRenderingContext2D>(*m_context).setUsesDisplayListDrawing(m_usesDisplayListDrawing);
    582580}
     
    589587    m_tracksDisplayListReplay = tracksDisplayListReplay;
    590588
    591     if (m_context && is<CanvasRenderingContext2D>(*m_context))
     589    if (is<CanvasRenderingContext2D>(m_context.get()))
    592590        downcast<CanvasRenderingContext2D>(*m_context).setTracksDisplayListReplay(m_tracksDisplayListReplay);
    593591}
     
    595593String HTMLCanvasElement::displayListAsText(DisplayList::AsTextFlags flags) const
    596594{
    597     if (m_context && is<CanvasRenderingContext2D>(*m_context))
     595    if (is<CanvasRenderingContext2D>(m_context.get()))
    598596        return downcast<CanvasRenderingContext2D>(*m_context).displayListAsText(flags);
    599597
     
    603601String HTMLCanvasElement::replayDisplayListAsText(DisplayList::AsTextFlags flags) const
    604602{
    605     if (m_context && is<CanvasRenderingContext2D>(*m_context))
     603    if (is<CanvasRenderingContext2D>(m_context.get()))
    606604        return downcast<CanvasRenderingContext2D>(*m_context).replayDisplayListAsText(flags);
    607605
     
    714712    m_didClearImageBuffer = true;
    715713
    716     if (m_context->is2d()) {
    717         CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
     714    if (is<CanvasRenderingContext2D>(*m_context)) {
    718715        // No need to undo transforms/clip/etc. because we are called right after the context is reset.
    719         context2D->clearRect(0, 0, width(), height());
     716        downcast<CanvasRenderingContext2D>(*m_context).clearRect(0, 0, width(), height());
    720717    }
    721718}
  • trunk/Source/WebCore/html/canvas/CanvasGradient.cpp

    r207487 r207720  
    2828#include "CanvasGradient.h"
    2929
    30 #include "CanvasPattern.h"
    3130#include "CanvasStyle.h"
    32 #include "CSSParser.h"
    3331#include "ExceptionCode.h"
    3432
     
    3735CanvasGradient::CanvasGradient(const FloatPoint& p0, const FloatPoint& p1)
    3836    : m_gradient(Gradient::create(p0, p1))
    39 #if ENABLE(DASHBOARD_SUPPORT)
    40     , m_dashboardCompatibilityMode(false)
    41 #endif
    4237{
    4338}
     
    4540CanvasGradient::CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
    4641    : m_gradient(Gradient::create(p0, r0, p1, r1))
    47 #if ENABLE(DASHBOARD_SUPPORT)
    48     , m_dashboardCompatibilityMode(false)
    49 #endif
    5042{
    5143}
    5244
    53 void CanvasGradient::addColorStop(float value, const String& colorString, ExceptionCode& ec)
     45ExceptionOr<void> CanvasGradient::addColorStop(float value, const String& colorString)
    5446{
    55     if (!(value >= 0 && value <= 1.0f)) {
    56         ec = INDEX_SIZE_ERR;
    57         return;
    58     }
     47    if (!(value >= 0 && value <= 1))
     48        return Exception { INDEX_SIZE_ERR };
    5949
     50    // FIXME: Passing null for canvas means this won't work for current color. Is that OK?
    6051    Color color = parseColorOrCurrentColor(colorString, nullptr /*canvas*/);
    6152    if (!color.isValid()) {
    6253#if ENABLE(DASHBOARD_SUPPORT)
    63         if (!m_dashboardCompatibilityMode)
    64             ec = SYNTAX_ERR;
    65 #else
    66         ec = SYNTAX_ERR;
     54        if (m_dashboardCompatibilityMode)
     55            return { };
    6756#endif
    68         return;
     57        return Exception { SYNTAX_ERR };
    6958    }
    7059
    7160    m_gradient->addColorStop(value, color);
     61    return { };
    7262}
    7363
    74 } // namespace
     64}
  • trunk/Source/WebCore/html/canvas/CanvasGradient.h

    r199537 r207720  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
    44 *
     
    2525 */
    2626
    27 #ifndef CanvasGradient_h
    28 #define CanvasGradient_h
     27#pragma once
    2928
     29#include "ExceptionOr.h"
    3030#include "Gradient.h"
    31 #include <wtf/Forward.h>
    32 #include <wtf/RefCounted.h>
    3331
    3432namespace WebCore {
    3533
    36     typedef int ExceptionCode;
     34class CanvasGradient : public RefCounted<CanvasGradient> {
     35public:
     36    static Ref<CanvasGradient> create(const FloatPoint& p0, const FloatPoint& p1)
     37    {
     38        return adoptRef(*new CanvasGradient(p0, p1));
     39    }
     40    static Ref<CanvasGradient> create(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
     41    {
     42        return adoptRef(*new CanvasGradient(p0, r0, p1, r1));
     43    }
    3744
    38     class CanvasGradient : public RefCounted<CanvasGradient> {
    39     public:
    40         static Ref<CanvasGradient> create(const FloatPoint& p0, const FloatPoint& p1)
    41         {
    42             return adoptRef(*new CanvasGradient(p0, p1));
    43         }
    44         static Ref<CanvasGradient> create(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
    45         {
    46             return adoptRef(*new CanvasGradient(p0, r0, p1, r1));
    47         }
    48        
    49         Gradient& gradient() { return m_gradient; }
    50         const Gradient& gradient() const { return m_gradient; }
     45    Gradient& gradient() { return m_gradient; }
     46    const Gradient& gradient() const { return m_gradient; }
    5147
    52         void addColorStop(float value, const String& color, ExceptionCode&);
     48    ExceptionOr<void> addColorStop(float value, const String& color);
    5349
    5450#if ENABLE(DASHBOARD_SUPPORT)
    55         void setDashboardCompatibilityMode() { m_dashboardCompatibilityMode = true; }
     51    void setDashboardCompatibilityMode() { m_dashboardCompatibilityMode = true; }
    5652#endif
    5753
    58     private:
    59         CanvasGradient(const FloatPoint& p0, const FloatPoint& p1);
    60         CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1);
    61        
    62         Ref<Gradient> m_gradient;
     54private:
     55    CanvasGradient(const FloatPoint& p0, const FloatPoint& p1);
     56    CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1);
     57
     58    Ref<Gradient> m_gradient;
    6359#if ENABLE(DASHBOARD_SUPPORT)
    64         bool m_dashboardCompatibilityMode;
     60    bool m_dashboardCompatibilityMode { false };
    6561#endif
    66     };
     62};
    6763
    68 } //namespace
    69 
    70 #endif
     64}
  • trunk/Source/WebCore/html/canvas/CanvasGradient.idl

    r206723 r207720  
    11/*
    2  * Copyright (C) 2006 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
     25
    2526[
    2627    ImplementationLacksVTable,
    2728] interface CanvasGradient {
    28     [MayThrowLegacyException] void addColorStop(float offset, DOMString color);
     29    [MayThrowException] void addColorStop(float offset, DOMString color);
    2930};
    30 
  • trunk/Source/WebCore/html/canvas/CanvasPath.cpp

    r204669 r207720  
    112112}
    113113
    114 void CanvasPath::arcTo(float x1, float y1, float x2, float y2, float r, ExceptionCode& ec)
    115 {
    116     ec = 0;
     114ExceptionOr<void> CanvasPath::arcTo(float x1, float y1, float x2, float y2, float r)
     115{
    117116    if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std::isfinite(y2) || !std::isfinite(r))
    118         return;
    119 
    120     if (r < 0) {
    121         ec = INDEX_SIZE_ERR;
    122         return;
    123     }
    124 
    125     if (!hasInvertibleTransform())
    126         return;
     117        return { };
     118
     119    if (r < 0)
     120        return Exception { INDEX_SIZE_ERR };
     121
     122    if (!hasInvertibleTransform())
     123        return { };
    127124
    128125    FloatPoint p1 = FloatPoint(x1, y1);
     
    135132    else
    136133        m_path.addArcTo(p1, p2, r);
     134
     135    return { };
    137136}
    138137
     
    156155}
    157156
    158 void CanvasPath::arc(float x, float y, float radius, float startAngle, float endAngle, bool anticlockwise, ExceptionCode& ec)
     157ExceptionOr<void> CanvasPath::arc(float x, float y, float radius, float startAngle, float endAngle, bool anticlockwise)
    159158{
    160159    if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius) || !std::isfinite(startAngle) || !std::isfinite(endAngle))
    161         return;
    162 
    163     if (radius < 0) {
    164         ec = INDEX_SIZE_ERR;
    165         return;
    166     }
    167 
    168     if (!hasInvertibleTransform())
    169         return;
     160        return { };
     161
     162    if (radius < 0)
     163        return Exception { INDEX_SIZE_ERR };
     164
     165    if (!hasInvertibleTransform())
     166        return { };
    170167
    171168    normalizeAngles(startAngle, endAngle, anticlockwise);
     
    174171        // The arc is empty but we still need to draw the connecting line.
    175172        lineTo(x + radius * cosf(startAngle), y + radius * sinf(startAngle));
    176         return;
     173        return { };
    177174    }
    178175
    179176    m_path.addArc(FloatPoint(x, y), radius, startAngle, endAngle, anticlockwise);
     177    return { };
    180178}
    181179   
    182 void CanvasPath::ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise, ExceptionCode& ec)
     180ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise)
    183181{
    184182    if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radiusX) || !std::isfinite(radiusY) || !std::isfinite(rotation) || !std::isfinite(startAngle) || !std::isfinite(endAngle))
    185         return;
    186 
    187     if (radiusX < 0 || radiusY < 0) {
    188         ec = INDEX_SIZE_ERR;
    189         return;
    190     }
    191 
    192     if (!hasInvertibleTransform())
    193         return;
     183        return { };
     184
     185    if (radiusX < 0 || radiusY < 0)
     186        return Exception { INDEX_SIZE_ERR };
     187
     188    if (!hasInvertibleTransform())
     189        return { };
    194190
    195191    normalizeAngles(startAngle, endAngle, anticlockwise);
     
    200196
    201197        lineTo(transform.mapPoint(FloatPoint(radiusX * cosf(startAngle), radiusY * sinf(startAngle))));
    202         return;
     198        return { };
    203199    }
    204200
     
    218214
    219215        lineTo(transform.mapPoint(FloatPoint(radiusX * cosf(endAngle), radiusY * sinf(endAngle))));
    220         return;
     216        return { };
    221217    }
    222218
    223219    m_path.addEllipse(FloatPoint(x, y), radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
     220    return { };
    224221}
    225222
  • trunk/Source/WebCore/html/canvas/CanvasPath.h

    r204669 r207720  
    2929#pragma once
    3030
     31#include "ExceptionOr.h"
    3132#include "Path.h"
    3233
    3334namespace WebCore {
    34 
    35 class FloatRect;
    36 
    37 typedef int ExceptionCode;
    3835
    3936class CanvasPath {
     
    4643    void quadraticCurveTo(float cpx, float cpy, float x, float y);
    4744    void bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y);
    48     void arcTo(float x0, float y0, float x1, float y1, float radius, ExceptionCode&);
    49     void arc(float x, float y, float r, float sa, float ea, bool anticlockwise, ExceptionCode&);
    50     void ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngled, bool anticlockwise, ExceptionCode&);
     45    ExceptionOr<void> arcTo(float x0, float y0, float x1, float y1, float radius);
     46    ExceptionOr<void> arc(float x, float y, float r, float sa, float ea, bool anticlockwise);
     47    ExceptionOr<void> ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngled, bool anticlockwise);
    5148    void rect(float x, float y, float width, float height);
    5249
  • trunk/Source/WebCore/html/canvas/CanvasPath.idl

    r206723 r207720  
    3434    void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
    3535    void bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
    36     [MayThrowLegacyException] void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
    37     // [MayThrowLegacyException] void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation);
     36    [MayThrowException] void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
     37    // [MayThrowException] void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation);
    3838    void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
    39     [MayThrowLegacyException] void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
    40     [MayThrowLegacyException] void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
     39    [MayThrowException] void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
     40    [MayThrowException] void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
    4141};
  • trunk/Source/WebCore/html/canvas/CanvasPattern.cpp

    r177733 r207720  
    3434namespace WebCore {
    3535
    36 Ref<CanvasPattern> CanvasPattern::create(PassRefPtr<Image> image, bool repeatX, bool repeatY, bool originClean)
     36Ref<CanvasPattern> CanvasPattern::create(Ref<Image>&& image, bool repeatX, bool repeatY, bool originClean)
    3737{
    38     return adoptRef(*new CanvasPattern(image, repeatX, repeatY, originClean));
     38    return adoptRef(*new CanvasPattern(WTFMove(image), repeatX, repeatY, originClean));
    3939}
    4040
    41 CanvasPattern::CanvasPattern(PassRefPtr<Image> image, bool repeatX, bool repeatY, bool originClean)
    42     : m_pattern(Pattern::create(image, repeatX, repeatY))
     41CanvasPattern::CanvasPattern(Ref<Image>&& image, bool repeatX, bool repeatY, bool originClean)
     42    : m_pattern(Pattern::create(WTFMove(image), repeatX, repeatY))
    4343    , m_originClean(originClean)
    4444{
     
    4949}
    5050
    51 void CanvasPattern::parseRepetitionType(const String& type, bool& repeatX, bool& repeatY, ExceptionCode& ec)
     51bool CanvasPattern::parseRepetitionType(const String& type, bool& repeatX, bool& repeatY)
    5252{
    53     ec = 0;
    5453    if (type.isEmpty() || type == "repeat") {
    5554        repeatX = true;
    5655        repeatY = true;
    57         return;
     56        return true;
    5857    }
    5958    if (type == "no-repeat") {
    6059        repeatX = false;
    6160        repeatY = false;
    62         return;
     61        return true;
    6362    }
    6463    if (type == "repeat-x") {
    6564        repeatX = true;
    6665        repeatY = false;
    67         return;
     66        return true;
    6867    }
    6968    if (type == "repeat-y") {
    7069        repeatX = false;
    7170        repeatY = true;
    72         return;
     71        return true;
    7372    }
    74     ec = SYNTAX_ERR;
     73    return false;
    7574}
    7675
  • trunk/Source/WebCore/html/canvas/CanvasPattern.h

    r177733 r207720  
    2424 */
    2525
    26 #ifndef CanvasPattern_h
    27 #define CanvasPattern_h
     26#pragma once
    2827
    2928#include <wtf/Forward.h>
    30 #include <wtf/PassRefPtr.h>
    3129#include <wtf/Ref.h>
    3230#include <wtf/RefCounted.h>
     
    3735class Pattern;
    3836
    39 typedef int ExceptionCode;
    40 
    4137class CanvasPattern : public RefCounted<CanvasPattern> {
    4238public:
    43     static Ref<CanvasPattern> create(PassRefPtr<Image>, bool repeatX, bool repeatY, bool originClean);
     39    static Ref<CanvasPattern> create(Ref<Image>&&, bool repeatX, bool repeatY, bool originClean);
    4440    ~CanvasPattern();
    4541
    46     static void parseRepetitionType(const String&, bool& repeatX, bool& repeatY, ExceptionCode&);
     42    static bool parseRepetitionType(const String&, bool& repeatX, bool& repeatY);
    4743
    4844    Pattern& pattern() { return m_pattern; }
     
    5248
    5349private:
    54     CanvasPattern(PassRefPtr<Image>, bool repeatX, bool repeatY, bool originClean);
     50    CanvasPattern(Ref<Image>&&, bool repeatX, bool repeatY, bool originClean);
    5551
    5652    Ref<Pattern> m_pattern;
     
    5955
    6056} // namespace WebCore
    61 
    62 #endif
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp

    r207537 r207720  
    5656}
    5757
    58 bool CanvasRenderingContext::wouldTaintOrigin(const HTMLImageElement* image)
     58bool CanvasRenderingContext::wouldTaintOrigin(const HTMLImageElement* element)
    5959{
    60     if (!image || !canvas()->originClean())
     60    if (!element || !canvas()->originClean())
    6161        return false;
    6262
    63     ASSERT(image->cachedImage());
    64     CachedImage& cachedImage = *image->cachedImage();
     63    auto* cachedImage = element->cachedImage();
     64    if (!cachedImage)
     65        return false;
    6566
    66     ASSERT(cachedImage.image());
    67     if (!cachedImage.image()->hasSingleSecurityOrigin())
     67    auto* image = cachedImage->image();
     68    if (!image)
     69        return false;
     70
     71    if (!image->hasSingleSecurityOrigin())
     72        return true;
     73
     74    if (!cachedImage->isCORSSameOrigin())
    6875        return true;
    6976
    7077    ASSERT(canvas()->securityOrigin());
    71     ASSERT(cachedImage.origin());
    72     ASSERT(canvas()->securityOrigin()->toString() == cachedImage.origin()->toString());
    73     return !cachedImage.isCORSSameOrigin();
     78    ASSERT(cachedImage->origin());
     79    ASSERT(canvas()->securityOrigin()->toString() == cachedImage->origin()->toString());
     80    return false;
    7481}
    7582
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r207361 r207720  
    133133};
    134134
    135 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)
    136     : CanvasRenderingContext(canvas)
     135CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)
     136    : CanvasRenderingContext(&canvas)
    137137    , m_stateStack(1)
    138138    , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode)
     
    13491349}
    13501350
    1351 void CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float x, float y, ExceptionCode& ec)
     1351ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float x, float y)
    13521352{
    13531353    LayoutSize destRectSize = size(imageElement, ImageSizeAfterDevicePixelRatio);
    1354     drawImage(imageElement, x, y, destRectSize.width(), destRectSize.height(), ec);
    1355 }
    1356 
    1357 void CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement,
    1358     float x, float y, float width, float height, ExceptionCode& ec)
     1354    return drawImage(imageElement, x, y, destRectSize.width(), destRectSize.height());
     1355}
     1356
     1357ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float x, float y, float width, float height)
    13591358{
    13601359    LayoutSize sourceRectSize = size(imageElement, ImageSizeBeforeDevicePixelRatio);
    1361     drawImage(imageElement, FloatRect(0, 0, sourceRectSize.width(), sourceRectSize.height()), FloatRect(x, y, width, height), ec);
    1362 }
    1363 
    1364 void CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement,
    1365     float sx, float sy, float sw, float sh,
    1366     float dx, float dy, float dw, float dh, ExceptionCode& ec)
    1367 {
    1368     drawImage(imageElement, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
    1369 }
    1370 
    1371 void CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode& ec)
    1372 {
    1373     drawImage(imageElement, srcRect, dstRect, state().globalComposite, state().globalBlend, ec);
    1374 }
    1375 
    1376 void CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMode& blendMode, ExceptionCode& ec)
    1377 {
    1378     ec = 0;
    1379 
     1360    return drawImage(imageElement, FloatRect { 0, 0, sourceRectSize.width(), sourceRectSize.height() }, FloatRect { x, y, width, height });
     1361}
     1362
     1363ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
     1364{
     1365    return drawImage(imageElement, FloatRect { sx, sy, sw, sh }, FloatRect { dx, dy, dw, dh });
     1366}
     1367
     1368ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, const FloatRect& srcRect, const FloatRect& dstRect)
     1369{
     1370    return drawImage(imageElement, srcRect, dstRect, state().globalComposite, state().globalBlend);
     1371}
     1372
     1373ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMode& blendMode)
     1374{
    13801375    if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfinite(dstRect.width()) || !std::isfinite(dstRect.height())
    13811376        || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::isfinite(srcRect.width()) || !std::isfinite(srcRect.height()))
    1382         return;
     1377        return { };
    13831378
    13841379    if (!dstRect.width() || !dstRect.height())
    1385         return;
     1380        return { };
    13861381
    13871382    if (!imageElement.complete())
    1388         return;
     1383        return { };
    13891384
    13901385    FloatRect normalizedSrcRect = normalizeRect(srcRect);
     
    13921387
    13931388    FloatRect imageRect = FloatRect(FloatPoint(), size(imageElement, ImageSizeBeforeDevicePixelRatio));
    1394     if (!srcRect.width() || !srcRect.height()) {
    1395         ec = INDEX_SIZE_ERR;
    1396         return;
    1397     }
     1389    if (!srcRect.width() || !srcRect.height())
     1390        return Exception { INDEX_SIZE_ERR };
    13981391
    13991392    // When the source rectangle is outside the source image, the source rectangle must be clipped
     
    14021395    normalizedSrcRect.intersect(imageRect);
    14031396    if (normalizedSrcRect.isEmpty())
    1404         return;
     1397        return { };
    14051398
    14061399    if (normalizedSrcRect != originalNormalizedSrcRect) {
     
    14081401        normalizedDstRect.setHeight(normalizedDstRect.height() * normalizedSrcRect.height() / originalNormalizedSrcRect.height());
    14091402        if (normalizedDstRect.isEmpty())
    1410             return;
    1411     }
    1412 
    1413     GraphicsContext* c = drawingContext();
    1414     if (!c)
    1415         return;
     1403            return { };
     1404    }
     1405
     1406    GraphicsContext* c = drawingContext();
     1407    if (!c)
     1408        return { };
    14161409    if (!state().hasInvertibleTransform)
    1417         return;
     1410        return { };
    14181411
    14191412    CachedImage* cachedImage = imageElement.cachedImage();
    14201413    if (!cachedImage)
    1421         return;
     1414        return { };
    14221415
    14231416    Image* image = cachedImage->imageForRenderer(imageElement.renderer());
    14241417    if (!image)
    1425         return;
    1426    
     1418        return { };
     1419
    14271420    ImageObserver* observer = image->imageObserver();
    14281421
     
    14511444
    14521445    checkOrigin(&imageElement);
    1453 }
    1454 
    1455 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, float x, float y, ExceptionCode& ec)
    1456 {
    1457     drawImage(sourceCanvas, 0, 0, sourceCanvas.width(), sourceCanvas.height(), x, y, sourceCanvas.width(), sourceCanvas.height(), ec);
    1458 }
    1459 
    1460 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas,
    1461     float x, float y, float width, float height, ExceptionCode& ec)
    1462 {
    1463     drawImage(sourceCanvas, FloatRect(0, 0, sourceCanvas.width(), sourceCanvas.height()), FloatRect(x, y, width, height), ec);
    1464 }
    1465 
    1466 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas,
    1467     float sx, float sy, float sw, float sh,
    1468     float dx, float dy, float dw, float dh, ExceptionCode& ec)
    1469 {
    1470     drawImage(sourceCanvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
    1471 }
    1472 
    1473 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, const FloatRect& srcRect,
    1474     const FloatRect& dstRect, ExceptionCode& ec)
     1446
     1447    return { };
     1448}
     1449
     1450ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, float x, float y)
     1451{
     1452    return drawImage(sourceCanvas, 0, 0, sourceCanvas.width(), sourceCanvas.height(), x, y, sourceCanvas.width(), sourceCanvas.height());
     1453}
     1454
     1455ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, float x, float y, float width, float height)
     1456{
     1457    return drawImage(sourceCanvas, FloatRect(0, 0, sourceCanvas.width(), sourceCanvas.height()), FloatRect { x, y, width, height });
     1458}
     1459
     1460ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
     1461{
     1462    return drawImage(sourceCanvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh));
     1463}
     1464
     1465ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, const FloatRect& srcRect, const FloatRect& dstRect)
    14751466{
    14761467    FloatRect srcCanvasRect = FloatRect(FloatPoint(), sourceCanvas.size());
    14771468
    1478     if (!srcCanvasRect.width() || !srcCanvasRect.height()) {
    1479         ec = INVALID_STATE_ERR;
    1480         return;
    1481     }
    1482 
    1483     if (!srcRect.width() || !srcRect.height()) {
    1484         ec = INDEX_SIZE_ERR;
    1485         return;
    1486     }
    1487 
    1488     ec = 0;
     1469    if (!srcCanvasRect.width() || !srcCanvasRect.height())
     1470        return Exception { INVALID_STATE_ERR };
     1471
     1472    if (!srcRect.width() || !srcRect.height())
     1473        return Exception { INDEX_SIZE_ERR };
    14891474
    14901475    if (!srcCanvasRect.contains(normalizeRect(srcRect)) || !dstRect.width() || !dstRect.height())
    1491         return;
    1492 
    1493     GraphicsContext* c = drawingContext();
    1494     if (!c)
    1495         return;
     1476        return { };
     1477
     1478    GraphicsContext* c = drawingContext();
     1479    if (!c)
     1480        return { };
    14961481    if (!state().hasInvertibleTransform)
    1497         return;
     1482        return { };
    14981483
    14991484    // FIXME: Do this through platform-independent GraphicsContext API.
    15001485    ImageBuffer* buffer = sourceCanvas.buffer();
    15011486    if (!buffer)
    1502         return;
     1487        return { };
    15031488
    15041489    checkOrigin(&sourceCanvas);
     
    15291514        didDraw(dstRect);
    15301515    }
     1516
     1517    return { };
    15311518}
    15321519
    15331520#if ENABLE(VIDEO)
    1534 void CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float x, float y, ExceptionCode& ec)
     1521
     1522ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float x, float y)
    15351523{
    15361524    FloatSize videoSize = size(video);
    1537     drawImage(video, x, y, videoSize.width(), videoSize.height(), ec);
    1538 }
    1539 
    1540 void CanvasRenderingContext2D::drawImage(HTMLVideoElement& video,
    1541                                          float x, float y, float width, float height, ExceptionCode& ec)
     1525    return drawImage(video, x, y, videoSize.width(), videoSize.height());
     1526}
     1527
     1528ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float x, float y, float width, float height)
    15421529{
    15431530    FloatSize videoSize = size(video);
    1544     drawImage(video, FloatRect(0, 0, videoSize.width(), videoSize.height()), FloatRect(x, y, width, height), ec);
    1545 }
    1546 
    1547 void CanvasRenderingContext2D::drawImage(HTMLVideoElement& video,
    1548     float sx, float sy, float sw, float sh,
    1549     float dx, float dy, float dw, float dh, ExceptionCode& ec)
    1550 {
    1551     drawImage(video, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
    1552 }
    1553 
    1554 void CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, const FloatRect& srcRect, const FloatRect& dstRect,
    1555                                          ExceptionCode& ec)
    1556 {
    1557     ec = 0;
    1558 
     1531    return drawImage(video, FloatRect { 0, 0, videoSize.width(), videoSize.height() }, FloatRect { x, y, width, height });
     1532}
     1533
     1534ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)
     1535{
     1536    return drawImage(video, FloatRect { sx, sy, sw, sh }, FloatRect { dx, dy, dw, dh });
     1537}
     1538
     1539ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, const FloatRect& srcRect, const FloatRect& dstRect)
     1540{
    15591541    if (video.readyState() == HTMLMediaElement::HAVE_NOTHING || video.readyState() == HTMLMediaElement::HAVE_METADATA)
    1560         return;
     1542        return { };
    15611543
    15621544    FloatRect videoRect = FloatRect(FloatPoint(), size(video));
    1563     if (!srcRect.width() || !srcRect.height()) {
    1564         ec = INDEX_SIZE_ERR;
    1565         return;
    1566     }
     1545    if (!srcRect.width() || !srcRect.height())
     1546        return Exception { INDEX_SIZE_ERR };
    15671547
    15681548    if (!videoRect.contains(normalizeRect(srcRect)) || !dstRect.width() || !dstRect.height())
    1569         return;
    1570 
    1571     GraphicsContext* c = drawingContext();
    1572     if (!c)
    1573         return;
     1549        return { };
     1550
     1551    GraphicsContext* c = drawingContext();
     1552    if (!c)
     1553        return { };
    15741554    if (!state().hasInvertibleTransform)
    1575         return;
     1555        return { };
    15761556
    15771557    checkOrigin(&video);
     
    15851565            didDraw(dstRect);
    15861566
    1587         return;
     1567        return { };
    15881568    }
    15891569#endif
     
    15971577    stateSaver.restore();
    15981578    didDraw(dstRect);
    1599 }
     1579
     1580    return { };
     1581}
     1582
    16001583#endif
    16011584
    1602 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement& imageElement,
    1603     float sx, float sy, float sw, float sh,
    1604     float dx, float dy, float dw, float dh,
    1605     const String& compositeOperation)
     1585void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement& imageElement, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, const String& compositeOperation)
    16061586{
    16071587    CompositeOperator op;
     
    16091589    if (!parseCompositeAndBlendOperator(compositeOperation, op, blendOp) || blendOp != BlendModeNormal)
    16101590        op = CompositeSourceOver;
    1611 
    1612     drawImage(imageElement, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), op, BlendModeNormal, IGNORE_EXCEPTION);
     1591    drawImage(imageElement, FloatRect { sx, sy, sw, sh }, FloatRect { dx, dy, dw, dh }, op, BlendModeNormal);
    16131592}
    16141593
     
    17481727}
    17491728
    1750 RefPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGradient(float x0, float y0, float x1, float y1, ExceptionCode& ec)
    1751 {
    1752     if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(x1) || !std::isfinite(y1)) {
    1753         ec = NOT_SUPPORTED_ERR;
    1754         return nullptr;
    1755     }
     1729ExceptionOr<Ref<CanvasGradient>> CanvasRenderingContext2D::createLinearGradient(float x0, float y0, float x1, float y1)
     1730{
     1731    if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(x1) || !std::isfinite(y1))
     1732        return Exception { NOT_SUPPORTED_ERR };
    17561733
    17571734    Ref<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1));
     
    17601737}
    17611738
    1762 RefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode& ec)
    1763 {
    1764     if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(r0) || !std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(r1)) {
    1765         ec = NOT_SUPPORTED_ERR;
    1766         return nullptr;
    1767     }
    1768 
    1769     if (r0 < 0 || r1 < 0) {
    1770         ec = INDEX_SIZE_ERR;
    1771         return nullptr;
    1772     }
     1739ExceptionOr<Ref<CanvasGradient>> CanvasRenderingContext2D::createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1)
     1740{
     1741    if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(r0) || !std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(r1))
     1742        return Exception { NOT_SUPPORTED_ERR };
     1743
     1744    if (r0 < 0 || r1 < 0)
     1745        return Exception { INDEX_SIZE_ERR };
    17731746
    17741747    Ref<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, FloatPoint(x1, y1), r1);
     
    17771750}
    17781751
    1779 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageElement& imageElement,
    1780     const String& repetitionType, ExceptionCode& ec)
     1752ExceptionOr<RefPtr<CanvasPattern>> CanvasRenderingContext2D::createPattern(HTMLImageElement& imageElement, const String& repetitionType)
    17811753{
    17821754    bool repeatX, repeatY;
    1783     ec = 0;
    1784     CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
    1785     if (ec)
    1786         return nullptr;
    1787 
    1788     CachedImage* cachedImage = imageElement.cachedImage();
     1755    if (!CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY))
     1756        return Exception { SYNTAX_ERR };
     1757
     1758    auto* cachedImage = imageElement.cachedImage();
     1759
    17891760    // If the image loading hasn't started or the image is not complete, it is not fully decodable.
    17901761    if (!cachedImage || !imageElement.complete())
    17911762        return nullptr;
    17921763
    1793     if (cachedImage->status() == CachedResource::LoadError) {
    1794         ec = INVALID_STATE_ERR;
    1795         return nullptr;
    1796     }
    1797 
    1798     if (!imageElement.cachedImage()->imageForRenderer(imageElement.renderer()))
    1799         return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true);
     1764    if (cachedImage->status() == CachedResource::LoadError)
     1765        return Exception { INVALID_STATE_ERR };
    18001766
    18011767    bool originClean = cachedImage->isOriginClean(canvas()->securityOrigin());
     
    18101776        originClean = false;
    18111777
    1812     return CanvasPattern::create(cachedImage->imageForRenderer(imageElement.renderer()), repeatX, repeatY, originClean);
    1813 }
    1814 
    1815 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElement& canvas,
    1816     const String& repetitionType, ExceptionCode& ec)
    1817 {
    1818     if (!canvas.width() || !canvas.height() || !canvas.buffer()) {
    1819         ec = INVALID_STATE_ERR;
    1820         return nullptr;
    1821     }
     1778    return RefPtr<CanvasPattern> { CanvasPattern::create(*cachedImage->imageForRenderer(imageElement.renderer()), repeatX, repeatY, originClean) };
     1779}
     1780
     1781ExceptionOr<Ref<CanvasPattern>> CanvasRenderingContext2D::createPattern(HTMLCanvasElement& canvas, const String& repetitionType)
     1782{
     1783    if (!canvas.width() || !canvas.height() || !canvas.buffer())
     1784        return Exception { INVALID_STATE_ERR };
    18221785
    18231786    bool repeatX, repeatY;
    1824     ec = 0;
    1825     CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
    1826     if (ec)
    1827         return nullptr;
    1828     return CanvasPattern::create(canvas.copiedImage(), repeatX, repeatY, canvas.originClean());
     1787    if (!CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY))
     1788        return Exception { SYNTAX_ERR };
     1789
     1790    return CanvasPattern::create(*canvas.copiedImage(), repeatX, repeatY, canvas.originClean());
    18291791}
    18301792   
    18311793#if ENABLE(VIDEO)
    1832 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLVideoElement& videoElement, const String& repetitionType, ExceptionCode& ec)
     1794
     1795ExceptionOr<RefPtr<CanvasPattern>> CanvasRenderingContext2D::createPattern(HTMLVideoElement& videoElement, const String& repetitionType)
    18331796{
    18341797    if (videoElement.readyState() < HTMLMediaElement::HAVE_CURRENT_DATA)
     
    18361799   
    18371800    bool repeatX, repeatY;
    1838     ec = 0;
    1839     CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
    1840     if (ec)
    1841         return nullptr;
    1842    
     1801    if (!CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY))
     1802        return Exception { SYNTAX_ERR };
     1803
    18431804    checkOrigin(&videoElement);
    18441805    bool originClean = canvas()->originClean();
     
    18461807#if USE(CG) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(GSTREAMER_GL) && USE(CAIRO))
    18471808    if (auto nativeImage = videoElement.nativeImageForCurrentTime())
    1848         return CanvasPattern::create(BitmapImage::create(WTFMove(nativeImage)), repeatX, repeatY, originClean);
     1809        return RefPtr<CanvasPattern> { CanvasPattern::create(BitmapImage::create(WTFMove(nativeImage)), repeatX, repeatY, originClean) };
    18491810#endif
    18501811
     
    18521813    videoElement.paintCurrentFrameInContext(imageBuffer->context(), FloatRect(FloatPoint(), size(videoElement)));
    18531814   
    1854     return CanvasPattern::create(ImageBuffer::sinkIntoImage(WTFMove(imageBuffer), Unscaled), repeatX, repeatY, originClean);
    1855 }
     1815    return RefPtr<CanvasPattern> { CanvasPattern::create(ImageBuffer::sinkIntoImage(WTFMove(imageBuffer), Unscaled).releaseNonNull(), repeatX, repeatY, originClean) };
     1816}
     1817
    18561818#endif
    18571819
     
    19761938}
    19771939
    1978 RefPtr<ImageData> CanvasRenderingContext2D::createImageData(RefPtr<ImageData>&& imageData, ExceptionCode& ec) const
    1979 {
    1980     if (!imageData) {
    1981         ec = NOT_SUPPORTED_ERR;
    1982         return nullptr;
    1983     }
     1940ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::createImageData(ImageData* imageData) const
     1941{
     1942    if (!imageData)
     1943        return Exception { NOT_SUPPORTED_ERR };
    19841944
    19851945    return createEmptyImageData(imageData->size());
    19861946}
    19871947
    1988 RefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float sh, ExceptionCode& ec) const
    1989 {
    1990     ec = 0;
    1991     if (!sw || !sh) {
    1992         ec = INDEX_SIZE_ERR;
    1993         return nullptr;
    1994     }
    1995     if (!std::isfinite(sw) || !std::isfinite(sh)) {
    1996         ec = TypeError;
    1997         return nullptr;
    1998     }
    1999 
    2000     FloatSize logicalSize(fabs(sw), fabs(sh));
     1948ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::createImageData(float sw, float sh) const
     1949{
     1950    if (!sw || !sh)
     1951        return Exception { INDEX_SIZE_ERR };
     1952
     1953    FloatSize logicalSize(std::abs(sw), std::abs(sh));
    20011954    if (!logicalSize.isExpressibleAsIntSize())
    20021955        return nullptr;
     
    20111964}
    20121965
    2013 RefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy, float sw, float sh, ExceptionCode& ec) const
    2014 {
    2015     return getImageData(ImageBuffer::LogicalCoordinateSystem, sx, sy, sw, sh, ec);
    2016 }
    2017 
    2018 RefPtr<ImageData> CanvasRenderingContext2D::webkitGetImageDataHD(float sx, float sy, float sw, float sh, ExceptionCode& ec) const
    2019 {
    2020     return getImageData(ImageBuffer::BackingStoreCoordinateSystem, sx, sy, sw, sh, ec);
    2021 }
    2022 
    2023 RefPtr<ImageData> CanvasRenderingContext2D::getImageData(ImageBuffer::CoordinateSystem coordinateSystem, float sx, float sy, float sw, float sh, ExceptionCode& ec) const
     1966ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::getImageData(float sx, float sy, float sw, float sh) const
     1967{
     1968    return getImageData(ImageBuffer::LogicalCoordinateSystem, sx, sy, sw, sh);
     1969}
     1970
     1971ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::webkitGetImageDataHD(float sx, float sy, float sw, float sh) const
     1972{
     1973    return getImageData(ImageBuffer::BackingStoreCoordinateSystem, sx, sy, sw, sh);
     1974}
     1975
     1976ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::getImageData(ImageBuffer::CoordinateSystem coordinateSystem, float sx, float sy, float sw, float sh) const
    20241977{
    20251978    if (!canvas()->originClean()) {
    20261979        static NeverDestroyed<String> consoleMessage(ASCIILiteral("Unable to get image data from canvas because the canvas has been tainted by cross-origin data."));
    20271980        canvas()->document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage);
    2028         ec = SECURITY_ERR;
    2029         return nullptr;
    2030     }
    2031 
    2032     if (!sw || !sh) {
    2033         ec = INDEX_SIZE_ERR;
    2034         return nullptr;
    2035     }
    2036     if (!std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !std::isfinite(sh)) {
    2037         ec = NOT_SUPPORTED_ERR;
    2038         return nullptr;
    2039     }
     1981        return Exception { SECURITY_ERR };
     1982    }
     1983
     1984    if (!sw || !sh)
     1985        return Exception { INDEX_SIZE_ERR };
    20401986
    20411987    if (sw < 0) {
     
    20612007        return createEmptyImageData(imageDataRect.size());
    20622008
    2063     RefPtr<Uint8ClampedArray> byteArray = buffer->getUnmultipliedImageData(imageDataRect, coordinateSystem);
     2009    auto byteArray = buffer->getUnmultipliedImageData(imageDataRect, coordinateSystem);
    20642010    if (!byteArray) {
    20652011        StringBuilder consoleMessage;
     
    20702016
    20712017        canvas()->document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage.toString());
    2072         ec = INVALID_STATE_ERR;
    2073         return nullptr;
     2018        return Exception { INVALID_STATE_ERR };
    20742019    }
    20752020
     
    20772022}
    20782023
    2079 void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy, ExceptionCode& ec)
    2080 {
    2081     putImageData(data, dx, dy, 0, 0, data.width(), data.height(), ec);
    2082 }
    2083 
    2084 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy, ExceptionCode& ec)
    2085 {
    2086     webkitPutImageDataHD(data, dx, dy, 0, 0, data.width(), data.height(), ec);
    2087 }
    2088 
    2089 void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy, float dirtyX, float dirtyY,
    2090                                             float dirtyWidth, float dirtyHeight, ExceptionCode& ec)
    2091 {
    2092     putImageData(data, ImageBuffer::LogicalCoordinateSystem, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight, ec);
    2093 }
    2094 
    2095 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode& ec)
    2096 {
    2097     putImageData(data, ImageBuffer::BackingStoreCoordinateSystem, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight, ec);
     2024void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy)
     2025{
     2026    putImageData(data, dx, dy, 0, 0, data.width(), data.height());
     2027}
     2028
     2029void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy)
     2030{
     2031    webkitPutImageDataHD(data, dx, dy, 0, 0, data.width(), data.height());
     2032}
     2033
     2034void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight)
     2035{
     2036    putImageData(data, ImageBuffer::LogicalCoordinateSystem, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight);
     2037}
     2038
     2039void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight)
     2040{
     2041    putImageData(data, ImageBuffer::BackingStoreCoordinateSystem, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight);
    20982042}
    20992043
     
    21122056    GraphicsContext* context = drawingContext();
    21132057
    2114     if (!element || !element->focused() || !state().hasInvertibleTransform || path.isEmpty()
    2115         || !element->isDescendantOf(canvas()) || !context)
     2058    if (!element || !element->focused() || !state().hasInvertibleTransform || path.isEmpty() || !element->isDescendantOf(canvas()) || !context)
    21162059        return;
    21172060
     
    21192062}
    21202063
    2121 void CanvasRenderingContext2D::putImageData(ImageData& data, ImageBuffer::CoordinateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY,
    2122                                             float dirtyWidth, float dirtyHeight, ExceptionCode& ec)
    2123 {
    2124     if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dirtyX) || !std::isfinite(dirtyY) || !std::isfinite(dirtyWidth) || !std::isfinite(dirtyHeight)) {
    2125         ec = NOT_SUPPORTED_ERR;
    2126         return;
    2127     }
    2128 
     2064void CanvasRenderingContext2D::putImageData(ImageData& data, ImageBuffer::CoordinateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight)
     2065{
    21292066    ImageBuffer* buffer = canvas()->buffer();
    21302067    if (!buffer)
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h

    r206538 r207720  
    6060class CanvasRenderingContext2D final : public CanvasRenderingContext, public CanvasPath {
    6161public:
    62     CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
     62    CanvasRenderingContext2D(HTMLCanvasElement&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
    6363    virtual ~CanvasRenderingContext2D();
    6464
     
    159159    void clearShadow();
    160160
    161     void drawImage(HTMLImageElement&, float x, float y, ExceptionCode&);
    162     void drawImage(HTMLImageElement&, float x, float y, float width, float height, ExceptionCode&);
    163     void drawImage(HTMLImageElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    164     void drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    165     void drawImage(HTMLCanvasElement&, float x, float y, ExceptionCode&);
    166     void drawImage(HTMLCanvasElement&, float x, float y, float width, float height, ExceptionCode&);
    167     void drawImage(HTMLCanvasElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    168     void drawImage(HTMLCanvasElement&, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    169     void drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&, ExceptionCode&);
     161    ExceptionOr<void> drawImage(HTMLImageElement&, float x, float y);
     162    ExceptionOr<void> drawImage(HTMLImageElement&, float x, float y, float width, float height);
     163    ExceptionOr<void> drawImage(HTMLImageElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
     164    ExceptionOr<void> drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect);
     165    ExceptionOr<void> drawImage(HTMLCanvasElement&, float x, float y);
     166    ExceptionOr<void> drawImage(HTMLCanvasElement&, float x, float y, float width, float height);
     167    ExceptionOr<void> drawImage(HTMLCanvasElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
     168    ExceptionOr<void> drawImage(HTMLCanvasElement&, const FloatRect& srcRect, const FloatRect& dstRect);
     169    ExceptionOr<void> drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&);
    170170#if ENABLE(VIDEO)
    171     void drawImage(HTMLVideoElement&, float x, float y, ExceptionCode&);
    172     void drawImage(HTMLVideoElement&, float x, float y, float width, float height, ExceptionCode&);
    173     void drawImage(HTMLVideoElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    174     void drawImage(HTMLVideoElement&, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
     171    ExceptionOr<void> drawImage(HTMLVideoElement&, float x, float y);
     172    ExceptionOr<void> drawImage(HTMLVideoElement&, float x, float y, float width, float height);
     173    ExceptionOr<void> drawImage(HTMLVideoElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
     174    ExceptionOr<void> drawImage(HTMLVideoElement&, const FloatRect& srcRect, const FloatRect& dstRect);
    175175#endif
    176176
    177     void drawImageFromRect(HTMLImageElement&, float sx = 0, float sy = 0, float sw = 0, float sh = 0,
    178                            float dx = 0, float dy = 0, float dw = 0, float dh = 0, const String& compositeOperation = emptyString());
     177    void drawImageFromRect(HTMLImageElement&, float sx = 0, float sy = 0, float sw = 0, float sh = 0, float dx = 0, float dy = 0, float dw = 0, float dh = 0, const String& compositeOperation = emptyString());
    179178
    180179    void setAlpha(float);
     
    182181    void setCompositeOperation(const String&);
    183182
    184     RefPtr<CanvasGradient> createLinearGradient(float x0, float y0, float x1, float y1, ExceptionCode&);
    185     RefPtr<CanvasGradient> createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&);
    186     RefPtr<CanvasPattern> createPattern(HTMLImageElement&, const String& repetitionType, ExceptionCode&);
    187     RefPtr<CanvasPattern> createPattern(HTMLCanvasElement&, const String& repetitionType, ExceptionCode&);
     183    ExceptionOr<Ref<CanvasGradient>> createLinearGradient(float x0, float y0, float x1, float y1);
     184    ExceptionOr<Ref<CanvasGradient>> createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1);
     185    ExceptionOr<RefPtr<CanvasPattern>> createPattern(HTMLImageElement&, const String& repetitionType);
     186    ExceptionOr<Ref<CanvasPattern>> createPattern(HTMLCanvasElement&, const String& repetitionType);
    188187#if ENABLE(VIDEO)
    189     RefPtr<CanvasPattern> createPattern(HTMLVideoElement&, const String& repetitionType, ExceptionCode&);
     188    ExceptionOr<RefPtr<CanvasPattern>> createPattern(HTMLVideoElement&, const String& repetitionType);
    190189#endif
    191190
    192     RefPtr<ImageData> createImageData(RefPtr<ImageData>&&, ExceptionCode&) const;
    193     RefPtr<ImageData> createImageData(float width, float height, ExceptionCode&) const;
    194     RefPtr<ImageData> getImageData(float sx, float sy, float sw, float sh, ExceptionCode&) const;
    195     RefPtr<ImageData> webkitGetImageDataHD(float sx, float sy, float sw, float sh, ExceptionCode&) const;
    196     void putImageData(ImageData&, float dx, float dy, ExceptionCode&);
    197     void putImageData(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);
    198     void webkitPutImageDataHD(ImageData&, float dx, float dy, ExceptionCode&);
    199     void webkitPutImageDataHD(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);
     191    ExceptionOr<RefPtr<ImageData>> createImageData(ImageData*) const;
     192    ExceptionOr<RefPtr<ImageData>> createImageData(float width, float height) const;
     193    ExceptionOr<RefPtr<ImageData>> getImageData(float sx, float sy, float sw, float sh) const;
     194    ExceptionOr<RefPtr<ImageData>> webkitGetImageDataHD(float sx, float sy, float sw, float sh) const;
     195    void putImageData(ImageData&, float dx, float dy);
     196    void putImageData(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
     197    void webkitPutImageDataHD(ImageData&, float dx, float dy);
     198    void webkitPutImageDataHD(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
    200199
    201200    void drawFocusIfNeeded(Element*);
     
    372371    void prepareGradientForDashboard(CanvasGradient& gradient) const;
    373372
    374     RefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx, float sy, float sw, float sh, ExceptionCode&) const;
    375     void putImageData(ImageData&, ImageBuffer::CoordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);
     373    ExceptionOr<RefPtr<ImageData>> getImageData(ImageBuffer::CoordinateSystem, float sx, float sy, float sw, float sh) const;
     374    void putImageData(ImageData&, ImageBuffer::CoordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
    376375
    377376    bool is2d() const override { return true; }
     
    392391    bool m_usesDashboardCompatibilityMode;
    393392#endif
    394 
    395393    bool m_usesDisplayListDrawing { false };
    396394    bool m_tracksDisplayListReplay { false };
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl

    r206723 r207720  
    5454    attribute DOMString globalCompositeOperation;
    5555
    56     [MayThrowLegacyException] CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1);
    57     [MayThrowLegacyException] CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1);
     56    [MayThrowException] CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1);
     57    [MayThrowException] CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1);
    5858
    5959    attribute unrestricted float lineWidth;
     
    133133    void strokeRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
    134134
    135     [MayThrowLegacyException] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y);
    136     [MayThrowLegacyException] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y,
    137         unrestricted float width, unrestricted float height);
    138     [MayThrowLegacyException] void drawImage(HTMLImageElement image, unrestricted float sx, unrestricted float sy, unrestricted float sw,
    139         unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
    140     [MayThrowLegacyException] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y);
    141     [MayThrowLegacyException] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y,
    142         unrestricted float width, unrestricted float height);
    143     [MayThrowLegacyException] void drawImage(HTMLCanvasElement canvas, unrestricted float sx, unrestricted float sy, unrestricted float sw,
    144         unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
    145     [Conditional=VIDEO, MayThrowLegacyException] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y);
    146     [Conditional=VIDEO, MayThrowLegacyException] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y,
    147         unrestricted float width, unrestricted float height);
    148     [Conditional=VIDEO, MayThrowLegacyException] void drawImage(HTMLVideoElement video, unrestricted float sx, unrestricted float sy, unrestricted float sw,
    149         unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
     135    [MayThrowException] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y);
     136    [MayThrowException] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
     137    [MayThrowException] void drawImage(HTMLImageElement image, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
     138    [MayThrowException] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y);
     139    [MayThrowException] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
     140    [MayThrowException] void drawImage(HTMLCanvasElement canvas, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
     141    [Conditional=VIDEO, MayThrowException] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y);
     142    [Conditional=VIDEO, MayThrowException] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
     143    [Conditional=VIDEO, MayThrowException] void drawImage(HTMLVideoElement video, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
    150144
    151145    void drawImageFromRect(HTMLImageElement image,
     
    163157        unrestricted float y, unrestricted float k, unrestricted float a);
    164158
    165     [MayThrowLegacyException] void putImageData(ImageData imagedata, float dx, float dy);
    166     [MayThrowLegacyException] void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
     159    void putImageData(ImageData imagedata, float dx, float dy);
     160    void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
    167161
    168     [MayThrowLegacyException] void webkitPutImageDataHD(ImageData imagedata, float dx, float dy);
    169     [MayThrowLegacyException] void webkitPutImageDataHD(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
     162    void webkitPutImageDataHD(ImageData imagedata, float dx, float dy);
     163    void webkitPutImageDataHD(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
    170164
    171     [MayThrowLegacyException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=EmptyString] DOMString repetitionType);
    172     [MayThrowLegacyException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=EmptyString] DOMString repetitionType);
    173     [Conditional=VIDEO, MayThrowLegacyException] CanvasPattern? createPattern(HTMLVideoElement video, [TreatNullAs=EmptyString] DOMString repetitionType);
    174     [MayThrowLegacyException] ImageData createImageData(ImageData? imagedata);
    175     [MayThrowLegacyException] ImageData createImageData(float sw, float sh);
     165    [MayThrowException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=EmptyString] DOMString repetitionType);
     166    [MayThrowException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=EmptyString] DOMString repetitionType);
     167    [Conditional=VIDEO, MayThrowException] CanvasPattern? createPattern(HTMLVideoElement video, [TreatNullAs=EmptyString] DOMString repetitionType);
     168    [MayThrowException] ImageData createImageData(ImageData? imagedata);
     169    [MayThrowException] ImageData createImageData(float sw, float sh);
    176170
    177171    [Custom] attribute custom strokeStyle;
     
    179173
    180174    // pixel manipulation
    181     [MayThrowLegacyException] ImageData getImageData(float sx, float sy, float sw, float sh);
    182 
    183     [MayThrowLegacyException] ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh);
     175    [MayThrowException] ImageData getImageData(float sx, float sy, float sw, float sh);
     176    [MayThrowException] ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh);
    184177   
    185178    // Focus rings
  • trunk/Source/WebCore/html/canvas/OESVertexArrayObject.cpp

    r200626 r207720  
    2525
    2626#include "config.h"
     27#include "OESVertexArrayObject.h"
    2728
    2829#if ENABLE(WEBGL)
    29 
    30 #include "OESVertexArrayObject.h"
    3130
    3231#include "Extensions3D.h"
     
    3534namespace WebCore {
    3635
    37 OESVertexArrayObject::OESVertexArrayObject(WebGLRenderingContextBase* context)
    38     : WebGLExtension(context)
    39 {
    40 }
    41 
    42 OESVertexArrayObject::~OESVertexArrayObject()
     36OESVertexArrayObject::OESVertexArrayObject(WebGLRenderingContextBase& context)
     37    : WebGLExtension(&context)
    4338{
    4439}
     
    5348    if (m_context->isContextLost())
    5449        return nullptr;
    55    
     50
    5651    auto object = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VAOTypeUser);
    5752    m_context->addContextObject(object.ptr());
     
    7267GC3Dboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
    7368{
    74     if (!arrayObject || m_context->isContextLost())
    75         return 0;
    76    
    77     if (!arrayObject->hasEverBeenBound())
    78         return 0;
    79    
    80     Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
    81     return extensions->isVertexArrayOES(arrayObject->object());
     69    return arrayObject && !m_context->isContextLost() && arrayObject->hasEverBeenBound()
     70        && m_context->graphicsContext3D()->getExtensions()->isVertexArrayOES(arrayObject->object());
    8271}
    8372
    84 void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject, ExceptionCode& ec)
     73void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
    8574{
    86     UNUSED_PARAM(ec);
    8775    if (m_context->isContextLost())
    8876        return;
    89    
     77
    9078    if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, context()))) {
    9179        m_context->graphicsContext3D()->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    9280        return;
    9381    }
    94    
    95     Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
     82
     83    auto& extensions = *m_context->graphicsContext3D()->getExtensions();
     84    auto& context = downcast<WebGLRenderingContext>(*m_context);
    9685    if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
    97         extensions->bindVertexArrayOES(arrayObject->object());
    98        
     86        extensions.bindVertexArrayOES(arrayObject->object());
    9987        arrayObject->setHasEverBeenBound();
    100         static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(arrayObject);
     88        context.setBoundVertexArrayObject(arrayObject);
    10189    } else {
    102         extensions->bindVertexArrayOES(0);
    103         static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(0);
     90        extensions.bindVertexArrayOES(0);
     91        context.setBoundVertexArrayObject(0);
    10492    }
    10593}
  • trunk/Source/WebCore/html/canvas/OESVertexArrayObject.h

    r200626 r207720  
    2424 */
    2525
    26 #ifndef OESVertexArrayObject_h
    27 #define OESVertexArrayObject_h
     26#pragma once
    2827
    2928#include "GraphicsTypes3D.h"
     
    3534class WebGLVertexArrayObjectOES;
    3635
    37 typedef int ExceptionCode;
    38 
    3936class OESVertexArrayObject final : public WebGLExtension {
    4037public:
    41     OESVertexArrayObject(WebGLRenderingContextBase*);
    42     virtual ~OESVertexArrayObject();
     38    explicit OESVertexArrayObject(WebGLRenderingContextBase&);
    4339
    44     ExtensionName getName() const override;
    45    
    4640    RefPtr<WebGLVertexArrayObjectOES> createVertexArrayOES();
    4741    void deleteVertexArrayOES(WebGLVertexArrayObjectOES*);
    4842    GC3Dboolean isVertexArrayOES(WebGLVertexArrayObjectOES*);
    49     void bindVertexArrayOES(WebGLVertexArrayObjectOES*, ExceptionCode&);
     43    void bindVertexArrayOES(WebGLVertexArrayObjectOES*);
     44
     45private:
     46    ExtensionName getName() const final;
    5047};
    5148
    5249} // namespace WebCore
    53 
    54 #endif // OESVertexArrayObject_h
  • trunk/Source/WebCore/html/canvas/OESVertexArrayObject.idl

    r206723 r207720  
    3535    void deleteVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null);
    3636    boolean isVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null);
    37     [MayThrowLegacyException] void bindVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null);
     37    void bindVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null);
    3838};
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

    r207715 r207720  
    6565}
    6666
    67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, RefPtr<GraphicsContext3D>&& context,
    68     GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes)
     67WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3D::Attributes attributes)
     68    : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes)
    6969{
    7070    initializeShaderExtensions();
     
    808808}
    809809
    810 WebGLGetInfo WebGL2RenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&)
     810WebGLGetInfo WebGL2RenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname)
    811811{
    812812    if (isContextLostOrPending() || !validateFramebufferFuncParameters("getFramebufferAttachmentParameter", target, attachment))
     
    10401040}
    10411041
    1042 void WebGL2RenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode& ec)
    1043 {
    1044     ec = 0;
     1042void WebGL2RenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels)
     1043{
    10451044    ASSERT(!isContextLost());
    10461045    if (!validateTexFuncParameters("texSubImage2D", TexSubImage, target, level, internalformat, width, height, 0, format, type))
     
    10621061}
    10631062
    1064 void WebGL2RenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
    1065 {
    1066     ec = 0;
     1063void WebGL2RenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha)
     1064{
    10671065    Vector<uint8_t> data;
    10681066    GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
     
    10901088    WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true);
    10911089    GC3Denum internalformat = tex->getInternalFormat(target, level);
    1092     texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->height(), internalformat, format, type,  needConversion ? data.data() : imagePixelData, ec);
     1090    texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->height(), internalformat, format, type,  needConversion ? data.data() : imagePixelData);
    10931091    if (m_unpackAlignment != 1)
    10941092        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    10951093}
    10961094
    1097 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels, ExceptionCode& ec)
     1095void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels)
    10981096{
    10991097    if (isContextLostOrPending() || !validateTexFuncData("texSubImage2D", level, width, height, GraphicsContext3D::NONE, format, type, pixels.get(), NullNotAllowed) || !validateTexFunc("texSubImage2D", TexSubImage, SourceArrayBufferView, target, level, GraphicsContext3D::NONE, width, height, 0, format, type, xoffset, yoffset))
     
    11171115    WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true);
    11181116    GC3Denum internalformat = tex->getInternalFormat(target, level);
    1119     texSubImage2DBase(target, level, xoffset, yoffset, width, height, internalformat, format, type, data, ec);
     1117    texSubImage2DBase(target, level, xoffset, yoffset, width, height, internalformat, format, type, data);
    11201118    if (changeUnpackAlignment)
    11211119        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    11221120}
    11231121
    1124 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode& ec)
    1125 {
    1126     ec = 0;
     1122void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels)
     1123{
    11271124    if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, GraphicsContext3D::NONE,  pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset))
    11281125        return;
     
    11451142    WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true);
    11461143    GC3Denum internalformat = tex->getInternalFormat(target, level);
    1147     texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), internalformat, format, type, needConversion ? data.data() : pixels->data()->data(), ec);
     1144    texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), internalformat, format, type, needConversion ? data.data() : pixels->data()->data());
    11481145    if (m_unpackAlignment != 1)
    11491146        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    11501147}
    11511148
    1152 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode& ec)
    1153 {
    1154     ec = 0;
    1155     if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image, ec))
    1156         return;
    1157    
     1149ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement* image)
     1150{
     1151    if (wouldTaintOrigin(image))
     1152        return Exception { SECURITY_ERR };
     1153    if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image))
     1154        return { };
     1155
    11581156    RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
    11591157    if (!imageForRender)
    1160         return;
     1158        return { };
    11611159
    11621160    if (imageForRender->isSVGImage())
     
    11641162   
    11651163    if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, GraphicsContext3D::NONE, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
    1166         return;
    1167    
    1168     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
    1169 }
    1170 
    1171 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    1172     GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode& ec)
    1173 {
    1174     ec = 0;
    1175     if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas, ec)
     1164        return { };
     1165   
     1166    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
     1167    return { };
     1168}
     1169
     1170ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas)
     1171{
     1172    if (wouldTaintOrigin(canvas))
     1173        return Exception { SECURITY_ERR };
     1174    if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas)
    11761175        || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, GraphicsContext3D::NONE, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
    1177         return;
    1178    
     1176        return { };
     1177
    11791178    RefPtr<ImageData> imageData = canvas->getImageData();
    11801179    if (imageData)
    1181         texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get(), ec);
     1180        texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get());
    11821181    else
    1183         texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
     1182        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
     1183    return { };
    11841184}
    11851185
    11861186#if ENABLE(VIDEO)
    1187 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode& ec)
    1188 {
    1189     ec = 0;
    1190     if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video, ec)
     1187
     1188ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement* video)
     1189{
     1190    if (wouldTaintOrigin(video))
     1191        return Exception { SECURITY_ERR };
     1192    if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video)
    11911193        || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, GraphicsContext3D::NONE, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
    1192         return;
    1193    
     1194        return { };
     1195
    11941196    RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode());
    11951197    if (!image)
    1196         return;
    1197     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
    1198 }
     1198        return { };
     1199    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
     1200    return { };
     1201}
     1202
    11991203#endif
    12001204
     
    12441248        }
    12451249
    1246         ExceptionCode ec;
    1247         bool isSRGB = (getFramebufferAttachmentParameter(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, ec).getInt() == GraphicsContext3D::SRGB);
     1250        bool isSRGB = (getFramebufferAttachmentParameter(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING).getInt() == GraphicsContext3D::SRGB);
    12481251        if (isSRGB != (framebufferInternalFormat == GraphicsContext3D::SRGB8 || framebufferInternalFormat == GraphicsContext3D::SRGB8_ALPHA8)) {
    12491252            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "framebuffer attachment color encoding and internal format do not match");
     
    18141817}
    18151818
    1816 WebGLGetInfo WebGL2RenderingContext::getParameter(GC3Denum pname, ExceptionCode&)
     1819WebGLGetInfo WebGL2RenderingContext::getParameter(GC3Denum pname)
    18171820{
    18181821    if (isContextLostOrPending())
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h

    r207685 r207720  
    2424 */
    2525
    26 #ifndef WebGL2RenderingContext_h
    27 #define WebGL2RenderingContext_h
     26#pragma once
    2827
    2928#if ENABLE(WEBGL2)
     
    4443    WebGL2RenderingContext(HTMLCanvasElement*, GraphicsContext3D::Attributes);
    4544    WebGL2RenderingContext(HTMLCanvasElement*, RefPtr<GraphicsContext3D>&&, GraphicsContext3D::Attributes);
    46     bool isWebGL2() const override { return true; }
    4745
    4846    /* Buffer objects */
     
    5452   
    5553    /* Framebuffer objects */
    56     WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&) override;
     54    WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname) final;
    5755    void blitFramebuffer(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter);
    5856    void framebufferTextureLayer(GC3Denum target, GC3Denum attachment, GC3Duint texture, GC3Dint level, GC3Dint layer);
     
    103101   
    104102    /* Writing to the drawing buffer */
    105     void clear(GC3Dbitfield mask) override;
     103    void clear(GC3Dbitfield mask) final;
    106104    void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
    107105    void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei instanceCount);
     
    171169    void bindVertexArray(WebGLVertexArrayObject* vertexArray);
    172170   
     171private:
     172    bool isWebGL2() const final { return true; }
     173
    173174    /* Extensions */
    174     WebGLExtension* getExtension(const String&) override;
    175     Vector<String> getSupportedExtensions() override;
    176     WebGLGetInfo getParameter(GC3Denum pname, ExceptionCode&) override;
    177 
    178     void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) override;
    179     void hint(GC3Denum target, GC3Denum mode) override;
    180     void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) override;
    181     void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&) override;
    182     void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&) override;
    183     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    184         GC3Dsizei width, GC3Dsizei height,
    185         GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&, ExceptionCode&) override;
    186     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    187         GC3Denum format, GC3Denum type, ImageData*, ExceptionCode&) override;
    188     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    189         GC3Denum format, GC3Denum type, HTMLImageElement*, ExceptionCode&) override;
    190     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    191         GC3Denum format, GC3Denum type, HTMLCanvasElement*, ExceptionCode&) override;
     175    WebGLExtension* getExtension(const String&) final;
     176    Vector<String> getSupportedExtensions() final;
     177    WebGLGetInfo getParameter(GC3Denum pname) final;
     178
     179    void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) final;
     180    void hint(GC3Denum target, GC3Denum mode) final;
     181    void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) final;
     182    void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels) final;
     183    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha) final;
     184    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&) final;
     185    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData*) final;
     186    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement*) final;
     187    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement*) final;
    192188#if ENABLE(VIDEO)
    193     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    194         GC3Denum format, GC3Denum type, HTMLVideoElement*, ExceptionCode&) override;
     189    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement*) final;
    195190#endif
    196191
    197 protected:
    198     void initializeVertexArrayObjects() override;
    199     GC3Dint getMaxDrawBuffers() override;
    200     GC3Dint getMaxColorAttachments() override;
    201     bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) override;
    202     bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
    203     bool validateTexFuncFormatAndType(const char* functionName, GC3Denum internalformat, GC3Denum format, GC3Denum type, GC3Dint level) override;
     192    void initializeVertexArrayObjects() final;
     193    GC3Dint getMaxDrawBuffers() final;
     194    GC3Dint getMaxColorAttachments() final;
     195    bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) final;
     196    bool validateBlendEquation(const char* functionName, GC3Denum mode) final;
     197    bool validateTexFuncFormatAndType(const char* functionName, GC3Denum internalformat, GC3Denum format, GC3Denum type, GC3Dint level) final;
    204198    bool validateTexFuncParameters(const char* functionName,
    205199        TexFuncValidationFunctionType,
     
    207201        GC3Denum internalformat,
    208202        GC3Dsizei width, GC3Dsizei height, GC3Dint border,
    209         GC3Denum format, GC3Denum type) override;
     203        GC3Denum format, GC3Denum type) final;
    210204    bool validateTexFuncData(const char* functionName, GC3Dint level,
    211205        GC3Dsizei width, GC3Dsizei height,
    212206        GC3Denum internalformat, GC3Denum format, GC3Denum type,
    213207        ArrayBufferView* pixels,
    214         NullDisposition) override;
    215     bool validateCapability(const char* functionName, GC3Denum cap) override;
    216     bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) override;
    217    
    218 private:
     208        NullDisposition) final;
     209    bool validateCapability(const char* functionName, GC3Denum cap) final;
     210    bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) final;
     211   
    219212    GC3Denum baseInternalFormatFromInternalFormat(GC3Denum internalformat);
    220213    bool isIntegerFormat(GC3Denum internalformat);
     
    227220
    228221#endif // WEBGL2
    229 
    230 #endif
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r207644 r207720  
    174174        if (!m_oesVertexArrayObject) {
    175175            m_context->getExtensions()->ensureEnabled("GL_OES_vertex_array_object");
    176             m_oesVertexArrayObject = std::make_unique<OESVertexArrayObject>(this);
     176            m_oesVertexArrayObject = std::make_unique<OESVertexArrayObject>(*this);
    177177        }
    178178        return m_oesVertexArrayObject.get();
     
    297297}
    298298
    299 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode& ec)
    300 {
    301     UNUSED_PARAM(ec);
     299WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname)
     300{
    302301    if (isContextLostOrPending() || !validateFramebufferFuncParameters("getFramebufferAttachmentParameter", target, attachment))
    303302        return WebGLGetInfo();
     
    511510}
    512511
    513 void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode& ec)
     512void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels)
    514513{
    515514    UNUSED_PARAM(internalformat);
    516     // FIXME: For now we ignore any errors returned
    517     ec = 0;
    518515    ASSERT(!isContextLost());
    519516    ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage, target, level, format, width, height, 0, format, type));
     
    534531}
    535532
    536 void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
    537 {
    538     ec = 0;
     533void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha)
     534{
    539535    Vector<uint8_t> data;
    540536    GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
     
    560556        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    561557
    562     texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->height(), format, format, type, needConversion ? data.data() : imagePixelData, ec);
     558    texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->height(), format, format, type, needConversion ? data.data() : imagePixelData);
    563559    if (m_unpackAlignment != 1)
    564560        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    565561}
    566562
    567 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels, ExceptionCode& ec)
     563void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels)
    568564{
    569565    if (isContextLostOrPending() || !validateTexFuncData("texSubImage2D", level, width, height, format, format, type, pixels.get(), NullNotAllowed) || !validateTexFunc("texSubImage2D", TexSubImage, SourceArrayBufferView, target, level, format, width, height, 0, format, type, xoffset, yoffset))
     
    586582        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    587583
    588     texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, format, type, data, ec);
     584    texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, format, type, data);
    589585    if (changeUnpackAlignment)
    590586        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    591587}
    592588
    593 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode& ec)
    594 {
    595     ec = 0;
     589void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels)
     590{
    596591    if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, format,  pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset))
    597592        return;
     
    612607        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    613608   
    614     texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, format, type, needConversion ? data.data() : pixels->data()->data(), ec);
     609    texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, format, type, needConversion ? data.data() : pixels->data()->data());
    615610    if (m_unpackAlignment != 1)
    616611        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    617612}
    618613
    619 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode& ec)
    620 {
    621     ec = 0;
    622     if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image, ec))
    623         return;
    624    
     614ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement* image)
     615{
     616    if (wouldTaintOrigin(image))
     617        return Exception { SECURITY_ERR };
     618    if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image))
     619        return { };
     620
    625621    RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
    626622    if (!imageForRender)
    627         return;
     623        return { };
    628624
    629625    if (imageForRender->isSVGImage())
     
    631627   
    632628    if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, format, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
    633         return;
    634    
    635     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
    636 }
    637 
    638 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode& ec)
    639 {
    640     ec = 0;
    641     if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas, ec)
     629        return { };
     630
     631    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
     632    return { };
     633}
     634
     635ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas)
     636{
     637    if (wouldTaintOrigin(canvas))
     638        return Exception { SECURITY_ERR };
     639    if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas)
    642640        || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
    643         return;
    644    
     641        return { };
     642
    645643    RefPtr<ImageData> imageData = canvas->getImageData();
    646644    if (imageData)
    647         texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get(), ec);
     645        texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get());
    648646    else
    649         texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
     647        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
     648    return { };
    650649}
    651650
    652651#if ENABLE(VIDEO)
    653 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode& ec)
    654 {
    655     ec = 0;
    656     if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video, ec)
     652
     653ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement* video)
     654{
     655    if (wouldTaintOrigin(video))
     656        return Exception { SECURITY_ERR };
     657    if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video)
    657658        || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
    658         return;
    659    
     659        return { };
     660
    660661    RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode());
    661662    if (!image)
    662         return;
    663     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
    664 }
     663        return { };
     664    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
     665    return { };
     666}
     667
    665668#endif
    666669
     
    916919}
    917920
    918 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode& ec)
    919 {
    920     UNUSED_PARAM(ec);
     921WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname)
     922{
    921923    if (isContextLostOrPending())
    922924        return WebGLGetInfo();
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r200298 r207720  
    2424 */
    2525
    26 #ifndef WebGLRenderingContext_h
    27 #define WebGLRenderingContext_h
     26#pragma once
    2827
    2928#include "WebGLRenderingContextBase.h"
     
    3534    WebGLRenderingContext(HTMLCanvasElement*, GraphicsContext3D::Attributes);
    3635    WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes);
    37     bool isWebGL1() const override { return true; }
    38    
    39     WebGLExtension* getExtension(const String&) override;
    40     WebGLGetInfo getParameter(GC3Denum pname, ExceptionCode&) override;
    41     Vector<String> getSupportedExtensions() override;
    4236
    43     WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&) override;
    44     void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) override;
    45     bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) override;
    46     void hint(GC3Denum target, GC3Denum mode) override;
    47     void clear(GC3Dbitfield mask) override;
    48     void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) override;
    49     void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&) override;
    50     void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&) override;
    51     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    52         GC3Dsizei width, GC3Dsizei height,
    53         GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&, ExceptionCode&) override;
    54     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    55         GC3Denum format, GC3Denum type, ImageData*, ExceptionCode&) override;
    56     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    57         GC3Denum format, GC3Denum type, HTMLImageElement*, ExceptionCode&) override;
    58     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    59         GC3Denum format, GC3Denum type, HTMLCanvasElement*, ExceptionCode&) override;
     37private:
     38    bool isWebGL1() const final { return true; }
     39
     40    WebGLExtension* getExtension(const String&) final;
     41    WebGLGetInfo getParameter(GC3Denum pname) final;
     42    Vector<String> getSupportedExtensions() final;
     43
     44    WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname) final;
     45    void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) final;
     46    bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) final;
     47    void hint(GC3Denum target, GC3Denum mode) final;
     48    void clear(GC3Dbitfield mask) final;
     49    void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) final;
     50    void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels) final;
     51    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha) final;
     52    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&) final;
     53    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData*) final;
     54    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement*) final;
     55    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement*) final;
    6056#if ENABLE(VIDEO)
    61     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    62         GC3Denum format, GC3Denum type, HTMLVideoElement*, ExceptionCode&) override;
     57    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement*) final;
    6358#endif
    6459
    65 protected:
    66     GC3Dint getMaxDrawBuffers() override;
    67     GC3Dint getMaxColorAttachments() override;
    68     void initializeVertexArrayObjects() override;
    69     bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) override;
    70     bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
    71     bool validateTexFuncParameters(const char* functionName,
    72         TexFuncValidationFunctionType,
    73         GC3Denum target, GC3Dint level,
    74         GC3Denum internalformat,
    75         GC3Dsizei width, GC3Dsizei height, GC3Dint border,
    76         GC3Denum format, GC3Denum type) override;
    77     bool validateTexFuncFormatAndType(const char* functionName, GC3Denum internalformat, GC3Denum format, GC3Denum type, GC3Dint level) override;
    78     bool validateTexFuncData(const char* functionName, GC3Dint level,
    79         GC3Dsizei width, GC3Dsizei height,
    80         GC3Denum internalformat, GC3Denum format, GC3Denum type,
    81         ArrayBufferView* pixels,
    82         NullDisposition) override;
    83     bool validateCapability(const char* functionName, GC3Denum cap) override;
     60    GC3Dint getMaxDrawBuffers() final;
     61    GC3Dint getMaxColorAttachments() final;
     62    void initializeVertexArrayObjects() final;
     63    bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) final;
     64    bool validateBlendEquation(const char* functionName, GC3Denum mode) final;
     65    bool validateTexFuncParameters(const char* functionName, TexFuncValidationFunctionType, GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type) final;
     66    bool validateTexFuncFormatAndType(const char* functionName, GC3Denum internalformat, GC3Denum format, GC3Denum type, GC3Dint level) final;
     67    bool validateTexFuncData(const char* functionName, GC3Dint level, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, ArrayBufferView* pixels, NullDisposition) final;
     68    bool validateCapability(const char* functionName, GC3Denum cap) final;
    8469};
    8570   
     
    8772
    8873SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGLRenderingContext, isWebGL1())
    89 
    90 #endif
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r207719 r207720  
    29772977}
    29782978
    2979 void WebGLRenderingContextBase::texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode& ec)
     2979void WebGLRenderingContextBase::texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
    29802980{
    29812981    // FIXME: For now we ignore any errors returned.
    2982     ec = 0;
    29832982    WebGLTexture* tex = validateTextureBinding("texImage2D", target, true);
    29842983    ASSERT(validateTexFuncParameters("texImage2D", TexImage, target, level, internalformat, width, height, border, format, type));
     
    30123011}
    30133012
    3014 void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
    3015 {
    3016     ec = 0;
     3013void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha)
     3014{
    30173015    Vector<uint8_t> data;
    30183016    GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
     
    30373035    if (m_unpackAlignment != 1)
    30383036        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    3039     texImage2DBase(target, level, internalformat, image->width(), image->height(), 0, format, type, needConversion ? data.data() : imagePixelData, ec);
     3037    texImage2DBase(target, level, internalformat, image->width(), image->height(), 0, format, type, needConversion ? data.data() : imagePixelData);
    30403038    if (m_unpackAlignment != 1)
    30413039        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
     
    30833081}
    30843082
    3085 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels, ExceptionCode& ec)
     3083void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels)
    30863084{
    30873085    if (isContextLostOrPending() || !validateTexFuncData("texImage2D", level, width, height, internalformat, format, type, pixels.get(), NullAllowed)
     
    31033101    if (changeUnpackAlignment)
    31043102        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    3105     texImage2DBase(target, level, internalformat, width, height, border,
    3106                    format, type, data, ec);
     3103    texImage2DBase(target, level, internalformat, width, height, border, format, type, data);
    31073104    if (changeUnpackAlignment)
    31083105        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    31093106}
    31103107
    3111 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Optional<TexImageSource> source, ExceptionCode& ec)
     3108ExceptionOr<void> WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Optional<TexImageSource> source)
    31123109{
    31133110    if (!source) {
    31143111        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "source is null");
    3115         return;
    3116     }
    3117 
    3118     auto visitor = WTF::makeVisitor([&](const RefPtr<ImageData>& pixels) {
    3119         ec = 0;
     3112        return { };
     3113    }
     3114
     3115    auto visitor = WTF::makeVisitor([&](const RefPtr<ImageData>& pixels) -> ExceptionOr<void> {
    31203116        if (isContextLostOrPending() || !validateTexFunc("texImage2D", TexImage, SourceImageData, target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, 0, 0))
    3121             return;
     3117            return { };
    31223118        Vector<uint8_t> data;
    31233119        bool needConversion = true;
     
    31293125            if (!m_context->extractImageData(pixels.get(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
    31303126                synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data");
    3131                 return;
     3127                return { };
    31323128            }
    31333129        }
    31343130        if (m_unpackAlignment != 1)
    31353131            m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    3136         texImage2DBase(target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), ec);
     3132        texImage2DBase(target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, needConversion ? data.data() : pixels->data()->data());
    31373133        if (m_unpackAlignment != 1)
    31383134            m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    3139     }, [&](const RefPtr<HTMLImageElement>& image) {
    3140         ec = 0;
    3141         if (isContextLostOrPending() || !validateHTMLImageElement("texImage2D", image.get(), ec))
    3142             return;
     3135        return { };
     3136    }, [&](const RefPtr<HTMLImageElement>& image) -> ExceptionOr<void> {
     3137        if (wouldTaintOrigin(image.get()))
     3138            return Exception { SECURITY_ERR };
     3139        if (isContextLostOrPending() || !validateHTMLImageElement("texImage2D", image.get()))
     3140            return { };
    31433141
    31443142        RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
    31453143        if (!imageForRender)
    3146             return;
     3144            return { };
    31473145
    31483146        if (imageForRender->isSVGImage())
     
    31503148
    31513149        if (!imageForRender || !validateTexFunc("texImage2D", TexImage, SourceHTMLImageElement, target, level, internalformat, imageForRender->width(), imageForRender->height(), 0, format, type, 0, 0))
    3152             return;
    3153 
    3154         texImage2DImpl(target, level, internalformat, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
    3155 
    3156     }, [&](const RefPtr<HTMLCanvasElement>& canvas) {
    3157         ec = 0;
    3158         if (isContextLostOrPending() || !validateHTMLCanvasElement("texImage2D", canvas.get(), ec) || !validateTexFunc("texImage2D", TexImage, SourceHTMLCanvasElement, target, level, internalformat, canvas->width(), canvas->height(), 0, format, type, 0, 0))
    3159             return;
     3150            return { };
     3151
     3152        texImage2DImpl(target, level, internalformat, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
     3153        return { };
     3154    }, [&](const RefPtr<HTMLCanvasElement>& canvas) -> ExceptionOr<void> {
     3155        if (wouldTaintOrigin(canvas.get()))
     3156            return Exception { SECURITY_ERR };
     3157        if (isContextLostOrPending() || !validateHTMLCanvasElement("texImage2D", canvas.get()) || !validateTexFunc("texImage2D", TexImage, SourceHTMLCanvasElement, target, level, internalformat, canvas->width(), canvas->height(), 0, format, type, 0, 0))
     3158            return { };
    31603159
    31613160        WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
     
    31723171            if (buffer && buffer->copyToPlatformTexture(*m_context.get(), target, texture->object(), internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
    31733172                texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas->height(), type);
    3174                 return;
     3173                return { };
    31753174            }
    31763175        }
     
    31783177        RefPtr<ImageData> imageData = canvas->getImageData();
    31793178        if (imageData)
    3180             texImage2D(target, level, internalformat, format, type, TexImageSource(imageData.get()), ec);
     3179            texImage2D(target, level, internalformat, format, type, TexImageSource(imageData.get()));
    31813180        else
    3182             texImage2DImpl(target, level, internalformat, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
    3183     }, [&](const RefPtr<HTMLVideoElement>& video) {
    3184         ec = 0;
    3185         if (isContextLostOrPending() || !validateHTMLVideoElement("texImage2D", video.get(), ec)
     3181            texImage2DImpl(target, level, internalformat, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
     3182        return { };
     3183    }, [&](const RefPtr<HTMLVideoElement>& video) -> ExceptionOr<void> {
     3184        if (wouldTaintOrigin(video.get()))
     3185            return Exception { SECURITY_ERR };
     3186        if (isContextLostOrPending() || !validateHTMLVideoElement("texImage2D", video.get())
    31863187            || !validateTexFunc("texImage2D", TexImage, SourceHTMLVideoElement, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0))
    3187             return;
     3188            return { };
    31883189
    31893190        // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
     
    31993200            if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
    32003201                texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type);
    3201                 return;
     3202                return { };
    32023203            }
    32033204        }
     
    32063207        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
    32073208        if (!image)
    3208             return;
    3209         texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
     3209            return { };
     3210        texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
     3211        return { };
    32103212    });
    32113213
    3212     WTF::visit(visitor, source.value());
     3214    return WTF::visit(visitor, source.value());
    32133215}
    32143216
     
    44734475}
    44744476
    4475 bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionName, HTMLImageElement* image, ExceptionCode& ec)
     4477bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionName, HTMLImageElement* image)
    44764478{
    44774479    if (!image || !image->cachedImage()) {
     
    44844486        return false;
    44854487    }
    4486     if (wouldTaintOrigin(image)) {
    4487         ec = SECURITY_ERR;
    4488         return false;
    4489     }
    44904488    return true;
    44914489}
    44924490
    4493 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas, ExceptionCode& ec)
     4491bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas)
    44944492{
    44954493    if (!canvas || !canvas->buffer()) {
     
    44974495        return false;
    44984496    }
    4499     if (wouldTaintOrigin(canvas)) {
    4500         ec = SECURITY_ERR;
    4501         return false;
    4502     }
    45034497    return true;
    45044498}
    45054499
    45064500#if ENABLE(VIDEO)
    4507 bool WebGLRenderingContextBase::validateHTMLVideoElement(const char* functionName, HTMLVideoElement* video, ExceptionCode& ec)
     4501
     4502bool WebGLRenderingContextBase::validateHTMLVideoElement(const char* functionName, HTMLVideoElement* video)
    45084503{
    45094504    if (!video || !video->videoWidth() || !video->videoHeight()) {
     
    45114506        return false;
    45124507    }
    4513     if (wouldTaintOrigin(video)) {
    4514         ec = SECURITY_ERR;
    4515         return false;
    4516     }
    45174508    return true;
    45184509}
     4510
    45194511#endif
    45204512
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r207719 r207720  
    2424 */
    2525
    26 #ifndef WebGLRenderingContextBase_h
    27 #define WebGLRenderingContextBase_h
     26#pragma once
    2827
    2928#include "ActiveDOMObject.h"
     
    3837#include <runtime/Float32Array.h>
    3938#include <runtime/Int32Array.h>
    40 #include <wtf/Variant.h>
    41 #include <wtf/text/WTFString.h>
    4239
    4340namespace WebCore {
     
    8582class WebGLVertexArrayObjectOES;
    8683
    87 typedef int ExceptionCode;
    88 
    8984inline void clip1D(GC3Dint start, GC3Dsizei range, GC3Dsizei sourceRange, GC3Dint* clippedStart, GC3Dsizei* clippedRange)
    9085{
     
    201196    GC3Denum getError();
    202197    virtual WebGLExtension* getExtension(const String& name) = 0;
    203     virtual WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&) = 0;
    204     virtual WebGLGetInfo getParameter(GC3Denum pname, ExceptionCode&) = 0;
     198    virtual WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname) = 0;
     199    virtual WebGLGetInfo getParameter(GC3Denum pname) = 0;
    205200    WebGLGetInfo getProgramParameter(WebGLProgram*, GC3Denum pname);
    206201    String getProgramInfoLog(WebGLProgram*);
     
    244239    void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
    245240
    246     void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&, ExceptionCode&);
     241    void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&);
    247242
    248243    using TexImageSource = WTF::Variant<RefPtr<ImageData>, RefPtr<HTMLImageElement>, RefPtr<HTMLCanvasElement>, RefPtr<HTMLVideoElement>>;
    249     void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Optional<TexImageSource>, ExceptionCode&);
     244    ExceptionOr<void> texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Optional<TexImageSource>);
    250245
    251246    void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param);
    252247    void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param);
    253248
    254     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    255         GC3Dsizei width, GC3Dsizei height,
    256         GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&, ExceptionCode&) = 0;
    257     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    258         GC3Denum format, GC3Denum type, ImageData*, ExceptionCode&) = 0;
    259     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    260         GC3Denum format, GC3Denum type, HTMLImageElement*, ExceptionCode&) = 0;
    261     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    262         GC3Denum format, GC3Denum type, HTMLCanvasElement*, ExceptionCode&) = 0;
     249    virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&) = 0;
     250    virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData*) = 0;
     251    virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement*) = 0;
     252    virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement*) = 0;
    263253#if ENABLE(VIDEO)
    264     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
    265         GC3Denum format, GC3Denum type, HTMLVideoElement*, ExceptionCode&) = 0;
     254    virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement*) = 0;
    266255#endif
    267256
     
    603592    void restoreStateAfterClear();
    604593
    605     void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&);
    606     void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&);
    607     virtual void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&) = 0;
    608     virtual void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&) = 0;
     594    void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels);
     595    void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha);
     596    virtual void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels) = 0;
     597    virtual void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha) = 0;
    609598
    610599    bool checkTextureCompleteness(const char*, bool);
     
    759748    WebGLBuffer* validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage);
    760749
    761     // Helper function for tex{Sub}Image2D to make sure image is ready and wouldn't taint Origin.
    762     bool validateHTMLImageElement(const char* functionName, HTMLImageElement*, ExceptionCode&);
    763 
    764     // Helper function for tex{Sub}Image2D to make sure canvas is ready and wouldn't taint Origin.
    765     bool validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement*, ExceptionCode&);
    766 
     750    // Helper function for tex{Sub}Image2D to make sure image is ready.
     751    bool validateHTMLImageElement(const char* functionName, HTMLImageElement*);
     752    bool validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement*);
    767753#if ENABLE(VIDEO)
    768     // Helper function for tex{Sub}Image2D to make sure video is ready wouldn't taint Origin.
    769     bool validateHTMLVideoElement(const char* functionName, HTMLVideoElement*, ExceptionCode&);
     754    bool validateHTMLVideoElement(const char* functionName, HTMLVideoElement*);
    770755#endif
    771756
     
    794779    void maybeRestoreContext();
    795780
    796     enum ConsoleDisplayPreference {
    797         DisplayInConsole,
    798         DontDisplayInConsole
    799     };
    800 
    801     // Wrapper for GraphicsContext3D::synthesizeGLError that sends a message
    802     // to the JavaScript console.
     781    // Wrapper for GraphicsContext3D::synthesizeGLError that sends a message to the JavaScript console.
     782    enum ConsoleDisplayPreference { DisplayInConsole, DontDisplayInConsole };
    803783    void synthesizeGLError(GC3Denum, const char* functionName, const char* description, ConsoleDisplayPreference = DisplayInConsole);
    804784
    805785    String ensureNotNull(const String&) const;
    806786
    807     // Enable or disable stencil test based on user setting and
    808     // whether the current FBO has a stencil buffer.
     787    // Enable or disable stencil test based on user setting and whether the current FBO has a stencil buffer.
    809788    void applyStencilTest();
    810789
     
    830809
    831810SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGLRenderingContextBase, is3d())
    832 
    833 #endif
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl

    r207719 r207720  
    2424 */
    2525
    26 typedef unsigned long  GLenum;
     26typedef unsigned long GLenum;
    2727typedef boolean GLboolean;
    28 typedef unsigned long  GLbitfield;
    29 typedef byte   GLbyte; /* 'byte' should be a signed 8 bit type. */
    30 typedef short  GLshort;
    31 typedef long   GLint;
    32 typedef long   GLsizei;
    33 typedef long long  GLintptr;
    34 typedef long long  GLsizeiptr;
    35 typedef octet  GLubyte; /* 'octet' should be an unsigned 8 bit type. */
     28typedef unsigned long GLbitfield;
     29typedef byte GLbyte; /* 'byte' should be a signed 8 bit type. */
     30typedef short GLshort;
     31typedef long GLint;
     32typedef long GLsizei;
     33typedef long long GLintptr;
     34typedef long long GLsizeiptr;
     35typedef octet GLubyte; /* 'octet' should be an unsigned 8 bit type. */
    3636typedef unsigned short GLushort;
    37 typedef unsigned long  GLuint;
     37typedef unsigned long GLuint;
    3838typedef unrestricted float GLfloat;
    3939typedef unrestricted float GLclampf;
     
    546546    WebGLActiveInfo getActiveUniform(WebGLProgram? program, GLuint index);
    547547
    548     [Custom, MayThrowLegacyException] void getAttachedShaders(WebGLProgram? program);
     548    [Custom] void getAttachedShaders(WebGLProgram? program);
    549549
    550550    GLint getAttribLocation(WebGLProgram? program, DOMString name);
     
    559559    [Custom] any getExtension(DOMString name);
    560560
    561     [Custom, MayThrowLegacyException] any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname);
    562     [Custom, MayThrowLegacyException] any getParameter(GLenum pname);
    563     [Custom, MayThrowLegacyException] any getProgramParameter(WebGLProgram? program, GLenum pname);
     561    [Custom] any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname);
     562    [Custom] any getParameter(GLenum pname);
     563    [Custom] any getProgramParameter(WebGLProgram? program, GLenum pname);
    564564    DOMString? getProgramInfoLog(WebGLProgram? program);
    565     [Custom, MayThrowLegacyException] any getRenderbufferParameter(GLenum target, GLenum pname);
    566     [Custom, MayThrowLegacyException] any getShaderParameter(WebGLShader? shader, GLenum pname);
     565    [Custom] any getRenderbufferParameter(GLenum target, GLenum pname);
     566    [Custom] any getShaderParameter(WebGLShader? shader, GLenum pname);
    567567
    568568    DOMString? getShaderInfoLog(WebGLShader? shader);
     
    574574    [Custom] sequence<DOMString> getSupportedExtensions();
    575575
    576     [Custom, MayThrowLegacyException] any getTexParameter(GLenum target, GLenum pname);
    577 
    578     [Custom, MayThrowLegacyException] any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
     576    [Custom] any getTexParameter(GLenum target, GLenum pname);
     577
     578    [Custom] any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
    579579
    580580    WebGLUniformLocation getUniformLocation(WebGLProgram? program, DOMString name);
    581581
    582     [Custom, MayThrowLegacyException] any getVertexAttrib(GLuint index, GLenum pname);
     582    [Custom] any getVertexAttrib(GLuint index, GLenum pname);
    583583
    584584    GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname);
     
    616616
    617617    // Supported forms:
    618     [MayThrowLegacyException] void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
    619     [MayThrowLegacyException] void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, TexImageSource? source);
    620 
    621     [MayThrowLegacyException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
    622  GLsizei width, GLsizei height,
    623  GLenum format, GLenum type, ArrayBufferView? pixels);
    624     [MayThrowLegacyException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
    625  GLenum format, GLenum type, ImageData? pixels);
    626     [MayThrowLegacyException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
    627  GLenum format, GLenum type, HTMLImageElement? image);
    628     [MayThrowLegacyException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
    629  GLenum format, GLenum type, HTMLCanvasElement? canvas);
    630 #if defined(ENABLE_VIDEO) && ENABLE_VIDEO
    631     [MayThrowLegacyException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
    632  GLenum format, GLenum type, HTMLVideoElement? video);
    633 #endif
     618    void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
     619    [MayThrowException] void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, TexImageSource? source);
     620
     621    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels);
     622    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, ImageData? pixels);
     623    [MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLImageElement? image);
     624    [MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLCanvasElement? canvas);
     625    [Conditional=VIDEO, MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLVideoElement? video);
    634626
    635627    void uniform1f(WebGLUniformLocation? location, GLfloat x);
    636     [Custom, MayThrowLegacyException] void uniform1fv(WebGLUniformLocation? location, Float32Array v);
     628    [Custom] void uniform1fv(WebGLUniformLocation? location, Float32Array v);
    637629    void uniform1i(WebGLUniformLocation? location, GLint x);
    638     [Custom, MayThrowLegacyException] void uniform1iv(WebGLUniformLocation? location, Int32Array v);
     630    [Custom] void uniform1iv(WebGLUniformLocation? location, Int32Array v);
    639631    void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
    640     [Custom, MayThrowLegacyException] void uniform2fv(WebGLUniformLocation? location, Float32Array v);
     632    [Custom] void uniform2fv(WebGLUniformLocation? location, Float32Array v);
    641633    void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
    642     [Custom, MayThrowLegacyException] void uniform2iv(WebGLUniformLocation? location, Int32Array v);
     634    [Custom] void uniform2iv(WebGLUniformLocation? location, Int32Array v);
    643635    void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
    644     [Custom, MayThrowLegacyException] void uniform3fv(WebGLUniformLocation? location, Float32Array v);
     636    [Custom] void uniform3fv(WebGLUniformLocation? location, Float32Array v);
    645637    void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
    646     [Custom, MayThrowLegacyException] void uniform3iv(WebGLUniformLocation? location, Int32Array v);
     638    [Custom] void uniform3iv(WebGLUniformLocation? location, Int32Array v);
    647639    void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    648     [Custom, MayThrowLegacyException] void uniform4fv(WebGLUniformLocation? location, Float32Array v);
     640    [Custom] void uniform4fv(WebGLUniformLocation? location, Float32Array v);
    649641    void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
    650     [Custom, MayThrowLegacyException] void uniform4iv(WebGLUniformLocation? location, Int32Array v);
    651 
    652     [Custom, MayThrowLegacyException] void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
    653     [Custom, MayThrowLegacyException] void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
    654     [Custom, MayThrowLegacyException] void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
     642    [Custom] void uniform4iv(WebGLUniformLocation? location, Int32Array v);
     643
     644    [Custom] void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
     645    [Custom] void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
     646    [Custom] void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
    655647
    656648    void useProgram(WebGLProgram? program);
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r206843 r207720  
    11731173        LOG(Media, "MediaControlTextTrackContainerElement::updateDisplay(%p) - adding and positioning cue #%zu: \"%s\", start=%.2f, end=%.2f, line=%.2f", this, i, cue->text().utf8().data(), cue->startTime(), cue->endTime(), cue->line());
    11741174
    1175         RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
     1175        Ref<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
    11761176        if (cue->track()->mode() == TextTrack::Mode::Disabled)
    11771177            continue;
     
    11821182            // WebVTT region whose region identifier is identical to cue's text
    11831183            // track cue region identifier, run the following substeps:
    1184             if (displayBox->hasChildNodes() && !contains(displayBox.get())) {
     1184            if (displayBox->hasChildNodes() && !contains(displayBox.ptr())) {
    11851185                // Note: the display tree of a cue is removed when the active flag of the cue is unset.
    1186                 appendChild(*displayBox, ASSERT_NO_EXCEPTION);
     1186                appendChild(displayBox, ASSERT_NO_EXCEPTION);
    11871187                cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
    11881188            }
     
    11961196                appendChild(region->getDisplayTree());
    11971197
    1198             region->appendTextTrackCueBox(displayBox);
     1198            region->appendTextTrackCueBox(WTFMove(displayBox));
    11991199        }
    12001200    }
  • trunk/Source/WebCore/html/track/DataCue.h

    r204466 r207720  
    2525 */
    2626
    27 #ifndef DataCue_h
    28 #define DataCue_h
     27#pragma once
    2928
    3029#if ENABLE(VIDEO_TRACK)
     
    115114
    116115#endif
    117 #endif
  • trunk/Source/WebCore/html/track/DataCue.idl

    r206723 r207720  
    3333    CustomConstructor(unrestricted double startTime, unrestricted double endTime, ArrayBuffer data),
    3434#endif
    35     ConstructorMayThrowLegacyException,
     35    ConstructorMayThrowException,
    3636] interface DataCue : TextTrackCue {
    3737    attribute ArrayBuffer data;
  • trunk/Source/WebCore/html/track/InbandDataTextTrack.cpp

    r202242 r207720  
    2626
    2727#include "config.h"
     28#include "InbandDataTextTrack.h"
    2829
    2930#if ENABLE(VIDEO_TRACK)
    30 #include "InbandDataTextTrack.h"
    3131
    3232#include "DataCue.h"
     
    3939namespace WebCore {
    4040
    41 Ref<InbandDataTextTrack> InbandDataTextTrack::create(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate> playerPrivate)
     41Ref<InbandDataTextTrack> InbandDataTextTrack::create(ScriptExecutionContext* context, TextTrackClient* client, RefPtr<InbandTextTrackPrivate>&& trackPrivate)
    4242{
    43     return adoptRef(*new InbandDataTextTrack(context, client, playerPrivate));
     43    return adoptRef(*new InbandDataTextTrack(context, client, WTFMove(trackPrivate)));
    4444}
    4545
    46 InbandDataTextTrack::InbandDataTextTrack(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate> trackPrivate)
     46InbandDataTextTrack::InbandDataTextTrack(ScriptExecutionContext* context, TextTrackClient* client, RefPtr<InbandTextTrackPrivate>&& trackPrivate)
    4747    : InbandTextTrack(context, client, trackPrivate)
    4848{
     
    5555void InbandDataTextTrack::addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, const void* data, unsigned length)
    5656{
    57     auto cue = DataCue::create(*scriptExecutionContext(), start, end, data, length);
    58     addCue(WTFMove(cue), ASSERT_NO_EXCEPTION);
     57    addCue(DataCue::create(*scriptExecutionContext(), start, end, data, length));
    5958}
    6059
    6160#if ENABLE(DATACUE_VALUE)
     61
    6262void InbandDataTextTrack::addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation> prpPlatformValue, const String& type)
    6363{
     
    7777    }
    7878
    79     addCue(WTFMove(cue), ASSERT_NO_EXCEPTION);
     79    addCue(WTFMove(cue));
    8080}
    8181
     
    118118    if (cue) {
    119119        LOG(Media, "InbandDataTextTrack::removeDataCue removing cue: start=%s, end=%s\n", toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data());
    120         removeCue(cue.get(), IGNORE_EXCEPTION);
     120        removeCue(cue.get());
    121121    }
    122122}
    123123
    124 void InbandDataTextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec)
     124ExceptionOr<void> InbandDataTextTrack::removeCue(TextTrackCue* cue)
    125125{
    126126    ASSERT(cue->cueType() == TextTrackCue::Data);
    127127
    128     SerializedPlatformRepresentation* platformValue = const_cast<SerializedPlatformRepresentation*>(toDataCue(cue)->platformValue());
    129     auto iter = m_incompleteCueMap.find(platformValue);
    130     if (iter != m_incompleteCueMap.end())
    131         m_incompleteCueMap.remove(platformValue);
     128    m_incompleteCueMap.remove(const_cast<SerializedPlatformRepresentation*>(toDataCue(cue)->platformValue()));
    132129
    133     InbandTextTrack::removeCue(cue, ec);
     130    return InbandTextTrack::removeCue(cue);
    134131}
    135132
  • trunk/Source/WebCore/html/track/InbandDataTextTrack.h

    r197563 r207720  
    2525 */
    2626
    27 #ifndef InbandDataTextTrack_h
    28 #define InbandDataTextTrack_h
     27#pragma once
    2928
    3029#if ENABLE(VIDEO_TRACK)
    3130
    3231#include "InbandTextTrack.h"
    33 #include <wtf/RefPtr.h>
    3432
    3533namespace WebCore {
    3634
    3735class DataCue;
    38 class Document;
    3936class InbandTextTrackPrivate;
    40 
    41 #if ENABLE(DATACUE_VALUE)
    4237class SerializedPlatformRepresentation;
    43 #endif
    4438
    4539class InbandDataTextTrack final : public InbandTextTrack {
    4640public:
    47     static Ref<InbandDataTextTrack> create(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
     41    static Ref<InbandDataTextTrack> create(ScriptExecutionContext*, TextTrackClient*, RefPtr<InbandTextTrackPrivate>&&);
    4842    virtual ~InbandDataTextTrack();
    4943
    5044private:
    51     InbandDataTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
     45    InbandDataTextTrack(ScriptExecutionContext*, TextTrackClient*, RefPtr<InbandTextTrackPrivate>&&);
    5246
    53     void addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, const void*, unsigned) override;
     47    void addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, const void*, unsigned) final;
    5448
    5549#if ENABLE(DATACUE_VALUE)
    56     void addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>, const String&) override;
    57     void updateDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>) override;
    58     void removeDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>) override;
    59     void removeCue(TextTrackCue*, ExceptionCode&) override;
     50    void addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>, const String&) final;
     51    void updateDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>) final;
     52    void removeDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>) final;
     53    ExceptionOr<void> removeCue(TextTrackCue*) final;
    6054
    6155    HashMap<RefPtr<SerializedPlatformRepresentation>, RefPtr<DataCue>> m_incompleteCueMap;
     
    6660
    6761#endif
    68 #endif
  • trunk/Source/WebCore/html/track/InbandGenericTextTrack.cpp

    r202242 r207720  
    2525
    2626#include "config.h"
     27#include "InbandGenericTextTrack.h"
    2728
    2829#if ENABLE(VIDEO_TRACK)
    29 
    30 #include "InbandGenericTextTrack.h"
    3130
    3231#include "ExceptionCodePlaceholder.h"
     
    3837#include <wtf/text/CString.h>
    3938
    40 
    4139namespace WebCore {
    4240
    43 GenericTextTrackCueMap::GenericTextTrackCueMap()
    44 {
    45 }
    46 
    47 GenericTextTrackCueMap::~GenericTextTrackCueMap()
    48 {
    49 }
    50 
    51 void GenericTextTrackCueMap::add(GenericCueData* cueData, TextTrackCueGeneric* cue)
    52 {
    53     m_dataToCueMap.add(cueData, cue);
    54     m_cueToDataMap.add(cue, cueData);
    55 }
    56 
    57 PassRefPtr<TextTrackCueGeneric> GenericTextTrackCueMap::find(GenericCueData* cueData)
    58 {
    59     CueDataToCueMap::iterator iter = m_dataToCueMap.find(cueData);
    60     if (iter == m_dataToCueMap.end())
    61         return 0;
    62 
    63     return iter->value;
    64 }
    65 
    66 PassRefPtr<GenericCueData> GenericTextTrackCueMap::find(TextTrackCue* cue)
    67 {
    68     CueToDataMap::iterator iter = m_cueToDataMap.find(cue);
    69     if (iter == m_cueToDataMap.end())
    70         return 0;
    71 
    72     return iter->value;
    73 }
    74 
    75 void GenericTextTrackCueMap::remove(GenericCueData* cueData)
    76 {
    77     RefPtr<TextTrackCueGeneric> cue = find(cueData);
    78 
    79     if (cue)
     41void GenericTextTrackCueMap::add(GenericCueData& cueData, TextTrackCueGeneric& cue)
     42{
     43    m_dataToCueMap.add(&cueData, &cue);
     44    m_cueToDataMap.add(&cue, &cueData);
     45}
     46
     47TextTrackCueGeneric* GenericTextTrackCueMap::find(GenericCueData& cueData)
     48{
     49    return m_dataToCueMap.get(&cueData);
     50}
     51
     52GenericCueData* GenericTextTrackCueMap::find(TextTrackCue& cue)
     53{
     54    return m_cueToDataMap.get(&cue);
     55}
     56
     57void GenericTextTrackCueMap::remove(GenericCueData& cueData)
     58{
     59    if (auto cue = m_dataToCueMap.take(&cueData))
    8060        m_cueToDataMap.remove(cue);
    81     m_dataToCueMap.remove(cueData);
    82 }
    83 
    84 void GenericTextTrackCueMap::remove(TextTrackCue* cue)
    85 {
    86     RefPtr<GenericCueData> genericData = find(cue);
    87     if (genericData) {
    88         m_dataToCueMap.remove(genericData);
    89         m_cueToDataMap.remove(cue);
    90     }
     61}
     62
     63void GenericTextTrackCueMap::remove(TextTrackCue& cue)
     64{
     65    if (auto data = m_cueToDataMap.take(&cue))
     66        m_dataToCueMap.remove(data);
    9167}
    9268
     
    12197
    12298    if (cueData->position() > 0)
    123         cue->setPosition(lround(cueData->position()), IGNORE_EXCEPTION);
     99        cue->setPosition(std::round(cueData->position()));
    124100    if (cueData->line() > 0)
    125         cue->setLine(lround(cueData->line()), IGNORE_EXCEPTION);
     101        cue->setLine(std::round(cueData->line()));
    126102    if (cueData->size() > 0)
    127         cue->setSize(lround(cueData->size()), IGNORE_EXCEPTION);
     103        cue->setSize(std::round(cueData->size()));
    128104    if (cueData->backgroundColor().isValid())
    129105        cue->setBackgroundColor(cueData->backgroundColor().rgb());
     
    134110
    135111    if (cueData->align() == GenericCueData::Start)
    136         cue->setAlign(ASCIILiteral("start"), IGNORE_EXCEPTION);
     112        cue->setAlign(ASCIILiteral("start"));
    137113    else if (cueData->align() == GenericCueData::Middle)
    138         cue->setAlign(ASCIILiteral("middle"), IGNORE_EXCEPTION);
     114        cue->setAlign(ASCIILiteral("middle"));
    139115    else if (cueData->align() == GenericCueData::End)
    140         cue->setAlign(ASCIILiteral("end"), IGNORE_EXCEPTION);
     116        cue->setAlign(ASCIILiteral("end"));
    141117    cue->setSnapToLines(false);
    142118
     
    149125
    150126    RefPtr<GenericCueData> cueData = prpCueData;
    151     if (m_cueMap.find(cueData.get()))
     127    if (m_cueMap.find(*cueData))
    152128        return;
    153129
     
    162138
    163139    if (cueData->status() != GenericCueData::Complete)
    164         m_cueMap.add(cueData.get(), cue.get());
    165 
    166     addCue(cue, ASSERT_NO_EXCEPTION);
     140        m_cueMap.add(*cueData, *cue);
     141
     142    addCue(WTFMove(cue));
    167143}
    168144
    169145void InbandGenericTextTrack::updateGenericCue(InbandTextTrackPrivate*, GenericCueData* cueData)
    170146{
    171     RefPtr<TextTrackCueGeneric> cue = m_cueMap.find(cueData);
     147    auto* cue = m_cueMap.find(*cueData);
    172148    if (!cue)
    173149        return;
    174150
    175     updateCueFromCueData(cue.get(), cueData);
     151    updateCueFromCueData(cue, cueData);
    176152
    177153    if (cueData->status() == GenericCueData::Complete)
    178         m_cueMap.remove(cueData);
     154        m_cueMap.remove(*cueData);
    179155}
    180156
    181157void InbandGenericTextTrack::removeGenericCue(InbandTextTrackPrivate*, GenericCueData* cueData)
    182158{
    183     RefPtr<TextTrackCueGeneric> cue = m_cueMap.find(cueData);
     159    auto* cue = m_cueMap.find(*cueData);
    184160    if (cue) {
    185161        LOG(Media, "InbandGenericTextTrack::removeGenericCue removing cue: start=%s, end=%s, content=\"%s\"\n",  toString(cueData->startTime()).utf8().data(), toString(cueData->endTime()).utf8().data(), cueData->content().utf8().data());
    186         removeCue(cue.get(), IGNORE_EXCEPTION);
     162        removeCue(cue);
    187163    } else {
    188164        LOG(Media, "InbandGenericTextTrack::removeGenericCue UNABLE to find cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
    189         m_cueMap.remove(cueData);
    190     }
    191 }
    192 
    193 void InbandGenericTextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec)
    194 {
    195     m_cueMap.remove(cue);
    196     TextTrack::removeCue(cue, ec);
     165    }
     166}
     167
     168ExceptionOr<void> InbandGenericTextTrack::removeCue(TextTrackCue* cue)
     169{
     170    auto result = TextTrack::removeCue(cue);
     171    if (!result.hasException() && cue)
     172        m_cueMap.remove(*cue);
     173    return result;
    197174}
    198175
     
    228205            return;
    229206        }
    230         addCue(WTFMove(vttCue), ASSERT_NO_EXCEPTION);
     207        addCue(WTFMove(vttCue));
    231208    }
    232209}
  • trunk/Source/WebCore/html/track/InbandGenericTextTrack.h

    r197563 r207720  
    2424 */
    2525
    26 #ifndef InbandGenericTextTrack_h
    27 #define InbandGenericTextTrack_h
     26#pragma once
    2827
    2928#if ENABLE(VIDEO_TRACK)
     
    3231#include "TextTrackCueGeneric.h"
    3332#include "WebVTTParser.h"
    34 #include <wtf/RefPtr.h>
    3533
    3634namespace WebCore {
     
    3836class Document;
    3937class InbandTextTrackPrivate;
    40 class TextTrackCue;
    4138
    42 class GenericTextTrackCueMap final {
     39class GenericTextTrackCueMap {
    4340public:
    44     GenericTextTrackCueMap();
    45     ~GenericTextTrackCueMap();
     41    void add(GenericCueData&, TextTrackCueGeneric&);
    4642
    47     void add(GenericCueData*, TextTrackCueGeneric*);
     43    void remove(TextTrackCue&);
     44    void remove(GenericCueData&);
    4845
    49     void remove(TextTrackCue*);
    50     void remove(GenericCueData*);
    51 
    52     PassRefPtr<GenericCueData> find(TextTrackCue*);
    53     PassRefPtr<TextTrackCueGeneric> find(GenericCueData*);
     46    GenericCueData* find(TextTrackCue&);
     47    TextTrackCueGeneric* find(GenericCueData&);
    5448
    5549private:
    56     typedef HashMap<RefPtr<TextTrackCue>, RefPtr<GenericCueData>> CueToDataMap;
    57     typedef HashMap<RefPtr<GenericCueData>, RefPtr<TextTrackCueGeneric>> CueDataToCueMap;
     50    using CueToDataMap = HashMap<RefPtr<TextTrackCue>, RefPtr<GenericCueData>>;
     51    using CueDataToCueMap = HashMap<RefPtr<GenericCueData>, RefPtr<TextTrackCueGeneric>>;
    5852
    5953    CueToDataMap m_cueToDataMap;
     
    6963    InbandGenericTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
    7064
    71     void addGenericCue(InbandTextTrackPrivate*, PassRefPtr<GenericCueData>) override;
    72     void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) override;
    73     void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) override;
    74     void removeCue(TextTrackCue*, ExceptionCode&) override;
     65    void addGenericCue(InbandTextTrackPrivate*, PassRefPtr<GenericCueData>) final;
     66    void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) final;
     67    void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) final;
     68    ExceptionOr<void> removeCue(TextTrackCue*) final;
    7569
    7670    PassRefPtr<TextTrackCueGeneric> createCue(PassRefPtr<GenericCueData>);
     
    7872
    7973    WebVTTParser& parser();
    80     void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override;
    81     void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) override;
     74    void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) final;
     75    void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) final;
    8276
    83     void newCuesParsed() override;
    84     void newRegionsParsed() override;
    85     void fileFailedToParse() override;
     77    void newCuesParsed() final;
     78    void newRegionsParsed() final;
     79    void fileFailedToParse() final;
    8680
    8781    GenericTextTrackCueMap m_cueMap;
     
    9286
    9387#endif
    94 #endif
  • trunk/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp

    r202242 r207720  
    8383            return;
    8484        }
    85         addCue(WTFMove(vttCue), ASSERT_NO_EXCEPTION);
     85        addCue(WTFMove(vttCue));
    8686    }
    8787}
  • trunk/Source/WebCore/html/track/TextTrack.cpp

    r205791 r207720  
    11/*
    2  * Copyright (C) 2011, 2013 Google Inc.  All rights reserved.
    3  * Copyright (C) 2011-2014 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
     3 * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    8686TextTrack* TextTrack::captionMenuOffItem()
    8787{
    88     static TextTrack& off = TextTrack::create(0, 0, "off menu item", emptyAtom, emptyAtom, emptyAtom).leakRef();
     88    static TextTrack& off = TextTrack::create(nullptr, nullptr, "off menu item", emptyAtom, emptyAtom, emptyAtom).leakRef();
    8989    return &off;
    9090}
     
    9292TextTrack* TextTrack::captionMenuAutomaticItem()
    9393{
    94     static TextTrack& automatic = TextTrack::create(0, 0, "automatic menu item", emptyAtom, emptyAtom, emptyAtom).leakRef();
     94    static TextTrack& automatic = TextTrack::create(nullptr, nullptr, "automatic menu item", emptyAtom, emptyAtom, emptyAtom).leakRef();
    9595    return &automatic;
    9696}
     
    291291}
    292292
    293 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec)
    294 {
    295     if (!prpCue)
    296         return;
    297 
    298     RefPtr<TextTrackCue> cue = prpCue;
     293ExceptionOr<void> TextTrack::addCue(RefPtr<TextTrackCue>&& cue)
     294{
     295    if (!cue)
     296        return { };
    299297
    300298    // 4.7.10.12.6 Text tracks exposing in-band metadata
     
    304302    // track kind set to metadata, throw a InvalidNodeTypeError exception and don't add the cue to the TextTrackList
    305303    // of the TextTrack.
    306     if (cue->cueType() == TextTrackCue::Data && m_kind != Kind::Metadata) {
    307         ec = INVALID_NODE_TYPE_ERR;
    308         return;
    309     }
     304    if (cue->cueType() == TextTrackCue::Data && m_kind != Kind::Metadata)
     305        return Exception { INVALID_NODE_TYPE_ERR };
    310306
    311307    // TODO(93143): Add spec-compliant behavior for negative time values.
    312308    if (!cue->startMediaTime().isValid() || !cue->endMediaTime().isValid() || cue->startMediaTime() < MediaTime::zeroTime() || cue->endMediaTime() < MediaTime::zeroTime())
    313         return;
     309        return { };
    314310
    315311    // 4.8.10.12.5 Text track API
     
    321317    TextTrack* cueTrack = cue->track();
    322318    if (cueTrack && cueTrack != this)
    323         cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION);
     319        cueTrack->removeCue(cue.get());
    324320
    325321    // 2. Add cue to the method's TextTrack object's text track's text track list of cues.
     
    329325    if (m_client)
    330326        m_client->textTrackAddCue(this, *cue);
    331 }
    332 
    333 void TextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec)
     327
     328    return { };
     329}
     330
     331ExceptionOr<void> TextTrack::removeCue(TextTrackCue* cue)
    334332{
    335333    if (!cue)
    336         return;
     334        return { };
    337335
    338336    // 4.8.10.12.5 Text track API
     
    342340    // 1. If the given cue is not currently listed in the method's TextTrack
    343341    // object's text track's text track list of cues, then throw a NotFoundError exception.
    344     if (cue->track() != this) {
    345         ec = NOT_FOUND_ERR;
    346         return;
    347     }
     342    if (cue->track() != this)
     343        return Exception { NOT_FOUND_ERR };
    348344
    349345    // 2. Remove cue from the method's TextTrack object's text track's text track list of cues.
    350     if (!m_cues || !m_cues->remove(cue)) {
    351         ec = INVALID_STATE_ERR;
    352         return;
    353     }
    354 
    355     cue->setTrack(0);
     346    if (!m_cues || !m_cues->remove(cue))
     347        return Exception { INVALID_STATE_ERR };
     348
     349    cue->setTrack(nullptr);
    356350    if (m_client)
    357351        m_client->textTrackRemoveCue(this, *cue);
     352
     353    return { };
    358354}
    359355
     
    379375}
    380376
    381 void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion)
    382 {
    383     if (!prpRegion)
    384         return;
    385 
    386     RefPtr<VTTRegion> region = prpRegion;
    387     VTTRegionList& regionList = ensureVTTRegionList();
     377void TextTrack::addRegion(RefPtr<VTTRegion>&& region)
     378{
     379    if (!region)
     380        return;
     381
     382    auto& regionList = ensureVTTRegionList();
    388383
    389384    // 1. If the given region is in a text track list of regions, then remove
    390385    // region from that text track list of regions.
    391     TextTrack* regionTrack = region->track();
     386    auto* regionTrack = region->track();
    392387    if (regionTrack && regionTrack != this)
    393         regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION);
     388        regionTrack->removeRegion(region.get());
    394389
    395390    // 2. If the method's TextTrack object's text track list of regions contains
     
    397392    // region's width, height, anchor point, viewport anchor point and scroll
    398393    // attributes with those of region.
    399     VTTRegion* existingRegion = regionList.getRegionById(region->id());
     394    auto* existingRegion = regionList.getRegionById(region->id());
    400395    if (existingRegion) {
    401         existingRegion->updateParametersFromRegion(region.get());
     396        existingRegion->updateParametersFromRegion(*region);
    402397        return;
    403398    }
     
    406401    // list of regions.
    407402    region->setTrack(this);
    408     regionList.add(region);
    409 }
    410 
    411 void TextTrack::removeRegion(VTTRegion* region, ExceptionCode &ec)
     403    regionList.add(WTFMove(region));
     404}
     405
     406ExceptionOr<void> TextTrack::removeRegion(VTTRegion* region)
    412407{
    413408    if (!region)
    414         return;
     409        return { };
    415410
    416411    // 1. If the given region is not currently listed in the method's TextTrack
    417412    // object's text track list of regions, then throw a NotFoundError exception.
    418     if (region->track() != this) {
    419         ec = NOT_FOUND_ERR;
    420         return;
    421     }
    422 
    423     if (!m_regions || !m_regions->remove(region)) {
    424         ec = INVALID_STATE_ERR;
    425         return;
    426     }
    427 
    428     region->setTrack(0);
     413    if (region->track() != this)
     414        return Exception { NOT_FOUND_ERR };
     415
     416    if (!m_regions || !m_regions->remove(region))
     417        return Exception { INVALID_STATE_ERR };
     418
     419    region->setTrack(nullptr);
     420    return { };
    429421}
    430422
  • trunk/Source/WebCore/html/track/TextTrack.h

    r204239 r207720  
    101101    TextTrackClient* client() { return m_client; }
    102102
    103     void addCue(PassRefPtr<TextTrackCue>, ExceptionCode&);
    104     virtual void removeCue(TextTrackCue*, ExceptionCode&);
     103    ExceptionOr<void> addCue(RefPtr<TextTrackCue>&&);
     104    virtual ExceptionOr<void> removeCue(TextTrackCue*);
    105105
    106106    bool hasCue(TextTrackCue*, TextTrackCue::CueMatchRules = TextTrackCue::MatchAllFields);
    107107
    108108    VTTRegionList* regions();
    109     void addRegion(PassRefPtr<VTTRegion>);
    110     void removeRegion(VTTRegion*, ExceptionCode&);
     109    void addRegion(RefPtr<VTTRegion>&&);
     110    ExceptionOr<void> removeRegion(VTTRegion*);
    111111
    112112    void cueWillChange(TextTrackCue*);
  • trunk/Source/WebCore/html/track/TextTrack.idl

    r206723 r207720  
    4545
    4646    // FIXME: cue parameter should not be nullable in addCue and removeCue.
    47     [MayThrowLegacyException] void addCue(TextTrackCue? cue);
    48     [MayThrowLegacyException] void removeCue(TextTrackCue? cue);
     47    [MayThrowException] void addCue(TextTrackCue? cue);
     48    [MayThrowException] void removeCue(TextTrackCue? cue);
    4949
    5050    attribute EventHandler oncuechange;
     
    5353    // FIXME: region parameter should not be nullable in addRegion and removeRegion.
    5454    void addRegion(VTTRegion? region);
    55     [MayThrowLegacyException] void removeRegion(VTTRegion? region);
     55    [MayThrowException] void removeRegion(VTTRegion? region);
    5656};
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r204765 r207720  
    5555static const int invalidCueIndex = -1;
    5656
     57const AtomicString& TextTrackCue::cueShadowPseudoId()
     58{
     59    static NeverDestroyed<const AtomicString> cue("cue", AtomicString::ConstructFromLiteral);
     60    return cue;
     61}
     62
    5763TextTrackCue::TextTrackCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end)
    5864    : m_startTime(start)
     
    6874}
    6975
    70 TextTrackCue::~TextTrackCue()
    71 {
    72 }
    73 
    7476void TextTrackCue::willChange()
    7577{
     
    111113}
    112114
    113 void TextTrackCue::setStartTime(double value, ExceptionCode& ec)
    114 {
    115     // NaN, Infinity and -Infinity values should trigger a TypeError.
    116     if (std::isinf(value) || std::isnan(value)) {
    117         ec = TypeError;
    118         return;
    119     }
    120    
     115void TextTrackCue::setStartTime(double value)
     116{
    121117    // TODO(93143): Add spec-compliant behavior for negative time values.
    122118    if (m_startTime.toDouble() == value || value < 0)
     
    133129}
    134130   
    135 void TextTrackCue::setEndTime(double value, ExceptionCode& ec)
    136 {
    137     // NaN, Infinity and -Infinity values should trigger a TypeError.
    138     if (std::isinf(value) || std::isnan(value)) {
    139         ec = TypeError;
    140         return;
    141     }
    142 
     131void TextTrackCue::setEndTime(double value)
     132{
    143133    // TODO(93143): Add spec-compliant behavior for negative time values.
    144134    if (m_endTime.toDouble() == value || value < 0)
  • trunk/Source/WebCore/html/track/TextTrackCue.h

    r204765 r207720  
    11/*
    2  * Copyright (C) 2011 Google Inc.  All rights reserved.
    3  * Copyright (C) 2012, 2013, 2014 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
     3 * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    3030 */
    3131
    32 #ifndef TextTrackCue_h
    33 #define TextTrackCue_h
     32#pragma once
    3433
    3534#if ENABLE(VIDEO_TRACK)
    3635
    37 #include "EventTarget.h"
    38 #include "HTMLElement.h"
     36#include "Document.h"
    3937#include <wtf/MediaTime.h>
    40 #include <wtf/NeverDestroyed.h>
    41 #include <wtf/RefCounted.h>
    4238
    4339namespace WebCore {
     
    4743class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInlineData {
    4844public:
    49     static const AtomicString& cueShadowPseudoId()
    50     {
    51         static NeverDestroyed<const AtomicString> cue("cue", AtomicString::ConstructFromLiteral);
    52         return cue;
    53     }
    54 
    55     virtual ~TextTrackCue();
     45    static const AtomicString& cueShadowPseudoId();
    5646
    5747    TextTrack* track() const;
     
    6151    void setId(const String&);
    6252
    63     MediaTime startMediaTime() const { return m_startTime; }
    6453    double startTime() const { return startMediaTime().toDouble(); }
    65     void setStartTime(const MediaTime&);
    66     void setStartTime(double, ExceptionCode&);
     54    void setStartTime(double);
    6755
    68     MediaTime endMediaTime() const { return m_endTime; }
    6956    double endTime() const { return endMediaTime().toDouble(); }
    70     void setEndTime(const MediaTime&);
    71     void setEndTime(double, ExceptionCode&);
     57    void setEndTime(double);
    7258
    7359    bool pauseOnExit() const { return m_pauseOnExit; }
    7460    void setPauseOnExit(bool);
    7561
     62    MediaTime startMediaTime() const { return m_startTime; }
     63    void setStartTime(const MediaTime&);
     64
     65    MediaTime endMediaTime() const { return m_endTime; }
     66    void setEndTime(const MediaTime&);
     67
    7668    int cueIndex();
    7769    void invalidateCueIndex();
    7870
    79     using EventTarget::dispatchEvent;
    80     bool dispatchEvent(Event&) override;
    81 
    8271    bool isActive();
    8372    virtual void setIsActive(bool);
    84 
    85     EventTargetInterface eventTargetInterface() const final { return TextTrackCueEventTargetInterfaceType; }
    86     ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
    8773
    8874    virtual bool isOrderedBefore(const TextTrackCue*) const;
     
    9177    bool hasEquivalentStartTime(const TextTrackCue&) const;
    9278
    93     enum CueType {
    94         Data,
    95         Generic,
    96         WebVTT
    97     };
     79    enum CueType { Data, Generic, WebVTT };
    9880    virtual CueType cueType() const = 0;
    9981    virtual bool isRenderable() const { return false; }
    10082
    101     enum CueMatchRules {
    102         MatchAllFields,
    103         IgnoreDuration,
    104     };
     83    enum CueMatchRules { MatchAllFields, IgnoreDuration };
    10584    virtual bool isEqual(const TextTrackCue&, CueMatchRules) const;
     85private:
    10686    virtual bool cueContentsMatch(const TextTrackCue&) const;
     87public:
    10788    virtual bool doesExtendCue(const TextTrackCue&) const;
    10889
     
    11091    virtual void didChange();
    11192
    112     using RefCounted<TextTrackCue>::ref;
    113     using RefCounted<TextTrackCue>::deref;
     93    using RefCounted::ref;
     94    using RefCounted::deref;
    11495
    11596protected:
     
    119100
    120101private:
    121 
    122102    void refEventTarget() final { ref(); }
    123103    void derefEventTarget() final { deref(); }
     104
     105    using EventTarget::dispatchEvent;
     106    bool dispatchEvent(Event&) final;
     107
     108    EventTargetInterface eventTargetInterface() const final { return TextTrackCueEventTargetInterfaceType; }
     109    ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
    124110
    125111    String m_id;
     
    140126
    141127#endif
    142 #endif
  • trunk/Source/WebCore/html/track/TextTrackCue.idl

    r206723 r207720  
    11/*
    2  * Copyright (C) 2011 Google Inc.  All rights reserved.
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626[
    2727    Conditional=VIDEO_TRACK,
    28     JSCustomMarkFunction,
    2928    CustomIsReachable,
    3029    CustomToJSObject,
     30    JSCustomMarkFunction,
    3131    SkipVTableValidation,
    3232] interface TextTrackCue : EventTarget {
     
    3434
    3535    attribute DOMString id;
    36     [SetterMayThrowLegacyException] attribute unrestricted double startTime;
    37     [SetterMayThrowLegacyException] attribute unrestricted double endTime;
     36    attribute double startTime;
     37    attribute double endTime;
    3838    attribute boolean pauseOnExit;
    3939
     
    4141    attribute EventHandler onexit;
    4242};
    43 
  • trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp

    r197563 r207720  
    7272   
    7373    TextTrackCueGeneric* cue = static_cast<TextTrackCueGeneric*>(getCue());
    74     RefPtr<HTMLSpanElement> cueElement = cue->element();
     74    Ref<HTMLSpanElement> cueElement = cue->element();
    7575
    7676    CSSValueID alignment = cue->getCSSAlignment();
     
    149149    , m_baseFontSizeRelativeToVideoHeight(0)
    150150    , m_fontSizeMultiplier(0)
    151     , m_defaultPosition(true)
    152 {
    153 }
    154 
    155 PassRefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree()
     151{
     152}
     153
     154Ref<VTTCueBox> TextTrackCueGeneric::createDisplayTree()
    156155{
    157156    return TextTrackCueGenericBoxElement::create(ownerDocument(), *this);
    158157}
    159158
    160 void TextTrackCueGeneric::setLine(double line, ExceptionCode& ec)
    161 {
    162     m_defaultPosition = false;
    163     VTTCue::setLine(line, ec);
    164 }
    165 
    166 void TextTrackCueGeneric::setPosition(double position, ExceptionCode& ec)
    167 {
    168     m_defaultPosition = false;
    169     VTTCue::setPosition(position, ec);
     159ExceptionOr<void> TextTrackCueGeneric::setLine(double line)
     160{
     161    auto result = VTTCue::setLine(line);
     162    if (!result.hasException())
     163        m_useDefaultPosition = false;
     164    return result;
     165}
     166
     167ExceptionOr<void> TextTrackCueGeneric::setPosition(double position)
     168{
     169    auto result = VTTCue::setPosition(position);
     170    if (!result.hasException())
     171        m_useDefaultPosition = false;
     172    return result;
    170173}
    171174
     
    183186    if (fontSizeMultiplier())
    184187        size *= fontSizeMultiplier() / 100;
    185     displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSPrimitiveValue::CSS_PX);
     188    displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSPrimitiveValue::CSS_PX);
    186189
    187190    LOG(Media, "TextTrackCueGeneric::setFontSize - setting cue font size to %li", lround(size));
  • trunk/Source/WebCore/html/track/TextTrackCueGeneric.h

    r206538 r207720  
    2424 */
    2525
    26 #ifndef TextTrackCueGeneric_h
    27 #define TextTrackCueGeneric_h
     26#pragma once
    2827
    2928#if ENABLE(VIDEO_TRACK)
     
    4342        return adoptRef(*new TextTrackCueGeneric(context, start, end, content));
    4443    }
    45    
    46     virtual ~TextTrackCueGeneric() { }
    4744
    48     PassRefPtr<VTTCueBox> createDisplayTree() override;
     45    ExceptionOr<void> setLine(double) final;
     46    ExceptionOr<void> setPosition(double) final;
    4947
    50     void setLine(double, ExceptionCode&) override;
    51     void setPosition(double, ExceptionCode&) override;
     48    bool useDefaultPosition() const { return m_useDefaultPosition; }
    5249
    53     bool useDefaultPosition() const { return m_defaultPosition; }
    54    
    5550    double baseFontSizeRelativeToVideoHeight() const { return m_baseFontSizeRelativeToVideoHeight; }
    5651    void setBaseFontSizeRelativeToVideoHeight(double size) { m_baseFontSizeRelativeToVideoHeight = size; }
     
    5954    void setFontSizeMultiplier(double size) { m_fontSizeMultiplier = size; }
    6055
    61     String fontName() const { return m_fontName; }
    62     void setFontName(String name) { m_fontName = name; }
     56    const String& fontName() const { return m_fontName; }
     57    void setFontName(const String& name) { m_fontName = name; }
    6358
    6459    const Color& foregroundColor() const { return m_foregroundColor; }
    65     void setForegroundColor(Color color) { m_foregroundColor = color; }
     60    void setForegroundColor(const Color& color) { m_foregroundColor = color; }
    6661   
    6762    const Color& backgroundColor() const { return m_backgroundColor; }
    68     void setBackgroundColor(Color color) { m_backgroundColor = color; }
     63    void setBackgroundColor(const Color& color) { m_backgroundColor = color; }
    6964   
    7065    const Color& highlightColor() const { return m_highlightColor; }
    71     void setHighlightColor(Color color) { m_highlightColor = color; }
    72    
    73     void setFontSize(int, const IntSize&, bool important) override;
     66    void setHighlightColor(const Color& color) { m_highlightColor = color; }
    7467
    75     bool isEqual(const TextTrackCue&, CueMatchRules) const override;
    76     bool cueContentsMatch(const TextTrackCue&) const override;
    77     bool doesExtendCue(const TextTrackCue&) const override;
    78 
    79     TextTrackCue::CueType cueType() const override { return TextTrackCue::Generic; }
     68    void setFontSize(int, const IntSize&, bool important) final;
    8069
    8170private:
    82     bool isOrderedBefore(const TextTrackCue*) const override;
    83     bool isPositionedAbove(const TextTrackCue*) const override;
    84 
    8571    TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&);
    8672   
     73    bool isOrderedBefore(const TextTrackCue*) const final;
     74    bool isPositionedAbove(const TextTrackCue*) const final;
     75
     76    Ref<VTTCueBox> createDisplayTree() final;
     77
     78    bool isEqual(const TextTrackCue&, CueMatchRules) const final;
     79    bool cueContentsMatch(const TextTrackCue&) const final;
     80    bool doesExtendCue(const TextTrackCue&) const final;
     81
     82    CueType cueType() const final { return Generic; }
     83
    8784    Color m_foregroundColor;
    8885    Color m_backgroundColor;
    8986    Color m_highlightColor;
    90     double m_baseFontSizeRelativeToVideoHeight;
    91     double m_fontSizeMultiplier;
     87    double m_baseFontSizeRelativeToVideoHeight { 0 };
     88    double m_fontSizeMultiplier { 0 };
    9289    String m_fontName;
    93     bool m_defaultPosition;
     90    bool m_useDefaultPosition { true };
    9491};
    9592
     
    9794
    9895#endif
    99 #endif
  • trunk/Source/WebCore/html/track/VTTCue.cpp

    r201736 r207720  
    293293}
    294294
    295 PassRefPtr<VTTCueBox> VTTCue::createDisplayTree()
     295Ref<VTTCueBox> VTTCue::createDisplayTree()
    296296{
    297297    return VTTCueBox::create(ownerDocument(), *this);
    298298}
    299299
    300 VTTCueBox* VTTCue::displayTreeInternal()
     300VTTCueBox& VTTCue::displayTreeInternal()
    301301{
    302302    if (!m_displayTree)
    303303        m_displayTree = createDisplayTree();
    304     return m_displayTree.get();
     304    return *m_displayTree;
    305305}
    306306
     
    326326}
    327327
    328 void VTTCue::setVertical(const String& value, ExceptionCode& ec)
     328ExceptionOr<void> VTTCue::setVertical(const String& value)
    329329{
    330330    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
     
    342342        direction = VerticalGrowingRight;
    343343    else
    344         ec = SYNTAX_ERR;
     344        return Exception { SYNTAX_ERR };
    345345   
    346346    if (direction == m_writingDirection)
    347         return;
     347        return { };
    348348
    349349    willChange();
    350350    m_writingDirection = direction;
    351351    didChange();
     352
     353    return { };
    352354}
    353355
     
    362364}
    363365
    364 void VTTCue::setLine(double position, ExceptionCode& ec)
     366ExceptionOr<void> VTTCue::setLine(double position)
    365367{
    366368    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
    367369    // On setting, if the text track cue snap-to-lines flag is not set, and the new
    368370    // value is negative or greater than 100, then throw an IndexSizeError exception.
    369     if (!m_snapToLines && (position < 0 || position > 100)) {
    370         ec = INDEX_SIZE_ERR;
    371         return;
    372     }
     371    if (!m_snapToLines && !(position >= 0 && position <= 100))
     372        return Exception { INDEX_SIZE_ERR };
    373373
    374374    // Otherwise, set the text track cue line position to the new value.
    375375    if (m_linePosition == position)
    376         return;
     376        return { };
    377377
    378378    willChange();
     
    380380    m_computedLinePosition = calculateComputedLinePosition();
    381381    didChange();
    382 }
    383 
    384 void VTTCue::setPosition(double position, ExceptionCode& ec)
     382
     383    return { };
     384}
     385
     386ExceptionOr<void> VTTCue::setPosition(double position)
    385387{
    386388    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position
    387389    // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
    388390    // Otherwise, set the text track cue text position to the new value.
    389     if (position < 0 || position > 100) {
    390         ec = INDEX_SIZE_ERR;
    391         return;
    392     }
    393    
     391    if (!(position >= 0 && position <= 100))
     392        return Exception { INDEX_SIZE_ERR };
     393
    394394    // Otherwise, set the text track cue line position to the new value.
    395395    if (m_textPosition == position)
    396         return;
     396        return { };
    397397   
    398398    willChange();
    399399    m_textPosition = position;
    400400    didChange();
    401 }
    402 
    403 void VTTCue::setSize(int size, ExceptionCode& ec)
     401
     402    return { };
     403}
     404
     405ExceptionOr<void> VTTCue::setSize(int size)
    404406{
    405407    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
    406408    // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
    407409    // exception. Otherwise, set the text track cue size to the new value.
    408     if (size < 0 || size > 100) {
    409         ec = INDEX_SIZE_ERR;
    410         return;
    411     }
    412    
     410    if (!(size >= 0 && size <= 100))
     411        return Exception { INDEX_SIZE_ERR };
     412
    413413    // Otherwise, set the text track cue line position to the new value.
    414414    if (m_cueSize == size)
    415         return;
     415        return { };
    416416   
    417417    willChange();
    418418    m_cueSize = size;
    419419    didChange();
     420
     421    return { };
    420422}
    421423
     
    439441}
    440442
    441 void VTTCue::setAlign(const String& value, ExceptionCode& ec)
     443ExceptionOr<void> VTTCue::setAlign(const String& value)
    442444{
    443445    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align
     
    447449    // agent must instead throw a SyntaxError exception.
    448450   
    449     CueAlignment alignment = m_cueAlignment;
     451    CueAlignment alignment;
    450452    if (value == startKeyword())
    451453        alignment = Start;
     
    459461        alignment = Right;
    460462    else
    461         ec = SYNTAX_ERR;
     463        return Exception { SYNTAX_ERR };
    462464   
    463465    if (alignment == m_cueAlignment)
    464         return;
     466        return { };
    465467
    466468    willChange();
    467469    m_cueAlignment = alignment;
    468470    didChange();
     471
     472    return { };
    469473}
    470474   
     
    787791}
    788792
    789 VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
    790 {
    791     RefPtr<VTTCueBox> displayTree = displayTreeInternal();
     793VTTCueBox& VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
     794{
     795    Ref<VTTCueBox> displayTree = displayTreeInternal();
    792796    if (!m_displayTreeShouldChange || !track()->isRendered())
    793797        return displayTree.get();
     
    840844    if (!hasDisplayTree())
    841845        return;
    842     displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
     846    displayTreeInternal().remove(ASSERT_NO_EXCEPTION);
    843847}
    844848
     
    11421146
    11431147    m_displayTreeShouldChange = true;
    1144     displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
     1148    displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
    11451149}
    11461150
  • trunk/Source/WebCore/html/track/VTTCue.h

    r204466 r207720  
    11/*
    2  * Copyright (C) 2011, 2013 Google Inc.  All rights reserved.
    3  * Copyright (C) 2012-2014 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
     3 * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    3030 */
    3131
    32 #ifndef VTTCue_h
    33 #define VTTCue_h
     32#pragma once
    3433
    3534#if ENABLE(VIDEO_TRACK)
     
    9190
    9291    const String& vertical() const;
    93     void setVertical(const String&, ExceptionCode&);
     92    ExceptionOr<void> setVertical(const String&);
    9493
    9594    bool snapToLines() const { return m_snapToLines; }
     
    9796
    9897    double line() const { return m_linePosition; }
    99     virtual void setLine(double, ExceptionCode&);
     98    virtual ExceptionOr<void> setLine(double);
    10099
    101100    double position() const { return m_textPosition; }
    102     virtual void setPosition(double, ExceptionCode&);
     101    virtual ExceptionOr<void> setPosition(double);
    103102
    104103    int size() const { return m_cueSize; }
    105     virtual void setSize(int, ExceptionCode&);
     104    ExceptionOr<void> setSize(int);
    106105
    107106    const String& align() const;
    108     void setAlign(const String&, ExceptionCode&);
     107    ExceptionOr<void> setAlign(const String&);
    109108
    110109    const String& text() const { return m_content; }
     
    124123
    125124    bool hasDisplayTree() const { return m_displayTree; }
    126     VTTCueBox* getDisplayTree(const IntSize& videoSize, int fontSize);
    127     HTMLSpanElement* element() const { return m_cueHighlightBox.get(); }
     125    VTTCueBox& getDisplayTree(const IntSize& videoSize, int fontSize);
     126    HTMLSpanElement& element() const { return *m_cueHighlightBox; }
    128127
    129128    void updateDisplayTree(const MediaTime&);
     
    174173    VTTCue(ScriptExecutionContext&, const WebVTTCueData&);
    175174
    176     virtual PassRefPtr<VTTCueBox> createDisplayTree();
    177     VTTCueBox* displayTreeInternal();
     175    virtual Ref<VTTCueBox> createDisplayTree();
     176    VTTCueBox& displayTreeInternal();
    178177
    179178private:
     
    231230
    232231#endif
    233 #endif
  • trunk/Source/WebCore/html/track/VTTCue.idl

    r206723 r207720  
    11/*
    2  * Copyright (C) 2011 Google Inc.  All rights reserved.
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
     25
    2526[
    2627    Conditional=VIDEO_TRACK,
     
    3031    JSGenerateToNativeObject,
    3132] interface VTTCue : TextTrackCue {
    32     [SetterMayThrowLegacyException] attribute DOMString vertical;
     33    [SetterMayThrowException] attribute DOMString vertical;
    3334    attribute boolean snapToLines;
    34     [SetterMayThrowLegacyException] attribute unrestricted double line;
    35     [SetterMayThrowLegacyException] attribute unrestricted double position;
    36     [SetterMayThrowLegacyException] attribute unrestricted double size;
    37     [SetterMayThrowLegacyException] attribute DOMString align;
     35    [SetterMayThrowException] attribute double line;
     36    [SetterMayThrowException] attribute double position;
     37    [SetterMayThrowException] attribute double size;
     38    [SetterMayThrowException] attribute DOMString align;
    3839    attribute DOMString text;
    3940    DocumentFragment getCueAsHTML();
  • trunk/Source/WebCore/html/track/VTTRegion.cpp

    r203322 r207720  
    5050namespace WebCore {
    5151
    52 // The following values default values are defined within the WebVTT Regions Spec.
     52// The default values are defined within the WebVTT Regions Spec.
    5353// https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/region.html
    54 
    55 // The region occupies by default 100% of the width of the video viewport.
    56 static const float defaultWidth = 100;
    57 
    58 // The region has, by default, 3 lines of text.
    59 static const long defaultHeightInLines = 3;
    60 
    61 // The region and viewport are anchored in the bottom left corner.
    62 static const float defaultAnchorPointX = 0;
    63 static const float defaultAnchorPointY = 100;
    64 
    65 // The region doesn't have scrolling text, by default.
    66 static const bool defaultScroll = false;
    6754
    6855// Default region line-height (vh units)
     
    7562    : ContextDestructionObserver(&context)
    7663    , m_id(emptyString())
    77     , m_width(defaultWidth)
    78     , m_heightInLines(defaultHeightInLines)
    79     , m_regionAnchor(FloatPoint(defaultAnchorPointX, defaultAnchorPointY))
    80     , m_viewportAnchor(FloatPoint(defaultAnchorPointX, defaultAnchorPointY))
    81     , m_scroll(defaultScroll)
    82     , m_cueContainer(nullptr)
    83     , m_regionDisplayTree(nullptr)
    84     , m_track(nullptr)
    85     , m_currentTop(0)
    8664    , m_scrollTimer(*this, &VTTRegion::scrollTimerFired)
    8765{
     
    10280}
    10381
    104 void VTTRegion::setWidth(double value, ExceptionCode& ec)
    105 {
    106     if (std::isinf(value) || std::isnan(value)) {
    107         ec = TypeError;
    108         return;
    109     }
    110 
    111     if (value < 0 || value > 100) {
    112         ec = INDEX_SIZE_ERR;
    113         return;
    114     }
    115 
     82ExceptionOr<void> VTTRegion::setWidth(double value)
     83{
     84    if (!(value >= 0 && value <= 100))
     85        return Exception { INDEX_SIZE_ERR };
    11686    m_width = value;
    117 }
    118 
    119 void VTTRegion::setHeight(long value, ExceptionCode& ec)
    120 {
    121     if (value < 0) {
    122         ec = INDEX_SIZE_ERR;
    123         return;
    124     }
    125 
     87    return { };
     88}
     89
     90ExceptionOr<void> VTTRegion::setHeight(int value)
     91{
     92    if (value < 0)
     93        return Exception { INDEX_SIZE_ERR };
    12694    m_heightInLines = value;
    127 }
    128 
    129 void VTTRegion::setRegionAnchorX(double value, ExceptionCode& ec)
    130 {
    131     if (std::isinf(value) || std::isnan(value)) {
    132         ec = TypeError;
    133         return;
    134     }
    135 
    136     if (value < 0 || value > 100) {
    137         ec = INDEX_SIZE_ERR;
    138         return;
    139     }
    140 
     95    return { };
     96}
     97
     98ExceptionOr<void> VTTRegion::setRegionAnchorX(double value)
     99{
     100    if (!(value >= 0 && value <= 100))
     101        return Exception { INDEX_SIZE_ERR };
    141102    m_regionAnchor.setX(value);
    142 }
    143 
    144 void VTTRegion::setRegionAnchorY(double value, ExceptionCode& ec)
    145 {
    146     if (std::isinf(value) || std::isnan(value)) {
    147         ec = TypeError;
    148         return;
    149     }
    150 
    151     if (value < 0 || value > 100) {
    152         ec = INDEX_SIZE_ERR;
    153         return;
    154     }
    155 
     103    return { };
     104}
     105
     106ExceptionOr<void> VTTRegion::setRegionAnchorY(double value)
     107{
     108    if (!(value >= 0 && value <= 100))
     109        return Exception { INDEX_SIZE_ERR };
    156110    m_regionAnchor.setY(value);
    157 }
    158 
    159 void VTTRegion::setViewportAnchorX(double value, ExceptionCode& ec)
    160 {
    161     if (std::isinf(value) || std::isnan(value)) {
    162         ec = TypeError;
    163         return;
    164     }
    165 
    166     if (value < 0 || value > 100) {
    167         ec = INDEX_SIZE_ERR;
    168         return;
    169     }
    170 
     111    return { };
     112}
     113
     114ExceptionOr<void> VTTRegion::setViewportAnchorX(double value)
     115{
     116    if (!(value >= 0 && value <= 100))
     117        return Exception { INDEX_SIZE_ERR };
    171118    m_viewportAnchor.setX(value);
    172 }
    173 
    174 void VTTRegion::setViewportAnchorY(double value, ExceptionCode& ec)
    175 {
    176     if (std::isinf(value) || std::isnan(value)) {
    177         ec = TypeError;
    178         return;
    179     }
    180 
    181     if (value < 0 || value > 100) {
    182         ec = INDEX_SIZE_ERR;
    183         return;
    184     }
    185 
     119    return { };
     120}
     121
     122ExceptionOr<void> VTTRegion::setViewportAnchorY(double value)
     123{
     124    if (!(value >= 0 && value <= 100))
     125        return Exception { INDEX_SIZE_ERR };
    186126    m_viewportAnchor.setY(value);
     127    return { };
     128}
     129
     130static const AtomicString& upKeyword()
     131{
     132    static NeverDestroyed<const AtomicString> upKeyword("up", AtomicString::ConstructFromLiteral);
     133    return upKeyword;
    187134}
    188135
    189136const AtomicString& VTTRegion::scroll() const
    190137{
    191     static NeverDestroyed<const AtomicString> upScrollValueKeyword("up", AtomicString::ConstructFromLiteral);
    192 
    193     if (m_scroll)
    194         return upScrollValueKeyword;
    195 
    196     return emptyAtom;
    197 }
    198 
    199 void VTTRegion::setScroll(const AtomicString& value, ExceptionCode& ec)
    200 {
    201     static NeverDestroyed<const AtomicString> upScrollValueKeyword("up", AtomicString::ConstructFromLiteral);
    202 
    203     if (value != emptyString() && value != upScrollValueKeyword) {
    204         ec = SYNTAX_ERR;
    205         return;
    206     }
    207 
    208     m_scroll = value == upScrollValueKeyword;
    209 }
    210 
    211 void VTTRegion::updateParametersFromRegion(VTTRegion* region)
    212 {
    213     m_heightInLines = region->height();
    214     m_width = region->width();
    215 
    216     m_regionAnchor = FloatPoint(region->regionAnchorX(), region->regionAnchorY());
    217     m_viewportAnchor = FloatPoint(region->viewportAnchorX(), region->viewportAnchorY());
    218 
    219     setScroll(region->scroll(), ASSERT_NO_EXCEPTION);
     138    return m_scroll ? upKeyword() : emptyAtom;
     139}
     140
     141ExceptionOr<void> VTTRegion::setScroll(const AtomicString& value)
     142{
     143    if (value.isEmpty()) {
     144        m_scroll = false;
     145        return { };
     146    }
     147    if (value == upKeyword()) {
     148        m_scroll = true;
     149        return { };
     150    }
     151    return Exception { SYNTAX_ERR };
     152}
     153
     154void VTTRegion::updateParametersFromRegion(const VTTRegion& other)
     155{
     156    m_heightInLines = other.m_heightInLines;
     157    m_width = other.m_width;
     158    m_regionAnchor = other.m_regionAnchor;
     159    m_viewportAnchor = other.m_viewportAnchor;
     160    m_scroll = other.m_scroll;
    220161}
    221162
     
    269210void VTTRegion::parseSettingValue(RegionSetting setting, VTTScanner& input)
    270211{
    271     static NeverDestroyed<const AtomicString> scrollUpValueKeyword("up", AtomicString::ConstructFromLiteral);
    272 
    273212    VTTScanner::Run valueRun = input.collectUntil<isHTMLSpace<UChar>>();
    274213
     
    313252    }
    314253    case Scroll:
    315         if (input.scanRun(valueRun, scrollUpValueKeyword.get()))
     254        if (input.scanRun(valueRun, upKeyword()))
    316255            m_scroll = true;
    317256        else
     
    346285}
    347286
    348 void VTTRegion::appendTextTrackCueBox(PassRefPtr<VTTCueBox> displayBox)
     287void VTTRegion::appendTextTrackCueBox(Ref<VTTCueBox>&& displayBox)
    349288{
    350289    ASSERT(m_cueContainer);
    351290
    352     if (m_cueContainer->contains(displayBox.get()))
     291    if (m_cueContainer->contains(displayBox.ptr()))
    353292        return;
    354293
    355     m_cueContainer->appendChild(*displayBox, ASSERT_NO_EXCEPTION);
     294    m_cueContainer->appendChild(displayBox, ASSERT_NO_EXCEPTION);
    356295    displayLastTextTrackCueBox();
    357296}
     
    406345{
    407346    if (!m_regionDisplayTree) {
    408         m_regionDisplayTree = HTMLDivElement::create(*ownerDocument());
     347        m_regionDisplayTree = HTMLDivElement::create(downcast<Document>(*m_scriptExecutionContext));
    409348        prepareRegionDisplayTree();
    410349    }
     
    448387    // The cue container is used to wrap the cues and it is the object which is
    449388    // gradually scrolled out as multiple cues are appended to the region.
    450     m_cueContainer = HTMLDivElement::create(*ownerDocument());
     389    m_cueContainer = HTMLDivElement::create(downcast<Document>(*m_scriptExecutionContext));
    451390    m_cueContainer->setInlineStyleProperty(CSSPropertyTop, 0.0f, CSSPrimitiveValue::CSS_PX);
    452391
  • trunk/Source/WebCore/html/track/VTTRegion.h

    r203322 r207720  
    11/*
    2  * Copyright (C) 2013 Google Inc.  All rights reserved.
    3  * Copyright (C) 2014 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2013 Google Inc. All rights reserved.
     3 * Copyright (C) 2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    3030 */
    3131
    32 #ifndef VTTRegion_h
    33 #define VTTRegion_h
     32#pragma once
    3433
    3534#if ENABLE(VIDEO_TRACK)
    3635
    3736#include "ContextDestructionObserver.h"
    38 #include "Document.h"
    3937#include "FloatPoint.h"
    4038#include "TextTrack.h"
    41 #include <wtf/RefCounted.h>
    4239
    4340namespace WebCore {
     
    6360
    6461    double width() const { return m_width; }
    65     void setWidth(double, ExceptionCode&);
     62    ExceptionOr<void> setWidth(double);
    6663
    67     long height() const { return m_heightInLines; }
    68     void setHeight(long, ExceptionCode&);
     64    int height() const { return m_heightInLines; }
     65    ExceptionOr<void> setHeight(int);
    6966
    7067    double regionAnchorX() const { return m_regionAnchor.x(); }
    71     void setRegionAnchorX(double, ExceptionCode&);
     68    ExceptionOr<void> setRegionAnchorX(double);
    7269
    7370    double regionAnchorY() const { return m_regionAnchor.y(); }
    74     void setRegionAnchorY(double, ExceptionCode&);
     71    ExceptionOr<void> setRegionAnchorY(double);
    7572
    7673    double viewportAnchorX() const { return m_viewportAnchor.x(); }
    77     void setViewportAnchorX(double, ExceptionCode&);
     74    ExceptionOr<void> setViewportAnchorX(double);
    7875
    7976    double viewportAnchorY() const { return m_viewportAnchor.y(); }
    80     void setViewportAnchorY(double, ExceptionCode&);
     77    ExceptionOr<void> setViewportAnchorY(double);
    8178
    8279    const AtomicString& scroll() const;
    83     void setScroll(const AtomicString&, ExceptionCode&);
     80    ExceptionOr<void> setScroll(const AtomicString&);
    8481
    85     void updateParametersFromRegion(VTTRegion*);
     82    void updateParametersFromRegion(const VTTRegion&);
    8683
    8784    const String& regionSettings() const { return m_settings; }
     
    9289    HTMLDivElement& getDisplayTree();
    9390   
    94     void appendTextTrackCueBox(PassRefPtr<VTTCueBox>);
     91    void appendTextTrackCueBox(Ref<VTTCueBox>&&);
    9592    void displayLastTextTrackCueBox();
    9693    void willRemoveTextTrackCueBox(VTTCueBox*);
     
    9895private:
    9996    VTTRegion(ScriptExecutionContext&);
    100 
    101     Document* ownerDocument() { return downcast<Document>(m_scriptExecutionContext); }
    10297
    10398    void prepareRegionDisplayTree();
     
    129124    String m_settings;
    130125
    131     double m_width;
    132     unsigned m_heightInLines;
     126    double m_width { 100 };
     127    unsigned m_heightInLines { 3 };
    133128
    134     FloatPoint m_regionAnchor;
    135     FloatPoint m_viewportAnchor;
     129    FloatPoint m_regionAnchor { 0, 100 };
     130    FloatPoint m_viewportAnchor { 0, 100 };
    136131
    137     bool m_scroll;
     132    bool m_scroll { false };
    138133
    139134    // The cue container is the container that is scrolled up to obtain the
     
    146141    // is cleared in the TextTrack destructor and it is generally
    147142    // set/reset within the addRegion and removeRegion methods.
    148     TextTrack* m_track;
     143    TextTrack* m_track { nullptr };
    149144
    150145    // Keep track of the current numeric value of the css "top" property.
    151     double m_currentTop;
     146    double m_currentTop { 0 };
    152147
    153148    // The timer is used to display the next cue line after the current one has
     
    162157
    163158#endif
    164 #endif
  • trunk/Source/WebCore/html/track/VTTRegion.idl

    r206723 r207720  
    11/*
    2  * Copyright (C) 2013 Google Inc.  All rights reserved.
    3  * Copyright (C) 2014 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2013 Google Inc. All rights reserved.
     3 * Copyright (C) 2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    2727[
    2828    Conditional=VIDEO_TRACK,
     29    Constructor(),
     30    ConstructorCallWith=ScriptExecutionContext,
    2931    JSGenerateToNativeObject,
    30     Constructor(),
    31     ConstructorCallWith=ScriptExecutionContext
    3232] interface VTTRegion {
    3333    readonly attribute TextTrack track;
    3434
    3535    attribute DOMString id;
    36     [SetterMayThrowLegacyException] attribute unrestricted double width;
    37     [SetterMayThrowLegacyException] attribute long height;
    38     [SetterMayThrowLegacyException] attribute unrestricted double regionAnchorX;
    39     [SetterMayThrowLegacyException] attribute unrestricted double regionAnchorY;
    40     [SetterMayThrowLegacyException] attribute unrestricted double viewportAnchorX;
    41     [SetterMayThrowLegacyException] attribute unrestricted double viewportAnchorY;
    42     [SetterMayThrowLegacyException] attribute DOMString scroll;
     36    [SetterMayThrowException] attribute double width;
     37    [SetterMayThrowException] attribute long height;
     38    [SetterMayThrowException] attribute double regionAnchorX;
     39    [SetterMayThrowException] attribute double regionAnchorY;
     40    [SetterMayThrowException] attribute double viewportAnchorX;
     41    [SetterMayThrowException] attribute double viewportAnchorY;
     42    [SetterMayThrowException] attribute DOMString scroll;
    4343};
    44 
Note: See TracChangeset for help on using the changeset viewer.