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

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

Issue 2292913002: Ensure clean layout before calling plainText() (flat tree version) (Closed)
Patch Set: 201608301918 Created 4 years, 3 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) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 1064
1065 String FrameSelection::selectedHTMLForClipboard() const 1065 String FrameSelection::selectedHTMLForClipboard() const
1066 { 1066 {
1067 const VisibleSelectionInFlatTree& visibleSelection = this->visibleSelection< EditingInFlatTreeStrategy>(); 1067 const VisibleSelectionInFlatTree& visibleSelection = this->visibleSelection< EditingInFlatTreeStrategy>();
1068 const EphemeralRangeInFlatTree& range = visibleSelection.toNormalizedEphemer alRange(); 1068 const EphemeralRangeInFlatTree& range = visibleSelection.toNormalizedEphemer alRange();
1069 return createMarkup(range.startPosition(), range.endPosition(), AnnotateForI nterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 1069 return createMarkup(range.startPosition(), range.endPosition(), AnnotateForI nterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
1070 } 1070 }
1071 1071
1072 String FrameSelection::selectedText(TextIteratorBehavior behavior) const 1072 String FrameSelection::selectedText(TextIteratorBehavior behavior) const
1073 { 1073 {
1074 if (!isAvailable())
1075 return emptyString();
1076
1077 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1078 // needs to be audited. See http://crbug.com/590369 for more details.
1079 m_document->updateStyleAndLayoutIgnorePendingStylesheets();
1080
1074 return extractSelectedText(*this, behavior); 1081 return extractSelectedText(*this, behavior);
1075 } 1082 }
1076 1083
1077 String FrameSelection::selectedTextForClipboard() const 1084 String FrameSelection::selectedTextForClipboard() const
yosin_UTC9 2016/08/31 04:58:21 There are only three call sites of selectedTextFor
Xiaocheng 2016/09/02 05:37:24 I guess the layout is already clean when called fr
1078 { 1085 {
1086 if (!isAvailable())
1087 return emptyString();
1088
1089 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1090 // needs to be audited. See http://crbug.com/590369 for more details.
1091 m_document->updateStyleAndLayoutIgnorePendingStylesheets();
1092
1079 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex t()) 1093 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex t())
1080 return extractSelectedText(*this, TextIteratorEmitsImageAltText); 1094 return extractSelectedText(*this, TextIteratorEmitsImageAltText);
1081 return selectedText(); 1095 return selectedText();
yosin_UTC9 2016/08/31 04:58:21 It seems we can replace |selectedText()| call to |
Xiaocheng 2016/09/02 05:37:24 Makes sense. Done.
1082 } 1096 }
1083 1097
1084 LayoutRect FrameSelection::bounds() const 1098 LayoutRect FrameSelection::bounds() const
1085 { 1099 {
1086 FrameView* view = m_frame->view(); 1100 FrameView* view = m_frame->view();
1087 if (!view) 1101 if (!view)
1088 return LayoutRect(); 1102 return LayoutRect();
1089 1103
1090 return intersection(unclippedBounds(), LayoutRect(view->visibleContentRect() )); 1104 return intersection(unclippedBounds(), LayoutRect(view->visibleContentRect() ));
1091 } 1105 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 1386
1373 void showTree(const blink::FrameSelection* sel) 1387 void showTree(const blink::FrameSelection* sel)
1374 { 1388 {
1375 if (sel) 1389 if (sel)
1376 sel->showTreeForThis(); 1390 sel->showTreeForThis();
1377 else 1391 else
1378 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1392 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1379 } 1393 }
1380 1394
1381 #endif 1395 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698