Mail hangs when removing multiple rows from large table.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Feb 2017 22:36:12 +0000 (22:36 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Feb 2017 22:36:12 +0000 (22:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168103
<rdar://problem/30090186>

Reviewed by Ryosuke Niwa.

PerformanceTests:

* DOM/large-table-edit.html: Added.

Source/WebCore:

DeleteSelectionCommand::removeNode doesn't actually destroy table structure items,
but instead it removes their content. In order to be able to continue editing the table after
the delete, we need to ensure that its cells' width and height are > 0. Currently we issue layout on
each table item recursively.
This patch delays the layout until after we've finished with the entire subtree delete (10x progression).

Performance test added.

* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::insertBlockPlaceholderForTableCellIfNeeded):
(WebCore::DeleteSelectionCommand::removeNodeUpdatingStates):
(WebCore::shouldRemoveContentOnly):
(WebCore::DeleteSelectionCommand::removeNode):
* editing/DeleteSelectionCommand.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212151 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/ChangeLog
PerformanceTests/DOM/large-table-edit.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/DeleteSelectionCommand.h

index 7ccaf81..2523720 100644 (file)
@@ -1,3 +1,13 @@
+2017-02-10  Zalan Bujtas  <zalan@apple.com>
+
+        Mail hangs when removing multiple rows from large table.
+        https://bugs.webkit.org/show_bug.cgi?id=168103
+        <rdar://problem/30090186>
+
+        Reviewed by Ryosuke Niwa.
+
+        * DOM/large-table-edit.html: Added.
+
 2017-02-05  Filip Pizlo  <fpizlo@apple.com>
 
         Beef up the ARES-6 explainer text
diff --git a/PerformanceTests/DOM/large-table-edit.html b/PerformanceTests/DOM/large-table-edit.html
new file mode 100644 (file)
index 0000000..f54c748
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/runner.js"></script>
+</head>
+<body>
+<table id=table contenteditable="true">
+<tr><td><div id=start>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div id=end>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+<tr><td><div>1</div></td><td><div>2</div></td><td><div>3</div></td><td><div>4</div></td><td><div>5</div></td><td><div>6</div></td><td><div>7</div></td><td><div>8</div></td><td><div>9</div></td><td><div>10</div></td><td><div>11</div></td><td><div>12</div></td><td><div>13</div></td><td><div>14</div></td><td><div>15</div></td><td><div>16</div></td><td><div>17</div></td><td><div>18</div></td><td><div>19</div></td><td><div>20</div></td><td><div>21</div></td><td><div>22</div></td><td><div>23</div></td><td><div>24</div></td><td><div>25</div></td><td><div>26</div></td><td><div>27</div></td><td><div>28</div></td><td><div>29</div></td><td><div>30</div></td><td><div>31</div></td><td><div>32</div></td><td><div>33</div></td><td><div>34</div></td><td><div>35</div></td><td><div>36</div></td><td><div>37</div></td><td><div>38</div></td><td><div>39</div></td><td><div>40</div></td><td><div>41</div></td><td><div>42</div></td><td><div>43</div></td><td><div>44</div></td><td><div>45</div></td><td><div>46</div></td><td><div>47</div></td><td><div>48</div></td><td><div>49</div></td><td><div>50</div></td></tr>
+</table>
+<script>
+var content = table.innerHTML;
+PerfTestRunner.measureRunsPerSecond({run: function() {
+    table.style.display = "table";
+    window.getSelection().removeAllRanges();
+
+    var range = document.createRange();
+    range.setStart(start, 0);
+    range.setEnd(end, 1);
+    window.getSelection().addRange(range);
+
+    document.execCommand("delete")
+
+    table.style.display = "none";
+    table.innerHTML = content;
+}});
+</script>
+</body>
+</html>
index e01a695..5255e79 100644 (file)
@@ -1,3 +1,26 @@
+2017-02-10  Zalan Bujtas  <zalan@apple.com>
+
+        Mail hangs when removing multiple rows from large table.
+        https://bugs.webkit.org/show_bug.cgi?id=168103
+        <rdar://problem/30090186>
+
+        Reviewed by Ryosuke Niwa.
+
+        DeleteSelectionCommand::removeNode doesn't actually destroy table structure items,
+        but instead it removes their content. In order to be able to continue editing the table after
+        the delete, we need to ensure that its cells' width and height are > 0. Currently we issue layout on
+        each table item recursively.
+        This patch delays the layout until after we've finished with the entire subtree delete (10x progression).
+
+        Performance test added.
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::insertBlockPlaceholderForTableCellIfNeeded):
+        (WebCore::DeleteSelectionCommand::removeNodeUpdatingStates):
+        (WebCore::shouldRemoveContentOnly):
+        (WebCore::DeleteSelectionCommand::removeNode):
+        * editing/DeleteSelectionCommand.h:
+
 2017-02-10  Joseph Pecoraro  <pecoraro@apple.com>
 
         [Resource Timing] Enable Resource Timing by default in Tests
index 8242c26..0917b8b 100644 (file)
@@ -30,6 +30,7 @@
 #include "DocumentMarkerController.h"
 #include "Editor.h"
 #include "EditorClient.h"
+#include "ElementIterator.h"
 #include "Frame.h"
 #include "HTMLBRElement.h"
 #include "HTMLLinkElement.h"
@@ -344,6 +345,37 @@ static Position firstEditablePositionInNode(Node* node)
     return next ? firstPositionInOrBeforeNode(next) : Position();
 }
 
+void DeleteSelectionCommand::insertBlockPlaceholderForTableCellIfNeeded(Element& element)
+{
+    // Make sure empty cell has some height.
+    auto* renderer = element.renderer();
+    if (!is<RenderTableCell>(renderer))
+        return;
+    if (downcast<RenderTableCell>(*renderer).contentHeight() > 0)
+        return;
+    insertBlockPlaceholder(firstEditablePositionInNode(&element));
+}
+    
+void DeleteSelectionCommand::removeNodeUpdatingStates(Node& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
+{
+    if (&node == m_startBlock && !isEndOfBlock(VisiblePosition(firstPositionInNode(m_startBlock.get())).previous()))
+        m_needPlaceholder = true;
+    else if (&node == m_endBlock && !isStartOfBlock(VisiblePosition(lastPositionInNode(m_startBlock.get())).next()))
+        m_needPlaceholder = true;
+    
+    // FIXME: Update the endpoints of the range being deleted.
+    updatePositionForNodeRemoval(m_endingPosition, node);
+    updatePositionForNodeRemoval(m_leadingWhitespace, node);
+    updatePositionForNodeRemoval(m_trailingWhitespace, node);
+    
+    CompositeEditCommand::removeNode(&node, shouldAssumeContentIsAlwaysEditable);
+}
+    
+static inline bool shouldRemoveContentOnly(const Node& node)
+{
+    return isTableStructureNode(&node) || node.isRootEditableElement();
+}
+
 void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
 {
     if (!node)
@@ -371,38 +403,34 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeConte
         }
     }
     
-    if (isTableStructureNode(node.get()) || node->isRootEditableElement()) {
+    if (shouldRemoveContentOnly(*node)) {
         // Do not remove an element of table structure; remove its contents.
         // Likewise for the root editable element.
-        Node* child = node->firstChild();
+        auto* child = NodeTraversal::next(*node, node.get());
         while (child) {
-            Node* remove = child;
-            child = child->nextSibling();
-            removeNode(remove, shouldAssumeContentIsAlwaysEditable);
+            if (shouldRemoveContentOnly(*child)) {
+                child = NodeTraversal::next(*child, node.get());
+                continue;
+            }
+            auto* remove = child;
+            child = NodeTraversal::nextSkippingChildren(*child, node.get());
+            removeNodeUpdatingStates(*remove, shouldAssumeContentIsAlwaysEditable);
         }
         
-        // Make sure empty cell has some height, if a placeholder can be inserted.
+        ASSERT(is<Element>(*node));
+        auto& element = downcast<Element>(*node);
         document().updateLayoutIgnorePendingStylesheets();
-        RenderObject* renderer = node->renderer();
-        if (is<RenderTableCell>(renderer) && downcast<RenderTableCell>(*renderer).contentHeight() <= 0) {
-            Position firstEditablePosition = firstEditablePositionInNode(node.get());
-            if (firstEditablePosition.isNotNull())
-                insertBlockPlaceholder(firstEditablePosition);
+        // Check if we need to insert a placeholder for descendant table cells.
+        auto* descendant = ElementTraversal::next(element, &element);
+        while (descendant) {
+            auto* placeholderCandidate = descendant;
+            descendant = ElementTraversal::next(*descendant, &element);
+            insertBlockPlaceholderForTableCellIfNeeded(*placeholderCandidate);
         }
+        insertBlockPlaceholderForTableCellIfNeeded(element);
         return;
     }
-    
-    if (node == m_startBlock && !isEndOfBlock(VisiblePosition(firstPositionInNode(m_startBlock.get())).previous()))
-        m_needPlaceholder = true;
-    else if (node == m_endBlock && !isStartOfBlock(VisiblePosition(lastPositionInNode(m_startBlock.get())).next()))
-        m_needPlaceholder = true;
-    
-    // FIXME: Update the endpoints of the range being deleted.
-    updatePositionForNodeRemoval(m_endingPosition, *node);
-    updatePositionForNodeRemoval(m_leadingWhitespace, *node);
-    updatePositionForNodeRemoval(m_trailingWhitespace, *node);
-    
-    CompositeEditCommand::removeNode(node, shouldAssumeContentIsAlwaysEditable);
+    removeNodeUpdatingStates(*node, shouldAssumeContentIsAlwaysEditable);
 }
 
 static void updatePositionForTextRemoval(Node* node, int offset, int count, Position& position)
index 484672f..c17f6de 100644 (file)
@@ -73,6 +73,9 @@ private:
     // This function provides access to original string after the correction has been deleted.
     String originalStringForAutocorrectionAtBeginningOfSelection();
 
+    void removeNodeUpdatingStates(Node&, ShouldAssumeContentIsAlwaysEditable);
+    void insertBlockPlaceholderForTableCellIfNeeded(Element&);
+
     bool m_hasSelectionToDelete;
     bool m_smartDelete;
     bool m_mergeBlocksAfterDelete;