Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 static bool isTableCellEmpty(Node* cell) { | 49 static bool isTableCellEmpty(Node* cell) { |
| 50 DCHECK(isTableCell(cell)) << cell; | 50 DCHECK(isTableCell(cell)) << cell; |
| 51 return VisiblePosition::firstPositionInNode(cell).deepEquivalent() == | 51 return VisiblePosition::firstPositionInNode(cell).deepEquivalent() == |
| 52 VisiblePosition::lastPositionInNode(cell).deepEquivalent(); | 52 VisiblePosition::lastPositionInNode(cell).deepEquivalent(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static bool isTableRowEmpty(Node* row) { | 55 static bool isTableRowEmpty(Node* row) { |
| 56 if (!isHTMLTableRowElement(row)) | 56 if (!isHTMLTableRowElement(row)) |
| 57 return false; | 57 return false; |
| 58 | 58 |
| 59 row->document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 59 for (Node* child = row->firstChild(); child; child = child->nextSibling()) { | 60 for (Node* child = row->firstChild(); child; child = child->nextSibling()) { |
| 60 if (isTableCell(child) && !isTableCellEmpty(child)) | 61 if (isTableCell(child) && !isTableCellEmpty(child)) |
| 61 return false; | 62 return false; |
| 62 } | 63 } |
| 63 return true; | 64 return true; |
| 64 } | 65 } |
| 65 | 66 |
| 66 DeleteSelectionCommand::DeleteSelectionCommand( | 67 DeleteSelectionCommand::DeleteSelectionCommand( |
| 67 Document& document, | 68 Document& document, |
| 68 bool smartDelete, | 69 bool smartDelete, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && | 408 bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && |
| 408 nodeAfterDownstreamStart == nodeAfterUpstreamEnd; | 409 nodeAfterDownstreamStart == nodeAfterUpstreamEnd; |
| 409 if (isBROnLineByItself) { | 410 if (isBROnLineByItself) { |
| 410 removeNode(nodeAfterDownstreamStart, editingState); | 411 removeNode(nodeAfterDownstreamStart, editingState); |
| 411 return true; | 412 return true; |
| 412 } | 413 } |
| 413 | 414 |
| 414 // FIXME: This code doesn't belong in here. | 415 // FIXME: This code doesn't belong in here. |
| 415 // We detect the case where the start is an empty line consisting of BR not | 416 // We detect the case where the start is an empty line consisting of BR not |
| 416 // wrapped in a block element. | 417 // wrapped in a block element. |
| 417 if (upstreamStartIsBR && downstreamStartIsBR && | 418 if (upstreamStartIsBR && downstreamStartIsBR) { |
| 418 !(isStartOfBlock(VisiblePosition::beforeNode(nodeAfterUpstreamStart)) && | 419 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
|
yosin_UTC9
2016/10/13 06:26:46
Wow, we has been updating layout in if-condition!
| |
| 419 isEndOfBlock(VisiblePosition::afterNode(nodeAfterUpstreamStart)))) { | 420 if (!(isStartOfBlock(VisiblePosition::beforeNode(nodeAfterUpstreamStart)) && |
| 420 m_startsAtEmptyLine = true; | 421 isEndOfBlock(VisiblePosition::afterNode(nodeAfterUpstreamStart)))) { |
| 421 m_endingPosition = m_downstreamEnd; | 422 m_startsAtEmptyLine = true; |
| 423 m_endingPosition = m_downstreamEnd; | |
| 424 } | |
| 422 } | 425 } |
| 423 | 426 |
| 424 return false; | 427 return false; |
| 425 } | 428 } |
| 426 | 429 |
| 427 static Position firstEditablePositionInNode(Node* node) { | 430 static Position firstEditablePositionInNode(Node* node) { |
| 428 DCHECK(node); | 431 DCHECK(node); |
| 429 Node* next = node; | 432 Node* next = node; |
| 430 while (next && !hasEditableStyle(*next)) | 433 while (next && !hasEditableStyle(*next)) |
| 431 next = NodeTraversal::next(*next, node); | 434 next = NodeTraversal::next(*next, node); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 486 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 484 LayoutObject* r = node->layoutObject(); | 487 LayoutObject* r = node->layoutObject(); |
| 485 if (r && r->isTableCell() && toLayoutTableCell(r)->contentHeight() <= 0) { | 488 if (r && r->isTableCell() && toLayoutTableCell(r)->contentHeight() <= 0) { |
| 486 Position firstEditablePosition = firstEditablePositionInNode(node); | 489 Position firstEditablePosition = firstEditablePositionInNode(node); |
| 487 if (firstEditablePosition.isNotNull()) | 490 if (firstEditablePosition.isNotNull()) |
| 488 insertBlockPlaceholder(firstEditablePosition, editingState); | 491 insertBlockPlaceholder(firstEditablePosition, editingState); |
| 489 } | 492 } |
| 490 return; | 493 return; |
| 491 } | 494 } |
| 492 | 495 |
| 496 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 493 if (node == m_startBlock) { | 497 if (node == m_startBlock) { |
| 494 VisiblePosition previous = previousPositionOf( | 498 VisiblePosition previous = previousPositionOf( |
| 495 VisiblePosition::firstPositionInNode(m_startBlock.get())); | 499 VisiblePosition::firstPositionInNode(m_startBlock.get())); |
| 496 if (previous.isNotNull() && !isEndOfBlock(previous)) | 500 if (previous.isNotNull() && !isEndOfBlock(previous)) |
| 497 m_needPlaceholder = true; | 501 m_needPlaceholder = true; |
| 498 } | 502 } |
| 499 if (node == m_endBlock) { | 503 if (node == m_endBlock) { |
| 500 VisiblePosition next = | 504 VisiblePosition next = |
| 501 nextPositionOf(VisiblePosition::lastPositionInNode(m_endBlock.get())); | 505 nextPositionOf(VisiblePosition::lastPositionInNode(m_endBlock.get())); |
| 502 if (next.isNotNull() && !isStartOfBlock(next)) | 506 if (next.isNotNull() && !isStartOfBlock(next)) |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 visitor->trace(m_deleteIntoBlockquoteStyle); | 1208 visitor->trace(m_deleteIntoBlockquoteStyle); |
| 1205 visitor->trace(m_startRoot); | 1209 visitor->trace(m_startRoot); |
| 1206 visitor->trace(m_endRoot); | 1210 visitor->trace(m_endRoot); |
| 1207 visitor->trace(m_startTableRow); | 1211 visitor->trace(m_startTableRow); |
| 1208 visitor->trace(m_endTableRow); | 1212 visitor->trace(m_endTableRow); |
| 1209 visitor->trace(m_temporaryPlaceholder); | 1213 visitor->trace(m_temporaryPlaceholder); |
| 1210 CompositeEditCommand::trace(visitor); | 1214 CompositeEditCommand::trace(visitor); |
| 1211 } | 1215 } |
| 1212 | 1216 |
| 1213 } // namespace blink | 1217 } // namespace blink |
| OLD | NEW |