Timing based on upper or lower part of sun/moon
It is the first one, i.e. as soon as the heavenly body can be first seen. Here a definition from http://www.ga.gov.au/scientific-topics/astronomical/astronomical-definitions

Sunrise is defined as the instant in the morning under ideal meteorological conditions, with standard refraction of the Sun's rays, when the upper edge of the sun's disk is coincident with an ideal horizon.