Move codes to handle page repainting from chrome to content