OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
8 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
10 * | 10 * |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 */ | 31 */ |
32 | 32 |
33 #include "config.h" | 33 #include "config.h" |
34 #include "core/html/canvas/CanvasRenderingContext2D.h" | 34 #include "core/html/canvas/CanvasRenderingContext2D.h" |
35 | 35 |
36 #include "CSSPropertyNames.h" | 36 #include "CSSPropertyNames.h" |
37 #include "core/accessibility/AXObjectCache.h" | |
37 #include "core/css/CSSFontSelector.h" | 38 #include "core/css/CSSFontSelector.h" |
38 #include "core/css/CSSParser.h" | 39 #include "core/css/CSSParser.h" |
39 #include "core/css/StylePropertySet.h" | 40 #include "core/css/StylePropertySet.h" |
40 #include "core/css/resolver/StyleResolver.h" | 41 #include "core/css/resolver/StyleResolver.h" |
41 #include "core/dom/ExceptionCode.h" | 42 #include "core/dom/ExceptionCode.h" |
42 #include "core/dom/ExceptionCodePlaceholder.h" | 43 #include "core/dom/ExceptionCodePlaceholder.h" |
43 #include "core/html/HTMLCanvasElement.h" | 44 #include "core/html/HTMLCanvasElement.h" |
44 #include "core/html/HTMLImageElement.h" | 45 #include "core/html/HTMLImageElement.h" |
45 #include "core/html/HTMLMediaElement.h" | 46 #include "core/html/HTMLMediaElement.h" |
46 #include "core/html/HTMLVideoElement.h" | 47 #include "core/html/HTMLVideoElement.h" |
47 #include "core/html/ImageData.h" | 48 #include "core/html/ImageData.h" |
48 #include "core/html/TextMetrics.h" | 49 #include "core/html/TextMetrics.h" |
49 #include "core/html/canvas/Canvas2DContextAttributes.h" | 50 #include "core/html/canvas/Canvas2DContextAttributes.h" |
50 #include "core/html/canvas/CanvasGradient.h" | 51 #include "core/html/canvas/CanvasGradient.h" |
51 #include "core/html/canvas/CanvasPattern.h" | 52 #include "core/html/canvas/CanvasPattern.h" |
52 #include "core/html/canvas/CanvasStyle.h" | 53 #include "core/html/canvas/CanvasStyle.h" |
53 #include "core/html/canvas/DOMPath.h" | 54 #include "core/html/canvas/DOMPath.h" |
54 #include "core/loader/cache/CachedImage.h" | 55 #include "core/loader/cache/CachedImage.h" |
55 #include "core/page/ImageBitmap.h" | 56 #include "core/page/ImageBitmap.h" |
56 #include "core/platform/graphics/DrawLooper.h" | 57 #include "core/platform/graphics/DrawLooper.h" |
57 #include "core/platform/graphics/FloatQuad.h" | 58 #include "core/platform/graphics/FloatQuad.h" |
58 #include "core/platform/graphics/FontCache.h" | 59 #include "core/platform/graphics/FontCache.h" |
59 #include "core/platform/graphics/GraphicsContextStateSaver.h" | 60 #include "core/platform/graphics/GraphicsContextStateSaver.h" |
60 #include "core/platform/graphics/TextRun.h" | 61 #include "core/platform/graphics/TextRun.h" |
61 #include "core/platform/graphics/transforms/AffineTransform.h" | 62 #include "core/platform/graphics/transforms/AffineTransform.h" |
62 #include "core/rendering/RenderLayer.h" | 63 #include "core/rendering/RenderLayer.h" |
64 #include "core/rendering/RenderTheme.h" | |
63 #include "weborigin/SecurityOrigin.h" | 65 #include "weborigin/SecurityOrigin.h" |
64 | 66 |
65 #include "wtf/CheckedArithmetic.h" | 67 #include "wtf/CheckedArithmetic.h" |
66 #include "wtf/MathExtras.h" | 68 #include "wtf/MathExtras.h" |
67 #include "wtf/OwnPtr.h" | 69 #include "wtf/OwnPtr.h" |
68 #include "wtf/Uint8ClampedArray.h" | 70 #include "wtf/Uint8ClampedArray.h" |
69 #include "wtf/text/StringBuilder.h" | 71 #include "wtf/text/StringBuilder.h" |
70 | 72 |
71 using namespace std; | 73 using namespace std; |
72 | 74 |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2330 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone); | 2332 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone); |
2331 } | 2333 } |
2332 | 2334 |
2333 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const | 2335 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const |
2334 { | 2336 { |
2335 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); | 2337 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); |
2336 attributes->setAlpha(m_hasAlpha); | 2338 attributes->setAlpha(m_hasAlpha); |
2337 return attributes.release(); | 2339 return attributes.release(); |
2338 } | 2340 } |
2339 | 2341 |
2342 void CanvasRenderingContext2D::drawSystemFocusRing(Element* element) | |
2343 { | |
2344 drawFocusRing(m_path, element, false); | |
2345 } | |
2346 | |
2347 bool CanvasRenderingContext2D::drawCustomFocusRing(Element* element) | |
2348 { | |
2349 drawFocusRing(m_path, element, true); | |
2350 // Blink doesn't draw a custom focus ring; we always return false to inform the web app it should draw it. | |
2351 return false; | |
2352 } | |
2353 | |
2354 void CanvasRenderingContext2D::drawFocusRing(const Path& path, Element* element, bool custom) | |
2355 { | |
2356 GraphicsContext* c = drawingContext(); | |
2357 if (!c) | |
2358 return; | |
2359 if (!state().m_invertibleCTM) | |
2360 return; | |
2361 if (path.isEmpty()) | |
2362 return; | |
2363 FloatRect boundingRect = path.boundingRect(); | |
2364 | |
2365 // If accessibility is enabled, associate this bounding box with the element . | |
2366 if (AXObjectCache* axObjectCache = element->document()->existingAXObjectCach e()) { | |
2367 if (AccessibilityObject* obj = axObjectCache->getOrCreate(element)) { | |
2368 IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect() ; | |
2369 LayoutRect rect = LayoutRect(boundingRect); | |
2370 rect.moveBy(canvasRect.location()); | |
2371 obj->setElementRect(rect); | |
2372 } | |
2373 } | |
2374 | |
2375 // Only draw if the element is focused and if the function called wasn't dra wCustomFocusRing. | |
2376 if (custom || !element->focused()) | |
2377 return; | |
2378 | |
2379 c->save(); | |
2380 c->setAlpha(1.0); | |
2381 c->clearShadow(); | |
2382 c->setCompositeOperation(CompositeSourceOver, BlendModeNormal); | |
2383 | |
2384 RefPtr<RenderStyle> style(RenderStyle::createDefaultStyle()); | |
2385 Color focusRingColor = RenderTheme::focusRingColor(); | |
2386 Vector<IntRect> rects; | |
2387 rects.append(pixelSnappedIntRect(LayoutRect(boundingRect))); | |
2388 c->drawFocusRing(rects, style->outlineWidth(), style->outlineOffset(), focus RingColor); | |
jbroman
2013/07/29 17:25:08
Why not draw the path itself? GraphicsContext::dra
Rik
2013/07/29 20:10:00
I'm unsure this is true. The spec is confusing her
dmazzoni
2013/07/29 21:44:21
It's unclear to me too.
Since this is behind a fl
| |
2389 | |
2390 c->restore(); | |
2391 didDraw(boundingRect); | |
2392 } | |
2393 | |
2340 } // namespace WebCore | 2394 } // namespace WebCore |
OLD | NEW |