| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, Google Inc. All rights reserved. | 2 * Copyright (c) 2012, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "platform/geometry/LayoutBoxExtent.h" | 32 #include "platform/geometry/LayoutBoxExtent.h" |
| 33 | 33 |
| 34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 LayoutUnit LayoutBoxExtent::logicalTop() const | 38 LayoutUnit LayoutBoxExtent::logicalTop() const |
| 39 { | 39 { |
| 40 return isHorizontalWritingMode() ? m_top : m_left; | 40 return m_top; |
| 41 } | 41 } |
| 42 | 42 |
| 43 LayoutUnit LayoutBoxExtent::logicalBottom() const | 43 LayoutUnit LayoutBoxExtent::logicalBottom() const |
| 44 { | 44 { |
| 45 return isHorizontalWritingMode() ? m_bottom : m_right; | 45 return m_bottom; |
| 46 } | 46 } |
| 47 | 47 |
| 48 LayoutUnit LayoutBoxExtent::logicalLeft() const | 48 LayoutUnit LayoutBoxExtent::logicalLeft() const |
| 49 { | 49 { |
| 50 return isHorizontalWritingMode() ? m_left : m_top; | 50 return m_left; |
| 51 } | 51 } |
| 52 | 52 |
| 53 LayoutUnit LayoutBoxExtent::logicalRight() const | 53 LayoutUnit LayoutBoxExtent::logicalRight() const |
| 54 { | 54 { |
| 55 return isHorizontalWritingMode() ? m_right : m_bottom; | 55 return m_right; |
| 56 } | 56 } |
| 57 | 57 |
| 58 LayoutUnit LayoutBoxExtent::before() const | 58 LayoutUnit LayoutBoxExtent::before() const |
| 59 { | 59 { |
| 60 // FIXME(sky): Remove | 60 // FIXME(sky): Remove |
| 61 return m_top; | 61 return m_top; |
| 62 } | 62 } |
| 63 | 63 |
| 64 LayoutUnit LayoutBoxExtent::after() const | 64 LayoutUnit LayoutBoxExtent::after() const |
| 65 { | 65 { |
| 66 // FIXME(sky): Remove | 66 // FIXME(sky): Remove |
| 67 return m_bottom; | 67 return m_bottom; |
| 68 } | 68 } |
| 69 | 69 |
| 70 LayoutUnit LayoutBoxExtent::start(TextDirection direction) const | 70 LayoutUnit LayoutBoxExtent::start(TextDirection direction) const |
| 71 { | 71 { |
| 72 if (isHorizontalWritingMode()) | 72 return isLeftToRightDirection(direction) ? m_left : m_right; |
| 73 return isLeftToRightDirection(direction) ? m_left : m_right; | |
| 74 return isLeftToRightDirection(direction) ? m_top : m_bottom; | |
| 75 } | 73 } |
| 76 | 74 |
| 77 LayoutUnit LayoutBoxExtent::end(TextDirection direction) const | 75 LayoutUnit LayoutBoxExtent::end(TextDirection direction) const |
| 78 { | 76 { |
| 79 if (isHorizontalWritingMode()) | 77 return isLeftToRightDirection(direction) ? m_right : m_left; |
| 80 return isLeftToRightDirection(direction) ? m_right : m_left; | |
| 81 return isLeftToRightDirection(direction) ? m_bottom : m_top; | |
| 82 } | 78 } |
| 83 | 79 |
| 84 void LayoutBoxExtent::setBefore(LayoutUnit value) | 80 void LayoutBoxExtent::setBefore(LayoutUnit value) |
| 85 { | 81 { |
| 86 // FIXME(sky): Remove | 82 // FIXME(sky): Remove |
| 87 m_top = value; | 83 m_top = value; |
| 88 } | 84 } |
| 89 | 85 |
| 90 void LayoutBoxExtent::setAfter(LayoutUnit value) | 86 void LayoutBoxExtent::setAfter(LayoutUnit value) |
| 91 { | 87 { |
| 92 // FIXME(sky): Remove | 88 // FIXME(sky): Remove |
| 93 m_bottom = value; | 89 m_bottom = value; |
| 94 } | 90 } |
| 95 | 91 |
| 96 void LayoutBoxExtent::setStart(TextDirection direction, LayoutUnit value) | 92 void LayoutBoxExtent::setStart(TextDirection direction, LayoutUnit value) |
| 97 { | 93 { |
| 98 if (isHorizontalWritingMode()) { | 94 if (isLeftToRightDirection(direction)) |
| 99 if (isLeftToRightDirection(direction)) | 95 m_left = value; |
| 100 m_left = value; | 96 else |
| 101 else | 97 m_right = value; |
| 102 m_right = value; | |
| 103 } else { | |
| 104 if (isLeftToRightDirection(direction)) | |
| 105 m_top = value; | |
| 106 else | |
| 107 m_bottom = value; | |
| 108 } | |
| 109 } | 98 } |
| 110 | 99 |
| 111 void LayoutBoxExtent::setEnd(TextDirection direction, LayoutUnit value) | 100 void LayoutBoxExtent::setEnd(TextDirection direction, LayoutUnit value) |
| 112 { | 101 { |
| 113 if (isHorizontalWritingMode()) { | 102 if (isLeftToRightDirection(direction)) |
| 114 if (isLeftToRightDirection(direction)) | 103 m_right = value; |
| 115 m_right = value; | 104 else |
| 116 else | 105 m_left = value; |
| 117 m_left = value; | |
| 118 } else { | |
| 119 if (isLeftToRightDirection(direction)) | |
| 120 m_bottom = value; | |
| 121 else | |
| 122 m_top = value; | |
| 123 } | |
| 124 } | 106 } |
| 125 | 107 |
| 126 LayoutUnit& LayoutBoxExtent::mutableLogicalLeft() | 108 LayoutUnit& LayoutBoxExtent::mutableLogicalLeft() |
| 127 { | 109 { |
| 128 return isHorizontalWritingMode() ? m_left : m_top; | 110 return m_left; |
| 129 } | 111 } |
| 130 | 112 |
| 131 LayoutUnit& LayoutBoxExtent::mutableLogicalRight() | 113 LayoutUnit& LayoutBoxExtent::mutableLogicalRight() |
| 132 { | 114 { |
| 133 return isHorizontalWritingMode() ? m_right : m_bottom; | 115 return m_right; |
| 134 } | 116 } |
| 135 | 117 |
| 136 LayoutUnit& LayoutBoxExtent::mutableBefore() | 118 LayoutUnit& LayoutBoxExtent::mutableBefore() |
| 137 { | 119 { |
| 138 return isHorizontalWritingMode() ? | 120 return m_top; |
| 139 (isFlippedBlocksWritingMode() ? m_bottom : m_top) : | |
| 140 (isFlippedBlocksWritingMode() ? m_right: m_left); | |
| 141 } | 121 } |
| 142 | 122 |
| 143 LayoutUnit& LayoutBoxExtent::mutableAfter() | 123 LayoutUnit& LayoutBoxExtent::mutableAfter() |
| 144 { | 124 { |
| 145 return isHorizontalWritingMode() ? | 125 return m_bottom; |
| 146 (isFlippedBlocksWritingMode() ? m_top : m_bottom) : | |
| 147 (isFlippedBlocksWritingMode() ? m_left: m_right); | |
| 148 } | 126 } |
| 149 | 127 |
| 150 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |