+2006-07-28 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by levi
+
+ <rdar://problem/4515463>
+ REGRESSION: Blot and Mail both do a very poor job of pasting the main www.apple.com page
+
+ Removed incorrect nesting:
+ * editing/pasteboard/paste-table-001-expected.checksum:
+ * editing/pasteboard/paste-table-001-expected.png:
+ * editing/pasteboard/paste-table-001-expected.txt:
+ * editing/pasteboard/paste-table-003-expected.txt:
+
2006-07-27 Justin Garcia <justin.garcia@apple.com>
Reviewed by levi
-d3284c7bb7cf0687066248b7d3ffa6ff
\ No newline at end of file
+ce343032b993d8881ce02fe72de0c59f
\ No newline at end of file
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 2 of TABLE > P > DIV > BODY > HTML > #document to 2 of TABLE > P > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of TABLE > P > DIV > BODY > HTML > #document to 2 of TABLE > P > DIV > BODY > HTML > #document toDOMRange:range from 32 of #text > TD > TR > TBODY > TABLE > P > DIV > BODY > HTML > #document to 32 of #text > TD > TR > TBODY > TABLE > P > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of TABLE > P > DIV > BODY > HTML > #document to 2 of TABLE > P > DIV > BODY > HTML > #document toDOMRange:range from 32 of #text > TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document to 32 of #text > TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
RenderText {#text} at (0,0) size 161x28
text run at (0,0) width 161: "Empty table cell"
RenderText {#text} at (0,0) size 0x0
- RenderBlock {P} at (14,66) size 756x108
+ RenderBlock {P} at (14,66) size 756x54
RenderTable {TABLE} at (0,0) size 292x54 [border: (2px outset #808080)]
RenderTableSection {TBODY} at (2,2) size 288x50
RenderTableRow {TR} at (0,2) size 288x22
RenderTableCell {TD} at (85,26) size 201x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
RenderText {#text} at (2,2) size 197x18
text run at (2,2) width 197: "I should be in the right column."
- RenderTable {TABLE} at (0,54) size 292x54 [border: (2px outset #808080)]
- RenderTableSection {TBODY} at (2,2) size 288x50
- RenderTableRow {TR} at (0,2) size 288x22
- RenderTableCell {TD} at (2,2) size 81x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
- RenderText {#text} at (2,2) size 77x18
- text run at (2,2) width 77: "Left column"
- RenderTableCell {TD} at (85,2) size 201x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
- RenderText {#text} at (2,2) size 86x18
- text run at (2,2) width 86: "Right column"
- RenderTableRow {TR} at (0,26) size 288x22
- RenderTableCell {TD} at (2,35) size 81x4 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
- RenderTableCell {TD} at (85,26) size 201x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
- RenderText {#text} at (2,2) size 197x18
- text run at (2,2) width 197: "I should be in the right column."
-caret: position 32 of child 0 {#text} of child 1 {TD} of child 1 {TR} of child 0 {TBODY} of child 2 {TABLE} of child 3 {P} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+ RenderTable {TABLE} at (14,144) size 292x54 [border: (2px outset #808080)]
+ RenderTableSection {TBODY} at (2,2) size 288x50
+ RenderTableRow {TR} at (0,2) size 288x22
+ RenderTableCell {TD} at (2,2) size 81x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+ RenderText {#text} at (2,2) size 77x18
+ text run at (2,2) width 77: "Left column"
+ RenderTableCell {TD} at (85,2) size 201x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+ RenderText {#text} at (2,2) size 86x18
+ text run at (2,2) width 86: "Right column"
+ RenderTableRow {TR} at (0,26) size 288x22
+ RenderTableCell {TD} at (2,35) size 81x4 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+ RenderTableCell {TD} at (85,26) size 201x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+ RenderText {#text} at (2,2) size 197x18
+ text run at (2,2) width 197: "I should be in the right column."
+caret: position 32 of child 0 {#text} of child 1 {TD} of child 1 {TR} of child 0 {TBODY} of child 4 {TABLE} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
RenderTableCell {TD} at (29,2) size 26x20 [r=0 c=1 rs=1 cs=1]
RenderText {#text} at (1,1) size 24x18
text run at (1,1) width 24: "two"
- RenderBlock {DIV} at (0,24) size 784x42
- RenderTable {TABLE} at (0,0) size 57x24
- RenderTableSection {TBODY} at (0,0) size 57x24
- RenderTableRow {TR} at (0,2) size 57x20
- RenderTableCell {TD} at (2,2) size 25x20 [r=0 c=0 rs=1 cs=1]
- RenderText {#text} at (1,1) size 23x18
- text run at (1,1) width 23: "one"
- RenderTableCell {TD} at (29,2) size 26x20 [r=0 c=1 rs=1 cs=1]
- RenderText {#text} at (1,1) size 24x18
- text run at (1,1) width 24: "two"
- RenderBlock (anonymous) at (0,24) size 784x18
- RenderBR {BR} at (0,0) size 0x18
-caret: position 0 of child 1 {BR} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+ RenderTable {TABLE} at (0,24) size 57x24
+ RenderTableSection {TBODY} at (0,0) size 57x24
+ RenderTableRow {TR} at (0,2) size 57x20
+ RenderTableCell {TD} at (2,2) size 25x20 [r=0 c=0 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 23x18
+ text run at (1,1) width 23: "one"
+ RenderTableCell {TD} at (29,2) size 26x20 [r=0 c=1 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 24x18
+ text run at (1,1) width 24: "two"
+ RenderBlock {DIV} at (0,48) size 784x18
+ RenderBR {BR} at (0,0) size 0x18
+caret: position 0 of child 0 {BR} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+2006-07-28 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by levi
+
+ First part of:
+ <rdar://problem/4515463>
+ REGRESSION: Blot and Mail both do a very poor job of pasting the main www.apple.com page
+
+ Migrate to isBlock and enclosingBlock.
+ Changed RendereringInfo::isBlock and ReplacementFragment::isBlock
+ to wasBlock so that they don't conflict with isBlock and because
+ it's more descriptive.
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplacementFragment::mergeStartNode):
+ (WebCore::ReplacementFragment::wasBlock):
+ (WebCore::ReplacementFragment::saveRenderingInfo):
+ (WebCore::ReplacementFragment::renderedBlocks):
+ (WebCore::RenderingInfo::RenderingInfo):
+ (WebCore::ReplaceSelectionCommand::shouldMergeStart):
+ (WebCore::ReplaceSelectionCommand::doApply):
+ * editing/ReplaceSelectionCommand.h:
+ (WebCore::RenderingInfo::wasBlock):
+
2006-07-27 Justin Garcia <justin.garcia@apple.com>
Reviewed by levi
Node *ReplacementFragment::mergeStartNode() const
{
Node *node = m_fragment->firstChild();
- while (node && isBlockFlow(node) && !isMailPasteAsQuotationNode(node))
+ while (node && wasBlock(node) && !isMailPasteAsQuotationNode(node))
node = node->traverseNextNode();
return node;
}
static_cast<const HTMLElement *>(node)->getAttribute(classAttr) == convertedSpaceSpanClassString;
}
-Node *ReplacementFragment::enclosingBlock(Node *node) const
-{
- while (node && !isBlockFlow(node))
- node = node->parentNode();
- return node ? node : m_fragment.get();
-}
-
void ReplacementFragment::removeNodePreservingChildren(Node *node)
{
if (!node)
}
}
-bool ReplacementFragment::isBlockFlow(Node* node) const
+bool ReplacementFragment::wasBlock(Node* node) const
{
RefPtr<RenderingInfo> info = m_renderingInfo.get(node);
ASSERT(info);
if (!info)
return false;
- return info->isBlockFlow();
+ return info->wasBlock();
}
static String &matchNearestBlockquoteColorString()
if (m_matchStyle) {
// No style restoration will be done, so we don't need to save styles or keep a node vector.
for (Node *node = holder->firstChild(); node; node = node->traverseNextNode(holder))
- m_renderingInfo.add(node, new RenderingInfo(0, node->isBlockFlow()));
+ m_renderingInfo.add(node, new RenderingInfo(0, isBlock(node)));
} else {
for (Node *node = holder->firstChild(); node; node = node->traverseNextNode(holder)) {
- m_renderingInfo.add(node, new RenderingInfo(styleForNode(node), node->isBlockFlow()));
+ m_renderingInfo.add(node, new RenderingInfo(styleForNode(node), isBlock(node)));
m_nodes.append(node);
}
}
int count = 0;
Node *prev = 0;
for (Node *node = holder->firstChild(); node; node = node->traverseNextNode(holder)) {
- if (node->isBlockFlow()) {
+ if (isBlock(node)) {
if (!prev) {
count++;
prev = node;
}
} else {
- Node *block = node->enclosingBlockFlowElement();
+ Node *block = enclosingBlock(node);
if (block != prev) {
count++;
prev = block;
}
}
-RenderingInfo::RenderingInfo(PassRefPtr<CSSMutableStyleDeclaration> style, bool isBlockFlow = false)
- : m_style(style), m_isBlockFlow(isBlockFlow)
+RenderingInfo::RenderingInfo(PassRefPtr<CSSMutableStyleDeclaration> style, bool wasBlock = false)
+ : m_style(style), m_wasBlock(wasBlock)
{
}
return true;
VisiblePosition visibleStart = destinationSelection.visibleStart();
- Node* startBlock = destinationSelection.start().node()->enclosingBlockFlowElement();
+ Node* startBlock = enclosingBlock(destinationSelection.start().node());
// <rdar://problem/4013642> Copied quoted word does not paste as a quote if pasted at the start of a line
if (isStartOfParagraph(visibleStart) && isMailBlockquote(incomingFragment.firstChild()))
VisiblePosition visibleStart(selection.start(), selection.affinity());
VisiblePosition visibleEnd(selection.end(), selection.affinity());
bool startAtStartOfBlock = isStartOfBlock(visibleStart);
- Node* startBlock = selection.start().node()->enclosingBlockFlowElement();
+ Node* startBlock = enclosingBlock(selection.start().node());
// Whether the first paragraph of the incoming fragment should be merged with content from visibleStart to startOfParagraph(visibleStart).
bool mergeStart = shouldMergeStart(fragment, selection);
RefPtr<Node> node = refNode->nextSibling();
fragment.removeNode(refNode);
insertNodeAtAndUpdateNodesInserted(refNode.get(), startPos.node(), startPos.offset());
- while (node && !fragment.isBlockFlow(node.get())) {
+ while (node && !fragment.wasBlock(node.get())) {
Node *next = node->nextSibling();
fragment.removeNode(node);
insertNodeAfterAndUpdateNodesInserted(node.get(), refNode.get());
if (fragment.firstChild()) {
RefPtr<Node> refNode = fragment.firstChild();
RefPtr<Node> node = refNode ? refNode->nextSibling() : 0;
- Node* insertionBlock = insertionPos.node()->enclosingBlockFlowElement();
+ Node* insertionBlock = enclosingBlock(insertionPos.node());
Node* insertionRoot = insertionPos.node()->rootEditableElement();
bool insertionBlockIsRoot = insertionBlock == insertionRoot;
VisiblePosition visibleInsertionPos(insertionPos);
fragment.removeNode(refNode);
// FIXME: The first two cases need to be rethought. They're about preventing the nesting of
// incoming blocks in the block where the paste is being performed. But, avoiding nesting doesn't
- // always produce the desired visual result, and the decisions are based on isBlockFlow, which
+ // always produce the desired visual result, and the decisions are based on wasBlock, which
// we're getting rid of.
- if (!insertionBlockIsRoot && fragment.isBlockFlow(refNode.get()) && isStartOfBlock(visibleInsertionPos) && !m_lastNodeInserted)
+ if (!insertionBlockIsRoot && fragment.wasBlock(refNode.get()) && isStartOfBlock(visibleInsertionPos) && !m_lastNodeInserted)
insertNodeBeforeAndUpdateNodesInserted(refNode.get(), insertionBlock);
- else if (!insertionBlockIsRoot && fragment.isBlockFlow(refNode.get()) && isEndOfBlock(visibleInsertionPos))
+ else if (!insertionBlockIsRoot && fragment.wasBlock(refNode.get()) && isEndOfBlock(visibleInsertionPos))
insertNodeAfterAndUpdateNodesInserted(refNode.get(), insertionBlock);
- else if (m_lastNodeInserted && !fragment.isBlockFlow(refNode.get())) {
+ else if (m_lastNodeInserted && !fragment.wasBlock(refNode.get())) {
// A non-null m_lastNodeInserted means we've done merging above. That means everything in the first paragraph
// of the fragment has been merged with everything up to the start of the paragraph where the paste was performed.
// refNode is the first node in the second paragraph of the fragment to paste. Since it's inline, we can't
RenderingInfo(PassRefPtr<CSSMutableStyleDeclaration>, bool);
CSSMutableStyleDeclaration* style() const { return m_style.get(); }
- bool isBlockFlow() const { return m_isBlockFlow; }
+ bool wasBlock() const { return m_wasBlock; }
private:
RefPtr<CSSMutableStyleDeclaration> m_style;
- bool m_isBlockFlow;
+ bool m_wasBlock;
};
typedef Vector<RefPtr<Node> > NodeVector;
bool hasInterchangeNewlineAtStart() const { return m_hasInterchangeNewlineAtStart; }
bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEnd; }
- bool isBlockFlow(Node*) const;
+ bool wasBlock(Node*) const;
void removeNode(PassRefPtr<Node>);
void restoreTestRenderingNodesToFragment(Node*);
int renderedBlocks(Node*);
void removeStyleNodes();
-
- Node* enclosingBlock(Node*) const;
+
void removeNodePreservingChildren(Node*);
void insertNodeBefore(Node* node, Node* refNode);