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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp

Issue 1903613002: Skip canvas filter construction in frameless documents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/canvas2d/CanvasRenderingContext2DState.h" 5 #include "modules/canvas2d/CanvasRenderingContext2DState.h"
6 6
7 #include "core/css/CSSFontSelector.h" 7 #include "core/css/CSSFontSelector.h"
8 #include "core/css/resolver/FilterOperationResolver.h" 8 #include "core/css/resolver/FilterOperationResolver.h"
9 #include "core/css/resolver/StyleBuilder.h" 9 #include "core/css/resolver/StyleBuilder.h"
10 #include "core/css/resolver/StyleResolverState.h" 10 #include "core/css/resolver/StyleResolverState.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 { 286 {
287 context->clearFilterReferences(); 287 context->clearFilterReferences();
288 context->addFilterReferences(filters, canvasElement->document()); 288 context->addFilterReferences(filters, canvasElement->document());
289 } 289 }
290 290
291 SkImageFilter* CanvasRenderingContext2DState::getFilter(Element* styleResolution Host, IntSize canvasSize, CanvasRenderingContext2D* context) const 291 SkImageFilter* CanvasRenderingContext2DState::getFilter(Element* styleResolution Host, IntSize canvasSize, CanvasRenderingContext2D* context) const
292 { 292 {
293 if (!m_filterValue) 293 if (!m_filterValue)
294 return nullptr; 294 return nullptr;
295 295
296 // StyleResolverState cannot be used in frame-less documents.
297 if (!styleResolutionHost->document().frame())
298 return nullptr;
299
296 if (!m_resolvedFilter) { 300 if (!m_resolvedFilter) {
297 RefPtr<ComputedStyle> filterStyle = ComputedStyle::create(); 301 RefPtr<ComputedStyle> filterStyle = ComputedStyle::create();
298 // Must set font in case the filter uses any font-relative units (em, ex ) 302 // Must set font in case the filter uses any font-relative units (em, ex )
299 filterStyle->setFont(m_fontForFilter); 303 filterStyle->setFont(m_fontForFilter);
300 304
301 StyleResolverState resolverState(styleResolutionHost->document(), styleR esolutionHost, filterStyle.get()); 305 StyleResolverState resolverState(styleResolutionHost->document(), styleR esolutionHost, filterStyle.get());
302 resolverState.setStyle(filterStyle); 306 resolverState.setStyle(filterStyle);
303 307
304 StyleBuilder::applyProperty(CSSPropertyWebkitFilter, resolverState, m_fi lterValue.get()); 308 StyleBuilder::applyProperty(CSSPropertyWebkitFilter, resolverState, m_fi lterValue.get());
305 resolverState.loadPendingResources(); 309 resolverState.loadPendingResources();
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 paint->setLooper(0); 561 paint->setLooper(0);
558 paint->setImageFilter(shadowAndForegroundImageFilter()); 562 paint->setImageFilter(shadowAndForegroundImageFilter());
559 return paint; 563 return paint;
560 } 564 }
561 paint->setLooper(sk_ref_sp(shadowAndForegroundDrawLooper())); 565 paint->setLooper(sk_ref_sp(shadowAndForegroundDrawLooper()));
562 paint->setImageFilter(0); 566 paint->setImageFilter(0);
563 return paint; 567 return paint;
564 } 568 }
565 569
566 } // namespace blink 570 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698