Commit 26f5b365 authored by darin's avatar darin

Reviewed by Justin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6142
          intermittent failures in some paste tests

        * khtml/editing/apply_style_command.cpp:
        (khtml::ApplyStyleCommand::applyBlockStyle): Call new updateLayout member function.
        (khtml::ApplyStyleCommand::applyInlineStyle): Ditto.
        (khtml::ApplyStyleCommand::pushDownTextDecorationStyleAtBoundaries): Ditto.
        * khtml/editing/composite_edit_command.cpp:
        (khtml::CompositeEditCommand::addBlockPlaceholderIfNeeded): Ditto.
        (khtml::CompositeEditCommand::findBlockPlaceholder): Ditto.
        (khtml::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary): Ditto.
        * khtml/editing/delete_selection_command.cpp:
        (khtml::DeleteSelectionCommand::fixupWhitespace): Ditto.
        (khtml::DeleteSelectionCommand::moveNodesAfterNode): Ditto.
        * khtml/editing/edit_command.cpp:
        (khtml::EditCommand::apply): Ditto.
        (khtml::EditCommand::unapply): Ditto.
        (khtml::EditCommand::reapply): Ditto.
        (khtml::EditCommand::updateLayout): Added. Calls updateLayoutIgnorePendingStylesheets
        on the document.
        * khtml/editing/edit_command.h: Added updateLayout member function.
        * khtml/editing/insert_line_break_command.cpp:
        (khtml::InsertLineBreakCommand::doApply): Call new updateLayout member function.
        * khtml/editing/insert_paragraph_separator_command.cpp:
        (khtml::InsertParagraphSeparatorCommand::doApply): Ditto.
        * khtml/editing/jsediting.cpp:
        (DOM::JSEditor::execCommand): Call updateLayoutIgnorePendingStylesheets instead of updateLayout.
        (DOM::JSEditor::queryCommandEnabled): Ditto.
        (DOM::JSEditor::queryCommandIndeterm): Ditto.
        (DOM::JSEditor::queryCommandState): Ditto.
        (DOM::JSEditor::queryCommandValue): Ditto.
        * khtml/editing/markup.cpp: (khtml::createMarkup): Ditto.
        * khtml/editing/replace_selection_command.cpp:
        (khtml::ReplacementFragment::insertFragmentForTestRendering): Ditto.
        (khtml::ReplaceSelectionCommand::fixupNodeStyles): Call new updateLayout member function.
        (khtml::ReplacementFragment::computeStylesUsingTestRendering): Call
        updateLayoutIgnorePendingStylesheets instead of updateLayout.
        (khtml::ReplaceSelectionCommand::doApply): Call new updateLayout member function.
        (khtml::ReplaceSelectionCommand::removeLinePlaceholderIfNeeded): Ditto.
        (khtml::ReplaceSelectionCommand::completeHTMLReplacement): Ditto.
        * khtml/editing/visible_units.cpp:
        (khtml::previousLinePosition): Call updateLayoutIgnorePendingStylesheets instead of updateLayout.
        (khtml::nextLinePosition): Ditto.
        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::innerText): Ditto.
        * kwq/WebCoreBridge.mm:
        (-[WebCoreBridge setSelectedDOMRange:affinity:closeTyping:]): Ditto.
        (-[WebCoreBridge smartDeleteRangeForProposedRange:]): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e8723102
2005-12-21 Darin Adler <darin@apple.com>
Reviewed by Justin.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6142
intermittent failures in some paste tests
* khtml/editing/apply_style_command.cpp:
(khtml::ApplyStyleCommand::applyBlockStyle): Call new updateLayout member function.
(khtml::ApplyStyleCommand::applyInlineStyle): Ditto.
(khtml::ApplyStyleCommand::pushDownTextDecorationStyleAtBoundaries): Ditto.
* khtml/editing/composite_edit_command.cpp:
(khtml::CompositeEditCommand::addBlockPlaceholderIfNeeded): Ditto.
(khtml::CompositeEditCommand::findBlockPlaceholder): Ditto.
(khtml::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary): Ditto.
* khtml/editing/delete_selection_command.cpp:
(khtml::DeleteSelectionCommand::fixupWhitespace): Ditto.
(khtml::DeleteSelectionCommand::moveNodesAfterNode): Ditto.
* khtml/editing/edit_command.cpp:
(khtml::EditCommand::apply): Ditto.
(khtml::EditCommand::unapply): Ditto.
(khtml::EditCommand::reapply): Ditto.
(khtml::EditCommand::updateLayout): Added. Calls updateLayoutIgnorePendingStylesheets
on the document.
* khtml/editing/edit_command.h: Added updateLayout member function.
* khtml/editing/insert_line_break_command.cpp:
(khtml::InsertLineBreakCommand::doApply): Call new updateLayout member function.
* khtml/editing/insert_paragraph_separator_command.cpp:
(khtml::InsertParagraphSeparatorCommand::doApply): Ditto.
* khtml/editing/jsediting.cpp:
(DOM::JSEditor::execCommand): Call updateLayoutIgnorePendingStylesheets instead of updateLayout.
(DOM::JSEditor::queryCommandEnabled): Ditto.
(DOM::JSEditor::queryCommandIndeterm): Ditto.
(DOM::JSEditor::queryCommandState): Ditto.
(DOM::JSEditor::queryCommandValue): Ditto.
* khtml/editing/markup.cpp: (khtml::createMarkup): Ditto.
* khtml/editing/replace_selection_command.cpp:
(khtml::ReplacementFragment::insertFragmentForTestRendering): Ditto.
(khtml::ReplaceSelectionCommand::fixupNodeStyles): Call new updateLayout member function.
(khtml::ReplacementFragment::computeStylesUsingTestRendering): Call
updateLayoutIgnorePendingStylesheets instead of updateLayout.
(khtml::ReplaceSelectionCommand::doApply): Call new updateLayout member function.
(khtml::ReplaceSelectionCommand::removeLinePlaceholderIfNeeded): Ditto.
(khtml::ReplaceSelectionCommand::completeHTMLReplacement): Ditto.
* khtml/editing/visible_units.cpp:
(khtml::previousLinePosition): Call updateLayoutIgnorePendingStylesheets instead of updateLayout.
(khtml::nextLinePosition): Ditto.
* khtml/html/html_elementimpl.cpp:
(HTMLElementImpl::innerText): Ditto.
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge setSelectedDOMRange:affinity:closeTyping:]): Ditto.
(-[WebCoreBridge smartDeleteRangeForProposedRange:]): Ditto.
2005-12-21 Darin Adler <darin@apple.com>
Reviewed by Geoff.
......@@ -45,7 +98,7 @@
2005-12-21 David Harrison <harrison@apple.com>
Reviewed by Justin).
Reviewed by Justin.
<rdar://problem/4039777> Pasting particular snippet of HTML containing list items and a link creates too many list items
- Fixed paste crash by making calling RenderBox::deleteLineBoxWrapper() from RenderObject::remove(),
......
......@@ -366,7 +366,7 @@ void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclarationImpl *style)
// update document layout once before removing styles
// so that we avoid the expense of updating before each and every call
// to check a computed style
document()->updateLayout();
updateLayout();
// get positions we want to use for applying style
Position start = startPosition();
......@@ -539,7 +539,7 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclarationImpl *style)
// update document layout once before removing styles
// so that we avoid the expense of updating before each and every call
// to check a computed style
document()->updateLayout();
updateLayout();
// adjust to the positions we want to use for applying style
Position start = startPosition();
......@@ -590,7 +590,7 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclarationImpl *style)
// update document layout once before running the rest of the function
// so that we avoid the expense of updating before each and every call
// to check a computed style
document()->updateLayout();
updateLayout();
NodeImpl *node = start.node();
if (start.offset() >= start.node()->caretMaxOffset())
......@@ -857,11 +857,11 @@ void ApplyStyleCommand::pushDownTextDecorationStyleAtBoundaries(const Position &
// decoration while pushing down.
pushDownTextDecorationStyleAroundNode(start.node(), start, end, false);
document()->updateLayout();
updateLayout();
pushDownTextDecorationStyleAroundNode(start.node(), start, end, true);
pushDownTextDecorationStyleAroundNode(end.node(), start, end, false);
document()->updateLayout();
updateLayout();
pushDownTextDecorationStyleAroundNode(end.node(), start, end, true);
}
......
......@@ -490,7 +490,7 @@ NodeImpl *CompositeEditCommand::addBlockPlaceholderIfNeeded(NodeImpl *node)
if (!node)
return false;
document()->updateLayout();
updateLayout();
RenderObject *renderer = node->renderer();
if (!renderer || !renderer->isBlockFlow())
......@@ -520,7 +520,7 @@ NodeImpl *CompositeEditCommand::findBlockPlaceholder(NodeImpl *node)
if (!node)
return 0;
document()->updateLayout();
updateLayout();
RenderObject *renderer = node->renderer();
if (!renderer || !renderer->isBlockFlow())
......@@ -544,7 +544,7 @@ void CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Posi
if (pos.isNull())
return;
document()->updateLayout();
updateLayout();
VisiblePosition visiblePos(pos, VP_DEFAULT_AFFINITY);
VisiblePosition visibleParagraphStart(startOfParagraph(visiblePos));
......
......@@ -491,7 +491,7 @@ static inline bool nextCharacterIsCollapsibleWhitespace(const Position &pos)
void DeleteSelectionCommand::fixupWhitespace()
{
document()->updateLayout();
updateLayout();
if (m_leadingWhitespace.isNotNull() && (m_trailingWhitespace.isNotNull() || !m_leadingWhitespace.isRenderedCharacter())) {
LOG(Editing, "replace leading");
TextImpl *textNode = static_cast<TextImpl *>(m_leadingWhitespace.node());
......@@ -591,10 +591,10 @@ void DeleteSelectionCommand::moveNodesAfterNode()
// This will have the side effect of moving 'Three' on to the same line as 'One'
// and 'Two'. This is undesirable. We fix this up by adding a BR before the 'Three'.
// This may not be ideal, but it is better than nothing.
document()->updateLayout();
updateLayout();
if (!startBlock->renderer() || !startBlock->renderer()->firstChild()) {
removeNode(startBlock);
document()->updateLayout();
updateLayout();
if (refNode->renderer() && refNode->renderer()->inlineBox() && refNode->renderer()->inlineBox()->nextOnLineExists()) {
insertNodeAfter(createBreakElement(document()), refNode);
}
......
......@@ -237,7 +237,7 @@ void EditCommand::apply()
setTypingStyle(0);
if (!isCompositeStep()) {
document()->updateLayout();
updateLayout();
EditCommandPtr cmd(this);
part->appliedEditing(cmd);
}
......@@ -258,7 +258,7 @@ void EditCommand::unapply()
m_state = NotApplied;
if (topLevel) {
document()->updateLayout();
updateLayout();
EditCommandPtr cmd(this);
part->unappliedEditing(cmd);
}
......@@ -279,7 +279,7 @@ void EditCommand::reapply()
m_state = Applied;
if (topLevel) {
document()->updateLayout();
updateLayout();
EditCommandPtr cmd(this);
part->reappliedEditing(cmd);
}
......@@ -387,4 +387,9 @@ CSSMutableStyleDeclarationImpl *EditCommand::styleAtPosition(const Position &pos
return style;
}
void EditCommand::updateLayout() const
{
document()->updateLayoutIgnorePendingStylesheets();
}
} // namespace khtml
......@@ -86,6 +86,8 @@ public:
virtual bool isInsertTextCommand() const;
virtual bool isTypingCommand() const;
void updateLayout() const;
private:
void assignTypingStyle(DOM::CSSMutableStyleDeclarationImpl *);
......
......@@ -153,7 +153,7 @@ void InsertLineBreakCommand::doApply()
Position endingPosition = Position(textNode, 0);
// Handle whitespace that occurs after the split
document()->updateLayout();
updateLayout();
if (!endingPosition.isRenderedCharacter()) {
// Clear out all whitespace and insert one non-breaking space
deleteInsignificantTextDownstream(endingPosition);
......
......@@ -299,7 +299,7 @@ void InsertParagraphSeparatorCommand::doApply()
// Handle whitespace that occurs after the split
if (splitText) {
document()->updateLayout();
updateLayout();
pos = Position(startNode, 0);
if (!pos.isRenderedCharacter()) {
// Clear out all whitespace and insert one non-breaking space
......
......@@ -73,7 +73,7 @@ bool JSEditor::execCommand(const DOMString &command, bool userInterface, const D
KHTMLPart *part = m_doc->part();
if (!part)
return false;
m_doc->updateLayout();
m_doc->updateLayoutIgnorePendingStylesheets();
return cmd->enabledFn(part) && cmd->execFn(part, userInterface, value);
}
......@@ -85,7 +85,7 @@ bool JSEditor::queryCommandEnabled(const DOMString &command)
KHTMLPart *part = m_doc->part();
if (!part)
return false;
m_doc->updateLayout();
m_doc->updateLayoutIgnorePendingStylesheets();
return cmd->enabledFn(part);
}
......@@ -97,7 +97,7 @@ bool JSEditor::queryCommandIndeterm(const DOMString &command)
KHTMLPart *part = m_doc->part();
if (!part)
return false;
m_doc->updateLayout();
m_doc->updateLayoutIgnorePendingStylesheets();
return cmd->stateFn(part) == KHTMLPart::mixedTriState;
}
......@@ -109,7 +109,7 @@ bool JSEditor::queryCommandState(const DOMString &command)
KHTMLPart *part = m_doc->part();
if (!part)
return false;
m_doc->updateLayout();
m_doc->updateLayoutIgnorePendingStylesheets();
return cmd->stateFn(part) != KHTMLPart::falseTriState;
}
......@@ -128,7 +128,7 @@ DOMString JSEditor::queryCommandValue(const DOMString &command)
KHTMLPart *part = m_doc->part();
if (!part)
return DOMString();
m_doc->updateLayout();
m_doc->updateLayoutIgnorePendingStylesheets();
return cmd->valueFn(part);
}
......
......@@ -337,7 +337,7 @@ QString createMarkup(const RangeImpl *range, QPtrList<NodeImpl> *nodes, EAnnotat
ASSERT(exceptionCode == 0);
DocumentImpl *doc = commonAncestor->getDocument();
doc->updateLayout();
doc->updateLayoutIgnorePendingStylesheets();
NodeImpl *commonAncestorBlock = 0;
if (commonAncestor != 0) {
......@@ -507,7 +507,7 @@ QString createMarkup(const DOM::NodeImpl *node, EChildrenOnly includeChildren,
QPtrList<DOM::NodeImpl> *nodes, EAnnotateForInterchange annotate)
{
ASSERT(annotate == DoNotAnnotateForInterchange); // annotation not yet implemented for this code path
node->getDocument()->updateLayout();
node->getDocument()->updateLayoutIgnorePendingStylesheets();
return markup(node, includeChildren, false, nodes);
}
......
......@@ -273,7 +273,7 @@ NodeImpl *ReplacementFragment::insertFragmentForTestRendering()
ASSERT(exceptionCode == 0);
holder->deref();
m_document->updateLayout();
m_document->updateLayoutIgnorePendingStylesheets();
return holder;
}
......@@ -305,7 +305,7 @@ void ReplaceSelectionCommand::fixupNodeStyles(const QValueList<NodeDesiredStyle>
// This function uses the mapped "desired style" to apply the additional style needed, if any,
// to make the node have the desired style.
document()->updateLayout();
updateLayout();
QValueListConstIterator<NodeDesiredStyle> it;
for (it = list.begin(); it != list.end(); ++it) {
......@@ -395,7 +395,7 @@ void ReplacementFragment::computeStylesUsingTestRendering(NodeImpl *holder)
if (!holder)
return;
m_document->updateLayout();
m_document->updateLayoutIgnorePendingStylesheets();
for (NodeImpl *node = holder->firstChild(); node; node = node->traverseNextNode(holder))
computeAndStoreNodeDesiredStyle(node, m_styles);
......@@ -636,7 +636,7 @@ void ReplaceSelectionCommand::doApply()
// delete the current range selection, or insert paragraph for caret selection, as needed
if (selection.isRange()) {
deleteSelection(false, !(m_fragment.hasInterchangeNewlineAtStart() || m_fragment.hasInterchangeNewlineAtEnd() || m_fragment.hasMoreThanOneBlock()));
document()->updateLayout();
updateLayout();
visibleStart = VisiblePosition(endingSelection().start(), VP_DEFAULT_AFFINITY);
if (m_fragment.hasInterchangeNewlineAtStart()) {
if (isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart)) {
......@@ -731,7 +731,7 @@ void ReplaceSelectionCommand::doApply()
// add "smart replace" space, handle trailing newline, clean up.
// initially, we say the insertion point is the start of selection
document()->updateLayout();
updateLayout();
Position insertionPos = startPos;
// step 1: merge content into the start block, if that is needed
......@@ -758,7 +758,7 @@ void ReplaceSelectionCommand::doApply()
// update insertion point to be at the end of the last block inserted
if (m_lastNodeInserted) {
document()->updateLayout();
updateLayout();
insertionPos = Position(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset());
}
}
......@@ -788,13 +788,13 @@ void ReplaceSelectionCommand::doApply()
refNode = node;
node = next;
}
document()->updateLayout();
updateLayout();
insertionPos = Position(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset());
}
// step 3 : handle "smart replace" whitespace
if (addTrailingSpace && m_lastNodeInserted) {
document()->updateLayout();
updateLayout();
Position pos(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset());
bool needsTrailingSpace = pos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull();
if (needsTrailingSpace) {
......@@ -812,7 +812,7 @@ void ReplaceSelectionCommand::doApply()
}
if (addLeadingSpace && m_firstNodeInserted) {
document()->updateLayout();
updateLayout();
Position pos(m_firstNodeInserted, 0);
bool needsLeadingSpace = pos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull();
if (needsLeadingSpace) {
......@@ -843,7 +843,7 @@ void ReplaceSelectionCommand::doApply()
insertParagraph = true;
} else {
// Handle end-of-document case.
document()->updateLayout();
updateLayout();
if (isEndOfDocument(pos))
insertParagraph = true;
}
......@@ -864,7 +864,7 @@ void ReplaceSelectionCommand::doApply()
}
else {
if (m_lastNodeInserted && m_lastNodeInserted->hasTagName(brTag) && !document()->inStrictMode()) {
document()->updateLayout();
updateLayout();
VisiblePosition pos(Position(m_lastNodeInserted, 1), DOWNSTREAM);
if (isEndOfBlock(pos)) {
NodeImpl *next = m_lastNodeInserted->traverseNextNode();
......@@ -877,7 +877,7 @@ void ReplaceSelectionCommand::doApply()
}
if (moveNodesAfterEnd && !isLastVisiblePositionInSpecialElement(Position(m_lastNodeInserted, maxRangeOffset(m_lastNodeInserted)))) {
document()->updateLayout();
updateLayout();
QValueList<NodeDesiredStyle> styles;
QPtrList<NodeImpl> blocks;
NodeImpl *node = beyondEndNode;
......@@ -899,7 +899,7 @@ void ReplaceSelectionCommand::doApply()
break;
node = next;
}
document()->updateLayout();
updateLayout();
for (QPtrListIterator<NodeImpl> it(blocks); it.current(); ++it) {
NodeImpl *blockToRemove = it.current();
if (!blockToRemove->inDocument())
......@@ -908,7 +908,7 @@ void ReplaceSelectionCommand::doApply()
if (blockToRemove->parentNode())
blocks.append(blockToRemove->parentNode()->enclosingBlockFlowElement());
removeNode(blockToRemove);
document()->updateLayout();
updateLayout();
}
}
......@@ -929,14 +929,14 @@ void ReplaceSelectionCommand::removeLinePlaceholderIfNeeded(NodeImpl *linePlaceh
if (!linePlaceholder)
return;
document()->updateLayout();
updateLayout();
if (linePlaceholder->inDocument()) {
VisiblePosition placeholderPos(linePlaceholder, linePlaceholder->renderer()->caretMinOffset(), DOWNSTREAM);
if (placeholderPos.next().isNull() ||
!(isStartOfLine(placeholderPos) && isEndOfLine(placeholderPos))) {
NodeImpl *block = linePlaceholder->enclosingBlockFlowElement();
removeNode(linePlaceholder);
document()->updateLayout();
updateLayout();
if (!block->renderer() || block->renderer()->height() == 0)
removeNode(block);
}
......@@ -970,7 +970,7 @@ void ReplaceSelectionCommand::completeHTMLReplacement(const Position &lastPositi
}
// Call updateLayout so caretMinOffset and caretMaxOffset return correct values.
document()->updateLayout();
updateLayout();
start = Position(firstLeaf, firstLeaf->caretMinOffset());
end = Position(lastLeaf, lastLeaf->caretMaxOffset());
......
......@@ -366,7 +366,7 @@ VisiblePosition previousLinePosition(const VisiblePosition &c, int x)
if (!node || !node->getDocument())
return VisiblePosition();
node->getDocument()->updateLayout();
node->getDocument()->updateLayoutIgnorePendingStylesheets();
RenderObject *renderer = node->renderer();
if (!renderer)
......@@ -429,7 +429,7 @@ VisiblePosition nextLinePosition(const VisiblePosition &c, int x)
if (!node || !node->getDocument())
return VisiblePosition();
node->getDocument()->updateLayout();
node->getDocument()->updateLayoutIgnorePendingStylesheets();
RenderObject *renderer = node->renderer();
if (!renderer)
......
......@@ -233,7 +233,7 @@ DOMString HTMLElementImpl::outerHTML() const
DOMString HTMLElementImpl::innerText() const
{
// We need to update layout, since plainText uses line boxes in the render tree.
getDocument()->updateLayout();
getDocument()->updateLayoutIgnorePendingStylesheets();
return plainText(rangeOfContents(const_cast<HTMLElementImpl *>(this)).get());
}
......
......@@ -1638,7 +1638,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
ASSERT(startContainer->getDocument());
ASSERT(startContainer->getDocument() == endContainer->getDocument());
_part->xmlDocImpl()->updateLayout();
_part->xmlDocImpl()->updateLayoutIgnorePendingStylesheets();
EAffinity affinity = static_cast<EAffinity>(selectionAffinity);
......@@ -1786,7 +1786,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
ASSERT(startContainer->getDocument());
ASSERT(startContainer->getDocument() == endContainer->getDocument());
_part->xmlDocImpl()->updateLayout();
_part->xmlDocImpl()->updateLayoutIgnorePendingStylesheets();
Position start(startContainer, [proposedRange startOffset]);
Position end(endContainer, [proposedRange endOffset]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment