2010-02-12 Nikolas Zimmermann <nzimmermann@rim.com>
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Feb 2010 22:18:46 +0000 (22:18 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Feb 2010 22:18:46 +0000 (22:18 +0000)
commitd43f4fc4a3736717ba3b9ac585754b0b12614cfd
treeb1d6e9704aa3d072526a1cae95136bed5c5fd59c
parentbcc8a3d4b90e19609762db52813645a9b569e493
2010-02-12  Nikolas Zimmermann  <nzimmermann@rim.com>

        Reviewed by Dirk Schulze.

        Repaint bug on Text selection in foreignObject
        https://bugs.webkit.org/show_bug.cgi?id=16939

        Tests: svg/overflow/overflow-on-foreignObject.svg
               svg/text/foreignObject-text-clipping-bug.xml

        Selecting text contained in <foreignObject> leads to artefacts. Same for zooming/panning.
        RenderForeignObject contained old legacy code returning FloatRect() for repaintRectInLocalCoordinates,
        which is obviously wrong. Fixing that leads to even more problems, as the underlying RenderBlock
        did not reflect the x/y translation set on the <foreignObject>. This is problematic, as laying out
        positioned objects in the XHTML subtree depends on proper size/location values of the frameRect.

        Correctly clip on overflow="hidden". overflow="scroll" & friends are not yet supported, see lengthy
        comment in RenderSVGBlock why we either need RenderLayer for RenderForeignObject or need to rework
        overflow handling to avoid RenderLayer.

        SVGForeignObjectElement uses a hacky custom solution to synchronize CSS width/height properties with
        the SVG width/height attributes. Remove all of that code and just implement calcWidth/calcHeight in
        RenderForeignObject, grabbing the right values from SVGForeignObjectElement::width/height upon layout.

        * rendering/RenderForeignObject.cpp:
        (WebCore::RenderForeignObject::paint): Clip properly to the actual bounds of the foreignObject, respecting that x/y translation is handled by RenderBlock now.
        (WebCore::RenderForeignObject::clippedOverflowRectForRepaint): Added missing function, forward to SVGRenderBase just like all other SVG renderers.
        (WebCore::RenderForeignObject::computeRectForRepaint): Remove manual implementation, forward to SVGRenderBase.
        (WebCore::RenderForeignObject::localToParentTransform): Respect x/y translation here _after_ applying localTransform().
        (WebCore::RenderForeignObject::calcWidth): Override RenderBlock::calcWidth to grab width() from SVGForeignObjectElement.
        (WebCore::RenderForeignObject::calcHeight): Override RenderBlock::calcHeight to grab height() from SVGForeignObjectElement.
        (WebCore::RenderForeignObject::layout): Calculate viewport once and cache it. Push x/y location down to RenderBlock - analogous to RenderSVGText.
        (WebCore::RenderForeignObject::nodeAtFloatPoint): Adapt to x/y translation changes (map through localTransform, not localToParentTransform). Respect overflow clipping.
        (WebCore::RenderForeignObject::mapLocalToContainer): Set useTransforms=true, to avoid assertions when selecting text in foreign objects.
        * rendering/RenderForeignObject.h:
        (WebCore::RenderForeignObject::objectBoundingBox): Return cached m_viewport.
        (WebCore::RenderForeignObject::strokeBoundingBox): Ditto.
        (WebCore::RenderForeignObject::repaintRectInLocalCoordinates): Ditto.
        * rendering/RenderSVGBlock.cpp:
        (WebCore::RenderSVGBlock::setStyle): Cleanup code, move setHasOverflowClip() overrides in updateBoxModelInfoFromStyle where it belongs.
        (WebCore::RenderSVGBlock::updateBoxModelInfoFromStyle): Added to force setting setHasOverflowClip(false).
        * rendering/RenderSVGBlock.h:
        * svg/SVGForeignObjectElement.cpp: Kill a lot of custom code - it was just plain wrong to utilize CSS to push width/height information down to RenderBlock.
        (WebCore::SVGForeignObjectElement::svgAttributeChanged):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@54735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
53 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-leopard/svg/custom/foreign-object-skew-expected.checksum
LayoutTests/platform/mac-leopard/svg/custom/foreign-object-skew-expected.png
LayoutTests/platform/mac/svg/custom/baseval-animval-equality-expected.txt
LayoutTests/platform/mac/svg/custom/dominant-baseline-hanging-expected.txt
LayoutTests/platform/mac/svg/custom/dynamic-svg-document-creation-expected.txt
LayoutTests/platform/mac/svg/custom/fill-SVGPaint-interface-expected.txt
LayoutTests/platform/mac/svg/custom/foreign-object-skew-expected.txt
LayoutTests/platform/mac/svg/custom/foreignObject-crash-on-hover-expected.txt
LayoutTests/platform/mac/svg/custom/getPresentationAttribute-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-1-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-1-expected.png
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-1-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-2-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-2-expected.png
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-2-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-3-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-3-expected.png
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-3-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-4-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-4-expected.png
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-4-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-5-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-5-expected.png
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-5-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-6-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-6-expected.png
LayoutTests/platform/mac/svg/custom/use-on-disallowed-foreign-object-6-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-g-containing-foreignObject-and-image-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-non-svg-namespaced-element-expected.checksum
LayoutTests/platform/mac/svg/custom/use-on-non-svg-namespaced-element-expected.png
LayoutTests/platform/mac/svg/custom/use-on-non-svg-namespaced-element-expected.txt
LayoutTests/platform/mac/svg/hixie/mixed/008-expected.txt
LayoutTests/platform/mac/svg/overflow/overflow-on-foreignObject-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/overflow/overflow-on-foreignObject-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/overflow/overflow-on-foreignObject-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/text/foreignObject-repaint-expected.txt
LayoutTests/platform/mac/svg/text/foreignObject-text-clipping-bug-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/text/foreignObject-text-clipping-bug-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/text/foreignObject-text-clipping-bug-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/baseval-animval-equality.svg
LayoutTests/svg/custom/dominant-baseline-hanging.svg
LayoutTests/svg/custom/dynamic-svg-document-creation.svg
LayoutTests/svg/custom/fill-SVGPaint-interface.svg
LayoutTests/svg/custom/getPresentationAttribute.svg
LayoutTests/svg/overflow/overflow-on-foreignObject.svg [new file with mode: 0644]
LayoutTests/svg/text/foreignObject-text-clipping-bug.xml [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderForeignObject.cpp
WebCore/rendering/RenderForeignObject.h
WebCore/rendering/RenderSVGBlock.cpp
WebCore/rendering/RenderSVGBlock.h
WebCore/svg/SVGForeignObjectElement.cpp