Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 3616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3627 if (genChild->isText()) | 3627 if (genChild->isText()) |
| 3628 genChild->setStyle(pseudoStyle); | 3628 genChild->setStyle(pseudoStyle); |
| 3629 } | 3629 } |
| 3630 } | 3630 } |
| 3631 | 3631 |
| 3632 static inline unsigned firstLetterLength(const String& text) | 3632 static inline unsigned firstLetterLength(const String& text) |
| 3633 { | 3633 { |
| 3634 unsigned length = 0; | 3634 unsigned length = 0; |
| 3635 unsigned textLength = text.length(); | 3635 unsigned textLength = text.length(); |
| 3636 | 3636 |
| 3637 if (textLength == 0) | |
| 3638 return length; | |
| 3639 | |
| 3637 // Account for leading spaces first. | 3640 // Account for leading spaces first. |
| 3638 while (length < textLength && isSpaceForFirstLetter(text[length])) | 3641 while (length < textLength && isSpaceForFirstLetter(text[length])) |
| 3639 length++; | 3642 length++; |
| 3640 | 3643 |
| 3641 // Now account for leading punctuation. | 3644 // Now account for leading punctuation. |
| 3642 while (length < textLength && isPunctuationForFirstLetter(text[length])) | 3645 while (length < textLength && isPunctuationForFirstLetter(text[length])) |
| 3643 length++; | 3646 length++; |
| 3644 | 3647 |
| 3645 // Bail if we didn't find a letter before the end of the text or before a sp ace. | 3648 // Bail if we didn't find a letter before the end of the text or before a sp ace. |
| 3646 if (isSpaceForFirstLetter(text[length]) || (textLength && length == textLeng th)) | 3649 if (isSpaceForFirstLetter(text[length]) || length == textLength) |
| 3647 return 0; | 3650 return 0; |
| 3648 | 3651 |
| 3649 // Account the next character for first letter. | 3652 // Account the next character for first letter. |
| 3650 length++; | 3653 length++; |
| 3651 | 3654 |
| 3652 // Keep looking allowed punctuation for the :first-letter. | 3655 // Keep looking allowed punctuation for the :first-letter. |
| 3653 for (unsigned scanLength = length; scanLength < textLength; ++scanLength) { | 3656 for (unsigned scanLength = length; scanLength < textLength; ++scanLength) { |
| 3654 UChar c = text[scanLength]; | 3657 UChar c = text[scanLength]; |
| 3655 | 3658 |
| 3656 if (!isPunctuationForFirstLetter(c)) | 3659 if (!isPunctuationForFirstLetter(c)) |
| 3657 break; | 3660 break; |
| 3658 | 3661 |
| 3659 length = scanLength + 1; | 3662 length = scanLength + 1; |
| 3660 } | 3663 } |
| 3661 | |
| 3662 // FIXME: If textLength is 0, length may still be 1! | |
| 3663 return length; | 3664 return length; |
| 3664 } | 3665 } |
| 3665 | 3666 |
| 3666 void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend erText& currentChild, unsigned length) | 3667 void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend erText& currentChild, unsigned length) |
| 3667 { | 3668 { |
| 3668 ASSERT(length); | 3669 ASSERT(length); |
| 3669 | 3670 |
| 3670 RenderObject* firstLetterContainer = currentChild.parent(); | 3671 RenderObject* firstLetterContainer = currentChild.parent(); |
| 3671 RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetter Container); | 3672 RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetter Container); |
| 3672 RenderBoxModelObject* firstLetter = 0; | 3673 RenderBoxModelObject* firstLetter = 0; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3725 return; | 3726 return; |
| 3726 | 3727 |
| 3727 // Drill into inlines looking for our first text child. | 3728 // Drill into inlines looking for our first text child. |
| 3728 RenderObject* currChild = firstLetterBlock->slowFirstChild(); | 3729 RenderObject* currChild = firstLetterBlock->slowFirstChild(); |
| 3729 unsigned length = 0; | 3730 unsigned length = 0; |
| 3730 while (currChild) { | 3731 while (currChild) { |
| 3731 if (currChild->isText()) { | 3732 if (currChild->isText()) { |
| 3732 // FIXME: If there is leading punctuation in a different RenderText than | 3733 // FIXME: If there is leading punctuation in a different RenderText than |
| 3733 // the first letter, we'll not apply the correct style to it. | 3734 // the first letter, we'll not apply the correct style to it. |
| 3734 length = firstLetterLength(toRenderText(currChild)->originalText()); | 3735 length = firstLetterLength(toRenderText(currChild)->originalText()); |
| 3735 if (length) | 3736 if (length || (currChild->isBR() || (currChild->isText() && toRender Text(currChild)->isWordBreak()))) |
|
leviw_travelin_and_unemployed
2014/10/29 20:26:52
Can you extract these cases into a static named fu
dsinclair
2014/10/30 14:07:27
Done.
| |
| 3736 break; | 3737 break; |
| 3737 currChild = currChild->nextSibling(); | 3738 currChild = currChild->nextSibling(); |
| 3738 } else if (currChild->isListMarker()) { | 3739 } else if (currChild->isListMarker()) { |
| 3739 currChild = currChild->nextSibling(); | 3740 currChild = currChild->nextSibling(); |
| 3740 } else if (currChild->isFloatingOrOutOfFlowPositioned()) { | 3741 } else if (currChild->isFloatingOrOutOfFlowPositioned()) { |
| 3741 if (currChild->style()->styleType() == FIRST_LETTER) { | 3742 if (currChild->style()->styleType() == FIRST_LETTER) { |
| 3742 currChild = currChild->slowFirstChild(); | 3743 currChild = currChild->slowFirstChild(); |
| 3743 break; | 3744 break; |
| 3744 } | 3745 } |
| 3745 currChild = currChild->nextSibling(); | 3746 currChild = currChild->nextSibling(); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4361 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const | 4362 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const |
| 4362 { | 4363 { |
| 4363 showRenderObject(); | 4364 showRenderObject(); |
| 4364 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 4365 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
| 4365 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 4366 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
| 4366 } | 4367 } |
| 4367 | 4368 |
| 4368 #endif | 4369 #endif |
| 4369 | 4370 |
| 4370 } // namespace blink | 4371 } // namespace blink |
| OLD | NEW |