 Chromium Code Reviews
 Chromium Code Reviews Issue 330383004:
  Oilpan: Introduce TempRangeScope to avoid needless Range attaches on Document.  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 330383004:
  Oilpan: Introduce TempRangeScope to avoid needless Range attaches on Document.  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 
| 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 
| 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 
| 5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) | 
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 
| 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 
| 8 * | 8 * | 
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or | 
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 #include "wtf/text/CString.h" | 50 #include "wtf/text/CString.h" | 
| 51 #include "wtf/text/StringBuilder.h" | 51 #include "wtf/text/StringBuilder.h" | 
| 52 #ifndef NDEBUG | 52 #ifndef NDEBUG | 
| 53 #include <stdio.h> | 53 #include <stdio.h> | 
| 54 #endif | 54 #endif | 
| 55 | 55 | 
| 56 namespace WebCore { | 56 namespace WebCore { | 
| 57 | 57 | 
| 58 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, rangeCounter, ("Range")); | 58 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, rangeCounter, ("Range")); | 
| 59 | 59 | 
| 60 #if ENABLE(OILPAN) | |
| 61 unsigned TemporaryRangeScope::s_nesting = 0; | |
| 62 #endif | |
| 63 | |
| 60 inline Range::Range(Document& ownerDocument) | 64 inline Range::Range(Document& ownerDocument) | 
| 61 : m_ownerDocument(&ownerDocument) | 65 : m_ownerDocument(&ownerDocument) | 
| 62 , m_start(m_ownerDocument) | 66 , m_start(m_ownerDocument) | 
| 63 , m_end(m_ownerDocument) | 67 , m_end(m_ownerDocument) | 
| 64 { | 68 { | 
| 65 #ifndef NDEBUG | 69 #ifndef NDEBUG | 
| 66 rangeCounter.increment(); | 70 rangeCounter.increment(); | 
| 67 #endif | 71 #endif | 
| 68 | |
| 69 ScriptWrappable::init(this); | 72 ScriptWrappable::init(this); | 
| 70 m_ownerDocument->attachRange(this); | 73 if (!TemporaryRangeScope::active()) | 
| 
haraken
2014/06/24 12:24:22
You can move this check into Document::attachRange
 | |
| 74 m_ownerDocument->attachRange(this); | |
| 71 } | 75 } | 
| 72 | 76 | 
| 73 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument) | 77 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument) | 
| 74 { | 78 { | 
| 75 return adoptRefWillBeNoop(new Range(ownerDocument)); | 79 return adoptRefWillBeNoop(new Range(ownerDocument)); | 
| 76 } | 80 } | 
| 77 | 81 | 
| 78 inline Range::Range(Document& ownerDocument, Node* startContainer, int startOffs et, Node* endContainer, int endOffset) | 82 inline Range::Range(Document& ownerDocument, Node* startContainer, int startOffs et, Node* endContainer, int endOffset) | 
| 79 : m_ownerDocument(&ownerDocument) | 83 : m_ownerDocument(&ownerDocument) | 
| 80 , m_start(m_ownerDocument) | 84 , m_start(m_ownerDocument) | 
| 81 , m_end(m_ownerDocument) | 85 , m_end(m_ownerDocument) | 
| 82 { | 86 { | 
| 83 #ifndef NDEBUG | 87 #ifndef NDEBUG | 
| 84 rangeCounter.increment(); | 88 rangeCounter.increment(); | 
| 85 #endif | 89 #endif | 
| 86 | |
| 87 ScriptWrappable::init(this); | 90 ScriptWrappable::init(this); | 
| 88 m_ownerDocument->attachRange(this); | 91 if (!TemporaryRangeScope::active()) | 
| 
haraken
2014/06/24 12:24:22
Ditto.
 | |
| 92 m_ownerDocument->attachRange(this); | |
| 89 | 93 | 
| 90 // Simply setting the containers and offsets directly would not do any of th e checking | 94 // Simply setting the containers and offsets directly would not do any of th e checking | 
| 91 // that setStart and setEnd do, so we call those functions. | 95 // that setStart and setEnd do, so we call those functions. | 
| 92 setStart(startContainer, startOffset); | 96 setStart(startContainer, startOffset); | 
| 93 setEnd(endContainer, endOffset); | 97 setEnd(endContainer, endOffset); | 
| 94 } | 98 } | 
| 95 | 99 | 
| 96 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, Node* start Container, int startOffset, Node* endContainer, int endOffset) | 100 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, Node* start Container, int startOffset, Node* endContainer, int endOffset) | 
| 97 { | 101 { | 
| 98 return adoptRefWillBeNoop(new Range(ownerDocument, startContainer, startOffs et, endContainer, endOffset)); | 102 return adoptRefWillBeNoop(new Range(ownerDocument, startContainer, startOffs et, endContainer, endOffset)); | 
| (...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1713 | 1717 | 
| 1714 void showTree(const WebCore::Range* range) | 1718 void showTree(const WebCore::Range* range) | 
| 1715 { | 1719 { | 
| 1716 if (range && range->boundaryPointsValid()) { | 1720 if (range && range->boundaryPointsValid()) { | 
| 1717 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); | 1721 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); | 
| 1718 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); | 1722 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); | 
| 1719 } | 1723 } | 
| 1720 } | 1724 } | 
| 1721 | 1725 | 
| 1722 #endif | 1726 #endif | 
| OLD | NEW |