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

Side by Side Diff: Source/core/html/shadow/ClearButtonElement.cpp

Issue 594093002: Fix for mouse capture and release on ClearButtonElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 PassRefPtrWillBeRawPtr<ClearButtonElement> ClearButtonElement::create(Document& document, ClearButtonOwner& clearButtonOwner) 46 PassRefPtrWillBeRawPtr<ClearButtonElement> ClearButtonElement::create(Document& document, ClearButtonOwner& clearButtonOwner)
47 { 47 {
48 RefPtrWillBeRawPtr<ClearButtonElement> element = adoptRefWillBeNoop(new Clea rButtonElement(document, clearButtonOwner)); 48 RefPtrWillBeRawPtr<ClearButtonElement> element = adoptRefWillBeNoop(new Clea rButtonElement(document, 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) {
57 if (LocalFrame* frame = document().frame())
58 frame->eventHandler().setCapturingMouseEventsNode(nullptr);
59 }
60 HTMLDivElement::detach(context); 56 HTMLDivElement::detach(context);
61 } 57 }
62 58
63 void ClearButtonElement::releaseCapture() 59 void ClearButtonElement::releaseCapture()
64 { 60 {
65 if (!m_capturing) 61 if (!m_capturing)
66 return; 62 return;
67 63 m_capturing = false;
68 if (LocalFrame* frame = document().frame()) {
69 frame->eventHandler().setCapturingMouseEventsNode(nullptr);
70 m_capturing = false;
71 }
72 } 64 }
73 65
74 void ClearButtonElement::defaultEventHandler(Event* event) 66 void ClearButtonElement::defaultEventHandler(Event* event)
75 { 67 {
76 if (!m_clearButtonOwner) { 68 if (!m_clearButtonOwner) {
77 if (!event->defaultHandled()) 69 if (!event->defaultHandled())
78 HTMLDivElement::defaultEventHandler(event); 70 HTMLDivElement::defaultEventHandler(event);
79 return; 71 return;
80 } 72 }
81 73
82 if (!m_clearButtonOwner->shouldClearButtonRespondToMouseEvents()) { 74 if (!m_clearButtonOwner->shouldClearButtonRespondToMouseEvents()) {
83 if (!event->defaultHandled()) 75 if (!event->defaultHandled())
84 HTMLDivElement::defaultEventHandler(event); 76 HTMLDivElement::defaultEventHandler(event);
85 return; 77 return;
86 } 78 }
87 79
88 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t oMouseEvent(event)->button() == LeftButton) { 80 if (event->type() == EventTypeNames::click) {
89 if (renderer() && renderer()->visibleToHitTesting()) {
Habib Virji 2014/10/16 08:39:53 Should you not still take visibileToHitTesting int
Paritosh Kumar 2014/10/18 05:46:03 Thanks. Done.
90 if (LocalFrame* frame = document().frame()) {
91 frame->eventHandler().setCapturingMouseEventsNode(this);
92 m_capturing = true;
93 }
94 }
95 m_clearButtonOwner->focusAndSelectClearButtonOwner(); 81 m_clearButtonOwner->focusAndSelectClearButtonOwner();
96 event->setDefaultHandled(); 82 event->setDefaultHandled();
97 } 83 if (hovered()) {
98 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM ouseEvent(event)->button() == LeftButton) { 84 m_capturing = true;
Habib Virji 2014/10/16 08:39:53 This looks bit unclear. You are changing m_capturi
99 if (m_capturing) { 85 m_clearButtonOwner->clearValue();
100 if (LocalFrame* frame = document().frame()) { 86 event->setDefaultHandled();
101 frame->eventHandler().setCapturingMouseEventsNode(nullptr);
102 m_capturing = false;
103 }
104 if (hovered()) {
105 m_clearButtonOwner->clearValue();
106 event->setDefaultHandled();
107 }
108 } 87 }
109 } 88 }
110 89
111 if (!event->defaultHandled()) 90 if (!event->defaultHandled())
112 HTMLDivElement::defaultEventHandler(event); 91 HTMLDivElement::defaultEventHandler(event);
113 } 92 }
114 93
115 bool ClearButtonElement::isClearButtonElement() const 94 bool ClearButtonElement::isClearButtonElement() const
116 { 95 {
117 return true; 96 return true;
118 } 97 }
119 98
120 void ClearButtonElement::trace(Visitor* visitor) 99 void ClearButtonElement::trace(Visitor* visitor)
121 { 100 {
122 visitor->trace(m_clearButtonOwner); 101 visitor->trace(m_clearButtonOwner);
123 HTMLDivElement::trace(visitor); 102 HTMLDivElement::trace(visitor);
124 } 103 }
125 104
126 } 105 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/date-multiple-fields/date-clearButton-click-and-preventDefault-then-mouseCapture_status-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698