/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// // Eric Vaughan // Netscape Communications // // See documentation in associated header file //
// If a web page calls event.preventDefault() we still want to // scroll when scroll arrow is clicked. See bug 511075. if (!mContent->IsInNativeAnonymousSubtree() &&
nsEventStatus_eConsumeNoDefault == *aEventStatus) { return NS_OK;
}
switch (aEvent->mMessage) { case eMouseDown:
mCursorOnThis = true; // if we didn't handle the press ourselves, pass it on to the superclass if (HandleButtonPress(aPresContext, aEvent, aEventStatus)) { return NS_OK;
} break; case eMouseUp:
HandleRelease(aPresContext, aEvent, aEventStatus); break; case eMouseOut:
mCursorOnThis = false; break; case eMouseMove: {
nsPoint cursor = nsLayoutUtils::GetEventCoordinatesRelativeTo(
aEvent, RelativeTo{this});
nsRect frameRect(nsPoint(0, 0), GetSize());
mCursorOnThis = frameRect.Contains(cursor); break;
} default: break;
}
// Get the button action metric from the pres. shell.
int32_t pressedButtonAction; if (NS_FAILED(LookAndFeel::GetInt(tmpAction, &pressedButtonAction))) { returnfalse;
}
// get the scrollbar control
nsIFrame* scrollbar;
GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
if (scrollbar == nullptr) { returnfalse;
}
static dom::Element::AttrValuesArray strings[] = {
nsGkAtoms::increment, nsGkAtoms::decrement, nullptr};
int32_t index = mContent->AsElement()->FindAttrValueIn(
kNameSpaceID_None, nsGkAtoms::type, strings, eCaseMatters);
int32_t direction; if (index == 0) {
direction = 1;
} elseif (index == 1) {
direction = -1;
} else { returnfalse;
}
if (nsScrollbarFrame* sb = do_QueryFrame(scrollbar)) {
nsIScrollbarMediator* m = sb->GetScrollbarMediator(); switch (pressedButtonAction) { case 0:
sb->SetIncrementToLine(direction); if (m) {
m->ScrollByLine(sb, direction, ScrollSnapFlags::IntendedDirection);
} break; case 1:
sb->SetIncrementToPage(direction); if (m) {
m->ScrollByPage(sb, direction,
ScrollSnapFlags::IntendedDirection |
ScrollSnapFlags::IntendedEndPosition);
} break; case 2:
sb->SetIncrementToWhole(direction); if (m) {
m->ScrollByWhole(sb, direction, ScrollSnapFlags::IntendedEndPosition);
} break; case 3: default: // We were told to ignore this click, or someone assigned a non-standard // value to the button's action. returnfalse;
} if (!weakFrame.IsAlive()) { returnfalse;
}
if (!m) {
sb->MoveToNewPosition(nsScrollbarFrame::ImplementsScrollByUnit::No); if (!weakFrame.IsAlive()) { returnfalse;
}
}
} if (repeat) {
StartRepeat();
} returntrue;
}
if (start) { // get the content node
nsIContent* child = start->GetContent();
if (child && child->IsXULElement(toFind)) {
result = start; return NS_OK;
}
}
}
result = nullptr; return NS_OK;
}
void nsScrollbarButtonFrame::Destroy(DestroyContext& aContext) { // Ensure our repeat service isn't going... it's possible that a scrollbar can // disappear out from under you while you're in the process of scrolling.
StopRepeat();
SimpleXULLeafFrame::Destroy(aContext);
}
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.