2009-02-24 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Feb 2009 02:50:28 +0000 (02:50 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Feb 2009 02:50:28 +0000 (02:50 +0000)
        Reviewed by Dave Hyatt

        https://bugs.webkit.org/show_bug.cgi?id=24137

        Fix localToAbsolute() and absoluteToLocal() to map points through 3d transforms,
        taking perspective and transform-style: preserve-3d into account.

        In order to support transform-style: preserve-3d, which keeps elements in a
        3d space, we have to carry along an accumulated matrix in TransformState.
        We also need to apply the perspective from the parent, if any, with the
        appropriate origin.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41208 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.base.exp
WebCore/WebCore.pro
WebCore/WebCore.scons
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/platform/graphics/transforms/TransformationMatrix.cpp
WebCore/platform/graphics/transforms/TransformationMatrix.h
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderBox.h
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderLayerBacking.cpp
WebCore/rendering/RenderLayerCompositor.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderTableCell.cpp
WebCore/rendering/RenderTableCell.h
WebCore/rendering/RenderView.cpp
WebCore/rendering/RenderView.h
WebCore/rendering/TransformState.cpp [new file with mode: 0644]
WebCore/rendering/TransformState.h [new file with mode: 0644]
WebCore/rendering/style/RenderStyle.h

index b73379b94b7d95863f4c6e658c00d35ef90b70a1..6090e87dd7921a561de36a0c5a4c1947786b421c 100644 (file)
@@ -1,3 +1,70 @@
+2009-02-24  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dave Hyatt
+
+        https://bugs.webkit.org/show_bug.cgi?id=24137
+        
+        Fix localToAbsolute() and absoluteToLocal() to map points through 3d transforms,
+        taking perspective and transform-style: preserve-3d into account.
+        
+        In order to support transform-style: preserve-3d, which keeps elements in a
+        3d space, we have to carry along an accumulated matrix in TransformState.
+        We also need to apply the perspective from the parent, if any, with the
+        appropriate origin.
+
+        * GNUmakefile.am:
+        * WebCore.base.exp:
+        * WebCore.pro:
+        * WebCore.scons:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * platform/graphics/transforms/TransformationMatrix.cpp:
+        (WebCore::TransformationMatrix::translate):
+        (WebCore::TransformationMatrix::translate3d):
+        (WebCore::TransformationMatrix::translateRight3d):
+        * platform/graphics/transforms/TransformationMatrix.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::mapLocalToAbsolutePoint):
+        (WebCore::RenderBox::mapAbsoluteToLocalPoint):
+        * rendering/RenderBox.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateTransform):
+        (WebCore::RenderLayer::perspectiveTransform):
+        (WebCore::RenderLayer::perspectiveOrigin):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::requiresCompositingLayerForTransform):
+        (WebCore::RenderLayerCompositor::layerHas3DContent):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::localToAbsolute):
+        (WebCore::RenderObject::absoluteToLocal):
+        (WebCore::RenderObject::mapLocalToAbsolutePoint):
+        (WebCore::RenderObject::mapAbsoluteToLocalPoint):
+        * rendering/RenderObject.h:
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::mapLocalToAbsolutePoint):
+        (WebCore::RenderTableCell::mapAbsoluteToLocalPoint):
+        * rendering/RenderTableCell.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::mapLocalToAbsolutePoint):
+        (WebCore::RenderView::mapAbsoluteToLocalPoint):
+        * rendering/RenderView.h:
+        * rendering/TransformState.cpp: Added.
+        (WebCore::TransformState::move):
+        (WebCore::TransformState::applyTransform):
+        (WebCore::TransformState::flatten):
+        * rendering/TransformState.h: Added.
+        (WebCore::TransformState::):
+        (WebCore::TransformState::TransformState):
+        (WebCore::TransformState::move):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::hasPerspective):
+
 2009-02-24  Sam Weinig  <sam@webkit.org>
 
         Reviewed by David Hyatt.
index 82487042ce9d2f455cf692fff1c74bc60750718e..07f25215877be784af1a5238c5153baf4065d810 100644 (file)
@@ -1630,6 +1630,8 @@ webcore_sources += \
        WebCore/rendering/TableLayout.h \
        WebCore/rendering/TextControlInnerElements.cpp \
        WebCore/rendering/TextControlInnerElements.h \
+       WebCore/rendering/TransformState.cpp \
+       WebCore/rendering/TransformState.h \
        WebCore/rendering/bidi.cpp \
        WebCore/rendering/bidi.h \
        WebCore/rendering/break_lines.cpp \
index bd816754307cd79a5624540743cb5e4288bbb059..8b0a5cd51956661fdf5a1095705ec3ec4d68cab8 100644 (file)
@@ -740,6 +740,7 @@ __ZNK7WebCore12IconDatabase12databasePathEv
 __ZNK7WebCore12IconDatabase24shouldStopThreadActivityEv
 __ZNK7WebCore12IconDatabase9isEnabledEv
 __ZNK7WebCore12RenderObject14enclosingLayerEv
+__ZNK7WebCore12RenderObject15localToAbsoluteENS_10FloatPointEbb
 __ZNK7WebCore12SharedBuffer4dataEv
 __ZNK7WebCore12SharedBuffer4sizeEv
 __ZNK7WebCore12TextEncoding6decodeEPKcmbRb
index 942d483d29cc71a6206de1ee2bfb236c6b6faec4..1ac4f583cac917cef209e8e473e7d25e2e3ac65e 100644 (file)
@@ -1020,6 +1020,7 @@ SOURCES += \
     rendering/RootInlineBox.cpp \
     rendering/SVGRenderTreeAsText.cpp \
     rendering/TextControlInnerElements.cpp \
+    rendering/TransformState.cpp \
     rendering/style/BindingURI.cpp \
     rendering/style/ContentData.cpp \
     rendering/style/CounterDirectives.cpp \
index c647db2c8d639e59ffda00a4e49b0cc2c66e10c8..57706fd56892ac8b6780115dbedc074878f11b84 100644 (file)
@@ -511,6 +511,7 @@ sources['rendering'] = [
     'rendering/SVGRenderTreeAsText.cpp',
     'rendering/SVGRootInlineBox.cpp',
     'rendering/TextControlInnerElements.cpp'
+    'rendering/TransformState.cpp'
 ]
 sources['rendering/style'] = [
     'rendering/style/BindingURI.cpp',
index 9f76cac4cde053fe1606cf3cf8e9933be3af0e40..298038a2ecd3a9af319aff4e89c16cdba191e29e 100644 (file)
                                RelativePath="..\rendering\TextControlInnerElements.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\rendering\TransformState.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\rendering\TransformState.h"\r
+                               >\r
+                       </File>\r
                        <Filter\r
                                Name="style"\r
                                >\r
index 243510bc496181e360e4be9a7c8540aec6f59562..e9332ac9af6b296010e4d7aba47e0b4b6506905b 100644 (file)
                0BE030A20F3112FB003C1A46 /* RenderLineBoxList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BE030A10F3112FB003C1A46 /* RenderLineBoxList.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F11A54F0F39233100C37884 /* RenderSelectionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F11A54E0F39233100C37884 /* RenderSelectionInfo.h */; };
                0F15DA8A0F3AAEE70000CE47 /* AnimationControllerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15DA890F3AAEE70000CE47 /* AnimationControllerPrivate.h */; };
+               0F500AAF0F54DB1B00EEF928 /* TransformState.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F500AAE0F54DB1B00EEF928 /* TransformState.h */; };
+               0F500AB10F54DB3100EEF928 /* TransformState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F500AB00F54DB3100EEF928 /* TransformState.cpp */; };
                0F56028F0E4B76580065B038 /* RenderMarquee.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F56028D0E4B76580065B038 /* RenderMarquee.h */; };
                0F5602900E4B76580065B038 /* RenderMarquee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F56028E0E4B76580065B038 /* RenderMarquee.cpp */; };
                0F580B050F12A2550051D689 /* GraphicsLayerCA.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F580B030F12A2540051D689 /* GraphicsLayerCA.mm */; };
                0BE030A10F3112FB003C1A46 /* RenderLineBoxList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderLineBoxList.h; sourceTree = "<group>"; };
                0F11A54E0F39233100C37884 /* RenderSelectionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSelectionInfo.h; sourceTree = "<group>"; };
                0F15DA890F3AAEE70000CE47 /* AnimationControllerPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationControllerPrivate.h; path = animation/AnimationControllerPrivate.h; sourceTree = "<group>"; };
+               0F500AAE0F54DB1B00EEF928 /* TransformState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformState.h; sourceTree = "<group>"; };
+               0F500AB00F54DB3100EEF928 /* TransformState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformState.cpp; sourceTree = "<group>"; };
                0F56028D0E4B76580065B038 /* RenderMarquee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMarquee.h; sourceTree = "<group>"; };
                0F56028E0E4B76580065B038 /* RenderMarquee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMarquee.cpp; sourceTree = "<group>"; };
                0F580B030F12A2540051D689 /* GraphicsLayerCA.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GraphicsLayerCA.mm; sourceTree = "<group>"; };
                                B275354F0B053814002CE64F /* IntPointMac.mm */,
                                B27535500B053814002CE64F /* IntRectMac.mm */,
                                B27535510B053814002CE64F /* IntSizeMac.mm */,
-                               0735EE690F40C5E4004A2604 /* MediaPlayerProxy.h */,
                                E4B41E100CBF90EF00AF2ECE /* MediaPlayerPrivateQTKit.h */,
                                E4B41E110CBF90EF00AF2ECE /* MediaPlayerPrivateQTKit.mm */,
+                               0735EE690F40C5E4004A2604 /* MediaPlayerProxy.h */,
                                B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */,
                                0FCF332B0F2B9A25004B6795 /* WebLayer.h */,
                                0FCF332A0F2B9A25004B6795 /* WebLayer.mm */,
                                BCFB2F75097A2E1A00BA703D /* Arena.h */,
                                51E1ECB10C91C55600DC255B /* AutodrainedPool.h */,
                                BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */,
+                               41D015C90F4B5C71004A662F /* ContentType.cpp */,
+                               41D015C80F4B5C71004A662F /* ContentType.h */,
                                93B6A0E70B0BCA6700F5027A /* ContextMenu.cpp */,
                                93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */,
                                06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */,
                                935207BD09BD410A00F2038D /* LocalizedStrings.h */,
                                A8239DFE09B3CF8A00B60641 /* Logging.cpp */,
                                A8239DFF09B3CF8A00B60641 /* Logging.h */,
-                               41D015C80F4B5C71004A662F /* ContentType.h */,
-                               41D015C90F4B5C71004A662F /* ContentType.cpp */,
                                BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */,
                                BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
                                4B2708C50AF19EE40065127F /* Pasteboard.h */,
                                A8CFF04C0A154F09000A4234 /* TableLayout.h */,
                                AB014DE10E689A4300E10445 /* TextControlInnerElements.cpp */,
                                AB014DE20E689A4300E10445 /* TextControlInnerElements.h */,
+                               0F500AB00F54DB3100EEF928 /* TransformState.cpp */,
+                               0F500AAE0F54DB1B00EEF928 /* TransformState.h */,
                                BCEA4813097D93020094C9E4 /* bidi.cpp */,
                                BCEA4814097D93020094C9E4 /* bidi.h */,
                                BCEA4815097D93020094C9E4 /* break_lines.cpp */,
                                BC0B36A50CD3C67C00AC7EB5 /* Console.h in Headers */,
                                A818721C0977D3C0005826D9 /* ContainerNode.h in Headers */,
                                BC5EB9810E82072500B25965 /* ContentData.h in Headers */,
+                               41D015CA0F4B5C71004A662F /* ContentType.h in Headers */,
                                93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */,
                                065AD4F50B0C2EDA005A2B1D /* ContextMenuClient.h in Headers */,
                                065AD4F70B0C2EDA005A2B1D /* ContextMenuController.h in Headers */,
                                9392F14C0AD1861B00691BD4 /* CounterNode.h in Headers */,
                                D0B0556809C6700100307E43 /* CreateLinkCommand.h in Headers */,
                                514C766E0CE923A1007EF3CD /* Credential.h in Headers */,
+                               2E4346590F546A9900B0F1BA /* CrossThreadCopier.h in Headers */,
                                93F1992F08245E59001E9ABC /* Cursor.h in Headers */,
                                BC2272A20E82E87C00E7F975 /* CursorData.h in Headers */,
                                BC2272AD0E82E8F300E7F975 /* CursorList.h in Headers */,
                                935C477509AC4D8E00A6AAB4 /* GapRects.h in Headers */,
                                BC23F0DB0DAFF4A4009FDC91 /* GeneratedImage.h in Headers */,
                                BCE04C8A0DAFF7A0007A0F41 /* Generator.h in Headers */,
+                               2E4346440F546A8200B0F1BA /* GenericWorkerTask.h in Headers */,
                                FE80D7C60E9C1F25000D6F75 /* Geolocation.h in Headers */,
                                FEAB90130EA51B9C006348C3 /* GeolocationService.h in Headers */,
                                FE80D7C90E9C1F25000D6F75 /* Geoposition.h in Headers */,
                                A8EA7CB70A192B9C00A8EF5F /* HTMLDivElement.h in Headers */,
                                93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
                                93F198E608245E59001E9ABC /* HTMLElement.h in Headers */,
+                               A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */,
                                A871D45C0A127CBC00B12A68 /* HTMLEmbedElement.h in Headers */,
                                A81369D4097374F600D74463 /* HTMLFieldSetElement.h in Headers */,
                                A8CFF7A60A156978000A4234 /* HTMLFontElement.h in Headers */,
                                BCCFBAE80B5152ED0001F1D7 /* Tokenizer.h in Headers */,
                                49E911CE0EF86D47009D0CAF /* TransformOperation.h in Headers */,
                                49E911D00EF86D47009D0CAF /* TransformOperations.h in Headers */,
+                               0F500AAF0F54DB1B00EEF928 /* TransformState.h in Headers */,
                                49E911C40EF86D47009D0CAF /* TransformationMatrix.h in Headers */,
                                49E911D20EF86D47009D0CAF /* TranslateTransformOperation.h in Headers */,
                                854FE7370A2297BE0058D7AD /* Traversal.h in Headers */,
                                9380F47409A11AB4001FDB34 /* Widget.h in Headers */,
                                939B02EF0EA2DBC400C54570 /* WidthIterator.h in Headers */,
                                BC8243E90D0CFD7500460C8F /* WindowFeatures.h in Headers */,
+                               2E4346460F546A8200B0F1BA /* Worker.h in Headers */,
+                               2E4346490F546A8200B0F1BA /* WorkerContext.h in Headers */,
+                               2E43464B0F546A8200B0F1BA /* WorkerContextProxy.h in Headers */,
+                               2E43464D0F546A8200B0F1BA /* WorkerLocation.h in Headers */,
+                               2E4346500F546A8200B0F1BA /* WorkerMessagingProxy.h in Headers */,
                                E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */,
+                               2E4346510F546A8200B0F1BA /* WorkerObjectProxy.h in Headers */,
+                               2E4346530F546A8200B0F1BA /* WorkerRunLoop.h in Headers */,
                                E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */,
+                               2E4346550F546A8200B0F1BA /* WorkerThread.h in Headers */,
                                0B9056F90F2685F30095FF6A /* WorkerThreadableLoader.h in Headers */,
                                93309E24099E64920056E581 /* WrapContentsInDummySpanCommand.h in Headers */,
                                6565820209D1508D000E61D7 /* XLinkNames.h in Headers */,
                                1A569D230D7E2B82007C3983 /* runtime_object.h in Headers */,
                                1A569D250D7E2B82007C3983 /* runtime_root.h in Headers */,
                                93309E1E099E64920056E581 /* visible_units.h in Headers */,
-                               A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */,
-                               41D015CA0F4B5C71004A662F /* ContentType.h in Headers */,
-                               2E4346440F546A8200B0F1BA /* GenericWorkerTask.h in Headers */,
-                               2E4346460F546A8200B0F1BA /* Worker.h in Headers */,
-                               2E4346490F546A8200B0F1BA /* WorkerContext.h in Headers */,
-                               2E43464B0F546A8200B0F1BA /* WorkerContextProxy.h in Headers */,
-                               2E43464D0F546A8200B0F1BA /* WorkerLocation.h in Headers */,
-                               2E4346500F546A8200B0F1BA /* WorkerMessagingProxy.h in Headers */,
-                               2E4346510F546A8200B0F1BA /* WorkerObjectProxy.h in Headers */,
-                               2E4346530F546A8200B0F1BA /* WorkerRunLoop.h in Headers */,
-                               2E4346550F546A8200B0F1BA /* WorkerThread.h in Headers */,
-                               2E4346590F546A9900B0F1BA /* CrossThreadCopier.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                B25599680D00D8BA00BB825C /* WKSpecularLightingFilter.cikernel in Resources */,
                                B255996B0D00D8BA00BB825C /* WKSpotLightFilter.cikernel in Resources */,
                                B255996E0D00D8BA00BB825C /* WKTableTransferFilter.cikernel in Resources */,
+                               2E4346470F546A8200B0F1BA /* Worker.idl in Resources */,
+                               2E43464A0F546A8200B0F1BA /* WorkerContext.idl in Resources */,
+                               2E43464E0F546A8200B0F1BA /* WorkerLocation.idl in Resources */,
                                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
                                46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
                                46D4F24A0AF97E810035385A /* contextMenuCursor.png in Resources */,
                                85136CA80AED665900F90A3D /* westResizeCursor.png in Resources */,
                                1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */,
                                1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
-                               2E4346470F546A8200B0F1BA /* Worker.idl in Resources */,
-                               2E43464A0F546A8200B0F1BA /* WorkerContext.idl in Resources */,
-                               2E43464E0F546A8200B0F1BA /* WorkerLocation.idl in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC0B36A40CD3C67C00AC7EB5 /* Console.cpp in Sources */,
                                A818721F0977D3C0005826D9 /* ContainerNode.cpp in Sources */,
                                BC5EB9800E82072500B25965 /* ContentData.cpp in Sources */,
+                               41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */,
                                93B6A0E80B0BCA6700F5027A /* ContextMenu.cpp in Sources */,
                                065AD4F60B0C2EDA005A2B1D /* ContextMenuController.cpp in Sources */,
                                06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */,
                                9392F1500AD1862300691BD4 /* CounterNode.cpp in Sources */,
                                D0B0556909C6700100307E43 /* CreateLinkCommand.cpp in Sources */,
                                514C766D0CE923A1007EF3CD /* Credential.cpp in Sources */,
+                               2E4346580F546A9900B0F1BA /* CrossThreadCopier.cpp in Sources */,
                                93F19A2608245E59001E9ABC /* CursorMac.mm in Sources */,
                                B2F34FE90E82F82700F627CD /* DNSCFNet.cpp in Sources */,
                                BC1A37AE097C715F0019F3D8 /* DOM.mm in Sources */,
                                A8EA7CB10A192B9C00A8EF5F /* HTMLDivElement.cpp in Sources */,
                                93F19A9108245E59001E9ABC /* HTMLDocument.cpp in Sources */,
                                93F19A9208245E59001E9ABC /* HTMLElement.cpp in Sources */,
+                               A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */,
                                A871D45F0A127CBC00B12A68 /* HTMLEmbedElement.cpp in Sources */,
                                A81369D5097374F600D74463 /* HTMLFieldSetElement.cpp in Sources */,
                                A8CFF7A20A156978000A4234 /* HTMLFontElement.cpp in Sources */,
                                E44613AF0CD6331000FADA75 /* TimeRanges.cpp in Sources */,
                                93309EA4099EB78C0056E581 /* Timer.cpp in Sources */,
                                49E911CF0EF86D47009D0CAF /* TransformOperations.cpp in Sources */,
+                               0F500AB10F54DB3100EEF928 /* TransformState.cpp in Sources */,
                                49E911C30EF86D47009D0CAF /* TransformationMatrix.cpp in Sources */,
                                B27535580B053814002CE64F /* TransformationMatrixCG.cpp in Sources */,
                                49E911D10EF86D47009D0CAF /* TranslateTransformOperation.cpp in Sources */,
                                9380F47809A11ACC001FDB34 /* WidgetMac.mm in Sources */,
                                939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
                                BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */,
+                               2E4346450F546A8200B0F1BA /* Worker.cpp in Sources */,
+                               2E4346480F546A8200B0F1BA /* WorkerContext.cpp in Sources */,
+                               2E43464C0F546A8200B0F1BA /* WorkerLocation.cpp in Sources */,
+                               2E43464F0F546A8200B0F1BA /* WorkerMessagingProxy.cpp in Sources */,
                                E1271A140EEEC80400F61213 /* WorkerNavigator.cpp in Sources */,
+                               2E4346520F546A8200B0F1BA /* WorkerRunLoop.cpp in Sources */,
                                E1A643FD0EC097A000779668 /* WorkerScriptController.cpp in Sources */,
+                               2E4346540F546A8200B0F1BA /* WorkerThread.cpp in Sources */,
                                0B9056F80F2685F30095FF6A /* WorkerThreadableLoader.cpp in Sources */,
                                93309E23099E64920056E581 /* WrapContentsInDummySpanCommand.cpp in Sources */,
                                A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
                                1A569D220D7E2B82007C3983 /* runtime_object.cpp in Sources */,
                                1A569D240D7E2B82007C3983 /* runtime_root.cpp in Sources */,
                                93309E1D099E64920056E581 /* visible_units.cpp in Sources */,
-                               A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */,
-                               41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */,
-                               2E4346450F546A8200B0F1BA /* Worker.cpp in Sources */,
-                               2E4346480F546A8200B0F1BA /* WorkerContext.cpp in Sources */,
-                               2E43464C0F546A8200B0F1BA /* WorkerLocation.cpp in Sources */,
-                               2E43464F0F546A8200B0F1BA /* WorkerMessagingProxy.cpp in Sources */,
-                               2E4346520F546A8200B0F1BA /* WorkerRunLoop.cpp in Sources */,
-                               2E4346540F546A8200B0F1BA /* WorkerThread.cpp in Sources */,
-                               2E4346580F546A9900B0F1BA /* CrossThreadCopier.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index a63b4061aee57461501bc41a194251c4ede77e39..13637953dfdeb4f915f9d4dd58a11f10bf28e7aa 100644 (file)
@@ -935,6 +935,7 @@ This file contains the list of files needed to build WebCore.
         rendering/RenderWordBreak.cpp
         rendering/RootInlineBox.cpp
         rendering/TextControlInnerElements.cpp
+        rendering/TransformState.cpp
         rendering/style/BindingURI.cpp
         rendering/style/ContentData.cpp
         rendering/style/CounterDirectives.cpp
index b41cc36c450c043fa311c792ef329f3a77bd1bd0..8916cd91eaf5bab7de12ab4ede5026c94b18b47c 100644 (file)
@@ -1159,7 +1159,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyWebkitMarginTopCollapse:
             return CSSPrimitiveValue::create(style->marginTopCollapse());
         case CSSPropertyWebkitPerspective:
-            if (style->perspective() == 0)
+            if (!style->hasPerspective())
                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
             return CSSPrimitiveValue::create(style->perspective(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitPerspectiveOrigin: {
index b0549a56cfbc098de029dce9f7cb67f769b68f3b..610f58a84a066e21d761674e54df240a4d5664e1 100644 (file)
@@ -771,6 +771,7 @@ TransformationMatrix& TransformationMatrix::rotate3d(double rx, double ry, doubl
 
 TransformationMatrix& TransformationMatrix::translate(double tx, double ty)
 {
+    // FIXME: optimize to avoid matrix copy
     TransformationMatrix mat;
     mat.m_matrix[3][0] = tx;
     mat.m_matrix[3][1] = ty;
@@ -781,6 +782,7 @@ TransformationMatrix& TransformationMatrix::translate(double tx, double ty)
 
 TransformationMatrix& TransformationMatrix::translate3d(double tx, double ty, double tz)
 {
+    // FIXME: optimize to avoid matrix copy
     TransformationMatrix mat;
     mat.m_matrix[3][0] = tx;
     mat.m_matrix[3][1] = ty;
@@ -790,6 +792,32 @@ TransformationMatrix& TransformationMatrix::translate3d(double tx, double ty, do
     return *this;
 }
 
+TransformationMatrix& TransformationMatrix::translateRight3d(double tx, double ty, double tz)
+{
+    if (tx != 0) {
+        m_matrix[0][0] +=  m_matrix[0][3] * tx;
+        m_matrix[1][0] +=  m_matrix[1][3] * tx;
+        m_matrix[2][0] +=  m_matrix[2][3] * tx;
+        m_matrix[3][0] +=  m_matrix[3][3] * tx;
+    }
+
+    if (ty != 0) {
+        m_matrix[0][1] +=  m_matrix[0][3] * ty;
+        m_matrix[1][1] +=  m_matrix[1][3] * ty;
+        m_matrix[2][1] +=  m_matrix[2][3] * ty;
+        m_matrix[3][1] +=  m_matrix[3][3] * ty;
+    }
+
+    if (tz != 0) {
+        m_matrix[0][2] +=  m_matrix[0][3] * tz;
+        m_matrix[1][2] +=  m_matrix[1][3] * tz;
+        m_matrix[2][2] +=  m_matrix[2][3] * tz;
+        m_matrix[3][2] +=  m_matrix[3][3] * tz;
+    }
+
+    return *this;
+}
+
 TransformationMatrix& TransformationMatrix::skew(double sx, double sy)
 {
     // angles are in degrees. Switch to radians
index 357212bb259698ee9258024505c6993e34def1b0..306a4ca5e94370501a00de1fc58fbb4e42320c5f 100644 (file)
@@ -206,6 +206,9 @@ public:
     
     TransformationMatrix& translate(double tx, double ty);
     TransformationMatrix& translate3d(double tx, double ty, double tz);
+
+    // translation added with a post-multiply
+    TransformationMatrix& translateRight3d(double tx, double ty, double tz);
     
     TransformationMatrix& flipX();
     TransformationMatrix& flipY();
index b69febee6bfab292ba3c64f5af6edcae10e52631..7d15e1d04755aa7c1103c3ed6e4d4227bfe0e1f9 100644 (file)
@@ -44,6 +44,7 @@
 #include "RenderTableCell.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "TransformState.h"
 #include <algorithm>
 #include <math.h>
 
@@ -944,17 +945,17 @@ int RenderBox::containingBlockWidthForContent() const
     return cb->availableWidth();
 }
 
-FloatPoint RenderBox::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
+void RenderBox::mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
     if (RenderView* v = view()) {
         if (v->layoutStateEnabled()) {
             LayoutState* layoutState = v->layoutState();
             IntSize offset = layoutState->m_offset;
             offset.expand(x(), y());
-            localPoint += offset;
             if (style()->position() == RelativePosition && layer())
-                localPoint += layer()->relativePositionOffset();
-            return localPoint;
+                offset += layer()->relativePositionOffset();
+            transformState.move(offset);
+            return;
         }
     }
 
@@ -963,20 +964,43 @@ FloatPoint RenderBox::localToAbsolute(FloatPoint localPoint, bool fixed, bool us
 
     RenderObject* o = container();
     if (o) {
-        if (useTransforms && layer() && layer()->transform()) {
+
+        if (hasLayer() && layer()->transform())
             fixed = false;  // Elements with transforms act as a containing block for fixed position descendants
-            localPoint = layer()->transform()->mapPoint(localPoint);
-        }
 
-        localPoint += offsetFromContainer(o);
+        IntSize containerOffset = offsetFromContainer(o);
+        if (useTransforms) {
+
+            TransformationMatrix transformFromContainer;
+            transformFromContainer.translate(containerOffset.width(), containerOffset.height());
+            if (hasLayer() && layer()->transform())
+                transformFromContainer.multLeft(*layer()->transform());
+            
+            // If either the container or this have transform-style: preserve-3d, we need to stay in 3d space by
+            // accumulating the transform.
+            bool accumulateTransform = (o->style()->transformStyle3D() == TransformStyle3DPreserve3D || style()->transformStyle3D() == TransformStyle3DPreserve3D);
+            if (o->style()->hasPerspective()) {
+                // Perpsective on the container affects us, so we have to factor it in here.
+                ASSERT(o->hasLayer());
+                FloatPoint perspectiveOrigin = toRenderBox(o)->layer()->perspectiveOrigin();
+
+                TransformationMatrix perspectiveMatrix;
+                perspectiveMatrix.applyPerspective(o->style()->perspective());
+                
+                transformFromContainer.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(), 0);
+                transformFromContainer.multiply(perspectiveMatrix);
+                transformFromContainer.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0);
+            }
+
+            transformState.applyTransform(transformFromContainer, accumulateTransform);
+        } else
+            transformState.move(containerOffset.width(), containerOffset.height());
 
-        return o->localToAbsolute(localPoint, fixed, useTransforms);
+        o->mapLocalToAbsolutePoint(fixed, useTransforms, transformState);
     }
-    
-    return FloatPoint();
 }
 
-FloatPoint RenderBox::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool useTransforms) const
+void RenderBox::mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
     // We don't expect absoluteToLocal() to be called during layout (yet)
     ASSERT(!view() || !view()->layoutStateEnabled());
@@ -989,14 +1013,35 @@ FloatPoint RenderBox::absoluteToLocal(FloatPoint containerPoint, bool fixed, boo
     
     RenderObject* o = container();
     if (o) {
-        FloatPoint localPoint = o->absoluteToLocal(containerPoint, fixed, useTransforms);
-        localPoint -= offsetFromContainer(o);
-        if (useTransforms && layer() && layer()->transform())
-            localPoint = layer()->transform()->inverse().mapPoint(localPoint);
-        return localPoint;
+        o->mapAbsoluteToLocalPoint(fixed, useTransforms, transformState);
+
+        IntSize containerOffset = offsetFromContainer(o);
+        if (useTransforms) {
+            TransformationMatrix transformFromContainer;
+            transformFromContainer.translate(containerOffset.width(), containerOffset.height());
+            if (hasLayer() && layer()->transform())
+                transformFromContainer.multLeft(*layer()->transform());
+            
+            // If either the container or this have transform-style: preserve-3d, we need to stay in 3d space by
+            // accumulating the transform.
+            bool accumulateTransform = (o->style()->transformStyle3D() == TransformStyle3DPreserve3D || style()->transformStyle3D() == TransformStyle3DPreserve3D);
+            if (o->style()->hasPerspective()) {
+                // Perpsective on the container affects us, so we have to factor it in here.
+                ASSERT(o->hasLayer());
+                FloatPoint perspectiveOrigin = toRenderBox(o)->layer()->perspectiveOrigin();
+
+                TransformationMatrix perspectiveMatrix;
+                perspectiveMatrix.applyPerspective(o->style()->perspective());
+                
+                transformFromContainer.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(), 0);
+                transformFromContainer.multiply(perspectiveMatrix);
+                transformFromContainer.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0);
+            }
+
+            transformState.applyTransform(transformFromContainer, accumulateTransform);
+        } else
+            transformState.move(-containerOffset.width(), -containerOffset.height());
     }
-    
-    return FloatPoint();
 }
 
 FloatQuad RenderBox::localToContainerQuad(const FloatQuad& localQuad, RenderBoxModelObject* repaintContainer, bool fixed) const
index 3a5799bbab230191821534715098eb228378cc61..ed1860cb2c4c86995ec02f0488f9cd7350a454ca 100644 (file)
@@ -138,8 +138,6 @@ public:
     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty, bool topLevel = true);
     virtual void absoluteQuads(Vector<FloatQuad>&, bool topLevel = true);
     
-    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
-    virtual FloatPoint absoluteToLocal(FloatPoint containerPoint, bool fixed = false, bool useTransforms = false) const;
     virtual FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false) const;
 
     IntRect reflectionBox() const;
@@ -305,6 +303,9 @@ protected:
     
     virtual bool shouldCalculateSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
 
+    virtual void mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState&) const;
+    virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
+
 private:
     bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); }
     bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); }
index 8b8a46a0492895927fedc7e5d8aa665e71abc200..3dfaa092585769637d25e86566b1bc6a090048f0 100644 (file)
@@ -313,7 +313,9 @@ void RenderLayer::updateLayerPositions(bool doFullRepaint, bool checkForRepaint)
 
 void RenderLayer::updateTransform()
 {
-    bool hasTransform = renderer()->hasTransform();
+    // hasTransform() on the renderer is also true when there is transform-style: preserve-3d or perspective set,
+    // so check style too.
+    bool hasTransform = renderer()->hasTransform() && renderer()->style()->hasTransform();
     bool hadTransform = m_transform;
     if (hasTransform != hadTransform) {
         if (hasTransform)
@@ -504,7 +506,7 @@ TransformationMatrix RenderLayer::perspectiveTransform() const
         return TransformationMatrix();
 
     RenderStyle* style = renderer()->style();
-    if (!style->perspective())
+    if (!style->hasPerspective())
         return TransformationMatrix();
 
     // Maybe fetch the perspective from the backing?
@@ -515,6 +517,8 @@ TransformationMatrix RenderLayer::perspectiveTransform() const
     float perspectiveOriginX = style->perspectiveOriginX().calcFloatValue(boxWidth);
     float perspectiveOriginY = style->perspectiveOriginY().calcFloatValue(boxHeight);
 
+    // A perspective origin of 0,0 makes the vanishing point in the center of the element.
+    // We want it to be in the top-left, so subtract half the height and width.
     perspectiveOriginX -= boxWidth / 2.0f;
     perspectiveOriginY -= boxHeight / 2.0f;
     
@@ -526,6 +530,18 @@ TransformationMatrix RenderLayer::perspectiveTransform() const
     return t;
 }
 
+FloatPoint RenderLayer::perspectiveOrigin() const
+{
+    if (!renderer()->hasTransform())
+        return FloatPoint();
+
+    const IntRect borderBox = toRenderBox(renderer())->borderBoxRect();
+    RenderStyle* style = renderer()->style();
+
+    return FloatPoint(style->perspectiveOriginX().calcFloatValue(borderBox.width()),
+                      style->perspectiveOriginY().calcFloatValue(borderBox.height()));
+}
+
 RenderLayer *RenderLayer::stackingContext() const
 {
     RenderLayer* curr = parent();
index 8acdda50a0db77478638c07e654425ed26946f6b..98f5ead0b541da9821856b05c518cb716f3e5c6a 100644 (file)
@@ -404,6 +404,7 @@ public:
     // Returns true if the layer has a -webkit-perspective.
     // Note that this transform has the perspective-origin baked in.
     TransformationMatrix perspectiveTransform() const;
+    FloatPoint perspectiveOrigin() const;
 
     void destroy(RenderArena*);
 
index c82181eb535792879f7bd7d327a6ffd20ec5cfa6..ce9e6db0f7af2d66e3e9e04ceda8feb5f2aea5fb 100644 (file)
@@ -259,7 +259,7 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
         m_graphicsLayer->setAnchorPoint(anchor);
 
         RenderStyle* style = renderer()->style();
-        if (style->perspective() > 0) {
+        if (style->hasPerspective()) {
             FloatPoint perspectiveOrigin = computePerspectiveOrigin(borderBox);
             
             float xOffset = perspectiveOrigin.x() - (float)borderBox.width() / 2.0f;
index b64934a1b560b9c410ba3783f78ecf7bc8747b34..247c36fd36dca51242f6c51cf56482d0f3909d22 100644 (file)
@@ -625,7 +625,7 @@ static bool requiresCompositingLayerForTransform(RenderObject* renderer)
     RenderStyle* style = renderer->style();
     // Note that we ask the renderer if it has a transform, because the style may have transforms,
     // but the renderer may be an inline that doesn't suppport them.
-    return renderer->hasTransform() && (style->transform().has3DOperation() || style->transformStyle3D() == TransformStyle3DPreserve3D || style->perspective() > 0);
+    return renderer->hasTransform() && (style->transform().has3DOperation() || style->transformStyle3D() == TransformStyle3DPreserve3D || style->hasPerspective());
 }
 
 #define VERBOSE_COMPOSITINGLAYER    0
@@ -755,7 +755,7 @@ bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const
 
     if (style && 
         (style->transformStyle3D() == TransformStyle3DPreserve3D ||
-         style->perspective() > 0 ||
+         style->hasPerspective() ||
          style->transform().has3DOperation()))
         return true;
 
index 1df11e9c717e6dceb9867346fc83a54daeb6cdf1..cb6781bf26b248a7a7e7bf57ed32f19a1430a3bf 100644 (file)
@@ -44,6 +44,7 @@
 #include "RenderTableRow.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "TransformState.h"
 #include <algorithm>
 #include <stdio.h>
 #include <wtf/RefCountedLeakCounter.h>
@@ -1635,27 +1636,50 @@ IntRect RenderObject::viewRect() const
 }
 
 FloatPoint RenderObject::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
+{
+    TransformState transformState(localPoint, TransformState::ApplyTransformDirection);
+    mapLocalToAbsolutePoint(fixed, useTransforms, transformState);
+
+    if (transformState.m_accumulatingTransform) {
+        // Do a final flatten if necessary
+        transformState.flatten();
+    }
+    
+    return transformState.m_lastPlanarPoint;
+}
+
+FloatPoint RenderObject::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool useTransforms) const
+{
+    TransformState transformState(containerPoint, TransformState::UnapplyInverseTransformDirection);
+    mapAbsoluteToLocalPoint(fixed, useTransforms, transformState);
+    
+    if (transformState.m_accumulatingTransform) {
+        // Do a final flatten if necessary
+        transformState.flatten();
+    }
+    
+    return transformState.m_lastPlanarPoint;
+}
+
+void RenderObject::mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
     RenderObject* o = parent();
     if (o) {
         if (o->hasOverflowClip())
-            localPoint -= toRenderBox(o)->layer()->scrolledContentOffset();
-        return o->localToAbsolute(localPoint, fixed, useTransforms);
-    }
+            transformState.move(-toRenderBox(o)->layer()->scrolledContentOffset());
 
-    return FloatPoint();
+        o->mapLocalToAbsolutePoint(fixed, useTransforms, transformState);
+    }
 }
 
-FloatPoint RenderObject::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool useTransforms) const
+void RenderObject::mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
     RenderObject* o = parent();
     if (o) {
-        FloatPoint localPoint = o->absoluteToLocal(containerPoint, fixed, useTransforms);
+        o->mapAbsoluteToLocalPoint(fixed, useTransforms, transformState);
         if (o->hasOverflowClip())
-            localPoint += toRenderBox(o)->layer()->scrolledContentOffset();
-        return localPoint;
+            transformState.move(toRenderBox(o)->layer()->scrolledContentOffset());
     }
-    return FloatPoint();
 }
 
 FloatQuad RenderObject::localToContainerQuad(const FloatQuad& localQuad, RenderBoxModelObject* repaintContainer, bool fixed) const
index 6ba9ba4b30a920d28cbee7bf235378333789c17b..0bb38c87ae16c21cc423b3d395ea07a0b3b60949 100644 (file)
@@ -30,6 +30,7 @@
 #include "Document.h"
 #include "RenderObjectChildList.h"
 #include "RenderStyle.h"
+#include "TransformationMatrix.h"
 
 namespace WebCore {
 
@@ -42,6 +43,7 @@ class RenderInline;
 class RenderBlock;
 class RenderFlow;
 class RenderLayer;
+class TransformState;
 class VisiblePosition;
 
 /*
@@ -476,8 +478,8 @@ public:
 
     // Convert the given local point to absolute coordinates
     // FIXME: Temporary. If useTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
-    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
-    virtual FloatPoint absoluteToLocal(FloatPoint, bool fixed = false, bool useTransforms = false) const;
+    FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
+    FloatPoint absoluteToLocal(FloatPoint, bool fixed = false, bool useTransforms = false) const;
 
     // Convert a local quad to absolute coordinates, taking transforms into account.
     FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false) const
@@ -670,6 +672,11 @@ public:
     AnimationController* animation() const;
 
     bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
+
+    // Map points through elements, potentially via 3d transforms. You should never need to call these directly; use
+    // localToAbsolute/absoluteToLocal instead.
+    virtual void mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState&) const;
+    virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
     
     virtual void addFocusRingRects(GraphicsContext*, int /*tx*/, int /*ty*/) { };
 
index 563d17c2e0cf8655438a0a1b248b541d77b692ac..41753477ecd38414563f6e54e710cf7ddd1df253 100644 (file)
@@ -31,6 +31,7 @@
 #include "HTMLTableCellElement.h"
 #include "RenderTableCol.h"
 #include "RenderView.h"
+#include "TransformState.h"
 
 using namespace std;
 
@@ -216,24 +217,25 @@ void RenderTableCell::computeRectForRepaint(RenderBoxModelObject* repaintContain
     RenderBlock::computeRectForRepaint(repaintContainer, r, fixed);
 }
 
-FloatPoint RenderTableCell::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
+void RenderTableCell::mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
     RenderView* v = view();
     if ((!v || !v->layoutStateEnabled()) && parent()) {
         // Rows are in the same coordinate space, so don't add their offset in.
-        localPoint.move(-parentBox()->x(), -parentBox()->y());
+        // FIXME: this is wrong with transforms
+        transformState.move(-parentBox()->x(), -parentBox()->y());
     }
-    return RenderBlock::localToAbsolute(localPoint, fixed, useTransforms);
+    RenderBlock::mapLocalToAbsolutePoint(fixed, useTransforms, transformState);
 }
 
-FloatPoint RenderTableCell::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool useTransforms) const
+void RenderTableCell::mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
-    FloatPoint localPoint = RenderBlock::absoluteToLocal(containerPoint, fixed, useTransforms);
+    RenderBlock::mapAbsoluteToLocalPoint(fixed, useTransforms, transformState);
     if (parent()) {
         // Rows are in the same coordinate space, so add their offset back in.
-        localPoint.move(parentBox()->x(), parentBox()->y());
+        // FIXME: this is wrong with transforms
+        transformState.move(parentBox()->x(), parentBox()->y());
     }
-    return localPoint;
 }
 
 FloatQuad RenderTableCell::localToContainerQuad(const FloatQuad& localQuad, RenderBoxModelObject* repaintContainer, bool fixed) const
index a15c88ec101442b5bf98e4c0b4a42dedf5027d12..551d3fee1b551c1b100e3e7fd3f5982c8ef15130 100644 (file)
@@ -96,8 +96,6 @@ public:
 
     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
-    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
-    virtual FloatPoint absoluteToLocal(FloatPoint containerPoint, bool fixed = false, bool useTransforms = false) const;
 
     virtual int baselinePosition(bool firstLine = false, bool isRootLineBox = false) const;
 
@@ -120,6 +118,9 @@ protected:
 
     virtual FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false) const;
 
+    virtual void mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState&) const;
+    virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
+
 private:
     int m_row;
     int m_column;
index bec781b78c2e085afa231856fa128b19c16132c3..43f5212cb1ec564ade1a054e364ef7aca4ad1e4d 100644 (file)
@@ -31,6 +31,7 @@
 #include "RenderLayer.h"
 #include "RenderSelectionInfo.h"
 #include "RenderWidget.h"
+#include "TransformState.h"
 
 #if USE(ACCELERATED_COMPOSITING)
 #include "RenderLayerCompositor.h"
@@ -134,20 +135,16 @@ void RenderView::layout()
     setNeedsLayout(false);
 }
 
-FloatPoint RenderView::localToAbsolute(FloatPoint localPoint, bool fixed, bool) const
+void RenderView::mapLocalToAbsolutePoint(bool fixed, bool /*useTransforms*/, TransformState& transformState) const
 {
     if (fixed && m_frameView)
-        localPoint += m_frameView->scrollOffset();
-
-    return localPoint;
+        transformState.move(m_frameView->scrollOffset());
 }
 
-FloatPoint RenderView::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool) const
+void RenderView::mapAbsoluteToLocalPoint(bool fixed, bool /*useTransforms*/, TransformState& transformState) const
 {
     if (fixed && m_frameView)
-        containerPoint -= m_frameView->scrollOffset();
-
-    return containerPoint;
+        transformState.move(-m_frameView->scrollOffset());
 }
 
 FloatQuad RenderView::localToContainerQuad(const FloatQuad& localQuad, RenderBoxModelObject* repaintContainer, bool fixed) const
index b2d49ffa6572b9998fe262eb1b7014bf01817bc4..75b577368062cbcd5125d8174168959131018202 100644 (file)
@@ -49,8 +49,6 @@ public:
     virtual void calcWidth();
     virtual void calcHeight();
     virtual void calcPrefWidths();
-    virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
-    virtual FloatPoint absoluteToLocal(FloatPoint containerPoint, bool fixed = false, bool useTransforms = false) const;
     
     int docHeight() const;
     int docWidth() const;
@@ -169,6 +167,9 @@ public:
 protected:
     virtual FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false) const;
 
+    virtual void mapLocalToAbsolutePoint(bool fixed, bool useTransforms, TransformState&) const;
+    virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
+
 private:
     bool shouldRepaint(const IntRect& r) const;
 
diff --git a/WebCore/rendering/TransformState.cpp b/WebCore/rendering/TransformState.cpp
new file mode 100644 (file)
index 0000000..c19ed81
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "TransformState.h"
+
+namespace WebCore {
+
+void TransformState::move(int x, int y)
+{
+    if (m_accumulatingTransform)
+        flatten();
+
+    m_lastPlanarPoint.move(x, y);
+}
+
+void TransformState::applyTransform(const TransformationMatrix& transformFromContainer, bool accumulateTransform)
+{
+    if (m_direction == ApplyTransformDirection)
+        m_accumulatedTransform.multiply(transformFromContainer);    
+    else
+        m_accumulatedTransform.multLeft(transformFromContainer);    
+
+    if (!accumulateTransform)
+        flatten();
+
+    m_accumulatingTransform = accumulateTransform;
+}
+
+void TransformState::flatten()
+{
+    if (m_direction == ApplyTransformDirection)
+        m_lastPlanarPoint = m_accumulatedTransform.mapPoint(m_lastPlanarPoint);
+    else
+        m_lastPlanarPoint = m_accumulatedTransform.inverse().projectPoint(m_lastPlanarPoint);
+    m_accumulatedTransform.makeIdentity();
+    m_accumulatingTransform = false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/rendering/TransformState.h b/WebCore/rendering/TransformState.h
new file mode 100644 (file)
index 0000000..f0b8490
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef TransformState_h
+#define TransformState_h
+
+#include "FloatPoint.h"
+#include "IntSize.h"
+#include "TransformationMatrix.h"
+
+namespace WebCore {
+
+class TransformState {
+public:
+    enum TransformDirection { ApplyTransformDirection, UnapplyInverseTransformDirection };
+    TransformState(const FloatPoint& p, TransformDirection mappingDirection)
+        : m_lastPlanarPoint(p)
+        , m_accumulatingTransform(false)
+        , m_direction(mappingDirection)
+    {
+    }
+
+    void move(const IntSize& s)
+    {
+        move(s.width(), s.height());
+    }
+    
+    void move(int x, int y);
+    void applyTransform(const TransformationMatrix& transformFromContainer, bool accumulateTransform);
+    void flatten();
+
+    FloatPoint m_lastPlanarPoint;
+    TransformationMatrix m_accumulatedTransform;
+    bool m_accumulatingTransform;
+    TransformDirection m_direction;
+};
+
+} // namespace WebCore
+
+#endif // TransformState_h
index d2cf8b11da59d8d8769e0a651ce3f1762f2e4459..ee696db9e7784fa260bb8f0b64c5259dca66f30f 100644 (file)
@@ -669,6 +669,7 @@ public:
     ETransformStyle3D transformStyle3D() const { return rareNonInheritedData->m_transformStyle3D; }
     EBackfaceVisibility backfaceVisibility() const { return rareNonInheritedData->m_backfaceVisibility; }
     float perspective() const { return rareNonInheritedData->m_perspective; }
+    bool hasPerspective() const { return rareNonInheritedData->m_perspective > 0; }
     Length perspectiveOriginX() const { return rareNonInheritedData->m_perspectiveOriginX; }
     Length perspectiveOriginY() const { return rareNonInheritedData->m_perspectiveOriginY; }