OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 for (const LayoutObject* r = node.layoutObject(); r; r = r->parent()) { | 844 for (const LayoutObject* r = node.layoutObject(); r; r = r->parent()) { |
845 if (r->isLayoutBlockFlow()) { | 845 if (r->isLayoutBlockFlow()) { |
846 primaryDirection = r->style()->direction(); | 846 primaryDirection = r->style()->direction(); |
847 break; | 847 break; |
848 } | 848 } |
849 } | 849 } |
850 | 850 |
851 return primaryDirection; | 851 return primaryDirection; |
852 } | 852 } |
853 | 853 |
854 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP aragraph, bool endIsEndOfParagraph) | 854 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP aragraph, bool endIsEndOfParagraph, bool nextTextSibling) |
855 { | 855 { |
856 unsigned length = string.length(); | 856 unsigned length = string.length(); |
857 | 857 |
858 StringBuilder rebalancedString; | 858 StringBuilder rebalancedString; |
859 rebalancedString.reserveCapacity(length); | 859 rebalancedString.reserveCapacity(length); |
860 | 860 |
861 bool previousCharacterWasSpace = false; | 861 bool previousCharacterWasSpace = false; |
862 for (size_t i = 0; i < length; i++) { | 862 for (size_t i = 0; i < length; i++) { |
863 UChar c = string[i]; | 863 UChar c = string[i]; |
864 if (!isWhitespace(c)) { | 864 if (!isWhitespace(c)) { |
865 rebalancedString.append(c); | 865 rebalancedString.append(c); |
866 previousCharacterWasSpace = false; | 866 previousCharacterWasSpace = false; |
867 continue; | 867 continue; |
868 } | 868 } |
869 | 869 |
870 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i + 1 == length && endIsEndOfParagraph)) { | 870 // We need to ensure there is no next sibling text node. See http://crbu g.com/310149 |
871 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i + 1 == length && endIsEndOfParagraph && !nextTextSibling)) { | |
yosin_UTC9
2016/07/25 07:42:23
Should we insert U+0020 instead of U+00A0 when pre
joone
2016/07/26 04:16:34
I'm not sure. In this case, the space is inserted
| |
871 rebalancedString.append(noBreakSpaceCharacter); | 872 rebalancedString.append(noBreakSpaceCharacter); |
872 previousCharacterWasSpace = false; | 873 previousCharacterWasSpace = false; |
873 } else { | 874 } else { |
874 rebalancedString.append(' '); | 875 rebalancedString.append(' '); |
875 previousCharacterWasSpace = true; | 876 previousCharacterWasSpace = true; |
876 } | 877 } |
877 } | 878 } |
878 | 879 |
879 DCHECK_EQ(rebalancedString.length(), length); | 880 DCHECK_EQ(rebalancedString.length(), length); |
880 | 881 |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1816 { | 1817 { |
1817 if (!RuntimeEnabledFeatures::inputEventEnabled()) | 1818 if (!RuntimeEnabledFeatures::inputEventEnabled()) |
1818 return DispatchEventResult::NotCanceled; | 1819 return DispatchEventResult::NotCanceled; |
1819 if (!target) | 1820 if (!target) |
1820 return DispatchEventResult::NotCanceled; | 1821 return DispatchEventResult::NotCanceled; |
1821 InputEvent* beforeInputEvent = InputEvent::createBeforeInput(inputType, data , InputEvent::EventCancelable::IsCancelable, InputEvent::EventIsComposing::NotCo mposing, ranges); | 1822 InputEvent* beforeInputEvent = InputEvent::createBeforeInput(inputType, data , InputEvent::EventCancelable::IsCancelable, InputEvent::EventIsComposing::NotCo mposing, ranges); |
1822 return target->dispatchEvent(beforeInputEvent); | 1823 return target->dispatchEvent(beforeInputEvent); |
1823 } | 1824 } |
1824 | 1825 |
1825 } // namespace blink | 1826 } // namespace blink |
OLD | NEW |