| OLD | NEW |
| 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 * | 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/rendering/RenderHTMLCanvas.h" | 27 #include "core/rendering/RenderHTMLCanvas.h" |
| 28 | 28 |
| 29 #include "core/frame/FrameView.h" |
| 30 #include "core/frame/LocalFrame.h" |
| 29 #include "core/html/HTMLCanvasElement.h" | 31 #include "core/html/HTMLCanvasElement.h" |
| 30 #include "core/html/canvas/CanvasRenderingContext.h" | 32 #include "core/html/canvas/CanvasRenderingContext.h" |
| 31 #include "core/frame/FrameView.h" | 33 #include "core/html/canvas/CanvasRenderingContext2D.h" |
| 32 #include "core/frame/LocalFrame.h" | |
| 33 #include "core/page/Page.h" | 34 #include "core/page/Page.h" |
| 35 #include "core/rendering/HitTestLocation.h" |
| 34 #include "core/rendering/PaintInfo.h" | 36 #include "core/rendering/PaintInfo.h" |
| 35 #include "core/rendering/RenderView.h" | 37 #include "core/rendering/RenderView.h" |
| 36 | 38 |
| 37 namespace WebCore { | 39 namespace WebCore { |
| 38 | 40 |
| 39 using namespace HTMLNames; | 41 using namespace HTMLNames; |
| 40 | 42 |
| 41 RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement* element) | 43 RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement* element) |
| 42 : RenderReplaced(element, element->size()) | 44 : RenderReplaced(element, element->size()) |
| 43 { | 45 { |
| 44 view()->frameView()->setIsVisuallyNonEmpty(); | 46 view()->frameView()->setIsVisuallyNonEmpty(); |
| 45 } | 47 } |
| 46 | 48 |
| 47 LayerType RenderHTMLCanvas::layerTypeRequired() const | 49 LayerType RenderHTMLCanvas::layerTypeRequired() const |
| 48 { | 50 { |
| 49 return NormalLayer; | 51 return NormalLayer; |
| 50 } | 52 } |
| 51 | 53 |
| 54 bool RenderHTMLCanvas::nodeAtPoint(const HitTestRequest& request, HitTestResult&
result, const HitTestLocation& locationInContainer, const LayoutPoint& accumula
tedOffset, HitTestAction hitTestAction) |
| 55 { |
| 56 if (!RenderReplaced::nodeAtPoint(request, result, locationInContainer, accum
ulatedOffset, hitTestAction)) |
| 57 return false; |
| 58 |
| 59 if (!visibleToHitTestRequest(request) || hitTestAction != HitTestForeground) |
| 60 return true; |
| 61 |
| 62 HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); |
| 63 // Thread/plumb through HTMLCanvasElement instead? |
| 64 if (!canvas->renderingContext() || !canvas->renderingContext()->is2d()) |
| 65 return true; |
| 66 |
| 67 // Check for intersections with hit regions. |
| 68 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
| 69 LayoutPoint localPoint = locationInContainer.point() - toLayoutSize(adjusted
Location); |
| 70 if (CanvasHitRegion* hitRegion = toCanvasRenderingContext2D(canvas->renderin
gContext())->hitRegionAtPoint(localPoint)) { |
| 71 hitRegion = hitRegion; |
| 72 updateHitTestResult(result, localPoint); |
| 73 } |
| 74 return true; |
| 75 } |
| 76 |
| 52 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) | 77 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) |
| 53 { | 78 { |
| 54 GraphicsContext* context = paintInfo.context; | 79 GraphicsContext* context = paintInfo.context; |
| 55 | 80 |
| 56 LayoutRect contentRect = contentBoxRect(); | 81 LayoutRect contentRect = contentBoxRect(); |
| 57 contentRect.moveBy(paintOffset); | 82 contentRect.moveBy(paintOffset); |
| 58 LayoutRect paintRect = replacedContentRect(); | 83 LayoutRect paintRect = replacedContentRect(); |
| 59 paintRect.moveBy(paintOffset); | 84 paintRect.moveBy(paintOffset); |
| 60 | 85 |
| 61 bool clip = !contentRect.contains(paintRect); | 86 bool clip = !contentRect.contains(paintRect); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return CompositingReasonNone; | 134 return CompositingReasonNone; |
| 110 | 135 |
| 111 HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); | 136 HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); |
| 112 if (canvas->renderingContext() && canvas->renderingContext()->isAccelerated(
)) | 137 if (canvas->renderingContext() && canvas->renderingContext()->isAccelerated(
)) |
| 113 return CompositingReasonCanvas; | 138 return CompositingReasonCanvas; |
| 114 | 139 |
| 115 return CompositingReasonNone; | 140 return CompositingReasonNone; |
| 116 } | 141 } |
| 117 | 142 |
| 118 } // namespace WebCore | 143 } // namespace WebCore |
| OLD | NEW |