Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2698793003: Get rid of redundant layout tree update related to selection (Closed)
Patch Set: 2017-02-17T16:13:56 selectionTypeWithLegacyGranularity() Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 void SpellChecker::markMisspellingsAfterTypingToWord( 487 void SpellChecker::markMisspellingsAfterTypingToWord(
488 const VisiblePosition& wordStart) { 488 const VisiblePosition& wordStart) {
489 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterTypingToWord"); 489 TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterTypingToWord");
490 490
491 VisibleSelection adjacentWords = 491 VisibleSelection adjacentWords =
492 createVisibleSelection(selectWord(wordStart)); 492 createVisibleSelection(selectWord(wordStart));
493 markMisspellingsInternal(adjacentWords); 493 markMisspellingsInternal(adjacentWords);
494 } 494 }
495 495
496 bool SpellChecker::isSpellCheckingEnabledInFocusedNode() const { 496 bool SpellChecker::isSpellCheckingEnabledInFocusedNode() const {
497 Node* focusedNode = frame().selection().start().anchorNode(); 497 // To avoid regression on speedometer benchmark[1] test, we should not
498 // update layout tree in this code block.
499 // [1] http://browserbench.org/Speedometer/
500 DocumentLifecycle::DisallowTransitionScope disallowTransition(
501 frame().document()->lifecycle());
502
503 Node* focusedNode = frame()
504 .selection()
505 .selectionInDOMTree()
506 .computeStartPosition()
507 .anchorNode();
498 if (!focusedNode) 508 if (!focusedNode)
499 return false; 509 return false;
500 const Element* focusedElement = focusedNode->isElementNode() 510 const Element* focusedElement = focusedNode->isElementNode()
501 ? toElement(focusedNode) 511 ? toElement(focusedNode)
502 : focusedNode->parentElement(); 512 : focusedNode->parentElement();
503 if (!focusedElement) 513 if (!focusedElement)
504 return false; 514 return false;
505 return focusedElement->isSpellCheckingEnabled(); 515 return focusedElement->isSpellCheckingEnabled();
506 } 516 }
507 517
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 startOfNextParagraph(createVisiblePosition(paragraphEnd)); 1187 startOfNextParagraph(createVisiblePosition(paragraphEnd));
1178 paragraphStart = newParagraphStart.toParentAnchoredPosition(); 1188 paragraphStart = newParagraphStart.toParentAnchoredPosition();
1179 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); 1189 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition();
1180 firstIteration = false; 1190 firstIteration = false;
1181 totalLengthProcessed += currentLength; 1191 totalLengthProcessed += currentLength;
1182 } 1192 }
1183 return std::make_pair(firstFoundItem, firstFoundOffset); 1193 return std::make_pair(firstFoundItem, firstFoundOffset);
1184 } 1194 }
1185 1195
1186 } // namespace blink 1196 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698