Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: Source/core/rendering/line/BreakingContextInlineHeaders.h

Issue 300853007: Empty inline elements always get a line box. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // If our original display was an INLINE type, then we can go ahead 355 // If our original display was an INLINE type, then we can go ahead
356 // and determine our static y position now. 356 // and determine our static y position now.
357 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); 357 box->layer()->setStaticBlockPosition(m_block->logicalHeight());
358 } 358 }
359 359
360 // If we're ignoring spaces, we have to stop and include this object and 360 // If we're ignoring spaces, we have to stop and include this object and
361 // then start ignoring spaces again. 361 // then start ignoring spaces again.
362 if (isInlineType || box->container()->isRenderInline()) { 362 if (isInlineType || box->container()->isRenderInline()) {
363 if (m_ignoringSpaces) 363 if (m_ignoringSpaces)
364 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box); 364 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box);
365 m_trailingObjects.appendBoxIfNeeded(box); 365 m_trailingObjects.appendObjectIfNeeded(box);
366 } else { 366 } else {
367 positionedObjects.append(box); 367 positionedObjects.append(box);
368 } 368 }
369 m_width.addUncommittedWidth(inlineLogicalWidth(box).toFloat()); 369 m_width.addUncommittedWidth(inlineLogicalWidth(box).toFloat());
370 // Reset prior line break context characters. 370 // Reset prior line break context characters.
371 m_renderTextInfo.m_lineBreakIterator.resetPriorContext(); 371 m_renderTextInfo.m_lineBreakIterator.resetPriorContext();
372 } 372 }
373 373
374 inline void BreakingContext::handleFloat() 374 inline void BreakingContext::handleFloat()
375 { 375 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 return false; 412 return false;
413 } 413 }
414 414
415 inline void BreakingContext::handleEmptyInline() 415 inline void BreakingContext::handleEmptyInline()
416 { 416 {
417 // This should only end up being called on empty inlines 417 // This should only end up being called on empty inlines
418 ASSERT(isEmptyInline(m_current.object())); 418 ASSERT(isEmptyInline(m_current.object()));
419 419
420 RenderInline* flowBox = toRenderInline(m_current.object()); 420 RenderInline* flowBox = toRenderInline(m_current.object());
421 421
422 // Now that some inline flows have line boxes, if we are already ignoring sp aces, we need
423 // to make sure that we stop to include this object and then start ignoring spaces again.
424 // If this object is at the start of the line, we need to behave like list m arkers and
425 // start ignoring spaces.
426 bool requiresLineBox = alwaysRequiresLineBox(m_current.object()); 422 bool requiresLineBox = alwaysRequiresLineBox(m_current.object());
427 if (requiresLineBox || requiresLineBoxForContent(flowBox, m_lineInfo)) { 423 if (requiresLineBox || requiresLineBoxForContent(flowBox, m_lineInfo)) {
428 // An empty inline that only has line-height, vertical-align or font-met rics will only get a 424 // An empty inline that only has line-height, vertical-align or font-met rics will
429 // line box to affect the height of the line if the rest of the line is not empty. 425 // not force linebox creation (and thus affect the height of the line) i f the rest of the line is empty.
430 if (requiresLineBox) 426 if (requiresLineBox)
431 m_lineInfo.setEmpty(false, m_block, &m_width); 427 m_lineInfo.setEmpty(false, m_block, &m_width);
432 if (m_ignoringSpaces) { 428 if (m_ignoringSpaces) {
429 // If we are in a run of ignored spaces then ensure we get a linebox if lineboxes are eventually
430 // created for the line...
433 m_trailingObjects.clear(); 431 m_trailingObjects.clear();
434 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_current.objec t()); 432 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_current.objec t());
435 } else if (m_blockStyle->collapseWhiteSpace() && m_resolver.position().o bject() == m_current.object() 433 } else if (m_blockStyle->collapseWhiteSpace() && m_resolver.position().o bject() == m_current.object()
436 && shouldSkipWhitespaceAfterStartObject(m_block, m_current.object(), m_lineMidpointState)) { 434 && shouldSkipWhitespaceAfterStartObject(m_block, m_current.object(), m_lineMidpointState)) {
437 // Like with list markers, we start ignoring spaces to make sure tha t any 435 // If this object is at the start of the line, we need to behave lik e list markers and
438 // additional spaces we see will be discarded. 436 // start ignoring spaces.
439 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = true; 437 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = true;
440 m_ignoringSpaces = true; 438 m_ignoringSpaces = true;
439 } else {
440 // If we are after a trailing space but aren't ignoring spaces yet t hen ensure we get a linebox
441 // if we encounter collapsible whitepace.
442 m_trailingObjects.appendObjectIfNeeded(m_current.object());
441 } 443 }
442 } 444 }
443 445
444 m_width.addUncommittedWidth((inlineLogicalWidth(m_current.object()) + border PaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)).toFloat()); 446 m_width.addUncommittedWidth((inlineLogicalWidth(m_current.object()) + border PaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)).toFloat());
445 } 447 }
446 448
447 inline void BreakingContext::handleReplaced() 449 inline void BreakingContext::handleReplaced()
448 { 450 {
449 RenderBox* replacedBox = toRenderBox(m_current.object()); 451 RenderBox* replacedBox = toRenderBox(m_current.object());
450 452
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 // If we encounter a newline, or if we encounter a 764 // If we encounter a newline, or if we encounter a
763 // second space, we need to go ahead and break up this 765 // second space, we need to go ahead and break up this
764 // run and enter a mode where we start collapsing spaces. 766 // run and enter a mode where we start collapsing spaces.
765 if (m_currentCharacterIsSpace && previousCharacterIsSpace) { 767 if (m_currentCharacterIsSpace && previousCharacterIsSpace) {
766 m_ignoringSpaces = true; 768 m_ignoringSpaces = true;
767 769
768 // We just entered a mode where we are ignoring 770 // We just entered a mode where we are ignoring
769 // spaces. Create a midpoint to terminate the run 771 // spaces. Create a midpoint to terminate the run
770 // before the second space. 772 // before the second space.
771 m_lineMidpointState.startIgnoringSpaces(m_startOfIgnoredSpac es); 773 m_lineMidpointState.startIgnoringSpaces(m_startOfIgnoredSpac es);
772 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidp ointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace); 774 m_trailingObjects.updateMidpointsForTrailingObjects(m_lineMi dpointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace);
773 } 775 }
774 } 776 }
775 } else if (m_ignoringSpaces) { 777 } else if (m_ignoringSpaces) {
776 // Stop ignoring spaces and begin at this 778 // Stop ignoring spaces and begin at this
777 // new point. 779 // new point.
778 m_ignoringSpaces = false; 780 m_ignoringSpaces = false;
779 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; 781 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0;
780 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurement s.last().width) ? wordSpacing : 0; 782 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurement s.last().width) ? wordSpacing : 0;
781 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in any of the ignored spaces. 783 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in any of the ignored spaces.
782 m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.o bject(), m_current.offset())); 784 m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.o bject(), m_current.offset()));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 907
906 if (style->textIndentType() == TextIndentHanging) 908 if (style->textIndentType() == TextIndentHanging)
907 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText; 909 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText;
908 910
909 return shouldIndentText; 911 return shouldIndentText;
910 } 912 }
911 913
912 } 914 }
913 915
914 #endif // BreakingContextInlineHeaders_h 916 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « Source/core/rendering/line/BreakingContext.cpp ('k') | Source/core/rendering/line/TrailingObjects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698