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

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: 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();
xlai (Olivia) 2016/06/10 19:28:17 Maybe add one more line here "m_context = nullptr;
Justin Novosad 2016/06/10 19:39:09 Done.
161 }
162
157 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt ring& oldValue, const AtomicString& value) 163 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt ring& oldValue, const AtomicString& value)
158 { 164 {
159 if (name == widthAttr || name == heightAttr) 165 if (name == widthAttr || name == heightAttr)
160 reset(); 166 reset();
161 HTMLElement::parseAttribute(name, oldValue, value); 167 HTMLElement::parseAttribute(name, oldValue, value);
162 } 168 }
163 169
164 LayoutObject* HTMLCanvasElement::createLayoutObject(const ComputedStyle& style) 170 LayoutObject* HTMLCanvasElement::createLayoutObject(const ComputedStyle& style)
165 { 171 {
166 LocalFrame* frame = document().frame(); 172 LocalFrame* frame = document().frame();
(...skipping 13 matching lines...) Expand all
180 setIntegralAttribute(heightAttr, value); 186 setIntegralAttribute(heightAttr, value);
181 } 187 }
182 188
183 void HTMLCanvasElement::setWidth(int value) 189 void HTMLCanvasElement::setWidth(int value)
184 { 190 {
185 setIntegralAttribute(widthAttr, value); 191 setIntegralAttribute(widthAttr, value);
186 } 192 }
187 193
188 HTMLCanvasElement::ContextFactoryVector& HTMLCanvasElement::renderingContextFact ories() 194 HTMLCanvasElement::ContextFactoryVector& HTMLCanvasElement::renderingContextFact ories()
189 { 195 {
190 ASSERT(isMainThread()); 196 DCHECK(isMainThread());
191 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi ngContext::ContextTypeCount)); 197 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi ngContext::ContextTypeCount));
192 return s_contextFactories; 198 return s_contextFactories;
193 } 199 }
194 200
195 CanvasRenderingContextFactory* HTMLCanvasElement::getRenderingContextFactory(int type) 201 CanvasRenderingContextFactory* HTMLCanvasElement::getRenderingContextFactory(int type)
196 { 202 {
197 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 203 DCHECK(type < CanvasRenderingContext::ContextTypeCount);
198 return renderingContextFactories()[type].get(); 204 return renderingContextFactories()[type].get();
199 } 205 }
200 206
201 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory) 207 void HTMLCanvasElement::registerRenderingContextFactory(PassOwnPtr<CanvasRenderi ngContextFactory> renderingContextFactory)
202 { 208 {
203 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType(); 209 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType();
204 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 210 DCHECK(type < CanvasRenderingContext::ContextTypeCount);
205 ASSERT(!renderingContextFactories()[type]); 211 DCHECK(!renderingContextFactories()[type]);
206 renderingContextFactories()[type] = std::move(renderingContextFactory); 212 renderingContextFactories()[type] = std::move(renderingContextFactory);
207 } 213 }
208 214
209 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes) 215 CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(const Strin g& type, const CanvasContextCreationAttributes& attributes)
210 { 216 {
211 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type); 217 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(type);
212 218
213 // Unknown type. 219 // Unknown type.
214 if (contextType == CanvasRenderingContext::ContextTypeCount) 220 if (contextType == CanvasRenderingContext::ContextTypeCount)
215 return nullptr; 221 return nullptr;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 FloatRect srcRect(0, 0, size().width(), size().height()); 298 FloatRect srcRect(0, 0, size().width(), size().height());
293 m_dirtyRect.intersect(srcRect); 299 m_dirtyRect.intersect(srcRect);
294 LayoutBox* ro = layoutBox(); 300 LayoutBox* ro = layoutBox();
295 // Canvas content updates do not need to be propagated as 301 // Canvas content updates do not need to be propagated as
296 // paint invalidations if the canvas is accelerated, since 302 // paint invalidations if the canvas is accelerated, since
297 // the canvas contents are sent separately through a texture layer. 303 // the canvas contents are sent separately through a texture layer.
298 if (ro && (!m_context || !m_context->isAccelerated())) { 304 if (ro && (!m_context || !m_context->isAccelerated())) {
299 LayoutRect mappedDirtyRect(enclosingIntRect(mapRect(m_dirtyRect, srcRect , FloatRect(ro->contentBoxRect())))); 305 LayoutRect mappedDirtyRect(enclosingIntRect(mapRect(m_dirtyRect, srcRect , FloatRect(ro->contentBoxRect()))));
300 // For querying PaintLayer::compositingState() 306 // For querying PaintLayer::compositingState()
301 // FIXME: is this invalidation using the correct compositing state? 307 // FIXME: is this invalidation using the correct compositing state?
302 DisableCompositingQueryAsserts disabler; 308 DisableCompositingQueryDCHECKs disabler;
303 ro->invalidatePaintRectangle(mappedDirtyRect); 309 ro->invalidatePaintRectangle(mappedDirtyRect);
304 } 310 }
305 m_dirtyRect = FloatRect(); 311 m_dirtyRect = FloatRect();
306 } 312 }
307 313
308 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const 314 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const
309 { 315 {
310 if (m_context) 316 if (m_context)
311 m_context->restoreCanvasMatrixClipStack(canvas); 317 m_context->restoreCanvasMatrixClipStack(canvas);
312 } 318 }
313 319
314 void HTMLCanvasElement::doDeferredPaintInvalidation() 320 void HTMLCanvasElement::doDeferredPaintInvalidation()
315 { 321 {
316 ASSERT(!m_dirtyRect.isEmpty()); 322 DCHECK(!m_dirtyRect.isEmpty());
317 if (!m_context->is2d()) { 323 if (!m_context->is2d()) {
318 didFinalizeFrame(); 324 didFinalizeFrame();
319 } else { 325 } else {
320 ASSERT(hasImageBuffer()); 326 DCHECK(hasImageBuffer());
321 FloatRect srcRect(0, 0, size().width(), size().height()); 327 FloatRect srcRect(0, 0, size().width(), size().height());
322 m_dirtyRect.intersect(srcRect); 328 m_dirtyRect.intersect(srcRect);
323 LayoutBox* lb = layoutBox(); 329 LayoutBox* lb = layoutBox();
324 if (lb) { 330 if (lb) {
325 FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, FloatRect( lb->contentBoxRect())); 331 FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, FloatRect( lb->contentBoxRect()));
326 if (m_context->isAccelerated()) { 332 if (m_context->isAccelerated()) {
327 // Accelerated 2D canvases need the dirty rect to be expressed r elative to the 333 // Accelerated 2D canvases need the dirty rect to be expressed r elative to the
328 // content box, as opposed to the layout box. 334 // content box, as opposed to the layout box.
329 mappedDirtyRect.move(-lb->contentBoxOffset()); 335 mappedDirtyRect.move(-lb->contentBoxOffset());
330 } 336 }
331 m_imageBuffer->finalizeFrame(mappedDirtyRect); 337 m_imageBuffer->finalizeFrame(mappedDirtyRect);
332 } else { 338 } else {
333 m_imageBuffer->finalizeFrame(m_dirtyRect); 339 m_imageBuffer->finalizeFrame(m_dirtyRect);
334 } 340 }
335 } 341 }
336 ASSERT(m_dirtyRect.isEmpty()); 342 DCHECK(m_dirtyRect.isEmpty());
337 } 343 }
338 344
339 void HTMLCanvasElement::reset() 345 void HTMLCanvasElement::reset()
340 { 346 {
341 if (m_ignoreReset) 347 if (m_ignoreReset)
342 return; 348 return;
343 349
344 m_dirtyRect = FloatRect(); 350 m_dirtyRect = FloatRect();
345 351
346 bool ok; 352 bool ok;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 layoutBox()->contentChanged(CanvasChanged); 389 layoutBox()->contentChanged(CanvasChanged);
384 } 390 }
385 if (hadImageBuffer) 391 if (hadImageBuffer)
386 layoutObject->setShouldDoFullPaintInvalidation(); 392 layoutObject->setShouldDoFullPaintInvalidation();
387 } 393 }
388 } 394 }
389 } 395 }
390 396
391 bool HTMLCanvasElement::paintsIntoCanvasBuffer() const 397 bool HTMLCanvasElement::paintsIntoCanvasBuffer() const
392 { 398 {
393 ASSERT(m_context); 399 DCHECK(m_context);
394 400
395 if (!m_context->isAccelerated()) 401 if (!m_context->isAccelerated())
396 return true; 402 return true;
397 if (layoutBox() && layoutBox()->hasAcceleratedCompositing()) 403 if (layoutBox() && layoutBox()->hasAcceleratedCompositing())
398 return false; 404 return false;
399 405
400 return true; 406 return true;
401 } 407 }
402 408
403 void HTMLCanvasElement::notifyListenersCanvasChanged() 409 void HTMLCanvasElement::notifyListenersCanvasChanged()
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 return lowercaseMimeType; 554 return lowercaseMimeType;
549 } 555 }
550 556
551 const AtomicString HTMLCanvasElement::imageSourceURL() const 557 const AtomicString HTMLCanvasElement::imageSourceURL() const
552 { 558 {
553 return AtomicString(toDataURLInternal(DefaultMimeType, 0, FrontBuffer)); 559 return AtomicString(toDataURLInternal(DefaultMimeType, 0, FrontBuffer));
554 } 560 }
555 561
556 void HTMLCanvasElement::prepareSurfaceForPaintingIfNeeded() const 562 void HTMLCanvasElement::prepareSurfaceForPaintingIfNeeded() const
557 { 563 {
558 ASSERT(m_context && m_context->is2d()); // This function is called by the 2d context 564 DCHECK(m_context && m_context->is2d()); // This function is called by the 2d context
559 if (buffer()) 565 if (buffer())
560 m_imageBuffer->prepareSurfaceForPaintingIfNeeded(); 566 m_imageBuffer->prepareSurfaceForPaintingIfNeeded();
561 } 567 }
562 568
563 ImageData* HTMLCanvasElement::toImageData(SourceDrawingBuffer sourceBuffer, Snap shotReason reason) const 569 ImageData* HTMLCanvasElement::toImageData(SourceDrawingBuffer sourceBuffer, Snap shotReason reason) const
564 { 570 {
565 ImageData* imageData; 571 ImageData* imageData;
566 if (is3D()) { 572 if (is3D()) {
567 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL(). 573 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL().
568 imageData = m_context->paintRenderingResultsToImageData(sourceBuffer); 574 imageData = m_context->paintRenderingResultsToImageData(sourceBuffer);
569 if (imageData) 575 if (imageData)
570 return imageData; 576 return imageData;
571 577
572 m_context->paintRenderingResultsToCanvas(sourceBuffer); 578 m_context->paintRenderingResultsToCanvas(sourceBuffer);
573 imageData = ImageData::create(m_size); 579 imageData = ImageData::create(m_size);
574 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAccelera tion, reason); 580 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAccelera tion, reason);
575 if (snapshot) { 581 if (snapshot) {
576 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8 888_SkColorType, kUnpremul_SkAlphaType); 582 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8 888_SkColorType, kUnpremul_SkAlphaType);
577 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo .minRowBytes(), 0, 0); 583 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo .minRowBytes(), 0, 0);
578 } 584 }
579 return imageData; 585 return imageData;
580 } 586 }
581 587
582 imageData = ImageData::create(m_size); 588 imageData = ImageData::create(m_size);
583 589
584 if (!m_context) 590 if (!m_context)
585 return imageData; 591 return imageData;
586 592
587 ASSERT(m_context->is2d()); 593 DCHECK(m_context->is2d());
588 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration , reason); 594 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration , reason);
589 if (snapshot) { 595 if (snapshot) {
590 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_ SkColorType, kUnpremul_SkAlphaType); 596 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_ SkColorType, kUnpremul_SkAlphaType);
591 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo.min RowBytes(), 0, 0); 597 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo.min RowBytes(), 0, 0);
592 } 598 }
593 599
594 return imageData; 600 return imageData;
595 } 601 }
596 602
597 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const 603 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 822
817 void HTMLCanvasElement::createImageBuffer() 823 void HTMLCanvasElement::createImageBuffer()
818 { 824 {
819 createImageBufferInternal(nullptr); 825 createImageBufferInternal(nullptr);
820 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty()) 826 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty())
821 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext); 827 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext);
822 } 828 }
823 829
824 void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurface) 830 void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurface)
825 { 831 {
826 ASSERT(!m_imageBuffer); 832 DCHECK(!m_imageBuffer);
827 833
828 m_didFailToCreateImageBuffer = true; 834 m_didFailToCreateImageBuffer = true;
829 m_imageBufferIsClear = true; 835 m_imageBufferIsClear = true;
830 836
831 if (!canCreateImageBuffer(size())) 837 if (!canCreateImageBuffer(size()))
832 return; 838 return;
833 839
834 int msaaSampleCount = 0; 840 int msaaSampleCount = 0;
835 OwnPtr<ImageBufferSurface> surface; 841 OwnPtr<ImageBufferSurface> surface;
836 if (externalSurface) { 842 if (externalSurface) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 SkCanvas* HTMLCanvasElement::existingDrawingCanvas() const 934 SkCanvas* HTMLCanvasElement::existingDrawingCanvas() const
929 { 935 {
930 if (!hasImageBuffer()) 936 if (!hasImageBuffer())
931 return nullptr; 937 return nullptr;
932 938
933 return m_imageBuffer->canvas(); 939 return m_imageBuffer->canvas();
934 } 940 }
935 941
936 ImageBuffer* HTMLCanvasElement::buffer() const 942 ImageBuffer* HTMLCanvasElement::buffer() const
937 { 943 {
938 ASSERT(m_context); 944 DCHECK(m_context);
939 if (!hasImageBuffer() && !m_didFailToCreateImageBuffer) 945 if (!hasImageBuffer() && !m_didFailToCreateImageBuffer)
940 const_cast<HTMLCanvasElement*>(this)->createImageBuffer(); 946 const_cast<HTMLCanvasElement*>(this)->createImageBuffer();
941 return m_imageBuffer.get(); 947 return m_imageBuffer.get();
942 } 948 }
943 949
944 void HTMLCanvasElement::createImageBufferUsingSurfaceForTesting(PassOwnPtr<Image BufferSurface> surface) 950 void HTMLCanvasElement::createImageBufferUsingSurfaceForTesting(PassOwnPtr<Image BufferSurface> surface)
945 { 951 {
946 discardImageBuffer(); 952 discardImageBuffer();
947 setWidth(surface->size().width()); 953 setWidth(surface->size().width());
948 setHeight(surface->size().height()); 954 setHeight(surface->size().height());
949 createImageBufferInternal(std::move(surface)); 955 createImageBufferInternal(std::move(surface));
950 } 956 }
951 957
952 void HTMLCanvasElement::ensureUnacceleratedImageBuffer() 958 void HTMLCanvasElement::ensureUnacceleratedImageBuffer()
953 { 959 {
954 ASSERT(m_context); 960 DCHECK(m_context);
955 if ((hasImageBuffer() && !m_imageBuffer->isAccelerated()) || m_didFailToCrea teImageBuffer) 961 if ((hasImageBuffer() && !m_imageBuffer->isAccelerated()) || m_didFailToCrea teImageBuffer)
956 return; 962 return;
957 discardImageBuffer(); 963 discardImageBuffer();
958 OpacityMode opacityMode = m_context->hasAlpha() ? NonOpaque : Opaque; 964 OpacityMode opacityMode = m_context->hasAlpha() ? NonOpaque : Opaque;
959 m_imageBuffer = ImageBuffer::create(size(), opacityMode); 965 m_imageBuffer = ImageBuffer::create(size(), opacityMode);
960 m_didFailToCreateImageBuffer = !m_imageBuffer; 966 m_didFailToCreateImageBuffer = !m_imageBuffer;
961 } 967 }
962 968
963 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe r, AccelerationHint hint) const 969 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe r, AccelerationHint hint) const
964 { 970 {
(...skipping 23 matching lines...) Expand all
988 void HTMLCanvasElement::clearCopiedImage() 994 void HTMLCanvasElement::clearCopiedImage()
989 { 995 {
990 if (m_copiedImage) { 996 if (m_copiedImage) {
991 m_copiedImage.clear(); 997 m_copiedImage.clear();
992 updateExternallyAllocatedMemory(); 998 updateExternallyAllocatedMemory();
993 } 999 }
994 } 1000 }
995 1001
996 AffineTransform HTMLCanvasElement::baseTransform() const 1002 AffineTransform HTMLCanvasElement::baseTransform() const
997 { 1003 {
998 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); 1004 DCHECK(hasImageBuffer() && !m_didFailToCreateImageBuffer);
999 return m_imageBuffer->baseTransform(); 1005 return m_imageBuffer->baseTransform();
1000 } 1006 }
1001 1007
1002 void HTMLCanvasElement::pageVisibilityChanged() 1008 void HTMLCanvasElement::pageVisibilityChanged()
1003 { 1009 {
1004 if (!m_context) 1010 if (!m_context)
1005 return; 1011 return;
1006 1012
1007 bool hidden = !page()->isPageVisible(); 1013 bool hidden = !page()->isPageVisible();
1008 m_context->setIsHidden(hidden); 1014 m_context->setIsHidden(hidden);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 return FloatSize(width(), height()); 1080 return FloatSize(width(), height());
1075 } 1081 }
1076 1082
1077 IntSize HTMLCanvasElement::bitmapSourceSize() const 1083 IntSize HTMLCanvasElement::bitmapSourceSize() const
1078 { 1084 {
1079 return IntSize(width(), height()); 1085 return IntSize(width(), height());
1080 } 1086 }
1081 1087
1082 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) 1088 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
1083 { 1089 {
1084 ASSERT(eventTarget.toLocalDOMWindow()); 1090 DCHECK(eventTarget.toLocalDOMWindow());
1085 if (!sw || !sh) { 1091 if (!sw || !sh) {
1086 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 1092 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
1087 return ScriptPromise(); 1093 return ScriptPromise();
1088 } 1094 }
1089 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); 1095 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr);
1090 } 1096 }
1091 1097
1092 bool HTMLCanvasElement::isOpaque() const 1098 bool HTMLCanvasElement::isOpaque() const
1093 { 1099 {
1094 return m_context && !m_context->hasAlpha(); 1100 return m_context && !m_context->hasAlpha();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 return m_context->getIdFromControl(element); 1171 return m_context->getIdFromControl(element);
1166 return String(); 1172 return String();
1167 } 1173 }
1168 1174
1169 void HTMLCanvasElement::createSurfaceLayerBridge() 1175 void HTMLCanvasElement::createSurfaceLayerBridge()
1170 { 1176 {
1171 m_surfaceLayerBridge = adoptPtr(new CanvasSurfaceLayerBridge()); 1177 m_surfaceLayerBridge = adoptPtr(new CanvasSurfaceLayerBridge());
1172 } 1178 }
1173 1179
1174 } // namespace blink 1180 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698