Changeset 144520 in webkit


Ignore:
Timestamp:
Mar 1, 2013 5:16:29 PM (11 years ago)
Author:
betravis@adobe.com
Message:

[css exclusions] Move ExclusionShapeInsideInfo into RenderBlockRareData
https://bugs.webkit.org/show_bug.cgi?id=110995

Reviewed by Julien Chaffraix.

This patch moves ExclusionShapeInsideInfo into the RenderBlockRareData struct,
which enables us to move away from the global ExclusionShapeInsideInfo map.
Some additional refactoring was done to remove ExclusionShapeInsideInfo's
dependency on InlineIterator, which depended on RenderBlock. This work required
adding a new LineSegmentIterator struct.

Refactoring, no new tests.

  • rendering/ExclusionShapeInsideInfo.cpp:

(WebCore):
(WebCore::LineSegmentRange::LineSegmentRange): Moving the InlineIterator
constructor to the .cpp file, as InlineIterator is now forward declared in
the .h file.
(WebCore::ExclusionShapeInsideInfo::isEnabledFor): Moving isEnabledFor to
the .cpp file, as RenderBlock is now forward declared in the .h file.

  • rendering/ExclusionShapeInsideInfo.h:

(WebCore):
(LineSegmentIterator): A simple struct for containing segment positions for
layout.
(WebCore::LineSegmentIterator::LineSegmentIterator): Constructor.
(LineSegmentRange): Transitioning to store LineSegmentIterator.
(WebCore::LineSegmentRange::LineSegmentRange): Ditto.
(ExclusionShapeInsideInfo):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::willBeDestroyed): Destroying a block will now destroy
its ExclusionShapeInsideInfo, so there is no need to remove it from the map.
(WebCore):
(WebCore::RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange): Use
the RenderBlockRareData struct rather than the global map.

  • rendering/RenderBlock.h:

(WebCore):
(WebCore::RenderBlock::ensureExclusionShapeInsideInfo): Ensure an info struct
is present if the shape-inside style is set.
(WebCore::RenderBlock::exclusionShapeInsideInfo): Look up the info struct for
the current block.
(WebCore::RenderBlock::setExclusionShapeInsideInfo): Update the info struct
for the current block.
(RenderBlockRareData): Add the ExclusionShapeInsideInfo member.

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::constructBidiRunsForLine): Construct the appropriate offsets during
layout based on the stored LineSegmentIterators.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r144519 r144520  
     12013-03-01  Bear Travis  <betravis@adobe.com>
     2
     3        [css exclusions] Move ExclusionShapeInsideInfo into RenderBlockRareData
     4        https://bugs.webkit.org/show_bug.cgi?id=110995
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        This patch moves ExclusionShapeInsideInfo into the RenderBlockRareData struct,
     9        which enables us to move away from the global ExclusionShapeInsideInfo map.
     10        Some additional refactoring was done to remove ExclusionShapeInsideInfo's
     11        dependency on InlineIterator, which depended on RenderBlock. This work required
     12        adding a new LineSegmentIterator struct.
     13
     14        Refactoring, no new tests.
     15
     16        * rendering/ExclusionShapeInsideInfo.cpp:
     17        (WebCore):
     18        (WebCore::LineSegmentRange::LineSegmentRange): Moving the InlineIterator
     19        constructor to the .cpp file, as InlineIterator is now forward declared in
     20        the .h file.
     21        (WebCore::ExclusionShapeInsideInfo::isEnabledFor): Moving isEnabledFor to
     22        the .cpp file, as RenderBlock is now forward declared in the .h file.
     23        * rendering/ExclusionShapeInsideInfo.h:
     24        (WebCore):
     25        (LineSegmentIterator): A simple struct for containing segment positions for
     26        layout.
     27        (WebCore::LineSegmentIterator::LineSegmentIterator): Constructor.
     28        (LineSegmentRange): Transitioning to store LineSegmentIterator.
     29        (WebCore::LineSegmentRange::LineSegmentRange): Ditto.
     30        (ExclusionShapeInsideInfo):
     31        * rendering/RenderBlock.cpp:
     32        (WebCore::RenderBlock::willBeDestroyed): Destroying a block will now destroy
     33        its ExclusionShapeInsideInfo, so there is no need to remove it from the map.
     34        (WebCore):
     35        (WebCore::RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange): Use
     36        the RenderBlockRareData struct rather than the global map.
     37        * rendering/RenderBlock.h:
     38        (WebCore):
     39        (WebCore::RenderBlock::ensureExclusionShapeInsideInfo): Ensure an info struct
     40        is present if the shape-inside style is set.
     41        (WebCore::RenderBlock::exclusionShapeInsideInfo): Look up the info struct for
     42        the current block.
     43        (WebCore::RenderBlock::setExclusionShapeInsideInfo): Update the info struct
     44        for the current block.
     45        (RenderBlockRareData): Add the ExclusionShapeInsideInfo member.
     46        * rendering/RenderBlockLineLayout.cpp:
     47        (WebCore::constructBidiRunsForLine): Construct the appropriate offsets during
     48        layout based on the stored LineSegmentIterators.
     49
    1502013-03-01  Terry Anderson  <tdanderson@chromium.org>
    251
  • trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp

    r142164 r144520  
    3333#if ENABLE(CSS_EXCLUSIONS)
    3434
     35#include "InlineIterator.h"
    3536#include "RenderBlock.h"
    3637
    3738namespace WebCore {
     39
     40LineSegmentRange::LineSegmentRange(const InlineIterator& start, const InlineIterator& end)
     41    : start(start.root(), start.object(), start.offset())
     42    , end(end.root(), end.object(), end.offset())
     43    {
     44    }
     45
     46bool ExclusionShapeInsideInfo::isEnabledFor(const RenderBlock* renderer)
     47{
     48    ExclusionShapeValue* shapeValue = renderer->style()->resolvedShapeInside();
     49    return (shapeValue && shapeValue->type() == ExclusionShapeValue::SHAPE) ? shapeValue->shape() : 0;
     50}
     51
    3852bool ExclusionShapeInsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
    3953{
  • trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.h

    r144487 r144520  
    3434
    3535#include "ExclusionShapeInfo.h"
    36 #include "InlineIterator.h"
    3736#include <wtf/PassOwnPtr.h>
    3837#include <wtf/Vector.h>
     
    4039namespace WebCore {
    4140
     41class InlineIterator;
    4242class RenderBlock;
     43class RenderObject;
    4344
    44 struct LineSegmentRange {
    45     InlineIterator start;
    46     InlineIterator end;
    47     LineSegmentRange(InlineIterator start, InlineIterator end)
    48         : start(start)
    49         , end(end)
     45struct LineSegmentIterator {
     46    RenderObject* root;
     47    RenderObject* object;
     48    unsigned offset;
     49    LineSegmentIterator(RenderObject* root, RenderObject* object, unsigned offset)
     50        : root(root)
     51        , object(object)
     52        , offset(offset)
    5053    {
    5154    }
    5255};
     56
     57struct LineSegmentRange {
     58    LineSegmentIterator start;
     59    LineSegmentIterator end;
     60    LineSegmentRange(const InlineIterator& start, const InlineIterator& end);
     61};
     62
    5363typedef Vector<LineSegmentRange> SegmentRangeList;
    5464
    55 class ExclusionShapeInsideInfo : public ExclusionShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside>, public MappedInfo<RenderBlock, ExclusionShapeInsideInfo> {
     65class ExclusionShapeInsideInfo : public ExclusionShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside> {
    5666public:
    5767    static PassOwnPtr<ExclusionShapeInsideInfo> createInfo(const RenderBlock* renderer) { return adoptPtr(new ExclusionShapeInsideInfo(renderer)); }
    5868
    59     static bool isEnabledFor(const RenderBlock* renderer)
    60     {
    61         ExclusionShapeValue* shapeValue = renderer->style()->resolvedShapeInside();
    62         return (shapeValue && shapeValue->type() == ExclusionShapeValue::SHAPE) ? shapeValue->shape() : 0;
    63     }
     69    static bool isEnabledFor(const RenderBlock* renderer);
    6470    bool lineOverlapsShapeBounds() const { return logicalLineTop() < shapeLogicalBottom() && logicalLineBottom() >= shapeLogicalTop(); }
    6571
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r144497 r144520  
    297297        lineGridBox()->destroy(renderArena());
    298298
    299 #if ENABLE(CSS_EXCLUSIONS)
    300     ExclusionShapeInsideInfo::removeInfo(this);
    301 #endif
    302 
    303299    if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0))
    304300        gDelayedUpdateScrollInfoSet->remove(this);
     
    13951391
    13961392#if ENABLE(CSS_EXCLUSIONS)
    1397 ExclusionShapeInsideInfo* RenderBlock::exclusionShapeInsideInfo() const
    1398 {
    1399     return style()->resolvedShapeInside() && ExclusionShapeInsideInfo::isEnabledFor(this) ? ExclusionShapeInsideInfo::info(this) : 0;
    1400 }
    1401 
    14021393void RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange(const ExclusionShapeValue* shapeInside, const ExclusionShapeValue* oldShapeInside)
    14031394{
     
    14071398
    14081399    if (shapeInside) {
    1409         ExclusionShapeInsideInfo* exclusionShapeInsideInfo = ExclusionShapeInsideInfo::ensureInfo(this);
     1400        ExclusionShapeInsideInfo* exclusionShapeInsideInfo = ensureExclusionShapeInsideInfo();
    14101401        exclusionShapeInsideInfo->dirtyShapeSize();
    14111402    } else
    1412         ExclusionShapeInsideInfo::removeInfo(this);
     1403        setExclusionShapeInsideInfo(nullptr);
    14131404}
    14141405#endif
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r144497 r144520  
    3636
    3737#if ENABLE(CSS_EXCLUSIONS)
     38#include "ExclusionShapeInsideInfo.h"
    3839#include "ExclusionShapeValue.h"
    3940#endif
     
    5556#if ENABLE(CSS_EXCLUSIONS)
    5657class BasicShape;
    57 class ExclusionShapeInsideInfo;
    5858#endif
    5959class TextLayout;
     
    447447
    448448#if ENABLE(CSS_EXCLUSIONS)
    449     ExclusionShapeInsideInfo* exclusionShapeInsideInfo() const;
     449    ExclusionShapeInsideInfo* ensureExclusionShapeInsideInfo()
     450    {
     451        if (!m_rareData || !m_rareData->m_shapeInsideInfo)
     452            setExclusionShapeInsideInfo(ExclusionShapeInsideInfo::createInfo(this));
     453        return m_rareData->m_shapeInsideInfo.get();
     454    }
     455    ExclusionShapeInsideInfo* exclusionShapeInsideInfo() const
     456    {
     457        return m_rareData && m_rareData->m_shapeInsideInfo && ExclusionShapeInsideInfo::isEnabledFor(this) ? m_rareData->m_shapeInsideInfo.get() : 0;
     458    }
     459    void setExclusionShapeInsideInfo(PassOwnPtr<ExclusionShapeInsideInfo> value)
     460    {
     461        if (!m_rareData)
     462            m_rareData = adoptPtr(new RenderBlockRareData(this));
     463        m_rareData->m_shapeInsideInfo = value;
     464    }
    450465    ExclusionShapeInsideInfo* layoutExclusionShapeInsideInfo() const;
    451466    bool allowsExclusionShapeInsideInfoSharing() const { return !isInline() && !isFloating(); }
     
    12361251
    12371252        RootInlineBox* m_lineBreakToAvoidWidow;
     1253#if ENABLE(CSS_EXCLUSIONS)
     1254        OwnPtr<ExclusionShapeInsideInfo> m_shapeInsideInfo;
     1255#endif
    12381256        bool m_shouldBreakAtLineToAvoidWidow : 1;
    12391257        bool m_discardMarginBefore : 1;
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r144497 r144520  
    12851285
    12861286    for (size_t i = 0; i < segmentRanges.size(); i++) {
    1287         InlineIterator segmentStart = segmentRanges[i].start;
    1288         InlineIterator segmentEnd = segmentRanges[i].end;
     1287        LineSegmentIterator iterator = segmentRanges[i].start;
     1288        InlineIterator segmentStart(iterator.root, iterator.object, iterator.offset);
     1289        iterator = segmentRanges[i].end;
     1290        InlineIterator segmentEnd(iterator.root, iterator.object, iterator.offset);
    12891291        if (i) {
    12901292            ASSERT(segmentStart.m_obj);
Note: See TracChangeset for help on using the changeset viewer.