OLD | NEW |
(Empty) | |
| 1 /* |
| 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. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 6 * |
| 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. |
| 11 * |
| 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. |
| 16 * |
| 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 |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. |
| 21 * |
| 22 */ |
| 23 |
| 24 #include "config.h" |
| 25 #include "core/rendering/line/BreakingContextInlineHeaders.h" |
| 26 |
| 27 namespace WebCore { |
| 28 |
| 29 InlineIterator BreakingContext::handleEndOfLine() |
| 30 { |
| 31 ShapeInsideInfo* shapeInfo = m_block->layoutShapeInsideInfo(); |
| 32 bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); |
| 33 |
| 34 if (m_lineBreak == m_resolver.position() && (!m_lineBreak.object() || !m_lin
eBreak.object()->isBR()) && segmentAllowsOverflow) { |
| 35 // we just add as much as possible |
| 36 if (m_blockStyle->whiteSpace() == PRE && !m_current.offset()) { |
| 37 m_lineBreak.moveTo(m_lastObject, m_lastObject->isText() ? m_lastObje
ct->length() : 0); |
| 38 } else if (m_lineBreak.object()) { |
| 39 // Don't ever break in the middle of a word if we can help it. |
| 40 // There's no room at all. We just have to be on this line, |
| 41 // even though we'll spill out. |
| 42 m_lineBreak.moveTo(m_current.object(), m_current.offset()); |
| 43 } |
| 44 } |
| 45 |
| 46 // FIXME Bug 100049: We do not need to consume input in a multi-segment line |
| 47 // unless no segment will. |
| 48 // make sure we consume at least one char/object. |
| 49 if (m_lineBreak == m_resolver.position() && segmentAllowsOverflow) |
| 50 m_lineBreak.increment(); |
| 51 |
| 52 // Sanity check our midpoints. |
| 53 m_lineMidpointState.checkMidpoints(m_lineBreak); |
| 54 |
| 55 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidpointState, m_lin
eBreak, TrailingObjects::CollapseFirstSpace); |
| 56 |
| 57 // We might have made lineBreak an iterator that points past the end |
| 58 // of the object. Do this adjustment to make it point to the start |
| 59 // of the next object instead to avoid confusing the rest of the |
| 60 // code. |
| 61 if (m_lineBreak.offset()) { |
| 62 // This loop enforces the invariant that line breaks should never point |
| 63 // at an empty inline. See http://crbug.com/305904. |
| 64 do { |
| 65 m_lineBreak.setOffset(m_lineBreak.offset() - 1); |
| 66 m_lineBreak.increment(); |
| 67 } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.object())); |
| 68 } |
| 69 |
| 70 return m_lineBreak; |
| 71 } |
| 72 |
| 73 } |
OLD | NEW |