| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "core/layout/LayoutText.h" | 25 #include "core/layout/LayoutText.h" |
| 26 | 26 |
| 27 #include <algorithm> |
| 27 #include "core/dom/AXObjectCache.h" | 28 #include "core/dom/AXObjectCache.h" |
| 28 #include "core/dom/Text.h" | 29 #include "core/dom/Text.h" |
| 29 #include "core/editing/VisiblePosition.h" | 30 #include "core/editing/VisiblePosition.h" |
| 30 #include "core/editing/iterators/TextIterator.h" | 31 #include "core/editing/iterators/TextIterator.h" |
| 31 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
| 32 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 33 #include "core/layout/LayoutBlock.h" | 34 #include "core/layout/LayoutBlock.h" |
| 34 #include "core/layout/LayoutTableCell.h" | 35 #include "core/layout/LayoutTableCell.h" |
| 35 #include "core/layout/LayoutTextCombine.h" | 36 #include "core/layout/LayoutTextCombine.h" |
| 36 #include "core/layout/LayoutView.h" | 37 #include "core/layout/LayoutView.h" |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 float min = std::numeric_limits<float>::max(); | 1007 float min = std::numeric_limits<float>::max(); |
| 1007 int end = start + length; | 1008 int end = start + length; |
| 1008 for (int i = start; i < end;) { | 1009 for (int i = start; i < end;) { |
| 1009 int fragmentLength; | 1010 int fragmentLength; |
| 1010 if (breakAllOrBreakWord == EWordBreak::BreakAllWordBreak) { | 1011 if (breakAllOrBreakWord == EWordBreak::BreakAllWordBreak) { |
| 1011 breakIterator.isBreakable(i + 1, nextBreakable, LineBreakType::BreakAll); | 1012 breakIterator.isBreakable(i + 1, nextBreakable, LineBreakType::BreakAll); |
| 1012 fragmentLength = (nextBreakable > i ? nextBreakable : length) - i; | 1013 fragmentLength = (nextBreakable > i ? nextBreakable : length) - i; |
| 1013 } else { | 1014 } else { |
| 1014 fragmentLength = U16_LENGTH(layoutText->codepointAt(i)); | 1015 fragmentLength = U16_LENGTH(layoutText->codepointAt(i)); |
| 1015 } | 1016 } |
| 1017 |
| 1018 // Ensure that malformed surrogate pairs don't cause us to read |
| 1019 // past the end of the string. |
| 1020 int textLength = layoutText->textLength(); |
| 1021 if (i + fragmentLength > textLength) |
| 1022 fragmentLength = std::max(textLength - i, 0); |
| 1023 |
| 1016 // The correct behavior is to measure width without re-shaping, but we | 1024 // The correct behavior is to measure width without re-shaping, but we |
| 1017 // reshape each fragment here because a) the current line breaker does not | 1025 // reshape each fragment here because a) the current line breaker does not |
| 1018 // support it, b) getCharacterRange() can reshape if the text is too long | 1026 // support it, b) getCharacterRange() can reshape if the text is too long |
| 1019 // to fit in the cache, and c) each fragment here is almost 1 char and thus | 1027 // to fit in the cache, and c) each fragment here is almost 1 char and thus |
| 1020 // reshape is fast. | 1028 // reshape is fast. |
| 1021 TextRun run = constructTextRun(font, layoutText, i, fragmentLength, style, | 1029 TextRun run = constructTextRun(font, layoutText, i, fragmentLength, style, |
| 1022 textDirection); | 1030 textDirection); |
| 1023 float fragmentWidth = font.width(run); | 1031 float fragmentWidth = font.width(run); |
| 1024 min = std::min(min, fragmentWidth); | 1032 min = std::min(min, fragmentWidth); |
| 1025 i += fragmentLength; | 1033 i += fragmentLength; |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 LayoutRect rect = LayoutRect( | 2027 LayoutRect rect = LayoutRect( |
| 2020 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 2028 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
| 2021 LayoutBlock* block = containingBlock(); | 2029 LayoutBlock* block = containingBlock(); |
| 2022 if (block && hasTextBoxes()) | 2030 if (block && hasTextBoxes()) |
| 2023 block->adjustChildDebugRect(rect); | 2031 block->adjustChildDebugRect(rect); |
| 2024 | 2032 |
| 2025 return rect; | 2033 return rect; |
| 2026 } | 2034 } |
| 2027 | 2035 |
| 2028 } // namespace blink | 2036 } // namespace blink |
| OLD | NEW |