OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
3 * Copyright (C) 2009 Google, Inc. | 3 * Copyright (C) 2009 Google, Inc. |
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 LayoutSVGForeignObject::LayoutSVGForeignObject(SVGForeignObjectElement* node) | 32 LayoutSVGForeignObject::LayoutSVGForeignObject(SVGForeignObjectElement* node) |
33 : LayoutSVGBlock(node), m_needsTransformUpdate(true) {} | 33 : LayoutSVGBlock(node), m_needsTransformUpdate(true) {} |
34 | 34 |
35 LayoutSVGForeignObject::~LayoutSVGForeignObject() {} | 35 LayoutSVGForeignObject::~LayoutSVGForeignObject() {} |
36 | 36 |
37 bool LayoutSVGForeignObject::isChildAllowed(LayoutObject* child, | 37 bool LayoutSVGForeignObject::isChildAllowed(LayoutObject* child, |
38 const ComputedStyle& style) const { | 38 const ComputedStyle& style) const { |
39 // Disallow arbitary SVG content. Only allow proper <svg xmlns="svgNS"> subdoc
uments. | 39 // Disallow arbitary SVG content. Only allow proper <svg xmlns="svgNS"> |
| 40 // subdocuments. |
40 return !child->isSVG() || child->isSVGRoot(); | 41 return !child->isSVG() || child->isSVGRoot(); |
41 } | 42 } |
42 | 43 |
43 void LayoutSVGForeignObject::paint(const PaintInfo& paintInfo, | 44 void LayoutSVGForeignObject::paint(const PaintInfo& paintInfo, |
44 const LayoutPoint&) const { | 45 const LayoutPoint&) const { |
45 SVGForeignObjectPainter(*this).paint(paintInfo); | 46 SVGForeignObjectPainter(*this).paint(paintInfo); |
46 } | 47 } |
47 | 48 |
48 const AffineTransform& LayoutSVGForeignObject::localToSVGParentTransform() | 49 const AffineTransform& LayoutSVGForeignObject::localToSVGParentTransform() |
49 const { | 50 const { |
50 m_localToParentTransform = localSVGTransform(); | 51 m_localToParentTransform = localSVGTransform(); |
51 m_localToParentTransform.translate(m_viewport.x(), m_viewport.y()); | 52 m_localToParentTransform.translate(m_viewport.x(), m_viewport.y()); |
52 return m_localToParentTransform; | 53 return m_localToParentTransform; |
53 } | 54 } |
54 | 55 |
55 void LayoutSVGForeignObject::updateLogicalWidth() { | 56 void LayoutSVGForeignObject::updateLogicalWidth() { |
56 // FIXME: Investigate in size rounding issues | 57 // FIXME: Investigate in size rounding issues |
57 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63
656 | 58 // FIXME: Remove unnecessary rounding when layout is off ints: |
| 59 // webkit.org/b/63656 |
58 setWidth(LayoutUnit(static_cast<int>(roundf(m_viewport.width())))); | 60 setWidth(LayoutUnit(static_cast<int>(roundf(m_viewport.width())))); |
59 } | 61 } |
60 | 62 |
61 void LayoutSVGForeignObject::computeLogicalHeight( | 63 void LayoutSVGForeignObject::computeLogicalHeight( |
62 LayoutUnit, | 64 LayoutUnit, |
63 LayoutUnit logicalTop, | 65 LayoutUnit logicalTop, |
64 LogicalExtentComputedValues& computedValues) const { | 66 LogicalExtentComputedValues& computedValues) const { |
65 // FIXME: Investigate in size rounding issues | 67 // FIXME: Investigate in size rounding issues |
66 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63
656 | 68 // FIXME: Remove unnecessary rounding when layout is off ints: |
| 69 // webkit.org/b/63656 |
67 // FIXME: Is this correct for vertical writing mode? | 70 // FIXME: Is this correct for vertical writing mode? |
68 computedValues.m_extent = | 71 computedValues.m_extent = |
69 LayoutUnit(static_cast<int>(roundf(m_viewport.height()))); | 72 LayoutUnit(static_cast<int>(roundf(m_viewport.height()))); |
70 computedValues.m_position = logicalTop; | 73 computedValues.m_position = logicalTop; |
71 } | 74 } |
72 | 75 |
73 void LayoutSVGForeignObject::layout() { | 76 void LayoutSVGForeignObject::layout() { |
74 ASSERT(needsLayout()); | 77 ASSERT(needsLayout()); |
75 | 78 |
76 SVGForeignObjectElement* foreign = toSVGForeignObjectElement(node()); | 79 SVGForeignObjectElement* foreign = toSVGForeignObjectElement(node()); |
(...skipping 16 matching lines...) Expand all Loading... |
93 SVGLengthMode::Height)); | 96 SVGLengthMode::Height)); |
94 m_viewport = FloatRect( | 97 m_viewport = FloatRect( |
95 viewportLocation, | 98 viewportLocation, |
96 FloatSize(lengthContext.valueForLength(styleRef().width(), styleRef(), | 99 FloatSize(lengthContext.valueForLength(styleRef().width(), styleRef(), |
97 SVGLengthMode::Width), | 100 SVGLengthMode::Width), |
98 lengthContext.valueForLength(styleRef().height(), styleRef(), | 101 lengthContext.valueForLength(styleRef().height(), styleRef(), |
99 SVGLengthMode::Height))); | 102 SVGLengthMode::Height))); |
100 if (!updateCachedBoundariesInParents) | 103 if (!updateCachedBoundariesInParents) |
101 updateCachedBoundariesInParents = oldViewport != m_viewport; | 104 updateCachedBoundariesInParents = oldViewport != m_viewport; |
102 | 105 |
103 // Set box origin to the foreignObject x/y translation, so positioned objects
in XHTML content get correct | 106 // Set box origin to the foreignObject x/y translation, so positioned objects |
104 // positions. A regular LayoutBoxModelObject would pull this information from
ComputedStyle - in SVG those | 107 // in XHTML content get correct positions. A regular LayoutBoxModelObject |
105 // properties are ignored for non <svg> elements, so we mimic what happens whe
n specifying them through CSS. | 108 // would pull this information from ComputedStyle - in SVG those properties |
| 109 // are ignored for non <svg> elements, so we mimic what happens when |
| 110 // specifying them through CSS. |
106 | 111 |
107 // FIXME: Investigate in location rounding issues - only affects LayoutSVGFore
ignObject & LayoutSVGText | 112 // FIXME: Investigate in location rounding issues - only affects |
| 113 // LayoutSVGForeignObject & LayoutSVGText |
108 setLocation(roundedIntPoint(viewportLocation)); | 114 setLocation(roundedIntPoint(viewportLocation)); |
109 | 115 |
110 bool layoutChanged = everHadLayout() && selfNeedsLayout(); | 116 bool layoutChanged = everHadLayout() && selfNeedsLayout(); |
111 LayoutBlock::layout(); | 117 LayoutBlock::layout(); |
112 ASSERT(!needsLayout()); | 118 ASSERT(!needsLayout()); |
113 | 119 |
114 // If our bounds changed, notify the parents. | 120 // If our bounds changed, notify the parents. |
115 if (updateCachedBoundariesInParents) | 121 if (updateCachedBoundariesInParents) |
116 LayoutSVGBlock::setNeedsBoundariesUpdate(); | 122 LayoutSVGBlock::setNeedsBoundariesUpdate(); |
117 | 123 |
(...skipping 24 matching lines...) Expand all Loading... |
142 HitTestLocation hitTestLocation(localPoint); | 148 HitTestLocation hitTestLocation(localPoint); |
143 return LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), | 149 return LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), |
144 HitTestForeground) || | 150 HitTestForeground) || |
145 LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), | 151 LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), |
146 HitTestFloat) || | 152 HitTestFloat) || |
147 LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), | 153 LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), |
148 HitTestChildBlockBackgrounds); | 154 HitTestChildBlockBackgrounds); |
149 } | 155 } |
150 | 156 |
151 } // namespace blink | 157 } // namespace blink |
OLD | NEW |