Changeset 139891 in webkit


Ignore:
Timestamp:
Jan 16, 2013 10:02:46 AM (11 years ago)
Author:
ojan@chromium.org
Message:

RenderListMarker::computePreferredLogicalWidth should not be public
https://bugs.webkit.org/show_bug.cgi?id=106956

Reviewed by Tony Chang.

RenderListItem was calling computePreferredLogicalWidths for the side
effects of updating the marker content and margins. Instead, call
updateMarginsAndContent directly.

  • rendering/RenderListItem.cpp:

(WebCore::RenderListItem::updateMarkerLocation):

  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::layout):
The isImage() codepath never calls computePreferredLogicalWidths, so we need to make
sure the content and margins are updated.

(WebCore::RenderListMarker::updateContent):
(WebCore::RenderListMarker::computePreferredLogicalWidths):
(WebCore::RenderListMarker::updateMarginsAndContent):

  • rendering/RenderListMarker.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139890 r139891  
     12013-01-16  Ojan Vafai  <ojan@chromium.org>
     2
     3        RenderListMarker::computePreferredLogicalWidth should not be public
     4        https://bugs.webkit.org/show_bug.cgi?id=106956
     5
     6        Reviewed by Tony Chang.
     7
     8        RenderListItem was calling computePreferredLogicalWidths for the side
     9        effects of updating the marker content and margins. Instead, call
     10        updateMarginsAndContent directly.
     11
     12        * rendering/RenderListItem.cpp:
     13        (WebCore::RenderListItem::updateMarkerLocation):
     14        * rendering/RenderListMarker.cpp:
     15        (WebCore::RenderListMarker::layout):
     16        The isImage() codepath never calls computePreferredLogicalWidths, so we need to make
     17        sure the content and margins are updated.
     18
     19        (WebCore::RenderListMarker::updateContent):
     20        (WebCore::RenderListMarker::computePreferredLogicalWidths):
     21        (WebCore::RenderListMarker::updateMarginsAndContent):
     22        * rendering/RenderListMarker.h:
     23
    1242013-01-16  Claudio Saavedra  <csaavedra@igalia.com>
    225
  • trunk/Source/WebCore/rendering/RenderListItem.cpp

    r139693 r139891  
    266266                lineBoxParent = this;
    267267            lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
    268             if (m_marker->preferredLogicalWidthsDirty())
    269                 m_marker->computePreferredLogicalWidths();
     268            m_marker->updateMarginsAndContent();
    270269            // If markerPar is an anonymous block that has lost all its children, destroy it.
    271270            if (markerPar && markerPar->isAnonymousBlock() && !markerPar->firstChild() && !toRenderBlock(markerPar)->continuation())
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r139789 r139891  
    13191319 
    13201320    if (isImage()) {
     1321        updateMarginsAndContent();
    13211322        setWidth(m_image->imageSize(this, style()->effectiveZoom()).width());
    13221323        setHeight(m_image->imageSize(this, style()->effectiveZoom()).height());
     
    13511352}
    13521353
    1353 void RenderListMarker::computePreferredLogicalWidths()
    1354 {
    1355     ASSERT(preferredLogicalWidthsDirty());
     1354void RenderListMarker::updateMarginsAndContent()
     1355{
     1356    updateContent();
     1357    updateMargins();
     1358}
     1359
     1360void RenderListMarker::updateContent()
     1361{
     1362    // FIXME: This if-statement is just a performance optimization, but it's messy to use the preferredLogicalWidths dirty bit for this.
     1363    // It's unclear if this is a premature optimization.
     1364    if (!preferredLogicalWidthsDirty())
     1365        return;
    13561366
    13571367    m_text = "";
    1358 
    1359     const Font& font = style()->font();
    1360     const FontMetrics& fontMetrics = font.fontMetrics();
    13611368
    13621369    if (isImage()) {
    13631370        // FIXME: This is a somewhat arbitrary width.  Generated images for markers really won't become particularly useful
    13641371        // until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box.
    1365         int bulletWidth = fontMetrics.ascent() / 2;
     1372        int bulletWidth = style()->fontMetrics().ascent() / 2;
    13661373        m_image->setContainerSizeForRenderer(this, IntSize(bulletWidth, bulletWidth), style()->effectiveZoom());
     1374        return;
     1375    }
     1376
     1377    EListStyleType type = style()->listStyleType();
     1378    switch (type) {
     1379    case NoneListStyle:
     1380        break;
     1381    case Circle:
     1382    case Disc:
     1383    case Square:
     1384        m_text = listMarkerText(type, 0); // value is ignored for these types
     1385        break;
     1386    case Asterisks:
     1387    case Footnotes:
     1388    case Afar:
     1389    case Amharic:
     1390    case AmharicAbegede:
     1391    case ArabicIndic:
     1392    case Armenian:
     1393    case BinaryListStyle:
     1394    case Bengali:
     1395    case Cambodian:
     1396    case CJKIdeographic:
     1397    case CjkEarthlyBranch:
     1398    case CjkHeavenlyStem:
     1399    case DecimalLeadingZero:
     1400    case DecimalListStyle:
     1401    case Devanagari:
     1402    case Ethiopic:
     1403    case EthiopicAbegede:
     1404    case EthiopicAbegedeAmEt:
     1405    case EthiopicAbegedeGez:
     1406    case EthiopicAbegedeTiEr:
     1407    case EthiopicAbegedeTiEt:
     1408    case EthiopicHalehameAaEr:
     1409    case EthiopicHalehameAaEt:
     1410    case EthiopicHalehameAmEt:
     1411    case EthiopicHalehameGez:
     1412    case EthiopicHalehameOmEt:
     1413    case EthiopicHalehameSidEt:
     1414    case EthiopicHalehameSoEt:
     1415    case EthiopicHalehameTiEr:
     1416    case EthiopicHalehameTiEt:
     1417    case EthiopicHalehameTig:
     1418    case Georgian:
     1419    case Gujarati:
     1420    case Gurmukhi:
     1421    case Hangul:
     1422    case HangulConsonant:
     1423    case Hebrew:
     1424    case Hiragana:
     1425    case HiraganaIroha:
     1426    case Kannada:
     1427    case Katakana:
     1428    case KatakanaIroha:
     1429    case Khmer:
     1430    case Lao:
     1431    case LowerAlpha:
     1432    case LowerArmenian:
     1433    case LowerGreek:
     1434    case LowerHexadecimal:
     1435    case LowerLatin:
     1436    case LowerNorwegian:
     1437    case LowerRoman:
     1438    case Malayalam:
     1439    case Mongolian:
     1440    case Myanmar:
     1441    case Octal:
     1442    case Oriya:
     1443    case Oromo:
     1444    case Persian:
     1445    case Sidama:
     1446    case Somali:
     1447    case Telugu:
     1448    case Thai:
     1449    case Tibetan:
     1450    case Tigre:
     1451    case TigrinyaEr:
     1452    case TigrinyaErAbegede:
     1453    case TigrinyaEt:
     1454    case TigrinyaEtAbegede:
     1455    case UpperAlpha:
     1456    case UpperArmenian:
     1457    case UpperGreek:
     1458    case UpperHexadecimal:
     1459    case UpperLatin:
     1460    case UpperNorwegian:
     1461    case UpperRoman:
     1462    case Urdu:
     1463        m_text = listMarkerText(type, m_listItem->value());
     1464        break;
     1465    }
     1466}
     1467
     1468void RenderListMarker::computePreferredLogicalWidths()
     1469{
     1470    ASSERT(preferredLogicalWidthsDirty());
     1471    updateContent();
     1472
     1473    if (isImage()) {
    13671474        LayoutSize imageSize = m_image->imageSize(this, style()->effectiveZoom());
    13681475        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height();
     
    13711478        return;
    13721479    }
     1480
     1481    const Font& font = style()->font();
    13731482
    13741483    LayoutUnit logicalWidth = 0;
     
    13791488        case Asterisks:
    13801489        case Footnotes:
    1381             m_text = listMarkerText(type, m_listItem->value());
    13821490            logicalWidth = font.width(m_text); // no suffix for these types
    13831491            break;
     
    13851493        case Disc:
    13861494        case Square:
    1387             m_text = listMarkerText(type, 0); // value is ignored for these types
    1388             logicalWidth = (fontMetrics.ascent() * 2 / 3 + 1) / 2 + 2;
     1495            logicalWidth = (font.fontMetrics().ascent() * 2 / 3 + 1) / 2 + 2;
    13891496            break;
    13901497        case Afar:
     
    14631570        case UpperRoman:
    14641571        case Urdu:
    1465             m_text = listMarkerText(type, m_listItem->value());
    14661572            if (m_text.isEmpty())
    14671573                logicalWidth = 0;
  • trunk/Source/WebCore/rendering/RenderListMarker.h

    r137169 r139891  
    3939    virtual ~RenderListMarker();
    4040
    41     virtual void computePreferredLogicalWidths();
    42 
    4341    const String& text() const { return m_text; }
    4442    String suffix() const;
     
    4846    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
    4947
     48    void updateMarginsAndContent();
     49
    5050private:
    5151    virtual const char* renderName() const { return "RenderListMarker"; }
     52    virtual void computePreferredLogicalWidths() OVERRIDE;
    5253
    5354    virtual bool isListMarker() const { return true; }
     
    7273
    7374    void updateMargins();
     75    void updateContent();
    7476
    7577    virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
Note: See TracChangeset for help on using the changeset viewer.