Changeset 57020 in webkit
- Timestamp:
- Apr 2, 2010 1:31:53 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r57018 r57020 1 2010-04-02 David Levin <levin@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 (non-generated) code should only use CanvasRenderingContext::canvas as a CanvasSurface. 6 https://bugs.webkit.org/show_bug.cgi?id=36906 7 8 * fast/canvas/script-tests/canvas-gradient-addStop-error.js: Changed the test 9 to create a new canvas after switching to dashboard compatiblity mode, which is 10 needed now that the compatibility mode is cached in the canvas. 11 1 12 2010-04-02 Zhenyao Mo <zmo@google.com> 2 13 -
trunk/LayoutTests/fast/canvas/script-tests/canvas-gradient-addStop-error.js
r48550 r57020 13 13 debug("The following tests will fail in the browser as we can only enable dashboard compatibility mode in DRT.") 14 14 } 15 15 // Create a new context so that will be created using dashboard compatibility mode. 16 ctx = document.createElement('canvas').getContext('2d'); 16 17 var gradient = ctx.createLinearGradient(0, 0, 0, 100); 17 18 shouldBeUndefined("gradient.addColorStop(1, 'rgb(NaN%, NaN%, NaN%)')"); -
trunk/WebCore/ChangeLog
r57018 r57020 1 2010-04-02 David Levin <levin@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 (non-generated) code should only use CanvasRenderingContext::canvas as a CanvasSurface. 6 https://bugs.webkit.org/show_bug.cgi?id=36906 7 8 * dom/CanvasSurface.cpp: Added methods for items that depended on 9 CanvasRenderingContext::canvas() being an HTMLElement(), so that this usage 10 can be dealt with in one place. 11 (WebCore::CanvasSurface::securityOrigin): Only used by methods that are 12 only run in the document context. 13 (WebCore::CanvasSurface::renderBox): Will likely return 0 in a worker context. 14 (WebCore::CanvasSurface::computedStyle): Used by setFont. Return value is TBD for 15 the worker context. 16 (WebCore::CanvasSurface::styleSelector): Ditto. 17 * dom/CanvasSurface.h: 18 * html/HTMLCanvasElement.cpp: 19 (WebCore::HTMLCanvasElement::getContext): Passing in information into 20 the CanvasRenderingContext2D constructor to eliminate some uses of document 21 inside of the CanvasRenderingContext2D class. 22 * html/HTMLCanvasElement.h: 23 (WebCore::HTMLCanvasElement::renderBox): Added to disambiguate between the 24 two parent class versions of the method. 25 (WebCore::HTMLCanvasElement::computedStyle): Ditto. 26 * html/canvas/CanvasRenderingContext2D.cpp: All of these changes are about 27 removing document usage either by using a bool that is set in the constructor or 28 by calling one of the new methods added to CanvasSurface. 29 (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D): 30 (WebCore::CanvasRenderingContext2D::clearPathForDashboardBackwardCompatibilityMode): 31 (WebCore::CanvasRenderingContext2D::checkOrigin): 32 (WebCore::CanvasRenderingContext2D::prepareGradientForDashboard): 33 (WebCore::CanvasRenderingContext2D::createPattern): 34 (WebCore::CanvasRenderingContext2D::setFont): 35 (WebCore::CanvasRenderingContext2D::drawTextInternal): 36 * html/canvas/CanvasRenderingContext2D.h: 37 * html/canvas/WebGLRenderingContext.cpp: Removed some duplicate includes. 38 (WebCore::WebGLRenderingContext::markContextChanged): Reduced calls to renderBox 39 as it may become slightly more expensive in the future. 40 (WebCore::WebGLRenderingContext::reshape): Ditto. 41 1 42 2010-04-02 Zhenyao Mo <zmo@google.com> 2 43 -
trunk/WebCore/dom/CanvasSurface.cpp
r56447 r57020 31 31 #include "FloatRect.h" 32 32 #include "GraphicsContext.h" 33 #include "HTMLCanvasElement.h" 33 34 #include "ImageBuffer.h" 34 35 #include "MIMETypeRegistry.h" … … 155 156 } 156 157 158 // FIXME: Everything below here relies on CanvasSurface really being 159 // a HTMLCanvasElement. 160 const SecurityOrigin& CanvasSurface::securityOrigin() const 161 { 162 return *(static_cast<const HTMLCanvasElement*>(this)->document()->securityOrigin()); 163 } 164 165 RenderBox* CanvasSurface::renderBox() const 166 { 167 return static_cast<const HTMLCanvasElement*>(this)->renderBox(); 168 } 169 170 RenderStyle* CanvasSurface::computedStyle() 171 { 172 return static_cast<HTMLCanvasElement*>(this)->computedStyle(); 173 } 174 175 CSSStyleSelector* CanvasSurface::styleSelector() 176 { 177 return static_cast<HTMLCanvasElement*>(this)->document()->styleSelector(); 178 } 179 157 180 } // namespace WebCore -
trunk/WebCore/dom/CanvasSurface.h
r56447 r57020 44 44 class String; 45 45 46 class CSSStyleSelector; 47 class RenderBox; 48 class RenderStyle; 49 class SecurityOrigin; 50 46 51 typedef int ExceptionCode; 47 52 … … 73 78 AffineTransform baseTransform() const; 74 79 80 const SecurityOrigin& securityOrigin() const; 81 RenderBox* renderBox() const; 82 RenderStyle* computedStyle(); 83 CSSStyleSelector* styleSelector(); 84 75 85 protected: 76 86 void setSurfaceSize(const IntSize&); -
trunk/WebCore/html/HTMLCanvasElement.cpp
r56447 r57020 134 134 if (m_context && !m_context->is2d()) 135 135 return 0; 136 if (!m_context) 137 m_context = new CanvasRenderingContext2D(this); 136 if (!m_context) { 137 bool usesDashbardCompatibilityMode = false; 138 #if ENABLE(DASHBOARD_SUPPORT) 139 if (Settings* settings = document()->settings()) 140 usesDashbardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode(); 141 #endif 142 m_context = new CanvasRenderingContext2D(this, document()->inCompatMode(), usesDashbardCompatibilityMode); 143 } 138 144 return m_context.get(); 139 145 } -
trunk/WebCore/html/HTMLCanvasElement.h
r56447 r57020 82 82 CanvasRenderingContext* renderingContext() const { return m_context.get(); } 83 83 84 RenderBox* renderBox() const { return HTMLElement::renderBox(); } 85 RenderStyle* computedStyle() { return HTMLElement::computedStyle(); } 86 84 87 #if ENABLE(3D_CANVAS) 85 88 bool is3D() const; -
trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r56810 r57020 40 40 #include "CSSPropertyNames.h" 41 41 #include "CSSStyleSelector.h" 42 #include "Document.h"43 42 #include "ExceptionCode.h" 44 43 #include "FloatConversion.h" … … 91 90 }; 92 91 93 94 95 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas) 92 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bool usesCSSCompatibilityParseMode, bool usesDashbardCompatibilityMode) 96 93 : CanvasRenderingContext(canvas) 97 94 , m_stateStack(1) 98 { 95 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) 96 #if ENABLE(DASHBOARD_SUPPORT) 97 , m_usesDashbardCompatibilityMode(usesDashbardCompatibilityMode) 98 #endif 99 { 100 #if !ENABLE(DASHBOARD_SUPPORT) 101 ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode); 102 #endif 103 99 104 // Make sure that even if the drawingContext() has a different default 100 105 // thickness, it is in sync with the canvas thickness. … … 637 642 void CanvasRenderingContext2D::clearPathForDashboardBackwardCompatibilityMode() 638 643 { 639 if (Settings* settings = canvas()->document()->settings()) 640 if (settings->usesDashboardBackwardCompatibilityMode()) 641 m_path.clear(); 644 if (m_usesDashbardCompatibilityMode) 645 m_path.clear(); 642 646 } 643 647 #endif … … 942 946 void CanvasRenderingContext2D::checkOrigin(const KURL& url) 943 947 { 944 if (canvas()-> document()->securityOrigin()->taintsCanvas(url))948 if (canvas()->securityOrigin().taintsCanvas(url)) 945 949 canvas()->setOriginTainted(); 946 950 } … … 1162 1166 { 1163 1167 #if ENABLE(DASHBOARD_SUPPORT) 1164 if (Settings* settings = canvas()->document()->settings()) 1165 if (settings->usesDashboardBackwardCompatibilityMode()) 1166 gradient->setDashboardCompatibilityMode(); 1168 if (m_usesDashbardCompatibilityMode) 1169 gradient->setDashboardCompatibilityMode(); 1167 1170 #else 1168 1171 UNUSED_PARAM(gradient); … … 1212 1215 return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true); 1213 1216 1214 bool originClean = !canvas()-> document()->securityOrigin()->taintsCanvas(KURL(KURL(), cachedImage->url())) && cachedImage->image()->hasSingleSecurityOrigin();1217 bool originClean = !canvas()->securityOrigin().taintsCanvas(KURL(KURL(), cachedImage->url())) && cachedImage->image()->hasSingleSecurityOrigin(); 1215 1218 return CanvasPattern::create(cachedImage->image(), repeatX, repeatY, originClean); 1216 1219 } … … 1370 1373 { 1371 1374 RefPtr<CSSMutableStyleDeclaration> tempDecl = CSSMutableStyleDeclaration::create(); 1372 CSSParser parser(! canvas()->document()->inCompatMode()); // Use the parse mode of the canvas' document when parsing CSS.1375 CSSParser parser(!m_usesCSSCompatibilityParseMode); 1373 1376 1374 1377 String declarationText("font: "); … … 1384 1387 // relative to the canvas. 1385 1388 RefPtr<RenderStyle> newStyle = RenderStyle::create(); 1386 if ( canvas()->computedStyle())1387 newStyle->setFontDescription(c anvas()->computedStyle()->fontDescription());1389 if (RenderStyle* computedStyle = canvas()->computedStyle()) 1390 newStyle->setFontDescription(computedStyle->fontDescription()); 1388 1391 1389 1392 // Now map the font property into the style. 1390 CSSStyleSelector* styleSelector = canvas()-> document()->styleSelector();1393 CSSStyleSelector* styleSelector = canvas()->styleSelector(); 1391 1394 styleSelector->applyPropertyToStyle(CSSPropertyFont, tempDecl->getPropertyCSSValue(CSSPropertyFont).get(), newStyle.get()); 1392 1395 … … 1462 1465 // FIXME: Need to turn off font smoothing. 1463 1466 1464 bool rtl = canvas()->computedStyle() ? canvas()->computedStyle()->direction() == RTL : false; 1465 bool override = canvas()->computedStyle() ? canvas()->computedStyle()->unicodeBidi() == Override : false; 1467 RenderStyle* computedStyle = canvas()->computedStyle(); 1468 bool rtl = computedStyle ? computedStyle->direction() == RTL : false; 1469 bool override = computedStyle ? computedStyle->unicodeBidi() == Override : false; 1466 1470 1467 1471 unsigned length = text.length(); -
trunk/WebCore/html/canvas/CanvasRenderingContext2D.h
r54137 r57020 58 58 class CanvasRenderingContext2D : public CanvasRenderingContext { 59 59 public: 60 CanvasRenderingContext2D(HTMLCanvasElement* );60 CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseMode, bool usesDashbardCompatibilityMode); 61 61 62 62 virtual ~CanvasRenderingContext2D(); … … 264 264 265 265 Vector<State, 1> m_stateStack; 266 bool m_usesCSSCompatibilityParseMode; 267 #if ENABLE(DASHBOARD_SUPPORT) 268 bool m_usesDashbardCompatibilityMode; 269 #endif 266 270 }; 267 271 -
trunk/WebCore/html/canvas/WebGLRenderingContext.cpp
r57018 r57020 47 47 #include "WebGLShader.h" 48 48 #include "WebGLUniformLocation.h" 49 #include "HTMLCanvasElement.h"50 #include "HTMLImageElement.h"51 #include "ImageBuffer.h"52 #include "NotImplemented.h"53 #include "RenderBox.h"54 #include "RenderLayer.h"55 49 56 50 #include <wtf/ByteArray.h> … … 109 103 { 110 104 #if USE(ACCELERATED_COMPOSITING) 111 if (canvas()->renderBox() && canvas()->renderBox()->hasLayer() && canvas()->renderBox()->layer()->hasAcceleratedCompositing()) { 112 canvas()->renderBox()->layer()->rendererContentChanged(); 113 } else { 105 RenderBox* renderBox = canvas()->renderBox(); 106 if (renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing()) 107 renderBox->layer()->rendererContentChanged(); 108 else { 114 109 #endif 115 110 if (!m_markedCanvasDirty) { … … 143 138 if (m_needsUpdate) { 144 139 #if USE(ACCELERATED_COMPOSITING) 145 if (canvas()->renderBox() && canvas()->renderBox()->hasLayer()) 146 canvas()->renderBox()->layer()->rendererContentChanged(); 140 RenderBox* renderBox = canvas()->renderBox(); 141 if (renderBox && renderBox->hasLayer()) 142 renderBox->layer()->rendererContentChanged(); 147 143 #endif 148 144 m_needsUpdate = false;
Note: See TracChangeset
for help on using the changeset viewer.