Changeset 57940 in webkit
- Timestamp:
- Apr 20, 2010 4:51:45 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r57939 r57940 1 2010-04-20 Shinichiro Hamaji <hamaji@chromium.org> 2 3 Reviewed by Darin Adler and Alexey Proskuryakov. 4 5 A backslash in EUC-JP becomes to a yen sign when it is copied 6 https://bugs.webkit.org/show_bug.cgi?id=36419 7 8 * editing/execCommand/transpose-backslash-with-euc-expected.txt: Added. 9 * editing/execCommand/transpose-backslash-with-euc.html: Added. 10 * editing/pasteboard/copy-backslash-with-euc-expected.txt: Added. 11 * editing/pasteboard/copy-backslash-with-euc.html: Added. 12 * editing/pasteboard/resources/copy-backslash-euc.html: Added. 13 1 14 2010-04-20 Andrew Scherkus <scherkus@chromium.org> 2 15 -
trunk/WebCore/ChangeLog
r57936 r57940 1 2010-04-20 Shinichiro Hamaji <hamaji@chromium.org> 2 3 Reviewed by Darin Adler and Alexey Proskuryakov. 4 5 A backslash in EUC-JP becomes to a yen sign when it is copied 6 https://bugs.webkit.org/show_bug.cgi?id=36419 7 8 Tests: editing/execCommand/transpose-backslash-with-euc.html 9 editing/pasteboard/copy-backslash-with-euc.html 10 11 * editing/Editor.cpp: Remove an unnecessary displayStringModifiedByEncoding calls. 12 (WebCore::Editor::addToKillRing): 13 * editing/TextIterator.cpp: TextIterator can use RenderText::textWithoutTranscoding and now plainText() uses this version 14 (WebCore::TextIterator::TextIterator): 15 (WebCore::TextIterator::init): 16 (WebCore::TextIterator::emitText): 17 (WebCore::plainTextToMallocAllocatedBuffer): 18 * editing/TextIterator.h: 19 (WebCore::): 20 * platform/mac/PasteboardMac.mm: Remove an unnecessary displayStringModifiedByEncoding call. 21 (WebCore::Pasteboard::writeSelection): 22 * platform/text/TextEncoding.h: Make backslashAsCurrencySymbol public. 23 * rendering/RenderText.cpp: Add RenderText::textWithoutTranscoding 24 (WebCore::RenderText::RenderText): 25 (WebCore::RenderText::updateNeedsTranscoding): 26 (WebCore::RenderText::styleDidChange): 27 (WebCore::isInlineFlowOrEmptyText): 28 (WebCore::RenderText::previousCharacter): 29 (WebCore::RenderText::setTextInternal): 30 (WebCore::RenderText::textWithoutTranscoding): 31 (WebCore::RenderText::transformText): 32 * rendering/RenderText.h: 33 * rendering/RenderTextControl.cpp: Remove an unnecessary displayStringModifiedByEncoding call. 34 (WebCore::RenderTextControl::setInnerTextValue): 35 (WebCore::RenderTextControl::finishText): 36 * rendering/RenderTextFragment.cpp: 37 (WebCore::RenderTextFragment::previousCharacter): 38 * rendering/RenderTextFragment.h: 39 1 40 2010-04-20 Nate Chapin <japhet@chromium.org> 2 41 -
trunk/WebCore/editing/Editor.cpp
r57895 r57940 2704 2704 startNewKillRingSequence(); 2705 2705 2706 String text = m_frame->displayStringModifiedByEncoding(plainText(range));2706 String text = plainText(range); 2707 2707 if (prepend) 2708 2708 prependToKillRing(text); -
trunk/WebCore/editing/TextIterator.cpp
r55705 r57940 257 257 , m_emitCharactersBetweenAllVisiblePositions(false) 258 258 , m_enterTextControls(false) 259 { 260 } 261 262 TextIterator::TextIterator(const Range* r, bool emitCharactersBetweenAllVisiblePositions, bool enterTextControls) 259 , m_emitsTextWithoutTranscoding(false) 260 { 261 } 262 263 TextIterator::TextIterator(const Range* r, bool emitCharactersBetweenAllVisiblePositions, bool enterTextControls) 263 264 : m_startContainer(0) 264 265 , m_startOffset(0) … … 270 271 , m_emitCharactersBetweenAllVisiblePositions(emitCharactersBetweenAllVisiblePositions) 271 272 , m_enterTextControls(enterTextControls) 273 , m_emitsTextWithoutTranscoding(false) 274 { 275 init(r); 276 } 277 278 TextIterator::TextIterator(const Range* r, TextIteratorBehavior behavior) 279 : m_startContainer(0) 280 , m_startOffset(0) 281 , m_endContainer(0) 282 , m_endOffset(0) 283 , m_positionNode(0) 284 , m_textCharacters(0) 285 , m_textLength(0) 286 , m_emitCharactersBetweenAllVisiblePositions(behavior & TextIteratorBehaviorEmitCharactersBetweenAllVisiblePositions) 287 , m_enterTextControls(behavior & TextIteratorBehaviorEnterTextControls) 288 , m_emitsTextWithoutTranscoding(behavior & TextIteratorBehaviorEmitsTextsWithoutTranscoding) 289 { 290 init(r); 291 } 292 293 void TextIterator::init(const Range* r) 272 294 { 273 295 if (!r) … … 890 912 { 891 913 RenderText* renderer = toRenderText(m_node->renderer()); 892 String str = renderer->text();914 String str = m_emitsTextWithoutTranscoding ? renderer->textWithoutTranscoding() : renderer->text(); 893 915 ASSERT(str.characters()); 894 916 … … 2105 2127 // -------- 2106 2128 2107 UChar* plainTextToMallocAllocatedBuffer(const Range* r, unsigned& bufferLength, bool isDisplayString) 2129 UChar* plainTextToMallocAllocatedBuffer(const Range* r, unsigned& bufferLength, bool isDisplayString) 2108 2130 { 2109 2131 UChar* result = 0; … … 2117 2139 Vector<UChar> textBuffer; 2118 2140 textBuffer.reserveInitialCapacity(cMaxSegmentSize); 2119 for (TextIterator it(r ); !it.atEnd(); it.advance()) {2141 for (TextIterator it(r, isDisplayString ? TextIteratorBehaviorDefault : TextIteratorBehaviorEmitsTextsWithoutTranscoding); !it.atEnd(); it.advance()) { 2120 2142 if (textBuffer.size() && textBuffer.size() + it.length() > cMaxSegmentSize) { 2121 2143 UChar* newSegmentBuffer = static_cast<UChar*>(malloc(textBuffer.size() * sizeof(UChar))); -
trunk/WebCore/editing/TextIterator.h
r44674 r57940 69 69 // chunks so as to optimize for performance of the iteration. 70 70 71 enum TextIteratorBehavior { 72 TextIteratorBehaviorDefault = 0, 73 TextIteratorBehaviorEmitCharactersBetweenAllVisiblePositions = 1 << 0, 74 TextIteratorBehaviorEnterTextControls = 1 << 1, 75 TextIteratorBehaviorEmitsTextsWithoutTranscoding = 1 << 2, 76 }; 77 71 78 class TextIterator { 72 79 public: 73 80 TextIterator(); 74 81 explicit TextIterator(const Range*, bool emitCharactersBetweenAllVisiblePositions = false, bool enterTextControls = false); 75 82 TextIterator(const Range*, TextIteratorBehavior); 83 76 84 bool atEnd() const { return !m_positionNode; } 77 85 void advance(); … … 88 96 89 97 private: 98 void init(const Range*); 90 99 void exitNode(); 91 100 bool shouldRepresentNodeOffsetZero(); … … 148 157 bool m_emitCharactersBetweenAllVisiblePositions; 149 158 bool m_enterTextControls; 159 160 // Used when we want texts for copying, pasting, and transposing. 161 bool m_emitsTextWithoutTranscoding; 150 162 }; 151 163 -
trunk/WebCore/platform/mac/PasteboardMac.mm
r55029 r57940 185 185 // Map to a plain old space because this is better for source code, other browsers do it, 186 186 // and because HTML forces you to do this any time you want two spaces in a row. 187 String text = frame->displayStringModifiedByEncoding(selectedRange->text());187 String text = selectedRange->text(); 188 188 NSMutableString *s = [[[(NSString*)text copy] autorelease] mutableCopy]; 189 189 -
trunk/WebCore/platform/text/TextEncoding.h
r56825 r57940 78 78 WTF::CString encode(const UChar*, size_t length, UnencodableHandling) const; 79 79 80 UChar backslashAsCurrencySymbol() const; 81 80 82 private: 81 UChar backslashAsCurrencySymbol() const;82 83 bool isNonByteBasedEncoding() const; 83 84 bool isUTF7Encoding() const; -
trunk/WebCore/rendering/RenderText.cpp
r57215 r57940 40 40 #include "Text.h" 41 41 #include "TextBreakIterator.h" 42 #include "TextResourceDecoder.h" 42 43 #include "VisiblePosition.h" 43 44 #include "break_lines.h" … … 89 90 : RenderObject(node) 90 91 , m_minWidth(-1) 91 , m_text( document()->displayStringModifiedByEncoding(str))92 , m_text(str) 92 93 , m_firstTextBox(0) 93 94 , m_lastTextBox(0) … … 100 101 , m_isAllASCII(m_text.containsOnlyASCII()) 101 102 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) 103 , m_needsTranscoding(false) 102 104 { 103 105 ASSERT(m_text); … … 134 136 { 135 137 return false; 138 } 139 140 void RenderText::updateNeedsTranscoding() 141 { 142 m_needsTranscoding = document()->decoder() && document()->decoder()->encoding().backslashAsCurrencySymbol() != '\\'; 136 143 } 137 144 … … 147 154 } 148 155 156 bool needsResetText = false; 157 if (!oldStyle) { 158 updateNeedsTranscoding(); 159 needsResetText = m_needsTranscoding; 160 } 161 149 162 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; 150 163 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; 151 152 if (oldTransform != style()->textTransform() || oldSecurity != style()->textSecurity()) { 164 if (needsResetText || oldTransform != style()->textTransform() || oldSecurity != style()->textSecurity()) { 153 165 if (RefPtr<StringImpl> textToTransform = originalText()) 154 166 setText(textToTransform.release(), true); … … 961 973 } 962 974 963 static inline bool isInlineFlowOrEmptyText( RenderObject* o)975 static inline bool isInlineFlowOrEmptyText(const RenderObject* o) 964 976 { 965 977 if (o->isRenderInline()) … … 973 985 } 974 986 975 UChar RenderText::previousCharacter() 987 UChar RenderText::previousCharacter() const 976 988 { 977 989 // find previous text renderer if one exists 978 RenderObject* previousText = this;990 const RenderObject* previousText = this; 979 991 while ((previousText = previousText->previousInPreOrder())) 980 992 if (!isInlineFlowOrEmptyText(previousText)) … … 987 999 } 988 1000 1001 void RenderText::transformText(String& text) const 1002 { 1003 ASSERT(style()); 1004 switch (style()->textTransform()) { 1005 case TTNONE: 1006 break; 1007 case CAPITALIZE: 1008 makeCapitalized(&text, previousCharacter()); 1009 break; 1010 case UPPERCASE: 1011 text.makeUpper(); 1012 break; 1013 case LOWERCASE: 1014 text.makeLower(); 1015 break; 1016 } 1017 } 1018 989 1019 void RenderText::setTextInternal(PassRefPtr<StringImpl> text) 990 1020 { 991 1021 ASSERT(text); 992 m_text = document()->displayStringModifiedByEncoding(text); 1022 if (m_needsTranscoding) 1023 m_text = document()->displayStringModifiedByEncoding(text); 1024 else 1025 m_text = text; 993 1026 ASSERT(m_text); 994 1027 … … 1023 1056 1024 1057 if (style()) { 1025 switch (style()->textTransform()) { 1026 case TTNONE: 1027 break; 1028 case CAPITALIZE: 1029 makeCapitalized(&m_text, previousCharacter()); 1030 break; 1031 case UPPERCASE: 1032 m_text.makeUpper(); 1033 break; 1034 case LOWERCASE: 1035 m_text.makeLower(); 1036 break; 1037 } 1058 transformText(m_text); 1038 1059 1039 1060 // We use the same characters here as for list markers. 1040 1061 // See the listMarkerText function in RenderListMarker.cpp. 1041 1062 switch (style()->textSecurity()) { 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1063 case TSNONE: 1064 break; 1065 case TSCIRCLE: 1066 m_text.makeSecure(whiteBullet); 1067 break; 1068 case TSDISC: 1069 m_text.makeSecure(bullet); 1070 break; 1071 case TSSQUARE: 1072 m_text.makeSecure(blackSquare); 1052 1073 } 1053 1074 } … … 1073 1094 if (axObjectCache->accessibilityEnabled()) 1074 1095 axObjectCache->contentChanged(this); 1096 } 1097 1098 String RenderText::textWithoutTranscoding() const 1099 { 1100 // If m_text isn't transcoded or is secure, we can just return the modified text. 1101 if (!m_needsTranscoding || style()->textSecurity() != TSNONE) 1102 return text(); 1103 1104 // Otherwise, we should use original text. If text-transform is 1105 // specified, we should transform the text on the fly. 1106 String text = originalText(); 1107 if (style()) 1108 transformText(text); 1109 return text; 1075 1110 } 1076 1111 -
trunk/WebCore/rendering/RenderText.h
r57215 r57940 52 52 53 53 StringImpl* text() const { return m_text.impl(); } 54 String textWithoutTranscoding() const; 54 55 55 56 InlineTextBox* createInlineTextBox(); … … 129 130 130 131 virtual void setTextInternal(PassRefPtr<StringImpl>); 131 virtual UChar previousCharacter() ;132 virtual UChar previousCharacter() const; 132 133 133 134 virtual InlineTextBox* createTextBox(); // Subclassed by SVG. … … 149 150 int widthFromCache(const Font&, int start, int len, int xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const; 150 151 bool isAllASCII() const { return m_isAllASCII; } 152 void updateNeedsTranscoding(); 153 154 inline void transformText(String&) const; 151 155 152 156 int m_minWidth; // here to minimize padding in 64-bit. … … 173 177 bool m_isAllASCII : 1; 174 178 mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1; 179 bool m_needsTranscoding : 1; 175 180 }; 176 181 -
trunk/WebCore/rendering/RenderTextControl.cpp
r56885 r57940 168 168 void RenderTextControl::setInnerTextValue(const String& innerTextValue) 169 169 { 170 String value; 171 172 if (innerTextValue.isNull()) 173 value = ""; 174 else { 175 value = innerTextValue; 176 value = document()->displayStringModifiedByEncoding(value); 177 } 178 170 String value = innerTextValue; 179 171 if (value != text() || !m_innerText->hasChildNodes()) { 180 172 if (value != text()) { … … 319 311 result.shrink(--size); 320 312 321 // Convert backslash to currency symbol.322 document()->displayBufferModifiedByEncoding(result.data(), result.size());323 324 313 return String::adopt(result); 325 314 } -
trunk/WebCore/rendering/RenderTextFragment.cpp
r55196 r57940 77 77 } 78 78 79 UChar RenderTextFragment::previousCharacter() 79 UChar RenderTextFragment::previousCharacter() const 80 80 { 81 81 if (start()) { -
trunk/WebCore/rendering/RenderTextFragment.h
r25754 r57940 52 52 private: 53 53 virtual void setTextInternal(PassRefPtr<StringImpl>); 54 virtual UChar previousCharacter() ;54 virtual UChar previousCharacter() const; 55 55 56 56 unsigned m_start;
Note: See TracChangeset
for help on using the changeset viewer.