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

Side by Side Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 2710883002: Expand FrameSeleciton::isNone() to increase chances of hoisting update layout (Closed)
Patch Set: 2017-02-23T16:27:43 rebase to resolve conflict with DOMSelection in r452402 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) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Google Inc. 3 * Copyright (C) 2008 Google Inc.
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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 458 }
459 459
460 // Returns true if node at |point| is editable with populating |dragCaret| and 460 // Returns true if node at |point| is editable with populating |dragCaret| and
461 // |range|, otherwise returns false. 461 // |range|, otherwise returns false.
462 // TODO(yosin): We should return |VisibleSelection| rather than three values. 462 // TODO(yosin): We should return |VisibleSelection| rather than three values.
463 static bool setSelectionToDragCaret(LocalFrame* frame, 463 static bool setSelectionToDragCaret(LocalFrame* frame,
464 VisibleSelection& dragCaret, 464 VisibleSelection& dragCaret,
465 Range*& range, 465 Range*& range,
466 const IntPoint& point) { 466 const IntPoint& point) {
467 frame->selection().setSelection(dragCaret); 467 frame->selection().setSelection(dragCaret);
468 if (frame->selection().isNone()) { 468 if (frame->selection()
469 .computeVisibleSelectionInDOMTreeDeprecated()
470 .isNone()) {
469 // TODO(editing-dev): The use of 471 // TODO(editing-dev): The use of
470 // updateStyleAndLayoutIgnorePendingStylesheets 472 // updateStyleAndLayoutIgnorePendingStylesheets
471 // needs to be audited. See http://crbug.com/590369 for more details. 473 // needs to be audited. See http://crbug.com/590369 for more details.
472 // |LocalFrame::positinForPoint()| requires clean layout. 474 // |LocalFrame::positinForPoint()| requires clean layout.
473 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 475 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
474 const PositionWithAffinity& position = frame->positionForPoint(point); 476 const PositionWithAffinity& position = frame->positionForPoint(point);
475 if (!position.isConnected()) 477 if (!position.isConnected())
476 return false; 478 return false;
477 479
478 frame->selection().setSelection( 480 frame->selection().setSelection(
479 SelectionInDOMTree::Builder().collapse(position).build()); 481 SelectionInDOMTree::Builder().collapse(position).build());
480 dragCaret = frame->selection().computeVisibleSelectionInDOMTreeDeprecated(); 482 dragCaret = frame->selection().computeVisibleSelectionInDOMTreeDeprecated();
481 range = createRange(dragCaret.toNormalizedEphemeralRange()); 483 range = createRange(dragCaret.toNormalizedEphemeralRange());
482 } 484 }
483 return !frame->selection().isNone() && 485 return !frame->selection()
486 .computeVisibleSelectionInDOMTreeDeprecated()
487 .isNone() &&
484 frame->selection() 488 frame->selection()
485 .computeVisibleSelectionInDOMTreeDeprecated() 489 .computeVisibleSelectionInDOMTreeDeprecated()
486 .isContentEditable(); 490 .isContentEditable();
487 } 491 }
488 492
489 DispatchEventResult DragController::dispatchTextInputEventFor( 493 DispatchEventResult DragController::dispatchTextInputEventFor(
490 LocalFrame* innerFrame, 494 LocalFrame* innerFrame,
491 DragData* dragData) { 495 DragData* dragData) {
492 // Layout should be clean due to a hit test performed in |elementUnderMouse|. 496 // Layout should be clean due to a hit test performed in |elementUnderMouse|.
493 DCHECK(!innerFrame->document()->needsLayoutTreeUpdate()); 497 DCHECK(!innerFrame->document()->needsLayoutTreeUpdate());
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 1257
1254 DEFINE_TRACE(DragController) { 1258 DEFINE_TRACE(DragController) {
1255 visitor->trace(m_page); 1259 visitor->trace(m_page);
1256 visitor->trace(m_documentUnderMouse); 1260 visitor->trace(m_documentUnderMouse);
1257 visitor->trace(m_dragInitiator); 1261 visitor->trace(m_dragInitiator);
1258 visitor->trace(m_dragState); 1262 visitor->trace(m_dragState);
1259 visitor->trace(m_fileInputElementUnderMouse); 1263 visitor->trace(m_fileInputElementUnderMouse);
1260 } 1264 }
1261 1265
1262 } // namespace blink 1266 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandlerTest.cpp ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698