Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 * | 7 * |
| 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 19 matching lines...) Expand all Loading... | |
| 30 #include "core/dom/Node.h" | 30 #include "core/dom/Node.h" |
| 31 #include "core/editing/VisiblePosition.h" | 31 #include "core/editing/VisiblePosition.h" |
| 32 #include "core/rendering/HitTestResult.h" | 32 #include "core/rendering/HitTestResult.h" |
| 33 #include "core/rendering/RenderObject.h" | 33 #include "core/rendering/RenderObject.h" |
| 34 #include "platform/weborigin/KURL.h" | 34 #include "platform/weborigin/KURL.h" |
| 35 #include "public/platform/WebPoint.h" | 35 #include "public/platform/WebPoint.h" |
| 36 #include "public/platform/WebURL.h" | 36 #include "public/platform/WebURL.h" |
| 37 #include "public/web/WebElement.h" | 37 #include "public/web/WebElement.h" |
| 38 #include "public/web/WebNode.h" | 38 #include "public/web/WebNode.h" |
| 39 | 39 |
| 40 using namespace blink; | 40 using namespace blink; |
|
sof
2014/07/24 07:18:14
nit: can be removed.
| |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class WebHitTestResultPrivate : public RefCountedWillBeGarbageCollectedFinalized <WebHitTestResultPrivate> { | |
| 45 public: | |
| 46 static PassRefPtrWillBeRawPtr<WebHitTestResultPrivate> create(const HitTestR esult&); | |
| 47 static PassRefPtrWillBeRawPtr<WebHitTestResultPrivate> create(const WebHitTe stResultPrivate&); | |
| 48 void trace(Visitor* visitor) { visitor->trace(m_result); } | |
| 49 const HitTestResult& result() const { return m_result; } | |
| 50 | |
| 51 private: | |
| 52 WebHitTestResultPrivate(const HitTestResult&); | |
| 53 WebHitTestResultPrivate(const WebHitTestResultPrivate&); | |
| 54 | |
| 55 HitTestResult m_result; | |
| 56 }; | |
| 57 | |
| 58 inline WebHitTestResultPrivate::WebHitTestResultPrivate(const HitTestResult& res ult) | |
| 59 : m_result(result) | |
| 60 { | |
| 61 } | |
| 62 | |
| 63 inline WebHitTestResultPrivate::WebHitTestResultPrivate(const WebHitTestResultPr ivate& result) | |
| 64 : m_result(result.m_result) | |
| 65 { | |
| 66 } | |
| 67 | |
| 68 PassRefPtrWillBeRawPtr<WebHitTestResultPrivate> WebHitTestResultPrivate::create( const HitTestResult& result) | |
| 69 { | |
| 70 return adoptRefWillBeNoop(new WebHitTestResultPrivate(result)); | |
| 71 } | |
| 72 | |
| 73 PassRefPtrWillBeRawPtr<WebHitTestResultPrivate> WebHitTestResultPrivate::create( const WebHitTestResultPrivate& result) | |
| 74 { | |
| 75 return adoptRefWillBeNoop(new WebHitTestResultPrivate(result)); | |
| 76 } | |
| 77 | |
| 44 WebNode WebHitTestResult::node() const | 78 WebNode WebHitTestResult::node() const |
| 45 { | 79 { |
| 46 return WebNode(m_private->innerNode()); | 80 return WebNode(m_private->result().innerNode()); |
| 47 } | 81 } |
| 48 | 82 |
| 49 WebPoint WebHitTestResult::localPoint() const | 83 WebPoint WebHitTestResult::localPoint() const |
| 50 { | 84 { |
| 51 return roundedIntPoint(m_private->localPoint()); | 85 return roundedIntPoint(m_private->result().localPoint()); |
| 52 } | 86 } |
| 53 | 87 |
| 54 WebElement WebHitTestResult::urlElement() const | 88 WebElement WebHitTestResult::urlElement() const |
| 55 { | 89 { |
| 56 return WebElement(m_private->URLElement()); | 90 return WebElement(m_private->result().URLElement()); |
| 57 } | 91 } |
| 58 | 92 |
| 59 WebURL WebHitTestResult::absoluteImageURL() const | 93 WebURL WebHitTestResult::absoluteImageURL() const |
| 60 { | 94 { |
| 61 return m_private->absoluteImageURL(); | 95 return m_private->result().absoluteImageURL(); |
| 62 } | 96 } |
| 63 | 97 |
| 64 WebURL WebHitTestResult::absoluteLinkURL() const | 98 WebURL WebHitTestResult::absoluteLinkURL() const |
| 65 { | 99 { |
| 66 return m_private->absoluteLinkURL(); | 100 return m_private->result().absoluteLinkURL(); |
| 67 } | 101 } |
| 68 | 102 |
| 69 bool WebHitTestResult::isContentEditable() const | 103 bool WebHitTestResult::isContentEditable() const |
| 70 { | 104 { |
| 71 return m_private->isContentEditable(); | 105 return m_private->result().isContentEditable(); |
| 72 } | 106 } |
| 73 | 107 |
| 74 WebHitTestResult::WebHitTestResult(const HitTestResult& result) | 108 WebHitTestResult::WebHitTestResult(const HitTestResult& result) |
| 109 : m_private(WebHitTestResultPrivate::create(result)) | |
| 75 { | 110 { |
| 76 m_private.reset(new HitTestResult(result)); | |
| 77 } | 111 } |
| 78 | 112 |
| 79 WebHitTestResult& WebHitTestResult::operator=(const HitTestResult& result) | 113 WebHitTestResult& WebHitTestResult::operator=(const HitTestResult& result) |
| 80 { | 114 { |
| 81 m_private.reset(new HitTestResult(result)); | 115 m_private = WebHitTestResultPrivate::create(result); |
| 82 return *this; | 116 return *this; |
| 83 } | 117 } |
| 84 | 118 |
| 85 WebHitTestResult::operator HitTestResult() const | |
| 86 { | |
| 87 return *m_private.get(); | |
| 88 } | |
| 89 | |
| 90 bool WebHitTestResult::isNull() const | 119 bool WebHitTestResult::isNull() const |
| 91 { | 120 { |
| 92 return !m_private.get(); | 121 return !m_private.get(); |
| 93 } | 122 } |
| 94 | 123 |
| 95 void WebHitTestResult::assign(const WebHitTestResult& info) | 124 void WebHitTestResult::assign(const WebHitTestResult& info) |
| 96 { | 125 { |
| 97 m_private.reset(new HitTestResult(info)); | 126 if (info.isNull()) |
| 127 m_private.reset(); | |
| 128 else | |
| 129 m_private = WebHitTestResultPrivate::create(*info.m_private.get()); | |
| 98 } | 130 } |
| 99 | 131 |
| 100 void WebHitTestResult::reset() | 132 void WebHitTestResult::reset() |
| 101 { | 133 { |
| 102 m_private.reset(0); | 134 m_private.reset(); |
| 103 } | 135 } |
| 104 | 136 |
| 105 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |