Commit 363181d9 authored by dglazkov@chromium.org's avatar dglazkov@chromium.org

2010-12-13 Dimitri Glazkov <dglazkov@chromium.org>

        Reviewed by David Levin.

        Move SliderThumbElement into its own file.
        https://bugs.webkit.org/show_bug.cgi?id=50973

        No change in behavior, so no tests.

        * Android.mk: Added SliderThumbElement.
        * CMakeLists.txt: Ditto.
        * WebCore.gyp/WebCore.gyp: Ditto.
        * WebCore.gypi: Ditto.
        * WebCore.pro: Ditto.
        * WebCore.vcproj/WebCore.vcproj: Ditto.
        * WebCore.xcodeproj/project.pbxproj: Ditto,
        * html/shadow/SliderThumbElement.cpp: Added.
        * html/shadow/SliderThumbElement.h: Added.
        * rendering/RenderSlider.cpp: Removed code that was moved into
            SliderThumbElement.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 265c44fb
......@@ -345,6 +345,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
html/parser/TextDocumentParser.cpp \
html/parser/TextViewSourceParser.cpp \
\
html/shadow/SliderThumbElement.cpp \
\
loader/cache/CachedCSSStyleSheet.cpp \
loader/cache/CachedFont.cpp \
loader/cache/CachedImage.cpp \
......
......@@ -18,6 +18,7 @@ SET(WebCore_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/html"
"${WEBCORE_DIR}/html/canvas"
"${WEBCORE_DIR}/html/parser"
"${WEBCORE_DIR}/html/shadow"
"${WEBCORE_DIR}/inspector"
"${WEBCORE_DIR}/loader"
"${WEBCORE_DIR}/loader/appcache"
......@@ -1142,6 +1143,8 @@ SET(WebCore_SOURCES
html/parser/TextDocumentParser.cpp
html/parser/TextViewSourceParser.cpp
html/shadow/SliderThumbElement.cpp
inspector/ConsoleMessage.cpp
inspector/InjectedScript.cpp
inspector/InjectedScriptHost.cpp
......
2010-12-13 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by David Levin.
Move SliderThumbElement into its own file.
https://bugs.webkit.org/show_bug.cgi?id=50973
No change in behavior, so no tests.
* Android.mk: Added SliderThumbElement.
* CMakeLists.txt: Ditto.
* WebCore.gyp/WebCore.gyp: Ditto.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto,
* html/shadow/SliderThumbElement.cpp: Added.
* html/shadow/SliderThumbElement.h: Added.
* rendering/RenderSlider.cpp: Removed code that was moved into
SliderThumbElement.
2010-12-13 Alexey Proskuryakov <ap@apple.com>
Reviewed by Adam Barth.
......
......@@ -24,6 +24,7 @@ webcore_cppflags += \
-I$(srcdir)/WebCore/html \
-I$(srcdir)/WebCore/html/canvas \
-I$(srcdir)/WebCore/html/parser \
-I$(srcdir)/WebCore/html/shadow \
-I$(srcdir)/WebCore/inspector \
-I$(srcdir)/WebCore/loader \
-I$(srcdir)/WebCore/loader/appcache \
......
......@@ -133,6 +133,7 @@
'../html',
'../html/canvas',
'../html/parser',
'../html/shadow',
'../inspector',
'../loader',
'../loader/appcache',
......
......@@ -1989,6 +1989,8 @@
'html/parser/TextDocumentParser.h',
'html/parser/TextViewSourceParser.cpp',
'html/parser/TextViewSourceParser.h',
'html/shadow/SliderThumbElement.cpp',
'html/shadow/SliderThumbElement.h',
'inspector/ConsoleMessage.cpp',
'inspector/ConsoleMessage.h',
'inspector/InjectedScript.cpp',
......
......@@ -227,6 +227,7 @@ WEBCORE_INCLUDEPATH = \
$$PWD/html \
$$PWD/html/canvas \
$$PWD/html/parser \
$$PWD/html/shadow \
$$PWD/inspector \
$$PWD/loader \
$$PWD/loader/appcache \
......@@ -1020,6 +1021,7 @@ SOURCES += \
html/parser/HTMLViewSourceParser.cpp \
html/parser/TextDocumentParser.cpp \
html/parser/TextViewSourceParser.cpp \
html/shadow/SliderThumbElement.cpp \
inspector/ConsoleMessage.cpp \
inspector/InjectedScript.cpp \
inspector/InjectedScriptHost.cpp \
......
......@@ -55321,6 +55321,18 @@
>
</File>
</Filter>
<Filter
Name="shadow"
>
<File
RelativePath="..\html\shadow\SliderThumbElement.cpp"
>
</File>
<File
RelativePath="..\html\shadow\SliderThumbElement.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="bindings"
......@@ -7,7 +7,7 @@
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..&quot;;&quot;$(ProjectDir)..\accessibility&quot;;&quot;$(ProjectDir)..\accessibility\win&quot;;&quot;$(ProjectDir)..\bridge&quot;;&quot;$(ProjectDir)..\bridge\c&quot;;&quot;$(ProjectDir)..\bridge\jsc&quot;;&quot;$(ProjectDir)..\css&quot;;&quot;$(ProjectDir)..\editing&quot;;&quot;$(ProjectDir)..\fileapi&quot;;&quot;$(ProjectDir)..\rendering&quot;;&quot;$(ProjectDir)..\rendering\style&quot;;&quot;$(ProjectDir)..\rendering\svg&quot;;&quot;$(ProjectDir)..\bindings&quot;;&quot;$(ProjectDir)..\bindings\generic&quot;;&quot;$(ProjectDir)..\bindings\js&quot;;&quot;$(ProjectDir)..\bindings\js\specialization&quot;;&quot;$(ProjectDir)..\dom&quot;;&quot;$(ProjectDir)..\dom\default&quot;;&quot;$(ProjectDir)..\history&quot;;&quot;$(ProjectDir)..\html&quot;;&quot;$(ProjectDir)..\html\canvas&quot;;&quot;$(ProjectDir)..\html\parser&quot;;&quot;$(ProjectDir)..\inspector&quot;;&quot;$(ProjectDir)..\loader&quot;;&quot;$(ProjectDir)..\loader\appcache&quot;;&quot;$(ProjectDir)..\loader\archive&quot;;&quot;$(ProjectDir)..\loader\archive\cf&quot;;&quot;$(ProjectDir)..\loader\cache&quot;;&quot;$(ProjectDir)..\loader\icon&quot;;&quot;$(ProjectDir)..\mathml&quot;;&quot;$(ProjectDir)..\notifications&quot;;&quot;$(ProjectDir)..\page&quot;;&quot;$(ProjectDir)..\page\animation&quot;;&quot;$(ProjectDir)..\page\win&quot;;&quot;$(ProjectDir)..\platform&quot;;&quot;$(ProjectDir)..\platform\animation&quot;;&quot;$(ProjectDir)..\platform\mock&quot;;&quot;$(ProjectDir)..\platform\sql&quot;;&quot;$(ProjectDir)..\platform\win&quot;;&quot;$(ProjectDir)..\platform\network&quot;;&quot;$(ProjectDir)..\platform\network\win&quot;;&quot;$(ProjectDir)..\platform\cf&quot;;&quot;$(ProjectDir)..\platform\graphics&quot;;&quot;$(ProjectDir)..\platform\graphics\filters&quot;;&quot;$(ProjectDir)..\platform\graphics\opentype&quot;;&quot;$(ProjectDir)..\platform\graphics\transforms&quot;;&quot;$(ProjectDir)..\platform\text&quot;;&quot;$(ProjectDir)..\platform\text\transcoder&quot;;&quot;$(ProjectDir)..\platform\graphics\win&quot;;&quot;$(ProjectDir)..\xml&quot;;&quot;$(WebKitOutputDir)\obj\WebCore\DerivedSources&quot;;&quot;$(ProjectDir)..\plugins&quot;;&quot;$(ProjectDir)..\plugins\win&quot;;&quot;$(ProjectDir)..\svg\animation&quot;;&quot;$(ProjectDir)..\svg\graphics&quot;;&quot;$(ProjectDir)..\svg\properties&quot;;&quot;$(ProjectDir)..\svg\graphics\filters&quot;;&quot;$(ProjectDir)..\svg&quot;;&quot;$(ProjectDir)..\wml&quot;;&quot;$(ProjectDir)..\storage&quot;;&quot;$(ProjectDir)..\websockets&quot;;&quot;$(ProjectDir)..\workers&quot;;&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\include\private&quot;;&quot;$(WebKitOutputDir)\include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\include\private\JavaScriptCore&quot;;&quot;$(ProjectDir)..\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\private\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;;&quot;$(WebKitLibrariesDir)\include\sqlite&quot;;&quot;$(WebKitLibrariesDir)\include\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\zlib&quot;"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..&quot;;&quot;$(ProjectDir)..\accessibility&quot;;&quot;$(ProjectDir)..\accessibility\win&quot;;&quot;$(ProjectDir)..\bridge&quot;;&quot;$(ProjectDir)..\bridge\c&quot;;&quot;$(ProjectDir)..\bridge\jsc&quot;;&quot;$(ProjectDir)..\css&quot;;&quot;$(ProjectDir)..\editing&quot;;&quot;$(ProjectDir)..\fileapi&quot;;&quot;$(ProjectDir)..\rendering&quot;;&quot;$(ProjectDir)..\rendering\style&quot;;&quot;$(ProjectDir)..\rendering\svg&quot;;&quot;$(ProjectDir)..\bindings&quot;;&quot;$(ProjectDir)..\bindings\generic&quot;;&quot;$(ProjectDir)..\bindings\js&quot;;&quot;$(ProjectDir)..\bindings\js\specialization&quot;;&quot;$(ProjectDir)..\dom&quot;;&quot;$(ProjectDir)..\dom\default&quot;;&quot;$(ProjectDir)..\history&quot;;&quot;$(ProjectDir)..\html&quot;;&quot;$(ProjectDir)..\html\canvas&quot;;&quot;$(ProjectDir)..\html\parser&quot;;&quot;$(ProjectDir)..\html\shadow&quot;;&quot;$(ProjectDir)..\inspector&quot;;&quot;$(ProjectDir)..\loader&quot;;&quot;$(ProjectDir)..\loader\appcache&quot;;&quot;$(ProjectDir)..\loader\archive&quot;;&quot;$(ProjectDir)..\loader\archive\cf&quot;;&quot;$(ProjectDir)..\loader\cache&quot;;&quot;$(ProjectDir)..\loader\icon&quot;;&quot;$(ProjectDir)..\mathml&quot;;&quot;$(ProjectDir)..\notifications&quot;;&quot;$(ProjectDir)..\page&quot;;&quot;$(ProjectDir)..\page\animation&quot;;&quot;$(ProjectDir)..\page\win&quot;;&quot;$(ProjectDir)..\platform&quot;;&quot;$(ProjectDir)..\platform\animation&quot;;&quot;$(ProjectDir)..\platform\mock&quot;;&quot;$(ProjectDir)..\platform\sql&quot;;&quot;$(ProjectDir)..\platform\win&quot;;&quot;$(ProjectDir)..\platform\network&quot;;&quot;$(ProjectDir)..\platform\network\win&quot;;&quot;$(ProjectDir)..\platform\cf&quot;;&quot;$(ProjectDir)..\platform\graphics&quot;;&quot;$(ProjectDir)..\platform\graphics\filters&quot;;&quot;$(ProjectDir)..\platform\graphics\opentype&quot;;&quot;$(ProjectDir)..\platform\graphics\transforms&quot;;&quot;$(ProjectDir)..\platform\text&quot;;&quot;$(ProjectDir)..\platform\text\transcoder&quot;;&quot;$(ProjectDir)..\platform\graphics\win&quot;;&quot;$(ProjectDir)..\xml&quot;;&quot;$(WebKitOutputDir)\obj\WebCore\DerivedSources&quot;;&quot;$(ProjectDir)..\plugins&quot;;&quot;$(ProjectDir)..\plugins\win&quot;;&quot;$(ProjectDir)..\svg\animation&quot;;&quot;$(ProjectDir)..\svg\graphics&quot;;&quot;$(ProjectDir)..\svg\properties&quot;;&quot;$(ProjectDir)..\svg\graphics\filters&quot;;&quot;$(ProjectDir)..\svg&quot;;&quot;$(ProjectDir)..\wml&quot;;&quot;$(ProjectDir)..\storage&quot;;&quot;$(ProjectDir)..\websockets&quot;;&quot;$(ProjectDir)..\workers&quot;;&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\include\private&quot;;&quot;$(WebKitOutputDir)\include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\include\private\JavaScriptCore&quot;;&quot;$(ProjectDir)..\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\private\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;;&quot;$(WebKitLibrariesDir)\include\sqlite&quot;;&quot;$(WebKitLibrariesDir)\include\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\zlib&quot;"
PreprocessorDefinitions="__WIN32__;DISABLE_3D_RENDERING;WEBCORE_CONTEXT_MENUS"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebCorePrefix.h"
......
......@@ -919,6 +919,8 @@
4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
4138D3351244054800323D33 /* EventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138D3331244054800323D33 /* EventContext.h */; };
4138D3361244054800323D33 /* EventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4138D3341244054800323D33 /* EventContext.cpp */; };
4150F9F112B6E0E70008C860 /* SliderThumbElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */; };
4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */; };
4162A450101145AE00DFF3ED /* DedicatedWorkerContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A44D101145AE00DFF3ED /* DedicatedWorkerContext.cpp */; };
4162A451101145AE00DFF3ED /* DedicatedWorkerContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4162A44E101145AE00DFF3ED /* DedicatedWorkerContext.h */; };
4162A454101145E300DFF3ED /* JSDedicatedWorkerContextCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A453101145E300DFF3ED /* JSDedicatedWorkerContextCustom.cpp */; };
......@@ -7220,6 +7222,8 @@
4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
4138D3331244054800323D33 /* EventContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventContext.h; sourceTree = "<group>"; };
4138D3341244054800323D33 /* EventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventContext.cpp; sourceTree = "<group>"; };
4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderThumbElement.h; sourceTree = "<group>"; };
4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SliderThumbElement.cpp; sourceTree = "<group>"; };
4162A44D101145AE00DFF3ED /* DedicatedWorkerContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DedicatedWorkerContext.cpp; path = workers/DedicatedWorkerContext.cpp; sourceTree = "<group>"; };
4162A44E101145AE00DFF3ED /* DedicatedWorkerContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DedicatedWorkerContext.h; path = workers/DedicatedWorkerContext.h; sourceTree = "<group>"; };
4162A44F101145AE00DFF3ED /* DedicatedWorkerContext.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DedicatedWorkerContext.idl; path = workers/DedicatedWorkerContext.idl; sourceTree = "<group>"; };
......@@ -13022,6 +13026,15 @@
name = Notifications;
sourceTree = "<group>";
};
4150F9ED12B6E0990008C860 /* shadow */ = {
isa = PBXGroup;
children = (
4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */,
4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */,
);
path = shadow;
sourceTree = "<group>";
};
449195900FBE175B00D9F824 /* Exports */ = {
isa = PBXGroup;
children = (
......@@ -15181,6 +15194,7 @@
children = (
49484FAE102CF01E00187DD3 /* canvas */,
97C1F5511228558800EDE616 /* parser */,
4150F9ED12B6E0990008C860 /* shadow */,
B0149E7911A4B21500196A7B /* AsyncImageResizer.cpp */,
B0149E7A11A4B21500196A7B /* AsyncImageResizer.h */,
379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */,
......@@ -21568,6 +21582,7 @@
B2C3DA650D006CD600EF6F26 /* SimpleFontData.h in Headers */,
51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */,
49E911CD0EF86D47009D0CAF /* SkewTransformOperation.h in Headers */,
4150F9F112B6E0E70008C860 /* SliderThumbElement.h in Headers */,
4B6FA6F40C39E48C00087011 /* SmartReplace.h in Headers */,
E4AFD00C0DAF335400F5F55C /* SMILTime.h in Headers */,
E4AFD00E0DAF335500F5F55C /* SMILTimeContainer.h in Headers */,
......@@ -24339,6 +24354,7 @@
B2AFFC7F0D00A5C10030074D /* SimpleFontDataMac.mm in Sources */,
51327D6111A33A2B004F9D65 /* SinkDocument.cpp in Sources */,
49E911CC0EF86D47009D0CAF /* SkewTransformOperation.cpp in Sources */,
4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */,
4B6FA6F50C39E48C00087011 /* SmartReplace.cpp in Sources */,
4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */,
E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */,
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "SliderThumbElement.h"
#include "Event.h"
#include "Frame.h"
#include "MouseEvent.h"
#include "RenderSlider.h"
namespace WebCore {
void SliderThumbElement::defaultEventHandler(Event* event)
{
if (!event->isMouseEvent()) {
ShadowBlockElement::defaultEventHandler(event);
return;
}
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
bool isLeftButton = mouseEvent->button() == LeftButton;
const AtomicString& eventType = event->type();
if (eventType == eventNames().mousedownEvent && isLeftButton) {
if (document()->frame() && renderer()) {
RenderSlider* slider = toRenderSlider(renderer()->parent());
if (slider) {
if (slider->mouseEventIsInThumb(mouseEvent)) {
// We selected the thumb, we want the cursor to always stay at
// the same position relative to the thumb.
m_offsetToThumb = slider->mouseEventOffsetToThumb(mouseEvent);
} else {
// We are outside the thumb, move the thumb to the point were
// we clicked. We'll be exactly at the center of the thumb.
m_offsetToThumb.setX(0);
m_offsetToThumb.setY(0);
}
m_inDragMode = true;
document()->frame()->eventHandler()->setCapturingMouseEventsNode(shadowHost());
event->setDefaultHandled();
return;
}
}
} else if (eventType == eventNames().mouseupEvent && isLeftButton) {
if (m_inDragMode) {
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(0);
m_inDragMode = false;
event->setDefaultHandled();
return;
}
} else if (eventType == eventNames().mousemoveEvent) {
if (m_inDragMode && renderer() && renderer()->parent()) {
RenderSlider* slider = toRenderSlider(renderer()->parent());
if (slider) {
FloatPoint curPoint = slider->absoluteToLocal(mouseEvent->absoluteLocation(), false, true);
IntPoint eventOffset(curPoint.x() + m_offsetToThumb.x(), curPoint.y() + m_offsetToThumb.y());
slider->setValueForPosition(slider->positionForOffset(eventOffset));
event->setDefaultHandled();
return;
}
}
}
ShadowBlockElement::defaultEventHandler(event);
}
void SliderThumbElement::detach()
{
if (m_inDragMode) {
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(0);
}
ShadowBlockElement::detach();
}
}
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SliderThumbElement_h
#define SliderThumbElement_h
#include "FloatPoint.h"
#include "ShadowElement.h"
#include <wtf/Forward.h>
namespace WebCore {
class HTMLElement;
class Event;
class FloatPoint;
class SliderThumbElement : public ShadowBlockElement {
public:
static PassRefPtr<SliderThumbElement> create(HTMLElement* shadowParent);
bool inDragMode() const { return m_inDragMode; }
virtual void defaultEventHandler(Event*);
virtual void detach();
private:
SliderThumbElement(HTMLElement* shadowParent);
FloatPoint m_offsetToThumb;
bool m_inDragMode;
};
inline SliderThumbElement::SliderThumbElement(HTMLElement* shadowParent)
: ShadowBlockElement(shadowParent)
, m_inDragMode(false)
{
}
inline PassRefPtr<SliderThumbElement> SliderThumbElement::create(HTMLElement* shadowParent)
{
return adoptRef(new SliderThumbElement(shadowParent));
}
}
#endif
......@@ -36,6 +36,7 @@
#include "RenderTheme.h"
#include "RenderView.h"
#include "ShadowElement.h"
#include "SliderThumbElement.h"
#include "StepRange.h"
#include <wtf/MathExtras.h>
......@@ -52,98 +53,6 @@ static double sliderPosition(HTMLInputElement* element)
return range.proportionFromValue(range.valueFromElement(element));
}
class SliderThumbElement : public ShadowBlockElement {
public:
static PassRefPtr<SliderThumbElement> create(HTMLElement* shadowParent);
bool inDragMode() const { return m_inDragMode; }
virtual void defaultEventHandler(Event*);
virtual void detach();
private:
SliderThumbElement(HTMLElement* shadowParent);
FloatPoint m_offsetToThumb;
bool m_inDragMode;
};
inline SliderThumbElement::SliderThumbElement(HTMLElement* shadowParent)
: ShadowBlockElement(shadowParent)
, m_inDragMode(false)
{
}
inline PassRefPtr<SliderThumbElement> SliderThumbElement::create(HTMLElement* shadowParent)
{
return adoptRef(new SliderThumbElement(shadowParent));
}
void SliderThumbElement::defaultEventHandler(Event* event)
{
if (!event->isMouseEvent()) {
ShadowBlockElement::defaultEventHandler(event);
return;
}
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
bool isLeftButton = mouseEvent->button() == LeftButton;
const AtomicString& eventType = event->type();
if (eventType == eventNames().mousedownEvent && isLeftButton) {
if (document()->frame() && renderer()) {
RenderSlider* slider = toRenderSlider(renderer()->parent());
if (slider) {
if (slider->mouseEventIsInThumb(mouseEvent)) {
// We selected the thumb, we want the cursor to always stay at
// the same position relative to the thumb.
m_offsetToThumb = slider->mouseEventOffsetToThumb(mouseEvent);
} else {
// We are outside the thumb, move the thumb to the point were
// we clicked. We'll be exactly at the center of the thumb.
m_offsetToThumb.setX(0);
m_offsetToThumb.setY(0);
}
m_inDragMode = true;
document()->frame()->eventHandler()->setCapturingMouseEventsNode(shadowHost());
event->setDefaultHandled();
return;
}
}
} else if (eventType == eventNames().mouseupEvent && isLeftButton) {
if (m_inDragMode) {
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(0);
m_inDragMode = false;
event->setDefaultHandled();
return;
}
} else if (eventType == eventNames().mousemoveEvent) {
if (m_inDragMode && renderer() && renderer()->parent()) {
RenderSlider* slider = toRenderSlider(renderer()->parent());
if (slider) {
FloatPoint curPoint = slider->absoluteToLocal(mouseEvent->absoluteLocation(), false, true);
IntPoint eventOffset(curPoint.x() + m_offsetToThumb.x(), curPoint.y() + m_offsetToThumb.y());
slider->setValueForPosition(slider->positionForOffset(eventOffset));
event->setDefaultHandled();
return;
}
}
}
ShadowBlockElement::defaultEventHandler(event);
}
void SliderThumbElement::detach()
{
if (m_inDragMode) {
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(0);
}
ShadowBlockElement::detach();
}
RenderSlider::RenderSlider(HTMLInputElement* element)
: RenderBlock(element)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment