| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "core/editing/TextIterator.h" | 34 #include "core/editing/TextIterator.h" |
| 35 #include "platform/text/TextBreakIterator.h" | 35 #include "platform/text/TextBreakIterator.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 AbstractInlineTextBox::InlineToAbstractInlineTextBoxHashMap* AbstractInlineTextB
ox::gAbstractInlineTextBoxMap = 0; | 39 AbstractInlineTextBox::InlineToAbstractInlineTextBoxHashMap* AbstractInlineTextB
ox::gAbstractInlineTextBoxMap = 0; |
| 40 | 40 |
| 41 PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::getOrCreate(RenderText*
renderText, InlineTextBox* inlineTextBox) | 41 PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::getOrCreate(RenderText*
renderText, InlineTextBox* inlineTextBox) |
| 42 { | 42 { |
| 43 if (!inlineTextBox) | 43 if (!inlineTextBox) |
| 44 return 0; | 44 return nullptr; |
| 45 | 45 |
| 46 if (!gAbstractInlineTextBoxMap) | 46 if (!gAbstractInlineTextBoxMap) |
| 47 gAbstractInlineTextBoxMap = new InlineToAbstractInlineTextBoxHashMap(); | 47 gAbstractInlineTextBoxMap = new InlineToAbstractInlineTextBoxHashMap(); |
| 48 | 48 |
| 49 InlineToAbstractInlineTextBoxHashMap::const_iterator it = gAbstractInlineTex
tBoxMap->find(inlineTextBox); | 49 InlineToAbstractInlineTextBoxHashMap::const_iterator it = gAbstractInlineTex
tBoxMap->find(inlineTextBox); |
| 50 if (it != gAbstractInlineTextBoxMap->end()) | 50 if (it != gAbstractInlineTextBoxMap->end()) |
| 51 return it->value; | 51 return it->value; |
| 52 | 52 |
| 53 RefPtr<AbstractInlineTextBox> obj = adoptRef(new AbstractInlineTextBox(rende
rText, inlineTextBox)); | 53 RefPtr<AbstractInlineTextBox> obj = adoptRef(new AbstractInlineTextBox(rende
rText, inlineTextBox)); |
| 54 gAbstractInlineTextBoxMap->set(inlineTextBox, obj); | 54 gAbstractInlineTextBoxMap->set(inlineTextBox, obj); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 void AbstractInlineTextBox::detach() | 70 void AbstractInlineTextBox::detach() |
| 71 { | 71 { |
| 72 m_renderText = 0; | 72 m_renderText = 0; |
| 73 m_inlineTextBox = 0; | 73 m_inlineTextBox = 0; |
| 74 } | 74 } |
| 75 | 75 |
| 76 PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::nextInlineTextBox() con
st | 76 PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::nextInlineTextBox() con
st |
| 77 { | 77 { |
| 78 if (!m_inlineTextBox) | 78 if (!m_inlineTextBox) |
| 79 return 0; | 79 return nullptr; |
| 80 | 80 |
| 81 return getOrCreate(m_renderText, m_inlineTextBox->nextTextBox()); | 81 return getOrCreate(m_renderText, m_inlineTextBox->nextTextBox()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 LayoutRect AbstractInlineTextBox::bounds() const | 84 LayoutRect AbstractInlineTextBox::bounds() const |
| 85 { | 85 { |
| 86 if (!m_inlineTextBox || !m_renderText) | 86 if (!m_inlineTextBox || !m_renderText) |
| 87 return LayoutRect(); | 87 return LayoutRect(); |
| 88 | 88 |
| 89 FloatRect boundaries = m_inlineTextBox->calculateBoundaries(); | 89 FloatRect boundaries = m_inlineTextBox->calculateBoundaries(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 return plainText(range.get(), TextIteratorIgnoresStyleVisibility); | 155 return plainText(range.get(), TextIteratorIgnoresStyleVisibility); |
| 156 } | 156 } |
| 157 | 157 |
| 158 String result = m_renderText->text().substring(start, len).simplifyWhiteSpac
e(WTF::DoNotStripWhiteSpace); | 158 String result = m_renderText->text().substring(start, len).simplifyWhiteSpac
e(WTF::DoNotStripWhiteSpace); |
| 159 if (m_inlineTextBox->nextTextBox() && m_inlineTextBox->nextTextBox()->start(
) > m_inlineTextBox->end() && result.length() && !result.right(1).containsOnlyWh
itespace()) | 159 if (m_inlineTextBox->nextTextBox() && m_inlineTextBox->nextTextBox()->start(
) > m_inlineTextBox->end() && result.length() && !result.right(1).containsOnlyWh
itespace()) |
| 160 return result + " "; | 160 return result + " "; |
| 161 return result; | 161 return result; |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace WebCore | 164 } // namespace WebCore |
| OLD | NEW |