Changeset 117832 in webkit


Ignore:
Timestamp:
May 21, 2012 4:42:54 PM (12 years ago)
Author:
eae@chromium.org
Message:

Move padding/margin/offset writing mode logic from RenderStyle to LengthBox
https://bugs.webkit.org/show_bug.cgi?id=86970

Reviewed by Eric Seidel.

Move writing mode and bidi logic for paddings, margins and offsets from
RenderStyle to LengthBox. This way the same logic can be used for all
three removing unnecessary code duplication.

No new tests, no change in functionality.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/LengthBox.cpp: Added.
  • platform/LengthBox.h:
  • rendering/style/RenderStyle.cpp:
  • rendering/style/RenderStyle.h:
Location:
trunk/Source/WebCore
Files:
1 added
10 edited

Legend:

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

    r117795 r117832  
    11141114    platform/Language.cpp
    11151115    platform/Length.cpp
     1116    platform/LengthBox.cpp
    11161117    platform/LinkHash.cpp
    11171118    platform/Logging.cpp
  • trunk/Source/WebCore/ChangeLog

    r117826 r117832  
     12012-05-21  Emil A Eklund  <eae@chromium.org>
     2
     3        Move padding/margin/offset writing mode logic from RenderStyle to LengthBox
     4        https://bugs.webkit.org/show_bug.cgi?id=86970
     5
     6        Reviewed by Eric Seidel.
     7
     8        Move writing mode and bidi logic for paddings, margins and offsets from
     9        RenderStyle to LengthBox. This way the same logic can be used for all
     10        three removing unnecessary code duplication.
     11
     12        No new tests, no change in functionality.
     13
     14        * CMakeLists.txt:
     15        * GNUmakefile.list.am:
     16        * Target.pri:
     17        * WebCore.gypi:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * platform/LengthBox.cpp: Added.
     21        * platform/LengthBox.h:
     22        * rendering/style/RenderStyle.cpp:
     23        * rendering/style/RenderStyle.h:
     24
    1252012-05-21  Mike West  <mkwst@chromium.org>
    226
  • trunk/Source/WebCore/GNUmakefile.list.am

    r117612 r117832  
    33843384        Source/WebCore/platform/Language.cpp \
    33853385        Source/WebCore/platform/Language.h \
     3386        Source/WebCore/platform/LengthBox.cpp \
    33863387        Source/WebCore/platform/LengthBox.h \
    33873388        Source/WebCore/platform/Length.cpp \
  • trunk/Source/WebCore/Target.pri

    r117420 r117832  
    11441144    platform/Language.cpp \
    11451145    platform/Length.cpp \
     1146    platform/LengthBox.cpp \
    11461147    platform/text/LineEnding.cpp \
    11471148    platform/leveldb/LevelDBDatabase.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r117750 r117832  
    31603160            'platform/Language.cpp',
    31613161            'platform/Length.cpp',
     3162            'platform/LengthBox.cpp',
    31623163            'platform/LinkHash.cpp',
    31633164            'platform/Logging.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r117750 r117832  
    2784727847                        </File>
    2784827848                        <File
     27849                                RelativePath="..\platform\LengthBox.cpp"
     27850                                >
     27851                        </File>
     27852                        <File
    2784927853                                RelativePath="..\platform\LengthBox.h"
    2785027854                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r117738 r117832  
    300300                144FCFE114EF2509000D17A3 /* FractionalLayoutRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 144FCFDF14EF2509000D17A3 /* FractionalLayoutRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
    301301                1464E06C135EC10600FDB00A /* JSMediaListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */; };
     302                146CC115156988E400109E37 /* LengthBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 146CC113156988BD00109E37 /* LengthBox.cpp */; };
    302303                1477E7760BF4134A00152872 /* PageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1477E7740BF4134A00152872 /* PageCache.cpp */; };
    303304                1477E7770BF4134A00152872 /* PageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1477E7750BF4134A00152872 /* PageCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    71857186                144FCFDF14EF2509000D17A3 /* FractionalLayoutRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutRect.h; sourceTree = "<group>"; };
    71867187                1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaListCustom.cpp; sourceTree = "<group>"; };
     7188                146CC113156988BD00109E37 /* LengthBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthBox.cpp; sourceTree = "<group>"; };
    71877189                1477E7740BF4134A00152872 /* PageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PageCache.cpp; sourceTree = "<group>"; };
    71887190                1477E7750BF4134A00152872 /* PageCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PageCache.h; sourceTree = "<group>"; };
     
    2032920331                                BCE65BE80EACDF16007E4533 /* Length.cpp */,
    2033020332                                BCE65BE90EACDF16007E4533 /* Length.h */,
     20333                                146CC113156988BD00109E37 /* LengthBox.cpp */,
    2033120334                                BCFF648F0EAD15C200C1D6F7 /* LengthBox.h */,
    2033220335                                BCFF64900EAD15C200C1D6F7 /* LengthSize.h */,
     
    2793827941                                FDB052DF1561A42C00B500D6 /* AudioSummingJunction.cpp in Sources */,
    2793927942                                371941961566B37200A276D8 /* WebCoreNSCellExtras.m in Sources */,
     27943                                146CC115156988E400109E37 /* LengthBox.cpp in Sources */,
    2794027944                        );
    2794127945                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/platform/LengthBox.h

    r61295 r117832  
    22    Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    33    Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
     4    Copyright (c) 2012, Google Inc. All rights reserved.
    45
    56    This library is free software; you can redistribute it and/or
     
    2526
    2627namespace WebCore {
     28
     29class RenderStyle;
    2730
    2831struct LengthBox {
     
    6871    Length bottom() const { return m_bottom; }
    6972
     73    Length logicalLeft(const RenderStyle*) const;
     74    Length logicalRight(const RenderStyle*) const;
     75
     76    Length before(const RenderStyle*) const;
     77    Length after(const RenderStyle*) const;
     78    Length start(const RenderStyle*) const;
     79    Length end(const RenderStyle*) const;
     80
    7081    bool operator==(const LengthBox& o) const
    7182    {
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r117613 r117832  
    14131413    return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth();
    14141414}
    1415    
    1416 Length RenderStyle::marginBefore() const
    1417 {
    1418     switch (writingMode()) {
    1419     case TopToBottomWritingMode:
    1420         return marginTop();
    1421     case BottomToTopWritingMode:
    1422         return marginBottom();
    1423     case LeftToRightWritingMode:
    1424         return marginLeft();
    1425     case RightToLeftWritingMode:
    1426         return marginRight();
    1427     }
    1428     ASSERT_NOT_REACHED();
    1429     return marginTop();
    1430 }
    1431 
    1432 Length RenderStyle::marginAfter() const
    1433 {
    1434     switch (writingMode()) {
    1435     case TopToBottomWritingMode:
    1436         return marginBottom();
    1437     case BottomToTopWritingMode:
    1438         return marginTop();
    1439     case LeftToRightWritingMode:
    1440         return marginRight();
    1441     case RightToLeftWritingMode:
    1442         return marginLeft();
    1443     }
    1444     ASSERT_NOT_REACHED();
    1445     return marginBottom();
    1446 }
    1447 
    1448 Length RenderStyle::marginBeforeUsing(const RenderStyle* otherStyle) const
    1449 {
    1450     switch (otherStyle->writingMode()) {
    1451     case TopToBottomWritingMode:
    1452         return marginTop();
    1453     case BottomToTopWritingMode:
    1454         return marginBottom();
    1455     case LeftToRightWritingMode:
    1456         return marginLeft();
    1457     case RightToLeftWritingMode:
    1458         return marginRight();
    1459     }
    1460     ASSERT_NOT_REACHED();
    1461     return marginTop();
    1462 }
    1463 
    1464 Length RenderStyle::marginAfterUsing(const RenderStyle* otherStyle) const
    1465 {
    1466     switch (otherStyle->writingMode()) {
    1467     case TopToBottomWritingMode:
    1468         return marginBottom();
    1469     case BottomToTopWritingMode:
    1470         return marginTop();
    1471     case LeftToRightWritingMode:
    1472         return marginRight();
    1473     case RightToLeftWritingMode:
    1474         return marginLeft();
    1475     }
    1476     ASSERT_NOT_REACHED();
    1477     return marginBottom();
    1478 }
    1479 
    1480 Length RenderStyle::marginStart() const
    1481 {
    1482     if (isHorizontalWritingMode())
    1483         return isLeftToRightDirection() ? marginLeft() : marginRight();
    1484     return isLeftToRightDirection() ? marginTop() : marginBottom();
    1485 }
    1486 
    1487 Length RenderStyle::marginEnd() const
    1488 {
    1489     if (isHorizontalWritingMode())
    1490         return isLeftToRightDirection() ? marginRight() : marginLeft();
    1491     return isLeftToRightDirection() ? marginBottom() : marginTop();
    1492 }
    1493    
    1494 Length RenderStyle::marginStartUsing(const RenderStyle* otherStyle) const
    1495 {
    1496     if (otherStyle->isHorizontalWritingMode())
    1497         return otherStyle->isLeftToRightDirection() ? marginLeft() : marginRight();
    1498     return otherStyle->isLeftToRightDirection() ? marginTop() : marginBottom();
    1499 }
    1500 
    1501 Length RenderStyle::marginEndUsing(const RenderStyle* otherStyle) const
    1502 {
    1503     if (otherStyle->isHorizontalWritingMode())
    1504         return otherStyle->isLeftToRightDirection() ? marginRight() : marginLeft();
    1505     return otherStyle->isLeftToRightDirection() ? marginBottom() : marginTop();
    1506 }
    15071415
    15081416void RenderStyle::setMarginStart(Length margin)
     
    15361444}
    15371445
    1538 Length RenderStyle::paddingBefore() const
    1539 {
    1540     switch (writingMode()) {
    1541     case TopToBottomWritingMode:
    1542         return paddingTop();
    1543     case BottomToTopWritingMode:
    1544         return paddingBottom();
    1545     case LeftToRightWritingMode:
    1546         return paddingLeft();
    1547     case RightToLeftWritingMode:
    1548         return paddingRight();
    1549     }
    1550     ASSERT_NOT_REACHED();
    1551     return paddingTop();
    1552 }
    1553 
    1554 Length RenderStyle::paddingAfter() const
    1555 {
    1556     switch (writingMode()) {
    1557     case TopToBottomWritingMode:
    1558         return paddingBottom();
    1559     case BottomToTopWritingMode:
    1560         return paddingTop();
    1561     case LeftToRightWritingMode:
    1562         return paddingRight();
    1563     case RightToLeftWritingMode:
    1564         return paddingLeft();
    1565     }
    1566     ASSERT_NOT_REACHED();
    1567     return paddingBottom();
    1568 }
    1569 
    1570 Length RenderStyle::paddingStart() const
    1571 {
    1572     if (isHorizontalWritingMode())
    1573         return isLeftToRightDirection() ? paddingLeft() : paddingRight();
    1574     return isLeftToRightDirection() ? paddingTop() : paddingBottom();
    1575 }
    1576 
    1577 Length RenderStyle::paddingEnd() const
    1578 {
    1579     if (isHorizontalWritingMode())
    1580         return isLeftToRightDirection() ? paddingRight() : paddingLeft();
    1581     return isLeftToRightDirection() ? paddingBottom() : paddingTop();
    1582 }
    1583 
    15841446TextEmphasisMark RenderStyle::textEmphasisMark() const
    15851447{
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r117613 r117832  
    499499
    500500    // Accessors for positioned object edges that take into account writing mode.
    501     Length logicalLeft() const { return isHorizontalWritingMode() ? left() : top(); }
    502     Length logicalRight() const { return isHorizontalWritingMode() ? right() : bottom(); }
    503     Length logicalTop() const { return isHorizontalWritingMode() ? (isFlippedBlocksWritingMode() ? bottom() : top()) : (isFlippedBlocksWritingMode() ? right() : left()); }
    504     Length logicalBottom() const { return isHorizontalWritingMode() ? (isFlippedBlocksWritingMode() ? top() : bottom()) : (isFlippedBlocksWritingMode() ? left() : right()); }
     501    Length logicalLeft() const { return surround->offset.logicalLeft(this); }
     502    Length logicalRight() const { return surround->offset.logicalRight(this); }
     503    Length logicalTop() const { return surround->offset.before(this); }
     504    Length logicalBottom() const { return surround->offset.after(this); }
    505505
    506506    // Whether or not a positioned element requires normal flow x/y to be computed
     
    739739    Length marginLeft() const { return surround->margin.left(); }
    740740    Length marginRight() const { return surround->margin.right(); }
    741     Length marginBefore() const;
    742     Length marginAfter() const;
    743     Length marginStart() const;
    744     Length marginEnd() const;
    745     Length marginStartUsing(const RenderStyle* otherStyle) const;
    746     Length marginEndUsing(const RenderStyle* otherStyle) const;
    747     Length marginBeforeUsing(const RenderStyle* otherStyle) const;
    748     Length marginAfterUsing(const RenderStyle* otherStyle) const;
     741    Length marginBefore() const { return surround->margin.before(this); }
     742    Length marginAfter() const { return surround->margin.after(this); }
     743    Length marginStart() const { return surround->margin.start(this); }
     744    Length marginEnd() const { return surround->margin.end(this); }
     745    Length marginStartUsing(const RenderStyle* otherStyle) const { return surround->margin.start(otherStyle); }
     746    Length marginEndUsing(const RenderStyle* otherStyle) const { return surround->margin.end(otherStyle); }
     747    Length marginBeforeUsing(const RenderStyle* otherStyle) const { return surround->margin.before(otherStyle); }
     748    Length marginAfterUsing(const RenderStyle* otherStyle) const { return surround->margin.after(otherStyle); }
    749749
    750750    LengthBox paddingBox() const { return surround->padding; }
     
    753753    Length paddingLeft() const { return surround->padding.left(); }
    754754    Length paddingRight() const { return surround->padding.right(); }
    755     Length paddingBefore() const;
    756     Length paddingAfter() const;
    757     Length paddingStart() const;
    758     Length paddingEnd() const;
     755    Length paddingBefore() const { return surround->padding.before(this); }
     756    Length paddingAfter() const { return surround->padding.after(this); }
     757    Length paddingStart() const { return surround->padding.start(this); }
     758    Length paddingEnd() const { return surround->padding.end(this); }
    759759
    760760    ECursor cursor() const { return static_cast<ECursor>(inherited_flags._cursor_style); }
Note: See TracChangeset for help on using the changeset viewer.