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

Side by Side Diff: Source/core/html/HTMLTextFormControlElement.cpp

Issue 330383004: Oilpan: Introduce TempRangeScope to avoid needless Range attaches on Document. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 newSelection.setIsDirectional(direction != SelectionHasNoDirection); 310 newSelection.setIsDirectional(direction != SelectionHasNoDirection);
311 311
312 if (LocalFrame* frame = document().frame()) 312 if (LocalFrame* frame = document().frame())
313 frame->selection().setSelection(newSelection); 313 frame->selection().setSelection(newSelection);
314 } 314 }
315 315
316 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c onst 316 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c onst
317 { 317 {
318 if (index <= 0) 318 if (index <= 0)
319 return VisiblePosition(firstPositionInNode(innerEditorElement()), DOWNST REAM); 319 return VisiblePosition(firstPositionInNode(innerEditorElement()), DOWNST REAM);
320 TemporaryRangeScope scope;
320 RefPtrWillBeRawPtr<Range> range = Range::create(document()); 321 RefPtrWillBeRawPtr<Range> range = Range::create(document());
321 range->selectNodeContents(innerEditorElement(), ASSERT_NO_EXCEPTION); 322 range->selectNodeContents(innerEditorElement(), ASSERT_NO_EXCEPTION);
322 CharacterIterator it(range.get()); 323 CharacterIterator it(range.get());
323 it.advance(index - 1); 324 it.advance(index - 1);
324 return VisiblePosition(it.range()->endPosition(), UPSTREAM); 325 return VisiblePosition(it.range()->endPosition(), UPSTREAM);
325 } 326 }
326 327
327 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p os) const 328 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p os) const
328 { 329 {
329 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); 330 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent();
330 if (enclosingTextFormControl(indexPosition) != this) 331 if (enclosingTextFormControl(indexPosition) != this)
331 return 0; 332 return 0;
333 TemporaryRangeScope scope;
332 ASSERT(indexPosition.document()); 334 ASSERT(indexPosition.document());
333 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document()); 335 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document());
334 range->setStart(innerEditorElement(), 0, ASSERT_NO_EXCEPTION); 336 range->setStart(innerEditorElement(), 0, ASSERT_NO_EXCEPTION);
335 range->setEnd(indexPosition.containerNode(), indexPosition.offsetInContainer Node(), ASSERT_NO_EXCEPTION); 337 range->setEnd(indexPosition.containerNode(), indexPosition.offsetInContainer Node(), ASSERT_NO_EXCEPTION);
336 return TextIterator::rangeLength(range.get()); 338 return TextIterator::rangeLength(range.get());
337 } 339 }
338 340
339 int HTMLTextFormControlElement::selectionStart() const 341 int HTMLTextFormControlElement::selectionStart() const
340 { 342 {
341 if (!isTextFormControl()) 343 if (!isTextFormControl())
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 655
654 return "ltr"; 656 return "ltr";
655 } 657 }
656 658
657 HTMLElement* HTMLTextFormControlElement::innerEditorElement() const 659 HTMLElement* HTMLTextFormControlElement::innerEditorElement() const
658 { 660 {
659 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor())); 661 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor()));
660 } 662 }
661 663
662 } // namespace Webcore 664 } // namespace Webcore
OLDNEW
« Source/core/editing/SpellChecker.cpp ('K') | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698