| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * Copyright (C) 2013 Adobe Systems Incorporated. | 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "core/layout/line/BreakingContextInlineHeaders.h" | 24 #include "core/layout/line/BreakingContextInlineHeaders.h" |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 InlineIterator BreakingContext::handleEndOfLine() | 28 InlineIterator BreakingContext::handleEndOfLine() |
| 29 { | 29 { |
| 30 if (m_lineBreak == m_resolver.position() && (!m_lineBreak.lineLayoutItem() |
| !m_lineBreak.lineLayoutItem().isBR())) { | 30 if (m_lineBreak == m_resolver.position() && (!m_lineBreak.getLineLayoutItem(
) || !m_lineBreak.getLineLayoutItem().isBR())) { |
| 31 // we just add as much as possible | 31 // we just add as much as possible |
| 32 if (m_blockStyle->whiteSpace() == PRE && !m_current.offset()) { | 32 if (m_blockStyle->whiteSpace() == PRE && !m_current.offset()) { |
| 33 m_lineBreak.moveTo(m_lastObject, m_lastObject.isText() ? m_lastObjec
t.length() : 0); | 33 m_lineBreak.moveTo(m_lastObject, m_lastObject.isText() ? m_lastObjec
t.length() : 0); |
| 34 } else if (m_lineBreak.lineLayoutItem()) { | 34 } else if (m_lineBreak.getLineLayoutItem()) { |
| 35 // Don't ever break in the middle of a word if we can help it. | 35 // Don't ever break in the middle of a word if we can help it. |
| 36 // There's no room at all. We just have to be on this line, | 36 // There's no room at all. We just have to be on this line, |
| 37 // even though we'll spill out. | 37 // even though we'll spill out. |
| 38 m_lineBreak.moveTo(m_current.lineLayoutItem(), m_current.offset()); | 38 m_lineBreak.moveTo(m_current.getLineLayoutItem(), m_current.offset()
); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 // FIXME Bug 100049: We do not need to consume input in a multi-segment line | 42 // FIXME Bug 100049: We do not need to consume input in a multi-segment line |
| 43 // unless no segment will. | 43 // unless no segment will. |
| 44 if (m_lineBreak == m_resolver.position()) | 44 if (m_lineBreak == m_resolver.position()) |
| 45 m_lineBreak.increment(); | 45 m_lineBreak.increment(); |
| 46 | 46 |
| 47 // Sanity check our midpoints. | 47 // Sanity check our midpoints. |
| 48 m_lineMidpointState.checkMidpoints(m_lineBreak); | 48 m_lineMidpointState.checkMidpoints(m_lineBreak); |
| 49 | 49 |
| 50 m_trailingObjects.updateMidpointsForTrailingObjects(m_lineMidpointState, m_l
ineBreak, TrailingObjects::CollapseFirstSpace); | 50 m_trailingObjects.updateMidpointsForTrailingObjects(m_lineMidpointState, m_l
ineBreak, TrailingObjects::CollapseFirstSpace); |
| 51 | 51 |
| 52 // We might have made lineBreak an iterator that points past the end | 52 // We might have made lineBreak an iterator that points past the end |
| 53 // of the object. Do this adjustment to make it point to the start | 53 // of the object. Do this adjustment to make it point to the start |
| 54 // of the next object instead to avoid confusing the rest of the | 54 // of the next object instead to avoid confusing the rest of the |
| 55 // code. | 55 // code. |
| 56 if (m_lineBreak.offset()) { | 56 if (m_lineBreak.offset()) { |
| 57 // This loop enforces the invariant that line breaks should never point | 57 // This loop enforces the invariant that line breaks should never point |
| 58 // at an empty inline. See http://crbug.com/305904. | 58 // at an empty inline. See http://crbug.com/305904. |
| 59 do { | 59 do { |
| 60 m_lineBreak.setOffset(m_lineBreak.offset() - 1); | 60 m_lineBreak.setOffset(m_lineBreak.offset() - 1); |
| 61 m_lineBreak.increment(); | 61 m_lineBreak.increment(); |
| 62 } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.lineLayoutIte
m())); | 62 } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.getLineLayout
Item())); |
| 63 } | 63 } |
| 64 | 64 |
| 65 return m_lineBreak; | 65 return m_lineBreak; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace blink | 68 } // namespace blink |
| OLD | NEW |