Changeset 166752 in webkit


Ignore:
Timestamp:
Apr 3, 2014 4:04:49 PM (10 years ago)
Author:
Bem Jones-Bey
Message:

Merge ShapeInfo & ShapeOutsideInfo now that ShapeInsideInfo is no more
https://bugs.webkit.org/show_bug.cgi?id=131180

Reviewed by Andreas Kling.

Now that ShapeInsideInfo is gone, having a class hiearachy and
templates doesn't make any sense. As a first step to cleaning up the
code, this remove ShapeInfo and puts all of its functionality into
ShapeOutsideInfo.

No new tests, no behavior change.

  • CMakeLists.txt:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • rendering/shapes/ShapeInfo.cpp: Removed.
  • rendering/shapes/ShapeInfo.h: Removed.
  • rendering/shapes/ShapeOutsideInfo.cpp:

(WebCore::ShapeOutsideInfo::computedShapePhysicalBoundingBox):
(WebCore::ShapeOutsideInfo::shapeToRendererPoint):
(WebCore::ShapeOutsideInfo::shapeToRendererSize):
(WebCore::referenceBox):
(WebCore::ShapeOutsideInfo::setReferenceBoxLogicalSize):
(WebCore::checkShapeImageOrigin):
(WebCore::getShapeImageAndRect):
(WebCore::getShapeImageMarginRect):
(WebCore::ShapeOutsideInfo::computedShape):
(WebCore::borderBeforeInWritingMode):
(WebCore::borderAndPaddingBeforeInWritingMode):
(WebCore::ShapeOutsideInfo::logicalTopOffset):
(WebCore::borderStartWithStyleForWritingMode):
(WebCore::borderAndPaddingStartWithStyleForWritingMode):
(WebCore::ShapeOutsideInfo::logicalLeftOffset):
(WebCore::ShapeOutsideInfo::computeSegmentsForLine):
(WebCore::ShapeOutsideInfo::updateDeltasForContainingBlockLine):
(WebCore::ShapeOutsideInfo::shapeValue): Deleted.
(WebCore::ShapeOutsideInfo::styleForWritingMode): Deleted.

  • rendering/shapes/ShapeOutsideInfo.h:
Location:
trunk/Source/WebCore
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r166657 r166752  
    22222222    rendering/shapes/RectangleShape.cpp
    22232223    rendering/shapes/Shape.cpp
    2224     rendering/shapes/ShapeInfo.cpp
    22252224    rendering/shapes/ShapeOutsideInfo.cpp
    22262225
  • trunk/Source/WebCore/ChangeLog

    r166751 r166752  
     12014-04-03  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        Merge ShapeInfo & ShapeOutsideInfo now that ShapeInsideInfo is no more
     4        https://bugs.webkit.org/show_bug.cgi?id=131180
     5
     6        Reviewed by Andreas Kling.
     7
     8        Now that ShapeInsideInfo is gone, having a class hiearachy and
     9        templates doesn't make any sense. As a first step to cleaning up the
     10        code, this remove ShapeInfo and puts all of its functionality into
     11        ShapeOutsideInfo.
     12
     13        No new tests, no behavior change.
     14
     15        * CMakeLists.txt:
     16        * WebCore.vcxproj/WebCore.vcxproj:
     17        * WebCore.vcxproj/WebCore.vcxproj.filters:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * rendering/shapes/ShapeInfo.cpp: Removed.
     20        * rendering/shapes/ShapeInfo.h: Removed.
     21        * rendering/shapes/ShapeOutsideInfo.cpp:
     22        (WebCore::ShapeOutsideInfo::computedShapePhysicalBoundingBox):
     23        (WebCore::ShapeOutsideInfo::shapeToRendererPoint):
     24        (WebCore::ShapeOutsideInfo::shapeToRendererSize):
     25        (WebCore::referenceBox):
     26        (WebCore::ShapeOutsideInfo::setReferenceBoxLogicalSize):
     27        (WebCore::checkShapeImageOrigin):
     28        (WebCore::getShapeImageAndRect):
     29        (WebCore::getShapeImageMarginRect):
     30        (WebCore::ShapeOutsideInfo::computedShape):
     31        (WebCore::borderBeforeInWritingMode):
     32        (WebCore::borderAndPaddingBeforeInWritingMode):
     33        (WebCore::ShapeOutsideInfo::logicalTopOffset):
     34        (WebCore::borderStartWithStyleForWritingMode):
     35        (WebCore::borderAndPaddingStartWithStyleForWritingMode):
     36        (WebCore::ShapeOutsideInfo::logicalLeftOffset):
     37        (WebCore::ShapeOutsideInfo::computeSegmentsForLine):
     38        (WebCore::ShapeOutsideInfo::updateDeltasForContainingBlockLine):
     39        (WebCore::ShapeOutsideInfo::shapeValue): Deleted.
     40        (WebCore::ShapeOutsideInfo::styleForWritingMode): Deleted.
     41        * rendering/shapes/ShapeOutsideInfo.h:
     42
    1432014-04-03  Andreas Kling  <akling@apple.com>
    244
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r166657 r166752  
    1131211312    <ClCompile Include="..\rendering\shapes\RectangleShape.cpp" />
    1131311313    <ClCompile Include="..\rendering\shapes\Shape.cpp" />
    11314     <ClCompile Include="..\rendering\shapes\ShapeInfo.cpp" />
    1131511314    <ClCompile Include="..\rendering\shapes\ShapeOutsideInfo.cpp" />
    1131611315    <ClCompile Include="..\rendering\svg\SVGPathData.cpp">
     
    2005920058    <ClInclude Include="..\rendering\shapes\RectangleShape.h" />
    2006020059    <ClInclude Include="..\rendering\shapes\Shape.h" />
    20061     <ClInclude Include="..\rendering\shapes\ShapeInfo.h" />
    2006220060    <ClInclude Include="..\rendering\shapes\ShapeInterval.h" />
    2006320061    <ClInclude Include="..\rendering\shapes\ShapeOutsideInfo.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r166657 r166752  
    68036803      <Filter>rendering\shapes</Filter>
    68046804    </ClCompile>
    6805     <ClCompile Include="..\rendering\shapes\ShapeInfo.cpp">
    6806       <Filter>rendering\shapes</Filter>
    6807     </ClCompile>
    68086805    <ClCompile Include="..\rendering\shapes\ShapeInsideInfo.cpp">
    68096806      <Filter>rendering\shapes</Filter>
     
    1464214639    </ClInclude>
    1464314640    <ClInclude Include="..\rendering\shapes\Shape.h">
    14644       <Filter>rendering\shapes</Filter>
    14645     </ClInclude>
    14646     <ClInclude Include="..\rendering\shapes\ShapeInfo.h">
    1464714641      <Filter>rendering\shapes</Filter>
    1464814642    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r166719 r166752  
    63936393                FD359190138DB22000E1EBEC /* AudioParamTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = FD35918E138DB22000E1EBEC /* AudioParamTimeline.h */; };
    63946394                FD45A94F175D3F3E00C21EC8 /* Shape.h in Headers */ = {isa = PBXBuildFile; fileRef = FD08A87F175D3926002CD360 /* Shape.h */; settings = {ATTRIBUTES = (Private, ); }; };
    6395                 FD45A950175D3F3E00C21EC8 /* ShapeInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = FD08A881175D3926002CD360 /* ShapeInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
    63966395                FD45A952175D3F3E00C21EC8 /* ShapeOutsideInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = FD08A887175D3926002CD360 /* ShapeOutsideInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
    63976396                FD45A953175D3FB800C21EC8 /* Shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD08A87E175D3926002CD360 /* Shape.cpp */; };
    6398                 FD45A954175D3FB800C21EC8 /* ShapeInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD08A880175D3926002CD360 /* ShapeInfo.cpp */; };
    63996397                FD45A956175D3FB800C21EC8 /* ShapeOutsideInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD08A886175D3926002CD360 /* ShapeOutsideInfo.cpp */; };
    64006398                FD45A957175D414C00C21EC8 /* PolygonShape.h in Headers */ = {isa = PBXBuildFile; fileRef = FD08A87B175D3926002CD360 /* PolygonShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1370713705                FD08A87E175D3926002CD360 /* Shape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shape.cpp; sourceTree = "<group>"; };
    1370813706                FD08A87F175D3926002CD360 /* Shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shape.h; sourceTree = "<group>"; };
    13709                 FD08A880175D3926002CD360 /* ShapeInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeInfo.cpp; sourceTree = "<group>"; };
    13710                 FD08A881175D3926002CD360 /* ShapeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeInfo.h; sourceTree = "<group>"; };
    1371113707                FD08A885175D3926002CD360 /* ShapeInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeInterval.h; sourceTree = "<group>"; };
    1371213708                FD08A886175D3926002CD360 /* ShapeOutsideInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeOutsideInfo.cpp; sourceTree = "<group>"; };
     
    2254122537                                FD08A87E175D3926002CD360 /* Shape.cpp */,
    2254222538                                FD08A87F175D3926002CD360 /* Shape.h */,
    22543                                 FD08A880175D3926002CD360 /* ShapeInfo.cpp */,
    22544                                 FD08A881175D3926002CD360 /* ShapeInfo.h */,
    2254522539                                FD08A885175D3926002CD360 /* ShapeInterval.h */,
    2254622540                                FD08A886175D3926002CD360 /* ShapeOutsideInfo.cpp */,
     
    2549225486                                A6D169641346B4C1000EB770 /* ShadowRoot.h in Headers */,
    2549325487                                FD45A94F175D3F3E00C21EC8 /* Shape.h in Headers */,
    25494                                 FD45A950175D3F3E00C21EC8 /* ShapeInfo.h in Headers */,
    2549525488                                FD45A95B175D41EE00C21EC8 /* ShapeInterval.h in Headers */,
    2549625489                                FD45A952175D3F3E00C21EC8 /* ShapeOutsideInfo.h in Headers */,
     
    2886528858                                A6D169621346B49B000EB770 /* ShadowRoot.cpp in Sources */,
    2886628859                                FD45A953175D3FB800C21EC8 /* Shape.cpp in Sources */,
    28867                                 FD45A954175D3FB800C21EC8 /* ShapeInfo.cpp in Sources */,
    2886828860                                FD45A956175D3FB800C21EC8 /* ShapeOutsideInfo.cpp in Sources */,
    2886928861                                1A4A954D0B4EDCCB002D8C3C /* SharedBuffer.cpp in Sources */,
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp

    r164363 r166752  
    3434#include "ShapeOutsideInfo.h"
    3535
     36#include "BoxShape.h"
    3637#include "FloatingObjects.h"
     38#include "LengthFunctions.h"
    3739#include "RenderBlockFlow.h"
    3840#include "RenderBox.h"
     41#include "RenderImage.h"
     42#include "RenderRegion.h"
    3943
    4044namespace WebCore {
     45
     46LayoutRect ShapeOutsideInfo::computedShapePhysicalBoundingBox() const
     47{
     48    LayoutRect physicalBoundingBox = computedShape().shapeMarginLogicalBoundingBox();
     49    physicalBoundingBox.setX(physicalBoundingBox.x() + logicalLeftOffset());
     50    physicalBoundingBox.setY(physicalBoundingBox.y() + logicalTopOffset());
     51    if (m_renderer.style().isFlippedBlocksWritingMode())
     52        physicalBoundingBox.setY(m_renderer.logicalHeight() - physicalBoundingBox.maxY());
     53    if (!m_renderer.style().isHorizontalWritingMode())
     54        physicalBoundingBox = physicalBoundingBox.transposedRect();
     55    return physicalBoundingBox;
     56}
     57
     58FloatPoint ShapeOutsideInfo::shapeToRendererPoint(FloatPoint point) const
     59{
     60    FloatPoint result = FloatPoint(point.x() + logicalLeftOffset(), point.y() + logicalTopOffset());
     61    if (m_renderer.style().isFlippedBlocksWritingMode())
     62        result.setY(m_renderer.logicalHeight() - result.y());
     63    if (!m_renderer.style().isHorizontalWritingMode())
     64        result = result.transposedPoint();
     65    return result;
     66}
     67
     68FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const
     69{
     70    if (!m_renderer.style().isHorizontalWritingMode())
     71        return size.transposedSize();
     72    return size;
     73}
     74
     75static inline CSSBoxType referenceBox(ShapeValue* shapeValue)
     76{
     77    if (shapeValue->cssBox() == BoxMissing) {
     78        if (shapeValue->type() == ShapeValue::Image)
     79            return ContentBox;
     80        return MarginBox;
     81    }
     82    return shapeValue->cssBox();
     83}
     84
     85void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize)
     86{
     87    bool isHorizontalWritingMode = m_renderer.containingBlock()->style().isHorizontalWritingMode();
     88    switch (referenceBox(m_renderer.style().shapeOutside())) {
     89    case MarginBox:
     90        if (isHorizontalWritingMode)
     91            newReferenceBoxLogicalSize.expand(m_renderer.horizontalMarginExtent(), m_renderer.verticalMarginExtent());
     92        else
     93            newReferenceBoxLogicalSize.expand(m_renderer.verticalMarginExtent(), m_renderer.horizontalMarginExtent());
     94        break;
     95    case BorderBox:
     96        break;
     97    case PaddingBox:
     98        if (isHorizontalWritingMode)
     99            newReferenceBoxLogicalSize.shrink(m_renderer.horizontalBorderExtent(), m_renderer.verticalBorderExtent());
     100        else
     101            newReferenceBoxLogicalSize.shrink(m_renderer.verticalBorderExtent(), m_renderer.horizontalBorderExtent());
     102        break;
     103    case ContentBox:
     104        if (isHorizontalWritingMode)
     105            newReferenceBoxLogicalSize.shrink(m_renderer.horizontalBorderAndPaddingExtent(), m_renderer.verticalBorderAndPaddingExtent());
     106        else
     107            newReferenceBoxLogicalSize.shrink(m_renderer.verticalBorderAndPaddingExtent(), m_renderer.horizontalBorderAndPaddingExtent());
     108        break;
     109    case Fill:
     110    case Stroke:
     111    case ViewBox:
     112    case BoxMissing:
     113        ASSERT_NOT_REACHED();
     114        break;
     115    }
     116
     117    if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize)
     118        return;
     119    markShapeAsDirty();
     120    m_referenceBoxLogicalSize = newReferenceBoxLogicalSize;
     121}
     122
     123static inline bool checkShapeImageOrigin(Document& document, CachedImage& cachedImage)
     124{
     125    if (cachedImage.isOriginClean(document.securityOrigin()))
     126        return true;
     127
     128    const URL& url = cachedImage.url();
     129    String urlString = url.isNull() ? "''" : url.stringCenterEllipsizedToLength();
     130    document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, "Unsafe attempt to load URL " + urlString + ".");
     131
     132    return false;
     133}
     134
     135static void getShapeImageAndRect(const ShapeValue* shapeValue, const RenderBox* renderBox, const LayoutSize& referenceBoxSize, Image*& image, LayoutRect& rect)
     136{
     137    ASSERT(shapeValue->isImageValid());
     138    StyleImage* styleImage = shapeValue->image();
     139
     140    const IntSize& imageSize = renderBox->calculateImageIntrinsicDimensions(styleImage, roundedIntSize(referenceBoxSize), RenderImage::ScaleByEffectiveZoom);
     141    styleImage->setContainerSizeForRenderer(renderBox, imageSize, renderBox->style().effectiveZoom());
     142
     143    image = styleImage->cachedImage()->imageForRenderer(renderBox);
     144    if (renderBox->isRenderImage())
     145        rect = toRenderImage(renderBox)->replacedContentRect(renderBox->intrinsicSize());
     146    else
     147        rect = LayoutRect(LayoutPoint(), imageSize);
     148}
     149
     150static LayoutRect getShapeImageMarginRect(const RenderBox& renderBox, const LayoutSize& referenceBoxLogicalSize)
     151{
     152    LayoutPoint marginBoxOrigin(-renderBox.marginLogicalLeft() - renderBox.borderAndPaddingLogicalLeft(), -renderBox.marginBefore() - renderBox.borderBefore() - renderBox.paddingBefore());
     153    LayoutSize marginBoxSizeDelta(renderBox.marginLogicalWidth() + renderBox.borderAndPaddingLogicalWidth(), renderBox.marginLogicalHeight() + renderBox.borderAndPaddingLogicalHeight());
     154    return LayoutRect(marginBoxOrigin, referenceBoxLogicalSize + marginBoxSizeDelta);
     155}
     156
     157const Shape& ShapeOutsideInfo::computedShape() const
     158{
     159    if (Shape* shape = m_shape.get())
     160        return *shape;
     161
     162    WritingMode writingMode = m_renderer.containingBlock()->style().writingMode();
     163    Length margin = m_renderer.style().shapeMargin();
     164    float shapeImageThreshold = m_renderer.style().shapeImageThreshold();
     165    const ShapeValue* shapeValue = this->m_renderer.style().shapeOutside();
     166    ASSERT(shapeValue);
     167
     168    switch (shapeValue->type()) {
     169    case ShapeValue::Shape:
     170        ASSERT(shapeValue->shape());
     171        m_shape = Shape::createShape(shapeValue->shape(), m_referenceBoxLogicalSize, writingMode, margin);
     172        break;
     173    case ShapeValue::Image: {
     174        Image* image;
     175        LayoutRect imageRect;
     176        getShapeImageAndRect(shapeValue, &m_renderer, m_referenceBoxLogicalSize, image, imageRect);
     177        const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referenceBoxLogicalSize);
     178        m_shape = Shape::createRasterShape(image, shapeImageThreshold, imageRect, marginRect, writingMode, margin);
     179        break;
     180    }
     181    case ShapeValue::Box: {
     182        RoundedRect shapeRect = computeRoundedRectForBoxShape(referenceBox(m_renderer.style().shapeOutside()), m_renderer);
     183        if (!m_renderer.containingBlock()->style().isHorizontalWritingMode())
     184            shapeRect = shapeRect.transposedRect();
     185        m_shape = Shape::createBoxShape(shapeRect, writingMode, margin);
     186        break;
     187    }
     188    case ShapeValue::Outside:
     189        // Outside should have already resolved to a different shape value
     190        ASSERT_NOT_REACHED();
     191    }
     192
     193    ASSERT(m_shape);
     194    return *m_shape;
     195}
     196
     197static inline LayoutUnit borderBeforeInWritingMode(const RenderBox& renderer, WritingMode writingMode)
     198{
     199    switch (writingMode) {
     200    case TopToBottomWritingMode: return renderer.borderTop();
     201    case BottomToTopWritingMode: return renderer.borderBottom();
     202    case LeftToRightWritingMode: return renderer.borderLeft();
     203    case RightToLeftWritingMode: return renderer.borderRight();
     204    }
     205
     206    ASSERT_NOT_REACHED();
     207    return renderer.borderBefore();
     208}
     209
     210static inline LayoutUnit borderAndPaddingBeforeInWritingMode(const RenderBox& renderer, WritingMode writingMode)
     211{
     212    switch (writingMode) {
     213    case TopToBottomWritingMode: return renderer.borderTop() + renderer.paddingTop();
     214    case BottomToTopWritingMode: return renderer.borderBottom() + renderer.paddingBottom();
     215    case LeftToRightWritingMode: return renderer.borderLeft() + renderer.paddingLeft();
     216    case RightToLeftWritingMode: return renderer.borderRight() + renderer.paddingRight();
     217    }
     218
     219    ASSERT_NOT_REACHED();
     220    return renderer.borderAndPaddingBefore();
     221}
     222
     223LayoutUnit ShapeOutsideInfo::logicalTopOffset() const
     224{
     225    switch (referenceBox(m_renderer.style().shapeOutside())) {
     226    case MarginBox: return -m_renderer.marginBefore(&m_renderer.containingBlock()->style());
     227    case BorderBox: return LayoutUnit();
     228    case PaddingBox: return borderBeforeInWritingMode(m_renderer, m_renderer.containingBlock()->style().writingMode());
     229    case ContentBox: return borderAndPaddingBeforeInWritingMode(m_renderer, m_renderer.containingBlock()->style().writingMode());
     230    case Fill: break;
     231    case Stroke: break;
     232    case ViewBox: break;
     233    case BoxMissing: break;
     234    }
     235   
     236    ASSERT_NOT_REACHED();
     237    return LayoutUnit();
     238}
     239
     240static inline LayoutUnit borderStartWithStyleForWritingMode(const RenderBox& renderer, const RenderStyle& style)
     241{
     242    if (style.isHorizontalWritingMode()) {
     243        if (style.isLeftToRightDirection())
     244            return renderer.borderLeft();
     245       
     246        return renderer.borderRight();
     247    }
     248    if (style.isLeftToRightDirection())
     249        return renderer.borderTop();
     250   
     251    return renderer.borderBottom();
     252}
     253
     254static inline LayoutUnit borderAndPaddingStartWithStyleForWritingMode(const RenderBox& renderer, const RenderStyle& style)
     255{
     256    if (style.isHorizontalWritingMode()) {
     257        if (style.isLeftToRightDirection())
     258            return renderer.borderLeft() + renderer.paddingLeft();
     259       
     260        return renderer.borderRight() + renderer.paddingRight();
     261    }
     262    if (style.isLeftToRightDirection())
     263        return renderer.borderTop() + renderer.paddingTop();
     264   
     265    return renderer.borderBottom() + renderer.paddingBottom();
     266}
     267
     268LayoutUnit ShapeOutsideInfo::logicalLeftOffset() const
     269{
     270    if (m_renderer.isRenderRegion())
     271        return LayoutUnit();
     272   
     273    switch (referenceBox(m_renderer.style().shapeOutside())) {
     274    case MarginBox: return -m_renderer.marginStart(&m_renderer.containingBlock()->style());
     275    case BorderBox: return LayoutUnit();
     276    case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, m_renderer.containingBlock()->style());
     277    case ContentBox: return borderAndPaddingStartWithStyleForWritingMode(m_renderer, m_renderer.containingBlock()->style());
     278    case Fill: break;
     279    case Stroke: break;
     280    case ViewBox: break;
     281    case BoxMissing: break;
     282    }
     283   
     284    ASSERT_NOT_REACHED();
     285    return LayoutUnit();
     286}
    41287
    42288bool ShapeOutsideInfo::isEnabledFor(const RenderBox& box)
     
    60306}
    61307
     308SegmentList ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const
     309{
     310    ASSERT(lineHeight >= 0);
     311    SegmentList segments;
     312
     313    computedShape().getExcludedIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments);
     314
     315    for (size_t i = 0; i < segments.size(); i++) {
     316        segments[i].logicalLeft += logicalLeftOffset();
     317        segments[i].logicalRight += logicalLeftOffset();
     318    }
     319   
     320    return segments;
     321}
     322
    62323void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
    63324{
     
    72333        LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&floatingObject);
    73334
    74         if (lineOverlapsShapeBounds()) {
     335        if (computedShape().lineOverlapsShapeMarginBounds(m_referenceBoxLineTop, m_lineHeight)) {
    75336            SegmentList segments = computeSegmentsForLine(borderBoxLineTop, lineHeight);
    76337            if (segments.size()) {
     
    96357}
    97358
    98 ShapeValue* ShapeOutsideInfo::shapeValue() const
    99 {
    100     return m_renderer.style().shapeOutside();
    101 }
    102 
    103 const RenderStyle& ShapeOutsideInfo::styleForWritingMode() const
    104 {
    105     ASSERT(m_renderer.containingBlock());
    106     return m_renderer.containingBlock()->style();
    107 }
    108 
    109359}
    110360
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h

    r165843 r166752  
    3333#if ENABLE(CSS_SHAPES)
    3434
     35#include "FloatRect.h"
    3536#include "LayoutSize.h"
    36 #include "ShapeInfo.h"
     37#include "LayoutUnit.h"
     38#include "RenderStyle.h"
     39#include "Shape.h"
     40#include "ShapeValue.h"
     41#include <memory>
    3742
    3843namespace WebCore {
     
    4247class FloatingObject;
    4348
    44 class ShapeOutsideInfo final : public ShapeInfo<RenderBox>, public MappedInfo<RenderBox, ShapeOutsideInfo> {
     49class ShapeOutsideInfo final {
     50    WTF_MAKE_FAST_ALLOCATED;
    4551public:
    4652    ShapeOutsideInfo(const RenderBox& renderer)
    47         : ShapeInfo<RenderBox>(renderer)
     53        : m_renderer(renderer)
    4854        , m_lineOverlapsShape(false)
    4955    {
     
    5864    void updateDeltasForContainingBlockLine(const RenderBlockFlow&, const FloatingObject&, LayoutUnit lineTop, LayoutUnit lineHeight);
    5965
    60     virtual bool lineOverlapsShapeBounds() const override
     66    void setReferenceBoxLogicalSize(LayoutSize);
     67
     68    LayoutUnit shapeLogicalTop() const { return computedShape().shapeMarginLogicalBoundingBox().y() + logicalTopOffset(); }
     69    LayoutUnit shapeLogicalBottom() const { return computedShape().shapeMarginLogicalBoundingBox().maxY() + logicalTopOffset(); }
     70    LayoutUnit shapeLogicalLeft() const { return computedShape().shapeMarginLogicalBoundingBox().x() + logicalLeftOffset(); }
     71    LayoutUnit shapeLogicalRight() const { return computedShape().shapeMarginLogicalBoundingBox().maxX() + logicalLeftOffset(); }
     72    LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLogicalBoundingBox().width(); }
     73    LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLogicalBoundingBox().height(); }
     74
     75    LayoutUnit logicalLineTop() const { return m_referenceBoxLineTop + logicalTopOffset(); }
     76    LayoutUnit logicalLineBottom() const { return m_referenceBoxLineTop + m_lineHeight + logicalTopOffset(); }
     77    LayoutUnit logicalLineBottom(LayoutUnit lineHeight) const { return m_referenceBoxLineTop + lineHeight + logicalTopOffset(); }
     78
     79    void markShapeAsDirty() { m_shape = nullptr; }
     80    bool isShapeDirty() { return !m_shape; }
     81
     82    LayoutRect computedShapePhysicalBoundingBox() const;
     83    FloatPoint shapeToRendererPoint(FloatPoint) const;
     84    FloatSize shapeToRendererSize(FloatSize) const;
     85
     86    const Shape& computedShape() const;
     87
     88    static ShapeOutsideInfo& ensureInfo(const RenderBox& key)
    6189    {
    62         return computedShape().lineOverlapsShapeMarginBounds(m_referenceBoxLineTop, m_lineHeight);
     90        InfoMap& infoMap = ShapeOutsideInfo::infoMap();
     91        if (ShapeOutsideInfo* info = infoMap.get(&key))
     92            return *info;
     93        auto result = infoMap.add(&key, std::make_unique<ShapeOutsideInfo>(key));
     94        return *result.iterator->value;
     95    }
     96    static void removeInfo(const RenderBox& key) { infoMap().remove(&key); }
     97    static ShapeOutsideInfo* info(const RenderBox& key) { return infoMap().get(&key); }
     98
     99private:
     100    SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const;
     101
     102    LayoutUnit logicalTopOffset() const;
     103    LayoutUnit logicalLeftOffset() const;
     104
     105    typedef HashMap<const RenderBox*, std::unique_ptr<ShapeOutsideInfo>> InfoMap;
     106    static InfoMap& infoMap()
     107    {
     108        DEPRECATED_DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ());
     109        return staticInfoMap;
    63110    }
    64111
    65 protected:
    66     virtual CSSBoxType referenceBox() const override
    67     {
    68         if (shapeValue()->cssBox() == BoxMissing) {
    69             if (shapeValue()->type() == ShapeValue::Image)
    70                 return ContentBox;
    71             return MarginBox;
    72         }
    73         return shapeValue()->cssBox();
    74     }
     112    const RenderBox& m_renderer;
    75113
    76 private:
    77     virtual LayoutRect computedShapeLogicalBoundingBox() const override { return computedShape().shapeMarginLogicalBoundingBox(); }
    78     virtual ShapeValue* shapeValue() const override;
    79     virtual void getIntervals(LayoutUnit lineTop, LayoutUnit lineHeight, SegmentList& segments) const override
    80     {
    81         return computedShape().getExcludedIntervals(lineTop, lineHeight, segments);
    82     }
    83 
    84     virtual const RenderStyle& styleForWritingMode() const override;
     114    mutable std::unique_ptr<Shape> m_shape;
     115    LayoutSize m_referenceBoxLogicalSize;
     116    LayoutUnit m_referenceBoxLineTop;
     117    LayoutUnit m_lineHeight;
    85118
    86119    LayoutUnit m_leftMarginBoxDelta;
Note: See TracChangeset for help on using the changeset viewer.