Changeset 180726 in webkit
- Timestamp:
- Feb 26, 2015, 9:51:31 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/mac/editing/inserting/5058163-1-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Position.cpp (modified) (8 diffs)
-
Source/WebCore/dom/PositionIterator.cpp (modified) (1 diff)
-
Source/WebCore/editing/ApplyBlockElementCommand.cpp (modified) (1 diff)
-
Source/WebCore/editing/htmlediting.cpp (modified) (5 diffs)
-
Source/WebCore/editing/htmlediting.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r180724 r180726 1 2015-02-26 Ryosuke Niwa <rniwa@webkit.org> 2 3 isEditablePosition and related functions shouldn't move position out of table 4 https://bugs.webkit.org/show_bug.cgi?id=129200 5 6 Reviewed by Darin Adler. 7 8 Rebaselined a test. There is no visual difference. 9 10 * platform/mac/editing/inserting/5058163-1-expected.txt: 11 1 12 2015-02-26 Brent Fulgham <bfulgham@apple.com> 2 13 -
trunk/LayoutTests/platform/mac/editing/inserting/5058163-1-expected.txt
r177774 r180726 14 14 RenderText {#text} at (1,1) size 476x18 15 15 text run at (1,1) width 476: "There should be two empty paragraphs after this table and before the next." 16 RenderBlock (anonymous) at (0,26) size 784x3616 RenderBlock {DIV} at (0,26) size 784x18 17 17 RenderBR {BR} at (0,0) size 0x18 18 RenderBR {BR} at (0,18) size 0x18 18 RenderBlock (anonymous) at (0,44) size 784x18 19 RenderBR {BR} at (0,0) size 0x18 19 20 RenderTable {TABLE} at (0,62) size 280x26 [border: (1px solid #AAAAAA)] 20 21 RenderTableSection {TBODY} at (1,1) size 278x24 -
trunk/Source/WebCore/ChangeLog
r180720 r180726 1 2015-02-26 Ryosuke Niwa <rniwa@webkit.org> 2 3 isEditablePosition and related functions shouldn't move position out of table 4 https://bugs.webkit.org/show_bug.cgi?id=129200 5 6 Reviewed by Darin Adler. 7 8 This patch removes the legacy editing position for elements display: table in its computed style. 9 Previously, we used (table, 0) and (table, !0) to denote positions immediately before and after 10 such an element for historical reasons. This forced us to update the style tree before computing 11 the editability of a position because we have to check the editability of the position outside 12 the element with display: table if the position was using such a legacy editing position. 13 e.g. if a table was not editable (contenteditable=false), the position before the table (table, 0) 14 should still be considered editable if the parent node of the table was editable. 15 16 This patch replaces such a legacy editing position by using modern position types: 17 PositionIsBeforeAnchor and PositionIsAfterAnchor. 18 19 No new tests since there should be no change in the user perceived editing operations. 20 21 * dom/Position.cpp: 22 (WebCore::Position::previous): Setup the node and the offset correctly when the original position's 23 type is PositionIsBeforeAnchor. Also return a position before or after node when the node we found 24 is "atomic" (e.g. input, img, br, etc...) or it's a table. This avoids creating a legacy editing 25 position inside a table. 26 (WebCore::Position::next): Ditto. 27 (WebCore::Position::atStartOfTree): Use atFirstEditingPositionForNode, which takes care of all types 28 of positions. 29 (WebCore::Position::atEndOfTree): Ditto. 30 (WebCore::Position::downstream): Return a position before a node instead of a legacy editing position 31 for an atomic element or a table element as done in the equivalent code in Position::upstream. 32 (WebCore::Position::isCandidate): Don't treat a position inside a table to be a candidate. e.g. 33 (table, 1) when there are more than two children of the table. 34 35 * dom/PositionIterator.cpp: 36 (WebCore::PositionIterator::operator Position): PositionIterator internally uses legacy editing 37 positions. So convert it to a modern position by returning a position before or after a table here. 38 * editing/ApplyBlockElementCommand.cpp: 39 (WebCore::ApplyBlockElementCommand::formatSelection): Check that the unsplittable element we found 40 is actually empty before executing the simple code path for an empty unsplittable element. Without 41 this check, block formatting a table element will fail. 42 43 * editing/htmlediting.cpp: 44 (WebCore::isEditablePosition): Use containerNode instead of deprecatedNode because the editability 45 of a position before or after an element is determined by its parent, not the element itself. 46 (WebCore::isAtUnsplittableElement): Ditto. 47 (WebCore::isRichlyEditablePosition): Ditto. Removed the code that moved the starting node out of 48 an element with display: table. This is the code removal for which this patch was made. 49 (WebCore::editableRootForPosition): Ditto. 50 1 51 2015-02-26 Timothy Horton <timothy_horton@apple.com> 2 52 -
trunk/Source/WebCore/dom/Position.cpp
r180213 r180726 309 309 ASSERT(offset >= 0); 310 310 311 if (anchorType() == PositionIsBeforeAnchor) { 312 node = containerNode(); 313 offset = computeOffsetInContainerNode(); 314 } 315 311 316 if (offset > 0) { 312 317 if (Node* child = node->traverseToChildAt(offset - 1)) … … 332 337 return *this; 333 338 339 if (positionBeforeOrAfterNodeIsCandidate(node)) 340 return positionBeforeNode(node); 341 342 Node* previousSibling = node->previousSibling(); 343 if (previousSibling && positionBeforeOrAfterNodeIsCandidate(previousSibling)) 344 return positionAfterNode(previousSibling); 345 334 346 return createLegacyEditingPosition(parent, node->computeNodeIndex()); 335 347 } … … 346 358 // FIXME: Negative offsets shouldn't be allowed. We should catch this earlier. 347 359 ASSERT(offset >= 0); 360 361 if (anchorType() == PositionIsAfterAnchor) { 362 node = containerNode(); 363 offset = computeOffsetInContainerNode(); 364 } 348 365 349 366 Node* child = node->traverseToChildAt(offset); … … 363 380 if (!parent) 364 381 return *this; 382 383 if (isRenderedTable(node) || editingIgnoresContent(node)) 384 return positionAfterNode(node); 385 386 Node* nextSibling = node->nextSibling(); 387 if (nextSibling && positionBeforeOrAfterNodeIsCandidate(nextSibling)) 388 return positionBeforeNode(nextSibling); 365 389 366 390 return createLegacyEditingPosition(parent, node->computeNodeIndex() + 1); … … 453 477 if (isNull()) 454 478 return true; 455 return !findParent( deprecatedNode()) && m_offset <= 0;479 return !findParent(containerNode()) && atFirstEditingPositionForNode(); 456 480 } 457 481 … … 460 484 if (isNull()) 461 485 return true; 462 return !findParent( deprecatedNode()) && m_offset >= lastOffsetForEditing(deprecatedNode());486 return !findParent(containerNode()) && atLastEditingPositionForNode(); 463 487 } 464 488 … … 755 779 if (editingIgnoresContent(currentNode) || isRenderedTable(currentNode)) { 756 780 if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset()) 757 return createLegacyEditingPosition(currentNode, renderer->caretMinOffset());781 return positionBeforeNode(currentNode); 758 782 continue; 759 783 } … … 932 956 return !nodeIsUserSelectNone(deprecatedNode()) && downcast<RenderText>(*renderer).containsCaretOffset(m_offset); 933 957 934 if (isRenderedTable(deprecatedNode()) || editingIgnoresContent(deprecatedNode())) 935 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode()) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); 958 if (positionBeforeOrAfterNodeIsCandidate(deprecatedNode())) { 959 return ((atFirstEditingPositionForNode() && m_anchorType == PositionIsBeforeAnchor) 960 || (atLastEditingPositionForNode() && m_anchorType == PositionIsAfterAnchor)) 961 && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); 962 } 936 963 937 964 if (m_anchorNode->hasTagName(htmlTag)) -
trunk/Source/WebCore/dom/PositionIterator.cpp
r174403 r180726 44 44 ASSERT(m_nodeAfterPositionInAnchor->parentNode() == m_anchorNode); 45 45 // FIXME: This check is inadaquete because any ancestor could be ignored by editing 46 if ( editingIgnoresContent(m_nodeAfterPositionInAnchor->parentNode()))46 if (positionBeforeOrAfterNodeIsCandidate(m_anchorNode)) 47 47 return positionBeforeNode(m_anchorNode); 48 48 return positionInParentBeforeNode(m_nodeAfterPositionInAnchor); 49 49 } 50 if (positionBeforeOrAfterNodeIsCandidate(m_anchorNode)) 51 return atStartOfNode() ? positionBeforeNode(m_anchorNode) : positionAfterNode(m_anchorNode); 50 52 if (m_anchorNode->hasChildNodes()) 51 53 return lastPositionInOrAfterNode(m_anchorNode); -
trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp
r174225 r180726 104 104 // and there's nothing to move. 105 105 Position start = startOfSelection.deepEquivalent().downstream(); 106 if (isAtUnsplittableElement(start) ) {106 if (isAtUnsplittableElement(start) && startOfParagraph(start) == endOfParagraph(endOfSelection)) { 107 107 RefPtr<Element> blockquote = createBlockElement(); 108 108 insertNodeAt(blockquote, start); -
trunk/Source/WebCore/editing/htmlediting.cpp
r179143 r180726 144 144 bool isEditablePosition(const Position& p, EditableType editableType, EUpdateStyle updateStyle) 145 145 { 146 Node* node = p. deprecatedNode();146 Node* node = p.containerNode(); 147 147 if (!node) 148 148 return false; … … 152 152 ASSERT(updateStyle == DoNotUpdateStyle); 153 153 154 if (node->renderer() && node->renderer()->isTable())155 node = node->parentNode();156 157 154 return node->hasEditableStyle(editableType); 158 155 } … … 160 157 bool isAtUnsplittableElement(const Position& pos) 161 158 { 162 Node* node = pos. deprecatedNode();159 Node* node = pos.containerNode(); 163 160 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType(pos, &isTableCell)); 164 161 } … … 167 164 bool isRichlyEditablePosition(const Position& p, EditableType editableType) 168 165 { 169 Node* node = p. deprecatedNode();166 Node* node = p.containerNode(); 170 167 if (!node) 171 168 return false; 172 173 if (node->renderer() && node->renderer()->isTable()) 174 node = node->parentNode(); 175 169 176 170 return node->hasRichlyEditableStyle(editableType); 177 171 } … … 182 176 if (!node) 183 177 return 0; 184 185 if (node->renderer() && node->renderer()->isTable()) 186 node = node->parentNode(); 187 178 188 179 return node->rootEditableElement(editableType); 189 180 } -
trunk/Source/WebCore/editing/htmlediting.h
r179861 r180726 121 121 bool isNonTableCellHTMLBlockElement(const Node*); 122 122 123 inline bool positionBeforeOrAfterNodeIsCandidate(Node* node) 124 { 125 return isRenderedTable(node) || editingIgnoresContent(node); 126 } 127 123 128 WEBCORE_EXPORT TextDirection directionOfEnclosingBlock(const Position&); 124 129
Note:
See TracChangeset
for help on using the changeset viewer.