Changeset 208206 in webkit
- Timestamp:
- Oct 31, 2016, 6:36:00 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r208203 r208206 1 2016-10-31 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Migrate CanvasRenderingContext's internal canvas pointer to a reference 4 https://bugs.webkit.org/show_bug.cgi?id=164259 5 6 Reviewed by Dean Jackson. 7 8 It is never nullptr. 9 10 No new tests because there is no behavior change. 11 12 * html/HTMLCanvasElement.cpp: 13 (WebCore::HTMLCanvasElement::getContext): 14 * html/canvas/CanvasRenderingContext.cpp: 15 (WebCore::CanvasRenderingContext::CanvasRenderingContext): 16 (WebCore::CanvasRenderingContext::wouldTaintOrigin): 17 (WebCore::CanvasRenderingContext::checkOrigin): 18 * html/canvas/CanvasRenderingContext.h: 19 (WebCore::CanvasRenderingContext::ref): 20 (WebCore::CanvasRenderingContext::deref): 21 (WebCore::CanvasRenderingContext::canvas): 22 (WebCore::CanvasRenderingContext::checkOrigin): 23 * html/canvas/CanvasRenderingContext2D.cpp: 24 (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D): 25 (WebCore::CanvasRenderingContext2D::unwindStateStack): 26 (WebCore::CanvasRenderingContext2D::isAccelerated): 27 (WebCore::CanvasRenderingContext2D::realizeSaves): 28 (WebCore::CanvasRenderingContext2D::setStrokeStyle): 29 (WebCore::CanvasRenderingContext2D::setFillStyle): 30 (WebCore::CanvasRenderingContext2D::setShadowColor): 31 (WebCore::CanvasRenderingContext2D::resetTransform): 32 (WebCore::CanvasRenderingContext2D::setStrokeColor): 33 (WebCore::CanvasRenderingContext2D::setFillColor): 34 (WebCore::CanvasRenderingContext2D::setShadow): 35 (WebCore::CanvasRenderingContext2D::clearCanvas): 36 (WebCore::CanvasRenderingContext2D::transformAreaToDevice): 37 (WebCore::CanvasRenderingContext2D::rectContainsCanvas): 38 (WebCore::CanvasRenderingContext2D::calculateCompositingBufferRect): 39 (WebCore::CanvasRenderingContext2D::compositeBuffer): 40 (WebCore::CanvasRenderingContext2D::createPattern): 41 (WebCore::CanvasRenderingContext2D::didDrawEntireCanvas): 42 (WebCore::CanvasRenderingContext2D::didDraw): 43 (WebCore::CanvasRenderingContext2D::paintRenderingResultsToCanvas): 44 (WebCore::CanvasRenderingContext2D::drawingContext): 45 (WebCore::CanvasRenderingContext2D::getImageData): 46 (WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal): 47 (WebCore::CanvasRenderingContext2D::putImageData): 48 (WebCore::CanvasRenderingContext2D::setFont): 49 (WebCore::CanvasRenderingContext2D::toTextDirection): 50 (WebCore::CanvasRenderingContext2D::direction): 51 (WebCore::CanvasRenderingContext2D::platformLayer): 52 * html/canvas/WebGL2RenderingContext.cpp: 53 (WebCore::WebGL2RenderingContext::WebGL2RenderingContext): 54 * html/canvas/WebGL2RenderingContext.h: 55 * html/canvas/WebGLRenderingContext.cpp: 56 (WebCore::WebGLRenderingContext::WebGLRenderingContext): 57 * html/canvas/WebGLRenderingContext.h: 58 * html/canvas/WebGLRenderingContextBase.cpp: 59 (WebCore::WebGLRenderingContextBase::create): 60 (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase): 61 (WebCore::WebGLRenderingContextBase::setupFlags): 62 (WebCore::WebGLRenderingContextBase::markContextChanged): 63 (WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas): 64 (WebCore::WebGLRenderingContextBase::reshape): 65 (WebCore::WebGLRenderingContextBase::isContextLostOrPending): 66 (WebCore::WebGLRenderingContextBase::readPixels): 67 (WebCore::WebGLRenderingContextBase::loseContextImpl): 68 (WebCore::WebGLRenderingContextBase::printWarningToConsole): 69 (WebCore::WebGLRenderingContextBase::dispatchContextLostEvent): 70 (WebCore::WebGLRenderingContextBase::maybeRestoreContext): 71 (WebCore::WebGLRenderingContextBase::clampedCanvasSize): 72 * html/canvas/WebGLRenderingContextBase.h: 73 1 74 2016-10-31 Brady Eidson <beidson@apple.com> 2 75 -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r208096 r208206 248 248 return nullptr; 249 249 if (!m_context) { 250 m_context = WebGLRenderingContextBase::create( this, static_cast<WebGLContextAttributes*>(attrs), type);250 m_context = WebGLRenderingContextBase::create(*this, static_cast<WebGLContextAttributes*>(attrs), type); 251 251 if (m_context) { 252 252 // Need to make sure a RenderLayer and compositing layer get created for the Canvas -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp
r207720 r208206 37 37 namespace WebCore { 38 38 39 CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement *canvas)39 CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement& canvas) 40 40 : m_canvas(canvas) 41 41 { … … 44 44 bool CanvasRenderingContext::wouldTaintOrigin(const CanvasPattern* pattern) 45 45 { 46 if (canvas() ->originClean() && pattern && !pattern->originClean())46 if (canvas().originClean() && pattern && !pattern->originClean()) 47 47 return true; 48 48 return false; … … 51 51 bool CanvasRenderingContext::wouldTaintOrigin(const HTMLCanvasElement* sourceCanvas) 52 52 { 53 if (canvas() ->originClean() && sourceCanvas && !sourceCanvas->originClean())53 if (canvas().originClean() && sourceCanvas && !sourceCanvas->originClean()) 54 54 return true; 55 55 return false; … … 58 58 bool CanvasRenderingContext::wouldTaintOrigin(const HTMLImageElement* element) 59 59 { 60 if (!element || !canvas() ->originClean())60 if (!element || !canvas().originClean()) 61 61 return false; 62 62 … … 75 75 return true; 76 76 77 ASSERT(canvas() ->securityOrigin());77 ASSERT(canvas().securityOrigin()); 78 78 ASSERT(cachedImage->origin()); 79 ASSERT(canvas() ->securityOrigin()->toString() == cachedImage->origin()->toString());79 ASSERT(canvas().securityOrigin()->toString() == cachedImage->origin()->toString()); 80 80 return false; 81 81 } … … 88 88 // make currentSrc be the final URL because then the 89 89 // HTMLMediaElement.currentSrc DOM API would leak redirect destinations! 90 if (!video || !canvas() ->originClean())90 if (!video || !canvas().originClean()) 91 91 return false; 92 92 … … 106 106 bool CanvasRenderingContext::wouldTaintOrigin(const URL& url) 107 107 { 108 if (!canvas() ->originClean())108 if (!canvas().originClean()) 109 109 return false; 110 110 … … 112 112 return false; 113 113 114 return !canvas() ->securityOrigin()->canRequest(url);114 return !canvas().securityOrigin()->canRequest(url); 115 115 } 116 116 … … 118 118 { 119 119 if (wouldTaintOrigin(url)) 120 canvas() ->setOriginTainted();120 canvas().setOriginTainted(); 121 121 } 122 122 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h
r208179 r208206 47 47 virtual ~CanvasRenderingContext() { } 48 48 49 void ref() { m_canvas ->ref(); }50 void deref() { m_canvas ->deref(); }51 HTMLCanvasElement *canvas() const { return m_canvas; }49 void ref() { m_canvas.ref(); } 50 void deref() { m_canvas.deref(); } 51 HTMLCanvasElement& canvas() const { return m_canvas; } 52 52 53 53 virtual bool is2d() const { return false; } … … 61 61 62 62 protected: 63 CanvasRenderingContext(HTMLCanvasElement *);63 CanvasRenderingContext(HTMLCanvasElement&); 64 64 bool wouldTaintOrigin(const CanvasPattern*); 65 65 bool wouldTaintOrigin(const HTMLCanvasElement*); … … 71 71 { 72 72 if (wouldTaintOrigin(arg)) 73 canvas() ->setOriginTainted();73 canvas().setOriginTainted(); 74 74 } 75 75 void checkOrigin(const URL&); 76 76 77 77 private: 78 HTMLCanvasElement *m_canvas;78 HTMLCanvasElement& m_canvas; 79 79 }; 80 80 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r208000 r208206 134 134 135 135 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) 136 : CanvasRenderingContext( &canvas)136 : CanvasRenderingContext(canvas) 137 137 , m_stateStack(1) 138 138 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) … … 152 152 // GraphicsContext dtor. 153 153 if (size_t stackSize = m_stateStack.size()) { 154 if (GraphicsContext* context = canvas() ->existingDrawingContext()) {154 if (GraphicsContext* context = canvas().existingDrawingContext()) { 155 155 while (--stackSize) 156 156 context->restore(); … … 172 172 { 173 173 #if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS) 174 if (!canvas() ->hasCreatedImageBuffer())174 if (!canvas().hasCreatedImageBuffer()) 175 175 return false; 176 176 GraphicsContext* context = drawingContext(); … … 359 359 if (m_unrealizedSaveCount) { 360 360 static NeverDestroyed<String> consoleMessage(ASCIILiteral("CanvasRenderingContext2D.save() has been called without a matching restore() too many times. Ignoring save().")); 361 canvas() ->document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage);361 canvas().document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage); 362 362 } 363 363 } … … 407 407 if (style.hasOverrideAlpha()) { 408 408 // FIXME: Should not use RGBA32 here. 409 style = CanvasStyle(colorWithOverrideAlpha(currentColor( canvas()).rgb(), style.overrideAlpha()));409 style = CanvasStyle(colorWithOverrideAlpha(currentColor(&canvas()).rgb(), style.overrideAlpha())); 410 410 } else 411 style = CanvasStyle(currentColor( canvas()));411 style = CanvasStyle(currentColor(&canvas())); 412 412 } else 413 413 checkOrigin(style.canvasPattern()); … … 434 434 if (style.hasOverrideAlpha()) { 435 435 // FIXME: Should not use RGBA32 here. 436 style = CanvasStyle(colorWithOverrideAlpha(currentColor( canvas()).rgb(), style.overrideAlpha()));436 style = CanvasStyle(colorWithOverrideAlpha(currentColor(&canvas()).rgb(), style.overrideAlpha())); 437 437 } else 438 style = CanvasStyle(currentColor( canvas()));438 style = CanvasStyle(currentColor(&canvas())); 439 439 } else 440 440 checkOrigin(style.canvasPattern()); … … 583 583 void CanvasRenderingContext2D::setShadowColor(const String& colorString) 584 584 { 585 Color color = parseColorOrCurrentColor(colorString, canvas());585 Color color = parseColorOrCurrentColor(colorString, &canvas()); 586 586 if (!color.isValid()) 587 587 return; … … 825 825 realizeSaves(); 826 826 827 c->setCTM(canvas() ->baseTransform());827 c->setCTM(canvas().baseTransform()); 828 828 modifiableState().transform = AffineTransform(); 829 829 … … 845 845 846 846 realizeSaves(); 847 setStrokeStyle(CanvasStyle::createFromString(color, &canvas() ->document()));847 setStrokeStyle(CanvasStyle::createFromString(color, &canvas().document())); 848 848 modifiableState().unparsedStrokeColor = color; 849 849 } … … 881 881 882 882 realizeSaves(); 883 setFillStyle(CanvasStyle::createFromString(color, &canvas() ->document()));883 setFillStyle(CanvasStyle::createFromString(color, &canvas().document())); 884 884 modifiableState().unparsedFillColor = color; 885 885 } … … 1253 1253 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& colorString, Optional<float> alpha) 1254 1254 { 1255 Color color = parseColorOrCurrentColor(colorString, canvas());1255 Color color = parseColorOrCurrentColor(colorString, &canvas()); 1256 1256 if (!colorString.isNull() && !color.isValid()) 1257 1257 return; … … 1604 1604 void CanvasRenderingContext2D::clearCanvas() 1605 1605 { 1606 FloatRect canvasRect(0, 0, canvas() ->width(), canvas()->height());1606 FloatRect canvasRect(0, 0, canvas().width(), canvas().height()); 1607 1607 GraphicsContext* c = drawingContext(); 1608 1608 if (!c) … … 1610 1610 1611 1611 c->save(); 1612 c->setCTM(canvas() ->baseTransform());1612 c->setCTM(canvas().baseTransform()); 1613 1613 c->clearRect(canvasRect); 1614 1614 c->restore(); … … 1619 1619 Path transformed(path); 1620 1620 transformed.transform(state().transform); 1621 transformed.transform(canvas() ->baseTransform());1621 transformed.transform(canvas().baseTransform()); 1622 1622 return transformed; 1623 1623 } … … 1633 1633 { 1634 1634 FloatQuad quad(rect); 1635 FloatQuad canvasQuad(FloatRect(0, 0, canvas() ->width(), canvas()->height()));1635 FloatQuad canvasQuad(FloatRect(0, 0, canvas().width(), canvas().height())); 1636 1636 return state().transform.mapQuad(quad).containsQuad(canvasQuad); 1637 1637 } … … 1639 1639 template<class T> IntRect CanvasRenderingContext2D::calculateCompositingBufferRect(const T& area, IntSize* croppedOffset) 1640 1640 { 1641 IntRect canvasRect(0, 0, canvas() ->width(), canvas()->height());1642 canvasRect = canvas() ->baseTransform().mapRect(canvasRect);1641 IntRect canvasRect(0, 0, canvas().width(), canvas().height()); 1642 canvasRect = canvas().baseTransform().mapRect(canvasRect); 1643 1643 Path path = transformAreaToDevice(area); 1644 1644 IntRect bufferRect = enclosingIntRect(path.fastBoundingRect()); … … 1657 1657 void CanvasRenderingContext2D::compositeBuffer(ImageBuffer& buffer, const IntRect& bufferRect, CompositeOperator op) 1658 1658 { 1659 IntRect canvasRect(0, 0, canvas() ->width(), canvas()->height());1660 canvasRect = canvas() ->baseTransform().mapRect(canvasRect);1659 IntRect canvasRect(0, 0, canvas().width(), canvas().height()); 1660 canvasRect = canvas().baseTransform().mapRect(canvasRect); 1661 1661 1662 1662 GraphicsContext* c = drawingContext(); … … 1765 1765 return Exception { INVALID_STATE_ERR }; 1766 1766 1767 bool originClean = cachedImage->isOriginClean(canvas() ->securityOrigin());1767 bool originClean = cachedImage->isOriginClean(canvas().securityOrigin()); 1768 1768 1769 1769 // FIXME: SVG images with animations can switch between clean and dirty (leaking cross-origin … … 1803 1803 1804 1804 checkOrigin(&videoElement); 1805 bool originClean = canvas() ->originClean();1805 bool originClean = canvas().originClean(); 1806 1806 1807 1807 #if USE(CG) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(GSTREAMER_GL) && USE(CAIRO)) … … 1820 1820 void CanvasRenderingContext2D::didDrawEntireCanvas() 1821 1821 { 1822 didDraw(FloatRect(FloatPoint::zero(), canvas() ->size()), CanvasDidDrawApplyClip);1822 didDraw(FloatRect(FloatPoint::zero(), canvas().size()), CanvasDidDrawApplyClip); 1823 1823 } 1824 1824 … … 1834 1834 // If we are drawing to hardware and we have a composited layer, just call contentChanged(). 1835 1835 if (isAccelerated()) { 1836 RenderBox* renderBox = canvas() ->renderBox();1836 RenderBox* renderBox = canvas().renderBox(); 1837 1837 if (renderBox && renderBox->hasAcceleratedCompositing()) { 1838 1838 renderBox->contentChanged(CanvasPixelsChanged); 1839 canvas() ->clearCopiedImage();1840 canvas() ->notifyObserversCanvasChanged(r);1839 canvas().clearCopiedImage(); 1840 canvas().notifyObserversCanvasChanged(r); 1841 1841 return; 1842 1842 } … … 1864 1864 } 1865 1865 1866 canvas() ->didDraw(dirtyRect);1866 canvas().didDraw(dirtyRect); 1867 1867 } 1868 1868 … … 1903 1903 return; 1904 1904 1905 FloatRect clip(FloatPoint::zero(), canvas() ->size());1906 DisplayList::Replayer replayer(*canvas() ->drawingContext(), m_recordingContext->displayList);1905 FloatRect clip(FloatPoint::zero(), canvas().size()); 1906 DisplayList::Replayer replayer(*canvas().drawingContext(), m_recordingContext->displayList); 1907 1907 1908 1908 if (UNLIKELY(m_tracksDisplayListReplay)) { … … 1920 1920 if (UNLIKELY(m_usesDisplayListDrawing)) { 1921 1921 if (!m_recordingContext) 1922 m_recordingContext = std::make_unique<DisplayListDrawingContext>(FloatRect(FloatPoint::zero(), canvas() ->size()));1922 m_recordingContext = std::make_unique<DisplayListDrawingContext>(FloatRect(FloatPoint::zero(), canvas().size())); 1923 1923 1924 1924 return &m_recordingContext->context; 1925 1925 } 1926 1926 1927 return canvas() ->drawingContext();1927 return canvas().drawingContext(); 1928 1928 } 1929 1929 … … 1976 1976 ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::getImageData(ImageBuffer::CoordinateSystem coordinateSystem, float sx, float sy, float sw, float sh) const 1977 1977 { 1978 if (!canvas() ->originClean()) {1978 if (!canvas().originClean()) { 1979 1979 static NeverDestroyed<String> consoleMessage(ASCIILiteral("Unable to get image data from canvas because the canvas has been tainted by cross-origin data.")); 1980 canvas() ->document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage);1980 canvas().document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage); 1981 1981 return Exception { SECURITY_ERR }; 1982 1982 } … … 2003 2003 2004 2004 IntRect imageDataRect = enclosingIntRect(logicalRect); 2005 ImageBuffer* buffer = canvas() ->buffer();2005 ImageBuffer* buffer = canvas().buffer(); 2006 2006 if (!buffer) 2007 2007 return createEmptyImageData(imageDataRect.size()); … … 2015 2015 consoleMessage.appendNumber(imageDataRect.height()); 2016 2016 2017 canvas() ->document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage.toString());2017 canvas().document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage.toString()); 2018 2018 return Exception { INVALID_STATE_ERR }; 2019 2019 } … … 2056 2056 GraphicsContext* context = drawingContext(); 2057 2057 2058 if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf( canvas()) || !context)2058 if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(&canvas()) || !context) 2059 2059 return; 2060 2060 … … 2064 2064 void CanvasRenderingContext2D::putImageData(ImageData& data, ImageBuffer::CoordinateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight) 2065 2065 { 2066 ImageBuffer* buffer = canvas() ->buffer();2066 ImageBuffer* buffer = canvas().buffer(); 2067 2067 if (!buffer) 2068 2068 return; … … 2153 2153 auto newStyle = RenderStyle::createPtr(); 2154 2154 2155 Document& document = canvas() ->document();2155 Document& document = canvas().document(); 2156 2156 document.updateStyleIfNeeded(); 2157 2157 2158 if (auto* computedStyle = canvas() ->computedStyle())2158 if (auto* computedStyle = canvas().computedStyle()) 2159 2159 newStyle->setFontDescription(computedStyle->fontDescription()); 2160 2160 else { … … 2170 2170 2171 2171 // Now map the font property longhands into the style. 2172 StyleResolver& styleResolver = canvas() ->styleResolver();2172 StyleResolver& styleResolver = canvas().styleResolver(); 2173 2173 styleResolver.applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), WTFMove(newStyle)); 2174 2174 styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get()); … … 2221 2221 inline TextDirection CanvasRenderingContext2D::toTextDirection(Direction direction, const RenderStyle** computedStyle) const 2222 2222 { 2223 auto* style = (computedStyle || direction == Direction::Inherit) ? canvas() ->computedStyle() : nullptr;2223 auto* style = (computedStyle || direction == Direction::Inherit) ? canvas().computedStyle() : nullptr; 2224 2224 if (computedStyle) 2225 2225 *computedStyle = style; … … 2239 2239 { 2240 2240 if (state().direction == Direction::Inherit) 2241 canvas() ->document().updateStyleIfNeeded();2241 canvas().document().updateStyleIfNeeded(); 2242 2242 return toTextDirection(state().direction) == RTL ? ASCIILiteral("rtl") : ASCIILiteral("ltr"); 2243 2243 } … … 2509 2509 auto CanvasRenderingContext2D::fontProxy() -> const FontProxy& 2510 2510 { 2511 canvas() ->document().updateStyleIfNeeded();2511 canvas().document().updateStyleIfNeeded(); 2512 2512 2513 2513 if (!state().font.realized()) … … 2519 2519 PlatformLayer* CanvasRenderingContext2D::platformLayer() const 2520 2520 { 2521 return canvas() ->buffer() ? canvas()->buffer()->platformLayer() : 0;2521 return canvas().buffer() ? canvas().buffer()->platformLayer() : 0; 2522 2522 } 2523 2523 #endif -
trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
r207724 r208206 60 60 namespace WebCore { 61 61 62 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement *passedCanvas, GraphicsContext3D::Attributes attributes)62 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas, GraphicsContext3D::Attributes attributes) 63 63 : WebGLRenderingContextBase(passedCanvas, attributes) 64 64 { 65 65 } 66 66 67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement *passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3D::Attributes attributes)67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3D::Attributes attributes) 68 68 : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes) 69 69 { -
trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h
r208032 r208206 41 41 class WebGL2RenderingContext final : public WebGLRenderingContextBase { 42 42 public: 43 WebGL2RenderingContext(HTMLCanvasElement *, GraphicsContext3D::Attributes);44 WebGL2RenderingContext(HTMLCanvasElement *, RefPtr<GraphicsContext3D>&&, GraphicsContext3D::Attributes);43 WebGL2RenderingContext(HTMLCanvasElement&, GraphicsContext3D::Attributes); 44 WebGL2RenderingContext(HTMLCanvasElement&, RefPtr<GraphicsContext3D>&&, GraphicsContext3D::Attributes); 45 45 46 46 /* Buffer objects */ -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r207724 r208206 65 65 namespace WebCore { 66 66 67 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement *passedCanvas, GraphicsContext3D::Attributes attributes)67 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement& passedCanvas, GraphicsContext3D::Attributes attributes) 68 68 : WebGLRenderingContextBase(passedCanvas, attributes) 69 69 { 70 70 } 71 71 72 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement *passedCanvas, PassRefPtr<GraphicsContext3D> context,72 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement& passedCanvas, PassRefPtr<GraphicsContext3D> context, 73 73 GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, context, attributes) 74 74 { -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r207724 r208206 32 32 class WebGLRenderingContext final : public WebGLRenderingContextBase { 33 33 public: 34 WebGLRenderingContext(HTMLCanvasElement *, GraphicsContext3D::Attributes);35 WebGLRenderingContext(HTMLCanvasElement *, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes);34 WebGLRenderingContext(HTMLCanvasElement&, GraphicsContext3D::Attributes); 35 WebGLRenderingContext(HTMLCanvasElement&, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes); 36 36 37 37 private: -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r208032 r208206 349 349 }; 350 350 351 std::unique_ptr<WebGLRenderingContextBase> WebGLRenderingContextBase::create(HTMLCanvasElement *canvas, WebGLContextAttributes* attrs, const String& type)351 std::unique_ptr<WebGLRenderingContextBase> WebGLRenderingContextBase::create(HTMLCanvasElement& canvas, WebGLContextAttributes* attrs, const String& type) 352 352 { 353 353 #if ENABLE(WEBGL2) … … 358 358 #endif 359 359 360 Document& document = canvas ->document();360 Document& document = canvas.document(); 361 361 Frame* frame = document.frame(); 362 362 if (!frame) … … 366 366 // particular, if WebGL contexts were lost one or more times via the GL_ARB_robustness extension. 367 367 if (!frame->loader().client().allowWebGL(frame->settings().webGLEnabled())) { 368 canvas ->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Web page was not allowed to create a WebGL context."));368 canvas.dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Web page was not allowed to create a WebGL context.")); 369 369 return nullptr; 370 370 } … … 427 427 428 428 if (!context || !context->makeContextCurrent()) { 429 canvas ->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Could not create a WebGL context."));429 canvas.dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Could not create a WebGL context.")); 430 430 return nullptr; 431 431 } … … 447 447 } 448 448 449 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement *passedCanvas, GraphicsContext3D::Attributes attributes)449 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, GraphicsContext3D::Attributes attributes) 450 450 : CanvasRenderingContext(passedCanvas) 451 , ActiveDOMObject(&passedCanvas ->document())451 , ActiveDOMObject(&passedCanvas.document()) 452 452 , m_context(nullptr) 453 453 , m_dispatchContextLostEventTimer(*this, &WebGLRenderingContextBase::dispatchContextLostEvent) … … 465 465 } 466 466 467 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement *passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3D::Attributes attributes)467 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, RefPtr<GraphicsContext3D>&& context, GraphicsContext3D::Attributes attributes) 468 468 : CanvasRenderingContext(passedCanvas) 469 , ActiveDOMObject(&passedCanvas ->document())469 , ActiveDOMObject(&passedCanvas.document()) 470 470 , m_context(WTFMove(context)) 471 471 , m_dispatchContextLostEventTimer(*this, &WebGLRenderingContextBase::dispatchContextLostEvent) … … 572 572 ASSERT(m_context); 573 573 574 if (Page* page = canvas() ->document().page())574 if (Page* page = canvas().document().page()) 575 575 m_synthesizedErrorsToConsole = page->settings().webGLErrorsToConsoleEnabled(); 576 576 … … 641 641 642 642 m_layerCleared = false; 643 RenderBox* renderBox = canvas() ->renderBox();643 RenderBox* renderBox = canvas().renderBox(); 644 644 if (isAccelerated() && renderBox && renderBox->hasAcceleratedCompositing()) { 645 645 m_markedCanvasDirty = true; 646 canvas() ->clearCopiedImage();646 canvas().clearCopiedImage(); 647 647 renderBox->contentChanged(CanvasChanged); 648 648 } else { 649 649 if (!m_markedCanvasDirty) { 650 650 m_markedCanvasDirty = true; 651 canvas() ->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize()));651 canvas().didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); 652 652 } 653 653 } … … 731 731 return; 732 732 733 if (canvas() ->document().printing())734 canvas() ->clearPresentationCopy();733 if (canvas().document().printing()) 734 canvas().clearPresentationCopy(); 735 735 736 736 // Until the canvas is written to by the application, the clear that 737 737 // happened after it was composited should be ignored by the compositor. 738 738 if (m_context->layerComposited() && !m_attributes.preserveDrawingBuffer) { 739 m_context->paintCompositedResultsToCanvas(canvas() ->buffer());740 741 canvas() ->makePresentationCopy();739 m_context->paintCompositedResultsToCanvas(canvas().buffer()); 740 741 canvas().makePresentationCopy(); 742 742 } else 743 canvas() ->clearPresentationCopy();743 canvas().clearPresentationCopy(); 744 744 clearIfComposited(); 745 745 … … 747 747 return; 748 748 749 canvas() ->clearCopiedImage();749 canvas().clearCopiedImage(); 750 750 m_markedCanvasDirty = false; 751 751 752 m_context->paintRenderingResultsToCanvas(canvas() ->buffer());752 m_context->paintRenderingResultsToCanvas(canvas().buffer()); 753 753 } 754 754 … … 783 783 784 784 if (m_needsUpdate) { 785 RenderBox* renderBox = canvas() ->renderBox();785 RenderBox* renderBox = canvas().renderBox(); 786 786 if (renderBox && renderBox->hasAcceleratedCompositing()) 787 787 renderBox->contentChanged(CanvasChanged); … … 2681 2681 if (m_isPendingPolicyResolution && !m_hasRequestedPolicyResolution) { 2682 2682 LOG(WebGL, "Context is being used. Attempt to resolve the policy."); 2683 Document& document = canvas() ->document().topDocument();2683 Document& document = canvas().document().topDocument(); 2684 2684 Page* page = document.page(); 2685 2685 if (page && !document.url().isLocalFile()) … … 2826 2826 // Due to WebGL's same-origin restrictions, it is not possible to 2827 2827 // taint the origin using the WebGL API. 2828 ASSERT(canvas() ->originClean());2828 ASSERT(canvas().originClean()); 2829 2829 // Validate input parameters. 2830 2830 switch (format) { … … 3811 3811 // Inform the embedder that a lost context was received. In response, the embedder might 3812 3812 // decide to take action such as asking the user for permission to use WebGL again. 3813 if (Frame* frame = canvas() ->document().frame())3813 if (Frame* frame = canvas().document().frame()) 3814 3814 frame->loader().client().didLoseWebGLContext(m_context->getExtensions()->getGraphicsResetStatusARB()); 3815 3815 } … … 4435 4435 void WebGLRenderingContextBase::printWarningToConsole(const String& message) 4436 4436 { 4437 if (!canvas()) 4438 return; 4439 canvas()->document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Warning, message); 4437 canvas().document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Warning, message); 4440 4438 } 4441 4439 … … 4781 4779 { 4782 4780 Ref<WebGLContextEvent> event = WebGLContextEvent::create(eventNames().webglcontextlostEvent, false, true, emptyString()); 4783 canvas() ->dispatchEvent(event);4781 canvas().dispatchEvent(event); 4784 4782 m_restoreAllowed = event->defaultPrevented(); 4785 4783 if (m_contextLostMode == RealLostContext && m_restoreAllowed) … … 4829 4827 } 4830 4828 4831 Frame* frame = canvas() ->document().frame();4829 Frame* frame = canvas().document().frame(); 4832 4830 if (!frame) 4833 4831 return; … … 4861 4859 initializeNewContext(); 4862 4860 initializeVertexArrayObjects(); 4863 canvas() ->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, emptyString()));4861 canvas().dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, emptyString())); 4864 4862 } 4865 4863 … … 4974 4972 IntSize WebGLRenderingContextBase::clampedCanvasSize() 4975 4973 { 4976 return IntSize(clamp(canvas() ->width(), 1, m_maxViewportDims[0]),4977 clamp(canvas()->height(), 1, m_maxViewportDims[1]));4974 return IntSize(clamp(canvas().width(), 1, m_maxViewportDims[0]), 4975 clamp(canvas().height(), 1, m_maxViewportDims[1])); 4978 4976 } 4979 4977 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r208032 r208206 109 109 class WebGLRenderingContextBase : public CanvasRenderingContext, public ActiveDOMObject { 110 110 public: 111 static std::unique_ptr<WebGLRenderingContextBase> create(HTMLCanvasElement *, WebGLContextAttributes*, const String&);111 static std::unique_ptr<WebGLRenderingContextBase> create(HTMLCanvasElement&, WebGLContextAttributes*, const String&); 112 112 virtual ~WebGLRenderingContextBase(); 113 113 … … 335 335 336 336 protected: 337 WebGLRenderingContextBase(HTMLCanvasElement *, GraphicsContext3D::Attributes);338 WebGLRenderingContextBase(HTMLCanvasElement *, RefPtr<GraphicsContext3D>&&, GraphicsContext3D::Attributes);337 WebGLRenderingContextBase(HTMLCanvasElement&, GraphicsContext3D::Attributes); 338 WebGLRenderingContextBase(HTMLCanvasElement&, RefPtr<GraphicsContext3D>&&, GraphicsContext3D::Attributes); 339 339 340 340 friend class WebGLDrawBuffers;
Note:
See TracChangeset
for help on using the changeset viewer.