Reviewed by Hyatt
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Oct 2004 21:07:24 +0000 (21:07 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Oct 2004 21:07:24 +0000 (21:07 +0000)
        * khtml/rendering/bidi.cpp:
        (khtml::RenderBlock::skipNonBreakingSpace): Also need to forego the
        skipping after a clean line break, in addition to the cases already
        checked for.
        * layout-tests/editing/inserting/insert-br-007-expected.txt: Added.
        * layout-tests/editing/inserting/insert-br-007.html: Added.
        * layout-tests/editing/inserting/insert-br-008-expected.txt: Added.
        * layout-tests/editing/inserting/insert-br-008.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7846 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/editing/inserting/insert-br-007-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-br-007.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-br-008-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-br-008.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/bidi.cpp

diff --git a/LayoutTests/editing/inserting/insert-br-007-expected.txt b/LayoutTests/editing/inserting/insert-br-007-expected.txt
new file mode 100644 (file)
index 0000000..9794d1e
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x84 [border: (2px solid #FF0000)]
+        RenderInline {SPAN} at (0,0) size 37x56
+          RenderText {TEXT} at (14,14) size 32x28
+            text run at (14,14) width 32: "foo"
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {TEXT} at (14,42) size 37x28
+            text run at (14,42) width 37: " bar"
+        RenderText {TEXT} at (0,0) size 0x0
+selection is CARET:
+start:      position 0 of child 3 {TEXT} of child 2 {SPAN} of root {DIV}
+upstream:   position 1 of child 2 {BR} of child 2 {SPAN} of root {DIV}
+downstream: position 0 of child 3 {TEXT} of child 2 {SPAN} of root {DIV}
diff --git a/LayoutTests/editing/inserting/insert-br-007.html b/LayoutTests/editing/inserting/insert-br-007.html
new file mode 100644 (file)
index 0000000..c61f451
--- /dev/null
@@ -0,0 +1,35 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    for (i = 0; i < 3; i++)
+        moveSelectionForwardByCharacterCommand();
+    insertNewlineCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body>
+<div contenteditable id="root" class="editing">
+<span id="test">foo bar</span>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/editing/inserting/insert-br-008-expected.txt b/LayoutTests/editing/inserting/insert-br-008-expected.txt
new file mode 100644 (file)
index 0000000..04cfc28
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x84 [border: (2px solid #FF0000)]
+        RenderBR {BR} at (14,14) size 0x28
+        RenderText {TEXT} at (14,42) size 38x28
+          text run at (14,42) width 38: " foo"
+selection is CARET:
+start:      position 1 of child 2 {TEXT} of child 1 {DIV} of root {BODY}
+upstream:   position 1 of child 2 {TEXT} of child 1 {DIV} of root {BODY}
+downstream: position 1 of child 2 {TEXT} of child 1 {DIV} of root {BODY}
diff --git a/LayoutTests/editing/inserting/insert-br-008.html b/LayoutTests/editing/inserting/insert-br-008.html
new file mode 100644 (file)
index 0000000..d47ecbd
--- /dev/null
@@ -0,0 +1,32 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    insertNewlineCommand();
+    typeCharacterCommand(" ");
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body id="root">
+<div contenteditable id="test" class="editing">foo</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
index 9fc5358..ee36912 100644 (file)
@@ -1,3 +1,16 @@
+2004-10-15  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Hyatt
+
+        * khtml/rendering/bidi.cpp:
+        (khtml::RenderBlock::skipNonBreakingSpace): Also need to forego the
+        skipping after a clean line break, in addition to the cases already 
+        checked for.
+        * layout-tests/editing/inserting/insert-br-007-expected.txt: Added.
+        * layout-tests/editing/inserting/insert-br-007.html: Added.
+        * layout-tests/editing/inserting/insert-br-008-expected.txt: Added.
+        * layout-tests/editing/inserting/insert-br-008.html: Added.
+
 === Safari-167 ===
 
 2004-10-14  Ken Kocienda  <kocienda@apple.com>
index 95e534c..62a2e66 100644 (file)
@@ -1739,9 +1739,17 @@ inline bool RenderBlock::skipNonBreakingSpace(BidiIterator &it)
     if (it.obj->style()->nbspMode() != SPACE || it.current().unicode() != nonBreakingSpace)
         return false;
  
-    // Do not skip a non-breaking spaces if it is the first character
+    // Do not skip a non-breaking space if it is the first character
     // on the first line of a block.
-    return !m_firstLine || !isLineEmpty;
+    if (m_firstLine && isLineEmpty)
+        return false;
+        
+    // Do not skip a non-breaking space if it is the first character
+    // on a line after a clean line break.
+    if (!m_firstLine && isLineEmpty && previousLineBrokeCleanly)
+        return false;
+    
+    return true;
 }
 
 int RenderBlock::skipWhitespace(BidiIterator &it, BidiState &bidi)