Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2057283002: Fix canvas-related crash caused by bad object teardown sequence (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test crash Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return false; 118 return false;
119 if (size.width() * size.height() > MaxCanvasArea) 119 if (size.width() * size.height() > MaxCanvasArea)
120 return false; 120 return false;
121 if (size.width() > MaxSkiaDim || size.height() > MaxSkiaDim) 121 if (size.width() > MaxSkiaDim || size.height() > MaxSkiaDim)
122 return false; 122 return false;
123 return true; 123 return true;
124 } 124 }
125 125
126 PassRefPtr<Image> createTransparentImage(const IntSize& size) 126 PassRefPtr<Image> createTransparentImage(const IntSize& size)
127 { 127 {
128 ASSERT(canCreateImageBuffer(size)); 128 DCHECK(canCreateImageBuffer(size));
129 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size .height()); 129 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size .height());
130 surface->getCanvas()->clear(SK_ColorTRANSPARENT); 130 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
131 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot())); 131 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()));
132 } 132 }
133 133
134 } // namespace 134 } // namespace
135 135
136 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) 136 inline HTMLCanvasElement::HTMLCanvasElement(Document& document)
137 : HTMLElement(canvasTag, document) 137 : HTMLElement(canvasTag, document)
138 , ContextLifecycleObserver(&document) 138 , ContextLifecycleObserver(&document)
139 , PageLifecycleObserver(document.page()) 139 , PageLifecycleObserver(document.page())
140 , m_size(DefaultWidth, DefaultHeight) 140 , m_size(DefaultWidth, DefaultHeight)
141 , m_ignoreReset(false) 141 , m_ignoreReset(false)
142 , m_externallyAllocatedMemory(0) 142 , m_externallyAllocatedMemory(0)
143 , m_originClean(true) 143 , m_originClean(true)
144 , m_didFailToCreateImageBuffer(false) 144 , m_didFailToCreateImageBuffer(false)
145 , m_imageBufferIsClear(false) 145 , m_imageBufferIsClear(false)
146 { 146 {
147 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::CanvasCreated); 147 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::CanvasCreated);
148 } 148 }
149 149
150 DEFINE_NODE_FACTORY(HTMLCanvasElement) 150 DEFINE_NODE_FACTORY(HTMLCanvasElement)
151 151
152 HTMLCanvasElement::~HTMLCanvasElement() 152 HTMLCanvasElement::~HTMLCanvasElement()
153 { 153 {
154 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory); 154 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory);
155 } 155 }
156 156
157 void HTMLCanvasElement::dispose()
158 {
159 if (m_context) {
160 m_context->detachCanvas();
161 m_context = nullptr;
162 }
163 }
164
157 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt ring& oldValue, const AtomicString& value) 165 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt ring& oldValue, const AtomicString& value)
158 { 166 {
159 if (name == widthAttr || name == heightAttr) 167 if (name == widthAttr || name == heightAttr)
160 reset(); 168 reset();
161 HTMLElement::parseAttribute(name, oldValue, value); 169 HTMLElement::parseAttribute(name, oldValue, value);
162 } 170 }
163 171
164 LayoutObject* HTMLCanvasElement::createLayoutObject(const ComputedStyle& style) 172 LayoutObject* HTMLCanvasElement::createLayoutObject(const ComputedStyle& style)
165 { 173 {
166 LocalFrame* frame = document().frame(); 174 LocalFrame* frame = document().frame();
(...skipping 13 matching lines...) Expand all
180 setIntegralAttribute(heightAttr, value); 188 setIntegralAttribute(heightAttr, value);
181 } 189 }
182 190
183 void HTMLCanvasElement::setWidth(int value) 191 void HTMLCanvasElement::setWidth(int value)
184 { 192 {
185 setIntegralAttribute(widthAttr, value); 193 setIntegralAttribute(widthAttr, value);
186 } 194 }
187 195
188 HTMLCanvasElement::ContextFactoryVector& HTMLCanvasElement::renderingContextFact ories() 196 HTMLCanvasElement::ContextFactoryVector& HTMLCanvasElement::renderingContextFact ories()
189 { 197 {
190 ASSERT(isMainThread()); 198 DCHECK(isMainThread());
191 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi ngContext::ContextTypeCount)); 199 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi ngContext::ContextTypeCount));
192 return s_contextFactories; 200 return s_contextFactories;
193 } 201 }
194 202
195 CanvasRenderingContextFactory* HTMLCanvasElement::getRenderingContextFactory(int type) 203 CanvasRenderingContextFactory* HTMLCanvasElement::getRenderingContextFactory(int type)
196 { 204 {
197 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 205 DCHECK(type < CanvasRenderingContext::ContextTypeCount);
198 return renderingContextFactories()[type].get(); 206 return renderingContextFactories()[type].get();
199 } 207 }
200 208
201 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory) 209 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory)
202 { 210 {
203 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType(); 211 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType();
204 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 212 DCHECK(type < CanvasRenderingContext::ContextTypeCount);
205 ASSERT(!renderingContextFactories()[type]); 213 DCHECK(!renderingContextFactories()[type]);
206 renderingContextFactories()[type] = std::move(renderingContextFactory); 214 renderingContextFactories()[type] = std::move(renderingContextFactory);
207 } 215 }
208 216
209 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes) 217 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes)
210 { 218 {
211 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type); 219 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type);
212 220
213 // Unknown type. 221 // Unknown type.
214 if (contextType == CanvasRenderingContext::ContextTypeCount) 222 if (contextType == CanvasRenderingContext::ContextTypeCount)
215 return nullptr; 223 return nullptr;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 314 }
307 315
308 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const 316 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const
309 { 317 {
310 if (m_context) 318 if (m_context)
311 m_context->restoreCanvasMatrixClipStack(canvas); 319 m_context->restoreCanvasMatrixClipStack(canvas);
312 } 320 }
313 321
314 void HTMLCanvasElement::doDeferredPaintInvalidation() 322 void HTMLCanvasElement::doDeferredPaintInvalidation()
315 { 323 {
316 ASSERT(!m_dirtyRect.isEmpty()); 324 DCHECK(!m_dirtyRect.isEmpty());
317 if (!m_context->is2d()) { 325 if (!m_context->is2d()) {
318 didFinalizeFrame(); 326 didFinalizeFrame();
319 } else { 327 } else {
320 ASSERT(hasImageBuffer()); 328 DCHECK(hasImageBuffer());
321 FloatRect srcRect(0, 0, size().width(), size().height()); 329 FloatRect srcRect(0, 0, size().width(), size().height());
322 m_dirtyRect.intersect(srcRect); 330 m_dirtyRect.intersect(srcRect);
323 LayoutBox* lb = layoutBox(); 331 LayoutBox* lb = layoutBox();
324 if (lb) { 332 if (lb) {
325 FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, FloatRect( lb->contentBoxRect())); 333 FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, FloatRect( lb->contentBoxRect()));
326 if (m_context->isAccelerated()) { 334 if (m_context->isAccelerated()) {
327 // Accelerated 2D canvases need the dirty rect to be expressed r elative to the 335 // Accelerated 2D canvases need the dirty rect to be expressed r elative to the
328 // content box, as opposed to the layout box. 336 // content box, as opposed to the layout box.
329 mappedDirtyRect.move(-lb->contentBoxOffset()); 337 mappedDirtyRect.move(-lb->contentBoxOffset());
330 } 338 }
331 m_imageBuffer->finalizeFrame(mappedDirtyRect); 339 m_imageBuffer->finalizeFrame(mappedDirtyRect);
332 } else { 340 } else {
333 m_imageBuffer->finalizeFrame(m_dirtyRect); 341 m_imageBuffer->finalizeFrame(m_dirtyRect);
334 } 342 }
335 } 343 }
336 ASSERT(m_dirtyRect.isEmpty()); 344 DCHECK(m_dirtyRect.isEmpty());
337 } 345 }
338 346
339 void HTMLCanvasElement::reset() 347 void HTMLCanvasElement::reset()
340 { 348 {
341 if (m_ignoreReset) 349 if (m_ignoreReset)
342 return; 350 return;
343 351
344 m_dirtyRect = FloatRect(); 352 m_dirtyRect = FloatRect();
345 353
346 bool ok; 354 bool ok;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 layoutBox()->contentChanged(CanvasChanged); 391 layoutBox()->contentChanged(CanvasChanged);
384 } 392 }
385 if (hadImageBuffer) 393 if (hadImageBuffer)
386 layoutObject->setShouldDoFullPaintInvalidation(); 394 layoutObject->setShouldDoFullPaintInvalidation();
387 } 395 }
388 } 396 }
389 } 397 }
390 398
391 bool HTMLCanvasElement::paintsIntoCanvasBuffer() const 399 bool HTMLCanvasElement::paintsIntoCanvasBuffer() const
392 { 400 {
393 ASSERT(m_context); 401 DCHECK(m_context);
394 402
395 if (!m_context->isAccelerated()) 403 if (!m_context->isAccelerated())
396 return true; 404 return true;
397 if (layoutBox() && layoutBox()->hasAcceleratedCompositing()) 405 if (layoutBox() && layoutBox()->hasAcceleratedCompositing())
398 return false; 406 return false;
399 407
400 return true; 408 return true;
401 } 409 }
402 410
403 void HTMLCanvasElement::notifyListenersCanvasChanged() 411 void HTMLCanvasElement::notifyListenersCanvasChanged()
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 return lowercaseMimeType; 556 return lowercaseMimeType;
549 } 557 }
550 558
551 const AtomicString HTMLCanvasElement::imageSourceURL() const 559 const AtomicString HTMLCanvasElement::imageSourceURL() const
552 { 560 {
553 return AtomicString(toDataURLInternal(DefaultMimeType, 0, FrontBuffer)); 561 return AtomicString(toDataURLInternal(DefaultMimeType, 0, FrontBuffer));
554 } 562 }
555 563
556 void HTMLCanvasElement::prepareSurfaceForPaintingIfNeeded() const 564 void HTMLCanvasElement::prepareSurfaceForPaintingIfNeeded() const
557 { 565 {
558 ASSERT(m_context && m_context->is2d()); // This function is called by the 2d context 566 DCHECK(m_context && m_context->is2d()); // This function is called by the 2d context
559 if (buffer()) 567 if (buffer())
560 m_imageBuffer->prepareSurfaceForPaintingIfNeeded(); 568 m_imageBuffer->prepareSurfaceForPaintingIfNeeded();
561 } 569 }
562 570
563 ImageData* HTMLCanvasElement::toImageData(SourceDrawingBuffer sourceBuffer, Snap shotReason reason) const 571 ImageData* HTMLCanvasElement::toImageData(SourceDrawingBuffer sourceBuffer, Snap shotReason reason) const
564 { 572 {
565 ImageData* imageData; 573 ImageData* imageData;
566 if (is3D()) { 574 if (is3D()) {
567 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL(). 575 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL().
568 imageData = m_context->paintRenderingResultsToImageData(sourceBuffer); 576 imageData = m_context->paintRenderingResultsToImageData(sourceBuffer);
569 if (imageData) 577 if (imageData)
570 return imageData; 578 return imageData;
571 579
572 m_context->paintRenderingResultsToCanvas(sourceBuffer); 580 m_context->paintRenderingResultsToCanvas(sourceBuffer);
573 imageData = ImageData::create(m_size); 581 imageData = ImageData::create(m_size);
574 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAccelera tion, reason); 582 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAccelera tion, reason);
575 if (snapshot) { 583 if (snapshot) {
576 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8 888_SkColorType, kUnpremul_SkAlphaType); 584 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8 888_SkColorType, kUnpremul_SkAlphaType);
577 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo .minRowBytes(), 0, 0); 585 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo .minRowBytes(), 0, 0);
578 } 586 }
579 return imageData; 587 return imageData;
580 } 588 }
581 589
582 imageData = ImageData::create(m_size); 590 imageData = ImageData::create(m_size);
583 591
584 if (!m_context) 592 if (!m_context)
585 return imageData; 593 return imageData;
586 594
587 ASSERT(m_context->is2d()); 595 DCHECK(m_context->is2d());
588 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration , reason); 596 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration , reason);
589 if (snapshot) { 597 if (snapshot) {
590 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_ SkColorType, kUnpremul_SkAlphaType); 598 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_ SkColorType, kUnpremul_SkAlphaType);
591 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo.min RowBytes(), 0, 0); 599 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo.min RowBytes(), 0, 0);
592 } 600 }
593 601
594 return imageData; 602 return imageData;
595 } 603 }
596 604
597 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const 605 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 824
817 void HTMLCanvasElement::createImageBuffer() 825 void HTMLCanvasElement::createImageBuffer()
818 { 826 {
819 createImageBufferInternal(nullptr); 827 createImageBufferInternal(nullptr);
820 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty()) 828 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty())
821 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext); 829 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext);
822 } 830 }
823 831
824 void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurface) 832 void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurface)
825 { 833 {
826 ASSERT(!m_imageBuffer); 834 DCHECK(!m_imageBuffer);
827 835
828 m_didFailToCreateImageBuffer = true; 836 m_didFailToCreateImageBuffer = true;
829 m_imageBufferIsClear = true; 837 m_imageBufferIsClear = true;
830 838
831 if (!canCreateImageBuffer(size())) 839 if (!canCreateImageBuffer(size()))
832 return; 840 return;
833 841
834 int msaaSampleCount = 0; 842 int msaaSampleCount = 0;
835 OwnPtr<ImageBufferSurface> surface; 843 OwnPtr<ImageBufferSurface> surface;
836 if (externalSurface) { 844 if (externalSurface) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 SkCanvas* HTMLCanvasElement::existingDrawingCanvas() const 936 SkCanvas* HTMLCanvasElement::existingDrawingCanvas() const
929 { 937 {
930 if (!hasImageBuffer()) 938 if (!hasImageBuffer())
931 return nullptr; 939 return nullptr;
932 940
933 return m_imageBuffer->canvas(); 941 return m_imageBuffer->canvas();
934 } 942 }
935 943
936 ImageBuffer* HTMLCanvasElement::buffer() const 944 ImageBuffer* HTMLCanvasElement::buffer() const
937 { 945 {
938 ASSERT(m_context); 946 DCHECK(m_context);
939 if (!hasImageBuffer() && !m_didFailToCreateImageBuffer) 947 if (!hasImageBuffer() && !m_didFailToCreateImageBuffer)
940 const_cast<HTMLCanvasElement*>(this)->createImageBuffer(); 948 const_cast<HTMLCanvasElement*>(this)->createImageBuffer();
941 return m_imageBuffer.get(); 949 return m_imageBuffer.get();
942 } 950 }
943 951
944 void HTMLCanvasElement::createImageBufferUsingSurfaceForTesting(PassOwnPtr<Image BufferSurface> surface) 952 void HTMLCanvasElement::createImageBufferUsingSurfaceForTesting(PassOwnPtr<Image BufferSurface> surface)
945 { 953 {
946 discardImageBuffer(); 954 discardImageBuffer();
947 setWidth(surface->size().width()); 955 setWidth(surface->size().width());
948 setHeight(surface->size().height()); 956 setHeight(surface->size().height());
949 createImageBufferInternal(std::move(surface)); 957 createImageBufferInternal(std::move(surface));
950 } 958 }
951 959
952 void HTMLCanvasElement::ensureUnacceleratedImageBuffer() 960 void HTMLCanvasElement::ensureUnacceleratedImageBuffer()
953 { 961 {
954 ASSERT(m_context); 962 DCHECK(m_context);
955 if ((hasImageBuffer() && !m_imageBuffer->isAccelerated()) || m_didFailToCrea teImageBuffer) 963 if ((hasImageBuffer() && !m_imageBuffer->isAccelerated()) || m_didFailToCrea teImageBuffer)
956 return; 964 return;
957 discardImageBuffer(); 965 discardImageBuffer();
958 OpacityMode opacityMode = m_context->hasAlpha() ? NonOpaque : Opaque; 966 OpacityMode opacityMode = m_context->hasAlpha() ? NonOpaque : Opaque;
959 m_imageBuffer = ImageBuffer::create(size(), opacityMode); 967 m_imageBuffer = ImageBuffer::create(size(), opacityMode);
960 m_didFailToCreateImageBuffer = !m_imageBuffer; 968 m_didFailToCreateImageBuffer = !m_imageBuffer;
961 } 969 }
962 970
963 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe r, AccelerationHint hint) const 971 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe r, AccelerationHint hint) const
964 { 972 {
(...skipping 23 matching lines...) Expand all
988 void HTMLCanvasElement::clearCopiedImage() 996 void HTMLCanvasElement::clearCopiedImage()
989 { 997 {
990 if (m_copiedImage) { 998 if (m_copiedImage) {
991 m_copiedImage.clear(); 999 m_copiedImage.clear();
992 updateExternallyAllocatedMemory(); 1000 updateExternallyAllocatedMemory();
993 } 1001 }
994 } 1002 }
995 1003
996 AffineTransform HTMLCanvasElement::baseTransform() const 1004 AffineTransform HTMLCanvasElement::baseTransform() const
997 { 1005 {
998 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); 1006 DCHECK(hasImageBuffer() && !m_didFailToCreateImageBuffer);
999 return m_imageBuffer->baseTransform(); 1007 return m_imageBuffer->baseTransform();
1000 } 1008 }
1001 1009
1002 void HTMLCanvasElement::pageVisibilityChanged() 1010 void HTMLCanvasElement::pageVisibilityChanged()
1003 { 1011 {
1004 if (!m_context) 1012 if (!m_context)
1005 return; 1013 return;
1006 1014
1007 bool hidden = !page()->isPageVisible(); 1015 bool hidden = !page()->isPageVisible();
1008 m_context->setIsHidden(hidden); 1016 m_context->setIsHidden(hidden);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 return FloatSize(width(), height()); 1082 return FloatSize(width(), height());
1075 } 1083 }
1076 1084
1077 IntSize HTMLCanvasElement::bitmapSourceSize() const 1085 IntSize HTMLCanvasElement::bitmapSourceSize() const
1078 { 1086 {
1079 return IntSize(width(), height()); 1087 return IntSize(width(), height());
1080 } 1088 }
1081 1089
1082 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) 1090 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
1083 { 1091 {
1084 ASSERT(eventTarget.toLocalDOMWindow()); 1092 DCHECK(eventTarget.toLocalDOMWindow());
1085 if (!sw || !sh) { 1093 if (!sw || !sh) {
1086 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 1094 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
1087 return ScriptPromise(); 1095 return ScriptPromise();
1088 } 1096 }
1089 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); 1097 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr);
1090 } 1098 }
1091 1099
1092 bool HTMLCanvasElement::isOpaque() const 1100 bool HTMLCanvasElement::isOpaque() const
1093 { 1101 {
1094 return m_context && !m_context->hasAlpha(); 1102 return m_context && !m_context->hasAlpha();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 return m_context->getIdFromControl(element); 1173 return m_context->getIdFromControl(element);
1166 return String(); 1174 return String();
1167 } 1175 }
1168 1176
1169 void HTMLCanvasElement::createSurfaceLayerBridge() 1177 void HTMLCanvasElement::createSurfaceLayerBridge()
1170 { 1178 {
1171 m_surfaceLayerBridge = adoptPtr(new CanvasSurfaceLayerBridge()); 1179 m_surfaceLayerBridge = adoptPtr(new CanvasSurfaceLayerBridge());
1172 } 1180 }
1173 1181
1174 } // namespace blink 1182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698