Remove PassRefPtr use from the "html" directory, other improvements
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jan 2017 06:45:48 +0000 (06:45 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jan 2017 06:45:48 +0000 (06:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166635

Reviewed by Alex Christensen.

Source/WebCore:

* CMakeLists.txt: Removed the duplicate copies of all the WebGL-specific files
in the main list of source files; there is no value in listing them twice.
Replaced WebGLGetInfo.cpp with WebGLAny.cpp.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::removeSourceBuffer): Updates since the tracks functions
return references now.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime): Removed
unneeded SourceBufferPrivate* argument.
(WebCore::SourceBuffer::appendBufferTimerFired): Ditto.
(WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): Ditto.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveRenderingError): Ditto.
(WebCore::SourceBuffer::videoTracks): Return a reference rather than a pointer.
(WebCore::SourceBuffer::audioTracks): Ditto.
(WebCore::SourceBuffer::textTracks): Ditto.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
Removed unneeded SourceBufferPrivate* argument.
(WebCore::SourceBuffer::validateInitializationSegment): Updated since tracks
functions now return a pointer.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Removed unneeded
SourceBufferPrivate* argument.
(WebCore::SourceBuffer::sourceBufferPrivateHasAudio): Ditto.
(WebCore::SourceBuffer::sourceBufferPrivateHasVideo): Ditto.
(WebCore::SourceBuffer::videoTrackSelectedChanged): Take a reference rather than
a pointer.
(WebCore::SourceBuffer::audioTrackEnabledChanged): Ditto.
(WebCore::SourceBuffer::textTrackModeChanged): Ditto.
(WebCore::SourceBuffer::textTrackAddCue): Ditto.
(WebCore::SourceBuffer::textTrackAddCues): Ditto.
(WebCore::SourceBuffer::textTrackRemoveCue): Ditto.
(WebCore::SourceBuffer::textTrackRemoveCues): Ditto.
(WebCore::SourceBuffer::textTrackKindChanged): Ditto.
(WebCore::SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples): Ditto.
(WebCore::SourceBuffer::provideMediaData): Ditto.
(WebCore::SourceBuffer::reenqueueMediaForTime): Ditto.
* Modules/mediasource/SourceBuffer.h: Updated for above changes.

* WebCore.xcodeproj/project.pbxproj: Replaced WebGLGetInfo with WebGLAny.

* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::toHTMLCanvasStyle): Removed explicit cast to CanvasStyle and unneeded
conversion to a pointer since CanvasStyle constructors now take references.

* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginInstance): Updated since bindingsInstance now returns a raw pointer.
(WebCore::pluginScriptObject): Ditto.

* bindings/js/JSWebGL2RenderingContextCustom.cpp:
(WebCore::toJS): Moved to WebGLAny.h/cpp.
(WebCore::JSWebGL2RenderingContext::getIndexedParameter): Updated since the toJS
function in WebGLAny.h takes references, not pointers.

* bindings/js/JSWebGLRenderingContextBaseCustom.cpp: Removed quite a few unneeded
includes and got rid of a lot of unneeded JSC prefixes.
(WebCore::toJS): Moved to WebGLAny.h/cpp.
(WebCore::toJSNewlyCreated):
(WebCore::objectParameter): Renamed from getObjectParameter and also changed to
take a pointer to member function so we don't need an enum and a switch statement.
(WebCore::toJS): Changed to take references rather than pointers.
(WebCore::JSWebGLRenderingContextBase::getAttachedShaders): Use a modern for loop.
(WebCore::JSWebGLRenderingContextBase::getBufferParameter): Use objectParameter.
(WebCore::JSWebGLRenderingContextBase::getRenderbufferParameter): Ditto.
(WebCore::JSWebGLRenderingContextBase::getVertexAttrib): Ditto.
(WebCore::toNumberVector): Renamed from toVector, since this is specifically for
vectors of numbers. Use uncheckedAppend instead of assignment.
(WebCore::functionForUniform): Marked this inline.
(WebCore::dataFunctionf): Updated for above changes.
(WebCore::dataFunctioni): Ditto.
(WebCore::dataFunctionMatrix): Ditto.

* bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::fetch): Moved assertions to the top of the function.
Also added a FIXME because it's unclear why these assertions are correct. Updated
to use downcastScriptElement instead of toScriptElementIfPossible.

* dom/Document.h: Sorted list of forward-declared classes. Removed duplicate
forward declaration of ScriptModuleLoader.

* dom/PendingScript.cpp:
(WebCore::PendingScript::create): Take a ScriptElement instead of an Element.
(WebCore::PendingScript::PendingScript): Ditto.
(WebCore::PendingScript::loadableScript): Moved inline to header and made inline.
(WebCore::PendingScript::setClient): Take a reference instead of a pointer.
* dom/PendingScript.h: UPdated for above changes.

* dom/ScriptElement.cpp:
(WebCore::ScriptElement::prepareScript): Pass a reference instead of a pointer.
(WebCore::ScriptElement::ref): Added. Forwards ref/deref to the underlying element
so we can use Ref and RefPtr with this class.
(WebCore::ScriptElement::deref): Ditto.
(WebCore::isScriptElement): Added. Replaces one of the two uses of
toScriptElementIfPossible, and is similar in style to is<Element>.
(WebCore::downcastScriptElement): Ditto, but for downcast.
* dom/ScriptElement.h: Updated for above changes.

* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::queueScriptForExecution): Take reference rather than
pointer, and pass ScriptElement rather than Element.
(WebCore::ScriptRunner::notifyFinished): Ditto.
(WebCore::ScriptRunner::timerFired): Ditto.
* dom/ScriptRunner.h: Updated for above changes.

* html/FileInputType.cpp:
(WebCore::FileInputType::files): Updated since m_fileList is a Ref.
(WebCore::FileInputType::createFileList): Updated to return a Ref instead of
a PassRefPtr. Also use reserveInitialCapacity/uncheckedAppend.
(WebCore::FileInputType::requestIcon): Updated since the updateRendering
function is now called iconLoaded. Also use references instead of pointers.
(WebCore::FileInputType::setFiles): Take a RefPtr&& insted of a PassRefPtr.
Also put some conditional code inside an #if.
(WebCore::FileInputType::filesChosen): Updated for function name change.
(WebCore::FileInputType::iconLoaded): Renamed from updateRendering.
Changed argument to RefPtr&& from PassRefPtr.
(WebCore::FileInputType::defaultToolTip): Got rid of unneeded local variable
and used the correct type, unsigned, rather than size_t.
* html/FileInputType.h: Updated for the above changes, use final instead
of override, and use Ref instead of RefPtr.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::form): Renamed from virtualForm.
* html/HTMLElement.h: Replaced the form/virtualForm pair of functions with
just a form function. The old design dates back before we had "final" for
virtual functions, and now we can just use that instead.

* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::virtualForm): Deleted.
* html/HTMLFormControlElement.h: Mark the form function final, since it's
now both an inline function in this class, and an override of a virtual
function inherited from the base class. Deleted the virtualForm function.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler): Removed use of the
formForSubmission function, which was just another way to get the same
thing as the form function; perhaps they were different in the past.
(WebCore::HTMLInputElement::setFiles): Take a RefPtr&& rather than a PassRefPtr.
* html/HTMLInputElement.h: Updated for the above.

* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::control): Made this const.
(WebCore::HTMLLabelElement::form): Made this const, so it can be used to
override the const form function from the base class.
* html/HTMLLabelElement.h: Marked the form function final, since we want it
to override the form function inherited from HTMLElement.

* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::form): Renamed from virtualForm.
* html/HTMLLegendElement.h: Override form instead of virtualForm and mark it final
This makes things more efficient if someone calls form directly on this class;
before it would make an unnecessary virtual function call.

* html/HTMLMediaElement.cpp:
(WebCore::TrackDisplayUpdateScope::TrackDisplayUpdateScope): Take a reference
rather than a pointer.
(WebCore::TrackDisplayUpdateScope::~TrackDisplayUpdateScope): Ditto.
(WebCore::eventTimeCueCompare): Compare the cues the same way the cue list would
rather than using cueIndex.
(WebCore::HTMLMediaElement::audioTrackEnabledChanged): Take a reference.
(WebCore::HTMLMediaElement::textTrackModeChanged): Ditto.
(WebCore::HTMLMediaElement::videoTrackSelectedChanged): Ditto.
(WebCore::HTMLMediaElement::textTrackKindChanged): Ditto.
(WebCore::HTMLMediaElement::textTrackAddCues): Ditto.
(WebCore::HTMLMediaElement::textTrackRemoveCues): Ditto.
(WebCore::HTMLMediaElement::textTrackAddCue): Ditto.
(WebCore::HTMLMediaElement::textTrackRemoveCue): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack): Pass references.
(WebCore::HTMLMediaElement::mediaPlayerDidAddTextTrack): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidAddVideoTrack): Ditto.
(WebCore::HTMLMediaElement::removeTextTrack): Ditto.
(WebCore::HTMLMediaElement::forgetResourceSpecificTracks): Ditto.
(WebCore::HTMLMediaElement::setController): Take a RefPtr&& instead of PassRefPtr.
* html/HTMLMediaElement.h: Updated for above changes.

* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::virtualForm): Deleted.
* html/HTMLObjectElement.h: Made the form function inline and final, which
achieves the same thing we did before with using, but without requiring the
separate virtualForm function, now deleted.

* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::collectOptionInnerText): Use isScriptElement
instead of toScriptElementIfPossible.

* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::bindingsInstance): Renamed from getInstance and
changed the return type to a raw pointer.
* html/HTMLPlugInElement.h: Updated for the above changes. Also changed the
updateSnapshot function to take a raw pointer instead of a PassRefPtr.

* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::createElementRenderer): Pass a pointer
to updateSnapshot.
(WebCore::HTMLPlugInImageElement::updateSnapshot): Updated to take a raw
pointer instead of a PassRefPtr.
* html/HTMLPlugInImageElement.h: Updated for above changes.

* html/HTMLScriptElement.h: Added using to resolve the ambiguity with the
ref/deref from HTMLElement and from ScriptElement.

* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::selection): Return a RefPtr instead
of a PassRefPtr.
* html/HTMLTextFormControlElement.h: Updated for above changes.

* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::textTrackKindChanged): Take a reference.
(WebCore::HTMLTrackElement::textTrackModeChanged): Ditto.
(WebCore::HTMLTrackElement::textTrackAddCues): Ditto.
(WebCore::HTMLTrackElement::textTrackRemoveCues): Ditto.
(WebCore::HTMLTrackElement::textTrackAddCue): Ditto.
(WebCore::HTMLTrackElement::textTrackRemoveCue): Ditto.
* html/HTMLTrackElement.h: Updated for above changes.

* html/InputType.cpp:
(WebCore::InputType::formForSubmission): Deleted.
(WebCore::InputType::setFiles): Take a RefPtr&& instead of a PassRefPtr.
* html/InputType.h: Updated for above changes.

* html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure): Pass a reference.
(WebCore::PluginDocument::setPluginElement): Take a reference rather than
a PassRefPtr.
* html/PluginDocument.h: Updated for above changes.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setStrokeStyle): Pass a reference.
(WebCore::CanvasRenderingContext2D::setFillStyle): Ditto.
(WebCore::CanvasRenderingContext2D::drawTextInternal): Ditto.

* html/canvas/CanvasStyle.cpp:
(WebCore::CanvasStyle::CanvasStyle): Rewrite all constructors to use the
m_style variant instead of separate m_type and other data members. Also
change from PassRefPtr to a reference.
(WebCore::CanvasStyle::createFromString): Update to use the variant.
(WebCore::CanvasStyle::createFromStringWithOverrideAlpha): Ditto.
(WebCore::CanvasStyle::isEquivalentColor): Ditto.
(WebCore::CanvasStyle::isEquivalentRGBA): Ditto.
(WebCore::CanvasStyle::isEquivalentCMYKA): Ditto.
(WebCore::CanvasStyle::CanvasStyle): Deleted copy constructor; the compiler
can now generate a correct copy or move constructor.
(WebCore::CanvasStyle::~CanvasStyle): Deleted. Compiler generates this
properly now without help from us.
(WebCore::CanvasStyle::operator=): Deleted. The compiler can now generate
a correct copy of move assignment operator.
(WebCore::CanvasStyle::applyStrokeColor): Updated to take a reference and
use the variant.
(WebCore::CanvasStyle::applyFillColor): Ditto.

* html/canvas/CanvasStyle.h: Redid this class to use a variant instead of
a type enumeration and a union.

* html/canvas/OESVertexArrayObject.cpp:
(WebCore::OESVertexArrayObject::createVertexArrayOES): Updated use of enum
since it's now an enum class.

* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::WebGL2RenderingContext): Use Ref&& instead of
RefPtr&& for the GraphicsContext3D.
(WebCore::WebGL2RenderingContext::initializeVertexArrayObjects): Updated enum
and also use references.
(WebCore::WebGL2RenderingContext::getInternalformatParameter): Use nullptr to
return null rather than the old idiom (default-constructed WebGLGetInfo).
(WebCore::WebGL2RenderingContext::texStorage2D): Ditto.
(WebCore::WebGL2RenderingContext::getQueryParameter): Ditto.
(WebCore::WebGL2RenderingContext::getSamplerParameter): Ditto.
(WebCore::WebGL2RenderingContext::getSyncParameter): Ditto.
(WebCore::WebGL2RenderingContext::getIndexedParameter): Ditto.
(WebCore::WebGL2RenderingContext::getActiveUniformBlockParameter): Ditto.
(WebCore::WebGL2RenderingContext::getActiveUniformBlockName): Ditto.
(WebCore::WebGL2RenderingContext::createVertexArray): Updated enum and also
use reference.
(WebCore::WebGL2RenderingContext::getExtension): Rearranged logic in three ways:
(1) Moved checks for whether an extension is supported inside the case for that
extension, rather than combining the extension name check with the extensions
enabled check. (2) Used the new enableSupportedExtension function to simplify
many of the checks to avoid repeating the extension name twice. (3) Changed the
idiom so we set the pointers to nullptr explicitly, preparing for a future where
we might make the extension pointers use std::optional so we can cache a negative
for each extension too, not just a positive result.
(WebCore::WebGL2RenderingContext::getSupportedExtensions): Use ASCIILiteral.
(WebCore::WebGL2RenderingContext::getFramebufferAttachmentParameter): Use nullptr
as above. For non-null types, return the object without converting, letting the
WebGLAny class handle things, except for enumerations, which we need to explicitly
static_cast to an integral type, and things that will be stored in the variant in
a RefPtr, where we use makeRefPtr.
(WebCore::WebGL2RenderingContext::validateFramebufferFuncParameters):
Simplified and clarified the handling of COLOR_ATTACHMENT.
(WebCore::WebGL2RenderingContext::getParameter): Return WebGLAny, same idiom as
described above for getFramebufferAttachmentParameter.
* html/canvas/WebGL2RenderingContext.h: Updated for above changes.

* html/canvas/WebGLAny.cpp: Added.
(WebCore::toJS): Handles conversion to JavaScript types. This function is based
on the existing toJS functions from the two classes that were using WebGLGetInfo.
Eventually we can probably just get the bindings to automatically generate this,
but there is some work to do to get to that point.
* html/canvas/WebGLAny.h: Added. This type, a variant, replaces the WebGLGetInfo
class. Also includes the toJS function, which is the real point of this type, since
it's about returning a variant mapped appropriately to JavaScript types.

* html/canvas/WebGLContextGroup.cpp:
(WebCore::WebGLContextGroup::getAGraphicsContext3D): Changed to return a reference.
Droped unnecessary local variable with a long type name.
(WebCore::WebGLContextGroup::addContext): Take a reference.
(WebCore::WebGLContextGroup::removeContext): Ditto.
(WebCore::WebGLContextGroup::removeObject): Ditto.
(WebCore::WebGLContextGroup::addObject): Ditto.
(WebCore::WebGLContextGroup::detachAndRemoveAllObjects): Dropped unnecessary
local variable with a long type name.
* html/canvas/WebGLContextGroup.h: Updated for above changes.

* html/canvas/WebGLContextObject.cpp:
(WebCore::WebGLContextObject::~WebGLContextObject): Pass references.
(WebCore::WebGLContextObject::detachContext): Ditto.

* html/canvas/WebGLGetInfo.cpp: Removed.
* html/canvas/WebGLGetInfo.h: Removed.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::WebGLRenderingContext): Take a Ref&& instead
of as PassRefPtr.
(WebCore::WebGLRenderingContext::initializeVertexArrayObjects): Updated enum
and also use references.
(WebCore::WebGLRenderingContext::getExtension): Rearranged logic in three ways:
(1) Moved checks for whether an extension is supported inside the case for that
extension, rather than combining the extension name check with the extensions
enabled check. (2) Used the new enableSupportedExtension function to simplify
many of the checks to avoid repeating the extension name twice. (3) Changed the
idiom so we set the pointers to nullptr explicitly, preparing for a future where
we might make the extension pointers use std::optional so we can cache a negative
for each extension too, not just a positive result.
(WebCore::WebGLRenderingContext::getSupportedExtensions): Use ASCIILiteral.
(WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): Use nullptr
as above. For non-null types, return the object without converting, letting the
WebGLAny class handle things, except for enumerations, which we need to explicitly
static_cast to an integral type, and things that will be stored in the variant in
a RefPtr, where we use makeRefPtr.
(WebCore::WebGLRenderingContext::validateFramebufferFuncParameters):
Simplified and clarified the handling of COLOR_ATTACHMENT adding a FIXME about
something questionable.
(WebCore::WebGLRenderingContext::getParameter): Return WebGLAny, same idiom as
described above for getFramebufferAttachmentParameter.
* html/canvas/WebGLRenderingContext.h: Updated for above changes.

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::create): Updated to pass references
instead of pointers in a couple cases
(WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase): Changed graphics
context argument type from RefPtr&& to Ref&&. Also moved initialization of scalars
from the constructor to the class definition.
(WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase): Pass a reference.
(WebCore::WebGLRenderingContextBase::createBuffer): Pass a reference instead of a pointer.
(WebCore::WebGLRenderingContextBase::createFramebuffer): Ditto.
(WebCore::WebGLRenderingContextBase::createTexture): Ditto.
(WebCore::WebGLRenderingContextBase::createProgram): Ditto.
(WebCore::WebGLRenderingContextBase::createRenderbuffer): Ditto.
(WebCore::WebGLRenderingContextBase::createShader): Ditto.
(WebCore::WebGLRenderingContextBase::deleteBuffer): Ditto.
(WebCore::WebGLRenderingContextBase::getBufferParameter): Update to use WebGLAny.
(WebCore::WebGLRenderingContextBase::getProgramParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getRenderbufferParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getShaderParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getTexParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getUniform): Ditto.
(WebCore::WebGLRenderingContextBase::getVertexAttrib): Ditto.
(WebCore::WebGLRenderingContextBase::getVertexAttribOffset): Removed unnneed
type casts.
(WebCore::WebGLRenderingContextBase::vertexAttribPointer): Pass a reference.
(WebCore::WebGLRenderingContextBase::removeSharedObject): Take a reference.
(WebCore::WebGLRenderingContextBase::addSharedObject): Ditto.
(WebCore::WebGLRenderingContextBase::removeContextObject): Ditto.
(WebCore::WebGLRenderingContextBase::addContextObject): Ditto.
(WebCore::WebGLRenderingContextBase::getBooleanParameter): Changed return type;
connversion to WebGLAny can happen at the point of use.
(WebCore::WebGLRenderingContextBase::getBooleanArrayParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getFloatParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getIntParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getUnsignedIntParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getInt64Parameter): Ditto.
(WebCore::WebGLRenderingContextBase::getWebGLFloatArrayParameter): Ditto.
(WebCore::WebGLRenderingContextBase::getWebGLIntArrayParameter): Ditto.
(WebCore::WebGLRenderingContextBase::validateBufferDataParameters): Use
optional to simplify logic and get rid of a boolean.
(WebCore::WebGLRenderingContextBase::enableSupportedExtension): Added.
Helper used by the getExtension functions.
* html/canvas/WebGLRenderingContextBase.h: Updated for the above changes.
Also changed setBoundVertexArrayObject to take a raw pointer instead of
as PassRefPtr.

* html/canvas/WebGLSharedObject.cpp:
(WebCore::WebGLSharedObject::~WebGLSharedObject): Pass a reference.
(WebCore::WebGLSharedObject::detachContextGroup): Ditto.
(WebCore::WebGLSharedObject::getAGraphicsContext3D): Updated since the
underlying getAGraphicsContext3D function now returns a reference.

* html/canvas/WebGLSharedObject.h: Removed many unused "is" virtual functions.
* html/canvas/WebGLTransformFeedback.h: Ditto.

* html/canvas/WebGLVertexArrayObject.cpp:
(WebCore::WebGLVertexArrayObject::create): Updated for new type enumeration.
(WebCore::WebGLVertexArrayObject::WebGLVertexArrayObject): Ditto.
(WebCore::WebGLVertexArrayObject::deleteObjectImpl): Ditto.
* html/canvas/WebGLVertexArrayObject.h: Updated for above changes.

* html/canvas/WebGLVertexArrayObjectBase.cpp:
(WebCore::WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase): Updated for new
type enumeration and moved initialization to class definition.
(WebCore::WebGLVertexArrayObjectBase::setElementArrayBuffer): Changed argument to
raw pointer instead of PassRefPtr.
(WebCore::WebGLVertexArrayObjectBase::setVertexAttribState): Changed argument to
reference instead of PassRefPtr.
(WebCore::WebGLVertexArrayObjectBase::unbindBuffer): Changed arugment type to
reference instead of PassRefPtr.
(WebCore::WebGLVertexArrayObjectBase::setVertexAttribDivisor): Removed unneeded
local variable.
* html/canvas/WebGLVertexArrayObjectBase.h: Updated for above changes.
Replaced VAOType with Type. Used class member initialization.

* html/canvas/WebGLVertexArrayObjectOES.cpp:
(WebCore::WebGLVertexArrayObjectOES::create): Updated for new type enumeration.
(WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES): Ditto.
(WebCore::WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES) Ditto.:
(WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl): Ditto.
* html/canvas/WebGLVertexArrayObjectOES.h: Updated for above changes.

* html/forms/FileIconLoader.cpp:
(WebCore::FileIconLoader::iconLoaded): Renamed from notifyFinished. Also changed
the name of the function this calls to iconLoaded. Changed the arguemnt to
RefPtr&& instead of PassRefPtr.
* html/forms/FileIconLoader.h: Updated for above changes.

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::attachLater): Use isScriptElement instead of
toScriptElementIfPossible.
(WebCore::HTMLConstructionSite::insertForeignElement): Ditto.

* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Pass script
element as a Ref rather than RefPtr.
(WebCore::HTMLDocumentParser::watchForLoad): Pass a reference instead of a pointer.

* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::executeParsingBlockingScript): Deleted. Moved the code
into the single call site, execute ParsingBlockingScripts.
(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): Changed argument
type to a reference from a RefPtr; this funtion was not taking ownership. Also remove
call to toScriptElementIfPossible,
since pending scripts now contains script elements already.
(WebCore::HTMLScriptRunner::execute): Changed argument type to Ref<ScriptElement>&&
from PassRefPtr<Element>.
(WebCore::HTMLScriptRunner::executeParsingBlockingScripts): Moved code here from
executeParsingBlockingScript. Also pass a reference.
(WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing): Pass a reference.
(WebCore::requestPendingScript): Changed argument type to ScriptElement& from
Element*.
(WebCore::HTMLScriptRunner::requestParsingBlockingScript): Ditto.
(WebCore::HTMLScriptRunner::requestDeferredScript): Ditto.
(WebCore::HTMLScriptRunner::runScript): Ditto.
* html/parser/HTMLScriptRunner.h: Updated for above changes.

* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::takeScriptToProcess): Changed return type from
RefPtr<Element> to RefPtr<ScriptElement>.
(WebCore::HTMLTreeBuilder::processEndTag): Downcast the script element to
HTMLScriptElement so we can store it as a ScriptElement.
(WebCore::HTMLTreeBuilder::processTokenInForeignContent): Downcast the script
element to SVGScriptElement so we can store it as a script element.
* html/parser/HTMLTreeBuilder.h: Updated for above changes. Changed the type
of m_scriptToProcess to RefPtr<ScriptElement>.

* html/parser/TextDocumentParser.cpp: Added now-needed include.

* html/parser/XSSAuditorDelegate.cpp:
(WebCore::XSSAuditorDelegate::generateViolationReport): Changed return type
to Ref from PassRefPtr.
* html/parser/XSSAuditorDelegate.h: Updated for above.

* html/track/AudioTrack.cpp:
(WebCore::AudioTrack::AudioTrack): Take references.
(WebCore::AudioTrack::setPrivate): Ditto.
(WebCore::AudioTrack::setEnabled): Removed redundant code to do what the
private setEnabled function is already going to do.
(WebCore::AudioTrack::inbandTrackIndex): Removed assertion since m_private
is now a Ref rather than RefPtr.
(WebCore::AudioTrack::enabledChanged): Added an early exit so we will only
call audioTrackEnabledChanged if m_enabled is actually changing. Also removed
the unneeded track private argument.
(WebCore::AudioTrack::idChanged): Ditto.
(WebCore::AudioTrack::labelChanged): Ditto.
(WebCore::AudioTrack::languageChanged): Ditto.
(WebCore::AudioTrack::willRemove): Ditto.
* html/track/AudioTrack.h: Updated for above changes.

* html/track/InbandDataTextTrack.cpp:
(WebCore::InbandDataTextTrack::addDataCue): Removed inband text track private
argument. Use contains instead of find/end.
(WebCore::InbandDataTextTrack::updateDataCue): Ditto. Use get instead of find/end.
(WebCore::InbandDataTextTrack::removeDataCue): Ditto.
* html/track/InbandDataTextTrack.h: Updated for above changes.

* html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::InbandGenericTextTrack): Take references.
(WebCore::InbandGenericTextTrack::create): Ditto.
(WebCore::InbandGenericTextTrack::updateCueFromCueData): Ditto.
(WebCore::InbandGenericTextTrack::addGenericCue): Ditto. Also removed unused
track private argument.
(WebCore::InbandGenericTextTrack::updateGenericCue): Ditto.
(WebCore::InbandGenericTextTrack::removeGenericCue): Ditto.
(WebCore::InbandGenericTextTrack::parseWebVTTCueData): Ditto.
(WebCore::InbandGenericTextTrack::parseWebVTTFileHeader): Ditto.
(WebCore::InbandGenericTextTrack::newRegionsParsed): Pass a reference.
* html/track/InbandGenericTextTrack.h: Updated for above changes.

* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::create): Return a Ref instead of a PassRefPtr. Take
references.
(WebCore::InbandTextTrack::InbandTextTrack): Ditto.
(WebCore::InbandTextTrack::setPrivate): Take a reference instead of a PassRefPtr.
(WebCore::InbandTextTrack::isClosedCaptions): Removed check for null since m_private
is now a Ref and so never null.
(WebCore::InbandTextTrack::isSDH): Ditto.
(WebCore::InbandTextTrack::containsOnlyForcedSubtitles): Ditto.
(WebCore::InbandTextTrack::isMainProgramContent): Ditto.
(WebCore::InbandTextTrack::isEasyToRead): Ditto.
(WebCore::InbandTextTrack::inbandTrackIndex): Ditto.
(WebCore::InbandTextTrack::inBandMetadataTrackDispatchType): Ditto.
(WebCore::InbandTextTrack::idChanged): Removed unneeded track private argument.
(WebCore::InbandTextTrack::labelChanged): Ditto.
(WebCore::InbandTextTrack::languageChanged): Ditto.
(WebCore::InbandTextTrack::willRemove): Ditto.
(WebCore::InbandTextTrack::updateKindFromPrivate): Improved switch statement
by removing default so we get a warning if we forget to handle a kind value.
(WebCore::InbandTextTrack::startTimeVariance): Removed check for null.
* html/track/InbandTextTrack.h: Updated for above changes. Changed m_private from
a RefPtr to a Ref.

* html/track/InbandWebVTTTextTrack.cpp:
(WebCore::InbandWebVTTTextTrack::InbandWebVTTTextTrack): Take references.
(WebCore::InbandWebVTTTextTrack::create): Ditto.
(WebCore::InbandWebVTTTextTrack::parseWebVTTCueData): Removed unneeded track
private arguemnt.
(WebCore::InbandWebVTTTextTrack::newRegionsParsed): Pass a reference.
* html/track/InbandWebVTTTextTrack.h: Updated for above changes.

* html/track/LoadableTextTrack.cpp:
(WebCore::LoadableTextTrack::newCuesAvailable): Pass references.
(WebCore::LoadableTextTrack::newRegionsAvailable): Ditto.

* html/track/TextTrack.cpp:
(WebCore::TextTrack::~TextTrack): Use references.
(WebCore::TextTrack::setKind): Ditto.
(WebCore::TextTrack::setMode): Ditto.
(WebCore::TextTrack::removeAllCues): Ditto.
(WebCore::TextTrack::activeCues): Ditto.
(WebCore::TextTrack::addCue): Ditto.
(WebCore::TextTrack::removeCue): Removed unneeded code to handle a cue
that points to a track but is not in that track. Added a call to
setIsActive(false) here instead of having the remove function do it.
(WebCore::TextTrack::addRegion): Use references.
(WebCore::TextTrack::removeRegion): Removed unneeded code to handle a
region that points to a track but is not in that track.
(WebCore::TextTrack::cueWillChange): Use references.
(WebCore::TextTrack::cueDidChange): Ditto.
(WebCore::TextTrack::setLanguage): Ditto.
* html/track/TextTrack.h: Updated for above changes.

* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::TextTrackCue): Initialized the data members
in the class definition.
(WebCore::TextTrackCue::cueIndex): Deleted.
(WebCore::TextTrackCue::invalidateCueIndex): Deleted.
* html/track/TextTrackCue.h: Updated for the above. Removed m_cueIndex,
because it is not a good design to store these and try to keep them up
to date.

* html/track/TextTrackCueList.cpp:
(WebCore::compareCues): Added. Helper for sorting and checking sorting.
(WebCore::TextTrackCueList::TextTrackCueList): Deleted. Let the compiler
generate this.
(WebCore::TextTrackCueList::length): Moved to header.
(WebCore::TextTrackCueList::cueIndex): Renamed from getCueIndex.
Changed return type to unsigned rather than unsigned long.
(WebCore::TextTrackCueList::item): Updated for name change.
(WebCore::TextTrackCueList::getCueById): Ditto.
(WebCore::TextTrackCueList::activeCues): Build the vector directly
rather than wastefully adding with TextTrackCueList::add, which will
try to sort.
(WebCore::TextTrackCueList::add): Take a Ref&& instead of a PassRefPtr.
Also, keep sorted using std::upper_bound instead of the recursive
binary search this code was using before. Also remove the
invalidateCueIndexes call since there are no cue indices any more.
Also remove the boolean return value since no caller was using it.
(WebCore::TextTrackCueList::remove): Take a reference instead of a
pointer. Also remove the boolean return value since no caller was using it.
(WebCore::TextTrackCueList::contains): Deleted. Was unused.
(WebCore::TextTrackCueList::updateCueIndex): Reimplemented using the
std::upper_bound and std::rotate operations. The old code that used
remove and add was inefficient and also could cause a cue to be deallocated
if something else wasn't holding a reference to the cue. Also changed to take
a reference.
(WebCore::TextTrackCueList::clear): Deleted. Was unused.
(WebCore::TextTrackCueList::invalidateCueIndexes): Deleted. No longer
needed since we don't store cue indices in the cues any more.
* html/track/TextTrackCueList.h: Updated for the above changes.

* html/track/VTTRegionList.cpp:
(WebCore::VTTRegionList::VTTRegionList): Deleted. Let the compiler
generate this.
(WebCore::VTTRegionList::length): Moved to header.
(WebCore::VTTRegionList::item): Updated for name and type changes.
(WebCore::VTTRegionList::getRegionById): Ditto.
(WebCore::VTTRegionList::add): Changed to take a Ref&& instead of a
PassRefPtr.
(WebCore::VTTRegionList::remove): Updated.
(WebCore::VTTRegionList::clear): Deleted. Was unused.
* html/track/VTTRegionList.h: Updated for the above changes.
* html/track/VTTRegionList.idl: Made return values nullable to reflect
the actual semantic of the code.

* html/track/VideoTrack.cpp:
(WebCore::VideoTrack::VideoTrack): Use references.
(WebCore::VideoTrack::setPrivate): Ditto.
(WebCore::VideoTrack::setSelected): Ditto.
(WebCore::VideoTrack::inbandTrackIndex): Removed assertion since m_private
is now a Ref instead of a RefPtr.
(WebCore::VideoTrack::selectedChanged): Removed unneeded track private argument.
(WebCore::VideoTrack::idChanged): Ditto.
(WebCore::VideoTrack::labelChanged): Ditto.
(WebCore::VideoTrack::languageChanged): Ditto.
(WebCore::VideoTrack::willRemove): Ditto.
(WebCore::VideoTrack::setKind): Updated to use reference.
(WebCore::VideoTrack::setLanguage): Ditto.
* html/track/VideoTrack.h: Updated for the above. Changed derivation to private.
Removed unneeded defaultKindKeyword.

* loader/EmptyClients.h: Updated to use reference.

* loader/PingLoader.cpp:
(WebCore::PingLoader::sendViolationReport): Take a Ref&& instead of RefPtr&&.
* loader/PingLoader.h: Updated for above change.

* page/Chrome.cpp:
(WebCore::Chrome::loadIconForFiles): Take a reference.
* page/Chrome.h: Updated for above change.
* page/ChromeClient.h: Ditto.

* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::reportViolation): Use auto.

* platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
(WebPlaybackSessionModelMediaElement::selectAudioMediaOption): Simplified
algorithm by removing unneeded direct call to audioTrackEnabledChanged,
which will be called by setEnabled and doesn't need to be called again here.
(WebPlaybackSessionModelMediaElement::selectLegibleMediaOption): Removed
unhelpful assertion and unnneded initialization.

* platform/graphics/AudioTrackPrivate.h: Removed unnneeed track private
argument and initialized data members where they are defined.

* platform/graphics/InbandTextTrackPrivateClient.h: Use Ref instead of
PassRefPtr, initialize data members where they are defined, and removed
the unneeded track private arguments from the client functions.

* platform/graphics/SourceBufferPrivate.h: Fixed functions that were taking
AtomicString to take a const& instead. Use Ref&& instead of PassRefPtr.

* platform/graphics/SourceBufferPrivateClient.h: Removed unneded private pointer
arguments from client functions.

* platform/graphics/TrackPrivateBase.h: Removed unneeded private pointers
from client functions.
* platform/graphics/VideoTrackPrivate: Ditto.

* platform/graphics/avfoundation/AudioTrackPrivateAVF.h: Use
const AtomicString&.

* platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp:
(WebCore::InbandMetadataTextTrackPrivateAVF::addDataCue): Updated for change to arguments.
(WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes): Ditto.
(WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues): Ditto.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Ditto.
(WebCore::InbandTextTrackPrivateAVF::resetCueValues): Ditto.
(WebCore::InbandTextTrackPrivateAVF::processNativeSamples): Ditto.

* platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp:
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC):
Moved initialization of data memebrs to where they are defined.
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::enabled): Deleted. No longer needed.
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::setEnabled): Changed to use the enabled
flag from the base class instead of a separate m_enabled in this class.
* platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h:
Removed the enabled function and the m_enabled data member.

* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: Marked functions
final instead of override and updated arguemnts.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): Updated for change
to arguments.
(WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::appendCompleted): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::hasVideo): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::hasAudio): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::layerDidReceiveError): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::flush): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::seekToTime): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): Ditto.

* platform/graphics/gstreamer/InbandMetadataTextTrackPrivateGStreamer.h: Updated for
changes to arguments.
* platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
(WebCore::InbandTextTrackPrivateGStreamer::notifyTrackOfSample): Ditto.
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
(WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged): Ditto.
* platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::appsinkNewSample): Ditto.
* platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
(WebCore::SourceBufferPrivateGStreamer::append): Ditto.
(WebCore::SourceBufferPrivateGStreamer::flush): Ditto.
(WebCore::SourceBufferPrivateGStreamer::enqueueSample): Ditto.
(WebCore::SourceBufferPrivateGStreamer::isReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateGStreamer::notifyReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateGStreamer::stopAskingForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateGStreamer::didReceiveInitializationSegment): Ditto.
(WebCore::SourceBufferPrivateGStreamer::didReceiveSample): Ditto.
(WebCore::SourceBufferPrivateGStreamer::didReceiveAllPendingSamples): Ditto.
* platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h: Ditto.
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockSourceBufferPrivate::append): Ditto.
(WebCore::MockSourceBufferPrivate::didReceiveInitializationSegment): Ditto.
(WebCore::MockSourceBufferPrivate::didReceiveSample): Ditto.
(WebCore::MockSourceBufferPrivate::enqueuedSamplesForTrackID): Ditto.
(WebCore::MockSourceBufferPrivate::enqueueSample): Ditto.
(WebCore::MockSourceBufferPrivate::hasVideo): Ditto.
(WebCore::MockSourceBufferPrivate::hasAudio): Ditto.
(WebCore::MockSourceBufferPrivate::fastSeekTimeForMediaTime): Ditto.
(WebCore::MockSourceBufferPrivate::seekToTime): Ditto.
* platform/mock/mediasource/MockSourceBufferPrivate.h: Ditto.

* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::updateSnapshot): Take raw pointer instead
of PassRefPtr.
* rendering/RenderSnapshottedPlugIn.h: Updated for above change.

* svg/SVGScriptElement.h: Added using to resolve the ambiguity with the
ref/deref from SVGElement and from ScriptElement.

* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::notifyFinished): Updated to simplify since
the pending script now has a script element.

* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::startElementNs): Use isSciprtElement instead
of toScriptElementIfPossible.
(WebCore::XMLDocumentParser::endElementNs): Ditto. Also use downcastScriptElement.

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::loadIconForFiles): Take a reference instead of a pointer.

Source/WebKit/win:

* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::loadIconForFiles): Take a reference instead of a pointer.
* WebCoreSupport/WebChromeClient.h: Updated for the above.

Source/WebKit2:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::loadIconForFiles): Take a reference instead of a pointer.
* WebProcess/WebCoreSupport/WebChromeClient.h: Ditto.

Source/WTF:

* wtf/RefPtr.h:
(WTF::makeRefPtr): Added.

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

174 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/RefPtr.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
Source/WebCore/bindings/js/JSWebGL2RenderingContextCustom.cpp
Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp
Source/WebCore/bindings/js/ScriptModuleLoader.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/PendingScript.cpp
Source/WebCore/dom/PendingScript.h
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/dom/ScriptElement.h
Source/WebCore/dom/ScriptRunner.cpp
Source/WebCore/dom/ScriptRunner.h
Source/WebCore/html/FileInputType.cpp
Source/WebCore/html/FileInputType.h
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLLabelElement.cpp
Source/WebCore/html/HTMLLabelElement.h
Source/WebCore/html/HTMLLegendElement.cpp
Source/WebCore/html/HTMLLegendElement.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLObjectElement.cpp
Source/WebCore/html/HTMLObjectElement.h
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInElement.h
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/html/HTMLScriptElement.cpp
Source/WebCore/html/HTMLScriptElement.h
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/PluginDocument.cpp
Source/WebCore/html/PluginDocument.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.h
Source/WebCore/html/canvas/CanvasStyle.cpp
Source/WebCore/html/canvas/CanvasStyle.h
Source/WebCore/html/canvas/OESVertexArrayObject.cpp
Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Source/WebCore/html/canvas/WebGL2RenderingContext.h
Source/WebCore/html/canvas/WebGLAny.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLAny.h [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLBuffer.cpp
Source/WebCore/html/canvas/WebGLBuffer.h
Source/WebCore/html/canvas/WebGLContextGroup.cpp
Source/WebCore/html/canvas/WebGLContextGroup.h
Source/WebCore/html/canvas/WebGLContextObject.cpp
Source/WebCore/html/canvas/WebGLFramebuffer.cpp
Source/WebCore/html/canvas/WebGLGetInfo.cpp [deleted file]
Source/WebCore/html/canvas/WebGLGetInfo.h [deleted file]
Source/WebCore/html/canvas/WebGLObject.cpp
Source/WebCore/html/canvas/WebGLObject.h
Source/WebCore/html/canvas/WebGLProgram.cpp
Source/WebCore/html/canvas/WebGLProgram.h
Source/WebCore/html/canvas/WebGLQuery.h
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.h
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/html/canvas/WebGLSampler.h
Source/WebCore/html/canvas/WebGLShader.h
Source/WebCore/html/canvas/WebGLSharedObject.cpp
Source/WebCore/html/canvas/WebGLSharedObject.h
Source/WebCore/html/canvas/WebGLSync.h
Source/WebCore/html/canvas/WebGLTransformFeedback.h
Source/WebCore/html/canvas/WebGLVertexArrayObject.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObject.h
Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.h
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h
Source/WebCore/html/forms/FileIconLoader.cpp
Source/WebCore/html/forms/FileIconLoader.h
Source/WebCore/html/parser/HTMLConstructionSite.cpp
Source/WebCore/html/parser/HTMLDocumentParser.cpp
Source/WebCore/html/parser/HTMLScriptRunner.cpp
Source/WebCore/html/parser/HTMLScriptRunner.h
Source/WebCore/html/parser/HTMLTreeBuilder.cpp
Source/WebCore/html/parser/HTMLTreeBuilder.h
Source/WebCore/html/parser/TextDocumentParser.cpp
Source/WebCore/html/parser/XSSAuditorDelegate.cpp
Source/WebCore/html/parser/XSSAuditorDelegate.h
Source/WebCore/html/track/AudioTrack.cpp
Source/WebCore/html/track/AudioTrack.h
Source/WebCore/html/track/InbandDataTextTrack.cpp
Source/WebCore/html/track/InbandDataTextTrack.h
Source/WebCore/html/track/InbandGenericTextTrack.cpp
Source/WebCore/html/track/InbandGenericTextTrack.h
Source/WebCore/html/track/InbandTextTrack.cpp
Source/WebCore/html/track/InbandTextTrack.h
Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
Source/WebCore/html/track/InbandWebVTTTextTrack.h
Source/WebCore/html/track/LoadableTextTrack.cpp
Source/WebCore/html/track/LoadableTextTrack.h
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/html/track/TextTrackCueList.cpp
Source/WebCore/html/track/TextTrackCueList.h
Source/WebCore/html/track/TrackBase.cpp
Source/WebCore/html/track/TrackBase.h
Source/WebCore/html/track/VTTRegionList.cpp
Source/WebCore/html/track/VTTRegionList.h
Source/WebCore/html/track/VTTRegionList.idl
Source/WebCore/html/track/VideoTrack.cpp
Source/WebCore/html/track/VideoTrack.h
Source/WebCore/loader/EmptyClients.h
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/PingLoader.h
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/Chrome.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/csp/ContentSecurityPolicy.cpp
Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm
Source/WebCore/platform/graphics/AudioTrackPrivate.h
Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h
Source/WebCore/platform/graphics/SourceBufferPrivate.h
Source/WebCore/platform/graphics/SourceBufferPrivateClient.h
Source/WebCore/platform/graphics/TrackPrivateBase.h
Source/WebCore/platform/graphics/VideoTrackPrivate.h
Source/WebCore/platform/graphics/avfoundation/AudioTrackPrivateAVF.h
Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
Source/WebCore/platform/graphics/avfoundation/VideoTrackPrivateAVF.h
Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp
Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp
Source/WebCore/platform/graphics/gstreamer/InbandMetadataTextTrackPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h
Source/WebCore/platform/mediastream/AudioTrackPrivateMediaStream.h
Source/WebCore/platform/mediastream/VideoTrackPrivateMediaStream.h
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h
Source/WebCore/platform/mock/mediasource/MockTracks.h
Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
Source/WebCore/rendering/RenderSnapshottedPlugIn.h
Source/WebCore/svg/SVGScriptElement.h
Source/WebCore/xml/parser/XMLDocumentParser.cpp
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/win/WebCoreSupport/WebChromeClient.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index 99e8c23..7b36c3b 100644 (file)
@@ -1,3 +1,13 @@
+2017-01-04  Darin Adler  <darin@apple.com>
+
+        Remove PassRefPtr use from the "html" directory, other improvements
+        https://bugs.webkit.org/show_bug.cgi?id=166635
+
+        Reviewed by Alex Christensen.
+
+        * wtf/RefPtr.h:
+        (WTF::makeRefPtr): Added.
+
 2017-01-04  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Unreviewed build fix after r210313
index 87fc456..fe1630c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
+ *  Copyright (C) 2005-2017 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Library General Public
@@ -242,10 +242,21 @@ template<typename T> inline RefPtr<T> adoptRef(T* p)
     return RefPtr<T>(p, RefPtr<T>::Adopt);
 }
 
+template<typename T> inline RefPtr<T> makeRefPtr(T* pointer)
+{
+    return pointer;
+}
+
+template<typename T> inline RefPtr<T> makeRefPtr(T& reference)
+{
+    return &reference;
+}
+
 } // namespace WTF
 
 using WTF::RefPtr;
 using WTF::adoptRef;
+using WTF::makeRefPtr;
 using WTF::static_pointer_cast;
 
 #endif // WTF_RefPtr_h
index 25f28c5..b626314 100644 (file)
@@ -1759,7 +1759,6 @@ set(WebCore_SOURCES
     html/ValidationMessage.cpp
     html/WeekInputType.cpp
 
-    html/canvas/ANGLEInstancedArrays.cpp
     html/canvas/CanvasGradient.cpp
     html/canvas/CanvasPath.cpp
     html/canvas/CanvasPattern.cpp
@@ -1768,51 +1767,6 @@ set(WebCore_SOURCES
     html/canvas/CanvasRenderingContext2D.cpp
     html/canvas/CanvasStyle.cpp
     html/canvas/DOMPath.cpp
-    html/canvas/EXTBlendMinMax.cpp
-    html/canvas/EXTFragDepth.cpp
-    html/canvas/EXTShaderTextureLOD.cpp
-    html/canvas/EXTTextureFilterAnisotropic.cpp
-    html/canvas/EXTsRGB.cpp
-    html/canvas/OESElementIndexUint.cpp
-    html/canvas/OESStandardDerivatives.cpp
-    html/canvas/OESTextureFloat.cpp
-    html/canvas/OESTextureFloatLinear.cpp
-    html/canvas/OESTextureHalfFloat.cpp
-    html/canvas/OESTextureHalfFloatLinear.cpp
-    html/canvas/OESVertexArrayObject.cpp
-    html/canvas/WebGL2RenderingContext.cpp
-    html/canvas/WebGLBuffer.cpp
-    html/canvas/WebGLCompressedTextureATC.cpp
-    html/canvas/WebGLCompressedTexturePVRTC.cpp
-    html/canvas/WebGLCompressedTextureS3TC.cpp
-    html/canvas/WebGLContextEvent.cpp
-    html/canvas/WebGLContextGroup.cpp
-    html/canvas/WebGLContextObject.cpp
-    html/canvas/WebGLDebugRendererInfo.cpp
-    html/canvas/WebGLDebugShaders.cpp
-    html/canvas/WebGLDepthTexture.cpp
-    html/canvas/WebGLDrawBuffers.cpp
-    html/canvas/WebGLExtension.cpp
-    html/canvas/WebGLFramebuffer.cpp
-    html/canvas/WebGLGetInfo.cpp
-    html/canvas/WebGLLoseContext.cpp
-    html/canvas/WebGLObject.cpp
-    html/canvas/WebGLProgram.cpp
-    html/canvas/WebGLQuery.cpp
-    html/canvas/WebGLRenderbuffer.cpp
-    html/canvas/WebGLRenderingContext.cpp
-    html/canvas/WebGLRenderingContextBase.cpp
-    html/canvas/WebGLSampler.cpp
-    html/canvas/WebGLShader.cpp
-    html/canvas/WebGLShaderPrecisionFormat.cpp
-    html/canvas/WebGLSharedObject.cpp
-    html/canvas/WebGLSync.cpp
-    html/canvas/WebGLTexture.cpp
-    html/canvas/WebGLTransformFeedback.cpp
-    html/canvas/WebGLUniformLocation.cpp
-    html/canvas/WebGLVertexArrayObject.cpp
-    html/canvas/WebGLVertexArrayObjectBase.cpp
-    html/canvas/WebGLVertexArrayObjectOES.cpp
 
     html/forms/FileIconLoader.cpp
 
@@ -3074,6 +3028,7 @@ if (ENABLE_WEBGL)
         html/canvas/OESTextureHalfFloatLinear.cpp
         html/canvas/OESVertexArrayObject.cpp
         html/canvas/WebGL2RenderingContext.cpp
+        html/canvas/WebGLAny.cpp
         html/canvas/WebGLBuffer.cpp
         html/canvas/WebGLCompressedTextureATC.cpp
         html/canvas/WebGLCompressedTexturePVRTC.cpp
@@ -3087,7 +3042,6 @@ if (ENABLE_WEBGL)
         html/canvas/WebGLDrawBuffers.cpp
         html/canvas/WebGLExtension.cpp
         html/canvas/WebGLFramebuffer.cpp
-        html/canvas/WebGLGetInfo.cpp
         html/canvas/WebGLLoseContext.cpp
         html/canvas/WebGLObject.cpp
         html/canvas/WebGLProgram.cpp
index af32356..fab882b 100644 (file)
@@ -1,3 +1,772 @@
+2017-01-04  Darin Adler  <darin@apple.com>
+
+        Remove PassRefPtr use from the "html" directory, other improvements
+        https://bugs.webkit.org/show_bug.cgi?id=166635
+
+        Reviewed by Alex Christensen.
+
+        * CMakeLists.txt: Removed the duplicate copies of all the WebGL-specific files
+        in the main list of source files; there is no value in listing them twice.
+        Replaced WebGLGetInfo.cpp with WebGLAny.cpp.
+
+        * Modules/mediasource/MediaSource.cpp:
+        (WebCore::MediaSource::removeSourceBuffer): Updates since the tracks functions
+        return references now.
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime): Removed
+        unneeded SourceBufferPrivate* argument.
+        (WebCore::SourceBuffer::appendBufferTimerFired): Ditto.
+        (WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): Ditto.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveRenderingError): Ditto.
+        (WebCore::SourceBuffer::videoTracks): Return a reference rather than a pointer.
+        (WebCore::SourceBuffer::audioTracks): Ditto.
+        (WebCore::SourceBuffer::textTracks): Ditto.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
+        Removed unneeded SourceBufferPrivate* argument.
+        (WebCore::SourceBuffer::validateInitializationSegment): Updated since tracks
+        functions now return a pointer.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Removed unneeded
+        SourceBufferPrivate* argument.
+        (WebCore::SourceBuffer::sourceBufferPrivateHasAudio): Ditto.
+        (WebCore::SourceBuffer::sourceBufferPrivateHasVideo): Ditto.
+        (WebCore::SourceBuffer::videoTrackSelectedChanged): Take a reference rather than
+        a pointer.
+        (WebCore::SourceBuffer::audioTrackEnabledChanged): Ditto.
+        (WebCore::SourceBuffer::textTrackModeChanged): Ditto.
+        (WebCore::SourceBuffer::textTrackAddCue): Ditto.
+        (WebCore::SourceBuffer::textTrackAddCues): Ditto.
+        (WebCore::SourceBuffer::textTrackRemoveCue): Ditto.
+        (WebCore::SourceBuffer::textTrackRemoveCues): Ditto.
+        (WebCore::SourceBuffer::textTrackKindChanged): Ditto.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples): Ditto.
+        (WebCore::SourceBuffer::provideMediaData): Ditto.
+        (WebCore::SourceBuffer::reenqueueMediaForTime): Ditto.
+        * Modules/mediasource/SourceBuffer.h: Updated for above changes.
+
+        * WebCore.xcodeproj/project.pbxproj: Replaced WebGLGetInfo with WebGLAny.
+
+        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
+        (WebCore::toHTMLCanvasStyle): Removed explicit cast to CanvasStyle and unneeded
+        conversion to a pointer since CanvasStyle constructors now take references.
+
+        * bindings/js/JSPluginElementFunctions.cpp:
+        (WebCore::pluginInstance): Updated since bindingsInstance now returns a raw pointer.
+        (WebCore::pluginScriptObject): Ditto.
+
+        * bindings/js/JSWebGL2RenderingContextCustom.cpp:
+        (WebCore::toJS): Moved to WebGLAny.h/cpp.
+        (WebCore::JSWebGL2RenderingContext::getIndexedParameter): Updated since the toJS
+        function in WebGLAny.h takes references, not pointers.
+
+        * bindings/js/JSWebGLRenderingContextBaseCustom.cpp: Removed quite a few unneeded
+        includes and got rid of a lot of unneeded JSC prefixes.
+        (WebCore::toJS): Moved to WebGLAny.h/cpp.
+        (WebCore::toJSNewlyCreated):
+        (WebCore::objectParameter): Renamed from getObjectParameter and also changed to
+        take a pointer to member function so we don't need an enum and a switch statement.
+        (WebCore::toJS): Changed to take references rather than pointers.
+        (WebCore::JSWebGLRenderingContextBase::getAttachedShaders): Use a modern for loop.
+        (WebCore::JSWebGLRenderingContextBase::getBufferParameter): Use objectParameter.
+        (WebCore::JSWebGLRenderingContextBase::getRenderbufferParameter): Ditto.
+        (WebCore::JSWebGLRenderingContextBase::getVertexAttrib): Ditto.
+        (WebCore::toNumberVector): Renamed from toVector, since this is specifically for
+        vectors of numbers. Use uncheckedAppend instead of assignment.
+        (WebCore::functionForUniform): Marked this inline.
+        (WebCore::dataFunctionf): Updated for above changes.
+        (WebCore::dataFunctioni): Ditto.
+        (WebCore::dataFunctionMatrix): Ditto.
+
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::fetch): Moved assertions to the top of the function.
+        Also added a FIXME because it's unclear why these assertions are correct. Updated
+        to use downcastScriptElement instead of toScriptElementIfPossible.
+
+        * dom/Document.h: Sorted list of forward-declared classes. Removed duplicate
+        forward declaration of ScriptModuleLoader.
+
+        * dom/PendingScript.cpp:
+        (WebCore::PendingScript::create): Take a ScriptElement instead of an Element.
+        (WebCore::PendingScript::PendingScript): Ditto.
+        (WebCore::PendingScript::loadableScript): Moved inline to header and made inline.
+        (WebCore::PendingScript::setClient): Take a reference instead of a pointer.
+        * dom/PendingScript.h: UPdated for above changes.
+
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::prepareScript): Pass a reference instead of a pointer.
+        (WebCore::ScriptElement::ref): Added. Forwards ref/deref to the underlying element
+        so we can use Ref and RefPtr with this class.
+        (WebCore::ScriptElement::deref): Ditto.
+        (WebCore::isScriptElement): Added. Replaces one of the two uses of
+        toScriptElementIfPossible, and is similar in style to is<Element>.
+        (WebCore::downcastScriptElement): Ditto, but for downcast.
+        * dom/ScriptElement.h: Updated for above changes.
+
+        * dom/ScriptRunner.cpp:
+        (WebCore::ScriptRunner::queueScriptForExecution): Take reference rather than
+        pointer, and pass ScriptElement rather than Element.
+        (WebCore::ScriptRunner::notifyFinished): Ditto.
+        (WebCore::ScriptRunner::timerFired): Ditto.
+        * dom/ScriptRunner.h: Updated for above changes.
+
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::files): Updated since m_fileList is a Ref.
+        (WebCore::FileInputType::createFileList): Updated to return a Ref instead of
+        a PassRefPtr. Also use reserveInitialCapacity/uncheckedAppend.
+        (WebCore::FileInputType::requestIcon): Updated since the updateRendering
+        function is now called iconLoaded. Also use references instead of pointers.
+        (WebCore::FileInputType::setFiles): Take a RefPtr&& insted of a PassRefPtr.
+        Also put some conditional code inside an #if.
+        (WebCore::FileInputType::filesChosen): Updated for function name change.
+        (WebCore::FileInputType::iconLoaded): Renamed from updateRendering.
+        Changed argument to RefPtr&& from PassRefPtr.
+        (WebCore::FileInputType::defaultToolTip): Got rid of unneeded local variable
+        and used the correct type, unsigned, rather than size_t.
+        * html/FileInputType.h: Updated for the above changes, use final instead
+        of override, and use Ref instead of RefPtr.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::form): Renamed from virtualForm.
+        * html/HTMLElement.h: Replaced the form/virtualForm pair of functions with
+        just a form function. The old design dates back before we had "final" for
+        virtual functions, and now we can just use that instead.
+
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::virtualForm): Deleted.
+        * html/HTMLFormControlElement.h: Mark the form function final, since it's
+        now both an inline function in this class, and an override of a virtual
+        function inherited from the base class. Deleted the virtualForm function.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::defaultEventHandler): Removed use of the
+        formForSubmission function, which was just another way to get the same
+        thing as the form function; perhaps they were different in the past.
+        (WebCore::HTMLInputElement::setFiles): Take a RefPtr&& rather than a PassRefPtr.
+        * html/HTMLInputElement.h: Updated for the above.
+
+        * html/HTMLLabelElement.cpp:
+        (WebCore::HTMLLabelElement::control): Made this const.
+        (WebCore::HTMLLabelElement::form): Made this const, so it can be used to
+        override the const form function from the base class.
+        * html/HTMLLabelElement.h: Marked the form function final, since we want it
+        to override the form function inherited from HTMLElement.
+
+        * html/HTMLLegendElement.cpp:
+        (WebCore::HTMLLegendElement::form): Renamed from virtualForm.
+        * html/HTMLLegendElement.h: Override form instead of virtualForm and mark it final
+        This makes things more efficient if someone calls form directly on this class;
+        before it would make an unnecessary virtual function call.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::TrackDisplayUpdateScope::TrackDisplayUpdateScope): Take a reference
+        rather than a pointer.
+        (WebCore::TrackDisplayUpdateScope::~TrackDisplayUpdateScope): Ditto.
+        (WebCore::eventTimeCueCompare): Compare the cues the same way the cue list would
+        rather than using cueIndex.
+        (WebCore::HTMLMediaElement::audioTrackEnabledChanged): Take a reference.
+        (WebCore::HTMLMediaElement::textTrackModeChanged): Ditto.
+        (WebCore::HTMLMediaElement::videoTrackSelectedChanged): Ditto.
+        (WebCore::HTMLMediaElement::textTrackKindChanged): Ditto.
+        (WebCore::HTMLMediaElement::textTrackAddCues): Ditto.
+        (WebCore::HTMLMediaElement::textTrackRemoveCues): Ditto.
+        (WebCore::HTMLMediaElement::textTrackAddCue): Ditto.
+        (WebCore::HTMLMediaElement::textTrackRemoveCue): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack): Pass references.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddVideoTrack): Ditto.
+        (WebCore::HTMLMediaElement::removeTextTrack): Ditto.
+        (WebCore::HTMLMediaElement::forgetResourceSpecificTracks): Ditto.
+        (WebCore::HTMLMediaElement::setController): Take a RefPtr&& instead of PassRefPtr.
+        * html/HTMLMediaElement.h: Updated for above changes.
+
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::virtualForm): Deleted.
+        * html/HTMLObjectElement.h: Made the form function inline and final, which
+        achieves the same thing we did before with using, but without requiring the
+        separate virtualForm function, now deleted.
+
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::collectOptionInnerText): Use isScriptElement
+        instead of toScriptElementIfPossible.
+
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::bindingsInstance): Renamed from getInstance and
+        changed the return type to a raw pointer.
+        * html/HTMLPlugInElement.h: Updated for the above changes. Also changed the
+        updateSnapshot function to take a raw pointer instead of a PassRefPtr.
+
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::createElementRenderer): Pass a pointer
+        to updateSnapshot.
+        (WebCore::HTMLPlugInImageElement::updateSnapshot): Updated to take a raw
+        pointer instead of a PassRefPtr.
+        * html/HTMLPlugInImageElement.h: Updated for above changes.
+
+        * html/HTMLScriptElement.h: Added using to resolve the ambiguity with the
+        ref/deref from HTMLElement and from ScriptElement.
+
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::selection): Return a RefPtr instead
+        of a PassRefPtr.
+        * html/HTMLTextFormControlElement.h: Updated for above changes.
+
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::textTrackKindChanged): Take a reference.
+        (WebCore::HTMLTrackElement::textTrackModeChanged): Ditto.
+        (WebCore::HTMLTrackElement::textTrackAddCues): Ditto.
+        (WebCore::HTMLTrackElement::textTrackRemoveCues): Ditto.
+        (WebCore::HTMLTrackElement::textTrackAddCue): Ditto.
+        (WebCore::HTMLTrackElement::textTrackRemoveCue): Ditto.
+        * html/HTMLTrackElement.h: Updated for above changes.
+
+        * html/InputType.cpp:
+        (WebCore::InputType::formForSubmission): Deleted.
+        (WebCore::InputType::setFiles): Take a RefPtr&& instead of a PassRefPtr.
+        * html/InputType.h: Updated for above changes.
+
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocumentParser::createDocumentStructure): Pass a reference.
+        (WebCore::PluginDocument::setPluginElement): Take a reference rather than
+        a PassRefPtr.
+        * html/PluginDocument.h: Updated for above changes.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setStrokeStyle): Pass a reference.
+        (WebCore::CanvasRenderingContext2D::setFillStyle): Ditto.
+        (WebCore::CanvasRenderingContext2D::drawTextInternal): Ditto.
+
+        * html/canvas/CanvasStyle.cpp:
+        (WebCore::CanvasStyle::CanvasStyle): Rewrite all constructors to use the
+        m_style variant instead of separate m_type and other data members. Also
+        change from PassRefPtr to a reference.
+        (WebCore::CanvasStyle::createFromString): Update to use the variant.
+        (WebCore::CanvasStyle::createFromStringWithOverrideAlpha): Ditto.
+        (WebCore::CanvasStyle::isEquivalentColor): Ditto.
+        (WebCore::CanvasStyle::isEquivalentRGBA): Ditto.
+        (WebCore::CanvasStyle::isEquivalentCMYKA): Ditto.
+        (WebCore::CanvasStyle::CanvasStyle): Deleted copy constructor; the compiler
+        can now generate a correct copy or move constructor.
+        (WebCore::CanvasStyle::~CanvasStyle): Deleted. Compiler generates this
+        properly now without help from us.
+        (WebCore::CanvasStyle::operator=): Deleted. The compiler can now generate
+        a correct copy of move assignment operator.
+        (WebCore::CanvasStyle::applyStrokeColor): Updated to take a reference and
+        use the variant.
+        (WebCore::CanvasStyle::applyFillColor): Ditto.
+
+        * html/canvas/CanvasStyle.h: Redid this class to use a variant instead of
+        a type enumeration and a union.
+
+        * html/canvas/OESVertexArrayObject.cpp:
+        (WebCore::OESVertexArrayObject::createVertexArrayOES): Updated use of enum
+        since it's now an enum class.
+
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::WebGL2RenderingContext): Use Ref&& instead of
+        RefPtr&& for the GraphicsContext3D.
+        (WebCore::WebGL2RenderingContext::initializeVertexArrayObjects): Updated enum
+        and also use references.
+        (WebCore::WebGL2RenderingContext::getInternalformatParameter): Use nullptr to
+        return null rather than the old idiom (default-constructed WebGLGetInfo).
+        (WebCore::WebGL2RenderingContext::texStorage2D): Ditto.
+        (WebCore::WebGL2RenderingContext::getQueryParameter): Ditto.
+        (WebCore::WebGL2RenderingContext::getSamplerParameter): Ditto.
+        (WebCore::WebGL2RenderingContext::getSyncParameter): Ditto.
+        (WebCore::WebGL2RenderingContext::getIndexedParameter): Ditto.
+        (WebCore::WebGL2RenderingContext::getActiveUniformBlockParameter): Ditto.
+        (WebCore::WebGL2RenderingContext::getActiveUniformBlockName): Ditto.
+        (WebCore::WebGL2RenderingContext::createVertexArray): Updated enum and also
+        use reference.
+        (WebCore::WebGL2RenderingContext::getExtension): Rearranged logic in three ways:
+        (1) Moved checks for whether an extension is supported inside the case for that
+        extension, rather than combining the extension name check with the extensions
+        enabled check. (2) Used the new enableSupportedExtension function to simplify
+        many of the checks to avoid repeating the extension name twice. (3) Changed the
+        idiom so we set the pointers to nullptr explicitly, preparing for a future where
+        we might make the extension pointers use std::optional so we can cache a negative
+        for each extension too, not just a positive result.
+        (WebCore::WebGL2RenderingContext::getSupportedExtensions): Use ASCIILiteral.
+        (WebCore::WebGL2RenderingContext::getFramebufferAttachmentParameter): Use nullptr
+        as above. For non-null types, return the object without converting, letting the
+        WebGLAny class handle things, except for enumerations, which we need to explicitly
+        static_cast to an integral type, and things that will be stored in the variant in
+        a RefPtr, where we use makeRefPtr.
+        (WebCore::WebGL2RenderingContext::validateFramebufferFuncParameters):
+        Simplified and clarified the handling of COLOR_ATTACHMENT.
+        (WebCore::WebGL2RenderingContext::getParameter): Return WebGLAny, same idiom as
+        described above for getFramebufferAttachmentParameter.
+        * html/canvas/WebGL2RenderingContext.h: Updated for above changes.
+
+        * html/canvas/WebGLAny.cpp: Added.
+        (WebCore::toJS): Handles conversion to JavaScript types. This function is based
+        on the existing toJS functions from the two classes that were using WebGLGetInfo.
+        Eventually we can probably just get the bindings to automatically generate this,
+        but there is some work to do to get to that point.
+        * html/canvas/WebGLAny.h: Added. This type, a variant, replaces the WebGLGetInfo
+        class. Also includes the toJS function, which is the real point of this type, since
+        it's about returning a variant mapped appropriately to JavaScript types.
+
+        * html/canvas/WebGLContextGroup.cpp:
+        (WebCore::WebGLContextGroup::getAGraphicsContext3D): Changed to return a reference.
+        Droped unnecessary local variable with a long type name.
+        (WebCore::WebGLContextGroup::addContext): Take a reference.
+        (WebCore::WebGLContextGroup::removeContext): Ditto.
+        (WebCore::WebGLContextGroup::removeObject): Ditto.
+        (WebCore::WebGLContextGroup::addObject): Ditto.
+        (WebCore::WebGLContextGroup::detachAndRemoveAllObjects): Dropped unnecessary
+        local variable with a long type name.
+        * html/canvas/WebGLContextGroup.h: Updated for above changes.
+
+        * html/canvas/WebGLContextObject.cpp:
+        (WebCore::WebGLContextObject::~WebGLContextObject): Pass references.
+        (WebCore::WebGLContextObject::detachContext): Ditto.
+
+        * html/canvas/WebGLGetInfo.cpp: Removed.
+        * html/canvas/WebGLGetInfo.h: Removed.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::WebGLRenderingContext): Take a Ref&& instead
+        of as PassRefPtr.
+        (WebCore::WebGLRenderingContext::initializeVertexArrayObjects): Updated enum
+        and also use references.
+        (WebCore::WebGLRenderingContext::getExtension): Rearranged logic in three ways:
+        (1) Moved checks for whether an extension is supported inside the case for that
+        extension, rather than combining the extension name check with the extensions
+        enabled check. (2) Used the new enableSupportedExtension function to simplify
+        many of the checks to avoid repeating the extension name twice. (3) Changed the
+        idiom so we set the pointers to nullptr explicitly, preparing for a future where
+        we might make the extension pointers use std::optional so we can cache a negative
+        for each extension too, not just a positive result.
+        (WebCore::WebGLRenderingContext::getSupportedExtensions): Use ASCIILiteral.
+        (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): Use nullptr
+        as above. For non-null types, return the object without converting, letting the
+        WebGLAny class handle things, except for enumerations, which we need to explicitly
+        static_cast to an integral type, and things that will be stored in the variant in
+        a RefPtr, where we use makeRefPtr.
+        (WebCore::WebGLRenderingContext::validateFramebufferFuncParameters):
+        Simplified and clarified the handling of COLOR_ATTACHMENT adding a FIXME about
+        something questionable.
+        (WebCore::WebGLRenderingContext::getParameter): Return WebGLAny, same idiom as
+        described above for getFramebufferAttachmentParameter.
+        * html/canvas/WebGLRenderingContext.h: Updated for above changes.
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::create): Updated to pass references
+        instead of pointers in a couple cases
+        (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase): Changed graphics
+        context argument type from RefPtr&& to Ref&&. Also moved initialization of scalars
+        from the constructor to the class definition.
+        (WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase): Pass a reference.
+        (WebCore::WebGLRenderingContextBase::createBuffer): Pass a reference instead of a pointer.
+        (WebCore::WebGLRenderingContextBase::createFramebuffer): Ditto.
+        (WebCore::WebGLRenderingContextBase::createTexture): Ditto.
+        (WebCore::WebGLRenderingContextBase::createProgram): Ditto.
+        (WebCore::WebGLRenderingContextBase::createRenderbuffer): Ditto.
+        (WebCore::WebGLRenderingContextBase::createShader): Ditto.
+        (WebCore::WebGLRenderingContextBase::deleteBuffer): Ditto.
+        (WebCore::WebGLRenderingContextBase::getBufferParameter): Update to use WebGLAny.
+        (WebCore::WebGLRenderingContextBase::getProgramParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getRenderbufferParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getShaderParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getTexParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getUniform): Ditto.
+        (WebCore::WebGLRenderingContextBase::getVertexAttrib): Ditto.
+        (WebCore::WebGLRenderingContextBase::getVertexAttribOffset): Removed unnneed
+        type casts.
+        (WebCore::WebGLRenderingContextBase::vertexAttribPointer): Pass a reference.
+        (WebCore::WebGLRenderingContextBase::removeSharedObject): Take a reference.
+        (WebCore::WebGLRenderingContextBase::addSharedObject): Ditto.
+        (WebCore::WebGLRenderingContextBase::removeContextObject): Ditto.
+        (WebCore::WebGLRenderingContextBase::addContextObject): Ditto.
+        (WebCore::WebGLRenderingContextBase::getBooleanParameter): Changed return type;
+        connversion to WebGLAny can happen at the point of use.
+        (WebCore::WebGLRenderingContextBase::getBooleanArrayParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getFloatParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getIntParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getUnsignedIntParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getInt64Parameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getWebGLFloatArrayParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::getWebGLIntArrayParameter): Ditto.
+        (WebCore::WebGLRenderingContextBase::validateBufferDataParameters): Use
+        optional to simplify logic and get rid of a boolean.
+        (WebCore::WebGLRenderingContextBase::enableSupportedExtension): Added.
+        Helper used by the getExtension functions.
+        * html/canvas/WebGLRenderingContextBase.h: Updated for the above changes.
+        Also changed setBoundVertexArrayObject to take a raw pointer instead of
+        as PassRefPtr.
+
+        * html/canvas/WebGLSharedObject.cpp:
+        (WebCore::WebGLSharedObject::~WebGLSharedObject): Pass a reference.
+        (WebCore::WebGLSharedObject::detachContextGroup): Ditto.
+        (WebCore::WebGLSharedObject::getAGraphicsContext3D): Updated since the
+        underlying getAGraphicsContext3D function now returns a reference.
+
+        * html/canvas/WebGLSharedObject.h: Removed many unused "is" virtual functions.
+        * html/canvas/WebGLTransformFeedback.h: Ditto.
+
+        * html/canvas/WebGLVertexArrayObject.cpp:
+        (WebCore::WebGLVertexArrayObject::create): Updated for new type enumeration.
+        (WebCore::WebGLVertexArrayObject::WebGLVertexArrayObject): Ditto.
+        (WebCore::WebGLVertexArrayObject::deleteObjectImpl): Ditto.
+        * html/canvas/WebGLVertexArrayObject.h: Updated for above changes.
+
+        * html/canvas/WebGLVertexArrayObjectBase.cpp:
+        (WebCore::WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase): Updated for new
+        type enumeration and moved initialization to class definition.
+        (WebCore::WebGLVertexArrayObjectBase::setElementArrayBuffer): Changed argument to
+        raw pointer instead of PassRefPtr.
+        (WebCore::WebGLVertexArrayObjectBase::setVertexAttribState): Changed argument to
+        reference instead of PassRefPtr.
+        (WebCore::WebGLVertexArrayObjectBase::unbindBuffer): Changed arugment type to
+        reference instead of PassRefPtr.
+        (WebCore::WebGLVertexArrayObjectBase::setVertexAttribDivisor): Removed unneeded
+        local variable.
+        * html/canvas/WebGLVertexArrayObjectBase.h: Updated for above changes.
+        Replaced VAOType with Type. Used class member initialization.
+
+        * html/canvas/WebGLVertexArrayObjectOES.cpp:
+        (WebCore::WebGLVertexArrayObjectOES::create): Updated for new type enumeration.
+        (WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES): Ditto.
+        (WebCore::WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES) Ditto.:
+        (WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl): Ditto.
+        * html/canvas/WebGLVertexArrayObjectOES.h: Updated for above changes.
+
+        * html/forms/FileIconLoader.cpp:
+        (WebCore::FileIconLoader::iconLoaded): Renamed from notifyFinished. Also changed
+        the name of the function this calls to iconLoaded. Changed the arguemnt to
+        RefPtr&& instead of PassRefPtr.
+        * html/forms/FileIconLoader.h: Updated for above changes.
+
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::attachLater): Use isScriptElement instead of
+        toScriptElementIfPossible.
+        (WebCore::HTMLConstructionSite::insertForeignElement): Ditto.
+
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Pass script
+        element as a Ref rather than RefPtr.
+        (WebCore::HTMLDocumentParser::watchForLoad): Pass a reference instead of a pointer.
+
+        * html/parser/HTMLScriptRunner.cpp:
+        (WebCore::HTMLScriptRunner::executeParsingBlockingScript): Deleted. Moved the code
+        into the single call site, execute ParsingBlockingScripts.
+        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): Changed argument
+        type to a reference from a RefPtr; this funtion was not taking ownership. Also remove
+        call to toScriptElementIfPossible,
+        since pending scripts now contains script elements already.
+        (WebCore::HTMLScriptRunner::execute): Changed argument type to Ref<ScriptElement>&&
+        from PassRefPtr<Element>.
+        (WebCore::HTMLScriptRunner::executeParsingBlockingScripts): Moved code here from
+        executeParsingBlockingScript. Also pass a reference.
+        (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing): Pass a reference.
+        (WebCore::requestPendingScript): Changed argument type to ScriptElement& from
+        Element*.
+        (WebCore::HTMLScriptRunner::requestParsingBlockingScript): Ditto.
+        (WebCore::HTMLScriptRunner::requestDeferredScript): Ditto.
+        (WebCore::HTMLScriptRunner::runScript): Ditto.
+        * html/parser/HTMLScriptRunner.h: Updated for above changes.
+
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::takeScriptToProcess): Changed return type from
+        RefPtr<Element> to RefPtr<ScriptElement>.
+        (WebCore::HTMLTreeBuilder::processEndTag): Downcast the script element to
+        HTMLScriptElement so we can store it as a ScriptElement.
+        (WebCore::HTMLTreeBuilder::processTokenInForeignContent): Downcast the script
+        element to SVGScriptElement so we can store it as a script element.
+        * html/parser/HTMLTreeBuilder.h: Updated for above changes. Changed the type
+        of m_scriptToProcess to RefPtr<ScriptElement>.
+
+        * html/parser/TextDocumentParser.cpp: Added now-needed include.
+
+        * html/parser/XSSAuditorDelegate.cpp:
+        (WebCore::XSSAuditorDelegate::generateViolationReport): Changed return type
+        to Ref from PassRefPtr.
+        * html/parser/XSSAuditorDelegate.h: Updated for above.
+
+        * html/track/AudioTrack.cpp:
+        (WebCore::AudioTrack::AudioTrack): Take references.
+        (WebCore::AudioTrack::setPrivate): Ditto.
+        (WebCore::AudioTrack::setEnabled): Removed redundant code to do what the
+        private setEnabled function is already going to do.
+        (WebCore::AudioTrack::inbandTrackIndex): Removed assertion since m_private
+        is now a Ref rather than RefPtr.
+        (WebCore::AudioTrack::enabledChanged): Added an early exit so we will only
+        call audioTrackEnabledChanged if m_enabled is actually changing. Also removed
+        the unneeded track private argument.
+        (WebCore::AudioTrack::idChanged): Ditto.
+        (WebCore::AudioTrack::labelChanged): Ditto.
+        (WebCore::AudioTrack::languageChanged): Ditto.
+        (WebCore::AudioTrack::willRemove): Ditto.
+        * html/track/AudioTrack.h: Updated for above changes.
+
+        * html/track/InbandDataTextTrack.cpp:
+        (WebCore::InbandDataTextTrack::addDataCue): Removed inband text track private
+        argument. Use contains instead of find/end.
+        (WebCore::InbandDataTextTrack::updateDataCue): Ditto. Use get instead of find/end.
+        (WebCore::InbandDataTextTrack::removeDataCue): Ditto.
+        * html/track/InbandDataTextTrack.h: Updated for above changes.
+
+        * html/track/InbandGenericTextTrack.cpp:
+        (WebCore::InbandGenericTextTrack::InbandGenericTextTrack): Take references.
+        (WebCore::InbandGenericTextTrack::create): Ditto.
+        (WebCore::InbandGenericTextTrack::updateCueFromCueData): Ditto.
+        (WebCore::InbandGenericTextTrack::addGenericCue): Ditto. Also removed unused
+        track private argument.
+        (WebCore::InbandGenericTextTrack::updateGenericCue): Ditto.
+        (WebCore::InbandGenericTextTrack::removeGenericCue): Ditto.
+        (WebCore::InbandGenericTextTrack::parseWebVTTCueData): Ditto.
+        (WebCore::InbandGenericTextTrack::parseWebVTTFileHeader): Ditto.
+        (WebCore::InbandGenericTextTrack::newRegionsParsed): Pass a reference.
+        * html/track/InbandGenericTextTrack.h: Updated for above changes.
+
+        * html/track/InbandTextTrack.cpp:
+        (WebCore::InbandTextTrack::create): Return a Ref instead of a PassRefPtr. Take
+        references.
+        (WebCore::InbandTextTrack::InbandTextTrack): Ditto.
+        (WebCore::InbandTextTrack::setPrivate): Take a reference instead of a PassRefPtr.
+        (WebCore::InbandTextTrack::isClosedCaptions): Removed check for null since m_private
+        is now a Ref and so never null.
+        (WebCore::InbandTextTrack::isSDH): Ditto.
+        (WebCore::InbandTextTrack::containsOnlyForcedSubtitles): Ditto.
+        (WebCore::InbandTextTrack::isMainProgramContent): Ditto.
+        (WebCore::InbandTextTrack::isEasyToRead): Ditto.
+        (WebCore::InbandTextTrack::inbandTrackIndex): Ditto.
+        (WebCore::InbandTextTrack::inBandMetadataTrackDispatchType): Ditto.
+        (WebCore::InbandTextTrack::idChanged): Removed unneeded track private argument.
+        (WebCore::InbandTextTrack::labelChanged): Ditto.
+        (WebCore::InbandTextTrack::languageChanged): Ditto.
+        (WebCore::InbandTextTrack::willRemove): Ditto.
+        (WebCore::InbandTextTrack::updateKindFromPrivate): Improved switch statement
+        by removing default so we get a warning if we forget to handle a kind value.
+        (WebCore::InbandTextTrack::startTimeVariance): Removed check for null.
+        * html/track/InbandTextTrack.h: Updated for above changes. Changed m_private from
+        a RefPtr to a Ref.
+
+        * html/track/InbandWebVTTTextTrack.cpp:
+        (WebCore::InbandWebVTTTextTrack::InbandWebVTTTextTrack): Take references.
+        (WebCore::InbandWebVTTTextTrack::create): Ditto.
+        (WebCore::InbandWebVTTTextTrack::parseWebVTTCueData): Removed unneeded track
+        private arguemnt.
+        (WebCore::InbandWebVTTTextTrack::newRegionsParsed): Pass a reference.
+        * html/track/InbandWebVTTTextTrack.h: Updated for above changes.
+
+        * html/track/LoadableTextTrack.cpp:
+        (WebCore::LoadableTextTrack::newCuesAvailable): Pass references.
+        (WebCore::LoadableTextTrack::newRegionsAvailable): Ditto.
+
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::~TextTrack): Use references.
+        (WebCore::TextTrack::setKind): Ditto.
+        (WebCore::TextTrack::setMode): Ditto.
+        (WebCore::TextTrack::removeAllCues): Ditto.
+        (WebCore::TextTrack::activeCues): Ditto.
+        (WebCore::TextTrack::addCue): Ditto.
+        (WebCore::TextTrack::removeCue): Removed unneeded code to handle a cue
+        that points to a track but is not in that track. Added a call to
+        setIsActive(false) here instead of having the remove function do it.
+        (WebCore::TextTrack::addRegion): Use references.
+        (WebCore::TextTrack::removeRegion): Removed unneeded code to handle a
+        region that points to a track but is not in that track.
+        (WebCore::TextTrack::cueWillChange): Use references.
+        (WebCore::TextTrack::cueDidChange): Ditto.
+        (WebCore::TextTrack::setLanguage): Ditto.
+        * html/track/TextTrack.h: Updated for above changes.
+
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::TextTrackCue): Initialized the data members
+        in the class definition.
+        (WebCore::TextTrackCue::cueIndex): Deleted.
+        (WebCore::TextTrackCue::invalidateCueIndex): Deleted.
+        * html/track/TextTrackCue.h: Updated for the above. Removed m_cueIndex,
+        because it is not a good design to store these and try to keep them up
+        to date.
+
+        * html/track/TextTrackCueList.cpp:
+        (WebCore::compareCues): Added. Helper for sorting and checking sorting.
+        (WebCore::TextTrackCueList::TextTrackCueList): Deleted. Let the compiler
+        generate this.
+        (WebCore::TextTrackCueList::length): Moved to header.
+        (WebCore::TextTrackCueList::cueIndex): Renamed from getCueIndex.
+        Changed return type to unsigned rather than unsigned long.
+        (WebCore::TextTrackCueList::item): Updated for name change.
+        (WebCore::TextTrackCueList::getCueById): Ditto.
+        (WebCore::TextTrackCueList::activeCues): Build the vector directly
+        rather than wastefully adding with TextTrackCueList::add, which will
+        try to sort.
+        (WebCore::TextTrackCueList::add): Take a Ref&& instead of a PassRefPtr.
+        Also, keep sorted using std::upper_bound instead of the recursive
+        binary search this code was using before. Also remove the
+        invalidateCueIndexes call since there are no cue indices any more.
+        Also remove the boolean return value since no caller was using it.
+        (WebCore::TextTrackCueList::remove): Take a reference instead of a
+        pointer. Also remove the boolean return value since no caller was using it.
+        (WebCore::TextTrackCueList::contains): Deleted. Was unused.
+        (WebCore::TextTrackCueList::updateCueIndex): Reimplemented using the
+        std::upper_bound and std::rotate operations. The old code that used
+        remove and add was inefficient and also could cause a cue to be deallocated
+        if something else wasn't holding a reference to the cue. Also changed to take
+        a reference.
+        (WebCore::TextTrackCueList::clear): Deleted. Was unused.
+        (WebCore::TextTrackCueList::invalidateCueIndexes): Deleted. No longer
+        needed since we don't store cue indices in the cues any more.
+        * html/track/TextTrackCueList.h: Updated for the above changes.
+
+        * html/track/VTTRegionList.cpp:
+        (WebCore::VTTRegionList::VTTRegionList): Deleted. Let the compiler
+        generate this.
+        (WebCore::VTTRegionList::length): Moved to header.
+        (WebCore::VTTRegionList::item): Updated for name and type changes.
+        (WebCore::VTTRegionList::getRegionById): Ditto.
+        (WebCore::VTTRegionList::add): Changed to take a Ref&& instead of a
+        PassRefPtr.
+        (WebCore::VTTRegionList::remove): Updated.
+        (WebCore::VTTRegionList::clear): Deleted. Was unused.
+        * html/track/VTTRegionList.h: Updated for the above changes.
+        * html/track/VTTRegionList.idl: Made return values nullable to reflect
+        the actual semantic of the code.
+
+        * html/track/VideoTrack.cpp:
+        (WebCore::VideoTrack::VideoTrack): Use references.
+        (WebCore::VideoTrack::setPrivate): Ditto.
+        (WebCore::VideoTrack::setSelected): Ditto.
+        (WebCore::VideoTrack::inbandTrackIndex): Removed assertion since m_private
+        is now a Ref instead of a RefPtr.
+        (WebCore::VideoTrack::selectedChanged): Removed unneeded track private argument.
+        (WebCore::VideoTrack::idChanged): Ditto.
+        (WebCore::VideoTrack::labelChanged): Ditto.
+        (WebCore::VideoTrack::languageChanged): Ditto.
+        (WebCore::VideoTrack::willRemove): Ditto.
+        (WebCore::VideoTrack::setKind): Updated to use reference.
+        (WebCore::VideoTrack::setLanguage): Ditto.
+        * html/track/VideoTrack.h: Updated for the above. Changed derivation to private.
+        Removed unneeded defaultKindKeyword.
+
+        * loader/EmptyClients.h: Updated to use reference.
+
+        * loader/PingLoader.cpp:
+        (WebCore::PingLoader::sendViolationReport): Take a Ref&& instead of RefPtr&&.
+        * loader/PingLoader.h: Updated for above change.
+
+        * page/Chrome.cpp:
+        (WebCore::Chrome::loadIconForFiles): Take a reference.
+        * page/Chrome.h: Updated for above change.
+        * page/ChromeClient.h: Ditto.
+
+        * page/csp/ContentSecurityPolicy.cpp:
+        (WebCore::ContentSecurityPolicy::reportViolation): Use auto.
+
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
+        (WebPlaybackSessionModelMediaElement::selectAudioMediaOption): Simplified
+        algorithm by removing unneeded direct call to audioTrackEnabledChanged,
+        which will be called by setEnabled and doesn't need to be called again here.
+        (WebPlaybackSessionModelMediaElement::selectLegibleMediaOption): Removed
+        unhelpful assertion and unnneded initialization.
+
+        * platform/graphics/AudioTrackPrivate.h: Removed unnneeed track private
+        argument and initialized data members where they are defined.
+
+        * platform/graphics/InbandTextTrackPrivateClient.h: Use Ref instead of
+        PassRefPtr, initialize data members where they are defined, and removed
+        the unneeded track private arguments from the client functions.
+
+        * platform/graphics/SourceBufferPrivate.h: Fixed functions that were taking
+        AtomicString to take a const& instead. Use Ref&& instead of PassRefPtr.
+
+        * platform/graphics/SourceBufferPrivateClient.h: Removed unneded private pointer
+        arguments from client functions.
+
+        * platform/graphics/TrackPrivateBase.h: Removed unneeded private pointers
+        from client functions.
+        * platform/graphics/VideoTrackPrivate: Ditto.
+
+        * platform/graphics/avfoundation/AudioTrackPrivateAVF.h: Use
+        const AtomicString&.
+
+        * platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp:
+        (WebCore::InbandMetadataTextTrackPrivateAVF::addDataCue): Updated for change to arguments.
+        (WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes): Ditto.
+        (WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues): Ditto.
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+        (WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Ditto.
+        (WebCore::InbandTextTrackPrivateAVF::resetCueValues): Ditto.
+        (WebCore::InbandTextTrackPrivateAVF::processNativeSamples): Ditto.
+
+        * platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp:
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC):
+        Moved initialization of data memebrs to where they are defined.
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::enabled): Deleted. No longer needed.
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::setEnabled): Changed to use the enabled
+        flag from the base class instead of a separate m_enabled in this class.
+        * platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h:
+        Removed the enabled function and the m_enabled data member.
+
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: Marked functions
+        final instead of override and updated arguemnts.
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): Updated for change
+        to arguments.
+        (WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::appendCompleted): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::hasVideo): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::hasAudio): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::layerDidReceiveError): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::flush): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::seekToTime): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): Ditto.
+
+        * platform/graphics/gstreamer/InbandMetadataTextTrackPrivateGStreamer.h: Updated for
+        changes to arguments.
+        * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
+        (WebCore::InbandTextTrackPrivateGStreamer::notifyTrackOfSample): Ditto.
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
+        (WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged): Ditto.
+        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
+        (WebCore::AppendPipeline::appsinkNewSample): Ditto.
+        * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
+        (WebCore::SourceBufferPrivateGStreamer::append): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::flush): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::enqueueSample): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::isReadyForMoreSamples): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::notifyReadyForMoreSamples): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::stopAskingForMoreSamples): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::didReceiveInitializationSegment): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::didReceiveSample): Ditto.
+        (WebCore::SourceBufferPrivateGStreamer::didReceiveAllPendingSamples): Ditto.
+        * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h: Ditto.
+        * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+        (WebCore::MockSourceBufferPrivate::append): Ditto.
+        (WebCore::MockSourceBufferPrivate::didReceiveInitializationSegment): Ditto.
+        (WebCore::MockSourceBufferPrivate::didReceiveSample): Ditto.
+        (WebCore::MockSourceBufferPrivate::enqueuedSamplesForTrackID): Ditto.
+        (WebCore::MockSourceBufferPrivate::enqueueSample): Ditto.
+        (WebCore::MockSourceBufferPrivate::hasVideo): Ditto.
+        (WebCore::MockSourceBufferPrivate::hasAudio): Ditto.
+        (WebCore::MockSourceBufferPrivate::fastSeekTimeForMediaTime): Ditto.
+        (WebCore::MockSourceBufferPrivate::seekToTime): Ditto.
+        * platform/mock/mediasource/MockSourceBufferPrivate.h: Ditto.
+
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugIn::updateSnapshot): Take raw pointer instead
+        of PassRefPtr.
+        * rendering/RenderSnapshottedPlugIn.h: Updated for above change.
+
+        * svg/SVGScriptElement.h: Added using to resolve the ambiguity with the
+        ref/deref from SVGElement and from ScriptElement.
+
+        * xml/parser/XMLDocumentParser.cpp:
+        (WebCore::XMLDocumentParser::notifyFinished): Updated to simplify since
+        the pending script now has a script element.
+
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::startElementNs): Use isSciprtElement instead
+        of toScriptElementIfPossible.
+        (WebCore::XMLDocumentParser::endElementNs): Ditto. Also use downcastScriptElement.
+
 2017-01-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Move editing history scripts to WebCore PrivateHeaders
index 43c0d00..4f188b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2013 Google Inc. All rights reserved.
- * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -693,18 +693,18 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
     buffer.abortIfUpdating();
 
     // 4. Let SourceBuffer audioTracks list equal the AudioTrackList object returned by sourceBuffer.audioTracks.
-    RefPtr<AudioTrackList> audioTracks = buffer.audioTracks();
+    auto& audioTracks = buffer.audioTracks();
 
     // 5. If the SourceBuffer audioTracks list is not empty, then run the following steps:
-    if (audioTracks->length()) {
+    if (audioTracks.length()) {
         // 5.1 Let HTMLMediaElement audioTracks list equal the AudioTrackList object returned by the audioTracks
         // attribute on the HTMLMediaElement.
         // 5.2 Let the removed enabled audio track flag equal false.
         bool removedEnabledAudioTrack = false;
 
         // 5.3 For each AudioTrack object in the SourceBuffer audioTracks list, run the following steps:
-        while (audioTracks->length()) {
-            auto& track = *audioTracks->lastItem();
+        while (audioTracks.length()) {
+            auto& track = *audioTracks.lastItem();
 
             // 5.3.1 Set the sourceBuffer attribute on the AudioTrack object to null.
             track.setSourceBuffer(nullptr);
@@ -723,7 +723,7 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
             // 5.3.5 Remove the AudioTrack object from the SourceBuffer audioTracks list.
             // 5.3.6 Queue a task to fire a trusted event named removetrack, that does not bubble and is not
             // cancelable, and that uses the TrackEvent interface, at the SourceBuffer audioTracks list.
-            audioTracks->remove(track);
+            audioTracks.remove(track);
         }
 
         // 5.4 If the removed enabled audio track flag equals true, then queue a task to fire a simple event
@@ -733,18 +733,18 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
     }
 
     // 6. Let SourceBuffer videoTracks list equal the VideoTrackList object returned by sourceBuffer.videoTracks.
-    RefPtr<VideoTrackList> videoTracks = buffer.videoTracks();
+    auto& videoTracks = buffer.videoTracks();
 
     // 7. If the SourceBuffer videoTracks list is not empty, then run the following steps:
-    if (videoTracks->length()) {
+    if (videoTracks.length()) {
         // 7.1 Let HTMLMediaElement videoTracks list equal the VideoTrackList object returned by the videoTracks
         // attribute on the HTMLMediaElement.
         // 7.2 Let the removed selected video track flag equal false.
         bool removedSelectedVideoTrack = false;
 
         // 7.3 For each VideoTrack object in the SourceBuffer videoTracks list, run the following steps:
-        while (videoTracks->length()) {
-            auto& track = *videoTracks->lastItem();
+        while (videoTracks.length()) {
+            auto& track = *videoTracks.lastItem();
 
             // 7.3.1 Set the sourceBuffer attribute on the VideoTrack object to null.
             track.setSourceBuffer(nullptr);
@@ -763,7 +763,7 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
             // 7.3.5 Remove the VideoTrack object from the SourceBuffer videoTracks list.
             // 7.3.6 Queue a task to fire a trusted event named removetrack, that does not bubble and is not
             // cancelable, and that uses the TrackEvent interface, at the SourceBuffer videoTracks list.
-            videoTracks->remove(track);
+            videoTracks.remove(track);
         }
 
         // 7.4 If the removed selected video track flag equals true, then queue a task to fire a simple event
@@ -773,18 +773,18 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
     }
 
     // 8. Let SourceBuffer textTracks list equal the TextTrackList object returned by sourceBuffer.textTracks.
-    RefPtr<TextTrackList> textTracks = buffer.textTracks();
+    auto& textTracks = buffer.textTracks();
 
     // 9. If the SourceBuffer textTracks list is not empty, then run the following steps:
-    if (textTracks->length()) {
+    if (textTracks.length()) {
         // 9.1 Let HTMLMediaElement textTracks list equal the TextTrackList object returned by the textTracks
         // attribute on the HTMLMediaElement.
         // 9.2 Let the removed enabled text track flag equal false.
         bool removedEnabledTextTrack = false;
 
         // 9.3 For each TextTrack object in the SourceBuffer textTracks list, run the following steps:
-        while (textTracks->length()) {
-            auto& track = *textTracks->lastItem();
+        while (textTracks.length()) {
+            auto& track = *textTracks.lastItem();
 
             // 9.3.1 Set the sourceBuffer attribute on the TextTrack object to null.
             track.setSourceBuffer(nullptr);
@@ -803,7 +803,7 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
             // 9.3.5 Remove the TextTrack object from the SourceBuffer textTracks list.
             // 9.3.6 Queue a task to fire a trusted event named removetrack, that does not bubble and is not
             // cancelable, and that uses the TrackEvent interface, at the SourceBuffer textTracks list.
-            textTracks->remove(track);
+            textTracks.remove(track);
         }
 
         // 9.4 If the removed enabled text track flag equals true, then queue a task to fire a simple event
index 7fee7e6..d9ae527 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2013 Google Inc. All rights reserved.
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -59,9 +59,6 @@
 #include <runtime/VM.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/NeverDestroyed.h>
-#if !LOG_DISABLED
-#include <wtf/text/StringBuilder.h>
-#endif
 
 namespace WebCore {
 
@@ -421,7 +418,7 @@ void SourceBuffer::seekToTime(const MediaTime& time)
     }
 }
 
-MediaTime SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime(SourceBufferPrivate*, const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold)
+MediaTime SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold)
 {
     MediaTime seekTime = targetTime;
     MediaTime lowerBoundTime = targetTime - negativeThreshold;
@@ -566,7 +563,7 @@ void SourceBuffer::appendBufferTimerFired()
 
     // 1. Loop Top: If the input buffer is empty, then jump to the need more data step below.
     if (!m_pendingAppendData.size()) {
-        sourceBufferPrivateAppendComplete(&m_private.get(), AppendSucceeded);
+        sourceBufferPrivateAppendComplete(AppendSucceeded);
         return;
     }
 
@@ -574,7 +571,7 @@ void SourceBuffer::appendBufferTimerFired()
     m_pendingAppendData.clear();
 }
 
-void SourceBuffer::sourceBufferPrivateAppendComplete(SourceBufferPrivate*, AppendResult result)
+void SourceBuffer::sourceBufferPrivateAppendComplete(AppendResult result)
 {
     if (isRemoved())
         return;
@@ -635,7 +632,7 @@ void SourceBuffer::sourceBufferPrivateAppendComplete(SourceBufferPrivate*, Appen
     LOG(Media, "SourceBuffer::sourceBufferPrivateAppendComplete(%p) - buffered = %s", this, toString(m_buffered->ranges()).utf8().data());
 }
 
-void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int error)
+void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(int error)
 {
 #if LOG_DISABLED
     UNUSED_PARAM(error);
@@ -945,35 +942,32 @@ size_t SourceBuffer::maximumBufferSize() const
     if (isRemoved())
         return 0;
 
-    HTMLMediaElement* element = m_source->mediaElement();
+    auto* element = m_source->mediaElement();
     if (!element)
         return 0;
 
     return element->maximumSourceBufferSize(*this);
 }
 
-VideoTrackList* SourceBuffer::videoTracks()
+VideoTrackList& SourceBuffer::videoTracks()
 {
     if (!m_videoTracks)
-        m_videoTracks = VideoTrackList::create(m_source->mediaElement(), ActiveDOMObject::scriptExecutionContext());
-
-    return m_videoTracks.get();
+        m_videoTracks = VideoTrackList::create(m_source->mediaElement(), scriptExecutionContext());
+    return *m_videoTracks;
 }
 
-AudioTrackList* SourceBuffer::audioTracks()
+AudioTrackList& SourceBuffer::audioTracks()
 {
     if (!m_audioTracks)
-        m_audioTracks = AudioTrackList::create(m_source->mediaElement(), ActiveDOMObject::scriptExecutionContext());
-
-    return m_audioTracks.get();
+        m_audioTracks = AudioTrackList::create(m_source->mediaElement(), scriptExecutionContext());
+    return *m_audioTracks;
 }
 
-TextTrackList* SourceBuffer::textTracks()
+TextTrackList& SourceBuffer::textTracks()
 {
     if (!m_textTracks)
-        m_textTracks = TextTrackList::create(m_source->mediaElement(), ActiveDOMObject::scriptExecutionContext());
-
-    return m_textTracks.get();
+        m_textTracks = TextTrackList::create(m_source->mediaElement(), scriptExecutionContext());
+    return *m_textTracks;
 }
 
 void SourceBuffer::setActive(bool active)
@@ -987,7 +981,7 @@ void SourceBuffer::setActive(bool active)
         m_source->sourceBufferDidChangeActiveState(*this, active);
 }
 
-void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivate*, const InitializationSegment& segment)
+void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(const InitializationSegment& segment)
 {
     if (isRemoved())
         return;
@@ -1024,40 +1018,40 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
             return;
         }
         // 3.2 Add the appropriate track descriptions from this initialization segment to each of the track buffers.
-        ASSERT(segment.audioTracks.size() == audioTracks()->length());
+        ASSERT(segment.audioTracks.size() == audioTracks().length());
         for (auto& audioTrackInfo : segment.audioTracks) {
-            if (audioTracks()->length() == 1) {
-                audioTracks()->item(0)->setPrivate(audioTrackInfo.track);
+            if (audioTracks().length() == 1) {
+                audioTracks().item(0)->setPrivate(*audioTrackInfo.track);
                 break;
             }
 
-            auto audioTrack = audioTracks()->getTrackById(audioTrackInfo.track->id());
+            auto audioTrack = audioTracks().getTrackById(audioTrackInfo.track->id());
             ASSERT(audioTrack);
-            audioTrack->setPrivate(audioTrackInfo.track);
+            audioTrack->setPrivate(*audioTrackInfo.track);
         }
 
-        ASSERT(segment.videoTracks.size() == videoTracks()->length());
+        ASSERT(segment.videoTracks.size() == videoTracks().length());
         for (auto& videoTrackInfo : segment.videoTracks) {
-            if (videoTracks()->length() == 1) {
-                videoTracks()->item(0)->setPrivate(videoTrackInfo.track);
+            if (videoTracks().length() == 1) {
+                videoTracks().item(0)->setPrivate(*videoTrackInfo.track);
                 break;
             }
 
-            auto videoTrack = videoTracks()->getTrackById(videoTrackInfo.track->id());
+            auto videoTrack = videoTracks().getTrackById(videoTrackInfo.track->id());
             ASSERT(videoTrack);
-            videoTrack->setPrivate(videoTrackInfo.track);
+            videoTrack->setPrivate(*videoTrackInfo.track);
         }
 
-        ASSERT(segment.textTracks.size() == textTracks()->length());
+        ASSERT(segment.textTracks.size() == textTracks().length());
         for (auto& textTrackInfo : segment.textTracks) {
-            if (textTracks()->length() == 1) {
-                downcast<InbandTextTrack>(*textTracks()->item(0)).setPrivate(textTrackInfo.track);
+            if (textTracks().length() == 1) {
+                downcast<InbandTextTrack>(*textTracks().item(0)).setPrivate(*textTrackInfo.track);
                 break;
             }
 
-            auto textTrack = textTracks()->getTrackById(textTrackInfo.track->id());
+            auto textTrack = textTracks().getTrackById(textTrackInfo.track->id());
             ASSERT(textTrack);
-            downcast<InbandTextTrack>(*textTrack).setPrivate(textTrackInfo.track);
+            downcast<InbandTextTrack>(*textTrack).setPrivate(*textTrackInfo.track);
         }
 
         // 3.3 Set the need random access point flag on all track buffers to true.
@@ -1076,16 +1070,14 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
 
         // 5.2 For each audio track in the initialization segment, run following steps:
         for (auto& audioTrackInfo : segment.audioTracks) {
-            AudioTrackPrivate* audioTrackPrivate = audioTrackInfo.track.get();
-
             // FIXME: Implement steps 5.2.1-5.2.8.1 as per Editor's Draft 09 January 2015, and reorder this
             // 5.2.1 Let new audio track be a new AudioTrack object.
             // 5.2.2 Generate a unique ID and assign it to the id property on new video track.
-            auto newAudioTrack = AudioTrack::create(this, audioTrackPrivate);
+            auto newAudioTrack = AudioTrack::create(*this, *audioTrackInfo.track);
             newAudioTrack->setSourceBuffer(this);
 
             // 5.2.3 If audioTracks.length equals 0, then run the following steps:
-            if (!audioTracks()->length()) {
+            if (!audioTracks().length()) {
                 // 5.2.3.1 Set the enabled property on new audio track to true.
                 newAudioTrack->setEnabled(true);
 
@@ -1097,7 +1089,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
             // 5.2.5 Queue a task to fire a trusted event named addtrack, that does not bubble and is
             // not cancelable, and that uses the TrackEvent interface, at the AudioTrackList object
             // referenced by the audioTracks attribute on this SourceBuffer object.
-            audioTracks()->append(newAudioTrack.copyRef());
+            audioTracks().append(newAudioTrack.copyRef());
 
             // 5.2.6 Add new audio track to the audioTracks attribute on the HTMLMediaElement.
             // 5.2.7 Queue a task to fire a trusted event named addtrack, that does not bubble and is
@@ -1107,7 +1099,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
 
             // 5.2.8 Create a new track buffer to store coded frames for this track.
             ASSERT(!m_trackBufferMap.contains(newAudioTrack->id()));
-            TrackBuffer& trackBuffer = m_trackBufferMap.add(newAudioTrack->id(), TrackBuffer()).iterator->value;
+            auto& trackBuffer = m_trackBufferMap.add(newAudioTrack->id(), TrackBuffer()).iterator->value;
 
             // 5.2.9 Add the track description for this track to the track buffer.
             trackBuffer.description = audioTrackInfo.description;
@@ -1117,16 +1109,14 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
 
         // 5.3 For each video track in the initialization segment, run following steps:
         for (auto& videoTrackInfo : segment.videoTracks) {
-            VideoTrackPrivate* videoTrackPrivate = videoTrackInfo.track.get();
-
             // FIXME: Implement steps 5.3.1-5.3.8.1 as per Editor's Draft 09 January 2015, and reorder this
             // 5.3.1 Let new video track be a new VideoTrack object.
             // 5.3.2 Generate a unique ID and assign it to the id property on new video track.
-            auto newVideoTrack = VideoTrack::create(this, videoTrackPrivate);
+            auto newVideoTrack = VideoTrack::create(*this, *videoTrackInfo.track);
             newVideoTrack->setSourceBuffer(this);
 
             // 5.3.3 If videoTracks.length equals 0, then run the following steps:
-            if (!videoTracks()->length()) {
+            if (!videoTracks().length()) {
                 // 5.3.3.1 Set the selected property on new video track to true.
                 newVideoTrack->setSelected(true);
 
@@ -1138,7 +1128,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
             // 5.3.5 Queue a task to fire a trusted event named addtrack, that does not bubble and is
             // not cancelable, and that uses the TrackEvent interface, at the VideoTrackList object
             // referenced by the videoTracks attribute on this SourceBuffer object.
-            videoTracks()->append(newVideoTrack.copyRef());
+            videoTracks().append(newVideoTrack.copyRef());
 
             // 5.3.6 Add new video track to the videoTracks attribute on the HTMLMediaElement.
             // 5.3.7 Queue a task to fire a trusted event named addtrack, that does not bubble and is
@@ -1148,7 +1138,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
 
             // 5.3.8 Create a new track buffer to store coded frames for this track.
             ASSERT(!m_trackBufferMap.contains(newVideoTrack->id()));
-            TrackBuffer& trackBuffer = m_trackBufferMap.add(newVideoTrack->id(), TrackBuffer()).iterator->value;
+            auto& trackBuffer = m_trackBufferMap.add(newVideoTrack->id(), TrackBuffer()).iterator->value;
 
             // 5.3.9 Add the track description for this track to the track buffer.
             trackBuffer.description = videoTrackInfo.description;
@@ -1158,33 +1148,33 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBuff
 
         // 5.4 For each text track in the initialization segment, run following steps:
         for (auto& textTrackInfo : segment.textTracks) {
-            InbandTextTrackPrivate* textTrackPrivate = textTrackInfo.track.get();
+            auto& textTrackPrivate = *textTrackInfo.track;
 
             // FIXME: Implement steps 5.4.1-5.4.8.1 as per Editor's Draft 09 January 2015, and reorder this
             // 5.4.1 Let new text track be a new TextTrack object with its properties populated with the
             // appropriate information from the initialization segment.
-            RefPtr<InbandTextTrack> newTextTrack = InbandTextTrack::create(scriptExecutionContext(), this, textTrackPrivate);
+            auto newTextTrack = InbandTextTrack::create(*scriptExecutionContext(), *this, textTrackPrivate);
 
             // 5.4.2 If the mode property on new text track equals "showing" or "hidden", then set active
             // track flag to true.
-            if (textTrackPrivate->mode() != InbandTextTrackPrivate::Disabled)
+            if (textTrackPrivate.mode() != InbandTextTrackPrivate::Disabled)
                 activeTrackFlag = true;
 
             // 5.4.3 Add new text track to the textTracks attribute on this SourceBuffer object.
             // 5.4.4 Queue a task to fire a trusted event named addtrack, that does not bubble and is
             // not cancelable, and that uses the TrackEvent interface, at textTracks attribute on this
             // SourceBuffer object.
-            textTracks()->append(*newTextTrack);
+            textTracks().append(newTextTrack.get());
 
             // 5.4.5 Add new text track to the textTracks attribute on the HTMLMediaElement.
             // 5.4.6 Queue a task to fire a trusted event named addtrack, that does not bubble and is
             // not cancelable, and that uses the TrackEvent interface, at the TextTrackList object
             // referenced by the textTracks attribute on the HTMLMediaElement.
-            m_source->mediaElement()->textTracks().append(newTextTrack.releaseNonNull());
+            m_source->mediaElement()->textTracks().append(WTFMove(newTextTrack));
 
             // 5.4.7 Create a new track buffer to store coded frames for this track.
-            ASSERT(!m_trackBufferMap.contains(textTrackPrivate->id()));
-            TrackBuffer& trackBuffer = m_trackBufferMap.add(textTrackPrivate->id(), TrackBuffer()).iterator->value;
+            ASSERT(!m_trackBufferMap.contains(textTrackPrivate.id()));
+            auto& trackBuffer = m_trackBufferMap.add(textTrackPrivate.id(), TrackBuffer()).iterator->value;
 
             // 5.4.8 Add the track description for this track to the track buffer.
             trackBuffer.description = textTrackInfo.description;
@@ -1231,9 +1221,9 @@ bool SourceBuffer::validateInitializationSegment(const InitializationSegment& se
 
     // Note: those are checks from step 3.1
     //   * The number of audio, video, and text tracks match what was in the first initialization segment.
-    if (segment.audioTracks.size() != audioTracks()->length()
-        || segment.videoTracks.size() != videoTracks()->length()
-        || segment.textTracks.size() != textTracks()->length())
+    if (segment.audioTracks.size() != audioTracks().length()
+        || segment.videoTracks.size() != videoTracks().length()
+        || segment.textTracks.size() != textTracks().length())
         return false;
 
     //   * The codecs for each track, match what was specified in the first initialization segment.
@@ -1319,7 +1309,7 @@ void SourceBuffer::appendError(bool decodeErrorParam)
         m_source->streamEndedWithError(MediaSource::EndOfStreamError::Decode);
 }
 
-void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, MediaSample& sample)
+void SourceBuffer::sourceBufferPrivateDidReceiveSample(MediaSample& sample)
 {
     if (isRemoved())
         return;
@@ -1666,30 +1656,30 @@ bool SourceBuffer::hasVideo() const
     return m_videoTracks && m_videoTracks->length();
 }
 
-bool SourceBuffer::sourceBufferPrivateHasAudio(const SourceBufferPrivate*) const
+bool SourceBuffer::sourceBufferPrivateHasAudio() const
 {
     return hasAudio();
 }
 
-bool SourceBuffer::sourceBufferPrivateHasVideo(const SourceBufferPrivate*) const
+bool SourceBuffer::sourceBufferPrivateHasVideo() const
 {
     return hasVideo();
 }
 
-void SourceBuffer::videoTrackSelectedChanged(VideoTrack* track)
+void SourceBuffer::videoTrackSelectedChanged(VideoTrack& track)
 {
     // 2.4.5 Changes to selected/enabled track state
     // If the selected video track changes, then run the following steps:
     // 1. If the SourceBuffer associated with the previously selected video track is not associated with
     // any other enabled tracks, run the following steps:
-    if (!track->selected()
+    if (!track.selected()
         && (!m_videoTracks || !m_videoTracks->isAnyTrackEnabled())
         && (!m_audioTracks || !m_audioTracks->isAnyTrackEnabled())
         && (!m_textTracks || !m_textTracks->isAnyTrackEnabled())) {
         // 1.1 Remove the SourceBuffer from activeSourceBuffers.
         // 1.2 Queue a task to fire a simple event named removesourcebuffer at activeSourceBuffers
         setActive(false);
-    } else if (track->selected()) {
+    } else if (track.selected()) {
         // 2. If the SourceBuffer associated with the newly selected video track is not already in activeSourceBuffers,
         // run the following steps:
         // 2.1 Add the SourceBuffer to activeSourceBuffers.
@@ -1697,26 +1687,26 @@ void SourceBuffer::videoTrackSelectedChanged(VideoTrack* track)
         setActive(true);
     }
 
-    if (m_videoTracks && m_videoTracks->contains(*track))
+    if (m_videoTracks && m_videoTracks->contains(track))
         m_videoTracks->scheduleChangeEvent();
 
     if (!isRemoved())
         m_source->mediaElement()->videoTrackSelectedChanged(track);
 }
 
-void SourceBuffer::audioTrackEnabledChanged(AudioTrack* track)
+void SourceBuffer::audioTrackEnabledChanged(AudioTrack& track)
 {
     // 2.4.5 Changes to selected/enabled track state
     // If an audio track becomes disabled and the SourceBuffer associated with this track is not
     // associated with any other enabled or selected track, then run the following steps:
-    if (!track->enabled()
+    if (!track.enabled()
         && (!m_videoTracks || !m_videoTracks->isAnyTrackEnabled())
         && (!m_audioTracks || !m_audioTracks->isAnyTrackEnabled())
         && (!m_textTracks || !m_textTracks->isAnyTrackEnabled())) {
         // 1. Remove the SourceBuffer associated with the audio track from activeSourceBuffers
         // 2. Queue a task to fire a simple event named removesourcebuffer at activeSourceBuffers
         setActive(false);
-    } else if (track->enabled()) {
+    } else if (track.enabled()) {
         // If an audio track becomes enabled and the SourceBuffer associated with this track is
         // not already in activeSourceBuffers, then run the following steps:
         // 1. Add the SourceBuffer associated with the audio track to activeSourceBuffers
@@ -1724,19 +1714,19 @@ void SourceBuffer::audioTrackEnabledChanged(AudioTrack* track)
         setActive(true);
     }
 
-    if (m_audioTracks && m_audioTracks->contains(*track))
+    if (m_audioTracks && m_audioTracks->contains(track))
         m_audioTracks->scheduleChangeEvent();
 
     if (!isRemoved())
         m_source->mediaElement()->audioTrackEnabledChanged(track);
 }
 
-void SourceBuffer::textTrackModeChanged(TextTrack* track)
+void SourceBuffer::textTrackModeChanged(TextTrack& track)
 {
     // 2.4.5 Changes to selected/enabled track state
     // If a text track mode becomes "disabled" and the SourceBuffer associated with this track is not
     // associated with any other enabled or selected track, then run the following steps:
-    if (track->mode() == TextTrack::Mode::Disabled
+    if (track.mode() == TextTrack::Mode::Disabled
         && (!m_videoTracks || !m_videoTracks->isAnyTrackEnabled())
         && (!m_audioTracks || !m_audioTracks->isAnyTrackEnabled())
         && (!m_textTracks || !m_textTracks->isAnyTrackEnabled())) {
@@ -1751,56 +1741,56 @@ void SourceBuffer::textTrackModeChanged(TextTrack* track)
         setActive(true);
     }
 
-    if (m_textTracks && m_textTracks->contains(*track))
+    if (m_textTracks && m_textTracks->contains(track))
         m_textTracks->scheduleChangeEvent();
 
     if (!isRemoved())
         m_source->mediaElement()->textTrackModeChanged(track);
 }
 
-void SourceBuffer::textTrackAddCue(TextTrack* track, TextTrackCue& cue)
+void SourceBuffer::textTrackAddCue(TextTrack& track, TextTrackCue& cue)
 {
     if (!isRemoved())
         m_source->mediaElement()->textTrackAddCue(track, cue);
 }
 
-void SourceBuffer::textTrackAddCues(TextTrack* track, TextTrackCueList const* cueList)
+void SourceBuffer::textTrackAddCues(TextTrack& track, const TextTrackCueList& cueList)
 {
     if (!isRemoved())
         m_source->mediaElement()->textTrackAddCues(track, cueList);
 }
 
-void SourceBuffer::textTrackRemoveCue(TextTrack* track, TextTrackCue& cue)
+void SourceBuffer::textTrackRemoveCue(TextTrack& track, TextTrackCue& cue)
 {
     if (!isRemoved())
         m_source->mediaElement()->textTrackRemoveCue(track, cue);
 }
 
-void SourceBuffer::textTrackRemoveCues(TextTrack* track, TextTrackCueList const* cueList)
+void SourceBuffer::textTrackRemoveCues(TextTrack& track, const TextTrackCueList& cueList)
 {
     if (!isRemoved())
         m_source->mediaElement()->textTrackRemoveCues(track, cueList);
 }
 
-void SourceBuffer::textTrackKindChanged(TextTrack* track)
+void SourceBuffer::textTrackKindChanged(TextTrack& track)
 {
     if (!isRemoved())
         m_source->mediaElement()->textTrackKindChanged(track);
 }
 
-void SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples(SourceBufferPrivate*, AtomicString trackID)
+void SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples(const AtomicString& trackID)
 {
     LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples(%p)", this);
     auto it = m_trackBufferMap.find(trackID);
     if (it == m_trackBufferMap.end())
         return;
 
-    TrackBuffer& trackBuffer = it->value;
+    auto& trackBuffer = it->value;
     if (!trackBuffer.needsReenqueueing && !m_source->isSeeking())
         provideMediaData(trackBuffer, trackID);
 }
 
-void SourceBuffer::provideMediaData(TrackBuffer& trackBuffer, AtomicString trackID)
+void SourceBuffer::provideMediaData(TrackBuffer& trackBuffer, const AtomicString& trackID)
 {
     if (m_source->isSeeking())
         return;
@@ -1834,7 +1824,7 @@ void SourceBuffer::provideMediaData(TrackBuffer& trackBuffer, AtomicString track
 
         trackBuffer.lastEnqueuedPresentationTime = sample->presentationTime();
         trackBuffer.lastEnqueuedDecodeEndTime = sample->decodeTime() + sample->duration();
-        m_private->enqueueSample(WTFMove(sample), trackID);
+        m_private->enqueueSample(sample.releaseNonNull(), trackID);
 #if !LOG_DISABLED
         ++enqueuedSamples;
 #endif
@@ -1843,7 +1833,7 @@ void SourceBuffer::provideMediaData(TrackBuffer& trackBuffer, AtomicString track
     LOG(MediaSource, "SourceBuffer::provideMediaData(%p) - Enqueued %u samples", this, enqueuedSamples);
 }
 
-void SourceBuffer::reenqueueMediaForTime(TrackBuffer& trackBuffer, AtomicString trackID, const MediaTime& time)
+void SourceBuffer::reenqueueMediaForTime(TrackBuffer& trackBuffer, const AtomicString& trackID, const MediaTime& time)
 {
     m_private->flush(trackID);
     trackBuffer.decodeQueue.clear();
index d9e1747..5a142d4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2013 Google Inc. All rights reserved.
- * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -49,6 +49,7 @@ class AudioTrackList;
 class BufferSource;
 class MediaSource;
 class PlatformTimeRanges;
+class SourceBufferPrivate;
 class TextTrackList;
 class TimeRanges;
 class VideoTrackList;
@@ -64,9 +65,9 @@ public:
     ExceptionOr<void> setTimestampOffset(double);
 
 #if ENABLE(VIDEO_TRACK)
-    VideoTrackList* videoTracks();
-    AudioTrackList* audioTracks();
-    TextTrackList* textTracks();
+    VideoTrackList& videoTracks();
+    AudioTrackList& audioTracks();
+    TextTrackList& textTracks();
 #endif
 
     double appendWindowStart() const;
@@ -124,25 +125,24 @@ private:
     const char* activeDOMObjectName() const final;
     bool canSuspendForDocumentSuspension() const final;
 
-    void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivate*, const InitializationSegment&) final;
-    void sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, MediaSample&) final;
-    bool sourceBufferPrivateHasAudio(const SourceBufferPrivate*) const final;
-    bool sourceBufferPrivateHasVideo(const SourceBufferPrivate*) const final;
-    void sourceBufferPrivateDidBecomeReadyForMoreSamples(SourceBufferPrivate*, AtomicString trackID) final;
-    MediaTime sourceBufferPrivateFastSeekTimeForMediaTime(SourceBufferPrivate*, const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) final;
-    void sourceBufferPrivateAppendComplete(SourceBufferPrivate*, AppendResult) final;
-    void sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int errorCode) final;
-
-    void audioTrackEnabledChanged(AudioTrack*) final;
-
-    void videoTrackSelectedChanged(VideoTrack*) final;
-
-    void textTrackKindChanged(TextTrack*) final;
-    void textTrackModeChanged(TextTrack*) final;
-    void textTrackAddCues(TextTrack*, const TextTrackCueList*) final;
-    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) final;
-    void textTrackAddCue(TextTrack*, TextTrackCue&) final;
-    void textTrackRemoveCue(TextTrack*, TextTrackCue&) final;
+    void sourceBufferPrivateDidReceiveInitializationSegment(const InitializationSegment&) final;
+    void sourceBufferPrivateDidReceiveSample(MediaSample&) final;
+    bool sourceBufferPrivateHasAudio() const final;
+    bool sourceBufferPrivateHasVideo() const final;
+    void sourceBufferPrivateDidBecomeReadyForMoreSamples(const AtomicString& trackID) final;
+    MediaTime sourceBufferPrivateFastSeekTimeForMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) final;
+    void sourceBufferPrivateAppendComplete(AppendResult) final;
+    void sourceBufferPrivateDidReceiveRenderingError(int errorCode) final;
+
+    void audioTrackEnabledChanged(AudioTrack&) final;
+    void videoTrackSelectedChanged(VideoTrack&) final;
+
+    void textTrackKindChanged(TextTrack&) final;
+    void textTrackModeChanged(TextTrack&) final;
+    void textTrackAddCues(TextTrack&, const TextTrackCueList&) final;
+    void textTrackRemoveCues(TextTrack&, const TextTrackCueList&) final;
+    void textTrackAddCue(TextTrack&, TextTrackCue&) final;
+    void textTrackRemoveCue(TextTrack&, TextTrackCue&) final;
 
     EventTargetInterface eventTargetInterface() const final { return SourceBufferEventTargetInterfaceType; }
 
@@ -157,8 +157,8 @@ private:
 
     bool validateInitializationSegment(const InitializationSegment&);
 
-    void reenqueueMediaForTime(TrackBuffer&, AtomicString trackID, const MediaTime&);
-    void provideMediaData(TrackBuffer&, AtomicString trackID);
+    void reenqueueMediaForTime(TrackBuffer&, const AtomicString& trackID, const MediaTime&);
+    void provideMediaData(TrackBuffer&, const AtomicString& trackID);
     void didDropSample();
     void evictCodedFrames(size_t newDataSize);
     size_t maximumBufferSize() const;
index ca6bef5..6b955c0 100644 (file)
                6E3FAE8E14733FDB00E42307 /* WebGLDepthTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAE8C14733FDB00E42307 /* WebGLDepthTexture.cpp */; };
                6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */; };
                6E3FAE8F14733FDB00E42307 /* WebGLDepthTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42307 /* WebGLDepthTexture.h */; };
-               6E47E66010B7944B00B186C8 /* WebGLGetInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */; };
-               6E47E66110B7944B00B186C8 /* WebGLGetInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */; };
+               6E47E66010B7944B00B186C8 /* WebGLAny.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E47E65E10B7944B00B186C8 /* WebGLAny.cpp */; };
+               6E47E66110B7944B00B186C8 /* WebGLAny.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E47E65F10B7944B00B186C8 /* WebGLAny.h */; };
                6E4ABCD4138EA0B70071D291 /* JSHTMLUnknownElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E4ABCD2138EA0B70071D291 /* JSHTMLUnknownElement.cpp */; };
                6E4ABCD5138EA0B70071D291 /* JSHTMLUnknownElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E4ABCD3138EA0B70071D291 /* JSHTMLUnknownElement.h */; };
                6E4E91AF10F7FB3100A2779C /* WebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E4E91AA10F7FB3100A2779C /* WebGLContextAttributes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6E3FAE8D14733FDB00E42307 /* WebGLDepthTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLDepthTexture.h; sourceTree = "<group>"; };
                6E3FAE9014733FEA00E42306 /* WebGLCompressedTextureS3TC.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLCompressedTextureS3TC.idl; sourceTree = "<group>"; };
                6E3FAE9014733FEA00E42307 /* WebGLDepthTexture.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLDepthTexture.idl; sourceTree = "<group>"; };
-               6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLGetInfo.cpp; sourceTree = "<group>"; };
-               6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLGetInfo.h; sourceTree = "<group>"; };
+               6E47E65E10B7944B00B186C8 /* WebGLAny.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLAny.cpp; sourceTree = "<group>"; };
+               6E47E65F10B7944B00B186C8 /* WebGLAny.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLAny.h; sourceTree = "<group>"; };
                6E4ABCD2138EA0B70071D291 /* JSHTMLUnknownElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLUnknownElement.cpp; sourceTree = "<group>"; };
                6E4ABCD3138EA0B70071D291 /* JSHTMLUnknownElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLUnknownElement.h; sourceTree = "<group>"; };
                6E4E91AA10F7FB3100A2779C /* WebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLContextAttributes.h; sourceTree = "<group>"; };
                                49C7B9AE1042D32E0009D447 /* WebGLFramebuffer.cpp */,
                                49C7B9AF1042D32E0009D447 /* WebGLFramebuffer.h */,
                                49C7B9B01042D32E0009D447 /* WebGLFramebuffer.idl */,
-                               6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */,
-                               6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */,
+                               6E47E65E10B7944B00B186C8 /* WebGLAny.cpp */,
+                               6E47E65F10B7944B00B186C8 /* WebGLAny.h */,
                                93F1D5B712D532C400832BEC /* WebGLLoseContext.cpp */,
                                93F1D5B812D532C400832BEC /* WebGLLoseContext.h */,
                                93F1D5B912D532C400832BEC /* WebGLLoseContext.idl */,
                                5B30695E18B3D3450099D5E8 /* WebGLDrawBuffers.h in Headers */,
                                6EBF0E5512A8929800DB1709 /* WebGLExtension.h in Headers */,
                                49C7B9CF1042D32F0009D447 /* WebGLFramebuffer.h in Headers */,
-                               6E47E66110B7944B00B186C8 /* WebGLGetInfo.h in Headers */,
+                               6E47E66110B7944B00B186C8 /* WebGLAny.h in Headers */,
                                49FFBF3F11C93EE3006A7118 /* WebGLLayer.h in Headers */,
                                93F1D5BB12D532C400832BEC /* WebGLLoseContext.h in Headers */,
                                49C7B9D51042D32F0009D447 /* WebGLObject.h in Headers */,
                                5B30695D18B3D3450099D5E8 /* WebGLDrawBuffers.cpp in Sources */,
                                6EBF0E5412A8929800DB1709 /* WebGLExtension.cpp in Sources */,
                                49C7B9CE1042D32F0009D447 /* WebGLFramebuffer.cpp in Sources */,
-                               6E47E66010B7944B00B186C8 /* WebGLGetInfo.cpp in Sources */,
+                               6E47E66010B7944B00B186C8 /* WebGLAny.cpp in Sources */,
                                49FFBF4011C93EE3006A7118 /* WebGLLayer.mm in Sources */,
                                93F1D5BA12D532C400832BEC /* WebGLLoseContext.cpp in Sources */,
                                49C7B9D41042D32F0009D447 /* WebGLObject.cpp in Sources */,
index e20b238..93b796a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -65,9 +65,9 @@ static CanvasStyle toHTMLCanvasStyle(ExecState*, JSValue value)
         return CanvasStyle();
     JSObject* object = asObject(value);
     if (object->inherits(JSCanvasGradient::info()))
-        return CanvasStyle(&jsCast<JSCanvasGradient*>(object)->wrapped());
+        return jsCast<JSCanvasGradient*>(object)->wrapped();
     if (object->inherits(JSCanvasPattern::info()))
-        return CanvasStyle(&jsCast<JSCanvasPattern*>(object)->wrapped());
+        return jsCast<JSCanvasPattern*>(object)->wrapped();
     return CanvasStyle();
 }
 
index f78a118..4181d74 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004-2008, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -40,7 +40,7 @@ Instance* pluginInstance(HTMLElement& element)
     // The plugin element holds an owning reference, so we don't have to.
     if (!is<HTMLPlugInElement>(element))
         return nullptr;
-    Instance* instance = downcast<HTMLPlugInElement>(element).getInstance().get();
+    auto* instance = downcast<HTMLPlugInElement>(element).bindingsInstance();
     if (!instance || !instance->rootObject())
         return nullptr;
     return instance;
@@ -71,23 +71,23 @@ JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
     if (!is<HTMLPlugInElement>(element))
         return nullptr;
 
-    HTMLPlugInElement& pluginElement = downcast<HTMLPlugInElement>(element);
+    auto& pluginElement = downcast<HTMLPlugInElement>(element);
 
     // Choke point for script/plugin interaction; notify DOMTimer of the event.
     DOMTimer::scriptDidInteractWithPlugin(pluginElement);
 
     // First, see if the element has a plug-in replacement with a script.
-    if (JSObject* scriptObject = pluginElement.scriptObjectForPluginReplacement())
+    if (auto* scriptObject = pluginElement.scriptObjectForPluginReplacement())
         return scriptObject;
     
     // Next, see if we can ask the plug-in view for its script object.
-    if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject()))
+    if (auto* scriptObject = pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject()))
         return scriptObject;
 
     // Otherwise, fall back to getting the object from the instance.
 
     // The plugin element holds an owning reference, so we don't have to.
-    Instance* instance = pluginElement.getInstance().get();
+    auto* instance = pluginElement.bindingsInstance();
     if (!instance || !instance->rootObject())
         return nullptr;
 
index 788ad24..4c50ccf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,37 +36,6 @@ using namespace JSC;
 
 namespace WebCore {
 
-// FIXME: There is a duplicate version of this function in JSWebGLRenderingContextBaseCustom.cpp,
-// but it is not exactly the same! We should merge these.
-static JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info)
-{
-    switch (info.getType()) {
-    case WebGLGetInfo::kTypeBool:
-        return jsBoolean(info.getBool());
-    case WebGLGetInfo::kTypeBoolArray: {
-        MarkedArgumentBuffer list;
-        for (auto& value : info.getBoolArray())
-            list.append(jsBoolean(value));
-        return constructArray(state, 0, globalObject, list);
-    }
-    case WebGLGetInfo::kTypeFloat:
-        return jsNumber(info.getFloat());
-    case WebGLGetInfo::kTypeInt:
-        return jsNumber(info.getInt());
-    case WebGLGetInfo::kTypeNull:
-        return jsNull();
-    case WebGLGetInfo::kTypeString:
-        return jsStringWithCache(state, info.getString());
-    case WebGLGetInfo::kTypeUnsignedInt:
-        return jsNumber(info.getUnsignedInt());
-    case WebGLGetInfo::kTypeInt64:
-        return jsNumber(info.getInt64());
-    default:
-        notImplemented();
-        return jsUndefined();
-    }
-}
-
 void JSWebGL2RenderingContext::visitAdditionalChildren(SlotVisitor& visitor)
 {
     visitor.addOpaqueRoot(&wrapped());
@@ -104,7 +73,7 @@ JSValue JSWebGL2RenderingContext::getIndexedParameter(ExecState& state)
     RETURN_IF_EXCEPTION(scope, JSValue());
     unsigned index = state.uncheckedArgument(1).toInt32(&state);
     RETURN_IF_EXCEPTION(scope, JSValue());
-    return toJS(&state, globalObject(), wrapped().getIndexedParameter(pname, index));
+    return toJS(state, *globalObject(), wrapped().getIndexedParameter(pname, index));
 }
 
 JSValue JSWebGL2RenderingContext::getActiveUniformBlockParameter(ExecState&)
index 825d250..533b0b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #if ENABLE(WEBGL)
 
-#include "JSWebGLRenderingContextBase.h"
-
-#include "ANGLEInstancedArrays.h"
 #include "EXTBlendMinMax.h"
 #include "EXTFragDepth.h"
 #include "EXTShaderTextureLOD.h"
 #include "EXTTextureFilterAnisotropic.h"
 #include "EXTsRGB.h"
 #include "ExceptionCode.h"
-#include "HTMLCanvasElement.h"
-#include "HTMLImageElement.h"
 #include "JSANGLEInstancedArrays.h"
 #include "JSEXTBlendMinMax.h"
 #include "JSEXTFragDepth.h"
@@ -73,7 +68,6 @@
 #include "JSWebGLVertexArrayObject.h"
 #include "JSWebGLVertexArrayObjectOES.h"
 #include "JSWebKitCSSMatrix.h"
-#include "NotImplemented.h"
 #include "OESElementIndexUint.h"
 #include "OESStandardDerivatives.h"
 #include "OESTextureFloat.h"
@@ -91,7 +85,6 @@
 #include "WebGLDrawBuffers.h"
 #include "WebGLExtension.h"
 #include "WebGLFramebuffer.h"
-#include "WebGLGetInfo.h"
 #include "WebGLLoseContext.h"
 #include "WebGLProgram.h"
 #include "WebGLRenderingContextBase.h"
 #include <wtf/FastMalloc.h>
 
 #if ENABLE(VIDEO)
-#include "HTMLVideoElement.h"
 #include "JSHTMLVideoElement.h"
 #endif
 
@@ -117,7 +109,7 @@ using namespace JSC;
 
 namespace WebCore {
 
-JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGLRenderingContextBase>&& object)
+JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGLRenderingContextBase>&& object)
 {
 #if ENABLE(WEBGL2)
     if (is<WebGL2RenderingContext>(object))
@@ -131,64 +123,7 @@ JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, WebGLRenderingCo
     return wrap(state, globalObject, object);
 }
     
-// FIXME: There is a duplicate version of this function in JSWebGL2RenderingContextCustom.cpp,
-// but it is not exactly the same! We should merge these.
-static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info)
-{
-    switch (info.getType()) {
-    case WebGLGetInfo::kTypeBool:
-        return jsBoolean(info.getBool());
-    case WebGLGetInfo::kTypeBoolArray: {
-        MarkedArgumentBuffer list;
-        for (auto& value : info.getBoolArray())
-            list.append(jsBoolean(value));
-        return constructArray(exec, 0, globalObject, list);
-    }
-    case WebGLGetInfo::kTypeFloat:
-        return jsNumber(info.getFloat());
-    case WebGLGetInfo::kTypeInt:
-        return jsNumber(info.getInt());
-    case WebGLGetInfo::kTypeNull:
-        return jsNull();
-    case WebGLGetInfo::kTypeString:
-        return jsStringWithCache(exec, info.getString());
-    case WebGLGetInfo::kTypeUnsignedInt:
-        return jsNumber(info.getUnsignedInt());
-    case WebGLGetInfo::kTypeWebGLBuffer:
-        return toJS(exec, globalObject, info.getWebGLBuffer());
-    case WebGLGetInfo::kTypeWebGLFloatArray:
-        return toJS(exec, globalObject, info.getWebGLFloatArray());
-    case WebGLGetInfo::kTypeWebGLFramebuffer:
-        return toJS(exec, globalObject, info.getWebGLFramebuffer());
-    case WebGLGetInfo::kTypeWebGLIntArray:
-        return toJS(exec, globalObject, info.getWebGLIntArray());
-        // FIXME: implement WebGLObjectArray
-        // case WebGLGetInfo::kTypeWebGLObjectArray:
-    case WebGLGetInfo::kTypeWebGLProgram:
-        return toJS(exec, globalObject, info.getWebGLProgram());
-    case WebGLGetInfo::kTypeWebGLRenderbuffer:
-        return toJS(exec, globalObject, info.getWebGLRenderbuffer());
-    case WebGLGetInfo::kTypeWebGLTexture:
-        return toJS(exec, globalObject, info.getWebGLTexture());
-    case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
-        return toJS(exec, globalObject, info.getWebGLUnsignedByteArray());
-    case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
-        return toJS(exec, globalObject, info.getWebGLUnsignedIntArray());
-#if ENABLE(WEBGL2)
-    case WebGLGetInfo::kTypeWebGLVertexArrayObject:
-        return toJS(exec, globalObject, info.getWebGLVertexArrayObject());
-#endif
-    case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
-        return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
-    default:
-        notImplemented();
-        return jsUndefined();
-    }
-}
-
-enum ObjectType { kBuffer, kRenderbuffer, kTexture, kVertexAttrib };
-
-static JSValue getObjectParameter(JSWebGLRenderingContextBase* obj, ExecState& state, ObjectType objectType)
+static JSValue objectParameter(JSWebGLRenderingContextBase& context, ExecState& state, WebGLAny (WebGLRenderingContextBase::*getter)(GC3Denum target, GC3Denum pname))
 {
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -196,90 +131,66 @@ static JSValue getObjectParameter(JSWebGLRenderingContextBase* obj, ExecState& s
     if (state.argumentCount() != 2)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
     
-    WebGLRenderingContextBase& context = obj->wrapped();
-    unsigned target = state.uncheckedArgument(0).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    WebGLGetInfo info;
-    switch (objectType) {
-    case kBuffer:
-        info = context.getBufferParameter(target, pname);
-        break;
-    case kRenderbuffer:
-        info = context.getRenderbufferParameter(target, pname);
-        break;
-    case kTexture:
-        info = context.getTexParameter(target, pname);
-        break;
-    case kVertexAttrib:
-        // target => index
-        info = context.getVertexAttrib(target, pname);
-        break;
-    default:
-        notImplemented();
-        break;
-    }
-    return toJS(&state, obj->globalObject(), info);
+    auto target = state.uncheckedArgument(0).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    auto pname = state.uncheckedArgument(1).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    return toJS(state, *context.globalObject(), (context.wrapped().*getter)(target, pname));
 }
 
-enum WhichProgramCall {
-    kProgramParameter, kUniform
-};
-
-static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExtension* extension)
+static JSValue toJS(ExecState& state, JSDOMGlobalObject& globalObject, WebGLExtension* extension)
 {
     if (!extension)
         return jsNull();
     switch (extension->getName()) {
     case WebGLExtension::WebGLLoseContextName:
-        return toJS(exec, globalObject, static_cast<WebGLLoseContext*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLLoseContext*>(extension));
     case WebGLExtension::EXTShaderTextureLODName:
-        return toJS(exec, globalObject, static_cast<EXTShaderTextureLOD*>(extension));
+        return toJS(&state, &globalObject, static_cast<EXTShaderTextureLOD*>(extension));
     case WebGLExtension::EXTTextureFilterAnisotropicName:
-        return toJS(exec, globalObject, static_cast<EXTTextureFilterAnisotropic*>(extension));
+        return toJS(&state, &globalObject, static_cast<EXTTextureFilterAnisotropic*>(extension));
     case WebGLExtension::EXTsRGBName:
-        return toJS(exec, globalObject, static_cast<EXTsRGB*>(extension));
+        return toJS(&state, &globalObject, static_cast<EXTsRGB*>(extension));
     case WebGLExtension::EXTFragDepthName:
-        return toJS(exec, globalObject, static_cast<EXTFragDepth*>(extension));
+        return toJS(&state, &globalObject, static_cast<EXTFragDepth*>(extension));
     case WebGLExtension::EXTBlendMinMaxName:
-        return toJS(exec, globalObject, static_cast<EXTBlendMinMax*>(extension));
+        return toJS(&state, &globalObject, static_cast<EXTBlendMinMax*>(extension));
     case WebGLExtension::OESStandardDerivativesName:
-        return toJS(exec, globalObject, static_cast<OESStandardDerivatives*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESStandardDerivatives*>(extension));
     case WebGLExtension::OESTextureFloatName:
-        return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESTextureFloat*>(extension));
     case WebGLExtension::OESTextureFloatLinearName:
-        return toJS(exec, globalObject, static_cast<OESTextureFloatLinear*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESTextureFloatLinear*>(extension));
     case WebGLExtension::OESTextureHalfFloatName:
-        return toJS(exec, globalObject, static_cast<OESTextureHalfFloat*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESTextureHalfFloat*>(extension));
     case WebGLExtension::OESTextureHalfFloatLinearName:
-        return toJS(exec, globalObject, static_cast<OESTextureHalfFloatLinear*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESTextureHalfFloatLinear*>(extension));
     case WebGLExtension::OESVertexArrayObjectName:
-        return toJS(exec, globalObject, static_cast<OESVertexArrayObject*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESVertexArrayObject*>(extension));
     case WebGLExtension::OESElementIndexUintName:
-        return toJS(exec, globalObject, static_cast<OESElementIndexUint*>(extension));
+        return toJS(&state, &globalObject, static_cast<OESElementIndexUint*>(extension));
     case WebGLExtension::WebGLDebugRendererInfoName:
-        return toJS(exec, globalObject, static_cast<WebGLDebugRendererInfo*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLDebugRendererInfo*>(extension));
     case WebGLExtension::WebGLDebugShadersName:
-        return toJS(exec, globalObject, static_cast<WebGLDebugShaders*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLDebugShaders*>(extension));
     case WebGLExtension::WebGLCompressedTextureATCName:
-        return toJS(exec, globalObject, static_cast<WebGLCompressedTextureATC*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLCompressedTextureATC*>(extension));
     case WebGLExtension::WebGLCompressedTexturePVRTCName:
-        return toJS(exec, globalObject, static_cast<WebGLCompressedTexturePVRTC*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLCompressedTexturePVRTC*>(extension));
     case WebGLExtension::WebGLCompressedTextureS3TCName:
-        return toJS(exec, globalObject, static_cast<WebGLCompressedTextureS3TC*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLCompressedTextureS3TC*>(extension));
     case WebGLExtension::WebGLDepthTextureName:
-        return toJS(exec, globalObject, static_cast<WebGLDepthTexture*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLDepthTexture*>(extension));
     case WebGLExtension::WebGLDrawBuffersName:
-        return toJS(exec, globalObject, static_cast<WebGLDrawBuffers*>(extension));
+        return toJS(&state, &globalObject, static_cast<WebGLDrawBuffers*>(extension));
     case WebGLExtension::ANGLEInstancedArraysName:
-        return toJS(exec, globalObject, static_cast<ANGLEInstancedArrays*>(extension));
+        return toJS(&state, &globalObject, static_cast<ANGLEInstancedArrays*>(extension));
     }
     ASSERT_NOT_REACHED();
     return jsNull();
 }
 
-bool JSWebGLRenderingContextBaseOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
+bool JSWebGLRenderingContextBaseOwner::isReachableFromOpaqueRoots(Handle<Unknown> handle, void*, SlotVisitor& visitor)
 {
     JSWebGLRenderingContextBase* jsWebGLRenderingContext = jsCast<JSWebGLRenderingContextBase*>(handle.slot()->asCell());
     void* root = WebCore::root(jsWebGLRenderingContext->wrapped().canvas());
@@ -306,9 +217,9 @@ JSValue JSWebGLRenderingContextBase::getAttachedShaders(ExecState& state)
     Vector<RefPtr<WebGLShader>> shaders;
     if (!context.getAttachedShaders(program, shaders))
         return jsNull();
-    JSC::MarkedArgumentBuffer list;
-    for (size_t ii = 0; ii < shaders.size(); ++ii)
-        list.append(toJS(&state, globalObject(), shaders[ii].get()));
+    MarkedArgumentBuffer list;
+    for (auto& shader : shaders)
+        list.append(toJS(&state, globalObject(), shader.get()));
     return constructArray(&state, 0, globalObject(), list);
 }
 
@@ -320,14 +231,14 @@ JSValue JSWebGLRenderingContextBase::getExtension(ExecState& state)
     if (state.argumentCount() < 1)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
     
-    String name = state.uncheckedArgument(0).toWTFString(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    return toJS(&state, globalObject(), wrapped().getExtension(name));
+    auto name = state.uncheckedArgument(0).toWTFString(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    return toJS(state, *globalObject(), wrapped().getExtension(name));
 }
 
 JSValue JSWebGLRenderingContextBase::getBufferParameter(ExecState& state)
 {
-    return getObjectParameter(this, state, kBuffer);
+    return objectParameter(*this, state, &WebGLRenderingContextBase::getBufferParameter);
 }
 
 JSValue JSWebGLRenderingContextBase::getFramebufferAttachmentParameter(ExecState& state)
@@ -338,13 +249,13 @@ JSValue JSWebGLRenderingContextBase::getFramebufferAttachmentParameter(ExecState
     if (state.argumentCount() != 3)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
     
-    unsigned target = state.uncheckedArgument(0).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    unsigned attachment = state.uncheckedArgument(1).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    unsigned pname = state.uncheckedArgument(2).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    return toJS(&state, globalObject(), wrapped().getFramebufferAttachmentParameter(target, attachment, pname));
+    auto target = state.uncheckedArgument(0).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    auto attachment = state.uncheckedArgument(1).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    auto pname = state.uncheckedArgument(2).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    return toJS(state, *globalObject(), wrapped().getFramebufferAttachmentParameter(target, attachment, pname));
 }
 
 JSValue JSWebGLRenderingContextBase::getParameter(ExecState& state)
@@ -355,9 +266,9 @@ JSValue JSWebGLRenderingContextBase::getParameter(ExecState& state)
     if (state.argumentCount() != 1)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
     
-    unsigned pname = state.uncheckedArgument(0).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    return toJS(&state, globalObject(), wrapped().getParameter(pname));
+    auto pname = state.uncheckedArgument(0).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    return toJS(state, *globalObject(), wrapped().getParameter(pname));
 }
 
 JSValue JSWebGLRenderingContextBase::getProgramParameter(ExecState& state)
@@ -368,17 +279,17 @@ JSValue JSWebGLRenderingContextBase::getProgramParameter(ExecState& state)
     if (state.argumentCount() != 2)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
     
-    WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
+    auto* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
     if (!program && !state.uncheckedArgument(0).isUndefinedOrNull())
         return throwTypeError(&state, scope);
-    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    return toJS(&state, globalObject(), wrapped().getProgramParameter(program, pname));
+    auto pname = state.uncheckedArgument(1).toInt32(&state);
+    RETURN_IF_EXCEPTION(scope, { });
+    return toJS(state, *globalObject(), wrapped().getProgramParameter(program, pname));
 }
 
 JSValue JSWebGLRenderingContextBase::getRenderbufferParameter(ExecState& state)
 {
-    return getObjectParameter(this, state, kRenderbuffer);
+    return objectParameter(*this, state, &WebGLRenderingContextBase::getRenderbufferParameter);
 }
 
 JSValue JSWebGLRenderingContextBase::getShaderParameter(ExecState& state)
@@ -393,8 +304,8 @@ JSValue JSWebGLRenderingContextBase::getShaderParameter(ExecState& state)
         return throwTypeError(&state, scope);
     WebGLShader* shader = JSWebGLShader::toWrapped(state.uncheckedArgument(0));
     unsigned pname = state.uncheckedArgument(1).toInt32(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    return toJS(&state, globalObject(), wrapped().getShaderParameter(shader, pname));
+    RETURN_IF_EXCEPTION(scope, { });
+    return toJS(state, *globalObject(), wrapped().getShaderParameter(shader, pname));
 }
 
 JSValue JSWebGLRenderingContextBase::getSupportedExtensions(ExecState& state)
@@ -410,7 +321,7 @@ JSValue JSWebGLRenderingContextBase::getSupportedExtensions(ExecState& state)
 
 JSValue JSWebGLRenderingContextBase::getTexParameter(ExecState& state)
 {
-    return getObjectParameter(this, state, kTexture);
+    return objectParameter(*this, state, &WebGLRenderingContextBase::getTexParameter);
 }
 
 JSValue JSWebGLRenderingContextBase::getUniform(ExecState& state)
@@ -427,36 +338,35 @@ JSValue JSWebGLRenderingContextBase::getUniform(ExecState& state)
     WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(1));
     if (!location && !state.uncheckedArgument(1).isUndefinedOrNull())
         return throwTypeError(&state, scope);
-    return toJS(&state, globalObject(), wrapped().getUniform(program, location));
+    return toJS(state, *globalObject(), wrapped().getUniform(program, location));
 }
 
 JSValue JSWebGLRenderingContextBase::getVertexAttrib(ExecState& state)
 {
-    return getObjectParameter(this, state, kVertexAttrib);
+    return objectParameter(*this, state, &WebGLRenderingContextBase::getVertexAttrib);
 }
 
-template<typename T, size_t inlineCapacity>
-bool toVector(JSC::ExecState& state, JSC::JSValue value, Vector<T, inlineCapacity>& vector)
+template<typename VectorType> bool toNumberVector(ExecState& state, JSValue value, VectorType& vector)
 {
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (!value.isObject())
         return false;
-    
-    JSC::JSObject* object = asObject(value);
-    int32_t length = object->get(&state, state.vm().propertyNames->length).toInt32(&state);
-    
+
+    auto& object = *asObject(value);
+    int32_t length = object.get(&state, state.vm().propertyNames->length).toInt32(&state);
+
     if (!vector.tryReserveCapacity(length))
         return false;
-    vector.resize(length);
-    
+
     for (int32_t i = 0; i < length; ++i) {
-        JSC::JSValue v = object->get(&state, i);
+        auto value = object.get(&state, i);
+        RETURN_IF_EXCEPTION(scope, false);
+        vector.uncheckedAppend(value.toNumber(&state));
         RETURN_IF_EXCEPTION(scope, false);
-        vector[i] = static_cast<T>(v.toNumber(&state));
     }
-    
+
     return true;
 }
 
@@ -469,7 +379,7 @@ enum DataFunctionMatrixToCall {
     f_uniformMatrix2fv, f_uniformMatrix3fv, f_uniformMatrix4fv
 };
 
-static bool functionForUniform(DataFunctionToCall f)
+static inline bool functionForUniform(DataFunctionToCall f)
 {
     switch (f) {
     case f_uniform1v:
@@ -477,12 +387,12 @@ static bool functionForUniform(DataFunctionToCall f)
     case f_uniform3v:
     case f_uniform4v:
         return true;
-    default: break;
+    default:
+        return false;
     }
-    return false;
 }
 
-static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState& state, WebGLRenderingContextBase& context)
+static JSValue dataFunctionf(DataFunctionToCall f, ExecState& state, WebGLRenderingContextBase& context)
 {
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -490,22 +400,19 @@ static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState& state, W
     if (state.argumentCount() != 2)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
     
-    WebGLUniformLocation* location = 0;
-    long index = -1;
-    
+    WebGLUniformLocation* location = nullptr;
+    GLuint index = -1;
+
     if (functionForUniform(f)) {
         location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
         if (!location && !state.uncheckedArgument(0).isUndefinedOrNull())
             return throwTypeError(&state, scope);
-    } else
+    } else {
         index = state.uncheckedArgument(0).toInt32(&state);
-    
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    
-    RefPtr<Float32Array> webGLArray = toUnsharedFloat32Array(state.uncheckedArgument(1));
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    
-    if (webGLArray) {
+        RETURN_IF_EXCEPTION(scope, { });
+    }
+
+    if (auto webGLArray = toUnsharedFloat32Array(state.uncheckedArgument(1))) {
         switch (f) {
         case f_uniform1v:
             context.uniform1fv(location, *webGLArray);
@@ -532,14 +439,13 @@ static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState& state, W
             context.vertexAttrib4fv(index, *webGLArray);
             break;
         }
-        
         return jsUndefined();
     }
-    
+
     Vector<float, 64> array;
-    if (!toVector(state, state.uncheckedArgument(1), array))
+    if (!toNumberVector(state, state.uncheckedArgument(1), array))
         return throwTypeError(&state, scope);
-    
+
     switch (f) {
     case f_uniform1v:
         context.uniform1fv(location, array.data(), array.size());
@@ -566,25 +472,22 @@ static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState& state, W
         context.vertexAttrib4fv(index, array.data(), array.size());
         break;
     }
-    
     return jsUndefined();
 }
 
-static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState& state, WebGLRenderingContextBase& context)
+static JSValue dataFunctioni(DataFunctionToCall f, ExecState& state, WebGLRenderingContextBase& context)
 {
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (state.argumentCount() != 2)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
-    
-    WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
+
+    auto* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
     if (!location && !state.uncheckedArgument(0).isUndefinedOrNull())
         return throwTypeError(&state, scope);
-    
-    RefPtr<Int32Array> webGLArray = toUnsharedInt32Array(state.uncheckedArgument(1));
-    
-    if (webGLArray) {
+
+    if (auto webGLArray = toUnsharedInt32Array(state.uncheckedArgument(1))) {
         switch (f) {
         case f_uniform1v:
             context.uniform1iv(location, *webGLArray);
@@ -601,15 +504,13 @@ static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState& state, W
         default:
             break;
         }
-        
         return jsUndefined();
     }
-    
-    
+
     Vector<int, 64> array;
-    if (!toVector(state, state.uncheckedArgument(1), array))
+    if (!toNumberVector(state, state.uncheckedArgument(1), array))
         return throwTypeError(&state, scope);
-    
+
     switch (f) {
     case f_uniform1v:
         context.uniform1iv(location, array.data(), array.size());
@@ -626,28 +527,25 @@ static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState& state, W
     default:
         break;
     }
-    
     return jsUndefined();
 }
 
-static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState& state, WebGLRenderingContextBase& context)
+static JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, ExecState& state, WebGLRenderingContextBase& context)
 {
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (state.argumentCount() != 3)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
-    
-    WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
+
+    auto* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
     if (!location && !state.uncheckedArgument(0).isUndefinedOrNull())
         return throwTypeError(&state, scope);
-    
+
     bool transpose = state.uncheckedArgument(1).toBoolean(&state);
-    RETURN_IF_EXCEPTION(scope, JSValue());
-    
-    RefPtr<Float32Array> webGLArray = toUnsharedFloat32Array(state.uncheckedArgument(2));
+    RETURN_IF_EXCEPTION(scope, { });
 
-    if (webGLArray) {
+    if (auto webGLArray = toUnsharedFloat32Array(state.uncheckedArgument(2))) {
         switch (f) {
         case f_uniformMatrix2fv:
             context.uniformMatrix2fv(location, transpose, *webGLArray);
@@ -659,14 +557,13 @@ static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecStat
             context.uniformMatrix4fv(location, transpose, *webGLArray);
             break;
         }
-
         return jsUndefined();
     }
-    
+
     Vector<float, 64> array;
-    if (!toVector(state, state.uncheckedArgument(2), array))
+    if (!toNumberVector(state, state.uncheckedArgument(2), array))
         return throwTypeError(&state, scope);
-    
+
     switch (f) {
     case f_uniformMatrix2fv:
         context.uniformMatrix2fv(location, transpose, array.data(), array.size());
@@ -678,81 +575,80 @@ static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecStat
         context.uniformMatrix4fv(location, transpose, array.data(), array.size());
         break;
     }
-
     return jsUndefined();
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform1fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform1fv(ExecState& state)
 {
     return dataFunctionf(f_uniform1v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform1iv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform1iv(ExecState& state)
 {
     return dataFunctioni(f_uniform1v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform2fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform2fv(ExecState& state)
 {
     return dataFunctionf(f_uniform2v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform2iv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform2iv(ExecState& state)
 {
     return dataFunctioni(f_uniform2v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform3fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform3fv(ExecState& state)
 {
     return dataFunctionf(f_uniform3v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform3iv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform3iv(ExecState& state)
 {
     return dataFunctioni(f_uniform3v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform4fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform4fv(ExecState& state)
 {
     return dataFunctionf(f_uniform4v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniform4iv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniform4iv(ExecState& state)
 {
     return dataFunctioni(f_uniform4v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniformMatrix2fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniformMatrix2fv(ExecState& state)
 {
     return dataFunctionMatrix(f_uniformMatrix2fv, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniformMatrix3fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniformMatrix3fv(ExecState& state)
 {
     return dataFunctionMatrix(f_uniformMatrix3fv, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::uniformMatrix4fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::uniformMatrix4fv(ExecState& state)
 {
     return dataFunctionMatrix(f_uniformMatrix4fv, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::vertexAttrib1fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::vertexAttrib1fv(ExecState& state)
 {
     return dataFunctionf(f_vertexAttrib1v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::vertexAttrib2fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::vertexAttrib2fv(ExecState& state)
 {
     return dataFunctionf(f_vertexAttrib2v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::vertexAttrib3fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::vertexAttrib3fv(ExecState& state)
 {
     return dataFunctionf(f_vertexAttrib3v, state, wrapped());
 }
 
-JSC::JSValue JSWebGLRenderingContextBase::vertexAttrib4fv(JSC::ExecState& state)
+JSValue JSWebGLRenderingContextBase::vertexAttrib4fv(ExecState& state)
 {
     return dataFunctionf(f_vertexAttrib4v, state, wrapped());
 }
index 9fa2940..e12a240 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -135,6 +135,10 @@ JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGloba
 
 JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue initiator)
 {
+    // FIXME: What guarantees these are true? Why don't we need to check?
+    ASSERT(JSC::jsDynamicCast<JSElement*>(initiator));
+    ASSERT(isScriptElement(JSC::jsDynamicCast<JSElement*>(initiator)->wrapped()));
+
     auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
     auto& jsPromise = *JSC::JSInternalPromiseDeferred::create(exec, &globalObject);
     auto deferred = DeferredPromise::create(globalObject, jsPromise);
@@ -156,17 +160,12 @@ JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalO
         return jsPromise.promise();
     }
 
-    ASSERT_WITH_MESSAGE(JSC::jsDynamicCast<JSElement*>(initiator), "Initiator should be an JSElement");
-    auto* scriptElement = toScriptElementIfPossible(&JSC::jsCast<JSElement*>(initiator)->wrapped());
-    ASSERT_WITH_MESSAGE(scriptElement, "Initiator should be ScriptElement.");
-
     if (auto* frame = m_document.frame()) {
         auto loader = CachedModuleScriptLoader::create(*this, deferred.get());
         m_loaders.add(loader.copyRef());
-        if (!loader->load(*scriptElement, completedURL)) {
+        if (!loader->load(downcastScriptElement(JSC::jsCast<JSElement*>(initiator)->wrapped()), completedURL)) {
             loader->clearClient();
             m_loaders.remove(WTFMove(loader));
-
             deferred->reject(frame->script().moduleLoaderAlreadyReportedErrorSymbol());
             return jsPromise.promise();
         }
index 4c43bdd..972beb1 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004-2010, 2012-2013, 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2011 Google Inc. All rights reserved.
@@ -66,9 +66,7 @@
 
 namespace JSC {
 class ExecState;
-#if ENABLE(WEB_REPLAY)
 class InputCursor;
-#endif
 }
 
 namespace WebCore {
@@ -99,8 +97,8 @@ class DocumentParser;
 class DocumentSharedObjectPool;
 class DocumentType;
 class ExtensionStyleSheets;
-class FloatRect;
 class FloatQuad;
+class FloatRect;
 class FormController;
 class Frame;
 class FrameView;
@@ -121,11 +119,10 @@ class HTMLScriptElement;
 class HitTestRequest;
 class HitTestResult;
 class IntPoint;
+class JSNode;
 class LayoutPoint;
 class LayoutRect;
 class LiveNodeList;
-class ScriptModuleLoader;
-class JSNode;
 class Locale;
 class Location;
 class MediaCanStartListener;
@@ -133,7 +130,6 @@ class MediaPlaybackTarget;
 class MediaPlaybackTargetClient;
 class MediaQueryList;
 class MediaQueryMatcher;
-class ScriptModuleLoader;
 class MouseEventWithHitTestResults;
 class NamedFlowCollection;
 class NodeFilter;
@@ -143,23 +139,24 @@ class PlatformMouseEvent;
 class ProcessingInstruction;
 class QualifiedName;
 class Range;
-class RenderView;
 class RenderFullScreen;
-class ScriptableDocumentParser;
+class RenderView;
+class SVGDocumentExtensions;
+class SVGSVGElement;
 class ScriptElementData;
+class ScriptModuleLoader;
 class ScriptRunner;
+class ScriptableDocumentParser;
 class SecurityOrigin;
+class SegmentedString;
 class SelectorQuery;
 class SelectorQueryCache;
 class SerializedScriptValue;
-class SegmentedString;
 class Settings;
 class StyleResolver;
 class StyleSheet;
 class StyleSheetContents;
 class StyleSheetList;
-class SVGDocumentExtensions;
-class SVGSVGElement;
 class Text;
 class TextResourceDecoder;
 class TreeWalker;
index 2be0e2e..2f98682 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "PendingScript.h"
 
-#include "Element.h"
 #include "PendingScriptClient.h"
+#include "ScriptElement.h"
 
 namespace WebCore {
 
-Ref<PendingScript> PendingScript::create(Element& element, LoadableScript& loadableScript)
+Ref<PendingScript> PendingScript::create(ScriptElement& element, LoadableScript& loadableScript)
 {
-    Ref<PendingScript> pendingScript = adoptRef(*new PendingScript(element, loadableScript));
+    auto pendingScript = adoptRef(*new PendingScript(element, loadableScript));
     loadableScript.addClient(pendingScript.get());
     return pendingScript;
 }
 
-Ref<PendingScript> PendingScript::create(Element& element, TextPosition scriptStartPosition)
+Ref<PendingScript> PendingScript::create(ScriptElement& element, TextPosition scriptStartPosition)
 {
     return adoptRef(*new PendingScript(element, scriptStartPosition));
 }
 
-PendingScript::PendingScript(Element& element, TextPosition startingPosition)
+PendingScript::PendingScript(ScriptElement& element, TextPosition startingPosition)
     : m_element(element)
     , m_startingPosition(startingPosition)
 {
 }
 
-PendingScript::PendingScript(Element& element, LoadableScript& loadableScript)
+PendingScript::PendingScript(ScriptElement& element, LoadableScript& loadableScript)
     : m_element(element)
     , m_loadableScript(&loadableScript)
 {
@@ -61,11 +62,6 @@ PendingScript::~PendingScript()
         m_loadableScript->removeClient(*this);
 }
 
-LoadableScript* PendingScript::loadableScript() const
-{
-    return m_loadableScript.get();
-}
-
 void PendingScript::notifyClientFinished()
 {
     Ref<PendingScript> protectedThis(*this);
@@ -88,10 +84,10 @@ bool PendingScript::error() const
     return m_loadableScript && m_loadableScript->error();
 }
 
-void PendingScript::setClient(PendingScriptClient* client)
+void PendingScript::setClient(PendingScriptClient& client)
 {
     ASSERT(!m_client);
-    m_client = client;
+    m_client = &client;
     if (isLoaded())
         notifyClientFinished();
 }
index 990f250..fc758d0 100644 (file)
 namespace WebCore {
 
 class CachedScript;
-class Element;
 class PendingScriptClient;
+class ScriptElement;
 
 // A container for scripts which may be loaded and executed.
 // This can hold LoadableScript and non external inline script.
 class PendingScript final : public RefCounted<PendingScript>, public LoadableScriptClient {
 public:
-    static Ref<PendingScript> create(Element&, LoadableScript&);
-    static Ref<PendingScript> create(Element&, TextPosition scriptStartPosition);
+    static Ref<PendingScript> create(ScriptElement&, LoadableScript&);
+    static Ref<PendingScript> create(ScriptElement&, TextPosition scriptStartPosition);
 
     virtual ~PendingScript();
 
@@ -51,8 +51,8 @@ public:
 
     bool watchingForLoad() const { return needsLoading() && m_client; }
 
-    Element& element() { return m_element.get(); }
-    const Element& element() const { return m_element.get(); }
+    ScriptElement& element() { return m_element.get(); }
+    const ScriptElement& element() const { return m_element.get(); }
 
     LoadableScript* loadableScript() const;
     bool needsLoading() const { return loadableScript(); }
@@ -62,19 +62,24 @@ public:
 
     void notifyFinished(LoadableScript&) override;
 
-    void setClient(PendingScriptClient*);
+    void setClient(PendingScriptClient&);
     void clearClient();
 
 private:
-    PendingScript(Element&, LoadableScript&);
-    PendingScript(Element&, TextPosition startingPosition);
+    PendingScript(ScriptElement&, LoadableScript&);
+    PendingScript(ScriptElement&, TextPosition startingPosition);
 
     void notifyClientFinished();
 
-    Ref<Element> m_element;
+    Ref<ScriptElement> m_element;
     TextPosition m_startingPosition; // Only used for inline script tags.
     RefPtr<LoadableScript> m_loadableScript;
     PendingScriptClient* m_client { nullptr };
 };
 
+inline LoadableScript* PendingScript::loadableScript() const
+{
+    return m_loadableScript.get();
+}
+
 }
index 61f2482..f68637a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -263,11 +263,11 @@ bool ScriptElement::prepareScript(const TextPosition& scriptStartPosition, Legac
     } else if ((isClassicExternalScript || scriptType == ScriptType::Module) && !asyncAttributeValue() && !m_forceAsync) {
         m_willExecuteInOrder = true;
         ASSERT(m_loadableScript);
-        document.scriptRunner()->queueScriptForExecution(this, *m_loadableScript, ScriptRunner::IN_ORDER_EXECUTION);
+        document.scriptRunner()->queueScriptForExecution(*this, *m_loadableScript, ScriptRunner::IN_ORDER_EXECUTION);
     } else if (hasSourceAttribute() || scriptType == ScriptType::Module) {
         ASSERT(m_loadableScript);
         ASSERT(asyncAttributeValue() || m_forceAsync);
-        document.scriptRunner()->queueScriptForExecution(this, *m_loadableScript, ScriptRunner::ASYNC_EXECUTION);
+        document.scriptRunner()->queueScriptForExecution(*this, *m_loadableScript, ScriptRunner::ASYNC_EXECUTION);
     } else if (!hasSourceAttribute() && m_parserInserted && !document.haveStylesheetsLoaded()) {
         ASSERT(scriptType == ScriptType::Classic);
         m_willBeParserExecuted = true;
@@ -487,15 +487,26 @@ String ScriptElement::scriptContent() const
     return result.toString();
 }
 
-ScriptElement* toScriptElementIfPossible(Element* element)
+void ScriptElement::ref()
 {
-    if (is<HTMLScriptElement>(*element))
-        return downcast<HTMLScriptElement>(element);
+    m_element.ref();
+}
 
-    if (is<SVGScriptElement>(*element))
-        return downcast<SVGScriptElement>(element);
+void ScriptElement::deref()
+{
+    m_element.deref();
+}
 
-    return nullptr;
+bool isScriptElement(Element& element)
+{
+    return is<HTMLScriptElement>(element) || is<SVGScriptElement>(element);
+}
+
+ScriptElement& downcastScriptElement(Element& element)
+{
+    if (is<HTMLScriptElement>(element))
+        return downcast<HTMLScriptElement>(element);
+    return downcast<SVGScriptElement>(element);
 }
 
 }
index 4079c17..5f181df 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "LoadableScript.h"
 #include "LoadableScriptClient.h"
 #include "Timer.h"
-#include "URL.h"
 #include <wtf/text/TextPosition.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
+class CachedModuleScript;
 class CachedScript;
 class ContainerNode;
 class Element;
 class PendingScript;
-class ScriptElement;
 class ScriptSourceCode;
-class CachedModuleScript;
+class URL;
 
 class ScriptElement {
 public:
@@ -73,6 +72,9 @@ public:
     enum class ScriptType { Classic, Module };
     ScriptType scriptType() const { return m_isModuleScript ? ScriptType::Module : ScriptType::Classic; }
 
+    void ref();
+    void deref();
+
 protected:
     ScriptElement(Element&, bool createdByParser, bool isEvaluated);
 
@@ -127,7 +129,8 @@ private:
     RefPtr<LoadableScript> m_loadableScript;
 };
 
-// FIXME: replace with downcast<ScriptElement>.
-ScriptElement* toScriptElementIfPossible(Element*);
+// FIXME: replace with is/downcast<ScriptElement>.
+bool isScriptElement(Element&);
+ScriptElement& downcastScriptElement(Element&);
 
 }
index 70989eb..041e6d1 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -56,26 +57,22 @@ ScriptRunner::~ScriptRunner()
     }
 }
 
-void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, LoadableScript& loadableScript, ExecutionType executionType)
+void ScriptRunner::queueScriptForExecution(ScriptElement& scriptElement, LoadableScript& loadableScript, ExecutionType executionType)
 {
-    ASSERT(scriptElement);
-
-    Element& element = scriptElement->element();
-    ASSERT(element.inDocument());
+    ASSERT(scriptElement.element().inDocument());
 
     m_document.incrementLoadEventDelayCount();
 
-    Ref<PendingScript> pendingScript = PendingScript::create(element, loadableScript);
+    auto pendingScript = PendingScript::create(scriptElement, loadableScript);
     switch (executionType) {
     case ASYNC_EXECUTION:
         m_pendingAsyncScripts.add(pendingScript.copyRef());
         break;
-
     case IN_ORDER_EXECUTION:
         m_scriptsToExecuteInOrder.append(pendingScript.copyRef());
         break;
     }
-    pendingScript->setClient(this);
+    pendingScript->setClient(*this);
 }
 
 void ScriptRunner::suspend()
@@ -91,9 +88,7 @@ void ScriptRunner::resume()
 
 void ScriptRunner::notifyFinished(PendingScript& pendingScript)
 {
-    auto* scriptElement = toScriptElementIfPossible(&pendingScript.element());
-    ASSERT(scriptElement);
-    if (scriptElement->willExecuteInOrder())
+    if (pendingScript.element().willExecuteInOrder())
         ASSERT(!m_scriptsToExecuteInOrder.isEmpty());
     else {
         ASSERT(m_pendingAsyncScripts.contains(pendingScript));
@@ -122,10 +117,8 @@ void ScriptRunner::timerFired()
         // Paper over https://bugs.webkit.org/show_bug.cgi?id=144050
         if (!script)
             continue;
-        auto* scriptElement = toScriptElementIfPossible(&script->element());
-        ASSERT(scriptElement);
         ASSERT(script->needsLoading());
-        scriptElement->executePendingScript(*script);
+        script->element().executePendingScript(*script);
         m_document.decrementLoadEventDelayCount();
     }
 }
index dfcf3c5..8e8f486 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "PendingScriptClient.h"
 #include "Timer.h"
 #include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
 class Document;
-class PendingScript;
 class ScriptElement;
 class LoadableScript;
 
@@ -45,7 +44,7 @@ public:
     ~ScriptRunner();
 
     enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION };
-    void queueScriptForExecution(ScriptElement*, LoadableScript&, ExecutionType);
+    void queueScriptForExecution(ScriptElement&, LoadableScript&, ExecutionType);
     bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty() || !m_scriptsToExecuteInOrder.isEmpty() || !m_pendingAsyncScripts.isEmpty(); }
     void suspend();
     void resume();
index 1367b4f..57d0dc1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -221,7 +221,7 @@ bool FileInputType::canSetStringValue() const
 
 FileList* FileInputType::files()
 {
-    return m_fileList.get();
+    return m_fileList.ptr();
 }
 
 bool FileInputType::canSetValue(const String& value)
@@ -258,12 +258,12 @@ void FileInputType::setValue(const String&, bool, TextFieldEventBehavior)
     element().invalidateStyleForSubtree();
 }
 
-PassRefPtr<FileList> FileInputType::createFileList(const Vector<FileChooserFileInfo>& files) const
+Ref<FileList> FileInputType::createFileList(const Vector<FileChooserFileInfo>& files)
 {
     Vector<RefPtr<File>> fileObjects;
-    for (const FileChooserFileInfo& info : files)
-        fileObjects.append(File::createWithName(info.path, info.displayName));
-
+    fileObjects.reserveInitialCapacity(files.size());
+    for (auto& info : files)
+        fileObjects.uncheckedAppend(File::createWithName(info.path, info.displayName));
     return FileList::create(WTFMove(fileObjects));
 }
 
@@ -302,29 +302,32 @@ void FileInputType::multipleAttributeChanged()
         button->setValue(element().multiple() ? fileButtonChooseMultipleFilesLabel() : fileButtonChooseFileLabel());
 }
 
+#if !PLATFORM(IOS)
+
 void FileInputType::requestIcon(const Vector<String>& paths)
 {
-#if PLATFORM(IOS)
-    UNUSED_PARAM(paths);
-#else
     if (!paths.size()) {
-        updateRendering(nullptr);
+        iconLoaded(nullptr);
         return;
     }
 
-    Chrome* chrome = this->chrome();
-    if (!chrome)
+    auto* chrome = this->chrome();
+    if (!chrome) {
+        iconLoaded(nullptr);
         return;
+    }
 
     if (m_fileIconLoader)
         m_fileIconLoader->invalidate();
 
-    m_fileIconLoader = std::make_unique<FileIconLoader>(static_cast<FileIconLoaderClient&>(*this));
+    FileIconLoaderClient& client = *this;
+    m_fileIconLoader = std::make_unique<FileIconLoader>(client);
 
-    chrome->loadIconForFiles(paths, m_fileIconLoader.get());
-#endif
+    chrome->loadIconForFiles(paths, *m_fileIconLoader);
 }
 
+#endif
+
 void FileInputType::applyFileChooserSettings(const FileChooserSettings& settings)
 {
     if (m_fileChooser)
@@ -333,18 +336,20 @@ void FileInputType::applyFileChooserSettings(const FileChooserSettings& settings
     m_fileChooser = FileChooser::create(this, settings);
 }
 
-void FileInputType::setFiles(PassRefPtr<FileList> files)
+void FileInputType::setFiles(RefPtr<FileList>&& files)
 {
     if (!files)
         return;
 
     Ref<HTMLInputElement> input(element());
 
+    unsigned length = files->length();
+
     bool pathsChanged = false;
-    if (files->length() != m_fileList->length())
+    if (length != m_fileList->length())
         pathsChanged = true;
     else {
-        for (unsigned i = 0; i < files->length(); ++i) {
+        for (unsigned i = 0; i < length; ++i) {
             if (files->item(i)->path() != m_fileList->item(i)->path()) {
                 pathsChanged = true;
                 break;
@@ -352,15 +357,18 @@ void FileInputType::setFiles(PassRefPtr<FileList> files)
         }
     }
 
-    m_fileList = files;
+    m_fileList = files.releaseNonNull();
 
     input->setFormControlValueMatchesRenderer(true);
     input->updateValidity();
 
+#if !PLATFORM(IOS)
     Vector<String> paths;
-    for (unsigned i = 0; i < m_fileList->length(); ++i)
-        paths.append(m_fileList->item(i)->path());
+    paths.reserveInitialCapacity(length);
+    for (unsigned i = 0; i < length; ++i)
+        paths.uncheckedAppend(m_fileList->item(i)->path());
     requestIcon(paths);
+#endif
 
     if (input->renderer())
         input->renderer()->repaint();
@@ -374,17 +382,19 @@ void FileInputType::setFiles(PassRefPtr<FileList> files)
 }
 
 #if PLATFORM(IOS)
+
 void FileInputType::filesChosen(const Vector<FileChooserFileInfo>& paths, const String& displayString, Icon* icon)
 {
     m_displayString = displayString;
     filesChosen(paths);
-    updateRendering(icon);
+    iconLoaded(icon);
 }
 
 String FileInputType::displayString() const
 {
     return m_displayString;
 }
+
 #endif
 
 void FileInputType::filesChosen(const Vector<FileChooserFileInfo>& files)
@@ -392,12 +402,12 @@ void FileInputType::filesChosen(const Vector<FileChooserFileInfo>& files)
     setFiles(createFileList(files));
 }
 
-void FileInputType::updateRendering(PassRefPtr<Icon> icon)
+void FileInputType::iconLoaded(RefPtr<Icon>&& icon)
 {
     if (m_icon == icon)
         return;
 
-    m_icon = icon;
+    m_icon = WTFMove(icon);
     if (element().renderer())
         element().renderer()->repaint();
 }
@@ -434,8 +444,7 @@ Icon* FileInputType::icon() const
 
 String FileInputType::defaultToolTip() const
 {
-    FileList* fileList = m_fileList.get();
-    unsigned listSize = fileList->length();
+    unsigned listSize = m_fileList->length();
     if (!listSize) {
         if (element().multiple())
             return fileButtonNoFilesSelectedLabel();
@@ -443,8 +452,8 @@ String FileInputType::defaultToolTip() const
     }
 
     StringBuilder names;
-    for (size_t i = 0; i < listSize; ++i) {
-        names.append(fileList->item(i)->name());
+    for (unsigned i = 0; i < listSize; ++i) {
+        names.append(m_fileList->item(i)->name());
         if (i != listSize - 1)
             names.append('\n');
     }
index f8a0dff..ee40648 100644 (file)
@@ -50,45 +50,45 @@ public:
     static Vector<FileChooserFileInfo> filesFromFormControlState(const FormControlState&);
 
 private:
-    const AtomicString& formControlType() const override;
-    FormControlState saveFormControlState() const override;
-    void restoreFormControlState(const FormControlState&) override;
-    bool appendFormData(FormDataList&, bool) const override;
-    bool valueMissing(const String&) const override;
-    String valueMissingText() const override;
-    void handleDOMActivateEvent(Event&) override;
-    RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) override;
-    bool canSetStringValue() const override;
-    FileList* files() override;
-    void setFiles(PassRefPtr<FileList>) override;
+    const AtomicString& formControlType() const final;
+    FormControlState saveFormControlState() const final;
+    void restoreFormControlState(const FormControlState&) final;
+    bool appendFormData(FormDataList&, bool) const final;
+    bool valueMissing(const String&) const final;
+    String valueMissingText() const final;
+    void handleDOMActivateEvent(Event&) final;
+    RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final;
+    bool canSetStringValue() const final;
+    FileList* files() final;
+    void setFiles(RefPtr<FileList>&&) final;
 #if PLATFORM(IOS)
-    String displayString() const override;
+    String displayString() const final;
 #endif
-    bool canSetValue(const String&) override;
-    bool getTypeSpecificValue(String&) override; // Checked first, before internal storage or the value attribute.
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
+    bool canSetValue(const String&) final;
+    bool getTypeSpecificValue(String&) final; // Checked first, before internal storage or the value attribute.
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
 
 #if ENABLE(DRAG_SUPPORT)
-    bool receiveDroppedFiles(const DragData&) override;
+    bool receiveDroppedFiles(const DragData&) final;
 #endif
 
-    Icon* icon() const override;
-    bool isFileUpload() const override;
-    void createShadowSubtree() override;
-    void disabledAttributeChanged() override;
-    void multipleAttributeChanged() override;
-    String defaultToolTip() const override;
+    Icon* icon() const final;
+    bool isFileUpload() const final;
+    void createShadowSubtree() final;
+    void disabledAttributeChanged() final;
+    void multipleAttributeChanged() final;
+    String defaultToolTip() const final;
 
     // FileChooserClient implementation.
-    void filesChosen(const Vector<FileChooserFileInfo>&) override;
+    void filesChosen(const Vector<FileChooserFileInfo>&) final;
 #if PLATFORM(IOS)
-    void filesChosen(const Vector<FileChooserFileInfo>&, const String& displayString, Icon*) override;
+    void filesChosen(const Vector<FileChooserFileInfo>&, const String& displayString, Icon*) final;
 #endif
 
     // FileIconLoaderClient implementation.
-    void updateRendering(PassRefPtr<Icon>) override;
+    void iconLoaded(RefPtr<Icon>&&) final;
 
-    PassRefPtr<FileList> createFileList(const Vector<FileChooserFileInfo>& files) const;
+    static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>&);
     void requestIcon(const Vector<String>&);
 
     void applyFileChooserSettings(const FileChooserSettings&);
@@ -98,7 +98,7 @@ private:
     std::unique_ptr<FileIconLoader> m_fileIconLoader;
 #endif
 
-    RefPtr<FileList> m_fileList;
+    Ref<FileList> m_fileList;
     RefPtr<Icon> m_icon;
 #if PLATFORM(IOS)
     String m_displayString;
index f4be715..0322b13 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2011 Motorola Mobility. All rights reserved.
  *
@@ -752,7 +752,7 @@ RenderPtr<RenderElement> HTMLElement::createElementRenderer(RenderStyle&& style,
     return RenderElement::createFor(*this, WTFMove(style));
 }
 
-HTMLFormElement* HTMLElement::virtualForm() const
+HTMLFormElement* HTMLElement::form() const
 {
     return HTMLFormElement::findClosestFormAncestor(*this);
 }
index 39d4cb7..c1f9ecb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004-2009, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -70,7 +70,7 @@ public:
     bool rendererIsNeeded(const RenderStyle&) override;
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
 
-    HTMLFormElement* form() const { return virtualForm(); }
+    WEBCORE_EXPORT virtual HTMLFormElement* form() const;
 
     WEBCORE_EXPORT const AtomicString& dir() const;
     WEBCORE_EXPORT void setDir(const AtomicString&);
@@ -133,8 +133,6 @@ private:
 
     void mapLanguageAttributeToLocale(const AtomicString&, MutableStyleProperties&);
 
-    virtual HTMLFormElement* virtualForm() const;
-
     ExceptionOr<Ref<DocumentFragment>> textToFragment(const String&);
 
     void dirAttributeChanged(const AtomicString&);
index 84516cb..2e872aa 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  *
  * This library is free software; you can redistribute it and/or
@@ -593,11 +593,6 @@ void HTMLFormControlElement::dispatchBlurEvent(RefPtr<Element>&& newFocusedEleme
     hideVisibleValidationMessage();
 }
 
-HTMLFormElement* HTMLFormControlElement::virtualForm() const
-{
-    return FormAssociatedElement::form();
-}
-
 #if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
 
 // FIXME: We should look to share this code with class HTMLFormElement instead of duplicating the logic.
index 4ff4894..50b8cd4 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -46,7 +46,7 @@ class HTMLFormControlElement : public LabelableElement, public FormAssociatedEle
 public:
     virtual ~HTMLFormControlElement();
 
-    HTMLFormElement* form() const { return FormAssociatedElement::form(); }
+    HTMLFormElement* form() const final { return FormAssociatedElement::form(); }
 
     WEBCORE_EXPORT String formEnctype() const;
     WEBCORE_EXPORT void setFormEnctype(const String&);
@@ -169,7 +169,6 @@ private:
 
     int tabIndex() const final;
 
-    HTMLFormElement* virtualForm() const override;
     bool isValidFormControlElement() const;
 
     bool computeIsDisabledByFieldsetAncestor() const;
index d43d4ef..8212cb2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
  * Copyright (C) 2010 Google Inc. All rights reserved.
@@ -1184,10 +1184,9 @@ void HTMLInputElement::defaultEventHandler(Event& event)
         if (wasChangedSinceLastFormControlChangeEvent())
             dispatchFormControlChangeEvent();
 
-        RefPtr<HTMLFormElement> formForSubmission = m_inputType->formForSubmission();
         // Form may never have been present, or may have been destroyed by code responding to the change event.
-        if (formForSubmission)
-            formForSubmission->submitImplicitly(event, canTriggerImplicitSubmission());
+        if (auto* formElement = form())
+            formElement->submitImplicitly(event, canTriggerImplicitSubmission());
 
         event.setDefaultHandled();
         return;
@@ -1342,9 +1341,9 @@ FileList* HTMLInputElement::files()
     return m_inputType->files();
 }
 
-void HTMLInputElement::setFiles(PassRefPtr<FileList> files)
+void HTMLInputElement::setFiles(RefPtr<FileList>&& files)
 {
-    m_inputType->setFiles(files);
+    m_inputType->setFiles(WTFMove(files));
 }
 
 #if ENABLE(DRAG_SUPPORT)
@@ -1869,7 +1868,7 @@ RadioButtonGroups* HTMLInputElement::radioButtonGroups() const
 {
     if (!isRadioButton())
         return nullptr;
-    if (HTMLFormElement* formElement = form())
+    if (auto* formElement = form())
         return &formElement->radioButtonGroups();
     if (inDocument())
         return &document().formController().radioButtonGroups();
index 8affd98..bf00baf 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -43,8 +43,8 @@ class Icon;
 class InputType;
 class ListAttributeTargetObserver;
 class RadioButtonGroups;
-class TextControlInnerTextElement;
 class URL;
+
 struct DateTimeChooserParameters;
 
 struct InputElementClickState {
@@ -238,7 +238,7 @@ public:
     WEBCORE_EXPORT void setShowAutoFillButton(AutoFillButtonType);
 
     WEBCORE_EXPORT FileList* files();
-    WEBCORE_EXPORT void setFiles(PassRefPtr<FileList>);
+    WEBCORE_EXPORT void setFiles(RefPtr<FileList>&&);
 
 #if ENABLE(DRAG_SUPPORT)
     // Returns true if the given DragData has more than one dropped files.
index 711d06d..010ffc4 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  *
  * This library is free software; you can redistribute it and/or
@@ -58,30 +58,28 @@ Ref<HTMLLabelElement> HTMLLabelElement::create(const QualifiedName& tagName, Doc
     return adoptRef(*new HTMLLabelElement(tagName, document));
 }
 
-LabelableElement* HTMLLabelElement::control()
+LabelableElement* HTMLLabelElement::control() const
 {
-    const AtomicString& controlId = attributeWithoutSynchronization(forAttr);
+    auto& controlId = attributeWithoutSynchronization(forAttr);
     if (controlId.isNull()) {
         // Search the children and descendants of the label element for a form element.
         // per http://dev.w3.org/html5/spec/Overview.html#the-label-element
         // the form element must be "labelable form-associated element".
         for (auto& labelableElement : descendantsOfType<LabelableElement>(*this)) {
             if (labelableElement.supportLabels())
-                return &labelableElement;
+                return const_cast<LabelableElement*>(&labelableElement);
         }
         return nullptr;
     }
-    
     return inDocument() ? firstElementWithIdIfLabelable(treeScope(), controlId) : nullptr;
 }
 
-HTMLFormElement* HTMLLabelElement::form()
+HTMLFormElement* HTMLLabelElement::form() const
 {
-    auto* labeledControl = control();
-    if (!labeledControl)
+    auto* control = this->control();
+    if (!is<HTMLFormControlElement>(control))
         return nullptr;
-
-    return is<HTMLFormControlElement>(*labeledControl) ? downcast<HTMLFormControlElement>(*labeledControl).form() : nullptr;
+    return downcast<HTMLFormControlElement>(*control).form();
 }
 
 void HTMLLabelElement::setActive(bool down, bool pause)
index 140d989..a3d1421 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -31,8 +31,8 @@ class HTMLLabelElement final : public HTMLElement {
 public:
     static Ref<HTMLLabelElement> create(const QualifiedName&, Document&);
 
-    WEBCORE_EXPORT LabelableElement* control();
-    WEBCORE_EXPORT HTMLFormElement* form();
+    WEBCORE_EXPORT LabelableElement* control() const;
+    WEBCORE_EXPORT HTMLFormElement* form() const final;
 
     bool willRespondToMouseClickEvents() final;
 
index 0481061..090e0c7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  *
  * This library is free software; you can redistribute it and/or
 
 namespace WebCore {
 
-using namespace HTMLNames;
-
-
 inline HTMLLegendElement::HTMLLegendElement(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document)
 {
-    ASSERT(hasTagName(legendTag));
+    ASSERT(hasTagName(HTMLNames::legendTag));
 }
 
 Ref<HTMLLegendElement> HTMLLegendElement::create(const QualifiedName& tagName, Document& document)
@@ -59,7 +56,6 @@ HTMLFormControlElement* HTMLLegendElement::associatedControl()
 
 void HTMLLegendElement::focus(bool restorePreviousSelection, FocusDirection direction)
 {
-    // To match other browsers' behavior, never restore previous selection.
     if (document().haveStylesheetsLoaded()) {
         document().updateLayoutIgnorePendingStylesheets();
         if (isFocusable()) {
@@ -67,25 +63,26 @@ void HTMLLegendElement::focus(bool restorePreviousSelection, FocusDirection dire
             return;
         }
     }
+
+    // To match other browsers' behavior, never restore previous selection.
     if (auto* control = associatedControl())
         control->focus(false, direction);
 }
 
 void HTMLLegendElement::accessKeyAction(bool sendMouseEvents)
 {
-    if (HTMLFormControlElement* control = associatedControl())
+    if (auto* control = associatedControl())
         control->accessKeyAction(sendMouseEvents);
 }
 
-HTMLFormElement* HTMLLegendElement::virtualForm() const
+HTMLFormElement* HTMLLegendElement::form() const
 {
     // According to the specification, If the legend has a fieldset element as
     // its parent, then the form attribute must return the same value as the
     // form attribute on that fieldset element. Otherwise, it must return null.
-    ContainerNode* fieldset = parentNode();
+    auto* fieldset = parentNode();
     if (!is<HTMLFieldSetElement>(fieldset))
         return nullptr;
-
     return downcast<HTMLFieldSetElement>(*fieldset).form();
 }
     
index 038cc9a..144e19f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,15 +33,16 @@ class HTMLLegendElement final : public HTMLElement {
 public:
     static Ref<HTMLLegendElement> create(const QualifiedName&, Document&);
 
+    WEBCORE_EXPORT HTMLFormElement* form() const final;
+
 private:
     HTMLLegendElement(const QualifiedName&, Document&);
 
-    // Control in the legend's fieldset that gets focus and access key.
+    // Control in the legend's field set that gets focus and access key.
     HTMLFormControlElement* associatedControl();
 
     void accessKeyAction(bool sendMouseEvents) final;
     void focus(bool restorePreviousSelection, FocusDirection) final;
-    HTMLFormElement* virtualForm() const final;
 };
 
 } // namespace WebCore
index cd4b5a2..5e21b83 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
+#include "HTMLMediaElement.h"
 
 #if ENABLE(VIDEO)
 
-#include "HTMLMediaElement.h"
-
 #include "ApplicationCacheHost.h"
 #include "ApplicationCacheResource.h"
 #include "Attribute.h"
@@ -269,22 +268,23 @@ static void removeElementFromDocumentMap(HTMLMediaElement& element, Document& do
 }
 
 #if ENABLE(VIDEO_TRACK)
+
 class TrackDisplayUpdateScope {
 public:
-    TrackDisplayUpdateScope(HTMLMediaElement* mediaElement)
+    TrackDisplayUpdateScope(HTMLMediaElement& element)
+        : m_element(element)
     {
-        m_mediaElement = mediaElement;
-        m_mediaElement->beginIgnoringTrackDisplayUpdateRequests();
+        m_element.beginIgnoringTrackDisplayUpdateRequests();
     }
     ~TrackDisplayUpdateScope()
     {
-        ASSERT(m_mediaElement);
-        m_mediaElement->endIgnoringTrackDisplayUpdateRequests();
+        m_element.endIgnoringTrackDisplayUpdateRequests();
     }
     
 private:
-    HTMLMediaElement* m_mediaElement;
+    HTMLMediaElement& m_element;
 };
+
 #endif
 
 struct HTMLMediaElement::TrackGroup {
@@ -1554,7 +1554,7 @@ static bool eventTimeCueCompare(const std::pair<MediaTime, TextTrackCue*>& a, co
     // 12 - Further sort tasks in events that have the same time by the
     // relative text track cue order of the text track cues associated
     // with these tasks.
-    return a.second->cueIndex() - b.second->cueIndex() < 0;
+    return a.second->isOrderedBefore(b.second);
 }
 
 static bool compareCueInterval(const CueInterval& one, const CueInterval& two)
@@ -1817,22 +1817,21 @@ void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track)
     }
 }
 
-void HTMLMediaElement::audioTrackEnabledChanged(AudioTrack* track)
+void HTMLMediaElement::audioTrackEnabledChanged(AudioTrack& track)
 {
-    ASSERT(track);
-    if (m_audioTracks && m_audioTracks->contains(*track))
+    if (m_audioTracks && m_audioTracks->contains(track))
         m_audioTracks->scheduleChangeEvent();
     if (ScriptController::processingUserGestureForMedia())
         removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
 }
 
-void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
+void HTMLMediaElement::textTrackModeChanged(TextTrack& track)
 {
     bool trackIsLoaded = true;
-    if (track->trackType() == TextTrack::TrackElement) {
+    if (track.trackType() == TextTrack::TrackElement) {
         trackIsLoaded = false;
         for (auto& trackElement : childrenOfType<HTMLTrackElement>(*this)) {
-            if (&trackElement.track() == track) {
+            if (&trackElement.track() == &track) {
                 if (trackElement.readyState() == HTMLTrackElement::LOADING || trackElement.readyState() == HTMLTrackElement::LOADED)
                     trackIsLoaded = true;
                 break;
@@ -1845,33 +1844,32 @@ void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
         m_textTracks = TextTrackList::create(this, ActiveDOMObject::scriptExecutionContext());
     
     // Mark this track as "configured" so configureTextTracks won't change the mode again.
-    track->setHasBeenConfigured(true);
+    track.setHasBeenConfigured(true);
     
-    if (track->mode() != TextTrack::Mode::Disabled && trackIsLoaded)
-        textTrackAddCues(track, track->cues());
+    if (track.mode() != TextTrack::Mode::Disabled && trackIsLoaded)
+        textTrackAddCues(track, *track.cues());
 
     configureTextTrackDisplay(AssumeTextTrackVisibilityChanged);
 
-    if (m_textTracks && m_textTracks->contains(*track))
+    if (m_textTracks && m_textTracks->contains(track))
         m_textTracks->scheduleChangeEvent();
 
 #if ENABLE(AVF_CAPTIONS)
-    if (track->trackType() == TextTrack::TrackElement && m_player)
+    if (track.trackType() == TextTrack::TrackElement && m_player)
         m_player->notifyTrackModeChanged();
 #endif
 }
 
-void HTMLMediaElement::videoTrackSelectedChanged(VideoTrack* track)
+void HTMLMediaElement::videoTrackSelectedChanged(VideoTrack& track)
 {
-    ASSERT(track);
-    if (m_videoTracks && m_videoTracks->contains(*track))
+    if (m_videoTracks && m_videoTracks->contains(track))
         m_videoTracks->scheduleChangeEvent();
 }
 
-void HTMLMediaElement::textTrackKindChanged(TextTrack* track)
+void HTMLMediaElement::textTrackKindChanged(TextTrack& track)
 {
-    if (track->kind() != TextTrack::Kind::Captions && track->kind() != TextTrack::Kind::Subtitles && track->mode() == TextTrack::Mode::Showing)
-        track->setMode(TextTrack::Mode::Hidden);
+    if (track.kind() != TextTrack::Kind::Captions && track.kind() != TextTrack::Kind::Subtitles && track.mode() == TextTrack::Mode::Showing)
+        track.setMode(TextTrack::Mode::Hidden);
 }
 
 void HTMLMediaElement::beginIgnoringTrackDisplayUpdateRequests()
@@ -1887,26 +1885,28 @@ void HTMLMediaElement::endIgnoringTrackDisplayUpdateRequests()
         updateActiveTextTrackCues(currentMediaTime());
 }
 
-void HTMLMediaElement::textTrackAddCues(TextTrack* track, const TextTrackCueList* cues) 
+void HTMLMediaElement::textTrackAddCues(TextTrack& track, const TextTrackCueList& cues)
 {
-    if (track->mode() == TextTrack::Mode::Disabled)
+    if (track.mode() == TextTrack::Mode::Disabled)
         return;
 
-    TrackDisplayUpdateScope scope(this);
-    for (size_t i = 0; i < cues->length(); ++i)
-        textTrackAddCue(track, *cues->item(i));
+    TrackDisplayUpdateScope scope { *this };
+    for (unsigned i = 0; i < cues.length(); ++i)
+        textTrackAddCue(track, *cues.item(i));
 }
 
-void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* cues)
+void HTMLMediaElement::textTrackRemoveCues(TextTrack&, const TextTrackCueList& cues)
 {
-    TrackDisplayUpdateScope scope(this);
-    for (size_t i = 0; i < cues->length(); ++i)
-        textTrackRemoveCue(cues->item(i)->track(), *cues->item(i));
+    TrackDisplayUpdateScope scope { *this };
+    for (unsigned i = 0; i < cues.length(); ++i) {
+        auto& cue = *cues.item(i);
+        textTrackRemoveCue(*cue.track(), cue);
+    }
 }
 
-void HTMLMediaElement::textTrackAddCue(TextTrack* track, TextTrackCue& cue)
+void HTMLMediaElement::textTrackAddCue(TextTrack& track, TextTrackCue& cue)
 {
-    if (track->mode() == TextTrack::Mode::Disabled)
+    if (track.mode() == TextTrack::Mode::Disabled)
         return;
 
     // Negative duration cues need be treated in the interval tree as
@@ -1919,7 +1919,7 @@ void HTMLMediaElement::textTrackAddCue(TextTrack* track, TextTrackCue& cue)
     updateActiveTextTrackCues(currentMediaTime());
 }
 
-void HTMLMediaElement::textTrackRemoveCue(TextTrack*, TextTrackCue& cue)
+void HTMLMediaElement::textTrackRemoveCue(TextTrack&, TextTrackCue& cue)
 {
     // Negative duration cues need to be treated in the interval tree as
     // zero-length cues.
@@ -3212,6 +3212,7 @@ void HTMLMediaElement::pauseInternal()
 }
 
 #if ENABLE(MEDIA_SOURCE)
+
 void HTMLMediaElement::detachMediaSource()
 {
     if (!m_mediaSource)
@@ -3220,6 +3221,7 @@ void HTMLMediaElement::detachMediaSource()
     m_mediaSource->detachFromElement(*this);
     m_mediaSource = nullptr;
 }
+
 #endif
 
 bool HTMLMediaElement::loop() const
@@ -3508,14 +3510,14 @@ void HTMLMediaElement::mediaPlayerDidAddAudioTrack(AudioTrackPrivate& track)
     if (isPlaying() && !m_mediaSession->playbackPermitted(*this))
         pauseInternal();
 
-    addAudioTrack(AudioTrack::create(this, &track));
+    addAudioTrack(AudioTrack::create(*this, track));
 }
 
 void HTMLMediaElement::mediaPlayerDidAddTextTrack(InbandTextTrackPrivate& track)
 {
     // 4.8.10.12.2 Sourcing in-band text tracks
     // 1. Associate the relevant data with a new text track and its corresponding new TextTrack object.
-    RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(ActiveDOMObject::scriptExecutionContext(), this, &track);
+    auto textTrack = InbandTextTrack::create(*ActiveDOMObject::scriptExecutionContext(), *this, track);
     textTrack->setMediaElement(this);
     
     // 2. Set the new text track's kind, label, and language based on the semantics of the relevant data,
@@ -3541,12 +3543,12 @@ void HTMLMediaElement::mediaPlayerDidAddTextTrack(InbandTextTrackPrivate& track)
     // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
     // interface, with the track attribute initialized to the text track's TextTrack object, at the media element's
     // textTracks attribute's TextTrackList object.
-    addTextTrack(textTrack.releaseNonNull());
+    addTextTrack(WTFMove(textTrack));
 }
 
 void HTMLMediaElement::mediaPlayerDidAddVideoTrack(VideoTrackPrivate& track)
 {
-    addVideoTrack(VideoTrack::create(this, &track));
+    addVideoTrack(VideoTrack::create(*this, track));
 }
 
 void HTMLMediaElement::mediaPlayerDidRemoveAudioTrack(AudioTrackPrivate& track)
@@ -3603,9 +3605,9 @@ void HTMLMediaElement::removeAudioTrack(AudioTrack& track)
 
 void HTMLMediaElement::removeTextTrack(TextTrack& track, bool scheduleEvent)
 {
-    TrackDisplayUpdateScope scope(this);
-    if (TextTrackCueList* cues = track.cues())
-        textTrackRemoveCues(&track, cues);
+    TrackDisplayUpdateScope scope { *this };
+    if (auto* cues = track.cues())
+        textTrackRemoveCues(track, *cues);
     track.clearClient();
     if (m_textTracks)
         m_textTracks->remove(track, scheduleEvent);
@@ -3625,7 +3627,7 @@ void HTMLMediaElement::forgetResourceSpecificTracks()
         removeAudioTrack(*m_audioTracks->lastItem());
 
     if (m_textTracks) {
-        TrackDisplayUpdateScope scope(this);
+        TrackDisplayUpdateScope scope { *this };
         for (int i = m_textTracks->length() - 1; i >= 0; --i) {
             auto& track = *m_textTracks->item(i);
             if (track.trackType() == TextTrack::InBand)
@@ -6078,12 +6080,12 @@ MediaController* HTMLMediaElement::controller() const
     return m_mediaController.get();
 }
 
-void HTMLMediaElement::setController(PassRefPtr<MediaController> controller)
+void HTMLMediaElement::setController(RefPtr<MediaController>&& controller)
 {
     if (m_mediaController)
         m_mediaController->removeMediaElement(*this);
 
-    m_mediaController = controller;
+    m_mediaController = WTFMove(controller);
 
     if (m_mediaController)
         m_mediaController->addMediaElement(*this);
index 023cc33..ca1898d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #if ENABLE(VIDEO)
 
-#include "HTMLElement.h"
 #include "ActiveDOMObject.h"
 #include "GenericEventQueue.h"
 #include "GenericTaskQueue.h"
+#include "HTMLElement.h"
 #include "HTMLMediaElementEnums.h"
 #include "MediaCanStartListener.h"
 #include "MediaControllerInterface.h"
@@ -69,9 +69,7 @@ class MediaControls;
 class MediaControlsHost;
 class MediaElementAudioSourceNode;
 class MediaError;
-#if ENABLE(ENCRYPTED_MEDIA)
 class MediaKeys;
-#endif
 class MediaPlayer;
 class MediaSession;
 class MediaSource;
@@ -81,7 +79,6 @@ class ScriptExecutionContext;
 class SourceBuffer;
 class TextTrackList;
 class TimeRanges;
-class URL;
 class VideoPlaybackQuality;
 class VideoTrackList;
 class VideoTrackPrivate;
@@ -331,20 +328,20 @@ public:
     void updateTextTrackDisplay();
 
     // AudioTrackClient
-    void audioTrackEnabledChanged(AudioTrack*) override;
+    void audioTrackEnabledChanged(AudioTrack&) final;
 
     void textTrackReadyStateChanged(TextTrack*);
 
     // TextTrackClient
-    void textTrackKindChanged(TextTrack*) override;
-    void textTrackModeChanged(TextTrack*) override;
-    void textTrackAddCues(TextTrack*, const TextTrackCueList*) override;
-    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) override;
-    void textTrackAddCue(TextTrack*, TextTrackCue&) override;
-    void textTrackRemoveCue(TextTrack*, TextTrackCue&) override;
+    void textTrackKindChanged(TextTrack&) override;
+    void textTrackModeChanged(TextTrack&) override;
+    void textTrackAddCues(TextTrack&, const TextTrackCueList&) override;
+    void textTrackRemoveCues(TextTrack&, const TextTrackCueList&) override;
+    void textTrackAddCue(TextTrack&, TextTrackCue&) override;
+    void textTrackRemoveCue(TextTrack&, TextTrackCue&) override;
 
     // VideoTrackClient
-    void videoTrackSelectedChanged(VideoTrack*) override;
+    void videoTrackSelectedChanged(VideoTrack&) final;
 
     bool requiresTextTrackRepresentation() const;
     void setTextTrackRepresentation(TextTrackRepresentation*);
@@ -422,7 +419,7 @@ public:
     void setMediaGroup(const String&);
 
     MediaController* controller() const;
-    void setController(PassRefPtr<MediaController>);
+    void setController(RefPtr<MediaController>&&);
 
     void enteredOrExitedFullscreen() { configureMediaControls(); }
 
index 890aa6a..53cdcd6 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  *
  * This library is free software; you can redistribute it and/or
@@ -519,11 +519,6 @@ bool HTMLObjectElement::appendFormData(FormDataList& encoding, bool)
     return true;
 }
 
-HTMLFormElement* HTMLObjectElement::virtualForm() const
-{
-    return FormAssociatedElement::form();
-}
-
 bool HTMLObjectElement::canContainRangeEndPoint() const
 {
     // Call through to HTMLElement because we need to skip HTMLPlugInElement
index e3c55e4..9ea893b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -54,7 +54,7 @@ public:
     using HTMLPlugInImageElement::ref;
     using HTMLPlugInImageElement::deref;
 
-    using FormAssociatedElement::form;
+    HTMLFormElement* form() const final { return FormAssociatedElement::form(); }
 
 private:
     HTMLObjectElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser);
@@ -91,7 +91,6 @@ private:
 
     void refFormAssociatedElement() final { ref(); }
     void derefFormAssociatedElement() final { deref(); }
-    HTMLFormElement* virtualForm() const final;
 
     FormNamedItem* asFormNamedItem() final { return this; }
     HTMLObjectElement& asHTMLElement() final { return *this; }
index 9a305ff..8fbe51e 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
- * Copyright (C) 2004, 2005, 2006, 2010, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2011 Motorola Mobility, Inc.  All rights reserved.
  *
@@ -334,7 +334,7 @@ String HTMLOptionElement::collectOptionInnerText() const
         if (is<Text>(*node))
             text.append(node->nodeValue());
         // Text nodes inside script elements are not part of the option text.
-        if (is<Element>(*node) && toScriptElementIfPossible(downcast<Element>(node)))
+        if (is<Element>(*node) && isScriptElement(downcast<Element>(*node)))
             node = NodeTraversal::nextSkippingChildren(*node, this);
         else
             node = NodeTraversal::next(*node, this);
index a864e87..ce6d3b6 100644 (file)
@@ -1,8 +1,8 @@
-/**
+/*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
- * Copyright (C) 2004, 2005, 2006, 2014 Apple Inc.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -108,21 +108,20 @@ void HTMLPlugInElement::resetInstance()
     m_instance = nullptr;
 }
 
-PassRefPtr<JSC::Bindings::Instance> HTMLPlugInElement::getInstance()
+JSC::Bindings::Instance* HTMLPlugInElement::bindingsInstance()
 {
-    Frame* frame = document().frame();
+    auto* frame = document().frame();
     if (!frame)
-        return 0;
+        return nullptr;
 
     // If the host dynamically turns off JavaScript (or Java) we will still return
     // the cached allocated Bindings::Instance.  Not supporting this edge-case is OK.
-    if (m_instance)
-        return m_instance;
-
-    if (Widget* widget = pluginWidget())
-        m_instance = frame->script().createScriptInstanceForWidget(widget);
 
-    return m_instance;
+    if (!m_instance) {
+        if (auto* widget = pluginWidget())
+            m_instance = frame->script().createScriptInstanceForWidget(widget);
+    }
+    return m_instance.get();
 }
 
 bool HTMLPlugInElement::guardedDispatchBeforeLoadEvent(const String& sourceURL)
@@ -199,7 +198,7 @@ void HTMLPlugInElement::defaultEventHandler(Event& event)
         }
 
         if (is<RenderSnapshottedPlugIn>(*renderer) && displayState() < Restarting) {
-            downcast<RenderSnapshottedPlugIn>(*renderer).handleEvent(&event);
+            downcast<RenderSnapshottedPlugIn>(*renderer).handleEvent(event);
             HTMLFrameOwnerElement::defaultEventHandler(event);
             return;
         }
index 5b8c5ad..89271c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -44,7 +44,7 @@ public:
 
     void resetInstance();
 
-    PassRefPtr<JSC::Bindings::Instance> getInstance();
+    JSC::Bindings::Instance* bindingsInstance();
 
     enum class PluginLoadingPolicy { DoNotLoad, Load };
     WEBCORE_EXPORT Widget* pluginWidget(PluginLoadingPolicy = PluginLoadingPolicy::Load) const;
@@ -60,7 +60,7 @@ public:
     };
     DisplayState displayState() const { return m_displayState; }
     virtual void setDisplayState(DisplayState);
-    virtual void updateSnapshot(PassRefPtr<Image>) { }
+    virtual void updateSnapshot(Image*) { }
     virtual void dispatchPendingMouseClick() { }
     virtual bool isRestartedPlugin() const { return false; }
 
index fa2347b..2a7628a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -171,7 +171,7 @@ RenderPtr<RenderElement> HTMLPlugInImageElement::createElementRenderer(RenderSty
 
     if (displayState() == DisplayingSnapshot) {
         auto renderSnapshottedPlugIn = createRenderer<RenderSnapshottedPlugIn>(*this, WTFMove(style));
-        renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage);
+        renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage.get());
         return WTFMove(renderSnapshottedPlugIn);
     }
 
@@ -301,7 +301,7 @@ void HTMLPlugInImageElement::startLoadingImage()
     m_imageLoader->updateFromElement();
 }
 
-void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)
+void HTMLPlugInImageElement::updateSnapshot(Image* image)
 {
     if (displayState() > DisplayingSnapshot)
         return;
index a3f7e10..b1c7626 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -118,7 +118,7 @@ private:
     void defaultEventHandler(Event&) final;
     void dispatchPendingMouseClick() final;
 
-    void updateSnapshot(PassRefPtr<Image>) final;
+    void updateSnapshot(Image*) final;
 
     void startLoadingImage();
     void updateWidgetIfNecessary();
index edc27b9..7a2b82d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
index f2bd525..32d8ee0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Inc. All rights reserved.
  * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -43,6 +43,9 @@ public:
     WEBCORE_EXPORT void setCrossOrigin(const AtomicString&);
     WEBCORE_EXPORT String crossOrigin() const;
 
+    using HTMLElement::ref;
+    using HTMLElement::deref;
+
 private:
     HTMLScriptElement(const QualifiedName&, Document&, bool wasInsertedByParser, bool alreadyStarted);
 
index 7db914f..a9a5374 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  *
  * This library is free software; you can redistribute it and/or
@@ -427,7 +427,7 @@ static inline void setContainerAndOffsetForRange(Node* node, int offset, Node*&
     }
 }
 
-PassRefPtr<Range> HTMLTextFormControlElement::selection() const
+RefPtr<Range> HTMLTextFormControlElement::selection() const
 {
     if (!renderer() || !isTextFormControl() || !hasCachedSelection())
         return nullptr;
index 4a63e97..128b031 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -74,7 +74,7 @@ public:
     WEBCORE_EXPORT virtual ExceptionOr<void> setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode);
     void setSelectionRange(int start, int end, const String& direction, const AXTextStateChangeIntent& = AXTextStateChangeIntent());
     WEBCORE_EXPORT void setSelectionRange(int start, int end, TextFieldSelectionDirection = SelectionHasNoDirection, const AXTextStateChangeIntent& = AXTextStateChangeIntent());
-    PassRefPtr<Range> selection() const;
+    RefPtr<Range> selection() const;
     String selectedText() const;
 
     void dispatchFormControlChangeEvent() final;
index 07f42d9..668b812 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -42,6 +43,7 @@ namespace WebCore {
 using namespace HTMLNames;
 
 #if !LOG_DISABLED
+
 static String urlForLoggingTrack(const URL& url)
 {
     static const unsigned maximumURLLengthForLogging = 128;
@@ -50,6 +52,7 @@ static String urlForLoggingTrack(const URL& url)
         return url.string();
     return url.string().substring(0, maximumURLLengthForLogging) + "...";
 }
+
 #endif
     
 inline HTMLTrackElement::HTMLTrackElement(const QualifiedName& tagName, Document& document)
@@ -279,43 +282,43 @@ const AtomicString& HTMLTrackElement::mediaElementCrossOriginAttribute() const
     return nullAtom;
 }
 
-void HTMLTrackElement::textTrackKindChanged(TextTrack* track)
+void HTMLTrackElement::textTrackKindChanged(TextTrack& track)
 {
-    if (HTMLMediaElement* parent = mediaElement())
+    if (auto* parent = mediaElement())
         parent->textTrackKindChanged(track);
 }
 
-void HTMLTrackElement::textTrackModeChanged(TextTrack* track)
+void HTMLTrackElement::textTrackModeChanged(TextTrack& track)
 {
     // Since we've moved to a new parent, we may now be able to load.
     if (readyState() == HTMLTrackElement::NONE)
         scheduleLoad();
 
-    if (HTMLMediaElement* parent = mediaElement())
+    if (auto* parent = mediaElement())
         parent->textTrackModeChanged(track);
 }
 
-void HTMLTrackElement::textTrackAddCues(TextTrack* track, const TextTrackCueList* cues)
+void HTMLTrackElement::textTrackAddCues(TextTrack& track, const TextTrackCueList& cues)
 {
-    if (HTMLMediaElement* parent = mediaElement())
+    if (auto* parent = mediaElement())
         parent->textTrackAddCues(track, cues);
 }
     
-void HTMLTrackElement::textTrackRemoveCues(TextTrack* track, const TextTrackCueList* cues)
+void HTMLTrackElement::textTrackRemoveCues(TextTrack& track, const TextTrackCueList& cues)
 {
-    if (HTMLMediaElement* parent = mediaElement())
+    if (auto* parent = mediaElement())
         parent->textTrackRemoveCues(track, cues);
 }
     
-void HTMLTrackElement::textTrackAddCue(TextTrack* track, TextTrackCue& cue)
+void HTMLTrackElement::textTrackAddCue(TextTrack& track, TextTrackCue& cue)
 {
-    if (HTMLMediaElement* parent = mediaElement())
+    if (auto* parent = mediaElement())
         parent->textTrackAddCue(track, cue);
 }
     
-void HTMLTrackElement::textTrackRemoveCue(TextTrack* track, TextTrackCue& cue)
+void HTMLTrackElement::textTrackRemoveCue(TextTrack& track, TextTrackCue& cue)
 {
-    if (HTMLMediaElement* parent = mediaElement())
+    if (auto* parent = mediaElement())
         parent->textTrackRemoveCue(track, cue);
 }
 
index 9b425dc..2251027 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -74,12 +75,12 @@ private:
     HTMLMediaElement* mediaElement() const;
 
     // TextTrackClient
-    void textTrackModeChanged(TextTrack*) final;
-    void textTrackKindChanged(TextTrack*) final;
-    void textTrackAddCues(TextTrack*, const TextTrackCueList*) final;
-    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) final;
-    void textTrackAddCue(TextTrack*, TextTrackCue&) final;
-    void textTrackRemoveCue(TextTrack*, TextTrackCue&) final;
+    void textTrackModeChanged(TextTrack&) final;
+    void textTrackKindChanged(TextTrack&) final;
+    void textTrackAddCues(TextTrack&, const TextTrackCueList&) final;
+    void textTrackRemoveCues(TextTrack&, const TextTrackCueList&) final;
+    void textTrackAddCue(TextTrack&, TextTrackCue&) final;
+    void textTrackRemoveCue(TextTrack&, TextTrackCue&) final;
 
     bool canLoadURL(const URL&);
 
index f6a6bbc..3a861ad 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
  * Copyright (C) 2009, 2010, 2011, 2012 Google Inc. All rights reserved.
@@ -482,11 +482,6 @@ bool InputType::shouldSubmitImplicitly(Event& event)
     return is<KeyboardEvent>(event) && event.type() == eventNames().keypressEvent && downcast<KeyboardEvent>(event).charCode() == '\r';
 }
 
-PassRefPtr<HTMLFormElement> InputType::formForSubmission() const
-{
-    return element().form();
-}
-
 RenderPtr<RenderElement> InputType::createInputRenderer(RenderStyle&& style)
 {
     return RenderPtr<RenderElement>(RenderElement::createFor(element(), WTFMove(style)));
@@ -551,7 +546,7 @@ Chrome* InputType::chrome() const
 {
     if (Page* page = element().document().page())
         return &page->chrome();
-    return 0;
+    return nullptr;
 }
 
 bool InputType::canSetStringValue() const
@@ -636,7 +631,7 @@ bool InputType::canBeSuccessfulSubmitButton()
 
 HTMLElement* InputType::placeholderElement() const
 {
-    return 0;
+    return nullptr;
 }
 
 bool InputType::rendererIsNeeded()
@@ -646,10 +641,10 @@ bool InputType::rendererIsNeeded()
 
 FileList* InputType::files()
 {
-    return 0;
+    return nullptr;
 }
 
-void InputType::setFiles(PassRefPtr<FileList>)
+void InputType::setFiles(RefPtr<FileList>&&)
 {
 }
 
@@ -731,25 +726,29 @@ String InputType::sanitizeValue(const String& proposedValue) const
 }
 
 #if ENABLE(DRAG_SUPPORT)
+
 bool InputType::receiveDroppedFiles(const DragData&)
 {
     ASSERT_NOT_REACHED();
     return false;
 }
+
 #endif
 
 Icon* InputType::icon() const
 {
     ASSERT_NOT_REACHED();
-    return 0;
+    return nullptr;
 }
 
 #if PLATFORM(IOS)
+
 String InputType::displayString() const
 {
     ASSERT_NOT_REACHED();
     return String();
 }
+
 #endif
 
 bool InputType::shouldResetOnDocumentActivation()
index c4be73d..98cff89 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2011, 2014-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -192,7 +192,6 @@ public:
     // Helpers for event handlers.
 
     virtual bool shouldSubmitImplicitly(Event&);
-    virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
     virtual bool hasCustomFocusLogic() const;
     virtual bool isKeyboardFocusable(KeyboardEvent&) const;
     virtual bool isMouseFocusable() const;
@@ -239,7 +238,7 @@ public:
     virtual void maxResultsAttributeChanged();
     virtual bool shouldRespectAlignAttribute();
     virtual FileList* files();
-    virtual void setFiles(PassRefPtr<FileList>);
+    virtual void setFiles(RefPtr<FileList>&&);
     virtual Icon* icon() const;
     virtual bool shouldSendChangeEventAfterCheckedChanged();
     virtual bool canSetValue(const String&);
index f351f97..bb300b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,15 +53,13 @@ public:
 private:
     PluginDocumentParser(Document& document)
         : RawDataDocumentParser(document)
-        , m_embedElement(0)
     {
     }
 
-    void appendBytes(DocumentWriter&, const char*, size_t) override;
-
+    void appendBytes(DocumentWriter&, const char*, size_t) final;
     void createDocumentStructure();
 
-    HTMLEmbedElement* m_embedElement;
+    HTMLEmbedElement* m_embedElement { nullptr };
 };
 
 void PluginDocumentParser::createDocumentStructure()
@@ -104,7 +102,7 @@ void PluginDocumentParser::createDocumentStructure()
     if (auto* loader = document.loader())
         m_embedElement->setAttributeWithoutSynchronization(typeAttr, loader->writer().mimeType());
 
-    document.setPluginElement(m_embedElement);
+    document.setPluginElement(*m_embedElement);
 
     body->appendChild(embedElement);
 }
@@ -116,7 +114,7 @@ void PluginDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
 
     createDocumentStructure();
 
-    Frame* frame = document()->frame();
+    auto* frame = document()->frame();
     if (!frame)
         return;
 
@@ -142,7 +140,6 @@ void PluginDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
 
 PluginDocument::PluginDocument(Frame* frame, const URL& url)
     : HTMLDocument(frame, url, PluginDocumentClass)
-    , m_shouldLoadPluginManually(true)
 {
     setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
     lockCompatibilityMode();
@@ -155,14 +152,17 @@ Ref<DocumentParser> PluginDocument::createParser()
 
 Widget* PluginDocument::pluginWidget()
 {
-    if (m_pluginElement && m_pluginElement->renderer())
-        return downcast<RenderEmbeddedObject>(*m_pluginElement->renderer()).widget();
-    return nullptr;
+    if (!m_pluginElement)
+        return nullptr;
+    auto* renderer = m_pluginElement->renderer();
+    if (!renderer)
+        return nullptr;
+    return downcast<RenderEmbeddedObject>(*m_pluginElement->renderer()).widget();
 }
 
-void PluginDocument::setPluginElement(PassRefPtr<HTMLPlugInElement> element)
+void PluginDocument::setPluginElement(HTMLPlugInElement& element)
 {
-    m_pluginElement = element;
+    m_pluginElement = &element;
 }
 
 void PluginDocument::detachFromPluginElement()
@@ -179,9 +179,10 @@ void PluginDocument::cancelManualPluginLoad()
     if (!shouldLoadPluginManually())
         return;
 
-    DocumentLoader* documentLoader = frame()->loader().activeDocumentLoader();
-    documentLoader->cancelMainResourceLoad(frame()->loader().cancelledError(documentLoader->request()));
-    setShouldLoadPluginManually(false);
+    auto& frameLoader = frame()->loader();
+    auto& documentLoader = *frameLoader.activeDocumentLoader();
+    documentLoader.cancelMainResourceLoad(frameLoader.cancelledError(documentLoader.request()));
+    m_shouldLoadPluginManually = false;
 }
 
 }
index 3cd0612..bd7ed6c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2008, 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,26 +38,23 @@ public:
         return adoptRef(*new PluginDocument(frame, url));
     }
 
-    void setPluginElement(PassRefPtr<HTMLPlugInElement>);
-
     WEBCORE_EXPORT Widget* pluginWidget();
     HTMLPlugInElement* pluginElement() { return m_pluginElement.get(); }
 
+    void setPluginElement(HTMLPlugInElement&);
     void detachFromPluginElement();
 
     void cancelManualPluginLoad();
 
-    bool shouldLoadPluginManually() { return m_shouldLoadPluginManually; }
+    bool shouldLoadPluginManually() const { return m_shouldLoadPluginManually; }
 
 private:
     PluginDocument(Frame*, const URL&);
 
-    Ref<DocumentParser> createParser() override;
-
-    void setShouldLoadPluginManually(bool loadManually) { m_shouldLoadPluginManually = loadManually; }
+    Ref<DocumentParser> createParser() final;
 
-    bool m_shouldLoadPluginManually;
     RefPtr<HTMLPlugInElement> m_pluginElement;
+    bool m_shouldLoadPluginManually { true };
 };
 
 } // namespace WebCore
index 94e8b4d..77fa518 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
@@ -172,7 +172,7 @@ bool CanvasRenderingContext2D::isAccelerated() const
 #if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
     if (!canvas().hasCreatedImageBuffer())
         return false;
-    GraphicsContext* context = drawingContext();
+    auto* context = drawingContext();
     return context && context->isAcceleratedContext();
 #else
     return false;
@@ -417,7 +417,7 @@ void CanvasRenderingContext2D::setStrokeStyle(CanvasStyle style)
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
-    state.strokeStyle.applyStrokeColor(c);
+    state.strokeStyle.applyStrokeColor(*c);
     state.unparsedStrokeColor = String();
 }
 
@@ -444,7 +444,7 @@ void CanvasRenderingContext2D::setFillStyle(CanvasStyle style)
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
-    state.fillStyle.applyFillColor(c);
+    state.fillStyle.applyFillColor(*c);
     state.unparsedFillColor = String();
 }
 
@@ -930,13 +930,13 @@ static bool validateRectForCanvas(float& x, float& y, float& width, float& heigh
     return true;
 }
 
-#if ENABLE(DASHBOARD_SUPPORT)
-void CanvasRenderingContext2D::clearPathForDashboardBackwardCompatibilityMode()
+inline void CanvasRenderingContext2D::clearPathForDashboardBackwardCompatibilityMode()
 {
+#if ENABLE(DASHBOARD_SUPPORT)
     if (m_usesDashboardCompatibilityMode)
         m_path.clear();
-}
 #endif
+}
 
 static bool isFullCanvasCompositeMode(CompositeOperator op)
 {
@@ -954,28 +954,19 @@ static WindRule toWindRule(CanvasRenderingContext2D::WindingRule rule)
 void CanvasRenderingContext2D::fill(WindingRule windingRule)
 {
     fillInternal(m_path, windingRule);
-
-#if ENABLE(DASHBOARD_SUPPORT)
     clearPathForDashboardBackwardCompatibilityMode();
-#endif
 }
 
 void CanvasRenderingContext2D::stroke()
 {
     strokeInternal(m_path);
-
-#if ENABLE(DASHBOARD_SUPPORT)
     clearPathForDashboardBackwardCompatibilityMode();
-#endif
 }
 
 void CanvasRenderingContext2D::clip(WindingRule windingRule)
 {
     clipInternal(m_path, windingRule);
-
-#if ENABLE(DASHBOARD_SUPPORT)
     clearPathForDashboardBackwardCompatibilityMode();
-#endif
 }
 
 void CanvasRenderingContext2D::fill(DOMPath& path, WindingRule windingRule)
@@ -995,19 +986,19 @@ void CanvasRenderingContext2D::clip(DOMPath& path, WindingRule windingRule)
 
 void CanvasRenderingContext2D::fillInternal(const Path& path, WindingRule windingRule)
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
         return;
 
     // If gradient size is zero, then paint nothing.
-    Gradient* gradient = c->fillGradient();
+    auto* gradient = c->fillGradient();
     if (gradient && gradient->isZeroSize())
         return;
 
     if (!path.isEmpty()) {
-        WindRule windRule = c->fillRule();
+        auto savedFillRule = c->fillRule();
         c->setFillRule(toWindRule(windingRule));
 
         if (isFullCanvasCompositeMode(state().globalComposite)) {
@@ -1024,20 +1015,20 @@ void CanvasRenderingContext2D::fillInternal(const Path& path, WindingRule windin
             didDraw(path.fastBoundingRect());
         }
         
-        c->setFillRule(windRule);
+        c->setFillRule(savedFillRule);
     }
 }
 
 void CanvasRenderingContext2D::strokeInternal(const Path& path)
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
         return;
 
     // If gradient size is zero, then paint nothing.
-    Gradient* gradient = c->strokeGradient();
+    auto* gradient = c->strokeGradient();
     if (gradient && gradient->isZeroSize())
         return;
 
@@ -1062,7 +1053,7 @@ void CanvasRenderingContext2D::strokeInternal(const Path& path)
 
 void CanvasRenderingContext2D::clipInternal(const Path& path, WindingRule windingRule)
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
@@ -1108,13 +1099,13 @@ bool CanvasRenderingContext2D::isPointInStroke(DOMPath& path, float x, float y)
 
 bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, float x, float y, WindingRule windingRule)
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return false;
     if (!state().hasInvertibleTransform)
         return false;
 
-    FloatPoint transformedPoint = state().transform.inverse().value_or(AffineTransform()).mapPoint(FloatPoint(x, y));
+    auto transformedPoint = state().transform.inverse().value_or(AffineTransform()).mapPoint(FloatPoint(x, y));
 
     if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.y()))
         return false;
@@ -1124,13 +1115,13 @@ bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, float x,
 
 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, float x, float y)
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return false;
     if (!state().hasInvertibleTransform)
         return false;
 
-    FloatPoint transformedPoint = state().transform.inverse().value_or(AffineTransform()).mapPoint(FloatPoint(x, y));
+    auto transformedPoint = state().transform.inverse().value_or(AffineTransform()).mapPoint(FloatPoint(x, y));
     if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.y()))
         return false;
 
@@ -1142,7 +1133,7 @@ void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
-    GraphicsContext* context = drawingContext();
+    auto* context = drawingContext();
     if (!context)
         return;
     if (!state().hasInvertibleTransform)
@@ -1180,7 +1171,7 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei
     if (!validateRectForCanvas(x, y, width, height))
         return;
 
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
@@ -1189,7 +1180,7 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei
     // from the HTML5 Canvas spec:
     // If x0 = x1 and y0 = y1, then the linear gradient must paint nothing
     // If x0 = x1 and y0 = y1 and r0 = r1, then the radial gradient must paint nothing
-    Gradient* gradient = c->fillGradient();
+    auto* gradient = c->fillGradient();
     if (gradient && gradient->isZeroSize())
         return;
 
@@ -1218,7 +1209,7 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h
     if (!validateRectForCanvas(x, y, width, height))
         return;
 
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
@@ -1227,7 +1218,7 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h
         return;
 
     // If gradient size is zero, then paint nothing.
-    Gradient* gradient = c->strokeGradient();
+    auto* gradient = c->strokeGradient();
     if (gradient && gradient->isZeroSize())
         return;
 
@@ -1251,11 +1242,12 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h
 
 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& colorString, std::optional<float> alpha)
 {
-    Color color = parseColorOrCurrentColor(colorString, &canvas());
-    if (!colorString.isNull() && !color.isValid())
-        return;
-    if (!color.isValid())
-        color = Color::transparent;
+    Color color = Color::transparent;
+    if (!colorString.isNull()) {
+        color = parseColorOrCurrentColor(colorString, &canvas());
+        if (!color.isValid())
+            return;
+    }
     // FIXME: Should not use RGBA32 here.
     setShadow(FloatSize(width, height), blur, colorWithOverrideAlpha(color.rgb(), alpha));
 }
@@ -1296,7 +1288,7 @@ void CanvasRenderingContext2D::setShadow(const FloatSize& offset, float blur, co
 
 void CanvasRenderingContext2D::applyShadow()
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
 
@@ -1313,35 +1305,33 @@ bool CanvasRenderingContext2D::shouldDrawShadows() const
     return state().shadowColor.isVisible() && (state().shadowBlur || !state().shadowOffset.isZero());
 }
 
-enum ImageSizeType {
-    ImageSizeAfterDevicePixelRatio,
-    ImageSizeBeforeDevicePixelRatio
-};
-
-static LayoutSize size(HTMLImageElement& imageElement, ImageSizeType sizeType = ImageSizeBeforeDevicePixelRatio)
+enum class ImageSizeType { AfterDevicePixelRatio, BeforeDevicePixelRatio };
+static LayoutSize size(HTMLImageElement& element, ImageSizeType sizeType = ImageSizeType::BeforeDevicePixelRatio)
 {
     LayoutSize size;
-    if (CachedImage* cachedImage = imageElement.cachedImage()) {
-        size = cachedImage->imageSizeForRenderer(imageElement.renderer(), 1.0f); // FIXME: Not sure about this.
-
-        if (sizeType == ImageSizeAfterDevicePixelRatio && is<RenderImage>(imageElement.renderer()) && cachedImage->image() && !cachedImage->image()->hasRelativeWidth())
-            size.scale(downcast<RenderImage>(*imageElement.renderer()).imageDevicePixelRatio());
+    if (auto* cachedImage = element.cachedImage()) {
+        size = cachedImage->imageSizeForRenderer(element.renderer(), 1.0f); // FIXME: Not sure about this.
+        if (sizeType == ImageSizeType::AfterDevicePixelRatio && is<RenderImage>(element.renderer()) && cachedImage->image() && !cachedImage->image()->hasRelativeWidth())
+            size.scale(downcast<RenderImage>(*element.renderer()).imageDevicePixelRatio());
     }
     return size;
 }
 
-static FloatSize size(HTMLCanvasElement& canvasElement)
+static inline FloatSize size(HTMLCanvasElement& canvasElement)
 {
-    return FloatSize(canvasElement.size());
+    return canvasElement.size();
 }
 
 #if ENABLE(VIDEO)
-static FloatSize size(HTMLVideoElement& video)
+
+static inline FloatSize size(HTMLVideoElement& video)
 {
-    if (MediaPlayer* player = video.player())
-        return player->naturalSize();
-    return FloatSize();
+    auto* player = video.player();
+    if (!player)
+        return { };
+    return player->naturalSize();
 }
+
 #endif
 
 static inline FloatRect normalizeRect(const FloatRect& rect)
@@ -1356,8 +1346,8 @@ ExceptionOr<void> CanvasRenderingContext2D::drawImage(CanvasImageSource&& image,
 {
     return WTF::switchOn(image,
         [&] (RefPtr<HTMLImageElement>& imageElement) -> ExceptionOr<void> {
-            LayoutSize destRectSize = size(*imageElement, ImageSizeAfterDevicePixelRatio);
-            LayoutSize sourceRectSize = size(*imageElement, ImageSizeBeforeDevicePixelRatio);
+            LayoutSize destRectSize = size(*imageElement, ImageSizeType::AfterDevicePixelRatio);
+            LayoutSize sourceRectSize = size(*imageElement, ImageSizeType::BeforeDevicePixelRatio);
             return this->drawImage(*imageElement, FloatRect { 0, 0, sourceRectSize.width(), sourceRectSize.height() }, FloatRect { dx, dy, destRectSize.width(), destRectSize.height() });
         },
         [&] (auto& element) -> ExceptionOr<void> {
@@ -1406,7 +1396,7 @@ ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLImageElement& imageEle
     FloatRect normalizedSrcRect = normalizeRect(srcRect);
     FloatRect normalizedDstRect = normalizeRect(dstRect);
 
-    FloatRect imageRect = FloatRect(FloatPoint(), size(imageElement, ImageSizeBeforeDevicePixelRatio));
+    FloatRect imageRect = FloatRect(FloatPoint(), size(imageElement, ImageSizeType::BeforeDevicePixelRatio));
     if (!srcRect.width() || !srcRect.height())
         return Exception { INDEX_SIZE_ERR };
 
@@ -1574,7 +1564,7 @@ ExceptionOr<void> CanvasRenderingContext2D::drawImage(HTMLVideoElement& video, c
 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement& imageElement, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, const String& compositeOperation)
 {
     CompositeOperator op;
-    BlendMode blendOp = BlendModeNormal;
+    auto blendOp = BlendModeNormal;
     if (!parseCompositeAndBlendOperator(compositeOperation, op, blendOp) || blendOp != BlendModeNormal)
         op = CompositeSourceOver;
     drawImage(imageElement, FloatRect { sx, sy, sw, sh }, FloatRect { dx, dy, dw, dh }, op, BlendModeNormal);
@@ -1592,14 +1582,13 @@ void CanvasRenderingContext2D::setCompositeOperation(const String& operation)
 
 void CanvasRenderingContext2D::clearCanvas()
 {
-    FloatRect canvasRect(0, 0, canvas().width(), canvas().height());
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
 
     c->save();
     c->setCTM(canvas().baseTransform());
-    c->clearRect(canvasRect);
+    c->clearRect(FloatRect(0, 0, canvas().width(), canvas().height()));
     c->restore();
 }
 
@@ -1648,7 +1637,7 @@ void CanvasRenderingContext2D::compositeBuffer(ImageBuffer& buffer, const IntRec
     IntRect canvasRect(0, 0, canvas().width(), canvas().height());
     canvasRect = canvas().baseTransform().mapRect(canvasRect);
 
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
 
@@ -1679,17 +1668,17 @@ template<class T> void CanvasRenderingContext2D::fullCanvasCompositedDrawImage(T
     ASSERT(isFullCanvasCompositeMode(op));
 
     IntSize croppedOffset;
-    IntRect bufferRect = calculateCompositingBufferRect(dest, &croppedOffset);
+    auto bufferRect = calculateCompositingBufferRect(dest, &croppedOffset);
     if (bufferRect.isEmpty()) {
         clearCanvas();
         return;
     }
 
-    std::unique_ptr<ImageBuffer> buffer = createCompositingBuffer(bufferRect);
+    auto buffer = createCompositingBuffer(bufferRect);
     if (!buffer)
         return;
 
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
 
@@ -1720,7 +1709,7 @@ ExceptionOr<Ref<CanvasGradient>> CanvasRenderingContext2D::createLinearGradient(
     if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(x1) || !std::isfinite(y1))
         return Exception { NOT_SUPPORTED_ERR };
 
-    Ref<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1));
+    auto gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1));
     prepareGradientForDashboard(gradient.get());
     return WTFMove(gradient);
 }
@@ -1733,7 +1722,7 @@ ExceptionOr<Ref<CanvasGradient>> CanvasRenderingContext2D::createRadialGradient(
     if (r0 < 0 || r1 < 0)
         return Exception { INDEX_SIZE_ERR };
 
-    Ref<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, FloatPoint(x1, y1), r1);
+    auto gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, FloatPoint(x1, y1), r1);
     prepareGradientForDashboard(gradient.get());
     return WTFMove(gradient);
 }
@@ -1745,7 +1734,7 @@ ExceptionOr<RefPtr<CanvasPattern>> CanvasRenderingContext2D::createPattern(Canva
         return Exception { SYNTAX_ERR };
 
     return WTF::switchOn(image,
-        [&](auto& element) -> ExceptionOr<RefPtr<CanvasPattern>> { return this->createPattern(*element, repeatX, repeatY); }
+        [&] (auto& element) -> ExceptionOr<RefPtr<CanvasPattern>> { return this->createPattern(*element, repeatX, repeatY); }
     );
 }
 
@@ -1812,7 +1801,7 @@ void CanvasRenderingContext2D::didDrawEntireCanvas()
 
 void CanvasRenderingContext2D::didDraw(const FloatRect& r, unsigned options)
 {
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
@@ -1866,19 +1855,17 @@ void CanvasRenderingContext2D::setTracksDisplayListReplay(bool tracksDisplayList
 
 String CanvasRenderingContext2D::displayListAsText(DisplayList::AsTextFlags flags) const
 {
-    if (m_recordingContext)
-        return m_recordingContext->displayList.asText(flags);
-    
-    return String();
+    if (!m_recordingContext)
+        return { };
+    return m_recordingContext->displayList.asText(flags);
 }
 
 String CanvasRenderingContext2D::replayDisplayListAsText(DisplayList::AsTextFlags flags) const
 {
-    auto it = contextDisplayListMap().find(this);
-    if (it != contextDisplayListMap().end())
-        return it->value->asText(flags);
-
-    return String();
+    auto* displayList = contextDisplayListMap().get(this);
+    if (!displayList)
+        return { };
+    return displayList->asText(flags);
 }
 
 void CanvasRenderingContext2D::paintRenderingResultsToCanvas()
@@ -1886,7 +1873,7 @@ void CanvasRenderingContext2D::paintRenderingResultsToCanvas()
     if (UNLIKELY(m_usesDisplayListDrawing)) {
         if (!m_recordingContext)
             return;
-        
+
         FloatRect clip(FloatPoint::zero(), canvas().size());
         DisplayList::Replayer replayer(*canvas().drawingContext(), m_recordingContext->displayList);
 
@@ -1905,7 +1892,6 @@ GraphicsContext* CanvasRenderingContext2D::drawingContext() const
     if (UNLIKELY(m_usesDisplayListDrawing)) {
         if (!m_recordingContext)
             m_recordingContext = std::make_unique<DisplayListDrawingContext>(FloatRect(FloatPoint::zero(), canvas().size()));
-
         return &m_recordingContext->context;
     }
 
@@ -1914,12 +1900,10 @@ GraphicsContext* CanvasRenderingContext2D::drawingContext() const
 
 static RefPtr<ImageData> createEmptyImageData(const IntSize& size)
 {
-    if (RefPtr<ImageData> data = ImageData::create(size)) {
+    auto data = ImageData::create(size);
+    if (data)
         data->data()->zeroFill();
-        return data;
-    }
-
-    return nullptr;
+    return data;
 }
 
 ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::createImageData(ImageData* imageData) const
@@ -2038,11 +2022,9 @@ void CanvasRenderingContext2D::drawFocusIfNeeded(DOMPath& path, Element& element
 
 void CanvasRenderingContext2D::drawFocusIfNeededInternal(const Path& path, Element& element)
 {
-    GraphicsContext* context = drawingContext();
-
+    auto* context = drawingContext();
     if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(canvas()) || !context)
         return;
-
     context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor());
 }
 
@@ -2270,7 +2252,6 @@ static inline bool isSpaceThatNeedsReplacing(UChar c)
 static void normalizeSpaces(String& text)
 {
     size_t i = text.find(isSpaceThatNeedsReplacing);
-
     if (i == notFound)
         return;
 
@@ -2301,10 +2282,10 @@ Ref<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)
 
 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, std::optional<float> maxWidth)
 {
-    const auto& fontProxy = this->fontProxy();
-    const FontMetrics& fontMetrics = fontProxy.fontMetrics();
+    auto& fontProxy = this->fontProxy();
+    const auto& fontMetrics = fontProxy.fontMetrics();
 
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (!c)
         return;
     if (!state().hasInvertibleTransform)
@@ -2315,7 +2296,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
         return;
 
     // If gradient size is zero, then paint nothing.
-    Gradient* gradient = c->strokeGradient();
+    auto* gradient = c->strokeGradient();
     if (!fill && gradient && gradient->isZeroSize())
         return;
 
@@ -2329,7 +2310,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
     // FIXME: Need to turn off font smoothing.
 
     const RenderStyle* computedStyle;
-    TextDirection direction = toTextDirection(state().direction, &computedStyle);
+    auto direction = toTextDirection(state().direction, &computedStyle);
     bool isRTL = direction == RTL;
     bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
 
@@ -2359,7 +2340,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
     bool useMaxWidth = maxWidth && maxWidth.value() < fontWidth;
     float width = useMaxWidth ? maxWidth.value() : fontWidth;
 
-    TextAlign align = state().textAlign;
+    auto align = state().textAlign;
     if (align == StartTextAlign)
         align = isRTL ? RightTextAlign : LeftTextAlign;
     else if (align == EndTextAlign)
@@ -2385,7 +2366,6 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
 #if USE(CG)
     const CanvasStyle& drawStyle = fill ? state().fillStyle : state().strokeStyle;
     if (drawStyle.canvasGradient() || drawStyle.canvasPattern()) {
-
         IntRect maskRect = enclosingIntRect(textRect);
 
         // If we have a shadow, we need to draw it before the mask operation.
@@ -2394,7 +2374,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
         if (shouldDrawShadows()) {
             GraphicsContextStateSaver stateSaver(*c);
 
-            FloatSize offset = FloatSize(0, 2 * maskRect.height());
+            FloatSize offset(0, 2 * maskRect.height());
 
             FloatSize shadowOffset;
             float shadowRadius;
@@ -2422,7 +2402,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
         if (!maskImage)
             return;
 
-        GraphicsContext& maskImageContext = maskImage->context();
+        auto& maskImageContext = maskImage->context();
 
         if (fill)
             maskImageContext.setFillColor(Color::black);
@@ -2445,7 +2425,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
 
         GraphicsContextStateSaver stateSaver(*c);
         c->clipToImageBuffer(*maskImage, maskRect);
-        drawStyle.applyFillColor(c);
+        drawStyle.applyFillColor(*c);
         c->fillRect(maskRect);
         return;
     }
@@ -2487,27 +2467,27 @@ void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const
         delta *= state().miterLimit;
     else if (state().lineCap == SquareCap)
         delta *= root2;
-
     rect.inflate(delta);
 }
 
 auto CanvasRenderingContext2D::fontProxy() -> const FontProxy&
 {
     canvas().document().updateStyleIfNeeded();
-
     if (!state().font.realized())
         setFont(state().unparsedFont);
     return state().font;
 }
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
+
 PlatformLayer* CanvasRenderingContext2D::platformLayer() const
 {
-    return canvas().buffer() ? canvas().buffer()->platformLayer() : 0;
+    return canvas().buffer() ? canvas().buffer()->platformLayer() : nullptr;
 }
+
 #endif
 
-static InterpolationQuality smoothingToInterpolationQuality(CanvasRenderingContext2D::ImageSmoothingQuality quality)
+static inline InterpolationQuality smoothingToInterpolationQuality(CanvasRenderingContext2D::ImageSmoothingQuality quality)
 {
     switch (quality) {
     case CanvasRenderingContext2D::ImageSmoothingQuality::Low:
@@ -2554,7 +2534,7 @@ void CanvasRenderingContext2D::setImageSmoothingEnabled(bool enabled)
 
     realizeSaves();
     modifiableState().imageSmoothingEnabled = enabled;
-    GraphicsContext* c = drawingContext();
+    auto* c = drawingContext();
     if (c)
         c->setImageInterpolationQuality(enabled ? smoothingToInterpolationQuality(state().imageSmoothingQuality) : InterpolationNone);
 }
index 54be9d0..e39f1b6 100644 (file)
@@ -340,9 +340,7 @@ private:
     // Therefore, all font operations must pass through the State.
     const FontProxy& fontProxy();
 
-#if ENABLE(DASHBOARD_SUPPORT)
     void clearPathForDashboardBackwardCompatibilityMode();
-#endif
 
     void beginCompositeLayer();
     void endCompositeLayer();
index 9aa0a05..9dc8f04 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
@@ -53,7 +53,6 @@ static Color parseColor(const String& colorString, Document* document = nullptr)
     Color color = CSSParser::parseColor(colorString);
     if (color.isValid())
         return color;
-
     return CSSParser::parseSystemColor(colorString, document);
 }
 
@@ -76,208 +75,150 @@ Color parseColorOrCurrentColor(const String& colorString, HTMLCanvasElement* can
 }
 
 CanvasStyle::CanvasStyle(Color color)
-    : m_color(color)
-    , m_type(RGBA)
+    : m_style(color)
 {
 }
 
 CanvasStyle::CanvasStyle(float grayLevel, float alpha)
-    : m_color(Color(grayLevel, grayLevel, grayLevel, alpha))
-    , m_type(RGBA)
+    : m_style(Color { grayLevel, grayLevel, grayLevel, alpha })
 {
 }
 
 CanvasStyle::CanvasStyle(float r, float g, float b, float a)
-    : m_color(Color(r, g, b, a))
-    , m_type(RGBA)
+    : m_style(Color { r, g, b, a })
 {
 }
 
 CanvasStyle::CanvasStyle(float c, float m, float y, float k, float a)
-    : m_cmyka(new CMYKAValues(Color(c, m, y, k, a), c, m, y, k, a))
-    , m_type(CMYKA)
+    : m_style(CMYKAColor { Color { c, m, y, k, a }, c, m, y, k, a })
 {
 }
 
-CanvasStyle::CanvasStyle(PassRefPtr<CanvasGradient> gradient)
-    : m_gradient(gradient.leakRef())
-    , m_type(Gradient)
+CanvasStyle::CanvasStyle(CanvasGradient& gradient)
+    : m_style(makeRefPtr(gradient))
 {
-    if (!m_gradient)
-        m_type = Invalid;
 }
 
-CanvasStyle::CanvasStyle(PassRefPtr<CanvasPattern> pattern)
-    : m_pattern(pattern.leakRef())
-    , m_type(ImagePattern)
+CanvasStyle::CanvasStyle(CanvasPattern& pattern)
+    : m_style(makeRefPtr(pattern))
 {
-    if (!m_pattern)
-        m_type = Invalid;
 }
 
-CanvasStyle::~CanvasStyle()
+inline CanvasStyle::CanvasStyle(CurrentColor color)
+    : m_style(color)
 {
-    if (m_type == Gradient)
-        m_gradient->deref();
-    else if (m_type == ImagePattern)
-        m_pattern->deref();
-    else if (m_type == CMYKA)
-        delete m_cmyka;
 }
 
 CanvasStyle CanvasStyle::createFromString(const String& colorString, Document* document)
 {
     if (isCurrentColorString(colorString))
-        return CanvasStyle(ConstructCurrentColor);
+        return CurrentColor { std::nullopt };
 
     Color color = parseColor(colorString, document);
-    if (color.isValid())
-        return CanvasStyle(color);
+    if (!color.isValid())
+        return { };
 
-    return CanvasStyle();
+    return color;
 }
 
 CanvasStyle CanvasStyle::createFromStringWithOverrideAlpha(const String& colorString, float alpha)
 {
     if (isCurrentColorString(colorString))
-        return CanvasStyle(CurrentColorWithOverrideAlpha, alpha);
+        return CurrentColor { alpha };
 
     Color color = parseColor(colorString);
-    if (color.isValid())
-        return CanvasStyle(colorWithOverrideAlpha(color.rgb(), alpha));
+    if (!color.isValid())
+        return { };
 
-    return CanvasStyle();
+    return Color { colorWithOverrideAlpha(color.rgb(), alpha) };
 }
 
 bool CanvasStyle::isEquivalentColor(const CanvasStyle& other) const
 {
-    if (m_type != other.m_type)
-        return false;
+    if (WTF::holds_alternative<Color>(m_style) && WTF::holds_alternative<Color>(other.m_style))
+        return WTF::get<Color>(m_style) == WTF::get<Color>(other.m_style);
 
-    switch (m_type) {
-    case RGBA:
-        return m_color == other.m_color;
-    case CMYKA:
-        return m_cmyka->c == other.m_cmyka->c
-            && m_cmyka->m == other.m_cmyka->m
-            && m_cmyka->y == other.m_cmyka->y
-            && m_cmyka->k == other.m_cmyka->k
-            && m_cmyka->a == other.m_cmyka->a;
-    case Gradient:
-    case ImagePattern:
-    case CurrentColor:
-    case CurrentColorWithOverrideAlpha:
-        return false;
-    case Invalid:
-        break;
+    if (WTF::holds_alternative<CMYKAColor>(m_style) && WTF::holds_alternative<CMYKAColor>(other.m_style)) {
+        auto& a = WTF::get<CMYKAColor>(m_style);
+        auto& b = WTF::get<CMYKAColor>(other.m_style);
+        return a.c == b.c && a.m == b.m && a.y == b.y && a.k == b.k && a.a == b.a;
     }
 
-    ASSERT_NOT_REACHED();
     return false;
 }
 
 bool CanvasStyle::isEquivalentRGBA(float r, float g, float b, float a) const
 {
-    if (m_type != RGBA)
-        return false;
-
-    return m_color == Color(r, g, b, a);
+    return WTF::holds_alternative<Color>(m_style) && WTF::get<Color>(m_style) == Color { r, g, b, a };
 }
 
 bool CanvasStyle::isEquivalentCMYKA(float c, float m, float y, float k, float a) const
 {
-    if (m_type != CMYKA)
+    if (!WTF::holds_alternative<CMYKAColor>(m_style))
         return false;
 
-    return c == m_cmyka->c
-        && m == m_cmyka->m
-        && y == m_cmyka->y
-        && k == m_cmyka->k
-        && a == m_cmyka->a;
-}
-
-CanvasStyle::CanvasStyle(const CanvasStyle& other)
-{
-    memcpy(this, &other, sizeof(CanvasStyle));
-    if (m_type == Gradient)
-        m_gradient->ref();
-    else if (m_type == ImagePattern)
-        m_pattern->ref();
-    else if (m_type == CMYKA)
-        m_cmyka = new CMYKAValues(other.m_cmyka->color, other.m_cmyka->c, other.m_cmyka->m, other.m_cmyka->y, other.m_cmyka->k, other.m_cmyka->a);
-}
-
-CanvasStyle& CanvasStyle::operator=(const CanvasStyle& other)
-{
-    if (this != &other) {
-        this->~CanvasStyle();
-        new (this) CanvasStyle(other);
-    }
-    return *this;
+    auto& channels = WTF::get<CMYKAColor>(m_style);
+    return c == channels.c && m == channels.m && y == channels.y && k == channels.k && a == channels.a;
 }
 
-void CanvasStyle::applyStrokeColor(GraphicsContext* context) const
+void CanvasStyle::applyStrokeColor(GraphicsContext& context) const
 {
-    if (!context)
-        return;
-    switch (m_type) {
-    case RGBA:
-        context->setStrokeColor(m_color);
-        break;
-    case CMYKA: {
-        // FIXME: Do this through platform-independent GraphicsContext API.
-        // We'll need a fancier Color abstraction to support CMYKA correctly
+    WTF::switchOn(m_style,
+        [&context] (const Color& color) {
+            context.setStrokeColor(color);
+        },
+        [&context] (const CMYKAColor& color) {
+            // FIXME: Do this through platform-independent GraphicsContext API.
+            // We'll need a fancier Color abstraction to support CMYKA correctly
 #if USE(CG)
-        CGContextSetCMYKStrokeColor(context->platformContext(), m_cmyka->c, m_cmyka->m, m_cmyka->y, m_cmyka->k, m_cmyka->a);
+            CGContextSetCMYKStrokeColor(context.platformContext(), color.c, color.m, color.y, color.k, color.a);
 #else
-        context->setStrokeColor(m_cmyka->color);
+            context.setStrokeColor(color.color);
 #endif
-        break;
-    }
-    case Gradient:
-        context->setStrokeGradient(canvasGradient()->gradient());
-        break;
-    case ImagePattern:
-        context->setStrokePattern(canvasPattern()->pattern());
-        break;
-    case CurrentColor:
-    case CurrentColorWithOverrideAlpha:
-    case Invalid:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-}
-
-void CanvasStyle::applyFillColor(GraphicsContext* context) const
-{
-    if (!context)
-        return;
-    switch (m_type) {
-    case RGBA:
-        context->setFillColor(m_color);
-        break;
-    case CMYKA: {
-        // FIXME: Do this through platform-independent GraphicsContext API.
-        // We'll need a fancier Color abstraction to support CMYKA correctly
+        },
+        [&context] (const RefPtr<CanvasGradient>& gradient) {
+            context.setStrokeGradient(gradient->gradient());
+        },
+        [&context] (const RefPtr<CanvasPattern>& pattern) {
+            context.setStrokePattern(pattern->pattern());
+        },
+        [] (const CurrentColor&) {
+            ASSERT_NOT_REACHED();
+        },
+        [] (const Invalid&) {
+            ASSERT_NOT_REACHED();
+        }
+    );
+}
+
+void CanvasStyle::applyFillColor(GraphicsContext& context) const
+{
+    WTF::switchOn(m_style,
+        [&context] (const Color& color) {
+            context.setFillColor(color);
+        },
+        [&context] (const CMYKAColor& color) {
+            // FIXME: Do this through platform-independent GraphicsContext API.
+            // We'll need a fancier Color abstraction to support CMYKA correctly
 #if USE(CG)
-        CGContextSetCMYKFillColor(context->platformContext(), m_cmyka->c, m_cmyka->m, m_cmyka->y, m_cmyka->k, m_cmyka->a);
+            CGContextSetCMYKFillColor(context.platformContext(), color.c, color.m, color.y, color.k, color.a);
 #else
-        context->setFillColor(m_cmyka->color);
+            context.setFillColor(color.color);
 #endif
-        break;
-    }
-    case Gradient:
-        context->setFillGradient(canvasGradient()->gradient());
-        break;
-    case ImagePattern:
-        context->setFillPattern(canvasPattern()->pattern());
-        break;
-    case CurrentColor:
-    case CurrentColorWithOverrideAlpha:
-    case Invalid:
-        ASSERT_NOT_REACHED();
-        break;
-    }
+        },
+        [&context] (const RefPtr<CanvasGradient>& gradient) {
+            context.setFillGradient(gradient->gradient());
+        },
+        [&context] (const RefPtr<CanvasPattern>& pattern) {
+            context.setFillPattern(pattern->pattern());
+        },
+        [] (const CurrentColor&) {
+            ASSERT_NOT_REACHED();
+        },
+        [] (const Invalid&) {
+            ASSERT_NOT_REACHED();
+        }
+    );
 }
 
 }
index b6bf47c..d78030a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  *
  * Redistribution and use in source and binary forms, with or without
 
 #pragma once
 
+#include "CanvasGradient.h"
+#include "CanvasPattern.h"
 #include "Color.h"
-#include <wtf/Assertions.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/Variant.h>
 
 namespace WebCore {
 
-    class CanvasGradient;
-    class CanvasPattern;
-    class Document;
-    class GraphicsContext;
-    class HTMLCanvasElement;
-
-    class CanvasStyle {
-    public:
-        CanvasStyle();
-        explicit CanvasStyle(Color);
-        CanvasStyle(float grayLevel, float alpha);
-        CanvasStyle(float r, float g, float b, float alpha);
-        CanvasStyle(float c, float m, float y, float k, float alpha);
-        explicit CanvasStyle(PassRefPtr<CanvasGradient>);
-        explicit CanvasStyle(PassRefPtr<CanvasPattern>);
-        ~CanvasStyle();
-
-        static CanvasStyle createFromString(const String& color, Document* = 0);
-        static CanvasStyle createFromStringWithOverrideAlpha(const String& color, float alpha);
-
-        bool isValid() const { return m_type != Invalid; }
-        bool isCurrentColor() const { return m_type == CurrentColor || m_type == CurrentColorWithOverrideAlpha; }
-        bool hasOverrideAlpha() const { return m_type == CurrentColorWithOverrideAlpha; }
-        float overrideAlpha() const { ASSERT(m_type == CurrentColorWithOverrideAlpha); return m_overrideAlpha; }
-
-        String color() const;
-        CanvasGradient* canvasGradient() const;
-        CanvasPattern* canvasPattern() const;
-
-        void applyFillColor(GraphicsContext*) const;
-        void applyStrokeColor(GraphicsContext*) const;
-
-        bool isEquivalentColor(const CanvasStyle&) const;
-        bool isEquivalentRGBA(float r, float g, float b, float a) const;
-        bool isEquivalentCMYKA(float c, float m, float y, float k, float a) const;
-
-        CanvasStyle(const CanvasStyle&);
-        CanvasStyle& operator=(const CanvasStyle&);
-        CanvasStyle(CanvasStyle&&);
-        CanvasStyle& operator=(CanvasStyle&&);
-
-    private:
-        enum Type { RGBA, CMYKA, Gradient, ImagePattern, CurrentColor, CurrentColorWithOverrideAlpha, Invalid };
-        struct CMYKAValues {
-            WTF_MAKE_FAST_ALLOCATED;
-            WTF_MAKE_NONCOPYABLE(CMYKAValues);
-        public:
-            CMYKAValues()
-                : color(), c(0), m(0), y(0), k(0), a(0)
-            { }
-
-            CMYKAValues(Color color, float cyan, float magenta, float yellow, float black, float alpha)
-                : color(color), c(cyan), m(magenta), y(yellow), k(black), a(alpha)
-            { }
-            Color color;
-            float c;
-            float m;
-            float y;
-            float k;
-            float a;
-        };
-
-        enum ConstructCurrentColorTag { ConstructCurrentColor };
-        CanvasStyle(ConstructCurrentColorTag) : m_type(CurrentColor) { }
-        CanvasStyle(Type type, float overrideAlpha)
-            : m_overrideAlpha(overrideAlpha)
-            , m_type(type)
+class Document;
+class GraphicsContext;
+class HTMLCanvasElement;
+
+class CanvasStyle {
+public:
+    CanvasStyle();
+    CanvasStyle(Color);
+    CanvasStyle(float grayLevel, float alpha);
+    CanvasStyle(float r, float g, float b, float alpha);
+    CanvasStyle(float c, float m, float y, float k, float alpha);
+    CanvasStyle(CanvasGradient&);
+    CanvasStyle(CanvasPattern&);
+
+    static CanvasStyle createFromString(const String& color, Document* = nullptr);
+    static CanvasStyle createFromStringWithOverrideAlpha(const String& color, float alpha);
+
+    bool isValid() const { return !WTF::holds_alternative<Invalid>(m_style); }
+    bool isCurrentColor() const { return WTF::holds_alternative<CurrentColor>(m_style); }
+    bool hasOverrideAlpha() const { return isCurrentColor() && WTF::get<CurrentColor>(m_style).overrideAlpha; }
+    float overrideAlpha() const { return WTF::get<CurrentColor>(m_style).overrideAlpha.value(); }
+
+    String color() const;
+    CanvasGradient* canvasGradient() const;
+    CanvasPattern* canvasPattern() const;
+
+    void applyFillColor(GraphicsContext&) const;
+    void applyStrokeColor(GraphicsContext&) const;
+
+    bool isEquivalentColor(const CanvasStyle&) const;
+    bool isEquivalentRGBA(float red, float green, float blue, float alpha) const;
+    bool isEquivalentCMYKA(float cyan, float magenta, float yellow, float black, float alpha) const;
+
+private:
+    struct Invalid { };
+
+    struct CMYKAColor {
+        CMYKAColor() = default;
+
+        CMYKAColor(Color color, float cyan, float magenta, float yellow, float black, float alpha)
+            : color(color), c(cyan), m(magenta), y(yellow), k(black), a(alpha)
         {
         }
 
-        union {
-            Color m_color;
-            float m_overrideAlpha;
-            CanvasGradient* m_gradient;
-            CanvasPattern* m_pattern;
-            CMYKAValues* m_cmyka;
-        };
-        Type m_type;
+        Color color;
+        float c { 0 };
+        float m { 0 };
+        float y { 0 };
+        float k { 0 };
+        float a { 0 };
     };
 
-    Color currentColor(HTMLCanvasElement*);
-    Color parseColorOrCurrentColor(const String& colorString, HTMLCanvasElement*);
-
-    inline CanvasStyle::CanvasStyle()
-        : m_type(Invalid)
-    {
-    }
-
-    inline CanvasGradient* CanvasStyle::canvasGradient() const
-    {
-        if (m_type == Gradient)
-            return m_gradient;
-        return 0;
-    }
-
-    inline CanvasPattern* CanvasStyle::canvasPattern() const
-    {
-        if (m_type == ImagePattern)
-            return m_pattern;
-        return 0;
-    }
-
-    inline String CanvasStyle::color() const
-    {
-        ASSERT(m_type == RGBA || m_type == CMYKA);
-        if (m_type == RGBA)
-            return m_color.serialized();
-        return m_cmyka->color.serialized();
-    }
-
-    inline CanvasStyle::CanvasStyle(CanvasStyle&& other)
-    {
-        memcpy(this, &other, sizeof(CanvasStyle));
-        other.m_type = Invalid;
-    }
-
-    inline CanvasStyle& CanvasStyle::operator=(CanvasStyle&& other)
-    {
-        if (this != &other) {
-            memcpy(this, &other, sizeof(CanvasStyle));
-            other.m_type = Invalid;
-        }
-        return *this;
-    }
+    struct CurrentColor {
+        std::optional<float> overrideAlpha;
+    };
+
+    CanvasStyle(CurrentColor);
+
+    Variant<Invalid, Color, CMYKAColor, RefPtr<CanvasGradient>, RefPtr<CanvasPattern>, CurrentColor> m_style;
+};
+
+Color currentColor(HTMLCanvasElement*);
+Color parseColorOrCurrentColor(const String& colorString, HTMLCanvasElement*);
+
+inline CanvasStyle::CanvasStyle()
+    : m_style(Invalid { })
+{
+}
+
+inline CanvasGradient* CanvasStyle::canvasGradient() const
+{
+    if (!WTF::holds_alternative<RefPtr<CanvasGradient>>(m_style))
+        return nullptr;
+    return WTF::get<RefPtr<CanvasGradient>>(m_style).get();
+}
+
+inline CanvasPattern* CanvasStyle::canvasPattern() const
+{
+    if (!WTF::holds_alternative<RefPtr<CanvasPattern>>(m_style))
+        return nullptr;
+    return WTF::get<RefPtr<CanvasPattern>>(m_style).get();
+}
+
+inline String CanvasStyle::color() const
+{
+    auto& color = WTF::holds_alternative<Color>(m_style) ? WTF::get<Color>(m_style) : WTF::get<CMYKAColor>(m_style).color;
+    return color.serialized();
+}
 
 } // namespace WebCore
index c8b10f7..111bc3b 100644 (file)
  */
 
 #include "config.h"
+#include "OESVertexArrayObject.h"
 
 #if ENABLE(WEBGL)
 
-#include "OESVertexArrayObject.h"
-
 #include "Extensions3D.h"
 #include "WebGLRenderingContext.h"
 
@@ -49,8 +48,8 @@ RefPtr<WebGLVertexArrayObjectOES> OESVertexArrayObject::createVertexArrayOES()
     if (m_context.isContextLost())
         return nullptr;
 
-    auto object = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VAOTypeUser);
-    m_context.addContextObject(object.ptr());
+    auto object = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::Type::User);
+    m_context.addContextObject(object.get());
     return WTFMove(object);
 }
 
@@ -58,9 +57,9 @@ void OESVertexArrayObject::deleteVertexArrayOES(WebGLVertexArrayObjectOES* array
 {
     if (!arrayObject || m_context.isContextLost())
         return;
-    
-    if (!arrayObject->isDefaultObject() && arrayObject == static_cast<WebGLRenderingContext*>(&m_context)->m_boundVertexArrayObject)
-        static_cast<WebGLRenderingContext*>(&m_context)->setBoundVertexArrayObject(0);
+
+    if (!arrayObject->isDefaultObject() && arrayObject == static_cast<WebGLRenderingContext&>(m_context).m_boundVertexArrayObject)
+        static_cast<WebGLRenderingContext&>(m_context).setBoundVertexArrayObject(nullptr);
 
     arrayObject->deleteObject(m_context.graphicsContext3D());
 }
@@ -89,7 +88,7 @@ void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayOb
         context.setBoundVertexArrayObject(arrayObject);
     } else {
         extensions.bindVertexArrayOES(0);
-        context.setBoundVertexArrayObject(0);
+        context.setBoundVertexArrayObject(nullptr);
     }
 }
 
index 480a0ca..79c13c2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
-
-#if ENABLE(WEBGL) && ENABLE(WEBGL2)
 #include "WebGL2RenderingContext.h"
 
+#if ENABLE(WEBGL2)
+
 #include "CachedImage.h"
 #include "EXTTextureFilterAnisotropic.h"
 #include "Extensions3D.h"
@@ -63,7 +63,7 @@ WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas,
 {
 }
 
-WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
+WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
     : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes)
 {
     initializeShaderExtensions();
@@ -72,8 +72,8 @@ WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas,
 
 void WebGL2RenderingContext::initializeVertexArrayObjects()
 {
-    m_defaultVertexArrayObject = WebGLVertexArrayObject::create(*this, WebGLVertexArrayObject::VAOTypeDefault);
-    addContextObject(m_defaultVertexArrayObject.get());
+    m_defaultVertexArrayObject = WebGLVertexArrayObject::create(*this, WebGLVertexArrayObject::Type::Default);
+    addContextObject(*m_defaultVertexArrayObject);
     m_boundVertexArrayObject = m_defaultVertexArrayObject;
     if (!isGLES2Compliant())
         initVertexAttrib0();
@@ -203,7 +203,7 @@ void WebGL2RenderingContext::copyBufferSubData(GC3Denum readTarget, GC3Denum wri
     }
 
     m_context->moveErrorsToSyntheticErrorList();
-#if PLATFORM(MAC) || PLATFORM(IOS)
+#if PLATFORM(COCOA)
     m_context->copyBufferSubData(readTarget, writeTarget, checkedReadOffset.unsafeGet(), checkedWriteOffset.unsafeGet(), checkedSize.unsafeGet());
 #endif
     if (m_context->moveErrorsToSyntheticErrorList()) {
@@ -272,7 +272,7 @@ void WebGL2RenderingContext::getBufferSubData(GC3Denum target, long long srcByte
     }
 
     m_context->moveErrorsToSyntheticErrorList();
-#if PLATFORM(MAC) || PLATFORM(IOS)
+#if PLATFORM(COCOA)
     // FIXME: Coalesce multiple getBufferSubData() calls to use a single map() call
     void* ptr = m_context->mapBufferRange(target, checkedSrcByteOffset.unsafeGet(), static_cast<GC3Dsizeiptr>(checkedCopyLengthPtr.unsafeGet() * checkedElementSize.unsafeGet()), GraphicsContext3D::MAP_READ_BIT);
     memcpy(static_cast<char*>(dstData->baseAddress()) + dstData->byteOffset() + dstOffset * elementSize, ptr, copyLength * elementSize);
@@ -290,16 +290,16 @@ void WebGL2RenderingContext::framebufferTextureLayer(GC3Denum, GC3Denum, GC3Duin
 {
 }
 
-WebGLGetInfo WebGL2RenderingContext::getInternalformatParameter(GC3Denum, GC3Denum, GC3Denum)
+WebGLAny WebGL2RenderingContext::getInternalformatParameter(GC3Denum, GC3Denum, GC3Denum)
 {
-    return WebGLGetInfo();
+    return nullptr;
 }
 
-void WebGL2RenderingContext::invalidateFramebuffer(GC3Denum, Vector<GC3Denum>)
+void WebGL2RenderingContext::invalidateFramebuffer(GC3Denum, const Vector<GC3Denum>&)
 {
 }
 
-void WebGL2RenderingContext::invalidateSubFramebuffer(GC3Denum, Vector<GC3Denum>, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+void WebGL2RenderingContext::invalidateSubFramebuffer(GC3Denum, const Vector<GC3Denum>&, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
 {
 }
 
@@ -407,7 +407,7 @@ void WebGL2RenderingContext::texStorage2D(GC3Denum target, GC3Dsizei levels, GC3
     if (isContextLostOrPending())
         return;
 
-    WebGLTexture* texture = validateTextureBinding("texStorage2D", target, false);
+    auto* texture = validateTextureBinding("texStorage2D", target, false);
     if (!texture)
         return;
 
@@ -502,7 +502,7 @@ void WebGL2RenderingContext::compressedTexSubImage3D(GC3Denum, GC3Dint, GC3Dint,
 {
 }
 
-GC3Dint WebGL2RenderingContext::getFragDataLocation(WebGLProgram*, String)
+GC3Dint WebGL2RenderingContext::getFragDataLocation(WebGLProgram*, const String&)
 {
     return 0;
 }
@@ -633,7 +633,7 @@ void WebGL2RenderingContext::drawRangeElements(GC3Denum, GC3Duint, GC3Duint, GC3
 {
 }
 
-void WebGL2RenderingContext::drawBuffers(Vector<GC3Denum> buffers)
+void WebGL2RenderingContext::drawBuffers(const Vector<GC3Denum>& buffers)
 {
     if (isContextLost())
         return;
@@ -782,9 +782,9 @@ RefPtr<WebGLQuery> WebGL2RenderingContext::getQuery(GC3Denum, GC3Denum)
     return nullptr;
 }
 
-WebGLGetInfo WebGL2RenderingContext::getQueryParameter(WebGLQuery*, GC3Denum)
+WebGLAny WebGL2RenderingContext::getQueryParameter(WebGLQuery*, GC3Denum)
 {
-    return WebGLGetInfo();
+    return nullptr;
 }
 
 RefPtr<WebGLSampler> WebGL2RenderingContext::createSampler()
@@ -813,9 +813,9 @@ void WebGL2RenderingContext::samplerParameterf(WebGLSampler*, GC3Denum, GC3Dfloa
 {
 }
 
-WebGLGetInfo WebGL2RenderingContext::getSamplerParameter(WebGLSampler*, GC3Denum)
+WebGLAny WebGL2RenderingContext::getSamplerParameter(WebGLSampler*, GC3Denum)
 {
-    return WebGLGetInfo();
+    return nullptr;
 }
 
 RefPtr<WebGLSync> WebGL2RenderingContext::fenceSync(GC3Denum, GC3Dbitfield)
@@ -841,9 +841,9 @@ void WebGL2RenderingContext::waitSync(WebGLSync*, GC3Dbitfield, GC3Duint64)
 {
 }
 
-WebGLGetInfo WebGL2RenderingContext::getSyncParameter(WebGLSync*, GC3Denum)
+WebGLAny WebGL2RenderingContext::getSyncParameter(WebGLSync*, GC3Denum)
 {
-    return WebGLGetInfo();
+    return nullptr;
 }
 
 RefPtr<WebGLTransformFeedback> WebGL2RenderingContext::createTransformFeedback()
@@ -872,7 +872,7 @@ void WebGL2RenderingContext::endTransformFeedback()
 {
 }
 
-void WebGL2RenderingContext::transformFeedbackVaryings(WebGLProgram*, Vector<String>, GC3Denum)
+void WebGL2RenderingContext::transformFeedbackVaryings(WebGLProgram*, const Vector<String>&, GC3Denum)
 {
 }
 
@@ -897,7 +897,7 @@ void WebGL2RenderingContext::bindBufferRange(GC3Denum, GC3Duint, WebGLBuffer*, G
 {
 }
 
-WebGLGetInfo WebGL2RenderingContext::getIndexedParameter(GC3Denum target, GC3Duint)
+WebGLAny WebGL2RenderingContext::getIndexedParameter(GC3Denum target, GC3Duint)
 {
     switch (target) {
     case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER_BINDING:
@@ -907,16 +907,14 @@ WebGLGetInfo WebGL2RenderingContext::getIndexedParameter(GC3Denum target, GC3Dui
     case GraphicsContext3D::UNIFORM_BUFFER_SIZE:
     case GraphicsContext3D::UNIFORM_BUFFER_START:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getIndexedParameter", "parameter name not yet supported");
-        return WebGLGetInfo();
+        return nullptr;
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getIndexedParameter", "invalid parameter name");
-        return WebGLGetInfo();
-            
+        return nullptr;
     }
-    return WebGLGetInfo();
 }
 
-Uint32Array* WebGL2RenderingContext::getUniformIndices(WebGLProgram*, Vector<String>)
+Uint32Array* WebGL2RenderingContext::getUniformIndices(WebGLProgram*, const Vector<String>&)
 {
     return nullptr;
 }
@@ -926,19 +924,19 @@ Int32Array* WebGL2RenderingContext::getActiveUniforms(WebGLProgram*, RefPtr<Uint
     return nullptr;
 }
 
-GC3Duint WebGL2RenderingContext::getUniformBlockIndex(WebGLProgram*, String)
+GC3Duint WebGL2RenderingContext::getUniformBlockIndex(WebGLProgram*, const String&)
 {
     return 0;
 }
 
-WebGLGetInfo WebGL2RenderingContext::getActiveUniformBlockParameter(WebGLProgram*, GC3Duint, GC3Denum)
+WebGLAny WebGL2RenderingContext::getActiveUniformBlockParameter(WebGLProgram*, GC3Duint, GC3Denum)
 {
-    return WebGLGetInfo();
+    return nullptr;
 }
 
-WebGLGetInfo WebGL2RenderingContext::getActiveUniformBlockName(WebGLProgram*, GC3Duint)
+WebGLAny WebGL2RenderingContext::getActiveUniformBlockName(WebGLProgram*, GC3Duint)
 {
-    return WebGLGetInfo();
+    return nullptr;
 }
 
 void WebGL2RenderingContext::uniformBlockBinding(WebGLProgram*, GC3Duint, GC3Duint)
@@ -950,8 +948,8 @@ RefPtr<WebGLVertexArrayObject> WebGL2RenderingContext::createVertexArray()
     if (isContextLost())
         return nullptr;
     
-    auto object = WebGLVertexArrayObject::create(*this, WebGLVertexArrayObject::VAOTypeUser);
-    addContextObject(object.ptr());
+    auto object = WebGLVertexArrayObject::create(*this, WebGLVertexArrayObject::Type::User);
+    addContextObject(object.get());
     return WTFMove(object);
 }
 
@@ -964,7 +962,7 @@ void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* arrayObje
         return;
     
     if (!arrayObject->isDefaultObject() && arrayObject == m_boundVertexArrayObject)
-        setBoundVertexArrayObject(0);
+        setBoundVertexArrayObject(nullptr);
     
     arrayObject->deleteObject(graphicsContext3D());
 }
@@ -972,10 +970,10 @@ void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* arrayObje
 GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* arrayObject)
 {
     if (!arrayObject || isContextLost())
-        return 0;
+        return false;
     
     if (!arrayObject->hasEverBeenBound() || !arrayObject->validate(0, *this))
-        return 0;
+        return false;
     
     return m_context->isVertexArray(arrayObject->object());
 }
@@ -996,7 +994,7 @@ void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* arrayObject
         setBoundVertexArrayObject(arrayObject);
     } else {
         m_context->bindVertexArray(m_defaultVertexArrayObject->object());
-        setBoundVertexArrayObject(m_defaultVertexArrayObject);
+        setBoundVertexArrayObject(m_defaultVertexArrayObject.get());
     }
 }
 
@@ -1005,43 +1003,38 @@ WebGLExtension* WebGL2RenderingContext::getExtension(const String& name)
     if (isContextLostOrPending())
         return nullptr;
 
-    if ((equalIgnoringASCIICase(name, "EXT_texture_filter_anisotropic") || equalIgnoringASCIICase(name, "WEBKIT_EXT_texture_filter_anisotropic"))
-        && m_context->getExtensions().supports("GL_EXT_texture_filter_anisotropic")) {
+    if (equalIgnoringASCIICase(name, "EXT_texture_filter_anisotropic") || equalIgnoringASCIICase(name, "WEBKIT_EXT_texture_filter_anisotropic")) {
         if (!m_extTextureFilterAnisotropic) {
-            m_context->getExtensions().ensureEnabled("GL_EXT_texture_filter_anisotropic");
-            m_extTextureFilterAnisotropic = std::make_unique<EXTTextureFilterAnisotropic>(*this);
+            m_extTextureFilterAnisotropic = enableSupportedExtension("GL_EXT_texture_filter_anisotropic")
+                ? std::make_unique<EXTTextureFilterAnisotropic>(*this) : nullptr;
         }
         return m_extTextureFilterAnisotropic.get();
     }
-    if (equalIgnoringASCIICase(name, "OES_texture_float")
-        && m_context->getExtensions().supports("GL_OES_texture_float")) {
+    if (equalIgnoringASCIICase(name, "OES_texture_float")) {
         if (!m_oesTextureFloat) {
-            m_context->getExtensions().ensureEnabled("GL_OES_texture_float");
-            m_oesTextureFloat = std::make_unique<OESTextureFloat>(*this);
+            m_oesTextureFloat = enableSupportedExtension("GL_OES_texture_float")
+                ? std::make_unique<OESTextureFloat>(*this) : nullptr;
         }
         return m_oesTextureFloat.get();
     }
-    if (equalIgnoringASCIICase(name, "OES_texture_float_linear")
-        && m_context->getExtensions().supports("GL_OES_texture_float_linear")) {
+    if (equalIgnoringASCIICase(name, "OES_texture_float_linear")) {
         if (!m_oesTextureFloatLinear) {
-            m_context->getExtensions().ensureEnabled("GL_OES_texture_float_linear");
-            m_oesTextureFloatLinear = std::make_unique<OESTextureFloatLinear>(*this);
+            m_oesTextureFloatLinear = enableSupportedExtension("GL_OES_texture_float_linear")
+                ? std::make_unique<OESTextureFloatLinear>(*this) : nullptr;
         }
         return m_oesTextureFloatLinear.get();
     }
-    if (equalIgnoringASCIICase(name, "OES_texture_half_float")
-        && m_context->getExtensions().supports("GL_OES_texture_half_float")) {
+    if (equalIgnoringASCIICase(name, "OES_texture_half_float")) {
         if (!m_oesTextureHalfFloat) {
-            m_context->getExtensions().ensureEnabled("GL_OES_texture_half_float");
-            m_oesTextureHalfFloat = std::make_unique<OESTextureHalfFloat>(*this);
+            m_oesTextureHalfFloat = enableSupportedExtension("GL_OES_texture_half_float")
+                ? std::make_unique<OESTextureHalfFloat>(*this) : nullptr;
         }
         return m_oesTextureHalfFloat.get();
     }
-    if (equalIgnoringASCIICase(name, "OES_texture_half_float_linear")
-        && m_context->getExtensions().supports("GL_OES_texture_half_float_linear")) {
+    if (equalIgnoringASCIICase(name, "OES_texture_half_float_linear")) {
         if (!m_oesTextureHalfFloatLinear) {
-            m_context->getExtensions().ensureEnabled("GL_OES_texture_half_float_linear");
-            m_oesTextureHalfFloatLinear = std::make_unique<OESTextureHalfFloatLinear>(*this);
+            m_oesTextureHalfFloatLinear = enableSupportedExtension("GL_OES_texture_half_float_linear")
+                ? std::make_unique<OESTextureHalfFloatLinear>(*this) : nullptr;
         }
         return m_oesTextureHalfFloatLinear.get();
     }
@@ -1050,28 +1043,32 @@ WebGLExtension* WebGL2RenderingContext::getExtension(const String& name)
             m_webglLoseContext = std::make_unique<WebGLLoseContext>(*this);
         return m_webglLoseContext.get();
     }
-    if ((equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_atc"))
-        && WebGLCompressedTextureATC::supported(*this)) {
-        if (!m_webglCompressedTextureATC)
-            m_webglCompressedTextureATC = std::make_unique<WebGLCompressedTextureATC>(*this);
+    if (equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_atc")) {
+        if (!m_webglCompressedTextureATC) {
+            if (WebGLCompressedTextureATC::supported(*this))
+                m_webglCompressedTextureATC = std::make_unique<WebGLCompressedTextureATC>(*this);
+        }
         return m_webglCompressedTextureATC.get();
     }
-    if ((equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_pvrtc"))
-        && WebGLCompressedTexturePVRTC::supported(*this)) {
-        if (!m_webglCompressedTexturePVRTC)
-            m_webglCompressedTexturePVRTC = std::make_unique<WebGLCompressedTexturePVRTC>(*this);
+    if (equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_pvrtc")) {
+        if (!m_webglCompressedTexturePVRTC) {
+            m_webglCompressedTexturePVRTC = WebGLCompressedTexturePVRTC::supported(*this)
+                ? std::make_unique<WebGLCompressedTexturePVRTC>(*this) : nullptr;
+        }