| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 mapAbsoluteToLocalPoint(mode, transformState); | 2033 mapAbsoluteToLocalPoint(mode, transformState); |
| 2034 transformState.flatten(); | 2034 transformState.flatten(); |
| 2035 return transformState.lastPlanarQuad(); | 2035 return transformState.lastPlanarQuad(); |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 void LayoutObject::mapLocalToContainer(const LayoutBoxModelObject* paintInvalida
tionContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* w
asFixed, const PaintInvalidationState* paintInvalidationState) const | 2038 void LayoutObject::mapLocalToContainer(const LayoutBoxModelObject* paintInvalida
tionContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* w
asFixed, const PaintInvalidationState* paintInvalidationState) const |
| 2039 { | 2039 { |
| 2040 if (paintInvalidationContainer == this) | 2040 if (paintInvalidationContainer == this) |
| 2041 return; | 2041 return; |
| 2042 | 2042 |
| 2043 LayoutObject* o = parent(); | 2043 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
| 2044 LayoutSize offset = paintInvalidationState->paintOffset(); |
| 2045 if (isBox()) |
| 2046 offset += toLayoutBox(this)->locationOffset(); |
| 2047 if (!isText() && style()->hasInFlowPosition() && hasLayer()) |
| 2048 offset += toLayoutBoxModelObject(this)->layer()->offsetForInFlowPosi
tion(); |
| 2049 transformState.move(offset); |
| 2050 return; |
| 2051 } |
| 2052 |
| 2053 bool containerSkipped; |
| 2054 LayoutObject* o = container(paintInvalidationContainer, &containerSkipped); |
| 2044 if (!o) | 2055 if (!o) |
| 2045 return; | 2056 return; |
| 2046 | 2057 |
| 2047 // FIXME: this should call offsetFromContainer to share code, but I'm not su
re it's ever called. | 2058 if (isBox()) { |
| 2048 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint()); | 2059 bool isFixedPos = style()->position() == FixedPosition; |
| 2049 if (mode & ApplyContainerFlip && o->isBox()) { | 2060 bool hasTransform = hasLayer() && toLayoutBox(this)->layer()->transform(
); |
| 2050 if (o->style()->isFlippedBlocksWritingMode()) | 2061 // If this box has a transform, it acts as a fixed position container fo
r fixed descendants, |
| 2051 transformState.move(toLayoutBox(o)->flipForWritingMode(roundedLayout
Point(transformState.mappedPoint())) - centerPoint); | 2062 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. |
| 2063 if (hasTransform && !isFixedPos) |
| 2064 mode &= ~IsFixed; |
| 2065 else if (isFixedPos) |
| 2066 mode |= IsFixed; |
| 2067 |
| 2068 if (wasFixed) |
| 2069 *wasFixed = mode & IsFixed; |
| 2070 |
| 2071 mode &= ~ApplyContainerFlip; |
| 2072 paintInvalidationState = nullptr; |
| 2073 } else if (mode & ApplyContainerFlip && o->isBox()) { |
| 2074 if (o->style()->isFlippedBlocksWritingMode()) { |
| 2075 IntPoint centerPoint = roundedIntPoint(transformState.mappedPoint())
; |
| 2076 transformState.move(toLayoutBox(o)->flipForWritingMode(LayoutPoint(c
enterPoint)) - centerPoint); |
| 2077 } |
| 2052 mode &= ~ApplyContainerFlip; | 2078 mode &= ~ApplyContainerFlip; |
| 2053 } | 2079 } |
| 2054 | 2080 |
| 2055 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped
Point()))); | 2081 LayoutSize containerOffset = offsetFromContainer(o); |
| 2082 containerOffset += o->columnOffset(roundedLayoutPoint(transformState.mappedP
oint()) + containerOffset); |
| 2056 | 2083 |
| 2057 if (o->hasOverflowClip()) | 2084 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || (!is
Text() && style()->preserves3D())); |
| 2058 transformState.move(-toLayoutBox(o)->scrolledContentOffset()); | 2085 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { |
| 2086 TransformationMatrix t; |
| 2087 getTransformFromContainer(o, containerOffset, t); |
| 2088 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate
Transform : TransformState::FlattenTransform); |
| 2089 } else { |
| 2090 transformState.move(containerOffset.width(), containerOffset.height(), p
reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo
rm); |
| 2091 } |
| 2092 |
| 2093 if (containerSkipped) { |
| 2094 // There can't be a transform between paintInvalidationContainer and o,
because transforms create containers, so it should be safe |
| 2095 // to just subtract the delta between the paintInvalidationContainer and
o. |
| 2096 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); |
| 2097 transformState.move(-containerOffset.width(), -containerOffset.height(),
preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans
form); |
| 2098 return; |
| 2099 } |
| 2059 | 2100 |
| 2060 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was
Fixed, paintInvalidationState); | 2101 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was
Fixed, paintInvalidationState); |
| 2061 } | 2102 } |
| 2062 | 2103 |
| 2063 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj
ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const | 2104 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj
ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const |
| 2064 { | 2105 { |
| 2065 ASSERT_NOT_REACHED(); | 2106 ASSERT_NOT_REACHED(); |
| 2066 return nullptr; | 2107 return nullptr; |
| 2067 } | 2108 } |
| 2068 | 2109 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 perspectiveMatrix.applyPerspective(containerObject->style()->perspective
()); | 2141 perspectiveMatrix.applyPerspective(containerObject->style()->perspective
()); |
| 2101 | 2142 |
| 2102 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(
), 0); | 2143 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(
), 0); |
| 2103 transform = perspectiveMatrix * transform; | 2144 transform = perspectiveMatrix * transform; |
| 2104 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(),
0); | 2145 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(),
0); |
| 2105 } | 2146 } |
| 2106 } | 2147 } |
| 2107 | 2148 |
| 2108 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const L
ayoutBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, bool*
wasFixed) const | 2149 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const L
ayoutBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, bool*
wasFixed) const |
| 2109 { | 2150 { |
| 2110 // Track the point at the center of the quad's bounding box. As mapLocalToCo
ntainer() calls offsetFromContainer(), | 2151 // Track the point at the center of the quad's bounding box. mapLocalToConta
iner() will use |
| 2111 // it will use that point as the reference point to decide which column's tr
ansform to apply in multiple-column blocks. | 2152 // that point as the reference point to decide which column we're in for mul
tiple-column blocks. |
| 2112 TransformState transformState(TransformState::ApplyTransformDirection, local
Quad.boundingBox().center(), localQuad); | 2153 TransformState transformState(TransformState::ApplyTransformDirection, local
Quad.boundingBox().center(), localQuad); |
| 2113 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply
ContainerFlip | UseTransforms, wasFixed); | 2154 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply
ContainerFlip | UseTransforms, wasFixed); |
| 2114 transformState.flatten(); | 2155 transformState.flatten(); |
| 2115 | 2156 |
| 2116 return transformState.lastPlanarQuad(); | 2157 return transformState.lastPlanarQuad(); |
| 2117 } | 2158 } |
| 2118 | 2159 |
| 2119 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con
st LayoutBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, b
ool* wasFixed, const PaintInvalidationState* paintInvalidationState) const | 2160 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con
st LayoutBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, b
ool* wasFixed, const PaintInvalidationState* paintInvalidationState) const |
| 2120 { | 2161 { |
| 2121 TransformState transformState(TransformState::ApplyTransformDirection, local
Point); | 2162 TransformState transformState(TransformState::ApplyTransformDirection, local
Point); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2136 | 2177 |
| 2137 // A layoutObject can have no invalidation backing if it is from a detached
frame, | 2178 // A layoutObject can have no invalidation backing if it is from a detached
frame, |
| 2138 // or when forced compositing is disabled. | 2179 // or when forced compositing is disabled. |
| 2139 if (paintInvalidationContainer.layer()->compositingState() == NotComposited) | 2180 if (paintInvalidationContainer.layer()->compositingState() == NotComposited) |
| 2140 return containerPoint; | 2181 return containerPoint; |
| 2141 | 2182 |
| 2142 DeprecatedPaintLayer::mapPointToPaintBackingCoordinates(&paintInvalidationCo
ntainer, containerPoint); | 2183 DeprecatedPaintLayer::mapPointToPaintBackingCoordinates(&paintInvalidationCo
ntainer, containerPoint); |
| 2143 return containerPoint; | 2184 return containerPoint; |
| 2144 } | 2185 } |
| 2145 | 2186 |
| 2146 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout
Point& point, bool* offsetDependsOnPoint) const | 2187 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const |
| 2147 { | 2188 { |
| 2148 ASSERT(o == container()); | 2189 ASSERT(o == container()); |
| 2149 | |
| 2150 LayoutSize offset = o->columnOffset(point); | |
| 2151 | |
| 2152 if (o->hasOverflowClip()) | 2190 if (o->hasOverflowClip()) |
| 2153 offset -= toLayoutBox(o)->scrolledContentOffset(); | 2191 return LayoutSize(-toLayoutBox(o)->scrolledContentOffset()); |
| 2154 | 2192 return LayoutSize(); |
| 2155 if (offsetDependsOnPoint) | |
| 2156 *offsetDependsOnPoint = o->isLayoutFlowThread(); | |
| 2157 | |
| 2158 return offset; | |
| 2159 } | 2193 } |
| 2160 | 2194 |
| 2161 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* contain
er) const | 2195 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* contain
er) const |
| 2162 { | 2196 { |
| 2163 if (container == this) | 2197 if (container == this) |
| 2164 return LayoutSize(); | 2198 return LayoutSize(); |
| 2165 | 2199 |
| 2166 LayoutSize offset; | 2200 LayoutSize offset; |
| 2167 LayoutPoint referencePoint; | 2201 LayoutPoint referencePoint; |
| 2168 const LayoutObject* currContainer = this; | 2202 const LayoutObject* currContainer = this; |
| 2169 do { | 2203 do { |
| 2170 const LayoutObject* nextContainer = currContainer->container(); | 2204 const LayoutObject* nextContainer = currContainer->container(); |
| 2171 ASSERT(nextContainer); // This means we reached the top without finding
container. | 2205 ASSERT(nextContainer); // This means we reached the top without finding
container. |
| 2172 if (!nextContainer) | 2206 if (!nextContainer) |
| 2173 break; | 2207 break; |
| 2174 ASSERT(!currContainer->hasTransformRelatedProperty()); | 2208 ASSERT(!currContainer->hasTransformRelatedProperty()); |
| 2175 LayoutSize currentOffset = currContainer->offsetFromContainer(nextContai
ner, referencePoint); | 2209 LayoutSize currentOffset = currContainer->offsetFromContainer(nextContai
ner); |
| 2210 currentOffset += container->columnOffset(referencePoint + currentOffset)
; |
| 2176 offset += currentOffset; | 2211 offset += currentOffset; |
| 2177 referencePoint.move(currentOffset); | 2212 referencePoint.move(currentOffset); |
| 2178 currContainer = nextContainer; | 2213 currContainer = nextContainer; |
| 2179 } while (currContainer != container); | 2214 } while (currContainer != container); |
| 2180 | 2215 |
| 2181 return offset; | 2216 return offset; |
| 2182 } | 2217 } |
| 2183 | 2218 |
| 2184 LayoutRect LayoutObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
oEndOfLine) | 2219 LayoutRect LayoutObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
oEndOfLine) |
| 2185 { | 2220 { |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3254 const blink::LayoutObject* root = object1; | 3289 const blink::LayoutObject* root = object1; |
| 3255 while (root->parent()) | 3290 while (root->parent()) |
| 3256 root = root->parent(); | 3291 root = root->parent(); |
| 3257 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3292 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3258 } else { | 3293 } else { |
| 3259 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); | 3294 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); |
| 3260 } | 3295 } |
| 3261 } | 3296 } |
| 3262 | 3297 |
| 3263 #endif | 3298 #endif |
| OLD | NEW |