+2006-08-03 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ * editing/style/non-inheritable-styles-expected.checksum: Added.
+ * editing/style/non-inheritable-styles-expected.png: Added.
+ * editing/style/non-inheritable-styles-expected.txt: Added.
+ * editing/style/non-inheritable-styles.html: Added.
+
2006-08-03 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
--- /dev/null
+90362ed413c7ab542a3b1c78fd6bca1a
\ No newline at end of file
--- /dev/null
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of SPAN > BODY > HTML > #document to 3 of SPAN > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of SPAN > BODY > HTML > #document to 0 of SPAN > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > BODY > HTML > #document to 30 of #text > SPAN > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of SPAN > BODY > HTML > #document to 3 of SPAN > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of SPAN > BODY > HTML > #document to 0 of SPAN > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of SPAN > BODY > HTML > #document to 0 of SPAN > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of SPAN > BODY > HTML > #document to 0 of SPAN > BODY > HTML > #document toDOMRange:range from 29 of #text > SPAN > BODY > HTML > #document to 29 of #text > SPAN > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+ RenderView 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 {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 507x18
+ text run at (0,0) width 102: "This tests copy. "
+ text run at (102,0) width 405: "Non-inheritable styles should be brought down from stylesheets."
+ RenderBlock {SPAN} at (0,34) size 784x54
+ RenderBlock (anonymous) at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 183x18
+ text run at (0,0) width 183: "This shouldn't have a border."
+ RenderBlock {DIV} at (0,18) size 784x18
+ RenderText {#text} at (0,0) size 289x18
+ text run at (0,0) width 289: "This should have blue border when its pasted."
+ RenderBlock (anonymous) at (0,36) size 784x18
+ RenderText {#text} at (0,0) size 183x18
+ text run at (0,0) width 183: "This shouldn't have a border."
+ RenderBlock {SPAN} at (0,88) size 784x56
+ RenderBlock (anonymous) at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 183x18
+ text run at (0,0) width 183: "This shouldn't have a border."
+ RenderBlock {DIV} at (0,18) size 784x20 [border: (1px solid #0000FF)]
+ RenderText {#text} at (1,1) size 289x18
+ text run at (1,1) width 289: "This should have blue border when its pasted."
+ RenderBlock (anonymous) at (0,38) size 784x18
+ RenderText {#text} at (0,0) size 183x18
+ text run at (0,0) width 183: "This shouldn't have a border."
+caret: position 29 of child 2 {#text} of child 5 {SPAN} of child 1 {BODY} of child 0 {HTML} of document
--- /dev/null
+<style>
+div {
+ border: 1px solid red;
+}
+#id {
+ border: 1px solid blue;
+}
+.class {
+ border: 1px solid black;
+}
+</style>
+
+<body>
+<p>This tests copy. Non-inheritable styles should be brought down from stylesheets.</p>
+<span id="copy" style="display:block" contenteditable="true">
+This shouldn't have a border.
+<div class="class" id="id">This should have blue border when its pasted.</div>
+This shouldn't have a border.</span>
+<span id="paste" style="display:block" contenteditable="true"></span>
+
+</body>
+<script>
+var sel = window.getSelection();
+var copy = document.getElementById("copy");
+var paste = document.getElementById("paste");
+
+sel.setPosition(copy, 0);
+document.execCommand("SelectAll");
+document.execCommand("Copy");
+var len = document.styleSheets[0].cssRules.length;
+for (var i = 0; i < len; i++)
+ document.styleSheets[0].deleteRule(0);
+
+sel.setPosition(paste, 0);
+document.execCommand("Paste");
+</script>
+</body>
\ No newline at end of file
+2006-08-03 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ <rdar://problem/4641033/4515463/4052426/4046570/4053718/4053724/4060115/4062858>
+ Copy/Paste fidelity was bad.
+
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::ApplyStyleCommand::applyInlineStyle):
+ * editing/markup.cpp:
+ (WebCore::startMarkup): We were not adding non-inheritable styles
+ to the markup for an element unless they were in the elements inline
+ style declaration.
+
2006-08-03 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Darin.
rangeIsEmpty = true;
}
+ // If end is [table, maxDeepOffset(table)], that means that the table is selected, and we want to visit
+ // contents of the table, instead of stopping at it.
if (end.node()->renderer() && end.node()->renderer()->isTable() && end.offset() == maxDeepOffset(end.node()))
endNode = end.node()->lastDescendant();
+ // If the end node is an ancestor of the start node then a pre-order
+ // traversal will never reach it. Adjust it so that this won't happen.
+ if (node->isAncestor(endNode))
+ endNode = endNode->lastDescendant();
if (node == endNode) {
addInlineStyleIfNeeded(style, node, node);
} else if (!rangeIsEmpty) {
- // If the end node is an ancestor of the start node then we need
- // to replace endNode with its next sibling to ensure that the
- // exit condition node == endNode is reached
- if (node->isAncestor(endNode))
- endNode = endNode->traverseNextSibling();
while (1) {
if (node->childNodeCount() == 0 && node->renderer() && node->renderer()->isInline() && node->isContentRichlyEditable()) {
#include "markup.h"
#include "CSSComputedStyleDeclaration.h"
+#include "CSSRule.h"
+#include "CSSRuleList.h"
+#include "CSSStyleRule.h"
+#include "cssstyleselector.h"
#include "Comment.h"
#include "Document.h"
#include "DocumentFragment.h"
if (defaultStyle && el->isHTMLElement()) {
RefPtr<CSSComputedStyleDeclaration> computedStyle = Position(const_cast<Element*>(el), 0).computedStyle();
RefPtr<CSSMutableStyleDeclaration> style = computedStyle->copyInheritableProperties();
+ RefPtr<CSSRuleList> matchedRules = node->document()->styleSelector()->styleRulesForElement(const_cast<Element*>(el), true);
+ if (matchedRules) {
+ for (unsigned i = 0; i < matchedRules->length(); i++) {
+ if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE) {
+ RefPtr<CSSMutableStyleDeclaration> s = static_cast<CSSStyleRule*>(matchedRules->item(i))->style();
+ style->merge(s.get(), true);
+ }
+ }
+ }
defaultStyle->diff(style.get());
if (style->length() > 0) {
CSSMutableStyleDeclaration *inlineStyleDecl = static_cast<const HTMLElement*>(el)->inlineStyleDecl();