109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)/* 209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All right reserved. 409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2010 Google Inc. All rights reserved. 509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2013 Adobe Systems Incorporated. 609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * 709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * This library is free software; you can redistribute it and/or 809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * modify it under the terms of the GNU Library General Public 909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * License as published by the Free Software Foundation; either 1009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * version 2 of the License, or (at your option) any later version. 1109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * 1209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * This library is distributed in the hope that it will be useful, 1309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of 1409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Library General Public License for more details. 1609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * 1709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * You should have received a copy of the GNU Library General Public License 1809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * along with this library; see the file COPYING.LIB. If not, write to 1909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 2009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Boston, MA 02110-1301, USA. 2109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * 2209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) */ 2309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 2409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "config.h" 2509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/rendering/line/BreakingContextInlineHeaders.h" 2609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 27c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 2809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 2909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)InlineIterator BreakingContext::handleEndOfLine() 3009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 3107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (m_lineBreak == m_resolver.position() && (!m_lineBreak.object() || !m_lineBreak.object()->isBR())) { 3209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // we just add as much as possible 3309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (m_blockStyle->whiteSpace() == PRE && !m_current.offset()) { 3409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_lineBreak.moveTo(m_lastObject, m_lastObject->isText() ? m_lastObject->length() : 0); 3509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } else if (m_lineBreak.object()) { 3609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // Don't ever break in the middle of a word if we can help it. 3709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // There's no room at all. We just have to be on this line, 3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // even though we'll spill out. 3909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_lineBreak.moveTo(m_current.object(), m_current.offset()); 4009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 4109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 4209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 4309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // FIXME Bug 100049: We do not need to consume input in a multi-segment line 4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // unless no segment will. 4507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (m_lineBreak == m_resolver.position()) 4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_lineBreak.increment(); 4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // Sanity check our midpoints. 4909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_lineMidpointState.checkMidpoints(m_lineBreak); 5009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 51f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) m_trailingObjects.updateMidpointsForTrailingObjects(m_lineMidpointState, m_lineBreak, TrailingObjects::CollapseFirstSpace); 5209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 5309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // We might have made lineBreak an iterator that points past the end 5409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // of the object. Do this adjustment to make it point to the start 5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // of the next object instead to avoid confusing the rest of the 5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // code. 5709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (m_lineBreak.offset()) { 5809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // This loop enforces the invariant that line breaks should never point 5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // at an empty inline. See http://crbug.com/305904. 6009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) do { 6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_lineBreak.setOffset(m_lineBreak.offset() - 1); 6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) m_lineBreak.increment(); 6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.object())); 6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return m_lineBreak; 6709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 6909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 70