OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 * 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 RefPtr<ClearButtonElement> element = adoptRef(new ClearButtonElement(documen
t, clearButtonOwner)); | 48 RefPtr<ClearButtonElement> element = adoptRef(new ClearButtonElement(documen
t, clearButtonOwner)); |
49 element->setShadowPseudoId(AtomicString("-webkit-clear-button", AtomicString
::ConstructFromLiteral)); | 49 element->setShadowPseudoId(AtomicString("-webkit-clear-button", AtomicString
::ConstructFromLiteral)); |
50 element->setAttribute(idAttr, ShadowElementNames::clearButton()); | 50 element->setAttribute(idAttr, ShadowElementNames::clearButton()); |
51 return element.release(); | 51 return element.release(); |
52 } | 52 } |
53 | 53 |
54 void ClearButtonElement::detach(const AttachContext& context) | 54 void ClearButtonElement::detach(const AttachContext& context) |
55 { | 55 { |
56 if (m_capturing) { | 56 if (m_capturing) { |
57 if (Frame* frame = document().frame()) | 57 if (Frame* frame = document().frame()) |
58 frame->eventHandler().setCapturingMouseEventsNode(0); | 58 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
59 } | 59 } |
60 HTMLDivElement::detach(context); | 60 HTMLDivElement::detach(context); |
61 } | 61 } |
62 | 62 |
63 void ClearButtonElement::releaseCapture() | 63 void ClearButtonElement::releaseCapture() |
64 { | 64 { |
65 if (!m_capturing) | 65 if (!m_capturing) |
66 return; | 66 return; |
67 | 67 |
68 if (Frame* frame = document().frame()) { | 68 if (Frame* frame = document().frame()) { |
69 frame->eventHandler().setCapturingMouseEventsNode(0); | 69 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
70 m_capturing = false; | 70 m_capturing = false; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void ClearButtonElement::defaultEventHandler(Event* event) | 74 void ClearButtonElement::defaultEventHandler(Event* event) |
75 { | 75 { |
76 if (!m_clearButtonOwner) { | 76 if (!m_clearButtonOwner) { |
77 if (!event->defaultHandled()) | 77 if (!event->defaultHandled()) |
78 HTMLDivElement::defaultEventHandler(event); | 78 HTMLDivElement::defaultEventHandler(event); |
79 return; | 79 return; |
(...skipping 11 matching lines...) Expand all Loading... |
91 frame->eventHandler().setCapturingMouseEventsNode(this); | 91 frame->eventHandler().setCapturingMouseEventsNode(this); |
92 m_capturing = true; | 92 m_capturing = true; |
93 } | 93 } |
94 } | 94 } |
95 m_clearButtonOwner->focusAndSelectClearButtonOwner(); | 95 m_clearButtonOwner->focusAndSelectClearButtonOwner(); |
96 event->setDefaultHandled(); | 96 event->setDefaultHandled(); |
97 } | 97 } |
98 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM
ouseEvent(event)->button() == LeftButton) { | 98 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM
ouseEvent(event)->button() == LeftButton) { |
99 if (m_capturing) { | 99 if (m_capturing) { |
100 if (Frame* frame = document().frame()) { | 100 if (Frame* frame = document().frame()) { |
101 frame->eventHandler().setCapturingMouseEventsNode(0); | 101 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
102 m_capturing = false; | 102 m_capturing = false; |
103 } | 103 } |
104 if (hovered()) { | 104 if (hovered()) { |
105 m_clearButtonOwner->clearValue(); | 105 m_clearButtonOwner->clearValue(); |
106 event->setDefaultHandled(); | 106 event->setDefaultHandled(); |
107 } | 107 } |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 if (!event->defaultHandled()) | 111 if (!event->defaultHandled()) |
112 HTMLDivElement::defaultEventHandler(event); | 112 HTMLDivElement::defaultEventHandler(event); |
113 } | 113 } |
114 | 114 |
115 bool ClearButtonElement::isClearButtonElement() const | 115 bool ClearButtonElement::isClearButtonElement() const |
116 { | 116 { |
117 return true; | 117 return true; |
118 } | 118 } |
119 | 119 |
120 } | 120 } |
OLD | NEW |