Changeset 207720 in webkit
- Timestamp:
- Oct 22, 2016 6:05:07 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 51 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207718 r207720 1 2016-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 1 13 2016-10-22 Michael Catanzaro <mcatanzaro@igalia.com> 2 14 -
trunk/LayoutTests/media/track/regions-webvtt/vtt-region-constructor-expected.txt
r203333 r207720 54 54 Invalid percentage value: -Infinity 55 55 RUN(region.viewportAnchorX = invalidPercentageValues[index]) 56 TypeError: T ype error56 TypeError: The provided value is non-finite 57 57 EXPECTED (region.viewportAnchorX == '0') OK 58 58 RUN(region.viewportAnchorY = invalidPercentageValues[index]) 59 TypeError: T ype error59 TypeError: The provided value is non-finite 60 60 EXPECTED (region.viewportAnchorY == '100') OK 61 61 RUN(region.regionAnchorX = invalidPercentageValues[index]) 62 TypeError: T ype error62 TypeError: The provided value is non-finite 63 63 EXPECTED (region.regionAnchorX == '0') OK 64 64 RUN(region.regionAnchorY = invalidPercentageValues[index]) 65 TypeError: T ype error65 TypeError: The provided value is non-finite 66 66 EXPECTED (region.regionAnchorY == '100') OK 67 67 RUN(region.width = invalidPercentageValues[index]) 68 TypeError: T ype error68 TypeError: The provided value is non-finite 69 69 EXPECTED (region.width == '100') OK 70 70 71 71 Invalid percentage value: Infinity 72 72 RUN(region.viewportAnchorX = invalidPercentageValues[index]) 73 TypeError: T ype error73 TypeError: The provided value is non-finite 74 74 EXPECTED (region.viewportAnchorX == '0') OK 75 75 RUN(region.viewportAnchorY = invalidPercentageValues[index]) 76 TypeError: T ype error76 TypeError: The provided value is non-finite 77 77 EXPECTED (region.viewportAnchorY == '100') OK 78 78 RUN(region.regionAnchorX = invalidPercentageValues[index]) 79 TypeError: T ype error79 TypeError: The provided value is non-finite 80 80 EXPECTED (region.regionAnchorX == '0') OK 81 81 RUN(region.regionAnchorY = invalidPercentageValues[index]) 82 TypeError: T ype error82 TypeError: The provided value is non-finite 83 83 EXPECTED (region.regionAnchorY == '100') OK 84 84 RUN(region.width = invalidPercentageValues[index]) 85 TypeError: T ype error85 TypeError: The provided value is non-finite 86 86 EXPECTED (region.width == '100') OK 87 87 88 88 Invalid percentage value: NaN 89 89 RUN(region.viewportAnchorX = invalidPercentageValues[index]) 90 TypeError: T ype error90 TypeError: The provided value is non-finite 91 91 EXPECTED (region.viewportAnchorX == '0') OK 92 92 RUN(region.viewportAnchorY = invalidPercentageValues[index]) 93 TypeError: T ype error93 TypeError: The provided value is non-finite 94 94 EXPECTED (region.viewportAnchorY == '100') OK 95 95 RUN(region.regionAnchorX = invalidPercentageValues[index]) 96 TypeError: T ype error96 TypeError: The provided value is non-finite 97 97 EXPECTED (region.regionAnchorX == '0') OK 98 98 RUN(region.regionAnchorY = invalidPercentageValues[index]) 99 TypeError: T ype error99 TypeError: The provided value is non-finite 100 100 EXPECTED (region.regionAnchorY == '100') OK 101 101 RUN(region.width = invalidPercentageValues[index]) 102 TypeError: T ype error102 TypeError: The provided value is non-finite 103 103 EXPECTED (region.width == '100') OK 104 104 RUN(region.height = -1) -
trunk/Source/WebCore/ChangeLog
r207719 r207720 1 2016-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 1 252 2016-10-22 Chris Dumez <cdumez@apple.com> 2 253 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207716 r207720 10644 10644 935FBCF109BA143B00E230B1 /* ExceptionCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCode.h; sourceTree = "<group>"; }; 10645 10645 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>"; }; 10646 10647 936DD03A09CEAC270056AE8C /* Range.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Range.idl; sourceTree = "<group>"; }; 10647 10648 9370918C1416D86B00477333 /* textAreaResizeCorner@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "textAreaResizeCorner@2x.png"; sourceTree = "<group>"; }; … … 16435 16436 4671E0631D67A57B00C6B497 /* CanvasPath.cpp */, 16436 16437 4671E0641D67A57B00C6B497 /* CanvasPath.h */, 16438 936B21F41DBBF8300052E117 /* CanvasPath.idl */, 16437 16439 49484FB6102CF23C00187DD3 /* CanvasPattern.cpp */, 16438 16440 49484FB7102CF23C00187DD3 /* CanvasPattern.h */, -
trunk/Source/WebCore/bindings/js/JSWebGL2RenderingContextCustom.cpp
r206386 r207720 25 25 26 26 #include "config.h" 27 #include "JSWebGL2RenderingContext.h" 27 28 28 29 #if ENABLE(WEBGL) && ENABLE(WEBGL2) 29 #include "JSWebGL2RenderingContext.h"30 30 31 31 #include <heap/HeapInlines.h> … … 38 38 namespace WebCore { 39 39 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. 42 static JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info) 41 43 { 42 44 switch (info.getType()) { … … 45 47 case WebGLGetInfo::kTypeBoolArray: { 46 48 MarkedArgumentBuffer list; 47 const auto& values = info.getBoolArray(); 48 for (const auto& value : values) 49 for (auto& value : info.getBoolArray()) 49 50 list.append(jsBoolean(value)); 50 return constructArray( exec, 0, globalObject, list);51 return constructArray(state, 0, globalObject, list); 51 52 } 52 53 case WebGLGetInfo::kTypeFloat: … … 57 58 return jsNull(); 58 59 case WebGLGetInfo::kTypeString: 59 return jsStringWithCache( exec, info.getString());60 return jsStringWithCache(state, info.getString()); 60 61 case WebGLGetInfo::kTypeUnsignedInt: 61 62 return jsNumber(info.getUnsignedInt()); … … 73 74 } 74 75 75 JSValue JSWebGL2RenderingContext::getInternalformatParameter(ExecState& exec)76 JSValue JSWebGL2RenderingContext::getInternalformatParameter(ExecState&) 76 77 { 77 UNUSED_PARAM(exec);78 78 return jsUndefined(); 79 79 } 80 80 81 JSValue JSWebGL2RenderingContext::getQueryParameter(ExecState& exec)81 JSValue JSWebGL2RenderingContext::getQueryParameter(ExecState&) 82 82 { 83 UNUSED_PARAM(exec);84 83 return jsUndefined(); 85 84 } 86 85 87 JSValue JSWebGL2RenderingContext::getSamplerParameter(ExecState& exec)86 JSValue JSWebGL2RenderingContext::getSamplerParameter(ExecState&) 88 87 { 89 UNUSED_PARAM(exec);90 88 return jsUndefined(); 91 89 } 92 90 93 JSValue JSWebGL2RenderingContext::getSyncParameter(ExecState& exec)91 JSValue JSWebGL2RenderingContext::getSyncParameter(ExecState&) 94 92 { 95 UNUSED_PARAM(exec);96 93 return jsUndefined(); 97 94 } 98 95 99 JSValue JSWebGL2RenderingContext::getIndexedParameter(ExecState& exec)96 JSValue JSWebGL2RenderingContext::getIndexedParameter(ExecState& state) 100 97 { 101 VM& vm = exec.vm();98 VM& vm = state.vm(); 102 99 auto scope = DECLARE_THROW_SCOPE(vm); 103 100 104 if ( exec.argumentCount() !=2)105 return throwException(& exec, scope, createNotEnoughArgumentsError(&exec));101 if (state.argumentCount() < 2) 102 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 106 103 107 WebGL2RenderingContext& context = wrapped(); 108 unsigned pname = exec.uncheckedArgument(0).toInt32(&exec); 104 unsigned pname = state.uncheckedArgument(0).toInt32(&state); 109 105 RETURN_IF_EXCEPTION(scope, JSValue()); 110 unsigned index = exec.uncheckedArgument(1).toInt32(&exec);106 unsigned index = state.uncheckedArgument(1).toInt32(&state); 111 107 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)); 114 109 } 115 110 116 JSValue JSWebGL2RenderingContext::getActiveUniformBlockParameter(ExecState& exec)111 JSValue JSWebGL2RenderingContext::getActiveUniformBlockParameter(ExecState&) 117 112 { 118 UNUSED_PARAM(exec);119 113 return jsUndefined(); 120 114 } 121 115 122 JSValue JSWebGL2RenderingContext::getActiveUniformBlockName(ExecState& exec)116 JSValue JSWebGL2RenderingContext::getActiveUniformBlockName(ExecState&) 123 117 { 124 UNUSED_PARAM(exec);125 118 return jsUndefined(); 126 119 } 127 128 120 129 121 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp
r207644 r207720 25 25 26 26 #include "config.h" 27 #include "JSWebGLRenderingContextBase.h" 27 28 28 29 #if ENABLE(WEBGL) 29 #include "JSWebGLRenderingContextBase.h"30 30 31 31 #include "ANGLEInstancedArrays.h" … … 131 131 } 132 132 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. 133 135 static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info) 134 136 { … … 138 140 case WebGLGetInfo::kTypeBoolArray: { 139 141 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)); 143 144 return constructArray(exec, 0, globalObject, list); 144 145 } … … 185 186 } 186 187 187 enum ObjectType { 188 kBuffer, kRenderbuffer, kTexture, kVertexAttrib 189 }; 188 enum ObjectType { kBuffer, kRenderbuffer, kTexture, kVertexAttrib }; 190 189 191 190 static JSValue getObjectParameter(JSWebGLRenderingContextBase* obj, ExecState& state, ObjectType objectType) … … 332 331 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 333 332 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)); 339 336 } 340 337 … … 352 349 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 353 350 354 ExceptionCode ec = 0;355 WebGLRenderingContextBase& context = wrapped();356 351 unsigned target = state.uncheckedArgument(0).toInt32(&state); 357 352 RETURN_IF_EXCEPTION(scope, JSValue()); … … 360 355 unsigned pname = state.uncheckedArgument(2).toInt32(&state); 361 356 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)); 368 358 } 369 359 … … 376 366 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 377 367 378 ExceptionCode ec = 0;379 WebGLRenderingContextBase& context = wrapped();380 368 unsigned pname = state.uncheckedArgument(0).toInt32(&state); 381 369 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)); 388 371 } 389 372 … … 396 379 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 397 380 398 ExceptionCode ec = 0;399 WebGLRenderingContextBase& context = wrapped();400 381 WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0)); 401 382 if (!program && !state.uncheckedArgument(0).isUndefinedOrNull()) … … 403 384 unsigned pname = state.uncheckedArgument(1).toInt32(&state); 404 385 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)); 411 387 } 412 388 … … 424 400 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 425 401 426 ExceptionCode ec = 0;427 WebGLRenderingContextBase& context = wrapped();428 402 if (!state.uncheckedArgument(0).isUndefinedOrNull() && !state.uncheckedArgument(0).inherits(JSWebGLShader::info())) 429 403 return throwTypeError(&state, scope); … … 431 405 unsigned pname = state.uncheckedArgument(1).toInt32(&state); 432 406 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)); 439 408 } 440 409 … … 444 413 if (context.isContextLost()) 445 414 return jsNull(); 446 Vector<String> value = context.getSupportedExtensions();447 415 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)); 450 418 return constructArray(&state, 0, globalObject(), list); 451 419 } … … 464 432 return throwException(&state, scope, createNotEnoughArgumentsError(&state)); 465 433 466 ExceptionCode ec = 0;467 WebGLRenderingContextBase& context = wrapped();468 434 WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0)); 469 435 if (!program && !state.uncheckedArgument(0).isUndefinedOrNull()) … … 472 438 if (!location && !state.uncheckedArgument(1).isUndefinedOrNull()) 473 439 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)); 480 441 } 481 442 -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r207458 r207720 229 229 } 230 230 231 m_context = std::make_unique<CanvasRenderingContext2D>( this, document().inQuirksMode(), usesDashboardCompatibilityMode);231 m_context = std::make_unique<CanvasRenderingContext2D>(*this, document().inQuirksMode(), usesDashboardCompatibilityMode); 232 232 233 233 downcast<CanvasRenderingContext2D>(*m_context).setUsesDisplayListDrawing(m_usesDisplayListDrawing); … … 323 323 } 324 324 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(); 329 327 330 328 IntSize oldSize = size(); … … 578 576 m_usesDisplayListDrawing = usesDisplayListDrawing; 579 577 580 if ( m_context && is<CanvasRenderingContext2D>(*m_context))578 if (is<CanvasRenderingContext2D>(m_context.get())) 581 579 downcast<CanvasRenderingContext2D>(*m_context).setUsesDisplayListDrawing(m_usesDisplayListDrawing); 582 580 } … … 589 587 m_tracksDisplayListReplay = tracksDisplayListReplay; 590 588 591 if ( m_context && is<CanvasRenderingContext2D>(*m_context))589 if (is<CanvasRenderingContext2D>(m_context.get())) 592 590 downcast<CanvasRenderingContext2D>(*m_context).setTracksDisplayListReplay(m_tracksDisplayListReplay); 593 591 } … … 595 593 String HTMLCanvasElement::displayListAsText(DisplayList::AsTextFlags flags) const 596 594 { 597 if ( m_context && is<CanvasRenderingContext2D>(*m_context))595 if (is<CanvasRenderingContext2D>(m_context.get())) 598 596 return downcast<CanvasRenderingContext2D>(*m_context).displayListAsText(flags); 599 597 … … 603 601 String HTMLCanvasElement::replayDisplayListAsText(DisplayList::AsTextFlags flags) const 604 602 { 605 if ( m_context && is<CanvasRenderingContext2D>(*m_context))603 if (is<CanvasRenderingContext2D>(m_context.get())) 606 604 return downcast<CanvasRenderingContext2D>(*m_context).replayDisplayListAsText(flags); 607 605 … … 714 712 m_didClearImageBuffer = true; 715 713 716 if (m_context->is2d()) { 717 CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get()); 714 if (is<CanvasRenderingContext2D>(*m_context)) { 718 715 // 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()); 720 717 } 721 718 } -
trunk/Source/WebCore/html/canvas/CanvasGradient.cpp
r207487 r207720 28 28 #include "CanvasGradient.h" 29 29 30 #include "CanvasPattern.h"31 30 #include "CanvasStyle.h" 32 #include "CSSParser.h"33 31 #include "ExceptionCode.h" 34 32 … … 37 35 CanvasGradient::CanvasGradient(const FloatPoint& p0, const FloatPoint& p1) 38 36 : m_gradient(Gradient::create(p0, p1)) 39 #if ENABLE(DASHBOARD_SUPPORT)40 , m_dashboardCompatibilityMode(false)41 #endif42 37 { 43 38 } … … 45 40 CanvasGradient::CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1) 46 41 : m_gradient(Gradient::create(p0, r0, p1, r1)) 47 #if ENABLE(DASHBOARD_SUPPORT)48 , m_dashboardCompatibilityMode(false)49 #endif50 42 { 51 43 } 52 44 53 void CanvasGradient::addColorStop(float value, const String& colorString, ExceptionCode& ec)45 ExceptionOr<void> CanvasGradient::addColorStop(float value, const String& colorString) 54 46 { 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 }; 59 49 50 // FIXME: Passing null for canvas means this won't work for current color. Is that OK? 60 51 Color color = parseColorOrCurrentColor(colorString, nullptr /*canvas*/); 61 52 if (!color.isValid()) { 62 53 #if ENABLE(DASHBOARD_SUPPORT) 63 if (!m_dashboardCompatibilityMode) 64 ec = SYNTAX_ERR; 65 #else 66 ec = SYNTAX_ERR; 54 if (m_dashboardCompatibilityMode) 55 return { }; 67 56 #endif 68 return ;57 return Exception { SYNTAX_ERR }; 69 58 } 70 59 71 60 m_gradient->addColorStop(value, color); 61 return { }; 72 62 } 73 63 74 } // namespace64 } -
trunk/Source/WebCore/html/canvas/CanvasGradient.h
r199537 r207720 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 4 * … … 25 25 */ 26 26 27 #ifndef CanvasGradient_h 28 #define CanvasGradient_h 27 #pragma once 29 28 29 #include "ExceptionOr.h" 30 30 #include "Gradient.h" 31 #include <wtf/Forward.h>32 #include <wtf/RefCounted.h>33 31 34 32 namespace WebCore { 35 33 36 typedef int ExceptionCode; 34 class CanvasGradient : public RefCounted<CanvasGradient> { 35 public: 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 } 37 44 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; } 51 47 52 void addColorStop(float value, const String& color, ExceptionCode&);48 ExceptionOr<void> addColorStop(float value, const String& color); 53 49 54 50 #if ENABLE(DASHBOARD_SUPPORT) 55 51 void setDashboardCompatibilityMode() { m_dashboardCompatibilityMode = true; } 56 52 #endif 57 53 58 59 60 61 62 54 private: 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; 63 59 #if ENABLE(DASHBOARD_SUPPORT) 64 bool m_dashboardCompatibilityMode;60 bool m_dashboardCompatibilityMode { false }; 65 61 #endif 66 62 }; 67 63 68 } //namespace 69 70 #endif 64 } -
trunk/Source/WebCore/html/canvas/CanvasGradient.idl
r206723 r207720 1 1 /* 2 * Copyright (C) 2006 Apple Inc. 2 * Copyright (C) 2006 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 [ 26 27 ImplementationLacksVTable, 27 28 ] interface CanvasGradient { 28 [MayThrow LegacyException] void addColorStop(float offset, DOMString color);29 [MayThrowException] void addColorStop(float offset, DOMString color); 29 30 }; 30 -
trunk/Source/WebCore/html/canvas/CanvasPath.cpp
r204669 r207720 112 112 } 113 113 114 void CanvasPath::arcTo(float x1, float y1, float x2, float y2, float r, ExceptionCode& ec) 115 { 116 ec = 0; 114 ExceptionOr<void> CanvasPath::arcTo(float x1, float y1, float x2, float y2, float r) 115 { 117 116 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 { }; 127 124 128 125 FloatPoint p1 = FloatPoint(x1, y1); … … 135 132 else 136 133 m_path.addArcTo(p1, p2, r); 134 135 return { }; 137 136 } 138 137 … … 156 155 } 157 156 158 void CanvasPath::arc(float x, float y, float radius, float startAngle, float endAngle, bool anticlockwise, ExceptionCode& ec)157 ExceptionOr<void> CanvasPath::arc(float x, float y, float radius, float startAngle, float endAngle, bool anticlockwise) 159 158 { 160 159 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 { }; 170 167 171 168 normalizeAngles(startAngle, endAngle, anticlockwise); … … 174 171 // The arc is empty but we still need to draw the connecting line. 175 172 lineTo(x + radius * cosf(startAngle), y + radius * sinf(startAngle)); 176 return ;173 return { }; 177 174 } 178 175 179 176 m_path.addArc(FloatPoint(x, y), radius, startAngle, endAngle, anticlockwise); 177 return { }; 180 178 } 181 179 182 void CanvasPath::ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise, ExceptionCode& ec)180 ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise) 183 181 { 184 182 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 { }; 194 190 195 191 normalizeAngles(startAngle, endAngle, anticlockwise); … … 200 196 201 197 lineTo(transform.mapPoint(FloatPoint(radiusX * cosf(startAngle), radiusY * sinf(startAngle)))); 202 return ;198 return { }; 203 199 } 204 200 … … 218 214 219 215 lineTo(transform.mapPoint(FloatPoint(radiusX * cosf(endAngle), radiusY * sinf(endAngle)))); 220 return ;216 return { }; 221 217 } 222 218 223 219 m_path.addEllipse(FloatPoint(x, y), radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise); 220 return { }; 224 221 } 225 222 -
trunk/Source/WebCore/html/canvas/CanvasPath.h
r204669 r207720 29 29 #pragma once 30 30 31 #include "ExceptionOr.h" 31 32 #include "Path.h" 32 33 33 34 namespace WebCore { 34 35 class FloatRect;36 37 typedef int ExceptionCode;38 35 39 36 class CanvasPath { … … 46 43 void quadraticCurveTo(float cpx, float cpy, float x, float y); 47 44 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); 51 48 void rect(float x, float y, float width, float height); 52 49 -
trunk/Source/WebCore/html/canvas/CanvasPath.idl
r206723 r207720 34 34 void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y); 35 35 void bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y); 36 [MayThrow LegacyException] void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);37 // [MayThrow LegacyException] 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); 38 38 void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); 39 [MayThrow LegacyException] void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);40 [MayThrow LegacyException] 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); 41 41 }; -
trunk/Source/WebCore/html/canvas/CanvasPattern.cpp
r177733 r207720 34 34 namespace WebCore { 35 35 36 Ref<CanvasPattern> CanvasPattern::create( PassRefPtr<Image>image, bool repeatX, bool repeatY, bool originClean)36 Ref<CanvasPattern> CanvasPattern::create(Ref<Image>&& image, bool repeatX, bool repeatY, bool originClean) 37 37 { 38 return adoptRef(*new CanvasPattern( image, repeatX, repeatY, originClean));38 return adoptRef(*new CanvasPattern(WTFMove(image), repeatX, repeatY, originClean)); 39 39 } 40 40 41 CanvasPattern::CanvasPattern( PassRefPtr<Image>image, bool repeatX, bool repeatY, bool originClean)42 : m_pattern(Pattern::create( image, repeatX, repeatY))41 CanvasPattern::CanvasPattern(Ref<Image>&& image, bool repeatX, bool repeatY, bool originClean) 42 : m_pattern(Pattern::create(WTFMove(image), repeatX, repeatY)) 43 43 , m_originClean(originClean) 44 44 { … … 49 49 } 50 50 51 void CanvasPattern::parseRepetitionType(const String& type, bool& repeatX, bool& repeatY, ExceptionCode& ec)51 bool CanvasPattern::parseRepetitionType(const String& type, bool& repeatX, bool& repeatY) 52 52 { 53 ec = 0;54 53 if (type.isEmpty() || type == "repeat") { 55 54 repeatX = true; 56 55 repeatY = true; 57 return ;56 return true; 58 57 } 59 58 if (type == "no-repeat") { 60 59 repeatX = false; 61 60 repeatY = false; 62 return ;61 return true; 63 62 } 64 63 if (type == "repeat-x") { 65 64 repeatX = true; 66 65 repeatY = false; 67 return ;66 return true; 68 67 } 69 68 if (type == "repeat-y") { 70 69 repeatX = false; 71 70 repeatY = true; 72 return ;71 return true; 73 72 } 74 ec = SYNTAX_ERR;73 return false; 75 74 } 76 75 -
trunk/Source/WebCore/html/canvas/CanvasPattern.h
r177733 r207720 24 24 */ 25 25 26 #ifndef CanvasPattern_h 27 #define CanvasPattern_h 26 #pragma once 28 27 29 28 #include <wtf/Forward.h> 30 #include <wtf/PassRefPtr.h>31 29 #include <wtf/Ref.h> 32 30 #include <wtf/RefCounted.h> … … 37 35 class Pattern; 38 36 39 typedef int ExceptionCode;40 41 37 class CanvasPattern : public RefCounted<CanvasPattern> { 42 38 public: 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); 44 40 ~CanvasPattern(); 45 41 46 static void parseRepetitionType(const String&, bool& repeatX, bool& repeatY, ExceptionCode&);42 static bool parseRepetitionType(const String&, bool& repeatX, bool& repeatY); 47 43 48 44 Pattern& pattern() { return m_pattern; } … … 52 48 53 49 private: 54 CanvasPattern( PassRefPtr<Image>, bool repeatX, bool repeatY, bool originClean);50 CanvasPattern(Ref<Image>&&, bool repeatX, bool repeatY, bool originClean); 55 51 56 52 Ref<Pattern> m_pattern; … … 59 55 60 56 } // namespace WebCore 61 62 #endif -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp
r207537 r207720 56 56 } 57 57 58 bool CanvasRenderingContext::wouldTaintOrigin(const HTMLImageElement* image)58 bool CanvasRenderingContext::wouldTaintOrigin(const HTMLImageElement* element) 59 59 { 60 if (! image|| !canvas()->originClean())60 if (!element || !canvas()->originClean()) 61 61 return false; 62 62 63 ASSERT(image->cachedImage()); 64 CachedImage& cachedImage = *image->cachedImage(); 63 auto* cachedImage = element->cachedImage(); 64 if (!cachedImage) 65 return false; 65 66 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()) 68 75 return true; 69 76 70 77 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; 74 81 } 75 82 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r207361 r207720 133 133 }; 134 134 135 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement *canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)136 : CanvasRenderingContext( canvas)135 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) 136 : CanvasRenderingContext(&canvas) 137 137 , m_stateStack(1) 138 138 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) … … 1349 1349 } 1350 1350 1351 void CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float x, float y, ExceptionCode& ec)1351 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float x, float y) 1352 1352 { 1353 1353 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 1357 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, float x, float y, float width, float height) 1359 1358 { 1360 1359 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 1363 ExceptionOr<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 1368 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, const FloatRect& srcRect, const FloatRect& dstRect) 1369 { 1370 return drawImage(imageElement, srcRect, dstRect, state().globalComposite, state().globalBlend); 1371 } 1372 1373 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageElement, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMode& blendMode) 1374 { 1380 1375 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfinite(dstRect.width()) || !std::isfinite(dstRect.height()) 1381 1376 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::isfinite(srcRect.width()) || !std::isfinite(srcRect.height())) 1382 return ;1377 return { }; 1383 1378 1384 1379 if (!dstRect.width() || !dstRect.height()) 1385 return ;1380 return { }; 1386 1381 1387 1382 if (!imageElement.complete()) 1388 return ;1383 return { }; 1389 1384 1390 1385 FloatRect normalizedSrcRect = normalizeRect(srcRect); … … 1392 1387 1393 1388 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 }; 1398 1391 1399 1392 // When the source rectangle is outside the source image, the source rectangle must be clipped … … 1402 1395 normalizedSrcRect.intersect(imageRect); 1403 1396 if (normalizedSrcRect.isEmpty()) 1404 return ;1397 return { }; 1405 1398 1406 1399 if (normalizedSrcRect != originalNormalizedSrcRect) { … … 1408 1401 normalizedDstRect.setHeight(normalizedDstRect.height() * normalizedSrcRect.height() / originalNormalizedSrcRect.height()); 1409 1402 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 { }; 1416 1409 if (!state().hasInvertibleTransform) 1417 return ;1410 return { }; 1418 1411 1419 1412 CachedImage* cachedImage = imageElement.cachedImage(); 1420 1413 if (!cachedImage) 1421 return ;1414 return { }; 1422 1415 1423 1416 Image* image = cachedImage->imageForRenderer(imageElement.renderer()); 1424 1417 if (!image) 1425 return ;1426 1418 return { }; 1419 1427 1420 ImageObserver* observer = image->imageObserver(); 1428 1421 … … 1451 1444 1452 1445 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 1450 ExceptionOr<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 1455 ExceptionOr<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 1460 ExceptionOr<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 1465 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLCanvasElement& sourceCanvas, const FloatRect& srcRect, const FloatRect& dstRect) 1475 1466 { 1476 1467 FloatRect srcCanvasRect = FloatRect(FloatPoint(), sourceCanvas.size()); 1477 1468 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 }; 1489 1474 1490 1475 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 { }; 1496 1481 if (!state().hasInvertibleTransform) 1497 return ;1482 return { }; 1498 1483 1499 1484 // FIXME: Do this through platform-independent GraphicsContext API. 1500 1485 ImageBuffer* buffer = sourceCanvas.buffer(); 1501 1486 if (!buffer) 1502 return ;1487 return { }; 1503 1488 1504 1489 checkOrigin(&sourceCanvas); … … 1529 1514 didDraw(dstRect); 1530 1515 } 1516 1517 return { }; 1531 1518 } 1532 1519 1533 1520 #if ENABLE(VIDEO) 1534 void CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float x, float y, ExceptionCode& ec) 1521 1522 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float x, float y) 1535 1523 { 1536 1524 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 1528 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, float x, float y, float width, float height) 1542 1529 { 1543 1530 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 1534 ExceptionOr<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 1539 ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, const FloatRect& srcRect, const FloatRect& dstRect) 1540 { 1559 1541 if (video.readyState() == HTMLMediaElement::HAVE_NOTHING || video.readyState() == HTMLMediaElement::HAVE_METADATA) 1560 return ;1542 return { }; 1561 1543 1562 1544 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 }; 1567 1547 1568 1548 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 { }; 1574 1554 if (!state().hasInvertibleTransform) 1575 return ;1555 return { }; 1576 1556 1577 1557 checkOrigin(&video); … … 1585 1565 didDraw(dstRect); 1586 1566 1587 return ;1567 return { }; 1588 1568 } 1589 1569 #endif … … 1597 1577 stateSaver.restore(); 1598 1578 didDraw(dstRect); 1599 } 1579 1580 return { }; 1581 } 1582 1600 1583 #endif 1601 1584 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) 1585 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement& imageElement, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, const String& compositeOperation) 1606 1586 { 1607 1587 CompositeOperator op; … … 1609 1589 if (!parseCompositeAndBlendOperator(compositeOperation, op, blendOp) || blendOp != BlendModeNormal) 1610 1590 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); 1613 1592 } 1614 1593 … … 1748 1727 } 1749 1728 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 } 1729 ExceptionOr<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 }; 1756 1733 1757 1734 Ref<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1)); … … 1760 1737 } 1761 1738 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 } 1739 ExceptionOr<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 }; 1773 1746 1774 1747 Ref<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, FloatPoint(x1, y1), r1); … … 1777 1750 } 1778 1751 1779 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageElement& imageElement, 1780 const String& repetitionType, ExceptionCode& ec) 1752 ExceptionOr<RefPtr<CanvasPattern>> CanvasRenderingContext2D::createPattern(HTMLImageElement& imageElement, const String& repetitionType) 1781 1753 { 1782 1754 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 1789 1760 // If the image loading hasn't started or the image is not complete, it is not fully decodable. 1790 1761 if (!cachedImage || !imageElement.complete()) 1791 1762 return nullptr; 1792 1763 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 }; 1800 1766 1801 1767 bool originClean = cachedImage->isOriginClean(canvas()->securityOrigin()); … … 1810 1776 originClean = false; 1811 1777 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 1781 ExceptionOr<Ref<CanvasPattern>> CanvasRenderingContext2D::createPattern(HTMLCanvasElement& canvas, const String& repetitionType) 1782 { 1783 if (!canvas.width() || !canvas.height() || !canvas.buffer()) 1784 return Exception { INVALID_STATE_ERR }; 1822 1785 1823 1786 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()); 1829 1791 } 1830 1792 1831 1793 #if ENABLE(VIDEO) 1832 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLVideoElement& videoElement, const String& repetitionType, ExceptionCode& ec) 1794 1795 ExceptionOr<RefPtr<CanvasPattern>> CanvasRenderingContext2D::createPattern(HTMLVideoElement& videoElement, const String& repetitionType) 1833 1796 { 1834 1797 if (videoElement.readyState() < HTMLMediaElement::HAVE_CURRENT_DATA) … … 1836 1799 1837 1800 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 1843 1804 checkOrigin(&videoElement); 1844 1805 bool originClean = canvas()->originClean(); … … 1846 1807 #if USE(CG) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(GSTREAMER_GL) && USE(CAIRO)) 1847 1808 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) }; 1849 1810 #endif 1850 1811 … … 1852 1813 videoElement.paintCurrentFrameInContext(imageBuffer->context(), FloatRect(FloatPoint(), size(videoElement))); 1853 1814 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 1856 1818 #endif 1857 1819 … … 1976 1938 } 1977 1939 1978 RefPtr<ImageData> CanvasRenderingContext2D::createImageData(RefPtr<ImageData>&& imageData, ExceptionCode& ec) const 1979 { 1980 if (!imageData) { 1981 ec = NOT_SUPPORTED_ERR; 1982 return nullptr; 1983 } 1940 ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::createImageData(ImageData* imageData) const 1941 { 1942 if (!imageData) 1943 return Exception { NOT_SUPPORTED_ERR }; 1984 1944 1985 1945 return createEmptyImageData(imageData->size()); 1986 1946 } 1987 1947 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)); 1948 ExceptionOr<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)); 2001 1954 if (!logicalSize.isExpressibleAsIntSize()) 2002 1955 return nullptr; … … 2011 1964 } 2012 1965 2013 RefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy, float sw, float sh, ExceptionCode& ec) const2014 { 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) const2019 { 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) const1966 ExceptionOr<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 1971 ExceptionOr<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 1976 ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::getImageData(ImageBuffer::CoordinateSystem coordinateSystem, float sx, float sy, float sw, float sh) const 2024 1977 { 2025 1978 if (!canvas()->originClean()) { 2026 1979 static NeverDestroyed<String> consoleMessage(ASCIILiteral("Unable to get image data from canvas because the canvas has been tainted by cross-origin data.")); 2027 1980 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 }; 2040 1986 2041 1987 if (sw < 0) { … … 2061 2007 return createEmptyImageData(imageDataRect.size()); 2062 2008 2063 RefPtr<Uint8ClampedArray>byteArray = buffer->getUnmultipliedImageData(imageDataRect, coordinateSystem);2009 auto byteArray = buffer->getUnmultipliedImageData(imageDataRect, coordinateSystem); 2064 2010 if (!byteArray) { 2065 2011 StringBuilder consoleMessage; … … 2070 2016 2071 2017 canvas()->document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage.toString()); 2072 ec = INVALID_STATE_ERR; 2073 return nullptr; 2018 return Exception { INVALID_STATE_ERR }; 2074 2019 } 2075 2020 … … 2077 2022 } 2078 2023 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); 2024 void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy) 2025 { 2026 putImageData(data, dx, dy, 0, 0, data.width(), data.height()); 2027 } 2028 2029 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy) 2030 { 2031 webkitPutImageDataHD(data, dx, dy, 0, 0, data.width(), data.height()); 2032 } 2033 2034 void 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 2039 void 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); 2098 2042 } 2099 2043 … … 2112 2056 GraphicsContext* context = drawingContext(); 2113 2057 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) 2116 2059 return; 2117 2060 … … 2119 2062 } 2120 2063 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 2064 void CanvasRenderingContext2D::putImageData(ImageData& data, ImageBuffer::CoordinateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight) 2065 { 2129 2066 ImageBuffer* buffer = canvas()->buffer(); 2130 2067 if (!buffer) -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r206538 r207720 60 60 class CanvasRenderingContext2D final : public CanvasRenderingContext, public CanvasPath { 61 61 public: 62 CanvasRenderingContext2D(HTMLCanvasElement *, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);62 CanvasRenderingContext2D(HTMLCanvasElement&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode); 63 63 virtual ~CanvasRenderingContext2D(); 64 64 … … 159 159 void clearShadow(); 160 160 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&); 170 170 #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); 175 175 #endif 176 176 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()); 179 178 180 179 void setAlpha(float); … … 182 181 void setCompositeOperation(const String&); 183 182 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); 188 187 #if ENABLE(VIDEO) 189 RefPtr<CanvasPattern> createPattern(HTMLVideoElement&, const String& repetitionType, ExceptionCode&);188 ExceptionOr<RefPtr<CanvasPattern>> createPattern(HTMLVideoElement&, const String& repetitionType); 190 189 #endif 191 190 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); 200 199 201 200 void drawFocusIfNeeded(Element*); … … 372 371 void prepareGradientForDashboard(CanvasGradient& gradient) const; 373 372 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); 376 375 377 376 bool is2d() const override { return true; } … … 392 391 bool m_usesDashboardCompatibilityMode; 393 392 #endif 394 395 393 bool m_usesDisplayListDrawing { false }; 396 394 bool m_tracksDisplayListReplay { false }; -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
r206723 r207720 54 54 attribute DOMString globalCompositeOperation; 55 55 56 [MayThrow LegacyException] CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1);57 [MayThrow LegacyException] 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); 58 58 59 59 attribute unrestricted float lineWidth; … … 133 133 void strokeRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); 134 134 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); 150 144 151 145 void drawImageFromRect(HTMLImageElement image, … … 163 157 unrestricted float y, unrestricted float k, unrestricted float a); 164 158 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); 167 161 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); 170 164 171 [MayThrow LegacyException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=EmptyString] DOMString repetitionType);172 [MayThrow LegacyException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=EmptyString] DOMString repetitionType);173 [Conditional=VIDEO, MayThrow LegacyException] CanvasPattern? createPattern(HTMLVideoElement video, [TreatNullAs=EmptyString] DOMString repetitionType);174 [MayThrow LegacyException] ImageData createImageData(ImageData? imagedata);175 [MayThrow LegacyException] 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); 176 170 177 171 [Custom] attribute custom strokeStyle; … … 179 173 180 174 // 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); 184 177 185 178 // Focus rings -
trunk/Source/WebCore/html/canvas/OESVertexArrayObject.cpp
r200626 r207720 25 25 26 26 #include "config.h" 27 #include "OESVertexArrayObject.h" 27 28 28 29 #if ENABLE(WEBGL) 29 30 #include "OESVertexArrayObject.h"31 30 32 31 #include "Extensions3D.h" … … 35 34 namespace WebCore { 36 35 37 OESVertexArrayObject::OESVertexArrayObject(WebGLRenderingContextBase* context) 38 : WebGLExtension(context) 39 { 40 } 41 42 OESVertexArrayObject::~OESVertexArrayObject() 36 OESVertexArrayObject::OESVertexArrayObject(WebGLRenderingContextBase& context) 37 : WebGLExtension(&context) 43 38 { 44 39 } … … 53 48 if (m_context->isContextLost()) 54 49 return nullptr; 55 50 56 51 auto object = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VAOTypeUser); 57 52 m_context->addContextObject(object.ptr()); … … 72 67 GC3Dboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject) 73 68 { 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()); 82 71 } 83 72 84 void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject , ExceptionCode& ec)73 void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject) 85 74 { 86 UNUSED_PARAM(ec);87 75 if (m_context->isContextLost()) 88 76 return; 89 77 90 78 if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, context()))) { 91 79 m_context->graphicsContext3D()->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); 92 80 return; 93 81 } 94 95 Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions(); 82 83 auto& extensions = *m_context->graphicsContext3D()->getExtensions(); 84 auto& context = downcast<WebGLRenderingContext>(*m_context); 96 85 if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) { 97 extensions->bindVertexArrayOES(arrayObject->object()); 98 86 extensions.bindVertexArrayOES(arrayObject->object()); 99 87 arrayObject->setHasEverBeenBound(); 100 static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(arrayObject);88 context.setBoundVertexArrayObject(arrayObject); 101 89 } else { 102 extensions ->bindVertexArrayOES(0);103 static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(0);90 extensions.bindVertexArrayOES(0); 91 context.setBoundVertexArrayObject(0); 104 92 } 105 93 } -
trunk/Source/WebCore/html/canvas/OESVertexArrayObject.h
r200626 r207720 24 24 */ 25 25 26 #ifndef OESVertexArrayObject_h 27 #define OESVertexArrayObject_h 26 #pragma once 28 27 29 28 #include "GraphicsTypes3D.h" … … 35 34 class WebGLVertexArrayObjectOES; 36 35 37 typedef int ExceptionCode;38 39 36 class OESVertexArrayObject final : public WebGLExtension { 40 37 public: 41 OESVertexArrayObject(WebGLRenderingContextBase*); 42 virtual ~OESVertexArrayObject(); 38 explicit OESVertexArrayObject(WebGLRenderingContextBase&); 43 39 44 ExtensionName getName() const override;45 46 40 RefPtr<WebGLVertexArrayObjectOES> createVertexArrayOES(); 47 41 void deleteVertexArrayOES(WebGLVertexArrayObjectOES*); 48 42 GC3Dboolean isVertexArrayOES(WebGLVertexArrayObjectOES*); 49 void bindVertexArrayOES(WebGLVertexArrayObjectOES*, ExceptionCode&); 43 void bindVertexArrayOES(WebGLVertexArrayObjectOES*); 44 45 private: 46 ExtensionName getName() const final; 50 47 }; 51 48 52 49 } // namespace WebCore 53 54 #endif // OESVertexArrayObject_h -
trunk/Source/WebCore/html/canvas/OESVertexArrayObject.idl
r206723 r207720 35 35 void deleteVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null); 36 36 boolean isVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null); 37 [MayThrowLegacyException]void bindVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null);37 void bindVertexArrayOES(optional WebGLVertexArrayObjectOES? arrayObject = null); 38 38 }; -
trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
r207715 r207720 65 65 } 66 66 67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, RefPtr<GraphicsContext3D>&& context, 68 GraphicsContext3D::Attributes attributes): WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes)67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3D::Attributes attributes) 68 : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes) 69 69 { 70 70 initializeShaderExtensions(); … … 808 808 } 809 809 810 WebGLGetInfo WebGL2RenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname , ExceptionCode&)810 WebGLGetInfo WebGL2RenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname) 811 811 { 812 812 if (isContextLostOrPending() || !validateFramebufferFuncParameters("getFramebufferAttachmentParameter", target, attachment)) … … 1040 1040 } 1041 1041 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; 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) 1043 { 1045 1044 ASSERT(!isContextLost()); 1046 1045 if (!validateTexFuncParameters("texSubImage2D", TexSubImage, target, level, internalformat, width, height, 0, format, type)) … … 1062 1061 } 1063 1062 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; 1063 void WebGL2RenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha) 1064 { 1067 1065 Vector<uint8_t> data; 1068 1066 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); … … 1090 1088 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); 1091 1089 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); 1093 1091 if (m_unpackAlignment != 1) 1094 1092 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 1095 1093 } 1096 1094 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)1095 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels) 1098 1096 { 1099 1097 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)) … … 1117 1115 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); 1118 1116 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); 1120 1118 if (changeUnpackAlignment) 1121 1119 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 1122 1120 } 1123 1121 1124 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode& ec) 1125 { 1126 ec = 0; 1122 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels) 1123 { 1127 1124 if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, GraphicsContext3D::NONE, pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset)) 1128 1125 return; … … 1145 1142 WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true); 1146 1143 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()); 1148 1145 if (m_unpackAlignment != 1) 1149 1146 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 1150 1147 } 1151 1148 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 1149 ExceptionOr<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 1158 1156 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer()); 1159 1157 if (!imageForRender) 1160 return ;1158 return { }; 1161 1159 1162 1160 if (imageForRender->isSVGImage()) … … 1164 1162 1165 1163 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 1170 ExceptionOr<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) 1176 1175 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, GraphicsContext3D::NONE, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) 1177 return ;1178 1176 return { }; 1177 1179 1178 RefPtr<ImageData> imageData = canvas->getImageData(); 1180 1179 if (imageData) 1181 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get() , ec);1180 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get()); 1182 1181 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 { }; 1184 1184 } 1185 1185 1186 1186 #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 1188 ExceptionOr<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) 1191 1193 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, GraphicsContext3D::NONE, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset)) 1192 return ;1193 1194 return { }; 1195 1194 1196 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode()); 1195 1197 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 1199 1203 #endif 1200 1204 … … 1244 1248 } 1245 1249 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); 1248 1251 if (isSRGB != (framebufferInternalFormat == GraphicsContext3D::SRGB8 || framebufferInternalFormat == GraphicsContext3D::SRGB8_ALPHA8)) { 1249 1252 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "framebuffer attachment color encoding and internal format do not match"); … … 1814 1817 } 1815 1818 1816 WebGLGetInfo WebGL2RenderingContext::getParameter(GC3Denum pname , ExceptionCode&)1819 WebGLGetInfo WebGL2RenderingContext::getParameter(GC3Denum pname) 1817 1820 { 1818 1821 if (isContextLostOrPending()) -
trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h
r207685 r207720 24 24 */ 25 25 26 #ifndef WebGL2RenderingContext_h 27 #define WebGL2RenderingContext_h 26 #pragma once 28 27 29 28 #if ENABLE(WEBGL2) … … 44 43 WebGL2RenderingContext(HTMLCanvasElement*, GraphicsContext3D::Attributes); 45 44 WebGL2RenderingContext(HTMLCanvasElement*, RefPtr<GraphicsContext3D>&&, GraphicsContext3D::Attributes); 46 bool isWebGL2() const override { return true; }47 45 48 46 /* Buffer objects */ … … 54 52 55 53 /* Framebuffer objects */ 56 WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname , ExceptionCode&) override;54 WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname) final; 57 55 void blitFramebuffer(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter); 58 56 void framebufferTextureLayer(GC3Denum target, GC3Denum attachment, GC3Duint texture, GC3Dint level, GC3Dint layer); … … 103 101 104 102 /* Writing to the drawing buffer */ 105 void clear(GC3Dbitfield mask) override;103 void clear(GC3Dbitfield mask) final; 106 104 void vertexAttribDivisor(GC3Duint index, GC3Duint divisor); 107 105 void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei instanceCount); … … 171 169 void bindVertexArray(WebGLVertexArrayObject* vertexArray); 172 170 171 private: 172 bool isWebGL2() const final { return true; } 173 173 174 /* 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; 192 188 #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; 195 190 #endif 196 191 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; 204 198 bool validateTexFuncParameters(const char* functionName, 205 199 TexFuncValidationFunctionType, … … 207 201 GC3Denum internalformat, 208 202 GC3Dsizei width, GC3Dsizei height, GC3Dint border, 209 GC3Denum format, GC3Denum type) override;203 GC3Denum format, GC3Denum type) final; 210 204 bool validateTexFuncData(const char* functionName, GC3Dint level, 211 205 GC3Dsizei width, GC3Dsizei height, 212 206 GC3Denum internalformat, GC3Denum format, GC3Denum type, 213 207 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 219 212 GC3Denum baseInternalFormatFromInternalFormat(GC3Denum internalformat); 220 213 bool isIntegerFormat(GC3Denum internalformat); … … 227 220 228 221 #endif // WEBGL2 229 230 #endif -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r207644 r207720 174 174 if (!m_oesVertexArrayObject) { 175 175 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); 177 177 } 178 178 return m_oesVertexArrayObject.get(); … … 297 297 } 298 298 299 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode& ec) 300 { 301 UNUSED_PARAM(ec); 299 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname) 300 { 302 301 if (isContextLostOrPending() || !validateFramebufferFuncParameters("getFramebufferAttachmentParameter", target, attachment)) 303 302 return WebGLGetInfo(); … … 511 510 } 512 511 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)512 void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels) 514 513 { 515 514 UNUSED_PARAM(internalformat); 516 // FIXME: For now we ignore any errors returned517 ec = 0;518 515 ASSERT(!isContextLost()); 519 516 ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage, target, level, format, width, height, 0, format, type)); … … 534 531 } 535 532 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; 533 void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha) 534 { 539 535 Vector<uint8_t> data; 540 536 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); … … 560 556 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 561 557 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); 563 559 if (m_unpackAlignment != 1) 564 560 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 565 561 } 566 562 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)563 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels) 568 564 { 569 565 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)) … … 586 582 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 587 583 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); 589 585 if (changeUnpackAlignment) 590 586 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 591 587 } 592 588 593 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode& ec) 594 { 595 ec = 0; 589 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels) 590 { 596 591 if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, format, pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset)) 597 592 return; … … 612 607 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 613 608 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()); 615 610 if (m_unpackAlignment != 1) 616 611 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 617 612 } 618 613 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 614 ExceptionOr<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 625 621 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer()); 626 622 if (!imageForRender) 627 return ;623 return { }; 628 624 629 625 if (imageForRender->isSVGImage()) … … 631 627 632 628 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 635 ExceptionOr<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) 642 640 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) 643 return ;644 641 return { }; 642 645 643 RefPtr<ImageData> imageData = canvas->getImageData(); 646 644 if (imageData) 647 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get() , ec);645 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get()); 648 646 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 { }; 650 649 } 651 650 652 651 #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 653 ExceptionOr<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) 657 658 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset)) 658 return ;659 659 return { }; 660 660 661 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode()); 661 662 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 665 668 #endif 666 669 … … 916 919 } 917 920 918 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode& ec) 919 { 920 UNUSED_PARAM(ec); 921 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname) 922 { 921 923 if (isContextLostOrPending()) 922 924 return WebGLGetInfo(); -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r200298 r207720 24 24 */ 25 25 26 #ifndef WebGLRenderingContext_h 27 #define WebGLRenderingContext_h 26 #pragma once 28 27 29 28 #include "WebGLRenderingContextBase.h" … … 35 34 WebGLRenderingContext(HTMLCanvasElement*, GraphicsContext3D::Attributes); 36 35 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;42 36 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; 37 private: 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; 60 56 #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; 63 58 #endif 64 59 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; 84 69 }; 85 70 … … 87 72 88 73 SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGLRenderingContext, isWebGL1()) 89 90 #endif -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r207719 r207720 2977 2977 } 2978 2978 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)2979 void WebGLRenderingContextBase::texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) 2980 2980 { 2981 2981 // FIXME: For now we ignore any errors returned. 2982 ec = 0;2983 2982 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); 2984 2983 ASSERT(validateTexFuncParameters("texImage2D", TexImage, target, level, internalformat, width, height, border, format, type)); … … 3012 3011 } 3013 3012 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; 3013 void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha) 3014 { 3017 3015 Vector<uint8_t> data; 3018 3016 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); … … 3037 3035 if (m_unpackAlignment != 1) 3038 3036 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); 3040 3038 if (m_unpackAlignment != 1) 3041 3039 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); … … 3083 3081 } 3084 3082 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)3083 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&& pixels) 3086 3084 { 3087 3085 if (isContextLostOrPending() || !validateTexFuncData("texImage2D", level, width, height, internalformat, format, type, pixels.get(), NullAllowed) … … 3103 3101 if (changeUnpackAlignment) 3104 3102 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); 3107 3104 if (changeUnpackAlignment) 3108 3105 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); 3109 3106 } 3110 3107 3111 void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Optional<TexImageSource> source, ExceptionCode& ec)3108 ExceptionOr<void> WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Optional<TexImageSource> source) 3112 3109 { 3113 3110 if (!source) { 3114 3111 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> { 3120 3116 if (isContextLostOrPending() || !validateTexFunc("texImage2D", TexImage, SourceImageData, target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, 0, 0)) 3121 return ;3117 return { }; 3122 3118 Vector<uint8_t> data; 3123 3119 bool needConversion = true; … … 3129 3125 if (!m_context->extractImageData(pixels.get(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { 3130 3126 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data"); 3131 return ;3127 return { }; 3132 3128 } 3133 3129 } 3134 3130 if (m_unpackAlignment != 1) 3135 3131 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()); 3137 3133 if (m_unpackAlignment != 1) 3138 3134 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 { }; 3143 3141 3144 3142 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer()); 3145 3143 if (!imageForRender) 3146 return ;3144 return { }; 3147 3145 3148 3146 if (imageForRender->isSVGImage()) … … 3150 3148 3151 3149 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 { }; 3160 3159 3161 3160 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); … … 3172 3171 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), target, texture->object(), internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3173 3172 texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas->height(), type); 3174 return ;3173 return { }; 3175 3174 } 3176 3175 } … … 3178 3177 RefPtr<ImageData> imageData = canvas->getImageData(); 3179 3178 if (imageData) 3180 texImage2D(target, level, internalformat, format, type, TexImageSource(imageData.get()) , ec);3179 texImage2D(target, level, internalformat, format, type, TexImageSource(imageData.get())); 3181 3180 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()) 3186 3187 || !validateTexFunc("texImage2D", TexImage, SourceHTMLVideoElement, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) 3187 return ;3188 return { }; 3188 3189 3189 3190 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. … … 3199 3200 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3200 3201 texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type); 3201 return ;3202 return { }; 3202 3203 } 3203 3204 } … … 3206 3207 RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode()); 3207 3208 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 { }; 3210 3212 }); 3211 3213 3212 WTF::visit(visitor, source.value());3214 return WTF::visit(visitor, source.value()); 3213 3215 } 3214 3216 … … 4473 4475 } 4474 4476 4475 bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionName, HTMLImageElement* image , ExceptionCode& ec)4477 bool WebGLRenderingContextBase::validateHTMLImageElement(const char* functionName, HTMLImageElement* image) 4476 4478 { 4477 4479 if (!image || !image->cachedImage()) { … … 4484 4486 return false; 4485 4487 } 4486 if (wouldTaintOrigin(image)) {4487 ec = SECURITY_ERR;4488 return false;4489 }4490 4488 return true; 4491 4489 } 4492 4490 4493 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas , ExceptionCode& ec)4491 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas) 4494 4492 { 4495 4493 if (!canvas || !canvas->buffer()) { … … 4497 4495 return false; 4498 4496 } 4499 if (wouldTaintOrigin(canvas)) {4500 ec = SECURITY_ERR;4501 return false;4502 }4503 4497 return true; 4504 4498 } 4505 4499 4506 4500 #if ENABLE(VIDEO) 4507 bool WebGLRenderingContextBase::validateHTMLVideoElement(const char* functionName, HTMLVideoElement* video, ExceptionCode& ec) 4501 4502 bool WebGLRenderingContextBase::validateHTMLVideoElement(const char* functionName, HTMLVideoElement* video) 4508 4503 { 4509 4504 if (!video || !video->videoWidth() || !video->videoHeight()) { … … 4511 4506 return false; 4512 4507 } 4513 if (wouldTaintOrigin(video)) {4514 ec = SECURITY_ERR;4515 return false;4516 }4517 4508 return true; 4518 4509 } 4510 4519 4511 #endif 4520 4512 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r207719 r207720 24 24 */ 25 25 26 #ifndef WebGLRenderingContextBase_h 27 #define WebGLRenderingContextBase_h 26 #pragma once 28 27 29 28 #include "ActiveDOMObject.h" … … 38 37 #include <runtime/Float32Array.h> 39 38 #include <runtime/Int32Array.h> 40 #include <wtf/Variant.h>41 #include <wtf/text/WTFString.h>42 39 43 40 namespace WebCore { … … 85 82 class WebGLVertexArrayObjectOES; 86 83 87 typedef int ExceptionCode;88 89 84 inline void clip1D(GC3Dint start, GC3Dsizei range, GC3Dsizei sourceRange, GC3Dint* clippedStart, GC3Dsizei* clippedRange) 90 85 { … … 201 196 GC3Denum getError(); 202 197 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; 205 200 WebGLGetInfo getProgramParameter(WebGLProgram*, GC3Denum pname); 206 201 String getProgramInfoLog(WebGLProgram*); … … 244 239 void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass); 245 240 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>&&); 247 242 248 243 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>); 250 245 251 246 void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param); 252 247 void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param); 253 248 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; 263 253 #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; 266 255 #endif 267 256 … … 603 592 void restoreStateAfterClear(); 604 593 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; 609 598 610 599 bool checkTextureCompleteness(const char*, bool); … … 759 748 WebGLBuffer* validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage); 760 749 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*); 767 753 #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*); 770 755 #endif 771 756 … … 794 779 void maybeRestoreContext(); 795 780 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 }; 803 783 void synthesizeGLError(GC3Denum, const char* functionName, const char* description, ConsoleDisplayPreference = DisplayInConsole); 804 784 805 785 String ensureNotNull(const String&) const; 806 786 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. 809 788 void applyStencilTest(); 810 789 … … 830 809 831 810 SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGLRenderingContextBase, is3d()) 832 833 #endif -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl
r207719 r207720 24 24 */ 25 25 26 typedef unsigned long 26 typedef unsigned long GLenum; 27 27 typedef boolean GLboolean; 28 typedef unsigned long 29 typedef byte 30 typedef short 31 typedef long 32 typedef long 33 typedef long long 34 typedef long long 35 typedef octet 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. */ 36 36 typedef unsigned short GLushort; 37 typedef unsigned long 37 typedef unsigned long GLuint; 38 38 typedef unrestricted float GLfloat; 39 39 typedef unrestricted float GLclampf; … … 546 546 WebGLActiveInfo getActiveUniform(WebGLProgram? program, GLuint index); 547 547 548 [Custom , MayThrowLegacyException] void getAttachedShaders(WebGLProgram? program);548 [Custom] void getAttachedShaders(WebGLProgram? program); 549 549 550 550 GLint getAttribLocation(WebGLProgram? program, DOMString name); … … 559 559 [Custom] any getExtension(DOMString name); 560 560 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); 564 564 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); 567 567 568 568 DOMString? getShaderInfoLog(WebGLShader? shader); … … 574 574 [Custom] sequence<DOMString> getSupportedExtensions(); 575 575 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); 579 579 580 580 WebGLUniformLocation getUniformLocation(WebGLProgram? program, DOMString name); 581 581 582 [Custom , MayThrowLegacyException] any getVertexAttrib(GLuint index, GLenum pname);582 [Custom] any getVertexAttrib(GLuint index, GLenum pname); 583 583 584 584 GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname); … … 616 616 617 617 // 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); 634 626 635 627 void uniform1f(WebGLUniformLocation? location, GLfloat x); 636 [Custom , MayThrowLegacyException] void uniform1fv(WebGLUniformLocation? location, Float32Array v);628 [Custom] void uniform1fv(WebGLUniformLocation? location, Float32Array v); 637 629 void uniform1i(WebGLUniformLocation? location, GLint x); 638 [Custom , MayThrowLegacyException] void uniform1iv(WebGLUniformLocation? location, Int32Array v);630 [Custom] void uniform1iv(WebGLUniformLocation? location, Int32Array v); 639 631 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); 641 633 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); 643 635 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); 645 637 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); 647 639 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); 649 641 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); 655 647 656 648 void useProgram(WebGLProgram? program); -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r206843 r207720 1173 1173 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()); 1174 1174 1175 Ref Ptr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize);1175 Ref<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize); 1176 1176 if (cue->track()->mode() == TextTrack::Mode::Disabled) 1177 1177 continue; … … 1182 1182 // WebVTT region whose region identifier is identical to cue's text 1183 1183 // track cue region identifier, run the following substeps: 1184 if (displayBox->hasChildNodes() && !contains(displayBox. get())) {1184 if (displayBox->hasChildNodes() && !contains(displayBox.ptr())) { 1185 1185 // 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); 1187 1187 cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant); 1188 1188 } … … 1196 1196 appendChild(region->getDisplayTree()); 1197 1197 1198 region->appendTextTrackCueBox( displayBox);1198 region->appendTextTrackCueBox(WTFMove(displayBox)); 1199 1199 } 1200 1200 } -
trunk/Source/WebCore/html/track/DataCue.h
r204466 r207720 25 25 */ 26 26 27 #ifndef DataCue_h 28 #define DataCue_h 27 #pragma once 29 28 30 29 #if ENABLE(VIDEO_TRACK) … … 115 114 116 115 #endif 117 #endif -
trunk/Source/WebCore/html/track/DataCue.idl
r206723 r207720 33 33 CustomConstructor(unrestricted double startTime, unrestricted double endTime, ArrayBuffer data), 34 34 #endif 35 ConstructorMayThrow LegacyException,35 ConstructorMayThrowException, 36 36 ] interface DataCue : TextTrackCue { 37 37 attribute ArrayBuffer data; -
trunk/Source/WebCore/html/track/InbandDataTextTrack.cpp
r202242 r207720 26 26 27 27 #include "config.h" 28 #include "InbandDataTextTrack.h" 28 29 29 30 #if ENABLE(VIDEO_TRACK) 30 #include "InbandDataTextTrack.h"31 31 32 32 #include "DataCue.h" … … 39 39 namespace WebCore { 40 40 41 Ref<InbandDataTextTrack> InbandDataTextTrack::create(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate> playerPrivate)41 Ref<InbandDataTextTrack> InbandDataTextTrack::create(ScriptExecutionContext* context, TextTrackClient* client, RefPtr<InbandTextTrackPrivate>&& trackPrivate) 42 42 { 43 return adoptRef(*new InbandDataTextTrack(context, client, playerPrivate));43 return adoptRef(*new InbandDataTextTrack(context, client, WTFMove(trackPrivate))); 44 44 } 45 45 46 InbandDataTextTrack::InbandDataTextTrack(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate>trackPrivate)46 InbandDataTextTrack::InbandDataTextTrack(ScriptExecutionContext* context, TextTrackClient* client, RefPtr<InbandTextTrackPrivate>&& trackPrivate) 47 47 : InbandTextTrack(context, client, trackPrivate) 48 48 { … … 55 55 void InbandDataTextTrack::addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, const void* data, unsigned length) 56 56 { 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)); 59 58 } 60 59 61 60 #if ENABLE(DATACUE_VALUE) 61 62 62 void InbandDataTextTrack::addDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation> prpPlatformValue, const String& type) 63 63 { … … 77 77 } 78 78 79 addCue(WTFMove(cue) , ASSERT_NO_EXCEPTION);79 addCue(WTFMove(cue)); 80 80 } 81 81 … … 118 118 if (cue) { 119 119 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()); 121 121 } 122 122 } 123 123 124 void InbandDataTextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec)124 ExceptionOr<void> InbandDataTextTrack::removeCue(TextTrackCue* cue) 125 125 { 126 126 ASSERT(cue->cueType() == TextTrackCue::Data); 127 127 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())); 132 129 133 InbandTextTrack::removeCue(cue, ec);130 return InbandTextTrack::removeCue(cue); 134 131 } 135 132 -
trunk/Source/WebCore/html/track/InbandDataTextTrack.h
r197563 r207720 25 25 */ 26 26 27 #ifndef InbandDataTextTrack_h 28 #define InbandDataTextTrack_h 27 #pragma once 29 28 30 29 #if ENABLE(VIDEO_TRACK) 31 30 32 31 #include "InbandTextTrack.h" 33 #include <wtf/RefPtr.h>34 32 35 33 namespace WebCore { 36 34 37 35 class DataCue; 38 class Document;39 36 class InbandTextTrackPrivate; 40 41 #if ENABLE(DATACUE_VALUE)42 37 class SerializedPlatformRepresentation; 43 #endif44 38 45 39 class InbandDataTextTrack final : public InbandTextTrack { 46 40 public: 47 static Ref<InbandDataTextTrack> create(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);41 static Ref<InbandDataTextTrack> create(ScriptExecutionContext*, TextTrackClient*, RefPtr<InbandTextTrackPrivate>&&); 48 42 virtual ~InbandDataTextTrack(); 49 43 50 44 private: 51 InbandDataTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);45 InbandDataTextTrack(ScriptExecutionContext*, TextTrackClient*, RefPtr<InbandTextTrackPrivate>&&); 52 46 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; 54 48 55 49 #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; 60 54 61 55 HashMap<RefPtr<SerializedPlatformRepresentation>, RefPtr<DataCue>> m_incompleteCueMap; … … 66 60 67 61 #endif 68 #endif -
trunk/Source/WebCore/html/track/InbandGenericTextTrack.cpp
r202242 r207720 25 25 26 26 #include "config.h" 27 #include "InbandGenericTextTrack.h" 27 28 28 29 #if ENABLE(VIDEO_TRACK) 29 30 #include "InbandGenericTextTrack.h"31 30 32 31 #include "ExceptionCodePlaceholder.h" … … 38 37 #include <wtf/text/CString.h> 39 38 40 41 39 namespace WebCore { 42 40 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) 41 void GenericTextTrackCueMap::add(GenericCueData& cueData, TextTrackCueGeneric& cue) 42 { 43 m_dataToCueMap.add(&cueData, &cue); 44 m_cueToDataMap.add(&cue, &cueData); 45 } 46 47 TextTrackCueGeneric* GenericTextTrackCueMap::find(GenericCueData& cueData) 48 { 49 return m_dataToCueMap.get(&cueData); 50 } 51 52 GenericCueData* GenericTextTrackCueMap::find(TextTrackCue& cue) 53 { 54 return m_cueToDataMap.get(&cue); 55 } 56 57 void GenericTextTrackCueMap::remove(GenericCueData& cueData) 58 { 59 if (auto cue = m_dataToCueMap.take(&cueData)) 80 60 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 63 void GenericTextTrackCueMap::remove(TextTrackCue& cue) 64 { 65 if (auto data = m_cueToDataMap.take(&cue)) 66 m_dataToCueMap.remove(data); 91 67 } 92 68 … … 121 97 122 98 if (cueData->position() > 0) 123 cue->setPosition( lround(cueData->position()), IGNORE_EXCEPTION);99 cue->setPosition(std::round(cueData->position())); 124 100 if (cueData->line() > 0) 125 cue->setLine( lround(cueData->line()), IGNORE_EXCEPTION);101 cue->setLine(std::round(cueData->line())); 126 102 if (cueData->size() > 0) 127 cue->setSize( lround(cueData->size()), IGNORE_EXCEPTION);103 cue->setSize(std::round(cueData->size())); 128 104 if (cueData->backgroundColor().isValid()) 129 105 cue->setBackgroundColor(cueData->backgroundColor().rgb()); … … 134 110 135 111 if (cueData->align() == GenericCueData::Start) 136 cue->setAlign(ASCIILiteral("start") , IGNORE_EXCEPTION);112 cue->setAlign(ASCIILiteral("start")); 137 113 else if (cueData->align() == GenericCueData::Middle) 138 cue->setAlign(ASCIILiteral("middle") , IGNORE_EXCEPTION);114 cue->setAlign(ASCIILiteral("middle")); 139 115 else if (cueData->align() == GenericCueData::End) 140 cue->setAlign(ASCIILiteral("end") , IGNORE_EXCEPTION);116 cue->setAlign(ASCIILiteral("end")); 141 117 cue->setSnapToLines(false); 142 118 … … 149 125 150 126 RefPtr<GenericCueData> cueData = prpCueData; 151 if (m_cueMap.find( cueData.get()))127 if (m_cueMap.find(*cueData)) 152 128 return; 153 129 … … 162 138 163 139 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)); 167 143 } 168 144 169 145 void InbandGenericTextTrack::updateGenericCue(InbandTextTrackPrivate*, GenericCueData* cueData) 170 146 { 171 RefPtr<TextTrackCueGeneric> cue = m_cueMap.find(cueData);147 auto* cue = m_cueMap.find(*cueData); 172 148 if (!cue) 173 149 return; 174 150 175 updateCueFromCueData(cue .get(), cueData);151 updateCueFromCueData(cue, cueData); 176 152 177 153 if (cueData->status() == GenericCueData::Complete) 178 m_cueMap.remove( cueData);154 m_cueMap.remove(*cueData); 179 155 } 180 156 181 157 void InbandGenericTextTrack::removeGenericCue(InbandTextTrackPrivate*, GenericCueData* cueData) 182 158 { 183 RefPtr<TextTrackCueGeneric> cue = m_cueMap.find(cueData);159 auto* cue = m_cueMap.find(*cueData); 184 160 if (cue) { 185 161 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); 187 163 } else { 188 164 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 168 ExceptionOr<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; 197 174 } 198 175 … … 228 205 return; 229 206 } 230 addCue(WTFMove(vttCue) , ASSERT_NO_EXCEPTION);207 addCue(WTFMove(vttCue)); 231 208 } 232 209 } -
trunk/Source/WebCore/html/track/InbandGenericTextTrack.h
r197563 r207720 24 24 */ 25 25 26 #ifndef InbandGenericTextTrack_h 27 #define InbandGenericTextTrack_h 26 #pragma once 28 27 29 28 #if ENABLE(VIDEO_TRACK) … … 32 31 #include "TextTrackCueGeneric.h" 33 32 #include "WebVTTParser.h" 34 #include <wtf/RefPtr.h>35 33 36 34 namespace WebCore { … … 38 36 class Document; 39 37 class InbandTextTrackPrivate; 40 class TextTrackCue;41 38 42 class GenericTextTrackCueMap final{39 class GenericTextTrackCueMap { 43 40 public: 44 GenericTextTrackCueMap(); 45 ~GenericTextTrackCueMap(); 41 void add(GenericCueData&, TextTrackCueGeneric&); 46 42 47 void add(GenericCueData*, TextTrackCueGeneric*); 43 void remove(TextTrackCue&); 44 void remove(GenericCueData&); 48 45 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&); 54 48 55 49 private: 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>>; 58 52 59 53 CueToDataMap m_cueToDataMap; … … 69 63 InbandGenericTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>); 70 64 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; 75 69 76 70 PassRefPtr<TextTrackCueGeneric> createCue(PassRefPtr<GenericCueData>); … … 78 72 79 73 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; 82 76 83 void newCuesParsed() override;84 void newRegionsParsed() override;85 void fileFailedToParse() override;77 void newCuesParsed() final; 78 void newRegionsParsed() final; 79 void fileFailedToParse() final; 86 80 87 81 GenericTextTrackCueMap m_cueMap; … … 92 86 93 87 #endif 94 #endif -
trunk/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
r202242 r207720 83 83 return; 84 84 } 85 addCue(WTFMove(vttCue) , ASSERT_NO_EXCEPTION);85 addCue(WTFMove(vttCue)); 86 86 } 87 87 } -
trunk/Source/WebCore/html/track/TextTrack.cpp
r205791 r207720 1 1 /* 2 * Copyright (C) 2011, 2013 Google Inc. 3 * Copyright (C) 2011-2014 Apple Inc. 2 * Copyright (C) 2011, 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2011-2014 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 86 86 TextTrack* TextTrack::captionMenuOffItem() 87 87 { 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(); 89 89 return &off; 90 90 } … … 92 92 TextTrack* TextTrack::captionMenuAutomaticItem() 93 93 { 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(); 95 95 return &automatic; 96 96 } … … 291 291 } 292 292 293 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec) 294 { 295 if (!prpCue) 296 return; 297 298 RefPtr<TextTrackCue> cue = prpCue; 293 ExceptionOr<void> TextTrack::addCue(RefPtr<TextTrackCue>&& cue) 294 { 295 if (!cue) 296 return { }; 299 297 300 298 // 4.7.10.12.6 Text tracks exposing in-band metadata … … 304 302 // track kind set to metadata, throw a InvalidNodeTypeError exception and don't add the cue to the TextTrackList 305 303 // 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 }; 310 306 311 307 // TODO(93143): Add spec-compliant behavior for negative time values. 312 308 if (!cue->startMediaTime().isValid() || !cue->endMediaTime().isValid() || cue->startMediaTime() < MediaTime::zeroTime() || cue->endMediaTime() < MediaTime::zeroTime()) 313 return ;309 return { }; 314 310 315 311 // 4.8.10.12.5 Text track API … … 321 317 TextTrack* cueTrack = cue->track(); 322 318 if (cueTrack && cueTrack != this) 323 cueTrack->removeCue(cue.get() , ASSERT_NO_EXCEPTION);319 cueTrack->removeCue(cue.get()); 324 320 325 321 // 2. Add cue to the method's TextTrack object's text track's text track list of cues. … … 329 325 if (m_client) 330 326 m_client->textTrackAddCue(this, *cue); 331 } 332 333 void TextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec) 327 328 return { }; 329 } 330 331 ExceptionOr<void> TextTrack::removeCue(TextTrackCue* cue) 334 332 { 335 333 if (!cue) 336 return ;334 return { }; 337 335 338 336 // 4.8.10.12.5 Text track API … … 342 340 // 1. If the given cue is not currently listed in the method's TextTrack 343 341 // 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 }; 348 344 349 345 // 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); 356 350 if (m_client) 357 351 m_client->textTrackRemoveCue(this, *cue); 352 353 return { }; 358 354 } 359 355 … … 379 375 } 380 376 381 void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion) 382 { 383 if (!prpRegion) 384 return; 385 386 RefPtr<VTTRegion> region = prpRegion; 387 VTTRegionList& regionList = ensureVTTRegionList(); 377 void TextTrack::addRegion(RefPtr<VTTRegion>&& region) 378 { 379 if (!region) 380 return; 381 382 auto& regionList = ensureVTTRegionList(); 388 383 389 384 // 1. If the given region is in a text track list of regions, then remove 390 385 // region from that text track list of regions. 391 TextTrack* regionTrack = region->track();386 auto* regionTrack = region->track(); 392 387 if (regionTrack && regionTrack != this) 393 regionTrack->removeRegion(region.get() , ASSERT_NO_EXCEPTION);388 regionTrack->removeRegion(region.get()); 394 389 395 390 // 2. If the method's TextTrack object's text track list of regions contains … … 397 392 // region's width, height, anchor point, viewport anchor point and scroll 398 393 // attributes with those of region. 399 VTTRegion* existingRegion = regionList.getRegionById(region->id());394 auto* existingRegion = regionList.getRegionById(region->id()); 400 395 if (existingRegion) { 401 existingRegion->updateParametersFromRegion( region.get());396 existingRegion->updateParametersFromRegion(*region); 402 397 return; 403 398 } … … 406 401 // list of regions. 407 402 region->setTrack(this); 408 regionList.add( region);409 } 410 411 void TextTrack::removeRegion(VTTRegion* region, ExceptionCode &ec)403 regionList.add(WTFMove(region)); 404 } 405 406 ExceptionOr<void> TextTrack::removeRegion(VTTRegion* region) 412 407 { 413 408 if (!region) 414 return ;409 return { }; 415 410 416 411 // 1. If the given region is not currently listed in the method's TextTrack 417 412 // 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 { }; 429 421 } 430 422 -
trunk/Source/WebCore/html/track/TextTrack.h
r204239 r207720 101 101 TextTrackClient* client() { return m_client; } 102 102 103 void addCue(PassRefPtr<TextTrackCue>, ExceptionCode&);104 virtual void removeCue(TextTrackCue*, ExceptionCode&);103 ExceptionOr<void> addCue(RefPtr<TextTrackCue>&&); 104 virtual ExceptionOr<void> removeCue(TextTrackCue*); 105 105 106 106 bool hasCue(TextTrackCue*, TextTrackCue::CueMatchRules = TextTrackCue::MatchAllFields); 107 107 108 108 VTTRegionList* regions(); 109 void addRegion( PassRefPtr<VTTRegion>);110 void removeRegion(VTTRegion*, ExceptionCode&);109 void addRegion(RefPtr<VTTRegion>&&); 110 ExceptionOr<void> removeRegion(VTTRegion*); 111 111 112 112 void cueWillChange(TextTrackCue*); -
trunk/Source/WebCore/html/track/TextTrack.idl
r206723 r207720 45 45 46 46 // FIXME: cue parameter should not be nullable in addCue and removeCue. 47 [MayThrow LegacyException] void addCue(TextTrackCue? cue);48 [MayThrow LegacyException] void removeCue(TextTrackCue? cue);47 [MayThrowException] void addCue(TextTrackCue? cue); 48 [MayThrowException] void removeCue(TextTrackCue? cue); 49 49 50 50 attribute EventHandler oncuechange; … … 53 53 // FIXME: region parameter should not be nullable in addRegion and removeRegion. 54 54 void addRegion(VTTRegion? region); 55 [MayThrow LegacyException] void removeRegion(VTTRegion? region);55 [MayThrowException] void removeRegion(VTTRegion? region); 56 56 }; -
trunk/Source/WebCore/html/track/TextTrackCue.cpp
r204765 r207720 55 55 static const int invalidCueIndex = -1; 56 56 57 const AtomicString& TextTrackCue::cueShadowPseudoId() 58 { 59 static NeverDestroyed<const AtomicString> cue("cue", AtomicString::ConstructFromLiteral); 60 return cue; 61 } 62 57 63 TextTrackCue::TextTrackCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end) 58 64 : m_startTime(start) … … 68 74 } 69 75 70 TextTrackCue::~TextTrackCue()71 {72 }73 74 76 void TextTrackCue::willChange() 75 77 { … … 111 113 } 112 114 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 115 void TextTrackCue::setStartTime(double value) 116 { 121 117 // TODO(93143): Add spec-compliant behavior for negative time values. 122 118 if (m_startTime.toDouble() == value || value < 0) … … 133 129 } 134 130 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 131 void TextTrackCue::setEndTime(double value) 132 { 143 133 // TODO(93143): Add spec-compliant behavior for negative time values. 144 134 if (m_endTime.toDouble() == value || value < 0) -
trunk/Source/WebCore/html/track/TextTrackCue.h
r204765 r207720 1 1 /* 2 * Copyright (C) 2011 Google Inc. 3 * Copyright (C) 2012, 2013, 2014 Apple Inc. 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 30 30 */ 31 31 32 #ifndef TextTrackCue_h 33 #define TextTrackCue_h 32 #pragma once 34 33 35 34 #if ENABLE(VIDEO_TRACK) 36 35 37 #include "EventTarget.h" 38 #include "HTMLElement.h" 36 #include "Document.h" 39 37 #include <wtf/MediaTime.h> 40 #include <wtf/NeverDestroyed.h>41 #include <wtf/RefCounted.h>42 38 43 39 namespace WebCore { … … 47 43 class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInlineData { 48 44 public: 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(); 56 46 57 47 TextTrack* track() const; … … 61 51 void setId(const String&); 62 52 63 MediaTime startMediaTime() const { return m_startTime; }64 53 double startTime() const { return startMediaTime().toDouble(); } 65 void setStartTime(const MediaTime&); 66 void setStartTime(double, ExceptionCode&); 54 void setStartTime(double); 67 55 68 MediaTime endMediaTime() const { return m_endTime; }69 56 double endTime() const { return endMediaTime().toDouble(); } 70 void setEndTime(const MediaTime&); 71 void setEndTime(double, ExceptionCode&); 57 void setEndTime(double); 72 58 73 59 bool pauseOnExit() const { return m_pauseOnExit; } 74 60 void setPauseOnExit(bool); 75 61 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 76 68 int cueIndex(); 77 69 void invalidateCueIndex(); 78 70 79 using EventTarget::dispatchEvent;80 bool dispatchEvent(Event&) override;81 82 71 bool isActive(); 83 72 virtual void setIsActive(bool); 84 85 EventTargetInterface eventTargetInterface() const final { return TextTrackCueEventTargetInterfaceType; }86 ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }87 73 88 74 virtual bool isOrderedBefore(const TextTrackCue*) const; … … 91 77 bool hasEquivalentStartTime(const TextTrackCue&) const; 92 78 93 enum CueType { 94 Data, 95 Generic, 96 WebVTT 97 }; 79 enum CueType { Data, Generic, WebVTT }; 98 80 virtual CueType cueType() const = 0; 99 81 virtual bool isRenderable() const { return false; } 100 82 101 enum CueMatchRules { 102 MatchAllFields, 103 IgnoreDuration, 104 }; 83 enum CueMatchRules { MatchAllFields, IgnoreDuration }; 105 84 virtual bool isEqual(const TextTrackCue&, CueMatchRules) const; 85 private: 106 86 virtual bool cueContentsMatch(const TextTrackCue&) const; 87 public: 107 88 virtual bool doesExtendCue(const TextTrackCue&) const; 108 89 … … 110 91 virtual void didChange(); 111 92 112 using RefCounted <TextTrackCue>::ref;113 using RefCounted <TextTrackCue>::deref;93 using RefCounted::ref; 94 using RefCounted::deref; 114 95 115 96 protected: … … 119 100 120 101 private: 121 122 102 void refEventTarget() final { ref(); } 123 103 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; } 124 110 125 111 String m_id; … … 140 126 141 127 #endif 142 #endif -
trunk/Source/WebCore/html/track/TextTrackCue.idl
r206723 r207720 1 1 /* 2 * Copyright (C) 2011 Google Inc. 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 [ 27 27 Conditional=VIDEO_TRACK, 28 JSCustomMarkFunction,29 28 CustomIsReachable, 30 29 CustomToJSObject, 30 JSCustomMarkFunction, 31 31 SkipVTableValidation, 32 32 ] interface TextTrackCue : EventTarget { … … 34 34 35 35 attribute DOMString id; 36 [SetterMayThrowLegacyException] attribute unrestricteddouble startTime;37 [SetterMayThrowLegacyException] attribute unrestricteddouble endTime;36 attribute double startTime; 37 attribute double endTime; 38 38 attribute boolean pauseOnExit; 39 39 … … 41 41 attribute EventHandler onexit; 42 42 }; 43 -
trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp
r197563 r207720 72 72 73 73 TextTrackCueGeneric* cue = static_cast<TextTrackCueGeneric*>(getCue()); 74 Ref Ptr<HTMLSpanElement> cueElement = cue->element();74 Ref<HTMLSpanElement> cueElement = cue->element(); 75 75 76 76 CSSValueID alignment = cue->getCSSAlignment(); … … 149 149 , m_baseFontSizeRelativeToVideoHeight(0) 150 150 , m_fontSizeMultiplier(0) 151 , m_defaultPosition(true) 152 { 153 } 154 155 PassRefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree() 151 { 152 } 153 154 Ref<VTTCueBox> TextTrackCueGeneric::createDisplayTree() 156 155 { 157 156 return TextTrackCueGenericBoxElement::create(ownerDocument(), *this); 158 157 } 159 158 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); 159 ExceptionOr<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 167 ExceptionOr<void> TextTrackCueGeneric::setPosition(double position) 168 { 169 auto result = VTTCue::setPosition(position); 170 if (!result.hasException()) 171 m_useDefaultPosition = false; 172 return result; 170 173 } 171 174 … … 183 186 if (fontSizeMultiplier()) 184 187 size *= fontSizeMultiplier() / 100; 185 displayTreeInternal() ->setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSPrimitiveValue::CSS_PX);188 displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSPrimitiveValue::CSS_PX); 186 189 187 190 LOG(Media, "TextTrackCueGeneric::setFontSize - setting cue font size to %li", lround(size)); -
trunk/Source/WebCore/html/track/TextTrackCueGeneric.h
r206538 r207720 24 24 */ 25 25 26 #ifndef TextTrackCueGeneric_h 27 #define TextTrackCueGeneric_h 26 #pragma once 28 27 29 28 #if ENABLE(VIDEO_TRACK) … … 43 42 return adoptRef(*new TextTrackCueGeneric(context, start, end, content)); 44 43 } 45 46 virtual ~TextTrackCueGeneric() { }47 44 48 PassRefPtr<VTTCueBox> createDisplayTree() override; 45 ExceptionOr<void> setLine(double) final; 46 ExceptionOr<void> setPosition(double) final; 49 47 50 void setLine(double, ExceptionCode&) override; 51 void setPosition(double, ExceptionCode&) override; 48 bool useDefaultPosition() const { return m_useDefaultPosition; } 52 49 53 bool useDefaultPosition() const { return m_defaultPosition; }54 55 50 double baseFontSizeRelativeToVideoHeight() const { return m_baseFontSizeRelativeToVideoHeight; } 56 51 void setBaseFontSizeRelativeToVideoHeight(double size) { m_baseFontSizeRelativeToVideoHeight = size; } … … 59 54 void setFontSizeMultiplier(double size) { m_fontSizeMultiplier = size; } 60 55 61 StringfontName() const { return m_fontName; }62 void setFontName( Stringname) { m_fontName = name; }56 const String& fontName() const { return m_fontName; } 57 void setFontName(const String& name) { m_fontName = name; } 63 58 64 59 const Color& foregroundColor() const { return m_foregroundColor; } 65 void setForegroundColor( Colorcolor) { m_foregroundColor = color; }60 void setForegroundColor(const Color& color) { m_foregroundColor = color; } 66 61 67 62 const Color& backgroundColor() const { return m_backgroundColor; } 68 void setBackgroundColor( Colorcolor) { m_backgroundColor = color; }63 void setBackgroundColor(const Color& color) { m_backgroundColor = color; } 69 64 70 65 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; } 74 67 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; 80 69 81 70 private: 82 bool isOrderedBefore(const TextTrackCue*) const override;83 bool isPositionedAbove(const TextTrackCue*) const override;84 85 71 TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&); 86 72 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 87 84 Color m_foregroundColor; 88 85 Color m_backgroundColor; 89 86 Color m_highlightColor; 90 double m_baseFontSizeRelativeToVideoHeight ;91 double m_fontSizeMultiplier ;87 double m_baseFontSizeRelativeToVideoHeight { 0 }; 88 double m_fontSizeMultiplier { 0 }; 92 89 String m_fontName; 93 bool m_ defaultPosition;90 bool m_useDefaultPosition { true }; 94 91 }; 95 92 … … 97 94 98 95 #endif 99 #endif -
trunk/Source/WebCore/html/track/VTTCue.cpp
r201736 r207720 293 293 } 294 294 295 PassRefPtr<VTTCueBox> VTTCue::createDisplayTree()295 Ref<VTTCueBox> VTTCue::createDisplayTree() 296 296 { 297 297 return VTTCueBox::create(ownerDocument(), *this); 298 298 } 299 299 300 VTTCueBox *VTTCue::displayTreeInternal()300 VTTCueBox& VTTCue::displayTreeInternal() 301 301 { 302 302 if (!m_displayTree) 303 303 m_displayTree = createDisplayTree(); 304 return m_displayTree.get();304 return *m_displayTree; 305 305 } 306 306 … … 326 326 } 327 327 328 void VTTCue::setVertical(const String& value, ExceptionCode& ec)328 ExceptionOr<void> VTTCue::setVertical(const String& value) 329 329 { 330 330 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical … … 342 342 direction = VerticalGrowingRight; 343 343 else 344 ec = SYNTAX_ERR;344 return Exception { SYNTAX_ERR }; 345 345 346 346 if (direction == m_writingDirection) 347 return ;347 return { }; 348 348 349 349 willChange(); 350 350 m_writingDirection = direction; 351 351 didChange(); 352 353 return { }; 352 354 } 353 355 … … 362 364 } 363 365 364 void VTTCue::setLine(double position, ExceptionCode& ec)366 ExceptionOr<void> VTTCue::setLine(double position) 365 367 { 366 368 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line 367 369 // On setting, if the text track cue snap-to-lines flag is not set, and the new 368 370 // 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 }; 373 373 374 374 // Otherwise, set the text track cue line position to the new value. 375 375 if (m_linePosition == position) 376 return ;376 return { }; 377 377 378 378 willChange(); … … 380 380 m_computedLinePosition = calculateComputedLinePosition(); 381 381 didChange(); 382 } 383 384 void VTTCue::setPosition(double position, ExceptionCode& ec) 382 383 return { }; 384 } 385 386 ExceptionOr<void> VTTCue::setPosition(double position) 385 387 { 386 388 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position 387 389 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. 388 390 // 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 394 394 // Otherwise, set the text track cue line position to the new value. 395 395 if (m_textPosition == position) 396 return ;396 return { }; 397 397 398 398 willChange(); 399 399 m_textPosition = position; 400 400 didChange(); 401 } 402 403 void VTTCue::setSize(int size, ExceptionCode& ec) 401 402 return { }; 403 } 404 405 ExceptionOr<void> VTTCue::setSize(int size) 404 406 { 405 407 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size 406 408 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError 407 409 // 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 413 413 // Otherwise, set the text track cue line position to the new value. 414 414 if (m_cueSize == size) 415 return ;415 return { }; 416 416 417 417 willChange(); 418 418 m_cueSize = size; 419 419 didChange(); 420 421 return { }; 420 422 } 421 423 … … 439 441 } 440 442 441 void VTTCue::setAlign(const String& value, ExceptionCode& ec)443 ExceptionOr<void> VTTCue::setAlign(const String& value) 442 444 { 443 445 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align … … 447 449 // agent must instead throw a SyntaxError exception. 448 450 449 CueAlignment alignment = m_cueAlignment;451 CueAlignment alignment; 450 452 if (value == startKeyword()) 451 453 alignment = Start; … … 459 461 alignment = Right; 460 462 else 461 ec = SYNTAX_ERR;463 return Exception { SYNTAX_ERR }; 462 464 463 465 if (alignment == m_cueAlignment) 464 return ;466 return { }; 465 467 466 468 willChange(); 467 469 m_cueAlignment = alignment; 468 470 didChange(); 471 472 return { }; 469 473 } 470 474 … … 787 791 } 788 792 789 VTTCueBox *VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)790 { 791 Ref Ptr<VTTCueBox> displayTree = displayTreeInternal();793 VTTCueBox& VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize) 794 { 795 Ref<VTTCueBox> displayTree = displayTreeInternal(); 792 796 if (!m_displayTreeShouldChange || !track()->isRendered()) 793 797 return displayTree.get(); … … 840 844 if (!hasDisplayTree()) 841 845 return; 842 displayTreeInternal() ->remove(ASSERT_NO_EXCEPTION);846 displayTreeInternal().remove(ASSERT_NO_EXCEPTION); 843 847 } 844 848 … … 1142 1146 1143 1147 m_displayTreeShouldChange = true; 1144 displayTreeInternal() ->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);1148 displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important); 1145 1149 } 1146 1150 -
trunk/Source/WebCore/html/track/VTTCue.h
r204466 r207720 1 1 /* 2 * Copyright (C) 2011, 2013 Google Inc. 3 * Copyright (C) 2012-2014 Apple Inc. 2 * Copyright (C) 2011, 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 30 30 */ 31 31 32 #ifndef VTTCue_h 33 #define VTTCue_h 32 #pragma once 34 33 35 34 #if ENABLE(VIDEO_TRACK) … … 91 90 92 91 const String& vertical() const; 93 void setVertical(const String&, ExceptionCode&);92 ExceptionOr<void> setVertical(const String&); 94 93 95 94 bool snapToLines() const { return m_snapToLines; } … … 97 96 98 97 double line() const { return m_linePosition; } 99 virtual void setLine(double, ExceptionCode&);98 virtual ExceptionOr<void> setLine(double); 100 99 101 100 double position() const { return m_textPosition; } 102 virtual void setPosition(double, ExceptionCode&);101 virtual ExceptionOr<void> setPosition(double); 103 102 104 103 int size() const { return m_cueSize; } 105 virtual void setSize(int, ExceptionCode&);104 ExceptionOr<void> setSize(int); 106 105 107 106 const String& align() const; 108 void setAlign(const String&, ExceptionCode&);107 ExceptionOr<void> setAlign(const String&); 109 108 110 109 const String& text() const { return m_content; } … … 124 123 125 124 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; } 128 127 129 128 void updateDisplayTree(const MediaTime&); … … 174 173 VTTCue(ScriptExecutionContext&, const WebVTTCueData&); 175 174 176 virtual PassRefPtr<VTTCueBox> createDisplayTree();177 VTTCueBox *displayTreeInternal();175 virtual Ref<VTTCueBox> createDisplayTree(); 176 VTTCueBox& displayTreeInternal(); 178 177 179 178 private: … … 231 230 232 231 #endif 233 #endif -
trunk/Source/WebCore/html/track/VTTCue.idl
r206723 r207720 1 1 /* 2 * Copyright (C) 2011 Google Inc. 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 [ 26 27 Conditional=VIDEO_TRACK, … … 30 31 JSGenerateToNativeObject, 31 32 ] interface VTTCue : TextTrackCue { 32 [SetterMayThrow LegacyException] attribute DOMString vertical;33 [SetterMayThrowException] attribute DOMString vertical; 33 34 attribute boolean snapToLines; 34 [SetterMayThrow LegacyException] attribute unrestricteddouble line;35 [SetterMayThrow LegacyException] attribute unrestricteddouble position;36 [SetterMayThrow LegacyException] attribute unrestricteddouble size;37 [SetterMayThrow LegacyException] attribute DOMString align;35 [SetterMayThrowException] attribute double line; 36 [SetterMayThrowException] attribute double position; 37 [SetterMayThrowException] attribute double size; 38 [SetterMayThrowException] attribute DOMString align; 38 39 attribute DOMString text; 39 40 DocumentFragment getCueAsHTML(); -
trunk/Source/WebCore/html/track/VTTRegion.cpp
r203322 r207720 50 50 namespace WebCore { 51 51 52 // The following valuesdefault values are defined within the WebVTT Regions Spec.52 // The default values are defined within the WebVTT Regions Spec. 53 53 // 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;67 54 68 55 // Default region line-height (vh units) … … 75 62 : ContextDestructionObserver(&context) 76 63 , 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)86 64 , m_scrollTimer(*this, &VTTRegion::scrollTimerFired) 87 65 { … … 102 80 } 103 81 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 82 ExceptionOr<void> VTTRegion::setWidth(double value) 83 { 84 if (!(value >= 0 && value <= 100)) 85 return Exception { INDEX_SIZE_ERR }; 116 86 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 90 ExceptionOr<void> VTTRegion::setHeight(int value) 91 { 92 if (value < 0) 93 return Exception { INDEX_SIZE_ERR }; 126 94 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 98 ExceptionOr<void> VTTRegion::setRegionAnchorX(double value) 99 { 100 if (!(value >= 0 && value <= 100)) 101 return Exception { INDEX_SIZE_ERR }; 141 102 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 106 ExceptionOr<void> VTTRegion::setRegionAnchorY(double value) 107 { 108 if (!(value >= 0 && value <= 100)) 109 return Exception { INDEX_SIZE_ERR }; 156 110 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 114 ExceptionOr<void> VTTRegion::setViewportAnchorX(double value) 115 { 116 if (!(value >= 0 && value <= 100)) 117 return Exception { INDEX_SIZE_ERR }; 171 118 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 122 ExceptionOr<void> VTTRegion::setViewportAnchorY(double value) 123 { 124 if (!(value >= 0 && value <= 100)) 125 return Exception { INDEX_SIZE_ERR }; 186 126 m_viewportAnchor.setY(value); 127 return { }; 128 } 129 130 static const AtomicString& upKeyword() 131 { 132 static NeverDestroyed<const AtomicString> upKeyword("up", AtomicString::ConstructFromLiteral); 133 return upKeyword; 187 134 } 188 135 189 136 const AtomicString& VTTRegion::scroll() const 190 137 { 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 141 ExceptionOr<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 154 void 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; 220 161 } 221 162 … … 269 210 void VTTRegion::parseSettingValue(RegionSetting setting, VTTScanner& input) 270 211 { 271 static NeverDestroyed<const AtomicString> scrollUpValueKeyword("up", AtomicString::ConstructFromLiteral);272 273 212 VTTScanner::Run valueRun = input.collectUntil<isHTMLSpace<UChar>>(); 274 213 … … 313 252 } 314 253 case Scroll: 315 if (input.scanRun(valueRun, scrollUpValueKeyword.get()))254 if (input.scanRun(valueRun, upKeyword())) 316 255 m_scroll = true; 317 256 else … … 346 285 } 347 286 348 void VTTRegion::appendTextTrackCueBox( PassRefPtr<VTTCueBox>displayBox)287 void VTTRegion::appendTextTrackCueBox(Ref<VTTCueBox>&& displayBox) 349 288 { 350 289 ASSERT(m_cueContainer); 351 290 352 if (m_cueContainer->contains(displayBox. get()))291 if (m_cueContainer->contains(displayBox.ptr())) 353 292 return; 354 293 355 m_cueContainer->appendChild( *displayBox, ASSERT_NO_EXCEPTION);294 m_cueContainer->appendChild(displayBox, ASSERT_NO_EXCEPTION); 356 295 displayLastTextTrackCueBox(); 357 296 } … … 406 345 { 407 346 if (!m_regionDisplayTree) { 408 m_regionDisplayTree = HTMLDivElement::create( *ownerDocument());347 m_regionDisplayTree = HTMLDivElement::create(downcast<Document>(*m_scriptExecutionContext)); 409 348 prepareRegionDisplayTree(); 410 349 } … … 448 387 // The cue container is used to wrap the cues and it is the object which is 449 388 // 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)); 451 390 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, 0.0f, CSSPrimitiveValue::CSS_PX); 452 391 -
trunk/Source/WebCore/html/track/VTTRegion.h
r203322 r207720 1 1 /* 2 * Copyright (C) 2013 Google Inc. 3 * Copyright (C) 2014 Apple Inc. 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 30 30 */ 31 31 32 #ifndef VTTRegion_h 33 #define VTTRegion_h 32 #pragma once 34 33 35 34 #if ENABLE(VIDEO_TRACK) 36 35 37 36 #include "ContextDestructionObserver.h" 38 #include "Document.h"39 37 #include "FloatPoint.h" 40 38 #include "TextTrack.h" 41 #include <wtf/RefCounted.h>42 39 43 40 namespace WebCore { … … 63 60 64 61 double width() const { return m_width; } 65 void setWidth(double, ExceptionCode&);62 ExceptionOr<void> setWidth(double); 66 63 67 longheight() const { return m_heightInLines; }68 void setHeight(long, ExceptionCode&);64 int height() const { return m_heightInLines; } 65 ExceptionOr<void> setHeight(int); 69 66 70 67 double regionAnchorX() const { return m_regionAnchor.x(); } 71 void setRegionAnchorX(double, ExceptionCode&);68 ExceptionOr<void> setRegionAnchorX(double); 72 69 73 70 double regionAnchorY() const { return m_regionAnchor.y(); } 74 void setRegionAnchorY(double, ExceptionCode&);71 ExceptionOr<void> setRegionAnchorY(double); 75 72 76 73 double viewportAnchorX() const { return m_viewportAnchor.x(); } 77 void setViewportAnchorX(double, ExceptionCode&);74 ExceptionOr<void> setViewportAnchorX(double); 78 75 79 76 double viewportAnchorY() const { return m_viewportAnchor.y(); } 80 void setViewportAnchorY(double, ExceptionCode&);77 ExceptionOr<void> setViewportAnchorY(double); 81 78 82 79 const AtomicString& scroll() const; 83 void setScroll(const AtomicString&, ExceptionCode&);80 ExceptionOr<void> setScroll(const AtomicString&); 84 81 85 void updateParametersFromRegion( VTTRegion*);82 void updateParametersFromRegion(const VTTRegion&); 86 83 87 84 const String& regionSettings() const { return m_settings; } … … 92 89 HTMLDivElement& getDisplayTree(); 93 90 94 void appendTextTrackCueBox( PassRefPtr<VTTCueBox>);91 void appendTextTrackCueBox(Ref<VTTCueBox>&&); 95 92 void displayLastTextTrackCueBox(); 96 93 void willRemoveTextTrackCueBox(VTTCueBox*); … … 98 95 private: 99 96 VTTRegion(ScriptExecutionContext&); 100 101 Document* ownerDocument() { return downcast<Document>(m_scriptExecutionContext); }102 97 103 98 void prepareRegionDisplayTree(); … … 129 124 String m_settings; 130 125 131 double m_width ;132 unsigned m_heightInLines ;126 double m_width { 100 }; 127 unsigned m_heightInLines { 3 }; 133 128 134 FloatPoint m_regionAnchor ;135 FloatPoint m_viewportAnchor ;129 FloatPoint m_regionAnchor { 0, 100 }; 130 FloatPoint m_viewportAnchor { 0, 100 }; 136 131 137 bool m_scroll ;132 bool m_scroll { false }; 138 133 139 134 // The cue container is the container that is scrolled up to obtain the … … 146 141 // is cleared in the TextTrack destructor and it is generally 147 142 // set/reset within the addRegion and removeRegion methods. 148 TextTrack* m_track ;143 TextTrack* m_track { nullptr }; 149 144 150 145 // Keep track of the current numeric value of the css "top" property. 151 double m_currentTop ;146 double m_currentTop { 0 }; 152 147 153 148 // The timer is used to display the next cue line after the current one has … … 162 157 163 158 #endif 164 #endif -
trunk/Source/WebCore/html/track/VTTRegion.idl
r206723 r207720 1 1 /* 2 * Copyright (C) 2013 Google Inc. 3 * Copyright (C) 2014 Apple Inc. 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 27 27 [ 28 28 Conditional=VIDEO_TRACK, 29 Constructor(), 30 ConstructorCallWith=ScriptExecutionContext, 29 31 JSGenerateToNativeObject, 30 Constructor(),31 ConstructorCallWith=ScriptExecutionContext32 32 ] interface VTTRegion { 33 33 readonly attribute TextTrack track; 34 34 35 35 attribute DOMString id; 36 [SetterMayThrow LegacyException] attribute unrestricteddouble width;37 [SetterMayThrow LegacyException] attribute long height;38 [SetterMayThrow LegacyException] attribute unrestricteddouble regionAnchorX;39 [SetterMayThrow LegacyException] attribute unrestricteddouble regionAnchorY;40 [SetterMayThrow LegacyException] attribute unrestricteddouble viewportAnchorX;41 [SetterMayThrow LegacyException] attribute unrestricteddouble viewportAnchorY;42 [SetterMayThrow LegacyException] 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; 43 43 }; 44
Note: See TracChangeset
for help on using the changeset viewer.