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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.h

Issue 300223009: Implement basic parts of hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: exclude clipping region part Created 6 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) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv ed.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #ifndef CanvasRenderingContext2D_h 26 #ifndef CanvasRenderingContext2D_h
27 #define CanvasRenderingContext2D_h 27 #define CanvasRenderingContext2D_h
28 28
29 #include "bindings/v8/ScriptWrappable.h" 29 #include "bindings/v8/ScriptWrappable.h"
30 #include "core/css/CSSFontSelectorClient.h" 30 #include "core/css/CSSFontSelectorClient.h"
31 #include "core/html/canvas/Canvas2DContextAttributes.h" 31 #include "core/html/canvas/Canvas2DContextAttributes.h"
32 #include "core/html/canvas/CanvasPathMethods.h" 32 #include "core/html/canvas/CanvasPathMethods.h"
33 #include "core/html/canvas/CanvasRenderingContext.h" 33 #include "core/html/canvas/CanvasRenderingContext.h"
34 #include "core/html/canvas/HitRegion.h"
34 #include "core/svg/SVGMatrixTearOff.h" 35 #include "core/svg/SVGMatrixTearOff.h"
35 #include "platform/fonts/Font.h" 36 #include "platform/fonts/Font.h"
36 #include "platform/graphics/Color.h" 37 #include "platform/graphics/Color.h"
37 #include "platform/geometry/FloatSize.h" 38 #include "platform/geometry/FloatSize.h"
38 #include "platform/graphics/GraphicsTypes.h" 39 #include "platform/graphics/GraphicsTypes.h"
39 #include "platform/graphics/ImageBuffer.h" 40 #include "platform/graphics/ImageBuffer.h"
40 #include "platform/graphics/Path.h" 41 #include "platform/graphics/Path.h"
41 #include "platform/transforms/AffineTransform.h" 42 #include "platform/transforms/AffineTransform.h"
42 #include "wtf/HashMap.h" 43 #include "wtf/HashMap.h"
43 #include "wtf/Vector.h" 44 #include "wtf/Vector.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 LineJoin getLineJoin() const { return state().m_lineJoin; } 221 LineJoin getLineJoin() const { return state().m_lineJoin; }
221 222
222 bool imageSmoothingEnabled() const; 223 bool imageSmoothingEnabled() const;
223 void setImageSmoothingEnabled(bool); 224 void setImageSmoothingEnabled(bool);
224 225
225 PassRefPtr<Canvas2DContextAttributes> getContextAttributes() const; 226 PassRefPtr<Canvas2DContextAttributes> getContextAttributes() const;
226 227
227 void drawFocusIfNeeded(Element*); 228 void drawFocusIfNeeded(Element*);
228 void drawFocusIfNeeded(Path2D*, Element*); 229 void drawFocusIfNeeded(Path2D*, Element*);
229 230
231 void addHitRegion(ExceptionState&);
232 void addHitRegion(const Dictionary&, ExceptionState&);
233 void removeHitRegion(const String& id);
234 void clearHitRegions();
235 HitRegion* hitRegionAtPoint(const LayoutPoint&);
236 unsigned hitRegionsCount() const;
237
230 void loseContext(); 238 void loseContext();
231 void restoreContext(); 239 void restoreContext();
232 240
233 virtual void trace(Visitor*) OVERRIDE; 241 virtual void trace(Visitor*) OVERRIDE;
234 242
235 private: 243 private:
236 class State FINAL : public CSSFontSelectorClient { 244 class State FINAL : public CSSFontSelectorClient {
237 public: 245 public:
238 State(); 246 State();
239 virtual ~State(); 247 virtual ~State();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 void inflateStrokeRect(FloatRect&) const; 334 void inflateStrokeRect(FloatRect&) const;
327 335
328 template<class T> void fullCanvasCompositedFill(const T&); 336 template<class T> void fullCanvasCompositedFill(const T&);
329 template<class T> void fullCanvasCompositedStroke(const T&); 337 template<class T> void fullCanvasCompositedStroke(const T&);
330 template<class T> void fullCanvasCompositedDrawImage(T*, const FloatRect&, c onst FloatRect&, CompositeOperator); 338 template<class T> void fullCanvasCompositedDrawImage(T*, const FloatRect&, c onst FloatRect&, CompositeOperator);
331 339
332 void drawFocusIfNeededInternal(const Path&, Element*); 340 void drawFocusIfNeededInternal(const Path&, Element*);
333 bool focusRingCallIsValid(const Path&, Element*); 341 bool focusRingCallIsValid(const Path&, Element*);
334 void drawFocusRing(const Path&); 342 void drawFocusRing(const Path&);
335 343
344 void addHitRegionInternal(const HitRegionOptions&, ExceptionState&);
345
336 void validateStateStack(); 346 void validateStateStack();
337 347
338 virtual bool is2d() const OVERRIDE { return true; } 348 virtual bool is2d() const OVERRIDE { return true; }
339 virtual bool isAccelerated() const OVERRIDE; 349 virtual bool isAccelerated() const OVERRIDE;
340 virtual bool hasAlpha() const OVERRIDE { return m_hasAlpha; } 350 virtual bool hasAlpha() const OVERRIDE { return m_hasAlpha; }
341 351
342 virtual bool isTransformInvertible() const OVERRIDE { return state().m_inver tibleCTM; } 352 virtual bool isTransformInvertible() const OVERRIDE { return state().m_inver tibleCTM; }
343 353
344 virtual blink::WebLayer* platformLayer() const OVERRIDE; 354 virtual blink::WebLayer* platformLayer() const OVERRIDE;
345 355
346 WillBeHeapVector<OwnPtrWillBeMember<State> > m_stateStack; 356 WillBeHeapVector<OwnPtrWillBeMember<State> > m_stateStack;
357 OwnPtrWillBeMember<HitRegionManager> m_hitRegionManager;
347 bool m_usesCSSCompatibilityParseMode; 358 bool m_usesCSSCompatibilityParseMode;
348 bool m_hasAlpha; 359 bool m_hasAlpha;
349 bool m_isContextLost; 360 bool m_isContextLost;
350 bool m_contextRestorable; 361 bool m_contextRestorable;
351 Canvas2DContextStorage m_storageMode; 362 Canvas2DContextStorage m_storageMode;
352 MutableStylePropertyMap m_fetchedFonts; 363 MutableStylePropertyMap m_fetchedFonts;
353 unsigned m_tryRestoreContextAttemptCount; 364 unsigned m_tryRestoreContextAttemptCount;
354 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; 365 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer;
355 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; 366 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer;
356 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; 367 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer;
357 }; 368 };
358 369
359 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con text->is2d(), context.is2d()); 370 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con text->is2d(), context.is2d());
360 371
361 } // namespace WebCore 372 } // namespace WebCore
362 373
363 #endif 374 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698