Diff
Modified: trunk/LayoutTests/ChangeLog (97204 => 97205)
--- trunk/LayoutTests/ChangeLog 2011-10-12 00:41:06 UTC (rev 97204)
+++ trunk/LayoutTests/ChangeLog 2011-10-12 01:07:57 UTC (rev 97205)
@@ -1,3 +1,18 @@
+2011-10-11 Ryosuke Niwa <[email protected]>
+
+ Dir attribute is converted into direction property when merging paragraphs
+ https://bugs.webkit.org/show_bug.cgi?id=69680
+
+ Reviewed by Enrica Casucci.
+
+ Added tests to merge paragraphs inside a block with dir attribute. WebKit should not add
+ direction or unicode-bidi properties.
+
+ * editing/deleting/merge-paragraph-into-h1-with-dir-2-expected.txt: Added.
+ * editing/deleting/merge-paragraph-into-h1-with-dir-2.html: Added.
+ * editing/deleting/merge-paragraph-into-h1-with-dir-expected.txt: Added.
+ * editing/deleting/merge-paragraph-into-h1-with-dir.html: Added.
+
2011-10-11 Fady Samuel <[email protected]>
Towards making PopupMenuClient more testable
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-2-expected.txt (0 => 97205)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-2-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-2-expected.txt 2011-10-12 01:07:57 UTC (rev 97205)
@@ -0,0 +1,20 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 5 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 0 of P > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 5 of #text > H1 > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break after h1 inside a block with dir attribute.
+WebKit should not add direction or unicode-bidi properties while merging paragraphs.
+| "
+"
+| <h1>
+| "hello<#selection-caret>"
+| <b>
+| "worl"
+| "d"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-2.html (0 => 97205)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-2.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-2.html 2011-10-12 01:07:57 UTC (rev 97205)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break after h1 inside a block with dir attribute.
+WebKit should not add direction or unicode-bidi properties while merging paragraphs.</p>
+<div id="test" dir="ltr" contenteditable>
+<h1>hello</h1>
+<p><b>worl</b>d</p>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-expected.txt (0 => 97205)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir-expected.txt 2011-10-12 01:07:57 UTC (rev 97205)
@@ -0,0 +1,17 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 5 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 0 of P > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 5 of #text > H1 > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break after h1 inside a block with dir attribute.
+WebKit should not add direction or unicode-bidi properties while merging paragraphs.
+| "
+"
+| <h1>
+| "hello<#selection-caret>world"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir.html (0 => 97205)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-dir.html 2011-10-12 01:07:57 UTC (rev 97205)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break after h1 inside a block with dir attribute.
+WebKit should not add direction or unicode-bidi properties while merging paragraphs.</p>
+<div id="test" dir="ltr" contenteditable>
+<h1>hello</h1>
+<p>world</p>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (97204 => 97205)
--- trunk/Source/WebCore/ChangeLog 2011-10-12 00:41:06 UTC (rev 97204)
+++ trunk/Source/WebCore/ChangeLog 2011-10-12 01:07:57 UTC (rev 97205)
@@ -1,3 +1,22 @@
+2011-10-11 Ryosuke Niwa <[email protected]>
+
+ Dir attribute is converted into direction property when merging paragraphs
+ https://bugs.webkit.org/show_bug.cgi?id=69680
+
+ Reviewed by Enrica Casucci.
+
+ Don't include direction and unicode-bidi properties in the wrapping style.
+
+ Tests: editing/deleting/merge-paragraph-into-h1-with-dir-2.html
+ editing/deleting/merge-paragraph-into-h1-with-dir.html
+
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Skip unicode-bidi and direction properties.
+ (WebCore::EditingStyle::wrappingStyleForSerialization): Extracted from StyledMarkupAccumulator::serializeNodes.
+ * editing/EditingStyle.h:
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::serializeNodes): Calls wrappingStyleForSerialization.
+
2011-10-11 Nico Weber <[email protected]>
[chromium] Let rule_binding use os.execvp() instead of subprocess.call() to spawn fewer processes.
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (97204 => 97205)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2011-10-12 00:41:06 UTC (rev 97204)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2011-10-12 01:07:57 UTC (rev 97205)
@@ -887,11 +887,44 @@
const Vector<OwnPtr<HTMLAttributeEquivalent> >& attributeEquivalents = htmlAttributeEquivalents();
for (size_t i = 0; i < attributeEquivalents.size(); ++i) {
+ if (attributeEquivalents[i]->attributeName() == HTMLNames::dirAttr)
+ continue; // We don't want to include directionality
if (elementMatchesAndPropertyIsNotInInlineStyleDecl(attributeEquivalents[i].get(), element, mode, m_mutableStyle.get()))
attributeEquivalents[i]->addToStyle(element, this);
}
}
+PassRefPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node* context, bool shouldAnnotate)
+{
+ RefPtr<EditingStyle> wrappingStyle;
+ if (shouldAnnotate) {
+ wrappingStyle = EditingStyle::create(context, EditingStyle::EditingInheritablePropertiesAndBackgroundColorInEffect);
+
+ // Styles that Mail blockquotes contribute should only be placed on the Mail blockquote,
+ // to help us differentiate those styles from ones that the user has applied.
+ // This helps us get the color of content pasted into blockquotes right.
+ wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(context), isMailBlockquote, CanCrossEditingBoundary));
+
+ // Call collapseTextDecorationProperties first or otherwise it'll copy the value over from in-effect to text-decorations.
+ wrappingStyle->collapseTextDecorationProperties();
+
+ return wrappingStyle.release();
+ }
+
+ wrappingStyle = EditingStyle::create();
+
+ // When not annotating for interchange, we only preserve inline style declarations.
+ for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
+ if (node->isStyledElement()) {
+ wrappingStyle->mergeInlineAndImplicitStyleOfElement(static_cast<StyledElement*>(node), EditingStyle::DoNotOverrideValues,
+ EditingStyle::EditingInheritablePropertiesAndBackgroundColorInEffect);
+ }
+ }
+
+ return wrappingStyle.release();
+}
+
+
static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge)
{
DEFINE_STATIC_LOCAL(const RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
Modified: trunk/Source/WebCore/editing/EditingStyle.h (97204 => 97205)
--- trunk/Source/WebCore/editing/EditingStyle.h 2011-10-12 00:41:06 UTC (rev 97204)
+++ trunk/Source/WebCore/editing/EditingStyle.h 2011-10-12 01:07:57 UTC (rev 97205)
@@ -125,7 +125,7 @@
void mergeTypingStyle(Document*);
enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues };
void mergeInlineStyleOfElement(StyledElement*, CSSPropertyOverrideMode, PropertiesToInclude = AllProperties);
- void mergeInlineAndImplicitStyleOfElement(StyledElement*, CSSPropertyOverrideMode, PropertiesToInclude);
+ static PassRefPtr<EditingStyle> wrappingStyleForSerialization(Node* context, bool shouldAnnotate);
void mergeStyleFromRules(StyledElement*);
void mergeStyleFromRulesForSerialization(StyledElement*);
void removeStyleFromRulesAndContext(StyledElement*, Node* context);
@@ -148,6 +148,7 @@
void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclaration*);
void extractFontSizeDelta();
bool conflictsWithInlineStyleOfElement(StyledElement*, EditingStyle* extractedStyle, Vector<CSSPropertyID>* conflictingProperties) const;
+ void mergeInlineAndImplicitStyleOfElement(StyledElement*, CSSPropertyOverrideMode, PropertiesToInclude);
void mergeStyle(CSSMutableStyleDeclaration*, CSSPropertyOverrideMode);
RefPtr<CSSMutableStyleDeclaration> m_mutableStyle;
Modified: trunk/Source/WebCore/editing/markup.cpp (97204 => 97205)
--- trunk/Source/WebCore/editing/markup.cpp 2011-10-12 00:41:06 UTC (rev 97204)
+++ trunk/Source/WebCore/editing/markup.cpp 2011-10-12 01:07:57 UTC (rev 97205)
@@ -343,30 +343,9 @@
m_highestNodeToBeSerialized = lastClosed;
}
- if (Node* parentOfHighestNode = m_highestNodeToBeSerialized ? m_highestNodeToBeSerialized->parentNode() : 0) {
- if (shouldAnnotate()) {
- m_wrappingStyle = EditingStyle::create(parentOfHighestNode, EditingStyle::EditingInheritablePropertiesAndBackgroundColorInEffect);
+ if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode())
+ m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(m_highestNodeToBeSerialized->parentNode(), shouldAnnotate());
- // Styles that Mail blockquotes contribute should only be placed on the Mail blockquote,
- // to help us differentiate those styles from ones that the user has applied.
- // This helps us get the color of content pasted into blockquotes right.
- m_wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(parentOfHighestNode), isMailBlockquote, CanCrossEditingBoundary));
-
- // Call collapseTextDecorationProperties first or otherwise it'll copy the value over from in-effect to text-decorations.
- m_wrappingStyle->collapseTextDecorationProperties();
- } else {
- m_wrappingStyle = EditingStyle::create();
-
- // When not annotating for interchange, we only preserve inline style declarations.
- for (Node* node = parentOfHighestNode; node && !node->isDocumentNode(); node = node->parentNode()) {
- if (node->isStyledElement()) {
- m_wrappingStyle->mergeInlineAndImplicitStyleOfElement(static_cast<StyledElement*>(node), EditingStyle::DoNotOverrideValues,
- EditingStyle::EditingInheritablePropertiesAndBackgroundColorInEffect);
- }
- }
- }
- }
-
return traverseNodesForSerialization(startNode, pastEnd, EmitString);
}